Removed now obsolete NDPI_DETECTION_SUPPORT_IPV6: code is more readeable now
This commit is contained in:
@@ -150,10 +150,9 @@ extern "C" {
|
|||||||
#define ndpi_match_strprefix(payload, payload_len, str) \
|
#define ndpi_match_strprefix(payload, payload_len, str) \
|
||||||
ndpi_match_prefix((payload), (payload_len), (str), (sizeof(str)-1))
|
ndpi_match_prefix((payload), (payload_len), (str), (sizeof(str)-1))
|
||||||
|
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
int ndpi_handle_ipv6_extension_headers(struct ndpi_detection_module_struct *ndpi_str,
|
||||||
int ndpi_handle_ipv6_extension_headers(struct ndpi_detection_module_struct *ndpi_str, const u_int8_t ** l4ptr, u_int16_t * l4len, u_int8_t * nxt_hdr);
|
const u_int8_t ** l4ptr, u_int16_t * l4len,
|
||||||
#endif
|
u_int8_t * nxt_hdr);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
#ifndef __NDPI_PROTOCOLS_IDS_H__
|
#ifndef __NDPI_PROTOCOLS_IDS_H__
|
||||||
#define __NDPI_PROTOCOLS_IDS_H__
|
#define __NDPI_PROTOCOLS_IDS_H__
|
||||||
|
|
||||||
#define NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
#define NDPI_PROTOCOL_SIZE 2
|
#define NDPI_PROTOCOL_SIZE 2
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
@@ -377,9 +377,7 @@ struct ndpi_dns_packet_header {
|
|||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
u_int32_t ipv4;
|
u_int32_t ipv4;
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
struct ndpi_in6_addr ipv6;
|
struct ndpi_in6_addr ipv6;
|
||||||
#endif
|
|
||||||
} ndpi_ip_addr_t;
|
} ndpi_ip_addr_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -809,9 +807,7 @@ struct ndpi_int_one_line_struct {
|
|||||||
|
|
||||||
struct ndpi_packet_struct {
|
struct ndpi_packet_struct {
|
||||||
const struct ndpi_iphdr *iph;
|
const struct ndpi_iphdr *iph;
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
const struct ndpi_ipv6hdr *iphv6;
|
const struct ndpi_ipv6hdr *iphv6;
|
||||||
#endif
|
|
||||||
const struct ndpi_tcphdr *tcp;
|
const struct ndpi_tcphdr *tcp;
|
||||||
const struct ndpi_udphdr *udp;
|
const struct ndpi_udphdr *udp;
|
||||||
const u_int8_t *generic_l4_ptr; /* is set only for non tcp-udp traffic */
|
const u_int8_t *generic_l4_ptr; /* is set only for non tcp-udp traffic */
|
||||||
@@ -1127,10 +1123,7 @@ struct ndpi_detection_module_struct {
|
|||||||
u_int32_t jabber_file_transfer_timeout;
|
u_int32_t jabber_file_transfer_timeout;
|
||||||
u_int8_t ip_version_limit;
|
u_int8_t ip_version_limit;
|
||||||
/* NDPI_PROTOCOL_BITTORRENT */
|
/* NDPI_PROTOCOL_BITTORRENT */
|
||||||
struct hash_ip4p_table *bt_ht;
|
struct hash_ip4p_table *bt_ht, *bt6_ht;
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
struct hash_ip4p_table *bt6_ht;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* BT_ANNOUNCE */
|
/* BT_ANNOUNCE */
|
||||||
struct bt_announce *bt_ann;
|
struct bt_announce *bt_ann;
|
||||||
|
|||||||
@@ -42,9 +42,7 @@ typedef struct fragment_wrapper {
|
|||||||
uint8_t l4_protocol;
|
uint8_t l4_protocol;
|
||||||
uint32_t initial_offset;
|
uint32_t initial_offset;
|
||||||
uint16_t ct_frag;
|
uint16_t ct_frag;
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
char *flow_label; // IP6
|
char *flow_label; // IP6
|
||||||
#endif
|
|
||||||
char gap[200];
|
char gap[200];
|
||||||
fragment_t **fragments_list;
|
fragment_t **fragments_list;
|
||||||
} fragments_wrapper_t;
|
} fragments_wrapper_t;
|
||||||
|
|||||||
+13
-73
@@ -3438,7 +3438,6 @@ void ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
/* handle extension headers in IPv6 packets
|
/* handle extension headers in IPv6 packets
|
||||||
* arguments:
|
* arguments:
|
||||||
* l4ptr: pointer to the byte following the initial IPv6 header
|
* l4ptr: pointer to the byte following the initial IPv6 header
|
||||||
@@ -3497,7 +3496,6 @@ int ndpi_handle_ipv6_extension_headers(struct ndpi_detection_module_struct *ndpi
|
|||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
|
|
||||||
|
|
||||||
static u_int8_t ndpi_iph_is_valid_and_not_fragmented(const struct ndpi_iphdr *iph, const u_int16_t ipsize) {
|
static u_int8_t ndpi_iph_is_valid_and_not_fragmented(const struct ndpi_iphdr *iph, const u_int16_t ipsize) {
|
||||||
|
|
||||||
@@ -3561,9 +3559,7 @@ static u_int8_t ndpi_detection_get_l4_internal(struct ndpi_detection_module_stru
|
|||||||
u_int16_t l3_len, const u_int8_t **l4_return, u_int16_t *l4_len_return,
|
u_int16_t l3_len, const u_int8_t **l4_return, u_int16_t *l4_len_return,
|
||||||
u_int8_t *l4_protocol_return, u_int32_t flags) {
|
u_int8_t *l4_protocol_return, u_int32_t flags) {
|
||||||
const struct ndpi_iphdr *iph = NULL;
|
const struct ndpi_iphdr *iph = NULL;
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
const struct ndpi_ipv6hdr *iph_v6 = NULL;
|
const struct ndpi_ipv6hdr *iph_v6 = NULL;
|
||||||
#endif
|
|
||||||
u_int16_t l4len = 0;
|
u_int16_t l4len = 0;
|
||||||
const u_int8_t *l4ptr = NULL;
|
const u_int8_t *l4ptr = NULL;
|
||||||
u_int8_t l4protocol = 0;
|
u_int8_t l4protocol = 0;
|
||||||
@@ -3577,27 +3573,21 @@ static u_int8_t ndpi_detection_get_l4_internal(struct ndpi_detection_module_stru
|
|||||||
if(iph->version == IPVERSION && iph->ihl >= 5) {
|
if(iph->version == IPVERSION && iph->ihl >= 5) {
|
||||||
NDPI_LOG_DBG2(ndpi_str, "ipv4 header\n");
|
NDPI_LOG_DBG2(ndpi_str, "ipv4 header\n");
|
||||||
}
|
}
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
else if(iph->version == 6 && l3_len >= sizeof(struct ndpi_ipv6hdr)) {
|
else if(iph->version == 6 && l3_len >= sizeof(struct ndpi_ipv6hdr)) {
|
||||||
NDPI_LOG_DBG2(ndpi_str, "ipv6 header\n");
|
NDPI_LOG_DBG2(ndpi_str, "ipv6 header\n");
|
||||||
iph_v6 = (const struct ndpi_ipv6hdr *) l3;
|
iph_v6 = (const struct ndpi_ipv6hdr *) l3;
|
||||||
iph = NULL;
|
iph = NULL;
|
||||||
}
|
} else {
|
||||||
#endif
|
|
||||||
else {
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((flags & NDPI_DETECTION_ONLY_IPV6) && iph != NULL) {
|
if((flags & NDPI_DETECTION_ONLY_IPV6) && iph != NULL) {
|
||||||
NDPI_LOG_DBG2(ndpi_str, "ipv4 header found but excluded by flag\n");
|
NDPI_LOG_DBG2(ndpi_str, "ipv4 header found but excluded by flag\n");
|
||||||
return(1);
|
return(1);
|
||||||
}
|
} else if((flags & NDPI_DETECTION_ONLY_IPV4) && iph_v6 != NULL) {
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
else if((flags & NDPI_DETECTION_ONLY_IPV4) && iph_v6 != NULL) {
|
|
||||||
NDPI_LOG_DBG2(ndpi_str, "ipv6 header found but excluded by flag\n");
|
NDPI_LOG_DBG2(ndpi_str, "ipv6 header found but excluded by flag\n");
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FRAG_MAN
|
#ifdef FRAG_MAN
|
||||||
if(iph != NULL) {
|
if(iph != NULL) {
|
||||||
@@ -3633,7 +3623,7 @@ static u_int8_t ndpi_detection_get_l4_internal(struct ndpi_detection_module_stru
|
|||||||
l4protocol = iph->protocol;
|
l4protocol = iph->protocol;
|
||||||
}
|
}
|
||||||
#endif //FRAGMAN
|
#endif //FRAGMAN
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
else if(iph_v6 != NULL && (l3_len - sizeof(struct ndpi_ipv6hdr)) >= ntohs(iph_v6->ip6_hdr.ip6_un1_plen)) {
|
else if(iph_v6 != NULL && (l3_len - sizeof(struct ndpi_ipv6hdr)) >= ntohs(iph_v6->ip6_hdr.ip6_un1_plen)) {
|
||||||
l4ptr = (((const u_int8_t *) iph_v6) + sizeof(struct ndpi_ipv6hdr));
|
l4ptr = (((const u_int8_t *) iph_v6) + sizeof(struct ndpi_ipv6hdr));
|
||||||
l4len = ntohs(iph_v6->ip6_hdr.ip6_un1_plen);
|
l4len = ntohs(iph_v6->ip6_hdr.ip6_un1_plen);
|
||||||
@@ -3644,9 +3634,7 @@ static u_int8_t ndpi_detection_get_l4_internal(struct ndpi_detection_module_stru
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
#endif
|
|
||||||
else {
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3694,36 +3682,23 @@ static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_str
|
|||||||
|
|
||||||
flow->packet.tcp = NULL, flow->packet.udp = NULL;
|
flow->packet.tcp = NULL, flow->packet.udp = NULL;
|
||||||
flow->packet.generic_l4_ptr = NULL;
|
flow->packet.generic_l4_ptr = NULL;
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
flow->packet.iphv6 = NULL;
|
flow->packet.iphv6 = NULL;
|
||||||
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
|
|
||||||
|
|
||||||
ndpi_apply_flow_protocol_to_packet(flow, &flow->packet);
|
ndpi_apply_flow_protocol_to_packet(flow, &flow->packet);
|
||||||
|
|
||||||
l3len = flow->packet.l3_packet_len;
|
l3len = flow->packet.l3_packet_len;
|
||||||
|
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
if(flow->packet.iph != NULL)
|
||||||
if(flow->packet.iph != NULL) {
|
|
||||||
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
|
|
||||||
|
|
||||||
decaps_iph = flow->packet.iph;
|
decaps_iph = flow->packet.iph;
|
||||||
|
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
}
|
|
||||||
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
|
|
||||||
|
|
||||||
if(decaps_iph && decaps_iph->version == IPVERSION && decaps_iph->ihl >= 5) {
|
if(decaps_iph && decaps_iph->version == IPVERSION && decaps_iph->ihl >= 5) {
|
||||||
NDPI_LOG_DBG2(ndpi_str, "ipv4 header\n");
|
NDPI_LOG_DBG2(ndpi_str, "ipv4 header\n");
|
||||||
}
|
} else if(decaps_iph && decaps_iph->version == 6 && l3len >= sizeof(struct ndpi_ipv6hdr) &&
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
else if(decaps_iph && decaps_iph->version == 6 && l3len >= sizeof(struct ndpi_ipv6hdr) &&
|
|
||||||
(ndpi_str->ip_version_limit & NDPI_DETECTION_ONLY_IPV4) == 0) {
|
(ndpi_str->ip_version_limit & NDPI_DETECTION_ONLY_IPV4) == 0) {
|
||||||
NDPI_LOG_DBG2(ndpi_str, "ipv6 header\n");
|
NDPI_LOG_DBG2(ndpi_str, "ipv6 header\n");
|
||||||
flow->packet.iphv6 = (struct ndpi_ipv6hdr *) flow->packet.iph;
|
flow->packet.iphv6 = (struct ndpi_ipv6hdr *) flow->packet.iph;
|
||||||
flow->packet.iph = NULL;
|
flow->packet.iph = NULL;
|
||||||
}
|
} else {
|
||||||
#endif
|
|
||||||
else {
|
|
||||||
flow->packet.iph = NULL;
|
flow->packet.iph = NULL;
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
@@ -3830,9 +3805,7 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
/* const for gcc code optimization and cleaner code */
|
/* const for gcc code optimization and cleaner code */
|
||||||
struct ndpi_packet_struct *packet = &flow->packet;
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
const struct ndpi_iphdr *iph = packet->iph;
|
const struct ndpi_iphdr *iph = packet->iph;
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
const struct ndpi_ipv6hdr *iphv6 = packet->iphv6;
|
const struct ndpi_ipv6hdr *iphv6 = packet->iphv6;
|
||||||
#endif
|
|
||||||
const struct ndpi_tcphdr *tcph = packet->tcp;
|
const struct ndpi_tcphdr *tcph = packet->tcp;
|
||||||
const struct ndpi_udphdr *udph = packet->udp;
|
const struct ndpi_udphdr *udph = packet->udp;
|
||||||
|
|
||||||
@@ -3844,10 +3817,9 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
if(iph != NULL && ntohl(iph->saddr) < ntohl(iph->daddr))
|
if(iph != NULL && ntohl(iph->saddr) < ntohl(iph->daddr))
|
||||||
packet->packet_direction = 1;
|
packet->packet_direction = 1;
|
||||||
|
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
if((iphv6 != NULL)
|
||||||
if(iphv6 != NULL && NDPI_COMPARE_IPV6_ADDRESS_STRUCTS(&iphv6->ip6_src, &iphv6->ip6_dst) != 0)
|
&& NDPI_COMPARE_IPV6_ADDRESS_STRUCTS(&iphv6->ip6_src, &iphv6->ip6_dst) != 0)
|
||||||
packet->packet_direction = 1;
|
packet->packet_direction = 1;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
packet->packet_lines_parsed_complete = 0;
|
packet->packet_lines_parsed_complete = 0;
|
||||||
@@ -4782,30 +4754,21 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
if(flow->packet.tcp_retransmission == 0)
|
if(flow->packet.tcp_retransmission == 0)
|
||||||
ndpi_selection_packet |= NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION;
|
ndpi_selection_packet |= NDPI_SELECTION_BITMASK_PROTOCOL_NO_TCP_RETRANSMISSION;
|
||||||
|
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
if(flow->packet.iphv6 != NULL)
|
if(flow->packet.iphv6 != NULL)
|
||||||
ndpi_selection_packet |= NDPI_SELECTION_BITMASK_PROTOCOL_IPV6 | NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6;
|
ndpi_selection_packet |= NDPI_SELECTION_BITMASK_PROTOCOL_IPV6 | NDPI_SELECTION_BITMASK_PROTOCOL_IPV4_OR_IPV6;
|
||||||
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
|
|
||||||
|
|
||||||
if((!flow->protocol_id_already_guessed) && (
|
if((!flow->protocol_id_already_guessed)
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
&& (flow->packet.iphv6 || flow->packet.iph)) {
|
||||||
flow->packet.iphv6 ||
|
|
||||||
#endif
|
|
||||||
flow->packet.iph)) {
|
|
||||||
u_int16_t sport, dport;
|
u_int16_t sport, dport;
|
||||||
u_int8_t protocol;
|
u_int8_t protocol;
|
||||||
u_int8_t user_defined_proto;
|
u_int8_t user_defined_proto;
|
||||||
|
|
||||||
flow->protocol_id_already_guessed = 1;
|
flow->protocol_id_already_guessed = 1;
|
||||||
|
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
if(flow->packet.iphv6 != NULL) {
|
if(flow->packet.iphv6 != NULL) {
|
||||||
protocol = flow->packet.iphv6->ip6_hdr.ip6_un1_nxt;
|
protocol = flow->packet.iphv6->ip6_hdr.ip6_un1_nxt;
|
||||||
} else
|
} else
|
||||||
#endif
|
|
||||||
{
|
|
||||||
protocol = flow->packet.iph->protocol;
|
protocol = flow->packet.iph->protocol;
|
||||||
}
|
|
||||||
|
|
||||||
if(flow->packet.udp)
|
if(flow->packet.udp)
|
||||||
sport = ntohs(flow->packet.udp->source), dport = ntohs(flow->packet.udp->dest);
|
sport = ntohs(flow->packet.udp->source), dport = ntohs(flow->packet.udp->dest);
|
||||||
@@ -5719,8 +5682,6 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
/* check if the source ip address in packet and ip are equal */
|
/* check if the source ip address in packet and ip are equal */
|
||||||
/* NTOP */
|
/* NTOP */
|
||||||
int ndpi_packet_src_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t *ip) {
|
int ndpi_packet_src_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t *ip) {
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
|
|
||||||
/* IPv6 */
|
/* IPv6 */
|
||||||
if(packet->iphv6 != NULL) {
|
if(packet->iphv6 != NULL) {
|
||||||
if(packet->iphv6->ip6_src.u6_addr.u6_addr32[0] == ip->ipv6.u6_addr.u6_addr32[0] &&
|
if(packet->iphv6->ip6_src.u6_addr.u6_addr32[0] == ip->ipv6.u6_addr.u6_addr32[0] &&
|
||||||
@@ -5731,7 +5692,6 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
//else
|
//else
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* IPv4 */
|
/* IPv4 */
|
||||||
if(packet->iph->saddr == ip->ipv4)
|
if(packet->iph->saddr == ip->ipv4)
|
||||||
@@ -5743,8 +5703,6 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
|
|
||||||
/* check if the destination ip address in packet and ip are equal */
|
/* check if the destination ip address in packet and ip are equal */
|
||||||
int ndpi_packet_dst_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t *ip) {
|
int ndpi_packet_dst_ip_eql(const struct ndpi_packet_struct *packet, const ndpi_ip_addr_t *ip) {
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
|
|
||||||
/* IPv6 */
|
/* IPv6 */
|
||||||
if(packet->iphv6 != NULL) {
|
if(packet->iphv6 != NULL) {
|
||||||
if(packet->iphv6->ip6_dst.u6_addr.u6_addr32[0] == ip->ipv6.u6_addr.u6_addr32[0] &&
|
if(packet->iphv6->ip6_dst.u6_addr.u6_addr32[0] == ip->ipv6.u6_addr.u6_addr32[0] &&
|
||||||
@@ -5755,7 +5713,6 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
//else
|
//else
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* IPv4 */
|
/* IPv4 */
|
||||||
if(packet->iph->saddr == ip->ipv4)
|
if(packet->iph->saddr == ip->ipv4)
|
||||||
@@ -5771,20 +5728,16 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
void ndpi_packet_src_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t *ip) {
|
void ndpi_packet_src_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t *ip) {
|
||||||
NDPI_PROTOCOL_IP_clear(ip);
|
NDPI_PROTOCOL_IP_clear(ip);
|
||||||
|
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
|
|
||||||
/* IPv6 */
|
/* IPv6 */
|
||||||
if(packet->iphv6 != NULL) {
|
if(packet->iphv6 != NULL) {
|
||||||
ip->ipv6.u6_addr.u6_addr32[0] = packet->iphv6->ip6_src.u6_addr.u6_addr32[0];
|
ip->ipv6.u6_addr.u6_addr32[0] = packet->iphv6->ip6_src.u6_addr.u6_addr32[0];
|
||||||
ip->ipv6.u6_addr.u6_addr32[1] = packet->iphv6->ip6_src.u6_addr.u6_addr32[1];
|
ip->ipv6.u6_addr.u6_addr32[1] = packet->iphv6->ip6_src.u6_addr.u6_addr32[1];
|
||||||
ip->ipv6.u6_addr.u6_addr32[2] = packet->iphv6->ip6_src.u6_addr.u6_addr32[2];
|
ip->ipv6.u6_addr.u6_addr32[2] = packet->iphv6->ip6_src.u6_addr.u6_addr32[2];
|
||||||
ip->ipv6.u6_addr.u6_addr32[3] = packet->iphv6->ip6_src.u6_addr.u6_addr32[3];
|
ip->ipv6.u6_addr.u6_addr32[3] = packet->iphv6->ip6_src.u6_addr.u6_addr32[3];
|
||||||
|
} else {
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* IPv4 */
|
/* IPv4 */
|
||||||
ip->ipv4 = packet->iph->saddr;
|
ip->ipv4 = packet->iph->saddr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ********************************************************************************* */
|
/* ********************************************************************************* */
|
||||||
@@ -5794,8 +5747,6 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
void ndpi_packet_dst_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t *ip) {
|
void ndpi_packet_dst_ip_get(const struct ndpi_packet_struct *packet, ndpi_ip_addr_t *ip) {
|
||||||
NDPI_PROTOCOL_IP_clear(ip);
|
NDPI_PROTOCOL_IP_clear(ip);
|
||||||
|
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
|
|
||||||
if(packet->iphv6 != NULL) {
|
if(packet->iphv6 != NULL) {
|
||||||
ip->ipv6.u6_addr.u6_addr32[0] = packet->iphv6->ip6_dst.u6_addr.u6_addr32[0];
|
ip->ipv6.u6_addr.u6_addr32[0] = packet->iphv6->ip6_dst.u6_addr.u6_addr32[0];
|
||||||
ip->ipv6.u6_addr.u6_addr32[1] = packet->iphv6->ip6_dst.u6_addr.u6_addr32[1];
|
ip->ipv6.u6_addr.u6_addr32[1] = packet->iphv6->ip6_dst.u6_addr.u6_addr32[1];
|
||||||
@@ -5803,21 +5754,14 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
ip->ipv6.u6_addr.u6_addr32[3] = packet->iphv6->ip6_dst.u6_addr.u6_addr32[3];
|
ip->ipv6.u6_addr.u6_addr32[3] = packet->iphv6->ip6_dst.u6_addr.u6_addr32[3];
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ip->ipv4 = packet->iph->daddr;
|
ip->ipv4 = packet->iph->daddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ********************************************************************************* */
|
/* ********************************************************************************* */
|
||||||
|
|
||||||
u_int8_t ndpi_is_ipv6(const ndpi_ip_addr_t *ip) {
|
u_int8_t ndpi_is_ipv6(const ndpi_ip_addr_t *ip) {
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
return(ip->ipv6.u6_addr.u6_addr32[1] != 0 || ip->ipv6.u6_addr.u6_addr32[2] != 0 ||
|
return(ip->ipv6.u6_addr.u6_addr32[1] != 0 || ip->ipv6.u6_addr.u6_addr32[2] != 0 ||
|
||||||
ip->ipv6.u6_addr.u6_addr32[3] != 0);
|
ip->ipv6.u6_addr.u6_addr32[3] != 0);
|
||||||
#else
|
|
||||||
return(0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ********************************************************************************* */
|
/* ********************************************************************************* */
|
||||||
@@ -5825,14 +5769,12 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
char *ndpi_get_ip_string(const ndpi_ip_addr_t *ip, char *buf, u_int buf_len) {
|
char *ndpi_get_ip_string(const ndpi_ip_addr_t *ip, char *buf, u_int buf_len) {
|
||||||
const u_int8_t *a = (const u_int8_t *) &ip->ipv4;
|
const u_int8_t *a = (const u_int8_t *) &ip->ipv4;
|
||||||
|
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
if(ndpi_is_ipv6(ip)) {
|
if(ndpi_is_ipv6(ip)) {
|
||||||
if(inet_ntop(AF_INET6, &ip->ipv6.u6_addr, buf, buf_len) == NULL)
|
if(inet_ntop(AF_INET6, &ip->ipv6.u6_addr, buf, buf_len) == NULL)
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
|
|
||||||
return(buf);
|
return(buf);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
snprintf(buf, buf_len, "%u.%u.%u.%u", a[0], a[1], a[2], a[3]);
|
snprintf(buf, buf_len, "%u.%u.%u.%u", a[0], a[1], a[2], a[3]);
|
||||||
|
|
||||||
@@ -5849,11 +5791,9 @@ uint8_t ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
|
|||||||
if(strchr(ip_str, '.')) {
|
if(strchr(ip_str, '.')) {
|
||||||
if(inet_pton(AF_INET, ip_str, &parsed_ip->ipv4) > 0)
|
if(inet_pton(AF_INET, ip_str, &parsed_ip->ipv4) > 0)
|
||||||
rv = 4;
|
rv = 4;
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
} else {
|
} else {
|
||||||
if(inet_pton(AF_INET6, ip_str, &parsed_ip->ipv6) > 0)
|
if(inet_pton(AF_INET6, ip_str, &parsed_ip->ipv6) > 0)
|
||||||
rv = 6;
|
rv = 6;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(rv);
|
return(rv);
|
||||||
|
|||||||
@@ -1878,9 +1878,7 @@ void free_fragment(fragments_wrapper_t *frag) {
|
|||||||
uint16_t id;
|
uint16_t id;
|
||||||
uint8_t l4_protocol;
|
uint8_t l4_protocol;
|
||||||
uint8_t ct_frag;
|
uint8_t ct_frag;
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
char *flow_label; // IP6
|
char *flow_label; // IP6
|
||||||
#endif
|
|
||||||
fragment_t **fragments_list;
|
fragment_t **fragments_list;
|
||||||
} fragments_wrapper_t;
|
} fragments_wrapper_t;
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -290,9 +290,7 @@ static int search_valid_dns(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if((((rsp_type == 0x1) && (data_len == 4)) /* A */
|
if((((rsp_type == 0x1) && (data_len == 4)) /* A */
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
|| ((rsp_type == 0x1c) && (data_len == 16)) /* AAAA */
|
|| ((rsp_type == 0x1c) && (data_len == 16)) /* AAAA */
|
||||||
#endif
|
|
||||||
)) {
|
)) {
|
||||||
memcpy(&flow->protos.dns.rsp_addr, flow->packet.payload + x, data_len);
|
memcpy(&flow->protos.dns.rsp_addr, flow->packet.payload + x, data_len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ void ndpi_search_in_non_tcp_udp(struct ndpi_detection_module_struct
|
|||||||
struct ndpi_packet_struct *packet = &flow->packet;
|
struct ndpi_packet_struct *packet = &flow->packet;
|
||||||
|
|
||||||
if (packet->iph == NULL) {
|
if (packet->iph == NULL) {
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
if (packet->iphv6 == NULL)
|
if (packet->iphv6 == NULL)
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,11 +73,7 @@ void ndpi_search_tcp_or_udp(struct ndpi_detection_module_struct *ndpi_struct, st
|
|||||||
proto = ndpi_search_tcp_or_udp_raw(ndpi_struct,
|
proto = ndpi_search_tcp_or_udp_raw(ndpi_struct,
|
||||||
flow,
|
flow,
|
||||||
flow->packet.iph ? flow->packet.iph->protocol :
|
flow->packet.iph ? flow->packet.iph->protocol :
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
flow->packet.iphv6->ip6_hdr.ip6_un1_nxt,
|
flow->packet.iphv6->ip6_hdr.ip6_un1_nxt,
|
||||||
#else
|
|
||||||
0,
|
|
||||||
#endif
|
|
||||||
ntohl(packet->iph->saddr),
|
ntohl(packet->iph->saddr),
|
||||||
ntohl(packet->iph->daddr),
|
ntohl(packet->iph->daddr),
|
||||||
sport, dport);
|
sport, dport);
|
||||||
|
|||||||
@@ -37,10 +37,8 @@ void ndpi_search_wsd(struct ndpi_detection_module_struct *ndpi_struct,
|
|||||||
if(packet->udp
|
if(packet->udp
|
||||||
&& (
|
&& (
|
||||||
(packet->iph && ((ntohl(packet->iph->daddr) & 0xF0000000) == 0xE0000000 /* A multicast address */))
|
(packet->iph && ((ntohl(packet->iph->daddr) & 0xF0000000) == 0xE0000000 /* A multicast address */))
|
||||||
#ifdef NDPI_DETECTION_SUPPORT_IPV6
|
|
||||||
||
|
||
|
||||||
(packet->iphv6 && ntohl(packet->iphv6->ip6_dst.u6_addr.u6_addr32[0]) == 0xFF020000)
|
(packet->iphv6 && ntohl(packet->iphv6->ip6_dst.u6_addr.u6_addr32[0]) == 0xFF020000)
|
||||||
#endif
|
|
||||||
)
|
)
|
||||||
&& (ntohs(packet->udp->dest) == WSD_PORT)
|
&& (ntohs(packet->udp->dest) == WSD_PORT)
|
||||||
&& (packet->payload_packet_len >= 40)
|
&& (packet->payload_packet_len >= 40)
|
||||||
|
|||||||
Reference in New Issue
Block a user