summaryrefslogtreecommitdiffhomepage
path: root/talpid-routing
diff options
context:
space:
mode:
authorAndrej Mihajlov <and.mikhaylov@gmail.com>2024-03-07 11:48:46 +0100
committerDavid Lönnhager <dv.lnh.d@gmail.com>2024-03-07 14:13:37 +0100
commit04bad18ae4fe15613aeae116402e83add24ca76c (patch)
tree27a76347d533b7c1fc456274d5478eacfc045b50 /talpid-routing
parent3182537973bb97e84e97f95fb3b22edac9d6d7c5 (diff)
downloadmullvadvpn-04bad18ae4fe15613aeae116402e83add24ca76c.tar.xz
mullvadvpn-04bad18ae4fe15613aeae116402e83add24ca76c.zip
routing: use libc constants
Diffstat (limited to 'talpid-routing')
-rw-r--r--talpid-routing/src/unix/macos/data.rs115
1 files changed, 57 insertions, 58 deletions
diff --git a/talpid-routing/src/unix/macos/data.rs b/talpid-routing/src/unix/macos/data.rs
index b404511d2c..0028466ed0 100644
--- a/talpid-routing/src/unix/macos/data.rs
+++ b/talpid-routing/src/unix/macos/data.rs
@@ -315,7 +315,7 @@ impl RouteMessage {
let mut header = super::data::rt_msghdr {
rtm_msglen,
rtm_version: libc::RTM_VERSION.try_into().unwrap(),
- rtm_type: message_type.bits(),
+ rtm_type: message_type.bits().try_into().unwrap(),
rtm_index: self.interface_index,
rtm_flags: self.route_flags.bits(),
rtm_addrs: address_flags.bits(),
@@ -657,127 +657,126 @@ bitflags::bitflags! {
/// See https://www.manpagez.com/man/4/route/.
pub struct AddressFlag: i32 {
/// Destination socket address
- const RTA_DST = 0x1;
+ const RTA_DST = libc::RTA_DST;
/// Gateway socket address
- const RTA_GATEWAY = 0x2;
+ const RTA_GATEWAY = libc::RTA_GATEWAY;
/// Netmask socket address
- const RTA_NETMASK = 0x4;
+ const RTA_NETMASK = libc::RTA_NETMASK;
/// Cloning mask socket address
- const RTA_GENMASK = 0x8;
+ const RTA_GENMASK = libc::RTA_GENMASK;
/// Interface name socket address
- const RTA_IFP = 0x10;
+ const RTA_IFP = libc::RTA_IFP;
/// Interface address socket address
- const RTA_IFA = 0x20;
+ const RTA_IFA = libc::RTA_IFA;
/// Socket address for author of redirect
- const RTA_AUTHOR = 0x40;
+ const RTA_AUTHOR = libc::RTA_AUTHOR;
/// Socket address for `NEWADDR`, broadcast or point-to-point destination address
- const RTA_BRD = 0x80;
+ const RTA_BRD = libc::RTA_BRD;
}
}
bitflags::bitflags! {
/// Types of routing messages
/// See https://www.manpagez.com/man/4/route/.
- pub struct MessageType: u8 {
+ pub struct MessageType: i32 {
/// Add Route
- const RTM_ADD = 0x1;
+ const RTM_ADD = libc::RTM_ADD;
/// Delete Route
- const RTM_DELETE = 0x2;
+ const RTM_DELETE = libc::RTM_DELETE;
/// Change Metrics or flags
- const RTM_CHANGE = 0x3;
+ const RTM_CHANGE = libc::RTM_CHANGE;
/// Report Metrics
- const RTM_GET = 0x4;
+ const RTM_GET = libc::RTM_GET;
/// RTM_LOSING is no longer generated by and is deprecated
- const RTM_LOSING = 0x5;
+ const RTM_LOSING = libc::RTM_LOSING;
/// Told to use different route
- const RTM_REDIRECT = 0x6;
+ const RTM_REDIRECT = libc::RTM_REDIRECT;
/// Lookup failed on this address
- const RTM_MISS = 0x7;
+ const RTM_MISS = libc::RTM_MISS;
/// fix specified metrics
- const RTM_LOCK = 0x8;
+ const RTM_LOCK = libc::RTM_LOCK;
/// caused by SIOCADDRT
- const RTM_OLDADD = 0x9;
+ const RTM_OLDADD = libc::RTM_OLDADD;
/// caused by SIOCDELRT
- const RTM_OLDDEL = 0xa;
+ const RTM_OLDDEL = libc::RTM_OLDDEL;
/// req to resolve dst to LL addr
- const RTM_RESOLVE = 0xb;
+ const RTM_RESOLVE = libc::RTM_RESOLVE;
/// address being added to iface
- const RTM_NEWADDR = 0xc;
+ const RTM_NEWADDR = libc::RTM_NEWADDR;
/// address being removed from iface
- const RTM_DELADDR = 0xd;
+ const RTM_DELADDR = libc::RTM_DELADDR;
/// iface going up/down etc.
- const RTM_IFINFO = 0xe;
+ const RTM_IFINFO = libc::RTM_IFINFO;
/// mcast group membership being added to if
- const RTM_NEWMADDR = 0xf;
+ const RTM_NEWMADDR = libc::RTM_NEWMADDR;
/// mcast group membership being deleted
- const RTM_DELMADDR = 0x10;
+ const RTM_DELMADDR = libc::RTM_DELMADDR;
}
/// Routing message flags
/// See https://www.manpagez.com/man/4/route/.
pub struct RouteFlag: i32 {
/// route usable
- const RTF_UP = 0x1;
+ const RTF_UP = libc::RTF_UP;
/// destination is a gateway
- const RTF_GATEWAY = 0x2;
+ const RTF_GATEWAY = libc::RTF_GATEWAY;
/// host entry (net otherwise)
- const RTF_HOST = 0x4;
+ const RTF_HOST = libc::RTF_HOST;
/// host or net unreachable
- const RTF_REJECT = 0x8;
+ const RTF_REJECT = libc::RTF_REJECT;
/// created dynamically (by redirect)
- const RTF_DYNAMIC = 0x10;
+ const RTF_DYNAMIC = libc::RTF_DYNAMIC;
/// modified dynamically (by redirect)
- const RTF_MODIFIED = 0x20;
+ const RTF_MODIFIED = libc::RTF_MODIFIED;
/// message confirmed
- const RTF_DONE = 0x40;
+ const RTF_DONE = libc::RTF_DONE;
/// delete cloned route
- const RTF_DELCLONE = 0x80;
+ const RTF_DELCLONE = libc::RTF_DELCLONE;
/// generate new routes on use
- const RTF_CLONING = 0x100;
+ const RTF_CLONING = libc::RTF_CLONING;
/// external daemon resolves name
- const RTF_XRESOLVE = 0x200;
- /// DEPRECATED - exists ONLY for backwards compatibility
- const RTF_LLINFO = 0x400;
+ const RTF_XRESOLVE = libc::RTF_XRESOLVE;
/// used by apps to add/del L2 entries
- const RTF_LLDATA = 0x400;
+ /// the newer constant is called RTF_LLDATA but absent in libc, has the same value.
+ const RTF_LLINFO = libc::RTF_LLINFO;
/// manually added
- const RTF_STATIC = 0x800;
+ const RTF_STATIC = libc::RTF_STATIC;
/// just discard pkts (during updates)
- const RTF_BLACKHOLE = 0x1000;
+ const RTF_BLACKHOLE = libc::RTF_BLACKHOLE;
/// not eligible for RTF_IFREF
- const RTF_NOIFREF = 0x2000;
+ const RTF_NOIFREF = libc::RTF_NOIFREF;
/// protocol specific routing flag
- const RTF_PROTO2 = 0x4000;
+ const RTF_PROTO2 = libc::RTF_PROTO2;
/// protocol specific routing flag
- const RTF_PROTO1 = 0x8000;
+ const RTF_PROTO1 = libc::RTF_PROTO1;
/// protocol requires cloning
- const RTF_PRCLONING = 0x10000;
+ const RTF_PRCLONING = libc::RTF_PRCLONING;
/// route generated through cloning
- const RTF_WASCLONED = 0x20000;
+ const RTF_WASCLONED = libc::RTF_WASCLONED;
/// protocol specific routing flag
- const RTF_PROTO3 = 0x40000;
+ const RTF_PROTO3 = libc::RTF_PROTO3;
/// future use
- const RTF_PINNED = 0x100000;
+ const RTF_PINNED = libc::RTF_PINNED;
/// route represents a local address
- const RTF_LOCAL = 0x200000;
+ const RTF_LOCAL = libc::RTF_LOCAL;
/// route represents a bcast address
- const RTF_BROADCAST = 0x400000;
+ const RTF_BROADCAST = libc::RTF_BROADCAST;
/// route represents a mcast address
- const RTF_MULTICAST = 0x800000;
+ const RTF_MULTICAST = libc::RTF_MULTICAST;
/// has valid interface scope
- const RTF_IFSCOPE = 0x1000000;
+ const RTF_IFSCOPE = libc::RTF_IFSCOPE;
/// defunct; no longer modifiable
- const RTF_CONDEMNED = 0x2000000;
+ const RTF_CONDEMNED = libc::RTF_CONDEMNED;
/// route holds a ref to interface
- const RTF_IFREF = 0x4000000;
+ const RTF_IFREF = libc::RTF_IFREF;
/// proxying, no interface scope
- const RTF_PROXY = 0x8000000;
+ const RTF_PROXY = libc::RTF_PROXY;
/// host is a router
- const RTF_ROUTER = 0x10000000;
+ const RTF_ROUTER = libc::RTF_ROUTER;
/// Route entry is being freed
- const RTF_DEAD = 0x20000000;
+ const RTF_DEAD = libc::RTF_DEAD;
/// route to destination of the global internet
- const RTF_GLOBAL = 0x40000000;
+ const RTF_GLOBAL = libc::RTF_GLOBAL;
}
}