Classifiers
[Traffic Control]

Modules

 Classifier Modules
 Classifier Object

Classifier Addition/Modification/Deletion



struct nl_msg * rtnl_cls_build_add_request (struct rtnl_cls *cls, int flags)
 Build a netlink message to add a new classifier.
int rtnl_cls_add (struct nl_handle *handle, struct rtnl_cls *cls, int flags)
 Add a new classifier.
struct nl_msg * rtnl_cls_build_change_request (struct rtnl_cls *cls, int flags)
 Build a netlink message to change classifier attributes.
int rtnl_cls_change (struct nl_handle *handle, struct rtnl_cls *cls, int flags)
 Change a classifier.
struct nl_msg * rtnl_cls_build_delete_request (struct rtnl_cls *cls, int flags)
 Build a netlink request message to delete a classifier.
int rtnl_cls_delete (struct nl_handle *handle, struct rtnl_cls *cls, int flags)
 Delete a classifier.

Cache Management



struct nl_cache * rtnl_cls_alloc_cache (struct nl_handle *handle, int ifindex, uint32_t parent)
 Build a classifier cache including all classifiers attached to the specified class/qdisc on eht specified interface.

Detailed Description

Classifier Identification
  • protocol
  • priority
  • parent
  • interface
  • kind
  • handle

Function Documentation

struct nl_msg* rtnl_cls_build_add_request ( struct rtnl_cls *  cls,
int  flags 
) [read]
Parameters:
cls classifier to add
flags additional netlink message flags

Builds a new netlink message requesting an addition of a classifier 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. classifier must contain the attributes of the new classifier set via rtnl_cls_set_* functions. opts may point to the clsasifier specific options.

Returns:
New netlink message

Definition at line 145 of file classifier.c.

References NLM_F_CREATE.

Referenced by rtnl_cls_add().

00146 {
00147         return cls_build(cls, RTM_NEWTFILTER, NLM_F_CREATE | flags);
00148 }

int rtnl_cls_add ( struct nl_handle *  handle,
struct rtnl_cls *  cls,
int  flags 
)
Parameters:
handle netlink handle
cls classifier to add
flags additional netlink message flags

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

Returns:
0 on sucess or a negative error if an error occured.

Definition at line 162 of file classifier.c.

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

00163 {
00164         int err;
00165         struct nl_msg *msg;
00166         
00167         msg = rtnl_cls_build_add_request(cls, flags);
00168         if (!msg)
00169                 return nl_errno(ENOMEM);
00170         
00171         err = nl_send_auto_complete(handle, msg);
00172         if (err < 0)
00173                 return err;
00174 
00175         nlmsg_free(msg);
00176         return nl_wait_for_ack(handle);
00177 }

struct nl_msg* rtnl_cls_build_change_request ( struct rtnl_cls *  cls,
int  flags 
) [read]
Parameters:
cls classifier to change
flags additional netlink message flags

Builds a new netlink message requesting a change of a neigh attributes. 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.

Returns:
The netlink message

Definition at line 191 of file classifier.c.

References NLM_F_REPLACE.

Referenced by rtnl_cls_change().

00192 {
00193         return cls_build(cls, RTM_NEWTFILTER, NLM_F_REPLACE | flags);
00194 }

int rtnl_cls_change ( struct nl_handle *  handle,
struct rtnl_cls *  cls,
int  flags 
)
Parameters:
handle netlink handle
cls classifier to change
flags additional netlink message flags

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

Returns:
0 on sucess or a negative error if an error occured.

Definition at line 208 of file classifier.c.

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

00210 {
00211         int err;
00212         struct nl_msg *msg;
00213         
00214         msg = rtnl_cls_build_change_request(cls, flags);
00215         if (!msg)
00216                 return nl_errno(ENOMEM);
00217         
00218         err = nl_send_auto_complete(handle, msg);
00219         if (err < 0)
00220                 return err;
00221 
00222         nlmsg_free(msg);
00223         return nl_wait_for_ack(handle);
00224 }

struct nl_msg* rtnl_cls_build_delete_request ( struct rtnl_cls *  cls,
int  flags 
) [read]
Parameters:
cls classifier to delete
flags additional netlink message flags

Builds a new netlink message requesting a deletion of a classifier. 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.

Returns:
New netlink message

Definition at line 238 of file classifier.c.

Referenced by rtnl_cls_delete().

00239 {
00240         return cls_build(cls, RTM_DELTFILTER, flags);
00241 }

int rtnl_cls_delete ( struct nl_handle *  handle,
struct rtnl_cls *  cls,
int  flags 
)
Parameters:
handle netlink handle
cls classifier to delete
flags additional netlink message flags

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

Returns:
0 on sucess or a negative error if an error occured.

Definition at line 256 of file classifier.c.

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

00257 {
00258         int err;
00259         struct nl_msg *msg;
00260         
00261         msg = rtnl_cls_build_delete_request(cls, flags);
00262         if (!msg)
00263                 return nl_errno(ENOMEM);
00264         
00265         err = nl_send_auto_complete(handle, msg);
00266         if (err < 0)
00267                 return err;
00268 
00269         nlmsg_free(msg);
00270         return nl_wait_for_ack(handle);
00271 }

struct nl_cache* rtnl_cls_alloc_cache ( struct nl_handle *  handle,
int  ifindex,
uint32_t  parent 
) [read]
Parameters:
handle netlink handle
ifindex interface index of the link the classes are attached to.
parent parent qdisc/class

Allocates a new cache, initializes it properly and updates it to include all classes attached to the specified interface.

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 295 of file classifier.c.

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

00297 {
00298         struct nl_cache * cache;
00299         
00300         cache = nl_cache_alloc(&rtnl_cls_ops);
00301         if (cache == NULL)
00302                 return NULL;
00303 
00304         cache->c_iarg1 = ifindex;
00305         cache->c_iarg2 = parent;
00306         
00307         if (handle && nl_cache_refill(handle, cache) < 0) {
00308                 nl_cache_free(cache);
00309                 return NULL;
00310         }
00311 
00312         return cache;
00313 }


Generated on 30 Oct 2009 for libnl by  doxygen 1.6.1