/* * --------------------------------------------------------------------------- * 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 NlFillOvsMsg(PNL_BUFFER nlBuf, UINT16 nlmsgType, UINT16 nlmsgFlags, UINT32 nlmsgSeq, UINT32 nlmsgPid, UINT8 genlCmd, UINT8 genlVer, 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.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)); return writeOk; }
/* * -------------------------------------------------------------------------- * Appends a nested Netlink attribute of the given 'type', with the 'size' * bytes of content starting at 'data', to 'msg'. * Refer nl_msg_put_nested for more details. * -------------------------------------------------------------------------- */ VOID NlMsgPutNested(PNL_BUFFER buf, UINT16 type, const PVOID data, UINT32 size) { UINT32 offset = NlMsgStartNested(buf, type); BOOLEAN ret = FALSE; ASSERT(offset); ret = NlMsgPutTail(buf, data, size); ASSERT(ret); NlMsgEndNested(buf, offset); }
/* * --------------------------------------------------------------------------- * Prepare NL_MSG_HDR only. This API appends a NL_MSG_HDR to the tail of * input NlBuf. * --------------------------------------------------------------------------- */ BOOLEAN NlFillNlHdr(PNL_BUFFER nlBuf, UINT16 nlmsgType, UINT16 nlmsgFlags, UINT32 nlmsgSeq, UINT32 nlmsgPid) { BOOLEAN writeOk; NL_MSG_HDR msgOut; UINT32 offset = NlBufSize(nlBuf); /* To keep compiler happy for release build. */ UNREFERENCED_PARAMETER(offset); ASSERT(NlBufAt(nlBuf, offset, 0) != 0); msgOut.nlmsgType = nlmsgType; msgOut.nlmsgFlags = nlmsgFlags; msgOut.nlmsgSeq = nlmsgSeq; msgOut.nlmsgPid = nlmsgPid; msgOut.nlmsgLen = sizeof(struct _NL_MSG_HDR); writeOk = NlMsgPutTail(nlBuf, (PCHAR)(&msgOut), sizeof(struct _NL_MSG_HDR)); return writeOk; }