added cisco hdlc datalink type - fix MPLS header - added BGP pcap with cisco hdlc & MPLS header

This commit is contained in:
Campus
2015-10-16 17:48:38 +02:00
parent 247acce949
commit fd9f4753bb
4 changed files with 35 additions and 7 deletions
+16 -2
View File
@@ -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;
+15 -5
View File
@@ -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>
Binary file not shown.
+4
View File
@@ -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]