Annotation of cci/usr/src/etc/nstat/host.c, revision 1.1.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: #include <nlist.h>
                     14: #include "nstat.h"
                     15: 
                     16: struct nlist hostnl[] = {
                     17: #              define  N_HOSTS         0
                     18:        { "_hosts" },
                     19:        { "" },
                     20: };
                     21: 
                     22: extern int     kmem;
                     23: extern char    *system;
                     24: extern char    *inetname();
                     25: 
                     26: /*
                     27:  * Print the host tables associated with the ARPANET IMP.
                     28:  * Symbolic addresses are shown unless the nflag is given.
                     29:  */
                     30: hostpr()
                     31: {
                     32:        off_t hostsaddr;
                     33:        struct mbuf *hosts, mb;
                     34:        register struct mbuf *m;
                     35:        register struct hmbuf *mh;
                     36:        register struct host *hp;
                     37:        struct hostent *p;
                     38:        char flagbuf[10], *flags;
                     39:        int first = 1;
                     40: 
                     41:        static  int     getvm = 0;
                     42: 
                     43:        if (!getvm) {
                     44:                nlist(system, hostnl);
                     45:                ++getvm;
                     46:        }
                     47:        hostsaddr = hostnl[N_HOSTS].n_value;
                     48:        if (hostsaddr == 0) {
                     49:                printf("hosts: symbol not in namelist\n");
                     50:                return;
                     51:        }
                     52:        klseek(kmem, hostsaddr, 0);
                     53:        read(kmem, &hosts, sizeof (hosts));
                     54:        m = hosts;
                     55:        printf("IMP Host Table\n");
                     56:        printf("%-5.5s %-15.15s %-4.4s %-9.9s %-4.4s %s\n",
                     57:                "Flags", "Host", "Qcnt", "Q Address", "RFNM", "Timer");
                     58:        while (m) {
                     59:                klseek(kmem, m, 0);
                     60:                read(kmem, &mb, sizeof (mb));
                     61:                m = &mb;
                     62:                mh = mtod(m, struct hmbuf *);
                     63:                if (mh->hm_count == 0) {
                     64:                        m = m->m_next;
                     65:                        continue;
                     66:                }
                     67:                for (hp = mh->hm_hosts; hp < mh->hm_hosts + HPMBUF; hp++) {
                     68:                        if ((hp->h_flags&HF_INUSE) == 0 && hp->h_timer == 0)
                     69:                                continue;
                     70:                        flags = flagbuf;
                     71:                        *flags++ = hp->h_flags&HF_INUSE ? 'A' : 'F';
                     72:                        if (hp->h_flags&HF_DEAD)
                     73:                                *flags++ = 'D';
                     74:                        if (hp->h_flags&HF_UNREACH)
                     75:                                *flags++ = 'U';
                     76:                        *flags = '\0';
                     77:                        printf("%-5.5s %-15.15s %-4d %-9x %-4d %d\n",
                     78:                                flagbuf,
                     79:                                inetname(hp->h_addr),
                     80:                                hp->h_qcnt,
                     81:                                hp->h_q,
                     82:                                hp->h_rfnm,
                     83:                                hp->h_timer);
                     84:                }
                     85:                m = m->m_next;
                     86:        }
                     87: }

unix.superglobalmegacorp.com

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