fix ignored message id key for NN>3, fix longer message key check (fixes #1436), add log message on exceeded max length
This commit is contained in:
+4
-1
@@ -408,7 +408,10 @@ int main(int argc, char* argv[], char* envp[]) {
|
|||||||
fout.close();
|
fout.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (overallResult == RESULT_OK && s_messageMap->getMaxIdLength() > 7) {
|
||||||
|
logNotice(lf_main, "max message ID length exceeded");
|
||||||
|
overallResult = RESULT_CONTINUE;
|
||||||
|
}
|
||||||
cleanup();
|
cleanup();
|
||||||
return overallResult == RESULT_OK ? EXIT_SUCCESS : EXIT_FAILURE;
|
return overallResult == RESULT_OK ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ uint64_t Message::createKey(const vector<symbol_t>& id, bool isWrite, bool isPas
|
|||||||
int exp = 5;
|
int exp = 5;
|
||||||
for (const auto it : id) {
|
for (const auto it : id) {
|
||||||
key ^= (uint64_t)it << (8 * exp--);
|
key ^= (uint64_t)it << (8 * exp--);
|
||||||
if (exp == 0) {
|
if (exp < 0) {
|
||||||
exp = 3;
|
exp = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,7 +206,7 @@ uint64_t Message::createKey(const MasterSymbolString& master, size_t maxIdLength
|
|||||||
int exp = 3;
|
int exp = 3;
|
||||||
for (size_t i = 0; i < idLength; i++) {
|
for (size_t i = 0; i < idLength; i++) {
|
||||||
key ^= (uint64_t)master.dataAt(i) << (8 * exp--);
|
key ^= (uint64_t)master.dataAt(i) << (8 * exp--);
|
||||||
if (exp == 0) {
|
if (exp < 0) {
|
||||||
exp = 3;
|
exp = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2712,13 +2712,12 @@ Message* MessageMap::find(const MasterSymbolString& master, bool anyDestination,
|
|||||||
if (anyDestination && master.size() >= 5 && master[4] == 0 && master[2] == 0x07 && master[3] == 0x04) {
|
if (anyDestination && master.size() >= 5 && master[4] == 0 && master[2] == 0x07 && master[3] == 0x04) {
|
||||||
return m_scanMessage;
|
return m_scanMessage;
|
||||||
}
|
}
|
||||||
uint64_t baseKey = Message::createKey(master,
|
size_t maxIdLength = anyDestination || master[1] != BROADCAST ? m_maxIdLength : m_maxBroadcastIdLength;
|
||||||
anyDestination || master[1] != BROADCAST ? m_maxIdLength : m_maxBroadcastIdLength, anyDestination);
|
uint64_t baseKey = Message::createKey(master, maxIdLength, anyDestination);
|
||||||
if (baseKey == INVALID_KEY) {
|
if (baseKey == INVALID_KEY) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
bool isWriteDest = isMaster(master[1]) || master[1] == BROADCAST;
|
bool isWriteDest = isMaster(master[1]) || master[1] == BROADCAST;
|
||||||
size_t maxIdLength = Message::getKeyLength(baseKey);
|
|
||||||
for (size_t idLength = maxIdLength; true; idLength--) {
|
for (size_t idLength = maxIdLength; true; idLength--) {
|
||||||
uint64_t key = baseKey;
|
uint64_t key = baseKey;
|
||||||
if (idLength == maxIdLength) {
|
if (idLength == maxIdLength) {
|
||||||
@@ -2728,7 +2727,7 @@ Message* MessageMap::find(const MasterSymbolString& master, bool anyDestination,
|
|||||||
int exp = 3;
|
int exp = 3;
|
||||||
for (size_t i = 0; i < idLength; i++) {
|
for (size_t i = 0; i < idLength; i++) {
|
||||||
key ^= (uint64_t)master.dataAt(i) << (8 * exp--);
|
key ^= (uint64_t)master.dataAt(i) << (8 * exp--);
|
||||||
if (exp == 0) {
|
if (exp < 0) {
|
||||||
exp = 3;
|
exp = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2907,6 +2906,10 @@ void MessageMap::dump(bool withConditions, OutputFormat outputFormat, ostream* o
|
|||||||
*output << (m_addAll ? "[" : "{");
|
*output << (m_addAll ? "[" : "{");
|
||||||
} else {
|
} else {
|
||||||
Message::dumpHeader(nullptr, output);
|
Message::dumpHeader(nullptr, output);
|
||||||
|
if (m_addAll) {
|
||||||
|
*output << endl << "# max ID length: " << static_cast<unsigned>(m_maxIdLength)
|
||||||
|
<< " (broadcast only: " << static_cast<unsigned>(m_maxBroadcastIdLength) << ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!(outputFormat & OF_SHORT)) {
|
if (!(outputFormat & OF_SHORT)) {
|
||||||
*output << endl;
|
*output << endl;
|
||||||
|
|||||||
@@ -158,13 +158,6 @@ class Message : public AttributedItem {
|
|||||||
*/
|
*/
|
||||||
static uint64_t createKey(symbol_t pb, symbol_t sb, bool broadcast);
|
static uint64_t createKey(symbol_t pb, symbol_t sb, bool broadcast);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the length field from the key.
|
|
||||||
* @param key the key.
|
|
||||||
* @return the length field from the key.
|
|
||||||
*/
|
|
||||||
static size_t getKeyLength(uint64_t key) { return (size_t)(key >> (8 * 7 + 5)); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse an ID part from the input @a string.
|
* Parse an ID part from the input @a string.
|
||||||
* @param input the input @a string, hex digits optionally separated by space.
|
* @param input the input @a string, hex digits optionally separated by space.
|
||||||
@@ -1651,6 +1644,10 @@ class MessageMap : public MappedFileReader {
|
|||||||
*/
|
*/
|
||||||
void dump(bool withConditions, OutputFormat outputFormat, ostream* output) const;
|
void dump(bool withConditions, OutputFormat outputFormat, ostream* output) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the maximum ID length used by any of the known @a Message instances.
|
||||||
|
*/
|
||||||
|
size_t getMaxIdLength() const { return m_maxIdLength; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** empty vector for @a getLoadedFiles(). */
|
/** empty vector for @a getLoadedFiles(). */
|
||||||
|
|||||||
Reference in New Issue
Block a user