Neighbour Tables
[Routing Netlink]

Allocation/Freeing



struct rtnl_neightbl * rtnl_neightbl_alloc (void)
void rtnl_neightbl_put (struct rtnl_neightbl *neightbl)

Neighbour Table Cache Management



struct nl_cache * rtnl_neightbl_alloc_cache (struct nl_handle *handle)
 Build a neighbour table cache including all neighbour tables currently configured in the kernel.
struct rtnl_neightbl * rtnl_neightbl_get (struct nl_cache *cache, const char *name, int ifindex)
 Lookup neighbour table by name and optional interface index.

Neighbour Table Modifications



struct nl_msg * rtnl_neightbl_build_change_request (struct rtnl_neightbl *old, struct rtnl_neightbl *tmpl)
 Builds a netlink change request message to change neighbour table attributes.
int rtnl_neightbl_change (struct nl_handle *handle, struct rtnl_neightbl *old, struct rtnl_neightbl *tmpl)
 Change neighbour table attributes.

Attribute Modification



void rtnl_neightbl_set_family (struct rtnl_neightbl *ntbl, int family)
void rtnl_neightbl_set_gc_interval (struct rtnl_neightbl *ntbl, uint64_t ms)
void rtnl_neightbl_set_gc_tresh1 (struct rtnl_neightbl *ntbl, int thresh)
void rtnl_neightbl_set_gc_tresh2 (struct rtnl_neightbl *ntbl, int thresh)
void rtnl_neightbl_set_gc_tresh3 (struct rtnl_neightbl *ntbl, int thresh)
void rtnl_neightbl_set_name (struct rtnl_neightbl *ntbl, const char *name)
void rtnl_neightbl_set_dev (struct rtnl_neightbl *ntbl, int ifindex)
void rtnl_neightbl_set_queue_len (struct rtnl_neightbl *ntbl, int len)
 Set the queue length for pending requests of a neighbour table to the specified value.
void rtnl_neightbl_set_proxy_queue_len (struct rtnl_neightbl *ntbl, int len)
 Set the queue length for delay proxy arp requests of a neighbour table to the specified value.
void rtnl_neightbl_set_app_probes (struct rtnl_neightbl *ntbl, int probes)
 Set the number of application probes of a neighbour table to the specified value.
void rtnl_neightbl_set_ucast_probes (struct rtnl_neightbl *ntbl, int probes)
 Set the number of unicast probes of a neighbour table to the specified value.
void rtnl_neightbl_set_mcast_probes (struct rtnl_neightbl *ntbl, int probes)
 Set the number of multicast probes of a neighbour table to the specified value.
void rtnl_neightbl_set_base_reachable_time (struct rtnl_neightbl *ntbl, uint64_t ms)
 Set the base reachable time of a neighbour table to the specified value.
void rtnl_neightbl_set_retrans_time (struct rtnl_neightbl *ntbl, uint64_t ms)
 Set the retransmit time of a neighbour table to the specified value.
void rtnl_neightbl_set_gc_stale_time (struct rtnl_neightbl *ntbl, uint64_t ms)
 Set the gc stale time of a neighbour table to the specified value.
void rtnl_neightbl_set_delay_probe_time (struct rtnl_neightbl *ntbl, uint64_t ms)
 Set the first probe delay time of a neighbour table to the specified value.
void rtnl_neightbl_set_anycast_delay (struct rtnl_neightbl *ntbl, uint64_t ms)
 Set the anycast delay of a neighbour table to the specified value.
void rtnl_neightbl_set_proxy_delay (struct rtnl_neightbl *ntbl, uint64_t ms)
 Set the proxy delay of a neighbour table to the specified value.
void rtnl_neightbl_set_locktime (struct rtnl_neightbl *ntbl, uint64_t ms)
 Set the locktime of a neighbour table to the specified value.

Function Documentation

struct nl_cache* rtnl_neightbl_alloc_cache ( struct nl_handle *  handle  )  [read]
Parameters:
handle netlink handle

Allocates a new neighbour table cache, initializes it properly and updates it to include all neighbour tables currently configured in the kernel.

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

Definition at line 407 of file neightbl.c.

