diff options
author | Dmitrii Okunev <xaionaro@fb.com> | 2019-11-28 12:10:49 +0000 |
---|---|---|
committer | Dmitrii Okunev <xaionaro@fb.com> | 2019-11-28 12:10:49 +0000 |
commit | 92b156c5580501ec2a4e8a504edbc3db55d7df82 (patch) | |
tree | 3161f6119c58160b89a324804c39ede08784c51c /dhcpv4/nclient4/conn_linux.go | |
parent | ec0e0154d15c429b3dcc56af60a2d7b62eb3d5e7 (diff) |
Simplified porting from client4 to nclient4
Signed-off-by: Dmitrii Okunev <xaionaro@fb.com>
Diffstat (limited to 'dhcpv4/nclient4/conn_linux.go')
-rw-r--r-- | dhcpv4/nclient4/conn_linux.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/dhcpv4/nclient4/conn_linux.go b/dhcpv4/nclient4/conn_linux.go index 064e6ca..1d0ec3a 100644 --- a/dhcpv4/nclient4/conn_linux.go +++ b/dhcpv4/nclient4/conn_linux.go @@ -7,7 +7,7 @@ package nclient4 import ( - "fmt" + "errors" "io" "net" @@ -23,6 +23,11 @@ var ( BroadcastMac = net.HardwareAddr([]byte{255, 255, 255, 255, 255, 255}) ) +var ( + // ErrUDPAddrIsRequired is an error used when a passed argument is not of type "*net.UDPAddr". + ErrUDPAddrIsRequired = errors.New("must supply UDPAddr") +) + // NewRawUDPConn returns a UDP connection bound to the interface and port // given based on a raw packet socket. All packets are broadcasted. // @@ -127,7 +132,7 @@ func (upc *BroadcastRawUDPConn) ReadFrom(b []byte) (int, net.Addr, error) { func (upc *BroadcastRawUDPConn) WriteTo(b []byte, addr net.Addr) (int, error) { udpAddr, ok := addr.(*net.UDPAddr) if !ok { - return 0, fmt.Errorf("must supply UDPAddr") + return 0, ErrUDPAddrIsRequired } // Using the boundAddr is not quite right here, but it works. |