- func MakeBroadcastSocket(ifname string) (int, error)
- func MakeListeningSocket(ifname string) (int, error)
- func MakeRawUDPPacket(payload byte, serverAddr, clientAddr net.UDPAddr) (byte, error)
- type Client
const ( MaxUDPReceivedPacketSize = 8192 )
MaxUDPReceivedPacketSize is the (arbitrary) maximum UDP packet size supported by this library. Theoretically could be up to 65kb.
func MakeBroadcastSocket ¶
MakeBroadcastSocket creates a socket that can be passed to unix.Sendto that will send packets out to the broadcast address.
func MakeListeningSocket ¶
MakeListeningSocket creates a listening socket on 0.0.0.0 for the DHCP client port and returns it.
Client is the object that actually performs the DHCP exchange. It currently only has read and write timeout values, plus (optional) local and remote addresses.
func NewClient() *Client
NewClient generates a new client to perform a DHCP exchange with, setting the read and write timeout fields to defaults.
Exchange runs a full DORA transaction: Discover, Offer, Request, Acknowledge, over UDP. Does not retry in case of failures. Returns a list of DHCPv4 structures representing the exchange. It can contain up to four elements, ordered as Discovery, Offer, Request and Acknowledge. In case of errors, an error is returned, and the list of DHCPv4 objects will be shorted than 4, containing all the sent and received DHCPv4 messages.
func (*Client) SendReceive ¶
SendReceive sends a packet (with some write timeout) and waits for a response up to some read timeout value. If the message type is not MessageTypeNone, it will wait for a specific message type