|
|
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 h
Length: 12560 (0x3110)
Types: TextFile
Names: »host.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z«
└─⟦d846658bd⟧
└─⟦this⟧ »osimis/smap/host.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.
*/
/* requests and receives the management information and
* processes event reports for one HOST (SMA)
*/
/*
* By George Pavlou, October 1988
*/
#include <stdio.h>"
#include "isode/rosap.h"
#include "msap.h"
#include "disp.h"
#include "recs.h"
#include "objectS.h"
#include "report.h"
T_EntityInvocationS *parseTEntityInvocation();
T_ConnectionEndpointS *parseTConnectionEndpoint();
MO_ID *objid2inst();
FREC *whdr(), *wfrec();
static int einvs, cepts;
extern int mask, nfds;
T_EntityInvocationS *Einv;
initialise_host (host, msd)
char *host;
int msd[];
{
struct MSAPindication mis;
MO_ID *inst, *EinvRdns, *einvrdn, *CeptRdns, *ceptrdn;
int replies, pid, fd, ind = 0;
DN rdns;
fprintf(stdout, "connecting to the SMA...\n");
if ((msd[0] = m_init(host)) == NOTOK) /* open mgmt connection */
error(NULLCP, "can't establish connection to %s", host);
mask |= 1 << msd[0];
nfds = msd[0] + 1;
/* set reports for einvs: TEinvReport, rcid 2
* and cepts: TCeptReport, rcid 3
*/
if (ReportSetRequest(TEINV_REP, m_addValue, msd[0]) == NOTOK ||
ReportSetRequest(TCEPT_REP, m_addValue, msd[0]) == NOTOK) {
m_term(msd[0]);
error(NULLCP, "ReportSetRequest failed");
}
fprintf(stdout, "getting management information...\n");
/* Get T-LayerEntity subordinate ids */
inst = objid2inst(T_ENTITY, ISODE);
if (SubordinateListGetRequest(T_ENTITY, inst, msd[0], 0)
== NOTOK) {
m_term(msd[0]);
error(NULLCP, "SubordinateListGetRequest failed");
}
moid_free(inst);
if (M_WaitReq(msd[0], NOTOK, &mis) == NOTOK ||
mis.mi_type != MI_GET_RES) {
m_term(msd[0]);
error(NULLCP, "failed to get result, mi_type = %d, reason is %s",
mis.mi_type, mis.mi_preject.mr_data);
}
if (decode_IF_RDNSequence(mis.mi_getr.result.gr_attrs[0].mp_val,
1, NULLIP, NULLVP, &rdns) == NOTOK) {
m_term(msd[0]);
error(NULLCP, "parse subordinates failed");
}
dn_decode(rdns);
EinvRdns = dn2moid(rdns);
dn_free(rdns);
mifree(&mis);
einvs = 0;
einvrdn = EinvRdns;
while (einvrdn != (MO_ID *) NULL) {
if (oid_cmp(&einvrdn->rdntype, str2oid("2.37.1.4.1")) == 0) {
bcopy(&einvrdn->rdnval[1], &pid, sizeof(int));
/* request T-EntityInvocations */
inst = objid2inst(T_EINV, ISODE, pid);
if (ManagedObjectGetRequest(T_EINV, inst, msd[0], einvs++)
== NOTOK) {
m_term(msd[0]);
error(NULLCP, "ManagedObjectGetRequest failed");
}
moid_free(inst);
}
einvrdn = einvrdn->Next;
}
moid_free(EinvRdns);
/* create header recs for einvs */
writerec(whdr(T_EINV, BLANK), ind++);
writerec(whdr(T_EINV, HDR1A), ind++);
writerec(whdr(T_EINV, HDR1B), ind++);
writerec(whdr(T_EINV, UNDLN), ind++);
/* Get T-EntityInvocations */
cepts = 0;
for (replies = 0; replies < einvs; ) {
ManagedObjectS mobj;
if (M_WaitReq(msd[0], NOTOK, &mis) == NOTOK) {
m_term(msd[0]);
error(NULLCP, "M_WaitReq failed: reason = %s",
mis.mi_preject.mr_data);
}
if (mis.mi_type != MI_GET_RES) {
if (mis.mi_type == MI_ERROR &&
mis.mi_errtype == m_noSuchObjectInstance)
replies++; /* requested object died */
else /* any other errors */
advise(NULLCP, "error = %d occurred", mis.mi_errtype);
continue;
}
if ((mobj.einv = parseTEntityInvocation(mis.mi_getr.result.gr_attrs))
== (T_EntityInvocationS *) NULL ||
decode_IF_RDNSequence(mis.mi_getr.result.gr_attrs[0].mp_val,
1, NULLIP,NULLVP, &rdns) == NOTOK) {
m_term(msd[0]);
error(NULLCP, "TEinv parsing failed");
}
dn_decode(rdns);
CeptRdns = dn2moid(rdns);
dn_free(rdns);
dn_decode(mis.mi_getr.result.gr_inst.mn_dn);
inst = dn2moid(mis.mi_getr.result.gr_inst.mn_dn);
writerec(wfrec(T_EINV, &mobj, inst), ind++);
moid_free(inst);
cfree(mobj.einv);
replies++;
/* find pid of the einv received */
if (objinst2id(inst, T_EINV, NULLIP, &pid) == NOTOK) {
m_term(msd[0]);
error(NULLCP, "illegal einvinst");
}
ceptrdn = CeptRdns;
while (ceptrdn != (MO_ID *) NULL) {
if (oid_cmp(&ceptrdn->rdntype, str2oid("2.37.1.5.1")) == 0) {
bcopy(&ceptrdn->rdnval[1], &fd, sizeof(int));
/* request T-ConnectionEndpoints */
inst = objid2inst(T_CEPT, ISODE, pid, fd);
if (ManagedObjectGetRequest(T_CEPT, inst, msd[0], cepts++)
== NOTOK) {
m_term(msd[0]);
error(NULLCP, "ManagedObjectGetRequest failed");
}
moid_free(inst);
}
ceptrdn = ceptrdn->Next;
}
moid_free(CeptRdns);
mifree(&mis);
}
/* create header recs for cepts */
writerec(whdr(T_CEPT, BLANK), ind++);
writerec(whdr(T_CEPT, HDR2A), ind++);
writerec(whdr(T_CEPT, HDR2B), ind++);
writerec(whdr(T_CEPT, UNDLN), ind++);
/* Get T-ConnectionEndpoints */
for (replies = 0; replies < cepts; ) {
ManagedObjectS mobj;
if (M_WaitReq(msd[0], NOTOK, &mis) == NOTOK) {
m_term(msd[0]);
error(NULLCP, "M_WaitReq failed: reason = %s",
mis.mi_preject.mr_data);
}
if (mis.mi_type != MI_GET_RES) {
if (mis.mi_type == MI_ERROR
&& mis.mi_errtype == m_noSuchObjectInstance)
replies++; /* requested object died */
else /* any other errors */
advise(NULLCP, "error = %d occurred", mis.mi_errtype);
continue;
}
if ((mobj.cept = parseTConnectionEndpoint(mis.mi_getr.result.gr_attrs))
== (T_ConnectionEndpointS *) NULL) {
m_term(msd[0]);
error(NULLCP, "parseTConnectionEndpoint failed");
}
dn_decode(mis.mi_getr.result.gr_inst.mn_dn);
inst = dn2moid(mis.mi_getr.result.gr_inst.mn_dn);
writerec(wfrec(T_CEPT, &mobj, inst), ind++);
moid_free(inst);
cfree(mobj.cept);
mifree(&mis);
replies++;
}
}
int process_evrep_host (EventReport)
struct MSAPeventrepv *EventReport;
{
struct event_rep_arg *eventrep = &EventReport->args;
OID evtype = eventrep->ea_type.mid_global;
ManagedObjectS mobj;
MO_ID * inst;
int pid, fd, ind;
char buf[64];
dn_decode(eventrep->ea_inst.mn_dn);
inst = dn2moid(eventrep->ea_inst.mn_dn);
if (oid_cmp(eventrep->ea_class.mid_global, str2oid("2.37.1.4")) == 0) {
if (objinst2id(inst, T_EINV, NULLIP, &pid)
== NOTOK) {
advise(NULLCP, "process_evrep_host: bad obj_inst");
return NOTOK;
}
if (oid_cmp(evtype, str2oid("2.37.2.9")) == 0) {
/* process tEinvCreation event report */
if (parse_Report_TEinvReport(eventrep->ea_info,
1, NULLIP, NULLVP, &mobj.einv)
== NOTOK) {
advise(NULLCP, "parse_Report_TEinvReport failed");
return NOTOK;
}
/* ignore any double tEinvCreation report */
if ((ind = find_rec(pid, GRP1)) == NOTOK) {
ind = find_rec(NULL, NEW_GRP1); /* should always
find this one */
writerec(wfrec(T_EINV, &mobj, inst), ind);
}
}
else
if (oid_cmp(evtype, str2oid("2.37.2.10")) == 0) {
/* process tEinvShutdown event report */
if ((ind = find_rec(pid, GRP1)) == NOTOK) {
advise(NULLCP, "find_rec: einv with pid %d not found", pid);
return NOTOK;
}
deleterec(ind);
/* delete any remaining cept recs for this einv */
while ((ind = find_rec(pid, GRP2)) != NOTOK)
deleterec(ind);
}
else
if (oid_cmp(evtype, str2oid("2.37.2.3")) == 0 ||
oid_cmp(evtype, str2oid("2.37.2.4")) == 0 ||
oid_cmp(evtype, str2oid("2.37.2.5")) == 0 ||
oid_cmp(evtype, str2oid("2.37.2.6")) == 0 ||
oid_cmp(evtype, str2oid("2.37.2.7")) == 0 ||
oid_cmp(evtype, str2oid("2.37.2.8")) == 0) {
/* process einv counter threshold event report */
if (parse_Report_TEinvReport(eventrep->ea_info,
1, NULLIP, NULLVP, &mobj.einv)
== NOTOK) {
advise(NULLCP, "parse_Report_TEinvReport failed");
return NOTOK;
}
if ((ind = find_rec(pid, GRP1)) == NOTOK) {
advise(NULLCP, "find_rec: einv with pid %d not found", pid);
return NOTOK;
}
overwriterec(wfrec(T_EINV, &mobj, inst), ind);
}
else {
advise(NULLCP, "illegal event report: obj_class %s, type %s",
strcpy(buf, sprintoid(eventrep->ea_class.mid_global)),
strcpy(buf+32, sprintoid(evtype)));
return NOTOK;
}
free(mobj.einv);
}
else
if (oid_cmp(eventrep->ea_class.mid_global, str2oid("2.37.1.5")) == 0) {
if (objinst2id(inst, T_CEPT, NULLIP, &pid, &fd)
== NOTOK) {
advise(NULLCP, "process_evrep_host: bad obj_inst");
return NOTOK;
}
if (oid_cmp(evtype, str2oid("2.37.2.14")) == 0) {
/* process tCeptCreation event report */
if (parse_Report_TCeptReport(eventrep->ea_info,
1, NULLIP, NULLVP, &mobj.cept)
== NOTOK) {
advise(NULLCP, "parse_Report_TCeptReport failed");
return NOTOK;
}
ind = find_rec(pid, NEW_GRP2); /* should always find this one */
writerec(wfrec(T_CEPT, &mobj, inst), ind);
/* hack to modify parent einv record */
free(mobj.cept);
mobj.einv = Einv;
modifyrec(T_EINV, &mobj, eventrep);
}
else
if (oid_cmp(evtype, str2oid("2.37.2.15")) == 0) {
/* process tCeptShutdown event report */
if (parse_Report_TCeptReport(eventrep->ea_info,
1, NULLIP, NULLVP, &mobj.cept)
== NOTOK) {
advise(NULLCP, "parse_Report_TCeptReport failed");
return NOTOK;
}
if ((ind = find_rec(pid, fd)) == NOTOK) {
advise(NULLCP, "find_rec: cept with pid %d, fd %d not found",
pid, fd);
return NOTOK;
}
deleterec(ind);
/* hack to modify parent einv record */
free(mobj.cept);
mobj.einv = Einv;
modifyrec(T_EINV, &mobj, eventrep);
}
else
if (oid_cmp(evtype, str2oid("2.37.2.11")) == 0 ||
oid_cmp(evtype, str2oid("2.37.2.12")) == 0 ||
oid_cmp(evtype, str2oid("2.37.2.13")) == 0) {
/* process cept counter threshold event report */
if (parse_Report_TCeptReport(eventrep->ea_info,
1, NULLIP, NULLVP, &mobj.cept)
== NOTOK) {
advise(NULLCP, "parse_Report_TCeptReport failed");
return NOTOK;
}
if ((ind = find_rec(pid, fd)) == NOTOK) {
advise(NULLCP, "find_rec: cept with pid %d, fd %d not found",
pid, fd);
return NOTOK;
}
overwriterec(wfrec(T_CEPT, &mobj, inst), ind);
free(mobj.cept);
}
else {
advise(NULLCP, "illegal event report: obj_class %s, type %s",
strcpy(buf, sprintoid(eventrep->ea_class.mid_global)),
strcpy(buf+32, sprintoid(evtype)));
return NOTOK;
}
free(Einv);
}
else {
advise(NULLCP, "illegal event report obj_class: %s",
sprintoid(eventrep->ea_class.mid_global));
moid_free(inst);
return NOTOK;
}
moid_free(inst);
return OK;
}
/* modifies the active connections gauge for a teinv record
* when a connection appears or dies */
extern REC temprecs[];
static int modifyrec (mode, mobj, evrep)
int mode;
ManagedObjectS *mobj;
struct event_rep_arg *evrep;
{
OID evtype = evrep->ea_type.mid_global;
MO_ID * inst;
int pid, fd, ind;
char buf[82];
if (mode != T_EINV) {
advise(NULLCP, "modifyrec: illegal mode %d", mode);
return NOTOK;
}
if (oid_cmp(evtype, str2oid("2.37.2.15")) == 0 &&
mobj->einv->activeConnections == 0)
return OK; /* don't be bothered to update einv rec
for the last cept shutdown event */
inst = dn2moid(evrep->ea_inst.mn_dn);
objinst2id(inst, T_CEPT, NULLIP, &pid, &fd);
moid_free(inst);
if ((ind = find_rec(pid, GRP1)) == NOTOK)
return NOTOK;
strcpy(buf, temprecs[ind].m_text);
if ((temprecs[ind].m_text
= (char *) malloc (temprecs[ind].m_len + 2))
== (char *) NULL) {
advise(NULLCP, "modifyrec: out of core");
return NOTOK;
}
strcpy(temprecs[ind].m_text, buf);
sprintf(buf, "%4d |%4d%5d",
mobj->einv->activeConnections,
mobj->einv->crTPDUSuccessfulIn,
mobj->einv->crTPDUSuccessfulOut);
strncpy(temprecs[ind].m_text+22, buf, 16);
return OK;
}