Fit padded ACL replies through the Companion frame envelope
This commit is contained in:
1 parent
1d96725e73
commit
3a016dd13b
10 files changed
+196
-64
No files matched your search
@@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define MAX_FRAME_SIZE 176 // +4 for transport codes (region scoping)
|
||||
#include "CompanionFrameLimits.h"
|
||||
|
||||
class BaseSerialInterface {
|
||||
protected:
|
||||
|
||||
@@ -2,15 +2,21 @@
|
||||
|
||||
#include <Packet.h>
|
||||
#include "DatagramPayloadLimits.h"
|
||||
#include "CompanionFrameLimits.h"
|
||||
|
||||
namespace mesh {
|
||||
|
||||
// Match createDatagram() and createPathReturn() admission limits. A flood
|
||||
// request returns its observed path inside the encrypted response, so those
|
||||
// bytes must also be reserved before adding legacy seven-byte ACL entries.
|
||||
static constexpr size_t CLIENT_ACL_DIRECT_REPLY_CAPACITY =
|
||||
static constexpr size_t CLIENT_ACL_DATAGRAM_REPLY_CAPACITY =
|
||||
DatagramPayloadLimits::maxPlaintext(
|
||||
MAX_PACKET_PAYLOAD, CIPHER_MAC_SIZE, CIPHER_BLOCK_SIZE);
|
||||
static constexpr size_t CLIENT_ACL_HOST_REPLY_CAPACITY =
|
||||
companionBinaryPlaintextCapacity(CIPHER_BLOCK_SIZE);
|
||||
static constexpr size_t CLIENT_ACL_DIRECT_REPLY_CAPACITY =
|
||||
CLIENT_ACL_DATAGRAM_REPLY_CAPACITY < CLIENT_ACL_HOST_REPLY_CAPACITY
|
||||
? CLIENT_ACL_DATAGRAM_REPLY_CAPACITY : CLIENT_ACL_HOST_REPLY_CAPACITY;
|
||||
|
||||
inline size_t clientACLReplyCapacity(bool flood, uint8_t path_len) {
|
||||
if (!Packet::isValidPathLen(path_len)) return 0;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define MAX_FRAME_SIZE 176 // +4 for transport codes (region scoping)
|
||||
|
||||
namespace mesh {
|
||||
|
||||
// Binary responses add an opcode and reserved byte to decrypted radio data.
|
||||
// A direct datagram exposes its zero padding, so reserve whole cipher blocks
|
||||
// that fit the host frame rather than counting only unpadded ACL entries.
|
||||
constexpr size_t companionBinaryPlaintextCapacity(size_t cipher_block_size) {
|
||||
return cipher_block_size > 0
|
||||
? ((MAX_FRAME_SIZE - 2) / cipher_block_size) * cipher_block_size : 0;
|
||||
}
|
||||
|
||||
} // namespace mesh
|
||||
Reference in new issue
Block a user