add sequence numbers to routing messages

pull/6/head^2
Jeff Becker 6 years ago
parent 19e3b9c642
commit dbe4a35230

@ -428,7 +428,8 @@ routing layer:
the routing layer provides inter network communication between the LLARP link
layer and ip (internet protocol) for exit traffic or ap (anonymous protocol) for
hidden services. replies to messages are sent back via the path they
originated from inside a LRDM.
originated from inside a LRDM. all routing messages have an S value which
provides the sequence number of the message so the messages can be ordered.
ipv4 addresses are allowed via ipv4 mapped ipv6 addresses, i.e. ::ffff.10.0.0.1
@ -436,10 +437,13 @@ path confirm message (PCM)
sent as the first message down a path after it's built to confirm it was built
always the first message sent
{
A: "P",
L: uint64_milliseconds_path_lifetime,
S: uint64_milliseconds_sent_timestamp,
S: 0,
T: uint64_milliseconds_sent_timestamp,
V: 0
}
@ -451,7 +455,7 @@ variant 1, request, generated by the path creator:
{
A: "L",
T: uint64_ping_transaction_id,
S: uint64_sequence_number,
V: 0
}
@ -459,7 +463,8 @@ variant 2, response, generated by the endpoint that recieved the request.
{
A: "L",
L: uint64_ping_transaction_id,
S: uint64_sequence_number,
T: uint64_timestamp_sent,
V: 0
}
@ -471,6 +476,7 @@ replies are sent down the path that messages originate from.
{
A: "X",
I: "<32 bytes signing public key for future communication>",
S: uint64_sequence_number,
T: uint64_transaction_id,
V: 0,
X: lifetime_of_address_mapping_in_seconds_uint64,
@ -486,6 +492,7 @@ ip address used for exit traffic.
A: "G",
E: XR,
I: "<32 bytes signing public key of requester>",
S: uint64_sequence_number,
T: transaction_id_uint64,
V: 0,
Z: "<64 bytes signature using exit info's signing key>"
@ -510,6 +517,7 @@ was denied.
B: backoff_milliseconds_uint64,
I: "<32 bytes signing public key of requester>",
R: "<optional reject metadata>",
S: uint64_sequence_number,
T: transaction_id_uint64,
V: 0,
Z: "<64 bytes signature signed by exit info's signing key>"
@ -572,6 +580,7 @@ transfer data between paths.
{
A: "T",
P: "<16 bytes path id>",
S: uint64_sequence_number,
T: message_transfered_between_paths,
V: 0
}
@ -586,6 +595,7 @@ transfer ip traffic for exit
{
A: "E",
S: uint64_sequence_number,
V: 0,
X: "<N bytes ipv6 packet>",
Y: "<16 bytes nounce>",
@ -609,6 +619,7 @@ should use the new path that this message came from.
{
A: "U",
S: uint64_sequence_number,
T: transaction_id_uint64,
V: 0,
Y: "<16 bytes nounce>",
@ -624,6 +635,7 @@ The address used in exit MAY be reused later.
{
A: "C",
S: uint64_sequence_number,
T: transaction_id_uint64,
V: 0,
Y: "<16 bytes nounce>",
@ -637,5 +649,6 @@ wrapper message for sending many dht messages down a path.
{
A: "M",
M: [many, dht, messages, here],
S: uint64_sequence_number,
V: 0
}

@ -31,7 +31,7 @@ namespace llarp
template < typename Int_t >
bool
BEncodeWriteDictInt(llarp_buffer_t* buf, const char* k, const Int_t& i)
BEncodeWriteDictInt(const char* k, const Int_t& i, llarp_buffer_t* buf)
{
return bencode_write_bytestring(buf, k, 1) && bencode_write_uint64(buf, i);
}

@ -41,7 +41,7 @@ struct llarp_link
LinkMap_t m_sessions;
mtx_t m_sessions_Mutex;
typedef std::unordered_map< llarp::PubKey, llarp::Addr, llarp::PubKeyHash >
typedef std::unordered_map< llarp::PubKey, llarp::Addr, llarp::PubKey::Hash >
SessionMap_t;
SessionMap_t m_Connected;

@ -15,7 +15,7 @@ namespace llarp
struct IMessage : public llarp::IBEncodeMessage
{
llarp::PathID_t from;
uint64_t S = 0;
virtual bool
HandleMessage(IMessageHandler* h, llarp_router* r) const = 0;
};

@ -13,7 +13,7 @@ namespace llarp
return false;
if(!EncodeParams(buf))
return false;
if(!BEncodeWriteDictInt(buf, "Y", seqno))
if(!BEncodeWriteDictInt("Y", seqno, buf))
return false;
if(!BEncodeWriteDictEntry("Z", hash, buf))
return false;

@ -66,13 +66,13 @@ namespace llarp
if(!BEncodeWriteDictMsgType(buf, "A", "F"))
return false;
// iterative
if(!BEncodeWriteDictInt(buf, "I", iterative ? 1 : 0))
if(!BEncodeWriteDictInt("I", iterative ? 1 : 0, buf))
return false;
if(N.IsZero())
{
return false;
// r5n counter
if(!BEncodeWriteDictInt(buf, "R", R))
if(!BEncodeWriteDictInt("R", R, buf))
return false;
// service address
if(!BEncodeWriteDictEntry("S", S, buf))
@ -83,14 +83,14 @@ namespace llarp
if(!BEncodeWriteDictEntry("N", N, buf))
return false;
// r5n counter
if(!BEncodeWriteDictInt(buf, "R", R))
if(!BEncodeWriteDictInt("R", R, buf))
return false;
}
// txid
if(!BEncodeWriteDictInt(buf, "T", T))
if(!BEncodeWriteDictInt("T", T, buf))
return false;
// protocol version
if(!BEncodeWriteDictInt(buf, "V", LLARP_PROTO_VERSION))
if(!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf))
return false;
return bencode_end(buf);

@ -89,9 +89,9 @@ namespace llarp
return false;
if(!BEncodeWriteDictList("I", I, buf))
return false;
if(!BEncodeWriteDictInt(buf, "T", T))
if(!BEncodeWriteDictInt("T", T, buf))
return false;
if(!BEncodeWriteDictInt(buf, "V", version))
if(!BEncodeWriteDictInt("V", version, buf))
return false;
return bencode_end(buf);
}

@ -28,11 +28,11 @@ namespace llarp
return false;
// txid
if(!BEncodeWriteDictInt(buf, "T", txid))
if(!BEncodeWriteDictInt("T", txid, buf))
return false;
// version
if(!BEncodeWriteDictInt(buf, "V", version))
if(!BEncodeWriteDictInt("V", version, buf))
return false;
return bencode_end(buf);

@ -92,13 +92,13 @@ namespace llarp
return false;
if(!BEncodeWriteDictEntry("I", I, buf))
return false;
if(!BEncodeWriteDictInt(buf, "R", R))
if(!BEncodeWriteDictInt("R", R, buf))
return false;
if(!BEncodeWriteDictInt(buf, "S", S))
if(!BEncodeWriteDictInt("S", S, buf))
return false;
if(!BEncodeWriteDictInt(buf, "T", txID))
if(!BEncodeWriteDictInt("T", txID, buf))
return false;
if(!BEncodeWriteDictInt(buf, "V", LLARP_PROTO_VERSION))
if(!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf))
return false;
return bencode_end(buf);
}

