Пример #1
0
void FindSrvs(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 = SLPFindSrvs(hslp, cmdline->cmdparam1, cmdline->scopes,
                     cmdline->cmdparam2, mySrvUrlCallback, 0);
      if (result != SLP_OK)
         printf("errorcode: %i\n", result);
      SLPClose(hslp);
   }
}
Пример #2
0
void find_srv::FindSrvs_URL(char* Asrvtype)

{
    SLPError    result;
    SLPHandle   hslp;
    SLPError callbackerr;

    if(SLPOpen("en",SLP_FALSE,&hslp) == SLP_OK)
    {    //printf("\ntest\n");


        result = SLPFindSrvs(hslp,
                             Asrvtype,
                             0,
                             0,
                             mySrvUrlCallback,
                             &callbackerr);
        //printf("\ntest2\n");


        if(result != SLP_OK)
        {
            printf("errorcode: %i\n",result);
        }
        SLPClose(hslp);
    }
}
Пример #3
0
int main(int argc, char * argv[])
{
   SLPError err;
   SLPError callbackerr;
   SLPHandle hslp;

   if (argc != 2)
   {
      printf("SLPFindSrvTypes\n  Finds a SLP service.\n "
            "Usage:\n   SLPFindSrvTypes\n     <naming authority>\n");
      return 0;
   } /* End If. */

   err = SLPOpen("en", SLP_FALSE, &hslp);
   check_error_state(err, "Error opening slp handle.");

   err = SLPFindSrvTypes(hslp, argv[1], 0,
         MySLPSrvTypeCallback, &callbackerr);
   check_error_state(err, "Error getting service type with slp.");

   /* Now that we're done using slp, close the slp handle */
   SLPClose(hslp);

   return 0;
}
Пример #4
0
void* CSLPNodeLookupThread::Run( void )
{
	DBGLOG( "CSLPNodeLookupThread::Run\n" );
    
    while ( !mCanceled )
	{
		SLPInternalError status = SLPOpen( "en", SLP_FALSE, &mSLPRef );
		
		if ( status )
		{
			DBGLOG( "CSLPNodeLookupThread::CSLPNodeLookupThread, SLPOpen returned (%d) %s\n", status, slperror(status) );
		}
		else if ( mSLPRef )
		{
			SLPInternalError	error = SLPFindScopesAsync( mSLPRef, SLPScopeLookupNotifier, this );
			
			if ( error )
				DBGLOG( "CSLPNodeLookupThread::CSLPNodeLookupThread, SLPFindScopesAsync returned (%d) %s\n", error, slperror(error) );
		}

		if( mSLPRef )
			SLPClose( mSLPRef );
		
		mSLPRef = NULL;
		
		if ( mDoItAgain )
			mDoItAgain = false;
		else
			break;
	}
	
    return NULL;
}
Пример #5
0
/*=========================================================================*/
void FindSrvTypes(SLPToolCommandLine* cmdline)
/*=========================================================================*/
{
    SLPError    result;
    SLPHandle   hslp;

    if(SLPOpen(cmdline->lang,SLP_FALSE,&hslp) == SLP_OK)
    {
        if(cmdline->cmdparam1)
        {
            result = SLPFindSrvTypes(hslp,
				     cmdline->cmdparam1,
				     cmdline->scopes,
				     mySrvTypeCallback,
				     0);
	}
        else
        {
	    result = SLPFindSrvTypes(hslp,
				     "*",
				     cmdline->scopes,
				     mySrvTypeCallback,
				     0);
	}
       
        if(result != SLP_OK)
        {
            printf("errorcode: %i\n",result);
        }
       
        SLPClose(hslp);
    }
}
Пример #6
0
void slapd_slp_deinit() {
	if( slapd_srvurls == NULL ) return;

	ldap_charray_free( slapd_srvurls );
	slapd_srvurls = NULL;

	/* close the SLP handle */
	SLPClose( slapd_hslp );
}
Пример #7
0
static ERL_NIF_TERM
ex_slp_close(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {
  SLPHandle **hslp_res;
  enif_get_resource(env, argv[0], NIF_SLP_HANDLE, (void *) hslp_res);
  SLPHandle *hslp = *hslp_res;
  if (hslp == NULL) return enif_make_badarg(env);
  SLPClose(hslp);
  return enif_make_int(env, 0);
}
Пример #8
0
void Deregister(SLPToolCommandLine * cmdline)
{
   SLPError result;
   SLPHandle hslp;

   if (SLPOpen(cmdline->lang, SLP_FALSE, &hslp) == SLP_OK)
   {
      result = SLPDereg(hslp, cmdline->cmdparam1, mySLPRegReport, 0);
      if (result != SLP_OK)
         printf("errorcode: %i\n", result);
      SLPClose(hslp);
   }
}
Пример #9
0
unsigned short SLPGetRefreshInterval() {
	slp_handle_impl_t *hp;	/* SLP handle for this request */
	SLPError err;		/* any SLPError */
	char *reply = NULL;	/* reply from slpd */
	void *collator = NULL;	/* attr collation handle */
	int mr = 0;		/* max results placeholder */
	unsigned short max = 0;	/* max interval result cookie */
	char *msg = NULL;	/* attrrqst msg */
	char hostname[MAXHOSTNAMELEN];	/* name of this host */

	if ((err = SLPOpen("en", SLP_FALSE, (void **)&hp)) != SLP_OK) {
	    slp_err(LOG_INFO, 0, "SLPGetRefreshInterval",
		    "Could not get SLPHandle: %s", slp_strerror(err));
	    return (0);
	}

	/* tag this as an internal call */
	hp->internal_call = SLP_TRUE;

	/* scope is name of this host */
	(void) gethostname(hostname, MAXHOSTNAMELEN);

	if (slp_packAttrRqst_single(SLP_SUN_DA_TYPE,
				    hostname,
				    "min-refresh-interval",
				    &msg, "en") != SLP_OK) {
	    goto done;
	}

	if (slp_send2slpd(msg, &reply) != SLP_OK) {
	    goto done;
	}

	(void) slp_UnpackAttrReply(hp, reply, refresh_interval_cb,
				    &max, &collator, &mr);

	/* clean up by invoking last call */
	(void) slp_UnpackAttrReply(hp, NULL, refresh_interval_cb,
				    &max, &collator, &mr);

done:
	if (msg) free(msg);
	if (reply) free(reply);

	SLPClose(hp);

	return (max);
}
Пример #10
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);
}
Пример #11
0
void FindScopes(SLPToolCommandLine * cmdline)
{
   SLPError result;
   SLPHandle hslp;
   char * scopes;

   if (SLPOpen(cmdline->lang, SLP_FALSE, &hslp) == SLP_OK)
   {
      result = SLPFindScopes(hslp, &scopes);
      if (result == SLP_OK)
      {
         printf("%s\n", scopes);
         SLPFree(scopes);
      }

      SLPClose(hslp);
   }
}
Пример #12
0
void Register(SLPToolCommandLine * cmdline)
{
   SLPError result;
   SLPHandle hslp;
   char srvtype[80] = "", * s;
   size_t len = 0;
   unsigned int lt = 0;

   if (cmdline->time) {
       lt = atoi(cmdline->time);
   }

   if (strncasecmp(cmdline->cmdparam1, "service:", 8) == 0)
      len = 8;

   s = strchr(cmdline->cmdparam1 + len, ':');
   if (!s)
   {
      printf("Invalid URL: %s\n", cmdline->cmdparam1);
      return;
   }
   len = s - cmdline->cmdparam1;
   strncpy(srvtype, cmdline->cmdparam1, len);
   srvtype[len] = 0;

   /* Clear property (if set), otherwise the register function is quite useless */
   SLPSetProperty("net.slp.watchRegistrationPID", 0);

   if ((cmdline->scopes != 0) && (*cmdline->scopes != 0))
      SLPSetProperty("net.slp.useScopes", cmdline->scopes);

   if (SLPOpen(cmdline->lang, SLP_FALSE, &hslp) == SLP_OK)
   {
      if (!lt || lt > SLP_LIFETIME_MAXIMUM)
           result = SLPReg(hslp, cmdline->cmdparam1, SLP_LIFETIME_MAXIMUM, srvtype,
                           cmdline->cmdparam2, SLP_TRUE, mySLPRegReport, 0);
      else
           result = SLPReg(hslp, cmdline->cmdparam1, (unsigned short)lt, srvtype,
                           cmdline->cmdparam2, SLP_TRUE, mySLPRegReport, 0);
      if (result != SLP_OK)
         printf("errorcode: %i\n", result);
      SLPClose(hslp);
   }
}
Пример #13
0
/*=========================================================================*/
void Register(SLPToolCommandLine* cmdline)
/*=========================================================================*/
{
    SLPError    result;
    SLPHandle   hslp;
    char srvtype[80] = "", *s;
    int len = 0;

    if (strncasecmp(cmdline->cmdparam1, "service:", 8) == 0)
	len = 8;

    s = strchr(cmdline->cmdparam1 + len, ':');
    if (!s)
    {
	printf("Invalid URL: %s\n", cmdline->cmdparam1);
	return;
    }
    len = s - cmdline->cmdparam1;
    strncpy(srvtype, cmdline->cmdparam1, len);
    srvtype[len] = 0;

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

        result = SLPReg(hslp,
			cmdline->cmdparam1,
			SLP_LIFETIME_MAXIMUM,
			srvtype,
			cmdline->cmdparam2,
			SLP_TRUE,
			mySLPRegReport,
			0);
        if(result != SLP_OK)
        {
            printf("errorcode: %i\n",result);
        }
        SLPClose(hslp);
    }               
}
Пример #14
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);
    }
}
Пример #15
0
int
main (int argc, char *argv[])
{
	SLPError err;
	SLPError callbackerr;
	SLPHandle hslp;

	err = SLPOpen ("en", SLP_FALSE, &hslp);
	check_error_state(err,"Error opening slp handle.");

	err = SLPFindSrvs (
			hslp, 
			argv[1],
			0,		/* use configured scopes */
			0,		/* no attr filter        */
			MySLPSrvURLCallback,
			&callbackerr);
	check_error_state(err, "Error registering service with slp.");

	/* Now that we're done using slp, close the slp handle */
	SLPClose (hslp);

	return(0);
}
Пример #16
0
ScopedSLPHandle::~ScopedSLPHandle()
{
    if (!good())
        return;
    SLPClose(m_handle);
}
Пример #17
0
/*=========================================================================*/
int main(int argc, char* argv[]) 

