Routing
[Routing Netlink]


Modules

 Nexthop

Routing Table Identifier Translations

char * rtnl_route_table2str (int table, char *buf, size_t size)
 Convert routing table identifier to character string.
int rtnl_route_str2table (const char *name)
 Convert character string to routing table identifier.

Routing Protocol Translations

char * rtnl_route_proto2str (int proto, char *buf, size_t size)
 Convert routing protocol identifier to character string.
int rtnl_route_str2proto (const char *name)
 Convert character string to routing protocol identifier.

Routing Metrices Translations

char * rtnl_route_metric2str (int metric, char *buf, size_t size)
 Convert routing metric identifier to character string.
int rtnl_route_str2metric (const char *name)
 Convert character string to routing metric identifier.

Nexthop Flags Translations

char * rtnl_route_nh_flags2str (int flags, char *buf, size_t len)
 Convert nexthop flags to a character string.
int rtnl_route_nh_str2flags (const char *name)
 Convert a character string to a nexthop flag.

Route Object Allocation/Freeage

rtnl_route * rtnl_route_alloc (void)
 Allocate a new route object.
void rtnl_route_free (struct rtnl_route *route)
 Free route object.

Route Object Reference Counting

void rtnl_route_get (struct rtnl_route *route)
void rtnl_route_put (struct rtnl_route *route)

Route Cache Management

nl_cache * rtnl_route_alloc_cache (struct nl_handle *handle)
 Build a route cache holding all routes currently configured in the kernel.

Route Addition

nl_msg * rtnl_route_build_add_request (struct rtnl_route *tmpl, int flags)
 Build netlink request message to add a new route.

Attribute: Routing Table

void rtnl_route_set_table (struct rtnl_route *route, int table)
 Set the table of a route to the specified value.
int rtnl_route_get_table (struct rtnl_route *route)
 Get the table of a route.

Attribute: Scope

void rtnl_route_set_scope (struct rtnl_route *route, int scope)
 Set the scope of a route to the specified value.
int rtnl_route_get_scope (struct rtnl_route *route)
 Get the scope of a route.

Attribute: Type Of Service

void rtnl_route_set_tos (struct rtnl_route *route, int tos)
 Set the TOS of a route to the specified value.
int rtnl_route_get_tos (struct rtnl_route *route)
 Get the TOS of a route.

Attribute: Realm

void rtnl_route_set_realms (struct rtnl_route *route, realm_t realms)
 Set the realms of a route to the specified value.
realm_t rtnl_route_get_realms (struct rtnl_route *route)
 Get realms of route object.

Attribute: Routing Protocol

void rtnl_route_set_protocol (struct rtnl_route *route, int proto)
 Set the protocol of a route to the specified value.
int rtnl_route_get_protocol (struct rtnl_route *route)
 Get the protocol of a route.

Attribute: Priority/Metric

void rtnl_route_set_prio (struct rtnl_route *route, int prio)
 Set the priority of a route to the specified value.
int rtnl_route_get_prio (struct rtnl_route *route)
 Get the priority of a route.

Attribute: Address Family

void rtnl_route_set_family (struct rtnl_route *route, int family)
 Set the address family of a route to the specified value.
int rtnl_route_get_family (struct rtnl_route *route)
 Get the address family of a route.

Attribute: Destination Address

int rtnl_route_set_dst (struct rtnl_route *route, struct nl_addr *addr)
 Set the destination address of a route to the specified address.
nl_addr * rtnl_route_get_dst (struct rtnl_route *route)
 Get the destination address of a route.
void rtnl_route_set_dst_len (struct rtnl_route *route, int prefix)
 Set the destination address prefix length of a route to the specified value.
int rtnl_route_get_dst_len (struct rtnl_route *route)
 Get the destination address prefix length of a route.

Attribute: Source Address

int rtnl_route_set_src (struct rtnl_route *route, struct nl_addr *addr)
 Set the source address of a route to the specified address.
nl_addr * rtnl_route_get_src (struct rtnl_route *route)
 Get the source address of a route.
void rtnl_route_set_src_len (struct rtnl_route *route, int prefix)
 Set the source address prefix length of a route to the specified value.
int rtnl_route_get_src_len (struct rtnl_route *route)
 Get the source address prefix length of a route.

Attribute: Gateway Address

int rtnl_route_set_gateway (struct rtnl_route *route, struct nl_addr *addr)
 Set the gateway address of a route to the specified address.
