diff options
author | Luca Deri <deri@ntop.org> | 2022-12-05 21:27:30 +0100 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2022-12-05 21:27:30 +0100 |
commit | e0afc16aa2ae78c39b7b51c73840f79ba1723c9c (patch) | |
tree | 58cb02776a9e8f069910fe1cddd8308496e6cce6 /src | |
parent | c882120afd76255d6511f9b43b9776f8e0a9044f (diff) |
Exported HTTP server in metadata
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ndpi_typedefs.h | 4 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 3 | ||||
-rw-r--r-- | src/lib/protocols/http.c | 11 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index 33ccd93ec..7c599f384 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -1355,14 +1355,14 @@ struct ndpi_flow_struct { ndpi_http_method method; u_int8_t request_version; /* 0=1.0 and 1=1.1. Create an enum for this? */ u_int16_t response_status_code; /* 200, 404, etc. */ - char *url, *content_type /* response */, *request_content_type /* e.g. for POST */, *user_agent; + char *url, *content_type /* response */, *request_content_type /* e.g. for POST */, *user_agent, *server; char *detected_os; /* Via HTTP/QUIC User-Agent */ char *nat_ip; /* Via HTTP X-Forwarded-For */ } http; /* Put outside of the union to avoid issues in case the protocol - is remapped to somethign pther than Kerberos due to a faulty + is remapped to something other than Kerberos due to a faulty dissector */ struct { diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 5d9ec40ef..1bc286f4d 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -5057,6 +5057,9 @@ void ndpi_free_flow_data(struct ndpi_flow_struct* flow) { if(flow->http.detected_os) ndpi_free(flow->http.detected_os); + if(flow->http.server) + ndpi_free(flow->http.server); + if(flow->kerberos_buf.pktbuf) ndpi_free(flow->kerberos_buf.pktbuf); diff --git a/src/lib/protocols/http.c b/src/lib/protocols/http.c index e33ee265d..2c8f474fa 100644 --- a/src/lib/protocols/http.c +++ b/src/lib/protocols/http.c @@ -882,6 +882,17 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_ flow->guessed_category = flow->category = ndpi_http_check_content(ndpi_struct, flow); } } + + if((flow->http.server == NULL) && (packet->server_line.len > 0)) { + int len = packet->server_line.len + 1; + + flow->http.server = ndpi_malloc(len); + if(flow->http.server) { + strncpy(flow->http.server, (char*)packet->server_line.ptr, + packet->server_line.len); + flow->http.server[packet->server_line.len] = '\0'; + } + } } if(flow->http_detected && packet->content_line.ptr && *(char*)packet->content_line.ptr) { |