diff options
author | Sean Karlage <skarlage@fb.com> | 2018-03-04 10:59:15 -0800 |
---|---|---|
committer | Sean Karlage <skarlage@fb.com> | 2018-03-05 15:08:56 -0800 |
commit | 6491fc7ec777dbdfdfe05365c85878bb6e4d691d (patch) | |
tree | 0de605d9df238a604272afa31e1831fc1cc7eee2 /dhcpv4/client.go | |
parent | 6cfb183f6e3c8496a80aad03b8f47423eeac1123 (diff) |
Move bsdp functionality to its own subpackage. Bring in stretchr/testify/assert for nicer asserts
Diffstat (limited to 'dhcpv4/client.go')
-rw-r--r-- | dhcpv4/client.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/dhcpv4/client.go b/dhcpv4/client.go index ef2af4e..3d91b84 100644 --- a/dhcpv4/client.go +++ b/dhcpv4/client.go @@ -10,7 +10,7 @@ import ( ) const ( - maxUDPReceivedPacketSize = 8192 // arbitrary size. Theoretically could be up to 65kb + MaxUDPReceivedPacketSize = 8192 // arbitrary size. Theoretically could be up to 65kb ) type Client struct { @@ -19,7 +19,7 @@ type Client struct { Timeout time.Duration } -func makeRawBroadcastPacket(payload []byte) ([]byte, error) { +func MakeRawBroadcastPacket(payload []byte) ([]byte, error) { udp := make([]byte, 8) binary.BigEndian.PutUint16(udp[:2], ClientPort) binary.BigEndian.PutUint16(udp[2:4], ServerPort) @@ -82,7 +82,7 @@ func (c *Client) Exchange(ifname string, d *DHCPv4) ([]DHCPv4, error) { } daddr := syscall.SockaddrInet4{Port: ClientPort, Addr: [4]byte{255, 255, 255, 255}} - packet, err := makeRawBroadcastPacket(d.ToBytes()) + packet, err := MakeRawBroadcastPacket(d.ToBytes()) if err != nil { return conversation, err } @@ -98,7 +98,7 @@ func (c *Client) Exchange(ifname string, d *DHCPv4) ([]DHCPv4, error) { } defer conn.Close() - buf := make([]byte, maxUDPReceivedPacketSize) + buf := make([]byte, MaxUDPReceivedPacketSize) oobdata := []byte{} // ignoring oob data n, _, _, _, err := conn.ReadMsgUDP(buf, oobdata) offer, err := FromBytes(buf[:n]) @@ -115,7 +115,7 @@ func (c *Client) Exchange(ifname string, d *DHCPv4) ([]DHCPv4, error) { return conversation, err } conversation = append(conversation, *request) - packet, err = makeRawBroadcastPacket(request.ToBytes()) + packet, err = MakeRawBroadcastPacket(request.ToBytes()) if err != nil { return conversation, err } @@ -125,7 +125,7 @@ func (c *Client) Exchange(ifname string, d *DHCPv4) ([]DHCPv4, error) { } // Acknowledge - buf = make([]byte, maxUDPReceivedPacketSize) + buf = make([]byte, MaxUDPReceivedPacketSize) n, _, _, _, err = conn.ReadMsgUDP(buf, oobdata) acknowledge, err := FromBytes(buf[:n]) if err != nil { |