Commit Graph

52 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen 4379ca962a Add dhclient(8).
Co-authored-by: Juhani Krekelä <juhani@krekelä.fi>
2023-02-21 23:24:06 +01:00
Jonas 'Sortie' Termansen 2ef6804ead Add networking stack.
This change adds all the kernel parts of a network stack. The network stack
is partial but implements many of the important parts.

Add if(4) network interface abstraction. Network interfaces are registered
in a global list that can be iterated and each assigned an unique integer
identifier.

Add reference counted packets with a cache that recycles recent packets.

Add support for lo(4) loopback and ether(4) ethernet network interfaces.
The /dev/lo0 loopback device is created automatically on boot.

Add arp(4) address resolution protocol driver for translation of inet(4)
network layer addresses into ether(4) link layer addresses. arp(4) entries
are cached and evicted from the cache when needed or when the entry has not
been used for a while. The cache is limited to 256 entries for now.

Add ip(4) internet protocol version 4 support. IP fragmentation and options
are not implemented yet.

Add tcp(4) transmission control protocol sockets for a reliable transport
layer protocol that provides a reliable byte stream connection between two
hosts. The implementation is incomplete and does not yet implement out of
band data, options, and high performance extensions.

Add udp(4) user datagram protocol sockets for a connectionless transport
layer that provides best-effort delivery of datagrams.

Add ping(4) sockets for a best-effort delivery of echo datagrams.

Change type of sa_family_t from unsigned short to uint16_t.

Add --disable-network-drivers to the kernel(7) options and expose it with a
bootloader menu. tix-iso-bootconfig can set this option by default.

Import CRC32 code from libz for the Ethernet checksum.

This is a compatible ABI change that adds features to socket(2) (AF_INET,
IPPROTO_TCP, IPPROTO_UDP, IPPROTO_PING), the ioctls for if(4), socket
options, and the lo0 loopback interface.

This commit is based on work by Meisaka Yukara contributed as the commit
bbf7f1e8a5238a2bd1fe8eb1d2cc5c9c2421e2c4. Almost no lines of this work
remains in this final commit as it has been rewritten or refactored away
over the years, see the individual file headers for which files contain
remnants of this work.

Co-authored-by: Meisaka Yukara <Meisaka.Yukara@gmail.com>
2022-12-11 13:40:34 +01:00
Juhani Krekelä e9c4946ff7 Document getdnsconfig(2) and setdnsconfig(2). 2022-03-06 16:18:12 +02:00
Jonas 'Sortie' Termansen 5e7605fad2 Implement threading primitives that truly sleep.
The idle thread is now actually run when the system is idle because it
truly goes idle. The idle thread is made power efficient by using the hlt
instruction rather than a busy loop.

The new futex(2) system call is used to implement fast user-space mutexes,
condition variables, and semaphores. The same backend and design is used as
kutexes for truly sleeping kernel mutexes and condition variables.

The new exit_thread(2) flag EXIT_THREAD_FUTEX_WAKE wakes a futex.

Sleeping on clocks in the kernel now uses timers for true sleep.

The interrupt worker thread now truly sleeps when idle.

Kernel threads are now named.

This is a compatible ABI change.
2021-06-23 22:10:47 +02:00
Jonas 'Sortie' Termansen 3b036b6c5d Add getdnsconfig(2) and setdnsconfig(2). 2021-06-13 23:27:52 +02:00
Jonas 'Sortie' Termansen b0496023a1 Allow AF_UNSPEC family in socketpair(2). 2017-08-26 16:49:57 +02:00
Jonas 'Sortie' Termansen cd7a984e9f Fix select(2) buffer overflow if the fd_set is smaller than normal.
OpenSSH is allocating a fd_set of exactly the needed size, which leads to
buffer overflows in select(2) when it tries to zero out the fd_set assuming
it is the normal size.
2017-04-09 22:44:32 +02:00
Jonas 'Sortie' Termansen eb7d0f4dd4 Fix select(2) error and end of file handling. 2017-03-19 13:25:27 +01:00
Jonas 'Sortie' Termansen 4b2cf28bbf Add socket(2).
This removes the /dev/net socket interface.

This is an incompatible ABI change.
2017-02-14 20:43:31 +01:00
Jonas 'Sortie' Termansen 264805a4aa Remove uname -i and -o options.
These are unportable GNU extensions that's not needed for Sortix.
2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen 2a6a246ff4 Remove getdomainname(2). 2016-05-15 22:43:29 +02:00
Jonas 'Sortie' Termansen fe87b61a33 Add tagline. 2016-03-26 23:50:50 +01:00
Jonas 'Sortie' Termansen 2b72262b4f Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.

All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.

All imported code from other projects is compatible with this license.

All GPL licensed code from other projects had previously been removed.

Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-05 22:21:50 +01:00
Jonas 'Sortie' Termansen 01b59c1947 Convert libc to C. 2016-03-03 23:02:23 +01:00
Jonas 'Sortie' Termansen f876667cc5 Add socketpair(2) AF_UNIX stream support. 2016-01-26 22:11:12 +01:00
Jonas 'Sortie' Termansen 2e4b15daed Simplify directory reading. 2016-01-26 18:42:54 +01:00
Jonas 'Sortie' Termansen bff1265d62 Add termios(2). 2016-01-25 15:47:40 +01:00
Jonas 'Sortie' Termansen 9a59ef2313 Fix select(2) conformance issues. 2016-01-22 20:01:32 +01:00
Jonas 'Sortie' Termansen 421f907055 Report ix86 model in uname(2). 2015-12-12 19:28:08 +01:00
Jonas 'Sortie' Termansen 4cb9ccfc4b Rename libc/time/times.cpp to libc/sys/times/times.cpp. 2015-08-22 01:29:37 +02:00
Jonas 'Sortie' Termansen bb70eef85b Replace system call array types with pointers. 2015-01-23 14:52:51 +01:00
Jonas 'Sortie' Termansen d890d3082d Add umount(2) and unmountat(2). 2014-12-26 21:45:29 +01:00
Jonas 'Sortie' Termansen 577f2f700b Add shutdown(2). 2014-11-27 01:39:53 +01:00
Jonas 'Sortie' Termansen a00d085b81 Implement recvfrom(2) and sendto(2). 2014-11-27 01:39:12 +01:00
Jonas 'Sortie' Termansen a8a8154adc Add getpeername(2) and getsockname(2). 2014-11-27 01:39:11 +01:00
Jonas 'Sortie' Termansen a24ecf4b83 Add getsockopt(2) and setsockopt(2). 2014-11-18 18:10:22 +01:00
Jonas 'Sortie' Termansen 708bcb4735 Add recvmsg(2) and sendmsg(2). 2014-11-18 16:27:19 +01:00
Jonas 'Sortie' Termansen a935148f60 Add statvfs(2), fstatvfs(2) and fstatvfsat(2). 2014-03-17 19:22:12 +01:00
Jonas 'Sortie' Termansen 2fe3595feb Add getumask(2). 2014-03-17 19:22:12 +01:00
Jonas 'Sortie' Termansen e677c455d8 Use getdomainname(2) in uname(3). 2014-03-17 19:22:12 +01:00
Jonas 'Sortie' Termansen 687096ec8a Add uname(3). 2014-03-17 19:22:11 +01:00
Jonas 'Sortie' Termansen 98a87fa1e5 Rename Sortix kernel directory to kernel. 2014-03-01 14:37:39 +01:00
Jonas 'Sortie' Termansen 4227d97f55 Fix send(2) calling sys_recv rather than sys_send. 2014-02-23 14:47:21 +01:00
Jonas 'Sortie' Termansen 187cdf03dc Fix accept4 ignoring addrlen parameter as input. 2014-01-19 00:32:11 +01:00
Jonas 'Sortie' Termansen efc0eb2829 Add getrusage(3). 2013-12-17 14:30:41 +01:00
Jonas 'Sortie' Termansen 7a5e549612 Add getrlimit(3) and setrlimit(3). 2013-12-17 14:30:41 +01:00
Jonas 'Sortie' Termansen 13f09cc515 Add prlimit(2). 2013-12-17 14:30:41 +01:00
Jonas 'Sortie' Termansen a6f38947f2 Add getpriority(2) and setpriority(2). 2013-12-17 14:30:41 +01:00
Jonas 'Sortie' Termansen 04019cab9e Add mmap(2), mprotect(2) and munmap(2). 2013-12-17 14:30:41 +01:00
Jonas 'Sortie' Termansen 106c269c62 Move sys/readdirents.h functions into their own directory. 2013-12-17 14:30:39 +01:00
Jonas 'Sortie' Termansen d162eac516 Move sys/ioctl.h functions into their own directory. 2013-12-17 14:30:38 +01:00
Jonas 'Sortie' Termansen 49cb00ab3f Move sys/kernelinfo.h functions into their own directory. 2013-12-17 14:30:38 +01:00
Jonas 'Sortie' Termansen e8bc31b798 Move sys/select.h functions into their own directory. 2013-12-17 14:30:38 +01:00
Jonas 'Sortie' Termansen d6c8dd6983 Move sys/display.h functions into their own directory. 2013-12-17 14:30:38 +01:00
Jonas 'Sortie' Termansen de36488e63 Move sys/termmode.h functions into their own directory. 2013-12-17 14:30:38 +01:00
Jonas 'Sortie' Termansen 9e6cfc3e13 Move sys/wait.h functions into their own directory. 2013-12-17 14:30:38 +01:00
Jonas 'Sortie' Termansen ecb5744afb Move sys/uio.h functions into their own directory. 2013-12-17 14:30:38 +01:00
Jonas 'Sortie' Termansen ecbb19273b Move sys/stat.h functions into their own directory. 2013-12-17 14:30:38 +01:00
Jonas 'Sortie' Termansen a15ffa955b Obsolete uptime(2). 2013-12-17 14:30:34 +01:00
Jonas 'Sortie' Termansen 1e2550c0d5 Add clock_*(2) API. 2013-12-17 14:30:34 +01:00