Coverage Report

Created: 2026-01-05 06:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ndpi/src/lib/protocols/alicloud.c
Line
Count
Source
1
/*
2
 * alicloud.c
3
 *
4
 * Copyright (C) 2022-23 - ntop.org
5
 *
6
 * nDPI is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * nDPI is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with nDPI.  If not, see <http://www.gnu.org/licenses/>.
18
 *
19
 */
20
21
22
#include "ndpi_protocol_ids.h"
23
24
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_ALICLOUD
25
26
#include "ndpi_api.h"
27
#include "ndpi_private.h"
28
29
static void ndpi_int_alicloud_add_connection(struct ndpi_detection_module_struct * const ndpi_struct,
30
                                             struct ndpi_flow_struct * const flow)
31
589
{
32
589
  NDPI_LOG_INFO(ndpi_struct, "found alicloud\n");
33
34
589
  ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_ALICLOUD, NDPI_PROTOCOL_UNKNOWN,
35
589
                             NDPI_CONFIDENCE_DPI);
36
589
}
37
38
static void ndpi_search_alicloud(struct ndpi_detection_module_struct *ndpi_struct,
39
                                 struct ndpi_flow_struct *flow)
40
3.69M
{
41
3.69M
  struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
42
43
3.69M
  NDPI_LOG_DBG(ndpi_struct, "search alicloud\n");
44
45
3.69M
  if (packet->payload_packet_len < 8)
46
820k
  {
47
820k
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
48
820k
    return;
49
820k
  }
50
51
2.87M
  if (ntohl(get_u_int32_t(packet->payload, 0)) == 0xcefabeba)
52
953
  {
53
953
    u_int32_t pdu_len = ntohl(get_u_int32_t(packet->payload, 4));
54
55
953
    if (packet->payload_packet_len == 8 && pdu_len > 0)
56
576
    {
57
576
      ndpi_int_alicloud_add_connection(ndpi_struct, flow);
58
576
      return;
59
576
    } else if (pdu_len == (u_int32_t)packet->payload_packet_len - 8) {
60
13
      ndpi_int_alicloud_add_connection(ndpi_struct, flow);
61
13
      return;
62
13
    }
63
953
  }
64
65
2.87M
  if (flow->packet_counter > 3)
66
115k
  {
67
115k
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
68
115k
  }
69
2.87M
}
70
71
void init_alicloud_dissector(struct ndpi_detection_module_struct *ndpi_struct)
72
19.1k
{
73
19.1k
  register_dissector("AliCloud", ndpi_struct,
74
19.1k
                     ndpi_search_alicloud,
75
19.1k
                     NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
76
19.1k
                     1, NDPI_PROTOCOL_ALICLOUD);
77
19.1k
}