Esempio n. 1
0
CMPIData
internalGetPropQualAt(CMPIConstClass * cc, CMPICount p, CMPICount i,
                      CMPIString **name, CMPIStatus *rc)
{
  ClClass        *cls = (ClClass *) cc->hdl;
  char           *n;
  CMPIData        rv = { 0, CMPI_notFound, {0} };

  if (ClClassGetPropQualifierAt(cls, p, i, &rv, name ? &n : NULL)) {
    if (rc)
      CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
    if (name)
      *name = sfcb_native_new_CMPIString(NULL, NULL, 0);
    return rv;
  }
  if (rv.type == CMPI_chars) {
    rv.value.string = sfcb_native_new_CMPIString(ClObjectGetClString
                                                 (&cls->hdr,
                                                  (ClString *) & rv.value.
                                                  chars), NULL, 0);
    rv.type = CMPI_string;
  }
  if (rv.type & CMPI_ARRAY && rv.value.dataPtr.ptr) {
    rv.value.array =
        native_make_CMPIArray((CMPIData *) rv.value.dataPtr.ptr, NULL,
                              &cls->hdr);
  }
  if (name) {
    *name = sfcb_native_new_CMPIString(n, NULL, 0);
  }
  if (rc)
    CMSetStatus(rc, CMPI_RC_OK);
  return rv;
}
Esempio n. 2
0
File: args.c Progetto: mchasal/SFCB
static CMPIData
__aft_getArgAt(const CMPIArgs * args,
               unsigned int i, CMPIString **name, CMPIStatus *rc)
{
  ClArgs         *ca = (ClArgs *) args->hdl;
  char           *n;
  CMPIData        rv = { 0, CMPI_notFound, {0} };

  if (ClArgsGetArgAt(ca, i, &rv, name ? &n : NULL)) {
    if (rc)
      CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
    return rv;
  }
  if (rv.type == CMPI_chars) {
    rv.value.string = sfcb_native_new_CMPIString(rv.value.chars, NULL, 0);
    rv.type = CMPI_string;
  } else if (rv.type == CMPI_ref) {
    rv.value.ref = getObjectPath((char *)
                                 ClObjectGetClString(&ca->hdr,
                                                     (ClString *) &
                                                     rv.value.chars),
                                 NULL);
  } else if (rv.type & CMPI_ARRAY && rv.value.array) {
    rv.value.array =
        internal_native_make_CMPIArray((CMPIData *) rv.value.array, NULL,
                                       &ca->hdr, MEM_TRACKED);
  }
  if (name) {
    *name = sfcb_native_new_CMPIString(n, NULL, 0);
  }
  if (rc)
    CMSetStatus(rc, CMPI_RC_OK);
  return rv;
}
static int
testNameSpace(const char *ns, CMPIStatus *st)
{
  char          **nsp = nsTab;

  if (interOpProvInfoPtr == forceNoProvInfoPtr) {
    if (strcasecmp(ns, interopNs) == 0) {
      st->msg =
          sfcb_native_new_CMPIString("Interop namespace disabled", NULL,
                                     0);
      st->rc = CMPI_RC_ERR_FAILED;
      return 0;
    }
  }

  while (nsTabLen && *nsp) {
    if (strcasecmp(*nsp, ns) == 0)
      return 1;
    nsp++;
  }
  if (existingNameSpace(ns)) {
    nsTab = nsp = realloc(nsTab, sizeof(nsp) * (nsTabLen + 2));
    nsp[nsTabLen++] = strdup(ns);
    nsp[nsTabLen] = NULL;
    return 1;
  }

  st->rc = CMPI_RC_ERR_INVALID_NAMESPACE;
  return 0;
}
Esempio n. 4
0
static CMPIData
getQualifierDeclData(CMPIQualifierDecl * cq, CMPIStatus *rc)
{
  ClQualifierDeclaration *q = (ClQualifierDeclaration *) cq->hdl;

  CMPIData        rv = { 0, CMPI_notFound, {0} };
  if (ClQualifierDeclarationGetQualifierData(q, &rv)) {
    if (rc)
      CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
    return rv;
  }
  if (rv.type == CMPI_chars) {
    rv.value.string = sfcb_native_new_CMPIString(ClObjectGetClString
                                                 (&q->hdr,
                                                  (ClString *) & rv.value.
                                                  chars), NULL, 0);
    rv.type = CMPI_string;
  }
  if (rv.type & CMPI_ARRAY && rv.value.array) {
    rv.value.array = native_make_CMPIArray((CMPIData *) rv.value.array,
                                           NULL, &q->hdr);
  }

  if (rc)
    CMSetStatus(rc, CMPI_RC_OK);
  return rv;
}
Esempio n. 5
0
static CMPIString *
__dtft_getStringFormat(const CMPIDateTime *dt, CMPIStatus *rc)
{
  struct native_datetime *ndt = (struct native_datetime *) dt;

  if (rc)
    CMSetStatus(rc, CMPI_RC_OK);
  return sfcb_native_new_CMPIString(ndt->cimDt, rc, 0);
}
Esempio n. 6
0
CMPIData
getPropertyQualsAt(CMPIConstClass * cc, CMPICount i, CMPIString **name,
                   unsigned long *quals, CMPIString **refName,
                   CMPIStatus *rc)
{
  ClClass        *cls = (ClClass *) cc->hdl;
  char           *n;
  char           *rName = NULL;
  CMPIData        rv = { 0, CMPI_notFound, {0} };
  if (ClClassGetPropertyAt(cls, i, &rv, name ? &n : NULL, quals, &rName)) {
    if (rc)
      CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
    return rv;
  }
  if (rv.type == CMPI_chars) {
    rv.value.string = sfcb_native_new_CMPIString(rv.value.chars, NULL, 0);
    rv.type = CMPI_string;
  } else if (rv.type == CMPI_ref) {
    if ((rv.state & CMPI_nullValue) == 0)
      rv.value.ref = getObjectPath((char *)
                                   ClObjectGetClString(&cls->hdr,
                                                       (ClString *) &
                                                       rv.value.chars),
                                   NULL);
  }
  if (rv.type & CMPI_ARRAY && rv.value.array) {
    rv.value.array =
        native_make_CMPIArray((CMPIData *) rv.value.array, NULL,
                              &cls->hdr);
  }
  if (name) {
    *name = sfcb_native_new_CMPIString(n, NULL, 0);
  }
  if (refName && rName) {
    *refName = sfcb_native_new_CMPIString(rName, NULL, 0);
  } else {
    if (refName) {
      *refName = NULL;
    }
  }
  if (rc)
    CMSetStatus(rc, CMPI_RC_OK);
  return rv;
}
Esempio n. 7
0
static CMPIContext* prepareUpcall(CMPIContext *ctx)
{
    /* used to invoke the internal provider in upcalls, otherwise we will
 *      * be routed here (interOpProvider) again*/
    CMPIContext *ctxLocal;
    ctxLocal = native_clone_CMPIContext(ctx);
    CMPIValue val;
    val.string = sfcb_native_new_CMPIString("$DefaultProvider$", NULL,0);
    ctxLocal->ft->addEntry(ctxLocal, "rerouteToProvider", &val, CMPI_string);
    return ctxLocal;
}
Esempio n. 8
0
static CMPIStatus
__eft_getData(const CMPIPredicate *pred, CMPIType *type,
              CMPIPredOp * opc, CMPIString **lhs, CMPIString **rhs)
{
  NativePredicate *p = (NativePredicate *) pred;
  QLOperation    *op = p->op,
      *o;
  CMPIStatus      irc = { CMPI_RC_OK, NULL };

  if (op) {
    if (op->opr == QL_bin) {
      QLOpd           type = QL_Invalid;
      if (op->lhon)
        o = op->lhon;
      else
        o = op->rhon;
      if (o->lhod && o->lhod->type != QL_PropertyName)
        type = o->lhod->type;
      else if (o->rhod && o->rhod->type != QL_PropertyName)
        type = o->rhod->type;
      if (opc)
        *opc = o->opr;
      if (lhs) {
	char* lstr = o->lhod->ft->toString(o->lhod);
        *lhs = sfcb_native_new_CMPIString(lstr, NULL, 0);
      }
      if (rhs) {
	char* rstr = o->rhod->ft->toString(o->rhod);
        *rhs = sfcb_native_new_CMPIString(rstr, NULL, 0);
      }
    } else {
      printf("--- NOT QL_bin\n");
      CMSetStatusWithString(&irc, CMPI_RC_ERR_FAILED,
                            sfcb_native_new_CMPIString
                            ("Predicate has no a binary operator.", NULL,
                             0));
    }
  }
  return irc;
}
void
ElementCapabilitiesInitInstances(const CMPIContext *ctx)
{
  CMPIObjectPath *op = NULL,
      *opLeft = NULL,
      *opRight = NULL,
      *left = NULL,
      *right = NULL;
  CMPIValue       val;
  CMPIEnumeration *enm = NULL;
  CMPIInstance   *ci = NULL;
  CMPIContext    *ctxLocal;

  ctxLocal = native_clone_CMPIContext(ctx);
  val.string = sfcb_native_new_CMPIString("$DefaultProvider$", NULL, 0);
  ctxLocal->ft->addEntry(ctxLocal, "rerouteToProvider", &val, CMPI_string);

  op = CMNewObjectPath(_broker, "root/interop", "SFCB_ElementCapabilities",
                       NULL);
  ci = CMNewInstance(_broker, op, NULL);

  opLeft =
      CMNewObjectPath(_broker, "root/interop", "CIM_IndicationService",
                      NULL);
  enm = CBEnumInstanceNames(_broker, ctx, opLeft, NULL);
  left = CMGetNext(enm, NULL).value.ref;
  opRight =
      CMNewObjectPath(_broker, "root/interop",
                      "SFCB_IndicationServiceCapabilities", NULL);
  enm = CBEnumInstanceNames(_broker, ctx, opRight, NULL);
  right = CMGetNext(enm, NULL).value.ref;

  CMAddKey(op, "ManagedElement", &left, CMPI_ref);
  CMAddKey(op, "Capabilities", &right, CMPI_ref);
  CMSetProperty(ci, "ManagedElement", &left, CMPI_ref);
  CMSetProperty(ci, "Capabilities", &right, CMPI_ref);
  CBCreateInstance(_broker, ctxLocal, op, ci, NULL);
  CMRelease(ctxLocal);
  return;
}
Esempio n. 10
0
static CMPIData
getQualifier(CMPIConstClass * cc, const char *name, CMPIStatus *rc)
{
  ClClass        *cls = (ClClass *) cc->hdl;
  CMPIData        rv_notfound = { 0, CMPI_notFound, {0} };
  CMPIData        rv;
  char           *qname;
  int             i;
  CMPICount       cnt = ClClassGetQualifierCount(cls);

  for (i = 0; i < cnt; i++) {
    if (ClClassGetQualifierAt(cls, i, &rv, &qname)) {
      if (rc)
        CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
      return rv_notfound;
    }
    if (strcasecmp(name, qname) == 0) {
      if (rv.type == CMPI_chars) {
        rv.value.string = sfcb_native_new_CMPIString(ClObjectGetClString
                                                     (&cls->hdr,
                                                      (ClString *) &
                                                      rv.value.chars),
                                                     NULL, 0);
        rv.type = CMPI_string;
      }
      if (rv.type & CMPI_ARRAY && rv.value.array) {
        rv.value.array = native_make_CMPIArray((CMPIData *) rv.value.array,
                                               NULL, &cls->hdr);
      }
      if (rc)
        CMSetStatus(rc, CMPI_RC_OK);
      return rv;
    };
  }
  if (rc)
    CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
  return rv_notfound;
}
Esempio n. 11
0
static CMPIString *
getSuperClassName(CMPIConstClass * cc, CMPIStatus *rc)
{
  const char     *cn = getCharSuperClassName(cc);
  return sfcb_native_new_CMPIString(cn, rc, 0);
}
Esempio n. 12
0
static CMPIData
getPropQualifier(CMPIConstClass * cc, const char *cp, const char *cpq,
                 CMPIStatus *rc)
{
  ClClass        *cls = (ClClass *) cc->hdl;
  ClSection      *prps = &cls->properties;
  char           *n = NULL;
  CMPIData        rv_notFound = { 0, CMPI_notFound, {0} };
  CMPIData        rv;
  CMPICount       p = ClObjectLocateProperty(&cls->hdr, prps, cp);
  CMPICount       num = ClClassGetPropQualifierCount(cls, p - 1);
  CMPICount       i;

  /*
   * special qualifier handling 
   */
  if (strcasecmp(cpq, "key") == 0) {
    unsigned long   quals;
    getPropertyQualsAt(cc, p - 1, NULL, &quals, NULL, rc);
    if (quals & ClProperty_Q_Key) {
      rv.type = CMPI_boolean;
      rv.state = CMPI_goodValue;
      rv.value.boolean = 1;
      if (rc)
        CMSetStatus(rc, CMPI_RC_OK);
      return rv;
    } else {
      if (rc) 
        CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
      return rv_notFound;
    }
  }
  if (strcasecmp(cpq, "embeddedobject") == 0) {
    unsigned long quals;
    getPropertyQualsAt(cc,p-1,NULL,&quals,NULL,rc);
    if (quals &  ClProperty_Q_EmbeddedObject) {
      rv.type = CMPI_boolean;
      rv.state = CMPI_goodValue;
      rv.value.boolean = 1;
      if (rc)
        CMSetStatus(rc, CMPI_RC_OK);
      return rv;
    } else {
      if (rc) 
        CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
      return rv_notFound;
    }
  }

  for (i = 0; i < num; i++) {
    if (ClClassGetPropQualifierAt(cls, p - 1, i, &rv, &n) == 0
        && strcasecmp(cpq, n) == 0) {
      if (rv.type == CMPI_chars) {
        rv.value.string = sfcb_native_new_CMPIString(ClObjectGetClString
                                                     (&cls->hdr,
                                                      (ClString *) &
                                                      rv.value.chars),
                                                     NULL, 0);
        rv.type = CMPI_string;
      } else if ((rv.type & CMPI_ARRAY) && rv.value.dataPtr.ptr) {
        rv.value.array =
            native_make_CMPIArray((CMPIData *) rv.value.dataPtr.ptr, NULL,
                                  &cls->hdr);
      }
      if (rc)
        CMSetStatus(rc, CMPI_RC_OK);
      return rv;
    }
    if (n && isMallocedStrBuf(&cls->hdr)) {
      free(n);
    }
  }
  if (rc) {
    CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND);
  }
  return rv_notFound;
}
Esempio n. 13
0
File: args.c Progetto: mchasal/SFCB
CMPIString     *
args2String(CMPIArgs * arg, CMPIStatus *rc)
{
  char           *argstr = ClArgsToString((ClArgs *) arg->hdl);
  return sfcb_native_new_CMPIString(argstr, NULL, 0);
}
Esempio n. 14
0
CMPIStatus
IndCIMXMLHandlerInvokeMethod(CMPIMethodMI * mi,
                             const CMPIContext *ctx,
                             const CMPIResult *rslt,
                             const CMPIObjectPath * ref,
                             const char *methodName,
                             const CMPIArgs * in, CMPIArgs * out)
{
  _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerInvokeMethod");

  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIStatus      circ = { CMPI_RC_OK, NULL };
  struct timeval tv;
  struct timezone tz;
  static unsigned int indID=1;


  if (interOpNameSpace(ref, &st) == 0)
    _SFCB_RETURN(st);

  if (strcasecmp(methodName, "_deliver") == 0) {

    // On the first indication, check if reliable indications are enabled.
    if (RIEnabled == -1) {
      CMPIObjectPath *op=CMNewObjectPath(_broker,"root/interop","CIM_IndicationService",NULL);
      CMPIEnumeration *isenm = _broker->bft->enumerateInstances(_broker, ctx, op, NULL, NULL);
      CMPIData isinst=CMGetNext(isenm,NULL);
      CMPIData mc=CMGetProperty(isinst.value.inst,"DeliveryRetryAttempts",NULL);
      RIEnabled=mc.value.uint16;
    }

    CMPIInstance *indo=CMGetArg(in,"indication",NULL).value.inst;
    CMPIInstance *ind=CMClone(indo,NULL);
    CMPIContext    *ctxLocal=NULL;
    CMPIObjectPath *iop=NULL,*subop=NULL;
    CMPIInstance *sub=NULL;

    if (RIEnabled) {
      ctxLocal = prepareUpcall((CMPIContext *) ctx);
      // Set the indication sequence values
      iop=CMGetObjectPath(ind,NULL);
      CMAddKey(iop,"SFCB_IndicationID",&indID,CMPI_uint32);
      CMSetProperty(ind,"SFCB_IndicationID",&indID,CMPI_uint32);
      // Prevent this property from showing up in the indication
      filterFlagProperty(ind, "SFCB_IndicationID");
      sub=CMGetArg(in,"subscription",NULL).value.inst;
      CMPIData handler=CMGetProperty(sub, "Handler", &st);
      CMPIObjectPath *hop=handler.value.ref;
      CMPIInstance *hdlr=CBGetInstance(_broker, ctxLocal, hop, NULL, &st);

      // Build the complete sequence context
      // Get the stub from the handler
      CMPIString *context = CMGetProperty(hdlr, "SequenceContext", &st).value.string;
      // and add the sfcb start time
      char *cstr=malloc( (strlen(context->ft->getCharPtr(context,NULL)) + strlen(sfcBrokerStart) + 1) * sizeof(char));
      sprintf(cstr,"%s%s",context->ft->getCharPtr(context,NULL),sfcBrokerStart);
      context = sfcb_native_new_CMPIString(cstr, NULL, 0); 
      // and put it in the indication
      CMSetProperty(ind, "SequenceContext", &context, CMPI_string);
      free(cstr);
      CMRelease(context);

      // Get the proper sequence number
      CMPIValue lastseq = CMGetProperty(hdlr, "LastSequenceNumber", &st).value;
      lastseq.sint64++;
      // Handle wrapping of the signed int
      if (lastseq.sint64 < 0) lastseq.sint64=0;
      // Update the last used number in the handler
      CMSetProperty(hdlr, "LastSequenceNumber", &lastseq.sint64, CMPI_sint64);
      CBModifyInstance(_broker, ctxLocal, hop, hdlr, NULL);
      // And the indication
      CMSetProperty(ind, "SequenceNumber", &lastseq, CMPI_sint64);
    }

    // Now send the indication
    st = deliverInd(ref, in, ind);
    if (st.rc != 0) {
      if (RIEnabled){
        _SFCB_TRACE(1,("--- Indication delivery failed, adding to retry queue"));
        // Indication delivery failed, send to retry queue
        // build an element
        RTElement      *element;
        element = (RTElement *) malloc(sizeof(*element));
        element->ref=ref->ft->clone(ref,NULL);
        // Get the OP of the subscription and indication
        subop=CMGetObjectPath(sub,NULL);
        element->sub=subop->ft->clone(subop,NULL);
        element->ind=iop->ft->clone(iop,NULL);
        // Store other attrs
        element->instanceID=indID;
        element->count=0;
        gettimeofday(&tv, &tz);
        element->lasttry=tv.tv_sec;
        // Push the indication to the repo
        CBCreateInstance(_broker, ctxLocal, iop, ind, &circ);
        if (circ.rc != 0) {
            mlogf(M_ERROR,M_SHOW,"Pushing indication instance to repository failed, rc:%d\n",circ.rc);
        }
        indID++;
        // Add it to the retry queue
        enqRetry(element,ctx,1);
        // And launch the thread if it isn't already running
        pthread_attr_init(&tattr);
        pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
        if (retryRunning == 0) {
          retryRunning = 1;
          _SFCB_TRACE(1,("--- Starting retryExport thread"));
          CMPIContext    *pctx = native_clone_CMPIContext(ctx);
          pthread_create(&t, &tattr, &retryExport, (void *) pctx);
        }
        CMRelease(ctxLocal);
      }
    }
    CMRelease(ind);
  }
  else {
    printf("--- ClassProvider: Invalid request %s\n", methodName);
    st.rc = CMPI_RC_ERR_METHOD_NOT_FOUND;
  }

  _SFCB_RETURN(st);
}
Esempio n. 15
0
CMPIStatus
IndCIMXMLHandlerCreateInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop,
                               const CMPIInstance *ci)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  CMPIArgs       *in,
                 *out = NULL;
  CMPIObjectPath *op;
  CMPIData        rv;
  unsigned short  persistenceType;

  _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerCreateInstance");

  if (interOpNameSpace(cop, &st) == 0)
    _SFCB_RETURN(st);

  internalProviderGetInstance(cop, &st);
  if (st.rc == CMPI_RC_ERR_FAILED)
    _SFCB_RETURN(st);
  if (st.rc == CMPI_RC_OK) {
    setStatus(&st, CMPI_RC_ERR_ALREADY_EXISTS, NULL);
    _SFCB_RETURN(st);
  }

  CMPIInstance   *ciLocal = CMClone(ci, NULL);
  memLinkInstance(ciLocal);
  CMPIObjectPath* copLocal = CMClone(cop, NULL);
  memLinkObjectPath(copLocal);

  setCCN(copLocal,ciLocal,"CIM_ComputerSystem");

  CMPIString *sysname=ciLocal->ft->getProperty(ciLocal,"SystemName",&st).value.string;
  if (sysname == NULL || sysname->hdl == NULL) {
    char hostName[512];
    hostName[0]=0;
    gethostname(hostName,511); /* should be the same as SystemName of IndicationService */
    CMAddKey(copLocal, "SystemName", hostName, CMPI_chars);
    CMSetProperty(ciLocal,"SystemName",hostName,CMPI_chars);
  }


  CMPIString     *dest =
      CMGetProperty(ciLocal, "destination", &st).value.string;
  if (dest == NULL || CMGetCharPtr(dest) == NULL) {
    setStatus(&st, CMPI_RC_ERR_FAILED,
              "Destination property not found; is required");
    CMRelease(ciLocal);
    _SFCB_RETURN(st);
  } else {                      /* if no scheme is given, assume http (as
                                 * req. for param by mof) */
    char           *ds = CMGetCharPtr(dest);
    if (strstr(ds, "://") == NULL) {
      char           *prefix = "http://";
      int             n = strlen(ds) + strlen(prefix) + 1;
      char           *newdest = (char *) malloc(n * sizeof(char));
      strcpy(newdest, prefix);
      strcat(newdest, ds);
      CMSetProperty(ciLocal, "destination", newdest, CMPI_chars);
      free(newdest);
    }
  }

  CMPIData        persistence =
      CMGetProperty(ciLocal, "persistencetype", &st);
  if (persistence.state == CMPI_nullValue
      || persistence.state == CMPI_notFound) {
    persistenceType = 2;        /* default is 2 = permanent */
  } else if (persistence.value.uint16 < 1 || persistence.value.uint16 > 3) {
    setStatus(&st, CMPI_RC_ERR_FAILED,
              "PersistenceType property must be 1, 2, or 3");
    CMRelease(ciLocal);
    _SFCB_RETURN(st);
  } else {
    persistenceType = persistence.value.uint16;
  }
  CMSetProperty(ciLocal, "persistencetype", &persistenceType, CMPI_uint16);

  if (CMClassPathIsA(_broker, copLocal, "cim_listenerdestination", NULL)) {
    //get the creation timestamp
    struct timeval  tv;
    struct timezone tz;
    char   context[100];
    gettimeofday(&tv, &tz);
    struct tm cttm;
    char * gtime = (char *) malloc(15 * sizeof(char));
    memset(gtime, 0, 15 * sizeof(char));
    if (gmtime_r(&tv.tv_sec, &cttm) != NULL) {
      strftime(gtime, 15, "%Y%m%d%H%M%S", &cttm);
    }

    // Even though reliable indications may be disabled, we need to do this 
    // in case it ever gets enabled.
    // Get the IndicationService name
    CMPIObjectPath * isop = CMNewObjectPath(_broker, "root/interop", "CIM_IndicationService", NULL);
    CMPIEnumeration * isenm = _broker->bft->enumerateInstances(_broker, ctx, isop, NULL, NULL);
    CMPIData isinst = CMGetNext(isenm, NULL);
    CMPIData mc = CMGetProperty(isinst.value.inst, "Name", NULL);

    // build the context string
    sprintf (context,"%s#%s#",mc.value.string->ft->getCharPtr(mc.value.string,NULL),gtime);
    CMPIValue scontext;
    scontext.string = sfcb_native_new_CMPIString(context, NULL, 0);
    free(gtime);

    // set the properties
    CMSetProperty(ciLocal, "SequenceContext", &scontext, CMPI_string);
    CMPIValue zarro = {.sint64 = -1 };
    CMSetProperty(ciLocal, "LastSequenceNumber", &zarro, CMPI_sint64);
  }

  CMPIString     *str = CDToString(_broker, copLocal, NULL);
  CMPIString     *ns = CMGetNameSpace(copLocal, NULL);
  _SFCB_TRACE(1,
              ("--- handler %s %s", (char *) ns->hdl, (char *) str->hdl));

  in = CMNewArgs(_broker, NULL);
  CMAddArg(in, "handler", &ciLocal, CMPI_instance);
  CMAddArg(in, "key", &copLocal, CMPI_ref);
  op = CMNewObjectPath(_broker, "root/interop",
                       "cim_indicationsubscription", &st);
  rv = CBInvokeMethod(_broker, ctx, op, "_addHandler", in, out, &st);

  if (st.rc == CMPI_RC_OK) {
    st = InternalProviderCreateInstance(NULL, ctx, rslt, copLocal, ciLocal);
  }
  else {
    rv=CBInvokeMethod(_broker,ctx,op,"_removeHandler",in,out,NULL);
  }

  _SFCB_RETURN(st);
}

