From 7e8a9c552d5d87d76cd9604c9b46a355d36f1b34 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 20 May 2024 22:27:00 +0700 Subject: [PATCH] Unify RTM_ADD and friends under bsd namespace --- src/unix/bsd/apple/mod.rs | 37 ---------------------------- src/unix/bsd/freebsdlike/mod.rs | 36 --------------------------- src/unix/bsd/mod.rs | 43 +++++++++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/mod.rs | 39 ------------------------------ 4 files changed, 43 insertions(+), 112 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index d9e3831ea2e1a..5ca4403cf8b14 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4905,22 +4905,11 @@ pub const XATTR_SHOWCOMPRESSION: ::c_int = 0x0020; pub const NET_RT_IFLIST2: ::c_int = 0x0006; // net/route.h -pub const RTF_UP: ::c_int = 0x1; -pub const RTF_GATEWAY: ::c_int = 0x2; -pub const RTF_HOST: ::c_int = 0x4; -pub const RTF_REJECT: ::c_int = 0x8; -pub const RTF_DYNAMIC: ::c_int = 0x10; -pub const RTF_MODIFIED: ::c_int = 0x20; -pub const RTF_DONE: ::c_int = 0x40; pub const RTF_DELCLONE: ::c_int = 0x80; pub const RTF_CLONING: ::c_int = 0x100; pub const RTF_XRESOLVE: ::c_int = 0x200; pub const RTF_LLINFO: ::c_int = 0x400; -pub const RTF_STATIC: ::c_int = 0x800; -pub const RTF_BLACKHOLE: ::c_int = 0x1000; pub const RTF_NOIFREF: ::c_int = 0x2000; -pub const RTF_PROTO2: ::c_int = 0x4000; -pub const RTF_PROTO1: ::c_int = 0x8000; pub const RTF_PRCLONING: ::c_int = 0x10000; pub const RTF_WASCLONED: ::c_int = 0x20000; pub const RTF_PROTO3: ::c_int = 0x40000; @@ -4939,13 +4928,6 @@ pub const RTF_GLOBAL: ::c_int = 0x40000000; pub const RTM_VERSION: ::c_int = 5; // Message types -pub const RTM_ADD: ::c_int = 0x1; -pub const RTM_DELETE: ::c_int = 0x2; -pub const RTM_CHANGE: ::c_int = 0x3; -pub const RTM_GET: ::c_int = 0x4; -pub const RTM_LOSING: ::c_int = 0x5; -pub const RTM_REDIRECT: ::c_int = 0x6; -pub const RTM_MISS: ::c_int = 0x7; pub const RTM_LOCK: ::c_int = 0x8; pub const RTM_OLDADD: ::c_int = 0x9; pub const RTM_OLDDEL: ::c_int = 0xa; @@ -4969,25 +4951,6 @@ pub const RTV_SSTHRESH: ::c_int = 0x20; pub const RTV_RTT: ::c_int = 0x40; pub const RTV_RTTVAR: ::c_int = 0x80; -// Bitmask values for rtm_addrs. -pub const RTA_DST: ::c_int = 0x1; -pub const RTA_GATEWAY: ::c_int = 0x2; -pub const RTA_NETMASK: ::c_int = 0x4; -pub const RTA_GENMASK: ::c_int = 0x8; -pub const RTA_IFP: ::c_int = 0x10; -pub const RTA_IFA: ::c_int = 0x20; -pub const RTA_AUTHOR: ::c_int = 0x40; -pub const RTA_BRD: ::c_int = 0x80; - -// Index offsets for sockaddr array for alternate internal encoding. -pub const RTAX_DST: ::c_int = 0; -pub const RTAX_GATEWAY: ::c_int = 1; -pub const RTAX_NETMASK: ::c_int = 2; -pub const RTAX_GENMASK: ::c_int = 3; -pub const RTAX_IFP: ::c_int = 4; -pub const RTAX_IFA: ::c_int = 5; -pub const RTAX_AUTHOR: ::c_int = 6; -pub const RTAX_BRD: ::c_int = 7; pub const RTAX_MAX: ::c_int = 8; pub const KERN_PROCARGS2: ::c_int = 49; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index d03591d05d138..4b08491993d59 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1016,32 +1016,14 @@ pub const SO_TYPE: ::c_int = 0x1008; pub const LOCAL_PEERCRED: ::c_int = 1; // net/route.h -pub const RTF_UP: ::c_int = 0x1; -pub const RTF_GATEWAY: ::c_int = 0x2; -pub const RTF_HOST: ::c_int = 0x4; -pub const RTF_REJECT: ::c_int = 0x8; -pub const RTF_DYNAMIC: ::c_int = 0x10; -pub const RTF_MODIFIED: ::c_int = 0x20; -pub const RTF_DONE: ::c_int = 0x40; pub const RTF_XRESOLVE: ::c_int = 0x200; pub const RTF_LLINFO: ::c_int = 0x400; -pub const RTF_STATIC: ::c_int = 0x800; -pub const RTF_BLACKHOLE: ::c_int = 0x1000; -pub const RTF_PROTO2: ::c_int = 0x4000; -pub const RTF_PROTO1: ::c_int = 0x8000; pub const RTF_PROTO3: ::c_int = 0x40000; pub const RTF_PINNED: ::c_int = 0x100000; pub const RTF_LOCAL: ::c_int = 0x200000; pub const RTF_BROADCAST: ::c_int = 0x400000; pub const RTF_MULTICAST: ::c_int = 0x800000; -pub const RTM_ADD: ::c_int = 0x1; -pub const RTM_DELETE: ::c_int = 0x2; -pub const RTM_CHANGE: ::c_int = 0x3; -pub const RTM_GET: ::c_int = 0x4; -pub const RTM_LOSING: ::c_int = 0x5; -pub const RTM_REDIRECT: ::c_int = 0x6; -pub const RTM_MISS: ::c_int = 0x7; pub const RTM_LOCK: ::c_int = 0x8; pub const RTM_RESOLVE: ::c_int = 0xb; pub const RTM_NEWADDR: ::c_int = 0xc; @@ -1052,24 +1034,6 @@ pub const RTM_DELMADDR: ::c_int = 0x10; pub const RTM_IFANNOUNCE: ::c_int = 0x11; pub const RTM_IEEE80211: ::c_int = 0x12; -pub const RTA_DST: ::c_int = 0x1; -pub const RTA_GATEWAY: ::c_int = 0x2; -pub const RTA_NETMASK: ::c_int = 0x4; -pub const RTA_GENMASK: ::c_int = 0x8; -pub const RTA_IFP: ::c_int = 0x10; -pub const RTA_IFA: ::c_int = 0x20; -pub const RTA_AUTHOR: ::c_int = 0x40; -pub const RTA_BRD: ::c_int = 0x80; - -pub const RTAX_DST: ::c_int = 0; -pub const RTAX_GATEWAY: ::c_int = 1; -pub const RTAX_NETMASK: ::c_int = 2; -pub const RTAX_GENMASK: ::c_int = 3; -pub const RTAX_IFP: ::c_int = 4; -pub const RTAX_IFA: ::c_int = 5; -pub const RTAX_AUTHOR: ::c_int = 6; -pub const RTAX_BRD: ::c_int = 7; - pub const SHUT_RD: ::c_int = 0; pub const SHUT_WR: ::c_int = 1; pub const SHUT_RDWR: ::c_int = 2; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 6ee2a3de44035..4320ec02cbab7 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -542,6 +542,49 @@ pub const ITIMER_REAL: ::c_int = 0; pub const ITIMER_VIRTUAL: ::c_int = 1; pub const ITIMER_PROF: ::c_int = 2; +// net/route.h + +pub const RTF_UP: ::c_int = 0x1; +pub const RTF_GATEWAY: ::c_int = 0x2; +pub const RTF_HOST: ::c_int = 0x4; +pub const RTF_REJECT: ::c_int = 0x8; +pub const RTF_DYNAMIC: ::c_int = 0x10; +pub const RTF_MODIFIED: ::c_int = 0x20; +pub const RTF_DONE: ::c_int = 0x40; +pub const RTF_STATIC: ::c_int = 0x800; +pub const RTF_BLACKHOLE: ::c_int = 0x1000; +pub const RTF_PROTO2: ::c_int = 0x4000; +pub const RTF_PROTO1: ::c_int = 0x8000; + +// Message types +pub const RTM_ADD: ::c_int = 0x1; +pub const RTM_DELETE: ::c_int = 0x2; +pub const RTM_CHANGE: ::c_int = 0x3; +pub const RTM_GET: ::c_int = 0x4; +pub const RTM_LOSING: ::c_int = 0x5; +pub const RTM_REDIRECT: ::c_int = 0x6; +pub const RTM_MISS: ::c_int = 0x7; + +// Bitmask values for rtm_addrs. +pub const RTA_DST: ::c_int = 0x1; +pub const RTA_GATEWAY: ::c_int = 0x2; +pub const RTA_NETMASK: ::c_int = 0x4; +pub const RTA_GENMASK: ::c_int = 0x8; +pub const RTA_IFP: ::c_int = 0x10; +pub const RTA_IFA: ::c_int = 0x20; +pub const RTA_AUTHOR: ::c_int = 0x40; +pub const RTA_BRD: ::c_int = 0x80; + +// Index offsets for sockaddr array for alternate internal encoding. +pub const RTAX_DST: ::c_int = 0; +pub const RTAX_GATEWAY: ::c_int = 1; +pub const RTAX_NETMASK: ::c_int = 2; +pub const RTAX_GENMASK: ::c_int = 3; +pub const RTAX_IFP: ::c_int = 4; +pub const RTAX_IFA: ::c_int = 5; +pub const RTAX_AUTHOR: ::c_int = 6; +pub const RTAX_BRD: ::c_int = 7; + f! { pub fn CMSG_FIRSTHDR(mhdr: *const ::msghdr) -> *mut ::cmsghdr { if (*mhdr).msg_controllen as usize >= ::mem::size_of::<::cmsghdr>() { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index b1d48c3aa584e..e92cf65940141 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -653,45 +653,6 @@ pub const TIOCM_RI: ::c_int = TIOCM_RNG; pub const TIMER_ABSTIME: ::c_int = 1; -// net/route.h -pub const RTF_UP: ::c_int = 0x1; -pub const RTF_GATEWAY: ::c_int = 0x2; -pub const RTF_HOST: ::c_int = 0x4; -pub const RTF_REJECT: ::c_int = 0x8; -pub const RTF_DYNAMIC: ::c_int = 0x10; -pub const RTF_MODIFIED: ::c_int = 0x20; -pub const RTF_DONE: ::c_int = 0x40; -pub const RTF_STATIC: ::c_int = 0x800; -pub const RTF_BLACKHOLE: ::c_int = 0x1000; -pub const RTF_PROTO2: ::c_int = 0x4000; -pub const RTF_PROTO1: ::c_int = 0x8000; - -pub const RTM_ADD: ::c_int = 0x1; -pub const RTM_DELETE: ::c_int = 0x2; -pub const RTM_CHANGE: ::c_int = 0x3; -pub const RTM_GET: ::c_int = 0x4; -pub const RTM_LOSING: ::c_int = 0x5; -pub const RTM_REDIRECT: ::c_int = 0x6; -pub const RTM_MISS: ::c_int = 0x7; - -pub const RTA_DST: ::c_int = 0x1; -pub const RTA_GATEWAY: ::c_int = 0x2; -pub const RTA_NETMASK: ::c_int = 0x4; -pub const RTA_GENMASK: ::c_int = 0x8; -pub const RTA_IFP: ::c_int = 0x10; -pub const RTA_IFA: ::c_int = 0x20; -pub const RTA_AUTHOR: ::c_int = 0x40; -pub const RTA_BRD: ::c_int = 0x80; - -pub const RTAX_DST: ::c_int = 0; -pub const RTAX_GATEWAY: ::c_int = 1; -pub const RTAX_NETMASK: ::c_int = 2; -pub const RTAX_GENMASK: ::c_int = 3; -pub const RTAX_IFP: ::c_int = 4; -pub const RTAX_IFA: ::c_int = 5; -pub const RTAX_AUTHOR: ::c_int = 6; -pub const RTAX_BRD: ::c_int = 7; - // sys/reboot.h pub const RB_AUTOBOOT: ::c_int = 0;