Skip to content

Commit cacee27

Browse files
tesujitgross35
authored andcommitted
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. (backport <#3714>) (cherry picked from commit e1566fd)
1 parent 8af2362 commit cacee27

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
@@ -874,6 +874,31 @@ RLIMIT_STACK
874874
RLIMIT_VMEM
875875
RLIM_INFINITY
876876
RLIM_NLIMITS
877+
RTF_XRESOLVE
878+
RTF_LLINFO
879+
RTF_PROTO3
880+
RTF_PINNED
881+
RTF_LOCAL
882+
RTF_BROADCAST
883+
RTF_MULTICAST
884+
RTM_LOCK
885+
RTM_RESOLVE
886+
RTM_NEWADDR
887+
RTM_DELADDR
888+
RTM_IFINFO
889+
RTM_NEWMADDR
890+
RTM_DELMADDR
891+
RTM_IFANNOUNCE
892+
RTM_IEEE80211
893+
RTF_CLONING
894+
RTF_PRCLONING
895+
RTF_WASCLONED
896+
RTF_MPLSOPS
897+
RTM_VERSION
898+
RTAX_MPLS1
899+
RTAX_MPLS2
900+
RTAX_MPLS3
901+
RTAX_MAX
877902
RTLD_NEXT
878903
RTLD_NODELETE
879904
RTLD_NOLOAD

libc-test/semver/freebsd.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,26 @@ RLIMIT_UMTXP
12181218
RLIMIT_VMEM
12191219
RLIM_INFINITY
12201220
RLIM_NLIMITS
1221+
RTF_XRESOLVE
1222+
RTF_LLINFO
1223+
RTF_PROTO3
1224+
RTF_PINNED
1225+
RTF_LOCAL
1226+
RTF_BROADCAST
1227+
RTF_MULTICAST
1228+
RTM_LOCK
1229+
RTM_RESOLVE
1230+
RTM_NEWADDR
1231+
RTM_DELADDR
1232+
RTM_IFINFO
1233+
RTM_NEWMADDR
1234+
RTM_DELMADDR
1235+
RTM_IFANNOUNCE
1236+
RTM_IEEE80211
1237+
RTF_LLDATA
1238+
RTF_FIXEDMTU
1239+
RTM_VERSION
1240+
RTAX_MAX
12211241
RTLD_NEXT
12221242
RTLD_NODELETE
12231243
RTLD_NOLOAD

libc-test/semver/netbsd.txt

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

libc-test/semver/openbsd.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,50 @@ RLIM_INFINITY
765765
RLIM_NLIMITS
766766
RLIM_SAVED_CUR
767767
RLIM_SAVED_MAX
768+
RTA_BFD
769+
RTA_DNS
770+
RTA_LABEL
771+
RTA_SEARCH
772+
RTA_SRC
773+
RTA_SRCMASK
774+
RTA_STATIC
775+
RTAX_BFD
776+
RTAX_DNS
777+
RTAX_LABEL
778+
RTAX_MAX
779+
RTAX_SEARCH
780+
RTAX_SRC
781+
RTAX_SRCMASK
782+
RTAX_STATIC
783+
RTF_ANNOUNCE
784+
RTF_BFD
785+
RTF_BROADCAST
786+
RTF_CACHED
787+
RTF_CLONED
788+
RTF_CLONING
789+
RTF_CONNECTED
790+
RTF_FMASK
791+
RTF_LLINFO
792+
RTF_LOCAL
793+
RTF_MPATH
794+
RTF_MPLS
795+
RTF_MULTICAST
796+
RTF_PROTO3
768797
RTLD_NEXT
769798
RTLD_SELF
799+
RTM_80211INFO
800+
RTM_BFD
801+
RTM_CHGADDRATTR
802+
RTM_DELADDR
803+
RTM_DESYNC
804+
RTM_IFANNOUNCE
805+
RTM_IFINFO
806+
RTM_INVALIDATE
807+
RTM_NEWADDR
808+
RTM_PROPOSAL
809+
RTM_RESOLVE
810+
RTM_SOURCE
811+
RTM_VERSION
770812
RUSAGE_CHILDREN
771813
RUSAGE_SELF
772814
RUSAGE_THREAD

src/unix/bsd/apple/mod.rs

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

49424942
// net/route.h
4943-
pub const RTF_UP: ::c_int = 0x1;
4944-
pub const RTF_GATEWAY: ::c_int = 0x2;
4945-
pub const RTF_HOST: ::c_int = 0x4;
4946-
pub const RTF_REJECT: ::c_int = 0x8;
4947-
pub const RTF_DYNAMIC: ::c_int = 0x10;
4948-
pub const RTF_MODIFIED: ::c_int = 0x20;
4949-
pub const RTF_DONE: ::c_int = 0x40;
49504943
pub const RTF_DELCLONE: ::c_int = 0x80;
49514944
pub const RTF_CLONING: ::c_int = 0x100;
49524945
pub const RTF_XRESOLVE: ::c_int = 0x200;
49534946
pub const RTF_LLINFO: ::c_int = 0x400;
4954-
pub const RTF_STATIC: ::c_int = 0x800;
4955-
pub const RTF_BLACKHOLE: ::c_int = 0x1000;
49564947
pub const RTF_NOIFREF: ::c_int = 0x2000;
4957-
pub const RTF_PROTO2: ::c_int = 0x4000;
4958-
pub const RTF_PROTO1: ::c_int = 0x8000;
49594948
pub const RTF_PRCLONING: ::c_int = 0x10000;
49604949
pub const RTF_WASCLONED: ::c_int = 0x20000;
49614950
pub const RTF_PROTO3: ::c_int = 0x40000;
@@ -4974,13 +4963,6 @@ pub const RTF_GLOBAL: ::c_int = 0x40000000;
49744963
pub const RTM_VERSION: ::c_int = 5;
49754964

49764965
// Message types
4977-
pub const RTM_ADD: ::c_int = 0x1;
4978-
pub const RTM_DELETE: ::c_int = 0x2;
4979-
pub const RTM_CHANGE: ::c_int = 0x3;
4980-
pub const RTM_GET: ::c_int = 0x4;
4981-
pub const RTM_LOSING: ::c_int = 0x5;
4982-
pub const RTM_REDIRECT: ::c_int = 0x6;
4983-
pub const RTM_MISS: ::c_int = 0x7;
49844966
pub const RTM_LOCK: ::c_int = 0x8;
49854967
pub const RTM_OLDADD: ::c_int = 0x9;
49864968
pub const RTM_OLDDEL: ::c_int = 0xa;
@@ -5004,25 +4986,6 @@ pub const RTV_SSTHRESH: ::c_int = 0x20;
50044986
pub const RTV_RTT: ::c_int = 0x40;
50054987
pub const RTV_RTTVAR: ::c_int = 0x80;
50064988

5007-
// Bitmask values for rtm_addrs.
5008-
pub const RTA_DST: ::c_int = 0x1;
5009-
pub const RTA_GATEWAY: ::c_int = 0x2;
5010-
pub const RTA_NETMASK: ::c_int = 0x4;
5011-
pub const RTA_GENMASK: ::c_int = 0x8;
5012-
pub const RTA_IFP: ::c_int = 0x10;
5013-
pub const RTA_IFA: ::c_int = 0x20;
5014-
pub const RTA_AUTHOR: ::c_int = 0x40;
5015-
pub const RTA_BRD: ::c_int = 0x80;
5016-
5017-
// Index offsets for sockaddr array for alternate internal encoding.
5018-
pub const RTAX_DST: ::c_int = 0;
5019-
pub const RTAX_GATEWAY: ::c_int = 1;
5020-
pub const RTAX_NETMASK: ::c_int = 2;
5021-
pub const RTAX_GENMASK: ::c_int = 3;
5022-
pub const RTAX_IFP: ::c_int = 4;
5023-
pub const RTAX_IFA: ::c_int = 5;
5024-
pub const RTAX_AUTHOR: ::c_int = 6;
5025-
pub const RTAX_BRD: ::c_int = 7;
50264989
pub const RTAX_MAX: ::c_int = 8;
50274990

50284991
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
@@ -4742,6 +4742,14 @@ pub const CPU_WHICH_CPUSET: ::c_int = 3;
47424742
pub const CPU_WHICH_IRQ: ::c_int = 4;
47434743
pub const CPU_WHICH_JAIL: ::c_int = 5;
47444744

4745+
// net/route.h
4746+
pub const RTF_LLDATA: ::c_int = 0x400;
4747+
pub const RTF_FIXEDMTU: ::c_int = 0x80000;
4748+
4749+
pub const RTM_VERSION: ::c_int = 5;
4750+
4751+
pub const RTAX_MAX: ::c_int = 8;
4752+
47454753
// sys/signal.h
47464754
pub const SIGTHR: ::c_int = 32;
47474755
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
@@ -1017,6 +1017,25 @@ pub const SO_TYPE: ::c_int = 0x1008;
10171017

10181018
pub const LOCAL_PEERCRED: ::c_int = 1;
10191019

1020+
// net/route.h
1021+
pub const RTF_XRESOLVE: ::c_int = 0x200;
1022+
pub const RTF_LLINFO: ::c_int = 0x400;
1023+
pub const RTF_PROTO3: ::c_int = 0x40000;
1024+
pub const RTF_PINNED: ::c_int = 0x100000;
1025+
pub const RTF_LOCAL: ::c_int = 0x200000;
1026+
pub const RTF_BROADCAST: ::c_int = 0x400000;
1027+
pub const RTF_MULTICAST: ::c_int = 0x800000;
1028+
1029+
pub const RTM_LOCK: ::c_int = 0x8;
1030+
pub const RTM_RESOLVE: ::c_int = 0xb;
1031+
pub const RTM_NEWADDR: ::c_int = 0xc;
1032+
pub const RTM_DELADDR: ::c_int = 0xd;
1033+
pub const RTM_IFINFO: ::c_int = 0xe;
1034+
pub const RTM_NEWMADDR: ::c_int = 0xf;
1035+
pub const RTM_DELMADDR: ::c_int = 0x10;
1036+
pub const RTM_IFANNOUNCE: ::c_int = 0x11;
1037+
pub const RTM_IEEE80211: ::c_int = 0x12;
1038+
10201039
pub const SHUT_RD: ::c_int = 0;
10211040
pub const SHUT_WR: ::c_int = 1;
10221041
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
@@ -2424,6 +2424,33 @@ cfg_if! {
24242424
}
24252425
}
24262426

