da86620288
Merge in DNS/adguard-home from 3443-dhcp-broadcast-vol.2 to master
Closes #3443.
Squashed commit of the following:
commit a85af89cb43f2489126fe3c12366fc034e89f59d
Merge: 72eb3a88 a4e07827
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date: Thu Sep 30 18:08:19 2021 +0300
Merge branch 'master' into 3443-dhcp-broadcast-vol.2
commit 72eb3a8853540b06ee1096decf50e836b539fe45
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date: Thu Sep 30 18:03:19 2021 +0300
dhcpd: imp code readability
commit 2d1fbc40d04a4125855d6be9f02e09d15430150d
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date: Thu Sep 30 14:16:59 2021 +0300
dhcpd: imp tests
commit 889fad3084ad2b81edfc12100e2ce29d323227ba
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date: Wed Sep 29 20:09:25 2021 +0300
dhcpd: imp code, docs
commit 1fd6b2346ff66e033bceaa169aed751be5822ca8
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date: Thu Sep 23 16:08:18 2021 +0300
dhcpd: unicast to mac address
22 lines
689 B
Go
22 lines
689 B
Go
//go:build freebsd || openbsd
|
|
// +build freebsd openbsd
|
|
|
|
package dhcpd
|
|
|
|
import (
|
|
"net"
|
|
)
|
|
|
|
// broadcast sends resp to the broadcast address specific for network interface.
|
|
func (c *dhcpConn) broadcast(respData []byte, peer *net.UDPAddr) (n int, err error) {
|
|
// Despite the fact that server4.NewIPv4UDPConn explicitly sets socket
|
|
// options to allow broadcasting, it also binds the connection to a
|
|
// specific interface. On FreeBSD and OpenBSD net.UDPConn.WriteTo
|
|
// causes errors while writing to the addresses that belong to another
|
|
// interface. So, use the broadcast address specific for the interface
|
|
// bound.
|
|
peer.IP = c.bcastIP
|
|
|
|
return c.udpConn.WriteTo(respData, peer)
|
|
}
|