refactor and cleanup
Change-Id: Ia59c83978c26cebe060a301ec37bacd805d36ef5
diff --git a/src/upnp/protocol/pupnp/pupnp.cpp b/src/upnp/protocol/pupnp/pupnp.cpp
index cc63347..6ea5563 100644
--- a/src/upnp/protocol/pupnp/pupnp.cpp
+++ b/src/upnp/protocol/pupnp/pupnp.cpp
@@ -92,9 +92,9 @@
auto errorCode = getFirstDocItem(doc, "errorCode");
if (not errorCode.empty()) {
auto errorDescription = getFirstDocItem(doc, "errorDescription");
- JAMI_WARNING("PUPnP: Response contains error: {:s}: {:s}",
- errorCode,
- errorDescription);
+ // JAMI_WARNING("PUPnP: Response contains error: {:s}: {:s}",
+ // errorCode,
+ // errorDescription);
return true;
}
return false;
@@ -104,16 +104,16 @@
PUPnP::PUPnP()
{
- JAMI_DBG("PUPnP: Creating instance [%p] ...", this);
+ // JAMI_DBG("PUPnP: Creating instance [%p] ...", this);
runOnPUPnPQueue([this] {
threadId_ = getCurrentThread();
- JAMI_DBG("PUPnP: Instance [%p] created", this);
+ // JAMI_DBG("PUPnP: Instance [%p] created", this);
});
}
PUPnP::~PUPnP()
{
- JAMI_DBG("PUPnP: Instance [%p] destroyed", this);
+ // JAMI_DBG("PUPnP: Instance [%p] destroyed", this);
}
void
@@ -124,7 +124,7 @@
int upnp_err = UpnpInit2(nullptr, 0);
if (upnp_err != UPNP_E_SUCCESS) {
- JAMI_ERR("PUPnP: Can't initialize libupnp: %s", UpnpGetErrorMessage(upnp_err));
+ // JAMI_ERR("PUPnP: Can't initialize libupnp: %s", UpnpGetErrorMessage(upnp_err));
UpnpFinish();
initialized_ = false;
return;
@@ -132,12 +132,12 @@
// Disable embedded WebServer if any.
if (UpnpIsWebserverEnabled() == 1) {
- JAMI_WARN("PUPnP: Web-server is enabled. Disabling");
+ // JAMI_WARN("PUPnP: Web-server is enabled. Disabling");
UpnpEnableWebserver(0);
if (UpnpIsWebserverEnabled() == 1) {
- JAMI_ERR("PUPnP: Could not disable Web-server!");
+ // JAMI_ERR("PUPnP: Could not disable Web-server!");
} else {
- JAMI_DBG("PUPnP: Web-server successfully disabled");
+ // JAMI_DBG("PUPnP: Web-server successfully disabled");
}
}
@@ -150,9 +150,9 @@
port6 = UpnpGetServerPort6();
#endif
if (ip_address6 and port6)
- JAMI_DBG("PUPnP: Initialized on %s:%u | %s:%u", ip_address, port, ip_address6, port6);
+ // JAMI_DBG("PUPnP: Initialized on %s:%u | %s:%u", ip_address, port, ip_address6, port6);
else
- JAMI_DBG("PUPnP: Initialized on %s:%u", ip_address, port);
+ // JAMI_DBG("PUPnP: Initialized on %s:%u", ip_address, port);
// Relax the parser to allow malformed XML text.
ixmlRelaxParser(1);
@@ -177,9 +177,9 @@
// Register Upnp control point.
int upnp_err = UpnpRegisterClient(ctrlPtCallback, this, &ctrlptHandle_);
if (upnp_err != UPNP_E_SUCCESS) {
- JAMI_ERR("PUPnP: Can't register client: %s", UpnpGetErrorMessage(upnp_err));
+ // JAMI_ERR("PUPnP: Can't register client: %s", UpnpGetErrorMessage(upnp_err));
} else {
- JAMI_DBG("PUPnP: Successfully registered client");
+ // JAMI_DBG("PUPnP: Successfully registered client");
clientRegistered_ = true;
}
}
@@ -196,7 +196,7 @@
return;
}
- JAMI_DBG("PUPnP: Setting observer to %p", obs);
+ // JAMI_DBG("PUPnP: Setting observer to %p", obs);
observer_ = obs;
}
@@ -211,7 +211,7 @@
void
PUPnP::terminate(std::condition_variable& cv)
{
- JAMI_DBG("PUPnP: Terminate instance %p", this);
+ // JAMI_DBG("PUPnP: Terminate instance %p", this);
clientRegistered_ = false;
observer_ = nullptr;
@@ -220,7 +220,7 @@
if (initialized_) {
if (UpnpFinish() != UPNP_E_SUCCESS) {
- JAMI_ERR("PUPnP: Failed to properly close lib-upnp");
+ // JAMI_ERR("PUPnP: Failed to properly close lib-upnp");
}
initialized_ = false;
@@ -250,9 +250,9 @@
});
if (cv.wait_for(lk, std::chrono::seconds(10), [this] { return shutdownComplete_; })) {
- JAMI_DBG("PUPnP: Shutdown completed");
+ // JAMI_DBG("PUPnP: Shutdown completed");
} else {
- JAMI_ERR("PUPnP: Shutdown timed-out");
+ // JAMI_ERR("PUPnP: Shutdown timed-out");
// Force stop if the shutdown take too much time.
shutdownComplete_ = true;
}
@@ -263,37 +263,37 @@
{
CHECK_VALID_THREAD();
- JAMI_DBG("PUPnP: Send IGD search request");
+ // JAMI_DBG("PUPnP: Send IGD search request");
// Send out search for multiple types of devices, as some routers may possibly
// only reply to one.
auto err = UpnpSearchAsync(ctrlptHandle_, SEARCH_TIMEOUT, UPNP_ROOT_DEVICE, this);
if (err != UPNP_E_SUCCESS) {
- JAMI_WARN("PUPnP: Send search for UPNP_ROOT_DEVICE failed. Error %d: %s",
- err,
- UpnpGetErrorMessage(err));
+ // JAMI_WARN("PUPnP: Send search for UPNP_ROOT_DEVICE failed. Error %d: %s",
+ // err,
+ // UpnpGetErrorMessage(err));
}
err = UpnpSearchAsync(ctrlptHandle_, SEARCH_TIMEOUT, UPNP_IGD_DEVICE, this);
if (err != UPNP_E_SUCCESS) {
- JAMI_WARN("PUPnP: Send search for UPNP_IGD_DEVICE failed. Error %d: %s",
- err,
- UpnpGetErrorMessage(err));
+ // JAMI_WARN("PUPnP: Send search for UPNP_IGD_DEVICE failed. Error %d: %s",
+ // err,
+ // UpnpGetErrorMessage(err));
}
err = UpnpSearchAsync(ctrlptHandle_, SEARCH_TIMEOUT, UPNP_WANIP_SERVICE, this);
if (err != UPNP_E_SUCCESS) {
- JAMI_WARN("PUPnP: Send search for UPNP_WANIP_SERVICE failed. Error %d: %s",
- err,
- UpnpGetErrorMessage(err));
+ // JAMI_WARN("PUPnP: Send search for UPNP_WANIP_SERVICE failed. Error %d: %s",
+ // err,
+ // UpnpGetErrorMessage(err));
}
err = UpnpSearchAsync(ctrlptHandle_, SEARCH_TIMEOUT, UPNP_WANPPP_SERVICE, this);
if (err != UPNP_E_SUCCESS) {
- JAMI_WARN("PUPnP: Send search for UPNP_WANPPP_SERVICE failed. Error %d: %s",
- err,
- UpnpGetErrorMessage(err));
+ // JAMI_WARN("PUPnP: Send search for UPNP_WANPPP_SERVICE failed. Error %d: %s",
+ // err,
+ // UpnpGetErrorMessage(err));
}
}
@@ -309,7 +309,7 @@
return;
}
- JAMI_DBG("PUPnP: clearing IGDs and devices lists");
+ // JAMI_DBG("PUPnP: clearing IGDs and devices lists");
if (searchForIgdTimer_)
searchForIgdTimer_->cancel();
@@ -344,23 +344,23 @@
updateHostAddress();
if (isReady()) {
- JAMI_DBG("PUPnP: Already have a valid IGD. Skip the search request");
+ // JAMI_DBG("PUPnP: Already have a valid IGD. Skip the search request");
return;
}
if (igdSearchCounter_++ >= PUPNP_MAX_RESTART_SEARCH_RETRIES) {
- JAMI_WARN("PUPnP: Setup failed after %u trials. PUPnP will be disabled!",
- PUPNP_MAX_RESTART_SEARCH_RETRIES);
+ // JAMI_WARN("PUPnP: Setup failed after %u trials. PUPnP will be disabled!",
+ // PUPNP_MAX_RESTART_SEARCH_RETRIES);
return;
}
- JAMI_DBG("PUPnP: Start search for IGD: attempt %u", igdSearchCounter_);
+ // JAMI_DBG("PUPnP: Start search for IGD: attempt %u", igdSearchCounter_);
// Do not init if the host is not valid. Otherwise, the init will fail
// anyway and may put libupnp in an unstable state (mainly deadlocks)
// even if the UpnpFinish() method is called.
if (not hasValidHostAddress()) {
- JAMI_WARN("PUPnP: Host address is invalid. Skipping the IGD search");
+ // JAMI_WARN("PUPnP: Host address is invalid. Skipping the IGD search");
} else {
// Init and register if needed
if (not initialized_) {
@@ -374,7 +374,7 @@
assert(initialized_);
searchForDevices();
} else {
- JAMI_WARN("PUPnP: PUPNP not fully setup. Skipping the IGD search");
+ // JAMI_WARN("PUPnP: PUPNP not fully setup. Skipping the IGD search");
}
}
@@ -479,41 +479,41 @@
return false;
}
- JAMI_DBG("PUPnP: Validating the IGD candidate [UDN: %s]\n"
- " Name : %s\n"
- " Service Type : %s\n"
- " Service ID : %s\n"
- " Base URL : %s\n"
- " Location URL : %s\n"
- " control URL : %s\n"
- " Event URL : %s",
- igd_candidate->getUID().c_str(),
- igd_candidate->getFriendlyName().c_str(),
- igd_candidate->getServiceType().c_str(),
- igd_candidate->getServiceId().c_str(),
- igd_candidate->getBaseURL().c_str(),
- igd_candidate->getLocationURL().c_str(),
- igd_candidate->getControlURL().c_str(),
- igd_candidate->getEventSubURL().c_str());
+ // JAMI_DBG("PUPnP: Validating the IGD candidate [UDN: %s]\n"
+ // " Name : %s\n"
+ // " Service Type : %s\n"
+ // " Service ID : %s\n"
+ // " Base URL : %s\n"
+ // " Location URL : %s\n"
+ // " control URL : %s\n"
+ // " Event URL : %s",
+ // igd_candidate->getUID().c_str(),
+ // igd_candidate->getFriendlyName().c_str(),
+ // igd_candidate->getServiceType().c_str(),
+ // igd_candidate->getServiceId().c_str(),
+ // igd_candidate->getBaseURL().c_str(),
+ // igd_candidate->getLocationURL().c_str(),
+ // igd_candidate->getControlURL().c_str(),
+ // igd_candidate->getEventSubURL().c_str());
// Check if IGD is connected.
if (not actionIsIgdConnected(*igd_candidate)) {
- JAMI_WARN("PUPnP: IGD candidate %s is not connected", igd_candidate->getUID().c_str());
+ // JAMI_WARN("PUPnP: IGD candidate %s is not connected", igd_candidate->getUID().c_str());
return false;
}
// Validate external Ip.
igd_candidate->setPublicIp(actionGetExternalIP(*igd_candidate));
if (igd_candidate->getPublicIp().toString().empty()) {
- JAMI_WARN("PUPnP: IGD candidate %s has no valid external Ip",
- igd_candidate->getUID().c_str());
+ // JAMI_WARN("PUPnP: IGD candidate %s has no valid external Ip",
+ // igd_candidate->getUID().c_str());
return false;
}
// Validate internal Ip.
if (igd_candidate->getBaseURL().empty()) {
- JAMI_WARN("PUPnP: IGD candidate %s has no valid internal Ip",
- igd_candidate->getUID().c_str());
+ // JAMI_WARN("PUPnP: IGD candidate %s has no valid internal Ip",
+ // igd_candidate->getUID().c_str());
return false;
}
@@ -523,8 +523,8 @@
if (const auto& localGw = ip_utils::getLocalGateway()) {
igd_candidate->setLocalIp(localGw);
} else {
- JAMI_WARN("PUPnP: Could not set internal address for IGD candidate %s",
- igd_candidate->getUID().c_str());
+ // JAMI_WARN("PUPnP: Could not set internal address for IGD candidate %s",
+ // igd_candidate->getUID().c_str());
return false;
}
@@ -538,11 +538,11 @@
// Must not be a null pointer
assert(igd.get() != nullptr);
if (*igd == *igd_candidate) {
- JAMI_DBG("PUPnP: Device [%s] with int/ext addresses [%s:%s] is already in the list "
- "of valid IGDs",
- igd_candidate->getUID().c_str(),
- igd_candidate->toString().c_str(),
- igd_candidate->getPublicIp().toString().c_str());
+ // JAMI_DBG("PUPnP: Device [%s] with int/ext addresses [%s:%s] is already in the list "
+ // "of valid IGDs",
+ // igd_candidate->getUID().c_str(),
+ // igd_candidate->toString().c_str(),
+ // igd_candidate->getPublicIp().toString().c_str());
return true;
}
}
@@ -551,12 +551,12 @@
// We have a valid IGD
igd_candidate->setValid(true);
- JAMI_DBG("PUPnP: Added a new IGD [%s] to the list of valid IGDs",
- igd_candidate->getUID().c_str());
+ // JAMI_DBG("PUPnP: Added a new IGD [%s] to the list of valid IGDs",
+ // igd_candidate->getUID().c_str());
- JAMI_DBG("PUPnP: New IGD addresses [int: %s - ext: %s]",
- igd_candidate->toString().c_str(),
- igd_candidate->getPublicIp().toString().c_str());
+ // JAMI_DBG("PUPnP: New IGD addresses [int: %s - ext: %s]",
+ // igd_candidate->toString().c_str(),
+ // igd_candidate->getPublicIp().toString().c_str());
// Subscribe to IGD events.
int upnp_err = UpnpSubscribeAsync(ctrlptHandle_,
@@ -565,13 +565,13 @@
subEventCallback,
this);
if (upnp_err != UPNP_E_SUCCESS) {
- JAMI_WARN("PUPnP: Failed to send subscribe request to %s: error %i - %s",
- igd_candidate->getUID().c_str(),
- upnp_err,
- UpnpGetErrorMessage(upnp_err));
+ // JAMI_WARN("PUPnP: Failed to send subscribe request to %s: error %i - %s",
+ // igd_candidate->getUID().c_str(),
+ // upnp_err,
+ // UpnpGetErrorMessage(upnp_err));
// return false;
} else {
- JAMI_DBG("PUPnP: Successfully subscribed to IGD %s", igd_candidate->getUID().c_str());
+ // JAMI_DBG("PUPnP: Successfully subscribed to IGD %s", igd_candidate->getUID().c_str());
}
{
@@ -647,7 +647,7 @@
});
if (iter == validIgdList_.end()) {
- JAMI_WARN("PUPnP: Did not find the IGD matching ctrl URL [%s]", ctrlURL.c_str());
+ // JAMI_WARN("PUPnP: Did not find the IGD matching ctrl URL [%s]", ctrlURL.c_str());
return {};
}
@@ -680,7 +680,7 @@
runOnUpnpContextQueue([w = weak(), map] {
if (auto upnpThis = w.lock()) {
- JAMI_DBG("PUPnP: Failed to request mapping %s", map.toString().c_str());
+ // JAMI_DBG("PUPnP: Failed to request mapping %s", map.toString().c_str());
if (upnpThis->observer_)
upnpThis->observer_->onMappingRequestFailed(map);
}
@@ -696,7 +696,7 @@
return;
runOnUpnpContextQueue([map, obs = observer_] {
- JAMI_DBG("PUPnP: Closed mapping %s", map.toString().c_str());
+ // JAMI_DBG("PUPnP: Closed mapping %s", map.toString().c_str());
obs->onMappingRemoved(map.getIgd(), std::move(map));
});
}
@@ -746,7 +746,7 @@
auto pupnp = static_cast<PUPnP*>(user_data);
if (pupnp == nullptr) {
- JAMI_WARN("PUPnP: Control point callback without PUPnP");
+ // JAMI_WARN("PUPnP: Control point callback without PUPnP");
return UPNP_E_SUCCESS;
}
@@ -794,7 +794,7 @@
// The host address must be valid to proceed.
if (not hasValidHostAddress()) {
- JAMI_WARN("PUPnP: Local address is invalid. Ignore search result for now!");
+ // JAMI_WARN("PUPnP: Local address is invalid. Ignore search result for now!");
return;
}
@@ -808,7 +808,7 @@
return;
}
- JAMI_DBG("PUPnP: Discovered a new IGD [%s]", igdId.c_str());
+ // JAMI_DBG("PUPnP: Discovered a new IGD [%s]", igdId.c_str());
// NOTE: here, we check if the location given is related to the source address.
// If it's not the case, it's certainly a router plugged in the network, but not
@@ -818,9 +818,9 @@
// Only check the IP address (ignore the port number).
dht::http::Url url(igdLocationUrl);
if (IpAddr(url.host).toString(false) != dstAddr.toString(false)) {
- JAMI_DBG("PUPnP: Returned location %s does not match the source address %s",
- IpAddr(url.host).toString(true, true).c_str(),
- dstAddr.toString(true, true).c_str());
+ // JAMI_DBG("PUPnP: Returned location %s does not match the source address %s",
+ // IpAddr(url.host).toString(true, true).c_str(),
+ // dstAddr.toString(true, true).c_str());
return;
}
@@ -840,11 +840,11 @@
int upnp_err = UpnpDownloadXmlDoc(locationUrl.c_str(), &doc_container_ptr);
if (upnp_err != UPNP_E_SUCCESS or not doc_container_ptr) {
- JAMI_WARN("PUPnP: Error downloading device XML document from %s -> %s",
- locationUrl.c_str(),
- UpnpGetErrorMessage(upnp_err));
+ // JAMI_WARN("PUPnP: Error downloading device XML document from %s -> %s",
+ // locationUrl.c_str(),
+ // UpnpGetErrorMessage(upnp_err));
} else {
- JAMI_DBG("PUPnP: Succeeded to download device XML document from %s", locationUrl.c_str());
+ // JAMI_DBG("PUPnP: Succeeded to download device XML document from %s", locationUrl.c_str());
runOnPUPnPQueue([w = weak(), url = locationUrl, doc_container_ptr] {
if (auto upnpThis = w.lock()) {
upnpThis->validateIgd(url, doc_container_ptr);
@@ -866,10 +866,10 @@
for (auto it = validIgdList_.begin(); it != validIgdList_.end();) {
if ((*it)->getUID() == cpDeviceId) {
igd = *it;
- JAMI_DBG("PUPnP: Received [%s] for IGD [%s] %s. Will be removed.",
- PUPnP::eventTypeToString(UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE),
- igd->getUID().c_str(),
- igd->toString().c_str());
+ // JAMI_DBG("PUPnP: Received [%s] for IGD [%s] %s. Will be removed.",
+ // PUPnP::eventTypeToString(UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE),
+ // igd->getUID().c_str(),
+ // igd->toString().c_str());
igd->setValid(false);
// Remove the IGD.
it = validIgdList_.erase(it);
@@ -895,10 +895,10 @@
for (auto& it : validIgdList_) {
if (auto igd = std::dynamic_pointer_cast<UPnPIGD>(it)) {
if (igd->getEventSubURL() == eventSubUrl) {
- JAMI_DBG("PUPnP: Received [%s] event for IGD [%s] %s. Request a new subscribe.",
- PUPnP::eventTypeToString(event_type),
- igd->getUID().c_str(),
- igd->toString().c_str());
+ // JAMI_DBG("PUPnP: Received [%s] event for IGD [%s] %s. Request a new subscribe.",
+ // PUPnP::eventTypeToString(event_type),
+ // igd->getUID().c_str(),
+ // igd->toString().c_str());
UpnpSubscribeAsync(ctrlptHandle_,
eventSubUrl.c_str(),
UPNP_INFINITE,
@@ -923,8 +923,8 @@
// First check the error code.
auto upnp_status = UpnpDiscovery_get_ErrCode(d_event);
if (upnp_status != UPNP_E_SUCCESS) {
- JAMI_ERR("PUPnP: UPNP discovery is in erroneous state: %s",
- UpnpGetErrorMessage(upnp_status));
+ // JAMI_ERR("PUPnP: UPNP discovery is in erroneous state: %s",
+ // UpnpGetErrorMessage(upnp_status));
break;
}
@@ -969,10 +969,10 @@
case UPNP_EVENT_AUTORENEWAL_FAILED:
case UPNP_EVENT_SUBSCRIPTION_EXPIRED: // This event will occur only if autorenewal is disabled.
{
- JAMI_WARN("PUPnP: Received Subscription Event %s", eventTypeToString(event_type));
+ // JAMI_WARN("PUPnP: Received Subscription Event %s", eventTypeToString(event_type));
const UpnpEventSubscribe* es_event = (const UpnpEventSubscribe*) event;
if (es_event == nullptr) {
- JAMI_WARN("PUPnP: Received Subscription Event with null pointer");
+ // JAMI_WARN("PUPnP: Received Subscription Event with null pointer");
break;
}
std::string publisherUrl(UpnpEventSubscribe_get_PublisherUrl_cstr(es_event));
@@ -989,7 +989,7 @@
case UPNP_EVENT_UNSUBSCRIBE_COMPLETE: {
UpnpEventSubscribe* es_event = (UpnpEventSubscribe*) event;
if (es_event == nullptr) {
- JAMI_WARN("PUPnP: Received Subscription Event with null pointer");
+ // JAMI_WARN("PUPnP: Received Subscription Event with null pointer");
} else {
UpnpEventSubscribe_delete(es_event);
}
@@ -998,18 +998,18 @@
case UPNP_CONTROL_ACTION_COMPLETE: {
const UpnpActionComplete* a_event = (const UpnpActionComplete*) event;
if (a_event == nullptr) {
- JAMI_WARN("PUPnP: Received Action Complete Event with null pointer");
+ // JAMI_WARN("PUPnP: Received Action Complete Event with null pointer");
break;
}
auto res = UpnpActionComplete_get_ErrCode(a_event);
if (res != UPNP_E_SUCCESS and res != UPNP_E_TIMEDOUT) {
auto err = UpnpActionComplete_get_ErrCode(a_event);
- JAMI_WARN("PUPnP: Received Action Complete error %i %s", err, UpnpGetErrorMessage(err));
+ // JAMI_WARN("PUPnP: Received Action Complete error %i %s", err, UpnpGetErrorMessage(err));
} else {
auto actionRequest = UpnpActionComplete_get_ActionRequest(a_event);
// Abort if there is no action to process.
if (actionRequest == nullptr) {
- JAMI_WARN("PUPnP: Can't get the Action Request data from the event");
+ // JAMI_WARN("PUPnP: Can't get the Action Request data from the event");
break;
}
@@ -1017,13 +1017,13 @@
if (actionResult != nullptr) {
ixmlDocument_free(actionResult);
} else {
- JAMI_WARN("PUPnP: Action Result document not found");
+ // JAMI_WARN("PUPnP: Action Result document not found");
}
}
break;
}
default: {
- JAMI_WARN("PUPnP: Unhandled Control Point event");
+ // JAMI_WARN("PUPnP: Unhandled Control Point event");
break;
}
}
@@ -1036,7 +1036,7 @@
{
if (auto pupnp = static_cast<PUPnP*>(user_data))
return pupnp->handleSubscriptionUPnPEvent(event_type, event);
- JAMI_WARN("PUPnP: Subscription callback without service Id string");
+ // JAMI_WARN("PUPnP: Subscription callback without service Id string");
return 0;
}
@@ -1046,15 +1046,15 @@
UpnpEventSubscribe* es_event = static_cast<UpnpEventSubscribe*>(const_cast<void*>(event));
if (es_event == nullptr) {
- JAMI_ERR("PUPnP: Unexpected null pointer!");
+ // JAMI_ERR("PUPnP: Unexpected null pointer!");
return UPNP_E_INVALID_ARGUMENT;
}
std::string publisherUrl(UpnpEventSubscribe_get_PublisherUrl_cstr(es_event));
int upnp_err = UpnpEventSubscribe_get_ErrCode(es_event);
if (upnp_err != UPNP_E_SUCCESS) {
- JAMI_WARN("PUPnP: Subscription error %s from %s",
- UpnpGetErrorMessage(upnp_err),
- publisherUrl.c_str());
+ // JAMI_WARN("PUPnP: Subscription error %s from %s",
+ // UpnpGetErrorMessage(upnp_err),
+ // publisherUrl.c_str());
return upnp_err;
}
@@ -1070,7 +1070,7 @@
// Check the UDN to see if its already in our device list.
std::string UDN(getFirstDocItem(doc, "UDN"));
if (UDN.empty()) {
- JAMI_WARN("PUPnP: could not find UDN in description document of device");
+ // JAMI_WARN("PUPnP: could not find UDN in description document of device");
return nullptr;
} else {
std::lock_guard<std::mutex> lk(pupnpMutex_);
@@ -1082,7 +1082,7 @@
}
}
- JAMI_DBG("PUPnP: Found new device [%s]", UDN.c_str());
+ // JAMI_DBG("PUPnP: Found new device [%s]", UDN.c_str());
std::unique_ptr<UPnPIGD> new_igd;
int upnp_err;
@@ -1146,15 +1146,15 @@
if (upnp_err == UPNP_E_SUCCESS)
controlURL = absolute_control_url;
else
- JAMI_WARN("PUPnP: Error resolving absolute controlURL -> %s",
- UpnpGetErrorMessage(upnp_err));
+ // JAMI_WARN("PUPnP: Error resolving absolute controlURL -> %s",
+ // UpnpGetErrorMessage(upnp_err));
std::free(absolute_control_url);
// Get the relative eventSubURL and turn it into absolute address using the URLBase.
std::string eventSubURL(getFirstElementItem(service_element, "eventSubURL"));
if (eventSubURL.empty()) {
- JAMI_WARN("PUPnP: IGD event sub URL is empty. Going to next node");
+ // JAMI_WARN("PUPnP: IGD event sub URL is empty. Going to next node");
continue;
}
@@ -1163,8 +1163,8 @@
if (upnp_err == UPNP_E_SUCCESS)
eventSubURL = absolute_event_sub_url;
else
- JAMI_WARN("PUPnP: Error resolving absolute eventSubURL -> %s",
- UpnpGetErrorMessage(upnp_err));
+ // JAMI_WARN("PUPnP: Error resolving absolute eventSubURL -> %s",
+ // UpnpGetErrorMessage(upnp_err));
std::free(absolute_event_sub_url);
@@ -1195,7 +1195,7 @@
0,
nullptr);
if (not action_container_ptr) {
- JAMI_WARN("PUPnP: Failed to make GetStatusInfo action");
+ // JAMI_WARN("PUPnP: Failed to make GetStatusInfo action");
return false;
}
XMLDocument action(action_container_ptr, ixmlDocument_free); // Action pointer.
@@ -1208,16 +1208,16 @@
action.get(),
&response_container_ptr);
if (not response_container_ptr or upnp_err != UPNP_E_SUCCESS) {
- JAMI_WARN("PUPnP: Failed to send GetStatusInfo action -> %s", UpnpGetErrorMessage(upnp_err));
+ // JAMI_WARN("PUPnP: Failed to send GetStatusInfo action -> %s", UpnpGetErrorMessage(upnp_err));
return false;
}
XMLDocument response(response_container_ptr, ixmlDocument_free);
if (errorOnResponse(response.get())) {
- JAMI_WARN("PUPnP: Failed to get GetStatusInfo from %s -> %d: %s",
- igd.getServiceType().c_str(),
- upnp_err,
- UpnpGetErrorMessage(upnp_err));
+ // JAMI_WARN("PUPnP: Failed to get GetStatusInfo from %s -> %d: %s",
+ // igd.getServiceType().c_str(),
+ // upnp_err,
+ // UpnpGetErrorMessage(upnp_err));
return false;
}
@@ -1246,7 +1246,7 @@
action.reset(action_container_ptr);
if (not action) {
- JAMI_WARN("PUPnP: Failed to make GetExternalIPAddress action");
+ // JAMI_WARN("PUPnP: Failed to make GetExternalIPAddress action");
return {};
}
@@ -1260,16 +1260,16 @@
response.reset(response_container_ptr);
if (not response or upnp_err != UPNP_E_SUCCESS) {
- JAMI_WARN("PUPnP: Failed to send GetExternalIPAddress action -> %s",
- UpnpGetErrorMessage(upnp_err));
+ // JAMI_WARN("PUPnP: Failed to send GetExternalIPAddress action -> %s",
+ // UpnpGetErrorMessage(upnp_err));
return {};
}
if (errorOnResponse(response.get())) {
- JAMI_WARN("PUPnP: Failed to get GetExternalIPAddress from %s -> %d: %s",
- igd.getServiceType().c_str(),
- upnp_err,
- UpnpGetErrorMessage(upnp_err));
+ // JAMI_WARN("PUPnP: Failed to get GetExternalIPAddress from %s -> %d: %s",
+ // igd.getServiceType().c_str(),
+ // upnp_err,
+ // UpnpGetErrorMessage(upnp_err));
return {};
}
@@ -1307,7 +1307,7 @@
action.reset(action_container_ptr);
if (not action) {
- JAMI_WARN("PUPnP: Failed to add NewPortMappingIndex action");
+ // JAMI_WARN("PUPnP: Failed to add NewPortMappingIndex action");
break;
}
@@ -1325,7 +1325,7 @@
}
if (upnp_err != UPNP_E_SUCCESS) {
- JAMI_ERR("PUPnP: GetGenericPortMappingEntry returned with error: %i", upnp_err);
+ // JAMI_ERR("PUPnP: GetGenericPortMappingEntry returned with error: %i", upnp_err);
break;
}
@@ -1335,7 +1335,7 @@
auto error = to_int<int>(errorCode);
if (error == ARRAY_IDX_INVALID or error == CONFLICT_IN_MAPPING) {
// No more port mapping entries in the response.
- JAMI_DBG("PUPnP: No more mappings (found a total of %i mappings", entry_idx);
+ // JAMI_DBG("PUPnP: No more mappings (found a total of %i mappings", entry_idx);
break;
} else {
auto errorDescription = getFirstDocItem(response.get(), "errorDescription");
@@ -1363,8 +1363,8 @@
std::string transport(getFirstDocItem(response.get(), "NewProtocol"));
if (port_internal.empty() || port_external.empty() || transport.empty()) {
- JAMI_ERR("PUPnP: GetGenericPortMappingEntry returned an invalid entry at index %i",
- entry_idx);
+ // JAMI_ERR("PUPnP: GetGenericPortMappingEntry returned an invalid entry at index %i",
+ // entry_idx);
continue;
}
@@ -1392,9 +1392,9 @@
if (not(clientRegistered_ and igd->getLocalIp()))
return;
- JAMI_DBG("PUPnP: Remove all mappings (if any) on IGD %s matching descr prefix %s",
- igd->toString().c_str(),
- Mapping::UPNP_MAPPING_DESCRIPTION_PREFIX);
+ // JAMI_DBG("PUPnP: Remove all mappings (if any) on IGD %s matching descr prefix %s",
+ // igd->toString().c_str(),
+ // Mapping::UPNP_MAPPING_DESCRIPTION_PREFIX);
auto mapList = getMappingsListByDescr(igd, description);
@@ -1482,13 +1482,13 @@
bool success = true;
if (upnp_err != UPNP_E_SUCCESS) {
- JAMI_WARN("PUPnP: Failed to send action %s for mapping %s. %d: %s",
- ACTION_ADD_PORT_MAPPING,
- mapping.toString().c_str(),
- upnp_err,
- UpnpGetErrorMessage(upnp_err));
- JAMI_WARN("PUPnP: IGD ctrlUrl %s", igd->getControlURL().c_str());
- JAMI_WARN("PUPnP: IGD service type %s", igd->getServiceType().c_str());
+ // JAMI_WARN("PUPnP: Failed to send action %s for mapping %s. %d: %s",
+ // ACTION_ADD_PORT_MAPPING,
+ // mapping.toString().c_str(),
+ // upnp_err,
+ // UpnpGetErrorMessage(upnp_err));
+ // JAMI_WARN("PUPnP: IGD ctrlUrl %s", igd->getControlURL().c_str());
+ // JAMI_WARN("PUPnP: IGD service type %s", igd->getServiceType().c_str());
success = false;
}
@@ -1503,10 +1503,10 @@
errorDescription = getFirstDocItem(response.get(), "errorDescription");
}
- JAMI_WARNING("PUPnP: {:s} returned with error: {:s} {:s}",
- ACTION_ADD_PORT_MAPPING,
- errorCode,
- errorDescription);
+ // JAMI_WARNING("PUPnP: {:s} returned with error: {:s} {:s}",
+ // ACTION_ADD_PORT_MAPPING,
+ // errorCode,
+ // errorDescription);
}
return success;
}
@@ -1565,19 +1565,19 @@
bool success = true;
if (upnp_err != UPNP_E_SUCCESS) {
- JAMI_WARN("PUPnP: Failed to send action %s for mapping from %s. %d: %s",
- ACTION_DELETE_PORT_MAPPING,
- mapping.toString().c_str(),
- upnp_err,
- UpnpGetErrorMessage(upnp_err));
- JAMI_WARN("PUPnP: IGD ctrlUrl %s", igd->getControlURL().c_str());
- JAMI_WARN("PUPnP: IGD service type %s", igd->getServiceType().c_str());
+ // JAMI_WARN("PUPnP: Failed to send action %s for mapping from %s. %d: %s",
+ // ACTION_DELETE_PORT_MAPPING,
+ // mapping.toString().c_str(),
+ // upnp_err,
+ // UpnpGetErrorMessage(upnp_err));
+ // JAMI_WARN("PUPnP: IGD ctrlUrl %s", igd->getControlURL().c_str());
+ // JAMI_WARN("PUPnP: IGD service type %s", igd->getServiceType().c_str());
success = false;
}
if (not response) {
- JAMI_WARN("PUPnP: Failed to get response for %s", ACTION_DELETE_PORT_MAPPING);
+ // JAMI_WARN("PUPnP: Failed to get response for %s", ACTION_DELETE_PORT_MAPPING);
success = false;
}
@@ -1585,10 +1585,10 @@
auto errorCode = getFirstDocItem(response.get(), "errorCode");
if (not errorCode.empty()) {
auto errorDescription = getFirstDocItem(response.get(), "errorDescription");
- JAMI_WARNING("PUPnP: {:s} returned with error: {:s}: {:s}",
- ACTION_DELETE_PORT_MAPPING,
- errorCode,
- errorDescription);
+ // JAMI_WARNING("PUPnP: {:s} returned with error: {:s}: {:s}",
+ // ACTION_DELETE_PORT_MAPPING,
+ // errorCode,
+ // errorDescription);
success = false;
}