diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2003-03-03 23:20:59 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2003-03-03 23:20:59 +0000 |
commit | 192d29fa4d87f93aa82943b7cfb9da689b20852b (patch) | |
tree | 1e631edb8e318b6c9fc493d23496af7a267b46d9 | |
parent | 60c415087a92f208a25d8423e31ea395d8903d4b (diff) | |
download | wireshark-192d29fa4d87f93aa82943b7cfb9da689b20852b.tar.gz wireshark-192d29fa4d87f93aa82943b7cfb9da689b20852b.tar.bz2 wireshark-192d29fa4d87f93aa82943b7cfb9da689b20852b.zip |
Update for tethereal -z io,users, top talkers :
"tcpip" added.
-z io,users,tcpip will create a top talkers list of individual tcpip connections
svn path=/trunk/; revision=7264
-rw-r--r-- | doc/tethereal.pod.template | 1 | ||||
-rw-r--r-- | packet-ip.c | 3 | ||||
-rw-r--r-- | packet-tcp.c | 5 | ||||
-rw-r--r-- | packet-tcp.h | 5 | ||||
-rw-r--r-- | tap-iousers.c | 74 |
5 files changed, 83 insertions, 5 deletions
diff --git a/doc/tethereal.pod.template b/doc/tethereal.pod.template index f09c4b0d88..0b3b5b80ae 100644 --- a/doc/tethereal.pod.template +++ b/doc/tethereal.pod.template @@ -363,6 +363,7 @@ I<type> specifies which type of conversation we want to generate the statistics for, currently the supported ones are "eth" Ethernet "ip" IP addresses + "tcpip" TCP/IP socketpairs "tr" TokenRing If the optional filter string is specified, only those packets that match the diff --git a/packet-ip.c b/packet-ip.c index f8172be26a..843048c6db 100644 --- a/packet-ip.c +++ b/packet-ip.c @@ -1,7 +1,7 @@ /* packet-ip.c * Routines for IP and miscellaneous IP protocol packet disassembly * - * $Id: packet-ip.c,v 1.183 2003/01/28 23:56:39 guy Exp $ + * $Id: packet-ip.c,v 1.184 2003/03/03 23:20:57 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -831,6 +831,7 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) eip_current=0; } iph=&eip_arr[eip_current]; + pinfo->private_data=iph; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "IP"); diff --git a/packet-tcp.c b/packet-tcp.c index 69d276c847..bdd2e77b4a 100644 --- a/packet-tcp.c +++ b/packet-tcp.c @@ -1,7 +1,7 @@ /* packet-tcp.c * Routines for TCP packet disassembly * - * $Id: packet-tcp.c,v 1.183 2003/03/03 03:16:36 sharpe Exp $ + * $Id: packet-tcp.c,v 1.184 2003/03/03 23:20:57 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1846,7 +1846,8 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) tcph_count=0; } tcph=&tcphstruct[tcph_count]; - + /* XXX add to ipv6 so this works for that protocol as well */ + tcph->ip_header=pinfo->private_data; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "TCP"); diff --git a/packet-tcp.h b/packet-tcp.h index d0c932c080..3ce804984d 100644 --- a/packet-tcp.h +++ b/packet-tcp.h @@ -1,6 +1,6 @@ /* packet-tcp.h * - * $Id: packet-tcp.h,v 1.13 2002/12/17 11:49:32 sahlberg Exp $ + * $Id: packet-tcp.h,v 1.14 2003/03/03 23:20:57 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -45,6 +45,9 @@ struct tcpheader { guint16 th_dport; guint8 th_hlen; guint8 th_flags; + /* this can either be ipv4 or ipv6, make sure you know which + one you get. */ + void *ip_header; }; /* diff --git a/tap-iousers.c b/tap-iousers.c index a49c8d8d00..40b5d1bea8 100644 --- a/tap-iousers.c +++ b/tap-iousers.c @@ -1,7 +1,7 @@ /* tap-iousers.c * iostat 2003 Ronnie Sahlberg * - * $Id: tap-iousers.c,v 1.2 2003/01/22 07:28:29 guy Exp $ + * $Id: tap-iousers.c,v 1.3 2003/03/03 23:20:57 sahlberg Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -39,6 +39,7 @@ #include "tap.h" #include "register.h" #include "packet-ip.h" +#include "packet-tcp.h" #include "packet-eth.h" #include "packet-tr.h" #include <string.h> @@ -61,6 +62,68 @@ typedef struct _io_users_item_t { guint32 bytes2; } io_users_item_t; + +/* XXX for now we only handle ipv4 as transport for tcp. + should extend in the future to also handle ipv6 +*/ +static int +iousers_tcpip_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_, void *vtcph) +{ + struct tcpheader *tcph=vtcph; + char name1[256],name2[256]; + io_users_item_t *iui; + e_ip *ipv4_header; + int direction=0; + + ipv4_header=tcph->ip_header; + switch(ipv4_header->ip_v_hl>>4){ + case 4: + if(ipv4_header->ip_src>ipv4_header->ip_dst){ + snprintf(name1,256,"%s:%s",get_hostname(ipv4_header->ip_src),get_tcp_port(tcph->th_sport)); + snprintf(name2,256,"%s:%s",get_hostname(ipv4_header->ip_dst),get_tcp_port(tcph->th_dport)); + } else { + direction=1; + snprintf(name2,256,"%s:%s",get_hostname(ipv4_header->ip_src),get_tcp_port(tcph->th_sport)); + snprintf(name1,256,"%s:%s",get_hostname(ipv4_header->ip_dst),get_tcp_port(tcph->th_dport)); + } + break; + default: + return 0; + } + + for(iui=iu->items;iui;iui=iui->next){ + if((!strcmp(iui->name1, name1)) + && (!strcmp(iui->name2, name2)) ){ + break; + } + } + + if(!iui){ + iui=g_malloc(sizeof(io_users_item_t)); + iui->next=iu->items; + iu->items=iui; + iui->addr1=NULL; + iui->name1=strdup(name1); + iui->addr2=NULL; + iui->name2=strdup(name2); + iui->frames1=0; + iui->frames2=0; + iui->bytes1=0; + iui->bytes2=0; + } + + if(direction){ + iui->frames1++; + iui->bytes1+=pinfo->fd->pkt_len; + } else { + iui->frames2++; + iui->bytes2+=pinfo->fd->pkt_len; + } + + return 1; +} + + static int iousers_ip_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_, void *vip) { @@ -268,6 +331,14 @@ iousers_init(char *optarg) } tap_type="eth"; packet_func=iousers_eth_packet; + } else if(!strncmp(optarg,"io,users,tcpip",14)){ + if(optarg[14]==','){ + filter=optarg+15; + } else { + filter=NULL; + } + tap_type="tcp"; + packet_func=iousers_tcpip_packet; } else if(!strncmp(optarg,"io,users,tr",11)){ if(optarg[11]==','){ filter=optarg+12; @@ -289,6 +360,7 @@ iousers_init(char *optarg) fprintf(stderr," <type> must be one of\n"); fprintf(stderr," \"eth\"\n"); fprintf(stderr," \"ip\"\n"); + fprintf(stderr," \"tcpip\"\n"); fprintf(stderr," \"tr\"\n"); exit(1); } |