Date: Wed, 11 Jun 2008 20:36:49 GMT From: Rui Paulo <rpaulo@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 143300 for review Message-ID: <200806112036.m5BKan9B084922@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=143300 Change 143300 by rpaulo@rpaulo_epsilon on 2008/06/11 20:35:55 Add missing dumper_* calls and make pktshead a pointer to the only list of packets in memory. Affected files ... .. //depot/projects/soc2008/rpaulo-tcpad/handler.c#6 edit .. //depot/projects/soc2008/rpaulo-tcpad/tcpad.h#6 edit Differences ... ==== //depot/projects/soc2008/rpaulo-tcpad/handler.c#6 (text+ko) ==== @@ -23,7 +23,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/soc2008/rpaulo-tcpad/handler.c#5 $ + * $P4: //depot/projects/soc2008/rpaulo-tcpad/handler.c#6 $ */ #include <stdio.h> @@ -91,8 +91,13 @@ DPRINTF("%s\n",inet_ntoa(cp->dv4addr)); LIST_INSERT_HEAD(&chead, cp, entries); print_packet(bytes, linkhlen); - TAILQ_INIT(&cp->pktshead); - dumper_addpkt(&cp->pktshead, ph, bytes); + + /* + * Packet list. Only one per connection. + */ + cp->pktshead = malloc(sizeof(*cp->pktshead)); + TAILQ_INIT(cp->pktshead); + dumper_addpkt(cp->pktshead, ph, bytes); } else if ((tcp->th_flags & TH_FLAGS) == (TH_SYN|TH_ACK)) { if (cp) { DPRINTF("connection already being tracked!\n"); @@ -112,12 +117,15 @@ DPRINTF("%s\n",inet_ntoa(cp->dv4addr)); LIST_INSERT_HEAD(&chead, cp, entries); print_packet(bytes, linkhlen); - TAILQ_INIT(&cp->pktshead); - dumper_addpkt(&cp->pktshead, ph, bytes); + + /* rcp->pktshead should have been already malloc'ed and + initted */ + cp->pktshead = rcp->pktshead; + dumper_addpkt(cp->pktshead, ph, bytes); } else if ((tcp->th_flags & TH_FLAGS) == TH_ACK) { if (cp) { - dumper_addpkt(&cp->pktshead, ph, bytes); + dumper_addpkt(cp->pktshead, ph, bytes); if (cp->tcpstate == TCPS_SYN_SENT || cp->tcpstate == TCPS_SYN_RECEIVED) { cp->tcpstate = TCPS_ESTABLISHED; @@ -133,13 +141,13 @@ } } else if ((tcp->th_flags & TH_FLAGS) == (TH_FIN|TH_ACK)) { if (cp) { - dumper_addpkt(&cp->pktshead, ph, bytes); + dumper_addpkt(cp->pktshead, ph, bytes); if (cp->tcpstate == TCPS_ESTABLISHED) { cp->tcpstate = TCPS_FIN_WAIT_1; rcp->tcpstate = TCPS_CLOSE_WAIT; DPRINTF("fin_wait_1\n"); print_packet(bytes, linkhlen); - dumper_error(p, "test.cap", &cp->pktshead); + dumper_error(p, "test.cap", cp->pktshead); } } } else if ((tcp->th_flags & TH_FLAGS) == (TH_RST|TH_ACK)) { @@ -175,6 +183,8 @@ { const struct ip *ip; const struct tcphdr *tcp; + + return; ip = (const struct ip *)linkhdr_remove(bytes, linkhlen); tcp = (const struct tcphdr *)linkhdr_remove(bytes, ==== //depot/projects/soc2008/rpaulo-tcpad/tcpad.h#6 (text+ko) ==== @@ -23,7 +23,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/soc2008/rpaulo-tcpad/tcpad.h#5 $ + * $P4: //depot/projects/soc2008/rpaulo-tcpad/tcpad.h#6 $ */ #ifndef _TCPAD_H_ @@ -41,7 +41,7 @@ unsigned short sport; int tcpstate; /* TCP FSM state */ int isv6; - struct dumppkth pktshead; + struct dumppkth *pktshead; } conn_t; LIST_HEAD(chead, _conn_t) chead;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806112036.m5BKan9B084922>