mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:12:45 +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:
		
							parent
							
								
									8b2beb2ebe
								
							
						
					
					
						commit
						545f4b6cc1
					
				
					 7 changed files with 36 additions and 6 deletions
				
			
		|  | @ -211,9 +211,10 @@ ErrorOr<size_t> IPv4Socket::sendto(OpenFileDescription&, UserOrKernelBuffer cons | |||
|     if (!is_connected() && m_peer_address.is_zero()) | ||||
|         return set_so_error(EPIPE); | ||||
| 
 | ||||
|     auto allow_broadcast = m_broadcast_allowed ? AllowBroadcast::Yes : AllowBroadcast::No; | ||||
|     auto allow_using_gateway = ((flags & MSG_DONTROUTE) || m_routing_disabled) ? AllowUsingGateway::No : AllowUsingGateway::Yes; | ||||
|     auto adapter = bound_interface().with([](auto& bound_device) -> RefPtr<NetworkAdapter> { return bound_device; }); | ||||
|     auto routing_decision = route_to(m_peer_address, m_local_address, adapter, allow_using_gateway); | ||||
|     auto routing_decision = route_to(m_peer_address, m_local_address, adapter, allow_broadcast, allow_using_gateway); | ||||
|     if (routing_decision.is_zero()) | ||||
|         return set_so_error(EHOSTUNREACH); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Idan Horowitz
						Idan Horowitz