Ejemplo n.º 1
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);
   }
}
Ejemplo n.º 2
0
/*-------------------------------------------------------------------------*/
int SlpPerfTest1_slpreg (SLPHandle hslp,
                         SLPList* service_list,
                         double* ave_slpreg,
                         int* count_slpreg)
/*-------------------------------------------------------------------------*/
{
    struct timezone tz;
    struct timeval  start;
    struct timeval  end;
    TestService_T*  srv;
    SLPError        errorcode;
        
    srv = CreateRandomTestService(*count_slpreg);
    if(srv == 0)
    {
        return ENOMEM;
    }

    
    /* mark start time */
    gettimeofday(&start,&tz);
    
    /* call SLP API */
    errorcode = SLPReg(hslp,
                       srv->serviceurl,
                       SLP_LIFETIME_MAXIMUM - 1,
                       srv->servicetype,
                       srv->attributes,
                       SLP_TRUE,
                       SlpPerfTest1_regreport,
                       srv);
    if(errorcode != SLP_OK)
    {
        printf("SLPReg(hslp,%s,SLP_LIFETIME_MAX,%s,%s,SLP_FALSE,callback,0) returned %i\n",
               srv->serviceurl,
               srv->servicetype,
               srv->attributes,
               errorcode);
        
        printf("This should not happen!\n");
        
        return -1;
    }
    /* mark end time */
    gettimeofday(&end,&tz);
    
    /* link the registered service into the list */
    SLPListLinkHead(service_list,(SLPListItem*)srv);

    /* recalculate average time */
    *ave_slpreg = (*ave_slpreg) * (*count_slpreg) + ElapsedTime(&start,&end);
    *count_slpreg = *count_slpreg + 1;
    *ave_slpreg = *ave_slpreg / *count_slpreg;

    return 0;
}
Ejemplo n.º 3
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);
    }               
}
Ejemplo n.º 4
0
void slapd_slp_reg() {
	int i;

	if( slapd_srvurls == NULL ) return;

	for( i=0; slapd_srvurls[i] != NULL; i++ ) {
		if( strncmp( slapd_srvurls[i], LDAP_SRVTYPE_PREFIX,
				sizeof( LDAP_SRVTYPE_PREFIX ) - 1 ) == 0 ||
		    strncmp( slapd_srvurls[i], LDAPS_SRVTYPE_PREFIX,
				sizeof( LDAPS_SRVTYPE_PREFIX ) - 1 ) == 0 )
		{
			SLPReg( slapd_hslp,
				slapd_srvurls[i],
				SLP_LIFETIME_MAXIMUM,
				"ldap",
				"",
				1,
				slapd_slp_regreport,
				NULL );
		}
	}
}
Ejemplo n.º 5
0
/*****************************************************************************
 * sout_SLPReg: Registers the program with SLP
 *****************************************************************************/
int sout_SLPReg( 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 , "Registering %s (name: %s) in SLP",
                      psz_service , psz_name);

    slp_res = SLPReg ( slp_handle,
            psz_service,
            SLP_LIFETIME_MAXIMUM,
            NULL,
            psz_name,
            SLP_TRUE,
            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
}
Ejemplo n.º 6
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());
			}
		}
	}