Skip to content

Commit 7a82634

Browse files
nicholas-shiNicholas Shi
andauthored
Add MacOS fix for serving DHCP IP broadcast (#1990)
* Add MacOS fix for serving DHCP IP broadcast * Remove setting socket options * Remove comment --------- Co-authored-by: Nicholas Shi <nicholas@Nicholass-MacBook-Pro.local>
1 parent c7d2dd4 commit 7a82634

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

DnsServerCore/Dhcp/DhcpServer.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,14 @@ private async Task ProcessDhcpRequestAsync(DhcpMessage request, IPEndPoint remot
261261
else
262262
udpSocket = udpListener; //no appropriate socket found so use default socket
263263

264-
await udpSocket.SendToAsync(new ArraySegment<byte>(sendBuffer, 0, (int)sendBufferStream.Position), SocketFlags.DontRoute, new IPEndPoint(IPAddress.Broadcast, 68)); //no routing for broadcast
264+
if (OperatingSystem.IsMacOS())
265+
{
266+
await udpSocket.SendToAsync(new ArraySegment<byte>(sendBuffer, 0, (int)sendBufferStream.Position), SocketFlags.None, new IPEndPoint(IPAddress.Broadcast, 68));
267+
}
268+
else
269+
{
270+
await udpSocket.SendToAsync(new ArraySegment<byte>(sendBuffer, 0, (int)sendBufferStream.Position), SocketFlags.DontRoute, new IPEndPoint(IPAddress.Broadcast, 68)); //no routing for broadcast
271+
}
265272
}
266273
}
267274
}

0 commit comments

Comments
 (0)