dhcp

package
v0.0.0-...-23e6066 Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: Apache-2.0 Imports: 13 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

This section is empty.

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: 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.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a DHCP server.

func NewServer

func NewServer(ctx context.Context, stack *stack.Stack, addrs []tcpip.Address, cfg Config) (*Server, error)

NewServer creates a new DHCP server and begins serving. The server continues serving until ctx is done.

Jump to

Keyboard shortcuts

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