Add networking & sockets related syscall limitations to the book
This commit is contained in:
parent
51eb74250e
commit
d8bc04dbbe
|
|
@ -62,20 +62,20 @@ which are summarized in the table below.
|
|||
| 39 | getpid | ✅ | |
|
||||
| 40 | sendfile | ✅ | |
|
||||
| 41 | socket | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#socket) |
|
||||
| 42 | connect | ✅ | |
|
||||
| 42 | connect | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#connect) |
|
||||
| 43 | accept | ✅ | |
|
||||
| 44 | sendto | ✅ | |
|
||||
| 45 | recvfrom | ✅ | |
|
||||
| 46 | sendmsg | ✅ | |
|
||||
| 47 | recvmsg | ✅ | |
|
||||
| 44 | sendto | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#sendto-and-sendmsg) |
|
||||
| 45 | recvfrom | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#recvfrom-and-recvmsg) |
|
||||
| 46 | sendmsg | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#sendto-and-sendmsg) |
|
||||
| 47 | recvmsg | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#recvfrom-and-recvmsg) |
|
||||
| 48 | shutdown | ✅ | |
|
||||
| 49 | bind | ✅ | |
|
||||
| 49 | bind | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#bind) |
|
||||
| 50 | listen | ✅ | |
|
||||
| 51 | getsockname | ✅ | |
|
||||
| 52 | getpeername | ✅ | |
|
||||
| 53 | socketpair | ✅ | |
|
||||
| 54 | setsockopt | ✅ | |
|
||||
| 55 | getsockopt | ✅ | |
|
||||
| 53 | socketpair | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#socketpair) |
|
||||
| 54 | setsockopt | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#getsockopt-and-setsockopt) |
|
||||
| 55 | getsockopt | ✅ | [⚠️](limitations-on-system-calls/networking-and-sockets.html#getsockopt-and-setsockopt) |
|
||||
| 56 | clone | ✅ | |
|
||||
| 57 | fork | ✅ | |
|
||||
| 58 | vfork | ❌ | |
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ under this category.
|
|||
|
||||
## `socket`
|
||||
|
||||
Supported functionality in SCML:
|
||||
|
||||
```c
|
||||
// Optional flags for socket type
|
||||
|
|
@ -46,4 +47,188 @@ socket(
|
|||
```
|
||||
|
||||
For more information,
|
||||
see [the man page](https://man7.org/linux/man-pages/man2/socket.2.html).
|
||||
see [the man page](https://man7.org/linux/man-pages/man2/socket.2.html).
|
||||
|
||||
## `socketpair`
|
||||
|
||||
Supported functionality in SCML:
|
||||
|
||||
```c
|
||||
// Create a pair of connected UNIX sockets
|
||||
socketpair(
|
||||
family = AF_UNIX,
|
||||
type = SOCK_STREAM | SOCK_SEQPACKET | <opt_type_flags>,
|
||||
protocol = 0,
|
||||
sv
|
||||
);
|
||||
```
|
||||
|
||||
For more information,
|
||||
see [the man page](https://man7.org/linux/man-pages/man2/socketpair.2.html).
|
||||
|
||||
## `bind`
|
||||
|
||||
Supported functionality in SCML:
|
||||
|
||||
```c
|
||||
struct sockaddr = {
|
||||
sa_family = AF_INET | AF_UNIX | AF_NETLINK | AF_VSOCK,
|
||||
..
|
||||
};
|
||||
|
||||
// Bind a socket to an address
|
||||
bind(
|
||||
sockfd, addr = <sockaddr>, addrlen
|
||||
);
|
||||
```
|
||||
|
||||
For more information,
|
||||
see [the man page](https://man7.org/linux/man-pages/man2/bind.2.html).
|
||||
|
||||
## `connect`
|
||||
|
||||
Supported functionality in SCML:
|
||||
|
||||
```c
|
||||
// Connect to a peer socket
|
||||
connect(
|
||||
sockfd, addr = <sockaddr>, addrlen
|
||||
);
|
||||
```
|
||||
|
||||
For more information,
|
||||
see [the man page](https://man7.org/linux/man-pages/man2/connect.2.html).
|
||||
|
||||
## `sendto` and `sendmsg`
|
||||
|
||||
Supported functionality in SCML:
|
||||
|
||||
```c
|
||||
// Send message on a socket
|
||||
sendto(
|
||||
sockfd, buf, len,
|
||||
flags = 0,
|
||||
dest_addr = <sockaddr>,
|
||||
addrlen
|
||||
);
|
||||
|
||||
// Send message using scatter-gather buffers and ancillary data
|
||||
sendmsg(
|
||||
sockfd,
|
||||
msg = {
|
||||
msg_name = <sockaddr>,
|
||||
msg_control = NULL,
|
||||
..
|
||||
},
|
||||
flags = 0
|
||||
);
|
||||
```
|
||||
|
||||
Unsupported flags:
|
||||
* `MSG_CONFIRM`
|
||||
* `MSG_DONTROUTE`
|
||||
* `MSG_DONTWAIT`
|
||||
* `MSG_EOR`
|
||||
* `MSG_MORE`
|
||||
* `MSG_CONFIRM`
|
||||
* `MSG_NOSIGNAL`
|
||||
* `MSG_OOB`
|
||||
* `MSG_FASTOPEN`
|
||||
|
||||
For more information,
|
||||
see [the man page](https://man7.org/linux/man-pages/man2/sendto.2.html).
|
||||
|
||||
## `recvfrom` and `recvmsg`
|
||||
|
||||
Supported functionality in SCML:
|
||||
|
||||
```c
|
||||
// Receive message from a socket
|
||||
recvfrom(
|
||||
sockfd, buf, size,
|
||||
flags = 0,
|
||||
src_addr, addrlen
|
||||
);
|
||||
|
||||
// Receive message using scatter-gather buffers and ancillary data
|
||||
recvmsg(
|
||||
sockfd,
|
||||
msg,
|
||||
flags = 0
|
||||
);
|
||||
```
|
||||
|
||||
Partially-supported flags:
|
||||
* `MSG_PEEK` because it is only supported in netlink socket
|
||||
|
||||
For more information,
|
||||
see [the man page](https://man7.org/linux/man-pages/man2/recvfrom.2.html).
|
||||
|
||||
## `getsockopt` and `setsockopt`
|
||||
|
||||
Supported functionality in SCML:
|
||||
|
||||
```c
|
||||
socket_options = SO_SNDBUF | SO_RCVBUF | SO_REUSEADDR | SO_REUSEPORT |
|
||||
SO_PRIORITY | SO_LINGER | SO_PASSCRED | SO_KEEPALIVE |
|
||||
SO_SNDBUFFORCE | SO_RCVBUFFORCE | SO_ERROR |
|
||||
SO_PEERCRED | SO_ACCEPTCONN | SO_PEERGROUPS;
|
||||
|
||||
ip_options = IP_TOS | IP_TTL | IP_HDRINCL;
|
||||
|
||||
tcp_options = TCP_NODELAY | TCP_MAXSEG | TCP_KEEPIDLE | TCP_SYNCNT |
|
||||
TCP_DEFER_ACCEPT | TCP_WINDOW_CLAMP | TCP_CONGESTION |
|
||||
TCP_USER_TIMEOUT | TCP_INQ;
|
||||
|
||||
// Get options at socket level
|
||||
getsockopt(
|
||||
sockfd, level = SOL_SOCKET,
|
||||
optname = <socket_options>,
|
||||
optval, optlen
|
||||
);
|
||||
|
||||
// Get options at IP level
|
||||
getsockopt(
|
||||
sockfd, level = SOL_IP,
|
||||
optname = <ip_options>,
|
||||
optval, optlen
|
||||
);
|
||||
|
||||
// Get options at TCP level
|
||||
getsockopt(
|
||||
sockfd, level = SOL_TCP,
|
||||
optname = <tcp_options>,
|
||||
optval, optlen
|
||||
);
|
||||
|
||||
// Set options at socket level
|
||||
setsockopt(
|
||||
sockfd, level = SOL_SOCKET,
|
||||
optname = <socket_options>,
|
||||
optval, optlen
|
||||
);
|
||||
|
||||
// Set options at IP level
|
||||
setsockopt(
|
||||
sockfd, level = SOL_IP,
|
||||
optname = <ip_options>,
|
||||
optval, optlen
|
||||
);
|
||||
|
||||
// Set options at TCP level
|
||||
setsockopt(
|
||||
sockfd, level = SOL_TCP,
|
||||
optname = <tcp_options>,
|
||||
optval, optlen
|
||||
);
|
||||
|
||||
// Set options at netlink level
|
||||
setsockopt(
|
||||
sockfd, level = SOL_NETLINK,
|
||||
optname = NETLINK_ADD_MEMBERSHIP | NETLINK_DROP_MEMBERSHIP,
|
||||
optval, optlen
|
||||
);
|
||||
```
|
||||
|
||||
For more information,
|
||||
see [the man page](https://man7.org/linux/man-pages/man2/getsockopt.2.html).
|
||||
Loading…
Reference in New Issue