From 9185c2ccc402d3368fc28ac90ab281b4f951719e Mon Sep 17 00:00:00 2001 From: Luca Deri Date: Wed, 3 Apr 2024 23:03:46 +0200 Subject: Added support for STUN Mapped IP address --- example/ndpiReader.c | 10 ++++++++-- example/reader_util.c | 3 +++ example/reader_util.h | 7 +++++++ 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'example') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 029f784f2..16c88e947 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -1457,7 +1457,6 @@ static void parseOptions(int argc, char **argv) { /* ********************************** */ -#if 0 /** * @brief A faster replacement for inet_ntoa(). */ @@ -1487,7 +1486,6 @@ char* intoaV4(u_int32_t addr, char* buf, u_int16_t bufLen) { return(cp); } -#endif /* ********************************** */ @@ -1905,6 +1903,14 @@ static void printFlow(u_int32_t id, struct ndpi_flow_info *flow, u_int16_t threa } } + if(flow->stun.mapped_address.ipv4 != 0) { + char buf[32]; + + fprintf(out, "[Mapped IP/Port: %s:%u]", + intoaV4(flow->stun.mapped_address.ipv4, buf, sizeof(buf)), + flow->stun.mapped_address.port); + } + if(flow->http.url[0] != '\0') { ndpi_risk_enum risk = ndpi_validate_url(flow->http.url); diff --git a/example/reader_util.c b/example/reader_util.c index 1afe4418f..69c244e8d 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -1309,6 +1309,9 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl ndpi_inc_bin(&flow->payload_len_bin, plen2slot(len), 1); } } + } else if(is_ndpi_proto(flow, NDPI_PROTOCOL_STUN)) { + flow->stun.mapped_address.ipv4 = flow->ndpi_flow->stun.mapped_address.ipv4, + flow->stun.mapped_address.port = flow->ndpi_flow->stun.mapped_address.port; } flow->multimedia_flow_type = flow->ndpi_flow->flow_multimedia_type; diff --git a/example/reader_util.h b/example/reader_util.h index 408a14ec4..9a729018d 100644 --- a/example/reader_util.h +++ b/example/reader_util.h @@ -299,6 +299,13 @@ typedef struct ndpi_flow_info { u_int response_status_code; } http; + struct { + struct { + u_int32_t ipv4; + u_int16_t port; + } mapped_address; + } stun; + struct { char *username, *password; } telnet; -- cgit v1.2.3