[ovs-dev] [PATCH v4 03/11] datapath-windows: Add new NlFillOvsMsgForNfGenMsg method in Netlink.c
Sairam Venugopal
vsairam at vmware.com
Thu Jun 30 00:08:45 UTC 2016
Create a new method to create and fill OvsMessage with NfGenMsg. This will
be used for sending Netfilter based Netlink messages.
Signed-off-by: Sairam Venugopal <vsairam at vmware.com>
Acked-by: Paul-Daniel Boca <pboca at cloudbasesolutions.com>
Acked-by: Nithin Raju <nithin at vmware.com>
---
datapath-windows/ovsext/Netlink/Netlink.c | 39 +++++++++++++++++++++++++++++++
datapath-windows/ovsext/Netlink/Netlink.h | 4 ++++
2 files changed, 43 insertions(+)
diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c
index ccf9ec1..2432205 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.c
+++ b/datapath-windows/ovsext/Netlink/Netlink.c
@@ -73,6 +73,45 @@ NlFillOvsMsg(PNL_BUFFER nlBuf, UINT16 nlmsgType,
/*
* ---------------------------------------------------------------------------
+ * Prepare netlink message headers. This API adds
+ * NL_MSG_HDR + GENL_HDR + OVS_HDR to the tail of input NLBuf.
+ * Attributes should be added by caller.
+ * ---------------------------------------------------------------------------
+ */
+BOOLEAN
+NlFillOvsMsgForNfGenMsg(PNL_BUFFER nlBuf, UINT16 nlmsgType,
+ UINT16 nlmsgFlags, UINT32 nlmsgSeq,
+ UINT32 nlmsgPid, UINT8 nfgenFamily,
+ UINT8 nfGenVersion, UINT32 dpNo)
+{
+ BOOLEAN writeOk;
+ OVS_MESSAGE msgOut;
+ UINT32 offset = NlBufSize(nlBuf);
+
+ /* To keep compiler happy for release build. */
+ UNREFERENCED_PARAMETER(offset);
+ ASSERT(NlBufAt(nlBuf, offset, 0) != 0);
+
+ msgOut.nlMsg.nlmsgType = nlmsgType;
+ msgOut.nlMsg.nlmsgFlags = nlmsgFlags;
+ msgOut.nlMsg.nlmsgSeq = nlmsgSeq;
+ msgOut.nlMsg.nlmsgPid = nlmsgPid;
+ msgOut.nlMsg.nlmsgLen = sizeof(struct _OVS_MESSAGE);
+
+ msgOut.nfGenMsg.nfgenFamily = nfgenFamily;
+ msgOut.nfGenMsg.version = nfGenVersion;
+ msgOut.nfGenMsg.resId = 0;
+
+ msgOut.ovsHdr.dp_ifindex = dpNo;
+
+ writeOk = NlMsgPutTail(nlBuf, (PCHAR)(&msgOut),
+ sizeof (struct _OVS_MESSAGE));
+
+ return writeOk;
+}
+
+/*
+ * ---------------------------------------------------------------------------
* Prepare NL_MSG_HDR only. This API appends a NL_MSG_HDR to the tail of
* input NlBuf.
* ---------------------------------------------------------------------------
diff --git a/datapath-windows/ovsext/Netlink/Netlink.h b/datapath-windows/ovsext/Netlink/Netlink.h
index 5261b9e..363f575 100644
--- a/datapath-windows/ovsext/Netlink/Netlink.h
+++ b/datapath-windows/ovsext/Netlink/Netlink.h
@@ -95,6 +95,10 @@ BOOLEAN NlFillOvsMsg(PNL_BUFFER nlBuf,
UINT16 nlmsgType, UINT16 nlmsgFlags,
UINT32 nlmsgSeq, UINT32 nlmsgPid,
UINT8 genlCmd, UINT8 genlVer, UINT32 dpNo);
+BOOLEAN NlFillOvsMsgForNfGenMsg(PNL_BUFFER nlBuf, UINT16 nlmsgType,
+ UINT16 nlmsgFlags, UINT32 nlmsgSeq,
+ UINT32 nlmsgPid, UINT8 nfgenFamily,
+ UINT8 nfGenVersion, UINT32 dpNo);
BOOLEAN NlFillNlHdr(PNL_BUFFER nlBuf,
UINT16 nlmsgType, UINT16 nlmsgFlags,
UINT32 nlmsgSeq, UINT32 nlmsgPid);
--
2.5.0.windows.1
More information about the dev
mailing list