[−][src]Module neli::consts
C constants defined as types
High level notes
The items in this module are created by macros, which give them the traits necessary to be
serialized into Netlink compatible types. The macros are exported - you can use them too!
See impl_var
, impl_trait
, and impl_var_trait
.
Note that most of these constants come from the Linux kernel headers, which can be found
in /usr/include/linux
on many distros. You can also see man 3 netlink
, man 7 netlink
,
and man 7 rtnetlink
for more information.
Design decisions
- Macros are exported so that these conventions are extensible and usable for data types implemented by the user in the case of new netlink families (which is supported by the protocol). In this case, there is no way in which I can support every custom netlink family but my aim is to make this library as flexible as possible so that it is painless to hook your custom netlink data type into the existing library support.
- Enums are used so that:
- Values can be checked based on a finite number of inputs as opposed to the range of whatever integer data type C defines as the struct member type. This hopefully makes it easier to catch garbage responses and corruption when an invalid netlink message is sent to the kernel.
- Only the enum or an enum implementing a marker trait in the case of generics can be used in the appropriate places when constructing netlink messages. This takes guess work out of which constants can be used where. Netlink documentation is not always complete and sometimes takes a bit of trial and error actually sending messages to the kernel to figure out if you are using the correct constants. This setup should let you know at compile time if you are doing something you should not be doing.
UnrecognizedVariant
is included in each enum because completeness cannot be guaranteed for every constant for every protocol. This allows you to inspect the integer value returned and if you are sure that it is correct, you can use it. If it is a garbage value, this can also be useful for error reporting.
Enums
AddrFamily | General address families for sockets |
Af | Internet address families |
Arphrd | Interface types |
CtrlAttr | Values for |
CtrlAttrMcastGrp | Values for |
CtrlCmd | Values for |
GenlId | Values for |
Ifa | Enum for use with |
IfaF | Interface address flags |
Iff | Values for |
Ifla | Enum for use with |
NlFamily | Values for |
NlmF | Values for |
Nlmsg | Values for |
Ntf | Arp neighbor cache entry flags |
Nud | Arp neighbor cache entry states |
RtScope |
|
RtTable |
|
Rta | Enum for use with |
RtmF |
|
Rtn |
|
Rtprot |
|
Tca | Enum for use with |
Traits
Cmd | Trait marking constants valid for use in |
NlAttrType | Marker trait for types usable in |
NlType | Trait marking constants valid for use in |
RtaType | Marker trait for |
Functions
alignto | Reimplementation of alignto macro in C |