Skip to content

Commit

Permalink
datapath-windows/Netlink: Add NlAttrLen API
Browse files Browse the repository at this point in the history
Added an API to retrieve the attribute length.
Added 2 more API for BE16 and BE8 attribute parsing.
Fixed a trailing whitespace issue.

Signed-off-by: Ankur Sharma <[email protected]>
Acked-by: Alin Gabriel Serdean <[email protected]>
Acked-by: Eitan Eliahu <[email protected]>
Acked-by: Nithin Raju <[email protected]>
Acked-by: Samuel Ghinet <[email protected]>
Tested-by: Ankur Sharma <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
ankursh authored and blp committed Sep 29, 2014
1 parent d5f1e53 commit dac9574
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
28 changes: 27 additions & 1 deletion datapath-windows/ovsext/Netlink/Netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ NlMsgAttrs(const PNL_MSG_HDR nlh)
* Returns size of to nlmsg attributes.
* ---------------------------------------------------------------------------
*/
INT
UINT32
NlMsgAttrLen(const PNL_MSG_HDR nlh)
{
return NlMsgPayloadLen(nlh) - GENL_HDRLEN - OVS_HDRLEN;
Expand Down Expand Up @@ -791,6 +791,32 @@ NlAttrGetBe32(const PNL_ATTR nla)
return NL_ATTR_GET_AS(nla, BE32);
}

/*
* ---------------------------------------------------------------------------
* Returns the 16-bit network byte order value in 'nla''s payload.
*
* Asserts that 'nla''s payload is at least 2 bytes long.
* ---------------------------------------------------------------------------
*/
BE16
NlAttrGetBe16(const PNL_ATTR nla)
{
return NL_ATTR_GET_AS(nla, BE16);
}

/*
* ---------------------------------------------------------------------------
* Returns the 8-bit network byte order value in 'nla''s payload.
*
* Asserts that 'nla''s payload is at least 1 byte long.
* ---------------------------------------------------------------------------
*/
BE8
NlAttrGetBe8(const PNL_ATTR nla)
{
return NL_ATTR_GET_AS(nla, BE8);
}

/*
* ---------------------------------------------------------------------------
* Returns the 8-bit value in 'nla''s payload.
Expand Down
13 changes: 12 additions & 1 deletion datapath-windows/ovsext/Netlink/Netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ UINT32 NlMsgSize(const PNL_MSG_HDR nlh);
PCHAR NlMsgPayload(const PNL_MSG_HDR nlh);
UINT32 NlMsgPayloadLen(const PNL_MSG_HDR nlh);
PNL_ATTR NlMsgAttrs(const PNL_MSG_HDR nlh);
INT NlMsgAttrLen(const PNL_MSG_HDR nlh);
UINT32 NlMsgAttrLen(const PNL_MSG_HDR nlh);

/* Netlink message parse */
PNL_MSG_HDR NlMsgNext(const PNL_MSG_HDR nlh);
Expand Down Expand Up @@ -121,6 +121,17 @@ BOOLEAN NlAttrParse(const PNL_MSG_HDR nlMsg, UINT32 attrOffset,
BOOLEAN NlParseNested(const PNL_ATTR, const NL_POLICY policy[],
PNL_ATTR attrs[], UINT32 n_attrs);

/*
* --------------------------------------------------------------------------
* Returns the length of attribute.
* --------------------------------------------------------------------------
*/
static __inline UINT16
NlAttrLen(const PNL_ATTR nla)
{
return nla->nlaLen;
}

/* Netlink attribute validation */
BOOLEAN NlAttrValidate(const PNL_ATTR, const PNL_POLICY);

Expand Down
1 change: 1 addition & 0 deletions datapath-windows/ovsext/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef uint8 __u8;

/* Defines the userspace specific data types for file
* included within kernel only. */
typedef UINT8 BE8;
typedef UINT16 BE16;
typedef UINT32 BE32;
typedef UINT64 BE64;
Expand Down

0 comments on commit dac9574

Please sign in to comment.