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

int nlmsg_append ( struct nl_msg *  n,
void *  data,
size_t  len,
int  pad 
)

Append raw data to a netlink message

  • n netlink message
  • data data to add
  • len length of data
  • pad add padding at the end?
Extends the netlink message as needed and appends the data of given length to the message. The length of the message is not aligned to anything. The caller is responsible to provide a length and evtentually padded data to fullfil any alignment requirements.

Returns:
0 on success or a negative error code
Attention:
Appending of improperly aligned raw data may result in a corrupt message. It is left to you to add the right amount of data to have the message aligned to NLMSG_ALIGNTO in the end.

Definition at line 441 of file msg.c.

Referenced by flnl_lookup_build_request(), nl_send_simple(), rtnl_link_build_change_request(), rtnl_neightbl_build_change_request(), and rtnl_qdisc_build_delete_request().

{
      void *tmp;

      if (pad)
            len = NLMSG_ALIGN(len);

      tmp = realloc(n->nm_nlh, n->nm_nlh->nlmsg_len + len);
      if (!tmp)
            return nl_errno(ENOMEM);

      n->nm_nlh = tmp;
      memcpy((void *) n->nm_nlh + n->nm_nlh->nlmsg_len, data, len);
      n->nm_nlh->nlmsg_len += len;

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index