diff options
Diffstat (limited to 'modules/upnp/upnp.cpp')
-rw-r--r-- | modules/upnp/upnp.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp index 5ef7575b0c..988bf3017d 100644 --- a/modules/upnp/upnp.cpp +++ b/modules/upnp/upnp.cpp @@ -44,9 +44,8 @@ bool UPNP::is_common_device(const String &dev) const { } int UPNP::discover(int timeout, int ttl, const String &device_filter) { - ERR_FAIL_COND_V(timeout < 0, UPNP_RESULT_INVALID_PARAM); - ERR_FAIL_COND_V(ttl < 0, UPNP_RESULT_INVALID_PARAM); - ERR_FAIL_COND_V(ttl > 255, UPNP_RESULT_INVALID_PARAM); + ERR_FAIL_COND_V_MSG(timeout < 0, UPNP_RESULT_INVALID_PARAM, "The response's wait time can't be negative."); + ERR_FAIL_COND_V_MSG(ttl < 0 || ttl > 255, UPNP_RESULT_INVALID_PARAM, "The time-to-live must be set between 0 and 255 (inclusive)."); devices.clear(); @@ -54,9 +53,9 @@ int UPNP::discover(int timeout, int ttl, const String &device_filter) { struct UPNPDev *devlist; if (is_common_device(device_filter)) { - devlist = upnpDiscover(timeout, discover_multicast_if.utf8().get_data(), NULL, discover_local_port, discover_ipv6, ttl, &error); + devlist = upnpDiscover(timeout, discover_multicast_if.utf8().get_data(), nullptr, discover_local_port, discover_ipv6, ttl, &error); } else { - devlist = upnpDiscoverAll(timeout, discover_multicast_if.utf8().get_data(), NULL, discover_local_port, discover_ipv6, ttl, &error); + devlist = upnpDiscoverAll(timeout, discover_multicast_if.utf8().get_data(), nullptr, discover_local_port, discover_ipv6, ttl, &error); } if (error != UPNPDISCOVER_SUCCESS) { @@ -133,7 +132,7 @@ void UPNP::parse_igd(Ref<UPNPDevice> dev, UPNPDev *devlist) { parserootdesc(xml, size, &data); free(xml); - xml = 0; + xml = nullptr; GetUPNPUrls(urls, &data, dev->get_description_url().utf8().get_data(), 0); @@ -235,20 +234,20 @@ int UPNP::get_device_count() const { } Ref<UPNPDevice> UPNP::get_device(int index) const { - ERR_FAIL_INDEX_V(index, devices.size(), NULL); + ERR_FAIL_INDEX_V(index, devices.size(), nullptr); return devices.get(index); } void UPNP::add_device(Ref<UPNPDevice> device) { - ERR_FAIL_COND(device == NULL); + ERR_FAIL_COND(device == nullptr); devices.push_back(device); } void UPNP::set_device(int index, Ref<UPNPDevice> device) { ERR_FAIL_INDEX(index, devices.size()); - ERR_FAIL_COND(device == NULL); + ERR_FAIL_COND(device == nullptr); devices.set(index, device); } @@ -264,17 +263,17 @@ void UPNP::clear_devices() { } Ref<UPNPDevice> UPNP::get_gateway() const { - ERR_FAIL_COND_V(devices.size() < 1, NULL); + ERR_FAIL_COND_V_MSG(devices.size() < 1, nullptr, "Couldn't find any UPNPDevices."); for (int i = 0; i < devices.size(); i++) { Ref<UPNPDevice> dev = get_device(i); - if (dev != NULL && dev->is_valid_gateway()) { + if (dev != nullptr && dev->is_valid_gateway()) { return dev; } } - return NULL; + return nullptr; } void UPNP::set_discover_multicast_if(const String &m_if) { @@ -304,7 +303,7 @@ bool UPNP::is_discover_ipv6() const { String UPNP::query_external_address() const { Ref<UPNPDevice> dev = get_gateway(); - if (dev == NULL) { + if (dev == nullptr) { return ""; } @@ -314,7 +313,7 @@ String UPNP::query_external_address() const { int UPNP::add_port_mapping(int port, int port_internal, String desc, String proto, int duration) const { Ref<UPNPDevice> dev = get_gateway(); - if (dev == NULL) { + if (dev == nullptr) { return UPNP_RESULT_NO_GATEWAY; } @@ -326,7 +325,7 @@ int UPNP::add_port_mapping(int port, int port_internal, String desc, String prot int UPNP::delete_port_mapping(int port, String proto) const { Ref<UPNPDevice> dev = get_gateway(); - if (dev == NULL) { + if (dev == nullptr) { return UPNP_RESULT_NO_GATEWAY; } |