mirror of
https://github.com/ratspeak/microReticulum
synced 2026-11-22 23:10:38 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a968fdfc64 | ||
|
|
9da37b29ac | ||
|
|
89dce2c73b | ||
|
|
e3a128ed2d |
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "microReticulum",
|
||||
"version": "0.2.7",
|
||||
"version": "0.2.8",
|
||||
"description": "Port of Reticulum Network Stack to C++ specifically but not exclusively targeting 32-bit and better MCUs",
|
||||
"keywords": "reticulum, rns, mesh, embedded, mcu, esp32, nrf52, native",
|
||||
"repository":
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name=microReticulum
|
||||
version=0.2.7
|
||||
version=0.2.8
|
||||
author=Chad Attermann <attermann@gmail.com>
|
||||
maintainer=Chad Attermann <attermann@gmail.com>
|
||||
sentence=Port of Reticulum Network Stack to C++
|
||||
|
||||
+7
-6
@@ -262,7 +262,7 @@ MEM("Creating from data-move...");
|
||||
//inline void assign(const std::string& string) { assign(string.c_str()); }
|
||||
inline void assign(const std::string& string) { assign((uint8_t*)string.c_str(), string.length()); }
|
||||
void assignHex(const uint8_t* hex, size_t hex_size);
|
||||
inline void assignHex(const char* hex) { assignHex((uint8_t*)hex, strlen(hex)); }
|
||||
inline void assignHex(const char* hex) { if (!hex) return; assignHex((uint8_t*)hex, strlen(hex)); }
|
||||
|
||||
inline void append(const Bytes& bytes) {
|
||||
// if append is empty then do nothing
|
||||
@@ -307,7 +307,7 @@ MEM("Creating from data-move...");
|
||||
//inline void append(const std::string& string) { append(string.c_str()); }
|
||||
inline void append(const std::string& string) { append((uint8_t*)string.c_str(), string.length()); }
|
||||
void appendHex(const uint8_t* hex, size_t hex_size);
|
||||
inline void appendHex(const char* hex) { appendHex((uint8_t*)hex, strlen(hex)); }
|
||||
inline void appendHex(const char* hex) { if (!hex) return; appendHex((uint8_t*)hex, strlen(hex)); }
|
||||
|
||||
inline uint8_t* writable(size_t size) {
|
||||
if (size > 0) {
|
||||
@@ -343,7 +343,7 @@ MEM("Creating from data-move...");
|
||||
public:
|
||||
int compare(const Bytes& bytes) const;
|
||||
int compare(const uint8_t* buf, size_t size) const;
|
||||
inline int compare(const char* str) const { return compare((const uint8_t*)str, strlen(str)); }
|
||||
inline int compare(const char* str) const { if (!str) return empty() ? 0 : 1; return compare((const uint8_t*)str, strlen(str)); }
|
||||
inline size_t size() const { if (!_data) return 0; return _data->size(); }
|
||||
inline bool empty() const { if (!_data) return true; return _data->empty(); }
|
||||
inline size_t capacity() const { if (!_data) return 0; return _data->capacity(); }
|
||||
@@ -358,7 +358,7 @@ MEM("Creating from data-move...");
|
||||
inline Bytes left(size_t len) const { if (!_data) return NONE; if (len > size()) len = size(); return {data(), len}; }
|
||||
inline Bytes right(size_t len) const { if (!_data) return NONE; if (len > size()) len = size(); return {data() + (size() - len), len}; }
|
||||
inline int find(int pos, const char* str) {
|
||||
if (!_data || _data->data() == nullptr || (size_t)pos >= _data->size()) {
|
||||
if (!str || !_data || _data->data() == nullptr || (size_t)pos >= _data->size()) {
|
||||
return -1;
|
||||
}
|
||||
//const char* ptr = strnstr((const char*)(_data->data() + pos), str, (_data->size() - pos));
|
||||
@@ -403,7 +403,7 @@ MEM("Creating from data-move...");
|
||||
//inline Bytes bytesFromChunk(const uint8_t* ptr, size_t len) { return Bytes(ptr, len); }
|
||||
inline Bytes bytesFromChunk(const uint8_t* ptr, size_t len) { return {ptr, len}; }
|
||||
//inline Bytes bytesFromString(const char* str) { return Bytes((uint8_t*)str, strlen(str)); }
|
||||
inline Bytes bytesFromString(const char* str) { return {(uint8_t*)str, strlen(str)}; }
|
||||
inline Bytes bytesFromString(const char* str) { if (!str) return {}; return {(uint8_t*)str, strlen(str)}; }
|
||||
//z inline Bytes bytesFromInt(const int) { return {(uint8_t*)str, strlen(str)}; }
|
||||
|
||||
inline std::string stringFromBytes(const Bytes& bytes) { return bytes.toString(); }
|
||||
@@ -440,7 +440,8 @@ namespace ArduinoJson {
|
||||
}
|
||||
// Deserialize
|
||||
inline void convertFromJson(JsonVariantConst src, RNS::Bytes& dst) {
|
||||
dst.assignHex(src.as<const char*>());
|
||||
const char* hex = src.as<const char*>();
|
||||
if (hex) dst.assignHex(hex);
|
||||
}
|
||||
inline bool canConvertFromJson(JsonVariantConst src, const RNS::Bytes&) {
|
||||
return src.is<const char*>();
|
||||
|
||||
@@ -1134,6 +1134,7 @@ void Link::receive(const Packet& packet) {
|
||||
if (!_object->_initiator) {
|
||||
rtt_packet(packet);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Type::Packet::LINKCLOSE:
|
||||
{
|
||||
|
||||
+36
-2
@@ -1547,7 +1547,41 @@ using namespace RNS::Utilities;
|
||||
if (packet.packet_type() == Type::Packet::LINKREQUEST) {
|
||||
TRACE("Transport::inbound: Packet is next-hop LINKREQUEST");
|
||||
double now = OS::time();
|
||||
double proof_timeout = now + Type::Link::ESTABLISHMENT_TIMEOUT_PER_HOP * std::max((uint8_t)1, remaining_hops);
|
||||
double proof_timeout = extra_link_proof_timeout(packet.receiving_interface());
|
||||
proof_timeout += now + Type::Link::ESTABLISHMENT_TIMEOUT_PER_HOP * std::max((uint8_t)1, remaining_hops);
|
||||
uint16_t path_mtu = Link::mtu_from_lr_packet(packet);
|
||||
Type::Link::link_mode mode = Link::mode_from_lr_packet(packet);
|
||||
uint16_t ph_mtu = 0;
|
||||
if (interface) {
|
||||
ph_mtu = interface.HW_MTU();
|
||||
}
|
||||
uint16_t nh_mtu = outbound_interface.HW_MTU();
|
||||
if (path_mtu != 0) {
|
||||
if (outbound_interface.HW_MTU() == 0) {
|
||||
DEBUG("No next-hop HW MTU, disabling link MTU upgrade");
|
||||
path_mtu = 0;
|
||||
new_raw = new_raw.left(new_raw.size()-Type::Link::LINK_MTU_SIZE);
|
||||
}
|
||||
else if (outbound_interface.AUTOCONFIGURE_MTU() == 0 && outbound_interface.FIXED_MTU() == 0) {
|
||||
DEBUG("Outbound interface doesn't support MTU autoconfiguration, disabling link MTU upgrade");
|
||||
path_mtu = 0;
|
||||
new_raw = new_raw.left(new_raw.size()-Type::Link::LINK_MTU_SIZE);
|
||||
}
|
||||
else {
|
||||
if (nh_mtu < path_mtu || (ph_mtu != 0 && ph_mtu < path_mtu)) {
|
||||
try {
|
||||
path_mtu = std::min(nh_mtu, ph_mtu);
|
||||
Bytes clamped_mtu = Link::signalling_bytes(path_mtu, mode);
|
||||
DEBUGF("Clamping link MTU to %u", path_mtu);
|
||||
new_raw = new_raw.left(new_raw.size()-Type::Link::LINK_MTU_SIZE)+clamped_mtu;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
WARNINGF("Dropping link request packet. The contained exception was: %s", e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LinkEntry link_entry(
|
||||
now,
|
||||
next_hop,
|
||||
@@ -1560,7 +1594,7 @@ using namespace RNS::Utilities;
|
||||
proof_timeout
|
||||
);
|
||||
// CBA ACCUMULATES
|
||||
_link_table.insert({packet.getTruncatedHash(), link_entry});
|
||||
_link_table.insert({Link::link_id_from_lr_packet(packet), link_entry});
|
||||
}
|
||||
else {
|
||||
TRACE("Transport::inbound: Packet is next-hop other type");
|
||||
|
||||
Reference in new issue
Block a user