2015-01-03 20:38:48 +00:00
|
|
|
#ifndef __UPNP_H__
|
|
|
|
#define __UPNP_H__
|
|
|
|
|
|
|
|
#ifdef USE_UPNP
|
|
|
|
#include <string>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
#include <miniupnpc/miniwget.h>
|
|
|
|
#include <miniupnpc/miniupnpc.h>
|
|
|
|
#include <miniupnpc/upnpcommands.h>
|
|
|
|
#include <miniupnpc/upnperrors.h>
|
2014-02-09 20:15:47 +00:00
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
|
2015-07-28 16:37:06 +00:00
|
|
|
#include "util/util.h"
|
2015-01-03 20:38:48 +00:00
|
|
|
|
|
|
|
#define I2P_UPNP_TCP 1
|
|
|
|
#define I2P_UPNP_UDP 2
|
|
|
|
|
2014-02-09 20:15:47 +00:00
|
|
|
namespace i2p
|
|
|
|
{
|
2015-05-06 16:19:20 +00:00
|
|
|
namespace transport
|
2015-01-03 20:38:48 +00:00
|
|
|
{
|
2015-07-16 21:29:52 +00:00
|
|
|
class UPnP
|
|
|
|
{
|
|
|
|
public:
|
2015-01-03 20:38:48 +00:00
|
|
|
|
2015-07-16 21:29:52 +00:00
|
|
|
UPnP ();
|
|
|
|
~UPnP ();
|
2015-01-03 20:38:48 +00:00
|
|
|
void Close ();
|
|
|
|
|
|
|
|
void Start ();
|
|
|
|
void Stop ();
|
|
|
|
|
2015-07-16 21:29:52 +00:00
|
|
|
void Discover ();
|
|
|
|
void TryPortMapping (int type, int port);
|
|
|
|
void CloseMapping (int type, int port);
|
|
|
|
private:
|
|
|
|
void Run ();
|
2015-01-03 20:38:48 +00:00
|
|
|
|
|
|
|
std::thread * m_Thread;
|
|
|
|
struct UPNPUrls m_upnpUrls;
|
|
|
|
struct IGDdatas m_upnpData;
|
|
|
|
|
|
|
|
// For miniupnpc
|
|
|
|
char * m_MulticastIf = 0;
|
|
|
|
char * m_Minissdpdpath = 0;
|
|
|
|
struct UPNPDev * m_Devlist = 0;
|
|
|
|
char m_NetworkAddr[64];
|
|
|
|
char m_externalIPAddress[40];
|
|
|
|
bool m_IsModuleLoaded;
|
2015-01-03 23:06:43 +00:00
|
|
|
#ifndef _WIN32
|
2015-01-03 20:38:48 +00:00
|
|
|
void *m_Module;
|
2015-01-03 23:06:43 +00:00
|
|
|
#else
|
2015-06-06 18:53:22 +00:00
|
|
|
HINSTANCE m_Module;
|
2015-01-03 23:06:43 +00:00
|
|
|
#endif
|
2015-07-16 21:29:52 +00:00
|
|
|
};
|
2014-02-09 20:15:47 +00:00
|
|
|
}
|
2015-01-03 20:38:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2014-02-09 20:15:47 +00:00
|
|
|
|
|
|
|
#endif
|