1
0
Fork 0
netddi/Integrations/Kea/KeaDhcp6LeaseHandler.cs

25 lines
596 B
C#
Raw Normal View History

2025-01-29 23:53:57 +01:00
using DotNetDDI.Services.Dhcp;
using nietras.SeparatedValues;
namespace DotNetDDI.Integrations.Kea;
public class KeaDhcp6LeaseHandler : IKeaDhcpLeaseHandler
{
public DhcpLeaseChange? Handle(in SepReader.Row row)
{
if (KeaDhcp6Lease.Parse(row) is not { } lease)
{
return null;
}
DhcpLeaseIdentifier identifier = lease.DUId switch
{
string clientId when !string.IsNullOrWhiteSpace(clientId) => new DhcpLeaseClientIdentifier(clientId),
_ => new DhcpLeaseHWAddrIdentifier(lease.HWAddr)
};
return new(lease.Address, lease.Hostname, identifier, lease.ValidLifetime);
}
}