Classes
[Traffic Control]


Modules

 Class Based Queueing (CBQ)
 Differentiated Services Marker (DSMARK)
 Hierachical Token Bucket (HTB)

Data Structures

struct  rtnl_class_ops
 Class operations. More...

Class Module API

int rtnl_class_register (struct rtnl_class_ops *ops)
 Register a class module.
int rtnl_class_unregister (struct rtnl_class_ops *ops)
 Unregister a class module.

Class Addition/Modification

nl_msg * rtnl_class_build_add_request (struct rtnl_class *class, int flags)
 Build a netlink message to add a new class.
int rtnl_class_add (struct nl_handle *handle, struct rtnl_class *class, int flags)
 Add a new class.

General

rtnl_class * rtnl_class_alloc (void)
 Allocate a new class object.
void rtnl_class_put (struct rtnl_class *class)
 Give back reference on rclass object.
void rtnl_class_free (struct rtnl_class *class)
 Free class object.
nl_cache * rtnl_class_alloc_cache (struct nl_handle *handle, int ifindex)
 Build a class cache including all classes attached to the specified interface.

Leaf Qdisc Access

int rtnl_class_has_leaf_qdisc (struct rtnl_class *class)
 Determine if the class has a leaf qdisc attached.
rtnl_qdisc * rtnl_class_leaf_qdisc (struct rtnl_class *class, struct nl_cache *cache)
 Lookup the leaf qdisc of a class.

Iterators

void rtnl_class_foreach_child (struct rtnl_class *class, struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)
 Call a callback for each child class of a class.
void rtnl_class_foreach_cls (struct rtnl_class *class, struct nl_cache *cache, void(*cb)(struct nl_object *, void *), void *arg)
 Call a callback for each classifier attached to the class.

Attribute Modifications

void rtnl_class_set_ifindex (struct rtnl_class *class, int ifindex)
 Set the interface index of a class to the specified value.
int rtnl_class_get_ifindex (struct rtnl_class *class)
 Get the interface index of a class.
void rtnl_class_set_handle (struct rtnl_class *class, uint32_t handle)
 Set the handle of a class to the specified value.
uint32_t rtnl_class_get_handle (struct rtnl_class *class)
 Get the handle of a class.
void rtnl_class_set_parent (struct rtnl_class *class, uint32_t parent)
 Set the parent handle of a class to the specified value.
uint32_t rtnl_class_get_parent (struct rtnl_class *class)
 Get the parent handle of a class.
void rtnl_class_set_kind (struct rtnl_class *class, const char *name)
 Set the kind of a class to the specified value.
char * rtnl_class_get_kind (struct rtnl_class *class)
 Get the kind of a class.
uint64_t rtnl_class_get_stat (struct rtnl_class *class, enum rtnl_tc_stats_id id)
 Get the statistic specified by the id.


Function Documentation

int rtnl_class_register ( struct rtnl_class_ops ops  ) 

Register a class module.

Parameters:
ops class module operations

Definition at line 62 of file class.c.

References rtnl_class_ops::co_kind, and rtnl_class_ops::co_next.

int rtnl_class_unregister ( struct rtnl_class_ops ops  ) 

Unregister a class module.

Parameters:
ops class module operations

Definition at line 83 of file class.c.

References rtnl_class_ops::co_kind, and rtnl_class_ops::co_next.

struct nl_msg* rtnl_class_build_add_request ( struct rtnl_class *  class,
int  flags 
)

Build a netlink message to add a new class.

Parameters:
class class to add
flags additional netlink message flags
Builds a new netlink message requesting an addition of a class. 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.

Common message flags

Returns:
New netlink message

Definition at line 275 of file class.c.

References NLM_F_CREATE.

Referenced by rtnl_class_add().

int rtnl_class_add ( struct nl_handle *  handle,
struct rtnl_class *  class,
int  flags 
)

Add a new class.

Parameters:
handle netlink handle
class class to delete
flags additional netlink message flags
Builds a netlink message by calling rtnl_qdisc_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.

Common message flags

Returns:
0 on success or a negative error code

Definition at line 295 of file class.c.

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

struct rtnl_class* rtnl_class_alloc ( void   ) 

Allocate a new class object.

Returns:
New class object

Definition at line 324 of file class.c.

References nl_object_alloc_from_ops().

Referenced by rtnl_class_foreach_child(), and rtnl_qdisc_foreach_child().

void rtnl_class_put ( struct rtnl_class *  class  ) 

Give back reference on rclass object.

Parameters:
class Class object to be given back.
Decrements the reference counter and frees the object if the last reference has been released.

Definition at line 336 of file class.c.

References nl_object_put().

Referenced by rtnl_class_foreach_child(), and rtnl_qdisc_foreach_child().

void rtnl_class_free ( struct rtnl_class *  class  ) 

