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

void* nlmsg_reserve ( struct nl_msg *  n,
size_t  len,
int  pad 

Reserve room for additional data in a netlink message

  • n netlink message
  • len length of additional data to reserve room for
  • pad number of bytes to align data to
Reserves room for additional data at the tail of the an existing netlink message. Eventual padding required will be zeroed out.

Pointer to start of additional data tailroom or NULL.

Definition at line 515 of file msg.c.

References nlmsg_len().

Referenced by nlmsg_append(), and nlmsg_put().

      void *buf = n->nm_nlh;
      size_t nlmsg_len = n->nm_nlh->nlmsg_len;
      size_t tlen;

      tlen = pad ? ((len + (pad - 1)) & ~(pad - 1)) : len;

      if ((tlen + nlmsg_len) > n->nm_size)
            return NULL;

      buf += nlmsg_len;
      n->nm_nlh->nlmsg_len += tlen;

      if (tlen > len)
            memset(buf + len, 0, tlen - len);

      NL_DBG(2, "msg %p: Reserved %zu bytes, pad=%d, nlmsg_len=%d\n",
              n, len, pad, n->nm_nlh->nlmsg_len);

      return buf;

Generated by  Doxygen 1.6.0   Back to index