2427+
// net/route.h
2428+
pub const RTF_MASK: ::c_int = 0x80;
2429+
pub const RTF_CONNECTED: ::c_int = 0x100;
2430+
pub const RTF_ANNOUNCE: ::c_int = 0x20000;
2431+
pub const RTF_SRC: ::c_int = 0x10000;
2432+
pub const RTF_LOCAL: ::c_int = 0x40000;
2433+
pub const RTF_BROADCAST: ::c_int = 0x80000;
2434+
pub const RTF_UPDATING: ::c_int = 0x100000;
2435+
pub const RTF_DONTCHANGEIFA: ::c_int = 0x200000;
2436+
2437+
pub const RTM_VERSION: ::c_int = 4;
2438+
pub const RTM_LOCK: ::c_int = 0x8;
2439+
pub const RTM_IFANNOUNCE: ::c_int = 0x10;
2440+
pub const RTM_IEEE80211: ::c_int = 0x11;
2441+
pub const RTM_SETGATE: ::c_int = 0x12;
2442+
pub const RTM_LLINFO_UPD: ::c_int = 0x13;
2443+
pub const RTM_IFINFO: ::c_int = 0x14;
2444+
pub const RTM_OCHGADDR: ::c_int = 0x15;
2445+
pub const RTM_NEWADDR: ::c_int = 0x16;
2446+
pub const RTM_DELADDR: ::c_int = 0x17;
2447+
pub const RTM_CHGADDR: ::c_int = 0x18;
2448+
2449+
pub const RTA_TAG: ::c_int = 0x100;
2450+
2451+
pub const RTAX_TAG: ::c_int = 8;
2452+
pub const RTAX_MAX: ::c_int = 9;
2453+
24272454
const_fn! {
24282455
{const} fn _ALIGN(p: usize) -> usize {
24292456
(p + _ALIGNBYTES) & !_ALIGNBYTES

0 commit comments

Comments
 (0)