netlink_packet_sock_diag/
constants.rs

1// SPDX-License-Identifier: MIT
2
3pub const SOCK_DIAG_BY_FAMILY: u16 = 20;
4pub const SOCK_DESTROY: u16 = 21;
5
6pub const AF_UNSPEC: u8 = libc::AF_UNSPEC as u8;
7pub const AF_UNIX: u8 = libc::AF_UNIX as u8;
8// pub const AF_LOCAL: u8 = libc::AF_LOCAL as u8;
9pub const AF_INET: u8 = libc::AF_INET as u8;
10pub const AF_AX25: u8 = libc::AF_AX25 as u8;
11pub const AF_IPX: u8 = libc::AF_IPX as u8;
12pub const AF_APPLETALK: u8 = libc::AF_APPLETALK as u8;
13pub const AF_NETROM: u8 = libc::AF_NETROM as u8;
14pub const AF_BRIDGE: u8 = libc::AF_BRIDGE as u8;
15pub const AF_ATMPVC: u8 = libc::AF_ATMPVC as u8;
16pub const AF_X25: u8 = libc::AF_X25 as u8;
17pub const AF_INET6: u8 = libc::AF_INET6 as u8;
18pub const AF_ROSE: u8 = libc::AF_ROSE as u8;
19pub const AF_DECNET: u8 = libc::AF_DECnet as u8;
20pub const AF_NETBEUI: u8 = libc::AF_NETBEUI as u8;
21pub const AF_SECURITY: u8 = libc::AF_SECURITY as u8;
22pub const AF_KEY: u8 = libc::AF_KEY as u8;
23pub const AF_NETLINK: u8 = libc::AF_NETLINK as u8;
24// pub const AF_ROUTE: u8 = libc::AF_ROUTE as u8;
25pub const AF_PACKET: u8 = libc::AF_PACKET as u8;
26pub const AF_ASH: u8 = libc::AF_ASH as u8;
27pub const AF_ECONET: u8 = libc::AF_ECONET as u8;
28pub const AF_ATMSVC: u8 = libc::AF_ATMSVC as u8;
29pub const AF_RDS: u8 = libc::AF_RDS as u8;
30pub const AF_SNA: u8 = libc::AF_SNA as u8;
31pub const AF_IRDA: u8 = libc::AF_IRDA as u8;
32pub const AF_PPPOX: u8 = libc::AF_PPPOX as u8;
33pub const AF_WANPIPE: u8 = libc::AF_WANPIPE as u8;
34pub const AF_LLC: u8 = libc::AF_LLC as u8;
35pub const AF_CAN: u8 = libc::AF_CAN as u8;
36pub const AF_TIPC: u8 = libc::AF_TIPC as u8;
37pub const AF_BLUETOOTH: u8 = libc::AF_BLUETOOTH as u8;
38pub const AF_IUCV: u8 = libc::AF_IUCV as u8;
39pub const AF_RXRPC: u8 = libc::AF_RXRPC as u8;
40pub const AF_ISDN: u8 = libc::AF_ISDN as u8;
41pub const AF_PHONET: u8 = libc::AF_PHONET as u8;
42pub const AF_IEEE802154: u8 = libc::AF_IEEE802154 as u8;
43pub const AF_CAIF: u8 = libc::AF_CAIF as u8;
44pub const AF_ALG: u8 = libc::AF_ALG as u8;
45
46/// Dummy protocol for TCP
47pub const IPPROTO_IP: u8 = 0;
48/// Internet Control Message Protocol
49pub const IPPROTO_ICMP: u8 = 1;
50/// Internet Group Management Protocol
51pub const IPPROTO_IGMP: u8 = 2;
52/// IPIP tunnels (older KA9Q tunnels use 94)
53pub const IPPROTO_IPIP: u8 = 4;
54/// Transmission Control Protocol
55pub const IPPROTO_TCP: u8 = 6;
56/// Exterior Gateway Protocol
57pub const IPPROTO_EGP: u8 = 8;
58/// PUP protocol
59pub const IPPROTO_PUP: u8 = 12;
60/// User Datagram Protocol
61pub const IPPROTO_UDP: u8 = 17;
62/// XNS IDP protocol
63pub const IPPROTO_IDP: u8 = 22;
64/// SO Transport Protocol Class 4
65pub const IPPROTO_TP: u8 = 29;
66/// Datagram Congestion Control Protocol
67pub const IPPROTO_DCCP: u8 = 33;
68/// IPv6 header
69pub const IPPROTO_IPV6: u8 = 41;
70/// Reservation Protocol
71pub const IPPROTO_RSVP: u8 = 46;
72/// General Routing Encapsulation
73pub const IPPROTO_GRE: u8 = 47;
74/// encapsulating security payload
75pub const IPPROTO_ESP: u8 = 50;
76/// authentication header
77pub const IPPROTO_AH: u8 = 51;
78/// Multicast Transport Protocol
79pub const IPPROTO_MTP: u8 = 92;
80/// IP option pseudo header for BEET
81pub const IPPROTO_BEETPH: u8 = 94;
82/// Encapsulation Header
83pub const IPPROTO_ENCAP: u8 = 98;
84/// Protocol Independent Multicast
85pub const IPPROTO_PIM: u8 = 103;
86/// Compression Header Protocol
87pub const IPPROTO_COMP: u8 = 108;
88/// Stream Control Transmission Protocol
89pub const IPPROTO_SCTP: u8 = 132;
90/// UDP-Lite protocol
91pub const IPPROTO_UDPLITE: u8 = 136;
92/// MPLS in IP
93pub const IPPROTO_MPLS: u8 = 137;
94/// Raw IP packets
95pub const IPPROTO_RAW: u8 = 255;
96/// IPv6 Hop-by-Hop options
97pub const IPPROTO_HOPOPTS: u8 = 0;
98/// IPv6 routing header
99pub const IPPROTO_ROUTING: u8 = 43;
100/// IPv6 fragmentation header
101pub const IPPROTO_FRAGMENT: u8 = 44;
102/// ICMPv6
103pub const IPPROTO_ICMPV6: u8 = 58;
104/// IPv6 no next header
105pub const IPPROTO_NONE: u8 = 59;
106/// IPv6 destination options
107pub const IPPROTO_DSTOPTS: u8 = 60;
108/// IPv6 mobility header
109pub const IPPROTO_MH: u8 = 135;
110
111// Extensions for inet
112pub const INET_DIAG_NONE: u16 = 0;
113pub const INET_DIAG_MEMINFO: u16 = 1;
114pub const INET_DIAG_INFO: u16 = 2;
115pub const INET_DIAG_VEGASINFO: u16 = 3;
116pub const INET_DIAG_CONG: u16 = 4;
117pub const INET_DIAG_TOS: u16 = 5;
118pub const INET_DIAG_TCLASS: u16 = 6;
119pub const INET_DIAG_SKMEMINFO: u16 = 7;
120pub const INET_DIAG_SHUTDOWN: u16 = 8;
121
122pub const INET_DIAG_DCTCPINFO: u16 = 9;
123pub const INET_DIAG_PROTOCOL: u16 = 10;
124pub const INET_DIAG_SKV6ONLY: u16 = 11;
125pub const INET_DIAG_LOCALS: u16 = 12;
126pub const INET_DIAG_PEERS: u16 = 13;
127pub const INET_DIAG_PAD: u16 = 14;
128pub const INET_DIAG_MARK: u16 = 15;
129pub const INET_DIAG_BBRINFO: u16 = 16;
130pub const INET_DIAG_CLASS_ID: u16 = 17;
131pub const INET_DIAG_MD5SIG: u16 = 18;
132
133/// (both server and client) represents an open connection, data
134/// received can be delivered to the user. The normal state for the
135/// data transfer phase of the connection.
136pub const TCP_ESTABLISHED: u8 = 1;
137/// (client) represents waiting for a matching connection request
138/// after having sent a connection request.
139pub const TCP_SYN_SENT: u8 = 2;
140/// (server) represents waiting for a confirming connection request
141/// acknowledgment after having both received and sent a connection
142/// request.
143pub const TCP_SYN_RECV: u8 = 3;
144/// (both server and client) represents waiting for a connection
145/// termination request from the remote TCP, or an acknowledgment of
146/// the connection termination request previously sent.
147pub const TCP_FIN_WAIT1: u8 = 4;
148/// (both server and client) represents waiting for a connection
149/// termination request from the remote TCP.
150pub const TCP_FIN_WAIT2: u8 = 5;
151/// (either server or client) represents waiting for enough time to
152/// pass to be sure the remote TCP received the acknowledgment of its
153/// connection termination request.
154pub const TCP_TIME_WAIT: u8 = 6;
155/// (both server and client) represents no connection state at all.
156pub const TCP_CLOSE: u8 = 7;
157/// (both server and client) represents waiting for a connection
158/// termination request from the local user.
159pub const TCP_CLOSE_WAIT: u8 = 8;
160/// (both server and client) represents waiting for an acknowledgment
161/// of the connection termination request previously sent to the
162/// remote TCP (which includes an acknowledgment of its connection
163/// termination request).
164pub const TCP_LAST_ACK: u8 = 9;
165/// (server) represents waiting for a connection request from any
166/// remote TCP and port.
167pub const TCP_LISTEN: u8 = 10;
168/// (both server and client) represents waiting for a connection termination
169/// request acknowledgment from the remote TCP.
170pub const TCP_CLOSING: u8 = 11;
171
172/// The attribute reported in answer to this request is
173/// `UNIX_DIAG_NAME`. The payload associated with this attribute is
174/// the pathname to which the socket was bound (a se quence of bytes
175/// up to `UNIX_PATH_MAX` length).
176pub const UDIAG_SHOW_NAME: u32 = 1 << UNIX_DIAG_NAME;
177/// The attribute reported in answer to this request is
178/// `UNIX_DIAG_VFS`, which returns VFS information associated to the
179/// inode.
180pub const UDIAG_SHOW_VFS: u32 = 1 << UNIX_DIAG_VFS;
181/// The attribute reported in answer to this request is
182/// `UNIX_DIAG_PEER`, which carries the peer's inode number. This
183/// attribute is reported for connected sockets only.
184pub const UDIAG_SHOW_PEER: u32 = 1 << UNIX_DIAG_PEER;
185/// The attribute reported in answer to this request is
186/// `UNIX_DIAG_ICONS`, which information about pending
187/// connections. Specifically, it contains the inode numbers of the
188/// sockets that have passed the `connect(2)` call, but hasn't been
189/// processed with `accept(2) yet`. This attribute is reported for
190/// listening sockets only.
191pub const UDIAG_SHOW_ICONS: u32 = 1 << UNIX_DIAG_ICONS;
192/// The attribute reported in answer to this request is
193/// `UNIX_DIAG_RQLEN`, which reports:
194///
195/// - for listening socket: the number of pending connections, and the backlog
196///   length (which equals to the value passed as the second argument to
197///   `listen(2)`).
198/// - for established sockets: the amount of data in incoming queue, and the
199///   amount of memory available for sending
200pub const UDIAG_SHOW_RQLEN: u32 = 1 << UNIX_DIAG_RQLEN;
201/// The attribute reported in answer to this request is
202/// `UNIX_DIAG_MEMINFO` which shows memory information about the
203/// socket
204pub const UDIAG_SHOW_MEMINFO: u32 = 1 << UNIX_DIAG_MEMINFO;
205
206pub const UNIX_DIAG_NAME: u16 = 0;
207pub const UNIX_DIAG_VFS: u16 = 1;
208pub const UNIX_DIAG_PEER: u16 = 2;
209pub const UNIX_DIAG_ICONS: u16 = 3;
210pub const UNIX_DIAG_RQLEN: u16 = 4;
211pub const UNIX_DIAG_MEMINFO: u16 = 5;
212pub const UNIX_DIAG_SHUTDOWN: u16 = 6;
213
214/// Provides sequenced, reliable, two-way, connection-based byte
215/// streams. An out-of-band data transmission mechanism may be
216/// supported.
217pub const SOCK_STREAM: u8 = libc::SOCK_STREAM as u8;
218/// Supports datagrams (connectionless, unreliable messages of a fixed
219/// maximum length).
220pub const SOCK_DGRAM: u8 = libc::SOCK_DGRAM as u8;
221/// Provides a sequenced, reliable, two-way connection-based data
222/// transmission path for datagrams of fixed maximum length; a
223/// consumer is required to read an entire packet with each input
224/// system call.
225pub const SOCK_SEQPACKET: u8 = libc::SOCK_SEQPACKET as u8;
226/// Provides raw network protocol access.
227pub const SOCK_RAW: u8 = libc::SOCK_RAW as u8;
228/// Provides a reliable datagram layer that does not guarantee
229/// ordering.
230pub const SOCK_RDM: u8 = libc::SOCK_RDM as u8;
231/// Obsolete and should not be used in new programs; see `packet(7)`.
232pub const SOCK_PACKET: u8 = libc::SOCK_PACKET as u8;
233
234/// Nothing bad has been observed recently. No apparent reordering, packet loss,
235/// or ECN marks.
236pub const TCP_CA_OPEN: u8 = 0;
237pub const TCPF_CA_OPEN: u32 = 1 << TCP_CA_OPEN;
238
239/// The sender enters disordered state when it has received DUPACKs or
240/// SACKs in the last round of packets sent. This could be due to
241/// packet loss or reordering but needs further information to confirm
242/// packets have been lost.
243pub const TCP_CA_DISORDER: u8 = 1;
244pub const TCPF_CA_DISORDER: u32 = 1 << TCP_CA_DISORDER;
245/// The sender enters Congestion Window Reduction (CWR) state when it
246/// has received ACKs with ECN-ECE marks, or has experienced
247/// congestion or packet discard on the sender host (e.g. qdisc).
248pub const TCP_CA_CWR: u8 = 2;
249pub const TCPF_CA_CWR: u32 = 1 << TCP_CA_CWR;
250/// The sender is in fast recovery and retransmitting lost packets, typically
251/// triggered by ACK events.
252pub const TCP_CA_RECOVERY: u8 = 3;
253pub const TCPF_CA_RECOVERY: u32 = 1 << TCP_CA_RECOVERY;
254/// The sender is in loss recovery triggered by retransmission timeout.
255pub const TCP_CA_LOSS: u8 = 4;
256pub const TCPF_CA_LOSS: u32 = 1 << TCP_CA_LOSS;
257
258pub const TCPI_OPT_TIMESTAMPS: u8 = 1;
259pub const TCPI_OPT_SACK: u8 = 2;
260pub const TCPI_OPT_WSCALE: u8 = 4;
261/// ECN was negociated at TCP session init
262pub const TCPI_OPT_ECN: u8 = 8;
263/// We received at least one packet with ECT
264pub const TCPI_OPT_ECN_SEEN: u8 = 16;
265/// SYN-ACK acked data in SYN sent or rcvd
266pub const TCPI_OPT_SYN_DATA: u8 = 32;
267
268/// Shutdown state of a socket. A socket shut down with `SHUT_RD` can
269/// no longer receive data. See also `man 2 shutdown`.
270pub const SHUT_RD: u8 = 0;
271/// Shutdown state of a socket. A socket shut down with `SHUT_WR` can
272/// no longer send data. See also `man 2 shutdown`.
273pub const SHUT_WR: u8 = 1;
274/// Shutdown state of a socket. A socket shut down with `SHUT_RDWR`
275/// can no longer receive nor send data. See also `man 2 shutdown`.
276pub const SHUT_RDWR: u8 = 2;