Coverage Report

Created: 2026-06-25 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ndpi/src/lib/protocols/lustre.c
Line
Count
Source
1
/*
2
 * lustre.c
3
 *
4
 * Lustre file system
5
 * 
6
 * Copyright (C) 2024 - ntop.org
7
 * Copyright (C) 2024 - V.G <v.gavrilov@securitycode.ru>
8
 *
9
 * This file is part of nDPI, an open source deep packet inspection
10
 * library based on the OpenDPI and PACE technology by ipoque GmbH
11
 *
12
 * nDPI is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Lesser General Public License as published by
14
 * the Free Software Foundation, either version 3 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * nDPI is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Lesser General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU Lesser General Public License
23
 * along with nDPI.  If not, see <http://www.gnu.org/licenses/>.
24
 * 
25
 */
26
27
#include "ndpi_protocol_ids.h"
28
29
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_LUSTRE
30
31
#include "ndpi_api.h"
32
#include "ndpi_private.h"
33
34
static void ndpi_int_lustre_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
35
                                           struct ndpi_flow_struct *flow) 
36
226
{
37
226
  NDPI_LOG_INFO(ndpi_struct, "found Lustre\n");
38
226
  ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_LUSTRE, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
39
226
}
40
41
static void ndpi_search_lustre(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
42
3.24M
{
43
3.24M
  struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
44
45
3.24M
  NDPI_LOG_DBG(ndpi_struct, "search Lustre\n");
46
47
3.24M
  u_int32_t lnd_dst_address = 0;
48
49
3.24M
  if (packet->payload_packet_len > 15) {
50
2.01M
    u_int32_t lnet_magic = le32toh(get_u_int32_t(packet->payload, 0));
51
2.01M
    lnd_dst_address = le32toh(get_u_int32_t(packet->payload, 8));
52
53
2.01M
    if ((lnet_magic == 0x45726963 || lnet_magic == 0xacce7100) && lnd_dst_address == ntohl(packet->iph->daddr))
54
147
    {
55
147
      ndpi_int_lustre_add_connection(ndpi_struct, flow);
56
147
      return;
57
147
    }
58
2.01M
  }
59
60
  /*
61
   * Mid-stream detection
62
   */
63
64
3.24M
  if (packet->payload_packet_len > 95 && le32toh(get_u_int32_t(packet->payload, 0)) == 0xC1)
65
600
  {
66
600
    lnd_dst_address = le32toh(get_u_int32_t(packet->payload, 24));
67
600
    u_int32_t lnet_payload_len = le32toh(get_u_int32_t(packet->payload, 52));
68
69
600
    if (lnd_dst_address == ntohl(packet->iph->daddr) &&
70
261
        lnet_payload_len == (u_int32_t)(packet->payload_packet_len-96))
71
79
    {
72
79
      ndpi_int_lustre_add_connection(ndpi_struct, flow);
73
79
      return;
74
79
    }
75
600
  }
76
77
3.24M
  NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
78
3.24M
}
79
80
void init_lustre_dissector(struct ndpi_detection_module_struct *ndpi_struct)
81
20.3k
{
82
20.3k
  ndpi_register_dissector("Lustre", ndpi_struct,
83
20.3k
                     ndpi_search_lustre,
84
20.3k
                     NDPI_SELECTION_BITMASK_PROTOCOL_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION, /* Ipv4 only; Lustre doesn't support IPv6 */
85
20.3k
                      1, NDPI_PROTOCOL_LUSTRE);
86
20.3k
}