2020-03-03 19:56:33 +00:00
|
|
|
#include "router_event.hpp"
|
|
|
|
|
|
|
|
#include <path/path_types.hpp>
|
2020-03-12 19:51:57 +00:00
|
|
|
#include <path/path.hpp>
|
|
|
|
#include <path/transit_hop.hpp>
|
2020-03-03 19:56:33 +00:00
|
|
|
|
|
|
|
namespace tooling
|
|
|
|
{
|
|
|
|
struct PathAttemptEvent : public RouterEvent
|
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
std::vector<llarp::path::PathHopConfig> hops;
|
2020-03-12 19:51:57 +00:00
|
|
|
llarp::PathID_t pathid;
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
PathAttemptEvent(const llarp::RouterID& routerID, std::shared_ptr<const llarp::path::Path> path)
|
2020-03-12 19:51:57 +00:00
|
|
|
: RouterEvent("PathAttemptEvent", routerID, false)
|
|
|
|
, hops(path->hops)
|
|
|
|
, pathid(path->hops[0].rxID)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-03-07 01:20:11 +00:00
|
|
|
std::string
|
2020-03-12 19:51:57 +00:00
|
|
|
ToString() const
|
|
|
|
{
|
|
|
|
std::string result = RouterEvent::ToString();
|
|
|
|
result += "---- [";
|
2020-03-03 19:56:33 +00:00
|
|
|
|
2020-03-12 19:51:57 +00:00
|
|
|
size_t i = 0;
|
2020-04-07 18:38:56 +00:00
|
|
|
for (const auto& hop : hops)
|
2020-03-12 19:51:57 +00:00
|
|
|
{
|
|
|
|
i++;
|
|
|
|
|
|
|
|
result += llarp::RouterID(hop.rc.pubkey).ShortString();
|
|
|
|
result += "]";
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
if (i != hops.size())
|
2020-03-12 19:51:57 +00:00
|
|
|
{
|
|
|
|
result += " -> [";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2020-03-03 19:56:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PathRequestReceivedEvent : public RouterEvent
|
|
|
|
{
|
|
|
|
llarp::RouterID prevHop;
|
|
|
|
llarp::RouterID nextHop;
|
|
|
|
llarp::PathID_t txid;
|
|
|
|
llarp::PathID_t rxid;
|
|
|
|
bool isEndpoint = false;
|
|
|
|
|
2020-03-12 19:51:57 +00:00
|
|
|
PathRequestReceivedEvent(
|
2020-04-07 18:38:56 +00:00
|
|
|
const llarp::RouterID& routerID, std::shared_ptr<const llarp::path::TransitHop> hop)
|
2020-03-12 19:51:57 +00:00
|
|
|
: RouterEvent("PathRequestReceivedEvent", routerID, true)
|
|
|
|
, prevHop(hop->info.downstream)
|
|
|
|
, nextHop(hop->info.upstream)
|
|
|
|
, txid(hop->info.txID)
|
|
|
|
, rxid(hop->info.rxID)
|
|
|
|
, isEndpoint(routerID == nextHop ? true : false)
|
|
|
|
{
|
|
|
|
}
|
2020-03-03 19:56:33 +00:00
|
|
|
|
2020-03-12 19:51:57 +00:00
|
|
|
std::string
|
|
|
|
ToString() const
|
|
|
|
{
|
|
|
|
std::string result = RouterEvent::ToString();
|
|
|
|
result += "---- [";
|
|
|
|
result += prevHop.ShortString();
|
|
|
|
result += "] -> [*";
|
|
|
|
result += routerID.ShortString();
|
|
|
|
result += "] -> [";
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
if (isEndpoint)
|
2020-03-12 19:51:57 +00:00
|
|
|
{
|
|
|
|
result += "nowhere]";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result += nextHop.ShortString();
|
|
|
|
result += "]";
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2020-03-03 19:56:33 +00:00
|
|
|
};
|
|
|
|
|
2020-03-12 19:51:57 +00:00
|
|
|
struct PathStatusReceivedEvent : public RouterEvent
|
2020-03-12 15:35:32 +00:00
|
|
|
{
|
2020-03-12 19:51:57 +00:00
|
|
|
llarp::PathID_t rxid;
|
|
|
|
uint64_t status;
|
2020-03-12 15:35:32 +00:00
|
|
|
|
2020-03-12 19:51:57 +00:00
|
|
|
PathStatusReceivedEvent(
|
2020-04-07 18:38:56 +00:00
|
|
|
const llarp::RouterID& routerID, const llarp::PathID_t rxid_, uint64_t status_)
|
|
|
|
: RouterEvent("PathStatusReceivedEvent", routerID, true), rxid(rxid_), status(status_)
|
2020-03-12 19:51:57 +00:00
|
|
|
{
|
|
|
|
}
|
2020-03-12 15:35:32 +00:00
|
|
|
|
|
|
|
std::string
|
2020-03-12 19:51:57 +00:00
|
|
|
ToString() const
|
|
|
|
{
|
|
|
|
std::string result = RouterEvent::ToString();
|
|
|
|
result += "---- path rxid: " + rxid.ShortHex();
|
|
|
|
result += ", status: " + std::to_string(status);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
2020-03-12 15:35:32 +00:00
|
|
|
|
2020-03-12 19:51:57 +00:00
|
|
|
struct PathBuildRejectedEvent : public RouterEvent
|
|
|
|
{
|
2020-03-12 15:35:32 +00:00
|
|
|
llarp::PathID_t rxid;
|
|
|
|
llarp::RouterID rejectedBy;
|
2020-03-12 19:51:57 +00:00
|
|
|
|
|
|
|
PathBuildRejectedEvent(
|
|
|
|
const llarp::RouterID& routerID,
|
|
|
|
const llarp::PathID_t rxid_,
|
|
|
|
const llarp::RouterID& rejectedBy_)
|
|
|
|
: RouterEvent("PathBuildRejectedEvent", routerID, false)
|
|
|
|
, rxid(rxid_)
|
|
|
|
, rejectedBy(rejectedBy_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
ToString() const
|
|
|
|
{
|
|
|
|
std::string result = RouterEvent::ToString();
|
|
|
|
result += "---- path rxid: " + rxid.ShortHex();
|
|
|
|
result += ", rejectedBy: " + rejectedBy.ShortString();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2020-03-12 15:35:32 +00:00
|
|
|
};
|
|
|
|
|
2020-03-07 01:20:11 +00:00
|
|
|
} // namespace tooling
|