2015-01-03 23:38:48 +03: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-10 00:15:47 +04:00
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
|
2015-01-03 23:38:48 +03:00
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
#define I2P_UPNP_TCP 1
|
|
|
|
#define I2P_UPNP_UDP 2
|
|
|
|
|
2014-02-10 00:15:47 +04:00
|
|
|
namespace i2p
|
|
|
|
{
|
2015-05-06 19:19:20 +03:00
|
|
|
namespace transport
|
2015-01-03 23:38:48 +03:00
|
|
|
{
|
2014-02-10 00:15:47 +04:00
|
|
|
class UPnP
|
|
|
|
{
|
2015-01-03 23:38:48 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
UPnP ();
|
|
|
|
~UPnP ();
|
|
|
|
void Close ();
|
|
|
|
|
|
|
|
void Start ();
|
|
|
|
void Stop ();
|
|
|
|
|
|
|
|
void Discover ();
|
2015-05-06 19:19:20 +03:00
|
|
|
void TryPortMapping (int type, int port);
|
|
|
|
void CloseMapping (int type, int port);
|
2015-01-03 23:38:48 +03: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-04 02:06:43 +03:00
|
|
|
#ifndef _WIN32
|
2015-01-03 23:38:48 +03:00
|
|
|
void *m_Module;
|
2015-01-04 02:06:43 +03:00
|
|
|
#else
|
2015-06-06 21:53:22 +03:00
|
|
|
HINSTANCE m_Module;
|
2015-01-04 02:06:43 +03:00
|
|
|
#endif
|
2015-01-03 23:38:48 +03:00
|
|
|
};
|
2014-02-10 00:15:47 +04:00
|
|
|
}
|
2015-01-03 23:38:48 +03:00
|
|
|
}
|
|
|
|
|
2016-03-24 03:00:00 +03:00
|
|
|
#endif // USE_UPNP
|
|
|
|
#endif // __UPNP_H__
|