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