mirror of
https://github.com/jhuebert/MeshCore.git
synced 2026-12-03 10:54:13 +00:00
simple_repeater: double keyed channel store to 16 entries
chan_mask was one bit per channel and one byte wide, capping the store at 8. Widen it to 16 bits (guard, delChannel remap arithmetic, ~128 B per rule slot) and double FILTER_MAX_CHANNELS to 16 (+712 B RAM, verified across nRF52/RP2040/ESP32 targets). Config format v3: older configs are discarded on upgrade.
This commit is contained in:
1 parent
e6cb14f9b2
commit
f123701d7e
4 files changed
+11
-11
No files matched your search
@@ -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.) |
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user