Skip to content

Commit 68d4a03

Browse files
committed
Add netlink constants
Add netlink constants from linux/netlink.h Signed-off-by: Jana Radhakrishnan <[email protected]>
1 parent 836cda9 commit 68d4a03

File tree

3 files changed

+286
-148
lines changed

3 files changed

+286
-148
lines changed

src/unix/notbsd/android/mod.rs

Lines changed: 84 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,10 @@ pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS);
261261
pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE);
262262
pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT);
263263
pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION);
264-
pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK
265-
| ::LC_NUMERIC_MASK
266-
| ::LC_TIME_MASK
267-
| ::LC_COLLATE_MASK
268-
| ::LC_MONETARY_MASK
269-
| ::LC_MESSAGES_MASK
270-
| LC_PAPER_MASK
271-
| LC_NAME_MASK
272-
| LC_ADDRESS_MASK
273-
| LC_TELEPHONE_MASK
274-
| LC_MEASUREMENT_MASK
275-
| LC_IDENTIFICATION_MASK;
264+
pub const LC_ALL_MASK: ::c_int =
265+
::LC_CTYPE_MASK | ::LC_NUMERIC_MASK | ::LC_TIME_MASK | ::LC_COLLATE_MASK |
266+
::LC_MONETARY_MASK | ::LC_MESSAGES_MASK | LC_PAPER_MASK | LC_NAME_MASK |
267+
LC_ADDRESS_MASK | LC_TELEPHONE_MASK | LC_MEASUREMENT_MASK | LC_IDENTIFICATION_MASK;
276268

277269
pub const MAP_ANON: ::c_int = 0x0020;
278270
pub const MAP_ANONYMOUS: ::c_int = 0x0020;
@@ -543,12 +535,12 @@ pub const CBAUD: ::tcflag_t = 0o0010017;
543535
pub const TAB1: ::c_int = 0x00000800;
544536
pub const TAB2: ::c_int = 0x00001000;
545537
pub const TAB3: ::c_int = 0x00001800;
546-
pub const CR1: ::c_int = 0x00000200;
547-
pub const CR2: ::c_int = 0x00000400;
548-
pub const CR3: ::c_int = 0x00000600;
549-
pub const FF1: ::c_int = 0x00008000;
550-
pub const BS1: ::c_int = 0x00002000;
551-
pub const VT1: ::c_int = 0x00004000;
538+
pub const CR1: ::c_int = 0x00000200;
539+
pub const CR2: ::c_int = 0x00000400;
540+
pub const CR3: ::c_int = 0x00000600;
541+
pub const FF1: ::c_int = 0x00008000;
542+
pub const BS1: ::c_int = 0x00002000;
543+
pub const VT1: ::c_int = 0x00004000;
552544
pub const VWERASE: usize = 14;
553545
pub const VREPRINT: usize = 12;
554546
pub const VSUSP: usize = 10;
@@ -580,6 +572,65 @@ pub const ICANON: ::tcflag_t = 0x00000002;
580572
pub const PENDIN: ::tcflag_t = 0x00004000;
581573
pub const NOFLSH: ::tcflag_t = 0x00000080;
582574

