aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/cassandra.c
diff options
context:
space:
mode:
authorVladimir Gavrilov <105977161+0xA50C1A1@users.noreply.github.com>2024-01-20 17:58:14 +0300
committerGitHub <noreply@github.com>2024-01-20 15:58:14 +0100
commit8651ce981149a73df6f2d9d64218ef58a4479c46 (patch)
tree8e99e68b13c15e38775950d8a1460cf37d1f6e43 /src/lib/protocols/cassandra.c
parenteb129297e90babf6025e33ae7d24a51fb4f16a11 (diff)
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
Diffstat (limited to 'src/lib/protocols/cassandra.c')
-rw-r--r--src/lib/protocols/cassandra.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/protocols/cassandra.c b/src/lib/protocols/cassandra.c
index effb9d255..191932ceb 100644
--- a/src/lib/protocols/cassandra.c
+++ b/src/lib/protocols/cassandra.c
@@ -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);