Ejemplo n.º 1
0
void FindAttrs(SLPToolCommandLine * cmdline)
{
   SLPError result;
   SLPHandle hslp;

   if (SLPOpen(cmdline->lang, SLP_FALSE, &hslp) == SLP_OK)
   {
#ifndef UNICAST_NOT_SUPPORTED
      if (cmdline->unicastifc && (result = SLPAssociateIP(hslp, 
            cmdline->unicastifc)) != SLP_OK)
      {
         printf("errorcode: %i\n", result);
         SLPClose(hslp);
         return;
      }
#endif
#ifndef MI_NOT_SUPPORTED 
      if (cmdline->interfaces && (result = SLPAssociateIFList(hslp, 
            cmdline->interfaces)) != SLP_OK)
      {
         printf("errorcode: %i\n", result);
         SLPClose(hslp);
         return;
      }
#endif
      result = SLPFindAttrs(hslp, cmdline->cmdparam1, cmdline->scopes,
                     cmdline->cmdparam2, myAttrCallback, 0);
      if (result != SLP_OK)
         printf("errorcode: %i\n", result);
      SLPClose(hslp);
   }
}
Ejemplo n.º 2
0
bp::object SLP::discoverAttrs(
    const bp::object &srvurl,
    const bp::object &scopelist,
    const bp::object &attrids,
    const bp::object &async)
{
    std::string std_srvurl = StringConv::asStdString(srvurl, "srvurl");
    std::string std_scopelist = StringConv::asStdString(scopelist, "scopelist");
    std::string std_attrids = StringConv::asStdString(attrids, "attrids");
    bool std_async = Conv::as<bool>(async, "async");

    // Open SLP handle.
    ScopedSLPHandle hslp(std_async);
    if (!hslp)
        throw_SLPError("Can't open SLP handle", static_cast<int>(hslp.error()));

    // Discover the attrs.
    SLPError err;
    bp::dict attrs;
    if ((err = SLPFindAttrs(
            hslp,
            std_srvurl.c_str(),
            std_scopelist.c_str(),
            std_attrids.c_str(),
            SLP::attrCallback,
            static_cast<void*>(&attrs))) != SLP_OK)
    {
        throw_SLPError("SLP attrs discovery failed", static_cast<int>(err));
    }

    return attrs;
}
Ejemplo n.º 3
0
int
main(int argc, char **argv)
{
	SLPError	slprv;
	SLPHandle	slph;
	struct SRV_URL_CB_INFO cbinfo;
	
	slprv = SLPOpen(NULL, SLP_FALSE, &slph);
	if(slprv != SLP_OK)	{
		printf("Error opening slp handle %i\n", slprv);
		exit(1);
	}
	
	cbinfo.num_url = 0;
	
	slprv = SLPFindSrvs( slph,
		"service:wbem",
		0,                    /* use configured scopes */
		0,                    /* no attr filter        */
		MySLPSrvURLCallback,
		&cbinfo );

	if((slprv != SLP_OK) || (cbinfo.callbackerr != SLP_OK))	{
		printf("SLPFindSrvs Error: %i\n", slprv);
		exit(1);
	}
	else	{
		int i;
		printf("SLPFindSrvs discovered %d servers:\n", cbinfo.num_url);
		for(i = 0; i < cbinfo.num_url; i++)	{
			printf("\t%s\n", cbinfo.srv_urls[i]);
			slprv = SLPFindAttrs(slph,
				cbinfo.srv_urls[i],
				"", /* attributes */
				"", /* use configured scopes */
				myAttrCallback,
				NULL);
			if(slprv != SLP_OK)	{
				printf("errorcode: %i\n", slprv);
			}
		}
	}
	
	SLPClose(slph);
}
Ejemplo n.º 4
0
/*-------------------------------------------------------------------------*/
int SlpPerfTest1_slpfindattrs (SLPHandle hslp, 
                               SLPList* service_list,
                               double* ave_slpfindattrs,
                               int* count_slpfindattrs)
/*-------------------------------------------------------------------------*/
{
    int             found;
    struct timezone tz;
    struct timeval  start;
    struct timeval  end;
    TestService_T*  srv;
    SLPError        errorcode;

    srv = FindRandomTestService(service_list);

       /* mark start time */
    gettimeofday(&start,&tz);
    
    /* call SLP API */
    found = 0;
   
    errorcode = SLPFindAttrs( hslp, 
                              srv->serviceurl,
                              0,
                              0,
                              SlpPerfTest1_slpfindattrscallback, 
                              &found);
    if(errorcode != SLP_OK)
    {
        printf("SLPFindAttrs(hslp,%s,0,0,callback,%i) returned %i\n", srv->serviceurl,found,errorcode);
        printf("This should not happen!\n");
    
        return -1;
    }

    if(found <= 0)
    {
        printf("Did not find any attributes on SLPFindAttrs(). This is bad\n");
        return -1;
    }
                     
    return 0;
}
Ejemplo n.º 5
0
/*=========================================================================*/
void FindAttrs(SLPToolCommandLine* cmdline)
/*=========================================================================*/
{
    SLPError    result;
    SLPHandle   hslp;

    if(SLPOpen(cmdline->lang,SLP_FALSE,&hslp) == SLP_OK)
    {

        result = SLPFindAttrs(hslp,
                             cmdline->cmdparam1,
                             cmdline->scopes,
                             cmdline->cmdparam2,
                             myAttrCallback,
                             0);
        if(result != SLP_OK)
        {
            printf("errorcode: %i\n",result);
        }
        SLPClose(hslp);
    }               
}
Ejemplo n.º 6
0
void FindAttrs(char *srv_url)

{
    SLPError    result;
    SLPHandle   hslp;

    if(SLPOpen("en",SLP_FALSE,&hslp) == SLP_OK)
    {
        //printf("xxx\n");
        result = SLPFindAttrs(hslp,
                              srv_url,
                              0,
                              0,
                              myAttrCallback,
                              0);
        //printf("xxx2\n");
        if(result != SLP_OK)
        {
            printf("errorcode: %i\n",result);
        }
        SLPClose(hslp);
    }
}