|
|
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: 7046 (0x1b86)
Types: TextFile
Names: »all.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z«
└─⟦d846658bd⟧
└─⟦this⟧ »osimis/smap/all.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 ALL hosts (SMAs)
*/
#include <stdio.h>"
#include <errno.h>"
#include <signal.h>"
#include "isode/rosap.h"
#include "msap.h"
#include "disp.h"
#include "recs.h"
#include "objectS.h"
#include "report.h"
#include "config.h"
#include "defs.h"
ManagedSystemS *parseManagedSystem();
T_LayerEntityS *parseTLayerEntity();
MO_ID *objid2inst();
FREC *whdr(), *wfrec();
extern int errno;
extern int recnt;
extern int mask, nfds;
extern char *hosts[];
extern int NofHosts;
int poll, requests, replies;
initialise_all (hosts, msd)
char *hosts[];
int msd[];
{
struct MSAPindication mis;
MO_ID *msysinst, *tentinst;
int i, done, ifds;
/* create header recs for t-ents */
writerec(whdr(T_ENTITY, BLANK), 0);
writerec(whdr(T_ENTITY, HDR1A), 1);
writerec(whdr(T_ENTITY, HDR1B), 2);
writerec(whdr(T_ENTITY, UNDLN), 3);
fprintf(stdout, "connecting to the SMAs...\n");
for (i = 0; i < NofHosts; i++) {
if ((msd[i] = m_init(hosts[i])) == NOTOK) {
MO_ID sysid;
sysid.rdnlen = i;
overwriterec(wfrec(NO_CONN, (ManagedSystemS *)NULL, &sysid), i+4);
fprintf(stdout, "can't open connection to %s\n", hosts[i]);
continue;
}
mask |= 1 << msd[i];
if (nfds < msd[i] + 1)
nfds = msd[i] + 1;
/* set reports for t-entities: TEntityReport, rcid 4 */
if (ReportSetRequest(TENT_REP, m_addValue, msd[i]) == NOTOK) {
close_connections(msd, NofHosts);
error(NULLCP, "ReportSetRequest failed");
}
/* request management information */
msysinst = objid2inst(M_SYSTEM, NULL);
tentinst = objid2inst(T_ENTITY, ISODE);
if (ManagedObjectGetRequest(M_SYSTEM, msysinst, msd[i], i) == NOTOK ||
ManagedObjectGetRequest(T_ENTITY, tentinst, msd[i], NofHosts+i)
== NOTOK) {
close_connections(msd, NofHosts);
error(NULLCP, "Get Request to %s failed", hosts[i]);
}
moid_free(msysinst);
moid_free(tentinst);
requests++;
}
recnt = HDRLNS + NofHosts; /* count of records displayed */
if ((requests = 2*requests) == 0) {
fprintf(stdout, "no SMAs are running...\n");
return;
}
fprintf(stdout, "getting management information...\n");
for (EVER) {
ifds = mask;
switch (xselect(nfds, &ifds, NULLIP, NULLIP, NOTOK)) {
case OK:
continue;
case NOTOK:
if (errno != EINTR) {
close_connections(msd, NofHosts);
error(NULLCP, "xselect failed");
}
continue; /* select interrupted by signal */
default:
break;
}
for (i = 0; i < NofHosts; i++)
if (msd[i] > 0 && ifds & (1 << msd[i])) {
M_WaitReq(msd[i], NOTOK, &mis);
switch (mis.mi_type) {
case MI_EVENT_REP:
process_evrep_all(&mis.mi_eventrepv, i);
break;
case MI_GET_RES:
done = process_getr_all(&mis.mi_getr);
break;
default:
advise(NULLCP, "unknown mi_type = %d", mis.mi_type);
continue;
}
mifree(&mis);
}
if (done == DONE)
break; /* all requests have been answered */
}
}
int process_evrep_all (EventReport, ind)
struct MSAPeventrepv *EventReport;
int ind;
{
struct event_rep_arg *eventrep = &EventReport->args;
OID evtype = eventrep->ea_type.mid_global;
ManagedObjectS mobj;
MO_ID sysid;
char buf[64];
if (oid_cmp(eventrep->ea_class.mid_global, str2oid("2.37.1.5")) != 0) {
advise(NULLCP, "illegal event report obj_class: %s",
sprintoid(eventrep->ea_class.mid_global));
return NOTOK;
}
/* tCeptCreation and tCeptShutdown event reports */
if (oid_cmp(evtype, str2oid("2.37.2.14")) != 0 &&
oid_cmp(evtype, str2oid("2.37.2.15")) != 0) {
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;
}
if (parse_Report_TEntityReport(eventrep->ea_info,
1, NULLIP, NULLVP, &mobj.tent)
== NOTOK) {
advise(NULLCP, "parse_Report_TCeptReport failed");
return NOTOK;
}
sysid.rdnlen = ind;
overwriterec(wfrec(T_ENTITY, &mobj, &sysid), ind+4);
return OK;
}
int process_getr_all (GetResult)
struct MSAPgetr *GetResult;
{
struct get_res *getres = &GetResult->result;
int i = GetResult->id;
ManagedObjectS mobj;
MO_ID sysid;
if (i < NofHosts) { /* id in (0 .. NofHosts-1) */
if ((mobj.msys = parseManagedSystem(getres->gr_attrs))
== (ManagedSystemS *) NULL) {
advise(NULLCP, "failed to parse ManagedSystem - host %s",
hosts[i]);
return NOTOK;
}
sysid.rdnlen = i;
wfrec(M_SYSTEM, &mobj, &sysid);
cfree(mobj.msys);
}
else { /* id in (NofHosts .. 2*NofHosts-1) */
if ((mobj.tent = parseTLayerEntity(getres->gr_attrs))
== (T_LayerEntityS *) NULL) {
advise(NULLCP, "failed to parse T-LayerEntity - host %s",
hosts[i]);
return NOTOK;
}
sysid.rdnlen = i-NofHosts;
overwriterec(wfrec(T_ENTITY, &mobj, &sysid), i-NofHosts+4);
cfree(mobj.tent);
}
if (++replies == requests)
return (DONE);
return OK;
}
setpoll ()
{
poll = YES;
alarm(WAIT);
}
do_poll (msd)
int msd[];
{
MO_ID *msysinst, *tentinst;
int i;
poll = NO;
replies = requests = 0;
for (i = 0; i < NofHosts; i++)
if (msd[i] == -1 && (msd[i] = m_init(hosts[i])) != NOTOK) {
/* update mask */
mask |= 1 << msd[i];
if (nfds < msd[i] + 1)
nfds = msd[i] + 1;
/* set reports for t-entities: TEntityReport, rcid 4 */
if (ReportSetRequest(TENT_REP, m_addValue, msd[i]) == NOTOK) {
close_connections(msd);
error(NULLCP, "ReportSetRequest failed");
}
/* request management information */
msysinst = objid2inst(M_SYSTEM, NULL);
tentinst = objid2inst(T_ENTITY, ISODE);
if (ManagedObjectGetRequest(M_SYSTEM, msysinst, msd[i], i)
== NOTOK ||
ManagedObjectGetRequest(T_ENTITY, tentinst, msd[i], NofHosts+i)
== NOTOK) {
close_connections(msd, NofHosts);
error(NULLCP, "Get Request to %s failed", hosts[i]);
}
moid_free(msysinst);
moid_free(tentinst);
requests++;
}
requests = 2*requests; /* M_SYSTEM and T_ENTITY for each host */
}