Skip to content

Commit 750fcf5

Browse files
committed
Add missing netfilter constants
Was able to move some of them up one level so they are valid on more platforms with less duplication
1 parent c8fb675 commit 750fcf5

File tree

5 files changed

+133
-30
lines changed

5 files changed

+133
-30
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ fn main() {
245245
cfg.header("linux/netlink.h");
246246
cfg.header("linux/genetlink.h");
247247
cfg.header("linux/netfilter_ipv4.h");
248+
cfg.header("linux/netfilter_ipv6.h");
248249
cfg.header("linux/fs.h");
249250
}
250251
if !musl {

src/unix/notbsd/android/mod.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
10011001
pub const MFD_CLOEXEC: ::c_uint = 0x0001;
10021002
pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
10031003

1004+
// linux/netfilter.h
10041005
pub const NF_DROP: ::c_int = 0;
10051006
pub const NF_ACCEPT: ::c_int = 1;
10061007
pub const NF_STOLEN: ::c_int = 2;
@@ -1037,6 +1038,52 @@ pub const NFPROTO_IPV6: ::c_int = 10;
10371038
pub const NFPROTO_DECNET: ::c_int = 12;
10381039
pub const NFPROTO_NUMPROTO: ::c_int = 13;
10391040

1041+
// linux/netfilter_ipv4.h
1042+
pub const NF_IP_PRE_ROUTING: ::c_int = 0;
1043+
pub const NF_IP_LOCAL_IN: ::c_int = 1;
1044+
pub const NF_IP_FORWARD: ::c_int = 2;
1045+
pub const NF_IP_LOCAL_OUT: ::c_int = 3;
1046+
pub const NF_IP_POST_ROUTING: ::c_int = 4;
1047+
pub const NF_IP_NUMHOOKS: ::c_int = 5;
1048+
1049+
pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN;
1050+
pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
1051+
pub const NF_IP_PRI_RAW: ::c_int = -300;
1052+
pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225;
1053+
pub const NF_IP_PRI_CONNTRACK: ::c_int = -200;
1054+
pub const NF_IP_PRI_MANGLE: ::c_int = -150;
1055+
pub const NF_IP_PRI_NAT_DST: ::c_int = -100;
1056+
pub const NF_IP_PRI_FILTER: ::c_int = 0;
1057+
pub const NF_IP_PRI_SECURITY: ::c_int = 50;
1058+
pub const NF_IP_PRI_NAT_SRC: ::c_int = 100;
1059+
pub const NF_IP_PRI_SELINUX_LAST: ::c_int = 225;
1060+
pub const NF_IP_PRI_CONNTRACK_HELPER: ::c_int = 300;
1061+
pub const NF_IP_PRI_CONNTRACK_CONFIRM: ::c_int = ::INT_MAX;
1062+
pub const NF_IP_PRI_LAST: ::c_int = ::INT_MAX;
1063+
1064+
// linux/netfilter_ipv6.h
1065+
pub const NF_IP6_PRE_ROUTING: ::c_int = 0;
1066+
pub const NF_IP6_LOCAL_IN: ::c_int = 1;
1067+
pub const NF_IP6_FORWARD: ::c_int = 2;
1068+
pub const NF_IP6_LOCAL_OUT: ::c_int = 3;
1069+
pub const NF_IP6_POST_ROUTING: ::c_int = 4;
1070+
pub const NF_IP6_NUMHOOKS: ::c_int = 5;
1071+
1072+
pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN;
1073+
pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
1074+
pub const NF_IP6_PRI_RAW: ::c_int = -300;
1075+
pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225;
1076+
pub const NF_IP6_PRI_CONNTRACK: ::c_int = -200;
1077+
pub const NF_IP6_PRI_MANGLE: ::c_int = -150;
1078+
pub const NF_IP6_PRI_NAT_DST: ::c_int = -100;
1079+
pub const NF_IP6_PRI_FILTER: ::c_int = 0;
1080+
pub const NF_IP6_PRI_SECURITY: ::c_int = 50;
1081+
pub const NF_IP6_PRI_NAT_SRC: ::c_int = 100;
1082+
pub const NF_IP6_PRI_SELINUX_LAST: ::c_int = 225;
1083+
pub const NF_IP6_PRI_CONNTRACK_HELPER: ::c_int = 300;
1084+
pub const NF_IP6_PRI_LAST: ::c_int = ::INT_MAX;
1085+
1086+
// linux/netfilter/nf_tables.h
10401087
pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32;
10411088
pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32;
10421089
pub const NFT_SET_MAXNAMELEN: ::c_int = 32;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,12 @@ pub const EHWPOISON: ::c_int = 168;
700700
pub const SIGEV_THREAD_ID: ::c_int = 4;
701701
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
702702

703+
pub const NF_NETDEV_INGRESS: ::c_int = 0;
704+
pub const NF_NETDEV_NUMHOOKS: ::c_int = 1;
705+
706+
pub const NFPROTO_INET: ::c_int = 1;
707+
pub const NFPROTO_NETDEV: ::c_int = 5;
708+
703709
pub const NLA_ALIGNTO: ::c_int = 4;
704710

705711
pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10;

src/unix/notbsd/linux/mod.rs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,84 @@ pub const CTRL_ATTR_MCAST_GRP_UNSPEC: ::c_int = 0;
13161316
pub const CTRL_ATTR_MCAST_GRP_NAME: ::c_int = 1;
13171317
pub const CTRL_ATTR_MCAST_GRP_ID: ::c_int = 2;
13181318

1319+
// linux/netfilter.h
1320+
pub const NF_DROP: ::c_int = 0;
1321+
pub const NF_ACCEPT: ::c_int = 1;
1322+
pub const NF_STOLEN: ::c_int = 2;
1323+
pub const NF_QUEUE: ::c_int = 3;
1324+
pub const NF_REPEAT: ::c_int = 4;
1325+
pub const NF_STOP: ::c_int = 5;
1326+
pub const NF_MAX_VERDICT: ::c_int = NF_STOP;
1327+
1328+
pub const NF_VERDICT_MASK: ::c_int = 0x000000ff;
1329+
pub const NF_VERDICT_FLAG_QUEUE_BYPASS: ::c_int = 0x00008000;
1330+
1331+
pub const NF_VERDICT_QMASK: ::c_int = 0xffff0000;
1332+
pub const NF_VERDICT_QBITS: ::c_int = 16;
1333+
1334+
pub const NF_VERDICT_BITS: ::c_int = 16;
1335+
1336+
pub const NF_INET_PRE_ROUTING: ::c_int = 0;
1337+
pub const NF_INET_LOCAL_IN: ::c_int = 1;
1338+
pub const NF_INET_FORWARD: ::c_int = 2;
1339+
pub const NF_INET_LOCAL_OUT: ::c_int = 3;
1340+
pub const NF_INET_POST_ROUTING: ::c_int = 4;
1341+
pub const NF_INET_NUMHOOKS: ::c_int = 5;
1342+
1343+
// Some NFPROTO are not compatible with musl and are defined in submodules.
1344+
pub const NFPROTO_UNSPEC: ::c_int = 0;
1345+
pub const NFPROTO_IPV4: ::c_int = 2;
1346+
pub const NFPROTO_ARP: ::c_int = 3;
1347+
pub const NFPROTO_BRIDGE: ::c_int = 7;
1348+
pub const NFPROTO_IPV6: ::c_int = 10;
1349+
pub const NFPROTO_DECNET: ::c_int = 12;
1350+
pub const NFPROTO_NUMPROTO: ::c_int = 13;
1351+
1352+
// linux/netfilter_ipv4.h
1353+
pub const NF_IP_PRE_ROUTING: ::c_int = 0;
1354+
pub const NF_IP_LOCAL_IN: ::c_int = 1;
1355+
pub const NF_IP_FORWARD: ::c_int = 2;
1356+
pub const NF_IP_LOCAL_OUT: ::c_int = 3;
1357+
pub const NF_IP_POST_ROUTING: ::c_int = 4;
1358+
pub const NF_IP_NUMHOOKS: ::c_int = 5;
1359+
1360+
pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN;
1361+
pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
1362+
pub const NF_IP_PRI_RAW: ::c_int = -300;
1363+
pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225;
1364+
pub const NF_IP_PRI_CONNTRACK: ::c_int = -200;
1365+
pub const NF_IP_PRI_MANGLE: ::c_int = -150;
1366+
pub const NF_IP_PRI_NAT_DST: ::c_int = -100;
1367+
pub const NF_IP_PRI_FILTER: ::c_int = 0;
1368+
pub const NF_IP_PRI_SECURITY: ::c_int = 50;
1369+
pub const NF_IP_PRI_NAT_SRC: ::c_int = 100;
1370+
pub const NF_IP_PRI_SELINUX_LAST: ::c_int = 225;
1371+
pub const NF_IP_PRI_CONNTRACK_HELPER: ::c_int = 300;
1372+
pub const NF_IP_PRI_CONNTRACK_CONFIRM: ::c_int = ::INT_MAX;
1373+
pub const NF_IP_PRI_LAST: ::c_int = ::INT_MAX;
1374+
1375+
// linux/netfilter_ipv6.h
1376+
pub const NF_IP6_PRE_ROUTING: ::c_int = 0;
1377+
pub const NF_IP6_LOCAL_IN: ::c_int = 1;
1378+
pub const NF_IP6_FORWARD: ::c_int = 2;
1379+
pub const NF_IP6_LOCAL_OUT: ::c_int = 3;
1380+
pub const NF_IP6_POST_ROUTING: ::c_int = 4;
1381+
pub const NF_IP6_NUMHOOKS: ::c_int = 5;
1382+
1383+
pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN;
1384+
pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
1385+
pub const NF_IP6_PRI_RAW: ::c_int = -300;
1386+
pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225;
1387+
pub const NF_IP6_PRI_CONNTRACK: ::c_int = -200;
1388+
pub const NF_IP6_PRI_MANGLE: ::c_int = -150;
1389+
pub const NF_IP6_PRI_NAT_DST: ::c_int = -100;
1390+
pub const NF_IP6_PRI_FILTER: ::c_int = 0;
1391+
pub const NF_IP6_PRI_SECURITY: ::c_int = 50;
1392+
pub const NF_IP6_PRI_NAT_SRC: ::c_int = 100;
1393+
pub const NF_IP6_PRI_SELINUX_LAST: ::c_int = 225;
1394+
pub const NF_IP6_PRI_CONNTRACK_HELPER: ::c_int = 300;
1395+
pub const NF_IP6_PRI_LAST: ::c_int = ::INT_MAX;
1396+
13191397
f! {
13201398
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
13211399
for slot in cpuset.bits.iter_mut() {

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

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -589,42 +589,13 @@ pub const TIOCM_DSR: ::c_int = 0x100;
589589
pub const TIOCM_CD: ::c_int = TIOCM_CAR;
590590
pub const TIOCM_RI: ::c_int = TIOCM_RNG;
591591

592-
pub const NF_DROP: ::c_int = 0;
593-
pub const NF_ACCEPT: ::c_int = 1;
594-
pub const NF_STOLEN: ::c_int = 2;
595-
pub const NF_QUEUE: ::c_int = 3;
596-
pub const NF_REPEAT: ::c_int = 4;
597-
pub const NF_STOP: ::c_int = 5;
598-
pub const NF_MAX_VERDICT: ::c_int = NF_STOP;
599-
600-
pub const NF_VERDICT_MASK: ::c_int = 0x000000ff;
601-
pub const NF_VERDICT_FLAG_QUEUE_BYPASS: ::c_int = 0x00008000;
602-
603-
pub const NF_VERDICT_QMASK: ::c_int = 0xffff0000;
604-
pub const NF_VERDICT_QBITS: ::c_int = 16;
605-
606-
pub const NF_VERDICT_BITS: ::c_int = 16;
607-
608-
pub const NF_INET_PRE_ROUTING: ::c_int = 0;
609-
pub const NF_INET_LOCAL_IN: ::c_int = 1;
610-
pub const NF_INET_FORWARD: ::c_int = 2;
611-
pub const NF_INET_LOCAL_OUT: ::c_int = 3;
612-
pub const NF_INET_POST_ROUTING: ::c_int = 4;
613-
pub const NF_INET_NUMHOOKS: ::c_int = 5;
614-
615592
pub const NF_NETDEV_INGRESS: ::c_int = 0;
616593
pub const NF_NETDEV_NUMHOOKS: ::c_int = 1;
617594

618-
pub const NFPROTO_UNSPEC: ::c_int = 0;
619595
pub const NFPROTO_INET: ::c_int = 1;
620-
pub const NFPROTO_IPV4: ::c_int = 2;
621-
pub const NFPROTO_ARP: ::c_int = 3;
622596
pub const NFPROTO_NETDEV: ::c_int = 5;
623-
pub const NFPROTO_BRIDGE: ::c_int = 7;
624-
pub const NFPROTO_IPV6: ::c_int = 10;
625-
pub const NFPROTO_DECNET: ::c_int = 12;
626-
pub const NFPROTO_NUMPROTO: ::c_int = 13;
627597

598+
// linux/netfilter/nf_tables.h
628599
cfg_if!{
629600
if #[cfg(any(target_arch = "arm", target_arch = "powerpc",
630601
target_arch = "powerpc64", target_arch = "aarch64"))] {

0 commit comments

Comments
 (0)