Documentation ¶
Overview ¶
Package dhcp4 provides building blocks for DHCP clients and servers.
Index ¶
- type Conn
- type MessageType
- type Option
- type Options
- func (o Options) Byte(n Option) (byte, error)
- func (o Options) Bytes(n Option) ([]byte, error)
- func (o Options) Copy() Options
- func (o Options) IP(n Option) (net.IP, error)
- func (o Options) IPMask(n Option) (net.IPMask, error)
- func (o Options) IPs(n Option) ([]net.IP, error)
- func (o Options) Int32(n Option) (int32, error)
- func (o Options) Marshal() ([]byte, error)
- func (o Options) String(n Option) (string, error)
- func (o Options) Uint16(n Option) (uint16, error)
- func (o Options) Uint32(n Option) (uint32, error)
- func (o Options) Unmarshal(bs []byte) error
- type Packet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a DHCP-oriented packet socket.
Multiple goroutines may invoke methods on a Conn simultaneously.
func NewSnooperConn ¶
NewSnooperConn creates a Conn that listens on the given UDP ip:port.
Unlike NewConn, NewSnooperConn does not bind to the ip:port, enabling the Conn to coexist with other services on the machine.
func (*Conn) Close ¶
Close closes the DHCP socket. Any blocked Read or Write operations will be unblocked and return errors.
func (*Conn) RecvDHCP ¶
RecvDHCP reads a Packet from the connection. It returns the packet and the interface it was received on.
func (*Conn) SendDHCP ¶
SendDHCP sends pkt. The precise transmission mechanism depends on pkt.txType(). intf should be the net.Interface returned by RecvDHCP if responding to a DHCP client, or the interface for which configuration is desired if acting as a client.
func (*Conn) SetReadDeadline ¶
SetReadDeadline sets the deadline for future Read calls. If the deadline is reached, Read will fail with a timeout (see net.Error) instead of blocking. A zero value for t means Read will not time out.
type MessageType ¶
type MessageType int
MessageType is the type of a DHCP message.
const ( MsgDiscover MessageType = iota + 1 MsgOffer MsgRequest MsgDecline MsgAck MsgNack MsgRelease MsgInform )
Message types as described in RFC 2131.
func (MessageType) String ¶
func (mt MessageType) String() string
type Option ¶
type Option byte
Option is a DHCP option.
const ( OptSubnetMask Option = 1 // IPMask OptTimeOffset Option = 2 // int32 OptRouters Option = 3 // IPs OptDNSServers Option = 6 // IPs OptHostname Option = 12 // string OptBootFileSize Option = 13 // uint16 OptDomainName Option = 15 // string OptInterfaceMTU Option = 26 // uint16 OptBroadcastAddr Option = 28 // IP OptNTPServers Option = 42 // IP OptVendorSpecific Option = 43 // []byte OptRequestedIP Option = 50 // IP OptLeaseTime Option = 51 // uint32 OptOverload Option = 52 // byte OptServerIdentifier Option = 54 // IP OptRequestedOptions Option = 55 // []byte OptMessage Option = 56 // string OptMaximumMessageSize Option = 57 // uint16 OptRenewalTime Option = 58 // uint32 OptRebindingTime Option = 59 // uint32 OptVendorIdentifier Option = 60 // string OptClientIdentifier Option = 61 // string OptFQDN Option = 81 // string OptTFTPServer Option = 66 // string OptBootFile Option = 67 // string OptDHCPMessageType Option = 53 // byte )
Some of the more commonly seen DHCP options. Refer to http://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml for the full authoritative list.
type Options ¶
Options stores DHCP options.
type Packet ¶
type Packet struct { Type MessageType TransactionID []byte // Always 4 bytes Broadcast bool HardwareAddr net.HardwareAddr // Only ethernet supported at the moment ClientAddr net.IP // Client's current IP address (it will respond to ARP for this IP) YourAddr net.IP // Client IP address offered/assigned by server ServerAddr net.IP // Responding server's IP address RelayAddr net.IP // IP address of DHCP relay agent, if an agent forwarded the request BootServerName string BootFilename string Options Options }
Packet represents a DHCP packet.
func (*Packet) DebugString ¶
DebugString prints the contents of a DHCP packet for human consumption.