@ -118,7 +118,7 @@ frame_state::got_xmit(frame_header hdr, size_t sz)
return true;
}
else
llarp::LogWarn("duplicate XMIT h=", h);
llarp::LogWarn("duplicate XMIT h=", llarp::ShortHash(h));
}
else
llarp::LogWarn("LSB not set on flags");

@ -74,7 +74,7 @@ namespace llarp
return false;
if(lifetime > 10 && lifetime < 600)
{
if(!BEncodeWriteDictInt(buf, "i", lifetime))
if(!BEncodeWriteDictInt("i", lifetime, buf))
return false;
}
if(!BEncodeWriteDictEntry("n", tunnelNonce, buf))

@ -28,7 +28,7 @@ namespace llarp
if(!BEncodeWriteDictEntry("p", pathid, buf))
return false;
if(!BEncodeWriteDictInt(buf, "v", LLARP_PROTO_VERSION))
if(!BEncodeWriteDictInt("v", LLARP_PROTO_VERSION, buf))
return false;
if(!BEncodeWriteDictEntry("x", X, buf))
return false;
@ -90,7 +90,7 @@ namespace llarp
if(!BEncodeWriteDictEntry("p", pathid, buf))
return false;
if(!BEncodeWriteDictInt(buf, "v", LLARP_PROTO_VERSION))
if(!BEncodeWriteDictInt("v", LLARP_PROTO_VERSION, buf))
return false;
if(!BEncodeWriteDictEntry("x", X, buf))
return false;

@ -20,6 +20,10 @@ namespace llarp
{
return llarp::dht::DecodeMesssageList(from, val, M, true);
}
else if(llarp_buffer_eq(key, "S"))
{
return bencode_read_integer(val, &S);
}
else if(llarp_buffer_eq(key, "V"))
{
return bencode_read_integer(val, &V);
@ -37,7 +41,9 @@ namespace llarp
return false;
if(!BEncodeWriteDictBEncodeList("M", M, buf))
return false;
if(!BEncodeWriteDictInt(buf, "V", LLARP_PROTO_VERSION))
if(!BEncodeWriteDictInt("S", S, buf))
return false;
if(!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf))
return false;
return bencode_end(buf);

