blob: 5eea5ee8ac36cb3ab75c25b68d98f1a014382fe5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package bsdp
import (
"fmt"
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/u-root/u-root/pkg/uio"
)
// OptReplyPort represents a BSDP protocol version.
//
// Implements the BSDP option reply port. This is used when BSDP responses
// should be sent to a reply port other than the DHCP default. The macOS GUI
// "Startup Disk Select" sends this option since it's operating in an
// unprivileged context.
type OptReplyPort struct {
Port uint16
}
// ParseOptReplyPort constructs an OptReplyPort struct from a sequence of
// bytes and returns it, or an error.
func ParseOptReplyPort(data []byte) (*OptReplyPort, error) {
buf := uio.NewBigEndianBuffer(data)
return &OptReplyPort{buf.Read16()}, buf.FinError()
}
// Code returns the option code.
func (o *OptReplyPort) Code() dhcpv4.OptionCode {
return OptionReplyPort
}
// ToBytes returns a serialized stream of bytes for this option.
func (o *OptReplyPort) ToBytes() []byte {
buf := uio.NewBigEndianBuffer(nil)
buf.Write16(o.Port)
return buf.Data()
}
// String returns a human-readable string for this option.
func (o *OptReplyPort) String() string {
return fmt.Sprintf("BSDP Reply Port -> %v", o.Port)
}
|