Don't print garbage values on failure

This commit is contained in:
Arran Cudbard-Bell 2014-05-13 21:04:14 +01:00
parent b9362f32a7
commit 0490d16221

View File

@ -251,13 +251,13 @@ static void SetRedirectAndTest(struct UPNPUrls * urls,
return; return;
} }
UPNP_GetExternalIPAddress(urls->controlURL, r = UPNP_GetExternalIPAddress(urls->controlURL,
data->first.servicetype, data->first.servicetype,
externalIPAddress); externalIPAddress);
if(externalIPAddress[0]) if(r!=UPNPCOMMAND_SUCCESS)
printf("ExternalIPAddress = %s\n", externalIPAddress);
else
printf("GetExternalIPAddress failed.\n"); printf("GetExternalIPAddress failed.\n");
else
printf("ExternalIPAddress = %s\n", externalIPAddress);
if (addAny) { if (addAny) {
r = UPNP_AddAnyPortMapping(urls->controlURL, data->first.servicetype, r = UPNP_AddAnyPortMapping(urls->controlURL, data->first.servicetype,
@ -285,8 +285,7 @@ static void SetRedirectAndTest(struct UPNPUrls * urls,
if(r!=UPNPCOMMAND_SUCCESS) if(r!=UPNPCOMMAND_SUCCESS)
printf("GetSpecificPortMappingEntry() failed with code %d (%s)\n", printf("GetSpecificPortMappingEntry() failed with code %d (%s)\n",
r, strupnperror(r)); r, strupnperror(r));
else {
if(intClient[0]) {
printf("InternalIP:Port = %s:%s\n", intClient, intPort); printf("InternalIP:Port = %s:%s\n", intClient, intPort);
printf("external %s:%s %s is redirected to internal %s:%s (duration=%s)\n", printf("external %s:%s %s is redirected to internal %s:%s (duration=%s)\n",
externalIPAddress, eport, proto, intClient, intPort, duration); externalIPAddress, eport, proto, intClient, intPort, duration);