Annotation of xinu/sys/rwhoind.c, revision 1.1

1.1     ! root        1: /* rwhoind.c - rwhoind */
        !             2: 
        !             3: #include <conf.h>
        !             4: #include <kernel.h>
        !             5: #include <network.h>
        !             6: #include <rwho.h>
        !             7: 
        !             8: /*------------------------------------------------------------------------
        !             9:  *  rwhoind  -  rwho daemon to record info from incoming rwho packets
        !            10:  *------------------------------------------------------------------------
        !            11:  */
        !            12: PROCESS        rwhoind()
        !            13: {
        !            14:        int     dev;
        !            15:        int     len;
        !            16:        int     i;
        !            17:        long    now;
        !            18:        PStype  ps;
        !            19:        struct  rwhopac *rpacptr;
        !            20:        struct  rwent   *rwptr;
        !            21: 
        !            22:        if ( (dev=open(INTERNET, ANYFPORT, URWHO)) == SYSERR ||
        !            23:              control(dev, DG_SETMODE, DG_DMODE) == SYSERR)
        !            24:                panic("rwho_in: cannot open rwho port");
        !            25:        while (TRUE) {
        !            26:                if ( (len = read(dev,Rwho.rbuf,RWMAXP)) == SYSERR )
        !            27:                        continue;
        !            28:                rpacptr = (struct rwhopac *) Rwho.rbuf;
        !            29:                for (i=0 ; i<Rwho.rwnent ; i++) {
        !            30:                        rwptr = &Rwho.rwcache[i];
        !            31:                        if (strncmp(rpacptr->rw_host, rwptr->rwmach,
        !            32:                            RMACLEN) == 0)
        !            33:                                break;
        !            34:                }
        !            35:                if (i >= Rwho.rwnent) {
        !            36:                        disable(ps);
        !            37:                        if (Rwho.rwnent >= RWCSIZ) {
        !            38:                                restore(ps);
        !            39:                                continue;
        !            40:                        }
        !            41:                        rwptr = &Rwho.rwcache[Rwho.rwnent++];
        !            42:                        strncpy(rwptr->rwmach, rpacptr->rw_host, RMACLEN);
        !            43:                        restore(ps);
        !            44:                }
        !            45:                rwptr->rwboot = net2hl(rpacptr->rw_btim);
        !            46:                gettime(&now);
        !            47:                rwptr->rwlast = now;
        !            48:                rwptr->rwslast = net2hl(rpacptr->rw_sndtim);
        !            49:                for (i=0 ; i<RWNLOAD ; i++)
        !            50:                        rwptr->rwload[i] = net2hl(rpacptr->rw_load[i]);
        !            51:                rwptr->rwusers = (len-RWMINP)/sizeof(struct rw_who);
        !            52:        }
        !            53: }

unix.superglobalmegacorp.com

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