aboutsummaryrefslogtreecommitdiffstats
path: root/tap-iousers.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2003-03-03 23:46:50 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2003-03-03 23:46:50 +0000
commit917f568b66e94438f58f21b2ef2436743373b962 (patch)
tree1f74b727d6695538307add1b949865ca32d7fe9b /tap-iousers.c
parent15eea3fbb6d24c4312f2db1f8e39fe67e93f885a (diff)
Added tap functionality to UDP
Added top talkers calculation for UDP socketpairs try -z io,users,udpip svn path=/trunk/; revision=7266
Diffstat (limited to 'tap-iousers.c')
-rw-r--r--tap-iousers.c72
1 files changed, 71 insertions, 1 deletions
diff --git a/tap-iousers.c b/tap-iousers.c
index 40b5d1bea8..0a89c877e0 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.3 2003/03/03 23:20:57 sahlberg Exp $
+ * $Id: tap-iousers.c,v 1.4 2003/03/03 23:46:48 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -40,6 +40,7 @@
#include "register.h"
#include "packet-ip.h"
#include "packet-tcp.h"
+#include "packet-udp.h"
#include "packet-eth.h"
#include "packet-tr.h"
#include <string.h>
@@ -63,6 +64,66 @@ typedef struct _io_users_item_t {
} io_users_item_t;
+/* XXX for now we only handle ipv4 as transport for udp.
+ should extend in the future to also handle ipv6
+*/
+static int
+iousers_udpip_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_, void *vudph)
+{
+ e_udphdr *udph=vudph;
+ char name1[256],name2[256];
+ io_users_item_t *iui;
+ e_ip *ipv4_header;
+ int direction=0;
+
+ ipv4_header=udph->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_udp_port(udph->uh_sport));
+ snprintf(name2,256,"%s:%s",get_hostname(ipv4_header->ip_dst),get_udp_port(udph->uh_dport));
+ } else {
+ direction=1;
+ snprintf(name2,256,"%s:%s",get_hostname(ipv4_header->ip_src),get_udp_port(udph->uh_sport));
+ snprintf(name1,256,"%s:%s",get_hostname(ipv4_header->ip_dst),get_udp_port(udph->uh_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;
+}
+
/* XXX for now we only handle ipv4 as transport for tcp.
should extend in the future to also handle ipv6
*/
@@ -339,6 +400,14 @@ iousers_init(char *optarg)
}
tap_type="tcp";
packet_func=iousers_tcpip_packet;
+ } else if(!strncmp(optarg,"io,users,udpip",14)){
+ if(optarg[14]==','){
+ filter=optarg+15;
+ } else {
+ filter=NULL;
+ }
+ tap_type="udp";
+ packet_func=iousers_udpip_packet;
} else if(!strncmp(optarg,"io,users,tr",11)){
if(optarg[11]==','){
filter=optarg+12;
@@ -362,6 +431,7 @@ iousers_init(char *optarg)
fprintf(stderr," \"ip\"\n");
fprintf(stderr," \"tcpip\"\n");
fprintf(stderr," \"tr\"\n");
+ fprintf(stderr," \"udpip\"\n");
exit(1);
}