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

Our link to libupnp. More...

#include <upnpplib.hxx>

Classes

class  Internal
 

Public Types

enum  InitFlags { UPNPPINIT_FLAG_NONE = 0, UPNPPINIT_FLAG_NOIPV6 = 1, UPNPPINIT_FLAG_SERVERONLY = 2 }
 Configuration flags for the initialisation call. More...
 
enum  InitOption {
  UPNPPINIT_OPTION_END = 0, UPNPPINIT_OPTION_IFNAMES, UPNPPINIT_OPTION_IPV4, UPNPPINIT_OPTION_PORT,
  UPNPPINIT_OPTION_SUBSCRIPTION_TIMEOUT, UPNPPINIT_OPTION_CLIENT_PRODUCT, UPNPPINIT_OPTION_CLIENT_VERSION
}
 Options for the initialisation call. More...
 
enum  LogLevel {
  LogLevelNone, LogLevelError, LogLevelInfo, LogLevelDebug,
  LogLevelAll
}
 libnpupnp (pupnp) logging: this is distinct from libupnpp logging More...
 

Public Member Functions

std::string host ()
 Return the IP v4 address as dotted notation.
 
std::string hwaddr ()
 Return one ethernet address.
 
void setMaxContentLength (int bytes)
 Set max library buffer size for reading content from servers. More...
 
bool ok () const
 Check state after initialization.
 

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 bool init (unsigned int flags,...)
 Initialize the library. More...
 
static std::string versionString ()
 Returns something like "libupnpp 0.14.0 libupnp x.y.z".
 
static bool setLogFileName (const std::string &fn, LogLevel level=LogLevelError)
 Set libnpupnp log file name and activate/deactivate logging. More...
 
static bool setLogLevel (LogLevel level)
 Set libnpupnp log level. More...
 
static int getInitError ()
 Retrieve init error if state not ok.
 
static std::string makeDevUUID (const std::string &name, const std::string &hw)
 Build a unique stable UUID. More...
 
static std::string errAsString (const std::string &who, int code)
 Translate libupnp integer error code (UPNP_E_XXX) to string.
 

Public Attributes

class UPNPP_LOCAL Internal
 
Internalm
 

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

◆ InitFlags

Configuration flags for the initialisation call.

Enumerator
UPNPPINIT_FLAG_NOIPV6 

Disable IPV6 support.

UPNPPINIT_FLAG_SERVERONLY 

Do not initialize the client side (we are a device)

◆ InitOption

Options for the initialisation call.

Each option argument may be followed by specific parameters.

Enumerator
UPNPPINIT_OPTION_END 

Terminate the VARARGs list.

UPNPPINIT_OPTION_IFNAMES 

Names of the interfaces to use.

A const std::string* follows. This is a space-separated list. If not set, we will use the first interface. If set to '*', we will use all possible interfaces.

UPNPPINIT_OPTION_IPV4 

Use single IPV4 address.

A const std::string* address in dot notation follows. This is incompatible with OPTION_IFNAMES.

UPNPPINIT_OPTION_PORT 

IP Port to use.

An int parameter follows. The lower lib default is 49152.

UPNPPINIT_OPTION_SUBSCRIPTION_TIMEOUT 

Control: subscription timeout in seconds.

An int param. follows.

UPNPPINIT_OPTION_CLIENT_PRODUCT 

Control: product name to set in user-agent strings.

A const std::string* follows.

UPNPPINIT_OPTION_CLIENT_VERSION 

Control: product version to set in user-agent strings.

A const std::string* follows.

◆ LogLevel

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

libnpupnp 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 
)
static

Retrieve the singleton LibUPnP object.

Using this call with arguments is deprecated. Call init() (creates the lib) then getLibUPnP() without arguments instead.

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

Parameters
serveronlyno client init

◆ init()

bool UPnPP::LibUPnP::init ( unsigned int  flags,
  ... 
)
static

Initialize the library.

On success you will then call getLibUPnP() to access the object instance.

Parameters
flagsA bitfield of InitFlags values.
...A list of InitOption and values, ended by UPNPPINIT_OPTION_END.
Returns
false for failure, true for success.

◆ makeDevUUID()

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

Build a unique stable UUID.

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

Parameters
namedevice "friendly name"
hwdevice ethernet address (as 12 ascii hexadecimal bytes)

◆ setLogFileName()

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

Set libnpupnp log file name and activate/deactivate logging.

Do not use the same file as the one used for libupnpp logging.

Parameters
fnfile name to use. Use an empty string log to stderr. LogLevelNone to turn off.

◆ setLogLevel()

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

Set libnpupnp log level.

Returns
true if 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: