Skip to content

Commit 987dc97

Browse files
committed
freebsd: move net/if_mib.h contents to submodule
There is a conflict of NETLINK_GENERIC definitions between net/if_mib.h and netlink/netlink.h. netlink.h is already exported in the crate root for Linux (and those definitions are already used by at least crates neli and netlink-packet-route), and if_mib is not much used yet, so this moves if_mib contents into its own namespace to leave place for netlink support on FreeBSD (#3194). Module definition moved to the end of file to avoid cryptic style.rs error "constant found after module when it belongs before". ctest as of 0.22 cannot be told a given header's symbols live in a submodule, so let the tests ignore all of them. Signed-off-by: Yann Dirson <[email protected]>
1 parent fe5fe49 commit 987dc97

File tree

3 files changed

+74
-45
lines changed

3 files changed

+74
-45
lines changed

libc-test/build.rs

+27
Original file line numberDiff line numberDiff line change
@@ -2426,6 +2426,33 @@ fn test_freebsd(target: &str) {
24262426
// Added in FreeBSD 14
24272427
"TFD_CLOEXEC" | "TFD_NONBLOCK" if Some(14) > freebsd_ver => true,
24282428

2429+
// submodule ifmib, cannot be checked today
2430+
"DOT3COMPLIANCE_STATS"
2431+
| "DOT3COMPLIANCE_COLLS"
2432+
| "IFDATA_GENERAL"
2433+
| "IFDATA_LINKSPECIFIC"
2434+
| "IFDATA_DRIVERNAME"
2435+
| "IFMIB_IFCOUNT"
2436+
| "IFMIB_IFDATA"
2437+
| "IFMIB_SYSTEM"
2438+
| "NETLINK_GENERIC"
2439+
| "dot3ChipSetAMD7990"
2440+
| "dot3ChipSetAMD79900"
2441+
| "dot3ChipSetAMD79C940"
2442+
| "dot3ChipSetIntel82586"
2443+
| "dot3ChipSetIntel82596"
2444+
| "dot3ChipSetIntel82557"
2445+
| "dot3ChipSetNational8390"
2446+
| "dot3ChipSetNationalSonic"
2447+
| "dot3ChipSetFujitsu86950"
2448+
| "dot3ChipSetDigitalDC21040"
2449+
| "dot3ChipSetDigitalDC21140"
2450+
| "dot3ChipSetDigitalDC21041"
2451+
| "dot3ChipSetDigitalDC21140A"
2452+
| "dot3ChipSetDigitalDC21142"
2453+
| "dot3ChipSetWesternDigital83C690"
2454+
| "dot3ChipSetWesternDigital83C790" => true,
2455+
24292456
_ => false,
24302457
}
24312458
});
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// sys/net/if_mib.h
2+
3+
/// non-interface-specific
4+
pub const IFMIB_SYSTEM: ::c_int = 1;
5+
/// per-interface data table
6+
pub const IFMIB_IFDATA: ::c_int = 2;
7+
8+
/// generic stats for all kinds of ifaces
9+
pub const IFDATA_GENERAL: ::c_int = 1;
10+
/// specific to the type of interface
11+
pub const IFDATA_LINKSPECIFIC: ::c_int = 2;
12+
/// driver name and unit
13+
pub const IFDATA_DRIVERNAME: ::c_int = 3;
14+
15+
/// number of interfaces configured
16+
pub const IFMIB_IFCOUNT: ::c_int = 1;
17+
18+
/// functions not specific to a type of iface
19+
pub const NETLINK_GENERIC: ::c_int = 0;
20+
21+
pub const DOT3COMPLIANCE_STATS: ::c_int = 1;
22+
pub const DOT3COMPLIANCE_COLLS: ::c_int = 2;
23+
24+
pub const dot3ChipSetAMD7990: ::c_int = 1;
25+
pub const dot3ChipSetAMD79900: ::c_int = 2;
26+
pub const dot3ChipSetAMD79C940: ::c_int = 3;
27+
28+
pub const dot3ChipSetIntel82586: ::c_int = 1;
29+
pub const dot3ChipSetIntel82596: ::c_int = 2;
30+
pub const dot3ChipSetIntel82557: ::c_int = 3;
31+
32+
pub const dot3ChipSetNational8390: ::c_int = 1;
33+
pub const dot3ChipSetNationalSonic: ::c_int = 2;
34+
35+
pub const dot3ChipSetFujitsu86950: ::c_int = 1;
36+
37+
pub const dot3ChipSetDigitalDC21040: ::c_int = 1;
38+
pub const dot3ChipSetDigitalDC21140: ::c_int = 2;
39+
pub const dot3ChipSetDigitalDC21041: ::c_int = 3;
40+
pub const dot3ChipSetDigitalDC21140A: ::c_int = 4;
41+
pub const dot3ChipSetDigitalDC21142: ::c_int = 5;
42+
43+
pub const dot3ChipSetWesternDigital83C690: ::c_int = 1;
44+
pub const dot3ChipSetWesternDigital83C790: ::c_int = 2;

src/unix/bsd/freebsdlike/freebsd/mod.rs

+3-45
Original file line numberDiff line numberDiff line change
@@ -3359,51 +3359,6 @@ pub const IFDR_MSG_SIZE: ::c_int = 64;
33593359
pub const IFDR_REASON_MSG: ::c_int = 1;
33603360
pub const IFDR_REASON_VENDOR: ::c_int = 2;
33613361

3362-
// sys/net/if_mib.h
3363-
3364-
/// non-interface-specific
3365-
pub const IFMIB_SYSTEM: ::c_int = 1;
3366-
/// per-interface data table
3367-
pub const IFMIB_IFDATA: ::c_int = 2;
3368-
3369-
/// generic stats for all kinds of ifaces
3370-
pub const IFDATA_GENERAL: ::c_int = 1;
3371-
/// specific to the type of interface
3372-
pub const IFDATA_LINKSPECIFIC: ::c_int = 2;
3373-
/// driver name and unit
3374-
pub const IFDATA_DRIVERNAME: ::c_int = 3;
3375-
3376-
/// number of interfaces configured
3377-
pub const IFMIB_IFCOUNT: ::c_int = 1;
3378-
3379-
/// functions not specific to a type of iface
3380-
pub const NETLINK_GENERIC: ::c_int = 0;
3381-
3382-
pub const DOT3COMPLIANCE_STATS: ::c_int = 1;
3383-
pub const DOT3COMPLIANCE_COLLS: ::c_int = 2;
3384-
3385-
pub const dot3ChipSetAMD7990: ::c_int = 1;
3386-
pub const dot3ChipSetAMD79900: ::c_int = 2;
3387-
pub const dot3ChipSetAMD79C940: ::c_int = 3;
3388-
3389-
pub const dot3ChipSetIntel82586: ::c_int = 1;
3390-
pub const dot3ChipSetIntel82596: ::c_int = 2;
3391-
pub const dot3ChipSetIntel82557: ::c_int = 3;
3392-
3393-
pub const dot3ChipSetNational8390: ::c_int = 1;
3394-
pub const dot3ChipSetNationalSonic: ::c_int = 2;
3395-
3396-
pub const dot3ChipSetFujitsu86950: ::c_int = 1;
3397-
3398-
pub const dot3ChipSetDigitalDC21040: ::c_int = 1;
3399-
pub const dot3ChipSetDigitalDC21140: ::c_int = 2;
3400-
pub const dot3ChipSetDigitalDC21041: ::c_int = 3;
3401-
pub const dot3ChipSetDigitalDC21140A: ::c_int = 4;
3402-
pub const dot3ChipSetDigitalDC21142: ::c_int = 5;
3403-
3404-
pub const dot3ChipSetWesternDigital83C690: ::c_int = 1;
3405-
pub const dot3ChipSetWesternDigital83C790: ::c_int = 2;
3406-
34073362
// sys/netinet/in.h
34083363
// Protocols (RFC 1700)
34093364
// NOTE: These are in addition to the constants defined in src/unix/mod.rs
@@ -5751,3 +5706,6 @@ cfg_if! {
57515706
// Unknown target_arch
57525707
}
57535708
}
5709+
5710+
// sys/net/if_mib.h
5711+
pub mod ifmib;

0 commit comments

Comments
 (0)