summaryrefslogtreecommitdiff
path: root/Kernel/Net/LocalSocket.h
AgeCommit message (Collapse)Author
2020-02-25AK: Make Vector use size_t for its size and capacityAndreas Kling
2020-02-16Kernel: More header dependency reduction workAndreas Kling
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
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-26Kernel: Zero-initialize LocalSocket::m_addressAndreas Kling
It was possible to read uninitialized kernel memory via getsockname(). Of course, kmalloc() is a good boy and scrubs new allocations with 0xBB so all you got was a bunch of 0xBB.
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.
2020-01-04Kernel: Make LocalSocket pre-bind GID be gid_t (#1012)erf
2020-01-03Kernel: Allow fchmod() and fchown() on pre-bind() local socketsAndreas Kling
In order to ensure a specific owner and mode when the local socket filesystem endpoint is instantiated, we need to be able to call fchmod() and fchown() on a socket fd between socket() and bind(). This is because until we call bind(), there is no filesystem inode for the socket yet.
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-12-01Kernel+SystemMonitor: Log amounts of I/O per threadAndreas Kling
This patch adds these I/O counters to each thread: - (Inode) file read bytes - (Inode) file write bytes - Unix socket read bytes - Unix socket write bytes - IPv4 socket read bytes - IPv4 socket write bytes These are then exposed in /proc/all and seen in SystemMonitor.
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-22LocalSocket: Teach recvfrom() how to block if needed, and simplify itAndreas Kling
If we can't already read when we enter recvfrom() on a LocalSocket, we'll now block the current thread until we can. Also added a buffer_for(FileDescription&) helper so that the client and server can share some of the code. :^)
2019-08-11Kernel: Customize absolute_path() for more file typesSergey Bugaev
2019-08-11Net: Store all the LocalSockets in an InlineLinkedListSergey Bugaev
2019-08-11Net: Add LocalSocket::socket_path()Sergey Bugaev
This is a little utility function to safely extract the path without manually dealing with sun_path and null-termination.
2019-08-11Net: Override LocalSocket::class_name()Sergey Bugaev
2019-08-11Kernel: Move socket role tracking to the Socket class itselfSergey Bugaev
This is more logical and allows us to solve the problem of non-blocking TCP sockets getting stuck in SocketRole::None. The only complication is that a single LocalSocket may be shared between two file descriptions (on the connect and accept sides), and should have two different roles depending from which side you look at it. To deal with it, Socket::role() is made a virtual method that accepts a file description, and LocalSocket internally tracks which FileDescription is the which one and returns a correct role.
2019-08-11Net: Simplify how LocalSocket tracks open fdsSergey Bugaev
Now that there can't be multiple clones of the same fd, we only need to track whether or not an fd exists on each side. Also there's no point in tracking connecting fds.
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-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-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-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-20LocalSocket: Fix mismatch between can_write() and write() logic.Andreas Kling
can_write() was saying yes in situations where write() would overflow the internal buffer. This patch adds a has_attached_peer() helper to make it easier to understand what's going on in these functions.
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