[lldp-devel] [PATCH 3/4] vdpnl decode and construct netlink messages

Thomas-Mich Richter tmricht at linux.vnet.ibm.com
Wed Mar 6 14:11:16 UTC 2013


On 03/05/2013 07:28 PM, John Fastabend wrote:
> On 02/25/2013 07:36 AM, Thomas Richter wrote:
>> This file decodes a received netlink message and fill
>> the new vdpnl_vsi data structure.
>> It also encodes a netlink message from a given vdpnl_vsi
>> data structure.
>>
>> Signed-off-by: Thomas Richter <tmricht at linux.vnet.ibm.com>
>> ---
> 
> [...]
> 
>> +
>> +/*
>> + * Construct the response as netlink message.
>> + */
>> +static void mynla_nest_end(struct nlmsghdr *nlh, struct nlattr *start)
>> +{
>> +    start->nla_type |= NLA_F_NESTED;
>> +    start->nla_len = (void *)nlh + nlh->nlmsg_len - (void *)start;
>> +}
>> +
>> +static struct nlattr *mynla_nest_start(struct nlmsghdr *nlh, int type)
>> +{
>> +    struct nlattr *ap = (struct nlattr *)((void *)nlh + nlh->nlmsg_len);
>> +
>> +    ap->nla_type = type;
>> +    nlh->nlmsg_len += NLA_HDRLEN;
>> +    return ap;
>> +}
>> +
>> +void mynla_put(struct nlmsghdr *nlh, int type, size_t len, void *data)
>> +{
>> +    struct nlattr *ap = (struct nlattr *)((void *)nlh + nlh->nlmsg_len);
>> +
>> +    ap->nla_type = type;
>> +    ap->nla_len = NLA_HDRLEN + len;
>> +    memcpy(ap + 1, data, len);
>> +    nlh->nlmsg_len += NLA_HDRLEN + NLA_ALIGN(len);
>> +}
>> +
>> +void mynla_put_u16(struct nlmsghdr *nlh, int type, uint16_t data)
>> +{
>> +    mynla_put(nlh, type, sizeof data, &data);
>> +}
>> +
>> +void mynla_put_u32(struct nlmsghdr *nlh, int type, uint32_t data)
>> +{
>> +    mynla_put(nlh, type, sizeof data, &data);
>> +}
>> +
> 
> Can these mynla routines be put in lldp_rtnl.c? Then I could consolidate
> similar code in lldp_dcbxnl.c which is using its own dcbnl helpers.
> 
> .John
> 

Done, sent as V2

-- 
Thomas Richter, Dept 3250, IBM LTC Boeblingen, Data Center Networking
--
Vorsitzende des Aufsichtsrats: Martina Koederitz 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294



More information about the lldp-devel mailing list