lokinet/include/llarp/dns_iptracker.hpp

53 lines
1.2 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
{
llarp::Addr 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-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
2018-10-04 14:10:09 +00:00
dns_iptracker_setup(dns_iptracker *iptracker, llarp::Addr 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