diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2023-12-04 10:33:34 +0000 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2023-12-06 07:48:09 +0100 |
commit | 8c70d406f6d24a17219a5f543174c1f3f3ad9e35 (patch) | |
tree | 7f9acc8e465b9b354dea197f1d77698370e648ab /dhcpv4/bsdp/client.go | |
parent | b0416c0f187a65a350b32d34fc31ea30f06c12ce (diff) |
Diffstat (limited to 'dhcpv4/bsdp/client.go')
-rw-r--r-- | dhcpv4/bsdp/client.go | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/dhcpv4/bsdp/client.go b/dhcpv4/bsdp/client.go deleted file mode 100644 index 5d0e667..0000000 --- a/dhcpv4/bsdp/client.go +++ /dev/null @@ -1,75 +0,0 @@ -package bsdp - -import ( - "errors" - - "github.com/insomniacslk/dhcp/dhcpv4" - "github.com/insomniacslk/dhcp/dhcpv4/client4" -) - -// Client represents a BSDP client that can perform BSDP exchanges via the -// broadcast address. -type Client struct { - client4.Client -} - -// NewClient constructs a new client with default read and write timeouts from -// dhcpv4.Client. -func NewClient() *Client { - return &Client{Client: client4.Client{}} -} - -// Exchange runs a full BSDP exchange (Inform[list], Ack, Inform[select], -// Ack). Returns a list of DHCPv4 structures representing the exchange. -func (c *Client) Exchange(ifname string) ([]*Packet, error) { - conversation := make([]*Packet, 0) - - // Get our file descriptor for the broadcast socket. - sendFd, err := client4.MakeBroadcastSocket(ifname) - if err != nil { - return conversation, err - } - recvFd, err := client4.MakeListeningSocket(ifname) - if err != nil { - return conversation, err - } - - // INFORM[LIST] - informList, err := NewInformListForInterface(ifname, dhcpv4.ClientPort) - if err != nil { - return conversation, err - } - conversation = append(conversation, informList) - - // ACK[LIST] - ackForList, err := c.Client.SendReceive(sendFd, recvFd, informList.v4(), dhcpv4.MessageTypeAck) - if err != nil { - return conversation, err - } - - // Rewrite vendor-specific option for pretty printing. - conversation = append(conversation, PacketFor(ackForList)) - - // Parse boot images sent back by server - bootImages, err := ParseBootImageListFromAck(ackForList) - if err != nil { - return conversation, err - } - if len(bootImages) == 0 { - return conversation, errors.New("got no BootImages from server") - } - - // INFORM[SELECT] - informSelect, err := InformSelectForAck(PacketFor(ackForList), dhcpv4.ClientPort, bootImages[0]) - if err != nil { - return conversation, err - } - conversation = append(conversation, informSelect) - - // ACK[SELECT] - ackForSelect, err := c.Client.SendReceive(sendFd, recvFd, informSelect.v4(), dhcpv4.MessageTypeAck) - if err != nil { - return conversation, err - } - return append(conversation, PacketFor(ackForSelect)), nil -} |