Merge pull request #506 from cavedon/dev
Fix MPLS header parsing in ndpiReader.
This commit is contained in:
+9
-6
@@ -689,7 +689,10 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
|
|||||||
const struct ndpi_wifi_header *wifi;
|
const struct ndpi_wifi_header *wifi;
|
||||||
|
|
||||||
/* --- MPLS header --- */
|
/* --- MPLS header --- */
|
||||||
struct ndpi_mpls_header *mpls;
|
union mpls {
|
||||||
|
uint32_t u32;
|
||||||
|
struct ndpi_mpls_header mpls;
|
||||||
|
} mpls;
|
||||||
|
|
||||||
/** --- IP header --- **/
|
/** --- IP header --- **/
|
||||||
struct ndpi_iphdr *iph;
|
struct ndpi_iphdr *iph;
|
||||||
@@ -846,15 +849,15 @@ struct ndpi_proto ndpi_workflow_process_packet (struct ndpi_workflow * workflow,
|
|||||||
break;
|
break;
|
||||||
case MPLS_UNI:
|
case MPLS_UNI:
|
||||||
case MPLS_MULTI:
|
case MPLS_MULTI:
|
||||||
mpls = (struct ndpi_mpls_header *) &packet[ip_offset];
|
mpls.u32 = *((uint32_t *) &packet[ip_offset]);
|
||||||
label = ntohl(mpls->label);
|
mpls.u32 = ntohl(mpls.u32);
|
||||||
/* label = ntohl(*((u_int32_t*)&packet[ip_offset])); */
|
|
||||||
workflow->stats.mpls_count++;
|
workflow->stats.mpls_count++;
|
||||||
type = ETH_P_IP, ip_offset += 4;
|
type = ETH_P_IP, ip_offset += 4;
|
||||||
|
|
||||||
while((label & 0x100) != 0x100) {
|
while(!mpls.mpls.s) {
|
||||||
ip_offset += 4;
|
ip_offset += 4;
|
||||||
label = ntohl(mpls->label);
|
mpls.u32 = *((uint32_t *) &packet[ip_offset]);
|
||||||
|
mpls.u32 = ntohl(mpls.u32);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PPPoE:
|
case PPPoE:
|
||||||
|
|||||||
@@ -178,7 +178,15 @@ struct ndpi_wifi_header
|
|||||||
PACK_ON
|
PACK_ON
|
||||||
struct ndpi_mpls_header
|
struct ndpi_mpls_header
|
||||||
{
|
{
|
||||||
|
/* Before using this strcut to parse an MPLS header, you will need to convert
|
||||||
|
* the 4-byte data to the correct endianess with ntohl(). */
|
||||||
|
#if defined(__LITTLE_ENDIAN__)
|
||||||
|
u_int32_t ttl:8, s:1, exp:3, label:20;
|
||||||
|
#elif defined(__BIG_ENDIAN__)
|
||||||
u_int32_t label:20, exp:3, s:1, ttl:8;
|
u_int32_t label:20, exp:3, s:1, ttl:8;
|
||||||
|
#else
|
||||||
|
# error "Byte order must be defined"
|
||||||
|
#endif
|
||||||
} PACK_OFF;
|
} PACK_OFF;
|
||||||
|
|
||||||
/* ++++++++++++++++++++++++ IP header ++++++++++++++++++++++++ */
|
/* ++++++++++++++++++++++++ IP header ++++++++++++++++++++++++ */
|
||||||
|
|||||||
Reference in New Issue
Block a user