Revision 5fafdf24 slirp/debug.c

b/slirp/debug.c
1 1
/*
2 2
 * Copyright (c) 1995 Danny Gasparovski.
3 3
 * Portions copyright (c) 2000 Kelly Price.
4
 * 
5
 * Please read the file COPYRIGHT for the 
4
 *
5
 * Please read the file COPYRIGHT for the
6 6
 * terms and conditions of the copyright.
7 7
 */
8 8

  
......
18 18

  
19 19
extern char *strerror _P((int));
20 20

  
21
/* Carry over one item from main.c so that the tty's restored. 
21
/* Carry over one item from main.c so that the tty's restored.
22 22
 * Only done when the tty being used is /dev/tty --RedWolf */
23 23
extern struct termios slirp_tty_settings;
24 24
extern int slirp_tty_restore;
......
32 32
	/* Close the old debugging file */
33 33
	if (dfd)
34 34
	   fclose(dfd);
35
	
35

  
36 36
	dfd = fopen(file,"w");
37 37
	if (dfd != NULL) {
38 38
#if 0
......
58 58
{
59 59
	u_char *pptr = (u_char *)dat;
60 60
	int j,k;
61
	
61

  
62 62
	n /= 16;
63 63
	n++;
64 64
	DEBUG_MISC((dfd, "PACKET DUMPED: \n"));
......
74 74
#if 0
75 75
/*
76 76
 * Statistic routines
77
 * 
77
 *
78 78
 * These will print statistics to the screen, the debug file (dfd), or
79 79
 * a buffer, depending on "type", so that the stats can be sent over
80 80
 * the link as well.
......
86 86
{
87 87
	struct slirp_ifstats *is = &ttyp->ifstats;
88 88
	char buff[512];
89
	
89

  
90 90
	lprint(" \r\n");
91
	
91

  
92 92
	if (if_comp & IF_COMPRESS)
93 93
	   strcpy(buff, "on");
94 94
	else if (if_comp & IF_NOCOMPRESS)
......
123 123
allttystats()
124 124
{
125 125
	struct ttys *ttyp;
126
	
126

  
127 127
	for (ttyp = ttys; ttyp; ttyp = ttyp->next)
128 128
	   ttystats(ttyp);
129 129
}
......
132 132
void
133 133
ipstats()
134 134
{
135
	lprint(" \r\n");	
135
	lprint(" \r\n");
136 136

  
137 137
	lprint("IP stats:\r\n");
138 138
	lprint("  %6d total packets received (%d were unaligned)\r\n",
......
158 158
vjstats()
159 159
{
160 160
	lprint(" \r\n");
161
	
161

  
162 162
	lprint("VJ compression stats:\r\n");
163
	
163

  
164 164
	lprint("  %6d outbound packets (%d compressed)\r\n",
165 165
	       comp_s.sls_packets, comp_s.sls_compressed);
166 166
	lprint("  %6d searches for connection stats (%d misses)\r\n",
......
178 178
	lprint(" \r\n");
179 179

  
180 180
	lprint("TCP stats:\r\n");
181
	
181

  
182 182
	lprint("  %6d packets sent\r\n", tcpstat.tcps_sndtotal);
183 183
	lprint("          %6d data packets (%d bytes)\r\n",
184 184
			tcpstat.tcps_sndpack, tcpstat.tcps_sndbyte);
......
191 191
	lprint("          %6d window update packets\r\n", tcpstat.tcps_sndwinup);
192 192
	lprint("          %6d control (SYN/FIN/RST) packets\r\n", tcpstat.tcps_sndctrl);
193 193
	lprint("          %6d times tcp_output did nothing\r\n", tcpstat.tcps_didnuttin);
194
	
195
	lprint("  %6d packets received\r\n", tcpstat.tcps_rcvtotal);       
194

  
195
	lprint("  %6d packets received\r\n", tcpstat.tcps_rcvtotal);      
196 196
	lprint("          %6d acks (for %d bytes)\r\n",
197 197
			tcpstat.tcps_rcvackpack, tcpstat.tcps_rcvackbyte);
198 198
	lprint("          %6d duplicate acks\r\n", tcpstat.tcps_rcvdupack);
......
201 201
			tcpstat.tcps_rcvpack, tcpstat.tcps_rcvbyte);
202 202
        lprint("          %6d completely duplicate packets (%d bytes)\r\n",
203 203
			tcpstat.tcps_rcvduppack, tcpstat.tcps_rcvdupbyte);
204
	
204

  
205 205
	lprint("          %6d packets with some duplicate data (%d bytes duped)\r\n",
206 206
			tcpstat.tcps_rcvpartduppack, tcpstat.tcps_rcvpartdupbyte);
207 207
	lprint("          %6d out-of-order packets (%d bytes)\r\n",
......
214 214
	lprint("          %6d discarded for bad checksums\r\n", tcpstat.tcps_rcvbadsum);
215 215
	lprint("          %6d discarded for bad header offset fields\r\n",
216 216
			tcpstat.tcps_rcvbadoff);
217
	
217

  
218 218
	lprint("  %6d connection requests\r\n", tcpstat.tcps_connattempt);
219 219
	lprint("  %6d connection accepts\r\n", tcpstat.tcps_accepts);
220 220
	lprint("  %6d connections established (including accepts)\r\n", tcpstat.tcps_connects);
......
233 233
	lprint("  %6d correct ACK header predictions\r\n", tcpstat.tcps_predack);
234 234
	lprint("  %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
235 235
	lprint("  %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss);
236
	
237
	
236

  
237

  
238 238
/*	lprint("    Packets received too short:		%d\r\n", tcpstat.tcps_rcvshort); */
239 239
/*	lprint("    Segments dropped due to PAWS:	%d\r\n", tcpstat.tcps_pawsdrop); */
240 240

  
......
272 272
{
273 273
	struct mbuf *m;
274 274
	int i;
275
	
275

  
276 276
        lprint(" \r\n");
277
	
277

  
278 278
	lprint("Mbuf stats:\r\n");
279 279

  
280 280
	lprint("  %6d mbufs allocated (%d max)\r\n", mbuf_alloced, mbuf_max);
281
	
281

  
282 282
	i = 0;
283 283
	for (m = m_freelist.m_next; m != &m_freelist; m = m->m_next)
284 284
		i++;
285 285
	lprint("  %6d mbufs on free list\r\n",  i);
286
	
286

  
287 287
	i = 0;
288 288
	for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next)
289 289
		i++;
......
299 299
	struct socket *so;
300 300

  
301 301
        lprint(" \r\n");
302
	
302

  
303 303
	lprint(
304 304
	   "Proto[state]     Sock     Local Address, Port  Remote Address, Port RecvQ SendQ\r\n");
305
			
306
	for (so = tcb.so_next; so != &tcb; so = so->so_next) {
307 305
		
306
	for (so = tcb.so_next; so != &tcb; so = so->so_next) {
307
	
308 308
		n = sprintf(buff, "tcp[%s]", so->so_tcpcb?tcpstates[so->so_tcpcb->t_state]:"NONE");
309 309
		while (n < 17)
310 310
		   buff[n++] = ' ';
......
316 316
				inet_ntoa(so->so_faddr), ntohs(so->so_fport),
317 317
				so->so_rcv.sb_cc, so->so_snd.sb_cc);
318 318
	}
319
		   
319
		  
320 320
	for (so = udb.so_next; so != &udb; so = so->so_next) {
321
		
321
	
322 322
		n = sprintf(buff, "udp[%d sec]", (so->so_expire - curtime) / 1000);
323 323
		while (n < 17)
324 324
		   buff[n++] = ' ';
......
338 338
	int exit_status;
339 339
{
340 340
	struct ttys *ttyp;
341
	
341

  
342 342
	DEBUG_CALL("slirp_exit");
343 343
	DEBUG_ARG("exit_status = %d", exit_status);
344 344

  
......
347 347
		if (!dfd)
348 348
		   debug_init("slirp_stats", 0xf);
349 349
		lprint_arg = (char **)&dfd;
350
		
350
	
351 351
		ipstats();
352 352
		tcpstats();
353 353
		udpstats();
......
357 357
		allttystats();
358 358
		vjstats();
359 359
	}
360
	
360

  
361 361
	for (ttyp = ttys; ttyp; ttyp = ttyp->next)
362 362
	   tty_detached(ttyp, 1);
363
	
363

  
364 364
	if (slirp_forked) {
365 365
		/* Menendez time */
366 366
		if (kill(getppid(), SIGQUIT) < 0)
367 367
			lprint("Couldn't kill parent process %ld!\n",
368 368
			    (long) getppid());
369 369
    	}
370
	
370

  
371 371
	/* Restore the terminal if we gotta */
372 372
	if(slirp_tty_restore)
373 373
	  tcsetattr(0,TCSANOW, &slirp_tty_settings);  /* NOW DAMMIT! */

Also available in: Unified diff