]>
git.proxmox.com Git - rustc.git/blob - vendor/rustix-0.36.5/src/backend/libc/net/types.rs
2 use bitflags
::bitflags
;
4 /// A type for holding raw integer socket types.
6 pub type RawSocketType
= u32;
8 /// `SOCK_*` constants for use with [`socket`].
10 /// [`socket`]: crate::net::socket
11 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
13 pub struct SocketType(pub(crate) RawSocketType
);
18 pub const STREAM
: Self = Self(c
::SOCK_STREAM
as u32);
21 pub const DGRAM
: Self = Self(c
::SOCK_DGRAM
as u32);
24 pub const SEQPACKET
: Self = Self(c
::SOCK_SEQPACKET
as u32);
27 pub const RAW
: Self = Self(c
::SOCK_RAW
as u32);
30 #[cfg(not(target_os = "haiku"))]
31 pub const RDM
: Self = Self(c
::SOCK_RDM
as u32);
33 /// Constructs a `SocketType` from a raw integer.
35 pub const fn from_raw(raw
: RawSocketType
) -> Self {
39 /// Returns the raw integer for this `SocketType`.
41 pub const fn as_raw(self) -> RawSocketType
{
46 /// A type for holding raw integer address families.
48 pub type RawAddressFamily
= c
::sa_family_t
;
51 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
53 pub struct AddressFamily(pub(crate) RawAddressFamily
);
58 pub const UNSPEC
: Self = Self(c
::AF_UNSPEC
as _
);
60 pub const INET
: Self = Self(c
::AF_INET
as _
);
62 pub const INET6
: Self = Self(c
::AF_INET6
as _
);
66 target_os
= "dragonfly",
67 target_os
= "freebsd",
69 target_os
= "illumos",
73 target_os
= "openbsd",
74 target_os
= "solaris",
76 pub const NETLINK
: Self = Self(c
::AF_NETLINK
as _
);
77 /// `AF_UNIX`, aka `AF_LOCAL`
78 #[doc(alias = "LOCAL")]
79 pub const UNIX
: Self = Self(c
::AF_UNIX
as _
);
83 target_os
= "dragonfly",
84 target_os
= "freebsd",
86 target_os
= "illumos",
90 target_os
= "openbsd",
91 target_os
= "solaris",
93 pub const AX25
: Self = Self(c
::AF_AX25
as _
);
95 pub const IPX
: Self = Self(c
::AF_IPX
as _
);
97 pub const APPLETALK
: Self = Self(c
::AF_APPLETALK
as _
);
101 target_os
= "dragonfly",
102 target_os
= "freebsd",
104 target_os
= "illumos",
107 target_os
= "netbsd",
108 target_os
= "openbsd",
109 target_os
= "solaris",
111 pub const NETROM
: Self = Self(c
::AF_NETROM
as _
);
115 target_os
= "dragonfly",
116 target_os
= "freebsd",
118 target_os
= "illumos",
121 target_os
= "netbsd",
122 target_os
= "openbsd",
123 target_os
= "solaris",
125 pub const BRIDGE
: Self = Self(c
::AF_BRIDGE
as _
);
129 target_os
= "dragonfly",
130 target_os
= "freebsd",
132 target_os
= "illumos",
135 target_os
= "netbsd",
136 target_os
= "openbsd",
137 target_os
= "solaris",
139 pub const ATMPVC
: Self = Self(c
::AF_ATMPVC
as _
);
143 target_os
= "dragonfly",
144 target_os
= "freebsd",
148 target_os
= "netbsd",
149 target_os
= "openbsd",
151 pub const X25
: Self = Self(c
::AF_X25
as _
);
155 target_os
= "dragonfly",
156 target_os
= "freebsd",
158 target_os
= "illumos",
161 target_os
= "netbsd",
162 target_os
= "openbsd",
163 target_os
= "solaris",
165 pub const ROSE
: Self = Self(c
::AF_ROSE
as _
);
167 #[allow(non_upper_case_globals)]
168 #[cfg(not(target_os = "haiku"))]
169 pub const DECnet
: Self = Self(c
::AF_DECnet
as _
);
173 target_os
= "dragonfly",
174 target_os
= "freebsd",
176 target_os
= "illumos",
179 target_os
= "netbsd",
180 target_os
= "openbsd",
181 target_os
= "solaris",
183 pub const NETBEUI
: Self = Self(c
::AF_NETBEUI
as _
);
187 target_os
= "dragonfly",
188 target_os
= "freebsd",
190 target_os
= "illumos",
193 target_os
= "netbsd",
194 target_os
= "openbsd",
195 target_os
= "solaris",
197 pub const SECURITY
: Self = Self(c
::AF_SECURITY
as _
);
201 target_os
= "dragonfly",
202 target_os
= "freebsd",
206 target_os
= "netbsd",
207 target_os
= "openbsd",
209 pub const KEY
: Self = Self(c
::AF_KEY
as _
);
213 target_os
= "dragonfly",
214 target_os
= "freebsd",
218 target_os
= "netbsd",
219 target_os
= "openbsd",
221 pub const PACKET
: Self = Self(c
::AF_PACKET
as _
);
225 target_os
= "dragonfly",
226 target_os
= "freebsd",
228 target_os
= "illumos",
231 target_os
= "netbsd",
232 target_os
= "openbsd",
233 target_os
= "solaris",
235 pub const ASH
: Self = Self(c
::AF_ASH
as _
);
239 target_os
= "dragonfly",
240 target_os
= "freebsd",
242 target_os
= "illumos",
245 target_os
= "netbsd",
246 target_os
= "openbsd",
247 target_os
= "solaris",
249 pub const ECONET
: Self = Self(c
::AF_ECONET
as _
);
253 target_os
= "dragonfly",
254 target_os
= "freebsd",
256 target_os
= "illumos",
259 target_os
= "netbsd",
260 target_os
= "openbsd",
261 target_os
= "solaris",
263 pub const ATMSVC
: Self = Self(c
::AF_ATMSVC
as _
);
267 target_os
= "dragonfly",
268 target_os
= "freebsd",
270 target_os
= "illumos",
273 target_os
= "netbsd",
274 target_os
= "openbsd",
275 target_os
= "solaris",
277 pub const RDS
: Self = Self(c
::AF_RDS
as _
);
279 #[cfg(not(target_os = "haiku"))]
280 pub const SNA
: Self = Self(c
::AF_SNA
as _
);
283 target_os
= "dragonfly",
284 target_os
= "freebsd",
286 target_os
= "illumos",
289 target_os
= "netbsd",
290 target_os
= "openbsd",
291 target_os
= "solaris",
293 pub const IRDA
: Self = Self(c
::AF_IRDA
as _
);
297 target_os
= "dragonfly",
298 target_os
= "freebsd",
300 target_os
= "illumos",
303 target_os
= "netbsd",
304 target_os
= "openbsd",
305 target_os
= "solaris",
307 pub const PPPOX
: Self = Self(c
::AF_PPPOX
as _
);
311 target_os
= "dragonfly",
312 target_os
= "freebsd",
314 target_os
= "illumos",
317 target_os
= "netbsd",
318 target_os
= "openbsd",
319 target_os
= "solaris",
321 pub const WANPIPE
: Self = Self(c
::AF_WANPIPE
as _
);
325 target_os
= "dragonfly",
326 target_os
= "freebsd",
328 target_os
= "illumos",
331 target_os
= "netbsd",
332 target_os
= "openbsd",
333 target_os
= "solaris",
335 pub const LLC
: Self = Self(c
::AF_LLC
as _
);
339 target_os
= "dragonfly",
340 target_os
= "freebsd",
342 target_os
= "illumos",
345 target_os
= "netbsd",
346 target_os
= "openbsd",
347 target_os
= "solaris",
349 pub const CAN
: Self = Self(c
::AF_CAN
as _
);
353 target_os
= "dragonfly",
354 target_os
= "freebsd",
356 target_os
= "illumos",
359 target_os
= "netbsd",
360 target_os
= "openbsd",
361 target_os
= "solaris",
363 pub const TIPC
: Self = Self(c
::AF_TIPC
as _
);
365 #[cfg(not(any(windows, target_os = "illumos", target_os = "ios", target_os = "macos", target_os = "solaris")))]
366 pub const BLUETOOTH
: Self = Self(c
::AF_BLUETOOTH
as _
);
370 target_os
= "dragonfly",
371 target_os
= "freebsd",
373 target_os
= "illumos",
376 target_os
= "netbsd",
377 target_os
= "openbsd",
378 target_os
= "solaris",
380 pub const IUCV
: Self = Self(c
::AF_IUCV
as _
);
384 target_os
= "dragonfly",
385 target_os
= "freebsd",
387 target_os
= "illumos",
390 target_os
= "netbsd",
391 target_os
= "openbsd",
392 target_os
= "solaris",
394 pub const RXRPC
: Self = Self(c
::AF_RXRPC
as _
);
396 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
397 pub const ISDN
: Self = Self(c
::AF_ISDN
as _
);
401 target_os
= "dragonfly",
402 target_os
= "freebsd",
404 target_os
= "illumos",
407 target_os
= "netbsd",
408 target_os
= "openbsd",
409 target_os
= "solaris",
411 pub const PHONET
: Self = Self(c
::AF_PHONET
as _
);
415 target_os
= "dragonfly",
416 target_os
= "freebsd",
418 target_os
= "illumos",
421 target_os
= "netbsd",
422 target_os
= "openbsd",
423 target_os
= "solaris",
425 pub const IEEE802154
: Self = Self(c
::AF_IEEE802154
as _
);
427 /// Constructs a `AddressFamily` from a raw integer.
429 pub const fn from_raw(raw
: RawAddressFamily
) -> Self {
433 /// Returns the raw integer for this `AddressFamily`.
435 pub const fn as_raw(self) -> RawAddressFamily
{
440 /// A type for holding raw integer protocols.
442 pub type RawProtocol
= i32;
445 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
447 pub struct Protocol(pub(crate) RawProtocol
);
452 pub const IP
: Self = Self(c
::IPPROTO_IP
as _
);
454 pub const ICMP
: Self = Self(c
::IPPROTO_ICMP
as _
);
456 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
457 pub const IGMP
: Self = Self(c
::IPPROTO_IGMP
as _
);
459 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
460 pub const IPIP
: Self = Self(c
::IPPROTO_IPIP
as _
);
462 pub const TCP
: Self = Self(c
::IPPROTO_TCP
as _
);
464 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
465 pub const EGP
: Self = Self(c
::IPPROTO_EGP
as _
);
467 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
468 pub const PUP
: Self = Self(c
::IPPROTO_PUP
as _
);
470 pub const UDP
: Self = Self(c
::IPPROTO_UDP
as _
);
472 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
473 pub const IDP
: Self = Self(c
::IPPROTO_IDP
as _
);
475 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
476 pub const TP
: Self = Self(c
::IPPROTO_TP
as _
);
480 target_os
= "dragonfly",
482 target_os
= "illumos",
485 target_os
= "openbsd",
486 target_os
= "solaris",
488 pub const DCCP
: Self = Self(c
::IPPROTO_DCCP
as _
);
490 pub const IPV6
: Self = Self(c
::IPPROTO_IPV6
as _
);
492 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
493 pub const RSVP
: Self = Self(c
::IPPROTO_RSVP
as _
);
495 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
496 pub const GRE
: Self = Self(c
::IPPROTO_GRE
as _
);
498 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
499 pub const ESP
: Self = Self(c
::IPPROTO_ESP
as _
);
501 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
502 pub const AH
: Self = Self(c
::IPPROTO_AH
as _
);
507 target_os
= "illumos",
508 target_os
= "netbsd",
509 target_os
= "openbsd",
510 target_os
= "solaris",
512 pub const MTP
: Self = Self(c
::IPPROTO_MTP
as _
);
516 target_os
= "dragonfly",
517 target_os
= "freebsd",
519 target_os
= "illumos",
522 target_os
= "netbsd",
523 target_os
= "openbsd",
524 target_os
= "solaris",
526 pub const BEETPH
: Self = Self(c
::IPPROTO_BEETPH
as _
);
528 #[cfg(not(any(windows, target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
529 pub const ENCAP
: Self = Self(c
::IPPROTO_ENCAP
as _
);
531 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
532 pub const PIM
: Self = Self(c
::IPPROTO_PIM
as _
);
536 target_os
= "dragonfly",
537 target_os
= "freebsd",
539 target_os
= "illumos",
542 target_os
= "netbsd",
543 target_os
= "openbsd",
544 target_os
= "solaris",
546 pub const COMP
: Self = Self(c
::IPPROTO_COMP
as _
);
548 #[cfg(not(any(target_os = "dragonfly", target_os = "haiku", target_os = "illumos", target_os = "openbsd", target_os = "solaris")))]
549 pub const SCTP
: Self = Self(c
::IPPROTO_SCTP
as _
);
550 /// `IPPROTO_UDPLITE`
553 target_os
= "dragonfly",
555 target_os
= "illumos",
558 target_os
= "netbsd",
559 target_os
= "openbsd",
560 target_os
= "solaris",
562 pub const UDPLITE
: Self = Self(c
::IPPROTO_UDPLITE
as _
);
566 target_os
= "dragonfly",
568 target_os
= "illumos",
571 target_os
= "netbsd",
572 target_os
= "solaris",
574 pub const MPLS
: Self = Self(c
::IPPROTO_MPLS
as _
);
576 pub const RAW
: Self = Self(c
::IPPROTO_RAW
as _
);
580 target_os
= "android",
581 target_os
= "dragonfly",
582 target_os
= "emscripten",
583 target_os
= "freebsd",
584 target_os
= "fuchsia",
586 target_os
= "illumos",
589 target_os
= "netbsd",
590 target_os
= "openbsd",
591 target_os
= "solaris",
593 pub const MPTCP
: Self = Self(c
::IPPROTO_MPTCP
as _
);
594 /// `IPPROTO_FRAGMENT`
595 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
596 pub const FRAGMENT
: Self = Self(c
::IPPROTO_FRAGMENT
as _
);
598 pub const ICMPV6
: Self = Self(c
::IPPROTO_ICMPV6
as _
);
602 target_os
= "dragonfly",
604 target_os
= "illumos",
607 target_os
= "netbsd",
608 target_os
= "openbsd",
609 target_os
= "solaris",
611 pub const MH
: Self = Self(c
::IPPROTO_MH
as _
);
612 /// `IPPROTO_ROUTING`
613 #[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
614 pub const ROUTING
: Self = Self(c
::IPPROTO_ROUTING
as _
);
616 /// Constructs a `Protocol` from a raw integer.
618 pub const fn from_raw(raw
: RawProtocol
) -> Self {
622 /// Returns the raw integer for this `Protocol`.
624 pub const fn as_raw(self) -> RawProtocol
{
629 /// `SHUT_*` constants for use with [`shutdown`].
631 /// [`shutdown`]: crate::net::shutdown
632 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
635 /// `SHUT_RD`—Disable further read operations.
637 /// `SHUT_WR`—Disable further write operations.
639 /// `SHUT_RDWR`—Disable further read and write operations.
640 ReadWrite
= c
::SHUT_RDWR
,
644 /// `SOCK_*` constants for use with [`accept_with`] and [`acceptfrom_with`].
646 /// [`accept_with`]: crate::net::accept_with
647 /// [`acceptfrom_with`]: crate::net::acceptfrom_with
648 pub struct AcceptFlags
: c
::c_int
{
650 #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
651 const NONBLOCK
= c
::SOCK_NONBLOCK
;
654 #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
655 const CLOEXEC
= c
::SOCK_CLOEXEC
;
660 /// `SOCK_*` constants for use with [`socket`].
662 /// [`socket`]: crate::net::socket
663 pub struct SocketFlags
: c
::c_int
{
665 #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
666 const NONBLOCK
= c
::SOCK_NONBLOCK
;
669 #[cfg(not(any(windows, target_os = "haiku", target_os = "ios", target_os = "macos")))]
670 const CLOEXEC
= c
::SOCK_CLOEXEC
;
674 /// Timeout identifier for use with [`set_socket_timeout`] and
675 /// [`get_socket_timeout`].
677 /// [`set_socket_timeout`]: crate::net::sockopt::set_socket_timeout.
678 /// [`get_socket_timeout`]: crate::net::sockopt::get_socket_timeout.
679 #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
682 /// `SO_RCVTIMEO`—Timeout for receiving.
683 Recv
= c
::SO_RCVTIMEO
,
685 /// `SO_SNDTIMEO`—Timeout for sending.
686 Send
= c
::SO_SNDTIMEO
,