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
struct nlattr* nla_reserve(struct nl_msg* msg, int attrtype, int attrlen)
{
    struct nlattr* nla;
    int tlen;

    if (attrlen < 0)
        return NULL;

    tlen = NLMSG_ALIGN(msg->nm_nlh->nlmsg_len) + nla_total_size(attrlen);

    if (tlen > msg->nm_size)
        return NULL;

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

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

    NL_DBG(2,
           "msg %p: attr <%p> %d: Reserved %d (%d) bytes at offset +%td "
           "nlmsg_len=%d\n",
           msg, nla, nla->nla_type, nla_total_size(attrlen), attrlen,
           (void*)nla - nlmsg_data(msg->nm_nlh), msg->nm_nlh->nlmsg_len);

    return nla;
}
/**
 * Reserve space for a attribute.
 * @arg msg		Netlink Message.
 * @arg attrtype	Attribute Type.
 * @arg attrlen		Length of payload.
 *
 * Reserves room for a attribute in the specified netlink message and
 * fills in the attribute header (type, length). Returns NULL if there
 * is unsuficient space for the attribute.
 *
 * Any padding between payload and the start of the next attribute is
 * zeroed out.
 *
 * @return Pointer to start of attribute or NULL on failure.
 */
Reserve space for a attribute.
@arg msg             Netlink Message.
@arg attrtype        Attribute Type.
@arg attrlen         Length of payload.

Reserves room for a attribute in the specified netlink message and
fills in the attribute header (type, length). Returns NULL if there
is unsuficient space for the attribute.

Any padding between payload and the start of the next attribute is
zeroed out.

@return Pointer to start of attribute or NULL on failure.
Reserve space for a attribute . @arg msg Netlink Message . @arg attrtype Attribute Type . @arg attrlen Length of payload . Reserves room for a attribute in the specified netlink message and fills in the attribute header ( type length ) . Returns NULL if there is unsuficient space for the attribute . Any padding between payload and the start of the next attribute is zeroed out . @return Pointer to start of attribute or NULL on failure .
struct nlattr* nla_reserve(struct nl_msg* msg, int attrtype, int attrlen)
{
    struct nlattr* nla;
    int tlen;
    if (attrlen < 0)
        return NULL;
    tlen = NLMSG_ALIGN(msg->nm_nlh->nlmsg_len) + nla_total_size(attrlen);
    if (tlen > msg->nm_size)
        return NULL;
    nla = (struct nlattr*)nlmsg_tail(msg->nm_nlh);
    nla->nla_type = attrtype;
    nla->nla_len = nla_attr_size(attrlen);
    if (attrlen)
        memset((unsigned char*)nla + nla->nla_len, 0, nla_padlen(attrlen));
    msg->nm_nlh->nlmsg_len = tlen;
    NL_DBG(2,
           "msg %p: attr <%p> %d: Reserved %d (%d) bytes at offset +%td "
           "nlmsg_len=%d\n",
           msg, nla, nla->nla_type, nla_total_size(attrlen), attrlen,
           (void*)nla - nlmsg_data(msg->nm_nlh), msg->nm_nlh->nlmsg_len);
    return nla;
}
struct nlattr * nla_reserve ( struct nl_msg * msg , int attrtype , int attrlen ) { struct nlattr * nla ; int tlen ; if ( attrlen < 0 ) return NULL ; tlen = NLMSG_ALIGN ( msg -> nm_nlh -> nlmsg_len ) + nla_total_size ( attrlen ) ; if ( tlen > msg -> nm_size ) return NULL ; nla = ( struct nlattr * ) nlmsg_tail ( msg -> nm_nlh ) ; nla -> nla_type = attrtype ; nla -> nla_len = nla_attr_size ( attrlen ) ; if ( attrlen ) memset ( ( unsigned char * ) nla + nla -> nla_len , 0 , nla_padlen ( attrlen ) ) ; msg -> nm_nlh -> nlmsg_len = tlen ; NL_DBG ( 2 , " " " \n " , msg , nla , nla -> nla_type , nla_total_size ( attrlen ) , attrlen , ( void * ) nla - nlmsg_data ( msg -> nm_nlh ) , msg -> nm_nlh -> nlmsg_len ) ; return nla ; }
Reserve space for a attribute.
Reserve space for a attribute .