diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2023-12-04 10:33:34 +0000 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2023-12-06 07:48:09 +0100 |
commit | 8c70d406f6d24a17219a5f543174c1f3f3ad9e35 (patch) | |
tree | 7f9acc8e465b9b354dea197f1d77698370e648ab /dhcpv4/bsdp/bsdp_option_misc.go | |
parent | b0416c0f187a65a350b32d34fc31ea30f06c12ce (diff) |
Diffstat (limited to 'dhcpv4/bsdp/bsdp_option_misc.go')
-rw-r--r-- | dhcpv4/bsdp/bsdp_option_misc.go | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/dhcpv4/bsdp/bsdp_option_misc.go b/dhcpv4/bsdp/bsdp_option_misc.go deleted file mode 100644 index 3848a6c..0000000 --- a/dhcpv4/bsdp/bsdp_option_misc.go +++ /dev/null @@ -1,66 +0,0 @@ -package bsdp - -import ( - "fmt" - "net" - - "github.com/insomniacslk/dhcp/dhcpv4" - "github.com/u-root/uio/uio" -) - -// OptReplyPort returns a new BSDP reply port option. -// -// 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. -func OptReplyPort(port uint16) dhcpv4.Option { - return dhcpv4.Option{Code: OptionReplyPort, Value: dhcpv4.Uint16(port)} -} - -// OptServerPriority returns a new BSDP server priority option. -func OptServerPriority(prio uint16) dhcpv4.Option { - return dhcpv4.Option{Code: OptionServerPriority, Value: dhcpv4.Uint16(prio)} -} - -// OptMachineName returns a BSDP Machine Name option. -func OptMachineName(name string) dhcpv4.Option { - return dhcpv4.Option{Code: OptionMachineName, Value: dhcpv4.String(name)} -} - -// Version is the BSDP protocol version. Can be one of 1.0 or 1.1. -type Version [2]byte - -// Specific versions. -var ( - Version1_0 = Version{1, 0} - Version1_1 = Version{1, 1} -) - -// ToBytes returns a serialized stream of bytes for this option. -func (o Version) ToBytes() []byte { - return o[:] -} - -// String returns a human-readable string for this option. -func (o Version) String() string { - return fmt.Sprintf("%d.%d", o[0], o[1]) -} - -// FromBytes constructs a Version struct from a sequence of -// bytes and returns it, or an error. -func (o *Version) FromBytes(data []byte) error { - buf := uio.NewBigEndianBuffer(data) - buf.ReadBytes(o[:]) - return buf.FinError() -} - -// OptVersion returns a new BSDP version option. -func OptVersion(version Version) dhcpv4.Option { - return dhcpv4.Option{Code: OptionVersion, Value: version} -} - -// OptServerIdentifier returns a new BSDP Server Identifier option. -func OptServerIdentifier(ip net.IP) dhcpv4.Option { - return dhcpv4.Option{Code: OptionServerIdentifier, Value: dhcpv4.IP(ip)} -} |