openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libnl/1_3.4.0-r0/libnl-3.4.0/lib/attr.c
int nla_put(struct nl_msg* msg, int attrtype, int datalen, const void* data)
{
    struct nlattr* nla;

    nla = nla_reserve(msg, attrtype, datalen);
    if (!nla)
    {
        if (datalen < 0)
            return -NLE_INVAL;

        return -NLE_NOMEM;
    }

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

    return 0;
}
/**
 * Add a unspecific attribute to netlink message.
 * @arg msg		Netlink message.
 * @arg attrtype	Attribute type.
 * @arg datalen		Length of data to be used as payload.
 * @arg 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 nla_reserve
 * @return 0 on success or a negative error code.
 */
Add a unspecific attribute to netlink message.
@arg msg             Netlink message.
@arg attrtype        Attribute type.
@arg datalen         Length of data to be used as payload.
@arg 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 nla_reserve
@return 0 on success or a negative error code.
Add a unspecific attribute to netlink message . @arg msg Netlink message . @arg attrtype Attribute type . @arg datalen Length of data to be used as payload . @arg 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 nla_reserve @return 0 on success or a negative error code .
int nla_put(struct nl_msg* msg, int attrtype, int datalen, const void* data)
{
    struct nlattr* nla;
    nla = nla_reserve(msg, attrtype, datalen);
    if (!nla)
    {
        if (datalen < 0)
            return -NLE_INVAL;
        return -NLE_NOMEM;
    }
    if (datalen > 0)
    {
        memcpy(nla_data(nla), data, datalen);
        NL_DBG(2, "msg %p: attr <%p> %d: Wrote %d bytes at offset +%td\n", msg,
               nla, nla->nla_type, datalen,
               (void*)nla - nlmsg_data(msg->nm_nlh));
    }
    return 0;
}
int nla_put ( struct nl_msg * msg , int attrtype , int datalen , const void * data ) { struct nlattr * nla ; nla = nla_reserve ( msg , attrtype , datalen ) ; if ( ! nla ) { if ( datalen < 0 ) return - NLE_INVAL ; return - NLE_NOMEM ; } if ( datalen > 0 ) { memcpy ( nla_data ( nla ) , data , datalen ) ; NL_DBG ( 2 , " \n " , msg , nla , nla -> nla_type , datalen , ( void * ) nla - nlmsg_data ( msg -> nm_nlh ) ) ; } return 0 ; }
Add a unspecific attribute to netlink message.
Add a unspecific attribute to netlink message .