|
| 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.
|
| bool | is_valid_igd (igd_status_e status) |
| | Check whether a UPNP_GetValidIGD() status code identifies a usable IGD.
|
| int | shared_prefix_length (std::string_view a, std::string_view b) |
| | Count the leading bits two IPv4 addresses have in common.
|
| std::string | url_host (std::string_view url) |
| | Extract the host from a URL such as http://192.168.1.1:1900/rootDesc.xml.
|
| 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.
|
| 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).
|
| std::unique_ptr< platf::deinit_t > | start () |
| | Start UPnP port mapping and return its shutdown guard.
|
| bool | lease_needs_refresh (std::string_view lease) |
| | Detect an owned finite lease that needs replacement on routers that do not renew repeated adds.
|
| mapping_state_e | classify_mapping (int result, std::string_view client, std::string_view port, std::string_view description, const owned_mapping_t &wanted) |
| | Classify a lookup without treating a destination alone as proof of ownership.
|
| bool | may_manage_mapping (mapping_state_e state, bool recorded) |
| | Require a local ownership record as well as a matching router response.
|
| template<class Specific, class Generic> |
| mapping_lookup_t | verify_mapping_lookup (const owned_mapping_t &wanted, bool recorded, Specific specific, Generic generic) |
| | Verify an owned rule even when GetSpecificPortMappingEntry reports port zero.
|
| bool | should_retain_recovery_record (mapping_state_e state, bool permanent) |
| | Keep permanent recovery records when router ownership is ambiguous.
|
| std::string | mapping_journal_event (const owned_mapping_t &mapping, bool added) |
| | Encode one append-only recovery event before adding or after removing a permanent rule.
|
| std::vector< owned_mapping_t > | read_mapping_journal (const std::string &text) |
| | Recover outstanding permanent rules, ignoring incomplete or invalid journal lines.
|
Result codes returned by the installed MiniUPnPc library.
Project-owned equivalent of the UPNP_GetValidIGD() result codes. MiniUPnPc 2.2.8 (API version 18) introduced the private-address result, renumbering the values that follow it; the library's own UPNP_* symbolic names only exist starting with MiniUPnPc 2.3.0 (API version 19), so this enum centralizes the version-dependent numbering instead of relying on those names.
| Enumerator |
|---|
| none | No IGD was found.
|
| connected | A connected IGD was found.
|
| disconnected | A disconnected IGD was found.
|
| unknown_device | The device was not recognized as an IGD.
|
Definition at line 46 of file upnp.h.
Check whether a UPNP_GetValidIGD() status code identifies a usable IGD.
Accepts every status code that identifies a valid IGD (connected, private-IP, or disconnected). The private_ip member only exists with MiniUPnPc >= 2.2.8 (API version 18); disconnected is 2 before API 18 and 3 starting with API 18, and unknown_device is 3 or 4 respectively. Callers don't need to handle the version difference themselves.
- Parameters
-
- Returns
- true if the status identifies a usable IGD, false otherwise.
Definition at line 133 of file upnp.cpp.
| std::size_t upnp::select_inner_igd |
( |
const std::vector< std::string > & | igd_hosts, |
|
|
std::string_view | lan_addr ) |
|
nodiscard |
Select the IGD of the network Hermes is attached to.
Behind two routers, the outer router often answers discovery too, and UPNP_GetValidIGD() prefers it because it has a public address. That router can't reach Hermes's address, so a mapping there opens nothing. The gateway Hermes is attached to is the one whose address shares the most leading bits with Hermes's own address. On a tie, the earlier entry wins, so the first entry (the IGD chosen by UPNP_GetValidIGD()) is kept unless another IGD is strictly closer.
- Parameters
-
| igd_hosts | Addresses of the discovered IGDs. |
| lan_addr | Hermes's local address. |
- Returns
- Index of the selected IGD in igd_hosts, or 0 if the list is empty.
Definition at line 185 of file upnp.cpp.
template<class Specific, class Generic>
Verify an owned rule even when GetSpecificPortMappingEntry reports port zero.
Some IGDs report the correct port only through GetGenericPortMappingEntry, but append garbage to its description. Never use that description as ownership evidence: require the exact description in specific queries both before and after a complete, bounded enumeration. An unrecorded rule cannot use this fallback.
- Parameters
-
| wanted | Rule on this exact gateway/service and wildcard remote host. |
| recorded | Whether Hermes has a local ownership record for this identity. |
| specific | Query the wildcard mapping by external port and protocol. |
| generic | Query a mapping by table index, returning 713 at the end. |
Definition at line 131 of file upnp_mapping.h.