Coverage Report

Created: 2025-07-23 07:29

/src/suricata7/src/app-layer-mqtt.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2020 Open Information Security Foundation
2
 *
3
 * You can copy, redistribute or modify this Program under the terms of
4
 * the GNU General Public License version 2 as published by the Free
5
 * Software Foundation.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * version 2 along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
 * 02110-1301, USA.
16
 */
17
18
/**
19
 * \file
20
 *
21
 * \author Sascha Steinbiss <sascha@steinbiss.name>
22
 */
23
24
#include "suricata-common.h"
25
#include "stream.h"
26
#include "conf.h"
27
28
#include "util-misc.h"
29
#include "util-unittest.h"
30
31
#include "app-layer-detect-proto.h"
32
#include "app-layer-parser.h"
33
34
#include "app-layer-mqtt.h"
35
#include "rust.h"
36
37
void RegisterMQTTParsers(void)
38
34
{
39
34
    SCLogDebug("Registering Rust mqtt parser.");
40
34
    uint32_t max_msg_len = 1048576; /* default: 1MB */
41
42
34
    if (AppLayerParserConfParserEnabled("tcp", "mqtt")) {
43
34
        ConfNode *p = ConfGetNode("app-layer.protocols.mqtt.max-msg-length");
44
34
        if (p != NULL) {
45
0
            uint32_t value;
46
0
            if (ParseSizeStringU32(p->val, &value) < 0) {
47
0
                SCLogError("invalid value for max-msg-length: %s", p->val);
48
0
            } else {
49
0
                max_msg_len = value;
50
0
            }
51
0
        }
52
34
        rs_mqtt_register_parser(max_msg_len);
53
34
    }
54
#ifdef UNITTESTS
55
    AppLayerParserRegisterProtocolUnittests(IPPROTO_TCP, ALPROTO_MQTT,
56
        MQTTParserRegisterTests);
57
#endif
58
34
}
59
60
void MQTTParserRegisterTests(void)
61
0
{
62
#ifdef UNITTESTS
63
#endif
64
0
}