dhcp4client

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: MPL-2.0 Imports: 12 Imported by: 1

README

dhcp4client

Please use the v2 branch for all projects.

Documentation

Index

Constants

View Source
const (
	MaxDHCPLen = 576
)

Variables

This section is empty.

Functions

func Broadcast

func Broadcast(b bool) func(*Client) error

func Connection

func Connection(conn ConnectionInt) func(*Client) error

func CryptoGenerateXID

func CryptoGenerateXID(b []byte)

func GenerateXID

func GenerateXID(g func([]byte)) func(*Client) error

func HardwareAddr

func HardwareAddr(h net.HardwareAddr) func(*Client) error

func Hostname added in v1.1.0

func Hostname(hostname string) func(*Client) error

func IgnoreServers

func IgnoreServers(s []net.IP) func(*Client) error

func MathGenerateXID

func MathGenerateXID(b []byte)

func NewInetSock

func NewInetSock(options ...func(*inetSock) error) (*inetSock, error)

func NewPacketSock

func NewPacketSock(ifindex int) (*packetSock, error)

func SetLocalAddr

func SetLocalAddr(l net.UDPAddr) func(*inetSock) error

func SetRemoteAddr

func SetRemoteAddr(r net.UDPAddr) func(*inetSock) error

func Timeout

func Timeout(t time.Duration) func(*Client) error

Types

type Client

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

func New

func New(options ...func(*Client) error) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

Close Connections

func (*Client) DeclinePacket

func (c *Client) DeclinePacket(acknowledgement *dhcp4.Packet) dhcp4.Packet

Create Decline Packet

func (*Client) DiscoverPacket

func (c *Client) DiscoverPacket() dhcp4.Packet

Create Discover Packet

func (*Client) GetAcknowledgement

func (c *Client) GetAcknowledgement(requestPacket *dhcp4.Packet) (dhcp4.Packet, error)

Retreive Acknowledgement Wait for the offer for a specific Request Packet.

func (*Client) GetOffer

func (c *Client) GetOffer(discoverPacket *dhcp4.Packet) (dhcp4.Packet, error)

Retreive Offer... Wait for the offer for a specific Discovery Packet.

func (*Client) Release

func (c *Client) Release(acknowledgement dhcp4.Packet) error

Release a lease backed on the Acknowledgement Packet. Returns Any Errors

func (*Client) ReleasePacket

func (c *Client) ReleasePacket(acknowledgement *dhcp4.Packet) dhcp4.Packet

Create Release Packet For a Release

func (*Client) Renew

func (c *Client) Renew(acknowledgement dhcp4.Packet) (bool, dhcp4.Packet, error)

Renew a lease backed on the Acknowledgement Packet. Returns Sucessfull, The AcknoledgementPacket, Any Errors

func (*Client) RenewalRequestPacket

func (c *Client) RenewalRequestPacket(acknowledgement *dhcp4.Packet) dhcp4.Packet

Create Request Packet For a Renew

func (*Client) Request

func (c *Client) Request() (bool, dhcp4.Packet, error)

Lets do a Full DHCP Request.

func (*Client) RequestPacket

func (c *Client) RequestPacket(offerPacket *dhcp4.Packet) dhcp4.Packet

Create Request Packet

func (*Client) SendDecline

func (c *Client) SendDecline(acknowledgementPacket *dhcp4.Packet) (dhcp4.Packet, error)

Send Decline to the received acknowledgement.

func (*Client) SendDiscoverPacket

func (c *Client) SendDiscoverPacket() (dhcp4.Packet, error)

Send the Discovery Packet to the Broadcast Channel

func (*Client) SendPacket

func (c *Client) SendPacket(packet dhcp4.Packet) error

Send a DHCP Packet.

func (*Client) SendRequest

func (c *Client) SendRequest(offerPacket *dhcp4.Packet) (dhcp4.Packet, error)

Send Request Based On the offer Received.

func (*Client) SetOption

func (c *Client) SetOption(options ...func(*Client) error) error

type ConnectionInt

type ConnectionInt interface {
	Close() error
	Write(packet []byte) error
	ReadFrom() ([]byte, net.IP, error)
	SetReadTimeout(t time.Duration) error
}

Abstracts the type of underlying socket used

type TimeoutError

type TimeoutError struct {
	Timeout time.Duration
}

TimeoutError records a timeout when waiting for a DHCP packet.

func (*TimeoutError) Error

func (te *TimeoutError) Error() string

Jump to

Keyboard shortcuts

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