2018-06-10 16:05:48 +02:00
|
|
|
#ifndef LLARP_ROUTER_ID_HPP
|
|
|
|
#define LLARP_ROUTER_ID_HPP
|
|
|
|
|
2019-01-10 20:41:51 +01:00
|
|
|
#include <util/aligned.hpp>
|
2019-02-11 18:14:43 +01:00
|
|
|
#include <util/status.hpp>
|
2018-06-10 16:05:48 +02:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2020-04-07 20:38:56 +02:00
|
|
|
struct RouterID : public AlignedBuffer<32>
|
2018-12-10 18:22:59 +01:00
|
|
|
{
|
2018-12-20 15:18:03 +01:00
|
|
|
static constexpr size_t SIZE = 32;
|
|
|
|
|
2020-04-07 20:38:56 +02:00
|
|
|
using Data = std::array<byte_t, SIZE>;
|
2018-12-20 15:18:03 +01:00
|
|
|
|
2019-08-27 01:29:17 +02:00
|
|
|
RouterID()
|
2018-12-20 15:18:03 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-04-07 20:38:56 +02:00
|
|
|
RouterID(const byte_t* buf) : AlignedBuffer<SIZE>(buf)
|
2018-12-10 18:22:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-04-07 20:38:56 +02:00
|
|
|
RouterID(const Data& data) : AlignedBuffer<SIZE>(data)
|
2018-12-10 18:22:59 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-11 18:14:43 +01:00
|
|
|
util::StatusObject
|
2019-04-19 17:10:26 +02:00
|
|
|
ExtractStatus() const;
|
2019-02-11 18:14:43 +01:00
|
|
|
|
2018-12-10 18:22:59 +01:00
|
|
|
std::string
|
|
|
|
ToString() const;
|
|
|
|
|
2020-03-01 01:26:23 +01:00
|
|
|
std::string
|
|
|
|
ShortString() const;
|
|
|
|
|
2018-12-10 18:22:59 +01:00
|
|
|
bool
|
|
|
|
FromString(const std::string& str);
|
|
|
|
|
|
|
|
RouterID&
|
|
|
|
operator=(const byte_t* ptr)
|
|
|
|
{
|
2019-01-02 02:04:04 +01:00
|
|
|
std::copy(ptr, ptr + SIZE, begin());
|
2018-12-10 18:22:59 +01:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend std::ostream&
|
|
|
|
operator<<(std::ostream& out, const RouterID& id)
|
|
|
|
{
|
|
|
|
return out << id.ToString();
|
|
|
|
}
|
|
|
|
|
2020-04-07 20:38:56 +02:00
|
|
|
using Hash = AlignedBuffer<SIZE>::Hash;
|
2018-12-10 18:22:59 +01:00
|
|
|
};
|
2019-01-23 00:50:26 +01:00
|
|
|
|
|
|
|
inline bool
|
|
|
|
operator==(const RouterID& lhs, const RouterID& rhs)
|
|
|
|
{
|
|
|
|
return lhs.as_array() == rhs.as_array();
|
|
|
|
}
|
|
|
|
|
2018-12-10 18:22:59 +01:00
|
|
|
} // namespace llarp
|
2018-06-10 16:05:48 +02:00
|
|
|
|
2018-11-23 00:59:03 +01:00
|
|
|
#endif
|