datapath-windows/ovsext/Oid.c
/*
 * --------------------------------------------------------------------------
 * Utility function to get the array of ports on the extensible switch. Upon
 * success, the caller needs to free the returned array.
 * --------------------------------------------------------------------------
 */
Utility function to get the array of ports on the extensible switch. Upon
success, the caller needs to free the returned array.
Utility function to get the array of ports on the extensible switch . Upon success the caller needs to free the returned array .
NDIS_STATUS
OvsGetPortsOnSwitch(POVS_SWITCH_CONTEXT switchContext,
                    PNDIS_SWITCH_PORT_ARRAY *portArrayOut)
{
    PNDIS_SWITCH_PORT_ARRAY portArray;
    UINT32 arraySize = sizeof *portArray;
    NDIS_STATUS status = NDIS_STATUS_FAILURE;
    OVS_LOG_TRACE("Enter: switchContext: %p, portArray: %p",
                  switchContext, portArrayOut);
    do {
        UINT32 reqdArraySize;
        portArray = OvsAllocateMemoryWithTag(arraySize, OVS_OID_POOL_TAG);
        if (!portArray) {
            status = NDIS_STATUS_RESOURCES;
            goto done;
        }
        RtlZeroMemory(portArray, sizeof *portArray);
        portArray->Header.Revision = NDIS_SWITCH_PORT_ARRAY_REVISION_1;
        portArray->Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
        portArray->Header.Size = NDIS_SIZEOF_NDIS_SWITCH_PORT_ARRAY_REVISION_1;
        status = OvsIssueOidRequest(switchContext, NdisRequestQueryInformation,
                                    OID_SWITCH_PORT_ARRAY, NULL, 0,
                                    (PVOID)portArray, arraySize,
                                    &reqdArraySize);
        if (status == NDIS_STATUS_SUCCESS) {
            *portArrayOut = portArray;
            break;
        }
        OvsFreeMemoryWithTag(portArray, OVS_OID_POOL_TAG);
        arraySize = reqdArraySize;
        if (status != NDIS_STATUS_INVALID_LENGTH) {
            break;
        }
    } while(status == NDIS_STATUS_INVALID_LENGTH);
done:
    OVS_LOG_TRACE("Exit: status %8x.", status);
    return status;
}
NDIS_STATUS OvsGetPortsOnSwitch ( POVS_SWITCH_CONTEXT switchContext , PNDIS_SWITCH_PORT_ARRAY * portArrayOut ) { PNDIS_SWITCH_PORT_ARRAY portArray ; UINT32 arraySize = sizeof * portArray ; NDIS_STATUS status = NDIS_STATUS_FAILURE ; OVS_LOG_TRACE ( " " , switchContext , portArrayOut ) ; do { UINT32 reqdArraySize ; portArray = OvsAllocateMemoryWithTag ( arraySize , OVS_OID_POOL_TAG ) ; if ( ! portArray ) { status = NDIS_STATUS_RESOURCES ; goto done ; } RtlZeroMemory ( portArray , sizeof * portArray ) ; portArray -> Header . Revision = NDIS_SWITCH_PORT_ARRAY_REVISION_1 ; portArray -> Header . Type = NDIS_OBJECT_TYPE_DEFAULT ; portArray -> Header . Size = NDIS_SIZEOF_NDIS_SWITCH_PORT_ARRAY_REVISION_1 ; status = OvsIssueOidRequest ( switchContext , NdisRequestQueryInformation , OID_SWITCH_PORT_ARRAY , NULL , 0 , ( PVOID ) portArray , arraySize , & reqdArraySize ) ; if ( status == NDIS_STATUS_SUCCESS ) { * portArrayOut = portArray ; break ; } OvsFreeMemoryWithTag ( portArray , OVS_OID_POOL_TAG ) ; arraySize = reqdArraySize ; if ( status != NDIS_STATUS_INVALID_LENGTH ) { break ; } } while ( status == NDIS_STATUS_INVALID_LENGTH ) ; done : OVS_LOG_TRACE ( " " , status ) ; return status ; }
Utility function to get the array of ports on the extensible switch.
Utility function to get the array of ports on the extensible switch .
/*
        * Even though 'portArray' is supposed to be populated by the OID, it
        * needs to be initialized nevertheless. Otherwise, OID returns
        * NDIS_STATUS_INVALID_PARAMETER. This is not clear in the documentation.
        */