VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/slirp/debug.c@ 14466

最後變更 在這個檔案從14466是 14466,由 vboxsync 提交於 16 年 前

warning

  • 屬性 svn:eol-style 設為 native
檔案大小: 9.9 KB
 
1/*
2 * Copyright (c) 1995 Danny Gasparovski.
3 * Portions copyright (c) 2000 Kelly Price.
4 *
5 * Please read the file COPYRIGHT for the
6 * terms and conditions of the copyright.
7 */
8
9#include <slirp.h>
10
11
12/* Carry over one item from main.c so that the tty's restored.
13 * Only done when the tty being used is /dev/tty --RedWolf */
14extern struct termios slirp_tty_settings;
15extern int slirp_tty_restore;
16#ifdef DEBUG
17void dump_packet(void *, int);
18#endif
19
20
21/*
22 * Dump a packet in the same format as tcpdump -x
23 */
24#ifdef DEBUG
25void
26dump_packet(void *dat, int n)
27{
28 Log(("nat: PACKET DUMPED:\n%.*Vhxd\n", n, dat));
29}
30#endif
31
32#if 0
33/*
34 * Statistic routines
35 *
36 * These will print statistics to the screen, the debug file (dfd), or
37 * a buffer, depending on "type", so that the stats can be sent over
38 * the link as well.
39 */
40
41void
42ttystats(ttyp)
43 struct ttys *ttyp;
44{
45 struct slirp_ifstats *is = &ttyp->ifstats;
46 char buff[512];
47
48 lprint(" \r\n");
49
50 if (if_comp & IF_COMPRESS)
51 strcpy(buff, "on");
52 else if (if_comp & IF_NOCOMPRESS)
53 strcpy(buff, "off");
54 else
55 strcpy(buff, "off (for now)");
56 lprint("Unit %d:\r\n", ttyp->unit);
57 lprint(" using %s encapsulation (VJ compression is %s)\r\n", (
58#ifdef USE_PPP
59 ttyp->proto==PROTO_PPP?"PPP":
60#endif
61 "SLIP"), buff);
62 lprint(" %d baudrate\r\n", ttyp->baud);
63 lprint(" interface is %s\r\n", ttyp->up?"up":"down");
64 lprint(" using fd %d, guardian pid is %d\r\n", ttyp->fd, ttyp->pid);
65#ifndef FULL_BOLT
66 lprint(" towrite is %d bytes\r\n", ttyp->towrite);
67#endif
68 if (ttyp->zeros)
69 lprint(" %d zeros have been typed\r\n", ttyp->zeros);
70 else if (ttyp->ones)
71 lprint(" %d ones have been typed\r\n", ttyp->ones);
72 lprint("Interface stats:\r\n");
73 lprint(" %6d output packets sent (%d bytes)\r\n", is->out_pkts, is->out_bytes);
74 lprint(" %6d output packets dropped (%d bytes)\r\n", is->out_errpkts, is->out_errbytes);
75 lprint(" %6d input packets received (%d bytes)\r\n", is->in_pkts, is->in_bytes);
76 lprint(" %6d input packets dropped (%d bytes)\r\n", is->in_errpkts, is->in_errbytes);
77 lprint(" %6d bad input packets\r\n", is->in_mbad);
78}
79
80void
81allttystats()
82{
83 struct ttys *ttyp;
84
85 for (ttyp = ttys; ttyp; ttyp = ttyp->next)
86 ttystats(ttyp);
87}
88#endif
89
90void
91ipstats(PNATState pData)
92{
93 lprint(" \r\n");
94
95 lprint("IP stats:\r\n");
96 lprint(" %6d total packets received (%d were unaligned)\r\n",
97 ipstat.ips_total, ipstat.ips_unaligned);
98 lprint(" %6d with incorrect version\r\n", ipstat.ips_badvers);
99 lprint(" %6d with bad header checksum\r\n", ipstat.ips_badsum);
100 lprint(" %6d with length too short (len < sizeof(iphdr))\r\n", ipstat.ips_tooshort);
101 lprint(" %6d with length too small (len < ip->len)\r\n", ipstat.ips_toosmall);
102 lprint(" %6d with bad header length\r\n", ipstat.ips_badhlen);
103 lprint(" %6d with bad packet length\r\n", ipstat.ips_badlen);
104 lprint(" %6d fragments received\r\n", ipstat.ips_fragments);
105 lprint(" %6d fragments dropped\r\n", ipstat.ips_fragdropped);
106 lprint(" %6d fragments timed out\r\n", ipstat.ips_fragtimeout);
107 lprint(" %6d packets reassembled ok\r\n", ipstat.ips_reassembled);
108 lprint(" %6d outgoing packets fragmented\r\n", ipstat.ips_fragmented);
109 lprint(" %6d total outgoing fragments\r\n", ipstat.ips_ofragments);
110 lprint(" %6d with bad protocol field\r\n", ipstat.ips_noproto);
111 lprint(" %6d total packets delivered\r\n", ipstat.ips_delivered);
112}
113
114#if 0
115void
116vjstats()
117{
118 lprint(" \r\n");
119
120 lprint("VJ compression stats:\r\n");
121
122 lprint(" %6d outbound packets (%d compressed)\r\n",
123 comp_s.sls_packets, comp_s.sls_compressed);
124 lprint(" %6d searches for connection stats (%d misses)\r\n",
125 comp_s.sls_searches, comp_s.sls_misses);
126 lprint(" %6d inbound uncompressed packets\r\n", comp_s.sls_uncompressedin);
127 lprint(" %6d inbound compressed packets\r\n", comp_s.sls_compressedin);
128 lprint(" %6d inbound unknown type packets\r\n", comp_s.sls_errorin);
129 lprint(" %6d inbound packets tossed due to error\r\n", comp_s.sls_tossed);
130}
131#endif
132
133void
134tcpstats(PNATState pData)
135{
136 lprint(" \r\n");
137
138 lprint("TCP stats:\r\n");
139
140 lprint(" %6d packets sent\r\n", tcpstat.tcps_sndtotal);
141 lprint(" %6d data packets (%d bytes)\r\n",
142 tcpstat.tcps_sndpack, tcpstat.tcps_sndbyte);
143 lprint(" %6d data packets retransmitted (%d bytes)\r\n",
144 tcpstat.tcps_sndrexmitpack, tcpstat.tcps_sndrexmitbyte);
145 lprint(" %6d ack-only packets (%d delayed)\r\n",
146 tcpstat.tcps_sndacks, tcpstat.tcps_delack);
147 lprint(" %6d URG only packets\r\n", tcpstat.tcps_sndurg);
148 lprint(" %6d window probe packets\r\n", tcpstat.tcps_sndprobe);
149 lprint(" %6d window update packets\r\n", tcpstat.tcps_sndwinup);
150 lprint(" %6d control (SYN/FIN/RST) packets\r\n", tcpstat.tcps_sndctrl);
151 lprint(" %6d times tcp_output did nothing\r\n", tcpstat.tcps_didnuttin);
152
153 lprint(" %6d packets received\r\n", tcpstat.tcps_rcvtotal);
154 lprint(" %6d acks (for %d bytes)\r\n",
155 tcpstat.tcps_rcvackpack, tcpstat.tcps_rcvackbyte);
156 lprint(" %6d duplicate acks\r\n", tcpstat.tcps_rcvdupack);
157 lprint(" %6d acks for unsent data\r\n", tcpstat.tcps_rcvacktoomuch);
158 lprint(" %6d packets received in sequence (%d bytes)\r\n",
159 tcpstat.tcps_rcvpack, tcpstat.tcps_rcvbyte);
160 lprint(" %6d completely duplicate packets (%d bytes)\r\n",
161 tcpstat.tcps_rcvduppack, tcpstat.tcps_rcvdupbyte);
162
163 lprint(" %6d packets with some duplicate data (%d bytes duped)\r\n",
164 tcpstat.tcps_rcvpartduppack, tcpstat.tcps_rcvpartdupbyte);
165 lprint(" %6d out-of-order packets (%d bytes)\r\n",
166 tcpstat.tcps_rcvoopack, tcpstat.tcps_rcvoobyte);
167 lprint(" %6d packets of data after window (%d bytes)\r\n",
168 tcpstat.tcps_rcvpackafterwin, tcpstat.tcps_rcvbyteafterwin);
169 lprint(" %6d window probes\r\n", tcpstat.tcps_rcvwinprobe);
170 lprint(" %6d window update packets\r\n", tcpstat.tcps_rcvwinupd);
171 lprint(" %6d packets received after close\r\n", tcpstat.tcps_rcvafterclose);
172 lprint(" %6d discarded for bad checksums\r\n", tcpstat.tcps_rcvbadsum);
173 lprint(" %6d discarded for bad header offset fields\r\n",
174 tcpstat.tcps_rcvbadoff);
175
176 lprint(" %6d connection requests\r\n", tcpstat.tcps_connattempt);
177 lprint(" %6d connection accepts\r\n", tcpstat.tcps_accepts);
178 lprint(" %6d connections established (including accepts)\r\n", tcpstat.tcps_connects);
179 lprint(" %6d connections closed (including %d drop)\r\n",
180 tcpstat.tcps_closed, tcpstat.tcps_drops);
181 lprint(" %6d embryonic connections dropped\r\n", tcpstat.tcps_conndrops);
182 lprint(" %6d segments we tried to get rtt (%d succeeded)\r\n",
183 tcpstat.tcps_segstimed, tcpstat.tcps_rttupdated);
184 lprint(" %6d retransmit timeouts\r\n", tcpstat.tcps_rexmttimeo);
185 lprint(" %6d connections dropped by rxmt timeout\r\n",
186 tcpstat.tcps_timeoutdrop);
187 lprint(" %6d persist timeouts\r\n", tcpstat.tcps_persisttimeo);
188 lprint(" %6d keepalive timeouts\r\n", tcpstat.tcps_keeptimeo);
189 lprint(" %6d keepalive probes sent\r\n", tcpstat.tcps_keepprobe);
190 lprint(" %6d connections dropped by keepalive\r\n", tcpstat.tcps_keepdrops);
191 lprint(" %6d correct ACK header predictions\r\n", tcpstat.tcps_predack);
192 lprint(" %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
193 lprint(" %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss);
194
195
196/* lprint(" Packets received too short: %d\r\n", tcpstat.tcps_rcvshort); */
197/* lprint(" Segments dropped due to PAWS: %d\r\n", tcpstat.tcps_pawsdrop); */
198
199}
200
201void
202udpstats(PNATState pData)
203{
204 lprint(" \r\n");
205
206 lprint("UDP stats:\r\n");
207 lprint(" %6d datagrams received\r\n", udpstat.udps_ipackets);
208 lprint(" %6d with packets shorter than header\r\n", udpstat.udps_hdrops);
209 lprint(" %6d with bad checksums\r\n", udpstat.udps_badsum);
210 lprint(" %6d with data length larger than packet\r\n", udpstat.udps_badlen);
211 lprint(" %6d UDP socket cache misses\r\n", udpstat.udpps_pcbcachemiss);
212 lprint(" %6d datagrams sent\r\n", udpstat.udps_opackets);
213}
214
215void
216icmpstats(PNATState pData)
217{
218 lprint(" \r\n");
219 lprint("ICMP stats:\r\n");
220 lprint(" %6d ICMP packets received\r\n", icmpstat.icps_received);
221 lprint(" %6d were too short\r\n", icmpstat.icps_tooshort);
222 lprint(" %6d with bad checksums\r\n", icmpstat.icps_checksum);
223 lprint(" %6d with type not supported\r\n", icmpstat.icps_notsupp);
224 lprint(" %6d with bad type feilds\r\n", icmpstat.icps_badtype);
225 lprint(" %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect);
226}
227
228void
229mbufstats(PNATState pData)
230{
231 struct mbuf *m;
232 int i;
233
234 lprint(" \r\n");
235
236 lprint("Mbuf stats:\r\n");
237
238 lprint(" %6d mbufs allocated (%d max)\r\n", mbuf_alloced, mbuf_max);
239
240 i = 0;
241 for (m = m_freelist.m_next; m != &m_freelist; m = m->m_next)
242 i++;
243 lprint(" %6d mbufs on free list\r\n", i);
244
245 i = 0;
246 for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next)
247 i++;
248 lprint(" %6d mbufs on used list\r\n", i);
249 lprint(" %6d mbufs queued as packets\r\n\r\n", if_queued);
250}
251
252void
253sockstats(PNATState pData)
254{
255 char buff[256];
256 int n;
257 struct socket *so;
258
259 lprint(" \r\n");
260
261 lprint(
262 "Proto[state] Sock Local Address, Port Remote Address, Port RecvQ SendQ\r\n");
263
264 for (so = tcb.so_next; so != &tcb; so = so->so_next) {
265
266 n = sprintf(buff, "tcp[%s]", so->so_tcpcb?tcpstates[so->so_tcpcb->t_state]:"NONE");
267 while (n < 17)
268 buff[n++] = ' ';
269 buff[17] = 0;
270 lprint("%s %3d %15s %5d ",
271 buff, so->s,
272 inet_ntoa(so->so_laddr), ntohs(so->so_lport));
273 lprint("%15s %5d %5d %5d\r\n",
274 inet_ntoa(so->so_faddr), ntohs(so->so_fport),
275 so->so_rcv.sb_cc, so->so_snd.sb_cc);
276 }
277
278 for (so = udb.so_next; so != &udb; so = so->so_next) {
279
280 n = sprintf(buff, "udp[%d sec]", (so->so_expire - curtime) / 1000);
281 while (n < 17)
282 buff[n++] = ' ';
283 buff[17] = 0;
284 lprint("%s %3d %15s %5d ",
285 buff, so->s,
286 inet_ntoa(so->so_laddr), ntohs(so->so_lport));
287 lprint("%15s %5d %5d %5d\r\n",
288 inet_ntoa(so->so_faddr), ntohs(so->so_fport),
289 so->so_rcv.sb_cc, so->so_snd.sb_cc);
290 }
291}
292
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette