This commit is based on work by Meisaka Yukara <Meisaka.Yukara@gmail.com> contributed as the commit bbf7f1e8a5238a2bd1fe8eb1d2cc5c9c2421e2c4. See the individual file headers for which files contain remnants of this work. 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 echo of 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.
142 lines
3 KiB
C
142 lines
3 KiB
C
/*
|
|
* Copyright (c) 2011-2016, 2020 Jonas 'Sortie' Termansen.
|
|
*
|
|
* 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.
|
|
*
|
|
* errno.h
|
|
* System error numbers.
|
|
*/
|
|
|
|
#ifndef INCLUDE_ERRNO_H
|
|
#define INCLUDE_ERRNO_H
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#define ENOTBLK 12
|
|
#define ENODEV 13
|
|
#define EBADF 15
|
|
#define EOVERFLOW 16
|
|
#define ENOENT 17
|
|
#define ENOSPC 18
|
|
#define EEXIST 19
|
|
#define EROFS 20
|
|
#define EINVAL 21
|
|
#define ENOTDIR 22
|
|
#define ENOMEM 23
|
|
#define ERANGE 24
|
|
#define EISDIR 25
|
|
#define EPERM 26
|
|
#define EIO 27
|
|
#define ENOEXEC 28
|
|
#define EACCES 29
|
|
#define ESRCH 30
|
|
#define ENOTTY 31
|
|
#define ECHILD 32
|
|
#define ENOSYS 33
|
|
#define ENOTSUP 34
|
|
#define EBLOCKING 35
|
|
#define EINTR 36
|
|
#define ENOTEMPTY 37
|
|
#define EBUSY 38
|
|
#define EPIPE 39
|
|
#define EILSEQ 40
|
|
#define ELAKE 41
|
|
#define EMFILE 42
|
|
#define EAGAIN 43
|
|
#define EEOF 44
|
|
#define EBOUND 45
|
|
#define EINIT 46
|
|
#define ENODRV 47
|
|
#define E2BIG 48
|
|
#define EFBIG 49
|
|
#define EXDEV 50
|
|
#define ESPIPE 51
|
|
#define ENAMETOOLONG 52
|
|
#define ELOOP 53
|
|
#define EMLINK 54
|
|
#define ENXIO 55
|
|
#define EPROTONOSUPPORT 56
|
|
#define EAFNOSUPPORT 57
|
|
#define ENOTSOCK 58
|
|
#define EADDRINUSE 59
|
|
#define ETIMEDOUT 60
|
|
#define ECONNREFUSED 61
|
|
#define EDOM 62
|
|
#define EINPROGRESS 63
|
|
#define EALREADY 64
|
|
#define ESHUTDOWN 65
|
|
#define ECONNABORTED 66
|
|
#define ECONNRESET 67
|
|
#define EADDRNOTAVAIL 68
|
|
#define EISCONN 69
|
|
#define EFAULT 70
|
|
#define EDESTADDRREQ 71
|
|
#define EHOSTUNREACH 72
|
|
#define EMSGSIZE 73
|
|
#define ENETDOWN 74
|
|
#define ENETRESET 75
|
|
#define ENETUNREACH 76
|
|
#define ENOBUFS 77
|
|
#define ENOMSG 78
|
|
#define ENOPROTOOPT 79
|
|
#define ENOTCONN 80
|
|
#define EDEADLK 81
|
|
#define ENFILE 82
|
|
#define EPROTOTYPE 83
|
|
#define ENOLCK 84
|
|
#define ESIGPENDING 87
|
|
#define ESTALE 88
|
|
#define EBADMSG 89
|
|
#define ECANCELED 90
|
|
#define EDQUOT 91
|
|
#define EIDRM 92
|
|
#define EMULTIHOP 93
|
|
#define ENOLINK 94
|
|
#define ENOTRECOVERABLE 95
|
|
#define EOWNERDEAD 96
|
|
#define EPROTO 97
|
|
#define ETXTBSY 98
|
|
#define ENOMOUNT 99
|
|
#define ENOMEDIUM 100
|
|
/* TODO: EHOSTDOWN is documented but not implemented? */
|
|
|
|
#define EOPNOTSUPP ENOTSUP
|
|
#define EWOULDBLOCK EAGAIN
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#if !defined(__is_sortix_libk) && !defined(__is_sortix_kernel)
|
|
|
|
extern __thread int errno;
|
|
#define errno errno
|
|
|
|
#else
|
|
|
|
int* libk_get_errno_location(void);
|
|
#define errno (*libk_get_errno_location())
|
|
|
|
#endif
|
|
|
|
#if __USE_SORTIX
|
|
extern char* program_invocation_name;
|
|
extern char* program_invocation_short_name;
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern "C" */
|
|
#endif
|
|
|
|
#endif
|