diff options
author | asynts <asynts@gmail.com> | 2020-08-15 18:38:24 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-15 21:21:18 +0200 |
commit | fff581cd725db6b9cc1e1fd25503c68ec2d044d3 (patch) | |
tree | 0c0a510f5cbd1c2c6c1613b11209655624eda893 /Kernel/Net | |
parent | 525d51bbb526912946c491e502b57cf439ab3906 (diff) | |
download | serenity-fff581cd725db6b9cc1e1fd25503c68ec2d044d3.zip |
AK: Rename span() to bytes() when appropriate.
I originally defined the bytes() method for the String class, because it
made it obvious that it's a span of bytes instead of span of characters.
This commit makes this more consistent by defining a bytes() method when
the type of the span is known to be u8.
Additionaly, the cast operator to Bytes is overloaded for ByteBuffer and
such.
Diffstat (limited to 'Kernel/Net')
-rw-r--r-- | Kernel/Net/NetworkTask.cpp | 2 | ||||
-rw-r--r-- | Kernel/Net/TCPSocket.cpp | 4 | ||||
-rw-r--r-- | Kernel/Net/UDPSocket.cpp | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index e88440344e..9fd05286e2 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -285,7 +285,7 @@ void handle_icmp(const EthernetFrameHeader& eth, const IPv4Packet& ipv4_packet) memcpy(response.payload(), request.payload(), icmp_payload_size); response.header.set_checksum(internet_checksum(&response, icmp_packet_size)); // FIXME: What is the right TTL value here? Is 64 ok? Should we use the same TTL as the echo request? - adapter->send_ipv4(eth.source(), ipv4_packet.source(), IPv4Protocol::ICMP, buffer.span(), 64); + adapter->send_ipv4(eth.source(), ipv4_packet.source(), IPv4Protocol::ICMP, buffer, 64); } } diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 58a41f12d7..cafe48370e 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -218,7 +218,7 @@ void TCPSocket::send_tcp_packet(u16 flags, const void* payload, size_t payload_s routing_decision.adapter->send_ipv4( routing_decision.next_hop, peer_address(), IPv4Protocol::TCP, - buffer.span(), ttl()); + buffer, ttl()); m_packets_out++; m_bytes_out += buffer.size(); @@ -246,7 +246,7 @@ void TCPSocket::send_outgoing_packets() #endif routing_decision.adapter->send_ipv4( routing_decision.next_hop, peer_address(), IPv4Protocol::TCP, - packet.buffer.span(), ttl()); + packet.buffer, ttl()); m_packets_out++; m_bytes_out += packet.buffer.size(); diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp index 2803ec9315..65091a37c1 100644 --- a/Kernel/Net/UDPSocket.cpp +++ b/Kernel/Net/UDPSocket.cpp @@ -102,7 +102,7 @@ KResultOr<size_t> UDPSocket::protocol_send(const void* data, size_t data_length) udp_packet.set_length(sizeof(UDPPacket) + data_length); memcpy(udp_packet.payload(), data, data_length); klog() << "sending as udp packet from " << routing_decision.adapter->ipv4_address().to_string().characters() << ":" << local_port() << " to " << peer_address().to_string().characters() << ":" << peer_port() << "!"; - routing_decision.adapter->send_ipv4(routing_decision.next_hop, peer_address(), IPv4Protocol::UDP, buffer.span(), ttl()); + routing_decision.adapter->send_ipv4(routing_decision.next_hop, peer_address(), IPv4Protocol::UDP, buffer, ttl()); return data_length; } |