/*=========================================================================*/
{
    SLPError    result = SLP_OK;
    SLPHandle   hslp;
    SLPResultCookie resultCookie;
    
    if (SLPOpen("en", SLP_FALSE, &hslp) == SLP_OK) {
        //Do a basic check to see if findslpsrvs is working at all
        setupResultCookie(&resultCookie, 
                          NUM_BASIC_FIND_STRS, 
                          basic_find_string,
                          SLP_OK); 
        result = doTest(hslp, 
                        "*",
                        "", 
                        "basic find pass one (default)", // <-- Test id string 
                        &resultCookie);

        //Do a basic check to see if findslpsrvs is working at all
        setupResultCookie(&resultCookie, 
                          NUM_SCOPE_STRS, 
                          scope_string,
                          SLP_OK); 
        result = doTest(hslp, 
                        "*",
                        "", 
                        "basic find pass two (testscope)", // <-- Test id string 
                        &resultCookie);

        //Do a basic check to see if findslpsrvs is working at all
        setupResultCookie(&resultCookie, 
                          NUM_NA_STRS, 
                          na_string,
                          SLP_OK); 
        result = doTest(hslp, 
                        "*",
                        "", 
                        "basic find pass three (naming authorities)", // <-- Test id string 
                        &resultCookie);

        //Do a basic check to see if findslpsrvs is working at all
        setupResultCookie(&resultCookie, 
                          NUM_SP_STRS, 
                          sp_string,
                          SLP_OK); 
        result = doTest(hslp, 
                        "*",
                        "", 
                        "basic find pass four (spanish scope)", // <-- Test id string 
                        &resultCookie);


        //Now see if you can find services in a particular scope
        // memset(&resultCookie, 0, sizeof(resultCookie));
        setupResultCookie(&resultCookie, NUM_SCOPE_STRS, scope_string, SLP_OK);
        result = doTest(hslp, 
                        "*", 
                        "testscope", 
                        "find in scope", // <-- Test id string 
                        &resultCookie);

        //Now see if you can find services by a particular Naming Authority
        setupResultCookie(&resultCookie, NUM_NA_STRS, na_string, SLP_OK);
        result = doTest(hslp, 
                        "TESTNA", 
                        "testscope", 
                        "find by NA (testscope scope)", // <-- Test id string 
                        &resultCookie);

        //Now find a service with odd characters in the name
        setupResultCookie(&resultCookie, NUM_SP_STRS, sp_string, SLP_OK);
        result = doTest(hslp, 
                        "*", 
                        "spanish", 
                        "find service with spanish chars in spanish scope", // <-- Test id string 
                        &resultCookie);

        //Now see if you can find services by a particular Naming Authority
        setupResultCookie(&resultCookie, NUM_NA_STRS, na_string, SLP_OK);
        result = doTest(hslp, 
                        "TESTNA", 
                        "spanish", 
                        "find by NA(spanish scope)", // <-- Test id string 
                        &resultCookie);

        //Now see if you can find services by a particular Naming Authority
        setupResultCookie(&resultCookie, NUM_NA_STRS, na_string, SLP_OK);
        result = doTest(hslp, 
                        "TESTNA", 
                        "", 
                        "find by NA(configured scopes)", // <-- Test id string
                        &resultCookie);



        SLPClose(hslp);
    }
    else {
        printf("CRITICAL ERROR: SLPOpen failed!\n");
    }

    return result;
}
Пример #18
0
/*=========================================================================*/
int SlpPerfTest1(int min_services,
                 int max_services,
                 int iterations,
                 int delay)
