示例#1
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;
}
示例#2
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);
    }
}
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;
}
示例#4
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);
   }
}
示例#5
0
文件: announce.c 项目: forthyen/SDesk
/*****************************************************************************
 * sout_SLDePReg: Unregisters the program from SLP
 *****************************************************************************/
int sout_SLPDereg( sout_instance_t *p_sout, char * psz_url,
                               char * psz_name)
{
#ifdef HAVE_SLP_H

    SLPHandle   slp_handle;
    SLPError    slp_res;
    char *psz_service= sout_SLPBuildName(psz_url,psz_name);

    if( SLPOpen( NULL, SLP_FALSE, &slp_handle ) != SLP_OK)
    {
        msg_Warn(p_sout,"Unable to initialize SLP");
        return -1;
    }

    msg_Info(p_sout , "Unregistering %s from SLP",
                      psz_service);

    slp_res = SLPDereg ( slp_handle,
            psz_service,
            sout_SLPReport,
            NULL );

    if( slp_res != SLP_OK )
    {
        msg_Warn(p_sout,"Error while registering service: %i", slp_res );
        return -1;
    }

    return 0;

#else /* This function should never be called if this is false */
    return -1;
#endif
}
示例#6
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);
    }
}
示例#7
0
static ERL_NIF_TERM
ex_slp_open(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {
  char         *lang;
  char         *ret_code;
  int           isasync;
  unsigned int  term_len;
  SLPHandle    *hslp;
  SLPEXP SLPError SLPAPI error;

  if (enif_get_atom_length(env, argv[0], &term_len, ERL_NIF_LATIN1) < 0) {
    return enif_make_badarg(env);
  }

  if (enif_get_atom(env, argv[0], lang, term_len, ERL_NIF_LATIN1) < 0) {
    return enif_make_badarg(env);
  }

  if ( ! enif_get_int(env, argv[1], &isasync)) return enif_make_badarg(env);

  hslp = enif_alloc_resource(NIF_SLP_HANDLE, sizeof(SLPHandle));

  if (hslp == NULL) return enif_make_badarg(env);

  //error = SLPOpen(lang, isasync > 0 ? SLP_TRUE : SLP_FALSE, hslp);
  error = SLPOpen(lang, isasync > 0 ? SLP_TRUE : SLP_FALSE, hslp);

  ERL_NIF_TERM term = enif_make_resource(env, hslp);

  enif_release_resource(hslp);

  return enif_make_tuple2(env, enif_make_int(env, error), term);
}
示例#8
0
ScopedSLPHandle::ScopedSLPHandle(
    const bool is_async,
    const String pc_lang)
{
    m_error = SLPOpen(
        pc_lang.c_str(),
        is_async ? SLP_TRUE : SLP_FALSE,
        &m_handle);
}
示例#9
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);
   }
}
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);
}
示例#11
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);
}
示例#12
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);
   }
}
示例#13
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);
   }
}
示例#14
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);
    }               
}
示例#15
0
void slapd_slp_init( const char* urls ) {
	int i;

	slapd_srvurls = ldap_str2charray( urls, " " );

	if( slapd_srvurls == NULL ) return;

	/* find and expand INADDR_ANY URLs */
	for( i=0; slapd_srvurls[i] != NULL; i++ ) {
		if( strcmp( slapd_srvurls[i], "ldap:///" ) == 0) {
			char *host = ldap_pvt_get_fqdn( NULL );
			if ( host != NULL ) {
				slapd_srvurls[i] = (char *) ch_realloc( slapd_srvurls[i],
					strlen( host ) +
					sizeof( LDAP_SRVTYPE_PREFIX ) );
				strcpy( lutil_strcopy(slapd_srvurls[i],
					LDAP_SRVTYPE_PREFIX ), host );

				ch_free( host );
			}

		} else if ( strcmp( slapd_srvurls[i], "ldaps:///" ) == 0) {
			char *host = ldap_pvt_get_fqdn( NULL );
			if ( host != NULL ) {
				slapd_srvurls[i] = (char *) ch_realloc( slapd_srvurls[i],
					strlen( host ) +
					sizeof( LDAPS_SRVTYPE_PREFIX ) );
				strcpy( lutil_strcopy(slapd_srvurls[i],
					LDAPS_SRVTYPE_PREFIX ), host );

				ch_free( host );
			}
		}
	}

	/* open the SLP handle */
	SLPOpen( "en", 0, &slapd_hslp );
}
示例#16
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);
    }
}
示例#17
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);
}
示例#18
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;
}
示例#19
0
	void doSlpRegister(const ProviderEnvironmentIFCRef& env)
	{
		SLPError err;
		SLPHandle slpHandle;
		if ((err = SLPOpen("en", SLP_FALSE, &slpHandle)) != SLP_OK)
		{
			OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("SLPProvider::doSlpRegister - SLPOpenFailed: %1",
				err).c_str());
			return;
		}
		slpHandleCloser closer(slpHandle);

		/*
		String attributes(
			"(namespace=root),(implementation=OpenWbem),(version="OW_VERSION"),"
			"(query-language=WBEMSQL2),(host-os="OW_STRPLATFORM")");
		if (!m_allowAnonymous)
		{
			attributes += ",(authentication=";
			if (m_useDigest)
			{
				attributes += "Digest)";
			}
			else
			{
				attributes += "Basic)";
			}
		}
		*/
		StringBuffer attributes;

		// service-hi-name - Optional

		// service-hi-description - Optional

		// service-id
		attributes += "(service-id=";
		attributes += m_serviceId;
		attributes += ')';

		// CommunicationMechanism
		attributes += ",(CommunicationMechanism=cim-xml)";

		// OtherCommunicationMechanismDescription

		// InteropSchemaNamespace
		attributes += ",(InteropSchemaNamespace=";
		attributes += m_interopSchemaNamespace;
		attributes += ')';

		// ProtocolVersion
		attributes += ",(ProtocolVersion=1.1)";

		// FunctionalProfilesSupported
		attributes += ",(FunctionalProfilesSupported=";
		attributes +=
			"Basic Read"
