WIP: Additional work on transport node support

Added processing for LINKREQUEST and PROOF in Transport. This is
expected to enable transport and repeating of these packets, but support
for local Link and Resources is yet to be implemented.
This commit is contained in:
attermann committed 2023-12-15 09:27:18 -07:00
1 parent 162dcff6cd
commit 7aac0f4355
10 files changed
+238 -104

No files matched your search

+29 -8
View File
@@ -13,7 +13,7 @@
[env:native]
platform = native
build_flags =
build_flags =
-std=c++11
-Wall
-Wextra
@@ -22,7 +22,7 @@ build_flags =
-Wno-unused-parameter
-Isrc
-DNATIVE
lib_deps =
lib_deps =
ArduinoJson@^6.21.3
rweather/Crypto@^0.4.0
lib_compat_mode = off
@@ -43,24 +43,46 @@ lib_deps =
rweather/Crypto@^0.4.0
lib_compat_mode = off
[env:cubecell_gps]
[env:cubecell-gps]
platform = heltec-cubecell
board = cubecell_gps
framework = arduino
monitor_speed = 115200
;build_flags = -Wl,-Map,output.map
build_flags =
build_flags =
-std=c++11
-Wall
-Wextra
-Wno-missing-field-initializers
-Wno-format
-Isrc
lib_deps =
lib_deps =
ArduinoJson@^6.21.3
rweather/Crypto@^0.4.0
; CBA NOTE must undef min and max from Arduino.h
[env:heltec-tracker]
platform = espressif32
board = heltec_wireless_tracker
upload_protocol = esp-builtin
;board_build.partitions = no_ota.csv
;board_build.partitions = huge_app.csv
framework = arduino
monitor_speed = 115200
build_flags =
-Wall
-Wextra
-Wno-missing-field-initializers
-Wno-format
-I variants/heltec_wireless_tracker
-Isrc
lib_deps =
ArduinoJson@^6.21.3
rweather/Crypto@^0.4.0
sandeepmistry/LoRa@^0.8.0
jgromes/RadioLib@^5.7.0
lovyan03/LovyanGFX@^1.1.8
[env:ttgo-t-beam]
platform = espressif32
board = ttgo-t-beam
@@ -68,14 +90,13 @@ board_build.partitions = no_ota.csv
;board_build.partitions = huge_app.csv
framework = arduino
monitor_speed = 115200
build_flags =
build_flags =
-Wall
-Wextra
-Wno-missing-field-initializers
-Wno-format
-Isrc
lib_deps =
lib_deps =
ArduinoJson@^6.21.3
rweather/Crypto@^0.4.0
sandeepmistry/LoRa@^0.8.0
WiFi@^2.0.0
+4 -2
View File
@@ -19,7 +19,8 @@ Interface::Interface(const char* name) : _object(new Object(this, name)), _creat
}
/*virtual*/ inline void Interface::on_incoming(const Bytes& data) {
extreme("Interface::on_incoming: data: " + data.toHex());
//extreme("Interface.on_incoming: data: " + data.toHex());
extreme("Interface.on_incoming");
assert(_object);
_object->_rxb += data.size();
// CBA TODO implement concept of owner or a callback mechanism for incoming data
@@ -28,7 +29,8 @@ Interface::Interface(const char* name) : _object(new Object(this, name)), _creat
}
/*virtual*/ inline void Interface::on_outgoing(const Bytes& data) {
extreme("Interface::on_outgoing: data: " + data.toHex());
//extreme("Interface.on_outgoing: data: " + data.toHex());
extreme("Interface.on_outgoing");
assert(_object);
_object->_txb += data.size();
}
+2 -2
View File
@@ -104,12 +104,12 @@ Serial.println(available);
}
/*virtual*/ void LoRaInterface::on_incoming(const Bytes& data) {
debug("LoRaInterface.on_incoming: data: " + data.toHex());
debug(toString() + ".on_incoming: data: " + data.toHex());
Interface::on_incoming(data);
}
/*virtual*/ void LoRaInterface::on_outgoing(const Bytes& data) {
debug("LoRaInterface.on_outgoing: data: " + data.toHex());
debug(toString() + ".on_outgoing: data: " + data.toHex());
try {
if (online()) {
extreme("LoRaInterface: sending " + std::to_string(data.size()) + " bytes...");
+2 -2
View File
@@ -219,12 +219,12 @@ void UDPInterface::loop() {
}
/*virtual*/ void UDPInterface::on_incoming(const Bytes& data) {
debug("UDPInterface.on_incoming: data: " + data.toHex());
debug(toString() + ".on_incoming: data: " + data.toHex());
Interface::on_incoming(data);
}
/*virtual*/ void UDPInterface::on_outgoing(const Bytes& data) {
debug("UDPInterface.on_outgoing: data: " + data.toHex());
debug(toString() + ".on_outgoing: data: " + data.toHex());
try {
if (online()) {
// Send packet
+2 -2
View File
@@ -37,8 +37,8 @@ namespace RNS { namespace Interfaces {
void stop();
void loop();
//virtual inline std::string toString() const { return "UDPInterface[" + name() + "/" + bind_ip + ":" + bind_port + "]"; }
virtual inline std::string toString() const { return "UDPInterface[" + name() + "]"; }
virtual inline std::string toString() const { return "UDPInterface[" + name() + "/" + _local_host + ":" + std::to_string(_local_port) + "]"; }
//virtual inline std::string toString() const { return "UDPInterface[" + name() + "]"; }
private:
virtual void on_incoming(const Bytes& data);
+32
View File
@@ -498,6 +498,22 @@ const Bytes Packet::get_hashable_part() const {
#ifndef NDEBUG
std::string Packet::debugString() const {
if (!_object) {
return "";
}
if (_object->_packed) {
//unpack();
}
std::string str = "ht=" + std::to_string(_object->_header_type);
str += " tt=" + std::to_string(_object->_transport_type);
str += " dt=" + std::to_string(_object->_destination_type);
str += " pt=" + std::to_string(_object->_packet_type);
str += " hp=" + std::to_string(_object->_hops);
str += " ti=" + _object->_transport_id.toHex();
str += " dh=" + _object->_destination_hash.toHex();
return str;
}
std::string Packet::dumpString() const {
if (!_object) {
return "";
}
@@ -540,6 +556,22 @@ std::string Packet::debugString() const {
}
#endif
PacketReceipt::PacketReceipt(const Packet& packet) : _object(new Object()) {
_object->_hash = packet.get_hash();
_object->_truncated_hash = packet.getTruncatedHash();
_object->_destination = packet.destination();
if (packet.destination().type() == Type::Destination::LINK) {
// CBA BUG? Destination does not have rtt or traffic_timeout_factor memebers
//z _object->_timeout = packet.destination().rtt() * packet.destination().traffic_timeout_factor();
_object->_timeout = TIMEOUT_PER_HOP * Transport::hops_to(_object->_destination.hash());
}
else {
_object->_timeout = TIMEOUT_PER_HOP * Transport::hops_to(_object->_destination.hash());
}
}
void PacketReceipt::check_timeout() {
assert(_object);
if (_object->_status == SENT && is_timed_out()) {
+5 -1
View File
@@ -45,7 +45,7 @@ namespace RNS {
PacketReceipt(Type::NoneConstructor none) {}
PacketReceipt(const PacketReceipt& packet_receipt) : _object(packet_receipt._object) {}
PacketReceipt() : _object(new Object()) {}
PacketReceipt(const Packet& packet) {}
PacketReceipt(const Packet& packet);
inline PacketReceipt& operator = (const PacketReceipt& packet_receipt) {
_object = packet_receipt._object;
@@ -97,6 +97,7 @@ namespace RNS {
}
// getters/setters
inline const Bytes& hash() const { assert(_object); return _object->_hash; }
inline Type::PacketReceipt::Status status() const { assert(_object); return _object->_status; }
private:
@@ -105,6 +106,8 @@ namespace RNS {
Object() {}
virtual ~Object() {}
private:
Bytes _hash;
Bytes _truncated_hash;
bool _sent = true;
double _sent_at = Utilities::OS::time();
bool _proved = false;
@@ -227,6 +230,7 @@ namespace RNS {
#ifndef NDEBUG
std::string debugString() const;
std::string dumpString() const;
#endif
private:
+137 -78
View File
@@ -121,12 +121,13 @@ using namespace RNS::Utilities;
}
*/
// Create transport-specific destinations
// Create transport-specific destination for path request
Destination path_request_destination({Type::NONE}, Type::Destination::IN, Type::Destination::PLAIN, APP_NAME, "path.request");
path_request_destination.set_packet_callback(path_request_handler);
_control_destinations.insert(path_request_destination);
_control_hashes.insert(path_request_destination.hash());
// Create transport-specific destination for tunnel synthesize
Destination tunnel_synthesize_destination({Type::NONE}, Type::Destination::IN, Type::Destination::PLAIN, APP_NAME, "tunnel.synthesize");
tunnel_synthesize_destination.set_packet_callback(tunnel_synthesize_handler);
// CBA BUG?
@@ -667,7 +668,8 @@ using namespace RNS::Utilities;
// Periodically persist data
if (OS::time() > (_last_saved + _save_interval)) {
persist_data();
// CBA temporarily disabled for testing with empty destination table
//persist_data();
_last_saved = OS::time();
}
}
@@ -860,15 +862,17 @@ using namespace RNS::Utilities;
if (packet.destination().type() == Type::Destination::LINK) {
if (packet.destination().status() == Type::Link::CLOSED) {
extreme("Transport::outbound: Pscket destination is link-closed, not transmitting");
should_transmit = false;
}
// CBA Destination has no member attached_interface
// CBA Bug? Destination has no member attached_interface
//z if (interface != packet.destination().attached_interface()) {
//z should_transmit = false;
//z }
}
if (packet.attached_interface() && interface != packet.attached_interface()) {
extreme("Transport::outbound: Packet has wrong attached interface, not transmitting");
should_transmit = false;
}
@@ -1296,6 +1300,7 @@ using namespace RNS::Utilities;
warning("Transport::inbound: Packet unpack failed!");
return;
}
extreme("Transport::inbound: packet: " + packet.debugString());
extreme("Transport::inbound: destination=" + packet.destination_hash().toHex() + " hops=" + std::to_string(packet.hops()));
@@ -1348,11 +1353,14 @@ using namespace RNS::Utilities;
//p for_local_client_link |= (packet.packet_type != RNS.Packet.ANNOUNCE) and (packet.destination_hash in Transport.link_table and Transport.link_table[packet.destination_hash][2] in Transport.local_client_interfaces)
bool for_local_client = false;
bool for_local_client_link = false;
// If packet is anything besides ANNOUNCE then determine if it's destinated for a local destinaiton or link
if (packet.packet_type() != Type::Packet::ANNOUNCE) {
auto destination_iter = _destination_table.find(packet.destination_hash());
if (destination_iter != _destination_table.end()) {
DestinationEntry destination_entry = (*destination_iter).second;
if (destination_entry._hops == 0) {
// Destined for a local destination
for_local_client = true;
}
}
@@ -1360,19 +1368,24 @@ using namespace RNS::Utilities;
if (link_iter != _link_table.end()) {
LinkEntry link_entry = (*link_iter).second;
if (_local_client_interfaces.find(link_entry._receiving_interface) != _local_client_interfaces.end()) {
// Destined for a local link
for_local_client_link = true;
}
if (_local_client_interfaces.find(link_entry._outbound_interface) != _local_client_interfaces.end()) {
// Destined for a local link
for_local_client_link = true;
}
}
}
//p roof_for_local_client = (packet.destination_hash in Transport.reverse_table) and (Transport.reverse_table[packet.destination_hash][0] in Transport.local_client_interfaces)
// Determine if packet is proof for local destination???
//p proof_for_local_client = (packet.destination_hash in Transport.reverse_table) and (Transport.reverse_table[packet.destination_hash][0] in Transport.local_client_interfaces)
bool proof_for_local_client = false;
auto reverse_iter = _reverse_table.find(packet.destination_hash());
if (reverse_iter != _reverse_table.end()) {
ReverseEntry reverse_entry = (*reverse_iter).second;
if (_local_client_interfaces.find(reverse_entry._receiving_interface) != _local_client_interfaces.end()) {
// Proof for local destination???
proof_for_local_client = true;
}
}
@@ -1380,9 +1393,12 @@ using namespace RNS::Utilities;
// Plain broadcast packets from local clients are sent
// directly on all attached interfaces, since they are
// never injected into transport.
// If packet is not destined for a local transport-specific destination
if (_control_hashes.find(packet.destination_hash()) == _control_hashes.end()) {
// If packet is destination type PLAIN and transport type BROADCAST
if (packet.destination_type() == Type::Destination::PLAIN && packet.transport_type() == Type::Transport::BROADCAST) {
// Send to all interfaces except the originator
// Send to all interfaces except the one the packet was recieved on
if (from_local_client) {
#if defined(INTERFACES_SET)
for (const Interface& interface : _interfaces) {
@@ -1444,8 +1460,10 @@ using namespace RNS::Utilities;
// accordingly if we are.
if (packet.transport_id() && packet.packet_type() != Type::Packet::ANNOUNCE) {
if (packet.transport_id() == _identity.hash()) {
extreme("Transport::inbound: We are designated next-hop");
auto destination_iter = _destination_table.find(packet.destination_hash());
if (destination_iter != _destination_table.end()) {
extreme("Transport::inbound: Found next-hop path to destination");
DestinationEntry destination_entry = (*destination_iter).second;
Bytes next_hop = destination_entry._received_from;
uint8_t remaining_hops = destination_entry._hops;
@@ -1486,8 +1504,9 @@ using namespace RNS::Utilities;
Interface& outbound_interface = destination_entry._receiving_interface;
if (packet.packet_type() == Type::Packet::LINKREQUEST) {
extreme("Transport::inbound: Packet is next-hop LINKREQUEST");
double now = OS::time();
double proof_timeout = now + Type::Link::ESTABLISHMENT_TIMEOUT_PER_HOP*1000 * std::max((uint8_t)1, remaining_hops);
double proof_timeout = now + Type::Link::ESTABLISHMENT_TIMEOUT_PER_HOP * std::max((uint8_t)1, remaining_hops);
LinkEntry link_entry(
now,
next_hop,
@@ -1502,6 +1521,7 @@ using namespace RNS::Utilities;
_link_table.insert({packet.getTruncatedHash(), link_entry});
}
else {
extreme("Transport::inbound: Packet is next-hop other type");
ReverseEntry reverse_entry(
packet.receiving_interface(),
outbound_interface,
@@ -1528,9 +1548,10 @@ using namespace RNS::Utilities;
// Link transport handling. Directs packets according
// to entries in the link tables
if (packet.packet_type() != Type::Packet::ANNOUNCE && packet.packet_type() != Type::Packet::LINKREQUEST && packet.context() == Type::Packet::LRPROOF) {
if (packet.packet_type() != Type::Packet::ANNOUNCE && packet.packet_type() != Type::Packet::LINKREQUEST && packet.context() != Type::Packet::LRPROOF) {
auto link_iter = _link_table.find(packet.destination_hash());
if (link_iter != _link_table.end()) {
extreme("Transport::inbound: Handling link transport");
LinkEntry link_entry = (*link_iter).second;
// If receiving and outbound interface is
// the same for this link, direction doesn't
@@ -2021,6 +2042,7 @@ using namespace RNS::Utilities;
else if (packet.packet_type() == Type::Packet::LINKREQUEST) {
extreme("Transport::inbound: Packet is LINKREQUEST");
if (!packet.transport_id() || packet.transport_id() == _identity.hash()) {
extreme("Transport::inbound: Checking if LINKREQUEST is for local destination");
#if defined(DESTINATIONS_SET)
for (auto& destination : _destinations) {
if (destination.hash() == packet.destination_hash() && destination.type() == packet.destination_type()) {
@@ -2043,26 +2065,30 @@ using namespace RNS::Utilities;
}
}
// Handling for local data packets
// Handling for data packets to local destinations
else if (packet.packet_type() == Type::Packet::DATA) {
extreme("Transport::inbound: Packet is DATA");
if (packet.destination_type() == Type::Destination::LINK) {
extreme("Transport::inbound: Packet is for LINK");
// Data is destined for a link
extreme("Transport::inbound: Packet is DATA for a LINK");
for (auto& link : _active_links) {
if (link.link_id() == packet.destination_hash()) {
extreme("Transport::inbound: Packet is DATA for an active LINK");
packet.link(link);
const_cast<Link&>(link).receive(packet);
}
}
}
else {
// Data is basic (not destined for a link)
#if defined(DESTINATIONS_SET)
for (auto& destination : _destinations) {
if (destination.hash() == packet.destination_hash() && destination.type() == packet.destination_type()) {
#elif defined(DESTINATIONS_MAP)
auto iter = _destinations.find(packet.destination_hash());
if (iter != _destinations.end()) {
debug("Transport::inbound: Packet destination " + packet.destination_hash().toHex() + " found");
// Data is for a local destination
debug("Transport::inbound: Packet destination " + packet.destination_hash().toHex() + " found, destination is local");
auto& destination = (*iter).second;
if (destination.type() == packet.destination_type()) {
debug("Transport::inbound: Packet destination type " + std::to_string(packet.destination_type()) + " matched, processing");
@@ -2103,91 +2129,124 @@ using namespace RNS::Utilities;
// Handling for proofs and link-request proofs
else if (packet.packet_type() == Type::Packet::PROOF) {
extreme("Transport::inbound: Packet is PROOF");
// TODO
/*
if packet.context == RNS.Packet.LRPROOF:
if (packet.context() == Type::Packet::LRPROOF) {
extreme("Transport::inbound: Packet is LINK PROOF");
// This is a link request proof, check if it
// needs to be transported
if (RNS.Reticulum.transport_enabled() or for_local_client_link or from_local_client) and packet.destination_hash in Transport.link_table:
link_entry = Transport.link_table[packet.destination_hash]
if packet.receiving_interface == link_entry[2]:
try:
if len(packet.data) == RNS.Identity.SIGLENGTH//8+RNS.Link.ECPUBSIZE//2:
peer_pub_bytes = packet.data[RNS.Identity.SIGLENGTH//8:RNS.Identity.SIGLENGTH//8+RNS.Link.ECPUBSIZE//2]
peer_identity = RNS.Identity.recall(link_entry[6])
peer_sig_pub_bytes = peer_identity.get_public_key()[RNS.Link.ECPUBSIZE//2:RNS.Link.ECPUBSIZE]
if ((Reticulum::transport_enabled() || for_local_client_link || from_local_client) && _link_table.find(packet.destination_hash()) != _link_table.end()) {
LinkEntry link_entry = (*_link_table.find(packet.destination_hash())).second;
if (packet.receiving_interface() == link_entry._outbound_interface) {
try {
if (packet.data().size() == (Type::Identity::SIGLENGTH/8 + Type::Link::ECPUBSIZE/2)) {
Bytes peer_pub_bytes = packet.data().mid(Type::Identity::SIGLENGTH/8, Type::Link::ECPUBSIZE/2);
Identity peer_identity = Identity::recall(link_entry._destination_hash);
Bytes peer_sig_pub_bytes = peer_identity.get_public_key().mid(Type::Link::ECPUBSIZE/2, Type::Link::ECPUBSIZE/2);
signed_data = packet.destination_hash+peer_pub_bytes+peer_sig_pub_bytes
signature = packet.data[:RNS.Identity.SIGLENGTH//8]
Bytes signed_data = packet.destination_hash() + peer_pub_bytes + peer_sig_pub_bytes;
Bytes signature = packet.data().left(Type::Identity::SIGLENGTH/8);
if peer_identity.validate(signature, signed_data):
RNS.log("Link request proof validated for transport via "+str(link_entry[4]), RNS.LOG_EXTREME)
new_raw = packet.raw[0:1]
new_raw += struct.pack("!B", packet.hops)
new_raw += packet.raw[2:]
Transport.link_table[packet.destination_hash][7] = True
Transport.transmit(link_entry[4], new_raw)
else:
RNS.log("Invalid link request proof in transport for link "+RNS.prettyhexrep(packet.destination_hash)+", dropping proof.", RNS.LOG_DEBUG)
except Exception as e:
RNS.log("Error while transporting link request proof. The contained exception was: "+str(e), RNS.LOG_ERROR)
else:
RNS.log("Link request proof received on wrong interface, not transporting it.", RNS.LOG_DEBUG)
else:
if (peer_identity.validate(signature, signed_data)) {
extreme("Link request proof validated for transport via " + link_entry._receiving_interface.toString());
//p new_raw = packet.raw[0:1]
Bytes new_raw = packet.raw().left(1);
//p new_raw += struct.pack("!B", packet.hops)
new_raw << packet.hops();
//p new_raw += packet.raw[2:]
new_raw << packet.raw().mid(2);
link_entry._validated = true;
transmit(link_entry._receiving_interface, new_raw);
}
else {
debug("Invalid link request proof in transport for link " + packet.destination_hash().toHex() + ", dropping proof.");
}
}
}
catch (std::exception& e) {
error("Error while transporting link request proof. The contained exception was: " + std::string(e.what()));
}
}
else {
debug("Link request proof received on wrong interface, not transporting it.");
}
}
else {
// Check if we can deliver it to a local
// pending link
for link in Transport.pending_links:
if link.link_id == packet.destination_hash:
link.validate_proof(packet)
for (auto& link : _pending_links) {
if (link.link_id() == packet.destination_hash()) {
// TODO
//z link.validate_proof(packet);
}
}
}
}
else if (packet.context() == Type::Packet::RESOURCE_PRF) {
extreme("Transport::inbound: Packet is RESOURCE PROOF");
for (auto& link : _active_links) {
if (link.link_id() == packet.destination_hash()) {
// TODO
//z link.receive(packet);
}
}
}
else {
extreme("Transport::inbound: Packet is regular PROOF");
if (packet.destination_type() == Type::Destination::LINK) {
for (auto& link : _active_links) {
if (link.link_id() == packet.destination_hash()) {
packet.link(link);
}
}
}
elif packet.context == RNS.Packet.RESOURCE_PRF:
for link in Transport.active_links:
if link.link_id == packet.destination_hash:
link.receive(packet)
else:
if packet.destination_type == RNS.Destination.LINK:
for link in Transport.active_links:
if link.link_id == packet.destination_hash:
packet.link = link
if len(packet.data) == RNS.PacketReceipt.EXPL_LENGTH:
proof_hash = packet.data[:RNS.Identity.HASHLENGTH//8]
else:
proof_hash = None
Bytes proof_hash;
if (packet.data().size() == Type::PacketReceipt::EXPL_LENGTH) {
proof_hash = packet.data().left(Type::Identity::HASHLENGTH/8);
}
// Check if this proof neds to be transported
if (RNS.Reticulum.transport_enabled() or from_local_client or proof_for_local_client) and packet.destination_hash in Transport.reverse_table:
reverse_entry = Transport.reverse_table.pop(packet.destination_hash)
if packet.receiving_interface == reverse_entry[1]:
RNS.log("Proof received on correct interface, transporting it via "+str(reverse_entry[0]), RNS.LOG_EXTREME)
new_raw = packet.raw[0:1]
new_raw += struct.pack("!B", packet.hops)
new_raw += packet.raw[2:]
Transport.transmit(reverse_entry[0], new_raw)
else:
RNS.log("Proof received on wrong interface, not transporting it.", RNS.LOG_DEBUG)
if ((Reticulum::transport_enabled() || from_local_client || proof_for_local_client) && _reverse_table.find(packet.destination_hash()) != _reverse_table.end()) {
ReverseEntry reverse_entry = (*_reverse_table.find(packet.destination_hash())).second;
if (packet.receiving_interface() == reverse_entry._outbound_interface) {
extreme("Proof received on correct interface, transporting it via " + reverse_entry._receiving_interface.toString());
//p new_raw = packet.raw[0:1]
Bytes new_raw = packet.raw().left(1);
//p new_raw += struct.pack("!B", packet.hops)
new_raw << packet.hops();
//p new_raw += packet.raw[2:]
new_raw << packet.raw().mid(2);
transmit(reverse_entry._receiving_interface, new_raw);
}
else {
debug("Proof received on wrong interface, not transporting it.");
}
}
for receipt in Transport.receipts:
receipt_validated = False
if proof_hash != None:
for (auto& receipt : _receipts) {
bool receipt_validated = false;
if (proof_hash) {
// Only test validation if hash matches
if receipt.hash == proof_hash:
receipt_validated = receipt.validate_proof_packet(packet)
else:
if (receipt.hash() == proof_hash) {
// TODO
//z receipt_validated = receipt.validate_proof_packet(packet);
}
}
else {
// TODO: This looks like it should actually
// be rewritten when implicit proofs are added.
// In case of an implicit proof, we have
// to check every single outstanding receipt
receipt_validated = receipt.validate_proof_packet(packet)
// TODO
//z receipt_validated = receipt.validate_proof_packet(packet);
}
if receipt_validated:
if receipt in Transport.receipts:
Transport.receipts.remove(receipt)
*/
// CBA TODO requires modifying of collection while ioterating which is forbidden
//z if (receipt_validated) {
//z if receipt in Transport.receipts:
//z Transport.receipts.remove(receipt)
}
}
}
}
+2 -2
View File
@@ -158,7 +158,7 @@ namespace RNS {
uint8_t _remaining_hops = 0;
// CBA TODO does this need to be a reference in order for virtual method callbacks to work?
//const Interface& _receiving_interface;
const Interface _receiving_interface = {Type::NONE};
Interface _receiving_interface = {Type::NONE};
uint8_t _hops = 0;
const Bytes _destination_hash;
bool _validated = false;
@@ -177,7 +177,7 @@ namespace RNS {
public:
// CBA TODO does this need to be a reference in order for virtual method callbacks to work?
//const Interface& _receiving_interface;
const Interface _receiving_interface = {Type::NONE};
Interface _receiving_interface = {Type::NONE};
// CBA TODO does this need to be a reference in order for virtual method callbacks to work?
//const Interface& _outbound_interface;
const Interface _outbound_interface = {Type::NONE};
+23 -7
View File
@@ -1,4 +1,4 @@
#define NDEBUG
//#define NDEBUG
#include "Test/Test.h"
@@ -34,11 +34,12 @@
#ifndef NDEBUG
#define RUN_TESTS
//#define RUN_TESTS
#endif
#define RUN_RETICULUM
//#define UDP_INTERFACE
#define UDP_INTERFACE
//#define UDP2_INTERFACE
#define LORA_INTERFACE
//#define RETICULUM_PACKET_TEST
@@ -101,7 +102,10 @@ RNS::Identity identity({RNS::Type::NONE});
RNS::Destination destination({RNS::Type::NONE});
#ifdef UDP_INTERFACE
RNS::Interfaces::UDPInterface udp_interface;
RNS::Interfaces::UDPInterface udp_interface("udp");
#endif
#ifdef UDP2_INTERFACE
RNS::Interfaces::UDPInterface udp2_interface("udp2");
#endif
#ifdef LORA_INTERFACE
RNS::Interfaces::LoRaInterface lora_interface;
@@ -166,6 +170,10 @@ void reticulum_setup() {
udp_interface.mode(RNS::Type::Interface::MODE_GATEWAY);
RNS::Transport::register_interface(udp_interface);
#endif
#ifdef UDP2_INTERFACE
udp2_interface.mode(RNS::Type::Interface::MODE_GATEWAY);
RNS::Transport::register_interface(udp2_interface);
#endif
#ifdef LORA_INTERFACE
lora_interface.mode(RNS::Type::Interface::MODE_GATEWAY);
RNS::Transport::register_interface(lora_interface);
@@ -173,10 +181,12 @@ void reticulum_setup() {
#ifdef UDP_INTERFACE
RNS::head("Starting UDPInterface...", RNS::LOG_EXTREME);
//udp_interface.start("wifi_ssid", "wifi_password", 4242);
udp_interface.start("broadmind-guest", "brcguest", 4242);
udp_interface.start("wifi_ssid", "wifi_password", 4242);
#endif
#ifdef UDP2_INTERFACE
RNS::head("Starting UDPInterface...", RNS::LOG_EXTREME);
udp_interface.start("wifi_ssid", "wifi_password", 2424);
#endif
#ifdef LORA_INTERFACE
RNS::head("Starting LoRaInterface...", RNS::LOG_EXTREME);
lora_interface.start();
@@ -282,6 +292,9 @@ void reticulum_teardown() {
#ifdef UDP_INTERFACE
RNS::Transport::deregister_interface(udp_interface);
#endif
#ifdef UDP2_INTERFACE
RNS::Transport::deregister_interface(udp2_interface);
#endif
#ifdef LORA_INTERFACE
RNS::Transport::deregister_interface(lora_interface);
#endif
@@ -354,6 +367,9 @@ void loop() {
#ifdef UDP_INTERFACE
udp_interface.loop();
#endif
#ifdef UDP2_INTERFACE
udp2_interface.loop();
#endif
#ifdef LORA_INTERFACE
lora_interface.loop();
#endif