DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T s

⟦fecf97be8⟧ TextFile

    Length: 5445 (0x1545)
    Types: TextFile
    Names: »sma.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z« 
        └─⟦d846658bd⟧ 
            └─⟦this⟧ »osimis/sma/sma.c« 

TextFile

/*
 * 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.
 */

/* System Management Agent main program */

/*
 * By Simon Walton, October 1988
 * Modified by George Pavlou, April 1990
 */

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netdb.h>
#include <netinet/in.h>
#include <signal.h>
#include <errno.h>

#include "isode/rosap.h"
#include "isode/tsap.h"
#include "isode/mpkt.h"
#include "msap.h"
#include "smi.h"
#include "config.h"

char *context = "management";
char *service = "SMA";


int cmip_init(), cmip_lose(), cmip_work(), ipc_check();
static int ManSoc;

struct ManagedObject MIBrootnode, * MIBroot = &MIBrootnode;
extern struct ManagedObject * findcomp(), * forccomp();
extern time_t time();
extern OID oid_copy();
extern EntInv_check();

main()
{
AEI aei;
struct TSAPdisconnect tds;
char * myhost;
static struct sigvec handlechld =
    {
    EntInv_check,
    sigmask(SIGEMT),
    0
    };
static struct itimerval looktime =
    {
    {10, 0},    /* every 10 seconds */
    {10, 0}
    };

isodesetailor("./smatailor");
fill_MO_init();
if (initialize_localport() == -1) exit(1);
if (initialize_MIB() == -1) exit(1);
sigvec(SIGALRM, &handlechld, (struct sigvec*) 0);
sigsetmask(sigblock(0) & ~sigmask(SIGALRM));
setitimer(ITIMER_REAL, &looktime, NULL);

myhost = PLocalHostName();
if ((aei = str2aei(myhost, service)) == NULLAEI)
    fatal("unknown application entity info %s-%s",
	PLocalHostName(), service);

quipu_syntaxes();
load_oid_table(strcat(ETCDIR, "oidtable"));

if (server(0, NULLVP, aei, cmip_init, cmip_work, cmip_lose,
    ipc_check, &tds ) == NOTOK)
    {
    if (tds.td_cc > 0)
	fatal("smap: isode error: [%s] %*.*s",
	    TErrString(tds.td_reason), tds.td_cc, tds.td_cc, tds.td_data);
    else
	fatal("smap: isode error: [%s]", TErrString(tds.td_reason));
    }

exit(0);


}

/* ARGSUSED */
int  server (argc, argv, aei, initfnx, workfnx, losefnx, localfnx, td)
int  argc;
char **argv;
AEI  aei;
IFP  initfnx, workfnx, losefnx, localfnx;
struct TSAPdisconnect  *td;
{
    fd_set ifds, xfds, mask;
    int fd, vecp, nfds;
    char *vec[4];
    struct PSAPaddr *pa;


    if (argc > 1)
	fatal("static server: should be started without args");

    if ((pa = aei2addr(aei)) == NULLPA)
	return tsaplose (td, DR_ADDRESS, NULLCP,
				"address translation failed");

    if (TNetListen(&pa->pa_addr.sa_addr, td) == NOTOK)
	return NOTOK;

    FD_ZERO(&mask);
    FD_SET(ManSoc, &mask);
    nfds = ManSoc + 1;
    isodetailor(service, 0);

    for (;;) {
	xfds = ifds = mask;
	if (TNetAccept(&vecp, vec, nfds, &ifds, NULL, &xfds, NOTOK, td)
		== NOTOK) {
	    if (errno == EINTR)
		continue;
	    mask.fds_bits[0] &= ~(ifds.fds_bits[0]);
	    FD_SET(ManSoc, &mask);
	    (void) (*losefnx)(td);
	    continue;
	}

	if (vecp > 0 && (fd = (*initfnx)(vecp, vec)) != NOTOK) {
	    if (fd >= nfds)
		nfds = fd + 1;
	    FD_SET(fd, &mask);
	}

	if FD_ISSET(ManSoc, &ifds)
	    {
	    (*localfnx)();
	    FD_CLR(ManSoc, &ifds);
	    }

	for (fd = 0; fd < nfds; fd++)
	    if ( FD_ISSET(fd, &ifds) && (*workfnx)(fd) == NOTOK) {
		if (nfds == fd + 1) {
		    int  tfd;

		    for (tfd = fd - 1; tfd >= 0; tfd--)
			if (FD_ISSET (tfd, &mask))
			    break;
		    nfds = tfd + 1;
		}
		FD_CLR(fd, &mask);
	    }


    }
}

initialize_localport()
{
struct servent * sp;
struct sockaddr_in sin;

if ((sp = getservbyname("manager", (char*) 0)) == 0)
	return (fprintf(stderr,"smap: No netmanage port\n"), -1);
if ((ManSoc = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
	return (perror("smap"), -1);
sin.sin_family = AF_INET;
sin.sin_port = sp->s_port;
sin.sin_addr.s_addr = INADDR_ANY;
if (bind(ManSoc, &sin, sizeof (sin)) < 0)
	return (perror("smap"), -1);
listen(ManSoc, 5);
return (0);
}

ipc_check()
{
int signalmask;
struct MReport Mins;
struct MReport * Min =  &Mins;

read(ManSoc, (caddr_t)Min, sizeof (*Min));
fprintf(stderr, "Management Packet Received\n");
signalmask = sigblock(sigmask(SIGALRM));   /* block alarm signals */
(void) MIB_update(Min);
sigsetmask(signalmask);
}

struct MO_ID
    isodelayer =
    {
    NULLCP, {0},
    6, "\1isode"
    },

    tlayer =
    {
    &isodelayer, {0,0},
    0, ""},

    thesystem =
    {
    &tlayer, {0,0},
    0, "" };


static initialize_MIB()
{
oid_copy(str2oid("2.37.1.1.1"), &thesystem.rdntype);
oid_copy(str2oid("2.37.1.2.1"), &tlayer.rdntype);
oid_copy(str2oid("2.37.1.3.1"), &isodelayer.rdntype);
/* create first MO, the managed system */
if (forccomp(MIBroot, &thesystem) == NULL) return (1);
return (0);
}


/* VARARGS1 */
static fatal (s, a, b, c, d, e)
char * s;
caddr_t a, b, c, d, e;
{
fprintf(stderr, s, a, b, c, d, e);
fputc('\n',stderr);
exit (-1);
}