Merge remote-tracking branch 'origin/keymindCascade' into keymindCascade

This commit is contained in:
mikecarper committed 2026-10-15 23:50:05 -07:00
commit 55373f692e
11 files changed
+692 -62

No files matched your search

+3 -2
View File
@@ -291,7 +291,8 @@ size_t encodeText(uint32_t from, uint32_t id, uint8_t hop_limit, const char* cha
size_t encodeNodeInfo(uint32_t from, uint32_t id, uint8_t hop_limit, const char* channel_name,
const uint8_t* key, size_t key_len, const char* long_name, size_t long_name_len,
const char* short_name, size_t short_name_len, uint8_t out[MaxFrameSize]) {
const char* short_name, size_t short_name_len, uint8_t out[MaxFrameSize],
bool rebroadcast) {
size_t short_characters = 0;
if (out == nullptr || key == nullptr || (key_len != 16 && key_len != 32)
|| !validName(channel_name) || from <= 3 || from == Broadcast || id == 0 || hop_limit > 7
@@ -319,7 +320,7 @@ size_t encodeNodeInfo(uint32_t from, uint32_t id, uint8_t hop_limit, const char*
}
data[count++] = 0x1a; data[count++] = static_cast<uint8_t>(short_name_len);
memcpy(data + count, short_name, short_name_len); count += short_name_len;
data[count++] = 0x38; data[count++] = 1; // Config.DeviceConfig.Role.CLIENT_MUTE.
data[count++] = 0x38; data[count++] = rebroadcast ? 0 : 1; // CLIENT / CLIENT_MUTE.
data[count++] = 0x48; data[count++] = 1; // User.is_unmessagable explicitly true.
data[3] = static_cast<uint8_t>(count - 4);
data[count++] = 0x48; data[count++] = 1; // Data.bitfield: MQTT upload consent.
+7 -3
View File
@@ -54,7 +54,9 @@ size_t encodeText(uint32_t from, uint32_t id, uint8_t hop_limit, const char* cha
const uint8_t* key, size_t key_len, const char* text, size_t text_len,
uint8_t out[MaxFrameSize]);
// Explicit broadcast NODEINFO_APP containing only User id, long/short names,
// CLIENT_MUTE (no forwarding), and is_unmessagable=true (no direct messages).
// CLIENT_MUTE by default (no forwarding), and is_unmessagable=true (no DMs).
// Explicitly enabled rebroadcast advertises CLIENT instead, without adding
// any fields or changing encryption, names, hop policy or MQTT consent.
// Names use explicit UTF-8 byte lengths, without their terminating NUL. Long
// names may be empty; short names require 1..4 UTF-8 bytes (stock wire bound).
// This can hold four ASCII characters but fewer multi-byte characters. Longer
@@ -63,9 +65,11 @@ size_t encodeText(uint32_t from, uint32_t id, uint8_t hop_limit, const char* cha
// explicit and first-successful-chat announcements and bounded retries.
size_t encodeNodeInfo(uint32_t from, uint32_t id, uint8_t hop_limit, const char* channel_name,
const uint8_t* key, size_t key_len, const char* long_name, size_t long_name_len,
const char* short_name, size_t short_name_len, uint8_t out[MaxFrameSize]);
const char* short_name, size_t short_name_len, uint8_t out[MaxFrameSize],
bool rebroadcast = false);
// Only broadcast TEXT_MESSAGE_APP is delivered. No DMs, ACKs, administrative
// handling, relaying or automatic transmissions. AES-CTR is not authenticated;
// handling or automatic transmissions occur in this decoder; a caller can
// separately opt into bounded relay handling. AES-CTR is not authenticated;
// a successful parse is not a proof of sender identity or PSK authenticity.
// On failure, decoded is left unchanged. Caller records dedup only on success.
bool decodeText(const uint8_t* raw, size_t length, const char* channel_name,
+15 -3
View File
@@ -5,11 +5,12 @@
namespace mesh { namespace mt {
// Three retained chats and one metadata slot. No heap, packet-pool entries,
// keys, positions or forwarding state are allocated by the delivery policy.
// Three retained chats and one metadata slot. Optional relays reuse a retained
// frame; no heap, packet-pool entry, key or additional payload buffer is needed.
struct PendingFrame {
uint8_t bytes[MaxFrameSize] = {};
uint8_t fingerprint[8] = {};
bool relayed = false; // Occupies the existing padding before generation.
uint32_t generation = 0, due = 0;
uint16_t length = 0;
uint8_t channel = 0, retries = 0;
@@ -20,12 +21,23 @@ struct PendingFrame {
// The sender/id/channel/ciphertext are immutable. Only remaining hops
// and next-hop/relay bytes may change. A copy at the original hop limit
// is not evidence that another node forwarded the transmission.
return length && sent && raw && size == length && size > HeaderSize
return !relayed && length && sent && raw && size == length && size > HeaderSize
&& memcmp(raw, bytes, 12) == 0 && raw[13] == bytes[13]
&& (raw[12] & 0xf8) == (bytes[12] & 0xf8)
&& (raw[12] & 7) < (bytes[12] & 7)
&& memcmp(raw + HeaderSize, bytes + HeaderSize, size - HeaderSize) == 0;
}
bool matchesRelayCopy(const uint8_t* raw, size_t size) const {
// A planned relay already decremented remaining hops. Another relay at
// that same or a lower remaining hop count makes ours redundant, even
// before we transmit. Original-sender retries retain more hops and must
// not cancel it. Preserve/check all immutable flags and ciphertext.
return relayed && raw && length > HeaderSize && length <= sizeof(bytes)
&& size == length && memcmp(raw, bytes, 12) == 0 && raw[13] == bytes[13]
&& (raw[12] & 0xf8) == (bytes[12] & 0xf8)
&& (raw[12] & 7) <= (bytes[12] & 7)
&& memcmp(raw + HeaderSize, bytes + HeaderSize, size - HeaderSize) == 0;
}
};
static constexpr unsigned DeliverySlots = 4;