|
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 a
Length: 15434 (0x3c4a) Types: TextFile Names: »attrs.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0 └─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z« └─⟦d846658bd⟧ └─⟦this⟧ »osimis/smap/attrs.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. */ /* transforms managed objects to attribute lists for display in osimic */ /* * By George Pavlou, October 1988 */ #include <stdio.h> #include "isode/rosap.h" #include "msap.h" #include "microscope.h" extern char *errmsg[]; static char *mobj_names [] = { "ManagedSystem", "T-LayerSubsystem", "T-LayerEntity", "T-EntityInvocation", "T-ConnectionEndpoint", "CounterThreshold", "GaugeThreshold", "ReportControl" }; AttrPairs *subords2attrpairs (subords, error) MO_ID *subords; Error *error; { MO_ID *rdn = subords; AttrPairs *attrs, *tattr; if (subords == (MO_ID *) NULL) { error->err_type = noSubordinateObjects; sprintf(error->err_msg, "%s", errmsg[3]); return ((AttrPairs *) NULL); } if ((tattr = attrs = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } while (rdn != (MO_ID *) NULL) { /* write attr type */ sprintf(tattr->attr_type, "%-30.30s", mobj_names[rdn2type(rdn)]); /* write attr value */ if (rdn->rdnlen == 0) /* Null */ strcpy(tattr->attr_value, "null"); else if (rdn->rdnval[0] == 0) { /* Integer */ int i; bcopy(&rdn->rdnval[1], &i, sizeof(int)); sprintf(tattr->attr_value, "%d", i); } else if (rdn->rdnval[0] == 1) { /* Ia5String */ strncpy(tattr->attr_value, &rdn->rdnval[1], 9); tattr->attr_value[9] = '\0'; /* in case rdnval is 9 chars */ } if ((rdn = rdn->Next) == (MO_ID *) NULL) break; if ((tattr = tattr->Next = (AttrPairs *) calloc(1,sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } } return (attrs); } static char *msys_attrs [] = { "systemCreationTime" }; AttrPairs *ManagedSystem2attrpairs (Msys, error) ManagedSystemS *Msys; Error *error; { AttrPairs *attrs, *tattr; if ((tattr = attrs = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } sprintf(tattr->attr_type, "%-30.30s", msys_attrs[0]); sprintf(tattr->attr_value,"%s", utct2disptime(&Msys->systemCreationTime)); return (attrs); } /* ARGSUSED */ AttrPairs *T_LayerSubsystem2attrpairs (Tsubsys, error) T_LayerSubsystemS *Tsubsys; Error *error; { error->err_type = noAttributes; sprintf(error->err_msg, "%s", errmsg[5]); return ((AttrPairs *) NULL); } static char *tent_attrs [] = { "activeEntityInvocations", "activeConnections", "previousConnections", "crTPDUSuccessfulIn", "crTPDUSuccessfulOut", "crTPDUUnsuccessfulIn", "crTPDUUnsuccessfulOut", "crTPDUCongestion", "crTPDUConfigurationError", "tProtocolError", "tPDUChecksumError", "numberTPDUSent", "numberTPDUReceived", "numberTPDURetransmitted" }; AttrPairs *T_LayerEntity2attrpairs (Tent, error) T_LayerEntityS *Tent; Error *error; { AttrPairs *attrs, *tattr; int attrno = 0; if ((tattr = attrs = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } while (attrno < TENT_ATTRS) { sprintf(tattr->attr_type, "%-30.30s", tent_attrs[attrno++]); if (attrno == TENT_ATTRS) break; if ((tattr = tattr->Next = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } } sprintf((tattr = attrs) -> attr_value, "%d", Tent->activeEntityInvocations); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->activeConnections); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->previousConnections); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->crTPDUSuccessfulIn); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->crTPDUSuccessfulOut); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->crTPDUUnsuccessfulIn); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->crTPDUUnsuccessfulOut); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->crTPDUCongestion); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->crTPDUConfigurationError); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->tProtocolError); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->tPDUChecksumError); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->numberTPDUSent); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->numberTPDUReceived); sprintf((tattr = tattr->Next) -> attr_value, "%d", Tent->numberTPDURetransmitted); return (attrs); } static char *einv_attrs [] = { "creationTime", "activeConnections", "crTPDUSuccessfulIn", "crTPDUSuccessfulOut", "crTPDUUnsuccessfulIn", "crTPDUUnsuccessfulOut", "crTPDUCongestion", "crTPDUConfigurationError", "tProtocolError", "tPDUChecksumError" }; AttrPairs *T_EntityInvoc2attrpairs (Einv, error) T_EntityInvocationS *Einv; Error *error; { AttrPairs *attrs, *tattr; int attrno = 0; if ((tattr = attrs = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } while (attrno < EINV_ATTRS) { sprintf(tattr->attr_type, "%-30.30s", einv_attrs[attrno++]); if (attrno == EINV_ATTRS) break; if ((tattr = tattr->Next = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } } sprintf((tattr = attrs) -> attr_value, "%s", utct2disptime(&Einv->creationTime)); sprintf((tattr = tattr->Next) -> attr_value, "%d", Einv->activeConnections); sprintf((tattr = tattr->Next) -> attr_value, "%d", Einv->crTPDUSuccessfulIn); sprintf((tattr = tattr->Next) -> attr_value, "%d", Einv->crTPDUSuccessfulOut); sprintf((tattr = tattr->Next) -> attr_value, "%d", Einv->crTPDUUnsuccessfulIn); sprintf((tattr = tattr->Next) -> attr_value, "%d", Einv->crTPDUUnsuccessfulOut); sprintf((tattr = tattr->Next) -> attr_value, "%d", Einv->crTPDUCongestion); sprintf((tattr = tattr->Next) -> attr_value, "%d", Einv->crTPDUConfigurationError); sprintf((tattr = tattr->Next) -> attr_value, "%d", Einv->tProtocolError); sprintf((tattr = tattr->Next) -> attr_value, "%d", Einv->tPDUChecksumError); return (attrs); } static char *cept_attrs [] = { "creationTime", "sourceTAddress", "destinationTAddress", "numberTPDUSent", "numberTPDUReceived", "numberTPDURetransmitted", "numberBytesSent", "numberBytesReceived", "numberBytesRetransmitted", "tProtocol" }; AttrPairs *T_ConnectionEpt2attrpairs (Cept, error) T_ConnectionEndpointS *Cept; Error *error; { AttrPairs *attrs, *tattr; int attrno = 0; if ((tattr = attrs = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } while (attrno < CEPT_ATTRS) { sprintf(tattr->attr_type, "%-30.30s", cept_attrs[attrno++]); if (attrno == CEPT_ATTRS) break; if ((tattr = tattr->Next = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } } sprintf((tattr = attrs) -> attr_value, "%s", utct2disptime(&Cept->creationTime)); sprintf((tattr = tattr->Next) -> attr_value, "%.5s %.25s", Cept->sourceTAddr.tsel, Cept->sourceTAddr.naddr); sprintf((tattr = tattr->Next) -> attr_value, "%.5s %.25s", Cept->destTAddr.tsel, Cept->destTAddr.naddr); sprintf((tattr = tattr->Next) -> attr_value, "%d", Cept->numberTPDUSent); sprintf((tattr = tattr->Next) -> attr_value, "%d", Cept->numberTPDUReceived); sprintf((tattr = tattr->Next) -> attr_value, "%d", Cept->numberTPDURetransmitted); sprintf((tattr = tattr->Next) -> attr_value, "%d", Cept->numberBytesSent); sprintf((tattr = tattr->Next) -> attr_value, "%d", Cept->numberBytesReceived); sprintf((tattr = tattr->Next) -> attr_value, "%d", Cept->numberBytesRetransmitted); sprintf((tattr = tattr->Next) -> attr_value, "%s", tprot2str(Cept->tProtocol)); return (attrs); } static char *cthld_attrs [] = { "comparisonLevel", "offsetValue", "onoffSwitch" }; AttrPairs *C_Threshold2attrpairs (Cthld, error) C_ThresholdS *Cthld; Error *error; { AttrPairs *attrs, *tattr, *tattr2; int i, attrno = 0; char buf[8]; if ((tattr = attrs = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } if (Cthld->compLevels[0] == COMP_LEVEL_FREE) { /* no comp levels */ sprintf(tattr->attr_type, "%-30.30s", cthld_attrs[attrno]); strcpy(tattr->attr_value, "empty"); } else for (i = 0; i < 10; ) { sprintf(tattr->attr_type, "%-30.30s", cthld_attrs[attrno]); sprintf(tattr->attr_value, "%d", Cthld->compLevels[i]); if (i >= 9 || Cthld->compLevels[++i] == COMP_LEVEL_FREE) break; if ((tattr = tattr->Next = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } } tattr2 = tattr; /* points before attribute #2 */ attrno++; while (attrno < CTHLD_ATTRS) { if ((tattr = tattr->Next = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } sprintf(tattr->attr_type, "%-30.30s", cthld_attrs[attrno++]); } if (Cthld->onoffSwitch) strcpy(buf, "on"); else strcpy(buf, "off"); tattr = tattr2; sprintf((tattr = tattr->Next) -> attr_value, "%d", Cthld->offsetValue); sprintf((tattr = tattr->Next) -> attr_value, "%s", buf); return (attrs); } static char *gthld_attrs [] = { "comparisonLevel", "hysteresisInterval", "onoffSwitch" }; AttrPairs *G_Threshold2attrpairs (Gthld, error) G_ThresholdS *Gthld; Error *error; { AttrPairs *attrs, *tattr, *tattr2; int i, attrno = 0; char buf[8]; if ((tattr = attrs = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } if (Gthld->compLevels[0] == COMP_LEVEL_FREE) { /* no comp levels */ sprintf(tattr->attr_type, "%-30.30s", gthld_attrs[attrno]); strcpy(tattr->attr_value, "empty"); } else for (i = 0; i < 10; ) { sprintf(tattr->attr_type, "%-30.30s", gthld_attrs[attrno]); sprintf(tattr->attr_value, "%d", Gthld->compLevels[i]); if (i >= 9 || Gthld->compLevels[++i] == COMP_LEVEL_FREE) break; if ((tattr = tattr->Next = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } } tattr2 = tattr; /* points before the attribute #2 */ attrno++; while (attrno < GTHLD_ATTRS) { if ((tattr = tattr->Next = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } sprintf(tattr->attr_type, "%-30.30s", gthld_attrs[attrno++]); } if (Gthld->onoffSwitch) strcpy(buf, "on"); else strcpy(buf, "off"); tattr = tattr2; sprintf((tattr = tattr->Next) -> attr_value, "%d", Gthld->hysterInterval); sprintf((tattr = tattr->Next) -> attr_value, "%d", buf); return (attrs); } static char *rpctl_attrs [] = { "reportDestination" }; AttrPairs *ReportControl2attrpairs (Rpctl, error) ReportControlS *Rpctl; Error *error; { AttrPairs *attrs, *tattr; destinationS *dest = Rpctl->listofdests; int attrno = 0; if ((tattr = attrs = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } if (dest == (destinationS *) NULL) { sprintf(tattr->attr_type, "%-30.30s", rpctl_attrs[attrno]); strcpy(tattr->attr_value, "empty"); return (attrs); } while (dest != (destinationS *) NULL) { sprintf(tattr->attr_type, "%-30.30s", rpctl_attrs[attrno]); if (dest->type == RCI_DEST_FD) strcpy(tattr->attr_value, "fd"); else if (dest->type == RCI_DEST_AEI) strcpy(tattr->attr_value, "AEI"); else if (dest->type == RCI_DEST_PSAP) sprintf(tattr->attr_value, "%.4s %.4s %.4s %.16s", dest->Psap_dest.psel, dest->Psap_dest.saddr.ssel, dest->Psap_dest.saddr.taddr.tsel, dest->Psap_dest.saddr.taddr.naddr); if ((dest = dest->Next) == (destinationS *) NULL) break; if ((tattr = tattr->Next = (AttrPairs *) calloc(1, sizeof(AttrPairs))) == (AttrPairs *) NULL) { error->err_type = outOfMemory; sprintf(error->err_msg, "Error: %s", errmsg[8]); return ((AttrPairs *) NULL); } } return (attrs); } AttrPairs *mobject2attrpairs (mobj, error) ManagedObjectS *mobj; Error *error; { switch (mobj->type) { case M_SYSTEM: return (ManagedSystem2attrpairs(mobj->msys, error)); case T_SUBSYS: return (T_LayerSubsystem2attrpairs(mobj->tsubsys, error)); case T_ENTITY: return (T_LayerEntity2attrpairs(mobj->tent, error)); case T_EINV: return (T_EntityInvoc2attrpairs(mobj->einv, error)); case T_CEPT: return (T_ConnectionEpt2attrpairs(mobj->cept, error)); case C_THLD: return (C_Threshold2attrpairs(mobj->cthld, error)); case G_THLD: return (G_Threshold2attrpairs(mobj->gthld, error)); case RPCTL: return (ReportControl2attrpairs(mobj->rpctl, error)); default: return ((AttrPairs *) NULL); } }