dhcp

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package dhcp implements a DHCP client and server as described in RFC 2131.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialUDP added in v0.2.0

func DialUDP(s *stack.Stack, laddr, raddr *tcpip.FullAddress, network tcpip.NetworkProtocolNumber) (*gonet.UDPConn, error)

Types

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) *Client

NewClient creates a DHCP client.

TODO(crawshaw): add s.LinkAddr(nicid) to *stack.Stack.

func (*Client) Address

func (c *Client) Address() tcpip.Address

Address reports the IP address acquired by the DHCP client.

func (*Client) Config

func (c *Client) Config() Config

Config reports the DHCP configuration acquired with the IP address lease.

func (*Client) Request

func (c *Client) Request(ctx context.Context, requestedAddr tcpip.Address) error

Request executes a DHCP request session.

On success, it adds a new address to this client's TCPIP stack. If the server sets a lease limit a timer is set to automatically renew it.

func (*Client) Shutdown

func (c *Client) Shutdown()

Shutdown relinquishes any lease and ends any outstanding renewal timers.

func (*Client) Start

func (c *Client) Start()

Start starts the DHCP client. It will periodically search for an IP address using the Request method.

type Config

type Config struct {
	ServerAddress    tcpip.Address     // address of the server
	SubnetMask       tcpip.AddressMask // client address subnet mask
	Gateway          tcpip.Address     // client default gateway
	DomainNameServer tcpip.Address     // client domain name server
	LeaseLength      time.Duration     // length of the address lease
}

Config is standard DHCP configuration.

Jump to

Keyboard shortcuts

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