Free class object.

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

Definition at line 348 of file class.c.

References nl_object_free().

struct nl_cache* rtnl_class_alloc_cache ( struct nl_handle *  handle,
int  ifindex 
)

Build a class cache including all classes attached to the specified interface.

Parameters:
handle netlink handle
ifindex interface index of the link the classes are attached to.
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 366 of file class.c.

References nl_cache_alloc_from_ops(), nl_cache_free(), and nl_cache_update().

int rtnl_class_has_leaf_qdisc ( struct rtnl_class *  class  ) 

Determine if the class has a leaf qdisc attached.

Parameters:
class class to check

Definition at line 395 of file class.c.

Referenced by rtnl_class_leaf_qdisc().

struct rtnl_qdisc* rtnl_class_leaf_qdisc ( struct rtnl_class *  class,
struct nl_cache *  cache 
)

Lookup the leaf qdisc of a class.

Parameters:
class the parent class
cache a qdisc cache including at laest all qdiscs of the interface the specified class is attached to
Returns:
The qdisc from the cache or NULL if the class has no leaf qdisc

Definition at line 407 of file class.c.

References rtnl_class_has_leaf_qdisc(), and rtnl_qdisc_get_by_parent().

void rtnl_class_foreach_child ( struct rtnl_class *  class,
struct nl_cache *  cache,
void(*)(struct nl_object *, void *)  cb,
void *  arg 
)

Call a callback for each child class of a class.

Parameters:
class the parent class
cache a class cache including all classes of the interface the specified class is attached to
cb callback function
arg argument to be passed to callback function

Definition at line 438 of file class.c.

References nl_cache_foreach_filter(), rtnl_class_alloc(), rtnl_class_put(), rtnl_class_set_ifindex(), rtnl_class_set_kind(), and rtnl_class_set_parent().

void rtnl_class_foreach_cls ( struct rtnl_class *  class,
struct nl_cache *  cache,
void(*)(struct nl_object *, void *)  cb,
void *  arg 
)

Call a callback for each classifier attached to the class.

Parameters:
class the parent class
cache a filter cache including at least all the filters attached to the specified class
cb callback function
arg argument to be passed to callback function

Definition at line 463 of file class.c.

References nl_cache_foreach_filter(), rtnl_cls_alloc(), rtnl_cls_put(), rtnl_cls_set_ifindex(), and rtnl_cls_set_parent().

void rtnl_class_set_ifindex ( struct rtnl_class *  class,
int  ifindex 
)

Set the interface index of a class to the specified value.

Parameters:
class class to be changed
ifindex new interface index

Definition at line 491 of file class.c.

Referenced by rtnl_class_foreach_child(), and rtnl_qdisc_foreach_child().

int rtnl_class_get_ifindex ( struct rtnl_class *  class  ) 

Get the interface index of a class.

Parameters:
class class handle
Returns:
Interface index or RTNL_LINK_NOT_FOUND if not set

Definition at line 501 of file class.c.

void rtnl_class_set_handle ( struct rtnl_class *  class,
uint32_t  handle 
)

Set the handle of a class to the specified value.

Parameters:
class class to be changed
handle new handle

Definition at line 512 of file class.c.

uint32_t rtnl_class_get_handle ( struct rtnl_class *  class  ) 

Get the handle of a class.

Parameters:
class class handle
Returns:
Handle or 0 if not set

Definition at line 522 of file class.c.

void rtnl_class_set_parent ( struct rtnl_class *  class,
uint32_t  parent 
)

Set the parent handle of a class to the specified value.

Parameters:
class class to be changed
parent new parent handle

Definition at line 532 of file class.c.

Referenced by rtnl_class_foreach_child(), and rtnl_qdisc_foreach_child().

uint32_t rtnl_class_get_parent ( struct rtnl_class *  class  ) 

Get the parent handle of a class.

Parameters:
class class handle
Returns:
Parent handle or 0 if not set

Definition at line 542 of file class.c.

void rtnl_class_set_kind ( struct rtnl_class *  class,
const char *  name 
)

Set the kind of a class to the specified value.

Parameters:
class class to be changed
name new kind name

Definition at line 552 of file class.c.

Referenced by rtnl_class_foreach_child(), and rtnl_qdisc_foreach_child().

char* rtnl_class_get_kind ( struct rtnl_class *  class  ) 

Get the kind of a class.

Parameters:
class class handle
Returns:
Kind or NULL if not set

Definition at line 562 of file class.c.

uint64_t rtnl_class_get_stat ( struct rtnl_class *  class,
enum rtnl_tc_stats_id  id 
)

Get the statistic specified by the id.

Parameters:
class class handle
id statistic id
Returns:
The current counter of the specified statistic

Definition at line 573 of file class.c.


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