Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
koltiradw committed Feb 16, 2025
1 parent 1151e92 commit 74c1289
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/lib/ndpi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6903,6 +6903,9 @@ void ndpi_free_flow_data(struct ndpi_flow_struct* flow) {

if(flow->protos.ssdp.server)
ndpi_free(flow->protos.ssdp.server);

if(flow->protos.ssdp.method)
ndpi_free(flow->protos.ssdp.method);
}

if(flow->tls_quic.message[0].buffer)
Expand Down
4 changes: 4 additions & 0 deletions src/lib/ndpi_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,10 @@ int ndpi_dpi2json(struct ndpi_detection_module_struct *ndpi_struct,
case NDPI_PROTOCOL_SSDP:
ndpi_serialize_start_of_block(serializer, "ssdp");

if (flow->protos.ssdp.method) {
ndpi_serialize_string_string(serializer, "METHOD", flow->protos.ssdp.method);
}

if (flow->protos.ssdp.cache_controle) {
ndpi_serialize_string_string(serializer, "CACHE-CONTROL", flow->protos.ssdp.cache_controle);
}
Expand Down
27 changes: 19 additions & 8 deletions src/lib/protocols/ssdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
#include "ndpi_api.h"
#include "ndpi_private.h"

static struct SSDP {
const char *detection_line;
const char *method;
} SSDP_METHODS[] = {
{ "M-SEARCH * HTTP/1.1", "M-SEARCH" },
{ "NOTIFY * HTTP/1.1", "NOTIFY" }
};

static void ssdp_parse_lines(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
Expand Down Expand Up @@ -187,14 +194,18 @@ static void ndpi_search_ssdp(struct ndpi_detection_module_struct *ndpi_struct, s
if (packet->udp != NULL) {

if (packet->payload_packet_len >= 19) {
if ((memcmp(packet->payload, "M-SEARCH * HTTP/1.1", 19) == 0)
|| memcmp(packet->payload, "NOTIFY * HTTP/1.1", 17) == 0) {


NDPI_LOG_INFO(ndpi_struct, "found ssdp\n");
ndpi_int_ssdp_add_connection(ndpi_struct, flow);
return;
}
for (unsigned int i=0; i < sizeof(SSDP_METHODS)/sizeof(SSDP_METHODS[0]); i++) {
if(memcmp(packet->payload, SSDP_METHODS[i].detection_line, strlen(SSDP_METHODS[i].detection_line)) == 0) {
flow->protos.ssdp.method = ndpi_malloc(strlen(SSDP_METHODS[i].detection_line) + 1);
if (flow->protos.ssdp.method) {
memcpy(flow->protos.ssdp.method, SSDP_METHODS[i].method, strlen(SSDP_METHODS[i].method));
flow->protos.ssdp.method[strlen(SSDP_METHODS[i].method)] = '\0';
}
NDPI_LOG_INFO(ndpi_struct, "found ssdp\n");
ndpi_int_ssdp_add_connection(ndpi_struct, flow);
return;
}
}

#define SSDP_HTTP "HTTP/1.1 200 OK\r\n"
if(memcmp(packet->payload, SSDP_HTTP, strlen(SSDP_HTTP)) == 0) {
Expand Down

0 comments on commit 74c1289

Please sign in to comment.