|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T c
Length: 18124 (0x46cc) Types: TextFile Names: »cmis.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z« └─⟦d846658bd⟧ └─⟦this⟧ »osimis/smap/cmis.c«
/* * Copyright (c) 1988 University College London * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the Department of Computer Science, University College London. * The name of the University may not be used to * endorse or promote products derived from this software without * specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* implements the CMIS/P side for client processes */ /* * By George Pavlou, October 1988 */ #include <stdio.h> #include <isode/rosap.h> #include "msap.h" #include "objectS.h" #include "config.h" static char *context = "management"; static char *service = "SMA"; OID objtype2class(); MO_ID *objid2inst(); int m_init (host) char *host; { struct MSAPconnect mcs; struct MSAPindication mis; AEI aei; struct PSAPaddr *pa; if ((aei = str2aei(host, service)) == NULLAEI) { advise(NULLCP, "%s-%s: unknown application entity title", host, service); return NOTOK; } if ((pa = aei2addr(aei)) == NULLPA) { advise(NULLCP, "aei translation failed"); return NOTOK; } if (M_InitialiseReq(NULLAEI, NULLPA, aei, pa, context, 0x1, 0x0, NULLEXTERN, NULLEXTERN, &mcs, &mis) == NOTOK) { if (mis.mi_abort.ma_reason == ACS_TRANSIENT) advise(NULLCP, "Remote SMA is busy, try later..."); else advise(NULLCP, "M_InitialiseRequest: %s", mis.mi_abort.ma_data); mifree(&mis); return NOTOK; } quipu_syntaxes(); load_oid_table(strcat(ETCDIR, "oidtable")); mcfree(&mcs); return (mcs.mc_sd); } int m_term (msd) int msd; { struct MSAPindication mis; if (M_TerminateReq(msd, ACF_NORMAL, NULLPE, &mis) != OK) { advise(NULLCP, "Terminate request failed: reason = %s", mis.mi_abort.ma_data); return NOTOK; } return OK; } close_connections (msd, nofhosts) int msd[], nofhosts; { int i; for (i = 0; i < nofhosts; i++) if (msd[i] > 0) m_term (msd[i]); } /* Request Subordinate Object List */ int SubordinateListGetRequest (objtype, objinst, msd, reqid) int objtype, msd, reqid; MO_ID * objinst; { struct MSAPindication mis; MIDent class, attr; MName inst; attr.mid_type = MID_LOCAL; attr.mid_local = 1; /* subordinateObjectIdList */ class.mid_type = MID_GLOBAL; class.mid_global = objtype2class(objtype); inst.mn_type = MN_DN; inst.mn_dn = moid2dn(objinst); if (M_Get(msd, reqid, &class, &inst, NULLSCOPE, NULLFILTER, NULLACCESS, s_bestEffort, 1, &attr, &mis) == NOTOK) { advise(NULLCP, "M_Get failed - reason: %s", mis.mi_preject.mr_data); return NOTOK; } oid_free(class.mid_global); dn_free(inst.mn_dn); return OK; } /* Request ManagedObject attributes */ int ManagedObjectGetRequest (objtype, objinst, msd, reqid) int objtype, msd, reqid; MO_ID *objinst; { struct MSAPindication mis; MIDent class, attrs[M_MAXATTRS]; MName inst; int i; switch (objtype) { case M_SYSTEM: for (i = 0; i <= MSYS_ATTRS; i++) { attrs[i].mid_type = MID_LOCAL; attrs[i].mid_local = i+1; } break; case T_SUBSYS: i = 0; attrs[i].mid_type = MID_LOCAL; attrs[i++].mid_local = 1; break; case T_ENTITY: attrs[0].mid_type = MID_LOCAL; attrs[0].mid_local = 1; /* don't request boundNSAP and SupportedTSAPs */ for (i = 1; i <= TENT_ATTRS; i++) { attrs[i].mid_type = MID_LOCAL; attrs[i].mid_local = i+3; } break; case T_EINV: for (i = 0; i <= EINV_ATTRS; i++) { attrs[i].mid_type = MID_LOCAL; attrs[i].mid_local = i+1; } break; case T_CEPT: for (i = 0; i <= CEPT_ATTRS; i++) { attrs[i].mid_type = MID_LOCAL; attrs[i].mid_local = i+1; } break; case C_THLD: for (i = 0; i < CTHLD_ATTRS; i++) { attrs[i].mid_type = MID_LOCAL; attrs[i].mid_local = i+2; } break; case G_THLD: for (i = 0; i < GTHLD_ATTRS; i++) { attrs[i].mid_type = MID_LOCAL; attrs[i].mid_local = i+2; } break; case RPCTL: for (i = 0; i < RPCTL_ATTRS; i++) { attrs[i].mid_type = MID_LOCAL; attrs[i].mid_local = i+2; } break; default: advise(NULLCP, "ManagedObjectGetRequest: unknown objtype %d", objtype); return NOTOK; } class.mid_type = MID_GLOBAL; class.mid_global = objtype2class(objtype); inst.mn_type = MN_DN; inst.mn_dn = moid2dn(objinst); if (M_Get(msd, reqid, &class, &inst, NULLSCOPE, NULLFILTER, NULLACCESS, s_bestEffort, i, attrs, &mis) == NOTOK) { advise(NULLCP, "M_Get failed - reason: %s", mis.mi_preject.mr_data); return NOTOK; } oid_free(class.mid_global); dn_free(inst.mn_dn); return OK; } /* Set reports */ int ReportSetRequest (rcid, modify, msd) int rcid, msd; ModifyOp modify; { struct MSAPindication mis; MIDent class; MName inst; MO_ID * moid; DN dn; CMISparam attr; struct destinationS dest; if (rcid == 1) { /* RPCTL below M_SYSTEM */ if ((moid = objid2inst(RPCTL, rcid)) == (MO_ID *) NULL) { advise(NULLCP, "out of core"); return NOTOK; } } else /* RPCTL below T_ENTITY */ if ((moid = objid2inst(RPCTL, ISODE, rcid)) == (MO_ID *) NULL) { advise(NULLCP, "out of core"); return NOTOK; } inst.mn_type = MN_DN; inst.mn_dn = moid2dn(moid); moid_free(moid); class.mid_type = MID_GLOBAL; class.mid_global = objtype2class(RPCTL); attr.mp_id.mid_type = MID_LOCAL; attr.mp_id.mid_local = 2; /* reportDestinations */ attr.mp_modify = modify; dest.type = RCI_DEST_FD; /* this association */ if (build_MIB_ReportDestination(&attr.mp_val, 1, NULLIP, NULLVP, &dest) == NOTOK) return NOTOK; /* the request id is always set equal to rcid */ if (M_Set(msd, rcid, &class, &inst, NULLSCOPE, NULLFILTER, NULLACCESS, s_bestEffort, 1, &attr, &mis) == NOTOK ) { advise(NULLCP, "M_Set failed - reason: %s", mis.mi_preject.mr_data); return NOTOK; } oid_free(class.mid_global); dn_free(inst.mn_dn); return OK; } /* parse ManagedSystem attributes */ ManagedSystemS *parseManagedSystem (attrs) CMISparam *attrs; { ManagedSystemS *Msys; if ((Msys = (ManagedSystemS *) calloc(1, sizeof(ManagedSystemS))) == (ManagedSystemS *) NULL) { advise(NULLCP, "parseManagedSystem: out of core"); return ((ManagedSystemS *) NULL); } if (attrs[1].mp_id.mid_local != 2) { advise(NULLCP, "parseManagedSystem: attribute mismatch"); cfree((char*) Msys); return ((ManagedSystemS *) NULL); } if (attrs[1].mp_val->pe_id == PE_DEFN_UTCT) Msys->systemCreationTime = *prim2utct(attrs[1].mp_val); /*structcpy*/ else Msys->systemCreationTime.ut_year = -1; return (Msys); } /* parse T-LayerEntity attributes */ T_LayerEntityS *parseTLayerEntity (attrs) CMISparam *attrs; { T_LayerEntityS *Tent; char *calloc(); int i; if ((Tent = (T_LayerEntityS *) calloc(1, sizeof(T_LayerEntityS))) == (T_LayerEntityS *) NULL) { advise(NULLCP, "parseTLayerEntity: out of core"); return ((T_LayerEntityS *) NULL); } for (i = 1; i <= TENT_ATTRS; i++) if (attrs[i].mp_id.mid_local != i+3) { advise(NULLCP, "parseTLayerEntity: attribute mismatch"); cfree((char*) Tent); return ((T_LayerEntityS *) NULL); } /* the following two attributes are not supported at present */ /* if (parse_MIB_NAddress(attrs[1].mp_val, 1, NULLIP, &cp, NULLCP) == NOTOK) Tent->boundNSAP[0] = '\0'; else strncpy(Tent->boundNSAP, cp, NADDRLEN); if (parse_MIB_TAddressList(attrs[2].mp_val, 1, NULLIP, NULLVP, &Tent->supportedTSAPs) == NOTOK) Tent->supportedTSAPs = (TSAPs *) NULL; */ if (parse_MIB_Gauge(attrs[1].mp_val, 1, NULLIP, NULLVP, &Tent->activeEntityInvocations) == NOTOK) Tent->activeEntityInvocations = -1; if (parse_MIB_Gauge(attrs[2].mp_val, 1, NULLIP, NULLVP, &Tent->activeConnections) == NOTOK) Tent->activeConnections = -1; if (parse_MIB_Counter(attrs[3].mp_val, 1, NULLIP, NULLVP, &Tent->previousConnections) == NOTOK) Tent->previousConnections = -1; if (parse_MIB_Counter(attrs[4].mp_val, 1, NULLIP, NULLVP, &Tent->crTPDUSuccessfulIn) == NOTOK) Tent->crTPDUSuccessfulIn = -1; if (parse_MIB_Counter(attrs[5].mp_val, 1, NULLIP, NULLVP, &Tent->crTPDUSuccessfulOut) == NOTOK) Tent->crTPDUSuccessfulOut = -1; if (parse_MIB_Counter(attrs[6].mp_val, 1, NULLIP, NULLVP, &Tent->crTPDUUnsuccessfulIn) == NOTOK) Tent->crTPDUUnsuccessfulIn = -1; if (parse_MIB_Counter(attrs[7].mp_val, 1, NULLIP, NULLVP, &Tent->crTPDUUnsuccessfulOut) == NOTOK) Tent->crTPDUUnsuccessfulOut = -1; if (parse_MIB_Counter(attrs[8].mp_val, 1, NULLIP, NULLVP, &Tent->crTPDUCongestion) == NOTOK) Tent->crTPDUCongestion = -1; if (parse_MIB_Counter(attrs[9].mp_val, 1, NULLIP, NULLVP, &Tent->crTPDUConfigurationError) == NOTOK) Tent->crTPDUConfigurationError = -1; if (parse_MIB_Counter(attrs[10].mp_val, 1, NULLIP, NULLVP, &Tent->tProtocolError) == NOTOK) Tent->tProtocolError = -1; if (parse_MIB_Counter(attrs[11].mp_val, 1, NULLIP, NULLVP, &Tent->tPDUChecksumError) == NOTOK) Tent->tPDUChecksumError = -1; if (parse_MIB_Counter(attrs[12].mp_val, 1, NULLIP, NULLVP, &Tent->numberTPDUSent) == NOTOK) Tent->numberTPDUSent = -1; if (parse_MIB_Counter(attrs[13].mp_val, 1, NULLIP, NULLVP, &Tent->numberTPDUReceived) == NOTOK) Tent->numberTPDUReceived = -1; if (parse_MIB_Counter(attrs[14].mp_val, 1, NULLIP, NULLVP, &Tent->numberTPDURetransmitted) == NOTOK) Tent->numberTPDURetransmitted = -1; return (Tent); } /* parse T-EntityInvocation attributes */ T_EntityInvocationS *parseTEntityInvocation (attrs) CMISparam *attrs; { T_EntityInvocationS *Einv; int i; if ((Einv = (T_EntityInvocationS*) calloc(1, sizeof(T_EntityInvocationS))) == (T_EntityInvocationS *) NULL) { advise(NULLCP, "parseTEntityInvocation: out of core"); return ((T_EntityInvocationS *) NULL); } for (i = 1; i <= EINV_ATTRS; i++) if (attrs[i].mp_id.mid_local != i+1) { advise(NULLCP, "parseTEntityInvocation: attribute mismatch"); cfree((char*) Einv); return ((T_EntityInvocationS *) NULL); } if (attrs[1].mp_val->pe_id == PE_DEFN_UTCT) Einv->creationTime = *prim2utct(attrs[1].mp_val); /* struct copy */ else Einv->creationTime.ut_year = -1; if (parse_MIB_Gauge(attrs[2].mp_val, 1, NULLIP, NULLVP, &Einv->activeConnections) == NOTOK) Einv->activeConnections = -1; if (parse_MIB_Counter(attrs[3].mp_val, 1, NULLIP, NULLVP, &Einv->crTPDUSuccessfulIn) == NOTOK) Einv->crTPDUSuccessfulIn = -1; if (parse_MIB_Counter(attrs[4].mp_val, 1, NULLIP, NULLVP, &Einv->crTPDUSuccessfulOut) == NOTOK) Einv->crTPDUSuccessfulOut = -1; if (parse_MIB_Counter(attrs[5].mp_val, 1, NULLIP, NULLVP, &Einv->crTPDUUnsuccessfulIn) == NOTOK) Einv->crTPDUUnsuccessfulIn = -1; if (parse_MIB_Counter(attrs[6].mp_val, 1, NULLIP, NULLVP, &Einv->crTPDUUnsuccessfulOut) == NOTOK) Einv->crTPDUUnsuccessfulOut = -1; if (parse_MIB_Counter(attrs[7].mp_val, 1, NULLIP, NULLVP, &Einv->crTPDUCongestion) == NOTOK) Einv->crTPDUCongestion = -1; if (parse_MIB_Counter(attrs[8].mp_val, 1, NULLIP, NULLVP, &Einv->crTPDUConfigurationError) == NOTOK) Einv->crTPDUConfigurationError = -1; if (parse_MIB_Counter(attrs[9].mp_val, 1, NULLIP, NULLVP, &Einv->tProtocolError) == NOTOK) Einv->tProtocolError = -1; if (parse_MIB_Counter(attrs[10].mp_val, 1, NULLIP, NULLVP, &Einv->tPDUChecksumError) == NOTOK) Einv->tPDUChecksumError = -1; return (Einv); } /* parse T-ConnectionEndpoint attributes */ T_ConnectionEndpointS *parseTConnectionEndpoint (attrs) CMISparam *attrs; { T_ConnectionEndpointS *Cept; int i; if ((Cept = (T_ConnectionEndpointS *) calloc(1, sizeof(T_ConnectionEndpointS))) == (T_ConnectionEndpointS *) NULL) { advise(NULLCP, "parseTConnectionEndpoint: out of core"); return ((T_ConnectionEndpointS *) NULL); } for (i = 1; i <= CEPT_ATTRS; i++) if (attrs[i].mp_id.mid_local != i+1) { advise(NULLCP, "parseTConnectionEndpoint: attribute mismatch"); cfree((char*) Cept); return ((T_ConnectionEndpointS *) NULL); } if (attrs[1].mp_val->pe_id == PE_DEFN_UTCT) Cept->creationTime = *prim2utct(attrs[1].mp_val); /* struct copy */ else Cept->creationTime.ut_year = -1; if (parse_MIB_TAddress(attrs[2].mp_val, 1, NULLIP, NULLVP, &Cept->sourceTAddr) == NOTOK) Cept->sourceTAddr.tsel_len = -1; if (parse_MIB_TAddress(attrs[3].mp_val, 1, NULLIP, NULLVP, &Cept->destTAddr) == NOTOK) Cept->destTAddr.tsel_len = -1; if (parse_MIB_Counter(attrs[4].mp_val, 1, NULLIP, NULLVP, &Cept->numberTPDUSent) == NOTOK) Cept->numberTPDUSent = -1; if (parse_MIB_Counter(attrs[5].mp_val, 1, NULLIP, NULLVP, &Cept->numberTPDUReceived) == NOTOK) Cept->numberTPDUReceived = -1; if (parse_MIB_Counter(attrs[6].mp_val, 1, NULLIP, NULLVP, &Cept->numberTPDURetransmitted) == NOTOK) Cept->numberTPDURetransmitted = -1; if (parse_MIB_Counter(attrs[7].mp_val, 1, NULLIP, NULLVP, &Cept->numberBytesSent) == NOTOK) Cept->numberBytesSent = -1; if (parse_MIB_Counter(attrs[8].mp_val, 1, NULLIP, NULLVP, &Cept->numberBytesReceived) == NOTOK) Cept->numberBytesReceived = -1; if (parse_MIB_Counter(attrs[9].mp_val, 1, NULLIP, NULLVP, &Cept->numberBytesRetransmitted) == NOTOK) Cept->numberBytesRetransmitted = -1; if (parse_MIB_TProtocolState(attrs[10].mp_val, 1, NULLIP, NULLVP, &Cept->tProtocol) == NOTOK) Cept->tProtocol = undefined; return (Cept); } /* parse CounterThreshold attributes */ C_ThresholdS *parseCounterThreshold (attrs) CMISparam *attrs; { C_ThresholdS *Cthld; int i; if ((Cthld = (C_ThresholdS *) calloc(1, sizeof(C_ThresholdS))) == (C_ThresholdS *) NULL) { advise(NULLCP, "parseCounterThreshold: out of core"); return ((C_ThresholdS *) NULL); } for (i = 0; i < CTHLD_ATTRS; i++) if (attrs[i].mp_id.mid_local != i+2) { advise(NULLCP, "parseCounterThreshold: attribute mismatch"); cfree((char*) Cthld); return ((C_ThresholdS *) NULL); } if (parse_MIB_ComparisonLevels(attrs[0].mp_val, 1, NULLIP, NULLVP, Cthld->compLevels) == NOTOK) Cthld->compLevels[0] = -1; if (parse_MIB_OffsetValue(attrs[1].mp_val, 1, NULLIP, NULLVP, &Cthld->offsetValue) == NOTOK) Cthld->offsetValue = -1; if (parse_MIB_OnoffSwitch(attrs[2].mp_val, 1, NULLIP, NULLVP, &Cthld->onoffSwitch) == NOTOK) Cthld->onoffSwitch = -1; return (Cthld); } /* parse GaugeThreshold attributes */ G_ThresholdS *parseGaugeThreshold (attrs) CMISparam *attrs; { G_ThresholdS *Gthld; int i; if ((Gthld = (G_ThresholdS *) calloc(1, sizeof(G_ThresholdS))) == (G_ThresholdS *) NULL) { advise(NULLCP, "parseGaugeThreshold: out of core"); return ((G_ThresholdS *) NULL); } for (i = 0; i < GTHLD_ATTRS; i++) if (attrs[i].mp_id.mid_local != i+2) { advise(NULLCP, "parseGaugeThreshold: attribute mismatch"); cfree((char*) Gthld); return ((G_ThresholdS *) NULL); } if (parse_MIB_ComparisonLevels(attrs[0].mp_val, 1, NULLIP, NULLVP, Gthld->compLevels) == NOTOK) Gthld->compLevels[0] = -1; if (parse_MIB_HysteresisInterval(attrs[1].mp_val, 1, NULLIP, NULLVP, &Gthld->hysterInterval) == NOTOK) Gthld->hysterInterval = -1; if (parse_MIB_OnoffSwitch(attrs[2].mp_val, 1, NULLIP, NULLVP, &Gthld->onoffSwitch) == NOTOK) Gthld->onoffSwitch = -1; return (Gthld); } /* parse ReportControl attributes */ ReportControlS *parseReportControl (attrs) CMISparam *attrs; { ReportControlS *Rpctl; if ((Rpctl = (ReportControlS *) calloc(1, sizeof(ReportControlS))) == (ReportControlS *) NULL) { advise(NULLCP, "parseReportControl: out of core"); return ((ReportControlS *) NULL); } if (attrs[0].mp_id.mid_local != 2) { advise(NULLCP, "parseReportControl: attribute mismatch"); cfree((char*) Rpctl); return ((ReportControlS *) NULL); } if (parse_MIB_ReportDestinationList(attrs[0].mp_val, 1, NULLIP, NULLVP, &Rpctl->listofdests) == NOTOK) Rpctl->listofdests = ((destinationS *) NULL); return (Rpctl); } /* parse ManagedObject attributes */ int parseManagedObject (mobj, attrs) ManagedObjectS *mobj; CMISparam *attrs; { switch (mobj->type) { case M_SYSTEM: if ((mobj->msys = parseManagedSystem(attrs)) == (ManagedSystemS *) NULL) return NOTOK; break; case T_SUBSYS: break; /* T_LayerSubsystem has got no attributes */ case T_ENTITY: if ((mobj->tent = parseTLayerEntity(attrs)) == (T_LayerEntityS *) NULL) return NOTOK; break; case T_EINV: if ((mobj->einv = parseTEntityInvocation(attrs)) == (T_EntityInvocationS *) NULL) return NOTOK; break; case T_CEPT: if ((mobj->cept = parseTConnectionEndpoint(attrs)) == (T_ConnectionEndpointS *) NULL) return NOTOK; break; case C_THLD: if ((mobj->cthld = parseCounterThreshold(attrs)) == (C_ThresholdS *) NULL) return NOTOK; break; case G_THLD: if ((mobj->gthld = parseGaugeThreshold(attrs)) == (G_ThresholdS *) NULL) return NOTOK; break; case RPCTL: if ((mobj->rpctl = parseReportControl(attrs)) == (ReportControlS *) NULL) return NOTOK; break; default: advise(NULLCP, "parseManagedObject: unknown objtype %d", mobj->type); return NOTOK; } return OK; }