dhclient

package
v0.0.0-...-7eb602e Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2018 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package dhclient provides a unified interface for interfacing with both DHCPv4 and DHCPv6 clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandlePacket

func HandlePacket(iface netlink.Link, packet Packet) error

HandlePacket adds IP addresses, routes, and DNS servers to the system.

func IfUp

func IfUp(ifname string) (netlink.Link, error)

IfUp ensures the given network interface is up and returns the link object.

Types

type Client

type Client interface {
	// Solicit solicits a new DHCP lease.
	Solicit() (Packet, error)

	// Renew renews an existing DHCP lease.
	Renew(p Packet) (Packet, error)
}

Client is a DHCP client.

type Client4

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

Client4 implements Client for DHCPv4.

func NewV4

func NewV4(iface netlink.Link, timeout time.Duration, retry int) (*Client4, error)

NewV4 implements a new DHCPv4 client.

func (*Client4) Renew

func (c *Client4) Renew(p Packet) (Packet, error)

Renew implements Client.Renew.

func (*Client4) Solicit

func (c *Client4) Solicit() (Packet, error)

Solicit implements Client.Solicit.

type Lease

type Lease struct {
	IPNet             *net.IPNet
	PreferredLifetime time.Duration
	ValidLifetime     time.Duration
}

Lease is a DHCP lease.

type Packet

type Packet interface {
	IPs() []net.IP

	// Leases are the leases returned by the DHCP server if specified,
	// otherwise nil.
	Leases() []Lease

	// Gateway is the gateway server, if specified, otherwise nil.
	Gateway() net.IP

	// DNS are DNS server addresses, if specified, otherwise nil.
	DNS() []net.IP

	// Boot returns the boot URI and boot parameters if specified,
	// otherwise an error.
	Boot() (url.URL, string, error)
}

Packet is a DHCP packet.

type Packet4

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

Packet4 implements Packet for IPv4 DHCP.

func (*Packet4) Boot

func (p *Packet4) Boot() (url.URL, string, error)

Boot implements Packet.Boot.

func (*Packet4) DNS

func (p *Packet4) DNS() []net.IP

DNS implements Packet.DNS.

func (*Packet4) Gateway

func (p *Packet4) Gateway() net.IP

Gateway implements Packet.Gateway.

OptionRouter is used as opposed to GIAddr, which seems unused by most DHCP servers?

func (*Packet4) IPs

func (p *Packet4) IPs() []net.IP

IPs implements Packet.IPs.

func (*Packet4) Leases

func (p *Packet4) Leases() []Lease

Leases implements Packet.Leases.

DHCPv4 only returns one lease at a time.

Jump to

Keyboard shortcuts

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