summaryrefslogtreecommitdiffstats
path: root/cpukit/libnetworking/netinet/tcp_debug.c
diff options
context:
space:
mode:
authorRalf Corsepius <ralf.corsepius@rtems.org>2011-02-24 06:48:52 +0000
committerRalf Corsepius <ralf.corsepius@rtems.org>2011-02-24 06:48:52 +0000
commit460674d99fa3cda2c368453e9618111a2216140d (patch)
tree0b45ddbb060a4c6c4ee56247e82b552e8810546d /cpukit/libnetworking/netinet/tcp_debug.c
parent2011-02-23 Ralf Corsépius <ralf.corsepius@rtems.org> (diff)
downloadrtems-460674d99fa3cda2c368453e9618111a2216140d.tar.bz2
2011-02-24 Ralf Corsépius <ralf.corsepius@rtems.org>
* libnetworking/netinet/in_systm.h, libnetworking/netinet/tcp_debug.c, libnetworking/netinet/tcp_debug.h, libnetworking/netinet/tcp_seq.h, libnetworking/netinet/tcp_var.h, libnetworking/netinet/tcpip.h: Misc changes from FreeBSD.
Diffstat (limited to 'cpukit/libnetworking/netinet/tcp_debug.c')
-rw-r--r--cpukit/libnetworking/netinet/tcp_debug.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/cpukit/libnetworking/netinet/tcp_debug.c b/cpukit/libnetworking/netinet/tcp_debug.c
index acf9ea5c74..779c5fb5c7 100644
--- a/cpukit/libnetworking/netinet/tcp_debug.c
+++ b/cpukit/libnetworking/netinet/tcp_debug.c
@@ -34,6 +34,8 @@
#include "config.h"
#endif
+#include <rtems/bsd/sys/cdefs.h>
+#include "opt_inet.h"
#include "opt_tcpdebug.h"
#ifdef TCPDEBUG
@@ -45,39 +47,39 @@
#endif
#include <sys/param.h>
-#include <rtems/bsd/sys/queue.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
#include <sys/protosw.h>
-#include <errno.h>
-#include <net/route.h>
-#include <net/if.h>
+#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#include <netinet/tcp_fsm.h>
-#include <netinet/tcp_seq.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet/tcpip.h>
#include <netinet/tcp_debug.h>
#ifdef TCPDEBUG
-static int tcpconsdebug = 0; /* set to 1 to enable prints */
+static int tcpconsdebug = 0;
#endif
-static struct tcp_debug tcp_debug[TCP_NDEBUG];
-static int tcp_debx;
+/*
+ * Global ring buffer of TCP debugging state. Each entry captures a snapshot
+ * of TCP connection state at any given moment. tcp_debx addresses at the
+ * next available slot. There is no explicit export of this data structure;
+ * it will be read via /dev/kmem by debugging tools.
+ */
+static struct tcp_debug tcp_debug[TCP_NDEBUG];
+static int tcp_debx;
/*
- * Tcp debug routines
+ * Save TCP state at a given moment; optionally, both tcpcb and TCP packet
+ * header state will be saved.
*/
void
tcp_trace(short act, short ostate, struct tcpcb *tp, struct tcpiphdr *ti,
@@ -87,15 +89,16 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, struct tcpiphdr *ti,
tcp_seq seq, ack;
int len, flags;
#endif
- struct tcp_debug *td = &tcp_debug[tcp_debx++];
+ struct tcp_debug *td;
+ td = &tcp_debug[tcp_debx++];
if (tcp_debx == TCP_NDEBUG)
tcp_debx = 0;
td->td_time = iptime();
td->td_act = act;
td->td_ostate = ostate;
td->td_tcb = (caddr_t)tp;
- if (tp)
+ if (tp != NULL)
td->td_cb = *tp;
else
bzero((caddr_t)&td->td_cb, sizeof (*tp));
@@ -107,13 +110,12 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, struct tcpiphdr *ti,
#ifdef TCPDEBUG
if (tcpconsdebug == 0)
return;
- if (tp)
+ if (tp != NULL)
printf("%p %s:", tp, tcpstates[ostate]);
else
printf("???????? ");
printf("%s ", tanames[act]);
switch (act) {
-
case TA_INPUT:
case TA_OUTPUT:
case TA_DROP:
@@ -154,11 +156,11 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, struct tcpiphdr *ti,
printf("<%s>", tcptimers[req>>8]);
break;
}
- if (tp)
+ if (tp != NULL)
printf(" -> %s", tcpstates[tp->t_state]);
/* print out internal state of tp !?! */
printf("\n");
- if (tp == 0)
+ if (tp == NULL)
return;
printf("\trcv_(nxt,wnd,up) (%x,%x,%x) snd_(una,nxt,max) (%x,%x,%x)\n",
tp->rcv_nxt, tp->rcv_wnd, tp->rcv_up, tp->snd_una, tp->snd_nxt,