Skip to content

Commit 138adca

Browse files
committed
fix, mostly, solaris build.
With few exceptions as newer interfaces like preadv/pwritev unsupported only on solaris.
1 parent b763d73 commit 138adca

19 files changed

+124
-107
lines changed

changelog/2248.fixed.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed solaris build globally.

src/ifaddrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl InterfaceAddress {
9494
unsafe { SockaddrStorage::from_raw(info.ifa_netmask, None) };
9595
let mut addr = InterfaceAddress {
9696
interface_name: ifname.to_string_lossy().to_string(),
97-
flags: InterfaceFlags::from_bits_truncate(info.ifa_flags as i32),
97+
flags: InterfaceFlags::from_bits_truncate(info.ifa_flags as IflagsType),
9898
address,
9999
netmask,
100100
broadcast: None,

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ feature! {
125125

126126
#[cfg(any(linux_android,
127127
bsd,
128-
target_os = "illumos"))]
128+
solarish))]
129129
#[deny(missing_docs)]
130130
pub mod ifaddrs;
131131
#[cfg(not(target_os = "redox"))]

src/net/if_.rs

+64-55
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ use std::fmt;
77
use crate::{Error, NixPath, Result};
88
use 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.
1118
pub 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

2229
libc_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
))]
252261
mod 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
))]
379388
pub use if_nameindex::*;

src/sys/ioctl/bsd.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/// The datatype used for the ioctl number
22
#[doc(hidden)]
3-
#[cfg(not(target_os = "illumos"))]
3+
#[cfg(not(solarish))]
44
pub type ioctl_num_type = ::libc::c_ulong;
55

66
#[doc(hidden)]
7-
#[cfg(target_os = "illumos")]
7+
#[cfg(solarish)]
88
pub type ioctl_num_type = ::libc::c_int;
99

1010
/// The datatype used for the 3rd argument

src/sys/ioctl/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ mod linux;
234234
#[cfg(any(linux_android, target_os = "redox"))]
235235
pub use self::linux::*;
236236

237-
#[cfg(any(bsd, target_os = "illumos", target_os = "haiku",))]
237+
#[cfg(any(bsd, solarish, target_os = "haiku",))]
238238
#[macro_use]
239239
mod bsd;
240240

241-
#[cfg(any(bsd, target_os = "illumos", target_os = "haiku",))]
241+
#[cfg(any(bsd, solarish, target_os = "haiku",))]
242242
pub use self::bsd::*;
243243

244244
/// Convert raw ioctl return value to a Nix result

src/sys/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ feature! {
3131
pub mod fanotify;
3232
}
3333

34-
#[cfg(any(bsd, linux_android, target_os = "redox", target_os = "illumos"))]
34+
#[cfg(any(bsd, linux_android, target_os = "redox", solarish))]
3535
#[cfg(feature = "ioctl")]
3636
#[cfg_attr(docsrs, doc(cfg(feature = "ioctl")))]
3737
#[macro_use]
@@ -88,7 +88,7 @@ feature! {
8888
#[cfg(not(any(
8989
target_os = "redox",
9090
target_os = "fuchsia",
91-
target_os = "illumos",
91+
solarish,
9292
target_os = "haiku"
9393
)))]
9494
feature! {
@@ -182,7 +182,7 @@ feature! {
182182
#[cfg(all(
183183
any(
184184
target_os = "freebsd",
185-
target_os = "illumos",
185+
solarish,
186186
target_os = "linux",
187187
target_os = "netbsd"
188188
),

0 commit comments

Comments
 (0)