#include <epan/tap.h>
#include <epan/conversation.h>
#include <epan/stat_cmd_args.h>
-#include "register.h"
#include <epan/dissectors/packet-ip.h>
+#include <epan/dissectors/packet-ipv6.h>
#include <epan/dissectors/packet-ipx.h>
#include <epan/dissectors/packet-tcp.h>
#include <epan/dissectors/packet-udp.h>
if(udph->uh_sport>udph->uh_dport){
direction=0;
- g_snprintf(name1,256,"%s:%s",address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport));
- g_snprintf(name2,256,"%s:%s",address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport));
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport));
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport));
} else if(udph->uh_sport<udph->uh_dport){
direction=1;
- g_snprintf(name2,256,"%s:%s",address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport));
- g_snprintf(name1,256,"%s:%s",address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport));
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport));
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport));
} else if(CMP_ADDRESS(&udph->ip_src, &udph->ip_dst)>0){
direction=0;
- g_snprintf(name1,256,"%s:%s",address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport));
- g_snprintf(name2,256,"%s:%s",address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport));
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport));
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport));
} else {
direction=1;
- g_snprintf(name2,256,"%s:%s",address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport));
- g_snprintf(name1,256,"%s:%s",address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport));
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&udph->ip_src),get_udp_port(udph->uh_sport));
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&udph->ip_dst),get_udp_port(udph->uh_dport));
}
for(iui=iu->items;iui;iui=iui->next){
if(sctph->sport > sctph->dport) {
direction=0;
- g_snprintf(name1,256,"%s:%s",address_to_str(&sctph->ip_src),s_sport);
- g_snprintf(name2,256,"%s:%s",address_to_str(&sctph->ip_dst),s_dport);
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&sctph->ip_src),s_sport);
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&sctph->ip_dst),s_dport);
} else if(sctph->sport < sctph->dport) {
direction=1;
- g_snprintf(name1,256,"%s:%s",address_to_str(&sctph->ip_src),s_sport);
- g_snprintf(name2,256,"%s:%s",address_to_str(&sctph->ip_dst),s_dport);
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&sctph->ip_src),s_sport);
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&sctph->ip_dst),s_dport);
} else {
direction=0;
- g_snprintf(name1,256,"%s:%s",address_to_str(&sctph->ip_src),s_sport);
- g_snprintf(name2,256,"%s:%s",address_to_str(&sctph->ip_dst),s_dport);
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&sctph->ip_src),s_sport);
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&sctph->ip_dst),s_dport);
}
for(iui=iu->items;iui;iui=iui->next){
if(tcph->th_sport>tcph->th_dport){
direction=0;
- g_snprintf(name1,256,"%s:%s",address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport));
- g_snprintf(name2,256,"%s:%s",address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport));
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport));
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport));
} else if(tcph->th_sport<tcph->th_dport){
direction=1;
- g_snprintf(name2,256,"%s:%s",address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport));
- g_snprintf(name1,256,"%s:%s",address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport));
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport));
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport));
} else if(CMP_ADDRESS(&tcph->ip_src, &tcph->ip_dst)>0){
direction=0;
- g_snprintf(name1,256,"%s:%s",address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport));
- g_snprintf(name2,256,"%s:%s",address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport));
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport));
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport));
} else {
direction=1;
- g_snprintf(name2,256,"%s:%s",address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport));
- g_snprintf(name1,256,"%s:%s",address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport));
+ g_snprintf(name2,256,"%s:%s",ep_address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport));
+ g_snprintf(name1,256,"%s:%s",ep_address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport));
}
for(iui=iu->items;iui;iui=iui->next){
iousers_ip_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip)
{
io_users_t *iu=arg;
- const e_ip *iph=vip;
+ const ws_ip *iph=vip;
const address *addr1, *addr2;
io_users_item_t *iui;
iui->next=iu->items;
iu->items=iui;
COPY_ADDRESS(&iui->addr1, addr1);
- iui->name1=g_strdup(address_to_str(addr1));
+ iui->name1=g_strdup(ep_address_to_str(addr1));
COPY_ADDRESS(&iui->addr2, addr2);
- iui->name2=g_strdup(address_to_str(addr2));
+ iui->name2=g_strdup(ep_address_to_str(addr2));
iui->frames1=0;
iui->frames2=0;
iui->bytes1=0;
return 1;
}
+static int
+iousers_ipv6_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip)
+{
+ io_users_t *iu=arg;
+ const struct ip6_hdr *ip6h=vip;
+ address src, dst;
+ const address *addr1, *addr2;
+ io_users_item_t *iui;
+
+ /* Addresses aren't implemented as 'address' type in struct ip6_hdr */
+ src.type = dst.type = AT_IPv6;
+ src.len = dst.len = sizeof(struct e_in6_addr);
+ src.data = &ip6h->ip6_src;
+ dst.data = &ip6h->ip6_dst;
+
+ if(CMP_ADDRESS(&src, &dst)>0){
+ addr1=&src;
+ addr2=&dst;
+ } else {
+ addr2=&src;
+ addr1=&dst;
+ }
+
+ for(iui=iu->items;iui;iui=iui->next){
+ if((!CMP_ADDRESS(&iui->addr1, addr1))
+ &&(!CMP_ADDRESS(&iui->addr2, addr2)) ){
+ break;
+ }
+ }
+
+ if(!iui){
+ iui=g_malloc(sizeof(io_users_item_t));
+ iui->next=iu->items;
+ iu->items=iui;
+ COPY_ADDRESS(&iui->addr1, addr1);
+ iui->name1=g_strdup(ep_address_to_str(addr1));
+ COPY_ADDRESS(&iui->addr2, addr2);
+ iui->name2=g_strdup(ep_address_to_str(addr2));
+ iui->frames1=0;
+ iui->frames2=0;
+ iui->bytes1=0;
+ iui->bytes2=0;
+ }
+
+ if(!CMP_ADDRESS(&dst, &iui->addr1)){
+ iui->frames1++;
+ iui->bytes1+=pinfo->fd->pkt_len;
+ } else {
+ iui->frames2++;
+ iui->bytes2+=pinfo->fd->pkt_len;
+ }
+
+ return 1;
+}
+
static int
iousers_ipx_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vipx)
{
iui->next=iu->items;
iu->items=iui;
COPY_ADDRESS(&iui->addr1, addr1);
- iui->name1=g_strdup(address_to_str(addr1));
+ iui->name1=g_strdup(ep_address_to_str(addr1));
COPY_ADDRESS(&iui->addr2, addr2);
- iui->name2=g_strdup(address_to_str(addr2));
+ iui->name2=g_strdup(ep_address_to_str(addr2));
iui->frames1=0;
iui->frames2=0;
iui->bytes1=0;
iui->next=iu->items;
iu->items=iui;
COPY_ADDRESS(&iui->addr1, addr1);
- iui->name1=g_strdup(address_to_str(addr1));
+ iui->name1=g_strdup(ep_address_to_str(addr1));
COPY_ADDRESS(&iui->addr2, addr2);
- iui->name2=g_strdup(address_to_str(addr2));
+ iui->name2=g_strdup(ep_address_to_str(addr2));
iui->frames1=0;
iui->frames2=0;
iui->bytes1=0;
iui->next=iu->items;
iu->items=iui;
COPY_ADDRESS(&iui->addr1, addr1);
- iui->name1=g_strdup(address_to_str(addr1));
+ iui->name1=g_strdup(ep_address_to_str(addr1));
COPY_ADDRESS(&iui->addr2, addr2);
- iui->name2=g_strdup(address_to_str(addr2));
+ iui->name2=g_strdup(ep_address_to_str(addr2));
iui->frames1=0;
iui->frames2=0;
iui->bytes1=0;
iui->next=iu->items;
iu->items=iui;
COPY_ADDRESS(&iui->addr1, addr1);
- iui->name1=g_strdup(address_to_str(addr1));
+ iui->name1=g_strdup(ep_address_to_str(addr1));
COPY_ADDRESS(&iui->addr2, addr2);
- iui->name2=g_strdup(address_to_str(addr2));
+ iui->name2=g_strdup(ep_address_to_str(addr2));
iui->frames1=0;
iui->frames2=0;
iui->bytes1=0;
iui->next=iu->items;
iu->items=iui;
COPY_ADDRESS(&iui->addr1, addr1);
- iui->name1=g_strdup(address_to_str(addr1));
+ iui->name1=g_strdup(ep_address_to_str(addr1));
COPY_ADDRESS(&iui->addr2, addr2);
- iui->name2=g_strdup(address_to_str(addr2));
+ iui->name2=g_strdup(ep_address_to_str(addr2));
iui->frames1=0;
iui->frames2=0;
iui->bytes1=0;
printf("================================================================================\n");
}
-void
+static void
iousers_init(const char *optarg, void* userdata _U_)
{
const char *filter=NULL;
tap_type="ip";
tap_type_name="IPv4";
packet_func=iousers_ip_packet;
+ } else if(!strncmp(optarg,"conv,ipv6",7)){
+ if(optarg[7]==','){
+ filter=optarg+10;
+ } else {
+ filter=NULL;
+ }
+ tap_type="ipv6";
+ tap_type_name="IPv6";
+ packet_func=iousers_ipv6_packet;
} else if(!strncmp(optarg,"conv,sctp",9)) {
if(optarg[9]==','){
filter=optarg+10;
iu->filter=NULL;
}
- error_string=register_tap_listener(tap_type, iu, filter, NULL, packet_func, iousers_draw);
+ error_string=register_tap_listener(tap_type, iu, filter, 0, NULL, packet_func, iousers_draw);
if(error_string){
if(iu->items){
g_free(iu->items);