Documentation ¶
Overview ¶
Package dhcp implements a DHCP client and server as described in RFC 2131.
Index ¶
Constants ¶
View Source
const ( // ServerPort is the well-known UDP port number for a DHCP server. ServerPort = 67 // ClientPort is the well-known UDP port number for a DHCP client. ClientPort = 68 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcquiredFunc ¶
type AcquiredFunc func(oldAddr, newAddr tcpip.AddressWithPrefix, cfg Config)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a DHCP client.
func NewClient ¶
func NewClient( s *stack.Stack, nicid tcpip.NICID, linkAddr tcpip.LinkAddress, acquisition, backoff, retransmission time.Duration, acquiredFunc AcquiredFunc, ) *Client
NewClient creates a DHCP client.
acquiredFunc will be called after each DHCP acquisition, and is responsible for making necessary modifications to the stack state.
type Config ¶
type Config struct { ServerAddress tcpip.Address // address of the server SubnetMask tcpip.AddressMask // client address subnet mask Router []tcpip.Address // client router addresses DNS []tcpip.Address // client DNS server addresses LeaseLength Seconds // length of the address lease RenewTime Seconds // time until client enters RENEWING state RebindTime Seconds // time until client enters REBINDING state Declined bool // server sent a NAK }
Config is standard DHCP configuration.
type Info ¶
type Info struct { // NICID is the identifer to the associated NIC. NICID tcpip.NICID // LinkAddr is the link-address of the associated NIC. LinkAddr tcpip.LinkAddress // Acquisition is the duration within which a complete DHCP transaction must // complete before timing out. Acquisition time.Duration // Backoff is the duration for which the client must wait before starting a // new DHCP transaction after a failed transaction. Backoff time.Duration // Retransmission is the duration to wait before resending a DISCOVER or // REQUEST within an active transaction. Retransmission time.Duration // Addr is the acquired network address. Addr tcpip.AddressWithPrefix // Server is the network address of the DHCP server. Server tcpip.Address // State is the DHCP client state. State dhcpClientState // OldAddr is the address reported in the last call to acquiredFunc. OldAddr tcpip.AddressWithPrefix }
type Seconds ¶
type Seconds uint32
Seconds represents a time duration in seconds.
RFC 2131 Section 3.3 https://tools.ietf.org/html/rfc2131#section-3.3
Throughout the protocol, times are to be represented in units of seconds. Representing relative times in units of seconds in an unsigned 32 bit word gives a range of relative times from 0 to approximately 100 years, which is sufficient for the relative times to be measured using DHCP.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a DHCP server.
type Stats ¶
type Stats struct { InitAcquire tcpip.StatCounter RenewAcquire tcpip.StatCounter RebindAcquire tcpip.StatCounter SendDiscovers tcpip.StatCounter RecvOffers tcpip.StatCounter SendRequests tcpip.StatCounter RecvAcks tcpip.StatCounter RecvNaks tcpip.StatCounter SendDiscoverErrors tcpip.StatCounter SendRequestErrors tcpip.StatCounter RecvOfferErrors tcpip.StatCounter RecvOfferUnexpectedType tcpip.StatCounter RecvOfferOptsDecodeErrors tcpip.StatCounter RecvOfferTimeout tcpip.StatCounter RecvOfferAcquisitionTimeout tcpip.StatCounter RecvAckErrors tcpip.StatCounter RecvNakErrors tcpip.StatCounter RecvAckOptsDecodeErrors tcpip.StatCounter RecvAckAddrErrors tcpip.StatCounter RecvAckUnexpectedType tcpip.StatCounter RecvAckTimeout tcpip.StatCounter RecvAckAcquisitionTimeout tcpip.StatCounter ReacquireAfterNAK tcpip.StatCounter }
Stats collects DHCP statistics per client.
Click to show internal directories.
Click to hide internal directories.