libupnpp 0.16.0
A C++ wrapper for the Portable UPnP reference library
|
Our link to libupnp. More...
#include <upnpplib.hxx>
Classes | |
class | Internal |
Public Types | |
enum | InitFlags { UPNPPINIT_FLAG_NONE = 0 , UPNPPINIT_FLAG_NOIPV6 = 0x1 , UPNPPINIT_FLAG_SERVERONLY = 0x2 , UPNPPINIT_FLAG_RESANITIZE_URLS = 0x4 } |
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 , UPNPPINIT_OPTION_SUBSOPS_TIMEOUTMS , UPNPPINIT_OPTION_RESANITIZED_CHARS , UPNPPINIT_OPTION_BOOTID } |
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 | |
LibUPnP (const LibUPnP &)=delete | |
LibUPnP & | operator= (const LibUPnP &)=delete |
std::string | host () |
Return the IP v4 address as dotted notation. | |
std::string | port () |
Return the listening port. | |
std::string | hwaddr () |
Return one ethernet address. | |
bool | setWebServerDocumentRoot (const std::string &rootpath) |
Set the root/base directory for the HTTP server. | |
void | setMaxContentLength (int bytes) |
Set max library buffer size for reading content from servers. | |
bool | ok () const |
Check state after initialization. | |
Static Public Member Functions | |
static bool | init (unsigned int flags,...) |
Initialize the library, with more complete control than a direct getLibUPnP() call. | |
static 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. | |
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. | |
static bool | setLogLevel (LogLevel level) |
Set libnpupnp log level. | |
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. | |
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 |
Internal * | m |
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.
Configuration flags for the initialisation call.
Options for the initialisation call.
Each option argument may be followed by specific parameters.
libnpupnp (pupnp) logging: this is distinct from libupnpp logging
libnpupnp log levels
|
static |
Retrieve the singleton LibUPnP object.
Using this call with arguments is deprecated. Call init() instead, (creates the lib) then getLibUPnP() without arguments.
This initializes libupnp, possibly setting an address and port, possibly registering a client if serveronly is false.
serveronly | no client init |
[output] | hwaddr returns 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. |
ifname | if not empty, network interface to use. Passed to libnpupnp. Null or empty to use the first interface, "*" for all interfaces, or space-separated list of interface names. |
ip | if not empty, IP address to use. Only used if ifname is empty. |
port | port parameter to UpnpInit() (0 for default). |
|
static |
Initialize the library, with more complete control than a direct getLibUPnP() call.
On success you will then call getLibUPnP() to access the object instance.
flags | A bitfield of InitFlags values. |
... | A list of InitOption and values, ended by UPNPPINIT_OPTION_END. |
|
static |
Build a unique stable UUID.
This uses a hash of the input name (e.g.: friendlyName), and the Ethernet address.
name | device "friendly name" |
hw | device ethernet address (as 12 ascii hexadecimal bytes) |
|
static |
Set libnpupnp log file name and activate/deactivate logging.
Do not use the same file as the one used for libupnpp logging.
fn | file name to use. Use an empty string log to stderr. |
level | verbosity. Set to LogLevelNone to turn off. |
|
static |
Set libnpupnp log level.
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.
bool UPnPP::LibUPnP::setWebServerDocumentRoot | ( | const std::string & | rootpath | ) |
Set the root/base directory for the HTTP server.
This is for serving files directly from the file system. If this is not called, no local files will be directly served, all data will have to go through the VDir interface.
rootpath | the absolute path to a file system directory. The paths for all requests which do not match a virtual directory will be interpreted as subdirectories of rootpath. |