From owner-p4-projects@FreeBSD.ORG Thu Jun 19 23:51:25 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 00C77106567E; Thu, 19 Jun 2008 23:51:25 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B61E91065673 for ; Thu, 19 Jun 2008 23:51:24 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 9BBB48FC18 for ; Thu, 19 Jun 2008 23:51:24 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m5JNpO5Q091261 for ; Thu, 19 Jun 2008 23:51:24 GMT (envelope-from rpaulo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m5JNpOfA091259 for perforce@freebsd.org; Thu, 19 Jun 2008 23:51:24 GMT (envelope-from rpaulo@FreeBSD.org) Date: Thu, 19 Jun 2008 23:51:24 GMT Message-Id: <200806192351.m5JNpOfA091259@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rpaulo@FreeBSD.org using -f From: Rui Paulo To: Perforce Change Reviews Cc: Subject: PERFORCE change 143795 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jun 2008 23:51:25 -0000 http://perforce.freebsd.org/chv.cgi?CH=143795 Change 143795 by rpaulo@rpaulo_epsilon on 2008/06/19 23:50:47 Rename variables to more sensible names. Affected files ... .. //depot/projects/soc2008/rpaulo-tcpad/handler.c#10 edit .. //depot/projects/soc2008/rpaulo-tcpad/tcpad.h#7 edit Differences ... ==== //depot/projects/soc2008/rpaulo-tcpad/handler.c#10 (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#9 $ + * $P4: //depot/projects/soc2008/rpaulo-tcpad/handler.c#10 $ */ #include @@ -47,9 +47,9 @@ #include "debug.h" -static conn_t * find_conn(struct in_addr ipsrc, struct in_addr ipdst, +static struct tcpc *find_conn(struct in_addr ipsrc, struct in_addr ipdst, unsigned short sport, unsigned short dport); -static void print_packet(const unsigned char *bytes, const int linkhlen); +static void print_packet(const unsigned char *bytes, const int linkhlen); void tcpad_pcaphandler(unsigned char *user, const struct pcap_pkthdr *ph, @@ -58,8 +58,8 @@ const struct ip *ip; const struct tcphdr *tcp; int linkhlen; - conn_t *cp; - conn_t *rcp; + struct tcpc *cp; + struct tcpc *rcp; linkhlen = (int)*user; @@ -80,7 +80,7 @@ free(cp); } cp = malloc(sizeof(*cp)); - cp->tcpstate = TCPS_SYN_SENT; + cp->t_state = TCPS_SYN_SENT; cp->dport = tcp->th_dport; cp->sport = tcp->th_sport; cp->isv6 = 0; @@ -89,7 +89,7 @@ DPRINTF("tracking (syn) connection between %s and ", inet_ntoa(cp->sv4addr)); DPRINTF("%s\n",inet_ntoa(cp->dv4addr)); - LIST_INSERT_HEAD(&chead, cp, entries); + LIST_INSERT_HEAD(&tcpchead, cp, entries); print_packet(bytes, linkhlen); /* @@ -112,7 +112,7 @@ free(cp); } cp = malloc(sizeof(*cp)); - cp->tcpstate = TCPS_SYN_RECEIVED; + cp->t_state = TCPS_SYN_RECEIVED; cp->dport = tcp->th_dport; cp->sport = tcp->th_sport; cp->isv6 = 0; @@ -121,7 +121,7 @@ DPRINTF("tracking (syn/ack) connection between %s and ", inet_ntoa(cp->sv4addr)); DPRINTF("%s\n",inet_ntoa(cp->dv4addr)); - LIST_INSERT_HEAD(&chead, cp, entries); + LIST_INSERT_HEAD(&tcpchead, cp, entries); print_packet(bytes, linkhlen); /* rcp->pktshead should have been already malloc'ed and @@ -133,22 +133,22 @@ return; dumper_addpkt(cp->pktshead, ph, bytes); - if (cp->tcpstate == TCPS_SYN_SENT || - cp->tcpstate == TCPS_SYN_RECEIVED) { - cp->tcpstate = TCPS_ESTABLISHED; - rcp->tcpstate = TCPS_ESTABLISHED; + if (cp->t_state == TCPS_SYN_SENT || + cp->t_state == TCPS_SYN_RECEIVED) { + cp->t_state = TCPS_ESTABLISHED; + rcp->t_state = TCPS_ESTABLISHED; DPRINTF("established\n"); print_packet(bytes, linkhlen); } - if (cp->tcpstate == TCPS_ESTABLISHED && - rcp->tcpstate == TCPS_FIN_WAIT_1) { + if (cp->t_state == TCPS_ESTABLISHED && + rcp->t_state == TCPS_FIN_WAIT_1) { printf("first ack\n"); - cp->tcpstate = TCPS_CLOSE_WAIT; - rcp->tcpstate = TCPS_FIN_WAIT_2; + cp->t_state = TCPS_CLOSE_WAIT; + rcp->t_state = TCPS_FIN_WAIT_2; } - if (cp->tcpstate == TCPS_LAST_ACK || - cp->tcpstate == TCPS_CLOSING) { - cp->tcpstate = TCPS_TIME_WAIT; + if (cp->t_state == TCPS_LAST_ACK || + cp->t_state == TCPS_CLOSING) { + cp->t_state = TCPS_TIME_WAIT; printf("connection down\n"); } } else if ((tcp->th_flags & TH_FLAGS) == (TH_FIN|TH_ACK)) { @@ -156,22 +156,22 @@ return; dumper_addpkt(cp->pktshead, ph, bytes); - if (cp->tcpstate == TCPS_ESTABLISHED) { - cp->tcpstate = TCPS_FIN_WAIT_1; + if (cp->t_state == TCPS_ESTABLISHED) { + cp->t_state = TCPS_FIN_WAIT_1; DPRINTF("fin_wait_1\n"); print_packet(bytes, linkhlen); } - if (cp->tcpstate == TCPS_CLOSE_WAIT && - rcp->tcpstate == TCPS_FIN_WAIT_2) { + if (cp->t_state == TCPS_CLOSE_WAIT && + rcp->t_state == TCPS_FIN_WAIT_2) { printf("last_ack\n"); - cp->tcpstate = TCPS_TIME_WAIT; - rcp->tcpstate = TCPS_LAST_ACK; + cp->t_state = TCPS_TIME_WAIT; + rcp->t_state = TCPS_LAST_ACK; } - if (cp->tcpstate == TCPS_FIN_WAIT_1) { - cp->tcpstate = TCPS_CLOSING; + if (cp->t_state == TCPS_FIN_WAIT_1) { + cp->t_state = TCPS_CLOSING; } } else if ((tcp->th_flags & TH_FLAGS) == (TH_RST|TH_ACK)) { - if (rcp && rcp->tcpstate == TCPS_SYN_SENT) { + if (rcp && rcp->t_state == TCPS_SYN_SENT) { DPRINTF("stopped tracking connection (rst) between" " %s and ", inet_ntoa(rcp->sv4addr)); DPRINTF("%s\n",inet_ntoa(rcp->dv4addr)); @@ -182,13 +182,13 @@ } } -static conn_t * +static struct tcpc * find_conn(struct in_addr ipsrc, struct in_addr ipdst, unsigned short sport, unsigned short dport) { - conn_t *cp; + struct tcpc *cp; - LIST_FOREACH(cp, &chead, entries) { + LIST_FOREACH(cp, &tcpchead, entries) { if (memcmp(&cp->sv4addr, &ipsrc, sizeof(struct in_addr)) == 0 && memcmp(&cp->dv4addr, &ipdst, sizeof(struct in_addr)) == 0 && cp->sport == sport && cp->dport == dport) { ==== //depot/projects/soc2008/rpaulo-tcpad/tcpad.h#7 (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#6 $ + * $P4: //depot/projects/soc2008/rpaulo-tcpad/tcpad.h#7 $ */ #ifndef _TCPAD_H_ @@ -33,17 +33,17 @@ pcap_t *p; -typedef struct _conn_t { - LIST_ENTRY(_conn_t) entries; +struct tcpc { + LIST_ENTRY(tcpc) entries; struct in_addr sv4addr; struct in_addr dv4addr; unsigned short dport; unsigned short sport; - int tcpstate; /* TCP FSM state */ + int t_state; /* TCP FSM state */ int isv6; struct dumppkth *pktshead; -} conn_t; +}; -LIST_HEAD(chead, _conn_t) chead; +LIST_HEAD(tcpchead, tcpc) tcpchead; #endif /* _TCPAD_H_ */