CMPIStatus
IndCIMXMLHandlerModifyInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop,
                               const CMPIInstance *ci,
                               const char **properties)
{
  CMPIStatus      st = { CMPI_RC_ERR_NOT_SUPPORTED, NULL };
  _SFCB_ENTER(TRACE_INDPROVIDER, "IndCIMXMLHandlerSetInstance");
  _SFCB_RETURN(st);
}
Esempio n. 16
0
CMPIStatus
InternalProviderCreateInstance(CMPIInstanceMI * mi,
                               const CMPIContext *ctx,
                               const CMPIResult *rslt,
                               const CMPIObjectPath * cop,
                               const CMPIInstance *ci)
{
  CMPIStatus      st = { CMPI_RC_OK, NULL };
  unsigned long   len;
  void           *blob;
  CMPIString     *cn = CMGetClassName(cop, NULL);
  CMPIString     *ns = CMGetNameSpace(cop, NULL);
  char           *key = normalizeObjectPathCharsDup(cop);
  const char     *nss = ns->ft->getCharPtr(ns, NULL);
  const char     *cns = cn->ft->getCharPtr(cn, NULL);
  const char     *bnss = repositoryNs(nss);

  _SFCB_ENTER(TRACE_INTERNALPROVIDER, "InternalProviderCreateInstance");

  if (testNameSpace(bnss, &st) == 0) {
    free(key);
    _SFCB_RETURN(st);
  }

  CMPIConstClass *cc = getConstClass(nss, cns);
  /*
   * per DSP0004 2.5.2 
   */
  if (cc != NULL && cc->ft->isAbstract(cc) != 0) {
    CMPIStatus      st = { CMPI_RC_ERR_NOT_SUPPORTED, NULL };
    free(key);
    _SFCB_RETURN(st);
  }

  if (existingBlob(bnss, cns, key)) {
    CMPIStatus      st = { CMPI_RC_ERR_ALREADY_EXISTS, NULL };
    free(key);
    _SFCB_RETURN(st);
  }

  len = getInstanceSerializedSize(ci);
  blob = malloc(len + 64);
  getSerializedInstance(ci, blob);

  if (addBlob(bnss, cns, key, blob, (int) len)) {
    CMPIStatus      st = { CMPI_RC_ERR_FAILED, NULL };
    st.msg =
        sfcb_native_new_CMPIString("Unable to write to repository", NULL,
                                   0);
    free(blob);
    free(key);
    _SFCB_RETURN(st);
  }
  free(blob);

  if (rslt) {
    CMReturnObjectPath(rslt, cop);
  }

  free(key);
  _SFCB_RETURN(st);
}
Esempio n. 17
0
CMPIString     *
__eft_getString(const CMPISelectExp *exp, CMPIStatus *rc)
{
  NativeSelectExp *e = (NativeSelectExp *) exp;
  return sfcb_native_new_CMPIString(e->queryString, rc, 0);
}
Esempio n. 18
0
int
cls2xml(CMPIConstClass * cls, UtilStringBuffer * sb, unsigned int flags)
{
  ClClass        *cl = (ClClass *) cls->hdl;
  int             i,
                  m,
                  q,
                  qm,
                  p,
                  pm;
  char           *type,
                 *superCls;
  CMPIString     *name,
                 *qname,
                 *refName;
  CMPIData        data,
                  qdata;
  CMPIType        mtype;
  unsigned long   quals;
  UtilStringBuffer *qsb = UtilFactory->newStrinBuffer(1024);

  _SFCB_ENTER(TRACE_CIMXMLPROC, "cls2xml");

  SFCB_APPENDCHARS_BLOCK(sb, "<CLASS NAME=\"");
  sb->ft->appendChars(sb, cls->ft->getCharClassName(cls));
  superCls = (char *) cls->ft->getCharSuperClassName(cls);
  if (superCls) {
    SFCB_APPENDCHARS_BLOCK(sb, "\" SUPERCLASS=\"");
    sb->ft->appendChars(sb, superCls);
  }
  SFCB_APPENDCHARS_BLOCK(sb, "\">\n");
  if (flags & FL_includeQualifiers)
    quals2xml(cl->quals, sb);

  if (flags & FL_includeQualifiers)
    for (i = 0, m = ClClassGetQualifierCount(cl); i < m; i++) {
      data = cls->ft->getQualifierAt(cls, i, &name, NULL);
      DATA2XML(&data, cls, name, NULL, "<QUALIFIER NAME=\"",
               "</QUALIFIER>\n", sb, NULL, 0, 0);
    }

  for (i = 0, m = ClClassGetPropertyCount(cl); i < m; i++) {
    qsb->ft->reset(qsb);
    data = getPropertyQualsAt(cls, i, &name, &quals, &refName, NULL);
    if (flags & FL_includeQualifiers)
      quals2xml(quals << 8, qsb);
    if (flags & FL_includeQualifiers)
      for (q = 0, qm = ClClassGetPropQualifierCount(cl, i); q < qm; q++) {
        qdata = internalGetPropQualAt(cls, i, q, &qname, NULL);
        DATA2XML(&qdata, cls, qname, NULL, "<QUALIFIER NAME=\"",
                 "</QUALIFIER>\n", qsb, NULL, 0, 0);
        CMRelease(qname);
        sfcb_native_release_CMPIValue(qdata.type, &qdata.value);
      }
    if (data.type & CMPI_ARRAY)
      DATA2XML(&data, cls, name, NULL, "<PROPERTY.ARRAY NAME=\"",
               "</PROPERTY.ARRAY>\n", sb, qsb, 0, 0);
    else {
      type = dataType(data.type);
      if (*type == '*') {
        DATA2XML(&data, cls, name, refName, "<PROPERTY.REFERENCE NAME=\"",
                 "</PROPERTY.REFERENCE>\n", sb, qsb, 0, 0);
      } else
        DATA2XML(&data, cls, name, NULL, "<PROPERTY NAME=\"",
                 "</PROPERTY>\n", sb, qsb, 0, 0);
    }
    CMRelease(name);
  }

  for (i = 0, m = ClClassGetMethodCount(cl); i < m; i++) {
    ClMethod       *meth;
    ClParameter    *parm;
    char           *sname,
                   *smname;
    CMPIString     *name,
                   *mname;

    qsb->ft->reset(qsb);
    ClClassGetMethodAt(cl, i, &mtype, &smname, &quals);
    mname = sfcb_native_new_CMPIString(smname, NULL, 2);
    meth = ((ClMethod *) ClObjectGetClSection(&cl->hdr, &cl->methods)) + i;

    if (flags & FL_includeQualifiers) {
      for (q = 0, qm = ClClassGetMethQualifierCount(cl, i); q < qm; q++) {
        ClClassGetMethQualifierAt(cl, meth, q, &qdata, &sname);
        name = sfcb_native_new_CMPIString(sname, NULL, 2);
        DATA2XML(&qdata, cls, name, NULL, "<QUALIFIER NAME=\"",
                 "</QUALIFIER>\n", qsb, NULL, 0, 0);
      }
    }

    for (p = 0, pm = ClClassGetMethParameterCount(cl, i); p < pm; p++) {
      CMPIParameter   pdata;
      ClClassGetMethParameterAt(cl, meth, p, &pdata, &sname);
      name = sfcb_native_new_CMPIString(sname, NULL, 2);
      parm = ((ClParameter *)
              ClObjectGetClSection(&cl->hdr, &meth->parameters)) + p;
      param2xml(&pdata, cls, parm, name, qsb, flags);
    }

    method2xml(mtype, mname, "<METHOD NAME=\"", "</METHOD>\n", sb, qsb);
  }

  SFCB_APPENDCHARS_BLOCK(sb, "</CLASS>\n");

  qsb->ft->release(qsb);

  _SFCB_RETURN(0);
}
Esempio n. 19
0
CMPIValue
str2CMPIValue(CMPIType type, XtokValue val, XtokValueReference * ref,
              char *ns, CMPIStatus *status)
{
  CMPIValue       value;
  CMPIType        t = 0;
  CMPIStatus rc = {CMPI_RC_OK, NULL};

  if (type == 0) {
    type = guessType(val.value);
  }

  if (type & CMPI_ARRAY) {
    /*
     * array type received -- needs special handling 
     */
    int             i,
                    max;
    CMPIValue       v;
    XtokValueArray *arr = (XtokValueArray *) ref;
    XtokValueRefArray *refarr = (XtokValueRefArray *) arr;
    max = arr->next;
    if ((type & CMPI_ref) == CMPI_ref) {
      t = CMPI_ref;
    } else if (type & ~CMPI_ARRAY) {
      t = type & ~CMPI_ARRAY;
    } else {
      /*
       * the guess type can go wrong 
       */
      if (max > 0) {
        t = guessType(arr->values[0].value);
      }
    }
    /*
     * build an array by looping thru the elements 
     */
    value.array = TrackedCMPIArray(max, t, NULL);
    if (value.array != NULL) {
      for (i = 0; i < max; i++) {
        v = str2CMPIValue(t, arr->values[i], refarr->values + i, ns, &rc);
        CMSetArrayElementAt(value.array, i, &v, t);
      }
      return value;
    }
  }

  /* Feature 75543 - set and return status->rc on failures */
  switch (type) {
  case CMPI_char16:
    value.char16 = *val.value;
    break;
  case CMPI_string:
    value.string = sfcb_native_new_CMPIString(val.value, NULL, 0);
    break;
  case CMPI_sint64:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%lld", &value.sint64);
    break;
  case CMPI_uint64:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%llu", &value.uint64);
    break;
  case CMPI_sint32:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%d", &value.sint32);
    break;
  case CMPI_uint32:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%u", &value.uint32);
    break;
  case CMPI_sint16:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%hd", &value.sint16);
    break;
  case CMPI_uint16:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%hu", &value.uint16);
    break;
  case CMPI_uint8:
    if (invalid_uint(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       sscanf(val.value, "%u", &value.uint32);
       value.uint8 = value.uint32;
    }
    break;
  case CMPI_sint8:
    if (invalid_int(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       sscanf(val.value, "%d", &value.sint32);
       value.sint8 = value.sint32;
    }
    break;
  case CMPI_boolean:
    if (invalid_boolean(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else {
       value.boolean = strcasecmp(val.value, "false");
       if (value.boolean)
         value.boolean = 1;
    }
    break;
  case CMPI_real32:
    if (invalid_real(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%f", &value.real32);
    break;
  case CMPI_real64:
    if (invalid_real(val.value, type))
       status->rc = CMPI_RC_ERR_INVALID_PARAMETER;
    else sscanf(val.value, "%lf", &value.real64);
    break;
  case CMPI_dateTime:
    value.dateTime =
        sfcb_native_new_CMPIDateTime_fromChars(val.value, NULL);
    break;
  case CMPI_ref:
    getKeyValueTypePtr("ref", NULL, ref, &value, &t, ns);
    break;
  case CMPI_instance:
    value = makeFromEmbeddedObject(val, ns);
    break;
  default:
    mlogf(M_ERROR, M_SHOW, "%s(%d): invalid value %d-%p\n", __FILE__,
          __LINE__, (int) type, val);
    abort();
  }
  return value;
}