lokinet/llarp/net/exit_info.hpp

63 lines
1.3 KiB
C++
Raw Normal View History

2018-08-30 18:48:43 +00:00
#ifndef LLARP_XI_HPP
#define LLARP_XI_HPP
#include <crypto/types.hpp>
#include <net/net.hpp>
#include <util/bencode.hpp>
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
{
struct ExitInfo final : public IBEncodeMessage
2018-08-30 18:48:43 +00:00
{
struct in6_addr address;
struct in6_addr netmask;
PubKey pubkey;
2019-02-05 00:41:33 +00:00
ExitInfo(const PubKey &pk, const nuint32_t &ipv4_exit)
: IBEncodeMessage(), 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;
memcpy(address.s6_addr + 12, &ipv4_exit, 4);
memset(netmask.s6_addr, 0xff, 16);
}
2018-09-06 11:46:19 +00:00
ExitInfo() : IBEncodeMessage()
{
}
2019-02-05 00:41:33 +00:00
ExitInfo(const ExitInfo &other)
: IBEncodeMessage(other.version), pubkey(other.pubkey)
2018-09-06 11:46:19 +00:00
{
memcpy(address.s6_addr, other.address.s6_addr, 16);
memcpy(netmask.s6_addr, other.netmask.s6_addr, 16);
}
2018-08-31 12:46:54 +00:00
~ExitInfo();
2018-08-30 18:48:43 +00:00
bool
BEncode(llarp_buffer_t *buf) const override;
2018-08-30 18:48:43 +00:00
bool
DecodeKey(const llarp_buffer_t &k, llarp_buffer_t *buf) override;
2018-08-30 18:48:43 +00:00
2018-08-31 13:51:24 +00:00
ExitInfo &
operator=(const ExitInfo &other);
2018-08-30 18:48:43 +00:00
};
2019-02-07 00:22:54 +00:00
std::ostream &
operator<<(std::ostream &out, const ExitInfo &xi);
2018-08-30 18:48:43 +00:00
} // namespace llarp
#endif