/* Performance test number 1.  Randomly registers up to "max_services"     *
 * services with no less than "min_services"                               *
 * Test will be performed for "iterations" iterations. Calls to SLP APIs   *
 * are delayed by "delay" seconds.                                         *
 *=========================================================================*/
{
    int             i;
    SLPError        result;
    double          ave_slpreg              = 0;
    int             count_slpreg            = 0;
    double          ave_slpfindsrvs         = 0;
    int             count_slpfindsrvs       = 0;
    double          ave_slpfindattrs        = 0;
    int             count_slpfindattrs      = 0;
    double          ave_slpfindsrvtypes     = 0;
    int             count_slpfindsrvtypes   = 0;
    double          ave_slpdereg            = 0;
    int             count_slpdereg          = 0;
    SLPHandle       hslp = 0;
    SLPList         service_list        = {0,0,0};

    /*-----------------*/
    /* Open SLP handle */
    /*-----------------*/
    result = SLPOpen("en",SLP_FALSE,&hslp);
    if(result)
    {
        printf("SLPOpen() failed %i \n",result);
        goto RESULTS;
    }

    /*--------------------------------------------------------*/
    /* make sure the minimum number of services is registered */
    /*--------------------------------------------------------*/
    printf("slpperf: Test #1 \n");
    printf("----------------------------------------------------------\n\n");
    printf("Setting up for test. Registering %i minimum services)... \n",
           min_services);
    for (i=0;i<min_services;i++)
    {
        result = SlpPerfTest1_slpreg(hslp,
                                     &service_list,
                                     &ave_slpreg,
                                     &count_slpreg);
        if (result) goto RESULTS;
        sleep(delay);   
    }
    
    /*-------------------------------*/
    /* now start the test iterations */
    /*-------------------------------*/
    printf("Performing %i test iterations...\n",iterations);
    for (i=0;i<iterations;i++)
    {
        switch(rand() % 10)
        {
        /* 10% chance */
        case 0:
            if(service_list.count < max_services)
            {
                result = SlpPerfTest1_slpreg(hslp,
                                             &service_list,
                                             &ave_slpreg,
                                             &count_slpreg);
            }
            else
            {
                /* call SlpPerfTest1_slpdereg() */
                result = SlpPerfTest1_slpdereg(hslp,
                                               &service_list,
                                               &ave_slpdereg,
                                               &count_slpdereg);
            }
            break;
        
        /* 10% chance */
        case 1:
            if(service_list.count > min_services)
            {
                 result = SlpPerfTest1_slpdereg(hslp,
                                               &service_list,
                                               &ave_slpdereg,
                                               &count_slpdereg);
            }
            else
            {
                result = SlpPerfTest1_slpreg(hslp,
                                             &service_list,
                                             &ave_slpreg,
                                             &count_slpreg);            }
            break;
            
        /* 50% chance */
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:            
            /* call SlpPerfTest1_slpfindsrv() */
            result = SlpPerfTest1_slpfindsrvs(hslp,
                                              &service_list,
                                              &ave_slpfindsrvs,
                                              &count_slpfindsrvs);
            break;

        /* 20% chance*/
        case 7:
        case 8:
            /* call SlpPerfTest1_slpfindattr() */
             result = SlpPerfTest1_slpfindattrs(hslp,
                                                &service_list,
                                                &ave_slpfindattrs,
                                                &count_slpfindattrs);
            break;

        /* 10% chance */
        case 9:
            result = SlpPerfTest1_slpfindsrvtypes(hslp,
                                                  &service_list,
                                                  &ave_slpfindsrvtypes,
                                                  &count_slpfindsrvtypes);
            break;
        }
        
        if(result)
        {
            break;
        }

        sleep(delay);
    }

    printf("----------------------------------------------------------\n");
    printf("Cleaning up registered services... \n");
    result = SlpPerfTest1_slpderegall(hslp,
                                      &service_list,
                                      &ave_slpdereg,
                                      &count_slpdereg);


    /*----------------------*/
    /* close the SLP handle */
    /*----------------------*/
    SLPClose(hslp);

RESULTS:
    /*---------------------*/
    /* Display the results */
    /*---------------------*/

    return result;
}