From 65da6eb5ddeeeac36fa4571c2ba0a570387f400d Mon Sep 17 00:00:00 2001 From: Christian Giese Date: Mon, 1 Mar 2021 11:26:04 +0100 Subject: [PATCH] Add IPv6 LI Stats --- src/bbl_li.c | 23 +++++++++++++++++++++-- src/bbl_li.h | 4 ++++ src/bbl_protocols.h | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/bbl_li.c b/src/bbl_li.c index c883d69f..7f34c077 100644 --- a/src/bbl_li.c +++ b/src/bbl_li.c @@ -58,6 +58,7 @@ bbl_qmx_li_handler_rx(bbl_ethernet_header_t *eth, bbl_qmx_li_t *qmx_li, bbl_inte bbl_ethernet_header_t *inner_eth; bbl_pppoe_session_t *inner_pppoe; bbl_ipv4_t *inner_ipv4 = NULL; + bbl_ipv6_t *inner_ipv6 = NULL; bbl_li_flow_t *li_flow; dict_insert_result result; @@ -96,10 +97,13 @@ bbl_qmx_li_handler_rx(bbl_ethernet_header_t *eth, bbl_qmx_li_t *qmx_li, bbl_inte inner_pppoe = (bbl_pppoe_session_t*)inner_eth->next; if(inner_pppoe->protocol == PROTOCOL_IPV4) { inner_ipv4 = (bbl_ipv4_t*)inner_pppoe->next; - - } + } else if(inner_pppoe->protocol == PROTOCOL_IPV6) { + inner_ipv6 = (bbl_ipv6_t*)inner_pppoe->next; + } } else if(inner_eth->type == ETH_TYPE_IPV4) { inner_ipv4 = (bbl_ipv4_t*)eth->next; + } else if(inner_eth->type == PROTOCOL_IPV6) { + inner_ipv6 = (bbl_ipv6_t*)eth->next; } if(inner_ipv4) { @@ -117,5 +121,20 @@ bbl_qmx_li_handler_rx(bbl_ethernet_header_t *eth, bbl_qmx_li_t *qmx_li, bbl_inte default: break; } + } else if (inner_ipv6) { + li_flow->packets_rx_ipv6++; + switch(inner_ipv6->protocol) { + case IPV6_NEXT_HEADER_TCP: + li_flow->packets_rx_ipv6_tcp++; + break; + case IPV6_NEXT_HEADER_UDP: + li_flow->packets_rx_ipv6_udp++; + break; + case IPV6_NEXT_HEADER_INTERNAL: + li_flow->packets_rx_ipv6_internal++; + break; + default: + break; + } } } diff --git a/src/bbl_li.h b/src/bbl_li.h index e03b6527..ec2e3711 100644 --- a/src/bbl_li.h +++ b/src/bbl_li.h @@ -29,6 +29,10 @@ typedef struct bbl_li_flow_ uint64_t packets_rx_ipv4_tcp; uint64_t packets_rx_ipv4_udp; uint64_t packets_rx_ipv4_internal; + uint64_t packets_rx_ipv6; + uint64_t packets_rx_ipv6_tcp; + uint64_t packets_rx_ipv6_udp; + uint64_t packets_rx_ipv6_internal; } bbl_li_flow_t; const char* bbl_li_direction_string(uint8_t direction); diff --git a/src/bbl_protocols.h b/src/bbl_protocols.h index d9bd9a00..ea33d159 100644 --- a/src/bbl_protocols.h +++ b/src/bbl_protocols.h @@ -139,8 +139,10 @@ #define UDP_PROTOCOL_L2TP 3 #define UDP_PROTOCOL_QMX_LI 4 +#define IPV6_NEXT_HEADER_TCP 6 #define IPV6_NEXT_HEADER_UDP 17 #define IPV6_NEXT_HEADER_ICMPV6 58 +#define IPV6_NEXT_HEADER_INTERNAL 61 #define ICMPV6_FLAGS_OTHER_CONFIG 0x40 #define ICMPV6_OPTION_PREFIX 3