References nl_cache_alloc(), nl_cache_free(), and nl_cache_refill().

00408 {
00409         struct nl_cache * cache;
00410         
00411         cache = nl_cache_alloc(&rtnl_neightbl_ops);
00412         if (cache == NULL)
00413                 return NULL;
00414         
00415         if (handle && nl_cache_refill(handle, cache) < 0) {
00416                 nl_cache_free(cache);
00417                 return NULL;
00418         }
00419 
00420         return cache;
00421 }

struct rtnl_neightbl* rtnl_neightbl_get ( struct nl_cache *  cache,
const char *  name,
int  ifindex 
) [read]
Parameters:
cache neighbour table cache
name name of table
ifindex optional interface index

Looks up the neighbour table matching the specified name and optionally the specified ifindex to retrieve device specific parameter sets.

Returns:
ptr to neighbour table inside the cache or NULL if no match was found.

Definition at line 436 of file neightbl.c.

References nl_object_get().

00438 {
00439         struct rtnl_neightbl *nt;
00440 
00441         if (cache->c_ops != &rtnl_neightbl_ops)
00442                 return NULL;
00443 
00444         nl_list_for_each_entry(nt, &cache->c_items, ce_list) {
00445                 if (!strcasecmp(nt->nt_name, name) &&
00446                     ((!ifindex && !nt->nt_parms.ntp_ifindex) ||
00447                      (ifindex && ifindex == nt->nt_parms.ntp_ifindex))) {
00448                         nl_object_get((struct nl_object *) nt);
00449                         return nt;
00450                 }
00451         }
00452 
00453         return NULL;
00454 }

struct nl_msg* rtnl_neightbl_build_change_request ( struct rtnl_neightbl *  old,
struct rtnl_neightbl *  tmpl 
) [read]
Parameters:
old neighbour table to change
tmpl template with requested changes

Builds a new netlink message requesting a change of neighbour table attributes. The netlink message header isn't fully equipped with all relevant fields and must be sent out via nl_send_auto_complete() or supplemented as needed. old must point to a neighbour table currently configured in the kernel and tmpl must contain the attributes to be changed set via rtnl_neightbl_set_* functions.

Returns:
New netlink message

Definition at line 478 of file neightbl.c.

References nla_put_nested(), nla_put_string(), nla_put_u32(), nla_put_u64(), nlmsg_alloc(), nlmsg_alloc_simple(), nlmsg_append(), and nlmsg_free().

Referenced by rtnl_neightbl_change().

