Commit | Line | Data |
---|---|---|
95f51977 | 1 | /* |
ca67e7b4 C |
2 | * Copyright (c) 1983, 1988 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
1c15e888 C |
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. | |
95f51977 C |
18 | */ |
19 | ||
e804469b | 20 | #ifndef lint |
1c15e888 | 21 | static char sccsid[] = "@(#)host.c 5.11 (Berkeley) 6/18/90"; |
ca67e7b4 | 22 | #endif /* not lint */ |
e804469b | 23 | |
1c15e888 | 24 | #include <sys/param.h> |
e804469b | 25 | #include <sys/mbuf.h> |
ca67e7b4 C |
26 | #include <sys/socket.h> |
27 | ||
28 | #include <net/if.h> | |
e804469b C |
29 | |
30 | #include <netinet/in.h> | |
31 | #include <netimp/if_imp.h> | |
32 | #include <netimp/if_imphost.h> | |
33 | ||
e804469b C |
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 | */ | |
ca67e7b4 C |
42 | hostpr(impsoftcaddr, nimpaddr) |
43 | off_t impsoftcaddr, nimpaddr; | |
e804469b C |
44 | { |
45 | struct mbuf *hosts, mb; | |
ca67e7b4 | 46 | struct imp_softc imp_softc; |
e804469b C |
47 | register struct mbuf *m; |
48 | register struct hmbuf *mh; | |
49 | register struct host *hp; | |
e804469b | 50 | char flagbuf[10], *flags; |
ca67e7b4 | 51 | int i, nimp; |
e804469b | 52 | |
ca67e7b4 C |
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"); | |
e804469b C |
59 | return; |
60 | } | |
1c15e888 | 61 | kvm_read(nimpaddr, (char *)&nimp, sizeof (nimp)); |
ca67e7b4 | 62 | for (i = 0; i < nimp; i++) { |
1c15e888 C |
63 | kvm_read(impsoftcaddr, (char *)&imp_softc, sizeof (imp_softc)); |
64 | impsoftcaddr += sizeof (imp_softc); | |
ca67e7b4 C |
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) { | |
1c15e888 | 70 | kvm_read((off_t)m, (char *)&mb, sizeof (mb)); |
e804469b | 71 | m = &mb; |
1c15e888 | 72 | mh = (struct hmbuf *)(m->m_dat); |
e804469b C |
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'; | |
ca67e7b4 | 87 | printf("%-5.5s %-6d %-8d %-4d %-9x %-4d %d\n", |
e804469b | 88 | flagbuf, |
ca67e7b4 C |
89 | hp->h_host, |
90 | ntohs(hp->h_imp), | |
e804469b C |
91 | hp->h_qcnt, |
92 | hp->h_q, | |
93 | hp->h_rfnm, | |
94 | hp->h_timer); | |
95 | } | |
96 | m = m->m_next; | |
ca67e7b4 C |
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; | |
1c15e888 | 110 | kvm_read(nimpaddr, (char *)&nimp, sizeof (nimp)); |
ca67e7b4 | 111 | for (i = 0; i < nimp; i++) { |
1c15e888 C |
112 | kvm_read(impsoftcaddr, (char *)&imp_softc, sizeof (imp_softc)); |
113 | impsoftcaddr == sizeof(imp_softc); | |
ca67e7b4 C |
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"); | |
e804469b C |
124 | } |
125 | } |