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

struct nlattr* nla_reserve ( struct nl_msg *  n,
int  attrtype,
int  attrlen 
) [read]

reserve room for attribute on the skb

  • n netlink message
  • attrtype attribute type
  • attrlen length of attribute payload
Adds a netlink attribute header to a netlink message and reserves room for the payload but does not copy it.

Definition at line 468 of file attr.c.

References nla_attr_size(), nlattr::nla_len, nla_padlen(), nla_total_size(), and nlattr::nla_type.

Referenced by nla_put().

{
      struct nlattr *nla;
      int tlen;
      
      tlen = NLMSG_ALIGN(n->nm_nlh->nlmsg_len) + nla_total_size(attrlen);

      n->nm_nlh = realloc(n->nm_nlh, tlen);
      if (!n->nm_nlh) {
            nl_errno(ENOMEM);
            return NULL;
      }

      nla = (struct nlattr *) nlmsg_tail(n->nm_nlh);
      nla->nla_type = attrtype;
      nla->nla_len = nla_attr_size(attrlen);

      memset((unsigned char *) nla + nla->nla_len, 0, nla_padlen(attrlen));
      n->nm_nlh->nlmsg_len = tlen;

      return nla;
}


Generated by  Doxygen 1.6.0   Back to index