From: Chris B. <buc...@us...> - 2013-02-28 00:02:47
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "sfcb - Small Footprint CIM Broker". The branch, master has been updated via 62af09340953e1b8b3ee376292490e8762f936f5 (commit) from b15ae230bf22a10f13f41721f08a830f1b46efbb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 62af09340953e1b8b3ee376292490e8762f936f5 Author: buccella <buc...@li...> Date: Wed Feb 27 19:02:13 2013 -0500 [sfcb-tix:#24] GetClass Operation does not filter the class ----------------------------------------------------------------------- Summary of changes: Makefile.am | 6 ++-- cimXmlGen.c | 6 +++ cimXmlOps.y | 1 - classProvider.c | 3 ++ classProviderCommon.c | 56 ++++++++++++++++++++++++++++++++ classProviderCommon.h | 3 ++ classProviderGz.c | 3 ++ classProviderSf.c | 3 ++ objectImpl.c | 34 +++++++++++++++++++ objectImpl.h | 25 +++----------- sfcbmacs.h | 2 +- test/xmltest/FilteredClassProperty.out | 1 + test/xmltest/FilteredClassProperty.xml | 10 ++++++ 13 files changed, 129 insertions(+), 24 deletions(-) diff --git a/Makefile.am b/Makefile.am index e3ae115..d5d43ea 100644 --- a/Makefile.am +++ b/Makefile.am @@ -288,17 +288,17 @@ libsfccimAccountPassthroughProvider_la_DEPENDENCIES=libsfcBrokerCore.la endif libsfcClassProviderGz_la_SOURCES = \ - classProviderGz.c + classProviderCommon.c classProviderGz.c libsfcClassProviderGz_la_LIBADD=-lsfcBrokerCore @SFCB_LIBZ@ libsfcClassProviderGz_la_DEPENDENCIES=libsfcBrokerCore.la libsfcClassProviderSf_la_SOURCES = \ - classProviderSf.c + classProviderCommon.c classProviderSf.c libsfcClassProviderSf_la_LIBADD=-lsfcBrokerCore @SFCB_LIBZ@ libsfcClassProviderSf_la_DEPENDENCIES=libsfcBrokerCore.la libsfcClassProvider_la_SOURCES = \ - classProvider.c + classProviderCommon.c classProvider.c libsfcClassProvider_la_LIBADD=-lsfcBrokerCore libsfcClassProvider_la_DEPENDENCIES=libsfcBrokerCore.la diff --git a/cimXmlGen.c b/cimXmlGen.c index 59850ed..d573a39 100644 --- a/cimXmlGen.c +++ b/cimXmlGen.c @@ -958,6 +958,9 @@ cls2xml(CMPIConstClass * cls, UtilStringBuffer * sb, unsigned int flags) } for (i = 0, m = ClClassGetPropertyCount(cl); i < m; i++) { + if(ClClassHasFilteredProps(cl) && ClClassIsPropertyAtFiltered(cl, i)) { + continue; + } qsb->ft->reset(qsb); data = getPropertyQualsAt(cls, i, &name, &quals, &refName, NULL); if (flags & FL_includeQualifiers) @@ -993,6 +996,9 @@ cls2xml(CMPIConstClass * cls, UtilStringBuffer * sb, unsigned int flags) CMPIString *name, *mname; + if(ClClassHasFilteredProps(cl) && ClClassIsMethodAtFiltered(cl, i)) { + continue; + } qsb->ft->reset(qsb); ClClassGetMethodAt(cl, i, &mtype, &smname, &quals); mname = sfcb_native_new_CMPIString(smname, NULL, 2); diff --git a/cimXmlOps.y b/cimXmlOps.y index 0af0e86..7317fb7 100644 --- a/cimXmlOps.y +++ b/cimXmlOps.y @@ -384,7 +384,6 @@ buildGetInstanceRequest(void *parm) sreq->hdr.sessionId = hdr->sessionId; for (i = 0; i < req->properties; i++) { - fprintf(stderr, "setting filter prop %d to %s\n", i, req->propertyList.values[i].value); sreq->properties[i] = setCharsMsgSegment(req->propertyList.values[i].value); } diff --git a/classProvider.c b/classProvider.c index 6c35e00..a37096b 100644 --- a/classProvider.c +++ b/classProvider.c @@ -902,6 +902,9 @@ ClassProviderGetClass(CMPIClassMI * mi, cl = getClass(cReg, (char *) cn->hdl); if (cl) { _SFCB_TRACE(1, ("--- Class found")); + if(properties) { + filterClass(cl, properties); + } CMReturnInstance(rslt, (CMPIInstance *) cl); } else { _SFCB_TRACE(1, ("--- Class not found")); diff --git a/classProviderCommon.c b/classProviderCommon.c new file mode 100644 index 0000000..0f5434f --- /dev/null +++ b/classProviderCommon.c @@ -0,0 +1,56 @@ +#include "classProviderCommon.h" + +//candidate for sfcCommon +int contained_list(const char **list, const char *name) +{ + if (list) { + while (*list) { + if (strcasecmp(*list++, name) == 0) return 1; + } + } + return 0; +} + +void filterClass(CMPIConstClass* cimClass, const char** props) +{ + _SFCB_ENTER(TRACE_PROVIDERS, "filterClass"); + char* name = NULL; + int propCount; + unsigned long quals; + CMPIData data = { 0, CMPI_notFound, {0} }; + CMPIType mtype; + char* refName = NULL; + int i; + + ClClass * cls = (ClClass*)cimClass->hdl; + ClClassSetHasFilteredProps(cls); + propCount = ClClassGetPropertyCount(cls); + + ClProperty *property = (ClProperty*)ClObjectGetClSection(&cls->hdr, &cls->properties); + + for(i = 0; i < propCount; i++) { + ClClassGetPropertyAt(cls, i, &data, &name, &quals, &refName); + if(name){ + if((!contained_list(props, name))) + (property + i)->flags |= ClProperty_Filtered; + } + } + + int methCount = ClClassGetMethodCount(cls); + + ClMethod *method = (ClMethod*)ClObjectGetClSection(&cls->hdr, &cls->methods); + + for(i = 0; i < methCount; i++) { + char * smname; + + ClClassGetMethodAt(cls, i, &mtype, &smname, &quals); + + if(smname){ + if((!contained_list(props, smname))) + { + (method + i)->flags |= ClProperty_Filtered; + } + } + } + +} diff --git a/classProviderCommon.h b/classProviderCommon.h index a809ccc..756c29d 100644 --- a/classProviderCommon.h +++ b/classProviderCommon.h @@ -59,6 +59,9 @@ static pthread_once_t nsHt_once = PTHREAD_ONCE_INIT; #define Iterator HashTableIterator* #define NEW(x) ((x *) calloc(1,sizeof(x))) + +void filterClass(CMPIConstClass* cimClass, const char** props); + /* MODELINES */ /* DO NOT EDIT BELOW THIS COMMENT */ /* Modelines are added by 'make pretty' */ diff --git a/classProviderGz.c b/classProviderGz.c index e65bc12..33ab5c9 100644 --- a/classProviderGz.c +++ b/classProviderGz.c @@ -847,6 +847,9 @@ ClassProviderGetClass(CMPIClassMI * mi, _SFCB_TRACE(1, ("--- Class found")); cl = clLocal->ft->clone(clLocal, NULL); memLinkInstance((CMPIInstance *) cl); + if(properties) { + filterClass(cl, properties); + } CMReturnInstance(rslt, (CMPIInstance *) cl); } else { _SFCB_TRACE(1, ("--- Class not found")); diff --git a/classProviderSf.c b/classProviderSf.c index 4fc48a5..1155078 100644 --- a/classProviderSf.c +++ b/classProviderSf.c @@ -1220,6 +1220,9 @@ ClassProviderGetClass(CMPIClassMI * mi, _SFCB_TRACE(1, ("--- Class found")); cl = clLocal->ft->clone(clLocal, NULL); memLinkInstance((CMPIInstance *) cl); + if(properties) { + filterClass(cl, properties); + } CMReturnInstance(rslt, (CMPIInstance *) cl); if (ctl != cached) CMRelease(cl); diff --git a/objectImpl.c b/objectImpl.c index 5125fd5..d72c0d2 100644 --- a/objectImpl.c +++ b/objectImpl.c @@ -2127,6 +2127,40 @@ ClClassGetMethParameterAt(ClClass * cls, ClMethod * m, int pid, return 0; } +//This function checks whether Methods from the class are filtered or not +int ClClassIsMethodAtFiltered(ClClass * inst, int id) +{ + ClMethod *p; + p = (ClMethod *) ClObjectGetClSection(&inst->hdr, &inst->methods); + if((p + id)->flags & ClProperty_Filtered) { + return 1; + } + else { + return 0; + } +} + +//This function checks whether Properties from the class are filtered or not +int ClClassIsPropertyAtFiltered(ClClass * inst, int id) +{ + ClProperty *p; + p = (ClProperty *) ClObjectGetClSection(&inst->hdr, &inst->properties); + if((p + id)->flags & ClProperty_Filtered) { + return 1; + } + else { + return 0; + } +} + +void ClClassSetHasFilteredProps(ClClass *cls) { + cls->hdr.flags |= HDR_HasFilteredProps; +} + +int ClClassHasFilteredProps(ClClass *cls) { + return ((cls->hdr.flags & HDR_HasFilteredProps) > 0); +} + // ------------------------------------------------------- // ----- // -- Instance support diff --git a/objectImpl.h b/objectImpl.h index a2e6edc..0359c61 100644 --- a/objectImpl.h +++ b/objectImpl.h @@ -157,6 +157,7 @@ typedef struct { #define HDR_StrBufferMalloced 16 #define HDR_ArrayBufferMalloced 32 #define HDR_FromMof 64 +#define HDR_HasFilteredProps 128 #endif unsigned short type; #ifndef SETCLPFX @@ -517,6 +518,10 @@ extern int ClClassGetMethParameterAt(ClClass * cls, ClMethod * m, extern int ClClassGetMethParamQualifierAt(ClClass * cls, ClParameter * parm, int id, CMPIData *d, char **name); +extern int ClClassIsMethodAtFiltered(ClClass * inst, int id); +extern int ClClassIsPropertyAtFiltered(ClClass * inst, int id); +extern void ClClassSetHasFilteredProps(ClClass *c); +extern int ClClassHasFilteredProps(ClClass *c); extern int isInstance(const CMPIInstance *ci); extern ClInstance *ClInstanceNew(const char *ns, const char *cn); extern ClInstance *ClInstanceNewFromMof(const char *ns, const char *cn); @@ -575,25 +580,7 @@ extern void ClQualifierRelocateQualifier(ClQualifierDeclaration * q); extern int ClQualifierAddQualifier(ClObjectHdr * hdr, ClSection * qlfs, const char *id, CMPIData d); -extern int - - - - - - - - - - - - - - - - - -ClQualifierDeclarationGetQualifierData(ClQualifierDeclaration * q, +extern int ClQualifierDeclarationGetQualifierData(ClQualifierDeclaration * q, CMPIData *data); extern void ClQualifierFree(ClQualifierDeclaration * q); const char *ClObjectGetClObject(ClObjectHdr * hdr, ClString * id); diff --git a/sfcbmacs.h b/sfcbmacs.h index 07fcf60..47ea1e8 100644 --- a/sfcbmacs.h +++ b/sfcbmacs.h @@ -3,7 +3,7 @@ */ static CMPIStatus __attribute__ ((unused)) notSupSt = { CMPI_RC_ERR_NOT_SUPPORTED, NULL }; -static CMPIStatus okSt = { CMPI_RC_OK, NULL }; +static CMPIStatus __attribute__ ((unused)) okSt = { CMPI_RC_OK, NULL }; #define notSupCMPI_EQ(pfx) \ pfx##ExecQuery(CMPIInstanceMI __attribute__ ((unused)) *mi, \ diff --git a/test/xmltest/FilteredClassProperty.out b/test/xmltest/FilteredClassProperty.out new file mode 100644 index 0000000..07e9f61 --- /dev/null +++ b/test/xmltest/FilteredClassProperty.out @@ -0,0 +1 @@ +500 Can't connect to localhost:5988 (Connection refused) diff --git a/test/xmltest/FilteredClassProperty.xml b/test/xmltest/FilteredClassProperty.xml new file mode 100644 index 0000000..ed19ed0 --- /dev/null +++ b/test/xmltest/FilteredClassProperty.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- From sfcb-tix#24 --> +<CIM CIMVERSION="2.0" DTDVERSION="2.0"><MESSAGE ID="1000" PROTOCOLVERSION="1.0"> +<SIMPLEREQ><IMETHODCALL NAME="GetClass"> +<LOCALNAMESPACEPATH><NAMESPACE NAME="root"/><NAMESPACE NAME="cimv2"/></LOCALNAMESPACEPATH> + <IPARAMVALUE NAME="ClassName"><CLASSNAME NAME="Linux_Processor"/></IPARAMVALUE> + <IPARAMVALUE NAME="LocalOnly"><VALUE>FALSE</VALUE></IPARAMVALUE> + <IPARAMVALUE NAME="PropertyList"> + <VALUE.ARRAY><VALUE>NumberOfEnabledCores</VALUE></VALUE.ARRAY> + </IPARAMVALUE><IPARAMVALUE NAME="IncludeQualifiers"><VALUE>FALSE</VALUE></IPARAMVALUE></IMETHODCALL></SIMPLEREQ></MESSAGE></CIM> hooks/post-receive -- sfcb - Small Footprint CIM Broker |