[ovs-dev] [PATCH v2 02/10] datapath-windows/Netlink: Add NlFillOvsMsg API for creating Netlink message headers.

2014-09-25 Thread Ankur Sharma
Added NlFillOvsMsg API in Netlink.c This API will be used to populate
netlink message headers.

Signed-off-by: Ankur Sharma ankursha...@vmware.com
Acked-by: Alin Gabriel Serdean aserd...@cloudbasesolutions.com
Acked-by: Eitan Eliahu elia...@vmware.com
---
 datapath-windows/ovsext/Netlink/Netlink.c | 38 +++
 datapath-windows/ovsext/Netlink/Netlink.h |  6 +
 2 files changed, 44 insertions(+)

diff --git a/datapath-windows/ovsext/Netlink/Netlink.c 
b/datapath-windows/ovsext/Netlink/Netlink.c
index c286c2f..a2829a5 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -34,6 +34,44 @@
 
 /*
  * ---
+ * Prepare netlink message headers. Attributes should be added by caller.
+ * ---
+ */
+NTSTATUS
+NlFillOvsMsg(POVS_MESSAGE msgOut, PNL_BUFFER nlBuf,
+ UINT16 nlmsgType, UINT16 nlmsgFlags,
+ UINT32 nlmsgSeq, UINT32 nlmsgPid,
+ UINT8 genlCmd, UINT8 genlVer, UINT32 dpNo)
+{
+BOOLEAN writeOk;
+PNL_MSG_HDR nlMsg;
+
+/* XXX: Add API for nlBuf-bufRemLen. */
+ASSERT(NlBufAt(nlBuf, 0, 0) != 0 
+   nlBuf-bufRemLen = sizeof (struct _OVS_MESSAGE));
+
+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 = NlMsgPutHead(nlBuf, (PCHAR)msgOut,
+   sizeof (struct _OVS_MESSAGE));
+
+nlMsg = (PNL_MSG_HDR)NlBufAt(nlBuf, 0, 0);
+nlMsg-nlmsgLen = NlBufSize(nlBuf);
+
+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..774faf4 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.h
+++ b/datapath-windows/ovsext/Netlink/Netlink.h
@@ -78,6 +78,12 @@ typedef struct _NL_POLICY
 #define NL_ATTR_GET_AS(NLA, TYPE) \
 (*(TYPE*) NlAttrGetUnspec(nla, sizeof(TYPE)))
 
+NTSTATUS
+NlFillOvsMsg(POVS_MESSAGE msgOut, 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
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH v2 02/10] datapath-windows/Netlink: Add NlFillOvsMsg API for creating Netlink message headers.

2014-09-25 Thread Nithin Raju
On Sep 24, 2014, at 11:57 PM, Ankur Sharma ankursha...@vmware.com
 wrote:

 Added NlFillOvsMsg API in Netlink.c This API will be used to populate
 netlink message headers.
 
 Signed-off-by: Ankur Sharma ankursha...@vmware.com
 Acked-by: Alin Gabriel Serdean aserd...@cloudbasesolutions.com
 Acked-by: Eitan Eliahu elia...@vmware.com
 ---
 datapath-windows/ovsext/Netlink/Netlink.c | 38 +++
 datapath-windows/ovsext/Netlink/Netlink.h |  6 +
 2 files changed, 44 insertions(+)
 
 diff --git a/datapath-windows/ovsext/Netlink/Netlink.c 
 b/datapath-windows/ovsext/Netlink/Netlink.c
 index c286c2f..a2829a5 100644
 --- a/datapath-windows/ovsext/Netlink/Netlink.c
 +++ b/datapath-windows/ovsext/Netlink/Netlink.c
 @@ -34,6 +34,44 @@
 
 /*
  * ---
 + * Prepare netlink message headers. Attributes should be added by caller.
 + * 
 ---
 + */
 +NTSTATUS
 +NlFillOvsMsg(POVS_MESSAGE msgOut, PNL_BUFFER nlBuf,
 + UINT16 nlmsgType, UINT16 nlmsgFlags,
 + UINT32 nlmsgSeq, UINT32 nlmsgPid,
 + UINT8 genlCmd, UINT8 genlVer, UINT32 dpNo)

We don't need msgOut and nlBuf both as parameters. One of them will suffice.
You can declare a local variable msgOut = NlBufAt(nlBuf, 0, sizeof *msgOut);

LG otherwise.

Acked-by: Nithin Raju nit...@vmware.com

-- Nithin
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev