From d668ab4becf446195f3c6cd338d5de2711d7bf4e Mon Sep 17 00:00:00 2001 From: Darryl Sokoloski Date: Sun, 27 Mar 2022 05:10:44 -0400 Subject: [SSDP] Extract HTTP user-agent when available. (#1500) [SSDP] Added capture file with UA header. [SSDP] Added pcap test output log file. Signed-off-by: Darryl Sokoloski --- src/lib/protocols/ssdp.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/lib') diff --git a/src/lib/protocols/ssdp.c b/src/lib/protocols/ssdp.c index 92354b27a..cc2eb2f71 100644 --- a/src/lib/protocols/ssdp.c +++ b/src/lib/protocols/ssdp.c @@ -29,9 +29,30 @@ #include "ndpi_api.h" +static void ssdp_parse_lines(struct ndpi_detection_module_struct + *ndpi_struct, struct ndpi_flow_struct *flow) +{ + struct ndpi_packet_struct *packet = &ndpi_struct->packet; + + ndpi_parse_packet_line_info(ndpi_struct, flow); + + /* Save user-agent for device discovery if available */ + if(packet->user_agent_line.ptr != NULL && packet->user_agent_line.len != 0) { + if(flow->http.user_agent == NULL) { + flow->http.user_agent = ndpi_malloc(packet->user_agent_line.len + 1); + if(flow->http.user_agent) { + memcpy(flow->http.user_agent, + (char*)packet->user_agent_line.ptr, packet->user_agent_line.len); + flow->http.user_agent[packet->user_agent_line.len] = '\0'; + } + } + } +} + static void ndpi_int_ssdp_add_connection(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { + ssdp_parse_lines(ndpi_struct, flow); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_SSDP, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); } -- cgit v1.2.3