summaryrefslogtreecommitdiff
path: root/Kernel/Net/TCPSocket.h
AgeCommit message (Collapse)Author
2020-06-02Kernel: Allow File::close() to failSergey Bugaev
And pass the result through to sys$close() return value. Fixes https://github.com/SerenityOS/serenity/issues/427
2020-04-18Kernel: Use shared locking mode in some placesSergey Bugaev
The notable piece of code that remains to be converted is Ext2FS.
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-02-08IPv4: Basic implementation of TCP socket shutdownAndreas Kling
We can now participate in the TCP connection closing handshake. :^) This implementation is definitely not complete and needs to handle a bunch of other cases. But it's a huge improvement over not being able to close connections at all. Note that we hold on to pending-close sockets indefinitely, until they are moved into the Closed state. This should also have a timeout but that's still a FIXME. :^) Fixes #428.
2020-02-08IPv4: Send TCP packets right away instead of waiting to "retry"Andreas Kling
Also be more explicit about zero-initializing OutgoingPacket objects.
2020-02-08Net: Make NetworkAdapter reference-countedAndreas Kling
The idea behind WeakPtr<NetworkAdapter> was to support hot-pluggable network adapters, but on closer thought, that's super impractical so let's not go down that road.
2020-01-29Kernel: Make IPv4Socket::protocol_send() use a size_t for buffer sizeAndreas Kling
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-11-23IPv4: Protect the list of unacked TCP packets with a lockAndreas Kling
Otherwise things get racy and crashy.
2019-09-08Kernel: Use a WeakPtr instead of a RefPtr for TCP socket originatorConrad Pankoff
2019-09-08Kernel: Implement outgoing TCP retransmission and better ACK handlingConrad Pankoff
This approach is a bit naiive - whenever we send a packet out, we check to see if there are any other packets we should try to send. This works well enough for a busy connection but not very well for a quiet one. Ideally we would check for not-acked packets on some kind of timer, and use the length of this not-acked list as feedback to throttle the writes coming from userspace.
2019-09-08Kernel: Hold socket back from accept() until it's fully set upConrad Pankoff
2019-09-08Kernel: Use RefPtr instead of SocketHandle for TCPSocket clientsConrad Pankoff
Using a SocketHandle takes a lock on the socket, which we don't want to do.
2019-08-10Kernel: Detect some outgoing TCP connection failuresConrad Pankoff
2019-08-10Kernel: Move TCP state logging into TCPSocketConrad Pankoff
2019-08-09Kernel: Make TCPSocket::for_each() callback accept a referenceSergey Bugaev
Yay for less arrows!
2019-08-09Kernel: Merge FooSocketHandle classes into a single SocketHandle<Foo>Andreas Kling
- IPv4SocketHandle => SocketHandle<IPv4Socket> - TCPSocketHandle => SocketHandle<TCPSocket> - UDPSocketHandle => SocketHandle<UDPSocket>
2019-08-09Kernel: Implement TCP listening sockets and incoming connectionsConrad Pankoff
2019-08-09Kernel: Use WeakPtr<NetworkAdapter> instead of NetworkAdapter* in net codeConrad Pankoff
2019-08-08Kernel: Record network statistics and expose as JSONConrad Pankoff
This is comprised of five small changes: * Keep a counter for tx/rx packets/bytes per TCP socket * Keep a counter for tx/rx packets/bytes per network adapter * Expose that data in /proc/net_tcp and /proc/netadapters * Convert /proc/netadapters to JSON * Fix up ifconfig to read the JSON from netadapters
2019-08-06Kernel: Refactor TCP/IP stackConrad Pankoff
This has several significant changes to the networking stack. * Significant refactoring of the TCP state machine. Right now it's probably more fragile than it used to be, but handles quite a lot more of the handshake process. * `TCPSocket` holds a `NetworkAdapter*`, assigned during `connect()` or `bind()`, whichever comes first. * `listen()` is now virtual in `Socket` and intended to be implemented in its child classes * `listen()` no longer works without `bind()` - this is a bit of a regression, but listening sockets didn't work at all before, so it's not possible to observe the regression. * A file is exposed at `/proc/net_tcp`, which is a JSON document listing the current TCP sockets with a bit of metadata. * There's an `ETHERNET_VERY_DEBUG` flag for dumping packet's content out to `kprintf`. It is, indeed, _very debug_.
2019-08-04IPv4: Use KBuffer instead of ByteBuffer for socket receive queuesAndreas Kling
This drastically reduces the pressure on the kernel heap when receiving data from IPv4 sockets.
2019-07-03AK: Rename the common integer typedefs to make it obvious what they are.Andreas Kling
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
2019-06-22Kernel: Fix all compiler warnings.Andreas Kling
2019-06-21AK: Rename RetainPtr => RefPtr and Retained => NonnullRefPtr.Andreas Kling
2019-06-07Meta: Tweak .clang-format to not wrap braces after enums.Andreas Kling
2019-06-07Kernel: Rename FileDescriptor to FileDescription.Andreas Kling
After reading a bunch of POSIX specs, I've learned that a file descriptor is the number that refers to a file description, not the description itself. So this patch renames FileDescriptor to FileDescription, and Process now has FileDescription* file_description(int fd).
2019-05-28Add clang-format fileRobin Burchell
Also run it across the whole tree to get everything using the One True Style. We don't yet run this in an automated fashion as it's a little slow, but there is a snippet to do so in makeall.sh.
2019-05-04IPv4: Rename source/destination in socket classes to local/peer.Andreas Kling
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.
2019-05-03IPv4: Implement bind() for TCP and UDP sockets.Andreas Kling
We can't accept connections just yet, but this patch makes it possible to bind() to a given source address/port.
2019-05-03Kernel: Make Socket inherit from File.Andreas Kling
2019-05-03Kernel: Prepare Socket for becoming a File.Andreas Kling
Make the Socket functions take a FileDescriptor& rather than a socket role throughout the code. Also change threads to block on a FileDescriptor, rather than either an fd index or a Socket.
2019-04-08Kernel: Support non-blocking connect().Andreas Kling
If connect() is called on a non-blocking socket, it will "fail" immediately with -EINPROGRESS. After that, you select() on the socket and wait for it to become writable.
2019-04-02Kernel: Move networking related files into Kernel/Net/.Andreas Kling