diff --git a/FILTER.md b/FILTER.md index f01922a4..c5a1c84b 100644 --- a/FILTER.md +++ b/FILTER.md @@ -103,8 +103,8 @@ bytes, not whole characters — one emoji is 4 bytes, so `J.hn` will not match | Constant | Default | Notes | |---|---|---| -| `FILTER_MAX_RULES` | 16 | ~119 B per rule slot | -| `FILTER_MAX_CHANNELS` | 8 | `chan` bitmask is one byte wide | +| `FILTER_MAX_RULES` | 16 | ~128 B per rule slot | +| `FILTER_MAX_CHANNELS` | 16 | `chan` bitmask is 16 bits (one bit per channel) | | `FILTER_CHAN_NAME_LEN` | 16 | channel name storage (NUL incl.) | | `FILTER_ADVERT_CACHE_SIZE` | 256 | advert rate-limiter cache | | `FILTER_SENDER_PATTERN_LEN` | 24 | sender regex length (NUL incl.) | diff --git a/examples/simple_repeater/PacketFilter.cpp b/examples/simple_repeater/PacketFilter.cpp index 68c0554c..080172ba 100644 --- a/examples/simple_repeater/PacketFilter.cpp +++ b/examples/simple_repeater/PacketFilter.cpp @@ -40,7 +40,7 @@ static int filterDecodeBase64(const char* in, size_t in_len, uint8_t* out) { // The well-known Public channel PSK (16 bytes); its sha256()[0] air hash is 0x11. #define FILTER_PUBLIC_PSK_B64 "izOH6cXN6mrJ5e26oRXNcg==" #define FILTER_CFG_FILE "/filter_cfg" -#define FILTER_CFG_VERSION 2 +#define FILTER_CFG_VERSION 3 // v3: chan_mask widened to 16 bits (v1/v2 configs discarded) #define FILTER_RULE_PERSIST_BYTES (offsetof(FilterRule, hits)) // config fields only; stats excluded #define FILTER_SAVE_DELAY_MS 3000 // lazy dirty-write delay (like ClientACL) #define FILTER_ADVERT_HOURS_MAX 720 // ~30 days; millis() wraps at ~49.7 days @@ -168,8 +168,8 @@ void FilterRules::delChannel(int idx) { // remap rule masks so they keep pointing at the same channels for (int i = 0; i < num_rules; i++) { FilterRule* r = &rules[i]; - uint8_t lo = r->chan_mask & ((1 << idx) - 1); - uint8_t hi = (uint8_t)(r->chan_mask >> (idx + 1)) << idx; + uint16_t lo = r->chan_mask & (uint16_t)((1 << idx) - 1); + uint16_t hi = (uint16_t)(r->chan_mask >> (idx + 1)) << idx; r->chan_mask = lo | hi; } dirty = true; dirty_since = millis(); diff --git a/examples/simple_repeater/PacketFilter.h b/examples/simple_repeater/PacketFilter.h index 34ba9c1b..8f65718c 100644 --- a/examples/simple_repeater/PacketFilter.h +++ b/examples/simple_repeater/PacketFilter.h @@ -54,8 +54,8 @@ #define FILTER_IV_HI_ANY 0x08 // hi unbounded (*) // flags == 0 -> predicate unset (wildcard) -#if FILTER_MAX_CHANNELS > 8 - #error "FILTER_MAX_CHANNELS > 8 needs a wider FilterRule::chan_mask" +#if FILTER_MAX_CHANNELS > 16 + #error "FILTER_MAX_CHANNELS > 16 needs a wider FilterRule::chan_mask" #endif struct FilterChannel { // keyed channel store @@ -85,7 +85,7 @@ struct FilterRule { uint8_t pos; // FILTER_PATH_* ; anchor position } path; uint8_t hash_size_mask; // bit0..3 = path hash size 1..4; 0 = any - uint8_t chan_mask; // keyed channels by stored name; bitmask over the + uint16_t chan_mask; // keyed channels by stored name; bitmask over the // FILTER_MAX_CHANNELS store; 0 = unset (deferred to // onGroupDataRecv, identity proven by MAC decrypt) uint8_t chan_hash; // 1-byte air hash (chanhash=XX); valid only w/ flag diff --git a/examples/simple_repeater/PacketFilterConfig.h b/examples/simple_repeater/PacketFilterConfig.h index d76b044a..728e6381 100644 --- a/examples/simple_repeater/PacketFilterConfig.h +++ b/examples/simple_repeater/PacketFilterConfig.h @@ -5,8 +5,8 @@ // build_flags (e.g. in platformio.local.ini: -DFILTER_MAX_RULES=32) or by // editing the defaults below. // -// NOTE: FilterRule::chan_mask is one byte wide; if FILTER_MAX_CHANNELS is -// raised above 8, widen chan_mask accordingly (see PacketFilter.h). +// NOTE: FilterRule::chan_mask is 16 bits wide; if FILTER_MAX_CHANNELS is +// raised above 16, widen chan_mask accordingly (see PacketFilter.h). #ifndef _PACKET_FILTER_CONFIG_H #define _PACKET_FILTER_CONFIG_H @@ -16,7 +16,7 @@ #endif #ifndef FILTER_MAX_CHANNELS - #define FILTER_MAX_CHANNELS 8 // keyed channel store entries + #define FILTER_MAX_CHANNELS 16 // keyed channel store entries #endif #ifndef FILTER_CHAN_NAME_LEN