mirror of
https://github.com/status-im/miniupnp.git
synced 2025-02-02 01:26:45 +00:00
parent
a4916a4c94
commit
3f0bcbf7b5
@ -314,7 +314,7 @@ static int SetRedirectAndTest(struct UPNPUrls * urls,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
RemoveRedirect(struct UPNPUrls * urls,
|
RemoveRedirect(struct UPNPUrls * urls,
|
||||||
struct IGDdatas * data,
|
struct IGDdatas * data,
|
||||||
const char * eport,
|
const char * eport,
|
||||||
@ -325,19 +325,25 @@ RemoveRedirect(struct UPNPUrls * urls,
|
|||||||
if(!proto || !eport)
|
if(!proto || !eport)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "invalid arguments\n");
|
fprintf(stderr, "invalid arguments\n");
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
proto = protofix(proto);
|
proto = protofix(proto);
|
||||||
if(!proto)
|
if(!proto)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "protocol invalid\n");
|
fprintf(stderr, "protocol invalid\n");
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
r = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, eport, proto, remoteHost);
|
r = UPNP_DeletePortMapping(urls->controlURL, data->first.servicetype, eport, proto, remoteHost);
|
||||||
printf("UPNP_DeletePortMapping() returned : %d\n", r);
|
if(r!=UPNPCOMMAND_SUCCESS) {
|
||||||
|
printf("UPNP_DeletePortMapping() failed with code : %d\n", r);
|
||||||
|
return -2;
|
||||||
|
}else {
|
||||||
|
printf("UPNP_DeletePortMapping() returned : %d\n", r);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
RemoveRedirectRange(struct UPNPUrls * urls,
|
RemoveRedirectRange(struct UPNPUrls * urls,
|
||||||
struct IGDdatas * data,
|
struct IGDdatas * data,
|
||||||
const char * ePortStart, char const * ePortEnd,
|
const char * ePortStart, char const * ePortEnd,
|
||||||
@ -351,16 +357,22 @@ RemoveRedirectRange(struct UPNPUrls * urls,
|
|||||||
if(!proto || !ePortStart || !ePortEnd)
|
if(!proto || !ePortStart || !ePortEnd)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "invalid arguments\n");
|
fprintf(stderr, "invalid arguments\n");
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
proto = protofix(proto);
|
proto = protofix(proto);
|
||||||
if(!proto)
|
if(!proto)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "protocol invalid\n");
|
fprintf(stderr, "protocol invalid\n");
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
r = UPNP_DeletePortMappingRange(urls->controlURL, data->first.servicetype, ePortStart, ePortEnd, proto, manage);
|
r = UPNP_DeletePortMappingRange(urls->controlURL, data->first.servicetype, ePortStart, ePortEnd, proto, manage);
|
||||||
printf("UPNP_DeletePortMappingRange() returned : %d\n", r);
|
if(r!=UPNPCOMMAND_SUCCESS) {
|
||||||
|
printf("UPNP_DeletePortMappingRange() failed with code : %d\n", r);
|
||||||
|
return -2;
|
||||||
|
}else {
|
||||||
|
printf("UPNP_DeletePortMappingRange() returned : %d\n", r);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IGD:2, functions for service WANIPv6FirewallControl:1 */
|
/* IGD:2, functions for service WANIPv6FirewallControl:1 */
|
||||||
@ -721,8 +733,9 @@ int main(int argc, char ** argv)
|
|||||||
retcode = 2;
|
retcode = 2;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
RemoveRedirect(&urls, &data, commandargv[0], commandargv[1],
|
if (RemoveRedirect(&urls, &data, commandargv[0], commandargv[1],
|
||||||
commandargc > 2 ? commandargv[2] : NULL);
|
commandargc > 2 ? commandargv[2] : NULL) < 0)
|
||||||
|
retcode = 2;
|
||||||
break;
|
break;
|
||||||
case 'n': /* aNy */
|
case 'n': /* aNy */
|
||||||
if (SetRedirectAndTest(&urls, &data,
|
if (SetRedirectAndTest(&urls, &data,
|
||||||
@ -736,8 +749,9 @@ int main(int argc, char ** argv)
|
|||||||
if (commandargc < 3)
|
if (commandargc < 3)
|
||||||
fprintf(stderr, "too few arguments\n");
|
fprintf(stderr, "too few arguments\n");
|
||||||
|
|
||||||
RemoveRedirectRange(&urls, &data, commandargv[0], commandargv[1], commandargv[2],
|
if (RemoveRedirectRange(&urls, &data, commandargv[0], commandargv[1], commandargv[2],
|
||||||
commandargc > 3 ? commandargv[3] : NULL);
|
commandargc > 3 ? commandargv[3] : NULL) < 0)
|
||||||
|
retcode = 2;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
GetConnectionStatus(&urls, &data);
|
GetConnectionStatus(&urls, &data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user