aboutsummaryrefslogtreecommitdiff
path: root/example/reader_util.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2023-05-20 15:12:14 +0200
committerGitHub <noreply@github.com>2023-05-20 15:12:14 +0200
commit9004d5c2ca71a9821a2041f0a5e16b4144a66ee7 (patch)
treecc61e74454eb12f8e34deb660defd2450ade4bb4 /example/reader_util.c
parent1ab5318f9c652474db838fc45920dab4a3cd4787 (diff)
ndpiReader: fix export of HTTP attributes (#1982)
Diffstat (limited to 'example/reader_util.c')
-rw-r--r--example/reader_util.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/example/reader_util.c b/example/reader_util.c
index 5d0f4f7f3..57b37ec4a 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -1237,19 +1237,6 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
sizeof(flow->kerberos.username),
"%s", flow->ndpi_flow->protos.kerberos.username);
}
- /* HTTP */
- else if(is_ndpi_proto(flow, NDPI_PROTOCOL_HTTP)
- || is_ndpi_proto(flow, NDPI_PROTOCOL_HTTP_PROXY)
- || is_ndpi_proto(flow, NDPI_PROTOCOL_HTTP_CONNECT)) {
- if(flow->ndpi_flow->http.url != NULL) {
- ndpi_snprintf(flow->http.url, sizeof(flow->http.url), "%s", flow->ndpi_flow->http.url);
- }
- flow->http.response_status_code = flow->ndpi_flow->http.response_status_code;
- ndpi_snprintf(flow->http.content_type, sizeof(flow->http.content_type), "%s", flow->ndpi_flow->http.content_type ? flow->ndpi_flow->http.content_type : "");
- ndpi_snprintf(flow->http.server, sizeof(flow->http.server), "%s", flow->ndpi_flow->http.server ? flow->ndpi_flow->http.server : "");
- ndpi_snprintf(flow->http.request_content_type, sizeof(flow->http.request_content_type), "%s", flow->ndpi_flow->http.request_content_type ? flow->ndpi_flow->http.request_content_type : "");
- ndpi_snprintf(flow->http.nat_ip, sizeof(flow->http.nat_ip), "%s", flow->ndpi_flow->http.nat_ip ? flow->ndpi_flow->http.nat_ip : "");
- }
/* RTP */
else if(is_ndpi_proto(flow, NDPI_PROTOCOL_RTP)) {
flow->info_type = INFO_RTP;
@@ -1348,6 +1335,21 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
}
}
+ /* HTTP metadata are "global" not in `flow->ndpi_flow->protos` union; for example, we can have
+ HTTP/BitTorrent and in that case we want to export also HTTP attributes */
+ if(is_ndpi_proto(flow, NDPI_PROTOCOL_HTTP)
+ || is_ndpi_proto(flow, NDPI_PROTOCOL_HTTP_PROXY)
+ || is_ndpi_proto(flow, NDPI_PROTOCOL_HTTP_CONNECT)) {
+ if(flow->ndpi_flow->http.url != NULL) {
+ ndpi_snprintf(flow->http.url, sizeof(flow->http.url), "%s", flow->ndpi_flow->http.url);
+ }
+ flow->http.response_status_code = flow->ndpi_flow->http.response_status_code;
+ ndpi_snprintf(flow->http.content_type, sizeof(flow->http.content_type), "%s", flow->ndpi_flow->http.content_type ? flow->ndpi_flow->http.content_type : "");
+ ndpi_snprintf(flow->http.server, sizeof(flow->http.server), "%s", flow->ndpi_flow->http.server ? flow->ndpi_flow->http.server : "");
+ ndpi_snprintf(flow->http.request_content_type, sizeof(flow->http.request_content_type), "%s", flow->ndpi_flow->http.request_content_type ? flow->ndpi_flow->http.request_content_type : "");
+ ndpi_snprintf(flow->http.nat_ip, sizeof(flow->http.nat_ip), "%s", flow->ndpi_flow->http.nat_ip ? flow->ndpi_flow->http.nat_ip : "");
+ }
+
ndpi_snprintf(flow->http.user_agent,
sizeof(flow->http.user_agent),
"%s", (flow->ndpi_flow->http.user_agent ? flow->ndpi_flow->http.user_agent : ""));