suricata
app-layer-mqtt.c
Go to the documentation of this file.
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 
38 {
39  SCLogDebug("Registering Rust mqtt parser.");
40  uint32_t max_msg_len = 1048576; /* default: 1MB */
41 
42  if (AppLayerParserConfParserEnabled("tcp", "mqtt")) {
43  ConfNode *p = ConfGetNode("app-layer.protocols.mqtt.max-msg-length");
44  if (p != NULL) {
45  uint32_t value;
46  if (ParseSizeStringU32(p->val, &value) < 0) {
47  SCLogError(SC_ERR_SIZE_PARSE, "invalid value for max-msg-length: %s", p->val);
48  } else {
49  max_msg_len = value;
50  }
51  }
52  rs_mqtt_register_parser(max_msg_len);
53  }
54 #ifdef UNITTESTS
57 #endif
58 }
59 
61 {
62 #ifdef UNITTESTS
63 #endif
64 }
ConfNode_::val
char * val
Definition: conf.h:34
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:298
AppLayerParserConfParserEnabled
int AppLayerParserConfParserEnabled(const char *ipproto, const char *alproto_name)
check if a parser is enabled in the config Returns enabled always if: were running unittests
Definition: app-layer-parser.c:301
ConfGetNode
ConfNode * ConfGetNode(const char *name)
Get a ConfNode by name.
Definition: conf.c:175
rust.h
util-unittest.h
SC_ERR_SIZE_PARSE
@ SC_ERR_SIZE_PARSE
Definition: util-error.h:230
app-layer-detect-proto.h
app-layer-parser.h
stream.h
AppLayerParserRegisterProtocolUnittests
void AppLayerParserRegisterProtocolUnittests(uint8_t ipproto, AppProto alproto, void(*RegisterUnittests)(void))
Definition: app-layer-parser.c:1721
conf.h
suricata-common.h
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:257
ParseSizeStringU32
int ParseSizeStringU32(const char *size, uint32_t *res)
Definition: util-misc.c:185
ConfNode_
Definition: conf.h:32
ALPROTO_MQTT
@ ALPROTO_MQTT
Definition: app-layer-protos.h:55
MQTTParserRegisterTests
void MQTTParserRegisterTests(void)
Definition: app-layer-mqtt.c:60
app-layer-mqtt.h
util-misc.h
RegisterMQTTParsers
void RegisterMQTTParsers(void)
Definition: app-layer-mqtt.c:37