nell 0.3.0

Linux netlink interface
Documentation
// Copyright (C) 2018 - Will Glozer. All rights reserved.

use std::os::raw::c_int;

pub const NETLINK_ROUTE:          c_int = 0;
pub const NETLINK_UNUSED:         c_int = 1;
pub const NETLINK_USERSOCK:       c_int = 2;
pub const NETLINK_FIREWALL:       c_int = 3;
pub const NETLINK_SOCK_DIAG:      c_int = 4;
pub const NETLINK_NFLOG:          c_int = 5;
pub const NETLINK_XFRM:           c_int = 6;
pub const NETLINK_SELINUX:        c_int = 7;
pub const NETLINK_ISCSI:          c_int = 8;
pub const NETLINK_AUDIT:          c_int = 9;
pub const NETLINK_FIB_LOOKUP:     c_int = 10;
pub const NETLINK_CONNECTOR:      c_int = 11;
pub const NETLINK_NETFILTER:      c_int = 12;
pub const NETLINK_IP6_FW:         c_int = 13;
pub const NETLINK_DNRTMSG:        c_int = 14;
pub const NETLINK_KOBJECT_UEVENT: c_int = 15;
pub const NETLINK_GENERIC:        c_int = 16;
pub const NETLINK_SCSITRANSPORT:  c_int = 18;
pub const NETLINK_ECRYPTFS:       c_int = 19;
pub const NETLINK_RDMA:           c_int = 20;
pub const NETLINK_CRYPTO:         c_int = 21;
pub const NETLINK_SMC:            c_int = 22;
pub const NETLINK_INET_DIAG:      c_int = NETLINK_SOCK_DIAG;

pub const NLM_F_REQUEST:          u16 = 0x01;
pub const NLM_F_MULTI:            u16 = 0x02;
pub const NLM_F_ACK:              u16 = 0x04;
pub const NLM_F_ECHO:             u16 = 0x08;
pub const NLM_F_DUMP_INTR:        u16 = 0x10;
pub const NLM_F_DUMP_FILTERED:    u16 = 0x20;
pub const NLM_F_ROOT:             u16 = 0x100;
pub const NLM_F_MATCH:            u16 = 0x200;
pub const NLM_F_ATOMIC:           u16 = 0x400;
pub const NLM_F_DUMP:             u16 = NLM_F_ROOT|NLM_F_MATCH;
pub const NLM_F_REPLACE:          u16 = 0x100;
pub const NLM_F_EXCL:             u16 = 0x200;
pub const NLM_F_CREATE:           u16 = 0x400;
pub const NLM_F_APPEND:           u16 = 0x800;
pub const NLM_F_CAPPED:           u16 = 0x100;
pub const NLM_F_ACK_TLVS:         u16 = 0x200;

pub const NLMSG_NOOP:             u16 = 0x01;
pub const NLMSG_ERROR:            u16 = 0x02;
pub const NLMSG_DONE:             u16 = 0x03;
pub const NLMSG_OVERRUN:          u16 = 0x04;

pub const AF_UNSPEC:               u8 = 0;
pub const AF_UNIX:                 u8 = 1;
pub const AF_INET:                 u8 = 2;
pub const AF_INET6:                u8 = 10;

pub const IPPROTO_ICMP:            u8 = 1;
pub const IPPROTO_IGMP:            u8 = 2;
pub const IPPROTO_IPIP:            u8 = 4;
pub const IPPROTO_TCP:             u8 = 6;
pub const IPPROTO_EGP:             u8 = 8;
pub const IPPROTO_PUP:             u8 = 12;
pub const IPPROTO_UDP:             u8 = 17;
pub const IPPROTO_IDP:             u8 = 22;
pub const IPPROTO_TP:              u8 = 29;
pub const IPPROTO_DCCP:            u8 = 33;
pub const IPPROTO_IPV6:            u8 = 41;
pub const IPPROTO_RSVP:            u8 = 46;
pub const IPPROTO_GRE:             u8 = 47;
pub const IPPROTO_ESP:             u8 = 50;
pub const IPPROTO_AH:              u8 = 51;
pub const IPPROTO_MTP:             u8 = 92;
pub const IPPROTO_BEETPH:          u8 = 94;
pub const IPPROTO_ENCAP:           u8 = 98;
pub const IPPROTO_PIM:             u8 = 103;
pub const IPPROTO_COMP:            u8 = 108;
pub const IPPROTO_SCTP:            u8 = 132;
pub const IPPROTO_UDPLITE:         u8 = 136;
pub const IPPROTO_MPLS:            u8 = 137;
pub const IPPROTO_RAW:             u8 = 255;

#[repr(C)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct nlmsghdr {
    pub nlmsg_len:   u32,
    pub nlmsg_type:  u16,
    pub nlmsg_flags: u16,
    pub nlmsg_seq:   u32,
    pub nlmsg_pid:   u32,
}

#[repr(C)]
#[derive(Clone, Debug, Default)]
pub struct nlmsgerr {
    pub error: c_int,
    pub msg:   nlmsghdr,
}

#[repr(C)]
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct nlattr {
    pub nla_len:  u16,
    pub nla_type: u16,
}