Esempio n. 1
0
BOOL
WSAAPI
WsNqBeginEnumerationProc(PVOID Context,
                         PNSCATALOG_ENTRY Entry)
{
    PNS_PROVIDER Provider;
    BOOLEAN GoOn = TRUE;
    PENUM_CONTEXT EnumContext = (PENUM_CONTEXT)Context;
    PNSQUERY NsQuery = EnumContext->NsQuery;
    DWORD NamespaceId = Entry->NamespaceId;

    /* Match the namespace ID, protocols and make sure it's enabled */
    if ((((EnumContext->lpqsRestrictions->dwNameSpace == NamespaceId) ||
          (EnumContext->lpqsRestrictions->dwNameSpace == NS_ALL)) &&
         (!(EnumContext->lpqsRestrictions->dwNumberOfProtocols) ||
           (WsNcMatchProtocols(NamespaceId,
                               Entry->AddressFamily,
                               EnumContext->lpqsRestrictions)))) &&
        (Entry->Enabled))
    {
        /* Get the provider */
        if (!(Provider = Entry->Provider))
        {
            /* None was laoded, load it */
            if ((WsNcLoadProvider(EnumContext->Catalog, Entry) != ERROR_SUCCESS))
            {
                /* return fake success */
                return TRUE;
            }

            /* Set the provider */
            Provider = Entry->Provider;
        }

        /* Add it to the query */
        if (!(WsNqAddProvider(NsQuery, Provider)))
        {
            /* We failed */
            EnumContext->ErrorCode = WSASYSCALLFAILURE;
            GoOn = FALSE;
        }
    }

    /* Return to caller */
    return GoOn;
}
Esempio n. 2
0
INT
WSAAPI
WsNcGetCatalogFromProviderId(IN PNSCATALOG Catalog,
                             IN LPGUID ProviderId,
                             OUT PNSCATALOG_ENTRY *CatalogEntry)
{
    PLIST_ENTRY NextEntry = Catalog->CatalogList.Flink;
    PNSCATALOG_ENTRY Entry;

    /* Lock the catalog */
    WsNcLock();

    /* Match the Id with all the entries in the List */
    while (NextEntry != &Catalog->CatalogList)
    {
        /* Get the Current Entry */
        Entry = CONTAINING_RECORD(NextEntry, NSCATALOG_ENTRY, CatalogLink);
        NextEntry = NextEntry->Flink;

        /* Check if this is the Catalog Entry ID we want */
        if (!(memcmp(&Entry->ProviderId, ProviderId, sizeof(GUID))))
        {
            /* Check if it doesn't already have a provider */
            if (!Entry->Provider)
            {
                /* Match, load the Provider */
                WsNcLoadProvider(Catalog, Entry);
            }

            /* Reference the entry and return it */
            InterlockedIncrement(&Entry->RefCount);
            *CatalogEntry = Entry;
            break;
        }
    }

    /* Release the catalog */
    WsNcUnlock();

    /* Return */
    return ERROR_SUCCESS;
}