Coverage Report

Created: 2024-01-13 07:07

/src/ndpi/src/lib/protocols/vmware.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * vmware.c
3
 *
4
 * Copyright (C) 2016-22 - 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
#include "ndpi_protocol_ids.h"
22
23
565
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_VMWARE
24
25
#include "ndpi_api.h"
26
#include "ndpi_private.h"
27
28
static void ndpi_search_vmware(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
29
565
{
30
565
  struct ndpi_packet_struct *packet = &ndpi_struct->packet;
31
32
565
  NDPI_LOG_DBG(ndpi_struct, "search vmware\n");
33
  /* Check whether this is an VMWARE flow */
34
565
  if(packet->udp != NULL){
35
565
    if((packet->payload_packet_len == 66) &&
36
565
       (ntohs(packet->udp->dest) == 902) &&
37
565
       ((packet->payload[0] & 0xFF) == 0xA4)){
38
      
39
0
      NDPI_LOG_INFO(ndpi_struct, "found vmware\n");
40
0
      ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_VMWARE, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
41
0
      return;
42
0
    }
43
565
  }
44
565
  NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
45
565
}
46
47
void init_vmware_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id)
48
7.35k
{
49
7.35k
  ndpi_set_bitmask_protocol_detection("VMWARE", ndpi_struct, *id,
50
7.35k
              NDPI_PROTOCOL_VMWARE,
51
7.35k
              ndpi_search_vmware,
52
7.35k
              NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
53
7.35k
              SAVE_DETECTION_BITMASK_AS_UNKNOWN,
54
7.35k
              ADD_TO_DETECTION_BITMASK);
55
  
56
7.35k
  *id += 1;
57
7.35k
}