1const AF_KCM: u8 = 41;
4const AF_QIPCRTR: u8 = 42;
5const AF_SMC: u8 = 43;
6const AF_XDP: u8 = 44;
7const AF_MCTP: u8 = 45;
8
9#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
10#[non_exhaustive]
11pub enum AddressFamily {
12 #[default]
13 Unspec,
14 Local,
15 Unix,
16 Inet,
17 Ax25,
18 Ipx,
19 Appletalk,
20 Netrom,
21 Bridge,
22 Atmpvc,
23 X25,
24 Inet6,
25 Rose,
26 Decnet,
27 Netbeui,
28 Security,
29 Key,
30 Route,
31 Netlink,
32 Packet,
33 Ash,
34 Econet,
35 Atmsvc,
36 Rds,
37 Sna,
38 Irda,
39 Pppox,
40 Wanpipe,
41 Llc,
42 #[cfg(not(target_os = "android"))]
43 Ib,
44 #[cfg(not(target_os = "android"))]
45 Mpls,
46 Can,
47 Tipc,
48 Bluetooth,
49 Iucv,
50 Rxrpc,
51 Isdn,
52 Phonet,
53 Ieee802154,
54 Caif,
55 Alg,
56 Nfc,
57 Vsock,
58 Kcm,
59 Qipcrtr,
60 Smc,
61 Xdp,
62 Mctp,
63 Other(u8),
64}
65
66impl From<u8> for AddressFamily {
67 fn from(d: u8) -> Self {
68 match d {
69 d if d == libc::AF_UNSPEC as u8 => Self::Unspec,
70 d if d == libc::AF_UNIX as u8 => Self::Unix,
71 d if d == libc::AF_LOCAL as u8 => Self::Local,
72 d if d == libc::AF_INET as u8 => Self::Inet,
73 d if d == libc::AF_AX25 as u8 => Self::Ax25,
74 d if d == libc::AF_IPX as u8 => Self::Ipx,
75 d if d == libc::AF_APPLETALK as u8 => Self::Appletalk,
76 d if d == libc::AF_NETROM as u8 => Self::Netrom,
77 d if d == libc::AF_BRIDGE as u8 => Self::Bridge,
78 d if d == libc::AF_ATMPVC as u8 => Self::Atmpvc,
79 d if d == libc::AF_X25 as u8 => Self::X25,
80 d if d == libc::AF_INET6 as u8 => Self::Inet6,
81 d if d == libc::AF_ROSE as u8 => Self::Rose,
82 d if d == libc::AF_DECnet as u8 => Self::Decnet,
83 d if d == libc::AF_NETBEUI as u8 => Self::Netbeui,
84 d if d == libc::AF_SECURITY as u8 => Self::Security,
85 d if d == libc::AF_KEY as u8 => Self::Key,
86 d if d == libc::AF_NETLINK as u8 => Self::Netlink,
87 d if d == libc::AF_ROUTE as u8 => Self::Route,
88 d if d == libc::AF_PACKET as u8 => Self::Packet,
89 d if d == libc::AF_ASH as u8 => Self::Ash,
90 d if d == libc::AF_ECONET as u8 => Self::Econet,
91 d if d == libc::AF_ATMSVC as u8 => Self::Atmsvc,
92 d if d == libc::AF_RDS as u8 => Self::Rds,
93 d if d == libc::AF_SNA as u8 => Self::Sna,
94 d if d == libc::AF_IRDA as u8 => Self::Irda,
95 d if d == libc::AF_PPPOX as u8 => Self::Pppox,
96 d if d == libc::AF_WANPIPE as u8 => Self::Wanpipe,
97 d if d == libc::AF_LLC as u8 => Self::Llc,
98 #[cfg(not(target_os = "android"))]
99 d if d == libc::AF_IB as u8 => Self::Ib,
100 #[cfg(not(target_os = "android"))]
101 d if d == libc::AF_MPLS as u8 => Self::Mpls,
102 d if d == libc::AF_CAN as u8 => Self::Can,
103 d if d == libc::AF_TIPC as u8 => Self::Tipc,
104 d if d == libc::AF_BLUETOOTH as u8 => Self::Bluetooth,
105 d if d == libc::AF_IUCV as u8 => Self::Iucv,
106 d if d == libc::AF_RXRPC as u8 => Self::Rxrpc,
107 d if d == libc::AF_ISDN as u8 => Self::Isdn,
108 d if d == libc::AF_PHONET as u8 => Self::Phonet,
109 d if d == libc::AF_IEEE802154 as u8 => Self::Ieee802154,
110 d if d == libc::AF_CAIF as u8 => Self::Caif,
111 d if d == libc::AF_ALG as u8 => Self::Alg,
112 d if d == libc::AF_NFC as u8 => Self::Nfc,
113 d if d == libc::AF_VSOCK as u8 => Self::Vsock,
114 d if d == AF_KCM => Self::Kcm,
115 d if d == AF_QIPCRTR => Self::Qipcrtr,
116 d if d == AF_SMC => Self::Smc,
117 d if d == AF_XDP => Self::Xdp,
118 d if d == AF_MCTP => Self::Mctp,
119 _ => Self::Other(d),
120 }
121 }
122}
123
124impl From<AddressFamily> for u8 {
125 fn from(v: AddressFamily) -> u8 {
126 match v {
127 AddressFamily::Unspec => libc::AF_UNSPEC as u8,
128 AddressFamily::Local => libc::AF_LOCAL as u8,
129 AddressFamily::Unix => libc::AF_UNIX as u8,
130 AddressFamily::Inet => libc::AF_INET as u8,
131 AddressFamily::Ax25 => libc::AF_AX25 as u8,
132 AddressFamily::Ipx => libc::AF_IPX as u8,
133 AddressFamily::Appletalk => libc::AF_APPLETALK as u8,
134 AddressFamily::Netrom => libc::AF_NETROM as u8,
135 AddressFamily::Bridge => libc::AF_BRIDGE as u8,
136 AddressFamily::Atmpvc => libc::AF_ATMPVC as u8,
137 AddressFamily::X25 => libc::AF_X25 as u8,
138 AddressFamily::Inet6 => libc::AF_INET6 as u8,
139 AddressFamily::Rose => libc::AF_ROSE as u8,
140 AddressFamily::Decnet => libc::AF_DECnet as u8,
141 AddressFamily::Netbeui => libc::AF_NETBEUI as u8,
142 AddressFamily::Security => libc::AF_SECURITY as u8,
143 AddressFamily::Key => libc::AF_KEY as u8,
144 AddressFamily::Route => libc::AF_ROUTE as u8,
145 AddressFamily::Netlink => libc::AF_NETLINK as u8,
146 AddressFamily::Packet => libc::AF_PACKET as u8,
147 AddressFamily::Ash => libc::AF_ASH as u8,
148 AddressFamily::Econet => libc::AF_ECONET as u8,
149 AddressFamily::Atmsvc => libc::AF_ATMSVC as u8,
150 AddressFamily::Rds => libc::AF_RDS as u8,
151 AddressFamily::Sna => libc::AF_SNA as u8,
152 AddressFamily::Irda => libc::AF_IRDA as u8,
153 AddressFamily::Pppox => libc::AF_PPPOX as u8,
154 AddressFamily::Wanpipe => libc::AF_WANPIPE as u8,
155 AddressFamily::Llc => libc::AF_LLC as u8,
156 #[cfg(not(target_os = "android"))]
157 AddressFamily::Ib => libc::AF_IB as u8,
158 #[cfg(not(target_os = "android"))]
159 AddressFamily::Mpls => libc::AF_MPLS as u8,
160 AddressFamily::Can => libc::AF_CAN as u8,
161 AddressFamily::Tipc => libc::AF_TIPC as u8,
162 AddressFamily::Bluetooth => libc::AF_BLUETOOTH as u8,
163 AddressFamily::Iucv => libc::AF_IUCV as u8,
164 AddressFamily::Rxrpc => libc::AF_RXRPC as u8,
165 AddressFamily::Isdn => libc::AF_ISDN as u8,
166 AddressFamily::Phonet => libc::AF_PHONET as u8,
167 AddressFamily::Ieee802154 => libc::AF_IEEE802154 as u8,
168 AddressFamily::Caif => libc::AF_CAIF as u8,
169 AddressFamily::Alg => libc::AF_ALG as u8,
170 AddressFamily::Nfc => libc::AF_NFC as u8,
171 AddressFamily::Vsock => libc::AF_VSOCK as u8,
172 AddressFamily::Kcm => AF_KCM,
173 AddressFamily::Qipcrtr => AF_QIPCRTR,
174 AddressFamily::Smc => AF_SMC,
175 AddressFamily::Xdp => AF_XDP,
176 AddressFamily::Mctp => AF_MCTP,
177 AddressFamily::Other(d) => d,
178 }
179 }
180}