MCPcopy Create free account
hub / github.com/danderson/netboot / validatePXE

Method validatePXE

pixiecore/pxe.go:94–127  ·  view source on GitHub ↗
(pkt *dhcp4.Packet)

Source from the content-addressed store, hash-verified

92}
93
94func (s *Server) validatePXE(pkt *dhcp4.Packet) (fwtype Firmware, err error) {
95 fwt, err := pkt.Options.Uint16(93)
96 if err != nil {
97 return 0, fmt.Errorf("malformed DHCP option 93 (required for PXE): %s", err)
98 }
99 switch fwt {
100 case 6:
101 fwtype = FirmwareEFI32
102 case 7:
103 fwtype = FirmwareEFI64
104 case 9:
105 fwtype = FirmwareEFIBC
106 default:
107 return 0, fmt.Errorf("unsupported client firmware type '%d'", fwt)
108 }
109 if s.Ipxe[fwtype] == nil {
110 return 0, fmt.Errorf("unsupported client firmware type '%d'", fwt)
111 }
112
113 guid := pkt.Options[97]
114 switch len(guid) {
115 case 0:
116 // Accept missing GUIDs even though it's a spec violation,
117 // same as in dhcp.go.
118 case 17:
119 if guid[0] != 0 {
120 return 0, errors.New("malformed client GUID (option 97), leading byte must be zero")
121 }
122 default:
123 return 0, errors.New("malformed client GUID (option 97), wrong size")
124 }
125
126 return fwtype, nil
127}
128
129func (s *Server) offerPXE(pkt *dhcp4.Packet, serverIP net.IP, fwtype Firmware) (resp *dhcp4.Packet, err error) {
130 resp = &dhcp4.Packet{

Callers 1

servePXEMethod · 0.95

Calls 1

Uint16Method · 0.80

Tested by

no test coverage detected