#ifndef OW_DISABLE_SCHEMA_MANIPULATION
			",Schema Manipulation"
#endif
#ifndef OW_DISABLE_INSTANCE_MANIPULATION
			",Basic Write"
			",Instance Manipulation"
#endif
#ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL
			",Association Traversal"
#endif
#ifndef OW_DISABLE_QUALIFIER_DECLARATION
			",Qualifier Declaration"
#endif
			;
		if (m_queryEnabled)
		{
			attributes += ",Query Execution";
		}
		if (m_indicationEnabled)
		{
			attributes += ",Indications";
		}
		attributes += ")";

		// FunctionalProfileDescriptions - Only use if we put "Other" in FunctionalProfilesSupported

		// MultipleOperationsSupported
		attributes += ",(MultipleOperationsSupported=true)";

		// AuthenticationMechanismsSupported
		attributes += ",(AuthenticationMechanismsSupported=";
		if (m_allowAnonymous) // this takes precedence over the other schemes
		{
			attributes += "None)";
		}
		else if (m_useDigest)
		{
			attributes += "Digest)";
		}
		else
		{
			attributes += "Basic)";
		}

		// AuthenticationMechansimDescriptions - Only use if we put "Other" in AuthenticationMechanismsSupported

		// Namespace - Optional, and it may be more information that we want to advertise.  Evaluate whether we want this when we've got more experience with it.
		// Classinfo - Options, won't do it for the same reason as Namespace

		// RegisteredProfilesSupported - TODO
		



		String hostname = SocketAddress::getAnyLocalHost().getName();
		StringArray urls;
		try
		{
			if (m_httpPort.toInt32() > 0)
			{
				String newUrl = "http://";
				newUrl += hostname + ":" + m_httpPort;
				urls.push_back(newUrl);
			}
		}
		catch (const StringConversionException&)
		{
		}
		try
		{
			if (m_httpsPort.toInt32() > 0)
			{
				String newUrl = "https://";
				newUrl += hostname + ":" + m_httpsPort;
				urls.push_back(newUrl);
			}
		}
		catch (const StringConversionException&)
		{
		}
		for (size_t i = 0; i < urls.size(); i++)
		{
			String urlString;
			urlString = OW_CIMOM_SLP_URL_PREFIX;
			urlString += urls[i];
			// Register URL with SLP
			LoggerRef lgr = env->getLogger(COMPONENT_NAME);
			err = SLPReg(slpHandle,		// SLP Handle from open
				urlString.c_str(),		// Service URL
				POLLING_INTERVAL+60,		// Length of time registration last
				0,								// Service type (not used)
				attributes.c_str(),		// Attributes string
				SLP_TRUE,					// Fresh registration (Always true for OpenSLP)
				slpRegReport,				// Call back for registration error reporting
				&lgr);						// Give cimom handle to callback
			if (err != SLP_OK)
			{
				OW_LOG_ERROR(env->getLogger(COMPONENT_NAME), Format("cimom failed to register url with SLP: %1",
					urlString).c_str());
			}
			else
			{
				OW_LOG_DEBUG(env->getLogger(COMPONENT_NAME), Format("cimom registered service url with SLP: %1",
					urlString).c_str());
			}
		}
	}
示例#20
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;
}