summaryrefslogtreecommitdiff
path: root/Kernel/Net/IPv4Socket.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-05-23Kernel: Use a FlatPtr for the "argument" to ioctl()Andreas Kling
Since it's often used to pass pointers, it should really be a FlatPtr.
2020-04-10Kernel: Add explicit offset parameter to File::read etcConrad Pankoff
2020-02-25AK: Make Vector use size_t for its size and capacityAndreas Kling
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-02-08IPv4: Sockets should say can_read() after reading is shut downAndreas Kling
This allows clients to get their EOF after shutting down reading.
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: Split IPv4Socket::recvfrom() into packet/byte buffered functionsAndreas Kling
This code was really hard to follow since it handles two separate modes of buffering the data.
2020-02-07Kernel: Truncate addresses stored by getsockname() and getpeername()Andreas Kling
If there's not enough space in the output buffer for the whole sockaddr we now simply truncate the address instead of returning EINVAL. This patch also makes getpeername() actually return the peer address rather than the local address.. :^)
2020-01-29Kernel: Make IPv4Socket::protocol_send() use a size_t for buffer sizeAndreas Kling
2020-01-23Kernel: Allow Socket subclasses to fail constructionAndreas Kling
For example, socket(AF_INET) should only succeed for valid SOCK_TYPEs.
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-12-14IPv4: Only buffer payload bytes for SOCK_STREAM socketsAndreas Kling
Since stream sockets don't actually need to deliver packets-at-a-time data in recvfrom(), they can just buffer the payload bytes instead. This avoids keeping one KBuffer per incoming packet in the receive queue, which was a big performance issue in ProtocolServer. This code is definitely not perfect and is something we should keep improving over time.
2019-12-06Kernel: Add getsockopt(SO_PEERCRED) for local socketsAndreas Kling
This sockopt gives you a struct with the PID, UID and GID of a socket's peer process.
2019-11-04Kernel: Make File's can_read/can_write take a const FileDescription&Andreas Kling
Asking a File if we could possibly read or write it will never mutate the asking FileDescription&, so it should be const.
2019-09-23IPv4: Implement socket ioctls SIOCGIFADDR and SIOCSIFADDRAndreas Kling
This allows userspace programs to get and set (superuser-only) the IPv4 address of a network adapter. :^)
2019-09-19IPv4: Support overriding the default TTL (64)Andreas Kling
Made getsockopt() and setsockopt() virtual so we can handle them in the various Socket subclasses. The subclasses map kinda nicely to "levels". This will allow us to implement things like "traceroute", although.. I spent some time trying to do that, but then hit a wall when it turned out that the user-mode networking in QEMU doesn't preserve TTL in the ICMP packets passing through.
2019-08-11Kernel: Customize absolute_path() for more file typesSergey Bugaev
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: Support binding to INADDR_ANY (all IPs)Conrad Pankoff
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-05Kernel: Make KBuffer a value-type wrapper around a KBufferImplAndreas Kling
A KBuffer always contains a valid KBufferImpl. If you need a "null" state buffer, use Optional<KBuffer>. This makes KBuffer very easy to work with and pass around, just like ByteBuffer before it.
2019-08-05Net: Let Socket have read/write wrappers around sendto/recvfromAndreas Kling
The situations in IPv4Socket and LocalSocket were mirrors of each other where one had implemented read/write as wrappers and the other had sendto/recvfrom as wrappers. Instead of this silliness, move read and write up to the Socket base. Then mark them final, so subclasses have no choice but to implement sendto and recvfrom.
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-08-04Kernel: Remove more unused members of IPv4Socket.Andreas Kling
I thought I had included these in the previous commit, but it turns out I hadn't, duh.
2019-08-04Kernel: Remove a bunch of unused members in IPv4Socket.Andreas Kling
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-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-20Kernel: Add getpeername() syscall, and fix getsockname() behavior.Andreas Kling
We were copying the raw IPv4 addresses into the wrong part of sockaddr_in, and we didn't set sa_family or sa_port.
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-04IPv4: Save the source address/port together with incoming packet payloads.Andreas Kling
We need the address/port to fill in the out-params in recvfrom(). It should now be more or less possible to create a UDP server. :^)
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-06Kernel: Move FIFO into FileSystem/ and Socket+LocalSocket into Net/.Andreas Kling
2019-04-02Kernel: Move networking related files into Kernel/Net/.Andreas Kling