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-01-03 20:38:48 +00:00
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
#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
|
|
|
{
|
2014-02-09 20:15:47 +00:00
|
|
|
class UPnP
|
|
|
|
{
|
2015-01-03 20:38:48 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
UPnP ();
|
|
|
|
~UPnP ();
|
|
|
|
void Close ();
|
|
|
|
|
|
|
|
void Start ();
|
|
|
|
void Stop ();
|
|
|
|
|
|
|
|
void Discover ();
|
2015-05-06 16:19:20 +00:00
|
|
|
void TryPortMapping (int type, int port);
|
|
|
|
void CloseMapping (int type, int port);
|
2015-01-03 20:38:48 +00:00
|
|
|
private:
|
|
|
|
void Run ();
|
|
|
|
|
|
|
|
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-01-03 20:38:48 +00:00
|
|
|
};
|
2014-02-09 20:15:47 +00:00
|
|
|
}
|
2015-01-03 20:38:48 +00:00
|
|
|
}
|
|
|
|
|
2016-03-24 00:00:00 +00:00
|
|
|
#endif // USE_UPNP
|
|
|
|
#endif // __UPNP_H__
|