575+
pub const NETLINK_ROUTE: ::c_int = 0;
576+
pub const NETLINK_UNUSED: ::c_int = 1;
577+
pub const NETLINK_USERSOCK: ::c_int = 2;
578+
pub const NETLINK_FIREWALL: ::c_int = 3;
579+
pub const NETLINK_SOCK_DIAG: ::c_int = 4;
580+
pub const NETLINK_NFLOG: ::c_int = 5;
581+
pub const NETLINK_XFRM: ::c_int = 6;
582+
pub const NETLINK_SELINUX: ::c_int = 7;
583+
pub const NETLINK_ISCSI: ::c_int = 8;
584+
pub const NETLINK_AUDIT: ::c_int = 9;
585+
pub const NETLINK_FIB_LOOKUP: ::c_int = 10;
586+
pub const NETLINK_CONNECTOR: ::c_int = 11;
587+
pub const NETLINK_NETFILTER: ::c_int = 12;
588+
pub const NETLINK_IP6_FW: ::c_int = 13;
589+
pub const NETLINK_DNRTMSG: ::c_int = 14;
590+
pub const NETLINK_KOBJECT_UEVENT: ::c_int = 15;
591+
pub const NETLINK_GENERIC: ::c_int = 16;
592+
pub const NETLINK_SCSITRANSPORT: ::c_int = 18;
593+
pub const NETLINK_ECRYPTFS: ::c_int = 19;
594+
pub const NETLINK_RDMA: ::c_int = 20;
595+
pub const NETLINK_CRYPTO: ::c_int = 21;
596+
pub const NETLINK_INET_DIAG: ::c_int = NETLINK_SOCK_DIAG;
597+
598+
pub const MAX_LINKS: ::c_int = 32;
599+
600+
pub const NLM_F_REQUEST: ::c_int = 1;
601+
pub const NLM_F_MULTI: ::c_int = 2;
602+
pub const NLM_F_ACK: ::c_int = 4;
603+
pub const NLM_F_ECHO: ::c_int = 8;
604+
pub const NLM_F_DUMP_INTR: ::c_int = 16;
605+
606+
pub const NLM_F_ROOT: ::c_int = 0x100;
607+
pub const NLM_F_MATCH: ::c_int = 0x200;
608+
pub const NLM_F_ATOMIC: ::c_int = 0x400;
609+
pub const NLM_F_DUMP: ::c_int = NLM_F_ROOT | NLM_F_MATCH;
610+
611+
pub const NLM_F_REPLACE: ::c_int = 0x100;
612+
pub const NLM_F_EXCL: ::c_int = 0x200;
613+
pub const NLM_F_CREATE: ::c_int = 0x400;
614+
pub const NLM_F_APPEND: ::c_int = 0x800;
615+
616+
pub const NLMSG_NOOP: ::c_int = 0x1;
617+
pub const NLMSG_ERROR: ::c_int = 0x2;
618+
pub const NLMSG_DONE: ::c_int = 0x3;
619+
pub const NLMSG_OVERRUN: ::c_int = 0x4;
620+
pub const NLMSG_MIN_TYPE: ::c_int = 0x10;
621+
622+
pub const NETLINK_ADD_MEMBERSHIP: ::c_int = 1;
623+
pub const NETLINK_DROP_MEMBERSHIP: ::c_int = 2;
624+
pub const NETLINK_PKTINFO: ::c_int = 3;
625+
pub const NETLINK_BROADCAST_ERROR: ::c_int = 4;
626+
pub const NETLINK_NO_ENOBUFS: ::c_int = 5;
627+
pub const NETLINK_RX_RING: ::c_int = 6;
628+
pub const NETLINK_TX_RING: ::c_int = 7;
629+
630+
pub const NLA_F_NESTED: ::c_int = 1 << 15;
631+
pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14;
632+
pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);
633+
583634
f! {
584635
pub fn sigemptyset(set: *mut sigset_t) -> ::c_int {
585636
*set = 0;
@@ -665,33 +716,32 @@ f! {
665716
}
666717
}
667718

668-
extern {
719+
extern "C" {
669720
static mut __progname: *mut ::c_char;
670721
}
671722

672-
extern {
673-
pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int)
674-
-> ::c_int;
723+
extern "C" {
724+
pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int;
675725
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
676-
pub fn readlink(path: *const ::c_char,
677-
buf: *mut ::c_char,
678-
bufsz: ::size_t)
679-
-> ::c_int;
680-
pub fn msync(addr: *const ::c_void, len: ::size_t,
681-
flags: ::c_int) -> ::c_int;
682-
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
683-
-> ::c_int;
726+
pub fn readlink(path: *const ::c_char, buf: *mut ::c_char, bufsz: ::size_t) -> ::c_int;
727+
pub fn msync(addr: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
728+
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
684729
pub fn sysconf(name: ::c_int) -> ::c_long;
685-
pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
686-
flags: ::c_int, addr: *const ::sockaddr,
687-
addrlen: *mut ::socklen_t) -> ::ssize_t;
730+
pub fn recvfrom(socket: ::c_int,
731+
buf: *mut ::c_void,
732+
len: ::size_t,
733+
flags: ::c_int,
734+
addr: *const ::sockaddr,
735+
addrlen: *mut ::socklen_t)
736+
-> ::ssize_t;
688737
pub fn getnameinfo(sa: *const ::sockaddr,
689738
salen: ::socklen_t,
690739
host: *mut ::c_char,
691740
hostlen: ::size_t,
692741
serv: *mut ::c_char,
693742
sevlen: ::size_t,
694-
flags: ::c_int) -> ::c_int;
743+
flags: ::c_int)
744+
-> ::c_int;
695745
pub fn ptrace(request: ::c_int, ...) -> ::c_long;
696746
pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int;
697747
pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int;

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

Lines changed: 83 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,10 @@ pub const LC_ADDRESS_MASK: ::c_int = (1 << LC_ADDRESS);
180180
pub const LC_TELEPHONE_MASK: ::c_int = (1 << LC_TELEPHONE);
181181
pub const LC_MEASUREMENT_MASK: ::c_int = (1 << LC_MEASUREMENT);
182182
pub const LC_IDENTIFICATION_MASK: ::c_int = (1 << LC_IDENTIFICATION);
183-
pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK
184-
| ::LC_NUMERIC_MASK
185-
| ::LC_TIME_MASK
186-
| ::LC_COLLATE_MASK
187-
| ::LC_MONETARY_MASK
188-
| ::LC_MESSAGES_MASK
189-
| LC_PAPER_MASK
190-
| LC_NAME_MASK
191-
| LC_ADDRESS_MASK
192-
| LC_TELEPHONE_MASK
193-
| LC_MEASUREMENT_MASK
194-
| LC_IDENTIFICATION_MASK;
183+
pub const LC_ALL_MASK: ::c_int =
184+
::LC_CTYPE_MASK | ::LC_NUMERIC_MASK | ::LC_TIME_MASK | ::LC_COLLATE_MASK |
185+
::LC_MONETARY_MASK | ::LC_MESSAGES_MASK | LC_PAPER_MASK | LC_NAME_MASK |
186+
LC_ADDRESS_MASK | LC_TELEPHONE_MASK | LC_MEASUREMENT_MASK | LC_IDENTIFICATION_MASK;
195187

196188
pub const MAP_ANON: ::c_int = 0x0020;
197189
pub const MAP_ANONYMOUS: ::c_int = 0x0020;
@@ -485,6 +477,69 @@ pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
485477
pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
486478
pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
487479

480+
pub const NETLINK_ROUTE: ::c_int = 0;
481+
pub const NETLINK_UNUSED: ::c_int = 1;
482+
pub const NETLINK_USERSOCK: ::c_int = 2;
483+
pub const NETLINK_FIREWALL: ::c_int = 3;
484+
pub const NETLINK_SOCK_DIAG: ::c_int = 4;
485+
pub const NETLINK_NFLOG: ::c_int = 5;
486+
pub const NETLINK_XFRM: ::c_int = 6;
487+
pub const NETLINK_SELINUX: ::c_int = 7;
488+
pub const NETLINK_ISCSI: ::c_int = 8;
489+
pub const NETLINK_AUDIT: ::c_int = 9;
490+
pub const NETLINK_FIB_LOOKUP: ::c_int = 10;
491+
pub const NETLINK_CONNECTOR: ::c_int = 11;
492+
pub const NETLINK_NETFILTER: ::c_int = 12;
493+
pub const NETLINK_IP6_FW: ::c_int = 13;
494+
pub const NETLINK_DNRTMSG: ::c_int = 14;
495+
pub const NETLINK_KOBJECT_UEVENT: ::c_int = 15;
496+
pub const NETLINK_GENERIC: ::c_int = 16;
497+
pub const NETLINK_SCSITRANSPORT: ::c_int = 18;
498+
pub const NETLINK_ECRYPTFS: ::c_int = 19;
499+
pub const NETLINK_RDMA: ::c_int = 20;
500+
pub const NETLINK_CRYPTO: ::c_int = 21;
501+
pub const NETLINK_INET_DIAG: ::c_int = NETLINK_SOCK_DIAG;
502+
503+
pub const MAX_LINKS: ::c_int = 32;
504+
505+
pub const NLM_F_REQUEST: ::c_int = 1;
506+
pub const NLM_F_MULTI: ::c_int = 2;
507+
pub const NLM_F_ACK: ::c_int = 4;
508+
pub const NLM_F_ECHO: ::c_int = 8;
509+
pub const NLM_F_DUMP_INTR: ::c_int = 16;
510+
pub const NLM_F_DUMP_FILTERED: ::c_int = 32;
511+
512+
pub const NLM_F_ROOT: ::c_int = 0x100;
513+
pub const NLM_F_MATCH: ::c_int = 0x200;
514+
pub const NLM_F_ATOMIC: ::c_int = 0x400;
515+
pub const NLM_F_DUMP: ::c_int = NLM_F_ROOT | NLM_F_MATCH;
516+
517+
pub const NLM_F_REPLACE: ::c_int = 0x100;
518+
pub const NLM_F_EXCL: ::c_int = 0x200;
519+
pub const NLM_F_CREATE: ::c_int = 0x400;
520+
pub const NLM_F_APPEND: ::c_int = 0x800;
521+
522+
pub const NLMSG_NOOP: ::c_int = 0x1;
523+
pub const NLMSG_ERROR: ::c_int = 0x2;
524+
pub const NLMSG_DONE: ::c_int = 0x3;
525+
pub const NLMSG_OVERRUN: ::c_int = 0x4;
526+
pub const NLMSG_MIN_TYPE: ::c_int = 0x10;
527+
528+
pub const NETLINK_ADD_MEMBERSHIP: ::c_int = 1;
529+
pub const NETLINK_DROP_MEMBERSHIP: ::c_int = 2;
530+
pub const NETLINK_PKTINFO: ::c_int = 3;
531+
pub const NETLINK_BROADCAST_ERROR: ::c_int = 4;
532+
pub const NETLINK_NO_ENOBUFS: ::c_int = 5;
533+
pub const NETLINK_RX_RING: ::c_int = 6;
534+
pub const NETLINK_TX_RING: ::c_int = 7;
535+
pub const NETLINK_LISTEN_ALL_NSID: ::c_int = 8;
536+
pub const NETLINK_LIST_MEMBERSHIPS: ::c_int = 9;
537+
pub const NETLINK_CAP_ACK: ::c_int = 10;
538+
539+
pub const NLA_F_NESTED: ::c_int = 1 << 15;
540+
pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14;
541+
pub const NLA_TYPE_MASK: ::c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);
542+
488543
cfg_if! {
489544
if #[cfg(any(target_arch = "arm", target_arch = "x86",
490545
target_arch = "x86_64"))] {
@@ -494,7 +549,7 @@ cfg_if! {
494549
}
495550
}
496551

