1
0
Fork 0
mirror of https://bitbucket.org/King_DuckZ/keepupnpup.git synced 2024-11-07 21:29:00 +00:00

Add verbosity in debug.

This commit is contained in:
King_DuckZ 2016-08-26 02:37:15 +02:00
parent 1d35e84cb4
commit e2ff673710

View file

@ -35,6 +35,20 @@
namespace kuu { namespace kuu {
namespace { namespace {
void freeUPNPDevlist (struct UPNPDev* parDele) {
#if defined(KUU_VERBOSE)
std::cout << "Deleting UPNPDev " << parDele << '\n';
#endif
::freeUPNPDevlist(parDele);
}
void FreeUPNPUrls (struct UPNPUrls* parDele) {
#if defined(KUU_VERBOSE)
std::cout << "Deleting UPNPUrls " << parDele << '\n';
#endif
::FreeUPNPUrls(parDele);
}
struct UPNPUrlsWithInitFlag { struct UPNPUrlsWithInitFlag {
UPNPUrlsWithInitFlag() : initialized(false) {} UPNPUrlsWithInitFlag() : initialized(false) {}
struct UPNPUrls urls; struct UPNPUrls urls;
@ -50,7 +64,7 @@ namespace kuu {
void operator() (UPNPUrlsWithInitFlag& parUrls) { void operator() (UPNPUrlsWithInitFlag& parUrls) {
if (parUrls.initialized) { if (parUrls.initialized) {
parUrls.initialized = false; parUrls.initialized = false;
FreeUPNPUrls(&parUrls.urls); kuu::FreeUPNPUrls(&parUrls.urls);
} }
} }
}; };
@ -112,7 +126,6 @@ namespace kuu {
std::cout << "External ip address: " << parExternalAddr << '\n'; std::cout << "External ip address: " << parExternalAddr << '\n';
} }
#endif #endif
} //unnamed namespace } //unnamed namespace
struct UPNP::LocalData { struct UPNP::LocalData {
@ -121,10 +134,16 @@ namespace kuu {
lanaddr(), lanaddr(),
externaladdr(), externaladdr(),
igd_reply(IGDNone), igd_reply(IGDNone),
devlist(nullptr, &freeUPNPDevlist) devlist(nullptr, &kuu::freeUPNPDevlist)
{ {
} }
~LocalData() noexcept {
#if defined(KUU_VERBOSE)
std::cout << "Destroying LocalData " << this << '\n';
#endif
}
std::string lanaddr; std::string lanaddr;
std::string externaladdr; std::string externaladdr;
struct IGDdatas data; struct IGDdatas data;
@ -147,7 +166,7 @@ namespace kuu {
2, //ttl 2, //ttl
&error &error
), ),
&freeUPNPDevlist &kuu::freeUPNPDevlist
); );
if (error) if (error)
throw UPNPException(error, "Error initializing upnpc in upnpDiscover()", nullptr); throw UPNPException(error, "Error initializing upnpc in upnpDiscover()", nullptr);