Пример #1
0
/*-------------------------------------------------------------------------*/
SLPBoolean KnownDAListFind(int scopelistlen,
                           const char* scopelist,
                           int spistrlen,
                           const char* spistr,
                           struct in_addr* daaddr)
/* Returns: non-zero on success, zero if DA can not be found               */
/*-------------------------------------------------------------------------*/
{
    SLPDatabaseHandle   dh;
    SLPDatabaseEntry*   entry;
    int result = SLP_FALSE;
   
    dh = SLPDatabaseOpen(&G_KnownDACache);
    if(dh)
    {
        /*----------------------------------------*/
        /* Check to see if there a matching entry */
        /*----------------------------------------*/
        while(1)
        {
            entry = SLPDatabaseEnum(dh);
            if(entry == NULL) break;
            
            /* Check scopes */
            if(SLPSubsetStringList(entry->msg->body.daadvert.scopelistlen,
                                   entry->msg->body.daadvert.scopelist,
                                   scopelistlen,
                                   scopelist))
            {
#ifdef ENABLE_SLPv2_SECURITY
                if(SLPCompareString(entry->msg->body.daadvert.spilistlen,
                                    entry->msg->body.daadvert.spilist,
                                    spistrlen,
                                    spistr) == 0)
#endif
                {
                    
                    memcpy(daaddr, 
                           &(entry->msg->peer.sin_addr),
                           sizeof(struct in_addr));
    
                    result = SLP_TRUE;
                }
            }
        }
        SLPDatabaseClose(dh);
    }

    return result;
}
Пример #2
0
/*-------------------------------------------------------------------------*/
SLPDAEntry* KnownDAListFindByScope(SLPList* dalist,
                                   int scopelistlen,
                                   const char* scopelist)
/* Returns: pointer to a DA that supports the specified scopelist          */
/*-------------------------------------------------------------------------*/
{
    SLPDAEntry*     entry;

    entry = (SLPDAEntry*)dalist->head;
    while(entry)
    {
        if(SLPSubsetStringList(scopelistlen,
                               scopelist,
                               entry->scopelistlen,
                               entry->scopelist))
        {
            break;
        }

        entry = (SLPDAEntry*) entry->listitem.next;
    }

    return entry;
}