Universal 32-bit Classifier
[Classifier Modules]

Attribute Modifications



void rtnl_u32_set_handle (struct rtnl_cls *cls, int htid, int hash, int nodeid)
int rtnl_u32_set_classid (struct rtnl_cls *cls, uint32_t classid)

Selector Modifications



int rtnl_u32_set_flags (struct rtnl_cls *cls, int flags)
int rtnl_u32_add_key (struct rtnl_cls *cls, uint32_t val, uint32_t mask, int off, int offmask)
 Append new 32-bit key to the selector.
int rtnl_u32_add_key_uint8 (struct rtnl_cls *cls, uint8_t val, uint8_t mask, int off, int offmask)
int rtnl_u32_add_key_uint16 (struct rtnl_cls *cls, uint16_t val, uint16_t mask, int off, int offmask)
 Append new selector key to match a 16-bit number.
int rtnl_u32_add_key_uint32 (struct rtnl_cls *cls, uint32_t val, uint32_t mask, int off, int offmask)
 Append new selector key to match a 32-bit number.
int rtnl_u32_add_key_in_addr (struct rtnl_cls *cls, struct in_addr *addr, uint8_t bitmask, int off, int offmask)
int rtnl_u32_add_key_in6_addr (struct rtnl_cls *cls, struct in6_addr *addr, uint8_t bitmask, int off, int offmask)

Function Documentation

int rtnl_u32_add_key ( struct rtnl_cls *  cls,
uint32_t  val,
uint32_t  mask,
int  off,
int  offmask 
)
Parameters:
cls classifier to be modifier
val value to be matched (network byte-order)
mask mask to be applied before matching (network byte-order)
off offset, in bytes, to start matching
offmask offset mask

General selectors define the pattern, mask and offset the pattern will be matched to the packet contents. Using the general selectors you can match virtually any single bit in the IP (or upper layer) header.

Definition at line 470 of file u32.c.

References nl_data_append().

Referenced by rtnl_u32_add_key_uint16(), and rtnl_u32_add_key_uint32().

00472 {
00473         struct tc_u32_sel *sel;
00474         struct rtnl_u32 *u;
00475         int err;
00476 
00477         u = u32_alloc(cls);
00478         if (!u)
00479                 return nl_errno(ENOMEM);
00480 
00481         sel = u32_selector_alloc(u);
00482         if (!sel)
00483                 return nl_errno(ENOMEM);
00484 
00485         err = nl_data_append(u->cu_selector, NULL, sizeof(struct tc_u32_key));
00486         if (err < 0)
00487                 return err;
00488 
00489         /* the selector might have been moved by realloc */
00490         sel = u32_selector(u);
00491 
00492         sel->keys[sel->nkeys].mask = mask;
00493         sel->keys[sel->nkeys].val = val & mask;
00494         sel->keys[sel->nkeys].off = off;
00495         sel->keys[sel->nkeys].offmask = offmask;
00496         sel->nkeys++;
00497         u->cu_mask |= U32_ATTR_SELECTOR;
00498 
00499         return 0;
00500 }

int rtnl_u32_add_key_uint16 ( struct rtnl_cls *  cls,
uint16_t  val,
uint16_t  mask,
int  off,
int  offmask 
)
Parameters:
cls classifier to be modified
val value to be matched (host byte-order)
mask mask to be applied before matching (host byte-order)
off offset, in bytes, to start matching
offmask offset mask

Definition at line 521 of file u32.c.

References rtnl_u32_add_key().

00523 {
00524         int shift = ((off & 3) == 0 ? 16 : 0);
00525         if (off % 2)
00526                 return nl_error(EINVAL, "Invalid offset alignment");
00527 
00528         return rtnl_u32_add_key(cls, htonl((uint32_t)val << shift),
00529                                 htonl((uint32_t)mask << shift),
00530                                 off & ~3, offmask);
00531 }

int rtnl_u32_add_key_uint32 ( struct rtnl_cls *  cls,
uint32_t  val,
uint32_t  mask,
int  off,
int  offmask 
)
Parameters:
cls classifier to be modified
val value to be matched (host byte-order)
mask mask to be applied before matching (host byte-order)
off offset, in bytes, to start matching
offmask offset mask

Definition at line 542 of file u32.c.

References rtnl_u32_add_key().

00544 {
00545         return rtnl_u32_add_key(cls, htonl(val), htonl(mask),
00546                                 off & ~3, offmask);
00547 }


Generated on 30 Oct 2009 for libnl by  doxygen 1.6.1