Skip to content

Commit d14bbca

Browse files
committed
Auto merge of #1351 - jbaublitz:nl_consts_pr, r=gnzlbg
Netlink constants for use with the route netlink subsystem Reopening a PR to close #1059. I'll be adding a few more constants but want to make sure CI works on Github first.
2 parents f3a7aad + 1f997a5 commit d14bbca

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,7 @@ fn test_linux(target: &str) {
23472347
"linux/futex.h",
23482348
"linux/fs.h",
23492349
"linux/genetlink.h",
2350+
"linux/if_addr.h",
23502351
"linux/if_alg.h",
23512352
"linux/if_ether.h",
23522353
"linux/if_tun.h",
@@ -2357,6 +2358,7 @@ fn test_linux(target: &str) {
23572358
"linux/netfilter_ipv6.h",
23582359
"linux/netlink.h",
23592360
"linux/random.h",
2361+
"linux/rtnetlink.h",
23602362
"linux/seccomp.h",
23612363
"linux/sockios.h",
23622364
}

src/unix/notbsd/linux/mod.rs

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,36 @@ pub const IFF_LOWER_UP: ::c_int = 0x10000;
10241024
pub const IFF_DORMANT: ::c_int = 0x20000;
10251025
pub const IFF_ECHO: ::c_int = 0x40000;
10261026

1027+
// linux/if_addr.h
1028+
pub const IFA_UNSPEC: ::c_ushort = 0;
1029+
pub const IFA_ADDRESS: ::c_ushort = 1;
1030+
pub const IFA_LOCAL: ::c_ushort = 2;
1031+
pub const IFA_LABEL: ::c_ushort = 3;
1032+
pub const IFA_BROADCAST: ::c_ushort = 4;
1033+
pub const IFA_ANYCAST: ::c_ushort = 5;
1034+
pub const IFA_CACHEINFO: ::c_ushort = 6;
1035+
pub const IFA_MULTICAST: ::c_ushort = 7;
1036+
1037+
pub const IFA_F_SECONDARY: u32 = 0x01;
1038+
pub const IFA_F_TEMPORARY: u32 = 0x01;
1039+
pub const IFA_F_NODAD: u32 = 0x02;
1040+
pub const IFA_F_OPTIMISTIC: u32 = 0x04;
1041+
pub const IFA_F_DADFAILED: u32 = 0x08;
1042+
pub const IFA_F_HOMEADDRESS: u32 = 0x10;
1043+
pub const IFA_F_DEPRECATED: u32 = 0x20;
1044+
pub const IFA_F_TENTATIVE: u32 = 0x40;
1045+
pub const IFA_F_PERMANENT: u32 = 0x80;
1046+
1047+
// linux/if_link.h
1048+
pub const IFLA_UNSPEC: ::c_ushort = 0;
1049+
pub const IFLA_ADDRESS: ::c_ushort = 1;
1050+
pub const IFLA_BROADCAST: ::c_ushort = 2;
1051+
pub const IFLA_IFNAME: ::c_ushort = 3;
1052+
pub const IFLA_MTU: ::c_ushort = 4;
1053+
pub const IFLA_LINK: ::c_ushort = 5;
1054+
pub const IFLA_QDISC: ::c_ushort = 6;
1055+
pub const IFLA_STATS: ::c_ushort = 7;
1056+
10271057
// linux/if_tun.h
10281058
pub const IFF_TUN: ::c_short = 0x0001;
10291059
pub const IFF_TAP: ::c_short = 0x0002;
@@ -1767,6 +1797,89 @@ pub const RT_CLASS_MAIN: u8 = 254;
17671797
pub const RT_CLASS_LOCAL: u8 = 255;
17681798
pub const RT_CLASS_MAX: u8 = 255;
17691799

1800+
// linux/neighbor.h
1801+
pub const NUD_NONE: u16 = 0x00;
1802+
pub const NUD_INCOMPLETE: u16 = 0x01;
1803+
pub const NUD_REACHABLE: u16 = 0x02;
1804+
pub const NUD_STALE: u16 = 0x04;
1805+
pub const NUD_DELAY: u16 = 0x08;
1806+
pub const NUD_PROBE: u16 = 0x10;
1807+
pub const NUD_FAILED: u16 = 0x20;
1808+
pub const NUD_NOARP: u16 = 0x40;
1809+
pub const NUD_PERMANENT: u16 = 0x80;
1810+
1811+
pub const NTF_USE: u8 = 0x01;
1812+
pub const NTF_SELF: u8 = 0x02;
1813+
pub const NTF_MASTER: u8 = 0x04;
1814+
pub const NTF_PROXY: u8 = 0x08;
1815+
pub const NTF_ROUTER: u8 = 0x80;
1816+
1817+
pub const NDA_UNSPEC: ::c_ushort = 0;
1818+
pub const NDA_DST: ::c_ushort = 1;
1819+
pub const NDA_LLADDR: ::c_ushort = 2;
1820+
pub const NDA_CACHEINFO: ::c_ushort = 3;
1821+
pub const NDA_PROBES: ::c_ushort = 4;
1822+
pub const NDA_VLAN: ::c_ushort = 5;
1823+
pub const NDA_PORT: ::c_ushort = 6;
1824+
pub const NDA_VNI: ::c_ushort = 7;
1825+
pub const NDA_IFINDEX: ::c_ushort = 8;
1826+
1827+
// linux/rtnetlink.h
1828+
pub const RTM_F_NOTIFY: ::c_uint = 0x100;
1829+
pub const RTM_F_CLONED: ::c_uint = 0x200;
1830+
pub const RTM_F_EQUALIZE: ::c_uint = 0x400;
1831+
pub const RTM_F_PREFIX: ::c_uint = 0x800;
1832+
1833+
pub const RTA_UNSPEC: ::c_ushort = 0;
1834+
pub const RTA_DST: ::c_ushort = 1;
1835+
pub const RTA_SRC: ::c_ushort = 2;
1836+
pub const RTA_IIF: ::c_ushort = 3;
1837+
pub const RTA_OIF: ::c_ushort = 4;
1838+
pub const RTA_GATEWAY: ::c_ushort = 5;
1839+
pub const RTA_PRIORITY: ::c_ushort = 6;
1840+
pub const RTA_PREFSRC: ::c_ushort = 7;
1841+
pub const RTA_METRICS: ::c_ushort = 8;
1842+
pub const RTA_MULTIPATH: ::c_ushort = 9;
1843+
pub const RTA_PROTOINFO: ::c_ushort = 10; // No longer used
1844+
pub const RTA_FLOW: ::c_ushort = 11;
1845+
pub const RTA_CACHEINFO: ::c_ushort = 12;
1846+
pub const RTA_SESSION: ::c_ushort = 13; // No longer used
1847+
pub const RTA_MP_ALGO: ::c_ushort = 14; // No longer used
1848+
pub const RTA_TABLE: ::c_ushort = 15;
1849+
pub const RTA_MARK: ::c_ushort = 16;
1850+
pub const RTA_MFC_STATS: ::c_ushort = 17;
1851+
1852+
pub const RTN_UNSPEC: ::c_uchar = 0;
1853+
pub const RTN_UNICAST: ::c_uchar = 1;
1854+
pub const RTN_LOCAL: ::c_uchar = 2;
1855+
pub const RTN_BROADCAST: ::c_uchar = 3;
1856+
pub const RTN_ANYCAST: ::c_uchar = 4;
1857+
pub const RTN_MULTICAST: ::c_uchar = 5;
1858+
pub const RTN_BLACKHOLE: ::c_uchar = 6;
1859+
pub const RTN_UNREACHABLE: ::c_uchar = 7;
1860+
pub const RTN_PROHIBIT: ::c_uchar = 8;
1861+
pub const RTN_THROW: ::c_uchar = 9;
1862+
pub const RTN_NAT: ::c_uchar = 10;
1863+
pub const RTN_XRESOLVE: ::c_uchar = 11;
1864+
1865+
pub const RTPROT_UNSPEC: ::c_uchar = 0;
1866+
pub const RTPROT_REDIRECT: ::c_uchar = 1;
1867+
pub const RTPROT_KERNEL: ::c_uchar = 2;
1868+
pub const RTPROT_BOOT: ::c_uchar = 3;
1869+
pub const RTPROT_STATIC: ::c_uchar = 4;
1870+
1871+
pub const RT_SCOPE_UNIVERSE: ::c_uchar = 0;
1872+
pub const RT_SCOPE_SITE: ::c_uchar = 200;
1873+
pub const RT_SCOPE_LINK: ::c_uchar = 253;
1874+
pub const RT_SCOPE_HOST: ::c_uchar = 254;
1875+
pub const RT_SCOPE_NOWHERE: ::c_uchar = 255;
1876+
1877+
pub const RT_TABLE_UNSPEC: ::c_uchar = 0;
1878+
pub const RT_TABLE_COMPAT: ::c_uchar = 252;
1879+
pub const RT_TABLE_DEFAULT: ::c_uchar = 253;
1880+
pub const RT_TABLE_MAIN: ::c_uchar = 254;
1881+
pub const RT_TABLE_LOCAL: ::c_uchar = 255;
1882+
17701883
pub const RTMSG_OVERRUN: u32 = ::NLMSG_OVERRUN as u32;
17711884
pub const RTMSG_NEWDEVICE: u32 = 0x11;
17721885
pub const RTMSG_DELDEVICE: u32 = 0x12;

src/unix/notbsd/linux/other/mod.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,36 @@ pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
603603
pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
604604
pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
605605

606+
// linux/rtnetlink.h
607+
pub const RTM_F_LOOKUP_TABLE: ::c_uint = 0x1000;
608+
pub const RTM_F_FIB_MATCH: ::c_uint = 0x2000;
609+
610+
pub const RTA_VIA: ::c_ushort = 18;
611+
pub const RTA_NEWDST: ::c_ushort = 19;
612+
pub const RTA_PREF: ::c_ushort = 20;
613+
pub const RTA_ENCAP_TYPE: ::c_ushort = 21;
614+
pub const RTA_ENCAP: ::c_ushort = 22;
615+
pub const RTA_EXPIRES: ::c_ushort = 23;
616+
pub const RTA_PAD: ::c_ushort = 24;
617+
pub const RTA_UID: ::c_ushort = 25;
618+
pub const RTA_TTL_PROPAGATE: ::c_ushort = 26;
619+
620+
// linux/neighbor.h
621+
pub const NTF_EXT_LEARNED: u8 = 0x10;
622+
pub const NTF_OFFLOADED: u8 = 0x20;
623+
624+
pub const NDA_MASTER: ::c_ushort = 9;
625+
pub const NDA_LINK_NETNSID: ::c_ushort = 10;
626+
pub const NDA_SRC_VNI: ::c_ushort = 11;
627+
628+
// linux/if_addr.h
629+
pub const IFA_FLAGS: ::c_ushort = 8;
630+
631+
pub const IFA_F_MANAGETEMPADDR: u32 = 0x100;
632+
pub const IFA_F_NOPREFIXROUTE: u32 = 0x200;
633+
pub const IFA_F_MCAUTOJOIN: u32 = 0x400;
634+
pub const IFA_F_STABLE_PRIVACY: u32 = 0x800;
635+
606636
pub const NETLINK_ROUTE: ::c_int = 0;
607637
pub const NETLINK_UNUSED: ::c_int = 1;
608638
pub const NETLINK_USERSOCK: ::c_int = 2;

0 commit comments

Comments
 (0)