Easy Port Forwarding and Managing Router with UPnP
Lo necesito en aplicación o en extension dll, primero intento usarlo como extensión DLL ya que es más util de esa forma, pero obtengo estos errores al compilar:
Citar
[Linker error] undefined reference to `UPNPNAT::init(int, int)'
[Linker error] undefined reference to `UPNPNAT::discovery()'
[Linker error] undefined reference to `UPNPNAT::add_port_mapping(char*, char*, unsigned short, unsigned short, char*)'
ld returned 1 exit status
C:\Users\...\Makefile.win [Build Error] [UPNP.dll] Error 1
[Linker error] undefined reference to `UPNPNAT::discovery()'
[Linker error] undefined reference to `UPNPNAT::add_port_mapping(char*, char*, unsigned short, unsigned short, char*)'
ld returned 1 exit status
C:\Users\...\Makefile.win [Build Error] [UPNP.dll] Error 1
Aqui el: dllmain.ccp
Código:
#include "dll.h"
#include <windows.h>
export double AddPortMap()
{
UPNPNAT nat;
nat.init(5,10);
if(!nat.discovery())
{
return 0;
}
if(!nat.add_port_mapping("NewPort", "192.168.1.65", 1234, 1234, "TCP"))
{
return 0;
}
return 1;
}
Aqui el: dll.h
Código:
#ifndef _DLL_H_
#define export extern "C" __declspec (dllexport)
#define _DLL_H_
#include <string>
#include <vector>
#pragma warning(disable: 4251)
#define DefaultTimeOut 10
#define DefaultInterval 200
class __declspec (dllexport) UPNPNAT
{
public:
bool init(int time_out=DefaultTimeOut,int interval=DefaultInterval); //init
bool discovery();//find router
/****
**** _description: port mapping name
**** _destination_ip: internal ip address
**** _port_ex:external: external listen port
**** _destination_port: internal port
**** _protocal: TCP or UDP
***/
bool add_port_mapping(
char * _description, char * _destination_ip, unsigned short int _port_ex,
unsigned short int _destination_port, char * _protocal);//add port mapping
const char * get_last_error(){ return last_error.c_str();}//get last error
private:
bool get_description(); //
bool parser_description(); //
bool tcp_connect(const char * _addr,unsigned short int _port);
bool parse_mapping_info();
int udp_socket_fd;
int tcp_socket_fd;
typedef enum
{
NAT_INIT=0,
NAT_FOUND,
NAT_TCP_CONNECTED,
NAT_GETDESCRIPTION,
NAT_GETCONTROL,
NAT_ADD,
NAT_DEL,
NAT_GET,
NAT_ERROR
} NAT_STAT;
NAT_STAT status;
int time_out;
int interval;
std::string service_type;
std::string describe_url;
std::string control_url;
std::string base_url;
std::string service_describe_url;
std::string description_info;
std::string last_error;
std::string mapping_info;
};
#endif /* _DLL_H_ */
¿Algún consejo que me puedan dar?