Refs #17349: InternetGatewayDevice.UPnP.Device.Enable is broken

This commit is contained in:
Feten Besbes 2019-11-29 15:29:37 +01:00
parent 8ab504585c
commit b89c48507e

View file

@ -36,8 +36,11 @@ DMLEAF tUPnPDeviceParams[] = {
/*#Device.UPnP.Device.Enable!UCI:upnpd/upnpd,config/enabled*/ /*#Device.UPnP.Device.Enable!UCI:upnpd/upnpd,config/enabled*/
int get_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int get_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
dmuci_get_option_value_string("upnpd","config","enabled", value); pid_t pid = get_pid("miniupnpd");
if ((*value)[0] == '\0') { if (pid < 0) {
*value = "0";
}
else {
*value = "1"; *value = "1";
} }
return 0; return 0;
@ -54,10 +57,13 @@ int set_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instanc
return 0; return 0;
case VALUESET: case VALUESET:
string_to_bool(value, &b); string_to_bool(value, &b);
if(b) if(b){
dmuci_set_value("upnpd", "config", "enabled", ""); dmuci_set_value("upnpd", "config", "enabled", "1");
else dmuci_set_value("upnpd", "config", "enable_natpmp", "1");
dmuci_set_value("upnpd", "config", "enable_upnp", "1");
} else {
dmuci_set_value("upnpd", "config", "enabled", "0"); dmuci_set_value("upnpd", "config", "enabled", "0");
}
return 0; return 0;
} }
return 0; return 0;
@ -74,4 +80,4 @@ int get_upnp_status(char *refparam, struct dmctx *ctx, void *data, char *instanc
*value = "Up"; *value = "Up";
} }
return 0; return 0;
} }