DhcpPacket.cs 1011 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Linq;
  3. using System.Net;
  4. namespace DhcpServer
  5. {
  6. public partial class DhcpPacket
  7. {
  8. public string ClientMacAddressHex => string.Join("-", ClientMacAddress.Select(p => p.ToString("X2")));
  9. internal void LoadClientEntry(DhcpEntry entry)
  10. {
  11. if (entry == null) throw new ArgumentNullException(nameof(entry));
  12. if (entry.IpAddress != null) YourIpAddress = IPAddress.Parse(entry.IpAddress);
  13. if (entry.SubNetMask != null) SubNetMask = IPAddress.Parse(entry.SubNetMask);
  14. if (entry.GateWay != null) Router = IPAddress.Parse(entry.GateWay);
  15. if (entry.DnsServer != null) DnsServer = IPAddress.Parse(entry.DnsServer);
  16. if (entry.TftpServer != null)
  17. {
  18. TftpServer = entry.TftpServer;
  19. NextServerIpAddress = IPAddress.Parse(entry.TftpServer);
  20. }
  21. if (entry.BootFileName != null) BootFileName = entry.BootFileName;
  22. }
  23. }
  24. }