@@ -7,6 +7,13 @@ use std::fmt;
77use crate :: { Error , NixPath , Result } ;
88use libc:: c_uint;
99
10+ #[ cfg( not( solarish) ) ]
11+ /// type alias for InterfaceFlags
12+ pub type IflagsType = libc:: c_int ;
13+ #[ cfg( solarish) ]
14+ /// type alias for InterfaceFlags
15+ pub type IflagsType = libc:: c_longlong ;
16+
1017/// Resolve an interface into a interface number.
1118pub fn if_nametoindex < P : ?Sized + NixPath > ( name : & P ) -> Result < c_uint > {
1219 let if_index = name
@@ -21,23 +28,24 @@ pub fn if_nametoindex<P: ?Sized + NixPath>(name: &P) -> Result<c_uint> {
2128
2229libc_bitflags ! (
2330 /// Standard interface flags, used by `getifaddrs`
24- pub struct InterfaceFlags : libc:: c_int {
31+ pub struct InterfaceFlags : IflagsType {
32+
2533 /// Interface is running. (see
2634 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
27- IFF_UP ;
35+ IFF_UP as IflagsType ;
2836 /// Valid broadcast address set. (see
2937 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
30- IFF_BROADCAST ;
38+ IFF_BROADCAST as IflagsType ;
3139 /// Internal debugging flag. (see
3240 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
3341 #[ cfg( not( target_os = "haiku" ) ) ]
34- IFF_DEBUG ;
42+ IFF_DEBUG as IflagsType ;
3543 /// Interface is a loopback interface. (see
3644 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
37- IFF_LOOPBACK ;
45+ IFF_LOOPBACK as IflagsType ;
3846 /// Interface is a point-to-point link. (see
3947 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
40- IFF_POINTOPOINT ;
48+ IFF_POINTOPOINT as IflagsType ;
4149 /// Avoid use of trailers. (see
4250 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
4351 #[ cfg( any(
@@ -46,27 +54,27 @@ libc_bitflags!(
4654 apple_targets,
4755 target_os = "fuchsia" ,
4856 target_os = "netbsd" ) ) ]
49- IFF_NOTRAILERS ;
57+ IFF_NOTRAILERS as IflagsType ;
5058 /// Interface manages own routes.
5159 #[ cfg( any( target_os = "dragonfly" ) ) ]
52- IFF_SMART ;
60+ IFF_SMART as IflagsType ;
5361 /// Resources allocated. (see
5462 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
5563 #[ cfg( any(
5664 linux_android,
5765 bsd,
5866 solarish,
5967 target_os = "fuchsia" ) ) ]
60- IFF_RUNNING ;
68+ IFF_RUNNING as IflagsType ;
6169 /// No arp protocol, L2 destination address not set. (see
6270 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
63- IFF_NOARP ;
71+ IFF_NOARP as IflagsType ;
6472 /// Interface is in promiscuous mode. (see
6573 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
66- IFF_PROMISC ;
74+ IFF_PROMISC as IflagsType ;
6775 /// Receive all multicast packets. (see
6876 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
69- IFF_ALLMULTI ;
77+ IFF_ALLMULTI as IflagsType ;
7078 /// Master of a load balancing bundle. (see
7179 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
7280 #[ cfg( any( linux_android, target_os = "fuchsia" ) ) ]
@@ -76,7 +84,7 @@ libc_bitflags!(
7684 IFF_OACTIVE ;
7785 /// Protocol code on board.
7886 #[ cfg( solarish) ]
79- IFF_INTELLIGENT ;
87+ IFF_INTELLIGENT as IflagsType ;
8088 /// Slave of a load balancing bundle. (see
8189 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
8290 #[ cfg( any( linux_android, target_os = "fuchsia" ) ) ]
@@ -86,13 +94,13 @@ libc_bitflags!(
8694 IFF_SIMPLEX ;
8795 /// Supports multicast. (see
8896 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
89- IFF_MULTICAST ;
97+ IFF_MULTICAST as IflagsType ;
9098 /// Per link layer defined bit.
9199 #[ cfg( bsd) ]
92100 IFF_LINK0 ;
93101 /// Multicast using broadcast.
94102 #[ cfg( solarish) ]
95- IFF_MULTI_BCAST ;
103+ IFF_MULTI_BCAST as IflagsType ;
96104 /// Is able to select media type via ifmap. (see
97105 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
98106 #[ cfg( any( linux_android, target_os = "fuchsia" ) ) ]
@@ -102,7 +110,7 @@ libc_bitflags!(
102110 IFF_LINK1 ;
103111 /// Non-unique address.
104112 #[ cfg( solarish) ]
105- IFF_UNNUMBERED ;
113+ IFF_UNNUMBERED as IflagsType ;
106114 /// Auto media selection active. (see
107115 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
108116 #[ cfg( any( linux_android, target_os = "fuchsia" ) ) ]
@@ -115,14 +123,14 @@ libc_bitflags!(
115123 IFF_ALTPHYS ;
116124 /// DHCP controls interface.
117125 #[ cfg( solarish) ]
118- IFF_DHCPRUNNING ;
126+ IFF_DHCPRUNNING as IflagsType ;
119127 /// The addresses are lost when the interface goes down. (see
120128 /// [`netdevice(7)`](https://man7.org/linux/man-pages/man7/netdevice.7.html))
121129 #[ cfg( any( linux_android, target_os = "fuchsia" ) ) ]
122130 IFF_DYNAMIC ;
123131 /// Do not advertise.
124132 #[ cfg( solarish) ]
125- IFF_PRIVATE ;
133+ IFF_PRIVATE as IflagsType ;
126134 /// Driver signals L1 up. Volatile.
127135 #[ cfg( any( target_os = "fuchsia" , target_os = "linux" ) ) ]
128136 IFF_LOWER_UP ;
@@ -134,7 +142,7 @@ libc_bitflags!(
134142 IFF_CANTCONFIG ;
135143 /// Do not transmit packets.
136144 #[ cfg( solarish) ]
137- IFF_NOXMIT ;
145+ IFF_NOXMIT as IflagsType ;
138146 /// Driver signals dormant. Volatile.
139147 #[ cfg( any( target_os = "fuchsia" , target_os = "linux" ) ) ]
140148 IFF_DORMANT ;
@@ -143,7 +151,7 @@ libc_bitflags!(
143151 IFF_PPROMISC ;
144152 /// Just on-link subnet.
145153 #[ cfg( solarish) ]
146- IFF_NOLOCAL ;
154+ IFF_NOLOCAL as IflagsType ;
147155 /// Echo sent packets. Volatile.
148156 #[ cfg( any( target_os = "fuchsia" , target_os = "linux" ) ) ]
149157 IFF_ECHO ;
@@ -152,19 +160,19 @@ libc_bitflags!(
152160 IFF_MONITOR ;
153161 /// Address is deprecated.
154162 #[ cfg( solarish) ]
155- IFF_DEPRECATED ;
163+ IFF_DEPRECATED as IflagsType ;
156164 /// Static ARP.
157165 #[ cfg( freebsdlike) ]
158166 IFF_STATICARP ;
159167 /// Address from stateless addrconf.
160168 #[ cfg( solarish) ]
161- IFF_ADDRCONF ;
169+ IFF_ADDRCONF as IflagsType ;
162170 /// Interface is in polling mode.
163171 #[ cfg( any( target_os = "dragonfly" ) ) ]
164172 IFF_NPOLLING ;
165173 /// Router on interface.
166174 #[ cfg( solarish) ]
167- IFF_ROUTER ;
175+ IFF_ROUTER as IflagsType ;
168176 /// Interface is in polling mode.
169177 #[ cfg( any( target_os = "dragonfly" ) ) ]
170178 IFF_IDIRECT ;
@@ -173,66 +181,67 @@ libc_bitflags!(
173181 IFF_DYING ;
174182 /// No NUD on interface.
175183 #[ cfg( solarish) ]
176- IFF_NONUD ;
184+ IFF_NONUD as IflagsType ;
177185 /// Interface is being renamed
178186 #[ cfg( any( target_os = "freebsd" ) ) ]
179187 IFF_RENAMING ;
180188 /// Anycast address.
181189 #[ cfg( solarish) ]
182- IFF_ANYCAST ;
190+ IFF_ANYCAST as IflagsType ;
183191 /// Don't exchange routing info.
184192 #[ cfg( solarish) ]
185- IFF_NORTEXCH ;
193+ IFF_NORTEXCH as IflagsType ;
186194 /// Do not provide packet information
187195 #[ cfg( any( linux_android, target_os = "fuchsia" ) ) ]
188- IFF_NO_PI as libc :: c_int ;
196+ IFF_NO_PI as IflagsType ;
189197 /// TUN device (no Ethernet headers)
190198 #[ cfg( any( linux_android, target_os = "fuchsia" ) ) ]
191- IFF_TUN as libc :: c_int ;
199+ IFF_TUN as IflagsType ;
192200 /// TAP device
193201 #[ cfg( any( linux_android, target_os = "fuchsia" ) ) ]
194- IFF_TAP as libc :: c_int ;
202+ IFF_TAP as IflagsType ;
195203 /// IPv4 interface.
196204 #[ cfg( solarish) ]
197- IFF_IPV4 ;
205+ IFF_IPV4 as IflagsType ;
198206 /// IPv6 interface.
199207 #[ cfg( solarish) ]
200- IFF_IPV6 ;
208+ IFF_IPV6 as IflagsType ;
201209 /// in.mpathd test address
202210 #[ cfg( solarish) ]
203- IFF_NOFAILOVER ;
211+ IFF_NOFAILOVER as IflagsType ;
204212 /// Interface has failed
205213 #[ cfg( solarish) ]
206- IFF_FAILED ;
214+ IFF_FAILED as IflagsType ;
207215 /// Interface is a hot-spare
208216 #[ cfg( solarish) ]
209- IFF_STANDBY ;
217+ IFF_STANDBY as IflagsType ;
210218 /// Functioning but not used
211219 #[ cfg( solarish) ]
212- IFF_INACTIVE ;
220+ IFF_INACTIVE as IflagsType ;
213221 /// Interface is offline
214222 #[ cfg( solarish) ]
215- IFF_OFFLINE ;
216- #[ cfg( target_os = "solaris" ) ]
217- IFF_COS_ENABLED ;
218- /// Prefer as source addr.
219- #[ cfg( target_os = "solaris" ) ]
220- IFF_PREFERRED ;
223+ IFF_OFFLINE as IflagsType ;
224+ /// Has CoS marking supported
225+ #[ cfg( solarish) ]
226+ IFF_COS_ENABLED as IflagsType ;
227+ /// Prefer as source addr
228+ #[ cfg( solarish) ]
229+ IFF_PREFERRED as IflagsType ;
221230 /// RFC3041
222- #[ cfg( target_os = "solaris" ) ]
223- IFF_TEMPORARY ;
224- /// MTU set with SIOCSLIFMTU
225- #[ cfg( target_os = "solaris" ) ]
226- IFF_FIXEDMTU ;
227- /// Cannot send / receive packets
228- #[ cfg( target_os = "solaris" ) ]
229- IFF_VIRTUAL ;
231+ #[ cfg( solarish ) ]
232+ IFF_TEMPORARY as IflagsType ;
233+ /// MTU set
234+ #[ cfg( solarish ) ]
235+ IFF_FIXEDMTU as IflagsType ;
236+ /// Cannot send/ receive packets
237+ #[ cfg( solarish ) ]
238+ IFF_VIRTUAL as IflagsType ;
230239 /// Local address in use
231- #[ cfg( target_os = "solaris" ) ]
232- IFF_DUPLICATE ;
240+ #[ cfg( solarish ) ]
241+ IFF_DUPLICATE as IflagsType ;
233242 /// IPMP IP interface
234- #[ cfg( target_os = "solaris" ) ]
235- IFF_IPMP ;
243+ #[ cfg( solarish ) ]
244+ IFF_IPMP as IflagsType ;
236245 }
237246) ;
238247
@@ -247,7 +256,7 @@ impl fmt::Display for InterfaceFlags {
247256 bsd,
248257 target_os = "fuchsia" ,
249258 target_os = "linux" ,
250- target_os = "illumos" ,
259+ solarish ,
251260) ) ]
252261mod if_nameindex {
253262 use super :: * ;
@@ -374,6 +383,6 @@ mod if_nameindex {
374383 bsd,
375384 target_os = "fuchsia" ,
376385 target_os = "linux" ,
377- target_os = "illumos" ,
386+ solarish ,
378387) ) ]
379388pub use if_nameindex:: * ;
0 commit comments