15#include <miniupnpc/miniupnpc.h>
33 using device_t = util::safe_ptr<UPNPDev, freeUPNPDevlist>;
35 KITTY_USING_MOVE_T(
urls_t, UPNPUrls, , {
49#if (MINIUPNPC_API_VERSION >= 18)
95 [[nodiscard]] std::string
url_host(std::string_view url);
108 [[nodiscard]] std::size_t
select_inner_igd(
const std::vector<std::string> &igd_hosts, std::string_view lan_addr);
119 [[nodiscard]] std::optional<std::size_t>
select_outer_igd(
const std::vector<std::string> &igd_hosts, std::size_t inner, std::string_view inner_external_addr);
126 [[nodiscard]] std::unique_ptr<platf::deinit_t>
start();
Owning wrapper for MiniUPnPc URLs.
Declarations for common platform specific utilities.
std::optional< std::size_t > select_outer_igd(const std::vector< std::string > &igd_hosts, std::size_t inner, std::string_view inner_external_addr)
Select the IGD in front of the inner gateway when Hermes is behind two routers (double NAT).
igd_status_e
Result codes returned by the installed MiniUPnPc library.
@ connected
A connected IGD was found.
@ disconnected
A disconnected IGD was found.
@ unknown_device
The device was not recognized as an IGD.
constexpr auto INET6_ADDRESS_STRLEN
Buffer size for a textual IPv6 address.
constexpr auto REFRESH_INTERVAL
Interval between mapping refresh passes.
std::string url_host(std::string_view url)
Extract the host from a URL such as http://192.168.1.1:1900/rootDesc.xml.
bool is_valid_igd(igd_status_e status)
Check whether a UPNP_GetValidIGD() status code identifies a usable IGD.
std::size_t select_inner_igd(const std::vector< std::string > &igd_hosts, std::string_view lan_addr)
Select the IGD of the network Hermes is attached to.
constexpr auto PORT_MAPPING_LIFETIME
Requested finite mapping lifetime.
std::unique_ptr< platf::deinit_t > start()
Start UPnP port mapping and return its shutdown guard.
util::safe_ptr< UPNPDev, freeUPNPDevlist > device_t
Owning pointer to miniupnpc device discovery results.
int shared_prefix_length(std::string_view a, std::string_view b)
Count the leading bits two IPv4 addresses have in common.
constexpr auto IPv4
IPv4 discovery.
constexpr auto IPv6
IPv6 discovery.
igd_status_e UPNP_GetValidIGDStatus(device_t &device, urls_t *urls, IGDdatas *data, std::array< char, INET6_ADDRESS_STRLEN > &lan_addr)
Get the valid IGD status.