Ethereal-dev: Re: [Ethereal-dev] Tethereal -z io,users,ip has stats in wrong order

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

Date: Mon, 19 May 2003 12:01:36 +0200
Martin Visser worte:
> 
> I had a quick look at the code in "tap-iousers.c", but I can't confirm
> where it is going wrong. I noticed some swapping/ordering going on that
> looks a bit suss???
> 
> if(iph->ip_src>iph->ip_dst){
> 		addr1=iph->ip_src;
> 		addr2=iph->ip_dst;
> 	} else {
> 		addr2=iph->ip_src;
> 		addr1=iph->ip_dst;
> 	}
> 
> 
> 

I think that:
	if(!memcmp(&iph->ip_src,iui->addr1,4)){
		iui->frames1++;
		iui->bytes1+=pinfo->fd->pkt_len;
	} else {
		iui->frames2++;
		iui->bytes2+=pinfo->fd->pkt_len;
	}
should be changed to:
	if(memcmp(&iph->ip_src,iui->addr1,4)){  
		iui->frames1++;
		iui->bytes1+=pinfo->fd->pkt_len;
	} else {
		iui->frames2++;
		iui->bytes2+=pinfo->fd->pkt_len;
        }

when ip_src is NOT equal to addr1 then frames1 should be
stepped it seems from the udpip and tcpip (direction=1 in the udpip scenario). 
memcmp returns 0 if they are equal.