1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

Kernel: Properly support the SO_BROADCAST socket option

POSIX requires that broadcast sends will only be allowed if the
SO_BROADCAST socket option was set on the socket.
Also, broadcast sends to protocols that do not support broadcast (like
TCP), should always fail.
This commit is contained in:
Idan Horowitz 2023-12-24 19:01:09 +02:00 committed by Andreas Kling
parent 8b2beb2ebe
commit 545f4b6cc1
7 changed files with 36 additions and 6 deletions

View file

@ -49,6 +49,11 @@ static bool send(InterfaceDescriptor const& iface, DHCPv4Packet const& packet, C
dbgln("ERROR: setsockopt(SO_BINDTODEVICE) :: {}", strerror(errno));
return false;
}
int allow_broadcast = 1;
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &allow_broadcast, sizeof(int)) < 0) {
dbgln("ERROR: setsockopt(SO_BROADCAST) :: {}", strerror(errno));
return false;
}
sockaddr_in dst;
memset(&dst, 0, sizeof(dst));