Update of /cvsroot/sblim/sfcb In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31908 Added Files: cimslp.c cimslpCMPI.c cimslpCMPI.h cimslpConfig.h cimslpSLP.c cimslpSLP.h cimslpUtil.c cimslpUtil.h Log Message: Initial Version of slp extension for slp commited --- NEW FILE: cimslpSLP.c --- /* * cimslpSLP.c * * (C) Copyright IBM Corp. 2006 * * 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: Sven Schuetz <sv...@de...> * Contributions: * * Description: * * Functions for slp regs/deregs * */ #include <slp.h> #include <stdio.h> #include <string.h> #include "cimslpCMPI.h" #include "cimslpSLP.h" #include "cimslpUtil.h" #define SIZE 1024 int size; char * gAttrstring = "NULL"; void freeCSS(cimSLPService css) { freeStr(css.url_syntax); freeStr(css.service_hi_name); freeStr(css.service_hi_description); freeStr(css.service_id); freeStr(css.CommunicationMechanism); freeStr(css.OtherCommunicationMechanismDescription); freeArr(css.InteropSchemaNamespace); freeStr(css.ProtocolVersion); freeArr(css.FunctionalProfilesSupported); freeArr(css.FunctionalProfileDescriptions); freeStr(css.MultipleOperationsSupported); freeArr(css.AuthenticationMechanismsSupported); freeArr(css.AuthenticationMechansimDescriptions); freeArr(css.Namespace); freeArr(css.Classinfo); freeArr(css.RegisteredProfilesSupported); } void MySLPRegReport(SLPHandle hslp, SLPError errcode, void* cookie) { /* return the error code in the cookie */ *(SLPError*)cookie = errcode; printf("Callback Code %i\n",errcode); /* You could do something else here like print out */ /* the errcode, etc. Remember, as a general rule, */ /* do not try to do too much in a callback because */ /* it is being executed by the same thread that is */ /* reading slp packets from the wire. */ } char* buildAttrString(char * name, char * value, char * attrstring) { int length; if(value == NULL) { return attrstring; } length = strlen(attrstring) + strlen(value) + strlen(name) + 5; if(length > size) { //make sure that string is big enough to hold the result //multiply with 3 so that we do not have to enlarge the next run already size = size + (length * 3); attrstring = (char *) realloc(attrstring, size * sizeof(char)); } if(strlen(attrstring) != 0) { strcat(attrstring, ","); } strcat(attrstring, "("); strcat(attrstring, name); strcat(attrstring, "="); strcat(attrstring, value); strcat(attrstring, ")"); return attrstring; } char* buildAttrStringFromArray(char * name, char ** value, char * attrstring) { int length=0; int i; if(value == NULL) { return attrstring; } for(i = 0; value[i] != NULL; i++) { length += strlen(value[i]); } length = length + strlen(attrstring) + strlen(name) + 5; if(length > size) { //make sure that string is big enough to hold the result //multiply with 3 so that we do not have to enlarge the next run already size = size + (length * 3); attrstring = (char *) realloc(attrstring, size * sizeof(char)); } if(strlen(attrstring) != 0) { strcat(attrstring, ","); } strcat(attrstring, "("); strcat(attrstring, name); strcat(attrstring, "="); for(i = 0; value[i] != NULL; i++) { strcat(attrstring, value[i]); strcat(attrstring, ","); } attrstring[strlen(attrstring) - 1] = '\0'; strcat(attrstring, ")"); return attrstring; } int registerCIMService(cimSLPService css) { SLPError err; SLPError callbackerr; SLPHandle hslp; char *attrstring; size = SIZE; attrstring = malloc(sizeof(char) * SIZE); attrstring[0] = 0; attrstring = buildAttrString("service-hi-name", css.service_hi_name, attrstring); attrstring = buildAttrString("service-hi-description", css.service_hi_description, attrstring); attrstring = buildAttrString("service-id", css.service_id, attrstring); attrstring = buildAttrString("CommunicationMechanism", css.CommunicationMechanism, attrstring); attrstring = buildAttrString("OtherCommunicationMechanismDescription", css.OtherCommunicationMechanismDescription, attrstring); attrstring = buildAttrStringFromArray("InteropSchemaNamespace", css.InteropSchemaNamespace, attrstring); attrstring = buildAttrString("ProtocolVersion", css.ProtocolVersion, attrstring); attrstring = buildAttrStringFromArray("FunctionalProfilesSupported", css.FunctionalProfilesSupported, attrstring); attrstring = buildAttrStringFromArray("FunctionalProfileDescriptions", css.FunctionalProfileDescriptions, attrstring); attrstring = buildAttrString("MultipleOperationsSupported", css.MultipleOperationsSupported, attrstring); attrstring = buildAttrStringFromArray("AuthenticationMechanismsSupported", css.AuthenticationMechanismsSupported, attrstring); attrstring = buildAttrStringFromArray("AuthenticationMechansimDescriptions", css.AuthenticationMechansimDescriptions, attrstring); attrstring = buildAttrStringFromArray("Namespace", css.Namespace, attrstring); attrstring = buildAttrStringFromArray("Classinfo", css.Classinfo, attrstring); attrstring = buildAttrStringFromArray("RegisteredProfilesSupported", css.RegisteredProfilesSupported, attrstring); err = SLPOpen("", SLP_FALSE, &hslp); if(err != SLP_OK) { printf("Error opening slp handle %i\n",err); return err; } if(strcmp(gAttrstring, attrstring)) { /*attrstring changed - dereg the service, and rereg with the new attributes actually, this is also true for the first run, as it changed from NULL to some value. Normally, this should be run only once if nothing changes. Then now further re/dreg is necessary. That's why I check if gAttrstring is "NULL" before deregging, as it would dereg a not existing service otherwise and probably return an error code */ if(strcmp(gAttrstring, "NULL")) { err = SLPDereg( hslp, css.url_syntax, MySLPRegReport, &callbackerr); free(gAttrstring); printf("deregistered!\n"); } err = SLPReg( hslp, css.url_syntax, SLP_LIFETIME_MAXIMUM, NULL, attrstring, SLP_TRUE, MySLPRegReport, &callbackerr ); printf("registered!\n"); printf("url_syntax: %s\n", css.url_syntax); printf("attrsting: %s\n", attrstring); if(( err != SLP_OK) || (callbackerr != SLP_OK)) { printf("Error registering service with slp %i\n",err); //return err; } if( callbackerr != SLP_OK) { printf("Error registering service with slp %i\n",callbackerr); //return callbackerr; } } //only save the last state when something changed to not waste mallocs if (strcmp(attrstring, gAttrstring)) { gAttrstring = strdup(attrstring); } free(attrstring); freeCSS(css); SLPClose(hslp); } --- NEW FILE: cimslpCMPI.c --- /* * cimslpCMPI.c * * (C) Copyright IBM Corp. 2006 * * 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: Sven Schuetz <sv...@de...> * Contributions: * * Description: * * Functions getting slp relevant information from the CIMOM utilizing sfcc * */ #include <cmci.h> #include <native.h> #include <unistd.h> #include "cimslpCMPI.h" #include "cimslpUtil.h" char * interOpNS; void initializeService(cimSLPService *rs) { rs->AuthenticationMechanismsSupported = NULL; rs->AuthenticationMechansimDescriptions = NULL; rs->Classinfo = NULL; rs->CommunicationMechanism = NULL; rs->FunctionalProfileDescriptions = NULL; rs->FunctionalProfilesSupported = NULL; rs->InteropSchemaNamespace = NULL; rs->MultipleOperationsSupported = NULL; rs->Namespace = NULL; rs->OtherCommunicationMechanismDescription = NULL; rs->ProtocolVersion = NULL; rs->RegisteredProfilesSupported = NULL; rs->service_hi_description = NULL; rs->service_hi_name = NULL; rs->service_id = NULL; rs->url_syntax = NULL; } //helper function ... until better solution is found to get to the //interop Namespace char ** getInterOpNS() { char ** retArr; interOpNS = "root/interop"; retArr = malloc(2 * sizeof(char *)); retArr[0] = (char *)malloc(13 * sizeof(char)); //length of "root/interop" strcpy(retArr[0], interOpNS); retArr[1] = NULL; return retArr; } CMPIInstance ** getInstances(CMCIClient *cc, char * path, char * objectname) { CMPIStatus status; CMPIObjectPath * objectpath; CMPIEnumeration * enumeration; CMPIData objectData; CMPIInstance ** retArr = NULL; objectpath = newCMPIObjectPath(path, objectname, &status); enumeration = cc->ft->enumInstances(cc, objectpath, 0, NULL, &status); if (objectpath) CMRelease(objectpath); //severe error, cimom not running etc. if(status.rc == CMPI_RC_ERR_FAILED) { printf("Fatal error. CIMOM not running? Connection params ok?\n"); exit(0); } //object not found ? if(status.rc == CMPI_RC_ERR_INVALID_CLASS || status.rc == CMPI_RC_ERR_NOT_FOUND) { if (enumeration) CMRelease(enumeration); return NULL; } if (!status.rc) { if (enumeration->ft->hasNext(enumeration, NULL)) { CMPIArray * arr; int n,i; arr = enumeration->ft->toArray(enumeration, NULL); n = CMGetArrayCount(arr, NULL); retArr = malloc(sizeof(CMPIInstance *) * (n + 1)); for(i = 0; i < n; i++) { CMPIData ele = CMGetArrayElementAt(arr, i, NULL); retArr[i] = ele.value.inst->ft->clone(ele.value.inst, NULL); } retArr[n] = NULL; } } if (enumeration) CMRelease(enumeration); return retArr; } CMPIConstClass * getClass(CMCIClient *cc, char * path, char * objectname) { CMPIStatus status; CMPIObjectPath * objectpath; CMPIConstClass * ccls; objectpath = newCMPIObjectPath(path, objectname, &status); ccls = cc->ft->getClass(cc, objectpath, CMPI_FLAG_IncludeQualifiers, NULL, &status); if (objectpath) CMRelease(objectpath); if (!status.rc) { return ccls; } else { //printf("Could not get class... ?\n"); //printf("Status: %d\n", status.rc); return NULL; } } cimSLPService getSLPData(cimomConfig cfg) { CMCIClient *cc; CMPIInstance **ci; CMPIStatus status; CMPIConstClass *ccls; cimSLPService rs; //service which is going to be returned to the calling function initializeService(&rs); cc = cmciConnect(cfg.cimhost, cfg.commScheme, cfg.port, cfg.cimuser, cfg.cimpassword, &status); if(status.rc) { printf("Could not connect to CIMOM. Check if it is running as well as your parameters.\n"); exit(0); } //first of all, get the interop namespace, needed for all further connections //this call fills the array as well as sets the global interOpNS variable rs.InteropSchemaNamespace = getInterOpNS(); //extract all relavant stuff for SLP out of CIM_ObjectManager //construct the server string ci = getInstances(cc, interOpNS, "CIM_ObjectManager"); if(ci) { rs.url_syntax = getUrlSyntax(myGetProperty(ci[0], "SystemName"), 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"); freeInstArr(ci); } //extract all relavant stuff for SLP out of CIM_ObjectManagerCommunicationMechanism ci = getInstances(cc, interOpNS, "CIM_ObjectManagerCommunicationMechanism"); if(ci) { rs.CommunicationMechanism = myGetProperty(ci[0], "CommunicationMechanism"); rs.OtherCommunicationMechanismDescription = myGetProperty(ci[0], "OtherCommunicationMechanism"); rs.ProtocolVersion = myGetProperty(ci[0], "Version"); rs.FunctionalProfilesSupported = myGetPropertyArray(ci[0], "FunctionalProfilesSupported"); rs.FunctionalProfileDescriptions = myGetPropertyArray(ci[0], "FunctionalProfileDescriptions"); rs.MultipleOperationsSupported = myGetProperty(ci[0], "MultipleOperationsSupported"); rs.AuthenticationMechanismsSupported = myGetPropertyArray(ci[0], "AuthenticationMechanismsSupported"); rs.AuthenticationMechansimDescriptions = myGetPropertyArray(ci[0], "AuthenticationMechansimDescriptions"); freeInstArr(ci); } //extract all relavant stuff for SLP out of CIM_Namespace ci = getInstances(cc, interOpNS, "CIM_Namespace"); if(ci) { rs.Namespace = myGetPropertyArrayFromArray(ci, "Name"); rs.Classinfo = myGetPropertyArrayFromArray(ci, "ClassInfo"); freeInstArr(ci); } //extract all relavant stuff for SLP out of CIM_RegisteredProfile ci = getInstances(cc, interOpNS, "CIM_RegisteredProfile"); if(ci) { rs.RegisteredProfilesSupported = myGetRegProfiles(ci, cc); free(ci); } //do the transformations from numbers to text via the qualifiers ccls = getClass(cc, interOpNS, "CIM_ObjectManagerCommunicationMechanism"); if(ccls) { rs.CommunicationMechanism = transformValue(rs.CommunicationMechanism, ccls, "CommunicationMechanism"); transformValueArray(rs.FunctionalProfilesSupported, ccls, "FunctionalProfilesSupported"); transformValueArray(rs.AuthenticationMechanismsSupported, ccls, "AuthenticationMechanismsSupported"); CMRelease(ccls); } if (cc) CMRelease(cc); return rs; } char ** myGetRegProfiles(CMPIInstance **instances, CMCIClient *cc) { CMPIObjectPath * objectpath; CMPIEnumeration * enumeration; CMPIStatus status; char ** retArr; int i,j=0; //count instances for(i = 0; instances != NULL && instances[i] != NULL; i++){} if(i == 0) { return NULL; } //allocating memory for the return array //a little too much memory will be allocated, since not each instance is a RegisteredProfile, for which a //string needs to be constructed ... but allocating dynamically would involve too much burden and overhead (?) retArr = (char **) malloc(i * sizeof(char *)); for(i = 0; instances[i] != NULL; i++) { objectpath = instances[i]->ft->getObjectPath(instances[i], &status); if(status.rc) { //no object path ?? return NULL; } objectpath->ft->setNameSpace(objectpath, interOpNS); enumeration = cc->ft->associatorNames(cc, objectpath, "CIM_SubProfileRequiresProfile", NULL, "Dependent", NULL, &status); //if the result is not null, we are operating on a CIM_RegisteredSubProfile, which we don't want if(! enumeration->ft->hasNext(enumeration, &status)) { CMPIData propertyData; propertyData = instances[i]->ft->getProperty(instances[i], "RegisteredOrganization", &status); retArr[j] = value2Chars(propertyData.type, &propertyData.value); propertyData = instances[i]->ft->getProperty(instances[i], "RegisteredName", &status); char * tempString = value2Chars(propertyData.type, &propertyData.value); retArr[j] = realloc(retArr[j], strlen(retArr[j]) + strlen(tempString) + 2); retArr[j] = strcat(retArr[j], ":"); retArr[j] = strcat(retArr[j], tempString); free(tempString); //now search for a CIM_RegisteredSubProfile for this instance enumeration = cc->ft->associators(cc, objectpath, "CIM_SubProfileRequiresProfile", NULL, "Antecedent", NULL, 0, NULL, &status); if(! enumeration->ft->hasNext(enumeration, &status)) { j++; } else while(enumeration->ft->hasNext(enumeration, &status)) { CMPIData data = enumeration->ft->getNext(enumeration, NULL); propertyData = data.value.inst->ft->getProperty(data.value.inst, "RegisteredName", &status); char * subprofilestring = value2Chars(propertyData.type, &propertyData.value); retArr[j] = realloc(retArr[j], strlen(retArr[j]) + strlen(subprofilestring) + 2); retArr[j] = strcat(retArr[j], ":"); retArr[j] = strcat(retArr[j], subprofilestring); j++; free(subprofilestring); } } } return retArr; } char ** transformValueArray(char ** cssf, CMPIConstClass * ccls, char * propertyName) { int i; for(i = 0; cssf[i] != NULL; i++) { cssf[i] = transformValue(cssf[i], ccls, propertyName); } } //transforms numerical values into their string counterpart //utilizing the Values and ValueMap qualifiers char * transformValue(char* cssf, CMPIConstClass * ccls, char * propertyName) //cssf = cimSLPService Field in the struct { CMPIData qd; CMPIStatus status; char * valuestr; qd=ccls->ft->getPropertyQualifier(ccls, propertyName, "ValueMap", &status); if (status.rc) { printf("getPropertyQualifier failed ... Status: %d\n", status.rc); return NULL; } if (CMIsArray(qd)) { CMPIArray *arr = qd.value.array; CMPIType eletyp = qd.type & ~CMPI_ARRAY; int j = 0; int n; n = CMGetArrayCount(arr, NULL); CMPIData ele; ele = CMGetArrayElementAt(arr, j, NULL); valuestr = value2Chars(eletyp, &ele.value); j++; while(strcmp(valuestr, cssf)) { free(valuestr); ele = CMGetArrayElementAt(arr, j, NULL); valuestr = value2Chars(eletyp, &ele.value); j++; } free(valuestr); free(cssf); if(j-1 <= n) { qd=ccls->ft->getPropertyQualifier(ccls, propertyName, "Values", &status); arr = qd.value.array; eletyp = qd.type & ~CMPI_ARRAY; ele = CMGetArrayElementAt(arr, j-1, NULL); return(value2Chars(eletyp, &ele.value)); } else { //printf("No Valuemap Entry for %s in %s. Exiting ...\n", cssf, propertyName); return NULL; } } else { //printf("No qualifier found for %s. Exiting ...\n", propertyName); return NULL; } } char * myGetProperty(CMPIInstance *instance, char * propertyName) { CMPIData propertyData; CMPIStatus status; if(! instance) return NULL; propertyData = instance->ft->getProperty(instance, propertyName, &status); if (!status.rc) { return value2Chars(propertyData.type, &propertyData.value); } else { return NULL; } } char ** myGetPropertyArrayFromArray(CMPIInstance **instances, char *propertyName) { int i; char **propertyArray; //count elements for(i = 0; instances != NULL && instances[i] != NULL; i++){} if(i == 0) { return NULL; } propertyArray = malloc((i + 1) * sizeof(char*)); for(i = 0; instances[i] != NULL; i++) { propertyArray[i] = myGetProperty(instances[i], propertyName); } propertyArray[i] = NULL; return propertyArray; } char ** myGetPropertyArray(CMPIInstance *instance, char *propertyName) { CMPIData propertyData; CMPIStatus status; char **propertyArray; propertyData = instance->ft->getProperty(instance, propertyName, &status); if (!status.rc) { if(CMIsArray(propertyData)) { CMPIArray *arr = propertyData.value.array; CMPIType eletyp = propertyData.type & ~CMPI_ARRAY; int n, i; n = CMGetArrayCount(arr, NULL); propertyArray = malloc(sizeof(char*)*(n + 1)); for(i = 0; i < n; i++) { CMPIData ele = CMGetArrayElementAt(arr, i, NULL); propertyArray[i] = value2Chars(eletyp, &ele.value); } propertyArray[n] = NULL; return propertyArray; } } else { return NULL; } } char * getUrlSyntax(char* sn, char * cs, char * port) { char * url_syntax; url_syntax = (char *) malloc((strlen(sn) + strlen(cs) + strlen(port) + 18) * sizeof(char)); //colon, double slash, colon, \0, service:wbem sprintf(url_syntax, "service:wbem:%s://%s:%s", cs, sn, port); //sprintf(url_syntax, "%s://%s:%s", cs, sn, port); free(sn); return url_syntax; } --- NEW FILE: cimslpConfig.h --- /* * cimslpCMPI.cimslpConfig.h * * (C) Copyright IBM Corp. 2006 * * 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: Sven Schuetz <sv...@de...> * Contributions: * * Description: * * Configuration options * */ #define SLP_RUN_STANDALONE --- NEW FILE: cimslp.c --- /* * cimslp.h * * (C) Copyright IBM Corp. 2006 * * 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: Sven Schuetz <sv...@de...> * Contributions: * * Description: * * Control functions, main if running standlone, or start thread * function if running in sfcb * */ #include <getopt.h> #include <stdio.h> #include <unistd.h> #include <string.h> #include "cimslpCMPI.h" #include "cimslpSLP.h" #include "cimslpConfig.h" #ifndef SLP_RUN_STANDALONE void startSLPThread() { cimomConfig cfg; //get the control stuff and call getSLPData with the filled cfg; } #else int main(int argc, char *argv[]) { int c; cimSLPService as; //Service which is going to be advertised cimomConfig cfg; cfg.commScheme = "http"; cfg.cimhost = "localhost"; cfg.port = "5988"; cfg.cimuser = "root"; cfg.cimpassword = "password"; static struct option const long_options[] = { { "cimhost", required_argument, 0, 'c' }, { "hostport", required_argument, 0, 'n' }, { "cimuser", required_argument, 0, 'u' }, { "cimpassword", required_argument, 0, 'p' }, { "commscheme", required_argument, 0, 's' }, { "help", no_argument, 0, 'h' }, { 0, 0, 0, 0 } }; while ((c = getopt_long(argc, argv, "c:n:u:p:s:h", long_options, 0)) != -1) { switch(c) { case 0: break; case 'c': cfg.cimhost = strdup(optarg); break; case 'n': cfg.port = strdup(optarg); break; case 'u': cfg.cimuser = strdup(optarg); break; case 'p': cfg.cimpassword = strdup(optarg); break; case 's': cfg.commScheme = strdup(optarg); break; case 'h': printf("Help\n"); break; default: printf("Help\n"); break; } } int i = 0; for(i = 0; i < 5; i++) { as = getSLPData(cfg); registerCIMService(as); //sleep(1); } } #endif --- NEW FILE: cimslpSLP.h --- /* * cimslpSLP.h * * (C) Copyright IBM Corp. 2006 * * 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: Sven Schuetz <sv...@de...> * Contributions: * * Description: * * Functions for slp regs/deregs * */ char* buildAttrString(char * name, char * value, char * attrstring); char* buildAttrStringFromArray(char * name, char ** value, char * attrstring); int registerCIMService(cimSLPService css); --- NEW FILE: cimslpCMPI.h --- /* * cimslpCMPI.h * * (C) Copyright IBM Corp. 2006 * * 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: Sven Schuetz <sv...@de...> * Contributions: * * Description: * * Functions getting slp relevant information from the CIMOM utilizing sfcc * */ #include <cmci.h> #include <native.h> #include <unistd.h> typedef struct { char * url_syntax; char * service_hi_name; char * service_hi_description; char * service_id; char * CommunicationMechanism; char * OtherCommunicationMechanismDescription; char ** InteropSchemaNamespace; char * ProtocolVersion; char ** FunctionalProfilesSupported; char ** FunctionalProfileDescriptions; char * MultipleOperationsSupported; char ** AuthenticationMechanismsSupported; char ** AuthenticationMechansimDescriptions; char ** Namespace; char ** Classinfo; char ** RegisteredProfilesSupported; } cimSLPService; typedef struct { char * commScheme; //http or https char * cimhost; char * port; char *cimuser; char *cimpassword; } cimomConfig; extern char *value2Chars(CMPIType type, CMPIValue * value); void initializeService(cimSLPService *rs); cimSLPService getSLPData(cimomConfig cfg); char * myGetProperty(CMPIInstance *instance, char * propertyName); char ** myGetPropertyArray(CMPIInstance *instance, char *propertyName); char ** myGetPropertyArrayFromArray(CMPIInstance **instances, char *propertyName); CMPIInstance ** getInstances(CMCIClient *cc, char * path, char * objectname); CMPIInstance ** getInstances(CMCIClient *cc, char * path, char * objectname); char * transformValue(char * cssf, CMPIConstClass * ccls, char * propertyName); char ** transformValueArray(char ** cssf, CMPIConstClass * ccls, char * propertyName); char ** myGetRegProfiles(CMPIInstance **instances, CMCIClient *cc); char ** getInterOpNS(); char * getUrlSyntax(char* sn, char * cs, char * port); --- NEW FILE: cimslpUtil.h --- /* * cimslpUtil.h * * (C) Copyright IBM Corp. 2006 * * 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: Sven Schuetz <sv...@de...> * Contributions: * * Description: * * some helper functions * */ #include <cmci.h> //#define freeArr(arr) \ // {int freeStrArrN=0;if (arr) {while (arr[freeStrArrN]) free(arr[freeStrArrN++]);free(arr);}} #define freeStr(str) \ {if (str) free(str);} void freeInstArr(CMPIInstance ** arr); void freeArr(char ** arr); --- NEW FILE: cimslpUtil.c --- /* * cimslpUtil.c * * (C) Copyright IBM Corp. 2006 * * 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: Sven Schuetz <sv...@de...> * Contributions: * * Description: * * some helper functions * */ #include "cimslpUtil.h" /*void freeStrArr(char ** arr) { int n=0; if (arr) {while (arr[n]) free(arr[n++]);free(arr);} }*/ void freeInstArr(CMPIInstance ** arr) { int i = 0; if(arr) { while (arr[i]) { CMRelease(arr[i]); i++; } free(arr); } } void freeArr(char ** arr) { int i = 0; if(arr) { while (arr[i]) { free(arr[i]); i++; } free(arr); } } |