libupnpp  0.16.0
A C++ wrapper for the Portable UPnP reference library
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
UPnPP::LibUPnP Class Reference

Our link to libupnp. More...

#include <upnpplib.hxx>


class  Internal

Public Types

enum  LogLevel { LogLevelNone, LogLevelError, LogLevelDebug }
 libupnp (pupnp) logging: this is distinct from libupnpp logging More...

Public Member Functions

std::string host ()
 Return the IP v4 address as dotted notation.
bool setLogFileName (const std::string &fn, LogLevel level=LogLevelError)
 Set libupnp log file name and activate/deactivate logging. More...
bool setLogLevel (LogLevel level)
 Set libupnp log level. More...
void setMaxContentLength (int bytes)
 Set max library buffer size for reading content from servers. More...
bool ok () const
 Check state after initialization.
int getInitError () const
 Retrieve init error if state not ok.
void registerHandler (Upnp_EventType et, Upnp_FunPtr handler, void *cookie)
 Private: specify function to be called on given UPnP event. More...
int setupWebServer (const std::string &description, UpnpDevice_Handle *dvh)
UpnpClient_Handle getclh ()

Static Public Member Functions

static LibUPnPgetLibUPnP (bool serveronly=false, std::string *hwaddr=0, const std::string ifname=std::string(), const std::string ip=std::string(), unsigned short port=0)
 Retrieve the singleton LibUPnP object. More...
static std::string versionString ()
 Returns something like "libupnpp 0.14.0 libupnp x.y.z".
static std::string makeDevUUID (const std::string &name, const std::string &hw)
 Build a unique persistent UUID for a root device. More...
static std::string errAsString (const std::string &who, int code)
 Translate libupnp integer error code (UPNP_E_XXX) to string.
static std::string evTypeAsString (Upnp_EventType)
 Private: translate libupnp event type to string.

Detailed Description

Our link to libupnp.

Initialize and keep the handle around.

Not all applications will need to use this. The initialization call will be performed internally as needed, you only need to call it if you need to set specific parameters.

Member Enumeration Documentation

◆ LogLevel

libupnp (pupnp) logging: this is distinct from libupnpp logging

libupnp log levels

Member Function Documentation

◆ getLibUPnP()

LibUPnP * UPnPP::LibUPnP::getLibUPnP ( bool  serveronly = false,
std::string *  hwaddr = 0,
const std::string  ifname = std::string(),
const std::string  ip = std::string(),
unsigned short  port = 0 

Retrieve the singleton LibUPnP object.

This initializes libupnp, possibly setting an address and port, possibly registering a client if serveronly is false.

Note: libupnp uses a single v4 address/interface (and a v6 one if enabled). This can be specified in the initialization call, else it will pick the first non-loopback one. There is no way to have a single instance of the library listen on multiple interfaces.

serveronlyno client init
hwaddrreturns the hardware address for the specified network interface, or the first one is ifname is empty. If the IP address is specified instead of the interface name, the hardware address returned is not necessarily the one matching the IP.
ifnameif not empty, network interface to use. Translated to IP address for the UpnpInit() call.
ipif not empty, IP address to use. Only used if ifname is empty.
portport parameter to UpnpInit() (0 for default).
0 for failure.

◆ makeDevUUID()

string UPnPP::LibUPnP::makeDevUUID ( const std::string &  name,
const std::string &  hw 

Build a unique persistent UUID for a root device.

This uses a hash of the input name (e.g.: friendlyName), and the host Ethernet address

◆ registerHandler()

void UPnPP::LibUPnP::registerHandler ( Upnp_EventType  et,
Upnp_FunPtr  handler,
void *  cookie 

Private: specify function to be called on given UPnP event.

This will happen in the libupnp thread context.

◆ setLogFileName()

bool UPnPP::LibUPnP::setLogFileName ( const std::string &  fn,
LogLevel  level = LogLevelError 

Set libupnp log file name and activate/deactivate logging.

This does nothing if libupnp was built with logging disabled. It may be useful for debugging in some case. You should not use the same file as the one used for libupnpp logging.

fnfile name to use. Use empty string to turn logging off.

◆ setLogLevel()

bool UPnPP::LibUPnP::setLogLevel ( LogLevel  level)

Set libupnp log level.

true if libupnp logging is enabled, else false.

◆ setMaxContentLength()

void UPnPP::LibUPnP::setMaxContentLength ( int  bytes)

Set max library buffer size for reading content from servers.

Just calls libupnp UpnpSetMaxContentLength(). This defines the maximum amount of data that Soap calls will accept from the remote. The libupnp default is very low (16KB), but libupnpp sets the value to 2MB during initialization. You can reset the value to your own choice by using this method.

The documentation for this class was generated from the following files: