Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
dec5bcc5
Commit
dec5bcc5
authored
Oct 14, 2020
by
Alessio Netti
Browse files
Minor improvements to parsing of MQTT CONNECT messages
parent
28944306
Changes
1
Hide whitespace changes
Inline
Side-by-side
collectagent/simplemqttservermessage.cpp
View file @
dec5bcc5
...
...
@@ -208,19 +208,23 @@ ssize_t SimpleMQTTMessage::receiveMessage(void* buf, size_t len)
// Message is malformed, break out
if
(
remainingLength
<
12
)
{
break
;
state
=
Error
;
}
else
{
ssize_t
idLen
=
ntohs
(((
uint16_t
*
)
data
)[
0
]);
data
+=
2
;
// Leveraging the topic field to store also the client ID on CONNECT messages
if
(
idLen
>
0
)
{
topic
=
string
(
data
,
idLen
);
data
+=
idLen
;
}
else
{
topic
=
""
;
}
// We store the rest of the CONNECT payload in its raw form
payloadPtr
=
(
void
*
)
data
;
payloadLength
=
remainingLength
-
((
uint8_t
*
)
payloadPtr
-
(
uint8_t
*
)
remainingRaw
);
}
ssize_t
idLen
=
ntohs
(((
uint16_t
*
)
data
)[
0
]);
data
+=
2
;
// Leveraging the topic field to store also the client ID on CONNECT messages
topic
=
string
(
data
,
idLen
);
data
+=
idLen
;
// We store the rest of the CONNECT payload in its raw form
payloadPtr
=
(
void
*
)
data
;
payloadLength
=
remainingLength
-
((
uint8_t
*
)
payloadPtr
-
(
uint8_t
*
)
remainingRaw
);
break
;
}
case
MQTT_PUBREL
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment