datapath-windows/ovsext/Vport.c
/*
 * --------------------------------------------------------------------------
 *  Utility function to construct an OVS_MESSAGE for the specified vport. The
 *  OVS_MESSAGE contains the output of a netdev command.
 * --------------------------------------------------------------------------
 */
Utility function to construct an OVS_MESSAGE for the specified vport. The
OVS_MESSAGE contains the output of a netdev command.
Utility function to construct an OVS_MESSAGE for the specified vport . The OVS_MESSAGE contains the output of a netdev command .
static NTSTATUS
CreateNetlinkMesgForNetdev(POVS_VPORT_EXT_INFO info,
                           POVS_MESSAGE msgIn,
                           PVOID outBuffer,
                           UINT32 outBufLen,
                           int dpIfIndex)
{
    NL_BUFFER nlBuffer;
    BOOLEAN ok;
    PNL_MSG_HDR nlMsg;
    UINT32 netdevFlags = 0;
    NlBufInit(&nlBuffer, outBuffer, outBufLen);
    ok = NlFillOvsMsg(&nlBuffer, msgIn->nlMsg.nlmsgType, NLM_F_MULTI,
                      msgIn->nlMsg.nlmsgSeq, msgIn->nlMsg.nlmsgPid,
                      msgIn->genlMsg.cmd, msgIn->genlMsg.version,
                      dpIfIndex);
    if (!ok) {
        return STATUS_INVALID_BUFFER_SIZE;
    }
    ok = NlMsgPutTailU32(&nlBuffer, OVS_WIN_NETDEV_ATTR_PORT_NO,
                         info->portNo);
    if (!ok) {
        return STATUS_INVALID_BUFFER_SIZE;
    }
    ok = NlMsgPutTailU32(&nlBuffer, OVS_WIN_NETDEV_ATTR_TYPE, info->type);
    if (!ok) {
        return STATUS_INVALID_BUFFER_SIZE;
    }
    ok = NlMsgPutTailString(&nlBuffer, OVS_WIN_NETDEV_ATTR_NAME,
                            info->name);
    if (!ok) {
        return STATUS_INVALID_BUFFER_SIZE;
    }
    ok = NlMsgPutTailUnspec(&nlBuffer, OVS_WIN_NETDEV_ATTR_MAC_ADDR,
             (PCHAR)info->macAddress, sizeof (info->macAddress));
    if (!ok) {
        return STATUS_INVALID_BUFFER_SIZE;
    }
    ok = NlMsgPutTailU32(&nlBuffer, OVS_WIN_NETDEV_ATTR_MTU, info->mtu);
    if (!ok) {
        return STATUS_INVALID_BUFFER_SIZE;
    }
    if (info->status != OVS_EVENT_CONNECT) {
        netdevFlags = OVS_WIN_NETDEV_IFF_UP;
    }
    ok = NlMsgPutTailU32(&nlBuffer, OVS_WIN_NETDEV_ATTR_IF_FLAGS,
                         netdevFlags);
    if (!ok) {
        return STATUS_INVALID_BUFFER_SIZE;
    }
    nlMsg = (PNL_MSG_HDR)NlBufAt(&nlBuffer, 0, 0);
    nlMsg->nlmsgLen = NlBufSize(&nlBuffer);
    return STATUS_SUCCESS;
}
static NTSTATUS CreateNetlinkMesgForNetdev ( POVS_VPORT_EXT_INFO info , POVS_MESSAGE msgIn , PVOID outBuffer , UINT32 outBufLen , int dpIfIndex ) { NL_BUFFER nlBuffer ; BOOLEAN ok ; PNL_MSG_HDR nlMsg ; UINT32 netdevFlags = 0 ; NlBufInit ( & nlBuffer , outBuffer , outBufLen ) ; ok = NlFillOvsMsg ( & nlBuffer , msgIn -> nlMsg . nlmsgType , NLM_F_MULTI , msgIn -> nlMsg . nlmsgSeq , msgIn -> nlMsg . nlmsgPid , msgIn -> genlMsg . cmd , msgIn -> genlMsg . version , dpIfIndex ) ; if ( ! ok ) { return STATUS_INVALID_BUFFER_SIZE ; } ok = NlMsgPutTailU32 ( & nlBuffer , OVS_WIN_NETDEV_ATTR_PORT_NO , info -> portNo ) ; if ( ! ok ) { return STATUS_INVALID_BUFFER_SIZE ; } ok = NlMsgPutTailU32 ( & nlBuffer , OVS_WIN_NETDEV_ATTR_TYPE , info -> type ) ; if ( ! ok ) { return STATUS_INVALID_BUFFER_SIZE ; } ok = NlMsgPutTailString ( & nlBuffer , OVS_WIN_NETDEV_ATTR_NAME , info -> name ) ; if ( ! ok ) { return STATUS_INVALID_BUFFER_SIZE ; } ok = NlMsgPutTailUnspec ( & nlBuffer , OVS_WIN_NETDEV_ATTR_MAC_ADDR , ( PCHAR ) info -> macAddress , sizeof ( info -> macAddress ) ) ; if ( ! ok ) { return STATUS_INVALID_BUFFER_SIZE ; } ok = NlMsgPutTailU32 ( & nlBuffer , OVS_WIN_NETDEV_ATTR_MTU , info -> mtu ) ; if ( ! ok ) { return STATUS_INVALID_BUFFER_SIZE ; } if ( info -> status != OVS_EVENT_CONNECT ) { netdevFlags = OVS_WIN_NETDEV_IFF_UP ; } ok = NlMsgPutTailU32 ( & nlBuffer , OVS_WIN_NETDEV_ATTR_IF_FLAGS , netdevFlags ) ; if ( ! ok ) { return STATUS_INVALID_BUFFER_SIZE ; } nlMsg = ( PNL_MSG_HDR ) NlBufAt ( & nlBuffer , 0 , 0 ) ; nlMsg -> nlmsgLen = NlBufSize ( & nlBuffer ) ; return STATUS_SUCCESS ; }
Utility function to construct an OVS_MESSAGE for the specified vport.
Utility function to construct an OVS_MESSAGE for the specified vport .
/*
     * XXX: add netdev_stats when we have the definition available in the
     * kernel.
     */