Update ndpi_ethernet definition

This commit is contained in:
Luca
2015-11-12 15:32:44 +01:00
parent 8399afa607
commit a407da79a9
2 changed files with 55 additions and 59 deletions
+1 -1
View File
@@ -1667,7 +1667,7 @@ static void pcap_packet_callback(u_char *args,
case DLT_EN10MB : case DLT_EN10MB :
ethernet = (struct ndpi_ethhdr *) &packet[eth_offset]; ethernet = (struct ndpi_ethhdr *) &packet[eth_offset];
ip_offset = sizeof(struct ndpi_ethhdr) + eth_offset; ip_offset = sizeof(struct ndpi_ethhdr) + eth_offset;
check = ntohs(ethernet->h_lt); check = ntohs(ethernet->h_proto);
if(check <= 1500) if(check <= 1500)
pyld_eth_len = check; pyld_eth_len = check;
+54 -58
View File
@@ -34,20 +34,20 @@
/* NDPI_LOG_LEVEL */ /* NDPI_LOG_LEVEL */
typedef enum typedef enum
{ {
NDPI_LOG_ERROR, NDPI_LOG_ERROR,
NDPI_LOG_TRACE, NDPI_LOG_TRACE,
NDPI_LOG_DEBUG NDPI_LOG_DEBUG
} ndpi_log_level_t; } ndpi_log_level_t;
/* NDPI_VISIT */ /* NDPI_VISIT */
typedef enum typedef enum
{ {
ndpi_preorder, ndpi_preorder,
ndpi_postorder, ndpi_postorder,
ndpi_endorder, ndpi_endorder,
ndpi_leaf ndpi_leaf
} ndpi_VISIT; } ndpi_VISIT;
/* NDPI_NODE */ /* NDPI_NODE */
typedef struct node_t typedef struct node_t
@@ -106,26 +106,27 @@ struct ndpi_cdp
u_int16_t length; u_int16_t length;
} __attribute__((packed)); } __attribute__((packed));
/* +++++++++++++++ Ethernet header (IEEE 802.3) +++++++++++++++ */ /* +++++++++++++++ Ethernet header (IEEE 802.3) +++++++++++++++ */
struct ndpi_ethhdr
struct ndpi_ethhdr
{ {
u_char h_dest[6]; /* destination eth addr */ u_char h_dest[6]; /* destination eth addr */
u_char h_source[6]; /* source ether addr */ u_char h_source[6]; /* source ether addr */
u_int16_t h_lt; /* data length (<= 1500) or type ID proto (>=1536) */ u_int16_t h_proto; /* data length (<= 1500) or type ID proto (>=1536) */
} __attribute__((packed)); } __attribute__((packed));
/* +++++++++++++++++++ LLC header (IEEE 802.2) ++++++++++++++++ */ /* +++++++++++++++++++ LLC header (IEEE 802.2) ++++++++++++++++ */
struct ndpi_snap_extension struct ndpi_snap_extension
{ {
u_int16_t oui; u_int16_t oui;
u_int8_t oui2; u_int8_t oui2;
u_int16_t proto_ID; u_int16_t proto_ID;
} __attribute__((packed)); } __attribute__((packed));
struct ndpi_llc_header struct ndpi_llc_header
{ {
u_int8_t dsap; u_int8_t dsap;
u_int8_t ssap; u_int8_t ssap;
u_int8_t ctrl; u_int8_t ctrl;
#ifdef SNAP_EXT #ifdef SNAP_EXT
@@ -133,9 +134,8 @@ struct ndpi_llc_header
#endif #endif
} __attribute__((packed)); } __attribute__((packed));
/* ++++++++++ RADIO TAP header (for IEEE 802.11) +++++++++++++ */ /* ++++++++++ RADIO TAP header (for IEEE 802.11) +++++++++++++ */
struct ndpi_radiotap_header struct ndpi_radiotap_header
{ {
u_int8_t version; /* set to 0 */ u_int8_t version; /* set to 0 */
u_int8_t pad; u_int8_t pad;
@@ -143,7 +143,7 @@ struct ndpi_radiotap_header
u_int32_t present; u_int32_t present;
u_int64_t MAC_timestamp; u_int64_t MAC_timestamp;
u_int8_t flags; u_int8_t flags;
} __attribute__((packed)); } __attribute__((packed));
/* ++++++++++++ Wireless header (IEEE 802.11) ++++++++++++++++ */ /* ++++++++++++ Wireless header (IEEE 802.11) ++++++++++++++++ */
@@ -158,19 +158,16 @@ struct ndpi_wifi_header
/* u_int64_t ccmp - for data encription only - check fc.flag */ /* u_int64_t ccmp - for data encription only - check fc.flag */
} __attribute__((packed)); } __attribute__((packed));
/* +++++++++++++++++++++++ MPLS header +++++++++++++++++++++++ */ /* +++++++++++++++++++++++ MPLS header +++++++++++++++++++++++ */
struct ndpi_mpls_header struct ndpi_mpls_header
{ {
u_int32_t label:20, exp:3, s:1, ttl:8; u_int32_t label:20, exp:3, s:1, ttl:8;
} __attribute__((packed)); } __attribute__((packed));
/* ++++++++++++++++++++++++ IP header ++++++++++++++++++++++++ */ /* ++++++++++++++++++++++++ IP header ++++++++++++++++++++++++ */
struct ndpi_iphdr { struct ndpi_iphdr {
#if defined(__LITTLE_ENDIAN__) #if defined(__LITTLE_ENDIAN__)
u_int8_t ihl:4, version:4; u_int8_t ihl:4, version:4;
#elif defined(__BIG_ENDIAN__) #elif defined(__BIG_ENDIAN__)
u_int8_t version:4, ihl:4; u_int8_t version:4, ihl:4;
@@ -188,7 +185,6 @@ struct ndpi_iphdr {
u_int32_t daddr; u_int32_t daddr;
} __attribute__((packed)); } __attribute__((packed));
/* +++++++++++++++++++++++ IPv6 header +++++++++++++++++++++++ */ /* +++++++++++++++++++++++ IPv6 header +++++++++++++++++++++++ */
/* rfc3542 */ /* rfc3542 */
@@ -215,13 +211,13 @@ struct ndpi_ipv6hdr
} ip6_un1; } ip6_un1;
u_int8_t ip6_un2_vfc; u_int8_t ip6_un2_vfc;
} ip6_ctlun; } ip6_ctlun;
struct ndpi_in6_addr ip6_src; struct ndpi_in6_addr ip6_src;
struct ndpi_in6_addr ip6_dst; struct ndpi_in6_addr ip6_dst;
} __attribute__((packed)); } __attribute__((packed));
/* +++++++++++++++++++++++ TCP header +++++++++++++++++++++++ */ /* +++++++++++++++++++++++ TCP header +++++++++++++++++++++++ */
struct ndpi_tcphdr struct ndpi_tcphdr
{ {
u_int16_t source; u_int16_t source;
@@ -234,13 +230,14 @@ struct ndpi_tcphdr
u_int16_t doff:4, res1:4, cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1; u_int16_t doff:4, res1:4, cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1;
#else #else
# error "Byte order must be defined" # error "Byte order must be defined"
#endif #endif
u_int16_t window; u_int16_t window;
u_int16_t check; u_int16_t check;
u_int16_t urg_ptr; u_int16_t urg_ptr;
} __attribute__((packed)); } __attribute__((packed));
/* +++++++++++++++++++++++ UDP header +++++++++++++++++++++++ */ /* +++++++++++++++++++++++ UDP header +++++++++++++++++++++++ */
struct ndpi_udphdr struct ndpi_udphdr
{ {
u_int16_t source; u_int16_t source;
@@ -249,8 +246,6 @@ struct ndpi_udphdr
u_int16_t check; u_int16_t check;
} __attribute__((packed)); } __attribute__((packed));
typedef union typedef union
{ {
u_int32_t ipv4; u_int32_t ipv4;
@@ -265,9 +260,11 @@ typedef union
/* ************************************************************ */ /* ************************************************************ */
#ifdef NDPI_PROTOCOL_BITTORRENT #ifdef NDPI_PROTOCOL_BITTORRENT
typedef struct spinlock { typedef struct spinlock {
volatile int val; volatile int val;
} spinlock_t; } spinlock_t;
typedef struct atomic { typedef struct atomic {
volatile int counter; volatile int counter;
} atomic_t; } atomic_t;
@@ -317,12 +314,11 @@ typedef enum {
} ndpi_http_method; } ndpi_http_method;
typedef struct ndpi_id_struct { typedef struct ndpi_id_struct {
/** /**
detected_protocol_bitmask: detected_protocol_bitmask:
access this bitmask to find out whether an id has used skype or not access this bitmask to find out whether an id has used skype or not
if a flag is set here, it will not be resetted if a flag is set here, it will not be resetted
to compare this, use: to compare this, use:
**/ **/
NDPI_PROTOCOL_BITMASK detected_protocol_bitmask; NDPI_PROTOCOL_BITMASK detected_protocol_bitmask;
#ifdef NDPI_PROTOCOL_RTSP #ifdef NDPI_PROTOCOL_RTSP
@@ -469,7 +465,7 @@ struct ndpi_flow_tcp_struct {
u_int32_t http_stage:2; u_int32_t http_stage:2;
u_int32_t http_empty_line_seen:1; u_int32_t http_empty_line_seen:1;
u_int32_t http_wait_for_retransmission:1; u_int32_t http_wait_for_retransmission:1;
#endif #endif
#ifdef NDPI_PROTOCOL_GNUTELLA #ifdef NDPI_PROTOCOL_GNUTELLA
u_int32_t gnutella_stage:2; // 0 - 2 u_int32_t gnutella_stage:2; // 0 - 2
#endif #endif
@@ -628,9 +624,9 @@ typedef struct ndpi_packet_struct {
#if !defined(WIN32) #if !defined(WIN32)
__attribute__ ((__packed__)) __attribute__ ((__packed__))
#endif #endif
u_int16_t protocol_stack_info; u_int16_t protocol_stack_info;
struct ndpi_int_one_line_struct line[NDPI_MAX_PARSE_LINES_PER_PACKET]; struct ndpi_int_one_line_struct line[NDPI_MAX_PARSE_LINES_PER_PACKET];
struct ndpi_int_one_line_struct host_line; struct ndpi_int_one_line_struct host_line;
@@ -733,7 +729,7 @@ typedef struct ndpi_detection_module_struct {
#ifdef NDPI_ENABLE_DEBUG_MESSAGES #ifdef NDPI_ENABLE_DEBUG_MESSAGES
void *user_data; void *user_data;
#endif #endif
/* callback function buffer */ /* callback function buffer */
struct ndpi_call_function_struct callback_buffer[NDPI_MAX_SUPPORTED_PROTOCOLS + 1]; struct ndpi_call_function_struct callback_buffer[NDPI_MAX_SUPPORTED_PROTOCOLS + 1];
u_int32_t callback_buffer_size; u_int32_t callback_buffer_size;
@@ -826,44 +822,44 @@ typedef struct ndpi_detection_module_struct {
typedef struct ndpi_flow_struct { typedef struct ndpi_flow_struct {
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_HISTORY_SIZE]; u_int16_t detected_protocol_stack[NDPI_PROTOCOL_HISTORY_SIZE];
#if !defined(WIN32) #if !defined(WIN32)
__attribute__ ((__packed__)) __attribute__ ((__packed__))
#endif #endif
u_int16_t protocol_stack_info; u_int16_t protocol_stack_info;
/* init parameter, internal used to set up timestamp,... */ /* init parameter, internal used to set up timestamp,... */
u_int16_t guessed_protocol_id, guessed_host_proto_id; u_int16_t guessed_protocol_id, guessed_host_proto_id;
u_int8_t protocol_id_already_guessed:1, host_already_guessed:1, init_finished:1, setup_packet_direction:1, packet_direction:1; u_int8_t protocol_id_already_guessed:1, host_already_guessed:1, init_finished:1, setup_packet_direction:1, packet_direction:1;
/* /*
if ndpi_struct->direction_detect_disable == 1 if ndpi_struct->direction_detect_disable == 1
tcp sequence number connection tracking tcp sequence number connection tracking
*/ */
u_int32_t next_tcp_seq_nr[2]; u_int32_t next_tcp_seq_nr[2];
/* /*
the tcp / udp / other l4 value union the tcp / udp / other l4 value union
used to reduce the number of bytes for tcp or udp protocol states used to reduce the number of bytes for tcp or udp protocol states
*/ */
union { union {
struct ndpi_flow_tcp_struct tcp; struct ndpi_flow_tcp_struct tcp;
struct ndpi_flow_udp_struct udp; struct ndpi_flow_udp_struct udp;
} l4; } l4;
/* /*
Pointer to src or dst Pointer to src or dst
that identifies the that identifies the
server of this connection server of this connection
*/ */
struct ndpi_id_struct *server_id; struct ndpi_id_struct *server_id;
/* HTTP host or DNS query */ /* HTTP host or DNS query */
u_char host_server_name[256]; u_char host_server_name[256];
/* Via HTTP User-Agent */ /* Via HTTP User-Agent */
u_char detected_os[32]; u_char detected_os[32];
/* Via HTTP X-Forwarded-For */ /* Via HTTP X-Forwarded-For */
u_char nat_ip[24]; u_char nat_ip[24];
/* /*
This structure below will not not stay inside the protos This structure below will not not stay inside the protos
structure below as HTTP is used by many subprotocols structure below as HTTP is used by many subprotocols
such as FaceBook, Google... so it is hard to know such as FaceBook, Google... so it is hard to know
@@ -871,7 +867,7 @@ typedef struct ndpi_flow_struct {
time being. time being.
*/ */
struct { struct {
ndpi_http_method method; ndpi_http_method method;
char *url, *content_type; char *url, *content_type;
} http; } http;
@@ -881,17 +877,17 @@ typedef struct ndpi_flow_struct {
u_int8_t bad_packet /* the received packet looks bad */; u_int8_t bad_packet /* the received packet looks bad */;
u_int16_t query_type, query_class, rsp_type; u_int16_t query_type, query_class, rsp_type;
} dns; } dns;
struct { struct {
u_int8_t request_code; u_int8_t request_code;
u_int8_t version; u_int8_t version;
} ntp; } ntp;
struct { struct {
char client_certificate[48], server_certificate[48]; char client_certificate[48], server_certificate[48];
} ssl; } ssl;
} protos; } protos;
/*** ALL protocol specific 64 bit variables here ***/ /*** ALL protocol specific 64 bit variables here ***/
/* protocols which have marked a connection as this connection cannot be protocol XXX, multiple u_int64_t */ /* protocols which have marked a connection as this connection cannot be protocol XXX, multiple u_int64_t */
@@ -918,7 +914,7 @@ typedef struct ndpi_flow_struct {
#endif #endif
#ifdef NDPI_PROTOCOL_HTTP #ifdef NDPI_PROTOCOL_HTTP
u_int32_t http_detected:1; u_int32_t http_detected:1;
#endif #endif
#ifdef NDPI_PROTOCOL_RTSP #ifdef NDPI_PROTOCOL_RTSP
u_int32_t rtsprdt_stage:2; u_int32_t rtsprdt_stage:2;
u_int32_t rtsp_control_flow:1; u_int32_t rtsp_control_flow:1;