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

int nla_put ( struct nl_msg *  msg,
int  attrtype,
int  datalen,
const void *  data 

Add a unspecific attribute to netlink message.

  • msg Netlink message.
  • attrtype Attribute type.
  • datalen Length of data to be used as payload.
  • data Pointer to data to be used as attribute payload.
Reserves room for a unspecific attribute and copies the provided data into the message as payload of the attribute. Returns an error if there is insufficient space for the attribute.

See also:
0 on success or a negative error code.

Definition at line 837 of file attr.c.

References nla_data(), nla_reserve(), and nlmsg_data().

Referenced by nla_nest_start(), nla_put_addr(), nla_put_data(), nla_put_flag(), nla_put_nested(), nla_put_string(), nla_put_u16(), nla_put_u32(), nla_put_u64(), and nla_put_u8().

      struct nlattr *nla;

      nla = nla_reserve(msg, attrtype, datalen);
      if (!nla)
            return -NLE_NOMEM;

      memcpy(nla_data(nla), data, datalen);
      NL_DBG(2, "msg %p: Wrote %d bytes at offset +%td for attr %d\n",
             msg, datalen, (void *) nla - nlmsg_data(msg->nm_nlh), attrtype);

      return 0;

Generated by  Doxygen 1.6.0   Back to index