Statistics
| Branch: | Revision:

root / slirp / debug.c @ 31a60e22

History | View | Annotate | Download (11.7 kB)

1 f0cbd3ec bellard
/*
2 f0cbd3ec bellard
 * Copyright (c) 1995 Danny Gasparovski.
3 f0cbd3ec bellard
 * Portions copyright (c) 2000 Kelly Price.
4 5fafdf24 ths
 *
5 5fafdf24 ths
 * Please read the file COPYRIGHT for the
6 f0cbd3ec bellard
 * terms and conditions of the copyright.
7 f0cbd3ec bellard
 */
8 f0cbd3ec bellard
9 f0cbd3ec bellard
#include <slirp.h>
10 f0cbd3ec bellard
11 f0cbd3ec bellard
FILE *dfd = NULL;
12 f0cbd3ec bellard
#ifdef DEBUG
13 f0cbd3ec bellard
int dostats = 1;
14 f0cbd3ec bellard
#else
15 f0cbd3ec bellard
int dostats = 0;
16 f0cbd3ec bellard
#endif
17 f0cbd3ec bellard
int slirp_debug = 0;
18 f0cbd3ec bellard
19 f0cbd3ec bellard
extern char *strerror _P((int));
20 f0cbd3ec bellard
21 5fafdf24 ths
/* Carry over one item from main.c so that the tty's restored.
22 f0cbd3ec bellard
 * Only done when the tty being used is /dev/tty --RedWolf */
23 31a60e22 blueswir1
#ifndef CONFIG_QEMU
24 f0cbd3ec bellard
extern struct termios slirp_tty_settings;
25 f0cbd3ec bellard
extern int slirp_tty_restore;
26 f0cbd3ec bellard
27 f0cbd3ec bellard
28 f0cbd3ec bellard
void
29 f0cbd3ec bellard
debug_init(file, dbg)
30 f0cbd3ec bellard
        char *file;
31 f0cbd3ec bellard
        int dbg;
32 f0cbd3ec bellard
{
33 f0cbd3ec bellard
        /* Close the old debugging file */
34 f0cbd3ec bellard
        if (dfd)
35 f0cbd3ec bellard
           fclose(dfd);
36 5fafdf24 ths
37 f0cbd3ec bellard
        dfd = fopen(file,"w");
38 f0cbd3ec bellard
        if (dfd != NULL) {
39 f0cbd3ec bellard
#if 0
40 f0cbd3ec bellard
                fprintf(dfd,"Slirp %s - Debugging Started.\n", SLIRP_VERSION);
41 f0cbd3ec bellard
#endif
42 f0cbd3ec bellard
                fprintf(dfd,"Debugging Started level %i.\r\n",dbg);
43 f0cbd3ec bellard
                fflush(dfd);
44 f0cbd3ec bellard
                slirp_debug = dbg;
45 f0cbd3ec bellard
        } else {
46 f0cbd3ec bellard
                lprint("Error: Debugging file \"%s\" could not be opened: %s\r\n",
47 f0cbd3ec bellard
                        file, strerror(errno));
48 f0cbd3ec bellard
        }
49 f0cbd3ec bellard
}
50 f0cbd3ec bellard
51 f0cbd3ec bellard
/*
52 f0cbd3ec bellard
 * Dump a packet in the same format as tcpdump -x
53 f0cbd3ec bellard
 */
54 f0cbd3ec bellard
#ifdef DEBUG
55 f0cbd3ec bellard
void
56 f0cbd3ec bellard
dump_packet(dat, n)
57 f0cbd3ec bellard
        void *dat;
58 f0cbd3ec bellard
        int n;
59 f0cbd3ec bellard
{
60 f0cbd3ec bellard
        u_char *pptr = (u_char *)dat;
61 f0cbd3ec bellard
        int j,k;
62 5fafdf24 ths
63 f0cbd3ec bellard
        n /= 16;
64 f0cbd3ec bellard
        n++;
65 f0cbd3ec bellard
        DEBUG_MISC((dfd, "PACKET DUMPED: \n"));
66 f0cbd3ec bellard
        for(j = 0; j < n; j++) {
67 f0cbd3ec bellard
                for(k = 0; k < 6; k++)
68 f0cbd3ec bellard
                        DEBUG_MISC((dfd, "%02x ", *pptr++));
69 f0cbd3ec bellard
                DEBUG_MISC((dfd, "\n"));
70 f0cbd3ec bellard
                fflush(dfd);
71 f0cbd3ec bellard
        }
72 f0cbd3ec bellard
}
73 f0cbd3ec bellard
#endif
74 31a60e22 blueswir1
#endif
75 f0cbd3ec bellard
76 31a60e22 blueswir1
#ifdef LOG_ENABLED
77 f0cbd3ec bellard
#if 0
78 f0cbd3ec bellard
/*
79 f0cbd3ec bellard
 * Statistic routines
80 5fafdf24 ths
 *
81 f0cbd3ec bellard
 * These will print statistics to the screen, the debug file (dfd), or
82 f0cbd3ec bellard
 * a buffer, depending on "type", so that the stats can be sent over
83 f0cbd3ec bellard
 * the link as well.
84 f0cbd3ec bellard
 */
85 f0cbd3ec bellard

86 31a60e22 blueswir1
static void
87 f0cbd3ec bellard
ttystats(ttyp)
88 f0cbd3ec bellard
        struct ttys *ttyp;
