Statistics
| Branch: | Revision:

root / slirp / debug.c @ 1b2b0af5

History | View | Annotate | Download (11.3 kB)

1 f0cbd3ec bellard
/*
2 f0cbd3ec bellard
 * Copyright (c) 1995 Danny Gasparovski.
3 f0cbd3ec bellard
 * Portions copyright (c) 2000 Kelly Price.
4 f0cbd3ec bellard
 * 
5 f0cbd3ec bellard
 * 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 f0cbd3ec bellard
/* 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 f0cbd3ec bellard
extern struct termios slirp_tty_settings;
24 f0cbd3ec bellard
extern int slirp_tty_restore;
25 f0cbd3ec bellard
26 f0cbd3ec bellard
27 f0cbd3ec bellard
void
28 f0cbd3ec bellard
debug_init(file, dbg)
29 f0cbd3ec bellard
        char *file;
30 f0cbd3ec bellard
        int dbg;
31 f0cbd3ec bellard
{
32 f0cbd3ec bellard
        /* Close the old debugging file */
33 f0cbd3ec bellard
        if (dfd)
34 f0cbd3ec bellard
           fclose(dfd);
35 f0cbd3ec bellard
        
36 f0cbd3ec bellard
        dfd = fopen(file,"w");
37 f0cbd3ec bellard
        if (dfd != NULL) {
38 f0cbd3ec bellard
#if 0
39 f0cbd3ec bellard
                fprintf(dfd,"Slirp %s - Debugging Started.\n", SLIRP_VERSION);
40 f0cbd3ec bellard
#endif
41 f0cbd3ec bellard
                fprintf(dfd,"Debugging Started level %i.\r\n",dbg);
42 f0cbd3ec bellard
                fflush(dfd);
43 f0cbd3ec bellard
                slirp_debug = dbg;
44 f0cbd3ec bellard
        } else {
45 f0cbd3ec bellard
                lprint("Error: Debugging file \"%s\" could not be opened: %s\r\n",
46 f0cbd3ec bellard
                        file, strerror(errno));
47 f0cbd3ec bellard
        }
48 f0cbd3ec bellard
}
49 f0cbd3ec bellard
50 f0cbd3ec bellard
/*
51 f0cbd3ec bellard
 * Dump a packet in the same format as tcpdump -x
52 f0cbd3ec bellard
 */
53 f0cbd3ec bellard
#ifdef DEBUG
54 f0cbd3ec bellard
void
55 f0cbd3ec bellard
dump_packet(dat, n)
56 f0cbd3ec bellard
        void *dat;
57 f0cbd3ec bellard
        int n;
58 f0cbd3ec bellard
{
59 f0cbd3ec bellard
        u_char *pptr = (u_char *)dat;
60 f0cbd3ec bellard
        int j,k;
61 f0cbd3ec bellard
        
62 f0cbd3ec bellard
        n /= 16;
63 f0cbd3ec bellard
        n++;
64 f0cbd3ec bellard
        DEBUG_MISC((dfd, "PACKET DUMPED: \n"));
65 f0cbd3ec bellard
        for(j = 0; j < n; j++) {
66 f0cbd3ec bellard
                for(k = 0; k < 6; k++)
67 f0cbd3ec bellard
                        DEBUG_MISC((dfd, "%02x ", *pptr++));
68 f0cbd3ec bellard
                DEBUG_MISC((dfd, "\n"));
69 f0cbd3ec bellard
                fflush(dfd);
70 f0cbd3ec bellard
        }
71 f0cbd3ec bellard
}
72 f0cbd3ec bellard
#endif
73 f0cbd3ec bellard
74 f0cbd3ec bellard
#if 0
75 f0cbd3ec bellard
/*
76 f0cbd3ec bellard
 * Statistic routines
77 f0cbd3ec bellard
 * 
78 f0cbd3ec bellard
 * These will print statistics to the screen, the debug file (dfd), or
79 f0cbd3ec bellard
 * a buffer, depending on "type", so that the stats can be sent over
80 f0cbd3ec bellard
 * the link as well.
81 f0cbd3ec bellard
 */
82 f0cbd3ec bellard

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

345 f0cbd3ec bellard
        if (dostats) {
346 f0cbd3ec bellard
                lprint_print = (int (*) _P((void *, const char *, va_list)))vfprintf;
347 f0cbd3ec bellard
                if (!dfd)
348 f0cbd3ec bellard
                   debug_init("slirp_stats", 0xf);
349 f0cbd3ec bellard
                lprint_arg = (char **)&dfd;
350 f0cbd3ec bellard
                
351 f0cbd3ec bellard
                ipstats();
352 f0cbd3ec bellard
                tcpstats();
353 f0cbd3ec bellard
                udpstats();
354 f0cbd3ec bellard
                icmpstats();
355 f0cbd3ec bellard
                mbufstats();
356 f0cbd3ec bellard
                sockstats();
357 f0cbd3ec bellard
                allttystats();
358 f0cbd3ec bellard
                vjstats();
359 f0cbd3ec bellard
        }
360 f0cbd3ec bellard
        
361 f0cbd3ec bellard
        for (ttyp = ttys; ttyp; ttyp = ttyp->next)
362 f0cbd3ec bellard
           tty_detached(ttyp, 1);
363 f0cbd3ec bellard
        
364 f0cbd3ec bellard
        if (slirp_forked) {
365 f0cbd3ec bellard
                /* Menendez time */
366 f0cbd3ec bellard
                if (kill(getppid(), SIGQUIT) < 0)
367 f0cbd3ec bellard
                        lprint("Couldn't kill parent process %ld!\n",
368 f0cbd3ec bellard
                            (long) getppid());
369 f0cbd3ec bellard
            }
370 f0cbd3ec bellard
        
371 f0cbd3ec bellard
        /* Restore the terminal if we gotta */
372 f0cbd3ec bellard
        if(slirp_tty_restore)
373 f0cbd3ec bellard
          tcsetattr(0,TCSANOW, &slirp_tty_settings);  /* NOW DAMMIT! */
374 f0cbd3ec bellard
        exit(exit_status);
375 f0cbd3ec bellard
}
376 f0cbd3ec bellard
#endif