Documentation ¶
Index ¶
- Constants
- Variables
- func MakeVendorClassIdentifier() (string, error)
- func OptBootImageList(b ...BootImage) dhcpv4.Option
- func OptDefaultBootImageID(b BootImageID) dhcpv4.Option
- func OptMachineName(name string) dhcpv4.Option
- func OptMessageType(mt MessageType) dhcpv4.Option
- func OptReplyPort(port uint16) dhcpv4.Option
- func OptSelectedBootImageID(b BootImageID) dhcpv4.Option
- func OptServerIdentifier(ip net.IP) dhcpv4.Option
- func OptServerPriority(prio uint16) dhcpv4.Option
- func OptVendorOptions(o ...dhcpv4.Option) dhcpv4.Option
- func OptVersion(version Version) dhcpv4.Option
- type BootImage
- type BootImageID
- type BootImageList
- type BootImageType
- type Client
- type MessageType
- type Packet
- func InformSelectForAck(ack *Packet, replyPort uint16, selectedImage BootImage) (*Packet, error)
- func NewInformList(hwaddr net.HardwareAddr, localIP net.IP, replyPort uint16, ...) (*Packet, error)
- func NewInformListForInterface(ifname string, replyPort uint16) (*Packet, error)
- func NewReplyForInformList(inform *Packet, config ReplyConfig) (*Packet, error)
- func NewReplyForInformSelect(inform *Packet, config ReplyConfig) (*Packet, error)
- func PacketFor(d *dhcpv4.DHCPv4) *Packet
- type ReplyConfig
- type VendorOptions
- func (v VendorOptions) BootImageList() BootImageList
- func (v VendorOptions) DefaultBootImageID() *BootImageID
- func (v *VendorOptions) FromBytes(data []byte) error
- func (v VendorOptions) MachineName() string
- func (v VendorOptions) MessageType() MessageType
- func (v VendorOptions) ReplyPort() (uint16, error)
- func (v VendorOptions) SelectedBootImageID() *BootImageID
- func (v VendorOptions) ServerIdentifier() net.IP
- func (v VendorOptions) ServerPriority() (uint16, error)
- func (v VendorOptions) String() string
- func (v VendorOptions) Version() (Version, error)
- type Version
Constants ¶
const ( OptionMessageType optionCode = 1 OptionVersion optionCode = 2 OptionServerIdentifier optionCode = 3 OptionServerPriority optionCode = 4 OptionReplyPort optionCode = 5 OptionBootImageListPath optionCode = 6 // Not used OptionDefaultBootImageID optionCode = 7 OptionSelectedBootImageID optionCode = 8 OptionBootImageList optionCode = 9 OptionNetboot1_0Firmware optionCode = 10 OptionBootImageAttributesFilterList optionCode = 11 OptionShadowMountPath optionCode = 128 OptionShadowFilePath optionCode = 129 OptionMachineName optionCode = 130 )
Options (occur as sub-options of DHCP option 43).
const AppleVendorID = "AAPLBSDPC"
AppleVendorID is the string constant set in the vendor class identifier (DHCP option 60) that is sent by the server.
const DefaultMacOSVendorClassIdentifier = AppleVendorID + "/i386/MacMini6,1"
DefaultMacOSVendorClassIdentifier is a default vendor class identifier used on non-darwin hosts where the vendor class identifier cannot be determined. It should mostly be used for debugging if testing BSDP on a non-darwin system.
const MaxDHCPMessageSize = 1500
MaxDHCPMessageSize is the size set in DHCP option 57 (DHCP Maximum Message Size). BSDP includes its own sub-option (12) to indicate to NetBoot servers that the client can support larger message sizes, and modern NetBoot servers will prefer this BSDP-specific option over the DHCP standard option.
Variables ¶
var ( Version1_0 = Version{1, 0} Version1_1 = Version{1, 1} )
Specific versions.
Functions ¶
func MakeVendorClassIdentifier ¶
MakeVendorClassIdentifier returns a static vendor class identifier for BSDP use on non-darwin hosts.
func OptBootImageList ¶
OptBootImageList returns a new BSDP boot image list.
func OptDefaultBootImageID ¶
func OptDefaultBootImageID(b BootImageID) dhcpv4.Option
OptDefaultBootImageID returns a new default boot image ID option as per BSDP.
func OptMachineName ¶
OptMachineName returns a BSDP Machine Name option.
func OptMessageType ¶
func OptMessageType(mt MessageType) dhcpv4.Option
OptMessageType returns a new BSDP Message Type option.
func OptReplyPort ¶
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 OptSelectedBootImageID ¶
func OptSelectedBootImageID(b BootImageID) dhcpv4.Option
OptSelectedBootImageID returns a new selected boot image ID option as per BSDP.
func OptServerIdentifier ¶
OptServerIdentifier returns a new BSDP Server Identifier option.
func OptServerPriority ¶
OptServerPriority returns a new BSDP server priority option.
func OptVendorOptions ¶
OptVendorOptions returns the BSDP Vendor Specific Info in o.
func OptVersion ¶
OptVersion returns a new BSDP version option.
Types ¶
type BootImage ¶
type BootImage struct { ID BootImageID Name string }
BootImage describes a boot image - contains the boot image ID and the name.
func ParseBootImageListFromAck ¶
ParseBootImageListFromAck parses the list of boot images presented in the ACK[LIST] packet and returns them as a list of BootImages.
type BootImageID ¶
type BootImageID struct { IsInstall bool ImageType BootImageType Index uint16 }
BootImageID describes a boot image ID - whether it's an install image and what kind of boot image (e.g. OS 9, macOS, hardware diagnostics)
func (*BootImageID) FromBytes ¶
func (b *BootImageID) FromBytes(data []byte) error
FromBytes reads data into b.
func (BootImageID) Marshal ¶
func (b BootImageID) Marshal(buf *uio.Lexer)
Marshal writes the binary representation to buf.
func (BootImageID) String ¶
func (b BootImageID) String() string
String converts a BootImageID to a human-readable representation.
func (BootImageID) ToBytes ¶
func (b BootImageID) ToBytes() []byte
ToBytes implements dhcpv4.OptionValue.
type BootImageList ¶
type BootImageList []BootImage
BootImageList contains a list of boot images presented by a netboot server.
Implements the BSDP option listing the boot images.
func (*BootImageList) FromBytes ¶
func (bil *BootImageList) FromBytes(data []byte) error
FromBytes deserializes data into bil.
func (BootImageList) String ¶
func (bil BootImageList) String() string
String returns a human-readable string for this option.
func (BootImageList) ToBytes ¶
func (bil BootImageList) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type BootImageType ¶
type BootImageType byte
BootImageType represents the different BSDP boot image types.
const ( BootImageTypeMacOS9 BootImageType = 0 BootImageTypeMacOSX BootImageType = 1 BootImageTypeMacOSXServer BootImageType = 2 BootImageTypeHardwareDiagnostics BootImageType = 3 )
Different types of BootImages - e.g. for different flavors of macOS.
type Client ¶
Client represents a BSDP client that can perform BSDP exchanges via the broadcast address.
type MessageType ¶
type MessageType byte
MessageType represents the different BSDP message types.
Implements the BSDP option message type. Can be one of LIST, SELECT, or FAILED.
const ( MessageTypeNone MessageType = 0 MessageTypeList MessageType = 1 MessageTypeSelect MessageType = 2 MessageTypeFailed MessageType = 3 )
BSDP Message types - e.g. LIST, SELECT, FAILED
func MessageTypeFromPacket ¶
func MessageTypeFromPacket(packet *dhcpv4.DHCPv4) MessageType
MessageTypeFromPacket extracts the BSDP message type (LIST, SELECT) from the vendor-specific options and returns it. If the message type option cannot be found, returns false.
func (*MessageType) FromBytes ¶
func (m *MessageType) FromBytes(data []byte) error
FromBytes reads data into m.
func (MessageType) String ¶
func (m MessageType) String() string
String returns a human-friendly representation of MessageType.
func (MessageType) ToBytes ¶
func (m MessageType) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type Packet ¶
Packet is a BSDP packet wrapper around a DHCPv4 packet in order to print the correct vendor-specific BSDP information in String().
func InformSelectForAck ¶
InformSelectForAck constructs an INFORM[SELECT] packet given an ACK to the previously-sent INFORM[LIST].
func NewInformList ¶
func NewInformList(hwaddr net.HardwareAddr, localIP net.IP, replyPort uint16, modifiers ...dhcpv4.Modifier) (*Packet, error)
NewInformList creates a new INFORM packet for interface with hardware address `hwaddr` and IP `localIP`. Packet will be sent out on port `replyPort`.
func NewInformListForInterface ¶
NewInformListForInterface creates a new INFORM packet for interface ifname with configuration options specified by config.
func NewReplyForInformList ¶
func NewReplyForInformList(inform *Packet, config ReplyConfig) (*Packet, error)
NewReplyForInformList constructs an ACK for the INFORM[LIST] packet `inform` with additional options in `config`.
func NewReplyForInformSelect ¶
func NewReplyForInformSelect(inform *Packet, config ReplyConfig) (*Packet, error)
NewReplyForInformSelect constructs an ACK for the INFORM[Select] packet `inform` with additional options in `config`.
type ReplyConfig ¶
type ReplyConfig struct { ServerIP net.IP ServerHostname, BootFileName string ServerPriority uint16 Images []BootImage DefaultImage, SelectedImage *BootImage }
ReplyConfig is a struct containing some common configuration values for a BSDP reply (ACK).
type VendorOptions ¶
VendorOptions is like dhcpv4.Options, but stringifies using BSDP-specific option codes.
func GetVendorOptions ¶
func GetVendorOptions(o dhcpv4.Options) *VendorOptions
GetVendorOptions returns a new BSDP Vendor Specific Info option.
func (VendorOptions) BootImageList ¶
func (v VendorOptions) BootImageList() BootImageList
BootImageList returns the BSDP boot image list in v.
func (VendorOptions) DefaultBootImageID ¶
func (v VendorOptions) DefaultBootImageID() *BootImageID
DefaultBootImageID returns the default boot image ID in v.
func (*VendorOptions) FromBytes ¶
func (v *VendorOptions) FromBytes(data []byte) error
FromBytes parses vendor options from
func (VendorOptions) MachineName ¶
func (v VendorOptions) MachineName() string
GetMachineName finds and parses the BSDP Machine Name option from v.
func (VendorOptions) MessageType ¶
func (v VendorOptions) MessageType() MessageType
MessageType returns the BSDP Message Type in v.
func (VendorOptions) ReplyPort ¶
func (v VendorOptions) ReplyPort() (uint16, error)
GetReplyPort returns the BSDP reply port in v if present.
func (VendorOptions) SelectedBootImageID ¶
func (v VendorOptions) SelectedBootImageID() *BootImageID
SelectedBootImageID returns the selected boot image ID in v.
func (VendorOptions) ServerIdentifier ¶
func (v VendorOptions) ServerIdentifier() net.IP
GetServerIdentifier returns the BSDP Server Identifier value in v if present.
func (VendorOptions) ServerPriority ¶
func (v VendorOptions) ServerPriority() (uint16, error)
GetServerPriority returns the BSDP server priority in v if present.
func (VendorOptions) String ¶
func (v VendorOptions) String() string
String prints the contained options using BSDP-specific option code parsing.
func (VendorOptions) Version ¶
func (v VendorOptions) Version() (Version, error)
GetVersion returns the BSDP version in v if present.