summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/Netlink
diff options
context:
space:
mode:
authorAnkur Sharma <ankursharma@vmware.com>2014-09-26 17:32:31 -0700
committerBen Pfaff <blp@nicira.com>2014-09-29 09:03:42 -0700
commitdac95740efd7c0b434714773424362c244120f93 (patch)
treec6695acbcd2e3ef0add2320dcd80b24bb3657cb3 /datapath-windows/ovsext/Netlink
parentd5f1e533c3f0cda6ef07fc8b01c0049c391212b6 (diff)
downloadopenvswitch-dac95740efd7c0b434714773424362c244120f93.tar.gz
datapath-windows/Netlink: Add NlAttrLen API
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 <ankursharma@vmware.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Acked-by: Eitan Eliahu <eliahue@vmware.com> Acked-by: Nithin Raju <nithin@vmware.com> Acked-by: Samuel Ghinet <sghinet@cloudbasesolutions.com> Tested-by: Ankur Sharma <ankursharma@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'datapath-windows/ovsext/Netlink')
-rw-r--r--datapath-windows/ovsext/Netlink/Netlink.c28
-rw-r--r--datapath-windows/ovsext/Netlink/Netlink.h13
2 files changed, 39 insertions, 2 deletions
diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c
index cd21ae4d5..b1be5fd6a 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -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;
@@ -793,6 +793,32 @@ NlAttrGetBe32(const PNL_ATTR nla)
/*
* ---------------------------------------------------------------------------
+ * 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.
* ---------------------------------------------------------------------------
*/
diff --git a/datapath-windows/ovsext/Netlink/Netlink.h b/datapath-windows/ovsext/Netlink/Netlink.h
index 9f7cc7001..13304e8b7 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.h
+++ b/datapath-windows/ovsext/Netlink/Netlink.h
@@ -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);
@@ -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);