libnl 1.1.4
Modules
Routing Netlink

Modules

 Addresses
 
 
 Neighbours
 The neighbour table establishes bindings between protocol addresses and link layer addresses for hosts sharing the same physical link.
 
 Neighbour Tables
 
 Routing
 
 Routing Rules
 
 Traffic Control
 

Routing Type Translations

char * nl_rtntype2str (int type, char *buf, size_t size)
 
int nl_str2rtntype (const char *name)
 

Scope Translations

char * rtnl_scope2str (int scope, char *buf, size_t size)
 
int rtnl_str2scope (const char *name)
 

Sending

int nl_rtgen_request (struct nl_handle *handle, int type, int family, int flags)
 Send routing netlink request message.
 

Realms Translations

char * rtnl_realms2str (uint32_t realms, char *buf, size_t len)
 

Realms

#define RTNL_REALM_MASK   (0xFFFF)
 Mask specying the size of each realm part.
 
#define RTNL_REALM_FROM(realm)   ((realm) >> 16)
 Extract FROM realm from a realms field.
 
#define RTNL_REALM_TO(realm)   ((realm) & RTNL_REALM_MASK)
 Extract TO realm from a realms field.
 
#define RTNL_MAKE_REALM(from, to)    ((RTNL_REALM_TO(from) << 16) & RTNL_REALM_TO(to))
 Build a realms field.
 
typedef uint32_t realm_t
 

Detailed Description

Macro Definition Documentation

◆ RTNL_REALM_MASK

#define RTNL_REALM_MASK   (0xFFFF)

Definition at line 32 of file rtnl.h.

◆ RTNL_REALM_FROM

#define RTNL_REALM_FROM (   realm)    ((realm) >> 16)

Definition at line 37 of file rtnl.h.

◆ RTNL_REALM_TO

#define RTNL_REALM_TO (   realm)    ((realm) & RTNL_REALM_MASK)

Definition at line 42 of file rtnl.h.

◆ RTNL_MAKE_REALM

#define RTNL_MAKE_REALM (   from,
  to 
)     ((RTNL_REALM_TO(from) << 16) & RTNL_REALM_TO(to))

Definition at line 47 of file rtnl.h.

Typedef Documentation

◆ realm_t

typedef uint32_t realm_t

Definition at line 26 of file rtnl.h.

Function Documentation

◆ nl_rtgen_request()

int nl_rtgen_request ( struct nl_handle *  handle,
int  type,
int  family,
int  flags 
)
Parameters
handleNetlink handle.
typeNetlink message type.
familyAddress family.
flagsAdditional netlink message flags.

Fills out a routing netlink request message and sends it out using nl_send_simple().

Returns
0 on success or a negative error code.

Definition at line 40 of file rtnl.c.

41{
42 struct rtgenmsg gmsg = {
43 .rtgen_family = family,
44 };
45
46 return nl_send_simple(handle, type, flags, &gmsg, sizeof(gmsg));
47}
int nl_send_simple(struct nl_handle *handle, int type, int flags, void *buf, size_t size)
Send simple netlink message using nl_send_auto_complete()
Definition: nl.c:410

References nl_send_simple().

◆ nl_rtntype2str()

char * nl_rtntype2str ( int  type,
char *  buf,
size_t  size 
)

Definition at line 71 of file rtnl.c.

72{
73 return __type2str(type, buf, size, rtntypes, ARRAY_SIZE(rtntypes));
74}

◆ nl_str2rtntype()

int nl_str2rtntype ( const char *  name)

Definition at line 76 of file rtnl.c.

77{
78 return __str2type(name, rtntypes, ARRAY_SIZE(rtntypes));
79}

◆ rtnl_scope2str()

char * rtnl_scope2str ( int  scope,
char *  buf,
size_t  size 
)

Definition at line 96 of file rtnl.c.

97{
98 return __type2str(scope, buf, size, scopes, ARRAY_SIZE(scopes));
99}

◆ rtnl_str2scope()

int rtnl_str2scope ( const char *  name)

Definition at line 101 of file rtnl.c.

102{
103 return __str2type(name, scopes, ARRAY_SIZE(scopes));
104}

◆ rtnl_realms2str()

char * rtnl_realms2str ( uint32_t  realms,
char *  buf,
size_t  len 
)

Definition at line 113 of file rtnl.c.

114{
115 int from = RTNL_REALM_FROM(realms);
116 int to = RTNL_REALM_TO(realms);
117
118 snprintf(buf, len, "%d/%d", from, to);
119
120 return buf;
121}
#define RTNL_REALM_TO(realm)
Extract TO realm from a realms field.
Definition: rtnl.h:42
#define RTNL_REALM_FROM(realm)
Extract FROM realm from a realms field.
Definition: rtnl.h:37