MibGetFirst Sample

[This is preliminary documentation and subject to change.]

DWORD
APIENTRY
MibGetFirst(
    IN     DWORD  dwInputSize,
    IN     PVOID  pInputData,
    IN OUT PDWORD pdwOutputSize,
       OUT PVOID  pOutputData
    )
/*++
  Routine Description


  Locks


  Arguments


  Return Value
      NO_ERROR

--*/
{
    PPROTO_MIB_QUERY    pQuery;
    PPROTO_MIB_RESPONSE pResponse;
    PPROTO_MIB_INTF     pMibIf;
    PPROTO_MIB_GLOBAL   pMibGlobal;
    ULONG               ulNumIndices;
    DWORD               dwResult;
    
    
    EnterProtocolApi();

    TraceEnter("MibGet");

    if(dwInputSize < sizeof(DWORD))
    {
        //
        // Need at least the OID to do the get
        //

        TraceLeave("MibGet");

        ExitProtocolApi();
        
        return ERROR_INVALID_PARAMETER;
    }

    //
    // The input to the function is the query
    //
    
    pQuery      = (PPROTO_MIB_QUERY)pInputData;
    pResponse   = (PPROTO_MIB_RESPONSE)pOutputData;
    
    //
    // It would be really bad if someone messed the sizes up
    //
    
    ASSERT(dwInputSize%sizeof(DWORD) == 0);
    
    ulNumIndices = NUM_INDICES(dwInputSize);

    dwResult = NO_ERROR;
    
    switch(pQuery->dwOid)
    {
        case PROTO_MIB_GLOBAL_ID:
        {
            //
            // Only support GET_FIRST for tables
            //

            dwResult = ERROR_INVALID_PARAMETER;
            
            break;
        }
        case PROTO_MIB_INTF_ID:
        {
            EnterCriticalSection(&g_csIfListLock);

            dwResult = LocateInterface(QUERY_TYPE_GET_FIRST,
                                       pQuery,
                                       ulNumIndices,
                                       pResponse,
                                       pdwOutputSize);
            

            LeaveCriticalSection(&g_csIfListLock);
            
            break;
        }
    }

    TraceLeave("MibGet");

    ExitProtocolApi();
        
    return dwResult;
}