2018-06-10 14:05:48 +00:00
|
|
|
#ifndef LLARP_ROUTER_ID_HPP
|
|
|
|
#define LLARP_ROUTER_ID_HPP
|
|
|
|
|
2018-12-12 02:52:51 +00:00
|
|
|
#include <aligned.hpp>
|
2018-06-10 14:05:48 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2018-12-10 17:22:59 +00:00
|
|
|
struct RouterID : public AlignedBuffer< 32 >
|
|
|
|
{
|
2018-12-20 14:18:03 +00:00
|
|
|
static constexpr size_t SIZE = 32;
|
|
|
|
|
|
|
|
using Data = std::array< byte_t, SIZE >;
|
|
|
|
|
|
|
|
RouterID() : AlignedBuffer< SIZE >()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RouterID(const byte_t* buf) : AlignedBuffer< SIZE >(buf)
|
2018-12-10 17:22:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-12-20 14:18:03 +00:00
|
|
|
RouterID(const Data& data) : AlignedBuffer< SIZE >(data)
|
2018-12-10 17:22:59 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string
|
|
|
|
ToString() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
FromString(const std::string& str);
|
|
|
|
|
|
|
|
RouterID&
|
|
|
|
operator=(const byte_t* ptr)
|
|
|
|
{
|
2019-01-02 01:04:04 +00:00
|
|
|
std::copy(ptr, ptr + SIZE, begin());
|
2018-12-10 17:22:59 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend std::ostream&
|
|
|
|
operator<<(std::ostream& out, const RouterID& id)
|
|
|
|
{
|
|
|
|
return out << id.ToString();
|
|
|
|
}
|
|
|
|
|
2018-12-20 14:18:03 +00:00
|
|
|
using Hash = AlignedBuffer< SIZE >::Hash;
|
2018-12-10 17:22:59 +00:00
|
|
|
};
|
|
|
|
} // namespace llarp
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-11-22 23:59:03 +00:00
|
|
|
#endif
|