diff --git a/src/include/ndpi_define.h.in b/src/include/ndpi_define.h.in index 998ea8785..a3cdb4767 100644 --- a/src/include/ndpi_define.h.in +++ b/src/include/ndpi_define.h.in @@ -88,7 +88,7 @@ #define MAX_DEFAULT_PORTS 5 -#define NDPI_EXCLUDE_DISSECTOR(mod,flow) exclude_dissector(mod, flow, mod->current_dissector_idx, __FILE__, __FUNCTION__, __LINE__) +#define NDPI_EXCLUDE_DISSECTOR(mod,flow) exclude_dissector(mod, flow, mod->current_dissector_idx, __FILE__, __func__, __LINE__) /** * macro for getting the string len of a static string diff --git a/src/lib/protocols/bittorrent.c b/src/lib/protocols/bittorrent.c index 6c77e29ef..9e5a67f3e 100644 --- a/src/lib/protocols/bittorrent.c +++ b/src/lib/protocols/bittorrent.c @@ -455,11 +455,11 @@ static u_int8_t ndpi_int_search_bittorrent_tcp_zero(struct ndpi_detection_module * 20 BytesPattern : 4c 00 00 00 ff ff ff ff 57 00 00 00 00 00 00 00 20 00 00 00 * 12 BytesPattern : 28 23 00 00 01 00 00 00 10 00 00 00 * */ - static const char pattern_20_bytes[20] = { 0x4c, 0x00, 0x00, 0x00, 0xff, + static const u_char pattern_20_bytes[20] = { 0x4c, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00 }; - static const char pattern_12_bytes[12] = { 0x28, 0x23, 0x00, 0x00, 0x01, + static const u_char pattern_12_bytes[12] = { 0x28, 0x23, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00 }; diff --git a/src/lib/protocols/ethereum.c b/src/lib/protocols/ethereum.c index 37eb802da..91a238c4f 100644 --- a/src/lib/protocols/ethereum.c +++ b/src/lib/protocols/ethereum.c @@ -142,8 +142,9 @@ static void ndpi_search_ethereum(struct ndpi_detection_module_struct *ndpi_struc struct ndpi_packet_struct *packet = &ndpi_struct->packet; if(packet->tcp) - return ndpi_search_ethereum_tcp(ndpi_struct, flow); - return ndpi_search_ethereum_udp(ndpi_struct, flow); + ndpi_search_ethereum_tcp(ndpi_struct, flow); + else + ndpi_search_ethereum_udp(ndpi_struct, flow); } diff --git a/src/lib/protocols/http.c b/src/lib/protocols/http.c index 2a01c731a..73addc24b 100644 --- a/src/lib/protocols/http.c +++ b/src/lib/protocols/http.c @@ -1012,7 +1012,7 @@ static void ndpi_check_http_server(struct ndpi_detection_module_struct *ndpi_str && (ndpi_isdigit(server[i]) || (server[i] == '.')); i++) buf[j++] = server[i]; - if(sscanf(buf, "%d.%d.%d", &a, &b, &c) == 3) { + if(sscanf(buf, "%u.%u.%u", &a, &b, &c) == 3) { u_int32_t version = (a * 1000000) + (b * 1000) + c; char msg[64]; @@ -1903,7 +1903,7 @@ static void ndpi_check_http_tcp(struct ndpi_detection_module_struct *ndpi_struct reset(ndpi_struct, flow); flow->l4.tcp.http_stage = 0; - return ndpi_check_http_tcp(ndpi_struct, flow); + ndpi_check_http_tcp(ndpi_struct, flow); } } diff --git a/src/lib/protocols/kcp.c b/src/lib/protocols/kcp.c index 0e01eaa2b..1441e0f06 100644 --- a/src/lib/protocols/kcp.c +++ b/src/lib/protocols/kcp.c @@ -36,7 +36,7 @@ struct kcp_header { uint32_t serial_number; uint32_t unacknowledged_serial_number; uint32_t length; - uint8_t data[0]; + uint8_t data[]; } PACK_OFF; enum kcp_commands { diff --git a/src/lib/protocols/nintendo.c b/src/lib/protocols/nintendo.c index 99e5b5be8..b8be82bc5 100644 --- a/src/lib/protocols/nintendo.c +++ b/src/lib/protocols/nintendo.c @@ -41,7 +41,7 @@ static void ndpi_search_nintendo(struct ndpi_detection_module_struct *ndpi_struc if(packet->udp != NULL) { if(payload_len > 48) { const char *payload = (const char *)packet->payload; - const char nintendo_pattern[] = { 0x32, 0xab, 0x98, 0x64, 0x02 }; + const unsigned char nintendo_pattern[] = { 0x32, 0xab, 0x98, 0x64, 0x02 }; if(memcmp(payload, nintendo_pattern, 5) == 0) { NDPI_LOG_INFO(ndpi_struct, "found nintendo\n"); diff --git a/src/lib/protocols/someip.c b/src/lib/protocols/someip.c index 0d17524d1..98c8801ef 100644 --- a/src/lib/protocols/someip.c +++ b/src/lib/protocols/someip.c @@ -56,21 +56,19 @@ enum SOMEIP_RETURN_CODES { E_RETURN_CODE_LEGAL_THRESHOLD = 0x40 //return codes from 0x40 (inclusive) and upwards are illegal. }; -enum SPECIAL_MESSAGE_IDS { - MSG_MAGIC_COOKIE = 0xffff0000, - MSG_MAGIC_COOKIE_ACK = 0xffff8000, - MSG_SD = 0xffff8100 -}; +/* SPECIAL_MESSAGE_IDS */ +const u_int32_t MSG_MAGIC_COOKIE = 0xffff0000; +const u_int32_t MSG_MAGIC_COOKIE_ACK = 0xffff8000; +const u_int32_t MSG_SD = 0xffff8100; enum PROTOCOL_VERSION{ LEGAL_PROTOCOL_VERSION = 0x01 }; -enum MAGIC_COOKIE_CONSTANTS{ - MC_REQUEST_ID = 0xDEADBEEF, - MC_LENGTH = 0x08, - MC_INTERFACE_VERSION = 0x01 -}; +/* MAGIC_COOKIE_CONST */ +const u_int32_t MC_REQUEST_ID = 0xDEADBEEF; +const u_int32_t MC_LENGTH = 0x08; +const u_int32_t MC_INTERFACE_VERSION = 0x01; /** * Entry point when protocol is identified. diff --git a/src/lib/protocols/stun.c b/src/lib/protocols/stun.c index 7710a9e9f..bd3795901 100644 --- a/src/lib/protocols/stun.c +++ b/src/lib/protocols/stun.c @@ -1069,8 +1069,8 @@ static int stun_telegram_search_again(struct ndpi_detection_module_struct *ndpi_ struct ndpi_packet_struct *packet = &ndpi_struct->packet; const u_int8_t *orig_payload; u_int16_t orig_payload_length; - char pattern[12] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + u_char pattern[12] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; u_int16_t length; NDPI_LOG_DBG2(ndpi_struct, "[T] Packet counter %d protos %d/%d Monitoring? %d\n", diff --git a/src/lib/protocols/thrift.c b/src/lib/protocols/thrift.c index 3c94f073c..5ca062de4 100644 --- a/src/lib/protocols/thrift.c +++ b/src/lib/protocols/thrift.c @@ -41,7 +41,7 @@ struct thrift_strict_hdr { uint8_t unused_byte_pad; uint8_t message_type; uint32_t method_length; - char method[0]; + char method[]; } PACK_OFF; // TCompactProtocol @@ -59,7 +59,7 @@ struct thrift_compact_hdr { #endif uint8_t sequence_id[3]; uint8_t method_length; - char method[0]; + char method[]; } PACK_OFF; enum thrift_message_type { diff --git a/tests/unit/unit.c b/tests/unit/unit.c index fd73637ab..087798842 100644 --- a/tests/unit/unit.c +++ b/tests/unit/unit.c @@ -139,7 +139,7 @@ int serializerUnitTest() { j = json_tokener_parse_verbose(buffer, &jerr); if (j == NULL) { printf("%s: ERROR (json validation failed: `%s')\n", - __FUNCTION__, json_tokener_error_desc(jerr)); + __func__, json_tokener_error_desc(jerr)); return -1; } else { /* Validation ok */ @@ -195,7 +195,7 @@ int serializerUnitTest() { } break; default: - printf("%s: ERROR Unsupported TLV key type %u (value type %u)\n", __FUNCTION__, kt, et); + printf("%s: ERROR Unsupported TLV key type %u (value type %u)\n", __func__, kt, et); return -1; } @@ -232,7 +232,7 @@ int serializerUnitTest() { default: if (verbose) printf("\n"); - printf("%s: ERROR Unsupported TLV value type %u (key type %u)\n", __FUNCTION__, et, kt); + printf("%s: ERROR Unsupported TLV value type %u (key type %u)\n", __func__, et, kt); return -1; } } @@ -256,7 +256,7 @@ int serializerUnitTest() { ndpi_term_serializer(&serializer); } - printf("%30s OK\n", __FUNCTION__); + printf("%30s OK\n", __func__); return 0; } @@ -316,8 +316,8 @@ int serializeProtoUnitTest(void) if (strncmp(buffer, expected_json_str, buffer_len) != 0) { - printf("%s: ERROR: expected JSON str: \"%s\"\n", __FUNCTION__, expected_json_str); - printf("%s: ERROR: got JSON str.....: \"%.*s\"\n", __FUNCTION__, (int)buffer_len, buffer); + printf("%s: ERROR: expected JSON str: \"%s\"\n", __func__, expected_json_str); + printf("%s: ERROR: got JSON str.....: \"%.*s\"\n", __func__, (int)buffer_len, buffer); return -1; } #endif @@ -330,7 +330,7 @@ int serializeProtoUnitTest(void) json_object * const j = json_tokener_parse_verbose(buffer, &jerr); if (j == NULL) { printf("%s: ERROR (json validation failed: `%s')\n", - __FUNCTION__, json_tokener_error_desc(jerr)); + __func__, json_tokener_error_desc(jerr)); return -1; } else { /* Validation ok */ @@ -346,8 +346,8 @@ int serializeProtoUnitTest(void) printf("%s\n", buffer); if (strncmp(buffer, expected_csv_hdr_str, buffer_len) != 0) { - printf("%s: ERROR: expected CSV str: \"%s\"\n", __FUNCTION__, expected_csv_hdr_str); - printf("%s: ERROR: got CSV str.....: \"%.*s\"\n", __FUNCTION__, (int)buffer_len, buffer); + printf("%s: ERROR: expected CSV str: \"%s\"\n", __func__, expected_csv_hdr_str); + printf("%s: ERROR: got CSV str.....: \"%.*s\"\n", __func__, (int)buffer_len, buffer); } char const * const expected_csv_buf_str = "Self-signed Cert,High,300,270,30,Obsolete TLS (v1.1 or older),High,310,275,35,Weak TLS Cipher,High,150,135,15,Malformed Packet,Low,160,80,80,DPI,TLS.Facebook,91.119,Facebook,119,1,Fun,6,SocialNetwork,340282346638528859811704183484516925440.000000,680564693277057719623408366969033850880.000000"; @@ -358,15 +358,15 @@ int serializeProtoUnitTest(void) printf("%s\n", buffer); if (strncmp(buffer, expected_csv_buf_str, buffer_len) != 0) { - printf("%s: ERROR: expected CSV str: \"%s\"\n", __FUNCTION__, expected_csv_buf_str); - printf("%s: ERROR: got CSV str.....: \"%.*s\"\n", __FUNCTION__, (int)buffer_len, buffer); + printf("%s: ERROR: expected CSV str: \"%s\"\n", __func__, expected_csv_buf_str); + printf("%s: ERROR: got CSV str.....: \"%.*s\"\n", __func__, (int)buffer_len, buffer); } } ndpi_term_serializer(&serializer); } - printf("%30s OK\n", __FUNCTION__); + printf("%30s OK\n", __func__); return 0; } diff --git a/windows/src/ndpi_define.h b/windows/src/ndpi_define.h index 1e6a4757f..c9ed2d9f0 100644 --- a/windows/src/ndpi_define.h +++ b/windows/src/ndpi_define.h @@ -87,7 +87,7 @@ #define MAX_DEFAULT_PORTS 5 -#define NDPI_EXCLUDE_DISSECTOR(mod,flow) exclude_dissector(mod, flow, mod->current_dissector_idx, __FILE__, __FUNCTION__, __LINE__) +#define NDPI_EXCLUDE_DISSECTOR(mod,flow) exclude_dissector(mod, flow, mod->current_dissector_idx, __FILE__, __func__, __LINE__) /** * macro for getting the string len of a static string