WIP
parent
a002c4b0a1
commit
50899f7f3c
|
@ -1,8 +1,11 @@
|
|||
using System;
|
||||
using ln.types.net;
|
||||
using ln.types.odb.attributes;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
namespace ln.dhcp
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum DHCPLeaseState
|
||||
{
|
||||
RELEASED,
|
||||
|
|
|
@ -288,6 +288,7 @@ namespace ln.dhcp
|
|||
lease.ValidThrough = validThrough;
|
||||
}
|
||||
lease.LeaseState = DHCPLeaseState.BOUND;
|
||||
lease.LastUpdate = DateTimeOffset.Now;
|
||||
Commit(lease);
|
||||
logLease.Log(LogLevel.INFO, "[ACK ] {0} {1} {2}", lease.ClientMAC, lease.ClientIP, lease.ClientName);
|
||||
|
||||
|
@ -328,10 +329,11 @@ namespace ln.dhcp
|
|||
IPv4 test = start;
|
||||
while (leasesAPI.FindLease(test) != null)
|
||||
{
|
||||
test = ippool.NextIP;
|
||||
test = ippool.GetNextIP();
|
||||
if (test.Equals(start))
|
||||
return null;
|
||||
}
|
||||
Commit(ippool);
|
||||
return test;
|
||||
}
|
||||
}
|
||||
|
|
16
IPPool.cs
16
IPPool.cs
|
@ -13,20 +13,24 @@ namespace ln.dhcp
|
|||
public IPv4 LastIP { get; set; }
|
||||
|
||||
IPv4 nextIP;
|
||||
public IPv4 NextIP
|
||||
public IPv4 NextIP
|
||||
{
|
||||
get
|
||||
get => nextIP;
|
||||
set => nextIP = value;
|
||||
}
|
||||
|
||||
public TimeSpan DefaultLeaseTime { get; set; }
|
||||
|
||||
public IPv4 GetNextIP()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
IPv4 next = nextIP++;
|
||||
if (nextIP > LastIP)
|
||||
nextIP = FirstIP;
|
||||
return next;
|
||||
}
|
||||
set => nextIP = value;
|
||||
}
|
||||
|
||||
public TimeSpan DefaultLeaseTime { get; set; }
|
||||
|
||||
private IPPool()
|
||||
{
|
||||
DefaultLeaseTime = TimeSpan.FromHours(1);
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1514,7 +1514,7 @@
|
|||
Converts the <see cref="T:System.Decimal"/> to its JSON string representation.
|
||||
</summary>
|
||||
<param name="value">The value to convert.</param>
|
||||
<returns>A JSON string representation of the <see cref="T:System.SByte"/>.</returns>
|
||||
<returns>A JSON string representation of the <see cref="T:System.Decimal"/>.</returns>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.JsonConvert.ToString(System.Guid)">
|
||||
<summary>
|
||||
|
@ -2162,6 +2162,12 @@
|
|||
</summary>
|
||||
<value>The member serialization.</value>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.JsonObjectAttribute.MissingMemberHandling">
|
||||
<summary>
|
||||
Gets or sets the missing member handling used when deserializing this object.
|
||||
</summary>
|
||||
<value>The missing member handling.</value>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.JsonObjectAttribute.ItemNullValueHandling">
|
||||
<summary>
|
||||
Gets or sets how the object's properties with null values are handled during serialization and deserialization.
|
||||
|
@ -8103,6 +8109,13 @@
|
|||
</summary>
|
||||
<param name="token">The token to read from.</param>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Linq.JTokenReader.#ctor(Newtonsoft.Json.Linq.JToken,System.String)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Newtonsoft.Json.Linq.JTokenReader"/> class.
|
||||
</summary>
|
||||
<param name="token">The token to read from.</param>
|
||||
<param name="initialPath">The initial path of the token. It is prepended to the returned <see cref="P:Newtonsoft.Json.Linq.JTokenReader.Path"/>.</param>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Linq.JTokenReader.Read">
|
||||
<summary>
|
||||
Reads the next JSON token from the underlying <see cref="T:Newtonsoft.Json.Linq.JToken"/>.
|
||||
|
@ -10199,6 +10212,13 @@
|
|||
</summary>
|
||||
<value>The converter.</value>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.Serialization.JsonContract.InternalConverter">
|
||||
<summary>
|
||||
Gets the internally resolved <see cref="T:Newtonsoft.Json.JsonConverter"/> for the contract's type.
|
||||
This converter is used as a fallback converter when no other converter is resolved.
|
||||
Setting <see cref="P:Newtonsoft.Json.Serialization.JsonContract.Converter"/> will always override this converter.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.Serialization.JsonContract.OnDeserializedCallbacks">
|
||||
<summary>
|
||||
Gets or sets all methods called immediately after deserialization of the object.
|
||||
|
@ -10344,6 +10364,12 @@
|
|||
</summary>
|
||||
<value>The member object serialization.</value>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.Serialization.JsonObjectContract.MissingMemberHandling">
|
||||
<summary>
|
||||
Gets or sets the missing member handling used when deserializing this object.
|
||||
</summary>
|
||||
<value>The missing member handling.</value>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.Serialization.JsonObjectContract.ItemRequired">
|
||||
<summary>
|
||||
Gets or sets a value that indicates whether the object's properties are required.
|
||||
|
@ -10510,6 +10536,11 @@
|
|||
</summary>
|
||||
<value>A value indicating whether this <see cref="T:Newtonsoft.Json.Serialization.JsonProperty"/> is required.</value>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.Serialization.JsonProperty.IsRequiredSpecified">
|
||||
<summary>
|
||||
Gets a value indicating whether <see cref="P:Newtonsoft.Json.Serialization.JsonProperty.Required"/> has a value specified.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Newtonsoft.Json.Serialization.JsonProperty.IsReference">
|
||||
<summary>
|
||||
Gets or sets a value indicating whether this property preserves object references.
|
||||
|
@ -10760,6 +10791,26 @@
|
|||
<param name="name">The property name to resolve.</param>
|
||||
<returns>The resolved property name.</returns>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Serialization.NamingStrategy.GetHashCode">
|
||||
<summary>
|
||||
Hash code calculation
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Serialization.NamingStrategy.Equals(System.Object)">
|
||||
<summary>
|
||||
Object equality implementation
|
||||
</summary>
|
||||
<param name="obj"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Newtonsoft.Json.Serialization.NamingStrategy.Equals(Newtonsoft.Json.Serialization.NamingStrategy)">
|
||||
<summary>
|
||||
Compare to another NamingStrategy
|
||||
</summary>
|
||||
<param name="other"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Newtonsoft.Json.Serialization.ObjectConstructor`1">
|
||||
<summary>
|
||||
Represents a method that constructs an object.
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -29,6 +29,9 @@
|
|||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Mono.Posix" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DHCPServer.cs" />
|
||||
|
@ -51,5 +54,8 @@
|
|||
<Name>ln.logging</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1 +1 @@
|
|||
62f8061fbf7e671ceaa150fc217748d6af510370
|
||||
52f74c261979b87de87fda0ff386127bee4e9aa4
|
||||
|
|
|
@ -25,4 +25,3 @@
|
|||
/home/haraldwolff/src/ln.skyspot/ln.dhcp/bin/Debug/sharp.logging.pdb
|
||||
/home/haraldwolff/src/ln.skyspot/ln.dhcp/bin/Debug/Newtonsoft.Json.xml
|
||||
/home/haraldwolff/src/ln.skyspot/ln.dhcp/obj/Debug/ln.dhcp.csproj.CopyComplete
|
||||
/home/haraldwolff/src/ln.skyspot/ln.dhcp/bin/Debug/Newtonsoft.Json.pdb
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net47" />
|
||||
</packages>
|
Loading…
Reference in New Issue