aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_main.c
diff options
context:
space:
mode:
authorToni <matzeton@googlemail.com>2022-04-25 13:00:50 +0200
committerGitHub <noreply@github.com>2022-04-25 13:00:50 +0200
commitbc2ad3407a1cf7f6d2913f113df31dfbf735c6f6 (patch)
treea06e65f5d38238a894dea0415b2b6584cd027e4f /src/lib/ndpi_main.c
parent075bce5f3de463975464472158dca980a45f48a3 (diff)
Added generic user agent setter. (#1530)
* ndpiReader: Print user agent if one was set and not just for certain protocols. Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'src/lib/ndpi_main.c')
-rw-r--r--src/lib/ndpi_main.c19
1 files changed, 19 insertions, 0 deletions
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;
+}