1
0
Fork 0

Migrate existing code

This commit is contained in:
Jöran Malek 2025-01-29 23:53:57 +01:00
parent 384ff4a6f3
commit 9b49f880a2
30 changed files with 1789 additions and 5 deletions

View 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;
}
}