00480 {
00481         struct nl_msg *m;
00482         struct ndtmsg ndt = {
00483                 .ndtm_family = old->nt_family,
00484         };
00485 
00486         m = nlmsg_alloc_simple(RTM_SETNEIGHTBL, 0);
00487         nlmsg_append(m, &ndt, sizeof(ndt), NLMSG_ALIGNTO);
00488 
00489         nla_put_string(m, NDTA_NAME, old->nt_name);
00490 
00491         if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH1)
00492                 nla_put_u32(m, NDTA_THRESH1, tmpl->nt_gc_thresh1);
00493 
00494         if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
00495                 nla_put_u32(m, NDTA_THRESH2, tmpl->nt_gc_thresh2);
00496 
00497         if (tmpl->ce_mask & NEIGHTBL_ATTR_THRESH2)
00498                 nla_put_u32(m, NDTA_THRESH2, tmpl->nt_gc_thresh2);
00499 
00500         if (tmpl->ce_mask & NEIGHTBL_ATTR_GC_INTERVAL)
00501                 nla_put_u64(m, NDTA_GC_INTERVAL,
00502                                       tmpl->nt_gc_interval);
00503 
00504         if (tmpl->ce_mask & NEIGHTBL_ATTR_PARMS) {
00505                 struct rtnl_neightbl_parms *p = &tmpl->nt_parms;
00506                 struct nl_msg *parms = nlmsg_alloc();
00507 
00508                 if (old->nt_parms.ntp_mask & NEIGHTBLPARM_ATTR_IFINDEX)
00509                         nla_put_u32(parms, NDTPA_IFINDEX,
00510                                               old->nt_parms.ntp_ifindex);
00511 
00512 
00513                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_QUEUE_LEN)
00514                         nla_put_u32(parms, NDTPA_QUEUE_LEN, p->ntp_queue_len);
00515 
00516                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_APP_PROBES)
00517                         nla_put_u32(parms, NDTPA_APP_PROBES, p->ntp_app_probes);
00518 
00519                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_UCAST_PROBES)
00520                         nla_put_u32(parms, NDTPA_UCAST_PROBES,
00521                                     p->ntp_ucast_probes);
00522 
00523                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_MCAST_PROBES)
00524                         nla_put_u32(parms, NDTPA_MCAST_PROBES,
00525                                     p->ntp_mcast_probes);
00526 
00527                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_QLEN)
00528                         nla_put_u32(parms, NDTPA_PROXY_QLEN,
00529                                     p->ntp_proxy_qlen);
00530 
00531                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME)
00532                         nla_put_u64(parms, NDTPA_BASE_REACHABLE_TIME,
00533                                     p->ntp_base_reachable_time);
00534 
00535                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_RETRANS_TIME)
00536                         nla_put_u64(parms, NDTPA_RETRANS_TIME,
00537                                     p->ntp_retrans_time);
00538 
00539                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_GC_STALETIME)
00540                         nla_put_u64(parms, NDTPA_GC_STALETIME,
00541                                     p->ntp_gc_stale_time);
00542 
00543                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME)
00544                         nla_put_u64(parms, NDTPA_DELAY_PROBE_TIME,
00545                                     p->ntp_proxy_delay);
00546 
00547                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_ANYCAST_DELAY)
00548                         nla_put_u64(parms, NDTPA_ANYCAST_DELAY,
00549                                     p->ntp_anycast_delay);
00550 
00551                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_PROXY_DELAY)
00552                         nla_put_u64(parms, NDTPA_PROXY_DELAY,
00553                                               p->ntp_proxy_delay);
00554 
00555                 if (p->ntp_mask & NEIGHTBLPARM_ATTR_LOCKTIME)
00556                         nla_put_u64(parms, NDTPA_LOCKTIME, p->ntp_locktime);
00557 
00558                 nla_put_nested(m, NDTA_PARMS, parms);
00559                 nlmsg_free(parms);
00560         }
00561         
00562         return m;
00563 }

int rtnl_neightbl_change ( struct nl_handle *  handle,
struct rtnl_neightbl *  old,
struct rtnl_neightbl *  tmpl 
)
Parameters:
handle netlink handle
old neighbour table to be changed
tmpl template with requested changes

Builds a new netlink message by calling rtnl_neightbl_build_change_request(), sends the request to the kernel and waits for the next ACK to be received, i.e. blocks until the request has been processed.

Returns:
0 on success or a negative error code

Definition at line 578 of file neightbl.c.

References nl_send_auto_complete(), nl_wait_for_ack(), nlmsg_free(), and rtnl_neightbl_build_change_request().

00580 {
00581         int err;
00582         struct nl_msg *msg;
00583         
00584         msg = rtnl_neightbl_build_change_request(old, tmpl);
00585         err = nl_send_auto_complete(handle, msg);
00586         if (err < 0)
00587                 return err;
00588 
00589         nlmsg_free(msg);
00590         return nl_wait_for_ack(handle);
00591 }

void rtnl_neightbl_set_queue_len ( struct rtnl_neightbl *  ntbl,
int  len 
)
Parameters:
ntbl neighbour table to change
len new queue len

Definition at line 648 of file neightbl.c.

00649 {
00650         ntbl->nt_parms.ntp_queue_len = len;
00651         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_QUEUE_LEN;
00652         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00653 }

void rtnl_neightbl_set_proxy_queue_len ( struct rtnl_neightbl *  ntbl,
int  len 
)
Parameters:
ntbl neighbour table to change
len new queue len

Definition at line 660 of file neightbl.c.

00661 {
00662         ntbl->nt_parms.ntp_proxy_qlen = len;
00663         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_QLEN;
00664         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00665 }

