ndpi_util: replace if / else by switch/case

Fix also
The left operand of '==' is a garbage value
Value stored to 'slarp' is never read
Value stored to 'cdp' is never read
This commit is contained in:
Alexis La Goutte
2016-05-23 23:03:26 +02:00
parent e0e1ed6936
commit a6c9d33c09
+10 -8
View File
@@ -679,12 +679,15 @@ void ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
} }
/* check ether type */ /* check ether type */
if(type == VLAN) { switch(type) {
case VLAN:
vlan_id = ((packet[ip_offset] << 8) + packet[ip_offset+1]) & 0xFFF; vlan_id = ((packet[ip_offset] << 8) + packet[ip_offset+1]) & 0xFFF;
type = (packet[ip_offset+2] << 8) + packet[ip_offset+3]; type = (packet[ip_offset+2] << 8) + packet[ip_offset+3];
ip_offset += 4; ip_offset += 4;
vlan_packet = 1; vlan_packet = 1;
} else if(type == MPLS_UNI || type == MPLS_MULTI) { break;
case MPLS_UNI:
case MPLS_MULTI:
mpls = (struct ndpi_mpls_header *) &packet[ip_offset]; mpls = (struct ndpi_mpls_header *) &packet[ip_offset];
label = ntohl(mpls->label); label = ntohl(mpls->label);
/* label = ntohl(*((u_int32_t*)&packet[ip_offset])); */ /* label = ntohl(*((u_int32_t*)&packet[ip_offset])); */
@@ -695,15 +698,14 @@ void ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
ip_offset += 4; ip_offset += 4;
label = ntohl(mpls->label); label = ntohl(mpls->label);
} }
} break;
else if(type == SLARP) case PPPoE:
slarp = (struct ndpi_slarp *) &packet[ip_offset];
else if(type == CISCO_D_PROTO)
cdp = (struct ndpi_cdp *) &packet[ip_offset];
else if(type == PPPoE) {
workflow->stats.pppoe_count++; workflow->stats.pppoe_count++;
type = ETH_P_IP; type = ETH_P_IP;
ip_offset += 8; ip_offset += 8;
break;
default:
break;
} }
workflow->stats.vlan_count += vlan_packet; workflow->stats.vlan_count += vlan_packet;