File:  [XINU] / xinu / sys / rwhoind.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:39:03 2018 UTC (8 years, 2 months ago) by root
Branches: xinu, MAIN
CVS tags: xinu-19870308, HEAD
Xinu for VAX

/* rwhoind.c - rwhoind */

#include <conf.h>
#include <kernel.h>
#include <network.h>
#include <rwho.h>

/*------------------------------------------------------------------------
 *  rwhoind  -  rwho daemon to record info from incoming rwho packets
 *------------------------------------------------------------------------
 */
PROCESS	rwhoind()
{
	int	dev;
	int	len;
	int	i;
	long	now;
	PStype	ps;
	struct	rwhopac	*rpacptr;
	struct	rwent	*rwptr;

	if ( (dev=open(INTERNET, ANYFPORT, URWHO)) == SYSERR ||
	      control(dev, DG_SETMODE, DG_DMODE) == SYSERR)
		panic("rwho_in: cannot open rwho port");
	while (TRUE) {
		if ( (len = read(dev,Rwho.rbuf,RWMAXP)) == SYSERR )
			continue;
		rpacptr = (struct rwhopac *) Rwho.rbuf;
		for (i=0 ; i<Rwho.rwnent ; i++) {
			rwptr = &Rwho.rwcache[i];
			if (strncmp(rpacptr->rw_host, rwptr->rwmach,
			    RMACLEN) == 0)
				break;
		}
		if (i >= Rwho.rwnent) {
			disable(ps);
			if (Rwho.rwnent >= RWCSIZ) {
				restore(ps);
				continue;
			}
			rwptr = &Rwho.rwcache[Rwho.rwnent++];
			strncpy(rwptr->rwmach, rpacptr->rw_host, RMACLEN);
			restore(ps);
		}
		rwptr->rwboot = net2hl(rpacptr->rw_btim);
		gettime(&now);
		rwptr->rwlast = now;
		rwptr->rwslast = net2hl(rpacptr->rw_sndtim);
		for (i=0 ; i<RWNLOAD ; i++)
			rwptr->rwload[i] = net2hl(rpacptr->rw_load[i]);
		rwptr->rwusers = (len-RWMINP)/sizeof(struct rw_who);
	}
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.