@ -22,7 +22,11 @@ namespace llarp
bool read = false;
if(!BEncodeMaybeReadDictInt("L", pathLifetime, read, key, val))
return false;
if(!BEncodeMaybeReadDictInt("S", pathCreated, read, key, val))
if(!BEncodeMaybeReadDictInt("S", S, read, key, val))
return false;
if(!BEncodeMaybeReadDictInt("T", pathCreated, read, key, val))
return false;
if(!BEncodeMaybeReadDictInt("V", version, read, key, val))
return false;
return read;
}
@ -34,9 +38,13 @@ namespace llarp
return false;
if(!BEncodeWriteDictMsgType(buf, "A", "P"))
return false;
if(!BEncodeWriteDictInt(buf, "L", pathLifetime))
if(!BEncodeWriteDictInt("L", pathLifetime, buf))
return false;
if(!BEncodeWriteDictInt("S", S, buf))
return false;
if(!BEncodeWriteDictInt("T", pathCreated, buf))
return false;
if(!BEncodeWriteDictInt(buf, "S", pathCreated))
if(!BEncodeWriteDictInt("V", version, buf))
return false;
return bencode_end(buf);
}

@ -15,6 +15,8 @@ namespace llarp
bool read = false;
if(!BEncodeMaybeReadDictInt("L", L, read, key, val))
return false;
if(!BEncodeMaybeReadDictInt("S", S, read, key, val))
return false;
if(!BEncodeMaybeReadDictInt("T", T, read, key, val))
return false;
return read;
@ -29,14 +31,16 @@ namespace llarp
return false;
if(L)
{
if(!BEncodeWriteDictInt(buf, "L", L))
if(!BEncodeWriteDictInt("L", L, buf))
return false;
}
if(T)
{
if(!BEncodeWriteDictInt(buf, "T", T))
if(!BEncodeWriteDictInt("T", T, buf))
return false;
}
if(!BEncodeWriteDictInt("S", S, buf))
return false;
return bencode_end(buf);
}

@ -20,6 +20,8 @@ namespace llarp
bool read = false;
if(!BEncodeMaybeReadDictEntry("P", P, read, key, val))
return false;
if(!BEncodeMaybeReadDictInt("S", S, read, key, val))
return false;
if(llarp_buffer_eq(key, "T"))
{
if(T)
@ -44,12 +46,15 @@ namespace llarp
if(!BEncodeWriteDictEntry("P", P, buf))
return false;
if(!BEncodeWriteDictInt("S", S, buf))
return false;
if(!bencode_write_bytestring(buf, "T", 1))
return false;
if(!T->BEncode(buf))
return false;
if(!BEncodeWriteDictInt(buf, "V", LLARP_PROTO_VERSION))
if(!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf))
return false;
if(!BEncodeWriteDictEntry("Y", Y, buf))
return false;

@ -66,7 +66,7 @@ namespace llarp
return false;
}
// write version
if(!BEncodeWriteDictInt(buf, "v", version))
if(!BEncodeWriteDictInt("v", version, buf))
return false;
if(W)
{
@ -128,14 +128,14 @@ namespace llarp
return false;
if(latency)
{
if(!BEncodeWriteDictInt(buf, "l", latency))
if(!BEncodeWriteDictInt("l", latency, buf))
return false;
}
if(!BEncodeWriteDictEntry("p", pathID, buf))
return false;
if(!BEncodeWriteDictInt(buf, "v", version))
if(!BEncodeWriteDictInt("v", version, buf))
return false;
if(!BEncodeWriteDictInt(buf, "x", expiresAt))
if(!BEncodeWriteDictInt("x", expiresAt, buf))
return false;
return bencode_end(buf);
}

@ -40,7 +40,7 @@ namespace llarp
return false;
if(!BEncodeWriteDictEntry("s", signkey, buf))
return false;
if(!BEncodeWriteDictInt(buf, "v", LLARP_PROTO_VERSION))
if(!BEncodeWriteDictInt("v", LLARP_PROTO_VERSION, buf))
return false;
if(!vanity.IsZero())
{

@ -56,9 +56,9 @@ namespace llarp
}
if(!BEncodeWriteDictEntry("N", N, buf))
return false;
if(!BEncodeWriteDictInt(buf, "S", S))
if(!BEncodeWriteDictInt("S", S, buf))
return false;
if(!BEncodeWriteDictInt(buf, "V", version))
if(!BEncodeWriteDictInt("V", version, buf))
return false;
if(!BEncodeWriteDictEntry("Z", Z, buf))
return false;

Loading…
Cancel
Save