lokinet/include/llarp/dns_iptracker.hpp

52 lines
1.1 KiB
C++
Raw Normal View History

2018-08-08 12:41:09 +00:00
#ifndef LIBLLARP_DNSIPTRACKER_HPP
#define LIBLLARP_DNSIPTRACKER_HPP
#include <llarp/net.hpp>
#include <map>
#include <vector>
2018-09-20 12:37:19 +00:00
#include <llarp/service/address.hpp>
#include "dns_dotlokilookup.hpp"
2018-08-08 12:41:09 +00:00
// either a request or response?
2018-09-20 12:37:19 +00:00
// neither, it's a result set row
2018-08-08 12:41:09 +00:00
struct dns_pointer
{
struct sockaddr *hostResult;
2018-09-20 12:37:19 +00:00
llarp::service::Address b32addr;
2018-08-08 12:41:09 +00:00
};
struct ip_range
{
uint8_t octet2;
uint8_t octet3;
// FIXME: we're not consecutive
uint8_t left;
std::unordered_map< uint8_t, dns_pointer * > used;
2018-08-08 12:41:09 +00:00
};
struct dns_iptracker
{
struct privatesInUse interfaces;
struct privatesInUse used_privates;
std::vector< std::unique_ptr <ip_range> > used_ten_ips;
std::vector< std::unique_ptr <ip_range> > used_seven_ips;
std::vector< std::unique_ptr <ip_range> > used_nine_ips;
2018-08-08 12:41:09 +00:00
};
void
dns_iptracker_init();
bool
dns_iptracker_setup_dotLokiLookup(dotLokiLookup *dll, llarp::Addr tunGatewayIp);
2018-09-20 12:37:19 +00:00
bool
dns_iptracker_setup(llarp::Addr tunGatewayIp);
2018-08-08 12:41:09 +00:00
struct dns_pointer *
dns_iptracker_get_free();
struct dns_pointer *
dns_iptracker_get_free(dns_iptracker *iptracker);
2018-08-08 12:41:09 +00:00
#endif