Skip to content

Commit

Permalink
[ 1945390 ] Request for SLP service URL hostname override
Browse files Browse the repository at this point in the history
    Patch from Tyrel Datwyler
  • Loading branch information
mchasal committed Sep 5, 2008
1 parent 0f2e7a2 commit 5e0dc03
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 6 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,3 +1,9 @@
2008-09-05 Michael Chase-Salerno <bratac@linux.vnet.ibm.com>

* Makefile.am, configure.ac, control.c, cimslpCMPI.c, sfcb.cfg.pre.in
Fixed [ 1945390 ] Request for SLP service URL hostname override
Patch from Tyrel Datwyler

2008-09-04 Michael Chase-Salerno <bratac@linux.vnet.ibm.com>

* cimslp.c cimslpCMPI.c:
Expand Down
12 changes: 11 additions & 1 deletion Makefile.am
Expand Up @@ -94,6 +94,12 @@ SLP_LIB =
SLP_HEADER =
endif

if SLP_HOSTNAME_LIB
SLP_HOSTNAME_LIBS = libsfcSlpHostname.la
else
SLP_HOSTNAME_LIBS =
endif

if QUALREP
QUALREP_LIBS = libsfcQualifierProvider.la
QUALREP_FILES = qualifier.c
Expand Down Expand Up @@ -140,8 +146,9 @@ lib_LTLIBRARIES = \
libcimcClientSfcbLocal.la \
$(QUALREP_LIBS) \
$(SLP_LIBS) \
$(SLP_HOSTNAME_LIBS) \
$(INDICATION_LIBS) \
$(PAM_LIBS)
$(PAM_LIBS)

if SLP_ALONE
SLP_PROGRAMFILES = cimslp
Expand Down Expand Up @@ -257,6 +264,9 @@ libsfcHttpAdapter_la_LIBADD=-lsfcBrokerCore $(CIMXMLCODEC_LIBS_LINK)
libsfcHttpAdapter_la_DEPENDENCIES=libsfcBrokerCore.la $(CIMXMLCODEC_LIBS)
endif

libsfcSlpHostname_la_SOURCES = \
sfcSlpHostname.c

libsfcBasicAuthentication_la_SOURCES = \
sfcBasicAuthentication.c

Expand Down
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -5,6 +5,7 @@ New features:

- 1978218 SFCB support for HTTP over a unix socket
- 2048878 sfcb does not implement setObjectPath
- 1945390 Request for SLP service URL hostname override

Bugs fixed:

Expand Down
48 changes: 43 additions & 5 deletions cimslpCMPI.c
Expand Up @@ -24,15 +24,19 @@
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <dlfcn.h>

#include "cimslpCMPI.h"
#include "cimslpSLP.h"
#include "cimslpUtil.h"
#include "trace.h"

#include "config.h"
#include "control.h"

char * interOpNS;

typedef int (*getSlpHostname)(char **hostname);
extern void libraryName(const char *dir, const char *location, const char *fullName);
extern char * configfile;

//helper function ... until better solution is found to get to the
//interop Namespace
Expand Down Expand Up @@ -130,8 +134,29 @@ cimSLPService getSLPData(cimomConfig cfg)
CMPIInstance **ci;
CMPIStatus status;
CMPIConstClass *ccls;

cimSLPService rs; //service which is going to be returned to the calling function
char *sn;

#ifdef SLP_HOSTNAME_LIB
static void *hostnameLib=NULL;
static getSlpHostname gethostname;
char *ln;
char dlName[512];
int err;

err = 1;
setupControl(configfile);
if (getControlChars("slpHostnamelib", &ln) == 0) {
libraryName(NULL,ln,dlName);
if ((hostnameLib = dlopen(dlName, RTLD_LAZY))) {
gethostname = dlsym(hostnameLib, "_sfcGetSlpHostname");
if (gethostname) err = 0;
}
}
sunsetControl();
if (err) mlogf(M_ERROR,M_SHOW,"--- SLP Hostname exit %s not found. Defaulting to system hostname.\n",
dlName);
#endif

_SFCB_ENTER(TRACE_SLP, "getSLPData");

