From 087e299e542a53050a247a39f29206878b08aacc Mon Sep 17 00:00:00 2001 From: lns Date: Mon, 25 Apr 2022 11:39:33 +0200 Subject: Added generic user agent setter. * ndpiReader: Print user agent if one was set and not just for certain protocols. Signed-off-by: lns --- src/lib/ndpi_main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/lib/ndpi_main.c') diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 5a6376c6f..a9e34f30b 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -8421,3 +8421,22 @@ char *ndpi_hostname_sni_set(struct ndpi_flow_struct *flow, const u_int8_t *value return dst; } + +/* ******************************************************************** */ + +char *ndpi_user_agent_set(struct ndpi_flow_struct *flow, const u_int8_t *value, size_t value_len) +{ + if (flow->http.user_agent != NULL) + { + return NULL; + } + + flow->http.user_agent = ndpi_malloc(value_len + 1); + if (flow->http.user_agent != NULL) + { + memcpy(flow->http.user_agent, value, value_len); + flow->http.user_agent[value_len] = '\0'; + } + + return flow->http.user_agent; +} -- cgit v1.2.3