diff options
Diffstat (limited to 'datapath-windows/ovsext/Netlink')
-rw-r--r-- | datapath-windows/ovsext/Netlink/Netlink.c | 40 | ||||
-rw-r--r-- | datapath-windows/ovsext/Netlink/Netlink.h | 6 |
2 files changed, 13 insertions, 33 deletions
diff --git a/datapath-windows/ovsext/Netlink/Netlink.c b/datapath-windows/ovsext/Netlink/Netlink.c index 7633f2ff1..0d48d081d 100644 --- a/datapath-windows/ovsext/Netlink/Netlink.c +++ b/datapath-windows/ovsext/Netlink/Netlink.c @@ -102,41 +102,23 @@ NlFillNlHdr(PNL_BUFFER nlBuf, UINT16 nlmsgType, return writeOk ? STATUS_SUCCESS : STATUS_INVALID_BUFFER_SIZE; } -static VOID -BuildMsgOut(POVS_MESSAGE msgIn, POVS_MESSAGE msgOut, UINT16 type, - UINT32 length, UINT16 flags) -{ - msgOut->nlMsg.nlmsgType = type; - msgOut->nlMsg.nlmsgFlags = flags; - msgOut->nlMsg.nlmsgSeq = msgIn->nlMsg.nlmsgSeq; - msgOut->nlMsg.nlmsgPid = msgIn->nlMsg.nlmsgPid; - msgOut->nlMsg.nlmsgLen = length; - - msgOut->genlMsg.cmd = msgIn->genlMsg.cmd; - msgOut->genlMsg.version = msgIn->genlMsg.version; - msgOut->genlMsg.reserved = 0; -} - /* - * XXX: should move out these functions to a Netlink.c or to a OvsMessage.c - * or even make them inlined functions in Datapath.h. Can be done after the - * first sprint once we have more code to refactor. + * --------------------------------------------------------------------------- + * Prepare a 'OVS_MESSAGE_ERROR' message. + * --------------------------------------------------------------------------- */ VOID -BuildReplyMsgFromMsgIn(POVS_MESSAGE msgIn, POVS_MESSAGE msgOut, UINT16 flags) +NlBuildErrorMsg(POVS_MESSAGE msgIn, POVS_MESSAGE_ERROR msgError, UINT errorCode) { - BuildMsgOut(msgIn, msgOut, msgIn->nlMsg.nlmsgType, sizeof(OVS_MESSAGE), - flags); -} + NL_BUFFER nlBuffer; -VOID -BuildErrorMsg(POVS_MESSAGE msgIn, POVS_MESSAGE_ERROR msgOut, UINT errorCode) -{ - BuildMsgOut(msgIn, (POVS_MESSAGE)msgOut, NLMSG_ERROR, - sizeof(OVS_MESSAGE_ERROR), 0); + NlBufInit(&nlBuffer, (PCHAR)msgError, sizeof *msgError); + NlFillNlHdr(&nlBuffer, NLMSG_ERROR, 0, + msgIn->nlMsg.nlmsgSeq, msgIn->nlMsg.nlmsgPid); - msgOut->errorMsg.error = errorCode; - msgOut->errorMsg.nlMsg = msgIn->nlMsg; + msgError->errorMsg.error = errorCode; + msgError->errorMsg.nlMsg = msgIn->nlMsg; + msgError->nlMsg.nlmsgLen = sizeof(OVS_MESSAGE_ERROR); } /* diff --git a/datapath-windows/ovsext/Netlink/Netlink.h b/datapath-windows/ovsext/Netlink/Netlink.h index 18e40b133..a7a53e005 100644 --- a/datapath-windows/ovsext/Netlink/Netlink.h +++ b/datapath-windows/ovsext/Netlink/Netlink.h @@ -94,10 +94,8 @@ NTSTATUS NlFillNlHdr(PNL_BUFFER nlBuf, UINT16 nlmsgType, UINT16 nlmsgFlags, UINT32 nlmsgSeq, UINT32 nlmsgPid); -VOID BuildReplyMsgFromMsgIn(POVS_MESSAGE msgIn, POVS_MESSAGE msgOut, - UINT16 flags); -VOID BuildErrorMsg(POVS_MESSAGE msgIn, POVS_MESSAGE_ERROR msgOut, - UINT errorCode); +VOID NlBuildErrorMsg(POVS_MESSAGE msgIn, POVS_MESSAGE_ERROR msgOut, + UINT errorCode); /* Netlink message accessing the payload */ PVOID NlMsgAt(const PNL_MSG_HDR nlh, UINT32 offset); |