-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocket_x.h
85 lines (78 loc) · 3.14 KB
/
socket_x.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// SPDX-FileCopyrightText: The vmnet-helper authors
// SPDX-FileCopyrightText: Authored by Alex Hultman, 2018-2019
// SPDX-License-Identifier: Apache-2.0
// Derived from
// https://github.com/oven-sh/bun/blob/main/packages/bun-usockets/src/internal/networking/bsd.h
#ifndef BSD_H
#define BSD_H
#include <sys/socket.h>
/*
* Extended version for sendmsg_x() and recvmsg_x() calls
*/
struct msghdr_x {
struct msghdr msg_hdr;
size_t msg_len; /* byte length of buffer in msg_iov */
};
/*
* recvmsg_x() is a system call similar to recvmsg(2) to receive
* several datagrams at once in the array of message headers "msgp".
*
* recvmsg_x() can be used only with protocols handlers that have been specially
* modified to support sending and receiving several datagrams at once.
*
* The size of the array "msgp" is given by the argument "cnt".
*
* The "flags" arguments supports only the value MSG_DONTWAIT.
*
* Each member of "msgp" array is of type "struct msghdr_x".
*
* The "msg_iov" and "msg_iovlen" are input parameters that describe where to
* store a datagram in a scatter gather locations of buffers -- see recvmsg(2).
* On output the field "msg_len" gives the length of the received datagram.
*
* The field "msg_flags" must be set to zero on input. On output, "msg_flags"
* may have MSG_TRUNC set to indicate the trailing portion of the datagram was
* discarded because the datagram was larger than the buffer supplied.
* recvmsg_x() returns as soon as a datagram is truncated.
*
* recvmsg_x() may return with less than "cnt" datagrams received based on
* the low water mark and the amount of data pending in the socket buffer.
*
* recvmsg_x() returns the number of datagrams that have been received,
* or -1 if an error occurred.
*
* NOTE: This a private system call, the API is subject to change.
*/
ssize_t recvmsg_x(int s, const struct msghdr_x *msgp, unsigned int cnt, int flags);
/*
* sendmsg_x() is a system call similar to send(2) to send
* several datagrams at once in the array of message headers "msgp".
*
* sendmsg_x() can be used only with protocols handlers that have been specially
* modified to support sending and receiving several datagrams at once.
*
* The size of the array "msgp" is given by the argument "cnt".
*
* The "flags" arguments supports only the value MSG_DONTWAIT.
*
* Each member of "msgp" array is of type "struct msghdr_x".
*
* The "msg_iov" and "msg_iovlen" are input parameters that specify the
* data to be sent in a scatter gather locations of buffers -- see sendmsg(2).
*
* sendmsg_x() fails with EMSGSIZE if the sum of the length of the datagrams
* is greater than the high water mark.
*
* Address and ancillary data are not supported so the following fields
* must be set to zero on input:
* "msg_name", "msg_namelen", "msg_control" and "msg_controllen".
*
* The field "msg_flags" and "msg_datalen" must be set to zero on input.
*
* sendmsg_x() returns the number of datagrams that have been sent,
* or -1 if an error occurred.
*
* NOTE: This a private system call, the API is subject to change.
*/
ssize_t sendmsg_x(int s, const struct msghdr_x *msgp, unsigned int cnt, int flags);
#endif // BSD_H