init struct size problem fix
This commit is contained in:
parent
8e5dbd4703
commit
c14a692493
@ -13,6 +13,7 @@ enum Code : uint8_t
|
||||
TinyString = 0x80,
|
||||
TinyList = 0x90,
|
||||
TinyMap = 0xA0,
|
||||
|
||||
TinyStruct = 0xB0,
|
||||
|
||||
Null = 0xC0,
|
||||
@ -53,6 +54,11 @@ enum Code : uint8_t
|
||||
EndOfStream = 0xDF,
|
||||
};
|
||||
|
||||
enum Rule : uint8_t
|
||||
{
|
||||
MaxInitStructSize = 0x02
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "communication/bolt/v1/states/init.hpp"
|
||||
|
||||
#include "communication/bolt/v1/session.hpp"
|
||||
#include "communication/bolt/v1/messaging/codes.hpp"
|
||||
#include "communication/bolt/v1/session.hpp"
|
||||
|
||||
#include "utils/likely.hpp"
|
||||
|
||||
@ -10,24 +10,23 @@ namespace bolt
|
||||
|
||||
Init::Init() : MessageParser<Init>(logging::log->logger("Init")) {}
|
||||
|
||||
State* Init::parse(Session& session, Message& message)
|
||||
State *Init::parse(Session &session, Message &message)
|
||||
{
|
||||
auto struct_type = session.decoder.read_byte();
|
||||
|
||||
if(UNLIKELY(struct_type != 0xB2))
|
||||
{
|
||||
if (UNLIKELY(struct_type & 0x0F <= pack::Rule::MaxInitStructSize)) {
|
||||
logger.debug("{}", struct_type);
|
||||
|
||||
logger.debug("Expected struct marker 0xB2 instead of 0x{:02X}",
|
||||
(unsigned)struct_type);
|
||||
logger.debug(
|
||||
"Expected struct marker of max size 0x{:02} instead of 0x{:02X}",
|
||||
pack::Rule::MaxInitStructSize, pack::Code(unsigned) struct_type);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto message_type = session.decoder.read_byte();
|
||||
|
||||
if(UNLIKELY(message_type != MessageCode::Init))
|
||||
{
|
||||
if (UNLIKELY(message_type != MessageCode::Init)) {
|
||||
logger.debug("Expected Init (0x01) instead of (0x{:02X})",
|
||||
(unsigned)message_type);
|
||||
|
||||
@ -36,12 +35,12 @@ State* Init::parse(Session& session, Message& message)
|
||||
|
||||
message.client_name = session.decoder.read_string();
|
||||
|
||||
// TODO read authentication tokens
|
||||
// TODO read authentication tokens if B2
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
State* Init::execute(Session& session, Message& message)
|
||||
State *Init::execute(Session &session, Message &message)
|
||||
{
|
||||
logger.debug("Client connected '{}'", message.client_name);
|
||||
|
||||
@ -51,5 +50,4 @@ State* Init::execute(Session& session, Message& message)
|
||||
|
||||
return session.bolt.states.executor.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user