libupnpp  0.16.0
A C++ wrapper for the Portable UPnP reference library
upnpplib.hxx
1 /* Copyright (C) 2006-2016 J.F.Dockes
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16  * 02110-1301 USA
17  */
18 #ifndef _LIBUPNP_H_X_INCLUDED_
19 #define _LIBUPNP_H_X_INCLUDED_
20 
21 #include <map>
22 #include <string>
23 
24 #include "upnppexports.hxx"
25 
27 #define LIBUPNPP_VERSION_MAJOR 0
28 #define LIBUPNPP_VERSION_MINOR 21
29 #define LIBUPNPP_VERSION_REVISION 0
30 #define LIBUPNPP_AT_LEAST(A,B,C) \
32  (LIBUPNPP_VERSION_MAJOR > (A) || \
33  (LIBUPNPP_VERSION_MAJOR == (A) && \
34  (LIBUPNPP_VERSION_MINOR > (B) || \
35  (LIBUPNPP_VERSION_MINOR == (B) && LIBUPNPP_VERSION_REVISION >= (C)))))
36 
37 // Let clients avoid including upnp.h if they don't need it for other reasons
38 #ifndef UPNP_E_SUCCESS
39 #define UPNP_E_SUCCESS 0
40 #endif
41 
42 // Feature test defines to help client programs, esp. for features
43 // added without breaking api and avi
44 
45 // upnp/av connection manager control api
46 #define LIBUPNPP_HAS_UPNPAVCONMAN 1
47 
48 namespace UPnPP {
49 
56 class UPNPP_API LibUPnP {
57 public:
58  ~LibUPnP();
59 
82  static LibUPnP* getLibUPnP(bool serveronly = false, std::string* hwaddr = 0,
83  const std::string ifname = std::string(),
84  const std::string ip = std::string(),
85  unsigned short port = 0);
86 
88  enum InitFlags {
89  UPNPPINIT_FLAG_NONE = 0,
91  UPNPPINIT_FLAG_NOIPV6 = 1,
93  UPNPPINIT_FLAG_SERVERONLY = 2,
94  };
95 
98  enum InitOption {
100  UPNPPINIT_OPTION_END = 0,
120  };
121 
129  static bool init(unsigned int flags, ...);
130 
132  std::string host();
134  std::string hwaddr();
136  static std::string versionString();
137 
140  enum LogLevel {LogLevelNone, LogLevelError, LogLevelInfo, LogLevelDebug,
141  LogLevelAll};
142 
150  static bool setLogFileName(
151  const std::string& fn, LogLevel level = LogLevelError);
152 
157  static bool setLogLevel(LogLevel level);
158 
167  void setMaxContentLength(int bytes);
168 
170  bool ok() const;
171 
173  static int getInitError();
174 
181  static std::string makeDevUUID(const std::string& name,
182  const std::string& hw);
183 
185  static std::string errAsString(const std::string& who, int code);
186 
187  class UPNPP_LOCAL Internal;
188  Internal *m;
189 
190 private:
191  LibUPnP();
192  LibUPnP(const LibUPnP &);
193  LibUPnP& operator=(const LibUPnP &);
194 };
195 
196 } // namespace UPnPP
197 
198 #endif /* _LIBUPNP.H_X_INCLUDED_ */
Use single IPV4 address.
Definition: upnpplib.hxx:108
Control: product name to set in user-agent strings.
Definition: upnpplib.hxx:116
Control: product version to set in user-agent strings.
Definition: upnpplib.hxx:119
InitOption
Options for the initialisation call.
Definition: upnpplib.hxx:98
LogLevel
libnpupnp (pupnp) logging: this is distinct from libupnpp logging
Definition: upnpplib.hxx:140
Control: subscription timeout in seconds.
Definition: upnpplib.hxx:113
Definition: base64.cxx:26
IP Port to use.
Definition: upnpplib.hxx:111
Our link to libupnp.
Definition: upnpplib.hxx:56
Names of the interfaces to use.
Definition: upnpplib.hxx:105
InitFlags
Configuration flags for the initialisation call.
Definition: upnpplib.hxx:88