|
|
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 ! 6: * provided that the above copyright notice and this paragraph are ! 7: * duplicated in all such forms and that any documentation, ! 8: * advertising materials, and other materials related to such ! 9: * distribution and use acknowledge that the software was developed ! 10: * by the University of California, Berkeley. The name of the ! 11: * University may not be used to endorse or promote products derived ! 12: * from this software without specific prior written permission. ! 13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 16: */ ! 17: ! 18: #ifndef lint ! 19: static char sccsid[] = "@(#)host.c 5.8 (Berkeley) 6/29/88"; ! 20: #endif /* not lint */ ! 21: ! 22: #include <sys/types.h> ! 23: #include <sys/mbuf.h> ! 24: #include <sys/socket.h> ! 25: ! 26: #include <net/if.h> ! 27: ! 28: #include <netinet/in.h> ! 29: #include <netimp/if_imp.h> ! 30: #include <netimp/if_imphost.h> ! 31: ! 32: extern int kmem; ! 33: extern int nflag; ! 34: extern char *inetname(); ! 35: ! 36: /* ! 37: * Print the host tables associated with the ARPANET IMP. ! 38: * Symbolic addresses are shown unless the nflag is given. ! 39: */ ! 40: hostpr(impsoftcaddr, nimpaddr) ! 41: off_t impsoftcaddr, nimpaddr; ! 42: { ! 43: struct mbuf *hosts, mb; ! 44: struct imp_softc imp_softc; ! 45: register struct mbuf *m; ! 46: register struct hmbuf *mh; ! 47: register struct host *hp; ! 48: char flagbuf[10], *flags; ! 49: int i, nimp; ! 50: ! 51: if (impsoftcaddr == 0) { ! 52: printf("imp_softc: symbol not in namelist\n"); ! 53: return; ! 54: } ! 55: if (nimpaddr == 0) { ! 56: printf("nimp: symbol not in namelist\n"); ! 57: return; ! 58: } ! 59: klseek(kmem, nimpaddr, 0); ! 60: read(kmem, (char *)&nimp, sizeof (nimp)); ! 61: klseek(kmem, impsoftcaddr, 0); ! 62: for (i = 0; i < nimp; i++) { ! 63: read(kmem, (char *)&imp_softc, sizeof (imp_softc)); ! 64: m = imp_softc.imp_hosts; ! 65: printf("IMP%d Host Table\n", i); ! 66: printf("%-5.5s %-6.6s %-8.8s %-4.4s %-9.9s %-4.4s %s\n", "Flags", ! 67: "Host", "Imp", "Qcnt", "Q Address", "RFNM", "Timer"); ! 68: while (m) { ! 69: klseek(kmem, (off_t)m, 0); ! 70: read(kmem, (char *)&mb, sizeof (mb)); ! 71: m = &mb; ! 72: mh = mtod(m, struct hmbuf *); ! 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: klseek(kmem, nimpaddr, 0); ! 111: read(kmem, (char *)&nimp, sizeof (nimp)); ! 112: klseek(kmem, impsoftcaddr, 0); ! 113: for (i = 0; i < nimp; i++) { ! 114: read(kmem, (char *)&imp_softc, sizeof (imp_softc)); ! 115: printf("imp%d statistics:\n", i); ! 116: #define p(f, m) printf(m, imp_softc.f, plural(imp_softc.f)) ! 117: p(imp_if.if_ipackets, "\t%u input message%s\n"); ! 118: p(imp_if.if_opackets, "\t%u output message%s\n"); ! 119: printf("\t%u times output blocked at least %d sec.\n", ! 120: imp_softc.imp_block, IMP_OTIMER); ! 121: p(imp_incomplete, "\t%u \"incomplete\" message%s\n"); ! 122: p(imp_lostrfnm, "\t%u lost RFNM message%s\n"); ! 123: p(imp_badrfnm, "\t%u late/bogus RFNM/incomplete message%s\n"); ! 124: p(imp_garbage, "\t%u unknown message type%s\n"); ! 125: } ! 126: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.