Documentation
¶
Index ¶
- Constants
- func InterfaceByAddress(ifAddr string) (*net.Interface, error)
- type AddressPool
- type BootConfiguration
- type Conn
- type IdentityAssociation
- type MessageType
- type Option
- func MakeDNSServersOption(addresses []net.IP) *Option
- func MakeIaAddrOption(addr net.IP, preferredLifetime, validLifetime uint32) *Option
- func MakeIaNaOption(iaid []byte, t1, t2 uint32, iaOption *Option) *Option
- func MakeOption(id uint16, value []byte) *Option
- func MakeStatusOption(statusCode uint16, message string) *Option
- func UnmarshalOption(bs []byte) (*Option, error)
- type Options
- func (o Options) Add(option *Option)
- func (o Options) BootFileURL() []byte
- func (o Options) ClientArchType() uint16
- func (o Options) ClientID() []byte
- func (o Options) HasBootFileURLOption() bool
- func (o Options) HasClientArchType() bool
- func (o Options) HasClientID() bool
- func (o Options) HasIaNa() bool
- func (o Options) HasIaTa() bool
- func (o Options) HasServerID() bool
- func (o Options) HumanReadable() []string
- func (o Options) IaNaIDs() [][]byte
- func (o Options) Marshal() ([]byte, error)
- func (o Options) ServerID() []byte
- func (o Options) UnmarshalOptionRequestOption() map[uint16]bool
- type Packet
- type PacketBuilder
Constants ¶
const ( // Client ID Option OptClientID uint16 = 1 // Server ID Option OptServerID = 2 // Identity Association for Non-temporary Addresses Option OptIaNa = 3 // Identity Association for Temporary Addresses Option OptIaTa = 4 // IA Address Option OptIaAddr = 5 // Option Request Option OptOro = 6 // Preference Option OptPreference = 7 // Elapsed Time Option OptElapsedTime = 8 // Relay Message Option OptRelayMessage = 9 // Authentication Option OptAuth = 11 // Server Unicast Option OptUnicast = 12 // Status Code Option OptStatusCode = 13 // Rapid Commit Option OptRapidCommit = 14 // User Class Option OptUserClass = 15 // Vendor Class Option OptVendorClass = 16 // Vendor-specific Information Option OptVendorOpts = 17 // Interface-Id Option OptInterfaceID = 18 // Reconfigure Message Option OptReconfMsg = 19 // Reconfigure Accept Option OptReconfAccept = 20 // Recursive DNS name servers Option OptRecursiveDNS = 23 // Boot File URL Option OptBootfileURL = 59 // Boot File Parameters Option OptBootfileParam = 60 // Client Architecture Type Option OptClientArchType = 61 )
DHCPv6 option IDs
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddressPool ¶
type AddressPool interface { ReserveAddresses(clientID []byte, interfaceIds [][]byte) ([]*IdentityAssociation, error) ReleaseAddresses(clientID []byte, interfaceIds [][]byte) }
AddressPool keeps track of assigned and available ip address in an address pool
type BootConfiguration ¶
type BootConfiguration interface { GetBootURL(id []byte, clientArchType uint16) ([]byte, error) GetPreference() []byte GetRecursiveDNS() []net.IP }
BootConfiguration implementation provides values for dhcp options served to dhcp clients
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is dhcpv6-specific socket
func (*Conn) SourceHardwareAddress ¶
func (c *Conn) SourceHardwareAddress() net.HardwareAddr
SourceHardwareAddress returns hardware address of the interface used by Conn
type IdentityAssociation ¶
type IdentityAssociation struct { IPAddress net.IP ClientID []byte InterfaceID []byte CreatedAt time.Time }
IdentityAssociation associates an ip address with a network interface of a client
type MessageType ¶
type MessageType uint8
MessageType contains ID identifying DHCP message type. See RFC 3315
const ( MsgSolicit MessageType = iota + 1 MsgAdvertise MsgRequest MsgConfirm MsgRenew MsgRebind MsgReply MsgRelease MsgDecline MsgReconfigure MsgInformationRequest MsgRelayForw MsgRelayRepl )
Constants for each of the dhcp message types defined in RFC 3315
type Option ¶
Option represents a DHCPv6 Option
func MakeDNSServersOption ¶
MakeDNSServersOption creates a Recursive DNS servers Option with the specified list of IP addresses
func MakeIaAddrOption ¶
MakeIaAddrOption creates an IA Address Option using IP address, preferred and valid lifetimes
func MakeIaNaOption ¶
MakeIaNaOption creates a Identity Association for Non-temporary Addresses Option with specified interface ID, t1 and t2 times, and an interface-specific option (an IA Address Option or a Status Option)
func MakeOption ¶
MakeOption creates an Option with given ID and value
func MakeStatusOption ¶
MakeStatusOption creates a Status Option with given status code and message
func UnmarshalOption ¶
UnmarshalOption de-serializes an Option
type Options ¶
Options contains all options of a DHCPv6 packet
func UnmarshalOptions ¶
UnmarshalOptions unmarshals individual Options and returns them in a new Options data structure
func (Options) BootFileURL ¶
BootFileURL returns the value in the Boot File URL Option, or nil if the option doesn't exist
func (Options) ClientArchType ¶
ClientArchType returns the value in the Client Architecture Type Option, or 0 if the option doesn't exist
func (Options) ClientID ¶
ClientID returns the value in the Client ID Option or nil if the option doesn't exist
func (Options) HasBootFileURLOption ¶
HasBootFileURLOption returns true if Options contains Boot File URL Option
func (Options) HasClientArchType ¶
HasClientArchType returns true if Options contains Client Architecture Type Option
func (Options) HasClientID ¶
HasClientID returns true if Options contains Client ID Option
func (Options) HasIaNa ¶
HasIaNa returns true if Options contains Identity Association for Non-Temporary Addresses Option
func (Options) HasIaTa ¶
HasIaTa returns true if Options contains Identity Association for Temporary Addresses Option
func (Options) HasServerID ¶
HasServerID returns true if Options contains Server ID Option
func (Options) HumanReadable ¶
HumanReadable presents DHCPv6 options in a human-readable form
func (Options) IaNaIDs ¶
IaNaIDs returns a list of interface IDs in all Identity Association for Non-Temporary Addresses Options, or an empty list if none exist
func (Options) ServerID ¶
ServerID returns the value in the Server ID Option or nil if the option doesn't exist
func (Options) UnmarshalOptionRequestOption ¶
UnmarshalOptionRequestOption de-serializes Option Request Option
type Packet ¶
type Packet struct { Type MessageType TransactionID [3]byte Options Options }
Packet represents a DHCPv6 packet
func (*Packet) ShouldDiscard ¶
ShouldDiscard returns true if the Packet fails validation
type PacketBuilder ¶
PacketBuilder is used for generating responses to requests received from dhcp clients
func MakePacketBuilder ¶
func MakePacketBuilder(preferredLifetime, validLifetime uint32) *PacketBuilder
MakePacketBuilder creates a new PacketBuilder and initializes it with preferred and valid lifetimes
func (*PacketBuilder) BuildResponse ¶
func (b *PacketBuilder) BuildResponse(in *Packet, serverDUID []byte, configuration BootConfiguration, addresses AddressPool) (*Packet, error)
BuildResponse generates a response packet for a packet received from a client