I'm currently working with P2P Network over the Internet using C/C++ and Winsock2. With that, I want to do port forwarding with the router using UPNP (I know some router does not have UPNP, I just need to do this with this technology).
I want to make a simple class namely "NATUPNP" to do all NAT Traversal using UPNP. I already made this class but it caused a lot of bugs since I'm not really into network programming sorry (simple knowledge only). If someone know how to do this I would really appreciate your effort. Below is my class with the functions/methods that I would like to be there and working. Thanks in advance.
#include <Winsock2.h>
#include <Ws2tcpip.h>
class NATUPNP
{
public:
string getPublicIP(); //return the Public IP Address of the Network
bool isUPNPEnabled(); //return true if router can do UPNP NAT Traversal, if not return false
bool isPortForwarded(int port); //return true if port is forwarded by the router, if not return false
bool addPortForward(int externalPort, int internalPort, string ipAddress); //ask router to forward this port to this local ipAddress
bool removePortForward(int externalPort, int internalPort, string ipAddress); //ask router to remove port forward to this local ipAddress
};