summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrea Barberio <insomniac@slackware.it>2018-03-10 22:02:16 +0000
committerinsomniac <insomniacslk@users.noreply.github.com>2018-03-10 22:11:04 +0000
commit7194d354e6b511c0af20bed1147347089da7315e (patch)
treef9ccf94573f2ca0e43784aabba73772d9767c018
parentabdd176f80b47882b4fb6982c035471ced6e50fd (diff)
dhcpv4: fix client regression
-rw-r--r--dhcpv4/client.go12
1 files changed, 3 insertions, 9 deletions
diff --git a/dhcpv4/client.go b/dhcpv4/client.go
index 2962fc5..0e379ba 100644
--- a/dhcpv4/client.go
+++ b/dhcpv4/client.go
@@ -17,14 +17,6 @@ const (
)
var (
- // BroadcastAddressBytes are the bytes representing net.IPv4bcast.
- BroadcastAddressBytes = [4]byte{
- net.IPv4bcast[0],
- net.IPv4bcast[1],
- net.IPv4bcast[2],
- net.IPv4bcast[3],
- }
-
// DefaultReadTimeout is the time to wait after listening in which the
// exchange is considered failed.
DefaultReadTimeout = 3 * time.Second
@@ -160,7 +152,9 @@ func BroadcastSendReceive(fd int, packet *DHCPv4, readTimeout, writeTimeout time
// Create a goroutine to perform the blocking send, and time it out after
// a certain amount of time.
- remoteAddr := syscall.SockaddrInet4{Port: ClientPort, Addr: BroadcastAddressBytes}
+ var destination [4]byte
+ copy(destination[:], net.IPv4bcast.To4())
+ remoteAddr := syscall.SockaddrInet4{Port: ClientPort, Addr: destination}
sendErrChan := make(chan error, 1)
go func() { sendErrChan <- syscall.Sendto(fd, packetBytes, 0, &remoteAddr) }()