dhcp

package
v0.0.0-...-ec91871 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

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 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, acquiredFunc func(old, new tcpip.Address, cfg Config)) *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) (cfg Config, reterr 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) Run

func (c *Client) Run(ctx context.Context)

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

type Config

type Config struct {
	Error         error
	ServerAddress tcpip.Address     // address of the server
	SubnetMask    tcpip.AddressMask // client address subnet mask
	Gateway       tcpip.Address     // client default gateway
	DNS           []tcpip.Address   // client DNS server addresses
	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, c conn, 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