diff options
author | Campus <campus@ntop.org> | 2015-10-16 17:48:38 +0200 |
---|---|---|
committer | Campus <campus@ntop.org> | 2015-10-16 17:48:38 +0200 |
commit | fd9f4753bb36bd37a54e0aeb596e2997f958c2c8 (patch) | |
tree | f83fed241e9c78a53a04f49853f3e579812d099a | |
parent | 247acce949e6647892f745248fa46d1264eb3d90 (diff) |
added cisco hdlc datalink type - fix MPLS header - added BGP pcap with cisco hdlc & MPLS header
-rw-r--r-- | example/ndpiReader.c | 18 | ||||
-rw-r--r-- | src/include/linux_compat.h | 20 | ||||
-rw-r--r-- | tests/pcap/BGP_redist.pcap | bin | 0 -> 378 bytes | |||
-rw-r--r-- | tests/result/BGP_redist.pcap.out | 4 |
4 files changed, 35 insertions, 7 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 91e98b2f4..a47bf6f7f 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -71,7 +71,8 @@ #endif #define VLAN 0x8100 -#define MPLS 0x8847 +#define MPLS_UNI 0x8847 +#define MPLS_MULTI 0x8848 #define PPPoE 0x8864 /* mask for FCF */ @@ -1551,6 +1552,8 @@ static void pcap_packet_callback(u_char *args, */ /** --- Ethernet header --- **/ const struct ndpi_ethhdr *ethernet; + /** --- Cisco HDLC header --- **/ + const struct ndpi_chdlc *chdlc; /** --- ieee802.11 --- **/ /* Radio Tap header */ @@ -1560,6 +1563,9 @@ static void pcap_packet_callback(u_char *args, /* Data frame */ const struct ndpi_wifi_data_frame *wifi_data; + /* MPLS header */ + const struct ndpi_mplshdr * mphls; + /** --- IP header --- **/ struct ndpi_iphdr *iph; /** --- IPv6 header --- **/ @@ -1624,6 +1630,14 @@ static void pcap_packet_callback(u_char *args, ip_offset = 4 + eth_offset; + /* Cisco PPP with HDLC framing - 104 (http://tools.ietf.org/html/rfc1547#section-4.3.1) */ + case DLT_C_HDLC: + chdlc = (struct ndpi_chdlc *) &packet[eth_offset]; + ip_offset = sizeof(struct ndpi_chdlc); /* CHDLC_OFF = 4 */ + type = ntohs(chdlc->proto_code); + break; + + /* IEEE 802.3 Ethernet - 1 */ case DLT_EN10MB : ethernet = (struct ndpi_ethhdr *) &packet[eth_offset]; ip_offset = sizeof(struct ndpi_ethhdr) + eth_offset; @@ -1684,7 +1698,7 @@ static void pcap_packet_callback(u_char *args, vlan_packet = 1; break; } - else if(type == MPLS) { + else if(type == MPLS_UNI || type == MPLS_MULTI) { label = ntohl(*((u_int32_t*)&packet[ip_offset])); ndpi_thread_info[thread_id].stats.mpls_count++; type = 0x800, ip_offset += 4; diff --git a/src/include/linux_compat.h b/src/include/linux_compat.h index 4f7b3cd00..0b58df76b 100644 --- a/src/include/linux_compat.h +++ b/src/include/linux_compat.h @@ -48,6 +48,16 @@ #pragma pack(pop) /* restore original alignment from stack */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +/* ++++++++++ Cisco HDLC data structures +++++++++++++++++++++++ */ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +struct ndpi_chdlc +{ + u_int8_t addr; /* 0x0F (Unicast) - 0x8F (Broadcast) */ + u_int8_t ctrl; /* always 0x00 */ + u_int16_t proto_code; /* protocol type (e.g. 0x0800 IP) */ +}; + /* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ /* +++++++++++ Ethernet data structures +++++++++++++ */ /* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ @@ -59,7 +69,6 @@ struct ndpi_ethhdr u_int16_t h_proto; /* packet type ID field */ }; - /* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ /* +++++++++++ ieee802.11 data structures +++++++++++ */ /* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ @@ -125,7 +134,6 @@ struct ndpi_llc_header_proto /* ++++++++++++++ IP data structures ++++++++++++++++ */ /* ++++++++++++++++++++++++++++++++++++++++++++++++++ */ - /* IP header */ struct ndpi_iphdr { #if defined(__LITTLE_ENDIAN__) @@ -180,9 +188,11 @@ struct ndpi_ip6_ext u_int8_t ip6e_len; /* length in units of 8 octets. */ }; -#define s6_addr __u6_addr.__u6_addr8 -#define s6_addr16 __u6_addr.__u6_addr16 -#define s6_addr32 __u6_addr.__u6_addr32 +/* +#define s6_addr u6_addr.u6_addr8 +#define s6_addr16 u6_addr.u6_addr16 +#define s6_addr32 u6_addr.u6_addr32 +*/ #else #ifndef __KERNEL__ #include <arpa/inet.h> diff --git a/tests/pcap/BGP_redist.pcap b/tests/pcap/BGP_redist.pcap Binary files differnew file mode 100644 index 000000000..6c05f3caf --- /dev/null +++ b/tests/pcap/BGP_redist.pcap diff --git a/tests/result/BGP_redist.pcap.out b/tests/result/BGP_redist.pcap.out new file mode 100644 index 000000000..5368c157a --- /dev/null +++ b/tests/result/BGP_redist.pcap.out @@ -0,0 +1,4 @@ +BGP 2 322 2 + + 1 TCP 2.2.2.2:179 <-> 4.4.4.4:63535 [proto: 13/BGP][1 pkts/163 bytes] + 2 TCP 2.2.2.2:179 <-> 5.5.5.5:49433 [proto: 13/BGP][1 pkts/159 bytes] |