aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca <deri@ntop.org>2015-11-12 15:23:00 +0100
committerLuca <deri@ntop.org>2015-11-12 15:23:00 +0100
commit8399afa607ca5e69deeceee0f1fbd0b12cec2192 (patch)
tree14a56ea7c964e5a7dd2749f1ad94de88fd8e2aa4
parent68091c7cdb4f0f01e23052ccbb3afa818e47d712 (diff)
Removed legacy linux_compat.h file
Updated IPv6 address dump format
-rw-r--r--example/ndpiReader.c24
-rw-r--r--src/include/linux_compat.h277
-rw-r--r--src/include/ndpi_unix.h2
-rw-r--r--tests/result/6in4tunnel.pcap.out20
-rw-r--r--tests/result/skype.pcap.out2
-rw-r--r--tests/result/skype_no_unknown.pcap.out2
-rw-r--r--tests/result/whatsapp_login_call.pcap.out4
-rw-r--r--tests/result/whatsapp_login_chat.pcap.out2
8 files changed, 26 insertions, 307 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 88dba03e9..337bdd36c 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -189,9 +189,8 @@ typedef struct ndpi_flow {
u_int16_t vlan_id;
struct ndpi_flow_struct *ndpi_flow;
char lower_name[48], upper_name[48];
-
+ u_int8_t ip_version;
u_int64_t last_seen;
-
u_int64_t bytes;
u_int32_t packets;
@@ -496,19 +495,18 @@ static void printFlow(u_int16_t thread_id, struct ndpi_flow *flow) {
FILE *out = results_file ? results_file : stdout;
if(!json_flag) {
-#if 0
- fprintf(out, "\t%s [VLAN: %u] %s:%u <-> %s:%u\n",
- ipProto2Name(flow->protocol), flow->vlan_id,
- flow->lower_name, ntohs(flow->lower_port),
- flow->upper_name, ntohs(flow->upper_port));
-
-#else
fprintf(out, "\t%u", ++num_flows);
- fprintf(out, "\t%s %s:%u <-> %s:%u ",
+ fprintf(out, "\t%s %s%s%s:%u <-> %s%s%s:%u ",
ipProto2Name(flow->protocol),
- flow->lower_name, ntohs(flow->lower_port),
- flow->upper_name, ntohs(flow->upper_port));
+ (flow->ip_version == 6) ? "[" : "",
+ flow->lower_name,
+ (flow->ip_version == 6) ? "]" : "",
+ ntohs(flow->lower_port),
+ (flow->ip_version == 6) ? "[" : "",
+ flow->upper_name,
+ (flow->ip_version == 6) ? "]" : "",
+ ntohs(flow->upper_port));
if(flow->vlan_id > 0) fprintf(out, "[VLAN: %u]", flow->vlan_id);
@@ -532,7 +530,6 @@ static void printFlow(u_int16_t thread_id, struct ndpi_flow *flow) {
if(flow->ssl.server_certificate[0] != '\0') fprintf(out, "[SSL server: %s]", flow->ssl.server_certificate);
fprintf(out, "\n");
-#endif
} else {
#ifdef HAVE_JSON_C
jObj = json_object_new_object();
@@ -875,6 +872,7 @@ static struct ndpi_flow *get_ndpi_flow(u_int16_t thread_id,
newflow->protocol = iph->protocol, newflow->vlan_id = vlan_id;
newflow->lower_ip = lower_ip, newflow->upper_ip = upper_ip;
newflow->lower_port = lower_port, newflow->upper_port = upper_port;
+ newflow->ip_version = version;
if(version == 4) {
inet_ntop(AF_INET, &lower_ip, newflow->lower_name, sizeof(newflow->lower_name));
diff --git a/src/include/linux_compat.h b/src/include/linux_compat.h
deleted file mode 100644
index 25ed2c4e9..000000000
--- a/src/include/linux_compat.h
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * linux_compat.h
- *
- * Copyright (C) 2009-2011 by ipoque GmbH
- * Copyright (C) 2011-15 - ntop.org
- *
- * This file is part of nDPI, an open source deep packet inspection
- * library based on the OpenDPI and PACE technology by ipoque GmbH
- *
- * nDPI is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * nDPI is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with nDPI. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#ifndef __NDPI_LINUX_COMPAT_H__
-#define __NDPI_LINUX_COMPAT_H__
-
-#include "ndpi_define.h"
-
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
-#include <machine/endian.h>
-
-#if _BYTE_ORDER == _LITTLE_ENDIAN
-#ifndef __LITTLE_ENDIAN__
-#define __LITTLE_ENDIAN__ 1
-#endif
-#else
-#ifndef __BIG_ENDIAN__
-#define __BIG_ENDIAN__ 1
-#endif
-#endif
-#endif
-
-#pragma pack(push, 1) /* push current alignment to stack */
-#pragma pack(1) /* set alignment to 1 byte boundary */
-
-#pragma pack(pop) /* restore original alignment from stack */
-
-
-/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-/* +++++++++++++++ Cisco data structures +++++++++++++++++++++++ */
-/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-
-/* Cisco HDLC */
-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) */
-};
-
-/* SLARP - Serial Line ARP http://tinyurl.com/qa54e95 */
-struct ndpi_slarp
-{
- /* address requests (0x00)
- address replies (0x01)
- keep-alive (0x02)
- */
- u_int32_t slarp_type;
- u_int32_t addr_1;
- u_int32_t addr_2;
-};
-
-/* Cisco Discovery Protocol http://tinyurl.com/qa6yw9l */
-struct ndpi_cdp
-{
- u_int8_t version;
- u_int8_t ttl;
- u_int16_t checksum;
- u_int16_t type;
- u_int16_t length;
-};
-
-
-/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */
-/* +++++++++++ Ethernet data structures +++++++++++++ */
-/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */
-
-struct ndpi_ethhdr
-{
- u_char h_dest[6]; /* destination eth addr */
- u_char h_source[6]; /* source ether addr */
- u_int16_t h_proto; /* packet type ID field */
-};
-
-/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */
-/* +++++++++++ ieee802.11 data structures +++++++++++ */
-/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */
-
-/******* RADIO TAP *******/
-/* radiotap header */
-struct ndpi_radiotap_header
-{
- u_int8_t version; /* set to 0 */
- u_int8_t pad;
- u_int16_t len;
- u_int32_t present;
- u_int64_t MAC_timestamp;
- u_int8_t flags;
-
-} __attribute__((__packed__));
-
-/* Beacon frame */
-struct ndpi_beacon
-{
- /* header -- 24 byte */
- u_int16_t fc;
- u_int16_t duration;
- u_char rcv_addr[6];
- u_char trsm_addr[6];
- u_char bssid[6];
- u_int16_t seq_ctrl;
- /* body (variable) */
- u_int64_t timestamp; /* 802.11 Timestamp value at frame send */
- u_int16_t beacon_interval; /* Interval at which beacons are send */
- u_int16_t capability;
- /** List of information elements **/
- /* union ndpi_80211_info info_element[0]; */
-} __attribute__((packed));
-
-
-/* Wifi data frame - TODO: specify when addr1 addr2 addr3 is rcv, trams or bssid*/
-struct ndpi_wifi_data_frame
-{
- u_int16_t fc;
- u_int16_t duration;
- u_char addr1[6];
- u_char addr2[6];
- u_char addr3[6];
- u_int16_t seq_ctrl;
-} __attribute__((packed));
-
-/* Logical-Link Control header */
-struct ndpi_llc_header_proto
-{
- u_int8_t dsap;
- u_int8_t ssap;
- u_int8_t ctl;
- /* u_int8_t pad1; */
- u_int16_t org;
- u_int8_t org2;
- /* u_int8_t pad2; */
- u_int16_t ether_IP_type;
-} __attribute__((packed));
-
-
-/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */
-/* ++++++++++++++ IP data structures ++++++++++++++++ */
-/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */
-
-/* IP header */
-struct ndpi_iphdr {
-#if defined(__LITTLE_ENDIAN__)
- u_int8_t ihl:4, version:4;
-#elif defined(__BIG_ENDIAN__)
- u_int8_t version:4, ihl:4;
-#else
-# error "Byte order must be defined"
-#endif
- u_int8_t tos;
- u_int16_t tot_len;
- u_int16_t id;
- u_int16_t frag_off;
- u_int8_t ttl;
- u_int8_t protocol;
- u_int16_t check;
- u_int32_t saddr;
- u_int32_t daddr;
-};
-
-
-#ifdef WIN32
-
-typedef unsigned char u_char;
-typedef unsigned short u_short;
-typedef unsigned int uint;
-typedef unsigned long u_long;
-typedef u_char u_int8_t;
-typedef u_short u_int16_t;
-typedef uint u_int32_t;
-
-#define _WS2TCPIP_H_ /* Avoid compilation problems */
-#define HAVE_SIN6_LEN
-
-/* IPv6 address */
-/* Already defined in WS2tcpip.h */
-struct ndpi_win_in6_addr
-{
- union {
- u_int8_t u6_addr8[16];
- u_int16_t u6_addr16[8];
- u_int32_t u6_addr32[4];
- } in6_u;
-};
-
-#define in6_addr win_in6_addr
-
-/* Generic extension header. */
-struct ndpi_ip6_ext
-{
- u_int8_t ip6e_nxt; /* next header. */
- 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
-*/
-#else
-#include <arpa/inet.h>
-#endif
-
-struct ndpi_in6_addr {
- union {
- u_int8_t u6_addr8[16];
- u_int16_t u6_addr16[8];
- u_int32_t u6_addr32[4];
- } u6_addr; /* 128-bit IP6 address */
-};
-
-
-struct ndpi_ip6_hdr {
- union {
- struct ndpi_ip6_hdrctl {
- u_int32_t ip6_un1_flow;
- u_int16_t ip6_un1_plen;
- u_int8_t ip6_un1_nxt;
- u_int8_t ip6_un1_hlim;
- } ip6_un1;
- u_int8_t ip6_un2_vfc;
- } ip6_ctlun;
- struct ndpi_in6_addr ip6_src;
- struct ndpi_in6_addr ip6_dst;
-};
-
-/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */
-/* ++++++++ Transport Layer data structures +++++++++ */
-/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */
-
-
-struct ndpi_tcphdr {
- u_int16_t source;
- u_int16_t dest;
- u_int32_t seq;
- u_int32_t ack_seq;
-#if defined(__LITTLE_ENDIAN__)
- u_int16_t res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1;
-#elif defined(__BIG_ENDIAN__)
- u_int16_t doff:4, res1:4, cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1;
-#else
-# error "Byte order must be defined"
-#endif
- u_int16_t window;
- u_int16_t check;
- u_int16_t urg_ptr;
-};
-
-struct ndpi_udphdr {
- u_int16_t source;
- u_int16_t dest;
- u_int16_t len;
- u_int16_t check;
-};
-
-#endif
diff --git a/src/include/ndpi_unix.h b/src/include/ndpi_unix.h
index d902cd9b2..b680d3c30 100644
--- a/src/include/ndpi_unix.h
+++ b/src/include/ndpi_unix.h
@@ -25,8 +25,6 @@
#ifndef __NDPI_UNIX_INCLUDE_FILE__
#define __NDPI_UNIX_INCLUDE_FILE__
-#include "linux_compat.h"
-
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <netinet/in.h>
#if defined(__NetBSD__) || defined(__OpenBSD__)
diff --git a/tests/result/6in4tunnel.pcap.out b/tests/result/6in4tunnel.pcap.out
index b04d78726..8afa97442 100644
--- a/tests/result/6in4tunnel.pcap.out
+++ b/tests/result/6in4tunnel.pcap.out
@@ -4,13 +4,13 @@ SSL_No_Cert 61 29323 2
ICMPV6 48 7862 3
Facebook 4 800 2
- 1 TCP 2001:470:1f17:13f:3e97:eff:fe73:4dec:443 <-> 2a03:2880:1010:6f03:face:b00c:0:2:53234 [proto: 64/SSL_No_Cert][33 pkts/13926 bytes]
- 2 UDP 2001:470:1f16:13f::2:6404 <-> 2a03:2880:fffe:b:face:b00c:0:99:53 [proto: 5.119/DNS.Facebook][2 pkts/394 bytes][Host: star.c10r.facebook.com]
- 3 TCP 2001:470:1f17:13f:3e97:eff:fe73:4dec:443 <-> 2604:a880:1:20::224:b001:60205 [proto: 64/SSL_No_Cert][28 pkts/15397 bytes]
- 4 ICMPV6 2001:470:1f16:13f::2:0 <-> 2604:a880:1:20::224:b001:0 [proto: 102/ICMPV6][1 pkts/200 bytes]
- 5 ICMPV6 2a03:2880:1010:6f03:face:b00c:0:2:0 <-> 2001:470:1f17:13f:3e97:eff:fe73:4dec:0 [proto: 102/ICMPV6][1 pkts/1314 bytes]
- 6 TCP 2604:a880:1:20::224:b001:993 <-> 2001:470:1f17:13f:6d69:c72:7313:616f:35610 [proto: 51/IMAPS][2 pkts/258 bytes]
- 7 ICMPV6 2001:470:1f17:13f:3e97:eff:fe73:4dec:0 <-> 2604:a880:1:20::224:b001:0 [proto: 102/ICMPV6][46 pkts/6348 bytes]
- 8 TCP 2604:a880:1:20::224:b001:993 <-> 2001:470:1f17:13f:6d69:c72:7313:616f:56381 [proto: 51/IMAPS][2 pkts/258 bytes]
- 9 UDP 2001:470:1f16:13f::2:53959 <-> 2a03:2880:fffe:b:face:b00c:0:99:53 [proto: 5.119/DNS.Facebook][2 pkts/406 bytes][Host: star.c10r.facebook.com]
- 10 TCP 2001:470:1f17:13f:3e97:eff:fe73:4dec:80 <-> 2604:a880:1:20::224:b001:41538 [proto: 7/HTTP][10 pkts/1792 bytes][Host: mail.tomasu.net]
+ 1 TCP [2001:470:1f17:13f:3e97:eff:fe73:4dec]:443 <-> [2a03:2880:1010:6f03:face:b00c::2]:53234 [proto: 64/SSL_No_Cert][33 pkts/13926 bytes]
+ 2 UDP [2001:470:1f16:13f::2]:6404 <-> [2a03:2880:fffe:b:face:b00c::99]:53 [proto: 5.119/DNS.Facebook][2 pkts/394 bytes][Host: star.c10r.facebook.com]
+ 3 TCP [2001:470:1f17:13f:3e97:eff:fe73:4dec]:443 <-> [2604:a880:1:20::224:b001]:60205 [proto: 64/SSL_No_Cert][28 pkts/15397 bytes]
+ 4 ICMPV6 [2001:470:1f16:13f::2]:0 <-> [2604:a880:1:20::224:b001]:0 [proto: 102/ICMPV6][1 pkts/200 bytes]
+ 5 ICMPV6 [2a03:2880:1010:6f03:face:b00c::2]:0 <-> [2001:470:1f17:13f:3e97:eff:fe73:4dec]:0 [proto: 102/ICMPV6][1 pkts/1314 bytes]
+ 6 TCP [2604:a880:1:20::224:b001]:993 <-> [2001:470:1f17:13f:6d69:c72:7313:616f]:35610 [proto: 51/IMAPS][2 pkts/258 bytes]
+ 7 ICMPV6 [2001:470:1f17:13f:3e97:eff:fe73:4dec]:0 <-> [2604:a880:1:20::224:b001]:0 [proto: 102/ICMPV6][46 pkts/6348 bytes]
+ 8 TCP [2604:a880:1:20::224:b001]:993 <-> [2001:470:1f17:13f:6d69:c72:7313:616f]:56381 [proto: 51/IMAPS][2 pkts/258 bytes]
+ 9 UDP [2001:470:1f16:13f::2]:53959 <-> [2a03:2880:fffe:b:face:b00c::99]:53 [proto: 5.119/DNS.Facebook][2 pkts/406 bytes][Host: star.c10r.facebook.com]
+ 10 TCP [2001:470:1f17:13f:3e97:eff:fe73:4dec]:80 <-> [2604:a880:1:20::224:b001]:41538 [proto: 7/HTTP][10 pkts/1792 bytes][Host: mail.tomasu.net]
diff --git a/tests/result/skype.pcap.out b/tests/result/skype.pcap.out
index 84954bdea..d4e820f04 100644
--- a/tests/result/skype.pcap.out
+++ b/tests/result/skype.pcap.out
@@ -289,7 +289,7 @@ Spotify 5 430 1
276 TCP 192.168.1.34:50100 <-> 111.221.74.46:443 [proto: 125/Skype][13 pkts/1109 bytes]
277 TCP 192.168.1.34:50035 <-> 213.199.179.175:40021 [proto: 125/Skype][17 pkts/1304 bytes]
278 TCP 192.168.1.34:50075 <-> 213.199.179.142:40003 [proto: 125/Skype][19 pkts/1495 bytes]
- 279 UDP fe80::c62c:3ff:fe06:49fe:5353 <-> ff02::fb:5353 [proto: 8/MDNS][4 pkts/908 bytes]
+ 279 UDP [fe80::c62c:3ff:fe06:49fe]:5353 <-> [ff02::fb]:5353 [proto: 8/MDNS][4 pkts/908 bytes]
Undetected flows:
diff --git a/tests/result/skype_no_unknown.pcap.out b/tests/result/skype_no_unknown.pcap.out
index bd0a5d9b4..eabcf69fb 100644
--- a/tests/result/skype_no_unknown.pcap.out
+++ b/tests/result/skype_no_unknown.pcap.out
@@ -260,7 +260,7 @@ Apple 84 20699 2
248 UDP 192.168.1.34:13021 <-> 65.55.223.44:40020 [proto: 125/Skype][1 pkts/76 bytes]
249 UDP 192.168.1.34:13021 <-> 65.55.223.42:40024 [proto: 125/Skype][1 pkts/76 bytes]
250 UDP 192.168.1.34:13021 <-> 65.55.223.43:40006 [proto: 125/Skype][1 pkts/77 bytes]
- 251 UDP fe80::c62c:3ff:fe06:49fe:5353 <-> ff02::fb:5353 [proto: 8/MDNS][2 pkts/258 bytes]
+ 251 UDP [fe80::c62c:3ff:fe06:49fe]:5353 <-> [ff02::fb]:5353 [proto: 8/MDNS][2 pkts/258 bytes]
252 TCP 192.168.1.34:51240 <-> 111.221.74.45:443 [proto: 125/Skype][14 pkts/1373 bytes]
253 TCP 111.221.74.18:443 <-> 192.168.1.34:51268 [proto: 125/Skype][14 pkts/1203 bytes]
254 TCP 192.168.1.34:51250 <-> 111.221.77.175:443 [proto: 125/Skype][14 pkts/1363 bytes]
diff --git a/tests/result/whatsapp_login_call.pcap.out b/tests/result/whatsapp_login_call.pcap.out
index 5ed7616e3..289214e9c 100644
--- a/tests/result/whatsapp_login_call.pcap.out
+++ b/tests/result/whatsapp_login_call.pcap.out
@@ -11,7 +11,7 @@ WhatsApp 182 25154 2
AppleiTunes 85 28087 2
Spotify 3 258 1
- 1 UDP fe80::da30:62ff:fe56:1c:5353 <-> ff02::fb:5353 [proto: 8/MDNS][2 pkts/258 bytes]
+ 1 UDP [fe80::da30:62ff:fe56:1c]:5353 <-> [ff02::fb]:5353 [proto: 8/MDNS][2 pkts/258 bytes]
2 UDP 192.168.2.1:17500 <-> 192.168.2.255:17500 [proto: 121/DropBox][4 pkts/2176 bytes]
3 ICMP 192.168.2.4:0 <-> 91.253.176.65:0 [proto: 81/ICMP][10 pkts/700 bytes]
4 UDP 173.252.114.1:3478 <-> 192.168.2.4:52794 [proto: 78/STUN][5 pkts/676 bytes]
@@ -65,7 +65,7 @@ Spotify 3 258 1
52 UDP 169.254.166.207:5353 <-> 224.0.0.251:5353 [proto: 8/MDNS][2 pkts/218 bytes]
53 UDP 192.168.2.1:5353 <-> 224.0.0.251:5353 [proto: 8/MDNS][2 pkts/218 bytes]
54 TCP 192.168.2.4:49192 <-> 93.186.135.8:80 [proto: 7/HTTP][5 pkts/330 bytes]
- 55 UDP fe80::c42c:3ff:fe60:6a64:5353 <-> ff02::fb:5353 [proto: 8/MDNS][2 pkts/258 bytes]
+ 55 UDP [fe80::c42c:3ff:fe60:6a64]:5353 <-> [ff02::fb]:5353 [proto: 8/MDNS][2 pkts/258 bytes]
Undetected flows:
diff --git a/tests/result/whatsapp_login_chat.pcap.out b/tests/result/whatsapp_login_chat.pcap.out
index d109353a3..0a904dd54 100644
--- a/tests/result/whatsapp_login_chat.pcap.out
+++ b/tests/result/whatsapp_login_chat.pcap.out
@@ -6,7 +6,7 @@ WhatsApp 32 3243 2
Spotify 1 86 1
1 UDP 192.168.2.1:17500 <-> 192.168.2.255:17500 [proto: 121/DropBox][2 pkts/1088 bytes]
- 2 UDP fe80::189c:c31b:1298:224:5353 <-> ff02::fb:5353 [proto: 8/MDNS][1 pkts/111 bytes]
+ 2 UDP [fe80::189c:c31b:1298:224]:5353 <-> [ff02::fb]:5353 [proto: 8/MDNS][1 pkts/111 bytes]
3 UDP 192.168.2.1:53 <-> 192.168.2.4:61697 [proto: 5.142/DNS.WhatsApp][2 pkts/280 bytes][Host: e12.whatsapp.net]
4 TCP 192.168.2.4:49205 <-> 17.173.66.102:443 [proto: 91.140/SSL.Apple][44 pkts/21371 bytes]
5 UDP 0.0.0.0:68 <-> 255.255.255.255:67 [proto: 18/DHCP][6 pkts/2052 bytes]