Migrate existing code
This commit is contained in:
parent
384ff4a6f3
commit
9b49f880a2
30 changed files with 1789 additions and 5 deletions
32
Integrations/Kea/KeaDhcp4LeaseHandler.cs
Normal file
32
Integrations/Kea/KeaDhcp4LeaseHandler.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using DotNetDDI.Services.Dhcp;
|
||||
|
||||
using nietras.SeparatedValues;
|
||||
|
||||
namespace DotNetDDI.Integrations.Kea;
|
||||
|
||||
public class KeaDhcp4LeaseHandler : IKeaDhcpLeaseHandler
|
||||
{
|
||||
public DhcpLeaseChange? Handle(in SepReader.Row row)
|
||||
{
|
||||
if (KeaDhcp4Lease.Parse(row) is not { } lease)
|
||||
{
|
||||
goto exitNull;
|
||||
}
|
||||
|
||||
if (lease.State != 0)
|
||||
{
|
||||
goto exitNull;
|
||||
}
|
||||
|
||||
DhcpLeaseIdentifier identifier = lease.ClientId switch
|
||||
{
|
||||
string clientId when !string.IsNullOrWhiteSpace(clientId) => new DhcpLeaseClientIdentifier(clientId),
|
||||
_ => new DhcpLeaseHWAddrIdentifier(lease.HWAddr)
|
||||
};
|
||||
|
||||
return new(lease.Address, lease.Hostname, identifier, lease.ValidLifetime);
|
||||
|
||||
exitNull:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue