Skip to content

Commit c57486c

Browse files
committed
Add RTF_*, RTA_*, RTAX_*, RTM_* definitions on BSDs
* Unify RTM_ADD and friends under bsd namespace * Keeps RTAX_MAX as it is used to loop over alternate internal encoding.
1 parent 72c4000 commit c57486c

File tree

11 files changed

+267
-37
lines changed

11 files changed

+267
-37
lines changed

libc-test/semver/dragonfly.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,31 @@ RLIMIT_STACK
873873
RLIMIT_VMEM
874874
RLIM_INFINITY
875875
RLIM_NLIMITS
876+
RTF_XRESOLVE
877+
RTF_LLINFO
878+
RTF_PROTO3
879+
RTF_PINNED
880+
RTF_LOCAL
881+
RTF_BROADCAST
882+
RTF_MULTICAST
883+
RTM_LOCK
884+
RTM_RESOLVE
885+
RTM_NEWADDR
886+
RTM_DELADDR
887+
RTM_IFINFO
888+
RTM_NEWMADDR
889+
RTM_DELMADDR
890+
RTM_IFANNOUNCE
891+
RTM_IEEE80211
892+
RTF_CLONING
893+
RTF_PRCLONING
894+
RTF_WASCLONED
895+
RTF_MPLSOPS
896+
RTM_VERSION
897+
RTAX_MPLS1
898+
RTAX_MPLS2
899+
RTAX_MPLS3
900+
RTAX_MAX
876901
RTLD_NEXT
877902
RTLD_NODELETE
878903
RTLD_NOLOAD

libc-test/semver/freebsd.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,26 @@ RLIMIT_UMTXP
12221222
RLIMIT_VMEM
12231223
RLIM_INFINITY
12241224
RLIM_NLIMITS
1225+
RTF_XRESOLVE
1226+
RTF_LLINFO
1227+
RTF_PROTO3
1228+
RTF_PINNED
1229+
RTF_LOCAL
1230+
RTF_BROADCAST
1231+
RTF_MULTICAST
1232+
RTM_LOCK
1233+
RTM_RESOLVE
1234+
RTM_NEWADDR
1235+
RTM_DELADDR
1236+
RTM_IFINFO
1237+
RTM_NEWMADDR
1238+
RTM_DELMADDR
1239+
RTM_IFANNOUNCE
1240+
RTM_IEEE80211
1241+
RTF_LLDATA
1242+
RTF_FIXEDMTU
1243+
RTM_VERSION
1244+
RTAX_MAX
12251245
RTLD_NEXT
12261246
RTLD_NODELETE
12271247
RTLD_NOLOAD

libc-test/semver/netbsd.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,28 @@ RLIM_INFINITY
927927
RLIM_NLIMITS
928928
RLIM_SAVED_CUR
929929
RLIM_SAVED_MAX
930+
RTF_MASK
931+
RTF_CONNECTED
932+
RTF_ANNOUNCE
933+
RTF_SRC
934+
RTF_LOCAL
935+
RTF_BROADCAST
936+
RTF_UPDATING
937+
RTF_DONTCHANGEIFA
938+
RTM_VERSION
939+
RTM_LOCK
940+
RTM_IFANNOUNCE
941+
RTM_IEEE80211
942+
RTM_SETGATE
943+
RTM_LLINFO_UPD
944+
RTM_IFINFO
945+
RTM_OCHGADDR
946+
RTM_NEWADDR
947+
RTM_DELADDR
948+
RTM_CHGADDR
949+
RTA_TAG
950+
RTAX_TAG
951+
RTAX_MAX
930952
RTLD_NEXT
931953
RTLD_NOLOAD
932954
RTLD_SELF

libc-test/semver/openbsd.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,50 @@ RLIM_INFINITY
761761
RLIM_NLIMITS
762762
RLIM_SAVED_CUR
763763
RLIM_SAVED_MAX
764+
RTA_BFD
765+
RTA_DNS
766+
RTA_LABEL
767+
RTA_SEARCH
768+
RTA_SRC
769+
RTA_SRCMASK
770+
RTA_STATIC
771+
RTAX_BFD
772+
RTAX_DNS
773+
RTAX_LABEL
774+
RTAX_MAX
775+
RTAX_SEARCH
776+
RTAX_SRC
777+
RTAX_SRCMASK
778+
RTAX_STATIC
779+
RTF_ANNOUNCE
780+
RTF_BFD
781+
RTF_BROADCAST
782+
RTF_CACHED
783+
RTF_CLONED
784+
RTF_CLONING
785+
RTF_CONNECTED
786+
RTF_FMASK
787+
RTF_LLINFO
788+
RTF_LOCAL
789+
RTF_MPATH
790+
RTF_MPLS
791+
RTF_MULTICAST
792+
RTF_PROTO3
764793
RTLD_NEXT
765794
RTLD_SELF
795+
RTM_80211INFO
796+
RTM_BFD
797+
RTM_CHGADDRATTR
798+
RTM_DELADDR
799+
RTM_DESYNC
800+
RTM_IFANNOUNCE
801+
RTM_IFINFO
802+
RTM_INVALIDATE
803+
RTM_NEWADDR
804+
RTM_PROPOSAL
805+
RTM_RESOLVE
806+
RTM_SOURCE
807+
RTM_VERSION
766808
RUSAGE_CHILDREN
767809
RUSAGE_SELF
768810
RUSAGE_THREAD

src/unix/bsd/apple/mod.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4893,22 +4893,11 @@ pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020;
48934893
pub const NET_RT_IFLIST2: ::c_int = 0x0006;
48944894

48954895
// net/route.h
4896-
pub const RTF_UP: ::c_int = 0x1;
4897-
pub const RTF_GATEWAY: ::c_int = 0x2;
4898-
pub const RTF_HOST: ::c_int = 0x4;
4899-
pub const RTF_REJECT: ::c_int = 0x8;
4900-
pub const RTF_DYNAMIC: ::c_int = 0x10;
4901-
pub const RTF_MODIFIED: ::c_int = 0x20;
4902-
pub const RTF_DONE: ::c_int = 0x40;
49034896
pub const RTF_DELCLONE: ::c_int = 0x80;
49044897
pub const RTF_CLONING: ::c_int = 0x100;
49054898
pub const RTF_XRESOLVE: ::c_int = 0x200;
49064899
pub const RTF_LLINFO: ::c_int = 0x400;
4907-
pub const RTF_STATIC: ::c_int = 0x800;
4908-
pub const RTF_BLACKHOLE: ::c_int = 0x1000;
49094900
pub const RTF_NOIFREF: ::c_int = 0x2000;
4910-
pub const RTF_PROTO2: ::c_int = 0x4000;
4911-
pub const RTF_PROTO1: ::c_int = 0x8000;
49124901
pub const RTF_PRCLONING: ::c_int = 0x10000;
49134902
pub const RTF_WASCLONED: ::c_int = 0x20000;
49144903
pub const RTF_PROTO3: ::c_int = 0x40000;
@@ -4927,13 +4916,6 @@ pub const RTF_GLOBAL: ::c_int = 0x40000000;
49274916
pub const RTM_VERSION: ::c_int = 5;
49284917

49294918
// Message types
4930-
pub const RTM_ADD: ::c_int = 0x1;
4931-
pub const RTM_DELETE: ::c_int = 0x2;
4932-
pub const RTM_CHANGE: ::c_int = 0x3;
4933-
pub const RTM_GET: ::c_int = 0x4;
4934-
pub const RTM_LOSING: ::c_int = 0x5;
4935-
pub const RTM_REDIRECT: ::c_int = 0x6;
4936-
pub const RTM_MISS: ::c_int = 0x7;
49374919
pub const RTM_LOCK: ::c_int = 0x8;
49384920
pub const RTM_OLDADD: ::c_int = 0x9;
49394921
pub const RTM_OLDDEL: ::c_int = 0xa;
@@ -4957,25 +4939,6 @@ pub const RTV_SSTHRESH: ::c_int = 0x20;
49574939
pub const RTV_RTT: ::c_int = 0x40;
49584940
pub const RTV_RTTVAR: ::c_int = 0x80;
49594941

4960-
// Bitmask values for rtm_addrs.
4961-
pub const RTA_DST: ::c_int = 0x1;
4962-
pub const RTA_GATEWAY: ::c_int = 0x2;
4963-
pub const RTA_NETMASK: ::c_int = 0x4;
4964-
pub const RTA_GENMASK: ::c_int = 0x8;
4965-
pub const RTA_IFP: ::c_int = 0x10;
4966-
pub const RTA_IFA: ::c_int = 0x20;
4967-
pub const RTA_AUTHOR: ::c_int = 0x40;
4968-
pub const RTA_BRD: ::c_int = 0x80;
4969-
4970-
// Index offsets for sockaddr array for alternate internal encoding.
4971-
pub const RTAX_DST: ::c_int = 0;
4972-
pub const RTAX_GATEWAY: ::c_int = 1;
4973-
pub const RTAX_NETMASK: ::c_int = 2;
4974-
pub const RTAX_GENMASK: ::c_int = 3;
4975-
pub const RTAX_IFP: ::c_int = 4;
4976-
pub const RTAX_IFA: ::c_int = 5;
4977-
pub const RTAX_AUTHOR: ::c_int = 6;
4978-
pub const RTAX_BRD: ::c_int = 7;
49794942
pub const RTAX_MAX: ::c_int = 8;
49804943

49814944
pub const KERN_PROCARGS2: ::c_int = 49;

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,19 @@ pub const NGROUPS: usize = 16;
15221522
pub const RB_PAUSE: ::c_int = 0x40000;
15231523
pub const RB_VIDEO: ::c_int = 0x20000000;
15241524

1525+
// net/route.h
1526+
pub const RTF_CLONING: ::c_int = 0x100;
1527+
pub const RTF_PRCLONING: ::c_int = 0x10000;
1528+
pub const RTF_WASCLONED: ::c_int = 0x20000;
1529+
pub const RTF_MPLSOPS: ::c_int = 0x1000000;
1530+
1531+
pub const RTM_VERSION: ::c_int = 7;
1532+
1533+
pub const RTAX_MPLS1: ::c_int = 8;
1534+
pub const RTAX_MPLS2: ::c_int = 9;
1535+
pub const RTAX_MPLS3: ::c_int = 10;
1536+
pub const RTAX_MAX: ::c_int = 11;
1537+
15251538
const_fn! {
15261539
{const} fn _CMSG_ALIGN(n: usize) -> usize {
15271540
(n + (::mem::size_of::<::c_long>() - 1)) & !(::mem::size_of::<::c_long>() - 1)

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4677,6 +4677,14 @@ pub const CPU_WHICH_CPUSET: ::c_int = 3;
46774677
pub const CPU_WHICH_IRQ: ::c_int = 4;
46784678
pub const CPU_WHICH_JAIL: ::c_int = 5;
46794679

4680+
// net/route.h
4681+
pub const RTF_LLDATA: ::c_int = 0x400;
4682+
pub const RTF_FIXEDMTU: ::c_int = 0x80000;
4683+
4684+
pub const RTM_VERSION: ::c_int = 5;
4685+
4686+
pub const RTAX_MAX: ::c_int = 8;
4687+
46804688
// sys/signal.h
46814689
pub const SIGTHR: ::c_int = 32;
46824690
pub const SIGLWP: ::c_int = SIGTHR;

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,25 @@ pub const SO_TYPE: ::c_int = 0x1008;
10091009

10101010
pub const LOCAL_PEERCRED: ::c_int = 1;
10111011

1012+
// net/route.h
1013+
pub const RTF_XRESOLVE: ::c_int = 0x200;
1014+
pub const RTF_LLINFO: ::c_int = 0x400;
1015+
pub const RTF_PROTO3: ::c_int = 0x40000;
1016+
pub const RTF_PINNED: ::c_int = 0x100000;
1017+
pub const RTF_LOCAL: ::c_int = 0x200000;
1018+
pub const RTF_BROADCAST: ::c_int = 0x400000;
1019+
pub const RTF_MULTICAST: ::c_int = 0x800000;
1020+
1021+
pub const RTM_LOCK: ::c_int = 0x8;
1022+
pub const RTM_RESOLVE: ::c_int = 0xb;
1023+
pub const RTM_NEWADDR: ::c_int = 0xc;
1024+
pub const RTM_DELADDR: ::c_int = 0xd;
1025+
pub const RTM_IFINFO: ::c_int = 0xe;
1026+
pub const RTM_NEWMADDR: ::c_int = 0xf;
1027+
pub const RTM_DELMADDR: ::c_int = 0x10;
1028+
pub const RTM_IFANNOUNCE: ::c_int = 0x11;
1029+
pub const RTM_IEEE80211: ::c_int = 0x12;
1030+
10121031
pub const SHUT_RD: ::c_int = 0;
10131032
pub const SHUT_WR: ::c_int = 1;
10141033
pub const SHUT_RDWR: ::c_int = 2;

src/unix/bsd/mod.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,49 @@ pub const ITIMER_REAL: ::c_int = 0;
543543
pub const ITIMER_VIRTUAL: ::c_int = 1;
544544
pub const ITIMER_PROF: ::c_int = 2;
545545

546+
// net/route.h
547+
548+
pub const RTF_UP: ::c_int = 0x1;
549+
pub const RTF_GATEWAY: ::c_int = 0x2;
550+
pub const RTF_HOST: ::c_int = 0x4;
551+
pub const RTF_REJECT: ::c_int = 0x8;
552+
pub const RTF_DYNAMIC: ::c_int = 0x10;
553+
pub const RTF_MODIFIED: ::c_int = 0x20;
554+
pub const RTF_DONE: ::c_int = 0x40;
555+
pub const RTF_STATIC: ::c_int = 0x800;
556+
pub const RTF_BLACKHOLE: ::c_int = 0x1000;
557+
pub const RTF_PROTO2: ::c_int = 0x4000;
558+
pub const RTF_PROTO1: ::c_int = 0x8000;
559+
560+
// Message types
561+
pub const RTM_ADD: ::c_int = 0x1;
562+
pub const RTM_DELETE: ::c_int = 0x2;
563+
pub const RTM_CHANGE: ::c_int = 0x3;
564+
pub const RTM_GET: ::c_int = 0x4;
565+
pub const RTM_LOSING: ::c_int = 0x5;
566+
pub const RTM_REDIRECT: ::c_int = 0x6;
567+
pub const RTM_MISS: ::c_int = 0x7;
568+
569+
// Bitmask values for rtm_addrs.
570+
pub const RTA_DST: ::c_int = 0x1;
571+
pub const RTA_GATEWAY: ::c_int = 0x2;
572+
pub const RTA_NETMASK: ::c_int = 0x4;
573+
pub const RTA_GENMASK: ::c_int = 0x8;
574+
pub const RTA_IFP: ::c_int = 0x10;
575+
pub const RTA_IFA: ::c_int = 0x20;
576+
pub const RTA_AUTHOR: ::c_int = 0x40;
577+
pub const RTA_BRD: ::c_int = 0x80;
578+
579+
// Index offsets for sockaddr array for alternate internal encoding.
580+
pub const RTAX_DST: ::c_int = 0;
581+
pub const RTAX_GATEWAY: ::c_int = 1;
582+
pub const RTAX_NETMASK: ::c_int = 2;
583+
pub const RTAX_GENMASK: ::c_int = 3;
584+
pub const RTAX_IFP: ::c_int = 4;
585+
pub const RTAX_IFA: ::c_int = 5;
586+
pub const RTAX_AUTHOR: ::c_int = 6;
587+
pub const RTAX_BRD: ::c_int = 7;
588+
546589
f! {
547590
pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr {
548591
if (*mhdr).msg_controllen as usize >= ::mem::size_of::<::cmsghdr>() {

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,6 +2400,33 @@ pub const fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int {
24002400
alignment << MAP_ALIGNMENT_SHIFT
24012401
}
24022402

2403+
// net/route.h
2404+
pub const RTF_MASK: ::c_int = 0x80;
2405+
pub const RTF_CONNECTED: ::c_int = 0x100;
2406+
pub const RTF_ANNOUNCE: ::c_int = 0x20000;
2407+
pub const RTF_SRC: ::c_int = 0x10000;
2408+
pub const RTF_LOCAL: ::c_int = 0x40000;
2409+
pub const RTF_BROADCAST: ::c_int = 0x80000;
2410+
pub const RTF_UPDATING: ::c_int = 0x100000;
2411+
pub const RTF_DONTCHANGEIFA: ::c_int = 0x200000;
2412+
2413+
pub const RTM_VERSION: ::c_int = 4;
2414+
pub const RTM_LOCK: ::c_int = 0x8;
2415+
pub const RTM_IFANNOUNCE: ::c_int = 0x10;
2416+
pub const RTM_IEEE80211: ::c_int = 0x11;
2417+
pub const RTM_SETGATE: ::c_int = 0x12;
2418+
pub const RTM_LLINFO_UPD: ::c_int = 0x13;
2419+
pub const RTM_IFINFO: ::c_int = 0x14;
2420+
pub const RTM_OCHGADDR: ::c_int = 0x15;
2421+
pub const RTM_NEWADDR: ::c_int = 0x16;
2422+
pub const RTM_DELADDR: ::c_int = 0x17;
2423+
pub const RTM_CHGADDR: ::c_int = 0x18;
2424+
2425+
pub const RTA_TAG: ::c_int = 0x100;
2426+
2427+
pub const RTAX_TAG: ::c_int = 8;
2428+
pub const RTAX_MAX: ::c_int = 9;
2429+
24032430
const_fn! {
24042431
{const} fn _ALIGN(p: usize) -> usize {
24052432
(p + _ALIGNBYTES) & !_ALIGNBYTES

0 commit comments

Comments
 (0)