Fix detection of new Cassandra versions (#2272)

* Fix detection of new Cassandra versions

* Add Cassandra Internode Communication protocol support

* Add default port for Cassandra Internode Communication protocol
This commit is contained in:
Vladimir Gavrilov
2024-01-20 15:58:14 +01:00
committed by GitHub
parent eb129297e9
commit 8651ce9811
5 changed files with 1339 additions and 1330 deletions
+12 -5
View File
@@ -33,12 +33,12 @@
static inline int ndpi_validate_cassandra_response(u_int8_t response)
{
return (response >= 0x81 && response <= 0x84) ? 1 : -1;
return (response >= 0x81 && response <= 0x85) ? 1 : -1;
}
static inline int ndpi_validate_cassandra_request(u_int8_t request)
{
return (request >= 0x01 && request <= 0x04) ? 1 : -1;
return (request >= 0x01 && request <= 0x05) ? 1 : -1;
}
static void ndpi_int_cassandra_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
@@ -58,6 +58,14 @@ static void ndpi_search_cassandra(struct ndpi_detection_module_struct *ndpi_stru
NDPI_LOG_DBG(ndpi_struct, "search Cassandra CQL\n");
if (packet->payload_packet_len == 19 &&
ntohl(get_u_int32_t(packet->payload, 0)) == 0xCA552DFA)
{
NDPI_LOG_INFO(ndpi_struct, "found Cassandra Internode Communication\n");
ndpi_int_cassandra_add_connection(ndpi_struct, flow);
return;
}
if (packet->payload_packet_len < 9 ||
(!ndpi_validate_cassandra_response(packet->payload[0]) ||
!ndpi_validate_cassandra_request(packet->payload[0])))
@@ -74,9 +82,8 @@ static void ndpi_search_cassandra(struct ndpi_detection_module_struct *ndpi_stru
/* Looking for a 'STARTUP' message from the client,
* which should always contain the CQL_VERSION string
*/
if (packet->payload_packet_len > 24 &&
(packet->payload[4] == 0x01 &&
(strncmp((char *)&packet->payload[13], "CQL_VERSION", 11) == 0)))
if (packet->payload_packet_len > 60 &&
memcmp(&packet->payload[packet->payload_packet_len-20], "CQL_VERSION", 11) == 0)
{
NDPI_LOG_INFO(ndpi_struct, "found Cassandra CQL\n");
ndpi_int_cassandra_add_connection(ndpi_struct, flow);