Documentation ¶
Overview ¶
Package nclient6 is a minimum-functionality client for DHCPv6.
Index ¶
- Variables
- func NewIPv6UDPConn(iface string, port int) (net.PacketConn, error)
- type Client
- func (c *Client) Close() error
- func (c *Client) InterfaceAddr() net.HardwareAddr
- func (c *Client) RapidSolicit(ctx context.Context, modifiers ...dhcpv6.Modifier) (*dhcpv6.Message, error)
- func (c *Client) RemoteAddr() *net.UDPAddr
- func (c *Client) Request(ctx context.Context, advertise *dhcpv6.Message, modifiers ...dhcpv6.Modifier) (*dhcpv6.Message, error)
- func (c *Client) SendAndRead(ctx context.Context, dest *net.UDPAddr, msg *dhcpv6.Message, match Matcher) (*dhcpv6.Message, error)
- func (c *Client) Solicit(ctx context.Context, modifiers ...dhcpv6.Modifier) (*dhcpv6.Message, error)
- type ClientOpt
- type Matcher
Constants ¶
This section is empty.
Variables ¶
var ( AllDHCPRelayAgentsAndServers = &net.UDPAddr{ IP: net.ParseIP("ff02::1:2"), Port: dhcpv6.DefaultServerPort, } AllDHCPServers = &net.UDPAddr{ IP: net.ParseIP("ff05::1:3"), Port: dhcpv6.DefaultServerPort, } )
Broadcast destination IP addresses as defined by RFC 3315
var ( // ErrNoResponse is returned when no response packet is received. ErrNoResponse = errors.New("no matching response packet received") )
Functions ¶
func NewIPv6UDPConn ¶
func NewIPv6UDPConn(iface string, port int) (net.PacketConn, error)
NewIPv6UDPConn returns a UDP connection bound to both the interface and port given based on a IPv6 DGRAM socket.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a DHCPv6 client.
func NewWithConn ¶
func NewWithConn(conn net.PacketConn, ifaceHWAddr net.HardwareAddr, opts ...ClientOpt) (*Client, error)
NewWithConn creates a new DHCP client that sends and receives packets on the given interface.
func (*Client) InterfaceAddr ¶
func (c *Client) InterfaceAddr() net.HardwareAddr
InterfaceAddr returns the MAC address of the client's interface.
func (*Client) RapidSolicit ¶
func (c *Client) RapidSolicit(ctx context.Context, modifiers ...dhcpv6.Modifier) (*dhcpv6.Message, error)
RapidSolicit sends a solicitation message with the RapidCommit option and returns the first valid reply received.
func (*Client) RemoteAddr ¶
RemoteAddr is the default DHCP server address this client sends messages to.
func (*Client) Request ¶
func (c *Client) Request(ctx context.Context, advertise *dhcpv6.Message, modifiers ...dhcpv6.Modifier) (*dhcpv6.Message, error)
Request requests an IP Assignment from peer given an advertise message.
func (*Client) SendAndRead ¶
func (c *Client) SendAndRead(ctx context.Context, dest *net.UDPAddr, msg *dhcpv6.Message, match Matcher) (*dhcpv6.Message, error)
SendAndRead sends a packet p to a destination dest and waits for the first response matching `match` as well as its Transaction ID.
If match is nil, the first packet matching the Transaction ID is returned.
type ClientOpt ¶
type ClientOpt func(*Client)
ClientOpt is a function that configures the Client.
func WithBroadcastAddr ¶
WithBroadcastAddr configures the address to broadcast to.
func WithConn ¶
func WithConn(conn net.PacketConn) ClientOpt
WithConn configures the packet connection to use.
func WithDebugLogger ¶
func WithDebugLogger() ClientOpt
WithDebugLogger logs multi-line full DHCPv6 messages when sent & received.
func WithLogDroppedPackets ¶
func WithLogDroppedPackets() ClientOpt
WithLogDroppedPackets logs a short message for dropped packets.
func WithSummaryLogger ¶
func WithSummaryLogger() ClientOpt
WithSummaryLogger logs one-line DHCPv6 message summarys when sent & received.
type Matcher ¶
Matcher matches DHCP packets.
func IsMessageType ¶
func IsMessageType(t dhcpv6.MessageType, tt ...dhcpv6.MessageType) Matcher
IsMessageType returns a matcher that checks for the message type.