nl_addr * rtnl_route_get_gateway (struct rtnl_route *route)
 Get the gateway address of a route.

Attribute: Type

void rtnl_route_set_type (struct rtnl_route *route, int type)
 Set the type of a route to the specified value.
int rtnl_route_get_type (struct rtnl_route *route)
 Get the type of a route.

Attribute: Flags

void rtnl_route_set_flags (struct rtnl_route *route, unsigned int flags)
 Add flags to a route.
void rtnl_route_unset_flags (struct rtnl_route *route, unsigned int flags)
 Remove flags from a route.
unsigned int rtnl_route_get_flags (struct rtnl_route *route)
 Get flags of a route.

Attribute: Routing Metrics

int rtnl_route_set_metric (struct rtnl_route *route, int metric, uint32_t value)
 Set a metric of a route to the specified value.
int rtnl_route_unset_metric (struct rtnl_route *route, int metric)
 Unset a metric of a route.
unsigned int rtnl_route_get_metric (struct rtnl_route *route, int metric)
 Get a metric for a route.

Attribute: Preferred Source Address

int rtnl_route_set_pref_src (struct rtnl_route *route, struct nl_addr *addr)
 Set the preferred source address of a route to the specified address.
nl_addr * rtnl_route_get_pref_src (struct rtnl_route *route)
 Get the preferred source address of a route.

Attribute: Outgoing Interface Index

void rtnl_route_set_oif (struct rtnl_route *route, int ifindex)
 Set the outgoing interface of a route to the specified value.
int rtnl_route_get_oif (struct rtnl_route *route)
 Get the outgoing interface index of a route.

Attribute: Incoming Interface

void rtnl_route_set_iif (struct rtnl_route *route, const char *name)
 Set the incoming interface of a route to the specified value.
char * rtnl_route_get_iif (struct rtnl_route *route)
 Get the incomming interface name of a route.

Attribute: Nexthop

void rtnl_route_add_nexthop (struct rtnl_route *route, struct rtnl_nexthop *nh)
void rtnl_route_remove_nexthop (struct rtnl_nexthop *nh)
nl_list_headrtnl_route_get_nexthops (struct rtnl_route *route)


Function Documentation

struct rtnl_route* rtnl_route_alloc ( void   ) 

Allocate a new route object.

Returns:
New route object

Definition at line 712 of file route.c.

References nl_object_alloc_from_ops().

void rtnl_route_free ( struct rtnl_route *  route  ) 

Free route object.

Parameters:
route Route object to be freed.
Note:
Always use rtnl_route_put() unless you're absolutely sure that no other user may have a reference on this object.

Definition at line 724 of file route.c.

References nl_object_free().

struct nl_cache* rtnl_route_alloc_cache ( struct nl_handle *  handle  ) 

Build a route cache holding all routes currently configured in the kernel.

Parameters:
handle netlink handle
Allocates a new cache, initializes it properly and updates it to contain all routes currently configured in the kernel.

Note:
The caller is responsible for destroying and freeing the cache after using it.
Returns:
The cache or NULL if an error has occured.

Definition at line 764 of file route.c.

References nl_cache_alloc_from_ops(), and nl_cache_update().

struct nl_msg* rtnl_route_build_add_request ( struct rtnl_route *  tmpl,
int  flags 
)

Build netlink request message to add a new route.

Parameters:
tmpl template with data of new route
flags additional netlink message flags
Builds a new netlink message requesting a addition of a new route. The netlink message header isn't fully equipped with all relevant fields and must thus be sent out via nl_send_auto_complete() or supplemented as needed. tmpl must contain the attributes of the new route set via rtnl_route_set_* functions.

The following attributes must be set in the template:

Returns:
The netlink message

Definition at line 849 of file route.c.

References NLM_F_CREATE.

void rtnl_route_set_table ( struct rtnl_route *  route,
int  table 
)

Set the table of a route to the specified value.

Parameters:
route route to be changed
table new table value

Definition at line 865 of file route.c.

int rtnl_route_get_table ( struct rtnl_route *  route  ) 

Get the table of a route.

Parameters:
route route handle
Returns:
Table id or -1 if not set

Definition at line 876 of file route.c.

void rtnl_route_set_scope ( struct rtnl_route *  route,
int  scope 
)

Set the scope of a route to the specified value.

