Send broadcast on each LAN interfaces on FreeBSD

On FreeBSD 12 or later, a new routing strategy is introduced, which
prevents broadcast using 255.255.255.255.
Thus, we need to explicitly send the broadcast to each network 
interfaces.
Here the commit can simply reuse the code for Windows.

Ref: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252596
This commit is contained in:
Weixuan Xiao 2022-07-19 10:14:35 +00:00
parent 182fd5f279
commit e468759df4

View file

@ -173,8 +173,8 @@ void LanLinkProvider::broadcastToNetwork()
} }
#endif #endif
#ifdef Q_OS_WIN #if defined(Q_OS_WIN) || defined(Q_OS_FREEBSD)
//On Windows we need to broadcast from every local IP address to reach all networks //On Windows and FreeBSD we need to broadcast from every local IP address to reach all networks
QUdpSocket sendSocket; QUdpSocket sendSocket;
sendSocket.setProxy(QNetworkProxy::NoProxy); sendSocket.setProxy(QNetworkProxy::NoProxy);
for (const QNetworkInterface& iface : QNetworkInterface::allInterfaces()) { for (const QNetworkInterface& iface : QNetworkInterface::allInterfaces()) {