Annotation of 42BSD/ucb/netstat/host.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char sccsid[] = "@(#)host.c     4.2 82/11/14";
        !             3: #endif
        !             4: 
        !             5: #include <sys/types.h>
        !             6: #include <sys/mbuf.h>
        !             7: 
        !             8: #include <netinet/in.h>
        !             9: #include <netimp/if_imp.h>
        !            10: #include <netimp/if_imphost.h>
        !            11: 
        !            12: #include <netdb.h>
        !            13: 
        !            14: extern int kmem;
        !            15: extern         int nflag;
        !            16: extern char *inetname();
        !            17: 
        !            18: /*
        !            19:  * Print the host tables associated with the ARPANET IMP.
        !            20:  * Symbolic addresses are shown unless the nflag is given.
        !            21:  */
        !            22: hostpr(hostsaddr)
        !            23:        off_t hostsaddr;
        !            24: {
        !            25:        struct mbuf *hosts, mb;
        !            26:        register struct mbuf *m;
        !            27:        register struct hmbuf *mh;
        !            28:        register struct host *hp;
        !            29:        struct hostent *p;
        !            30:        char flagbuf[10], *flags;
        !            31:        int first = 1;
        !            32: 
        !            33:        if (hostsaddr == 0) {
        !            34:                printf("hosts: symbol not in namelist\n");
        !            35:                return;
        !            36:        }
        !            37:        klseek(kmem, hostsaddr, 0);
        !            38:        read(kmem, &hosts, sizeof (hosts));
        !            39:        m = hosts;
        !            40:        printf("IMP Host Table\n");
        !            41:        printf("%-5.5s %-15.15s %-4.4s %-9.9s %-4.4s %s\n",
        !            42:                "Flags", "Host", "Qcnt", "Q Address", "RFNM", "Timer");
        !            43:        while (m) {
        !            44:                klseek(kmem, m, 0);
        !            45:                read(kmem, &mb, sizeof (mb));
        !            46:                m = &mb;
        !            47:                mh = mtod(m, struct hmbuf *);
        !            48:                if (mh->hm_count == 0) {
        !            49:                        m = m->m_next;
        !            50:                        continue;
        !            51:                }
        !            52:                for (hp = mh->hm_hosts; hp < mh->hm_hosts + HPMBUF; hp++) {
        !            53:                        if ((hp->h_flags&HF_INUSE) == 0 && hp->h_timer == 0)
        !            54:                                continue;
        !            55:                        flags = flagbuf;
        !            56:                        *flags++ = hp->h_flags&HF_INUSE ? 'A' : 'F';
        !            57:                        if (hp->h_flags&HF_DEAD)
        !            58:                                *flags++ = 'D';
        !            59:                        if (hp->h_flags&HF_UNREACH)
        !            60:                                *flags++ = 'U';
        !            61:                        *flags = '\0';
        !            62:                        printf("%-5.5s %-15.15s %-4d %-9x %-4d %d\n",
        !            63:                                flagbuf,
        !            64:                                inetname(hp->h_addr),
        !            65:                                hp->h_qcnt,
        !            66:                                hp->h_q,
        !            67:                                hp->h_rfnm,
        !            68:                                hp->h_timer);
        !            69:                }
        !            70:                m = m->m_next;
        !            71:        }
        !            72: }

unix.superglobalmegacorp.com

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