(/home/sate/Testcases/c/cve/wireshark-1.2.0/tap-iousers.c) |
| |
| 193 | | | iousers_tcpip_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vtcph) |
| 194 | | | { |
| 195 | | | io_users_t *iu=arg; |
| 196 | | | const struct *tcph=vtcph; |
| 197 | | | char name1[256],name2[256]; |
| 198 | | | io_users_item_t *iui; |
| 199 | | | int direction=0; |
| 200 | | | |
| 201 | | | if(tcph->th_sport>tcph->th_dport){ |
| 202 | | | direction=0; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 203 | | | g_snprintf(name1,256,"%s:%s",address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport)); |
| 204 | | | g_snprintf(name2,256,"%s:%s",address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport)); |
| 205 | | | } else if(tcph->th_sport<tcph->th_dport){ |
| 206 | | | direction=1; |
| 207 | | | g_snprintf(name2,256,"%s:%s",address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport)); |
| 208 | | | g_snprintf(name1,256,"%s:%s",address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport)); |
| 209 | | | } else if(CMP_ADDRESS(&tcph->ip_src, &tcph->ip_dst)>0){
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
78 | #define CMP_ADDRESS(addr1, addr2) \ |
79 | ( ((addr1)->type > (addr2)->type)?1: \ |
80 | ((addr1)->type < (addr2)->type)?-1: \ |
81 | ((addr1)->len > (addr2)->len) ?1: \ |
82 | ((addr1)->len < (addr2)->len) ?-1: \ |
83 | memcmp((addr1)->data, (addr2)->data, (addr1)->len)\ |
84 | ) |
| |
|
| 210 | | | direction=0; |
| 211 | | | g_snprintf(name1,256,"%s:%s",address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport)); |
| 212 | | | g_snprintf(name2,256,"%s:%s",address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport)); |
| 213 | | | } else { |
| 214 | | | direction=1; |
| 215 | | | g_snprintf(name2,256,"%s:%s",address_to_str(&tcph->ip_src),get_tcp_port(tcph->th_sport)); |
| 216 | | | g_snprintf(name1,256,"%s:%s",address_to_str(&tcph->ip_dst),get_tcp_port(tcph->th_dport)); |
| 217 | | | } |
| 218 | | | |
| 219 | | | for(iui=iu->items;iui;iui=iui->next){ |
| 220 | | | if((!strcmp(iui->name1, name1)) |
| 221 | | | && (!strcmp(iui->name2, name2)) ){ |
| 222 | | | break; |
| 223 | | | } |
| 224 | | | } |
| 225 | | | |
| 226 | | | if(!iui){ |
| 227 | | | iui=g_malloc(sizeof(io_users_item_t)); |
| 228 | | | iui->next=iu->items; |
| 229 | | | iu->items=iui; |
| 230 | | | |
| 231 | | | iui->name1=g_strdup(name1); |
| 232 | | | |
| 233 | | | iui->name2=g_strdup(name2); |
| 234 | | | iui->frames1=0; |
| 235 | | | iui->frames2=0; |
| 236 | | | iui->bytes1=0; |
| 237 | | | iui->bytes2=0; |
| 238 | | | } |
| 239 | | | |
| 240 | | | if(direction){ |
| 241 | | | iui->frames1++; |
| 242 | | | iui->bytes1+=pinfo->fd->pkt_len; |
| 243 | | | } else { |
| 244 | | | iui->frames2++; |
| 245 | | | iui->bytes2+=pinfo->fd->pkt_len; |
| 246 | | | } |
| 247 | | | |
| 248 | | | return 1; |
| 249 | | | } |
| |