From 460674d99fa3cda2c368453e9618111a2216140d Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Thu, 24 Feb 2011 06:48:52 +0000 Subject: =?UTF-8?q?2011-02-24=09Ralf=20Cors=C3=A9pius=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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. --- cpukit/libnetworking/netinet/tcp_debug.c | 38 +++++++++++++++++--------------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'cpukit/libnetworking/netinet/tcp_debug.c') 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 +#include "opt_inet.h" #include "opt_tcpdebug.h" #ifdef TCPDEBUG @@ -45,39 +47,39 @@ #endif #include -#include #include #include -#include -#include #include -#include -#include -#include +#include #include #include #include -#include #include #include #include -#include #include #include #include #include #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, -- cgit v1.2.3