bsdp

package
v0.0.0-...-430ae03 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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).

View Source
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.

View Source
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

View Source
var (
	Version1_0 = []byte{1, 0}
	Version1_1 = []byte{1, 1}
)

Specific versions.

View Source
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.

View Source
var MessageTypeToString = map[MessageType]string{
	MessageTypeList:   "LIST",
	MessageTypeSelect: "SELECT",
	MessageTypeFailed: "FAILED",
}

MessageTypeToString maps each BSDP message type to a human-readable string.

View Source
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

func MakeVendorClassIdentifier() (string, error)

MakeVendorClassIdentifier returns a static vendor class identifier for BSDP use on non-darwin hosts.

func NewInformListForInterface

func NewInformListForInterface(iface string, replyPort uint16) (*dhcpv4.DHCPv4, error)

NewInformListForInterface creates a new INFORM packet for interface ifname with configuration options specified by config.

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

func BootImageFromBytes(bytes []byte) (*BootImage, error)

BootImageFromBytes returns a deserialized BootImage struct from bytes.

func ParseBootImageListFromAck

func ParseBootImageListFromAck(ack dhcpv4.DHCPv4) ([]BootImage, error)

ParseBootImageListFromAck parses the list of boot images presented in the ACK[LIST] packet and returns them as a list of BootImages.

func (*BootImage) String

func (b *BootImage) String() string

String converts a BootImage to a human-readable representation.

func (*BootImage) ToBytes

func (b *BootImage) ToBytes() []byte

ToBytes converts a BootImage to a slice of bytes.

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

type Client dhcpv4.Client

Client represents a BSDP client that can perform BSDP exchanges via the broadcast address.

func NewClient

func NewClient() *Client

NewClient constructs a new client with default read and write timeouts from dhcpv4.Client.

func (*Client) Exchange

func (c *Client) Exchange(ifname string, informList *dhcpv4.DHCPv4) ([]dhcpv4.DHCPv4, error)

Exchange runs a full BSDP exchange (Inform[list], Ack, Inform[select], Ack). Returns a list of DHCPv4 structures representing the exchange.

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

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

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

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

type OptServerIdentifier struct {
	ServerID net.IP
}

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

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

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

type OptVendorSpecificInformation struct {
	Options []dhcpv4.Option
}

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

Code returns the option code.

func (*OptVendorSpecificInformation) GetOption

GetOption returns the first suboption that matches the OptionCode code.

func (*OptVendorSpecificInformation) GetOptions

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL