mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-04 07:36:03 +00:00
* CommonCLI: added "get/set path.hash.mode "
This commit is contained in:
@@ -10,14 +10,27 @@ Packet::Packet() {
|
||||
payload_len = 0;
|
||||
}
|
||||
|
||||
uint8_t Packet::copyPath(uint8_t* dest, const uint8_t* src, uint8_t path_len) {
|
||||
bool Packet::isValidPathLen(uint8_t path_len) {
|
||||
uint8_t hash_count = path_len & 63;
|
||||
uint8_t hash_size = (path_len >> 6) + 1;
|
||||
if (hash_count*hash_size > MAX_PATH_SIZE) {
|
||||
if (hash_size == 4) return false; // Reserved for future
|
||||
return hash_count*hash_size <= MAX_PATH_SIZE;
|
||||
}
|
||||
|
||||
size_t Packet::writePath(uint8_t* dest, const uint8_t* src, uint8_t path_len) {
|
||||
uint8_t hash_count = path_len & 63;
|
||||
uint8_t hash_size = (path_len >> 6) + 1;
|
||||
size_t len = hash_count*hash_size;
|
||||
if (len > MAX_PATH_SIZE) {
|
||||
MESH_DEBUG_PRINTLN("Packet::copyPath, invalid path_len=%d", (uint32_t)path_len);
|
||||
return 0; // Error
|
||||
}
|
||||
memcpy(dest, src, hash_count*hash_size);
|
||||
memcpy(dest, src, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
uint8_t Packet::copyPath(uint8_t* dest, const uint8_t* src, uint8_t path_len) {
|
||||
if (writePath(dest, src, path_len) == 0) return 0;
|
||||
return path_len;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user