lokinet/llarp/dns/iptracker.hpp

57 lines
1.3 KiB
C++
Raw Normal View History

2019-01-11 01:19:36 +00:00
#ifndef LLARP_DNSIPTRACKER_HPP
#define LLARP_DNSIPTRACKER_HPP
2018-08-08 12:41:09 +00:00
2019-01-11 01:19:36 +00:00
#include <dns/dotlokilookup.hpp>
#include <net.hpp>
2018-12-12 02:15:08 +00:00
#include <service/address.hpp>
2018-08-08 12:41:09 +00:00
#include <map>
#include <vector>
// 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
{
2018-11-03 13:19:18 +00:00
llarp::huint32_t hostResult;
2018-09-20 12:37:19 +00:00
llarp::service::Address b32addr;
2018-09-29 10:25:50 +00:00
// we could store the timeout at which we expect it to be available
// or a list of pending requests for it
2018-08-08 12:41:09 +00:00
};
struct ip_range
{
uint8_t octet2;
uint8_t octet3;
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;
2018-09-29 10:25:50 +00:00
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-11-03 13:19:18 +00:00
// make it easier to find a entry
std::vector< std::unique_ptr< dns_pointer > > map;
2018-08-08 12:41:09 +00:00
};
void
dns_iptracker_init();
bool
2018-11-03 13:19:18 +00:00
dns_iptracker_setup_dotLokiLookup(dotLokiLookup *dll,
llarp::huint32_t tunGatewayIp);
2018-09-20 12:37:19 +00:00
bool
2018-11-03 13:19:18 +00:00
dns_iptracker_setup(dns_iptracker *iptracker, llarp::huint32_t tunGatewayIp);
2018-09-20 12:37:19 +00:00
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