2021-09-07 18:33:23 +03:00
|
|
|
//go:build freebsd || openbsd
|
|
|
|
|
|
|
|
package dhcpd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
|
|
|
// broadcast sends resp to the broadcast address specific for network interface.
|
2021-09-30 18:28:19 +03:00
|
|
|
func (c *dhcpConn) broadcast(respData []byte, peer *net.UDPAddr) (n int, err error) {
|
2021-09-07 18:33:23 +03:00
|
|
|
// Despite the fact that server4.NewIPv4UDPConn explicitly sets socket
|
2022-09-13 23:45:35 +03:00
|
|
|
// 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.
|
2021-09-30 18:28:19 +03:00
|
|
|
peer.IP = c.bcastIP
|
2021-09-07 18:33:23 +03:00
|
|
|
|
2021-09-30 18:28:19 +03:00
|
|
|
return c.udpConn.WriteTo(respData, peer)
|
2021-09-07 18:33:23 +03:00
|
|
|
}
|