Expand Down Expand Up @@ -163,8 +188,21 @@ cimSLPService getSLPData(cimomConfig cfg)
//construct the server string
ci = myGetInstances(cc, interOpNS, "CIM_ObjectManager");
if(ci) {
rs.url_syntax = getUrlSyntax(myGetProperty(ci[0], "SystemName"),
cfg.commScheme, cfg.port);
sn = myGetProperty(ci[0], "SystemName");

#ifdef SLP_HOSTNAME_LIB
if (!err) {
char *tmp;
if ((err = gethostname(&tmp))) {
free(sn);
sn = tmp;
} else {
printf("-#- SLP call to %s for hostname failed. Defaulting to system hostname.\n", dlName);
}
}
#endif
rs.url_syntax = getUrlSyntax(sn, cfg.commScheme,
cfg.port);
rs.service_hi_name = myGetProperty(ci[0], "ElementName");
rs.service_hi_description = myGetProperty(ci[0], "Description");
rs.service_id = myGetProperty(ci[0], "Name");
Expand Down
10 changes: 10 additions & 0 deletions configure.ac
Expand Up @@ -56,6 +56,10 @@ AC_ARG_ENABLE(slp,
[AC_HELP_STRING([--enable-slp],
[include slp agent for SFCB - EXPERIMENTAL.])])

AC_ARG_ENABLE(slp-hostname-lib,
[AC_HELP_STRING([--enable-slp-hostname-lib],
[aquire hostname for slp registration from external library.])])

AC_ARG_ENABLE(qualifierrep,
[AC_HELP_STRING([--disable-qualifierrep],
[disable qualifier repository support.])],
Expand Down Expand Up @@ -157,6 +161,10 @@ if test "$enable_slp" == "yes"; then
AC_DEFINE(HAVE_SLP,,[SLP support enabled.])
fi

if test "$enable_slp_hostname_lib" == "yes"; then
AC_DEFINE(SLP_HOSTNAME_LIB,,[SLP Hostname lib enabled])
fi

if test "$enable_qualifierrep" == "yes"; then
LOAD_QUALIFIER_PROVIDER=
AC_DEFINE(HAVE_QUALREP,,[Qualifier repository support enabled.])
Expand Down Expand Up @@ -344,6 +352,7 @@ AM_CONDITIONAL(INDICATIONS,[test "$enable_indications" == "yes"])
AM_CONDITIONAL(JDBC,[test "$enable_jdbc" == "yes"])
AM_CONDITIONAL(SSL,[test "$enable_ssl" == "yes"])
AM_CONDITIONAL(SLP,[test "$enable_slp" == "yes"])
AM_CONDITIONAL(SLP_HOSTNAME_LIB,[test "$enable_slp_hostname_lib" == "yes"])
AM_CONDITIONAL(SLP_ALONE,[test "$enable_slp" == "standalone"])
AM_CONDITIONAL(QUALREP,[test "$enable_qualifierrep" == "yes"])
AM_CONDITIONAL(PAM,[test "$enable_pam" == "yes"])
Expand All @@ -366,6 +375,7 @@ echo =================================================================
echo Configuration Features:
echo -e "ssl"\\t\\t\\t\\t"${enable_ssl:-no}"
echo -e "slp"\\t\\t\\t\\t"${enable_slp:-no}"
echo -e "slp hostname lib"\\t\\t"${enable_slp_hostname_lib:-no}"
echo -e "jdbc"\\t\\t\\t\\t"${enable_jdbc:-no}"
echo -e "IPv6"\\t\\t\\t\\t"${enable_ipv6:-no}"
echo -e "debug"\\t\\t\\t\\t"${enable_debug:-no}"
Expand Down
1 change: 1 addition & 0 deletions control.c
Expand Up @@ -75,6 +75,7 @@ Control init[] = {
#endif
#ifdef HAVE_SLP
{"slpRefreshInterval", 1, "600"},
{"slpHostnameLib", 0, "sfcSlpHostname"},
#endif
{"provProcs", 1, "32"},
{"basicAuthLib", 0, "sfcBasicAuthentication"},
Expand Down
45 changes: 45 additions & 0 deletions sfcSlpHostname.c
@@ -0,0 +1,45 @@

/*
* sfcSlpHostname.c
*
* (C) Copyright IBM Corp. 2008
*
* THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
* CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
*
* You can obtain a current copy of the Eclipse Public License from
* http://www.opensource.org/licenses/eclipse-1.0.php
*
* Author: Tyrel Datwyler <tyreld@us.ibm.com>
*
* Description:
*
* Obtain custom hostname string to register with SLP DA
* This is only a sample of how to write the custom routine
* used to provide the hostname. You will need to replace this
* with a routine that uses the desired method to obtain the
* proper value.
*
*/


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

extern int _sfcGetSlpHostname(char **hostname)
{
char *sn;
sn = (char *) malloc((strlen("mycimom.com") + 1) * sizeof(char));
sn = strncpy(sn, "mycimom.com", strlen("mycimom.com") + 1);
if (sn == NULL)
return 0;

printf("-#- Request for custom SLP service hostname: (hostname = %s)\n", sn);
*hostname = sn;

/* Return value of 1 for successs and 0 for failure. */
return 1;
}

1 change: 1 addition & 0 deletions sfcb.cfg.pre.in
Expand Up @@ -11,6 +11,7 @@ provProcs: 32
doBasicAuth: @SFCB_CONF_DOBASICAUTH@
doUdsAuth: true
basicAuthLib: @SFCB_CONF_BASICAUTHLIB@
slpHostnameLib: sfcSlpHostname
useChunking: true
keepaliveTimeout: 1
keepaliveMaxRequest: 10
Expand Down

0 comments on commit 5e0dc03

Please sign in to comment.