2018-08-30 18:48:43 +00:00
|
|
|
#ifndef LLARP_XI_HPP
|
|
|
|
#define LLARP_XI_HPP
|
2018-12-12 02:52:51 +00:00
|
|
|
|
2019-01-13 16:30:07 +00:00
|
|
|
#include <crypto/types.hpp>
|
2019-01-11 01:42:02 +00:00
|
|
|
#include <net/net.hpp>
|
2019-01-10 19:41:51 +00:00
|
|
|
#include <util/bencode.hpp>
|
2018-12-12 02:52:51 +00:00
|
|
|
|
2019-02-07 00:22:54 +00:00
|
|
|
#include <iosfwd>
|
2018-08-30 18:48:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* exit_info.h
|
|
|
|
*
|
|
|
|
* utilities for handling exits on the llarp network
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// Exit info model
|
|
|
|
namespace llarp
|
|
|
|
{
|
2019-05-24 02:01:36 +00:00
|
|
|
struct ExitInfo
|
2018-08-30 18:48:43 +00:00
|
|
|
{
|
|
|
|
struct in6_addr address;
|
|
|
|
struct in6_addr netmask;
|
|
|
|
PubKey pubkey;
|
2019-05-24 02:01:36 +00:00
|
|
|
uint64_t version = LLARP_PROTO_VERSION;
|
2018-08-30 18:48:43 +00:00
|
|
|
|
2019-05-24 02:01:36 +00:00
|
|
|
ExitInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ExitInfo(const PubKey &pk, const nuint32_t &ipv4_exit) : pubkey(pk)
|
2018-11-14 19:34:17 +00:00
|
|
|
{
|
|
|
|
memset(address.s6_addr, 0, 16);
|
|
|
|
address.s6_addr[11] = 0xff;
|
|
|
|
address.s6_addr[10] = 0xff;
|
2019-04-08 17:40:51 +00:00
|
|
|
memcpy(address.s6_addr + 12, &ipv4_exit.n, 4);
|
2018-11-14 19:34:17 +00:00
|
|
|
memset(netmask.s6_addr, 0xff, 16);
|
|
|
|
}
|
|
|
|
|
2019-05-24 02:01:36 +00:00
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t *buf) const;
|
2018-09-06 11:46:19 +00:00
|
|
|
|
2019-05-24 02:01:36 +00:00
|
|
|
bool
|
|
|
|
BDecode(llarp_buffer_t *buf)
|
2018-09-06 11:46:19 +00:00
|
|
|
{
|
2019-05-24 02:01:36 +00:00
|
|
|
return bencode_decode_dict(*this, buf);
|
2018-09-06 11:46:19 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 18:48:43 +00:00
|
|
|
bool
|
2019-05-24 02:01:36 +00:00
|
|
|
DecodeKey(const llarp_buffer_t &k, llarp_buffer_t *buf);
|
2019-02-24 23:46:37 +00:00
|
|
|
|
|
|
|
std::ostream &
|
|
|
|
print(std::ostream &stream, int level, int spaces) const;
|
2018-08-30 18:48:43 +00:00
|
|
|
};
|
2019-02-07 00:22:54 +00:00
|
|
|
|
2019-02-24 23:46:37 +00:00
|
|
|
inline std::ostream &
|
|
|
|
operator<<(std::ostream &out, const ExitInfo &xi)
|
|
|
|
{
|
|
|
|
return xi.print(out, -1, -1);
|
|
|
|
}
|
2018-08-30 18:48:43 +00:00
|
|
|
} // namespace llarp
|
|
|
|
|
|
|
|
#endif
|