Parameters:
route route to be changed
scope new scope

Definition at line 895 of file route.c.

int rtnl_route_get_scope ( struct rtnl_route *  route  ) 

Get the scope of a route.

Parameters:
route route handle
Returns:
Scope or -1 if not set

Definition at line 906 of file route.c.

void rtnl_route_set_tos ( struct rtnl_route *  route,
int  tos 
)

Set the TOS of a route to the specified value.

Parameters:
route route to be changed
tos new TOS value

Definition at line 925 of file route.c.

int rtnl_route_get_tos ( struct rtnl_route *  route  ) 

Get the TOS of a route.

Parameters:
route route handle
Returns:
TOS value or -1 if not set

Definition at line 936 of file route.c.

void rtnl_route_set_realms ( struct rtnl_route *  route,
realm_t  realms 
)

Set the realms of a route to the specified value.

Parameters:
route route to be changed
realms New realms value.

Definition at line 955 of file route.c.

realm_t rtnl_route_get_realms ( struct rtnl_route *  route  ) 

Get realms of route object.

Parameters:
route Route object.
Returns:
Realms value or 0 if not set.

Definition at line 966 of file route.c.

void rtnl_route_set_protocol ( struct rtnl_route *  route,
int  proto 
)

Set the protocol of a route to the specified value.

Parameters:
route route to be changed
proto new protocol

Definition at line 985 of file route.c.

int rtnl_route_get_protocol ( struct rtnl_route *  route  ) 

Get the protocol of a route.

Parameters:
route route handle
Returns:
Protocol number or -1 if not set

Definition at line 996 of file route.c.

void rtnl_route_set_prio ( struct rtnl_route *  route,
int  prio 
)

Set the priority of a route to the specified value.

Parameters:
route route to be changed
prio new priority

Definition at line 1015 of file route.c.

int rtnl_route_get_prio ( struct rtnl_route *  route  ) 

Get the priority of a route.

Parameters:
route route handle
Returns:
Priority or -1 if not set

Definition at line 1026 of file route.c.

void rtnl_route_set_family ( struct rtnl_route *  route,
int  family 
)

Set the address family of a route to the specified value.

Parameters:
route route to be changed
family new address family

Definition at line 1045 of file route.c.

int rtnl_route_get_family ( struct rtnl_route *  route  ) 

Get the address family of a route.

Parameters:
route route handle
Returns:
Address family or AF_UNSPEC if not set

Definition at line 1056 of file route.c.

int rtnl_route_set_dst ( struct rtnl_route *  route,
struct nl_addr *  addr 
)

Set the destination address of a route to the specified address.

Parameters:
route route to be changed
addr new destination address
Assigns the new destination address to the specified route, overwrites the destination address length (rtnl_route::rt_dst_len), and sets the route's address family to the new address's family if it is not set already.

If a address family has been specified already via either calling rtnl_route_set_family() or by setting one of the other addresses, the specified addr is automatically validated against this family and the assignment fails in case of a mismatch.

Returns:
0 on success or a negative error code.

Definition at line 1087 of file route.c.

References nl_addr_get(), and nl_addr_put().

struct nl_addr* rtnl_route_get_dst ( struct rtnl_route *  route  ) 

Get the destination address of a route.

Parameters:
route route handle
Returns:
Destination address or NULL if not set

Definition at line 1111 of file route.c.

void rtnl_route_set_dst_len ( struct rtnl_route *  route,
int  prefix 
)

Set the destination address prefix length of a route to the specified value.

Parameters:
route route to be changed
prefix new destination address prefix
Attention:
The destination address prefix gets overwritten by calls to rtnl_route_set_dst() rtnl_route_set_dst_str().

Definition at line 1126 of file route.c.

int rtnl_route_get_dst_len ( struct rtnl_route *  route  ) 

Get the destination address prefix length of a route.

Parameters:
route route handle
Returns:
Prefix length or -1 if not set

Definition at line 1137 of file route.c.

int rtnl_route_set_src ( struct rtnl_route *  route,
struct nl_addr *  addr 
)

Set the source address of a route to the specified address.

Parameters:
route route to be changed
addr new source address
Assigns the new source address to the specified route, overwrites the source address length (rtnl_route::rt_src_len), and sets the route's address family to the new address's family if it is not set already.

If a address family has been specified already via either calling rtnl_route_set_family() or by setting one of the other addresses, the specified addr is automatically validated against this family and the assignment fails in case of a mismatch.

