Skip to content

Commit c9e67b8

Browse files
committed
Auto merge of #911 - faern:add-netfilter, r=alexcrichton
Add netfilter constants to Linux Constants and enums from [`netfilter.h`] and [`nf_tables.h`]. I was not really sure what to do with the enums, for example `nf_tables_msg_types`. But since I could not find a C enum mapped into a Rust enum in this crate I assumed you wanted them as constants instead. I also wanted to get the `nf_inet_addr` union in here. But I did not find any unions in this crate so I was not sure how you would prefer it represented. There are of course a billion more netfilter constants and types to map. But this is a good start. [`netfilter.h`]: https://github.com/torvalds/linux/blob/ead751507de86d90fa250431e9990a8b881f713c/include/uapi/linux/netfilter.h [`nf_tables.h`]: https://github.com/torvalds/linux/blob/ead751507de86d90fa250431e9990a8b881f713c/include/uapi/linux/netfilter/nf_tables.h
2 parents 11cabde + 4d5ed47 commit c9e67b8

File tree

4 files changed

+175
-1
lines changed

4 files changed

+175
-1
lines changed

libc-test/build.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ fn main() {
247247
cfg.header("linux/netlink.h");
248248
cfg.header("linux/magic.h");
249249
cfg.header("linux/reboot.h");
250+
cfg.header("linux/netfilter/nf_tables.h");
250251

251252
if !mips {
252253
cfg.header("linux/quota.h");
@@ -255,7 +256,7 @@ fn main() {
255256
}
256257
if solaris {
257258
cfg.header("sys/epoll.h");
258-
}
259+
}
259260

260261
if linux || android {
261262
cfg.header("sys/fsuid.h");

src/unix/notbsd/android/mod.rs

+66
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,72 @@ pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
912912
pub const MFD_CLOEXEC: ::c_uint = 0x0001;
913913
pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
914914

915+
pub const NF_DROP: ::c_int = 0;
916+
pub const NF_ACCEPT: ::c_int = 1;
917+
pub const NF_STOLEN: ::c_int = 2;
918+
pub const NF_QUEUE: ::c_int = 3;
919+
pub const NF_REPEAT: ::c_int = 4;
920+
pub const NF_STOP: ::c_int = 5;
921+
pub const NF_MAX_VERDICT: ::c_int = NF_STOP;
922+
923+
pub const NF_VERDICT_MASK: ::c_int = 0x000000ff;
924+
pub const NF_VERDICT_FLAG_QUEUE_BYPASS: ::c_int = 0x00008000;
925+
926+
pub const NF_VERDICT_QMASK: ::c_int = 0xffff0000;
927+
pub const NF_VERDICT_QBITS: ::c_int = 16;
928+
929+
pub const NF_VERDICT_BITS: ::c_int = 16;
930+
931+
pub const NF_INET_PRE_ROUTING: ::c_int = 0;
932+
pub const NF_INET_LOCAL_IN: ::c_int = 1;
933+
pub const NF_INET_FORWARD: ::c_int = 2;
934+
pub const NF_INET_LOCAL_OUT: ::c_int = 3;
935+
pub const NF_INET_POST_ROUTING: ::c_int = 4;
936+
pub const NF_INET_NUMHOOKS: ::c_int = 5;
937+
938+
pub const NF_NETDEV_INGRESS: ::c_int = 0;
939+
pub const NF_NETDEV_NUMHOOKS: ::c_int = 1;
940+
941+
pub const NFPROTO_UNSPEC: ::c_int = 0;
942+
pub const NFPROTO_INET: ::c_int = 1;
943+
pub const NFPROTO_IPV4: ::c_int = 2;
944+
pub const NFPROTO_ARP: ::c_int = 3;
945+
pub const NFPROTO_NETDEV: ::c_int = 5;
946+
pub const NFPROTO_BRIDGE: ::c_int = 7;
947+
pub const NFPROTO_IPV6: ::c_int = 10;
948+
pub const NFPROTO_DECNET: ::c_int = 12;
949+
pub const NFPROTO_NUMPROTO: ::c_int = 13;
950+
951+
pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32;
952+
pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32;
953+
pub const NFT_SET_MAXNAMELEN: ::c_int = 32;
954+
pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32;
955+
pub const NFT_USERDATA_MAXLEN: ::c_int = 256;
956+
957+
pub const NFT_MSG_NEWTABLE: ::c_int = 0;
958+
pub const NFT_MSG_GETTABLE: ::c_int = 1;
959+
pub const NFT_MSG_DELTABLE: ::c_int = 2;
960+
pub const NFT_MSG_NEWCHAIN: ::c_int = 3;
961+
pub const NFT_MSG_GETCHAIN: ::c_int = 4;
962+
pub const NFT_MSG_DELCHAIN: ::c_int = 5;
963+
pub const NFT_MSG_NEWRULE: ::c_int = 6;
964+
pub const NFT_MSG_GETRULE: ::c_int = 7;
965+
pub const NFT_MSG_DELRULE: ::c_int = 8;
966+
pub const NFT_MSG_NEWSET: ::c_int = 9;
967+
pub const NFT_MSG_GETSET: ::c_int = 10;
968+
pub const NFT_MSG_DELSET: ::c_int = 11;
969+
pub const NFT_MSG_NEWSETELEM: ::c_int = 12;
970+
pub const NFT_MSG_GETSETELEM: ::c_int = 13;
971+
pub const NFT_MSG_DELSETELEM: ::c_int = 14;
972+
pub const NFT_MSG_NEWGEN: ::c_int = 15;
973+
pub const NFT_MSG_GETGEN: ::c_int = 16;
974+
pub const NFT_MSG_TRACE: ::c_int = 17;
975+
pub const NFT_MSG_NEWOBJ: ::c_int = 18;
976+
pub const NFT_MSG_GETOBJ: ::c_int = 19;
977+
pub const NFT_MSG_DELOBJ: ::c_int = 20;
978+
pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21;
979+
pub const NFT_MSG_MAX: ::c_int = 22;
980+
915981
f! {
916982
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
917983
for slot in cpuset.__bits.iter_mut() {

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

+30
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,36 @@ pub const EHWPOISON: ::c_int = 168;
662662
pub const SIGEV_THREAD_ID: ::c_int = 4;
663663
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
664664

665+
pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32;
666+
pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32;
667+
pub const NFT_SET_MAXNAMELEN: ::c_int = 32;
668+
pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32;
669+
pub const NFT_USERDATA_MAXLEN: ::c_int = 256;
670+
671+
pub const NFT_MSG_NEWTABLE: ::c_int = 0;
672+
pub const NFT_MSG_GETTABLE: ::c_int = 1;
673+
pub const NFT_MSG_DELTABLE: ::c_int = 2;
674+
pub const NFT_MSG_NEWCHAIN: ::c_int = 3;
675+
pub const NFT_MSG_GETCHAIN: ::c_int = 4;
676+
pub const NFT_MSG_DELCHAIN: ::c_int = 5;
677+
pub const NFT_MSG_NEWRULE: ::c_int = 6;
678+
pub const NFT_MSG_GETRULE: ::c_int = 7;
679+
pub const NFT_MSG_DELRULE: ::c_int = 8;
680+
pub const NFT_MSG_NEWSET: ::c_int = 9;
681+
pub const NFT_MSG_GETSET: ::c_int = 10;
682+
pub const NFT_MSG_DELSET: ::c_int = 11;
683+
pub const NFT_MSG_NEWSETELEM: ::c_int = 12;
684+
pub const NFT_MSG_GETSETELEM: ::c_int = 13;
685+
pub const NFT_MSG_DELSETELEM: ::c_int = 14;
686+
pub const NFT_MSG_NEWGEN: ::c_int = 15;
687+
pub const NFT_MSG_GETGEN: ::c_int = 16;
688+
pub const NFT_MSG_TRACE: ::c_int = 17;
689+
pub const NFT_MSG_NEWOBJ: ::c_int = 18;
690+
pub const NFT_MSG_GETOBJ: ::c_int = 19;
691+
pub const NFT_MSG_DELOBJ: ::c_int = 20;
692+
pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21;
693+
pub const NFT_MSG_MAX: ::c_int = 22;
694+
665695
#[doc(hidden)]
666696
pub const AF_MAX: ::c_int = 42;
667697
#[doc(hidden)]

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

+77
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,83 @@ pub const TIOCM_DSR: ::c_int = 0x100;
537537
pub const TIOCM_CD: ::c_int = TIOCM_CAR;
538538
pub const TIOCM_RI: ::c_int = TIOCM_RNG;
539539

540+
pub const NF_DROP: ::c_int = 0;
541+
pub const NF_ACCEPT: ::c_int = 1;
542+
pub const NF_STOLEN: ::c_int = 2;
543+
pub const NF_QUEUE: ::c_int = 3;
544+
pub const NF_REPEAT: ::c_int = 4;
545+
pub const NF_STOP: ::c_int = 5;
546+
pub const NF_MAX_VERDICT: ::c_int = NF_STOP;
547+
548+
pub const NF_VERDICT_MASK: ::c_int = 0x000000ff;
549+
pub const NF_VERDICT_FLAG_QUEUE_BYPASS: ::c_int = 0x00008000;
550+
551+
pub const NF_VERDICT_QMASK: ::c_int = 0xffff0000;
552+
pub const NF_VERDICT_QBITS: ::c_int = 16;
553+
554+
pub const NF_VERDICT_BITS: ::c_int = 16;
555+
556+
pub const NF_INET_PRE_ROUTING: ::c_int = 0;
557+
pub const NF_INET_LOCAL_IN: ::c_int = 1;
558+
pub const NF_INET_FORWARD: ::c_int = 2;
559+
pub const NF_INET_LOCAL_OUT: ::c_int = 3;
560+
pub const NF_INET_POST_ROUTING: ::c_int = 4;
561+
pub const NF_INET_NUMHOOKS: ::c_int = 5;
562+
563+
pub const NF_NETDEV_INGRESS: ::c_int = 0;
564+
pub const NF_NETDEV_NUMHOOKS: ::c_int = 1;
565+
566+
pub const NFPROTO_UNSPEC: ::c_int = 0;
567+
pub const NFPROTO_INET: ::c_int = 1;
568+
pub const NFPROTO_IPV4: ::c_int = 2;
569+
pub const NFPROTO_ARP: ::c_int = 3;
570+
pub const NFPROTO_NETDEV: ::c_int = 5;
571+
pub const NFPROTO_BRIDGE: ::c_int = 7;
572+
pub const NFPROTO_IPV6: ::c_int = 10;
573+
pub const NFPROTO_DECNET: ::c_int = 12;
574+
pub const NFPROTO_NUMPROTO: ::c_int = 13;
575+
576+
pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32;
577+
pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32;
578+
pub const NFT_SET_MAXNAMELEN: ::c_int = 32;
579+
cfg_if! {
580+
if #[cfg(not(target_arch = "sparc64"))] {
581+
pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32;
582+
} else {
583+
}
584+
}
585+
pub const NFT_USERDATA_MAXLEN: ::c_int = 256;
586+
587+
pub const NFT_MSG_NEWTABLE: ::c_int = 0;
588+
pub const NFT_MSG_GETTABLE: ::c_int = 1;
589+
pub const NFT_MSG_DELTABLE: ::c_int = 2;
590+
pub const NFT_MSG_NEWCHAIN: ::c_int = 3;
591+
pub const NFT_MSG_GETCHAIN: ::c_int = 4;
592+
pub const NFT_MSG_DELCHAIN: ::c_int = 5;
593+
pub const NFT_MSG_NEWRULE: ::c_int = 6;
594+
pub const NFT_MSG_GETRULE: ::c_int = 7;
595+
pub const NFT_MSG_DELRULE: ::c_int = 8;
596+
pub const NFT_MSG_NEWSET: ::c_int = 9;
597+
pub const NFT_MSG_GETSET: ::c_int = 10;
598+
pub const NFT_MSG_DELSET: ::c_int = 11;
599+
pub const NFT_MSG_NEWSETELEM: ::c_int = 12;
600+
pub const NFT_MSG_GETSETELEM: ::c_int = 13;
601+
pub const NFT_MSG_DELSETELEM: ::c_int = 14;
602+
pub const NFT_MSG_NEWGEN: ::c_int = 15;
603+
pub const NFT_MSG_GETGEN: ::c_int = 16;
604+
pub const NFT_MSG_TRACE: ::c_int = 17;
605+
cfg_if! {
606+
if #[cfg(not(target_arch = "sparc64"))] {
607+
pub const NFT_MSG_NEWOBJ: ::c_int = 18;
608+
pub const NFT_MSG_GETOBJ: ::c_int = 19;
609+
pub const NFT_MSG_DELOBJ: ::c_int = 20;
610+
pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21;
611+
pub const NFT_MSG_MAX: ::c_int = 22;
612+
} else {
613+
pub const NFT_MSG_MAX: ::c_int = 18;
614+
}
615+
}
616+
540617
#[doc(hidden)]
541618
pub const AF_MAX: ::c_int = 42;
542619
#[doc(hidden)]

0 commit comments

Comments
 (0)