89 f0cbd3ec bellard
{
90 f0cbd3ec bellard
        struct slirp_ifstats *is = &ttyp->ifstats;
91 f0cbd3ec bellard
        char buff[512];
92 5fafdf24 ths

93 f0cbd3ec bellard
        lprint(" \r\n");
94 5fafdf24 ths

95 f0cbd3ec bellard
        if (if_comp & IF_COMPRESS)
96 f0cbd3ec bellard
           strcpy(buff, "on");
97 f0cbd3ec bellard
        else if (if_comp & IF_NOCOMPRESS)
98 f0cbd3ec bellard
           strcpy(buff, "off");
99 f0cbd3ec bellard
        else
100 f0cbd3ec bellard
           strcpy(buff, "off (for now)");
101 f0cbd3ec bellard
        lprint("Unit %d:\r\n", ttyp->unit);
102 f0cbd3ec bellard
        lprint("  using %s encapsulation (VJ compression is %s)\r\n", (
103 f0cbd3ec bellard
#ifdef USE_PPP
104 f0cbd3ec bellard
               ttyp->proto==PROTO_PPP?"PPP":
105 f0cbd3ec bellard
#endif
106 f0cbd3ec bellard
               "SLIP"), buff);
107 f0cbd3ec bellard
        lprint("  %d baudrate\r\n", ttyp->baud);
108 f0cbd3ec bellard
        lprint("  interface is %s\r\n", ttyp->up?"up":"down");
109 f0cbd3ec bellard
        lprint("  using fd %d, guardian pid is %d\r\n", ttyp->fd, ttyp->pid);
110 f0cbd3ec bellard
#ifndef FULL_BOLT
111 f0cbd3ec bellard
        lprint("  towrite is %d bytes\r\n", ttyp->towrite);
112 f0cbd3ec bellard
#endif
113 f0cbd3ec bellard
        if (ttyp->zeros)
114 f0cbd3ec bellard
           lprint("  %d zeros have been typed\r\n", ttyp->zeros);
115 f0cbd3ec bellard
        else if (ttyp->ones)
116 f0cbd3ec bellard
           lprint("  %d ones have been typed\r\n", ttyp->ones);
117 f0cbd3ec bellard
        lprint("Interface stats:\r\n");
118 f0cbd3ec bellard
        lprint("  %6d output packets sent (%d bytes)\r\n", is->out_pkts, is->out_bytes);
119 f0cbd3ec bellard
        lprint("  %6d output packets dropped (%d bytes)\r\n", is->out_errpkts, is->out_errbytes);
120 f0cbd3ec bellard
        lprint("  %6d input packets received (%d bytes)\r\n", is->in_pkts, is->in_bytes);
121 f0cbd3ec bellard
        lprint("  %6d input packets dropped (%d bytes)\r\n", is->in_errpkts, is->in_errbytes);
122 f0cbd3ec bellard
        lprint("  %6d bad input packets\r\n", is->in_mbad);
123 f0cbd3ec bellard
}
124 f0cbd3ec bellard
125 31a60e22 blueswir1
static void
126 31a60e22 blueswir1
allttystats(void)
127 f0cbd3ec bellard
{
128 f0cbd3ec bellard
        struct ttys *ttyp;
129 5fafdf24 ths
130 f0cbd3ec bellard
        for (ttyp = ttys; ttyp; ttyp = ttyp->next)
131 f0cbd3ec bellard
           ttystats(ttyp);
132 f0cbd3ec bellard
}
133 f0cbd3ec bellard
#endif
134 f0cbd3ec bellard
135 31a60e22 blueswir1
static void
136 31a60e22 blueswir1
ipstats(void)
137 f0cbd3ec bellard
{
138 5fafdf24 ths
        lprint(" \r\n");
139 f0cbd3ec bellard
140 f0cbd3ec bellard
        lprint("IP stats:\r\n");
141 f0cbd3ec bellard
        lprint("  %6d total packets received (%d were unaligned)\r\n",
142 f0cbd3ec bellard
                        ipstat.ips_total, ipstat.ips_unaligned);
143 f0cbd3ec bellard
        lprint("  %6d with incorrect version\r\n", ipstat.ips_badvers);
144 f0cbd3ec bellard
        lprint("  %6d with bad header checksum\r\n", ipstat.ips_badsum);
145 f0cbd3ec bellard
        lprint("  %6d with length too short (len < sizeof(iphdr))\r\n", ipstat.ips_tooshort);
146 f0cbd3ec bellard
        lprint("  %6d with length too small (len < ip->len)\r\n", ipstat.ips_toosmall);
147 f0cbd3ec bellard
        lprint("  %6d with bad header length\r\n", ipstat.ips_badhlen);
148 f0cbd3ec bellard
        lprint("  %6d with bad packet length\r\n", ipstat.ips_badlen);
149 f0cbd3ec bellard
        lprint("  %6d fragments received\r\n", ipstat.ips_fragments);
150 f0cbd3ec bellard
        lprint("  %6d fragments dropped\r\n", ipstat.ips_fragdropped);
151 f0cbd3ec bellard
        lprint("  %6d fragments timed out\r\n", ipstat.ips_fragtimeout);
152 f0cbd3ec bellard
        lprint("  %6d packets reassembled ok\r\n", ipstat.ips_reassembled);
153 f0cbd3ec bellard
        lprint("  %6d outgoing packets fragmented\r\n", ipstat.ips_fragmented);
154 f0cbd3ec bellard
        lprint("  %6d total outgoing fragments\r\n", ipstat.ips_ofragments);
155 f0cbd3ec bellard
        lprint("  %6d with bad protocol field\r\n", ipstat.ips_noproto);
156 f0cbd3ec bellard
        lprint("  %6d total packets delivered\r\n", ipstat.ips_delivered);
157 f0cbd3ec bellard
}
158 f0cbd3ec bellard
159 31a60e22 blueswir1
#ifndef CONFIG_QEMU
160 31a60e22 blueswir1
static void
161 31a60e22 blueswir1
vjstats(void)
162 f0cbd3ec bellard
{
163 f0cbd3ec bellard
        lprint(" \r\n");
164 5fafdf24 ths
165 f0cbd3ec bellard
        lprint("VJ compression stats:\r\n");
166 5fafdf24 ths
167 f0cbd3ec bellard
        lprint("  %6d outbound packets (%d compressed)\r\n",
168 f0cbd3ec bellard
               comp_s.sls_packets, comp_s.sls_compressed);
169 f0cbd3ec bellard
        lprint("  %6d searches for connection stats (%d misses)\r\n",
170 f0cbd3ec bellard
               comp_s.sls_searches, comp_s.sls_misses);
171 f0cbd3ec bellard
        lprint("  %6d inbound uncompressed packets\r\n", comp_s.sls_uncompressedin);
172 f0cbd3ec bellard
        lprint("  %6d inbound compressed packets\r\n", comp_s.sls_compressedin);
173 f0cbd3ec bellard
        lprint("  %6d inbound unknown type packets\r\n", comp_s.sls_errorin);
174 f0cbd3ec bellard
        lprint("  %6d inbound packets tossed due to error\r\n", comp_s.sls_tossed);
175 f0cbd3ec bellard
}
176 f0cbd3ec bellard
#endif
177 f0cbd3ec bellard
178 31a60e22 blueswir1
static void
179 31a60e22 blueswir1
tcpstats(void)
180 f0cbd3ec bellard
{
181 f0cbd3ec bellard
        lprint(" \r\n");
182 f0cbd3ec bellard
183 f0cbd3ec bellard
        lprint("TCP stats:\r\n");
184 5fafdf24 ths
185 f0cbd3ec bellard
        lprint("  %6d packets sent\r\n", tcpstat.tcps_sndtotal);
186 f0cbd3ec bellard
        lprint("          %6d data packets (%d bytes)\r\n",
187 f0cbd3ec bellard
                        tcpstat.tcps_sndpack, tcpstat.tcps_sndbyte);
188 f0cbd3ec bellard
        lprint("          %6d data packets retransmitted (%d bytes)\r\n",
189 f0cbd3ec bellard
                        tcpstat.tcps_sndrexmitpack, tcpstat.tcps_sndrexmitbyte);
190 f0cbd3ec bellard
        lprint("          %6d ack-only packets (%d delayed)\r\n",
191 f0cbd3ec bellard
                        tcpstat.tcps_sndacks, tcpstat.tcps_delack);
192 f0cbd3ec bellard
        lprint("          %6d URG only packets\r\n", tcpstat.tcps_sndurg);
193 f0cbd3ec bellard
        lprint("          %6d window probe packets\r\n", tcpstat.tcps_sndprobe);
194 f0cbd3ec bellard
        lprint("          %6d window update packets\r\n", tcpstat.tcps_sndwinup);
195 f0cbd3ec bellard
        lprint("          %6d control (SYN/FIN/RST) packets\r\n", tcpstat.tcps_sndctrl);
196 f0cbd3ec bellard
        lprint("          %6d times tcp_output did nothing\r\n", tcpstat.tcps_didnuttin);
197 5fafdf24 ths
198 3b46e624 ths
        lprint("  %6d packets received\r\n", tcpstat.tcps_rcvtotal);
199 f0cbd3ec bellard
        lprint("          %6d acks (for %d bytes)\r\n",
200 f0cbd3ec bellard
                        tcpstat.tcps_rcvackpack, tcpstat.tcps_rcvackbyte);
201 f0cbd3ec bellard
        lprint("          %6d duplicate acks\r\n", tcpstat.tcps_rcvdupack);
202 f0cbd3ec bellard
        lprint("          %6d acks for unsent data\r\n", tcpstat.tcps_rcvacktoomuch);
203 f0cbd3ec bellard
        lprint("          %6d packets received in sequence (%d bytes)\r\n",
204 f0cbd3ec bellard
                        tcpstat.tcps_rcvpack, tcpstat.tcps_rcvbyte);
205 f0cbd3ec bellard
        lprint("          %6d completely duplicate packets (%d bytes)\r\n",
206 f0cbd3ec bellard
                        tcpstat.tcps_rcvduppack, tcpstat.tcps_rcvdupbyte);
207 5fafdf24 ths
208 f0cbd3ec bellard
        lprint("          %6d packets with some duplicate data (%d bytes duped)\r\n",
209 f0cbd3ec bellard
                        tcpstat.tcps_rcvpartduppack, tcpstat.tcps_rcvpartdupbyte);
210 f0cbd3ec bellard
        lprint("          %6d out-of-order packets (%d bytes)\r\n",
211 f0cbd3ec bellard
                        tcpstat.tcps_rcvoopack, tcpstat.tcps_rcvoobyte);
212 f0cbd3ec bellard
        lprint("          %6d packets of data after window (%d bytes)\r\n",
213 f0cbd3ec bellard
                        tcpstat.tcps_rcvpackafterwin, tcpstat.tcps_rcvbyteafterwin);
214 f0cbd3ec bellard
        lprint("          %6d window probes\r\n", tcpstat.tcps_rcvwinprobe);
215 f0cbd3ec bellard
        lprint("          %6d window update packets\r\n", tcpstat.tcps_rcvwinupd);
216 f0cbd3ec bellard
        lprint("          %6d packets received after close\r\n", tcpstat.tcps_rcvafterclose);
217 f0cbd3ec bellard
        lprint("          %6d discarded for bad checksums\r\n", tcpstat.tcps_rcvbadsum);
218 f0cbd3ec bellard
        lprint("          %6d discarded for bad header offset fields\r\n",
219 f0cbd3ec bellard
                        tcpstat.tcps_rcvbadoff);
220 5fafdf24 ths
221 f0cbd3ec bellard
        lprint("  %6d connection requests\r\n", tcpstat.tcps_connattempt);
222 f0cbd3ec bellard
        lprint("  %6d connection accepts\r\n", tcpstat.tcps_accepts);
223 f0cbd3ec bellard
        lprint("  %6d connections established (including accepts)\r\n", tcpstat.tcps_connects);
224 f0cbd3ec bellard
        lprint("  %6d connections closed (including %d drop)\r\n",
225 f0cbd3ec bellard
                        tcpstat.tcps_closed, tcpstat.tcps_drops);
226 f0cbd3ec bellard
        lprint("  %6d embryonic connections dropped\r\n", tcpstat.tcps_conndrops);
227 f0cbd3ec bellard
        lprint("  %6d segments we tried to get rtt (%d succeeded)\r\n",
228 f0cbd3ec bellard
                        tcpstat.tcps_segstimed, tcpstat.tcps_rttupdated);
229 f0cbd3ec bellard
        lprint("  %6d retransmit timeouts\r\n", tcpstat.tcps_rexmttimeo);
230 f0cbd3ec bellard
        lprint("          %6d connections dropped by rxmt timeout\r\n",
231 f0cbd3ec bellard
                        tcpstat.tcps_timeoutdrop);
232 f0cbd3ec bellard
        lprint("  %6d persist timeouts\r\n", tcpstat.tcps_persisttimeo);
233 f0cbd3ec bellard
        lprint("  %6d keepalive timeouts\r\n", tcpstat.tcps_keeptimeo);
234 f0cbd3ec bellard
        lprint("          %6d keepalive probes sent\r\n", tcpstat.tcps_keepprobe);
235 f0cbd3ec bellard
        lprint("          %6d connections dropped by keepalive\r\n", tcpstat.tcps_keepdrops);
236 f0cbd3ec bellard
        lprint("  %6d correct ACK header predictions\r\n", tcpstat.tcps_predack);
237 f0cbd3ec bellard
        lprint("  %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
238 f0cbd3ec bellard
        lprint("  %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss);
239 5fafdf24 ths
240 5fafdf24 ths
241 f0cbd3ec bellard
/*        lprint("    Packets received too short:                %d\r\n", tcpstat.tcps_rcvshort); */
242 f0cbd3ec bellard
/*        lprint("    Segments dropped due to PAWS:        %d\r\n", tcpstat.tcps_pawsdrop); */
243 f0cbd3ec bellard
244 f0cbd3ec bellard
}
245 f0cbd3ec bellard
246 31a60e22 blueswir1
static void
247 31a60e22 blueswir1
udpstats(void)
248 f0cbd3ec bellard
{
249 f0cbd3ec bellard
        lprint(" \r\n");
250 f0cbd3ec bellard
251 f0cbd3ec bellard
        lprint("UDP stats:\r\n");
252 f0cbd3ec bellard
        lprint("  %6d datagrams received\r\n", udpstat.udps_ipackets);
253 f0cbd3ec bellard
        lprint("  %6d with packets shorter than header\r\n", udpstat.udps_hdrops);
254 f0cbd3ec bellard
        lprint("  %6d with bad checksums\r\n", udpstat.udps_badsum);
255 f0cbd3ec bellard
        lprint("  %6d with data length larger than packet\r\n", udpstat.udps_badlen);
256 f0cbd3ec bellard
        lprint("  %6d UDP socket cache misses\r\n", udpstat.udpps_pcbcachemiss);
257 f0cbd3ec bellard
        lprint("  %6d datagrams sent\r\n", udpstat.udps_opackets);
258 f0cbd3ec bellard
}
259 f0cbd3ec bellard
260 31a60e22 blueswir1
static void
261 31a60e22 blueswir1
icmpstats(void)
262 f0cbd3ec bellard
{
263 f0cbd3ec bellard
        lprint(" \r\n");
264 f0cbd3ec bellard
        lprint("ICMP stats:\r\n");
265 f0cbd3ec bellard
        lprint("  %6d ICMP packets received\r\n", icmpstat.icps_received);
266 f0cbd3ec bellard
        lprint("  %6d were too short\r\n", icmpstat.icps_tooshort);
267 f0cbd3ec bellard
        lprint("  %6d with bad checksums\r\n", icmpstat.icps_checksum);
268 f0cbd3ec bellard
        lprint("  %6d with type not supported\r\n", icmpstat.icps_notsupp);
269 f0cbd3ec bellard
        lprint("  %6d with bad type feilds\r\n", icmpstat.icps_badtype);
270 f0cbd3ec bellard
        lprint("  %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect);
271 f0cbd3ec bellard
}
272 f0cbd3ec bellard
273 31a60e22 blueswir1
static void
274 31a60e22 blueswir1
mbufstats(void)
275 f0cbd3ec bellard
{
276 f0cbd3ec bellard
        struct mbuf *m;
277 f0cbd3ec bellard
        int i;
278 5fafdf24 ths
279 f0cbd3ec bellard
        lprint(" \r\n");
280 5fafdf24 ths
281 f0cbd3ec bellard
        lprint("Mbuf stats:\r\n");
282 f0cbd3ec bellard
283 f0cbd3ec bellard
        lprint("  %6d mbufs allocated (%d max)\r\n", mbuf_alloced, mbuf_max);
284 5fafdf24 ths
285 f0cbd3ec bellard
        i = 0;
286 f0cbd3ec bellard
        for (m = m_freelist.m_next; m != &m_freelist; m = m->m_next)
287 f0cbd3ec bellard
                i++;
288 f0cbd3ec bellard
        lprint("  %6d mbufs on free list\r\n",  i);
289 5fafdf24 ths
290 f0cbd3ec bellard
        i = 0;
291 f0cbd3ec bellard
        for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next)
292 f0cbd3ec bellard
                i++;
293 f0cbd3ec bellard
        lprint("  %6d mbufs on used list\r\n",  i);
294 f0cbd3ec bellard
        lprint("  %6d mbufs queued as packets\r\n\r\n", if_queued);
295 f0cbd3ec bellard
}
296 f0cbd3ec bellard
297 31a60e22 blueswir1
static void
298 31a60e22 blueswir1
sockstats(void)
299 f0cbd3ec bellard
{
300 f0cbd3ec bellard
        char buff[256];
301 f0cbd3ec bellard
        int n;
302 f0cbd3ec bellard
        struct socket *so;
303 f0cbd3ec bellard
304 f0cbd3ec bellard
        lprint(" \r\n");
305 5fafdf24 ths
306 f0cbd3ec bellard
        lprint(
307 f0cbd3ec bellard
           "Proto[state]     Sock     Local Address, Port  Remote Address, Port RecvQ SendQ\r\n");
308 3b46e624 ths
309 5fafdf24 ths
        for (so = tcb.so_next; so != &tcb; so = so->so_next) {
310 3b46e624 ths
311 f0cbd3ec bellard
                n = sprintf(buff, "tcp[%s]", so->so_tcpcb?tcpstates[so->so_tcpcb->t_state]:"NONE");
312 f0cbd3ec bellard
                while (n < 17)
313 f0cbd3ec bellard
                   buff[n++] = ' ';
314 f0cbd3ec bellard
                buff[17] = 0;
315 f0cbd3ec bellard
                lprint("%s %3d   %15s %5d ",
316 f0cbd3ec bellard
                                buff, so->s,
317 f0cbd3ec bellard
                                inet_ntoa(so->so_laddr), ntohs(so->so_lport));
318 f0cbd3ec bellard
                lprint("%15s %5d %5d %5d\r\n",
319 f0cbd3ec bellard
                                inet_ntoa(so->so_faddr), ntohs(so->so_fport),
320 f0cbd3ec bellard
                                so->so_rcv.sb_cc, so->so_snd.sb_cc);
321 f0cbd3ec bellard
        }
322 3b46e624 ths
323 f0cbd3ec bellard
        for (so = udb.so_next; so != &udb; so = so->so_next) {
324 3b46e624 ths
325 f0cbd3ec bellard
                n = sprintf(buff, "udp[%d sec]", (so->so_expire - curtime) / 1000);
326 f0cbd3ec bellard
                while (n < 17)
327 f0cbd3ec bellard
                   buff[n++] = ' ';
328 f0cbd3ec bellard
                buff[17] = 0;
329 f0cbd3ec bellard
                lprint("%s %3d  %15s %5d  ",
330 f0cbd3ec bellard
                                buff, so->s,
331 f0cbd3ec bellard
                                inet_ntoa(so->so_laddr), ntohs(so->so_lport));
332 f0cbd3ec bellard
                lprint("%15s %5d %5d %5d\r\n",
333 f0cbd3ec bellard
                                inet_ntoa(so->so_faddr), ntohs(so->so_fport),
334 f0cbd3ec bellard
                                so->so_rcv.sb_cc, so->so_snd.sb_cc);
335 f0cbd3ec bellard
        }
336 f0cbd3ec bellard
}
337 31a60e22 blueswir1
#endif
338 f0cbd3ec bellard
339 31a60e22 blueswir1
#ifndef CONFIG_QEMU
340 f0cbd3ec bellard
void
341 f0cbd3ec bellard
slirp_exit(exit_status)
342 f0cbd3ec bellard
        int exit_status;
343 f0cbd3ec bellard
{
344 f0cbd3ec bellard
        struct ttys *ttyp;
345 5fafdf24 ths
346 f0cbd3ec bellard
        DEBUG_CALL("slirp_exit");
347 f0cbd3ec bellard
        DEBUG_ARG("exit_status = %d", exit_status);
348 f0cbd3ec bellard
349 f0cbd3ec bellard
        if (dostats) {
350 f0cbd3ec bellard
                lprint_print = (int (*) _P((void *, const char *, va_list)))vfprintf;
351 f0cbd3ec bellard
                if (!dfd)
352 f0cbd3ec bellard
                   debug_init("slirp_stats", 0xf);
353 f0cbd3ec bellard
                lprint_arg = (char **)&dfd;
354 3b46e624 ths
355 f0cbd3ec bellard
                ipstats();
356 f0cbd3ec bellard
                tcpstats();
357 f0cbd3ec bellard
                udpstats();
358 f0cbd3ec bellard
                icmpstats();
359 f0cbd3ec bellard
                mbufstats();
360 f0cbd3ec bellard
                sockstats();
361 f0cbd3ec bellard
                allttystats();
362 f0cbd3ec bellard
                vjstats();
363 f0cbd3ec bellard
        }
364 5fafdf24 ths
365 f0cbd3ec bellard
        for (ttyp = ttys; ttyp; ttyp = ttyp->next)
366 f0cbd3ec bellard
           tty_detached(ttyp, 1);
367 5fafdf24 ths
368 f0cbd3ec bellard
        if (slirp_forked) {
369 f0cbd3ec bellard
                /* Menendez time */
370 f0cbd3ec bellard
                if (kill(getppid(), SIGQUIT) < 0)
371 f0cbd3ec bellard
                        lprint("Couldn't kill parent process %ld!\n",
372 f0cbd3ec bellard
                            (long) getppid());
373 f0cbd3ec bellard
            }
374 5fafdf24 ths
375 f0cbd3ec bellard
        /* Restore the terminal if we gotta */
376 f0cbd3ec bellard
        if(slirp_tty_restore)
377 f0cbd3ec bellard
          tcsetattr(0,TCSANOW, &slirp_tty_settings);  /* NOW DAMMIT! */
378 f0cbd3ec bellard
        exit(exit_status);
379 f0cbd3ec bellard
}
380 f0cbd3ec bellard
#endif
381 31a60e22 blueswir1
382 31a60e22 blueswir1
void
383 31a60e22 blueswir1
slirp_stats(void)
384 31a60e22 blueswir1
{
385 31a60e22 blueswir1
#ifdef LOG_ENABLED
386 31a60e22 blueswir1
    ipstats();
387 31a60e22 blueswir1
    tcpstats();
388 31a60e22 blueswir1
    udpstats();
389 31a60e22 blueswir1
    icmpstats();
390 31a60e22 blueswir1
    mbufstats();
391 31a60e22 blueswir1
    sockstats();
392 31a60e22 blueswir1
#else
393 31a60e22 blueswir1
    lprint("SLIRP statistics code not compiled.\n");
394 31a60e22 blueswir1
#endif
395 31a60e22 blueswir1
}