Logo Search packages:      
Sourcecode: libnl2 version File versions  Download package

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

  • 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 397 of file u32.c.

References nl_data_append(), and u32_selector().

Referenced by rtnl_u32_add_key_uint16(), and rtnl_u32_add_key_uint32().

{
      struct tc_u32_sel *sel;
      struct rtnl_u32 *u = rtnl_cls_data(cls);
      int err;

      sel = u32_selector_alloc(u);
      if (!sel)
            return -NLE_NOMEM;

      err = nl_data_append(u->cu_selector, NULL, sizeof(struct tc_u32_key));
      if (err < 0)
            return err;

      /* the selector might have been moved by realloc */
      sel = u32_selector(u);

      sel->keys[sel->nkeys].mask = mask;
      sel->keys[sel->nkeys].val = val & mask;
      sel->keys[sel->nkeys].off = off;
      sel->keys[sel->nkeys].offmask = offmask;
      sel->nkeys++;
      u->cu_mask |= U32_ATTR_SELECTOR;

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index