kdhcp/dhcp/options.go

77 lines
2.5 KiB
Go
Raw Normal View History

2023-05-02 23:33:14 +00:00
package dhcp
import (
"fmt"
2023-05-02 23:33:14 +00:00
"io"
)
type OptionTag uint8
2023-05-06 05:21:27 +00:00
func (opt OptionTag) String() string {
s, ok := optionStrings[opt]
if !ok {
panic(fmt.Sprintf("no string for option %d", opt))
}
return s
}
2023-05-02 23:33:14 +00:00
type Option func(req *BootRequest, r io.Reader) error
const (
OptionTagPadding OptionTag = 0
2023-05-06 05:21:27 +00:00
OptionTagSubnetMask OptionTag = 1
OptionTagTimeOffset OptionTag = 2
OptionTagRouter OptionTag = 3
OptionTagDomainNameServer OptionTag = 6
OptionTagHostName OptionTag = 12
2023-05-06 05:21:27 +00:00
OptionTagDomainName OptionTag = 15
OptionTagInterfaceMTU OptionTag = 26
OptionTagBroadcastAddress OptionTag = 28
OptionTagNTPServers OptionTag = 42
OptionTagNBNS OptionTag = 44
OptionTagNBScope OptionTag = 47
OptionTagMessageType OptionTag = 53
OptionTagParameterRequestList OptionTag = 55
2023-05-09 07:28:54 +00:00
OptionTagDHCPMaxMessageSize OptionTag = 57
OptionTagClientID OptionTag = 61
2023-05-06 05:21:27 +00:00
OptionTagDomainSearch OptionTag = 119
OptionTagClasslessStaticRoute OptionTag = 121
OptionTagEnd OptionTag = 255
2023-05-02 23:33:14 +00:00
)
2023-05-06 05:21:27 +00:00
var optionStrings = map[OptionTag]string{
OptionTagPadding: "pad",
OptionTagSubnetMask: "subnet mask",
OptionTagTimeOffset: "time offset from UTC",
OptionTagRouter: "routers",
OptionTagDomainNameServer: "domain name servers",
OptionTagHostName: "host name",
OptionTagDomainName: "domain name",
OptionTagInterfaceMTU: "interface MTU",
OptionTagBroadcastAddress: "broadcast address",
OptionTagNTPServers: "NTP servers",
OptionTagNBNS: "NetBIOS name servers",
OptionTagNBScope: "NetBIOS scope",
OptionTagMessageType: "message type",
OptionTagParameterRequestList: "parameter request list",
2023-05-09 07:28:54 +00:00
OptionTagDHCPMaxMessageSize: "DHCP max message size",
OptionTagClientID: "client ID",
2023-05-06 05:21:27 +00:00
OptionTagDomainSearch: "search domain",
OptionTagClasslessStaticRoute: "classless static route",
OptionTagEnd: "end",
2023-05-02 23:33:14 +00:00
}
2023-05-06 05:21:27 +00:00
type DHCPMessageType uint8
2023-05-02 23:33:14 +00:00
2023-05-06 05:21:27 +00:00
const (
DHCPMessageTypeDiscover DHCPMessageType = 1
DHCPMessageTypeOffer DHCPMessageType = 2
DHCPMessageTypeRequest DHCPMessageType = 3
DHCPMessageTypeDecline DHCPMessageType = 4
DHCPMessageTypeAck DHCPMessageType = 5
DHCPMessageTypeNAK DHCPMessageType = 6
DHCPMessageTypeRelease DHCPMessageType = 7
DHCPMessageTypeInform DHCPMessageType = 8
)