summaryrefslogtreecommitdiff
path: root/Kernel/Net/UDPSocket.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-04 16:40:34 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-04 16:40:34 +0200
commit5e938868a226cd9d2c2f2736c678f98618f345f5 (patch)
tree4cae733c660d5bab12b5b6d6018c13a080d60acb /Kernel/Net/UDPSocket.cpp
parent780d2a08c488e5e8a61f7508f7cc31f35bdf8b26 (diff)
downloadserenity-5e938868a226cd9d2c2f2736c678f98618f345f5.zip
IPv4: Rename source/destination in socket classes to local/peer.
It was way too ambiguous who's the source and who's the destination, and it didn't really follow a logical pattern. "Local port" vs "Peer port" is super obvious, so let's call it that.
Diffstat (limited to 'Kernel/Net/UDPSocket.cpp')
-rw-r--r--Kernel/Net/UDPSocket.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp
index 982bdd8606..ee3597e386 100644
--- a/Kernel/Net/UDPSocket.cpp
+++ b/Kernel/Net/UDPSocket.cpp
@@ -36,7 +36,7 @@ UDPSocket::UDPSocket(int protocol)
UDPSocket::~UDPSocket()
{
LOCKER(sockets_by_port().lock());
- sockets_by_port().resource().remove(source_port());
+ sockets_by_port().resource().remove(local_port());
}
Retained<UDPSocket> UDPSocket::create(int protocol)
@@ -59,25 +59,25 @@ int UDPSocket::protocol_receive(const ByteBuffer& packet_buffer, void* buffer, s
int UDPSocket::protocol_send(const void* data, int data_length)
{
- auto* adapter = adapter_for_route_to(destination_address());
+ auto* adapter = adapter_for_route_to(peer_address());
if (!adapter)
return -EHOSTUNREACH;
auto buffer = ByteBuffer::create_zeroed(sizeof(UDPPacket) + data_length);
auto& udp_packet = *(UDPPacket*)(buffer.pointer());
- udp_packet.set_source_port(source_port());
- udp_packet.set_destination_port(destination_port());
+ udp_packet.set_source_port(local_port());
+ udp_packet.set_destination_port(peer_port());
udp_packet.set_length(sizeof(UDPPacket) + data_length);
memcpy(udp_packet.payload(), data, data_length);
kprintf("sending as udp packet from %s:%u to %s:%u!\n",
adapter->ipv4_address().to_string().characters(),
- source_port(),
- destination_address().to_string().characters(),
- destination_port());
- adapter->send_ipv4(MACAddress(), destination_address(), IPv4Protocol::UDP, move(buffer));
+ local_port(),
+ peer_address().to_string().characters(),
+ peer_port());
+ adapter->send_ipv4(MACAddress(), peer_address(), IPv4Protocol::UDP, move(buffer));
return data_length;
}
-int UDPSocket::protocol_allocate_source_port()
+int UDPSocket::protocol_allocate_local_port()
{
static const word first_ephemeral_port = 32768;
static const word last_ephemeral_port = 60999;
@@ -88,7 +88,7 @@ int UDPSocket::protocol_allocate_source_port()
for (word port = first_scan_port;;) {
auto it = sockets_by_port().resource().find(port);
if (it == sockets_by_port().resource().end()) {
- set_source_port(port);
+ set_local_port(port);
sockets_by_port().resource().set(port, this);
return port;
}
@@ -104,8 +104,8 @@ int UDPSocket::protocol_allocate_source_port()
KResult UDPSocket::protocol_bind()
{
LOCKER(sockets_by_port().lock());
- if (sockets_by_port().resource().contains(source_port()))
+ if (sockets_by_port().resource().contains(local_port()))
return KResult(-EADDRINUSE);
- sockets_by_port().resource().set(source_port(), this);
+ sockets_by_port().resource().set(local_port(), this);
return KSuccess;
}