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-01-03 20:38:48 +00:00
|
|
|
namespace UPnP
|
|
|
|
{
|
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 ();
|
|
|
|
void TryPortMapping (int type);
|
|
|
|
void CloseMapping (int type);
|
|
|
|
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;
|
|
|
|
std::string m_Port = std::to_string (util::config::GetArg ("-port", 17070));
|
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
|
|
|
|
HINSTANCE *m_Module;
|
|
|
|
#endif
|
2015-01-03 20:38:48 +00:00
|
|
|
};
|
|
|
|
extern UPnP upnpc;
|
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
|