data.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Package data is an interface between DHCP macAndIPXE implementations and the DHCP server.
  2. package data
  3. import (
  4. "github.com/insomniacslk/dhcp/dhcpv4"
  5. "net"
  6. "net/netip"
  7. )
  8. // Packet holds the data that is passed to a DHCP handler.
  9. type Packet struct {
  10. // Peer is the address of the client that sent the DHCP message.
  11. Peer net.Addr
  12. // Pkt is the DHCP message.
  13. Pkt *dhcpv4.DHCPv4
  14. // Md is the metadata that was passed to the DHCP server.
  15. Md *Metadata
  16. }
  17. // Metadata holds metadata about the DHCP packet that was received.
  18. type Metadata struct {
  19. // IfName is the name of the interface that the DHCP message was received on.
  20. IfName string
  21. // IfIndex is the index of the interface that the DHCP message was received on.
  22. IfIndex int
  23. }
  24. // DHCP holds the DHCP headers and options to be set in a DHCP handler response.
  25. // This is the API between a DHCP handler and a macAndIPXE.
  26. type DHCP struct {
  27. MACAddress net.HardwareAddr // chaddr DHCP header.
  28. IPAddress netip.Addr // yiaddr DHCP header.
  29. SubnetMask net.IPMask // DHCP option 1.
  30. DefaultGateway netip.Addr // DHCP option 3.
  31. NameServers []net.IP // DHCP option 6.
  32. DomainName string // DHCP option 15.
  33. BroadcastAddress netip.Addr // DHCP option 28.
  34. NTPServers []net.IP // DHCP option 42.
  35. VLANID string // DHCP option 43.116.
  36. LeaseTime uint32 // DHCP option 51.
  37. DomainSearch []string // DHCP option 119.
  38. ServerIP net.IP // DHCP option 54.
  39. }