Sunshine master
Self-hosted game stream host for Moonlight.
upnp Namespace Reference

UPnP port mapping. More...

Classes

class  deinit_t
 RAII helper that runs shutdown cleanup when destroyed. More...
 
struct  mapping_t
 UPnP port mapping description and lease state. More...
 
class  urls_t
 Move-only RAII wrapper generated by KITTY_USING_MOVE_T.
Alias for element type. More...
 

Typedefs

using device_t = util::safe_ptr<UPNPDev, freeUPNPDevlist>
 Owning pointer to miniupnpc device discovery results.
 

Functions

std::unique_ptr< platf::deinit_tstart ()
 Start UPnP port mapping and return its shutdown guard.
 
int UPNP_GetValidIGDStatus (device_t &device, urls_t *urls, IGDdatas *data, std::array< char, INET6_ADDRESS_STRLEN > &lan_addr)
 Get the valid IGD status.
 

Variables

constexpr auto INET6_ADDRESS_STRLEN = 46
 Protocol or platform constant for inet6 address strlen.
 
constexpr auto IPv4 = 0
 I pv4.
 
constexpr auto IPv6 = 1
 I pv6.
 
constexpr auto PORT_MAPPING_LIFETIME = 3600s
 GameStream port offset for port mapping lifetime.
 
constexpr auto REFRESH_INTERVAL = 120s
 Protocol or platform constant for refresh interval.
 

Detailed Description

UPnP port mapping.

Function Documentation

◆ start()

std::unique_ptr< platf::deinit_t > upnp::start ( )
nodiscard

Start UPnP port mapping and return its shutdown guard.

Returns
Start status.

◆ UPNP_GetValidIGDStatus()

int upnp::UPNP_GetValidIGDStatus ( device_t & device,
urls_t * urls,
IGDdatas * data,
std::array< char, INET6_ADDRESS_STRLEN > & lan_addr )

Get the valid IGD status.

This function is a wrapper around UPNP_GetValidIGD() that returns the status code. There is a pre-processor check to determine which version of the function to call based on the version of the MiniUPnPc library.

Parameters
deviceThe device.
urlsThe URLs.
dataThe IGD data.
lan_addrThe LAN address.
Returns
The UPnP Status.
Return values
0No IGD found.
1A valid connected IGD has been found.
2A valid IGD has been found but it reported as not connected.
3An UPnP device has been found but was not recognized as an IGD.