Support 2+ path-hash width filters

This commit is contained in:
mikecarper committed 2026-10-02 10:21:17 -07:00
1 parent d084f5b837
commit 7324bf06ef
12 files changed
+202 -37

No files matched your search

+7 -5
View File
@@ -7426,8 +7426,8 @@ void MyMesh::formatFloodPacketFilterDetail(int index, char* reply, size_t reply_
char retry[10];
char hashbytes[16] = {};
if (entry.path_hops == 0 && entry.path_hash_size != 0)
snprintf(hashbytes, sizeof(hashbytes), " hashbytes=%u",
(unsigned)entry.path_hash_size);
snprintf(hashbytes, sizeof(hashbytes), " hashbytes=%s",
FloodFilterPolicy::pathHashBytesName(entry.path_hash_size));
formatFloodFilterHopSpec(hops, sizeof(hops), entry.min_hops, entry.max_hops);
if (entry.match_blacklisted_path) {
strcpy(prefix, "blacklist");
@@ -7945,7 +7945,7 @@ void MyMesh::setFloodPacketFilter(const char* args, char* reply,
}
if (!FloodFilterPolicy::parsePathHashBytes(
strchr(tokens[i], '=') + 1, hashbytes)) {
strcpy(reply, "Err - hashbytes must be any, 1, 2, or 3");
strcpy(reply, "Err - hashbytes must be any, 1, 2, 2+, or 3");
return;
}
hashbytes_set = true;
@@ -7984,11 +7984,13 @@ void MyMesh::setFloodPacketFilter(const char* args, char* reply,
}
}
if (hashbytes != 0) {
if (path_hash_size != 0 && path_hash_size != hashbytes) {
if (path_hash_size != 0
&& !FloodFilterPolicy::pathHashBytesMatch(hashbytes, path_hash_size)) {
strcpy(reply, "Err - hashbytes conflicts with prefix width");
return;
}
path_hash_size = hashbytes;
// An explicit prefix already narrows 2+ to its exact 2- or 3-byte width.
if (path_hash_size == 0) path_hash_size = hashbytes;
}
if (scope_timing_set && !target_set) {
strcpy(reply, "Err - tx timing requires scope= or region=");
@@ -1108,8 +1108,8 @@ void FloodRuleEngine::formatDetail(int index, char* reply,
char retry[10];
char hashbytes[16] = {};
if (entry.path_hops == 0 && entry.path_hash_size != 0)
snprintf(hashbytes, sizeof(hashbytes), " hashbytes=%u",
(unsigned)entry.path_hash_size);
snprintf(hashbytes, sizeof(hashbytes), " hashbytes=%s",
FloodFilterPolicy::pathHashBytesName(entry.path_hash_size));
formatHopSpec(hops, sizeof(hops), entry.min_hops, entry.max_hops);
if (entry.match_blacklisted_path) copyString(prefix, "blacklist", sizeof(prefix));
else formatPathPrefix(prefix, sizeof(prefix), entry.path_hash_size,
@@ -1616,7 +1616,7 @@ void FloodRuleEngine::set(const char* args, char* reply,
}
if (!FloodFilterPolicy::parsePathHashBytes(
strchr(tokens[i], '=') + 1, hashbytes)) {
copyString(reply, "Err - hashbytes must be any, 1, 2, or 3", 160);
copyString(reply, "Err - hashbytes must be any, 1, 2, 2+, or 3", 160);
return;
}
hashbytes_set = true;
@@ -1654,11 +1654,13 @@ void FloodRuleEngine::set(const char* args, char* reply,
}
if (hashbytes != 0) {
if (path_hash_size != 0 && path_hash_size != hashbytes) {
if (path_hash_size != 0
&& !FloodFilterPolicy::pathHashBytesMatch(hashbytes, path_hash_size)) {
copyString(reply, "Err - hashbytes conflicts with prefix width", 160);
return;
}
path_hash_size = hashbytes;
// An explicit prefix already narrows 2+ to its exact 2- or 3-byte width.
if (path_hash_size == 0) path_hash_size = hashbytes;
}
if (scope_timing_set && !target_set) {
copyString(reply, "Err - tx timing requires scope= or region=", 160);