Added NlFillOvsMsg API in Netlink.c This API will be used to populate
netlink message headers.

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]>

---
 datapath-windows/ovsext/Netlink/Netlink.c | 43 +++++++++++++++++++++++++++++++
 datapath-windows/ovsext/Netlink/Netlink.h |  5 ++++
 2 files changed, 48 insertions(+)

diff --git a/datapath-windows/ovsext/Netlink/Netlink.c 
b/datapath-windows/ovsext/Netlink/Netlink.c
index c286c2f..cd21ae4 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -34,6 +34,49 @@
 
 /*
  * ---------------------------------------------------------------------------
+ * Prepare netlink message headers. Attributes should be added by caller.
+ * ---------------------------------------------------------------------------
+ */
+NTSTATUS
+NlFillOvsMsg(PNL_BUFFER nlBuf, UINT16 nlmsgType,
+             UINT16 nlmsgFlags, UINT32 nlmsgSeq,
+             UINT32 nlmsgPid, UINT8 genlCmd,
+             UINT8 genlVer, UINT32 dpNo)
+{
+    BOOLEAN writeOk;
+    PNL_MSG_HDR nlMsg;
+    OVS_MESSAGE msgOut;
+    UINT32 offset = NlBufSize(nlBuf);
+
+    ASSERT(NlBufAt(nlBuf, offset, sizeof(struct _OVS_MESSAGE)) != 0);
+
+    msgOut.nlMsg.nlmsgType = nlmsgType;
+    msgOut.nlMsg.nlmsgFlags = nlmsgFlags;
+    msgOut.nlMsg.nlmsgSeq = nlmsgSeq;
+    msgOut.nlMsg.nlmsgPid = nlmsgPid;
+
+    msgOut.genlMsg.cmd = genlCmd;
+    msgOut.genlMsg.version = genlVer;
+    msgOut.genlMsg.reserved = 0;
+
+    msgOut.ovsHdr.dp_ifindex = dpNo;
+
+    writeOk = NlMsgPutTail(nlBuf, (PCHAR)(&msgOut),
+                           sizeof (struct _OVS_MESSAGE));
+
+    if (!writeOk) {
+        goto done;
+    }
+
+    nlMsg = (PNL_MSG_HDR)NlBufAt(nlBuf, offset, sizeof(struct _NL_MSG_HDR));
+    nlMsg->nlmsgLen = sizeof(struct _OVS_MESSAGE);
+
+done:
+    return writeOk ? STATUS_SUCCESS : STATUS_INVALID_BUFFER_SIZE;
+}
+
+/*
+ * ---------------------------------------------------------------------------
  * Adds Netlink Header to the NL_BUF.
  * ---------------------------------------------------------------------------
  */
diff --git a/datapath-windows/ovsext/Netlink/Netlink.h 
b/datapath-windows/ovsext/Netlink/Netlink.h
index b036723..9f7cc70 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.h
+++ b/datapath-windows/ovsext/Netlink/Netlink.h
@@ -78,6 +78,11 @@ typedef struct _NL_POLICY
 #define NL_ATTR_GET_AS(NLA, TYPE) \
         (*(TYPE*) NlAttrGetUnspec(nla, sizeof(TYPE)))
 
+NTSTATUS NlFillOvsMsg(PNL_BUFFER nlBuf,
+                      UINT16 nlmsgType, UINT16 nlmsgFlags,
+                      UINT32 nlmsgSeq, UINT32 nlmsgPid,
+                      UINT8 genlCmd, UINT8 genlVer, UINT32 dpNo);
+
 /* Netlink message accessing the payload */
 PVOID NlMsgAt(const PNL_MSG_HDR nlh, UINT32 offset);
 UINT32 NlMsgSize(const PNL_MSG_HDR nlh);
-- 
1.9.1

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to