Returns:
0 on success or a negative error code.

Definition at line 1168 of file route.c.

References nl_addr_get(), and nl_addr_put().

struct nl_addr* rtnl_route_get_src ( struct rtnl_route *  route  ) 

Get the source address of a route.

Parameters:
route route handle
Returns:
Source address or NULL if not set

Definition at line 1191 of file route.c.

void rtnl_route_set_src_len ( struct rtnl_route *  route,
int  prefix 
)

Set the source address prefix length of a route to the specified value.

Parameters:
route route to be changed
prefix new source address prefix
Attention:
The source address prefix gets overwritten by calls to rtnl_route_src_dst() rtnl_route_set_src_str().

Definition at line 1206 of file route.c.

int rtnl_route_get_src_len ( struct rtnl_route *  route  ) 

Get the source address prefix length of a route.

Parameters:
route route handle
Returns:
Prefix length or -1 if not set

Definition at line 1217 of file route.c.

int rtnl_route_set_gateway ( struct rtnl_route *  route,
struct nl_addr *  addr 
)

Set the gateway address of a route to the specified address.

Parameters:
route route to be changed
addr new gateway address
Assigns the new gateway address to the specified route, and sets the route's address family to the new address's family if it is not set already.

If a address family has been specified already via either calling rtnl_route_set_family() or by setting one of the other addresses, the specified addr is automatically validated against this family and the assignment fails in case of a mismatch.

Returns:
0 on success or a negative error code.

Definition at line 1247 of file route.c.

References nl_addr_get(), and nl_addr_put().

struct nl_addr* rtnl_route_get_gateway ( struct rtnl_route *  route  ) 

Get the gateway address of a route.

Parameters:
route route handle
Returns:
Gateway address or NULL if not set

Definition at line 1270 of file route.c.

void rtnl_route_set_type ( struct rtnl_route *  route,
int  type 
)

Set the type of a route to the specified value.

Parameters:
route route to be changed
type new route type

Definition at line 1289 of file route.c.

int rtnl_route_get_type ( struct rtnl_route *  route  ) 

Get the type of a route.

Parameters:
route route handle
Returns:
Type of route or -1 if not set

Definition at line 1300 of file route.c.

void rtnl_route_set_flags ( struct rtnl_route *  route,
unsigned int  flags 
)

Add flags to a route.

Parameters:
route route to be changed
flags flags to set

Definition at line 1319 of file route.c.

void rtnl_route_unset_flags ( struct rtnl_route *  route,
unsigned int  flags 
)

Remove flags from a route.

Parameters:
route route to be changed
flags flags to unset

Definition at line 1331 of file route.c.

unsigned int rtnl_route_get_flags ( struct rtnl_route *  route  ) 

Get flags of a route.

Parameters:
route route handle

Definition at line 1342 of file route.c.

int rtnl_route_set_metric ( struct rtnl_route *  route,
int  metric,
uint32_t  value 
)

Set a metric of a route to the specified value.

Parameters:
route route to be changed
metric metric to be changed (see XXX)
value new metric value
Returns:
0 on sucess or a negative error code

Definition at line 1360 of file route.c.

int rtnl_route_unset_metric ( struct rtnl_route *  route,
int  metric 
)

Unset a metric of a route.

Parameters:
route route to be changed
metric metric to be unset (see XXX)
Returns:
0 on sucess or a negative error code

Definition at line 1378 of file route.c.

unsigned int rtnl_route_get_metric ( struct rtnl_route *  route,
int  metric 
)

Get a metric for a route.

Parameters:
route route handle
metric metric to get
Returns:
The value for the specified metric or UINT_MAX if not set

Definition at line 1395 of file route.c.

int rtnl_route_set_pref_src ( struct rtnl_route *  route,
struct nl_addr *  addr 
)

Set the preferred source address of a route to the specified address.

Parameters:
route route to be changed
addr new preferred source address
Assigns the new preferred source address to the specified route, and sets the route's address family to the new address's family if it is not set already.

If a address family has been specified already via either calling rtnl_route_set_family() or by setting one of the other addresses, the specified addr is automatically validated against this family and the assignment fails in case of a mismatch.

Returns:
0 on success or a negative error code.

Definition at line 1428 of file route.c.

References nl_addr_get(), and nl_addr_put().

