aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/ndpi_api.h13
-rw-r--r--src/lib/ndpi_utils.c23
2 files changed, 23 insertions, 13 deletions
diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h
index 3db2c1bbc..d304ceb5d 100644
--- a/src/include/ndpi_api.h
+++ b/src/include/ndpi_api.h
@@ -1775,7 +1775,7 @@ extern "C" {
u_int ndpi_hex2bin(u_char *out, u_int out_len, u_char* in, u_int in_len);
u_int ndpi_bin2hex(u_char *out, u_int out_len, u_char* in, u_int in_len);
-
+
/* ******************************* */
int ndpi_des_init(struct ndpi_des_struct *des, double alpha, double beta, float significance);
@@ -2301,6 +2301,7 @@ extern "C" {
int ndpi_snprintf(char * str, size_t size, char const * format, ...);
struct tm *ndpi_gmtime_r(const time_t *timep, struct tm *result);
char* ndpi_strrstr(const char *haystack, const char *needle);
+ int ndpi_str_endswith(const char *s, const char *suffix);
/* ******************************* */
@@ -2322,16 +2323,16 @@ extern "C" {
u_int16_t cleartext_msg_len,
u_int16_t *encrypted_msg_len,
u_char encrypt_key[64]);
-
+
char* ndpi_quick_decrypt(const char *encrypted_msg,
u_int16_t encrypted_msg_len,
u_int16_t *decrypted_msg_len,
u_char decrypt_key[64]);
-
+
/* ******************************* */
const char* ndpi_print_os_hint(u_int8_t os_hint);
-
+
/* ******************************* */
bool ndpi_serialize_flow_fingerprint(struct ndpi_detection_module_struct *ndpi_str,
@@ -2348,7 +2349,7 @@ extern "C" {
u_int32_t epoch_now, u_int32_t ttl);
bool ndpi_address_cache_dump(struct ndpi_address_cache *cache, char *path, u_int32_t epoch_now);
u_int32_t ndpi_address_cache_restore(struct ndpi_address_cache *cache, char *path, u_int32_t epoch_now);
-
+
bool ndpi_cache_address(struct ndpi_detection_module_struct *ndpi_struct,
ndpi_ip_addr_t ip_addr, char *hostname,
@@ -2357,7 +2358,7 @@ extern "C" {
bool ndpi_cache_address_dump(struct ndpi_detection_module_struct *ndpi_struct, char *path, u_int32_t epoch_now);
u_int32_t ndpi_cache_address_restore(struct ndpi_detection_module_struct *ndpi_struct, char *path, u_int32_t epoch_now);
u_int32_t ndpi_cache_address_flush_expired(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t epoch_now);
-
+
/* ******************************* */
const char *ndpi_lru_cache_idx_to_name(lru_cache_type idx);
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c
index 5f9a86188..4e981ed96 100644
--- a/src/lib/ndpi_utils.c
+++ b/src/lib/ndpi_utils.c
@@ -1272,7 +1272,7 @@ int ndpi_dpi2json(struct ndpi_detection_module_struct *ndpi_struct,
ndpi_serialize_string_string(serializer, "hostname", host_server_name);
ndpi_serialize_string_string(serializer, "domainame", ndpi_get_host_domain(ndpi_struct, host_server_name));
}
-
+
switch(l7_protocol.proto.master_protocol ? l7_protocol.proto.master_protocol : l7_protocol.proto.app_protocol) {
case NDPI_PROTOCOL_IP_ICMP:
if(flow->entropy > 0.0f) {
@@ -1654,7 +1654,7 @@ int ndpi_flow2json(struct ndpi_detection_module_struct *ndpi_struct,
if(flow->tcp.fingerprint)
ndpi_serialize_string_string(serializer, "tcp_fingerprint", flow->tcp.fingerprint);
-
+
ndpi_serialize_string_string(serializer, "proto",
ndpi_get_ip_proto_name(l4_protocol, l4_proto_name, sizeof(l4_proto_name)));
@@ -3494,6 +3494,15 @@ char* ndpi_strrstr(const char *haystack, const char *needle) {
return (char*) last_occurrence;
}
+/* ************************************************************** */
+
+int ndpi_str_endswith(const char *s, const char *suffix) {
+ size_t slen = strlen(s);
+ size_t suffixlen = strlen(suffix);
+
+ return((slen >= suffixlen) && (!memcmp(&s[slen - suffixlen], suffix, suffixlen)));
+}
+
/* ******************************************* */
const char *ndpi_lru_cache_idx_to_name(lru_cache_type idx)
@@ -3708,7 +3717,7 @@ u_int ndpi_hex2bin(u_char *out, u_int out_len, u_char* in, u_int in_len) {
if(((in_len+1) / 2) > out_len)
return(0);
-
+
for(i=0, j=0; i<in_len; i += 2, j++) {
char buf[3];
@@ -3784,7 +3793,7 @@ char* ndpi_quick_encrypt(const char *cleartext_msg,
ndpi_free(encoded_buf);
*encrypted_msg_len = strlen(encoded);
-
+
return(encoded);
}
@@ -3803,7 +3812,7 @@ char* ndpi_quick_decrypt(const char *encrypted_msg,
struct AES_ctx ctx;
*decrypted_msg_len = 0;
-
+
if(decoded_string == NULL) {
/* Allocation failure */
return(NULL);
@@ -3839,7 +3848,7 @@ char* ndpi_quick_decrypt(const char *encrypted_msg,
}
*decrypted_msg_len = content_len;
-
+
ndpi_free(content);
return(decoded_string);
@@ -3849,7 +3858,7 @@ char* ndpi_quick_decrypt(const char *encrypted_msg,
const char* ndpi_print_os_hint(u_int8_t os_hint) {
switch(os_hint) {
- case os_hint_windows: return("Windows");
+ case os_hint_windows: return("Windows");
case os_hint_macos: return("macOS");
case os_hint_ios_ipad_os: return("iOS/iPad");
case os_hint_android: return("Android");