Coverage Report

Created: 2025-11-09 07:18

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
0
{
32
0
  NDPI_LOG_INFO(ndpi_struct, "found alicloud\n");
33
34
0
  ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_ALICLOUD, NDPI_PROTOCOL_UNKNOWN,
35
0
                             NDPI_CONFIDENCE_DPI);
36
0
}
37
38
static void ndpi_search_alicloud(struct ndpi_detection_module_struct *ndpi_struct,
39
                                 struct ndpi_flow_struct *flow)
40
183
{
41
183
  struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
42
43
183
  NDPI_LOG_DBG(ndpi_struct, "search alicloud\n");
44
45
183
  if (packet->payload_packet_len < 8)
46
2
  {
47
2
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
48
2
    return;
49
2
  }
50
51
181
  if (ntohl(get_u_int32_t(packet->payload, 0)) == 0xcefabeba)
52
0
  {
53
0
    u_int32_t pdu_len = ntohl(get_u_int32_t(packet->payload, 4));
54
55
0
    if (packet->payload_packet_len == 8 && pdu_len > 0)
56
0
    {
57
0
      ndpi_int_alicloud_add_connection(ndpi_struct, flow);
58
0
      return;
59
0
    } else if (pdu_len == (u_int32_t)packet->payload_packet_len - 8) {
60
0
      ndpi_int_alicloud_add_connection(ndpi_struct, flow);
61
0
      return;
62
0
    }
63
0
  }
64
65
181
  if (flow->packet_counter > 3)
66
0
  {
67
0
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
68
0
  }
69
181
}
70
71
void init_alicloud_dissector(struct ndpi_detection_module_struct *ndpi_struct)
72
796
{
73
796
  register_dissector("AliCloud", ndpi_struct,
74
796
                     ndpi_search_alicloud,
75
796
                     NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
76
796
                     1, NDPI_PROTOCOL_ALICLOUD);
77
796
}