struct nl_addr* rtnl_route_get_pref_src ( struct rtnl_route *  route  ) 

Get the preferred source address of a route.

Parameters:
route route handle
Returns:
Preferred source address or NULL if not set

Definition at line 1451 of file route.c.

void rtnl_route_set_oif ( struct rtnl_route *  route,
int  ifindex 
)

Set the outgoing interface of a route to the specified value.

Parameters:
route route to be changed
ifindex interface index of new outoing interface

Definition at line 1470 of file route.c.

int rtnl_route_get_oif ( struct rtnl_route *  route  ) 

Get the outgoing interface index of a route.

Parameters:
route route handle
Returns:
interface index or RTNL_LINK_NOT_FOUND if not set

Definition at line 1481 of file route.c.

References RTNL_LINK_NOT_FOUND.

void rtnl_route_set_iif ( struct rtnl_route *  route,
const char *  name 
)

Set the incoming interface of a route to the specified value.

Parameters:
route route to be changed
name interface name of the new incoming interface

Definition at line 1500 of file route.c.

char* rtnl_route_get_iif ( struct rtnl_route *  route  ) 

Get the incomming interface name of a route.

Parameters:
route route handle
Returns:
interface name or NULL if not set

Definition at line 1511 of file route.c.

char* rtnl_route_table2str ( int  table,
char *  buf,
size_t  size 
)

Convert routing table identifier to character string.

Parameters:
table Routing table identifier.
buf Destination buffer
size Size of destination buffer.
Converts a routing table identifier to a character string and stores it in the specified destination buffer.

Returns:
The destination buffer or the type encoded in hexidecimal form if the routing table identifier is unknown.

Definition at line 1571 of file route.c.

int rtnl_route_str2table ( const char *  name  ) 

Convert character string to routing table identifier.

Parameters:
name Name of routing table.
Converts the provided character string specifying a routing table identifier to the corresponding numeric value.

Returns:
Routing table identifier or a negative value if no match was found.

Definition at line 1586 of file route.c.

char* rtnl_route_proto2str ( int  proto,
char *  buf,
size_t  size 
)

Convert routing protocol identifier to character string.

Parameters:
proto Routing protocol identifier.
buf Destination buffer
size Size of destination buffer.
Converts a routing protocol identifier to a character string and stores it in the specified destination buffer.

Returns:
The destination buffer or the protocol encoded in hexidecimal form if the routing protocol is unknown.

Definition at line 1619 of file route.c.

int rtnl_route_str2proto ( const char *  name  ) 

Convert character string to routing protocol identifier.

Parameters:
name Name of routing protocol.
Converts the provided character string specifying a routing protocl identifier to the corresponding numeric value.

Returns:
Routing protocol dentifier or a negative value if no match was found.

Definition at line 1634 of file route.c.

char* rtnl_route_metric2str ( int  metric,
char *  buf,
size_t  size 
)

Convert routing metric identifier to character string.

Parameters:
metric Routing metric identifier.
buf Destination buffer
size Size of destination buffer.
Converts a routing metric identifier to a character string and stores it in the specified destination buffer.

Returns:
The destination buffer or the metric encoded in hexidecimal form if the routing metric identifier is unknown.

Definition at line 1674 of file route.c.

int rtnl_route_str2metric ( const char *  name  ) 

Convert character string to routing metric identifier.

Parameters:
name Name of routing metric.
Converts the provided character string specifying a routing metric identifier to the corresponding numeric value.

Returns:
Routing metric dentifier or a negative value if no match was found.

Definition at line 1689 of file route.c.

char* rtnl_route_nh_flags2str ( int  flags,
char *  buf,
size_t  len 
)

Convert nexthop flags to a character string.

Parameters:
flags Nexthop flags.
buf Destination buffer.
len Length of destination buffer.
Converts nexthop flags to a character string separated by commas and stores it in the specified destination buffer.

Returns:
The destination buffer

Definition at line 1718 of file route.c.

int rtnl_route_nh_str2flags ( const char *  name  ) 

Convert a character string to a nexthop flag.

Parameters:
name Name of nexthop flag.
Converts the provided character string specifying a nexthop flag to the corresponding numeric value.

Returns:
Nexthop flag or a negative value if none was found.

Definition at line 1732 of file route.c.


Generated on Fri Apr 27 14:14:08 2007 for libnl by  doxygen 1.5.1