void rtnl_neightbl_set_app_probes ( struct rtnl_neightbl *  ntbl,
int  probes 
)
Parameters:
ntbl neighbour table to change
probes new probes value

Definition at line 672 of file neightbl.c.

00673 {
00674         ntbl->nt_parms.ntp_app_probes = probes;
00675         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_APP_PROBES;
00676         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00677 }

void rtnl_neightbl_set_ucast_probes ( struct rtnl_neightbl *  ntbl,
int  probes 
)
Parameters:
ntbl neighbour table to change
probes new probes value

Definition at line 684 of file neightbl.c.

00685 {
00686         ntbl->nt_parms.ntp_ucast_probes = probes;
00687         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_UCAST_PROBES;
00688         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00689 }

void rtnl_neightbl_set_mcast_probes ( struct rtnl_neightbl *  ntbl,
int  probes 
)
Parameters:
ntbl neighbour table to change
probes new probes value

Definition at line 696 of file neightbl.c.

00697 {
00698         ntbl->nt_parms.ntp_mcast_probes = probes;
00699         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_MCAST_PROBES;
00700         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00701 }

void rtnl_neightbl_set_base_reachable_time ( struct rtnl_neightbl *  ntbl,
uint64_t  ms 
)
Parameters:
ntbl neighbour table to change
ms new base reachable time in milliseconds

Definition at line 708 of file neightbl.c.

00710 {
00711         ntbl->nt_parms.ntp_base_reachable_time = ms;
00712         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_BASE_REACHABLE_TIME;
00713         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00714 }

void rtnl_neightbl_set_retrans_time ( struct rtnl_neightbl *  ntbl,
uint64_t  ms 
)
Parameters:
ntbl neighbour table to change
ms new retransmit time

Definition at line 721 of file neightbl.c.

00722 {
00723         ntbl->nt_parms.ntp_retrans_time = ms;
00724         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_RETRANS_TIME;
00725         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00726 }

void rtnl_neightbl_set_gc_stale_time ( struct rtnl_neightbl *  ntbl,
uint64_t  ms 
)
Parameters:
ntbl neighbour table to change
ms new gc stale time in milliseconds

Definition at line 733 of file neightbl.c.

00734 {
00735         ntbl->nt_parms.ntp_gc_stale_time = ms;
00736         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_GC_STALETIME;
00737         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00738 }

void rtnl_neightbl_set_delay_probe_time ( struct rtnl_neightbl *  ntbl,
uint64_t  ms 
)
Parameters:
ntbl neighbour table to change
ms new first probe delay time in milliseconds

Definition at line 745 of file neightbl.c.

00746 {
00747         ntbl->nt_parms.ntp_probe_delay = ms;
00748         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_DELAY_PROBE_TIME;
00749         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00750 }

void rtnl_neightbl_set_anycast_delay ( struct rtnl_neightbl *  ntbl,
uint64_t  ms 
)
Parameters:
ntbl neighbour table to change
ms new anycast delay in milliseconds

Definition at line 757 of file neightbl.c.

00758 {
00759         ntbl->nt_parms.ntp_anycast_delay = ms;
00760         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_ANYCAST_DELAY;
00761         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00762 }

void rtnl_neightbl_set_proxy_delay ( struct rtnl_neightbl *  ntbl,
uint64_t  ms 
)
Parameters:
ntbl neighbour table to change
ms new proxy delay in milliseconds

Definition at line 769 of file neightbl.c.

00770 {
00771         ntbl->nt_parms.ntp_proxy_delay = ms;
00772         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_PROXY_DELAY;
00773         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00774 }

void rtnl_neightbl_set_locktime ( struct rtnl_neightbl *  ntbl,
uint64_t  ms 
)
Parameters:
ntbl neighbour table to change
ms new locktime in milliseconds

Definition at line 781 of file neightbl.c.

00782 {
00783         ntbl->nt_parms.ntp_locktime = ms;
00784         ntbl->nt_parms.ntp_mask |= NEIGHTBLPARM_ATTR_LOCKTIME;
00785         ntbl->ce_mask |= NEIGHTBL_ATTR_PARMS;
00786 }


Generated on 30 Oct 2009 for libnl by  doxygen 1.6.1