Skip to content

Commit e1566fd

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.
1 parent 113efbf commit e1566fd

File tree

11 files changed

+267
-37
lines changed

11 files changed

+267
-37
lines changed

libc-test/semver/dragonfly.txt

+25
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

+20
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

+22
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

+42
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

-37
Original file line numberDiff line numberDiff line change
@@ -4914,22 +4914,11 @@ pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020;
49144914
pub const NET_RT_IFLIST2: ::c_int = 0x0006;
49154915

49164916
// net/route.h
4917-
pub const RTF_UP: ::c_int = 0x1;
4918-
pub const RTF_GATEWAY: ::c_int = 0x2;
4919-
pub const RTF_HOST: ::c_int = 0x4;
4920-
pub const RTF_REJECT: ::c_int = 0x8;
4921-
pub const RTF_DYNAMIC: ::c_int = 0x10;
4922-
pub const RTF_MODIFIED: ::c_int = 0x20;
4923-
pub const RTF_DONE: ::c_int = 0x40;
49244917
pub const RTF_DELCLONE: ::c_int = 0x80;
49254918
pub const RTF_CLONING: ::c_int = 0x100;
49264919
pub const RTF_XRESOLVE: ::c_int = 0x200;
49274920
pub const RTF_LLINFO: ::c_int = 0x400;
4928-
pub const RTF_STATIC: ::c_int = 0x800;
4929-
pub const RTF_BLACKHOLE: ::c_int = 0x1000;
49304921
pub const RTF_NOIFREF: ::c_int = 0x2000;
4931-
pub const RTF_PROTO2: ::c_int = 0x4000;
4932-
pub const RTF_PROTO1: ::c_int = 0x8000;
49334922
pub const RTF_PRCLONING: ::c_int = 0x10000;
49344923
pub const RTF_WASCLONED: ::c_int = 0x20000;
49354924
pub const RTF_PROTO3: ::c_int = 0x40000;
@@ -4948,13 +4937,6 @@ pub const RTF_GLOBAL: ::c_int = 0x40000000;
49484937
pub const RTM_VERSION: ::c_int = 5;
49494938

49504939
// Message types
4951-
pub const RTM_ADD: ::c_int = 0x1;
4952-
pub const RTM_DELETE: ::c_int = 0x2;
4953-
pub const RTM_CHANGE: ::c_int = 0x3;
4954-
pub const RTM_GET: ::c_int = 0x4;
4955-
pub const RTM_LOSING: ::c_int = 0x5;
4956-
pub const RTM_REDIRECT: ::c_int = 0x6;
4957-
pub const RTM_MISS: ::c_int = 0x7;
49584940
pub const RTM_LOCK: ::c_int = 0x8;
49594941
pub const RTM_OLDADD: ::c_int = 0x9;
49604942
pub const RTM_OLDDEL: ::c_int = 0xa;
@@ -4978,25 +4960,6 @@ pub const RTV_SSTHRESH: ::c_int = 0x20;
49784960
pub const RTV_RTT: ::c_int = 0x40;
49794961
pub const RTV_RTTVAR: ::c_int = 0x80;
49804962

4981-
// Bitmask values for rtm_addrs.
4982-
pub const RTA_DST: ::c_int = 0x1;
4983-
pub const RTA_GATEWAY: ::c_int = 0x2;
4984-
pub const RTA_NETMASK: ::c_int = 0x4;
4985-
pub const RTA_GENMASK: ::c_int = 0x8;
4986-
pub const RTA_IFP: ::c_int = 0x10;
4987-
pub const RTA_IFA: ::c_int = 0x20;
4988-
pub const RTA_AUTHOR: ::c_int = 0x40;
4989-
pub const RTA_BRD: ::c_int = 0x80;
4990-
4991-
// Index offsets for sockaddr array for alternate internal encoding.
4992-
pub const RTAX_DST: ::c_int = 0;
4993-
pub const RTAX_GATEWAY: ::c_int = 1;
4994-
pub const RTAX_NETMASK: ::c_int = 2;
4995-
pub const RTAX_GENMASK: ::c_int = 3;
4996-
pub const RTAX_IFP: ::c_int = 4;
4997-
pub const RTAX_IFA: ::c_int = 5;
4998-
pub const RTAX_AUTHOR: ::c_int = 6;
4999-
pub const RTAX_BRD: ::c_int = 7;
50004963
pub const RTAX_MAX: ::c_int = 8;
50014964

50024965
pub const KERN_PROCARGS2: ::c_int = 49;

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

+13
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

+8
Original file line numberDiff line numberDiff line change
@@ -4697,6 +4697,14 @@ pub const CPU_WHICH_CPUSET: ::c_int = 3;
46974697
pub const CPU_WHICH_IRQ: ::c_int = 4;
46984698
pub const CPU_WHICH_JAIL: ::c_int = 5;
46994699

4700+
// net/route.h
4701+
pub const RTF_LLDATA: ::c_int = 0x400;
4702+
pub const RTF_FIXEDMTU: ::c_int = 0x80000;
4703+
4704+
pub const RTM_VERSION: ::c_int = 5;
4705+
4706+
pub const RTAX_MAX: ::c_int = 8;
4707+
47004708
// sys/signal.h
47014709
pub const SIGTHR: ::c_int = 32;
47024710
pub const SIGLWP: ::c_int = SIGTHR;

src/unix/bsd/freebsdlike/mod.rs

+19
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

+43
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

+27
Original file line numberDiff line numberDiff line change
@@ -2402,6 +2402,33 @@ pub const fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int {
24022402
alignment << MAP_ALIGNMENT_SHIFT
24032403
}
24042404

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

0 commit comments

Comments
 (0)