mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 07:02:44 +00:00 
			
		
		
		
	Kernel: Use KResult a bit more in the IPv4 networking code
This commit is contained in:
		
							parent
							
								
									b00799b9ce
								
							
						
					
					
						commit
						9984201634
					
				
					 7 changed files with 23 additions and 21 deletions
				
			
		|  | @ -184,7 +184,7 @@ KResultOr<size_t> TCPSocket::protocol_send(const UserOrKernelBuffer& data, size_ | |||
|     return data_length; | ||||
| } | ||||
| 
 | ||||
| int TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload, size_t payload_size) | ||||
| KResult TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload, size_t payload_size) | ||||
| { | ||||
|     const size_t buffer_size = sizeof(TCPPacket) + payload_size; | ||||
|     alignas(TCPPacket) u8 buffer[buffer_size]; | ||||
|  | @ -202,7 +202,7 @@ int TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload, siz | |||
|         tcp_packet.set_ack_number(m_ack_number); | ||||
| 
 | ||||
|     if (payload && !payload->read(tcp_packet.payload(), payload_size)) | ||||
|         return -EFAULT; | ||||
|         return EFAULT; | ||||
| 
 | ||||
|     if (flags & TCPFlags::SYN) { | ||||
|         ++m_sequence_number; | ||||
|  | @ -216,22 +216,22 @@ int TCPSocket::send_tcp_packet(u16 flags, const UserOrKernelBuffer* payload, siz | |||
|         LOCKER(m_not_acked_lock); | ||||
|         m_not_acked.append({ m_sequence_number, ByteBuffer::copy(buffer, buffer_size) }); | ||||
|         send_outgoing_packets(); | ||||
|         return 0; | ||||
|         return KSuccess; | ||||
|     } | ||||
| 
 | ||||
|     auto routing_decision = route_to(peer_address(), local_address(), bound_interface()); | ||||
|     ASSERT(!routing_decision.is_zero()); | ||||
| 
 | ||||
|     auto packet_buffer = UserOrKernelBuffer::for_kernel_buffer(buffer); | ||||
|     int err = routing_decision.adapter->send_ipv4( | ||||
|     auto result = routing_decision.adapter->send_ipv4( | ||||
|         routing_decision.next_hop, peer_address(), IPv4Protocol::TCP, | ||||
|         packet_buffer, buffer_size, ttl()); | ||||
|     if (err < 0) | ||||
|         return err; | ||||
|     if (result.is_error()) | ||||
|         return result; | ||||
| 
 | ||||
|     m_packets_out++; | ||||
|     m_bytes_out += buffer_size; | ||||
|     return 0; | ||||
|     return KSuccess; | ||||
| } | ||||
| 
 | ||||
| void TCPSocket::send_outgoing_packets() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling