Documentation ¶
Index ¶
- Constants
- Variables
- func InformSelectForAck(ack dhcpv4.DHCPv4, replyPort uint16, selectedImage BootImage) (*dhcpv4.DHCPv4, error)
- func MakeVendorClassIdentifier() (string, error)
- func NewInformListForInterface(iface string, replyPort uint16) (*dhcpv4.DHCPv4, error)
- type BootImage
- type BootImageID
- type BootImageType
- type Client
- type MessageType
- type OptBootImageList
- type OptDefaultBootImageID
- type OptGeneric
- type OptMachineName
- type OptMessageType
- type OptReplyPort
- type OptSelectedBootImageID
- type OptServerIdentifier
- type OptServerPriority
- type OptVendorSpecificInformation
- func (o *OptVendorSpecificInformation) Code() dhcpv4.OptionCode
- func (o *OptVendorSpecificInformation) GetOption(code dhcpv4.OptionCode) dhcpv4.Option
- func (o *OptVendorSpecificInformation) GetOptions(code dhcpv4.OptionCode) []dhcpv4.Option
- func (o *OptVendorSpecificInformation) Length() int
- func (o *OptVendorSpecificInformation) String() string
- func (o *OptVendorSpecificInformation) ToBytes() []byte
- type OptVersion
Constants ¶
const ( OptionMessageType dhcpv4.OptionCode = 1 OptionVersion dhcpv4.OptionCode = 2 OptionServerIdentifier dhcpv4.OptionCode = 3 OptionServerPriority dhcpv4.OptionCode = 4 OptionReplyPort dhcpv4.OptionCode = 5 OptionBootImageListPath dhcpv4.OptionCode = 6 // Not used OptionDefaultBootImageID dhcpv4.OptionCode = 7 OptionSelectedBootImageID dhcpv4.OptionCode = 8 OptionBootImageList dhcpv4.OptionCode = 9 OptionNetboot1_0Firmware dhcpv4.OptionCode = 10 OptionBootImageAttributesFilterList dhcpv4.OptionCode = 11 OptionShadowMountPath dhcpv4.OptionCode = 128 OptionShadowFilePath dhcpv4.OptionCode = 129 OptionMachineName dhcpv4.OptionCode = 130 )
Options (occur as sub-options of DHCP option 43).
const DefaultMacOSVendorClassIdentifier = "AAPLBSDP/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 = []byte{1, 0} Version1_1 = []byte{1, 1} )
Specific versions.
var BootImageTypeToString = map[BootImageType]string{ BootImageTypeMacOS9: "macOS 9", BootImageTypeMacOSX: "macOS", BootImageTypeMacOSXServer: "macOS Server", BootImageTypeHardwareDiagnostics: "Hardware Diagnostic", }
BootImageTypeToString maps the different BootImageTypes to human-readable representations.
var MessageTypeToString = map[MessageType]string{ MessageTypeList: "LIST", MessageTypeSelect: "SELECT", MessageTypeFailed: "FAILED", }
MessageTypeToString maps each BSDP message type to a human-readable string.
var OptionCodeToString = map[dhcpv4.OptionCode]string{ OptionMessageType: "BSDP Message Type", OptionVersion: "BSDP Version", OptionServerIdentifier: "BSDP Server Identifier", OptionServerPriority: "BSDP Server Priority", OptionReplyPort: "BSDP Reply Port", OptionBootImageListPath: "", OptionDefaultBootImageID: "BSDP Default Boot Image ID", OptionSelectedBootImageID: "BSDP Selected Boot Image ID", OptionBootImageList: "BSDP Boot Image List", OptionNetboot1_0Firmware: "BSDP Netboot 1.0 Firmware", OptionBootImageAttributesFilterList: "BSDP Boot Image Attributes Filter List", OptionShadowMountPath: "BSDP Shadow Mount Path", OptionShadowFilePath: "BSDP Shadow File Path", OptionMachineName: "BSDP Machine Name", }
OptionCodeToString maps BSDP OptionCodes to human-readable strings describing what they are.
Functions ¶
func InformSelectForAck ¶
func InformSelectForAck(ack dhcpv4.DHCPv4, replyPort uint16, selectedImage BootImage) (*dhcpv4.DHCPv4, error)
InformSelectForAck constructs an INFORM[SELECT] packet given an ACK to the previously-sent INFORM[LIST] with Config config.
func MakeVendorClassIdentifier ¶
MakeVendorClassIdentifier returns a static vendor class identifier for BSDP use on non-darwin hosts.
Types ¶
type BootImage ¶
type BootImage struct { ID BootImageID Name string }
BootImage describes a boot image - contains the boot image ID and the name.
func BootImageFromBytes ¶
BootImageFromBytes returns a deserialized BootImage struct from bytes.
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 BootImageIDFromBytes ¶
func BootImageIDFromBytes(bytes []byte) (*BootImageID, error)
BootImageIDFromBytes deserializes a collection of 4 bytes to a BootImageID.
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 serializes a BootImageID to network-order bytes.
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.
const ( MessageTypeList MessageType = 1 MessageTypeSelect MessageType = 2 MessageTypeFailed MessageType = 3 )
BSDP Message types - e.g. LIST, SELECT, FAILED
type OptBootImageList ¶
type OptBootImageList struct {
Images []BootImage
}
OptBootImageList contains the list of boot images presented by a netboot server.
func ParseOptBootImageList ¶
func ParseOptBootImageList(data []byte) (*OptBootImageList, error)
ParseOptBootImageList constructs an OptBootImageList struct from a sequence of bytes and returns it, or an error.
func (*OptBootImageList) Code ¶
func (o *OptBootImageList) Code() dhcpv4.OptionCode
Code returns the option code.
func (*OptBootImageList) Length ¶
func (o *OptBootImageList) Length() int
Length returns the length of the data portion of this option.
func (*OptBootImageList) String ¶
func (o *OptBootImageList) String() string
String returns a human-readable string for this option.
func (*OptBootImageList) ToBytes ¶
func (o *OptBootImageList) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type OptDefaultBootImageID ¶
type OptDefaultBootImageID struct {
ID BootImageID
}
OptDefaultBootImageID contains the selected boot image ID.
func ParseOptDefaultBootImageID ¶
func ParseOptDefaultBootImageID(data []byte) (*OptDefaultBootImageID, error)
ParseOptDefaultBootImageID constructs an OptDefaultBootImageID struct from a sequence of bytes and returns it, or an error.
func (*OptDefaultBootImageID) Code ¶
func (o *OptDefaultBootImageID) Code() dhcpv4.OptionCode
Code returns the option code.
func (*OptDefaultBootImageID) Length ¶
func (o *OptDefaultBootImageID) Length() int
Length returns the length of the data portion of this option.
func (*OptDefaultBootImageID) String ¶
func (o *OptDefaultBootImageID) String() string
String returns a human-readable string for this option.
func (*OptDefaultBootImageID) ToBytes ¶
func (o *OptDefaultBootImageID) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type OptGeneric ¶
type OptGeneric struct { OptionCode dhcpv4.OptionCode Data []byte }
OptGeneric is an option that only contains the option code and associated data. Every option that does not have a specific implementation will fall back to this option.
func ParseOptGeneric ¶
func ParseOptGeneric(data []byte) (*OptGeneric, error)
ParseOptGeneric parses a bytestream and creates a new OptGeneric from it, or an error.
func (OptGeneric) Code ¶
func (o OptGeneric) Code() dhcpv4.OptionCode
Code returns the generic option code.
func (OptGeneric) Length ¶
func (o OptGeneric) Length() int
Length returns the number of bytes comprising the data section of the option.
func (OptGeneric) String ¶
func (o OptGeneric) String() string
String returns a human-readable representation of a generic option.
func (OptGeneric) ToBytes ¶
func (o OptGeneric) ToBytes() []byte
ToBytes returns a serialized generic option as a slice of bytes.
type OptMachineName ¶
type OptMachineName struct {
Name string
}
OptMachineName represents a BSDP message type.
func ParseOptMachineName ¶
func ParseOptMachineName(data []byte) (*OptMachineName, error)
ParseOptMachineName constructs an OptMachineName struct from a sequence of bytes and returns it, or an error.
func (*OptMachineName) Code ¶
func (o *OptMachineName) Code() dhcpv4.OptionCode
Code returns the option code.
func (*OptMachineName) Length ¶
func (o *OptMachineName) Length() int
Length returns the length of the data portion of this option.
func (*OptMachineName) String ¶
func (o *OptMachineName) String() string
String returns a human-readable string for this option.
func (*OptMachineName) ToBytes ¶
func (o *OptMachineName) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type OptMessageType ¶
type OptMessageType struct {
Type MessageType
}
OptMessageType represents a BSDP message type.
func ParseOptMessageType ¶
func ParseOptMessageType(data []byte) (*OptMessageType, error)
ParseOptMessageType constructs an OptMessageType struct from a sequence of bytes and returns it, or an error.
func (*OptMessageType) Code ¶
func (o *OptMessageType) Code() dhcpv4.OptionCode
Code returns the option code.
func (*OptMessageType) Length ¶
func (o *OptMessageType) Length() int
Length returns the length of the data portion of this option.
func (*OptMessageType) String ¶
func (o *OptMessageType) String() string
String returns a human-readable string for this option.
func (*OptMessageType) ToBytes ¶
func (o *OptMessageType) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type OptReplyPort ¶
type OptReplyPort struct {
Port uint16
}
OptReplyPort represents a BSDP protocol version.
func ParseOptReplyPort ¶
func ParseOptReplyPort(data []byte) (*OptReplyPort, error)
ParseOptReplyPort constructs an OptReplyPort struct from a sequence of bytes and returns it, or an error.
func (*OptReplyPort) Code ¶
func (o *OptReplyPort) Code() dhcpv4.OptionCode
Code returns the option code.
func (*OptReplyPort) Length ¶
func (o *OptReplyPort) Length() int
Length returns the length of the data portion of this option.
func (*OptReplyPort) String ¶
func (o *OptReplyPort) String() string
String returns a human-readable string for this option.
func (*OptReplyPort) ToBytes ¶
func (o *OptReplyPort) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type OptSelectedBootImageID ¶
type OptSelectedBootImageID struct {
ID BootImageID
}
OptSelectedBootImageID contains the selected boot image ID.
func ParseOptSelectedBootImageID ¶
func ParseOptSelectedBootImageID(data []byte) (*OptSelectedBootImageID, error)
ParseOptSelectedBootImageID constructs an OptSelectedBootImageID struct from a sequence of bytes and returns it, or an error.
func (*OptSelectedBootImageID) Code ¶
func (o *OptSelectedBootImageID) Code() dhcpv4.OptionCode
Code returns the option code.
func (*OptSelectedBootImageID) Length ¶
func (o *OptSelectedBootImageID) Length() int
Length returns the length of the data portion of this option.
func (*OptSelectedBootImageID) String ¶
func (o *OptSelectedBootImageID) String() string
String returns a human-readable string for this option.
func (*OptSelectedBootImageID) ToBytes ¶
func (o *OptSelectedBootImageID) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type OptServerIdentifier ¶
OptServerIdentifier represents an option encapsulating the server identifier.
func ParseOptServerIdentifier ¶
func ParseOptServerIdentifier(data []byte) (*OptServerIdentifier, error)
ParseOptServerIdentifier returns a new OptServerIdentifier from a byte stream, or error if any.
func (*OptServerIdentifier) Code ¶
func (o *OptServerIdentifier) Code() dhcpv4.OptionCode
Code returns the option code.
func (*OptServerIdentifier) Length ¶
func (o *OptServerIdentifier) Length() int
Length returns the length of the data portion (excluding option code an byte length).
func (*OptServerIdentifier) String ¶
func (o *OptServerIdentifier) String() string
String returns a human-readable string.
func (*OptServerIdentifier) ToBytes ¶
func (o *OptServerIdentifier) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type OptServerPriority ¶
type OptServerPriority struct {
Priority int
}
OptServerPriority represents an option encapsulating the server priority.
func ParseOptServerPriority ¶
func ParseOptServerPriority(data []byte) (*OptServerPriority, error)
ParseOptServerPriority returns a new OptServerPriority from a byte stream, or error if any.
func (*OptServerPriority) Code ¶
func (o *OptServerPriority) Code() dhcpv4.OptionCode
Code returns the option code.
func (*OptServerPriority) Length ¶
func (o *OptServerPriority) Length() int
Length returns the length of the data portion (excluding option code an byte length).
func (*OptServerPriority) String ¶
func (o *OptServerPriority) String() string
String returns a human-readable string.
func (*OptServerPriority) ToBytes ¶
func (o *OptServerPriority) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type OptVendorSpecificInformation ¶
OptVendorSpecificInformation encapsulates the BSDP-specific options used for the protocol.
func ParseOptVendorSpecificInformation ¶
func ParseOptVendorSpecificInformation(data []byte) (*OptVendorSpecificInformation, error)
ParseOptVendorSpecificInformation constructs an OptVendorSpecificInformation struct from a sequence of bytes and returns it, or an error.
func (*OptVendorSpecificInformation) Code ¶
func (o *OptVendorSpecificInformation) Code() dhcpv4.OptionCode
Code returns the option code.
func (*OptVendorSpecificInformation) GetOption ¶
func (o *OptVendorSpecificInformation) GetOption(code dhcpv4.OptionCode) dhcpv4.Option
GetOption returns the first suboption that matches the OptionCode code.
func (*OptVendorSpecificInformation) GetOptions ¶
func (o *OptVendorSpecificInformation) GetOptions(code dhcpv4.OptionCode) []dhcpv4.Option
GetOptions returns all suboptions that match the given OptionCode code.
func (*OptVendorSpecificInformation) Length ¶
func (o *OptVendorSpecificInformation) Length() int
Length returns the length of the data portion of this option. Take into account code + data length bytes for each sub option.
func (*OptVendorSpecificInformation) String ¶
func (o *OptVendorSpecificInformation) String() string
String returns a human-readable string for this option.
func (*OptVendorSpecificInformation) ToBytes ¶
func (o *OptVendorSpecificInformation) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
type OptVersion ¶
type OptVersion struct {
Version []byte
}
OptVersion represents a BSDP protocol version.
func ParseOptVersion ¶
func ParseOptVersion(data []byte) (*OptVersion, error)
ParseOptVersion constructs an OptVersion struct from a sequence of bytes and returns it, or an error.
func (*OptVersion) Code ¶
func (o *OptVersion) Code() dhcpv4.OptionCode
Code returns the option code.
func (*OptVersion) Length ¶
func (o *OptVersion) Length() int
Length returns the length of the data portion of this option.
func (*OptVersion) String ¶
func (o *OptVersion) String() string
String returns a human-readable string for this option.
func (*OptVersion) ToBytes ¶
func (o *OptVersion) ToBytes() []byte
ToBytes returns a serialized stream of bytes for this option.
Source Files ¶
- boot_image.go
- bsdp.go
- bsdp_option_boot_image_list.go
- bsdp_option_default_boot_image_id.go
- bsdp_option_generic.go
- bsdp_option_machine_name.go
- bsdp_option_message_type.go
- bsdp_option_reply_port.go
- bsdp_option_selected_boot_image_id.go
- bsdp_option_server_identifier.go
- bsdp_option_server_priority.go
- bsdp_option_version.go
- client.go
- doc.go
- option_vendor_specific_information.go
- types.go
- vendor_class_identifier.go