|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983, 1988 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted provided ! 6: * that: (1) source distributions retain this entire copyright notice and ! 7: * comment, and (2) distributions including binaries display the following ! 8: * acknowledgement: ``This product includes software developed by the ! 9: * University of California, Berkeley and its contributors'' in the ! 10: * documentation or other materials provided with the distribution and in ! 11: * all advertising materials mentioning features or use of this software. ! 12: * Neither the name of the University nor the names of its contributors may ! 13: * be used to endorse or promote products derived from this software without ! 14: * specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)host.c 5.11 (Berkeley) 6/18/90"; ! 22: #endif /* not lint */ ! 23: ! 24: #include <sys/param.h> ! 25: #include <sys/mbuf.h> ! 26: #include <sys/socket.h> ! 27: ! 28: #include <net/if.h> ! 29: ! 30: #include <netinet/in.h> ! 31: #include <netimp/if_imp.h> ! 32: #include <netimp/if_imphost.h> ! 33: ! 34: extern int kmem; ! 35: extern int nflag; ! 36: extern char *inetname(); ! 37: ! 38: /* ! 39: * Print the host tables associated with the ARPANET IMP. ! 40: * Symbolic addresses are shown unless the nflag is given. ! 41: */ ! 42: hostpr(impsoftcaddr, nimpaddr) ! 43: off_t impsoftcaddr, nimpaddr; ! 44: { ! 45: struct mbuf *hosts, mb; ! 46: struct imp_softc imp_softc; ! 47: register struct mbuf *m; ! 48: register struct hmbuf *mh; ! 49: register struct host *hp; ! 50: char flagbuf[10], *flags; ! 51: int i, nimp; ! 52: ! 53: if (impsoftcaddr == 0) { ! 54: printf("imp_softc: symbol not in namelist\n"); ! 55: return; ! 56: } ! 57: if (nimpaddr == 0) { ! 58: printf("nimp: symbol not in namelist\n"); ! 59: return; ! 60: } ! 61: kvm_read(nimpaddr, (char *)&nimp, sizeof (nimp)); ! 62: for (i = 0; i < nimp; i++) { ! 63: kvm_read(impsoftcaddr, (char *)&imp_softc, sizeof (imp_softc)); ! 64: impsoftcaddr += sizeof (imp_softc); ! 65: m = imp_softc.imp_hosts; ! 66: printf("IMP%d Host Table\n", i); ! 67: printf("%-5.5s %-6.6s %-8.8s %-4.4s %-9.9s %-4.4s %s\n", "Flags", ! 68: "Host", "Imp", "Qcnt", "Q Address", "RFNM", "Timer"); ! 69: while (m) { ! 70: kvm_read((off_t)m, (char *)&mb, sizeof (mb)); ! 71: m = &mb; ! 72: mh = (struct hmbuf *)(m->m_dat); ! 73: if (mh->hm_count == 0) { ! 74: m = m->m_next; ! 75: continue; ! 76: } ! 77: for (hp = mh->hm_hosts; hp < mh->hm_hosts + HPMBUF; hp++) { ! 78: if ((hp->h_flags&HF_INUSE) == 0 && hp->h_timer == 0) ! 79: continue; ! 80: flags = flagbuf; ! 81: *flags++ = hp->h_flags&HF_INUSE ? 'A' : 'F'; ! 82: if (hp->h_flags&HF_DEAD) ! 83: *flags++ = 'D'; ! 84: if (hp->h_flags&HF_UNREACH) ! 85: *flags++ = 'U'; ! 86: *flags = '\0'; ! 87: printf("%-5.5s %-6d %-8d %-4d %-9x %-4d %d\n", ! 88: flagbuf, ! 89: hp->h_host, ! 90: ntohs(hp->h_imp), ! 91: hp->h_qcnt, ! 92: hp->h_q, ! 93: hp->h_rfnm, ! 94: hp->h_timer); ! 95: } ! 96: m = m->m_next; ! 97: } ! 98: } ! 99: } ! 100: ! 101: impstats(impsoftcaddr, nimpaddr) ! 102: off_t impsoftcaddr, nimpaddr; ! 103: { ! 104: struct imp_softc imp_softc; ! 105: int i, nimp; ! 106: extern char *plural(); ! 107: ! 108: if (impsoftcaddr == 0 || nimpaddr == 0) ! 109: return; ! 110: kvm_read(nimpaddr, (char *)&nimp, sizeof (nimp)); ! 111: for (i = 0; i < nimp; i++) { ! 112: kvm_read(impsoftcaddr, (char *)&imp_softc, sizeof (imp_softc)); ! 113: impsoftcaddr == sizeof(imp_softc); ! 114: printf("imp%d statistics:\n", i); ! 115: #define p(f, m) printf(m, imp_softc.f, plural(imp_softc.f)) ! 116: p(imp_if.if_ipackets, "\t%u input message%s\n"); ! 117: p(imp_if.if_opackets, "\t%u output message%s\n"); ! 118: printf("\t%u times output blocked at least %d sec.\n", ! 119: imp_softc.imp_block, IMP_OTIMER); ! 120: p(imp_incomplete, "\t%u \"incomplete\" message%s\n"); ! 121: p(imp_lostrfnm, "\t%u lost RFNM message%s\n"); ! 122: p(imp_badrfnm, "\t%u late/bogus RFNM/incomplete message%s\n"); ! 123: p(imp_garbage, "\t%u unknown message type%s\n"); ! 124: } ! 125: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.