497-
extern {
552+
extern "C" {
498553
pub fn utmpxname(file: *const ::c_char) -> ::c_int;
499554
pub fn getutxent() -> *mut utmpx;
500555
pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
@@ -505,7 +560,7 @@ extern {
505560
}
506561

507562
#[link(name = "util")]
508-
extern {
563+
extern "C" {
509564
pub fn sysctl(name: *mut ::c_int,
510565
namelen: ::c_int,
511566
oldp: *mut ::c_void,
@@ -514,31 +569,33 @@ extern {
514569
newlen: ::size_t)
515570
-> ::c_int;
516571
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
517-
pub fn backtrace(buf: *mut *mut ::c_void,
518-
sz: ::c_int) -> ::c_int;
572+
pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int;
519573
pub fn glob64(pattern: *const ::c_char,
520574
flags: ::c_int,
521-
errfunc: ::dox::Option<extern fn(epath: *const ::c_char,
522-
errno: ::c_int)
523-
-> ::c_int>,
524-
pglob: *mut glob64_t) -> ::c_int;
575+
errfunc: ::dox::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int)
576+
-> ::c_int>,
577+
pglob: *mut glob64_t)
578+
-> ::c_int;
525579
pub fn globfree64(pglob: *mut glob64_t);
526580
pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
527581
pub fn pthread_attr_getaffinity_np(attr: *const ::pthread_attr_t,
528582
cpusetsize: ::size_t,
529-
cpuset: *mut ::cpu_set_t) -> ::c_int;
583+
cpuset: *mut ::cpu_set_t)
584+
-> ::c_int;
530585
pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
531586
cpusetsize: ::size_t,
532-
cpuset: *const ::cpu_set_t) -> ::c_int;
587+
cpuset: *const ::cpu_set_t)
588+
-> ::c_int;
533589
pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int;
534-
pub fn setpriority(which: ::__priority_which_t, who: ::id_t,
535-
prio: ::c_int) -> ::c_int;
590+
pub fn setpriority(which: ::__priority_which_t, who: ::id_t, prio: ::c_int) -> ::c_int;
536591
pub fn pthread_getaffinity_np(thread: ::pthread_t,
537592
cpusetsize: ::size_t,
538-
cpuset: *mut ::cpu_set_t) -> ::c_int;
593+
cpuset: *mut ::cpu_set_t)
594+
-> ::c_int;
539595
pub fn pthread_setaffinity_np(thread: ::pthread_t,
540596
cpusetsize: ::size_t,
541-
cpuset: *const ::cpu_set_t) -> ::c_int;
597+
cpuset: *const ::cpu_set_t)
598+
-> ::c_int;
542599
pub fn sched_getcpu() -> ::c_int;
543600
}
544601

0 commit comments

Comments
 (0)