debug.c revision a39ab93d71daee43e60b32f614c426492d5cf2d2
/*
* Copyright (c) 1995 Danny Gasparovski.
* Portions copyright (c) 2000 Kelly Price.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/
#include <slirp.h>
#ifndef VBOX
#ifdef DEBUG
int dostats = 1;
#else
int dostats = 0;
#endif
int slirp_debug = 0;
#endif /* !VBOX */
#ifndef VBOX
#endif
/* Carry over one item from main.c so that the tty's restored.
extern struct termios slirp_tty_settings;
extern int slirp_tty_restore;
#ifndef VBOX
void
char *file;
int dbg;
{
/* Close the old debugging file */
if (dfd)
#if 0
#endif
slirp_debug = dbg;
} else {
lprint("Error: Debugging file \"%s\" could not be opened: %s\r\n",
}
}
#endif /* !VBOX */
#ifndef VBOX
/*
* Dump a packet in the same format as tcpdump -x
*/
#ifdef DEBUG
void
dump_packet(dat, n)
void *dat;
int n;
{
#ifndef VBOX
int j,k;
n /= 16;
n++;
for(j = 0; j < n; j++) {
for(k = 0; k < 6; k++)
}
#else /* VBOX */
#endif /* VBOX */
}
#endif
#endif /* !VBOX */
#if 0
/*
* Statistic routines
*
* These will print statistics to the screen, the debug file (dfd), or
* a buffer, depending on "type", so that the stats can be sent over
* the link as well.
*/
void
{
char buff[512];
lprint(" \r\n");
if (if_comp & IF_COMPRESS)
else if (if_comp & IF_NOCOMPRESS)
else
lprint(" using %s encapsulation (VJ compression is %s)\r\n", (
#ifdef USE_PPP
#endif
"SLIP"), buff);
#ifndef FULL_BOLT
#endif
lprint("Interface stats:\r\n");
}
void
{
}
#endif
void
#ifdef VBOX
#else /* !VBOX */
ipstats()
#endif /* !VBOX */
{
lprint(" \r\n");
lprint("IP stats:\r\n");
lprint(" %6d total packets received (%d were unaligned)\r\n",
}
#if 0
void
vjstats()
{
lprint(" \r\n");
lprint("VJ compression stats:\r\n");
lprint(" %6d outbound packets (%d compressed)\r\n",
lprint(" %6d searches for connection stats (%d misses)\r\n",
}
#endif
void
#ifdef VBOX
#else /* !VBOX */
tcpstats()
#endif /* !VBOX */
{
lprint(" \r\n");
lprint("TCP stats:\r\n");
lprint(" %6d data packets (%d bytes)\r\n",
lprint(" %6d data packets retransmitted (%d bytes)\r\n",
lprint(" %6d ack-only packets (%d delayed)\r\n",
lprint(" %6d acks (for %d bytes)\r\n",
lprint(" %6d packets received in sequence (%d bytes)\r\n",
lprint(" %6d completely duplicate packets (%d bytes)\r\n",
lprint(" %6d packets with some duplicate data (%d bytes duped)\r\n",
lprint(" %6d out-of-order packets (%d bytes)\r\n",
lprint(" %6d packets of data after window (%d bytes)\r\n",
lprint(" %6d discarded for bad header offset fields\r\n",
lprint(" %6d connections closed (including %d drop)\r\n",
lprint(" %6d segments we tried to get rtt (%d succeeded)\r\n",
lprint(" %6d connections dropped by rxmt timeout\r\n",
/* lprint(" Packets received too short: %d\r\n", tcpstat.tcps_rcvshort); */
/* lprint(" Segments dropped due to PAWS: %d\r\n", tcpstat.tcps_pawsdrop); */
}
void
#ifdef VBOX
#else /* !VBOX */
udpstats()
#endif /* !VBOX */
{
lprint(" \r\n");
lprint("UDP stats:\r\n");
}
void
#ifdef VBOX
#else /* !VBOX */
#endif /* !VBOX */
{
lprint(" \r\n");
lprint("ICMP stats:\r\n");
}
void
#ifdef VBOX
#else /* !VBOX */
#endif /* !VBOX */
{
struct mbuf *m;
int i;
lprint(" \r\n");
lprint("Mbuf stats:\r\n");
i = 0;
i++;
lprint(" %6d mbufs on free list\r\n", i);
i = 0;
i++;
lprint(" %6d mbufs on used list\r\n", i);
}
void
#ifdef VBOX
#else /* !VBOX */
#endif /* !VBOX */
{
char buff[256];
int n;
lprint(" \r\n");
"Proto[state] Sock Local Address, Port Remote Address, Port RecvQ SendQ\r\n");
while (n < 17)
buff[n++] = ' ';
buff[17] = 0;
lprint("%s %3d %15s %5d ",
lprint("%15s %5d %5d %5d\r\n",
}
while (n < 17)
buff[n++] = ' ';
buff[17] = 0;
lprint("%s %3d %15s %5d ",
lprint("%15s %5d %5d %5d\r\n",
}
}
#if 0
void
int exit_status;
{
DEBUG_CALL("slirp_exit");
if (dostats) {
if (!dfd)
lprint_arg = (char **)&dfd;
ipstats();
tcpstats();
udpstats();
icmpstats();
mbufstats();
sockstats();
allttystats();
vjstats();
}
if (slirp_forked) {
/* Menendez time */
lprint("Couldn't kill parent process %ld!\n",
(long) getppid());
}
/* Restore the terminal if we gotta */
}
#endif