Ticket refs #1254: TR-x69: add support for parameter validation

This commit is contained in:
Amin Ben Ramdhane 2020-02-20 23:25:49 +01:00
parent 3848bac3aa
commit 905d78844c
54 changed files with 26539 additions and 15312 deletions

View file

@ -14,7 +14,8 @@ libbbf_api_la_CFLAGS = \
$(AM_CFLAGS) \
$(LIBUCI_CFLAGS) \
$(LIBUBOX_CFLAGS) \
$(LIBUBUS_CFLAGS)
$(LIBUBUS_CFLAGS) \
-Wall -Werror
libbbf_api_la_LDFLAGS = \
$(AM_LDFLAGS) \
@ -116,7 +117,8 @@ libbbfdm_la_CFLAGS = \
$(AM_CFLAGS) \
$(LIBUCI_CFLAGS) \
$(LIBUBOX_CFLAGS) \
$(LIBUBUS_CFLAGS)
$(LIBUBUS_CFLAGS) \
-Wall -Werror
libbbfdm_la_LDFLAGS = \
$(AM_LDFLAGS) \

View file

@ -81,8 +81,8 @@ void upnp_getInterfaceStatus(char *interfaceName, char **status){
*status = NULL;
goto end_bloc;
}
up = dm_ubus_get_value(res, 1, "up");
if(up == NULL) {
up = dmjson_get_value(res, 1, "up");
if (up == NULL) {
*status = NULL;
goto end_bloc;
}

View file

@ -130,7 +130,7 @@ DMLEAF tServicesVoiceServiceVoiceProfileParams[] = {
DMLEAF tServicesVoiceServiceVoiceProfileSIPParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"ProxyServer", &DMWRITE, DMT_STRING, get_voice_profile_sip_proxyserver, set_voice_profile_sip_proxyserver, NULL, NULL, BBFDM_BOTH},
{"ProxyServerPort", &DMWRITE, DMT_UNINT, get_empty, set_sip_proxy_server_port, NULL, NULL, BBFDM_BOTH},
//{"ProxyServerPort", &DMWRITE, DMT_UNINT, get_empty, set_sip_proxy_server_port, NULL, NULL, BBFDM_BOTH},
{"ProxyServerTransport", &DMWRITE, DMT_STRING, get_sip_proxy_server_transport, set_sip_proxy_server_transport, NULL, NULL, BBFDM_BOTH},
{"RegistrarServer", &DMWRITE, DMT_STRING, get_voice_profile_sip_registerserver, set_voice_profile_sip_registerserver, NULL, NULL, BBFDM_BOTH},
{"RegistrarServerPort", &DMWRITE, DMT_UNINT, get_voice_profile_sip_registerserverport, set_voice_profile_sip_registerserverport, NULL, NULL, BBFDM_BOTH},
@ -544,13 +544,10 @@ int get_line_max_instance(struct uci_section **tel_section)
uci_foreach_sections("voice_client", "tel_line", s) {
i++;
dmuci_get_value_by_section_string(s, "sip_account", &value);
if (strcmp(value, "-") == 0)
{
found=1;
if (strcmp(value, "-") == 0) {
found = 1;
break;
}
else if (i >= line_number) {
} else if (i >= line_number) {
i = 0;
break;
}
@ -558,7 +555,7 @@ int get_line_max_instance(struct uci_section **tel_section)
if (found == 1)
*tel_section = s;
else {
i=0;
i = 0;
*tel_section = NULL;
}
return i;
@ -571,8 +568,9 @@ char *update_vp_line_instance(struct uci_section *tel_s, char *sipx)
char *instance, buf[8];
get_dmmap_section_of_config_section("dmmap_voice_client", "tel_line", section_name(tel_s), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "lineinstance", &instance);
if(instance[0] != '\0'){
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "lineinstance", &instance);
if (instance[0] != '\0') {
return instance;
}
uci_foreach_option_eq("voice_client", "tel_line", "sip_account", sipx, s) {
@ -623,7 +621,6 @@ char *update_vp_line_instance_alias(int action, char **last_inst, void *argv[])
}
return instance;
}
/*******/
int add_line(struct uci_section *s, char *s_name)
{
@ -650,12 +647,10 @@ int add_line_object(char *refparam, struct dmctx *ctx, void *data, char **instan
dmuci_set_value_by_section(dmmap_voice_line_section, "voice_profile_key", voice_profile_key);
*instancepara = update_vp_line_instance(s, section_name(sipargs->sip_section));
dmuci_get_value_by_section_string(sipargs->sip_section, "call_lines", &value);
if (value[0] == '\0') {
if (value[0] == '\0')
snprintf(call_lines, sizeof(call_lines), "%d", i - 1);
}
else {
else
snprintf(call_lines, sizeof(call_lines), "%s %d", value, i - 1);
}
dmuci_set_value_by_section(sipargs->sip_section, "call_lines", call_lines);
return 0;
}
@ -678,8 +673,7 @@ int delete_line(struct uci_section *line_section, struct uci_section *sip_sectio
if (strcmp(pch, line_id) != 0) {
if (new_call_lines[0] == '\0') {
dmstrappendstr(p, pch);
}
else {
} else {
dmstrappendchr(p, ' ');
dmstrappendstr(p, pch);
}
@ -697,13 +691,14 @@ int delete_line_object(char *refparam, struct dmctx *ctx, void *data, char *inst
struct uci_section *s;
struct sip_args *sipargs;
struct tel_args *bargs; //profile_num must be added to tel_args
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (del_action) {
case DEL_INST:
bargs = (struct tel_args *)data;
get_dmmap_section_of_config_section("dmmap_voice_client", "tel_line", section_name(bargs->tel_section), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
delete_line(bargs->tel_section, bargs->sip_section);
break;
case DEL_ALL:
@ -711,7 +706,7 @@ int delete_line_object(char *refparam, struct dmctx *ctx, void *data, char *inst
s_name = section_name(sipargs->sip_section);
uci_foreach_option_eq("voice_client", "tel_line", "sip_account", s_name, s) {
get_dmmap_section_of_config_section("dmmap_voice_client", "tel_line", section_name(s), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
delete_line(s, sipargs->sip_section);
}
@ -882,8 +877,11 @@ int get_voice_profile_enable(char *refparam, struct dmctx *ctx, void *data, char
int set_voice_profile_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct sip_args *sipargs = (struct sip_args *)data;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, ProfileEnable, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if(strcmp(value, "Enabled") == 0)
@ -901,7 +899,7 @@ int set_voice_profile_reset(char *refparam, struct dmctx *ctx, void *data, char
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -933,6 +931,8 @@ int set_voice_profile_signaling_protocol(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
return 0;
@ -947,8 +947,8 @@ int get_voice_profile_max_sessions(char *refparam, struct dmctx *ctx, void *data
char *sub_channel = NULL, *num_lines = NULL;
dmubus_call("voice.asterisk", "lines", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
sub_channel = dm_ubus_get_value(res, 1, "num_subchannels");
num_lines = dm_ubus_get_value(res, 1, "num_lines");
sub_channel = dmjson_get_value(res, 1, "num_subchannels");
num_lines = dmjson_get_value(res, 1, "num_lines");
dmasprintf(value, "%d", atoi(sub_channel) * atoi(num_lines)); // MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
@ -984,6 +984,8 @@ int set_voice_profile_sip_proxyserver(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("voice_client", "SIP", "sip_proxy", value);
@ -996,9 +998,11 @@ int set_sip_proxy_server_port(char *refparam, struct dmctx *ctx, void *data, cha
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
//TODO: not implemented in old scripts
//TODO
return 0;
}
return 0;
@ -1019,6 +1023,8 @@ int set_sip_proxy_server_transport(char *refparam, struct dmctx *ctx, void *data
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(sipargs->sip_section, "transport", value);
@ -1042,6 +1048,8 @@ int set_voice_profile_sip_registerserver(char *refparam, struct dmctx *ctx, void
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(sipargs->sip_section, "host", value);
@ -1065,6 +1073,8 @@ int set_voice_profile_sip_registerserverport(char *refparam, struct dmctx *ctx,
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(sipargs->sip_section, "port", value);
@ -1088,6 +1098,8 @@ int set_sip_registrar_server_transport(char *refparam, struct dmctx *ctx, void *
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(sipargs->sip_section, "transport", value);
@ -1111,6 +1123,8 @@ int set_sip_user_agent_domain(char *refparam, struct dmctx *ctx, void *data, cha
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(sipargs->sip_section, "domain", value);
@ -1130,6 +1144,8 @@ int set_sip_user_agent_port(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("voice_client", "SIP", "bindport", value);
@ -1157,6 +1173,8 @@ int set_sip_user_agent_transport(char *refparam, struct dmctx *ctx, void *data,
struct sip_args *sipargs = (struct sip_args *)data;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (strcasecmp(value, "udp")==0) dmuci_set_value_by_section(sipargs->sip_section, "transport", "");
@ -1181,6 +1199,8 @@ int set_sip_outbound_proxy(char *refparam, struct dmctx *ctx, void *data, char *
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(sipargs->sip_section, "outboundproxy", value);
@ -1203,6 +1223,8 @@ int set_sip_outbound_proxy_port(char *refparam, struct dmctx *ctx, void *data, c
struct sip_args *sipargs = (struct sip_args *)data;
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(sipargs->sip_section, "outboundproxyport", value);
@ -1222,6 +1244,8 @@ int set_sip_registration_period(char *refparam, struct dmctx *ctx, void *data, c
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("voice_client", "SIP", "defaultexpiry", value);
@ -1241,6 +1265,8 @@ int set_sip_re_invite_expires(char *refparam, struct dmctx *ctx, void *data, cha
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("voice_client", "SIP", "registertimeout", value);
@ -1264,6 +1290,7 @@ int set_sip_call_lines(char *refparam, struct dmctx *ctx, void *data, char *inst
switch (action) {
case VALUECHECK:
//TODO
return 0;
case VALUESET:
dmuci_set_value_by_section(sipargs->sip_section, "call_lines", value);
@ -1278,11 +1305,11 @@ int get_voice_profile_sip_dtmfmethod(char *refparam, struct dmctx *ctx, void *da
char *tmp;
dmuci_get_option_value_string("voice_client", "SIP", "dtmfmode", &tmp);
if(strcmp(tmp, "inband") == 0)
if (strcmp(tmp, "inband") == 0)
*value = "InBand";
else if(strcmp(tmp, "rfc2833") == 0)
else if (strcmp(tmp, "rfc2833") == 0)
*value = "RFC2833";
else if(strcmp(tmp, "info") == 0)
else if (strcmp(tmp, "info") == 0)
*value = "SIPInfo";
else
*value = tmp;
@ -1293,6 +1320,8 @@ int set_voice_profile_sip_dtmfmethod(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", DTMFMethod, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if(strcmp(value, "InBand") == 0)
@ -1326,6 +1355,8 @@ int set_sip_profile_region(char *refparam, struct dmctx *ctx, void *data, char *
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
for (i = 0; i < ARRAY_SIZE(capabilities_regions); i++) {
@ -1356,6 +1387,8 @@ int set_voice_service_serviceproviderinfo_name(char *refparam, struct dmctx *ctx
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(sipargs->sip_section, "provider_name", value);
@ -1374,21 +1407,15 @@ int get_sip_fax_t38_enable(char *refparam, struct dmctx *ctx, void *data, char *
int set_sip_fax_t38_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct sip_args *sipargs = (struct sip_args *)data;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
value = "1";
else
value = "0";
dmuci_set_value_by_section(sipargs->sip_section, "is_fax", value);
dmuci_set_value_by_section(((struct sip_args *)data)->sip_section, "is_fax", b ? "1" : "0");
return 0;
}
return 0;
@ -1410,6 +1437,8 @@ int set_voice_service_vp_rtp_portmin(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("voice_client", "SIP", "rtpstart", value);
@ -1435,6 +1464,8 @@ int set_voice_profile_rtp_localportmax(char *refparam, struct dmctx *ctx, void *
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("voice_client", "SIP", "rtpend", value);
@ -1465,6 +1496,8 @@ int set_voice_service_vp_rtp_dscp(char *refparam, struct dmctx *ctx, void *data,
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "63"))
return FAULT_9007;
return 0;
case VALUESET:
for (i = 0; i < ARRAY_SIZE(list_rtp_tos); i++) {
@ -1480,13 +1513,8 @@ int set_voice_service_vp_rtp_dscp(char *refparam, struct dmctx *ctx, void *data,
int get_voice_service_vp_rtp_rtcp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
pid_t pid;
pid = get_pid("asterisk");
if(pid < 0)
*value = "0";
else
*value = "1";
pid_t pid = get_pid("asterisk");
*value = (pid < 0) ? "0" : "1";
return 0;
}
@ -1506,6 +1534,8 @@ int set_voice_service_vp_rtp_rtcp_txrepeatinterval(char *refparam, struct dmctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("voice_client", "SIP", "rtcpinterval", value);
@ -1520,7 +1550,7 @@ int get_voice_service_vp_rtp_srtp_enable(char *refparam, struct dmctx *ctx, void
struct sip_args *sipargs = (struct sip_args *)data;
dmuci_get_value_by_section_string(sipargs->sip_section, "encryption", &tmp);
if(strcasecmp(tmp, "yes") == 0)
if (strcasecmp(tmp, "yes") == 0)
*value = "1";
else
*value = "0";
@ -1534,15 +1564,12 @@ int set_voice_service_vp_rtp_srtp_enable(char *refparam, struct dmctx *ctx, void
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(sipargs->sip_section, "encryption", "yes");
else
dmuci_set_value_by_section(sipargs->sip_section, "encryption", "");
dmuci_set_value_by_section(sipargs->sip_section, "encryption", b ? "yes" : "");
return 0;
}
return 0;
@ -1555,8 +1582,7 @@ int get_voice_profile_line_enable(char *refparam, struct dmctx *ctx, void *data,
struct tel_args *telargs = (struct tel_args *)data;
dmuci_get_value_by_section_string(telargs->sip_section, "enabled", &tmp);
if(strcmp(tmp, "0") == 0)
if (strcmp(tmp, "0") == 0)
*value = "Disabled";
else
*value = "Enabled";
@ -1566,8 +1592,11 @@ int get_voice_profile_line_enable(char *refparam, struct dmctx *ctx, void *data,
int set_voice_profile_line_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct tel_args *telargs = (struct tel_args *)data;
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
if(strcmp(value, "Enabled") == 0)
@ -1593,6 +1622,8 @@ int set_line_directory_number(char *refparam, struct dmctx *ctx, void *data, cha
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "32", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(telargs->tel_section, "extension", value);
@ -1765,15 +1796,12 @@ int set_line_confort_noise_enable(char *refparam, struct dmctx *ctx, void *data,
switch (action) {
case VALUECHECK:
if(string_to_bool(value, &b))
if(dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(telargs->tel_section, "noise", "1");
else
dmuci_set_value_by_section(telargs->tel_section, "noise", "0");
dmuci_set_value_by_section(telargs->tel_section, "noise", b ? "1" : "0");
return 0;
}
return 0;
@ -1795,15 +1823,12 @@ int set_line_voice_processing_cancellation_enable(char *refparam, struct dmctx *
switch (action) {
case VALUECHECK:
if(string_to_bool(value, &b))
if(dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(telargs->tel_section, "echo_cancel", "1");
else
dmuci_set_value_by_section(telargs->tel_section, "echo_cancel", "0");
dmuci_set_value_by_section(telargs->tel_section, "echo_cancel", b ? "1" : "0");
return 0;
}
return 0;
@ -1824,6 +1849,8 @@ int set_line_calling_features_caller_id_name(char *refparam, struct dmctx *ctx,
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(telargs->sip_section, "displayname", value);
@ -1849,15 +1876,12 @@ int set_line_calling_features_callwaiting(char *refparam, struct dmctx *ctx, voi
switch (action) {
case VALUECHECK:
if(string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(telargs->tel_section, "callwaiting", "1");
else
dmuci_set_value_by_section(telargs->tel_section, "callwaiting", "");
dmuci_set_value_by_section(telargs->tel_section, "callwaiting", b ? "1" : "");
return 0;
}
return 0;
@ -1877,6 +1901,8 @@ int set_line_sip_auth_username(char *refparam, struct dmctx *ctx, void *data, ch
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "128", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(telargs->sip_section, "authuser", value);
@ -1891,6 +1917,8 @@ int set_line_sip_auth_password(char *refparam, struct dmctx *ctx, void *data, ch
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "128", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(telargs->sip_section, "secret", value);
@ -1920,6 +1948,8 @@ int set_line_sip_uri(char *refparam, struct dmctx *ctx, void *data, char *instan
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "389", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
str1 = dmstrdup(value);
@ -2095,10 +2125,11 @@ int get_line_codec_list_enable(char *refparam, struct dmctx *ctx, void *data, ch
int get_line_codec_list_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct line_codec_args *line_codecargs = (struct line_codec_args *)data;
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_voice_client", "sip_service_provider", section_name(line_codecargs->sip_section), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, line_codecargs->priority_cdc, value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, line_codecargs->priority_cdc, value);
return 0;
}
@ -2108,6 +2139,8 @@ int set_line_codec_list_packetization(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, NULL, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(line_codecargs->sip_section, line_codecargs->ptime_cdc, value);
@ -2122,14 +2155,14 @@ int set_line_codec_list_enable(char *refparam, struct dmctx *ctx, void *data, ch
int j;
char *codec;
struct line_codec_args *line_codecargs = (struct line_codec_args *)data;
int error = string_to_bool(value, &b);
switch (action) {
case VALUECHECK:
if (error)
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b) {
for (j = 0; j < ARRAY_SIZE(codec_option_array); j++) {
dmuci_get_value_by_section_string(line_codecargs->sip_section, codec_option_array[j], &codec);
@ -2157,19 +2190,23 @@ int set_line_codec_list_priority(char *refparam, struct dmctx *ctx, void *data,
int i;
char *val;
struct line_codec_args *line_codecargs = (struct line_codec_args *)data;
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_voice_client", "sip_service_provider", section_name(line_codecargs->sip_section), &dmmap_section);
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, line_codecargs->priority_cdc, value);
for (i =0; i < ARRAY_SIZE(codec_option_array); i++) {
dmuci_get_value_by_section_string(line_codecargs->sip_section, codec_option_array[i], &val);
if (strcmp(val, line_codecargs->cdc) == 0) {
codec_priority_sort(line_codecargs->sip_section, NULL);
return 0;
get_dmmap_section_of_config_section("dmmap_voice_client", "sip_service_provider", section_name(line_codecargs->sip_section), &dmmap_section);
if (dmmap_section) {
dmuci_set_value_by_section(dmmap_section, line_codecargs->priority_cdc, value);
for (i =0; i < ARRAY_SIZE(codec_option_array); i++) {
dmuci_get_value_by_section_string(line_codecargs->sip_section, codec_option_array[i], &val);
if (strcmp(val, line_codecargs->cdc) == 0) {
codec_priority_sort(line_codecargs->sip_section, NULL);
return 0;
}
}
}
return 0;
@ -2224,6 +2261,8 @@ int set_service_alias(char *refparam, struct dmctx *ctx, void *data, char *insta
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(service_section, "vsalias", value);
@ -2242,8 +2281,11 @@ int get_cap_codec_alias(char *refparam, struct dmctx *ctx, void *data, char *ins
int set_cap_codec_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct codec_args *cur_codec_args = (struct codec_args *)data;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_codec_args->codec_section, "codecalias", value);
@ -2255,25 +2297,28 @@ int set_cap_codec_alias(char *refparam, struct dmctx *ctx, void *data, char *ins
int get_voice_profile_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct sip_args *sipargs = (struct sip_args *)data;
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_voice_client", "sip_service_provider", section_name(sipargs->sip_section), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "profilealias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "profilealias", value);
return 0;
}
int set_voice_profile_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct sip_args *sipargs = (struct sip_args *)data;
struct uci_section *dmmap_section;
get_dmmap_section_of_config_section("dmmap_voice_client", "sip_service_provider", section_name(sipargs->sip_section), &dmmap_section);
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "profilealias", value);
get_dmmap_section_of_config_section("dmmap_voice_client", "sip_service_provider", section_name(sipargs->sip_section), &dmmap_section);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "profilealias", value);
return 0;
}
return 0;
@ -2282,24 +2327,28 @@ int set_voice_profile_alias(char *refparam, struct dmctx *ctx, void *data, char
int get_line_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct tel_args *telarg = (struct tel_args *)data;
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_voice_client", "tel_line", section_name(telarg->tel_section), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "linealias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "linealias", value);
return 0;
}
int set_line_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct tel_args *telarg = (struct tel_args *)data;
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_voice_client", "tel_line", section_name(telarg->tel_section), &dmmap_section);
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "linealias", value);
get_dmmap_section_of_config_section("dmmap_voice_client", "tel_line", section_name(telarg->tel_section), &dmmap_section);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "linealias", value);
return 0;
}
return 0;
@ -2315,6 +2364,8 @@ int set_line_codec_list_alias(char *refparam, struct dmctx *ctx, void *data, cha
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct line_codec_args *)data)->codec_sec, "codecalias", value);
@ -2323,7 +2374,8 @@ int set_line_codec_list_alias(char *refparam, struct dmctx *ctx, void *data, cha
return 0;
}
///////////////////////////////////////
void set_voice_profile_key_of_line(struct uci_section *dmmap_line_section, char* prev_instance){
void set_voice_profile_key_of_line(struct uci_section *dmmap_line_section, char* prev_instance)
{
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_line_section, "voice_profile_key", prev_instance);
}

File diff suppressed because it is too large Load diff

View file

@ -355,9 +355,10 @@ int get_BulkData_Enable(char *refparam, struct dmctx *ctx, void *data, char *ins
int set_BulkData_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -438,9 +439,10 @@ int get_BulkDataProfile_Enable(char *refparam, struct dmctx *ctx, void *data, ch
int set_BulkDataProfile_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -462,6 +464,8 @@ int set_BulkDataProfile_Alias(char *refparam, struct dmctx *ctx, void *data, cha
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "profile_alias", value);
@ -481,6 +485,8 @@ int set_BulkDataProfile_Name(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "255", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "name", value);
@ -500,6 +506,8 @@ int set_BulkDataProfile_NumberOfRetainedFailedReports(char *refparam, struct dmc
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "nbre_of_retained_failed_reports", value);
@ -512,7 +520,7 @@ int set_BulkDataProfile_NumberOfRetainedFailedReports(char *refparam, struct dmc
int get_BulkDataProfile_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "protocol", value);
if(strcmp(*value, "http") == 0)
if (strcmp(*value, "http") == 0)
*value = "HTTP";
return 0;
}
@ -521,6 +529,8 @@ int set_BulkDataProfile_Protocol(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, BulkDataProtocols, NULL))
return FAULT_9007;
break;
case VALUESET:
if(strcmp(value, "HTTP") == 0)
@ -545,6 +555,8 @@ int set_BulkDataProfile_EncodingType(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, EncodingTypes, NULL))
return FAULT_9007;
break;
case VALUESET:
if(strcmp(value, "JSON") == 0)
@ -567,6 +579,8 @@ int set_BulkDataProfile_ReportingInterval(char *refparam, struct dmctx *ctx, voi
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "reporting_interval", value);
@ -596,8 +610,11 @@ int set_BulkDataProfile_TimeReference(char *refparam, struct dmctx *ctx, void *d
{
struct tm tm;
char buf[16];
switch (action) {
case VALUECHECK:
if (dm_validate_dateTime(value))
return FAULT_9007;
break;
case VALUESET:
if (!(strptime(value, "%Y-%m-%dT%H:%M:%S", &tm)))
@ -619,6 +636,8 @@ int set_BulkDataProfile_StreamingHost(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -637,6 +656,8 @@ int set_BulkDataProfile_StreamingPort(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -655,6 +676,8 @@ int set_BulkDataProfile_StreamingSessionID(char *refparam, struct dmctx *ctx, vo
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "65", "90"))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -673,6 +696,8 @@ int set_BulkDataProfile_FileTransferURL(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -691,6 +716,8 @@ int set_BulkDataProfile_FileTransferUsername(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -709,6 +736,8 @@ int set_BulkDataProfile_FileTransferPassword(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -727,6 +756,8 @@ int set_BulkDataProfile_ControlFileFormat(char *refparam, struct dmctx *ctx, voi
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "128", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -770,6 +801,8 @@ int set_BulkDataProfileParameter_Name(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "name", value);
@ -789,6 +822,8 @@ int set_BulkDataProfileParameter_Reference(char *refparam, struct dmctx *ctx, vo
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "reference", value);
@ -808,6 +843,8 @@ int set_BulkDataProfileCSVEncoding_FieldSeparator(char *refparam, struct dmctx *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "csv_encoding_field_separator", value);
@ -827,6 +864,8 @@ int set_BulkDataProfileCSVEncoding_RowSeparator(char *refparam, struct dmctx *ct
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
if((strcmp(value, "&#10;") == 0) || (strcmp(value, "&#13;") == 0))
@ -847,6 +886,8 @@ int set_BulkDataProfileCSVEncoding_EscapeCharacter(char *refparam, struct dmctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
if(strcmp(value, "&quot;") == 0)
@ -871,6 +912,8 @@ int set_BulkDataProfileCSVEncoding_ReportFormat(char *refparam, struct dmctx *ct
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, CSVReportFormat, NULL))
return FAULT_9007;
break;
case VALUESET:
if(strcmp(value, "ParameterPerRow") == 0)
@ -899,6 +942,8 @@ int set_BulkDataProfileCSVEncoding_RowTimestamp(char *refparam, struct dmctx *ct
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, RowTimestamp, NULL))
return FAULT_9007;
break;
case VALUESET:
if(strcmp(value, "Unix-Epoch") == 0)
@ -927,6 +972,8 @@ int set_BulkDataProfileJSONEncoding_ReportFormat(char *refparam, struct dmctx *c
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, JSONReportFormat, NULL))
return FAULT_9007;
break;
case VALUESET:
if(strcmp(value, "ObjectHierarchy") == 0)
@ -955,6 +1002,8 @@ int set_BulkDataProfileJSONEncoding_ReportTimestamp(char *refparam, struct dmctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, RowTimestamp, NULL))
return FAULT_9007;
break;
case VALUESET:
if(strcmp(value, "Unix-Epoch") == 0)
@ -979,6 +1028,8 @@ int set_BulkDataProfileHTTP_URL(char *refparam, struct dmctx *ctx, void *data, c
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "1024", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "http_url", value);
@ -998,6 +1049,8 @@ int set_BulkDataProfileHTTP_Username(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "http_username", value);
@ -1017,6 +1070,8 @@ int set_BulkDataProfileHTTP_Password(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "http_password", value);
@ -1048,6 +1103,8 @@ int set_BulkDataProfileHTTP_Compression(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
if(strcmp(value, "GZIP") == 0)
@ -1082,6 +1139,8 @@ int set_BulkDataProfileHTTP_Method(char *refparam, struct dmctx *ctx, void *data
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
if(strcmp(value, "POST") == 0)
@ -1103,9 +1162,10 @@ int get_BulkDataProfileHTTP_UseDateHeader(char *refparam, struct dmctx *ctx, voi
int set_BulkDataProfileHTTP_UseDateHeader(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -1126,9 +1186,10 @@ int get_BulkDataProfileHTTP_RetryEnable(char *refparam, struct dmctx *ctx, void
int set_BulkDataProfileHTTP_RetryEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -1150,6 +1211,8 @@ int set_BulkDataProfileHTTP_RetryMinimumWaitInterval(char *refparam, struct dmct
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", "65535"))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "http_retry_minimum_wait_interval", value);
@ -1169,6 +1232,8 @@ int set_BulkDataProfileHTTP_RetryIntervalMultiplier(char *refparam, struct dmctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1000", "65535"))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "http_retry_interval_multiplier", value);
@ -1205,9 +1270,10 @@ int get_BulkDataProfileHTTP_PersistAcrossReboot(char *refparam, struct dmctx *ct
int set_BulkDataProfileHTTP_PersistAcrossReboot(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -1229,6 +1295,8 @@ int set_BulkDataProfileHTTPRequestURIParameter_Name(char *refparam, struct dmctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "name", value);
@ -1248,6 +1316,8 @@ int set_BulkDataProfileHTTPRequestURIParameter_Reference(char *refparam, struct
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "reference", value);

View file

@ -37,10 +37,10 @@ DMLEAF tSoftwareModulesExecEnvParams[] = {
{"Alias", &DMWRITE, DMT_STRING, get_SoftwareModulesExecEnv_Alias, set_SoftwareModulesExecEnv_Alias, NULL, NULL, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_SoftwareModulesExecEnv_Name, NULL, NULL, NULL, BBFDM_BOTH},
{"Type", &DMREAD, DMT_STRING, get_SoftwareModulesExecEnv_Type, NULL, NULL, NULL, BBFDM_BOTH},
{"InitialRunLevel", &DMWRITE, DMT_UNINT, get_SoftwareModulesExecEnv_InitialRunLevel, set_SoftwareModulesExecEnv_InitialRunLevel, NULL, NULL, BBFDM_BOTH},
{"RequestedRunLevel", &DMWRITE, DMT_INT, get_SoftwareModulesExecEnv_RequestedRunLevel, set_SoftwareModulesExecEnv_RequestedRunLevel, NULL, NULL, BBFDM_CWMP},
{"CurrentRunLevel", &DMREAD, DMT_INT, get_SoftwareModulesExecEnv_CurrentRunLevel, NULL, NULL, NULL, BBFDM_BOTH},
{"InitialExecutionUnitRunLevel", &DMWRITE, DMT_INT, get_SoftwareModulesExecEnv_InitialExecutionUnitRunLevel, set_SoftwareModulesExecEnv_InitialExecutionUnitRunLevel, NULL, NULL, BBFDM_BOTH},
//{"InitialRunLevel", &DMWRITE, DMT_UNINT, get_SoftwareModulesExecEnv_InitialRunLevel, set_SoftwareModulesExecEnv_InitialRunLevel, NULL, NULL, BBFDM_BOTH},
//{"RequestedRunLevel", &DMWRITE, DMT_INT, get_SoftwareModulesExecEnv_RequestedRunLevel, set_SoftwareModulesExecEnv_RequestedRunLevel, NULL, NULL, BBFDM_CWMP},
//{"CurrentRunLevel", &DMREAD, DMT_INT, get_SoftwareModulesExecEnv_CurrentRunLevel, NULL, NULL, NULL, BBFDM_BOTH},
//{"InitialExecutionUnitRunLevel", &DMWRITE, DMT_INT, get_SoftwareModulesExecEnv_InitialExecutionUnitRunLevel, set_SoftwareModulesExecEnv_InitialExecutionUnitRunLevel, NULL, NULL, BBFDM_BOTH},
{"Vendor", &DMREAD, DMT_STRING, get_SoftwareModulesExecEnv_Vendor, NULL, NULL, NULL, BBFDM_BOTH},
{"Version", &DMREAD, DMT_STRING, get_SoftwareModulesExecEnv_Version, NULL, NULL, NULL, BBFDM_BOTH},
{"ParentExecEnv", &DMREAD, DMT_STRING, get_SoftwareModulesExecEnv_ParentExecEnv, NULL, NULL, NULL, BBFDM_BOTH},
@ -76,7 +76,7 @@ DMLEAF tSoftwareModulesDeploymentUnitParams[] = {
/* *** Device.SoftwareModules.ExecutionUnit.{i}. *** */
DMOBJ tSoftwareModulesExecutionUnitObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/
{"Extensions", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, BBFDM_BOTH},
//{"Extensions", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -87,11 +87,11 @@ DMLEAF tSoftwareModulesExecutionUnitParams[] = {
{"Name", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_Name, NULL, NULL, NULL, BBFDM_BOTH},
{"ExecEnvLabel", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_ExecEnvLabel, NULL, NULL, NULL, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_Status, NULL, NULL, NULL, BBFDM_BOTH},
{"RequestedState", &DMWRITE, DMT_STRING, get_SoftwareModulesExecutionUnit_RequestedState, set_SoftwareModulesExecutionUnit_RequestedState, NULL, NULL, BBFDM_CWMP},
{"ExecutionFaultCode", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_ExecutionFaultCode, NULL, NULL, NULL, BBFDM_BOTH},
{"ExecutionFaultMessage", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_ExecutionFaultMessage, NULL, NULL, NULL, BBFDM_BOTH},
{"AutoStart", &DMWRITE, DMT_BOOL, get_SoftwareModulesExecutionUnit_AutoStart, set_SoftwareModulesExecutionUnit_AutoStart, NULL, NULL, BBFDM_BOTH},
{"RunLevel", &DMWRITE, DMT_UNINT, get_SoftwareModulesExecutionUnit_RunLevel, set_SoftwareModulesExecutionUnit_RunLevel, NULL, NULL, BBFDM_BOTH},
//{"RequestedState", &DMWRITE, DMT_STRING, get_SoftwareModulesExecutionUnit_RequestedState, set_SoftwareModulesExecutionUnit_RequestedState, NULL, NULL, BBFDM_CWMP},
//{"ExecutionFaultCode", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_ExecutionFaultCode, NULL, NULL, NULL, BBFDM_BOTH},
//{"ExecutionFaultMessage", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_ExecutionFaultMessage, NULL, NULL, NULL, BBFDM_BOTH},
//{"AutoStart", &DMWRITE, DMT_BOOL, get_SoftwareModulesExecutionUnit_AutoStart, set_SoftwareModulesExecutionUnit_AutoStart, NULL, NULL, BBFDM_BOTH},
//{"RunLevel", &DMWRITE, DMT_UNINT, get_SoftwareModulesExecutionUnit_RunLevel, set_SoftwareModulesExecutionUnit_RunLevel, NULL, NULL, BBFDM_BOTH},
{"Vendor", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_Vendor, NULL, NULL, NULL, BBFDM_BOTH},
{"Version", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_Version, NULL, NULL, NULL, BBFDM_BOTH},
{"Description", &DMREAD, DMT_STRING, get_SoftwareModulesExecutionUnit_Description, NULL, NULL, NULL, BBFDM_BOTH},
@ -255,14 +255,19 @@ int get_SoftwareModulesExecEnv_Enable(char *refparam, struct dmctx *ctx, void *d
int set_SoftwareModulesExecEnv_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
char *env_name;
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
env_name = dmjson_get_value((json_object *)data, 1, "name");
if (strcmp(env_name, "OpenWRT_Linux")) {
if (value)
if (b)
dmcmd_no_wait("/usr/bin/lxc-start", 2, "-n", env_name);
else
dmcmd_no_wait("/usr/bin/lxc-stop", 2, "-n", env_name);
@ -287,15 +292,19 @@ int get_SoftwareModulesExecEnv_Reset(char *refparam, struct dmctx *ctx, void *da
int set_SoftwareModulesExecEnv_Reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
char *env_name;
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
env_name = dmjson_get_value((json_object *)data, 1, "name");
if (strcmp(env_name, "OpenWRT_Linux") == 0) {
if (value) dmcmd_no_wait("/sbin/defaultreset", 0);
if (b) dmcmd_no_wait("/sbin/defaultreset", 0);
}
break;
}
@ -326,6 +335,8 @@ int set_SoftwareModulesExecEnv_Alias(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
name = dmjson_get_value((json_object *)data, 1, "name");
@ -359,7 +370,7 @@ int get_SoftwareModulesExecEnv_Type(char *refparam, struct dmctx *ctx, void *dat
int get_SoftwareModulesExecEnv_InitialRunLevel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "-1";
//TODO
return 0;
}
@ -367,8 +378,11 @@ int set_SoftwareModulesExecEnv_InitialRunLevel(char *refparam, struct dmctx *ctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, "65535"))
return FAULT_9007;
break;
case VALUESET:
//TODO
break;
}
return 0;
@ -376,7 +390,7 @@ int set_SoftwareModulesExecEnv_InitialRunLevel(char *refparam, struct dmctx *ctx
int get_SoftwareModulesExecEnv_RequestedRunLevel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "-1";
//TODO
return 0;
}
@ -384,8 +398,11 @@ int set_SoftwareModulesExecEnv_RequestedRunLevel(char *refparam, struct dmctx *c
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", "65535"))
return FAULT_9007;
break;
case VALUESET:
//TODO
break;
}
return 0;
@ -393,13 +410,13 @@ int set_SoftwareModulesExecEnv_RequestedRunLevel(char *refparam, struct dmctx *c
int get_SoftwareModulesExecEnv_CurrentRunLevel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "-1";
//TODO
return 0;
}
int get_SoftwareModulesExecEnv_InitialExecutionUnitRunLevel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "-1";
//TODO
return 0;
}
@ -407,8 +424,11 @@ int set_SoftwareModulesExecEnv_InitialExecutionUnitRunLevel(char *refparam, stru
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", "65535"))
return FAULT_9007;
break;
case VALUESET:
//TODO
break;
}
return 0;
@ -545,6 +565,8 @@ int set_SoftwareModulesDeploymentUnit_Alias(char *refparam, struct dmctx *ctx, v
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
name = dmjson_get_value((json_object *)data, 1, "name");
@ -712,6 +734,8 @@ int set_SoftwareModulesExecutionUnit_Alias(char *refparam, struct dmctx *ctx, vo
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
euid = dmjson_get_value((json_object *)data, 1, "euid");
@ -758,7 +782,7 @@ int get_SoftwareModulesExecutionUnit_Status(char *refparam, struct dmctx *ctx, v
int get_SoftwareModulesExecutionUnit_RequestedState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "Active";
//TODO
return 0;
}
@ -766,8 +790,11 @@ int set_SoftwareModulesExecutionUnit_RequestedState(char *refparam, struct dmctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, RequestedState, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
break;
}
return 0;
@ -775,19 +802,19 @@ int set_SoftwareModulesExecutionUnit_RequestedState(char *refparam, struct dmctx
int get_SoftwareModulesExecutionUnit_ExecutionFaultCode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "NoFault";
//TODO
return 0;
}
int get_SoftwareModulesExecutionUnit_ExecutionFaultMessage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
//TODO
return 0;
}
int get_SoftwareModulesExecutionUnit_AutoStart(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
//TODO
return 0;
}
@ -795,8 +822,11 @@ int set_SoftwareModulesExecutionUnit_AutoStart(char *refparam, struct dmctx *ctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
break;
}
return 0;
@ -804,7 +834,7 @@ int set_SoftwareModulesExecutionUnit_AutoStart(char *refparam, struct dmctx *ctx
int get_SoftwareModulesExecutionUnit_RunLevel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
//TODO
return 0;
}
@ -812,8 +842,11 @@ int set_SoftwareModulesExecutionUnit_RunLevel(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, "65535"))
return FAULT_9007;
break;
case VALUESET:
//TODO
break;
}
return 0;

View file

@ -52,7 +52,8 @@ DMLEAF tATMLinkStatsParams[] = {
/**************************************************************************
* LINKER
***************************************************************************/
int get_atm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
int get_atm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
if (data && ((struct atm_args *)data)->ifname) {
*linker = ((struct atm_args *)data)->ifname;
return 0;
@ -81,33 +82,27 @@ int get_atm_destination_address(char *refparam, struct dmctx *ctx, void *data, c
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "vpi", &vpi);
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "vci", &vci);
dmasprintf(value, "PVC: %s/%s", vpi, vci); // MEM WILL BE FREED IN DMMEMCLEAN
dmasprintf(value, "%s/%s", vpi, vci); // MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
int set_atm_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *vpi = NULL, *vci = NULL, *spch, *val;
char *vpi = NULL, *vci = NULL, *spch;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, DestinationAddress))
return FAULT_9007;
return 0;
case VALUESET:
if (strstr(value, "PVC: "))
value += 5;
else
return 0;
val = dmstrdup(value);
vpi = strtok_r(val, "/", &spch);
if (vpi) {
vci = strtok_r(NULL, "/", &spch);
}
if (vpi && vci) {
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "vpi", vpi);
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "vci", vci);
}
dmfree(val);
break;
vpi = strtok_r(value, "/", &spch);
if (vpi)
vci = strtok_r(NULL, "/", &spch);
if (vpi && vci) {
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "vpi", vpi);
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "vci", vci);
}
return 0;
}
return 0;
@ -126,32 +121,27 @@ int get_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *i
char *encapsulation;
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "encapsulation", &encapsulation);
if (strcasecmp(encapsulation, "vcmux") == 0) {
if (strcmp(encapsulation, "vcmux") == 0)
*value = "VCMUX";
} else if (strcasecmp(encapsulation, "llc") == 0) {
else if (strcmp(encapsulation, "llc") == 0)
*value = "LLC";
} else {
else
*value = "";
}
return 0;
}
int set_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *encapsulation;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, Encapsulation, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "VCMUX") == 0)
encapsulation = "vcmux";
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "encapsulation", "vcmux");
else if (strcmp(value, "LLC") == 0)
encapsulation = "llc";
else
return 0;
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "encapsulation", encapsulation);
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "encapsulation", "llc");
return 0;
}
return 0;
@ -160,8 +150,19 @@ int set_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *i
/*#Device.ATM.Link.{i}.LinkType!UCI:dsl/atm-device,@i-1/link_type*/
int get_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "link_type", value);
char *link_type;
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "link_type", &link_type);
if (strcmp(link_type, "eoa") == 0)
*value = "EoA";
else if (strcmp(link_type, "ipoa") == 0)
*value = "IPoA";
else if (strcmp(link_type, "pppoa") == 0)
*value = "PPPoA";
else if (strcmp(link_type, "cip") == 0)
*value = "CIP";
else
*value = "Unconfigured";
return 0;
}
@ -169,9 +170,20 @@ int set_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, LinkType, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "link_type", value);
if (strcmp(value, "EoA") == 0)
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "link_type", "eoa");
else if (strcmp(value, "IPoA") == 0)
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "link_type", "ipoa");
else if (strcmp(value, "PPPoA") == 0)
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "link_type", "pppoa");
else if (strcmp(value, "CIP") == 0)
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "link_type", "cip");
else
dmuci_set_value_by_section(((struct atm_args *)data)->atm_sec, "link_type", "");
return 0;
}
return 0;
@ -317,23 +329,27 @@ int delete_atm_link(char *refparam, struct dmctx *ctx, void *data, char *instanc
*************************************************************/
int get_atm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(((struct atm_args *)data)->atm_sec), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "atmlinkalias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "atmlinkalias", value);
return 0;
}
int set_atm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_dsl", "atm-device", section_name(((struct atm_args *)data)->atm_sec), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "atmlinkalias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "atmlinkalias", value);
return 0;
}
return 0;

View file

@ -71,7 +71,7 @@ DMLEAF tBridgingBridgePortParams[] = {
{"Name", &DMREAD, DMT_STRING, get_br_port_name, NULL, NULL, NULL, BBFDM_BOTH},
{"LastChange", &DMREAD, DMT_UNINT, get_br_port_last_change, NULL, NULL, NULL, BBFDM_BOTH},
{"LowerLayers", &DMWRITE, DMT_STRING, get_port_lower_layer, set_port_lower_layer, NULL, NULL, BBFDM_BOTH},
{"ManagementPort", &DMWRITE, DMT_STRING, get_br_port_management, set_br_port_management, NULL, NULL, BBFDM_BOTH},
{"ManagementPort", &DMWRITE, DMT_BOOL, get_br_port_management, set_br_port_management, NULL, NULL, BBFDM_BOTH},
{"Type", &DMWRITE, DMT_STRING, get_br_port_type, set_br_port_type, NULL, NULL, BBFDM_BOTH},
{"DefaultUserPriority", &DMWRITE, DMT_UNINT, get_br_port_default_user_priority, set_br_port_default_user_priority, NULL, NULL, BBFDM_BOTH},
{"PriorityRegeneration", &DMWRITE, DMT_STRING, get_br_port_priority_regeneration, set_br_port_priority_regeneration, NULL, NULL, BBFDM_BOTH},
@ -84,20 +84,20 @@ DMLEAF tBridgingBridgePortParams[] = {
/*** Bridging.Bridge.{i}.Port.{i}.Stats. ***/
DMLEAF tBridgingBridgePortStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNINT, get_br_port_stats_tx_bytes, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNINT, get_br_port_stats_rx_bytes, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, get_br_port_stats_tx_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_br_port_stats_rx_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesSent", &DMREAD, DMT_UNLONG, get_br_port_stats_tx_bytes, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_br_port_stats_rx_bytes, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_br_port_stats_tx_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_br_port_stats_rx_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_br_port_stats_tx_errors, NULL, NULL, NULL, BBFDM_BOTH},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_br_port_stats_rx_errors, NULL, NULL, NULL, BBFDM_BOTH},
{"UnicastPacketsSent", &DMREAD, DMT_UNINT, get_br_port_stats_tx_unicast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"UnicastPacketsReceived", &DMREAD, DMT_UNINT, get_br_port_stats_rx_unicast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"UnicastPacketsSent", &DMREAD, DMT_UNLONG, get_br_port_stats_tx_unicast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"UnicastPacketsReceived", &DMREAD, DMT_UNLONG, get_br_port_stats_rx_unicast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_br_port_stats_tx_discard_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_br_port_stats_rx_discard_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"MulticastPacketsSent", &DMREAD, DMT_UNINT, get_br_port_stats_tx_multicast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"MulticastPacketsReceived", &DMREAD, DMT_UNINT, get_br_port_stats_rx_multicast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"BroadcastPacketsSent", &DMREAD, DMT_UNINT, get_br_port_stats_tx_broadcast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"BroadcastPacketsReceived", &DMREAD, DMT_UNINT, get_br_port_stats_rx_broadcast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"MulticastPacketsSent", &DMREAD, DMT_UNLONG, get_br_port_stats_tx_multicast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"MulticastPacketsReceived", &DMREAD, DMT_UNLONG, get_br_port_stats_rx_multicast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"BroadcastPacketsSent", &DMREAD, DMT_UNLONG, get_br_port_stats_tx_broadcast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"BroadcastPacketsReceived", &DMREAD, DMT_UNLONG, get_br_port_stats_rx_broadcast_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"UnknownProtoPacketsReceived", &DMREAD, DMT_UNINT, get_br_port_stats_rx_unknown_proto_packets, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -108,7 +108,7 @@ DMLEAF tBridgingBridgeVLANParams[] = {
{"Enable", &DMWRITE, DMT_BOOL, get_br_vlan_enable, set_br_vlan_enable, NULL, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING,get_br_vlan_alias, set_br_vlan_alias, NULL, NULL, BBFDM_BOTH},
{"Name", &DMWRITE, DMT_STRING, get_br_vlan_name, set_br_vlan_name, NULL, NULL, BBFDM_BOTH},
{"VLANID", &DMWRITE, DMT_STRING, get_br_vlan_vid, set_br_vlan_vid, NULL, NULL, BBFDM_BOTH},
{"VLANID", &DMWRITE, DMT_INT, get_br_vlan_vid, set_br_vlan_vid, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"VLANPriority", &DMWRITE, DMT_STRING, get_br_vlan_priority, set_br_vlan_priority, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -129,8 +129,8 @@ DMLEAF tBridgingBridgeVLANPortParams[] = {
***************************************************************************/
int get_linker_br_port(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
if(data && ((struct bridging_port_args *)data)->bridge_port_sec) {
dmasprintf(linker,"%s+%s", section_name(((struct bridging_port_args *)data)->bridge_port_sec), ((struct bridging_port_args *)data)->ifname);
if (data && ((struct bridging_port_args *)data)->bridge_port_sec) {
dmasprintf(linker, "%s+%s", section_name(((struct bridging_port_args *)data)->bridge_port_sec), ((struct bridging_port_args *)data)->ifname);
return 0;
}
*linker = "";
@ -139,8 +139,8 @@ int get_linker_br_port(char *refparam, struct dmctx *dmctx, void *data, char *in
int get_linker_br_vlan(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
if(data && ((struct bridging_vlan_args *)data)->vlan_port) {
dmasprintf(linker,"vlan%s_%s", ((struct bridging_vlan_args *)data)->vlan_port, ((struct bridging_vlan_args *)data)->br_inst);
if (data && ((struct bridging_vlan_args *)data)->vlan_port) {
dmasprintf(linker, "vlan%s_%s", ((struct bridging_vlan_args *)data)->vlan_port, ((struct bridging_vlan_args *)data)->br_inst);
return 0;
}
*linker = "";
@ -189,10 +189,10 @@ char *get_last_vid(void)
if(!vlan_s)
break;
dmuci_get_value_by_section_string(vlan_s, "type", &type);
if (strcmp(type, "untagged")==0)
if (strcmp(type, "untagged") == 0)
continue;
dmuci_get_value_by_section_string(vlan_s, "vid", &vid);
if( atoi(vid)> num_vid )
if (atoi(vid) > num_vid)
num_vid = atoi(vid);
dmasprintf(&vid, "%d", num_vid);
}
@ -206,7 +206,7 @@ int check_ifname_exist_in_br_ifname_list(char *ifname)
uci_foreach_option_eq("network", "interface", "type", "bridge", s) {
dmuci_get_value_by_section_string(s, "ifname", &br_ifname_list);
if(br_ifname_list[0] == '\0')
if (br_ifname_list[0] == '\0')
return 0;
br_ifname_dup = dmstrdup(br_ifname_list);
for (pch = strtok_r(br_ifname_dup, " ", &spch); pch != NULL; pch = strtok_r(NULL, " ", &spch)) {
@ -404,8 +404,7 @@ int get_Bridge_Number_Of_Entries(char *refparam, struct dmctx *ctx, void *data,
struct uci_section *s = NULL;
int cnt = 0;
uci_foreach_option_eq("network", "interface", "type", "bridge", s)
{
uci_foreach_option_eq("network", "interface", "type", "bridge", s) {
cnt++;
}
dmasprintf(value, "%d", cnt);
@ -428,7 +427,7 @@ int set_br_enable(char *refparam, struct dmctx *ctx, void *data, char *instance,
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -447,7 +446,7 @@ int get_br_status(char *refparam, struct dmctx *ctx, void *data, char *instance,
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(((struct bridging_args *)data)->bridge_sec), String}}, 1, &res);
DM_ASSERT(res, *value = "Disabled");
*value = dmjson_get_value(res, 1, "up");
if(strcmp(*value, "true") == 0)
if (strcmp(*value, "true") == 0)
*value = "Enabled";
else
*value = "Disabled";
@ -464,6 +463,8 @@ int set_br_standard(char *refparam, struct dmctx *ctx, void *data, char *instanc
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, BridgeStandard, NULL))
return FAULT_9007;
return 0;
case VALUESET:
return 0;
@ -517,6 +518,8 @@ int set_br_associated_interfaces(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct bridging_args *)data)->bridge_sec, "ifname", value);
@ -555,10 +558,9 @@ int get_br_port_enable(char *refparam, struct dmctx *ctx, void *data, char *inst
int set_br_port_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -573,10 +575,7 @@ int get_br_port_status(char *refparam, struct dmctx *ctx, void *data, char *inst
bool b;
get_br_port_enable(refparam, ctx, data, instance, value);
string_to_bool(*value, &b);
if (b)
*value = "Up";
else
*value = "Down";
*value = b ? "Up" : "Down";
return 0;
}
@ -603,17 +602,17 @@ int get_br_port_management(char *refparam, struct dmctx *ctx, void *data, char *
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_bridge_port", "bridge_port", section_name(((struct bridging_port_args *)data)->bridge_port_sec), &dmmap_section);
if (!dmmap_section) dmmap_section = ((struct bridging_port_args *)data)->bridge_port_sec;
if (!dmmap_section)
dmmap_section = ((struct bridging_port_args *)data)->bridge_port_sec;
dmuci_get_value_by_section_string(dmmap_section, "mg_port", value);
return 0;
}
int set_br_port_management(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -646,6 +645,8 @@ int set_br_port_type(char *refparam, struct dmctx *ctx, void *data, char *instan
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, BridgeType, NULL))
return FAULT_9007;
return 0;
case VALUESET:
return 0;
@ -676,6 +677,8 @@ int set_br_port_default_user_priority(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "7"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct bridging_port_args *)data)->bridge_port_sec, "name", &name);
@ -700,6 +703,8 @@ int set_br_port_priority_regeneration(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt_list(value, "8", "8", NULL, "0", "7"))
return FAULT_9007;
return 0;
case VALUESET:
return 0;
@ -710,6 +715,7 @@ int set_br_port_priority_regeneration(char *refparam, struct dmctx *ctx, void *d
int get_br_port_port_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *name;
dmuci_get_value_by_section_string(((struct bridging_port_args *)data)->bridge_port_sec, "name", &name);
if (check_if_ifname_is_tagged(name) != NULL)
*value = "Forwarding";
@ -742,6 +748,8 @@ int set_br_port_pvid(char *refparam, struct dmctx *ctx, void *data, char *instan
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "1", "4094"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct bridging_port_args *)data)->bridge_port_sec, "name", &name);
@ -769,13 +777,14 @@ int set_br_port_pvid(char *refparam, struct dmctx *ctx, void *data, char *instan
int get_br_port_tpid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *type;
dmuci_get_value_by_section_string(((struct bridging_port_args *)data)->bridge_port_sec, "type", &type);
if (strcmp(type, "8021q") == 0 || strcmp(type, "untagged") == 0)
*value = "33024";
else if (strcmp(type, "8021ad") == 0)
*value = "34984";
else
*value = "";
*value = "37120";
return 0;
}
@ -783,6 +792,8 @@ int set_br_port_tpid(char *refparam, struct dmctx *ctx, void *data, char *instan
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "33024") == 0)
@ -943,8 +954,7 @@ static int update_br_vlan_ifname(struct bridging_vlan_args *curr_arg, int status
int get_br_vlan_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "false";
int status;
status = is_bridge_vlan_enabled((struct bridging_vlan_args *)data);
int status = is_bridge_vlan_enabled((struct bridging_vlan_args *)data);
if (status)
*value = "true";
return 0;
@ -957,7 +967,7 @@ int set_br_vlan_enable(char *refparam, struct dmctx *ctx, void *data, char *inst
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -984,9 +994,11 @@ int set_br_vlan_name(char *refparam, struct dmctx *ctx, void *data, char *instan
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_rename_section_by_section(((struct bridging_vlan_args *)data)->bridge_vlan_sec,value);
dmuci_rename_section_by_section(((struct bridging_vlan_args *)data)->bridge_vlan_sec, value);
return 0;
}
return 0;
@ -1005,6 +1017,8 @@ int set_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *instanc
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "1", "4094"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct bridging_vlan_args *)data)->bridge_vlan_sec, "vid", value);
@ -1032,6 +1046,7 @@ int set_br_vlan_priority(char *refparam, struct dmctx *ctx, void *data, char *in
{
switch (action) {
case VALUECHECK:
//TODO
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct bridging_vlan_args *)data)->bridge_vlan_sec, "priority", value);
@ -1044,23 +1059,27 @@ int set_br_vlan_priority(char *refparam, struct dmctx *ctx, void *data, char *in
**************************************************************/
int get_br_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct bridging_args *)data)->bridge_sec), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "bridge_alias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "bridge_alias", value);
return 0;
}
int set_br_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct bridging_args *)data)->bridge_sec), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "bridge_alias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "bridge_alias", value);
return 0;
}
return 0;
@ -1071,7 +1090,8 @@ int get_br_port_alias(char *refparam, struct dmctx *ctx, void *data, char *insta
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_bridge_port", "bridge_port", section_name(((struct bridging_port_args *)data)->bridge_port_sec), &dmmap_section);
if (!dmmap_section) dmmap_section= ((struct bridging_port_args *)data)->bridge_port_sec;
if (!dmmap_section)
dmmap_section = ((struct bridging_port_args *)data)->bridge_port_sec;
dmuci_get_value_by_section_string(dmmap_section, "bridge_port_alias", value);
return 0;
}
@ -1082,10 +1102,13 @@ int set_br_port_alias(char *refparam, struct dmctx *ctx, void *data, char *insta
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_bridge_port", "bridge_port", section_name(((struct bridging_port_args *)data)->bridge_port_sec), &dmmap_section);
if(!dmmap_section) dmmap_section= ((struct bridging_port_args *)data)->bridge_port_sec;
if(!dmmap_section)
dmmap_section = ((struct bridging_port_args *)data)->bridge_port_sec;
dmuci_set_value_by_section(dmmap_section, "bridge_port_alias", value);
return 0;
}
@ -1094,23 +1117,27 @@ int set_br_port_alias(char *refparam, struct dmctx *ctx, void *data, char *insta
int get_br_vlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(((struct bridging_vlan_args *)data)->bridge_vlan_sec), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "bridge_vlan_alias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "bridge_vlan_alias", value);
return 0;
}
int set_br_vlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(((struct bridging_vlan_args *)data)->bridge_vlan_sec), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "bridge_vlan_alias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "bridge_vlan_alias", value);
return 0;
}
return 0;
@ -1124,7 +1151,7 @@ int add_bridge(char *refparam, struct dmctx *ctx, void *data, char **instance)
char *last_inst, *v;
char bridge_name[16], ib[8];
char *p = bridge_name;
struct uci_section* dmmap_bridge= NULL;
struct uci_section* dmmap_bridge = NULL;
last_inst = get_last_instance_lev2_bbfdm("network", "interface", "dmmap_network", "bridge_instance", "type", "bridge");
snprintf(ib, sizeof(ib), "%d", last_inst ? atoi(last_inst)+1 : 1);
@ -1432,6 +1459,8 @@ int set_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *in
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, "1024", NULL, NULL, NULL, NULL))
return FAULT_9007;
get_dmmap_section_of_config_section("dmmap_bridge_port", "bridge_port", section_name(((struct bridging_port_args *)data)->bridge_port_sec), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "mg_port", &mg_port);
if (value[strlen(value)-1]!='.') {
@ -1503,7 +1532,7 @@ int set_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *in
int get_vlan_port_vlan_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char linker[8];
snprintf(linker, sizeof(linker),"vlan%s_%s", ((struct bridging_vlan_args *)data)->vlan_port, ((struct bridging_vlan_args *)data)->br_inst);
snprintf(linker, sizeof(linker), "vlan%s_%s", ((struct bridging_vlan_args *)data)->vlan_port, ((struct bridging_vlan_args *)data)->br_inst);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
@ -1514,6 +1543,8 @@ int set_vlan_port_vlan_ref(char *refparam, struct dmctx *ctx, void *data, char *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
return 0;
@ -1525,7 +1556,7 @@ int get_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data, char *
{
char linker[16], *name;
dmuci_get_value_by_section_string(((struct bridging_vlan_args *)data)->bridge_vlan_sec, "name", &name);
snprintf(linker, sizeof(linker),"%s+%s", section_name(((struct bridging_vlan_args *)data)->bridge_vlan_sec), name);
snprintf(linker, sizeof(linker), "%s+%s", section_name(((struct bridging_vlan_args *)data)->bridge_vlan_sec), name);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cBridging%cBridge%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
@ -1534,11 +1565,12 @@ int get_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data, char *
int set_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *linker = NULL, *vid, *enable, *vifname, tmp[8], *pch, *p, *br_ifname;
char new_ifname[16];
char *linker = NULL, *vid, *enable, *vifname, *pch, *p, *br_ifname, tmp[8], new_ifname[16];
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
@ -1604,6 +1636,8 @@ int set_br_vlan_untagged(char *refparam, struct dmctx *ctx, void *data, char *in
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
return 0;

View file

@ -12,6 +12,6 @@
int get_Device_RootDataModelVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= "2.13";
*value = "2.13";
return 0;
}

View file

@ -36,8 +36,8 @@ DMLEAF tDeviceInfoParams[] = {
{"SpecVersion", &DMREAD, DMT_STRING, get_device_specversion, NULL, &DMFINFRM, NULL, BBFDM_BOTH},
{"ProvisioningCode", &DMWRITE, DMT_STRING, get_device_provisioningcode, set_device_provisioningcode, &DMFINFRM, &DMACTIVE, BBFDM_BOTH},
{CUSTOM_PREFIX"BaseMacAddr", &DMREAD, DMT_STRING, get_base_mac_addr, NULL, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"CATVEnabled", &DMWRITE, DMT_STRING, get_catv_enabled, set_device_catvenabled, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"MemoryBank", &DMWRITE, DMT_STRING, get_device_memory_bank, set_device_memory_bank, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"CATVEnabled", &DMWRITE, DMT_BOOL, get_catv_enabled, set_device_catvenabled, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"MemoryBank", &DMWRITE, DMT_INT, get_device_memory_bank, set_device_memory_bank, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -157,7 +157,7 @@ char *get_deviceid_manufactureroui()
}
}
} else
mac = dm_ubus_get_value(res, 2, "system", "basemac");
mac = dmjson_get_value(res, 2, "system", "basemac");
if(mac) {
size_t ln = strlen(mac);
@ -272,7 +272,7 @@ int get_device_devicelog(char *refparam, struct dmctx *ctx, void *data, char *in
return 0;
buff[len] = '\0';
char *p = buff;
while (*p) { //TODO to optimize, we can avoid this if the '<' and '>' does not cause problem in the tests.
while (*p) {
if (*p == '<') {
*p = '(';
if (p == buff || *(p-1) == '\n') {
@ -288,7 +288,7 @@ int get_device_devicelog(char *refparam, struct dmctx *ctx, void *data, char *in
*p = ')';
p++;
}
if(msg == NULL)
if (msg == NULL)
*value = "";
else
*value = dmstrdup(msg);// MEM WILL BE FREED IN DMMEMCLEAN
@ -311,7 +311,9 @@ int get_device_provisioningcode(char *refparam, struct dmctx *ctx, void *data, c
int set_device_provisioningcode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "cpe", "provisioning_code", value);
@ -325,7 +327,7 @@ int get_base_mac_addr(char *refparam, struct dmctx *ctx, void *data, char *insta
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dm_ubus_get_value(res, 2, "system", "basemac");
*value = dmjson_get_value(res, 2, "system", "basemac");
return 0;
}
@ -334,7 +336,7 @@ int get_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *
json_object *res;
dmubus_call("router.system", "memory_bank", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dm_ubus_get_value(res, 1, "code");
*value = dmjson_get_value(res, 1, "code");
return 0;
}
@ -342,6 +344,7 @@ int set_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *
{
switch (action) {
case VALUECHECK:
//TODO
return 0;
case VALUESET:
dmubus_call_set("router.system", "memory_bank", UBUS_ARGS{{"bank", value, Integer}}, 1);
@ -364,19 +367,14 @@ int get_catv_enabled(char *refparam, struct dmctx *ctx, void *data, char *instan
int set_device_catvenabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
char *stat;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
stat = "on";
else
stat = "off";
dmuci_set_value("catv", "catv", "enable", stat);
dmuci_set_value("catv", "catv", "enable", b ? "on" : "off");
return 0;
}
return 0;
@ -387,7 +385,7 @@ int get_catv_optical_input_level(char *refparam, struct dmctx *ctx, void *data,
json_object *res;
dmubus_call("catv", "vpd", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dm_ubus_get_value(res, 1, "VPD");
*value = dmjson_get_value(res, 1, "VPD");
return 0;
}
@ -396,7 +394,7 @@ int get_catv_rf_output_level(char *refparam, struct dmctx *ctx, void *data, char
json_object *res;
dmubus_call("catv", "rf", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dm_ubus_get_value(res, 1, "RF");
*value = dmjson_get_value(res, 1, "RF");
return 0;
}
@ -405,7 +403,7 @@ int get_catv_temperature(char *refparam, struct dmctx *ctx, void *data, char *in
json_object *res;
dmubus_call("catv", "temp", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dm_ubus_get_value(res, 1, "Temperature");
*value = dmjson_get_value(res, 1, "Temperature");
return 0;
}
@ -414,7 +412,7 @@ int get_catv_voltage(char *refparam, struct dmctx *ctx, void *data, char *instan
json_object *res;
dmubus_call("catv", "vcc", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dm_ubus_get_value(res, 1, "VCC");
*value = dmjson_get_value(res, 1, "VCC");
return 0;
}
@ -476,6 +474,8 @@ int set_vcf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "vcf_alias", value);
@ -519,6 +519,8 @@ int set_vlf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "vlf_alias", value);
@ -552,7 +554,7 @@ int get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "0");
*value = dm_ubus_get_value(res, 2, "memoryKB", "total");
*value = dmjson_get_value(res, 2, "memoryKB", "total");
return 0;
}
@ -562,7 +564,7 @@ int get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "0");
*value = dm_ubus_get_value(res, 2, "memoryKB", "free");
*value = dmjson_get_value(res, 2, "memoryKB", "free");
return 0;
}
@ -572,7 +574,7 @@ int get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *i
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
DM_ASSERT(res, *value = "0");
*value = dm_ubus_get_value(res, 2, "system", "cpu_per");
*value = dmjson_get_value(res, 2, "system", "cpu_per");
return 0;
}
@ -620,7 +622,7 @@ int get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *in
if (val < 0) val = 0;
dmasprintf(value, "%ld", val);
} else
*value= "0";
*value = "0";
return 0;
}

View file

@ -92,9 +92,9 @@ DMLEAF tDHCPv4ClientParams[] = {
{"IPRouters", &DMREAD, DMT_STRING, get_DHCPv4Client_IPRouters, NULL, NULL, NULL, BBFDM_BOTH},
{"DNSServers", &DMREAD, DMT_STRING, get_DHCPv4Client_DNSServers, NULL, NULL, NULL, BBFDM_BOTH},
{"LeaseTimeRemaining", &DMREAD, DMT_INT, get_DHCPv4Client_LeaseTimeRemaining, NULL, NULL, NULL, BBFDM_BOTH},
{"DHCPServer", &DMREAD, DMT_STRING, get_DHCPv4Client_DHCPServer, NULL, NULL, NULL, BBFDM_BOTH},
{"PassthroughEnable", &DMWRITE, DMT_BOOL, get_DHCPv4Client_PassthroughEnable, set_DHCPv4Client_PassthroughEnable, NULL, NULL, BBFDM_BOTH},
{"PassthroughDHCPPool", &DMWRITE, DMT_STRING, get_DHCPv4Client_PassthroughDHCPPool, set_DHCPv4Client_PassthroughDHCPPool, NULL, NULL, BBFDM_BOTH},
//{"DHCPServer", &DMREAD, DMT_STRING, get_DHCPv4Client_DHCPServer, NULL, NULL, NULL, BBFDM_BOTH},
//{"PassthroughEnable", &DMWRITE, DMT_BOOL, get_DHCPv4Client_PassthroughEnable, set_DHCPv4Client_PassthroughEnable, NULL, NULL, BBFDM_BOTH},
//{"PassthroughDHCPPool", &DMWRITE, DMT_STRING, get_DHCPv4Client_PassthroughDHCPPool, set_DHCPv4Client_PassthroughDHCPPool, NULL, NULL, BBFDM_BOTH},
{"SentOptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv4Client_SentOptionNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{"ReqOptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv4Client_ReqOptionNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
@ -114,16 +114,16 @@ DMLEAF tDHCPv4ClientSentOptionParams[] = {
DMLEAF tDHCPv4ClientReqOptionParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv4ClientReqOption_Enable, set_DHCPv4ClientReqOption_Enable, NULL, NULL, BBFDM_BOTH},
{"Order", &DMWRITE, DMT_UNINT, get_DHCPv4ClientReqOption_Order, set_DHCPv4ClientReqOption_Order, NULL, NULL, BBFDM_BOTH},
//{"Order", &DMWRITE, DMT_UNINT, get_DHCPv4ClientReqOption_Order, set_DHCPv4ClientReqOption_Order, NULL, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv4ClientReqOption_Alias, set_DHCPv4ClientReqOption_Alias, NULL, NULL, BBFDM_BOTH},
{"Tag", &DMWRITE, DMT_UNINT, get_DHCPv4ClientReqOption_Tag, set_DHCPv4ClientReqOption_Tag, NULL, NULL, BBFDM_BOTH},
{"Value", &DMREAD, DMT_HEXBIN, get_DHCPv4ClientReqOption_Value, NULL, NULL, NULL, BBFDM_BOTH},
//{"Value", &DMREAD, DMT_HEXBIN, get_DHCPv4ClientReqOption_Value, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tDHCPv4ServerParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv4Server_Enable, set_DHCPv4Server_Enable, NULL, NULL, BBFDM_BOTH},
//{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv4Server_Enable, set_DHCPv4Server_Enable, NULL, NULL, BBFDM_BOTH},
{"PoolNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv4Server_PoolNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -148,7 +148,7 @@ DMOBJ tDHCPv4ServerPoolObj[] = {
DMOBJ tDHCPv4ServerPoolClientObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/
{"IPv4Address", &DMREAD, NULL, NULL, NULL, browseDhcpClientIPv4Inst, NULL, NULL, NULL, NULL, tDHCPv4ServerPoolClientIPv4AddressParams, NULL, BBFDM_BOTH},
{"Option", &DMREAD, NULL, NULL, NULL, browseDHCPv4ServerPoolClientOptionInst, NULL, NULL, NULL, NULL, tDHCPv4ServerPoolClientOptionParams, NULL, BBFDM_BOTH},
//{"Option", &DMREAD, NULL, NULL, NULL, browseDHCPv4ServerPoolClientOptionInst, NULL, NULL, NULL, NULL, tDHCPv4ServerPoolClientOptionParams, NULL, BBFDM_BOTH},
{0}
};
@ -187,7 +187,7 @@ DMLEAF tDHCPv4ServerPoolAddressParams[] = {
DMLEAF tDHCPv4ServerPoolClientParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Chaddr", &DMREAD, DMT_STRING, get_dhcp_client_chaddr, NULL, NULL, NULL, BBFDM_BOTH},
{"Active", &DMREAD, DMT_STRING, get_dhcp_client_active, NULL, NULL, NULL, BBFDM_BOTH},
{"Active", &DMREAD, DMT_BOOL, get_dhcp_client_active, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -195,7 +195,7 @@ DMLEAF tDHCPv4ServerPoolClientParams[] = {
DMLEAF tDHCPv4ServerPoolClientIPv4AddressParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"LeaseTimeRemaining", &DMREAD, DMT_TIME, get_dhcp_client_ipv4address_leasetime, NULL, NULL, NULL, BBFDM_BOTH},
{"IPAddress", &DMREAD, DMT_TIME, get_dhcp_client_ipv4address_ip_address, NULL, NULL, NULL, BBFDM_BOTH},
{"IPAddress", &DMREAD, DMT_STRING, get_dhcp_client_ipv4address_ip_address, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -212,8 +212,8 @@ DMLEAF tDHCPv4ServerPoolOptionParams[] = {
/* *** Device.DHCPv4.Server.Pool.{i}.Client.{i}.Option.{i}. *** */
DMLEAF tDHCPv4ServerPoolClientOptionParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Tag", &DMREAD, DMT_UNINT, get_DHCPv4ServerPoolClientOption_Tag, NULL, NULL, NULL, BBFDM_BOTH},
{"Value", &DMREAD, DMT_HEXBIN, get_DHCPv4ServerPoolClientOption_Value, NULL, NULL, NULL, BBFDM_BOTH},
//{"Tag", &DMREAD, DMT_UNINT, get_DHCPv4ServerPoolClientOption_Tag, NULL, NULL, NULL, BBFDM_BOTH},
//{"Value", &DMREAD, DMT_HEXBIN, get_DHCPv4ServerPoolClientOption_Value, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -237,20 +237,20 @@ DMLEAF tDHCPv4RelayForwardingParams[] = {
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv4RelayForwarding_Enable, set_DHCPv4RelayForwarding_Enable, NULL, NULL, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_DHCPv4RelayForwarding_Status, NULL, NULL, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv4RelayForwarding_Alias, set_DHCPv4RelayForwarding_Alias, NULL, NULL, BBFDM_BOTH},
{"Order", &DMWRITE, DMT_UNINT, get_DHCPv4RelayForwarding_Order, set_DHCPv4RelayForwarding_Order, NULL, NULL, BBFDM_BOTH},
//{"Order", &DMWRITE, DMT_UNINT, get_DHCPv4RelayForwarding_Order, set_DHCPv4RelayForwarding_Order, NULL, NULL, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_DHCPv4RelayForwarding_Interface, set_DHCPv4RelayForwarding_Interface, NULL, NULL, BBFDM_BOTH},
{"VendorClassID", &DMWRITE, DMT_STRING, get_DHCPv4RelayForwarding_VendorClassID, set_DHCPv4RelayForwarding_VendorClassID, NULL, NULL, BBFDM_BOTH},
{"VendorClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv4RelayForwarding_VendorClassIDExclude, set_DHCPv4RelayForwarding_VendorClassIDExclude, NULL, NULL, BBFDM_BOTH},
{"VendorClassIDMode", &DMWRITE, DMT_STRING, get_DHCPv4RelayForwarding_VendorClassIDMode, set_DHCPv4RelayForwarding_VendorClassIDMode, NULL, NULL, BBFDM_BOTH},
{"ClientID", &DMWRITE, DMT_HEXBIN, get_DHCPv4RelayForwarding_ClientID, set_DHCPv4RelayForwarding_ClientID, NULL, NULL, BBFDM_BOTH},
{"ClientIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv4RelayForwarding_ClientIDExclude, set_DHCPv4RelayForwarding_ClientIDExclude, NULL, NULL, BBFDM_BOTH},
//{"VendorClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv4RelayForwarding_VendorClassIDExclude, set_DHCPv4RelayForwarding_VendorClassIDExclude, NULL, NULL, BBFDM_BOTH},
//{"VendorClassIDMode", &DMWRITE, DMT_STRING, get_DHCPv4RelayForwarding_VendorClassIDMode, set_DHCPv4RelayForwarding_VendorClassIDMode, NULL, NULL, BBFDM_BOTH},
//{"ClientID", &DMWRITE, DMT_HEXBIN, get_DHCPv4RelayForwarding_ClientID, set_DHCPv4RelayForwarding_ClientID, NULL, NULL, BBFDM_BOTH},
//{"ClientIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv4RelayForwarding_ClientIDExclude, set_DHCPv4RelayForwarding_ClientIDExclude, NULL, NULL, BBFDM_BOTH},
{"UserClassID", &DMWRITE, DMT_HEXBIN, get_DHCPv4RelayForwarding_UserClassID, set_DHCPv4RelayForwarding_UserClassID, NULL, NULL, BBFDM_BOTH},
{"UserClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv4RelayForwarding_UserClassIDExclude, set_DHCPv4RelayForwarding_UserClassIDExclude, NULL, NULL, BBFDM_BOTH},
//{"UserClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv4RelayForwarding_UserClassIDExclude, set_DHCPv4RelayForwarding_UserClassIDExclude, NULL, NULL, BBFDM_BOTH},
{"Chaddr", &DMWRITE, DMT_STRING, get_DHCPv4RelayForwarding_Chaddr, set_DHCPv4RelayForwarding_Chaddr, NULL, NULL, BBFDM_BOTH},
{"ChaddrMask", &DMWRITE, DMT_STRING, get_DHCPv4RelayForwarding_ChaddrMask, set_DHCPv4RelayForwarding_ChaddrMask, NULL, NULL, BBFDM_BOTH},
{"ChaddrExclude", &DMWRITE, DMT_BOOL, get_DHCPv4RelayForwarding_ChaddrExclude, set_DHCPv4RelayForwarding_ChaddrExclude, NULL, NULL, BBFDM_BOTH},
{"LocallyServed", &DMWRITE, DMT_BOOL, get_DHCPv4RelayForwarding_LocallyServed, set_DHCPv4RelayForwarding_LocallyServed, NULL, NULL, BBFDM_BOTH},
{"DHCPServerIPAddress", &DMWRITE, DMT_STRING, get_DHCPv4RelayForwarding_DHCPServerIPAddress, set_DHCPv4RelayForwarding_DHCPServerIPAddress, NULL, NULL, BBFDM_BOTH},
//{"LocallyServed", &DMWRITE, DMT_BOOL, get_DHCPv4RelayForwarding_LocallyServed, set_DHCPv4RelayForwarding_LocallyServed, NULL, NULL, BBFDM_BOTH},
//{"DHCPServerIPAddress", &DMWRITE, DMT_STRING, get_DHCPv4RelayForwarding_DHCPServerIPAddress, set_DHCPv4RelayForwarding_DHCPServerIPAddress, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -341,7 +341,7 @@ int add_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char **instan
{
char *value, *v;
char *instance;
struct uci_section *s = NULL, *dmmap_dhcp= NULL;
struct uci_section *s = NULL, *dmmap_dhcp = NULL;
check_create_dmmap_package("dmmap_dhcp");
instance = get_last_instance_bbfdm("dmmap_dhcp", "dhcp", "dhcp_instance");
@ -359,7 +359,7 @@ int add_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char **instan
int delete_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
int found = 0;
struct uci_section *s = NULL, *ss = NULL, *dmmap_section= NULL;
struct uci_section *s = NULL, *ss = NULL, *dmmap_section = NULL;
switch (del_action) {
case DEL_INST:
@ -370,7 +370,7 @@ int delete_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char *inst
dmuci_delete_by_section_unnamed(((struct dhcp_args *)data)->dhcp_sec, NULL, NULL);
} else {
get_dmmap_section_of_config_section("dmmap_dhcp", "dhcp", section_name(((struct dhcp_args *)data)->dhcp_sec), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section_unnamed_bbfdm(dmmap_section, NULL, NULL);
dmuci_delete_by_section(((struct dhcp_args *)data)->dhcp_sec, NULL, NULL);
}
@ -380,7 +380,7 @@ int delete_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char *inst
uci_foreach_sections("dhcp", "dhcp", s) {
if (found != 0){
get_dmmap_section_of_config_section("dmmap_dhcp", "dhcp", section_name(s), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
@ -389,7 +389,7 @@ int delete_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char *inst
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_dhcp", "dhcp", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
@ -430,7 +430,8 @@ int delete_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *data, cha
dmuci_delete_by_section_unnamed(dhcpargs->dhcpsection, NULL, NULL);
} else {
get_dmmap_section_of_config_section("dmmap_dhcp", "host", section_name(dhcpargs->dhcpsection), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(dhcpargs->dhcpsection, NULL, NULL);
}
break;
@ -438,7 +439,8 @@ int delete_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *data, cha
uci_foreach_option_eq("dhcp", "host", "dhcp", ((struct dhcp_args *)data)->interface, s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_dhcp", "host", section_name(ss), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
@ -446,7 +448,8 @@ int delete_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *data, cha
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_dhcp", "host", section_name(ss), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
break;
@ -697,9 +700,9 @@ int addObjDHCPv4RelayForwarding(char *refparam, struct dmctx *ctx, void *data, c
int delObjDHCPv4RelayForwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct dhcp_client_args *dhcp_relay_args = (struct dhcp_client_args*)data;
struct uci_section *s = NULL, *ss = NULL, *dmmap_section;
struct uci_section *s = NULL, *ss = NULL, *dmmap_section = NULL;
char *proto = NULL;
int found= 0;
int found = 0;
switch (del_action) {
case DEL_INST:
@ -710,7 +713,8 @@ int delObjDHCPv4RelayForwarding(char *refparam, struct dmctx *ctx, void *data, c
dmuci_delete_by_section_unnamed(dhcp_relay_args->dhcp_client_conf, NULL, NULL);
} else {
get_dmmap_section_of_config_section("dmmap_dhcp_relay", "interface", section_name(dhcp_relay_args->dhcp_client_conf), &dmmap_section);
dmuci_delete_by_section_unnamed_bbfdm(dmmap_section, NULL, NULL);
if (dmmap_section != NULL)
dmuci_delete_by_section_unnamed_bbfdm(dmmap_section, NULL, NULL);
dmuci_delete_by_section(dhcp_relay_args->dhcp_client_conf, NULL, NULL);
}
break;
@ -720,7 +724,7 @@ int delObjDHCPv4RelayForwarding(char *refparam, struct dmctx *ctx, void *data, c
dmuci_get_value_by_section_string(ss, "proto", &proto);
if (strcmp(proto, "relay") == 0) {
get_dmmap_section_of_config_section("dmmap_dhcp_relay", "interface", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
@ -732,7 +736,7 @@ int delObjDHCPv4RelayForwarding(char *refparam, struct dmctx *ctx, void *data, c
dmuci_get_value_by_section_string(ss, "proto", &proto);
if (strcmp(proto, "relay") == 0) {
get_dmmap_section_of_config_section("dmmap_dhcp_relay", "interface", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
@ -747,32 +751,36 @@ int delObjDHCPv4RelayForwarding(char *refparam, struct dmctx *ctx, void *data, c
**************************************************************/
int get_server_pool_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_sect;
struct uci_section *dmmap_sect = NULL;
get_dmmap_section_of_config_section("dmmap_dhcp", "dhcp", section_name(((struct dhcp_args *)data)->dhcp_sec), &dmmap_sect);
if (dmmap_sect) dmuci_get_value_by_section_string(dmmap_sect, "dhcp_alias", value);
if (dmmap_sect)
dmuci_get_value_by_section_string(dmmap_sect, "dhcp_alias", value);
return 0;
}
int set_server_pool_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_sect;
struct uci_section *dmmap_sect = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_dhcp", "dhcp", section_name(((struct dhcp_args *)data)->dhcp_sec), &dmmap_sect);
if (dmmap_sect) DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "dhcp_alias", value);
if (dmmap_sect)
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "dhcp_alias", value);
return 0;
}
return 0;
}
/*#Device.DHCPv4.Server.Pool.{i}.DNSServers!UBUBS:network.interface/status/interface,@Name/dns-server*/
/*#Device.DHCPv4.Server.Pool.{i}.DNSServers!UBUS:network.interface/status/interface,@Name/dns-server*/
int get_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
json_object *res = NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", ((struct dhcp_args *)data)->interface, String}}, 1, &res);
if (res) {
@ -802,6 +810,8 @@ int set_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, "4", NULL, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
dup = dmstrdup(value);
@ -838,7 +848,7 @@ int set_dhcp_configurable(char *refparam, struct dmctx *ctx, void *data, char *i
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -877,23 +887,27 @@ int get_dhcp_status(char *refparam, struct dmctx *ctx, void *data, char *instanc
int get_dhcp_sever_pool_order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_sect;
struct uci_section *dmmap_sect = NULL;
get_dmmap_section_of_config_section("dmmap_dhcp", "dhcp", section_name(((struct dhcp_args *)data)->dhcp_sec), &dmmap_sect);
if (dmmap_sect) dmuci_get_value_by_section_string(dmmap_sect, "order", value);
if (dmmap_sect)
dmuci_get_value_by_section_string(dmmap_sect, "order", value);
return 0;
}
int set_dhcp_sever_pool_order(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_sect;
struct uci_section *dmmap_sect = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
break;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_dhcp", "dhcp", section_name(((struct dhcp_args *)data)->dhcp_sec), &dmmap_sect);
if (dmmap_sect) set_section_order("dhcp", "dmmap_dhcp", "dhcp", dmmap_sect, ((struct dhcp_args *)data)->dhcp_sec, 1, value);
if (dmmap_sect)
set_section_order("dhcp", "dmmap_dhcp", "dhcp", dmmap_sect, ((struct dhcp_args *)data)->dhcp_sec, 1, value);
break;
}
return 0;
@ -933,6 +947,7 @@ int get_clients_number_of_entries(char *refparam, struct dmctx *ctx, void *data,
const struct dhcp_args *dhcp = data;
dmasprintf(value, "%u", dhcp->n_leases);
return 0;
}
/*#Device.DHCPv4.Server.Pool.{i}.Enable!UCI:dhcp/interface,@i-1/ignore*/
@ -959,16 +974,13 @@ int set_dhcp_enable(char *refparam, struct dmctx *ctx, void *data, char *instanc
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
if (b)
dmuci_set_value_by_section(s, "ignore", "");
else
dmuci_set_value_by_section(s, "ignore", "1");
dmuci_set_value_by_section(s, "ignore", b ? "0" : "1");
break;
}
return 0;
@ -1055,6 +1067,8 @@ int set_dhcp_address_min(char *refparam, struct dmctx *ctx, void *data, char *in
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "ipaddr", &ipaddr);
@ -1101,6 +1115,8 @@ int set_dhcp_address_max(char *refparam, struct dmctx *ctx, void *data, char *in
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
@ -1180,6 +1196,8 @@ int set_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *data, c
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, "32", NULL, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
get_dhcp_interval_address(ctx, data, instance, &min, LANIP_INTERVAL_START);
@ -1244,6 +1262,8 @@ int set_dhcp_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *ins
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
@ -1269,6 +1289,8 @@ int set_dhcp_iprouters(char *refparam, struct dmctx *ctx, void *data, char *inst
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, "4", NULL, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("network", ((struct dhcp_args *)data)->interface, "gateway", value);
@ -1351,6 +1373,8 @@ int set_dhcp_leasetime(char *refparam, struct dmctx *ctx, void *data, char *inst
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
@ -1381,6 +1405,8 @@ int set_dhcp_interface_linker_parameter(char *refparam, struct dmctx *ctx, void
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
@ -1424,6 +1450,8 @@ int set_dhcp_domainname(char *refparam, struct dmctx *ctx, void *data, char *ins
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
@ -1447,22 +1475,26 @@ end:
int get_dhcp_static_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_dhcp", "host", section_name(((struct dhcp_static_args *)data)->dhcpsection), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "ldhcpalias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "ldhcpalias", value);
return 0;
}
int set_dhcp_static_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_dhcp", "host", section_name(((struct dhcp_static_args *)data)->dhcpsection), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "ldhcpalias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "ldhcpalias", value);
return 0;
}
return 0;
@ -1487,6 +1519,8 @@ int set_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, void *data,
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "17", NULL, MACAddress))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct dhcp_static_args *)data)->dhcpsection, "mac", &chaddr);
@ -1502,9 +1536,7 @@ int set_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, void *data,
/*#Device.DHCPv4.Server.Pool.{i}.StaticAddress.{i}.Yiaddr!UCI:dhcp/host,@i-1/ip*/
int get_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)data;
dmuci_get_value_by_section_string(dhcpargs->dhcpsection, "ip", value);
dmuci_get_value_by_section_string(((struct dhcp_static_args *)data)->dhcpsection, "ip", value);
return 0;
}
@ -1512,6 +1544,8 @@ int set_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct dhcp_static_args *)data)->dhcpsection, "ip", value);
@ -1573,16 +1607,16 @@ int get_DHCPv4Client_Enable(char *refparam, struct dmctx *ctx, void *data, char
char *v = NULL;
if(((struct dhcp_client_args *)data)->dhcp_client_conf == NULL) {
*value= "0";
*value = "0";
return 0;
}
dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", &v);
if (v == NULL || strlen(v) == 0 || strcmp(v, "1") != 0)
*value= "1";
*value = "1";
else
*value= "0";
*value = "0";
return 0;
}
@ -1593,16 +1627,13 @@ int set_DHCPv4Client_Enable(char *refparam, struct dmctx *ctx, void *data, char
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", "0");
else
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", "1");
break;
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", b ? "0" : "1");
return 0;
}
return 0;
}
@ -1618,6 +1649,8 @@ int set_DHCPv4Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->dhcp_client_dm, "bbf_dhcpv4client_alias", value);
@ -1632,8 +1665,10 @@ int get_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *data, ch
*value = "";
return 0;
}
char *linker= dmstrdup(section_name(((struct dhcp_client_args *)data)->dhcp_client_conf));
char *linker = dmstrdup(section_name(((struct dhcp_client_args *)data)->dhcp_client_conf));
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL)
*value = "";
return 0;
}
@ -1644,6 +1679,9 @@ int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *data, ch
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
if(strlen(value) == 0 || strcmp(value, "") == 0)
return FAULT_9007;
@ -1680,8 +1718,8 @@ int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *data, ch
/*#Device.DHCPv4.Client.{i}.Status!UCI:network/interface,@i-1/disabled*/
int get_DHCPv4Client_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *v = "";
if(((struct dhcp_client_args *)data)->dhcp_client_conf == NULL) {
char *v = NULL;
if (((struct dhcp_client_args *)data)->dhcp_client_conf == NULL) {
*value = "Error_Misconfigured";
return 0;
}
@ -1720,7 +1758,6 @@ int get_DHCPv4Client_DHCPStatus(char *refparam, struct dmctx *ctx, void *data, c
int get_DHCPv4Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "false";
return 0;
}
@ -1731,6 +1768,8 @@ int set_DHCPv4Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
if (((struct dhcp_client_args *)data)->dhcp_client_conf == NULL && strcasecmp(value, "true") != 0)
@ -1827,9 +1866,7 @@ int get_DHCPv4Client_DHCPServer(char *refparam, struct dmctx *ctx, void *data, c
int get_DHCPv4Client_PassthroughEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
//TODO
return 0;
}
@ -1837,6 +1874,8 @@ int set_DHCPv4Client_PassthroughEnable(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1847,7 +1886,7 @@ int set_DHCPv4Client_PassthroughEnable(char *refparam, struct dmctx *ctx, void *
int get_DHCPv4Client_PassthroughDHCPPool(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
//TODO
return 0;
}
@ -1855,6 +1894,8 @@ int set_DHCPv4Client_PassthroughDHCPPool(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1866,13 +1907,11 @@ int set_DHCPv4Client_PassthroughDHCPPool(char *refparam, struct dmctx *ctx, void
/*#Device.DHCPv4.Client.{i}.SentOptionNumberOfEntries!UCI:network/interface,@i-1/sendopts*/
int get_DHCPv4Client_SentOptionNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct dhcp_client_args* dhcp_client_args= (struct dhcp_client_args*)data;
char *v = NULL;
size_t length;
if(dhcp_client_args->dhcp_client_conf != NULL)
dmuci_get_value_by_section_string(dhcp_client_args->dhcp_client_conf, "sendopts", &v);
if (((struct dhcp_client_args *)data)->dhcp_client_conf != NULL)
dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "sendopts", &v);
if (v == NULL) {
*value = "0";
return 0;
@ -1924,7 +1963,7 @@ int set_DHCPv4ClientSentOption_Enable(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -1957,6 +1996,8 @@ int set_DHCPv4ClientSentOption_Alias(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
DMUCI_SET_VALUE_BY_SECTION(bbfdm, ((struct dhcp_client_option_args *)data)->opt_sect, "bbf_dhcpv4_sentopt_alias", value);
@ -1978,6 +2019,8 @@ int set_DHCPv4ClientSentOption_Tag(char *refparam, struct dmctx *ctx, void *data
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", "254"))
return FAULT_9007;
dmuci_get_value_by_section_string(((struct dhcp_client_option_args *)data)->client_sect, "sendopts", &v);
if (v == NULL)
return 0;
@ -2014,6 +2057,8 @@ int set_DHCPv4ClientSentOption_Value(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (dm_validate_hexBinary(value, "0", "255"))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string(((struct dhcp_client_option_args *)data)->client_sect, "sendopts", &v);
@ -2037,7 +2082,7 @@ int get_DHCPv4ClientReqOption_Enable(char *refparam, struct dmctx *ctx, void *da
return 0;
}
dmuci_get_value_by_section_string(((struct dhcp_client_option_args *)data)->client_sect, "reqopts", &v);
if(is_elt_exit_in_str_list(v, ((struct dhcp_client_option_args *)data)->option_tag))
if (is_elt_exit_in_str_list(v, ((struct dhcp_client_option_args *)data)->option_tag))
*value = "1";
else
*value = "0";
@ -2051,7 +2096,7 @@ int set_DHCPv4ClientReqOption_Enable(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -2083,6 +2128,8 @@ int set_DHCPv4ClientReqOption_Order(char *refparam, struct dmctx *ctx, void *dat
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2101,6 +2148,8 @@ int set_DHCPv4ClientReqOption_Alias(char *refparam, struct dmctx *ctx, void *dat
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
DMUCI_SET_VALUE_BY_SECTION(bbfdm, ((struct dhcp_client_option_args *)data)->opt_sect, "bbf_dhcpv4_reqtopt_alias", value);
@ -2118,10 +2167,12 @@ int get_DHCPv4ClientReqOption_Tag(char *refparam, struct dmctx *ctx, void *data,
int set_DHCPv4ClientReqOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch, *spch, *list, *v;
size_t length;
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", "254"))
return FAULT_9007;
dmuci_get_value_by_section_string(((struct dhcp_client_option_args *)data)->client_sect, "reqopts", &v);
if (v == NULL)
return 0;
@ -2159,6 +2210,8 @@ int set_DHCPv4Server_Enable(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2177,6 +2230,8 @@ int set_DHCPv4RelayForwarding_DHCPServerIPAddress(char *refparam, struct dmctx *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2220,7 +2275,7 @@ int set_DHCPv4ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -2268,6 +2323,8 @@ int set_DHCPv4ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
DMUCI_SET_VALUE_BY_SECTION(bbfdm, ((struct dhcp_client_option_args *)data)->opt_sect, "bbf_dhcpv4_servpool_option_alias", value);
@ -2291,6 +2348,9 @@ int set_DHCPv4ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", "254"))
return FAULT_9007;
dmuci_get_value_by_section_list(((struct dhcp_client_option_args *)data)->client_sect, "dhcp_option", &dhcp_option_list);
if (dhcp_option_list == NULL)
return 0;
@ -2327,6 +2387,9 @@ int set_DHCPv4ServerPoolOption_Value(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (dm_validate_hexBinary(value, "0", "255"))
return FAULT_9007;
dmuci_get_value_by_section_list(((struct dhcp_client_option_args *)data)->client_sect, "dhcp_option", &dhcp_option_list);
if (dhcp_option_list == NULL)
return 0;
@ -2373,15 +2436,12 @@ int set_DHCPv4RelayForwarding_Enable(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", "0");
else
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", "1");
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", b ? "0" : "1");
break;
}
return 0;
@ -2397,6 +2457,8 @@ int set_DHCPv4RelayForwarding_Alias(char *refparam, struct dmctx *ctx, void *dat
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dhcp_client_args *)data)->dhcp_client_dm, "bbf_dhcpv4relay_alias", value);
@ -2415,6 +2477,8 @@ int set_DHCPv4RelayForwarding_Order(char *refparam, struct dmctx *ctx, void *dat
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2441,6 +2505,9 @@ int set_DHCPv4RelayForwarding_Interface(char *refparam, struct dmctx *ctx, void
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
if (strlen(value) == 0 || strcmp(value, "") == 0)
return FAULT_9007;
@ -2488,6 +2555,8 @@ int set_DHCPv4RelayForwarding_VendorClassID(char *refparam, struct dmctx *ctx, v
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "255", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
if(((struct dhcp_client_args *)data)->vendorclassidclassifier)
@ -2499,7 +2568,7 @@ int set_DHCPv4RelayForwarding_VendorClassID(char *refparam, struct dmctx *ctx, v
int get_DHCPv4RelayForwarding_VendorClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "false";
//TODO
return 0;
}
@ -2507,6 +2576,8 @@ int set_DHCPv4RelayForwarding_VendorClassIDExclude(char *refparam, struct dmctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2517,7 +2588,7 @@ int set_DHCPv4RelayForwarding_VendorClassIDExclude(char *refparam, struct dmctx
int get_DHCPv4RelayForwarding_VendorClassIDMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "Prefix";
//TODO
return 0;
}
@ -2525,6 +2596,8 @@ int set_DHCPv4RelayForwarding_VendorClassIDMode(char *refparam, struct dmctx *ct
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, VendorClassIDMode, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2537,7 +2610,8 @@ int set_DHCPv4RelayForwarding_VendorClassIDMode(char *refparam, struct dmctx *ct
int get_DHCPv4RelayForwarding_Chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *mac, **macarray, *res = NULL, *tmp = "";
size_t length, i;
size_t length;
int i;
if (((struct dhcp_client_args *)data)->macclassifier == NULL) {
*value = "";
@ -2568,9 +2642,10 @@ int set_DHCPv4RelayForwarding_Chaddr(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "17", NULL, MACAddress))
return FAULT_9007;
break;
case VALUESET:
//TODO
break;
}
return 0;
@ -2580,7 +2655,8 @@ int set_DHCPv4RelayForwarding_Chaddr(char *refparam, struct dmctx *ctx, void *da
int get_DHCPv4RelayForwarding_ChaddrMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *mac, **macarray, *res = NULL, *tmp = "";
size_t length, i;
size_t length;
int i;
if (((struct dhcp_client_args *)data)->macclassifier == NULL) {
*value= "";
@ -2611,9 +2687,10 @@ int set_DHCPv4RelayForwarding_ChaddrMask(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "17", NULL, MACAddress))
return FAULT_9007;
break;
case VALUESET:
//TODO
break;
}
return 0;
@ -2629,6 +2706,8 @@ int set_DHCPv4RelayForwarding_ChaddrExclude(char *refparam, struct dmctx *ctx, v
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2647,6 +2726,8 @@ int set_DHCPv4RelayForwarding_LocallyServed(char *refparam, struct dmctx *ctx, v
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2689,6 +2770,8 @@ int set_DHCPv4RelayForwarding_ClientID(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_hexBinary(value, NULL, "255"))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2699,7 +2782,7 @@ int set_DHCPv4RelayForwarding_ClientID(char *refparam, struct dmctx *ctx, void *
int get_DHCPv4RelayForwarding_ClientIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= "true";
//TODO
return 0;
}
@ -2707,6 +2790,8 @@ int set_DHCPv4RelayForwarding_ClientIDExclude(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2727,6 +2812,8 @@ int set_DHCPv4RelayForwarding_UserClassID(char *refparam, struct dmctx *ctx, voi
{
switch (action) {
case VALUECHECK:
if (dm_validate_hexBinary(value, NULL, "255"))
return FAULT_9007;
break;
case VALUESET:
if(((struct dhcp_client_args *)data)->userclassclassifier)
@ -2738,7 +2825,7 @@ int set_DHCPv4RelayForwarding_UserClassID(char *refparam, struct dmctx *ctx, voi
int get_DHCPv4RelayForwarding_UserClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "false";
//TODO
return 0;
}
@ -2746,6 +2833,8 @@ int set_DHCPv4RelayForwarding_UserClassIDExclude(char *refparam, struct dmctx *c
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -2776,15 +2865,12 @@ int set_DHCPv4Relay_Enable(char *refparam, struct dmctx *ctx, void *data, char *
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmcmd("/etc/init.d/relayd", 1, "enable");
else
dmcmd("/etc/init.d/relayd", 1, "disable");
dmcmd("/etc/init.d/relayd", 1, b ? "enable" : "disable");
break;
}
return 0;
@ -3057,7 +3143,8 @@ int browseDHCPv4ClientSentOptionInst(struct dmctx *dmctx, DMNODE *parent_node, v
struct uci_section *dmmap_sect;
struct dhcp_client_option_args dhcp_client_opt_args = {0};
char *instance, *instnbr = NULL, *v1, *v2, **sentopts = NULL, **buf = NULL, *tmp, *optionvalue, *v = NULL;
size_t length = 0, lgh2, i, j;
size_t length = 0, lgh2;
int i, j;
if (dhcp_client_args->dhcp_client_conf != NULL)
dmuci_get_value_by_section_string(dhcp_client_args->dhcp_client_conf, "sendopts", &v);
@ -3106,7 +3193,8 @@ int browseDHCPv4ClientReqOptionInst(struct dmctx *dmctx, DMNODE *parent_node, vo
struct uci_section *dmmap_sect;
struct dhcp_client_option_args dhcp_client_opt_args = {0};
char *instance, *instnbr = NULL, *v1, **reqtopts = NULL, *v = NULL;
size_t length = 0, i, j;
size_t length = 0;
int i;
if (dhcp_client_args->dhcp_client_conf != NULL)
dmuci_get_value_by_section_string(dhcp_client_args->dhcp_client_conf, "reqopts", &v);
@ -3141,7 +3229,8 @@ int browseDHCPv4ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_node, v
struct dhcp_args *curr_dhcp_args = (struct dhcp_args*)prev_data;
struct uci_section *dmmap_sect;
char **tagvalue = NULL, *instance, *instnbr = NULL, *optionvalue = NULL, *tmp, *v1, *v2, *v;
size_t length, j;
size_t length;
int j;
struct dhcp_client_option_args dhcp_client_opt_args = {0};
dmuci_get_value_by_section_list(curr_dhcp_args->dhcp_sec, "dhcp_option", &dhcp_options_list);
@ -3191,7 +3280,8 @@ char *get_dhcp_network_from_relay_list(char *net_list)
{
struct uci_section *s;
char **net_list_arr, *v;
size_t length, i;
int i;
size_t length;
net_list_arr = strsplit(net_list, " ", &length);
uci_foreach_sections("network", "interface", s) {

View file

@ -29,9 +29,9 @@ DMLEAF tDHCPv6Params[] = {
/* *** Device.DHCPv6.Client.{i}. *** */
DMOBJ tDHCPv6ClientObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/
{"Server", &DMREAD, NULL, NULL, NULL, browseDHCPv6ClientServerInst, NULL, NULL, NULL, NULL, tDHCPv6ClientServerParams, NULL, BBFDM_BOTH},
{"SentOption", &DMWRITE, addObjDHCPv6ClientSentOption, delObjDHCPv6ClientSentOption, NULL, browseDHCPv6ClientSentOptionInst, NULL, NULL, NULL, NULL, tDHCPv6ClientSentOptionParams, NULL, BBFDM_BOTH},
{"ReceivedOption", &DMREAD, NULL, NULL, NULL, browseDHCPv6ClientReceivedOptionInst, NULL, NULL, NULL, NULL, tDHCPv6ClientReceivedOptionParams, NULL, BBFDM_BOTH},
//{"Server", &DMREAD, NULL, NULL, NULL, browseDHCPv6ClientServerInst, NULL, NULL, NULL, NULL, tDHCPv6ClientServerParams, NULL, BBFDM_BOTH},
//{"SentOption", &DMWRITE, addObjDHCPv6ClientSentOption, delObjDHCPv6ClientSentOption, NULL, browseDHCPv6ClientSentOptionInst, NULL, NULL, NULL, NULL, tDHCPv6ClientSentOptionParams, NULL, BBFDM_BOTH},
//{"ReceivedOption", &DMREAD, NULL, NULL, NULL, browseDHCPv6ClientReceivedOptionInst, NULL, NULL, NULL, NULL, tDHCPv6ClientReceivedOptionParams, NULL, BBFDM_BOTH},
{0}
};
@ -44,43 +44,43 @@ DMLEAF tDHCPv6ClientParams[] = {
{"DUID", &DMREAD, DMT_HEXBIN, get_DHCPv6Client_DUID, NULL, NULL, NULL, BBFDM_BOTH},
{"RequestAddresses", &DMWRITE, DMT_BOOL, get_DHCPv6Client_RequestAddresses, set_DHCPv6Client_RequestAddresses, NULL, NULL, BBFDM_BOTH},
{"RequestPrefixes", &DMWRITE, DMT_BOOL, get_DHCPv6Client_RequestPrefixes, set_DHCPv6Client_RequestPrefixes, NULL, NULL, BBFDM_BOTH},
{"RapidCommit", &DMWRITE, DMT_BOOL, get_DHCPv6Client_RapidCommit, set_DHCPv6Client_RapidCommit, NULL, NULL, BBFDM_BOTH},
//{"RapidCommit", &DMWRITE, DMT_BOOL, get_DHCPv6Client_RapidCommit, set_DHCPv6Client_RapidCommit, NULL, NULL, BBFDM_BOTH},
{"Renew", &DMWRITE, DMT_BOOL, get_DHCPv6Client_Renew, set_DHCPv6Client_Renew, NULL, NULL, BBFDM_BOTH},
{"SuggestedT1", &DMWRITE, DMT_INT, get_DHCPv6Client_SuggestedT1, set_DHCPv6Client_SuggestedT1, NULL, NULL, BBFDM_BOTH},
{"SuggestedT2", &DMWRITE, DMT_INT, get_DHCPv6Client_SuggestedT2, set_DHCPv6Client_SuggestedT2, NULL, NULL, BBFDM_BOTH},
{"SupportedOptions", &DMREAD, DMT_STRING, get_DHCPv6Client_SupportedOptions, NULL, NULL, NULL, BBFDM_BOTH},
//{"SuggestedT1", &DMWRITE, DMT_INT, get_DHCPv6Client_SuggestedT1, set_DHCPv6Client_SuggestedT1, NULL, NULL, BBFDM_BOTH},
//{"SuggestedT2", &DMWRITE, DMT_INT, get_DHCPv6Client_SuggestedT2, set_DHCPv6Client_SuggestedT2, NULL, NULL, BBFDM_BOTH},
//{"SupportedOptions", &DMREAD, DMT_STRING, get_DHCPv6Client_SupportedOptions, NULL, NULL, NULL, BBFDM_BOTH},
{"RequestedOptions", &DMWRITE, DMT_STRING, get_DHCPv6Client_RequestedOptions, set_DHCPv6Client_RequestedOptions, NULL, NULL, BBFDM_BOTH},
{"ServerNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_ServerNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{"SentOptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_SentOptionNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{"ReceivedOptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_ReceivedOptionNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
//{"ServerNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_ServerNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
//{"SentOptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_SentOptionNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
//{"ReceivedOptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_ReceivedOptionNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.DHCPv6.Client.{i}.Server.{i}. *** */
DMLEAF tDHCPv6ClientServerParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"SourceAddress", &DMREAD, DMT_STRING, get_DHCPv6ClientServer_SourceAddress, NULL, NULL, NULL, BBFDM_BOTH},
{"DUID", &DMREAD, DMT_HEXBIN, get_DHCPv6ClientServer_DUID, NULL, NULL, NULL, BBFDM_BOTH},
{"InformationRefreshTime", &DMREAD, DMT_TIME, get_DHCPv6ClientServer_InformationRefreshTime, NULL, NULL, NULL, BBFDM_BOTH},
//{"SourceAddress", &DMREAD, DMT_STRING, get_DHCPv6ClientServer_SourceAddress, NULL, NULL, NULL, BBFDM_BOTH},
//{"DUID", &DMREAD, DMT_HEXBIN, get_DHCPv6ClientServer_DUID, NULL, NULL, NULL, BBFDM_BOTH},
//{"InformationRefreshTime", &DMREAD, DMT_TIME, get_DHCPv6ClientServer_InformationRefreshTime, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.DHCPv6.Client.{i}.SentOption.{i}. *** */
DMLEAF tDHCPv6ClientSentOptionParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv6ClientSentOption_Enable, set_DHCPv6ClientSentOption_Enable, NULL, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ClientSentOption_Alias, set_DHCPv6ClientSentOption_Alias, NULL, NULL, BBFDM_BOTH},
{"Tag", &DMWRITE, DMT_UNINT, get_DHCPv6ClientSentOption_Tag, set_DHCPv6ClientSentOption_Tag, NULL, NULL, BBFDM_BOTH},
{"Value", &DMWRITE, DMT_HEXBIN, get_DHCPv6ClientSentOption_Value, set_DHCPv6ClientSentOption_Value, NULL, NULL, BBFDM_BOTH},
//{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv6ClientSentOption_Enable, set_DHCPv6ClientSentOption_Enable, NULL, NULL, BBFDM_BOTH},
//{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ClientSentOption_Alias, set_DHCPv6ClientSentOption_Alias, NULL, NULL, BBFDM_BOTH},
//{"Tag", &DMWRITE, DMT_UNINT, get_DHCPv6ClientSentOption_Tag, set_DHCPv6ClientSentOption_Tag, NULL, NULL, BBFDM_BOTH},
//{"Value", &DMWRITE, DMT_HEXBIN, get_DHCPv6ClientSentOption_Value, set_DHCPv6ClientSentOption_Value, NULL, NULL, BBFDM_BOTH},
{0}
};
/* *** Device.DHCPv6.Client.{i}.ReceivedOption.{i}. *** */
DMLEAF tDHCPv6ClientReceivedOptionParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Tag", &DMREAD, DMT_UNINT, get_DHCPv6ClientReceivedOption_Tag, NULL, NULL, NULL, BBFDM_BOTH},
{"Value", &DMREAD, DMT_HEXBIN, get_DHCPv6ClientReceivedOption_Value, NULL, NULL, NULL, BBFDM_BOTH},
{"Server", &DMREAD, DMT_STRING, get_DHCPv6ClientReceivedOption_Server, NULL, NULL, NULL, BBFDM_BOTH},
//{"Tag", &DMREAD, DMT_UNINT, get_DHCPv6ClientReceivedOption_Tag, NULL, NULL, NULL, BBFDM_BOTH},
//{"Value", &DMREAD, DMT_HEXBIN, get_DHCPv6ClientReceivedOption_Value, NULL, NULL, NULL, BBFDM_BOTH},
//{"Server", &DMREAD, DMT_STRING, get_DHCPv6ClientReceivedOption_Server, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -113,22 +113,22 @@ DMLEAF tDHCPv6ServerPoolParams[] = {
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_Alias, set_DHCPv6ServerPool_Alias, NULL, NULL, BBFDM_BOTH},
{"Order", &DMWRITE, DMT_UNINT, get_DHCPv6ServerPool_Order, set_DHCPv6ServerPool_Order, NULL, NULL, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_Interface, set_DHCPv6ServerPool_Interface, NULL, NULL, BBFDM_BOTH},
{"DUID", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPool_DUID, set_DHCPv6ServerPool_DUID, NULL, NULL, BBFDM_BOTH},
{"DUIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_DUIDExclude, set_DHCPv6ServerPool_DUIDExclude, NULL, NULL, BBFDM_BOTH},
//{"DUID", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPool_DUID, set_DHCPv6ServerPool_DUID, NULL, NULL, BBFDM_BOTH},
//{"DUIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_DUIDExclude, set_DHCPv6ServerPool_DUIDExclude, NULL, NULL, BBFDM_BOTH},
{"VendorClassID", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPool_VendorClassID, set_DHCPv6ServerPool_VendorClassID, NULL, NULL, BBFDM_BOTH},
{"VendorClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_VendorClassIDExclude, set_DHCPv6ServerPool_VendorClassIDExclude, NULL, NULL, BBFDM_BOTH},
//{"VendorClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_VendorClassIDExclude, set_DHCPv6ServerPool_VendorClassIDExclude, NULL, NULL, BBFDM_BOTH},
{"UserClassID", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPool_UserClassID, set_DHCPv6ServerPool_UserClassID, NULL, NULL, BBFDM_BOTH},
{"UserClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_UserClassIDExclude, set_DHCPv6ServerPool_UserClassIDExclude, NULL, NULL, BBFDM_BOTH},
//{"UserClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_UserClassIDExclude, set_DHCPv6ServerPool_UserClassIDExclude, NULL, NULL, BBFDM_BOTH},
{"SourceAddress", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_SourceAddress, set_DHCPv6ServerPool_SourceAddress, NULL, NULL, BBFDM_BOTH},
{"SourceAddressMask", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_SourceAddressMask, set_DHCPv6ServerPool_SourceAddressMask, NULL, NULL, BBFDM_BOTH},
{"SourceAddressExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_SourceAddressExclude, set_DHCPv6ServerPool_SourceAddressExclude, NULL, NULL, BBFDM_BOTH},
{"IANAEnable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_IANAEnable, set_DHCPv6ServerPool_IANAEnable, NULL, NULL, BBFDM_BOTH},
{"IANAManualPrefixes", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_IANAManualPrefixes, set_DHCPv6ServerPool_IANAManualPrefixes, NULL, NULL, BBFDM_BOTH},
{"IANAPrefixes", &DMREAD, DMT_STRING, get_DHCPv6ServerPool_IANAPrefixes, NULL, NULL, NULL, BBFDM_BOTH},
{"IAPDEnable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_IAPDEnable, set_DHCPv6ServerPool_IAPDEnable, NULL, NULL, BBFDM_BOTH},
{"IAPDManualPrefixes", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_IAPDManualPrefixes, set_DHCPv6ServerPool_IAPDManualPrefixes, NULL, NULL, BBFDM_BOTH},
{"IAPDPrefixes", &DMREAD, DMT_STRING, get_DHCPv6ServerPool_IAPDPrefixes, NULL, NULL, NULL, BBFDM_BOTH},
{"IAPDAddLength", &DMWRITE, DMT_UNINT, get_DHCPv6ServerPool_IAPDAddLength, set_DHCPv6ServerPool_IAPDAddLength, NULL, NULL, BBFDM_BOTH},
//{"SourceAddressExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_SourceAddressExclude, set_DHCPv6ServerPool_SourceAddressExclude, NULL, NULL, BBFDM_BOTH},
//{"IANAEnable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_IANAEnable, set_DHCPv6ServerPool_IANAEnable, NULL, NULL, BBFDM_BOTH},
//{"IANAManualPrefixes", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_IANAManualPrefixes, set_DHCPv6ServerPool_IANAManualPrefixes, NULL, NULL, BBFDM_BOTH},
//{"IANAPrefixes", &DMREAD, DMT_STRING, get_DHCPv6ServerPool_IANAPrefixes, NULL, NULL, NULL, BBFDM_BOTH},
//{"IAPDEnable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_IAPDEnable, set_DHCPv6ServerPool_IAPDEnable, NULL, NULL, BBFDM_BOTH},
//{"IAPDManualPrefixes", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_IAPDManualPrefixes, set_DHCPv6ServerPool_IAPDManualPrefixes, NULL, NULL, BBFDM_BOTH},
//{"IAPDPrefixes", &DMREAD, DMT_STRING, get_DHCPv6ServerPool_IAPDPrefixes, NULL, NULL, NULL, BBFDM_BOTH},
//{"IAPDAddLength", &DMWRITE, DMT_UNINT, get_DHCPv6ServerPool_IAPDAddLength, set_DHCPv6ServerPool_IAPDAddLength, NULL, NULL, BBFDM_BOTH},
{"ClientNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPool_ClientNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{"OptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPool_OptionNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
@ -139,18 +139,18 @@ DMOBJ tDHCPv6ServerPoolClientObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextdynamicobj, nextobj, leaf, linker, bbfdm_type*/
{"IPv6Address", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientIPv6AddressInst, NULL, NULL, NULL, NULL, tDHCPv6ServerPoolClientIPv6AddressParams, NULL, BBFDM_BOTH},
{"IPv6Prefix", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientIPv6PrefixInst, NULL, NULL, NULL, NULL, tDHCPv6ServerPoolClientIPv6PrefixParams, NULL, BBFDM_BOTH},
{"Option", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientOptionInst, NULL, NULL, NULL, NULL, tDHCPv6ServerPoolClientOptionParams, NULL, BBFDM_BOTH},
//{"Option", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientOptionInst, NULL, NULL, NULL, NULL, tDHCPv6ServerPoolClientOptionParams, NULL, BBFDM_BOTH},
{0}
};
DMLEAF tDHCPv6ServerPoolClientParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolClient_Alias, set_DHCPv6ServerPoolClient_Alias, NULL, NULL, BBFDM_BOTH},
{"SourceAddress", &DMREAD, DMT_STRING, get_DHCPv6ServerPoolClient_SourceAddress, NULL, NULL, NULL, BBFDM_BOTH},
{"Active", &DMREAD, DMT_BOOL, get_DHCPv6ServerPoolClient_Active, NULL, NULL, NULL, BBFDM_BOTH},
//{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolClient_Alias, set_DHCPv6ServerPoolClient_Alias, NULL, NULL, BBFDM_BOTH},
//{"SourceAddress", &DMREAD, DMT_STRING, get_DHCPv6ServerPoolClient_SourceAddress, NULL, NULL, NULL, BBFDM_BOTH},
//{"Active", &DMREAD, DMT_BOOL, get_DHCPv6ServerPoolClient_Active, NULL, NULL, NULL, BBFDM_BOTH},
{"IPv6AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClient_IPv6AddressNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{"IPv6PrefixNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClient_IPv6PrefixNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{"OptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClient_OptionNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
//{"OptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClient_OptionNumberOfEntries, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -175,8 +175,8 @@ DMLEAF tDHCPv6ServerPoolClientIPv6PrefixParams[] = {
/* *** Device.DHCPv6.Server.Pool.{i}.Client.{i}.Option.{i}. *** */
DMLEAF tDHCPv6ServerPoolClientOptionParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"Tag", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClientOption_Tag, NULL, NULL, NULL, BBFDM_BOTH},
{"Value", &DMREAD, DMT_HEXBIN, get_DHCPv6ServerPoolClientOption_Value, NULL, NULL, NULL, BBFDM_BOTH},
//{"Tag", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClientOption_Tag, NULL, NULL, NULL, BBFDM_BOTH},
//{"Value", &DMREAD, DMT_HEXBIN, get_DHCPv6ServerPoolClientOption_Value, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -187,7 +187,7 @@ DMLEAF tDHCPv6ServerPoolOptionParams[] = {
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolOption_Alias, set_DHCPv6ServerPoolOption_Alias, NULL, NULL, BBFDM_BOTH},
{"Tag", &DMWRITE, DMT_UNINT, get_DHCPv6ServerPoolOption_Tag, set_DHCPv6ServerPoolOption_Tag, NULL, NULL, BBFDM_BOTH},
{"Value", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPoolOption_Value, set_DHCPv6ServerPoolOption_Value, NULL, NULL, BBFDM_BOTH},
{"PassthroughClient", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolOption_PassthroughClient, set_DHCPv6ServerPoolOption_PassthroughClient, NULL, NULL, BBFDM_BOTH},
//{"PassthroughClient", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolOption_PassthroughClient, set_DHCPv6ServerPoolOption_PassthroughClient, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -372,7 +372,8 @@ int browseDHCPv6ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_node, v
struct dhcpv6_args *curr_dhcp_args = (struct dhcpv6_args*)prev_data;
struct uci_section *dmmap_sect;
char **tagvalue = NULL, *instance, *instnbr = NULL, *optionvalue= NULL, *tmp, *v1, *v2, *v;
size_t length, j;
size_t length;
int j;
struct dhcpv6_client_option_args dhcp_client_opt_args = {0};
dmuci_get_value_by_section_list(curr_dhcp_args->dhcp_sec, "dhcp_option", &dhcp_options_list);
@ -688,16 +689,13 @@ int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "disabled", "0");
else
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "disabled", "1");
break;
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "disabled", b ? "0" : "1");
return 0;
}
return 0;
}
@ -712,6 +710,8 @@ int set_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_dm, "bbf_dhcpv6client_alias", value);
@ -739,6 +739,9 @@ int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, ch
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
if (strlen(value) == 0 || strcmp(value, "") == 0) {
return FAULT_9007;
}
@ -778,17 +781,17 @@ int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, ch
/*#Device.DHCPv6.Client.{i}.Status!UCI:network/interface,@i-1/disabled*/
int get_DHCPv6Client_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *v = "";
char *v = NULL;
if(((struct dhcpv6_client_args *)data)->dhcp_client_conf == NULL) {
*value= "Error_Misconfigured";
*value = "Error_Misconfigured";
return 0;
}
dmuci_get_value_by_section_string(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "disabled", &v);
if (v == NULL || strlen(v) == 0 || strcmp(v, "1") != 0)
*value= "Enabled";
*value = "Enabled";
else
*value= "Disabled";
*value = "Disabled";
return 0;
}
@ -807,7 +810,7 @@ int get_DHCPv6Client_DUID(char *refparam, struct dmctx *ctx, void *data, char *i
/*#Device.DHCPv6.Client.{i}.RequestAddresses!UCI:network/interface,@i-1/reqaddress*/
int get_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *v = "";
char *v = NULL;
if(((struct dhcpv6_client_args *)data)->dhcp_client_conf == NULL) {
*value = "";
return 0;
@ -827,15 +830,12 @@ int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "reqaddress", "force");
else
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "reqaddress", "none");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "reqaddress", b ? "force" : "none");
break;
}
return 0;
@ -864,16 +864,13 @@ int set_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "reqprefix", "auto");
else
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "reqprefix", "no");
break;
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "reqprefix", b ? "auto" : "no");
return 0;
}
return 0;
}
@ -888,6 +885,8 @@ int set_DHCPv6Client_RapidCommit(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -898,7 +897,7 @@ int set_DHCPv6Client_RapidCommit(char *refparam, struct dmctx *ctx, void *data,
int get_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= "false";
*value = "false";
return 0;
}
@ -909,6 +908,8 @@ int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
@ -931,6 +932,8 @@ int set_DHCPv6Client_SuggestedT1(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -949,6 +952,8 @@ int set_DHCPv6Client_SuggestedT2(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -978,6 +983,8 @@ int set_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt_list(value, NULL, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dhcp_client_conf, "reqopts", value);
@ -1032,6 +1039,8 @@ int set_DHCPv6ClientSentOption_Enable(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1050,6 +1059,8 @@ int set_DHCPv6ClientSentOption_Alias(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1068,6 +1079,8 @@ int set_DHCPv6ClientSentOption_Tag(char *refparam, struct dmctx *ctx, void *data
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1086,6 +1099,8 @@ int set_DHCPv6ClientSentOption_Value(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_hexBinary(value, "0", "65535"))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1128,15 +1143,12 @@ int set_DHCPv6Server_Enable(char *refparam, struct dmctx *ctx, void *data, char
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmcmd("/etc/init.d/odhcpd", 1, "enable");
else
dmcmd("/etc/init.d/odhcpd", 1, "disable");
dmcmd("/etc/init.d/odhcpd", 1, b ? "enable" : "disable");
break;
}
return 0;
@ -1145,8 +1157,8 @@ int set_DHCPv6Server_Enable(char *refparam, struct dmctx *ctx, void *data, char
int get_DHCPv6Server_PoolNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s;
int i= 0;
char *v= NULL;
int i = 0;
char *v = NULL;
uci_foreach_sections("dhcp", "dhcp", s) {
dmuci_get_value_by_section_string(s, "dhcpv6", &v);
@ -1159,7 +1171,8 @@ int get_DHCPv6Server_PoolNumberOfEntries(char *refparam, struct dmctx *ctx, void
/*#Device.DHCPv6.Server.Pool.{i}.Enable!UCI:dhcp/dhcp,@i-1/ignore*/
int get_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ struct uci_section *s = NULL;
{
struct uci_section *s = NULL;
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcpv6_args *)data)->interface, s) {
dmuci_get_value_by_section_string(s, "ignore", value);
@ -1180,16 +1193,13 @@ int set_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *data, c
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcpv6_args *)data)->interface, s) {
if (b)
dmuci_set_value_by_section(s, "ignore", "");
else
dmuci_set_value_by_section(s, "ignore", "1");
dmuci_set_value_by_section(s, "ignore", b ? "0" : "1");
break;
}
return 0;
@ -1202,6 +1212,7 @@ int get_DHCPv6ServerPool_Status(char *refparam, struct dmctx *ctx, void *data, c
{
struct uci_section *s = NULL;
char *v= NULL;
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcpv6_args *)data)->interface, s) {
dmuci_get_value_by_section_string(s, "ignore", &v);
*value = (v && *v == '1') ? "Disabled" : "Enabled";
@ -1213,46 +1224,55 @@ int get_DHCPv6ServerPool_Status(char *refparam, struct dmctx *ctx, void *data, c
int get_DHCPv6ServerPool_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_sect;
struct uci_section *dmmap_sect = NULL;
get_dmmap_section_of_config_section("dmmap_dhcpv6", "dhcp", section_name(((struct dhcpv6_args *)data)->dhcp_sec), &dmmap_sect);
if (dmmap_sect) dmuci_get_value_by_section_string(dmmap_sect, "dhcpv6_serv_pool_alias", value);
if (dmmap_sect)
dmuci_get_value_by_section_string(dmmap_sect, "dhcpv6_serv_pool_alias", value);
return 0;
}
int set_DHCPv6ServerPool_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_sect;
struct uci_section *dmmap_sect = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_dhcpv6", "dhcp", section_name(((struct dhcpv6_args *)data)->dhcp_sec), &dmmap_sect);
if (dmmap_sect) DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "dhcpv6_serv_pool_alias", value);
if (dmmap_sect)
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dmmap_sect, "dhcpv6_serv_pool_alias", value);
return 0;
}
return 0;
}
int get_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_sect;
struct uci_section *dmmap_sect = NULL;
get_dmmap_section_of_config_section("dmmap_dhcpv6", "dhcp", section_name(((struct dhcpv6_args *)data)->dhcp_sec), &dmmap_sect);
if (dmmap_sect) dmuci_get_value_by_section_string(dmmap_sect, "order", value);
if (dmmap_sect)
dmuci_get_value_by_section_string(dmmap_sect, "order", value);
return 0;
}
int set_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_sect;
struct uci_section *dmmap_sect = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
break;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_dhcpv6", "dhcp", section_name(((struct dhcpv6_args *)data)->dhcp_sec), &dmmap_sect);
if (dmmap_sect) set_section_order("dhcp", "dmmap_dhcpv6", "dhcp", dmmap_sect, ((struct dhcpv6_args *)data)->dhcp_sec, 1, value);
if (dmmap_sect)
set_section_order("dhcp", "dmmap_dhcpv6", "dhcp", dmmap_sect, ((struct dhcpv6_args *)data)->dhcp_sec, 1, value);
break;
}
return 0;
@ -1275,6 +1295,8 @@ int set_DHCPv6ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
@ -1297,6 +1319,8 @@ int set_DHCPv6ServerPool_DUID(char *refparam, struct dmctx *ctx, void *data, cha
{
switch (action) {
case VALUECHECK:
if (dm_validate_hexBinary(value, NULL, "130"))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1315,6 +1339,8 @@ int set_DHCPv6ServerPool_DUIDExclude(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1327,9 +1353,8 @@ int set_DHCPv6ServerPool_DUIDExclude(char *refparam, struct dmctx *ctx, void *da
int get_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *vendorclassidclassifier = get_dhcpv6_classifier("vendorclass", ((struct dhcpv6_args *)data)->interface);
if(vendorclassidclassifier == NULL)
return 0;
dmuci_get_value_by_section_string(vendorclassidclassifier, "vendorclass", value);
if (vendorclassidclassifier)
dmuci_get_value_by_section_string(vendorclassidclassifier, "vendorclass", value);
return 0;
}
@ -1339,12 +1364,13 @@ int set_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx, void *
switch (action) {
case VALUECHECK:
if (dm_validate_hexBinary(value, NULL, "65535"))
return FAULT_9007;
break;
case VALUESET:
vendorclassidclassifier= get_dhcpv6_classifier("vendorclass", ((struct dhcpv6_args *)data)->interface);
if (vendorclassidclassifier == NULL)
return 0;
dmuci_set_value_by_section(vendorclassidclassifier, "vendorclass", value);
vendorclassidclassifier = get_dhcpv6_classifier("vendorclass", ((struct dhcpv6_args *)data)->interface);
if (vendorclassidclassifier)
dmuci_set_value_by_section(vendorclassidclassifier, "vendorclass", value);
break;
}
return 0;
@ -1352,7 +1378,7 @@ int set_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx, void *
int get_DHCPv6ServerPool_VendorClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "false";
//TODO
return 0;
}
@ -1360,6 +1386,8 @@ int set_DHCPv6ServerPool_VendorClassIDExclude(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1372,9 +1400,8 @@ int set_DHCPv6ServerPool_VendorClassIDExclude(char *refparam, struct dmctx *ctx,
int get_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *userclassidclassifier= get_dhcpv6_classifier("userclass", ((struct dhcpv6_args *)data)->interface);
if (userclassidclassifier == NULL)
return 0;
dmuci_get_value_by_section_string(userclassidclassifier, "userclass", value);
if (userclassidclassifier)
dmuci_get_value_by_section_string(userclassidclassifier, "userclass", value);
return 0;
}
@ -1384,12 +1411,13 @@ int set_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (dm_validate_hexBinary(value, NULL, "65535"))
return FAULT_9007;
break;
case VALUESET:
userclassidclassifier= get_dhcpv6_classifier("userclass", ((struct dhcpv6_args *)data)->interface);
if (userclassidclassifier == NULL)
return 0;
dmuci_set_value_by_section(userclassidclassifier, "userclass", value);
if (userclassidclassifier)
dmuci_set_value_by_section(userclassidclassifier, "userclass", value);
break;
}
return 0;
@ -1397,7 +1425,7 @@ int set_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, void *da
int get_DHCPv6ServerPool_UserClassIDExclude(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "false";
//TODO
return 0;
}
@ -1405,6 +1433,8 @@ int set_DHCPv6ServerPool_UserClassIDExclude(char *refparam, struct dmctx *ctx, v
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1417,7 +1447,8 @@ int get_DHCPv6ServerPool_SourceAddress(char *refparam, struct dmctx *ctx, void *
{
struct uci_section *macaddrclassifier;
char *mac, **macarray, *res = NULL, *tmp = "";
size_t length, i;
int i;
size_t length;
macaddrclassifier = get_dhcpv6_classifier("mac", ((struct dhcpv6_args *)data)->interface);
if (macaddrclassifier == NULL) {
@ -1449,9 +1480,10 @@ int set_DHCPv6ServerPool_SourceAddress(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "45", NULL, IPv6Address))
return FAULT_9007;
break;
case VALUESET:
//TODO
break;
}
return 0;
@ -1461,7 +1493,8 @@ int get_DHCPv6ServerPool_SourceAddressMask(char *refparam, struct dmctx *ctx, vo
{
struct uci_section *macaddrclassifier;
char *mac, **macarray, *res = NULL, *tmp = "";
size_t length, i;
int i;
size_t length;
macaddrclassifier = get_dhcpv6_classifier("mac", ((struct dhcpv6_args *)data)->interface);
if (macaddrclassifier == NULL) {
@ -1492,9 +1525,10 @@ int set_DHCPv6ServerPool_SourceAddressMask(char *refparam, struct dmctx *ctx, vo
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "45", NULL, IPv6Address))
return FAULT_9007;
break;
case VALUESET:
//TODO
break;
}
return 0;
@ -1510,6 +1544,8 @@ int set_DHCPv6ServerPool_SourceAddressExclude(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1528,6 +1564,8 @@ int set_DHCPv6ServerPool_IANAEnable(char *refparam, struct dmctx *ctx, void *dat
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1546,6 +1584,8 @@ int set_DHCPv6ServerPool_IANAManualPrefixes(char *refparam, struct dmctx *ctx, v
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, "8", NULL, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1570,6 +1610,8 @@ int set_DHCPv6ServerPool_IAPDEnable(char *refparam, struct dmctx *ctx, void *dat
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1588,6 +1630,8 @@ int set_DHCPv6ServerPool_IAPDManualPrefixes(char *refparam, struct dmctx *ctx, v
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, "8", NULL, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1612,6 +1656,8 @@ int set_DHCPv6ServerPool_IAPDAddLength(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, "64"))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -1673,6 +1719,8 @@ int set_DHCPv6ServerPoolClient_Alias(char *refparam, struct dmctx *ctx, void *da
case VALUECHECK:
break;
case VALUESET:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
//TODO
break;
}
@ -1812,7 +1860,7 @@ int set_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -1828,7 +1876,7 @@ int set_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, void *d
uci_foreach_element(dhcp_option_list, e) {
buf = strsplit(e->name, ",", &length);
if (strcmp(buf[0], ((struct dhcpv6_client_option_args *)data)->option_tag) == 0) {
test= true;
test = true;
if (!b)
dmuci_del_list_value_by_section(((struct dhcpv6_client_option_args *)data)->client_sect, "dhcp_option", opt_value);
break;
@ -1852,6 +1900,8 @@ int set_DHCPv6ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
DMUCI_SET_VALUE_BY_SECTION(bbfdm, ((struct dhcpv6_client_option_args *)data)->opt_sect, "bbf_dhcpv6_servpool_option_alias", value);
@ -1862,7 +1912,7 @@ int set_DHCPv6ServerPoolOption_Alias(char *refparam, struct dmctx *ctx, void *da
int get_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= dmstrdup(((struct dhcpv6_client_option_args *)data)->option_tag);
*value = dmstrdup(((struct dhcpv6_client_option_args *)data)->option_tag);
return 0;
}
@ -1875,6 +1925,9 @@ int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, void *data
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
dmuci_get_value_by_section_list(((struct dhcpv6_client_option_args *)data)->client_sect, "dhcp_option", &dhcp_option_list);
if (dhcp_option_list == NULL)
@ -1913,6 +1966,9 @@ int set_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (dm_validate_hexBinary(value, "0", "65535"))
return FAULT_9007;
dmuci_get_value_by_section_list(((struct dhcpv6_client_option_args *)data)->client_sect, "dhcp_option", &dhcp_option_list);
if (dhcp_option_list == NULL)
return 0;
@ -1945,6 +2001,8 @@ int set_DHCPv6ServerPoolOption_PassthroughClient(char *refparam, struct dmctx *c
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO

View file

@ -138,7 +138,7 @@ static inline char *nslookup_get(char *option, char *def)
{
char *tmp;
dmuci_get_varstate_string("cwmp", "@nslookupdiagnostic[0]", option, &tmp);
if(tmp && tmp[0] == '\0')
if (tmp && tmp[0] == '\0')
return dmstrdup(def);
else
return tmp;
@ -239,12 +239,10 @@ int browseServerInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
char *instance, *instnbr = NULL;
dmmap_synchronizeDNSClientRelayServer(dmctx, NULL, NULL, NULL);
uci_path_foreach_sections(bbfdm, "dmmap_dns", "dns_server", s)
{
uci_path_foreach_sections(bbfdm, "dmmap_dns", "dns_server", s) {
instance = handle_update_instance(1, dmctx, &instnbr, update_instance_alias_bbfdm, 3, s, "dns_server_instance", "dns_server_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, instance) == DM_STOP)
break;
}
return 0;
}
@ -255,8 +253,7 @@ int browseRelayForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *pr
char *instance, *instnbr = NULL;
dmmap_synchronizeDNSClientRelayServer(dmctx, NULL, NULL, NULL);
uci_path_foreach_sections(bbfdm, "dmmap_dns", "dns_server", s)
{
uci_path_foreach_sections(bbfdm, "dmmap_dns", "dns_server", s) {
instance = handle_update_instance(1, dmctx, &instnbr, update_instance_alias_bbfdm, 3, s, "dns_server_instance", "dns_server_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, instance) == DM_STOP)
break;
@ -270,8 +267,7 @@ int browseResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
struct uci_section *s = NULL;
char *instance, *idx_last = NULL;
uci_foreach_sections_state("cwmp", "NSLookupResult", s)
{
uci_foreach_sections_state("cwmp", "NSLookupResult", s) {
instance = handle_update_instance(2, dmctx, &idx_last, update_instance_alias, 3, (void *)s, "nslookup_res_instance", "nslookup_res_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, instance) == DM_STOP)
break;
@ -411,8 +407,7 @@ int get_client_server_number_of_entries(char *refparam, struct dmctx *ctx, void
int cnt = 0;
dmmap_synchronizeDNSClientRelayServer(ctx, NULL, NULL, NULL);
uci_path_foreach_sections(bbfdm, "dmmap_dns", "dns_server", s)
{
uci_path_foreach_sections(bbfdm, "dmmap_dns", "dns_server", s) {
cnt++;
}
dmasprintf(value, "%d", cnt);
@ -452,6 +447,8 @@ int get_server_interface(char *refparam, struct dmctx *ctx, void *data, char *in
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &linker);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL)
*value = "";
return 0;
}
@ -462,12 +459,10 @@ int get_server_type(char *refparam, struct dmctx *ctx, void *data, char *instanc
dmuci_get_value_by_section_string((struct uci_section *)data, "peerdns", &v);
if (*v == '1') {
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &v);
if (strchr(v, ':') == NULL) {
if (strchr(v, ':') == NULL)
*value = "DHCPv4";
}
else {
else
*value = "DHCPv6";
}
}
return 0;
}
@ -498,8 +493,7 @@ int get_relay_forward_number_of_entries(char *refparam, struct dmctx *ctx, void
int cnt = 0;
dmmap_synchronizeDNSClientRelayServer(ctx, NULL, NULL, NULL);
uci_path_foreach_sections(bbfdm, "dmmap_dns", "dns_server", s)
{
uci_path_foreach_sections(bbfdm, "dmmap_dns", "dns_server", s) {
cnt++;
}
dmasprintf(value, "%d", cnt);
@ -539,6 +533,8 @@ int get_forwarding_interface(char *refparam, struct dmctx *ctx, void *data, char
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &linker);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL)
*value = "";
return 0;
}
@ -549,12 +545,10 @@ int get_forwarding_type(char *refparam, struct dmctx *ctx, void *data, char *ins
dmuci_get_value_by_section_string((struct uci_section *)data, "peerdns", &v);
if (*v == '1') {
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &v);
if (strchr(v, ':') == NULL) {
if (strchr(v, ':') == NULL)
*value = "DHCPv4";
}
else {
else
*value = "DHCPv6";
}
}
return 0;
}
@ -606,8 +600,7 @@ int get_nslookupdiagnostics_result_number_of_entries(char *refparam, struct dmct
struct uci_section *s = NULL;
int cnt = 0;
uci_foreach_sections_state("cwmp", "NSLookupResult", s)
{
uci_foreach_sections_state("cwmp", "NSLookupResult", s) {
cnt++;
}
dmasprintf(value, "%d", cnt); // MEM WILL BE FREED IN DMMEMCLEAN
@ -654,6 +647,8 @@ int set_client_enable(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -668,7 +663,7 @@ int set_server_enable(char *refparam, struct dmctx *ctx, void *data, char *insta
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -683,12 +678,10 @@ int set_server_enable(char *refparam, struct dmctx *ctx, void *data, char *insta
dmuci_set_value_by_section((struct uci_section *)data, "enable", b ? "1" : "0");
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &interface);
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &ip);
if (b == 1) {
if (b == 1)
dmuci_add_list_value("network", interface, "dns", ip);
}
else {
else
dmuci_del_list_value("network", interface, "dns", ip);
}
break;
}
return 0;
@ -698,6 +691,8 @@ int set_server_alias(char *refparam, struct dmctx *ctx, void *data, char *instan
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "dns_server_alias", value);
@ -716,6 +711,8 @@ int set_server_dns_server(char *refparam, struct dmctx *ctx, void *data, char *i
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "45", NULL, IPAddress))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &oip);
@ -755,6 +752,8 @@ int set_server_interface(char *refparam, struct dmctx *ctx, void *data, char *in
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &ointerface);
@ -767,9 +766,8 @@ int set_server_interface(char *refparam, struct dmctx *ctx, void *data, char *in
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &ip);
dmuci_del_list_value("network", ointerface, "dns", ip);
dmuci_get_value_by_section_string((struct uci_section *)data, "enable", &str);
if (str[0] == '1') {
if (str[0] == '1')
dmuci_add_list_value("network", interface, "dns", ip);
}
dmuci_set_value_by_section((struct uci_section *)data, "interface", interface);
break;
}
@ -782,15 +780,12 @@ int set_relay_enable(char *refparam, struct dmctx *ctx, void *data, char *instan
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmcmd("/etc/init.d/dnsmasq", 1, "enable");
else
dmcmd("/etc/init.d/dnsmasq", 1, "disable");
dmcmd("/etc/init.d/dnsmasq", 1, b ? "enable" : "disable");
break;
}
return 0;
@ -803,7 +798,7 @@ int set_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *i
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -818,12 +813,10 @@ int set_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *i
dmuci_set_value_by_section((struct uci_section *)data, "enable", b ? "1" : "0");
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &interface);
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &ip);
if (b == 1) {
if (b == 1)
dmuci_add_list_value("network", interface, "dns", ip);
}
else {
else
dmuci_del_list_value("network", interface, "dns", ip);
}
break;
}
return 0;
@ -833,6 +826,8 @@ int set_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *in
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "dns_server_alias", value);
@ -851,6 +846,8 @@ int set_forwarding_dns_server(char *refparam, struct dmctx *ctx, void *data, cha
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "45", NULL, IPAddress))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &oip);
@ -890,6 +887,8 @@ int set_forwarding_interface(char *refparam, struct dmctx *ctx, void *data, char
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &ointerface);
@ -902,9 +901,8 @@ int set_forwarding_interface(char *refparam, struct dmctx *ctx, void *data, char
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &ip);
dmuci_del_list_value("network", ointerface, "dns", ip);
dmuci_get_value_by_section_string((struct uci_section *)data, "enable", &str);
if (str[0] == '1') {
if (str[0] == '1')
dmuci_add_list_value("network", interface, "dns", ip);
}
dmuci_set_value_by_section((struct uci_section *)data, "interface", interface);
break;
}
@ -918,15 +916,15 @@ int set_nslookupdiagnostics_diagnostics_state(char *refparam, struct dmctx *ctx,
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, DiagnosticsState, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "Requested") == 0) {
NSLOOKUP_STOP
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "nslookupdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
if (!curr_section)
dmuci_add_state_section("cwmp", "nslookupdiagnostic", &curr_section, &tmp);
}
dmuci_set_varstate_value("cwmp", "@nslookupdiagnostic[0]", "DiagnosticState", value);
cwmp_set_end_session(END_SESSION_NSLOOKUP_DIAGNOSTIC);
}
@ -942,14 +940,14 @@ int set_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
NSLOOKUP_STOP
curr_section = dmuci_walk_state_section("cwmp", "nslookupdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
if (!curr_section)
dmuci_add_state_section("cwmp", "nslookupdiagnostic", &curr_section, &tmp);
}
dmuci_set_varstate_value("cwmp", "@nslookupdiagnostic[0]", "interface", value);
return 0;
}
@ -963,14 +961,14 @@ int set_nslookupdiagnostics_host_name(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
NSLOOKUP_STOP
curr_section = dmuci_walk_state_section("cwmp", "nslookupdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
if (!curr_section)
dmuci_add_state_section("cwmp", "nslookupdiagnostic", &curr_section, &tmp);
}
dmuci_set_varstate_value("cwmp", "@nslookupdiagnostic[0]", "HostName", value);
return 0;
}
@ -984,14 +982,14 @@ int set_nslookupdiagnostics_d_n_s_server(char *refparam, struct dmctx *ctx, void
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
NSLOOKUP_STOP
curr_section = dmuci_walk_state_section("cwmp", "nslookupdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
if (!curr_section)
dmuci_add_state_section("cwmp", "nslookupdiagnostic", &curr_section, &tmp);
}
dmuci_set_varstate_value("cwmp", "@nslookupdiagnostic[0]", "DNSServer", value);
return 0;
}
@ -1005,14 +1003,14 @@ int set_nslookupdiagnostics_timeout(char *refparam, struct dmctx *ctx, void *dat
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
NSLOOKUP_STOP
curr_section = dmuci_walk_state_section("cwmp", "nslookupdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
if (!curr_section)
dmuci_add_state_section("cwmp", "nslookupdiagnostic", &curr_section, &tmp);
}
dmuci_set_varstate_value("cwmp", "@nslookupdiagnostic[0]", "Timeout", value);
return 0;
}
@ -1026,14 +1024,14 @@ int set_nslookupdiagnostics_number_of_repetitions(char *refparam, struct dmctx *
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
NSLOOKUP_STOP
curr_section = dmuci_walk_state_section("cwmp", "nslookupdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
if (!curr_section)
dmuci_add_state_section("cwmp", "nslookupdiagnostic", &curr_section, &tmp);
}
dmuci_set_varstate_value("cwmp", "@nslookupdiagnostic[0]", "NumberOfRepetitions", value);
return 0;
}

View file

@ -485,6 +485,8 @@ int set_DSLLine_Enable(char *refparam, struct dmctx *ctx, void *data, char *inst
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -510,6 +512,8 @@ int set_DSLLine_Alias(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dsl_line_args *)data)->line_sec, "dsl_line_alias", value);
@ -534,6 +538,8 @@ int set_DSLLine_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, "1024", NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1106,6 +1112,8 @@ int set_DSLChannel_Enable(char *refparam, struct dmctx *ctx, void *data, char *i
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1131,6 +1139,8 @@ int set_DSLChannel_Alias(char *refparam, struct dmctx *ctx, void *data, char *in
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dsl_channel_args *)data)->channel_sec, "dsl_channel_alias", value);

View file

@ -405,9 +405,10 @@ int get_DynamicDNSClient_Enable(char *refparam, struct dmctx *ctx, void *data, c
int set_DynamicDNSClient_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -455,22 +456,27 @@ int get_DynamicDNSClient_Status(char *refparam, struct dmctx *ctx, void *data, c
int get_DynamicDNSClient_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_ddns", "service", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "clientalias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "clientalias", value);
return 0;
}
int set_DynamicDNSClient_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_ddns", "service", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "clientalias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "clientalias", value);
break;
}
return 0;
@ -529,6 +535,8 @@ int set_DynamicDNSClient_Server(char *refparam, struct dmctx *ctx, void *data, c
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
@ -558,6 +566,8 @@ int set_DynamicDNSClient_Interface(char *refparam, struct dmctx *ctx, void *data
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
@ -581,6 +591,8 @@ int set_DynamicDNSClient_Username(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "username", value);
@ -600,6 +612,8 @@ int set_DynamicDNSClient_Password(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "password", value);
@ -626,9 +640,10 @@ int get_DynamicDNSClientHostname_Enable(char *refparam, struct dmctx *ctx, void
int set_DynamicDNSClientHostname_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -683,6 +698,8 @@ int set_DynamicDNSClientHostname_Name(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "domain", value);
@ -747,6 +764,8 @@ int set_DynamicDNSServer_Enable(char *refparam, struct dmctx *ctx, void *data, c
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "enabled", value);
@ -772,6 +791,8 @@ int set_DynamicDNSServer_Name(char *refparam, struct dmctx *ctx, void *data, cha
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "section_name", value);
@ -795,6 +816,8 @@ int set_DynamicDNSServer_Alias(char *refparam, struct dmctx *ctx, void *data, ch
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "serveralias", value);
@ -817,6 +840,8 @@ int set_DynamicDNSServer_ServiceName(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "service_name", &service_name);
@ -853,6 +878,8 @@ int set_DynamicDNSServer_ServerAddress(char *refparam, struct dmctx *ctx, void *
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "dns_server", &dns_server);
@ -879,11 +906,7 @@ int set_DynamicDNSServer_ServerAddress(char *refparam, struct dmctx *ctx, void *
strcpy(new, value);
dmuci_set_value_by_section(s, "dns_server", new);
}
}
break;
}
return 0;
@ -912,6 +935,8 @@ int set_DynamicDNSServer_ServerPort(char *refparam, struct dmctx *ctx, void *dat
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "dns_server", &dns_server);
@ -972,6 +997,8 @@ int set_DynamicDNSServer_Protocol(char *refparam, struct dmctx *ctx, void *data,
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, SupportedProtocols, NULL))
return FAULT_9007;
break;
case VALUESET:
if (strcmp(value, "HTTP") == 0)
@ -1007,6 +1034,8 @@ int set_DynamicDNSServer_CheckInterval(char *refparam, struct dmctx *ctx, void *
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "check_unit", &check_unit);
@ -1045,6 +1074,8 @@ int set_DynamicDNSServer_RetryInterval(char *refparam, struct dmctx *ctx, void *
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "retry_unit", &retry_unit);
@ -1081,6 +1112,8 @@ int set_DynamicDNSServer_MaxRetries(char *refparam, struct dmctx *ctx, void *dat
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "retry_count", value);

View file

@ -433,7 +433,7 @@ int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data,
dmuci_delete_by_section_unnamed(((struct dm_args *)data)->section, NULL, NULL);
} else {
get_dmmap_section_of_config_section("dmmap_dropbear", "dropbear", section_name(((struct dm_args *)data)->section), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section_unnamed_bbfdm(dmmap_section, NULL, NULL);
dmuci_delete_by_section(((struct dm_args *)data)->section, NULL, NULL);
}
@ -442,7 +442,7 @@ int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data,
uci_foreach_sections("network", "device", s) {
if (found != 0){
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(s), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
@ -451,7 +451,7 @@ int delObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data,
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
@ -469,8 +469,7 @@ int get_Ethernet_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, voi
struct uci_section *s = NULL;
int cnt = 0;
uci_foreach_sections("ports", "ethport", s)
{
uci_foreach_sections("ports", "ethport", s) {
cnt++;
}
dmasprintf(value, "%d", cnt);
@ -483,8 +482,7 @@ int get_Ethernet_LinkNumberOfEntries(char *refparam, struct dmctx *ctx, void *da
int cnt = 0;
dmmap_synchronizeEthernetLink(ctx, NULL, NULL, NULL);
uci_path_foreach_sections(bbfdm, DMMAP, "link", s)
{
uci_path_foreach_sections(bbfdm, DMMAP, "link", s) {
cnt++;
}
dmasprintf(value, "%d", cnt);
@ -498,8 +496,7 @@ int get_Ethernet_VLANTerminationNumberOfEntries(char *refparam, struct dmctx *ct
char *type, *vlan_method;
int cnt = 0;
uci_foreach_sections("network", "device", s)
{
uci_foreach_sections("network", "device", s) {
dmuci_get_value_by_section_string(s, "type", &type);
dmuci_get_option_value_string("cwmp", "cpe", "vlan_method", &vlan_method);
if ((strcmp(vlan_method, "2") != 0 && strcmp(vlan_method, "1") != 0) || (strcmp(vlan_method, "1") == 0 && strcmp(type, "untagged") == 0))
@ -535,7 +532,7 @@ int set_EthernetInterface_Enable(char *refparam, struct dmctx *ctx, void *data,
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -565,25 +562,29 @@ int get_EthernetInterface_Status(char *refparam, struct dmctx *ctx, void *data,
int get_EthernetInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_ports", "ethport", section_name(((struct eth_port_args *)data)->eth_port_sec), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "eth_port_alias", value);
if(*value == NULL || strlen(*value)<1)
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "eth_port_alias", value);
if (*value == NULL || strlen(*value) < 1)
dmuci_get_value_by_section_string(((struct eth_port_args *)data)->eth_port_sec, "name", value);
return 0;
}
int set_EthernetInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_ports", "ethport", section_name(((struct eth_port_args *)data)->eth_port_sec), &dmmap_section);
dmuci_set_value_by_section(dmmap_section, "eth_port_alias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "eth_port_alias", value);
return 0;
}
return 0;
@ -628,6 +629,8 @@ int set_EthernetInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, "1024", NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -677,19 +680,20 @@ int set_EthernetInterface_MaxBitRate(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (strcasecmp(value, "0") == 0 ) {
if (strcasecmp(value, "0") == 0 )
dmuci_set_value_by_section(((struct eth_port_args *)data)->eth_port_sec, "speed", "disabled");
} else if (strcmp(value, "-1") == 0) {
else if (strcmp(value, "-1") == 0)
dmuci_set_value_by_section(((struct eth_port_args *)data)->eth_port_sec, "speed", "auto");
} else {
else {
dmuci_get_value_by_section_string(((struct eth_port_args *)data)->eth_port_sec, "speed", &duplex);
if (strcmp(duplex, "auto") == 0 || strcmp(duplex, "disabled") == 0)
p = "FDAUTO";
else {
else
p = strchr(duplex, 'F') ? strchr(duplex, 'F') : strchr(duplex, 'H');
}
if (p) dmastrcat(&val, value, p);
dmuci_set_value_by_section(((struct eth_port_args *)data)->eth_port_sec, "speed", val);
dmfree(val);
@ -720,11 +724,11 @@ int get_EthernetInterface_CurrentBitRate(char *refparam, struct dmctx *ctx, void
int get_EthernetInterface_DuplexMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct eth_port_args *)data)->eth_port_sec, "speed", value);
if (*value[0] == '\0') {
if (*value[0] == '\0')
*value = "";
} else if (strcmp(*value, "auto") == 0) {
else if (strcmp(*value, "auto") == 0)
*value = "Auto";
} else {
else {
if (strchr(*value, 'F'))
*value = "Full";
else if (strchr(*value, 'H'))
@ -741,6 +745,8 @@ int set_EthernetInterface_DuplexMode(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, DuplexMode, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (strcasecmp(value, "auto") == 0) {
@ -877,6 +883,8 @@ int set_EthernetLink_Enable(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -900,6 +908,8 @@ int set_EthernetLink_Alias(char *refparam, struct dmctx *ctx, void *data, char *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dm_args *)data)->section, "link_alias", value);
@ -981,6 +991,8 @@ int set_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, "1024", NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1085,6 +1097,8 @@ int set_EthernetVLANTermination_Enable(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1100,34 +1114,39 @@ int get_EthernetVLANTermination_Status(char *refparam, struct dmctx *ctx, void *
int get_EthernetVLANTermination_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
char *vlan_method= NULL;
struct uci_section *dmmap_section = NULL;
char *vlan_method = NULL;
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(((struct dm_args *)data)->section), &dmmap_section);
dmuci_get_option_value_string("cwmp", "cpe", "vlan_method", &vlan_method);
if(strcmp(vlan_method, "2") == 0)
dmuci_get_value_by_section_string(dmmap_section, "all_vlan_term_alias", value);
else
dmuci_get_value_by_section_string(dmmap_section, "vlan_term_alias", value);
if (dmmap_section) {
dmuci_get_option_value_string("cwmp", "cpe", "vlan_method", &vlan_method);
if(strcmp(vlan_method, "2") == 0)
dmuci_get_value_by_section_string(dmmap_section, "all_vlan_term_alias", value);
else
dmuci_get_value_by_section_string(dmmap_section, "vlan_term_alias", value);
}
return 0;
}
int set_EthernetVLANTermination_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
char *vlan_method= NULL;
struct uci_section *dmmap_section = NULL;
char *vlan_method = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(((struct dm_args *)data)->section), &dmmap_section);
dmuci_get_option_value_string("cwmp", "cpe", "vlan_method", &vlan_method);
if(strcmp(vlan_method, "2") == 0)
dmuci_set_value_by_section(dmmap_section, "all_vlan_term_alias", value);
else
dmuci_set_value_by_section(dmmap_section, "vlan_term_alias", value);
if (dmmap_section) {
dmuci_get_option_value_string("cwmp", "cpe", "vlan_method", &vlan_method);
if(strcmp(vlan_method, "2") == 0)
dmuci_set_value_by_section(dmmap_section, "all_vlan_term_alias", value);
else
dmuci_set_value_by_section(dmmap_section, "vlan_term_alias", value);
}
return 0;
}
return 0;
@ -1188,9 +1207,11 @@ int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx *ctx, v
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, "1024", NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (value[strlen(value)-1]!='.') {
if (value[strlen(value)-1] != '.') {
dmasprintf(&newvalue, "%s.", value);
adm_entry_get_linker_value(ctx, newvalue, &linker);
} else
@ -1229,6 +1250,8 @@ int set_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx, void *
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", "4094"))
return FAULT_9007;
return 0;
case VALUESET: {
dmuci_get_value_by_section_string(((struct dm_args *)data)->section, "ifname", &ifname);
@ -1258,7 +1281,7 @@ int get_EthernetVLANTermination_TPID(char *refparam, struct dmctx *ctx, void *da
else if (strcmp(type, "8021ad") == 0)
*value = "34984";
else
return -1;
*value = "37120";
return 0;
}
@ -1266,6 +1289,8 @@ int set_EthernetVLANTermination_TPID(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "33024") == 0)

View file

@ -70,7 +70,7 @@ DMLEAF tFirewallChainRuleParams[] = {
{"Order", &DMWRITE, DMT_UNINT, get_rule_order, set_rule_order, NULL, NULL, BBFDM_BOTH},
{"Description", &DMWRITE, DMT_STRING, get_rule_description, set_rule_description, NULL, NULL, BBFDM_BOTH},
{"Target", &DMWRITE, DMT_STRING, get_rule_target, set_rule_target, NULL, NULL, BBFDM_BOTH},
{"TargetChain", &DMWRITE, DMT_STRING, get_rule_target_chain, set_rule_target_chain, NULL, NULL, BBFDM_BOTH},
//{"TargetChain", &DMWRITE, DMT_STRING, get_rule_target_chain, set_rule_target_chain, NULL, NULL, BBFDM_BOTH},
{"SourceInterface", &DMWRITE, DMT_STRING, get_rule_source_interface, set_rule_source_interface, NULL, NULL, BBFDM_BOTH},
{"DestInterface", &DMWRITE, DMT_STRING, get_rule_dest_interface, set_rule_dest_interface, NULL, NULL, BBFDM_BOTH},
{"IPVersion", &DMWRITE, DMT_INT, get_rule_i_p_version, set_rule_i_p_version, NULL, NULL, BBFDM_BOTH},
@ -148,10 +148,7 @@ int add_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char **inst
char ib[8];
last_inst = get_last_instance_bbfdm("dmmap_firewall", "rule", "firewall_chain_rule_instance");
if (last_inst)
snprintf(ib, sizeof(ib), "%s", last_inst);
else
snprintf(ib, sizeof(ib), "%s", "1");
snprintf(ib, sizeof(ib), "%s", last_inst ? last_inst : "1");
dmasprintf(&rule_name, "Firewall rule %d", atoi(ib)+1);
dmuci_add_section("firewall", "rule", &s, &sect_name);
@ -168,7 +165,7 @@ int add_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char **inst
int delete_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *ss = NULL, *dmmap_section;
struct uci_section *s = NULL, *ss = NULL, *dmmap_section = NULL;
int found = 0;
switch (del_action) {
@ -180,7 +177,8 @@ int delete_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char *in
dmuci_delete_by_section_unnamed((struct uci_section *)data, NULL, NULL);
} else {
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section_unnamed_bbfdm(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section_unnamed_bbfdm(dmmap_section, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
}
break;
@ -188,7 +186,8 @@ int delete_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char *in
uci_foreach_sections("firewall", "rule", s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(ss), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
@ -196,7 +195,8 @@ int delete_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char *in
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(ss), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
}
@ -339,17 +339,19 @@ int get_rule_status(char *refparam, struct dmctx *ctx, void *data, char *instanc
int get_rule_order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dms;
struct uci_section *dms = NULL;
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name((struct uci_section *)data), &dms);
if (dms) dmuci_get_value_by_section_string(dms, "firewall_chain_rule_instance", value);
if (dms)
dmuci_get_value_by_section_string(dms, "firewall_chain_rule_instance", value);
return 0;
}
int get_rule_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dms;
struct uci_section *dms = NULL;
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name((struct uci_section *)data), &dms);
if (dms) dmuci_get_value_by_section_string(dms, "description", value);
if (dms)
dmuci_get_value_by_section_string(dms, "description", value);
return 0;
}
@ -357,19 +359,18 @@ int get_rule_description(char *refparam, struct dmctx *ctx, void *data, char *in
int get_rule_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *v;
*value = "";
dmuci_get_value_by_section_string((struct uci_section *)data, "target", &v);
if (strcasecmp(v, "Accept") == 0) {
if (strcasecmp(v, "Accept") == 0)
*value = "Accept";
} else if (strcasecmp(v, "Reject") == 0) {
else if (strcasecmp(v, "Reject") == 0)
*value = "Reject";
} else if (strcasecmp(v, "Drop") == 0) {
else if (strcasecmp(v, "Drop") == 0)
*value = "Drop";
} else if (strcasecmp(v, "MARK") == 0) {
else if (strcasecmp(v, "MARK") == 0)
*value = "Return";
} else {
else
*value = v;
}
return 0;
}
@ -488,7 +489,6 @@ int get_rule_dest_ip(char *refparam, struct dmctx *ctx, void *data, char *instan
int get_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *pch, *destip;
*value = "";
dmuci_get_value_by_section_string((struct uci_section *)data, "dest_ip", &destip);
if (*destip == '\0')
@ -511,7 +511,8 @@ int get_rule_source_ip(char *refparam, struct dmctx *ctx, void *data, char *inst
dmuci_get_value_by_section_string((struct uci_section *)data, "src_ip", &srcip);
strcpy(buf, srcip);
pch = strchr(buf, '/');
if (pch) *pch = '\0';
if (pch)
*pch = '\0';
*value = dmstrdup(buf);
return 0;
}
@ -556,7 +557,7 @@ int get_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char *insta
while (fgets (buf , 256 , fp) != NULL) {
sscanf(buf, "%31s %15s", protocol, protocol_nbr);
if (strcmp(protocol, v) == 0) {
*value =dmstrdup(protocol_nbr);
*value = dmstrdup(protocol_nbr);
fclose(fp);
return 0;
}
@ -657,7 +658,7 @@ int get_rule_icmp_type(char *refparam, struct dmctx *ctx, void *data, char *inst
int get_rule_source_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *v= NULL;
char *v = NULL;
dmuci_get_value_by_section_string((struct uci_section *)data, "src_mac", &v);
*value = (v) ? v : "";
return 0;
@ -698,15 +699,12 @@ int set_firewall_enable(char *refparam, struct dmctx *ctx, void *data, char *ins
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmcmd("/etc/init.d/firewall", 1, "enable");
else
dmcmd("/etc/init.d/firewall", 1, "disable");
dmcmd("/etc/init.d/firewall", 1, b ? "enable" : "disable");
break;
}
return 0;
@ -716,10 +714,12 @@ int set_firewall_config(char *refparam, struct dmctx *ctx, void *data, char *ins
{
switch (action) {
case VALUECHECK:
if (strcasecmp(value, "Advanced") != 0)
if (dm_validate_string(value, NULL, NULL, Config, NULL))
return FAULT_9007;
break;
case VALUESET:
if (strcasecmp(value, "Advanced") != 0)
return FAULT_9007;
break;
}
return 0;
@ -729,10 +729,12 @@ int set_firewall_advanced_level(char *refparam, struct dmctx *ctx, void *data, c
{
switch (action) {
case VALUECHECK:
if (strcasecmp(value, "Device.Firewall.Level.1.") != 0)
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
if (strcasecmp(value, "Device.Firewall.Level.1.") != 0)
return FAULT_9007;
break;
}
return 0;
@ -742,6 +744,8 @@ int set_level_name(char *refparam, struct dmctx *ctx, void *data, char *instance
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
DMUCI_SET_VALUE_BY_SECTION(bbfdm, (struct uci_section *)data, "name", value);
@ -754,6 +758,8 @@ int set_level_description(char *refparam, struct dmctx *ctx, void *data, char *i
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
DMUCI_SET_VALUE_BY_SECTION(bbfdm, (struct uci_section *)data, "description", value);
@ -770,7 +776,7 @@ int set_level_port_mapping_enabled(char *refparam, struct dmctx *ctx, void *data
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -801,7 +807,7 @@ int set_level_default_log_policy(char *refparam, struct dmctx *ctx, void *data,
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -822,10 +828,9 @@ int set_level_default_log_policy(char *refparam, struct dmctx *ctx, void *data,
int set_chain_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b) || !b)
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -838,6 +843,8 @@ int set_chain_name(char *refparam, struct dmctx *ctx, void *data, char *instance
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
DMUCI_SET_VALUE_BY_SECTION(bbfdm, (struct uci_section *)data, "name", value);
@ -852,12 +859,12 @@ int set_rule_enable(char *refparam, struct dmctx *ctx, void *data, char *instanc
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "enabled", (b) ? "" : "no");
dmuci_set_value_by_section((struct uci_section *)data, "enabled", b ? "" : "no");
break;
}
return 0;
@ -867,6 +874,8 @@ int set_rule_order(char *refparam, struct dmctx *ctx, void *data, char *instance
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -876,14 +885,17 @@ int set_rule_order(char *refparam, struct dmctx *ctx, void *data, char *instance
int set_rule_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dms;
struct uci_section *dms = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name((struct uci_section *)data), &dms);
if (dms) DMUCI_SET_VALUE_BY_SECTION(bbfdm, dms, "description", value);
if (dms)
DMUCI_SET_VALUE_BY_SECTION(bbfdm, dms, "description", value);
break;
}
return 0;
@ -893,17 +905,18 @@ int set_rule_target(char *refparam, struct dmctx *ctx, void *data, char *instanc
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, Target, NULL))
return FAULT_9007;
break;
case VALUESET:
if (strcasecmp(value, "Accept") == 0) {
if (strcasecmp(value, "Accept") == 0)
dmuci_set_value_by_section((struct uci_section *)data, "target", "ACCEPT");
} else if (strcasecmp(value, "Reject") == 0) {
else if (strcasecmp(value, "Reject") == 0)
dmuci_set_value_by_section((struct uci_section *)data, "target", "REJECT");
} else if (strcasecmp(value, "Drop") == 0) {
else if (strcasecmp(value, "Drop") == 0)
dmuci_set_value_by_section((struct uci_section *)data, "target", "DROP");
} else if (strcasecmp(value, "Return") == 0) {
else if (strcasecmp(value, "Return") == 0)
dmuci_set_value_by_section((struct uci_section *)data, "target", "MARK");
}
break;
}
return 0;
@ -913,6 +926,8 @@ int set_rule_target_chain(char *refparam, struct dmctx *ctx, void *data, char *i
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -927,8 +942,11 @@ int set_rule_source_interface(char *refparam, struct dmctx *ctx, void *data, cha
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
adm_entry_get_linker_value(ctx, value, &iface);
if(iface == NULL || iface[0] == '\0')
if (iface == NULL || iface[0] == '\0')
return FAULT_9007;
break;
case VALUESET:
@ -955,6 +973,8 @@ int set_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data, char
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &iface);
@ -977,15 +997,16 @@ int set_rule_i_p_version(char *refparam, struct dmctx *ctx, void *data, char *in
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", "15"))
return FAULT_9007;
break;
case VALUESET:
if (strcmp(value, "4") == 0) {
if (strcmp(value, "4") == 0)
dmuci_set_value_by_section((struct uci_section *)data, "family", "ipv4");
} else if (strcmp(value, "6") == 0) {
else if (strcmp(value, "6") == 0)
dmuci_set_value_by_section((struct uci_section *)data, "family", "ipv6");
} else if (strcmp(value, "-1") == 0) {
else if (strcmp(value, "-1") == 0)
dmuci_set_value_by_section((struct uci_section *)data, "family", "");
}
break;
}
return 0;
@ -993,21 +1014,21 @@ int set_rule_i_p_version(char *refparam, struct dmctx *ctx, void *data, char *in
int set_rule_dest_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char buf[64], new[64];
char *pch, *destip;
char buf[64], new[64], *pch, *destip;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "45", NULL, IPAddress))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "dest_ip", &destip);
strcpy(buf, destip);
pch = strchr(buf, '/');
if (pch) {
if (pch)
snprintf(new, sizeof(new), "%s%s", value, pch);
} else {
else
strcpy(new, value);
}
dmuci_set_value_by_section((struct uci_section *)data, "dest_ip", new);
break;
}
@ -1016,19 +1037,19 @@ int set_rule_dest_ip(char *refparam, struct dmctx *ctx, void *data, char *instan
int set_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char buf[64], new[64];
char *pch, *destip;
char buf[64], new[64], *pch, *destip;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "49", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "dest_ip", &destip);
strcpy(buf, destip);
pch = strchr(buf, '/');
if (pch) {
if (pch)
*pch = '\0';
}
snprintf(new, sizeof(new), "%s/%s", buf, value);
dmuci_set_value_by_section((struct uci_section *)data, "dest_ip", new);
break;
@ -1038,21 +1059,21 @@ int set_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, char *inst
int set_rule_source_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char buf[64], new[64];
char *pch, *srcip;
char buf[64], new[64], *pch, *srcip;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "45", NULL, IPAddress))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "src_ip", &srcip);
strcpy(buf, srcip);
pch = strchr(buf, '/');
if (pch) {
if (pch)
snprintf(new, sizeof(new), "%s%s", value, pch);
} else {
else
strcpy(new, value);
}
dmuci_set_value_by_section((struct uci_section *)data, "src_ip", new);
break;
}
@ -1061,19 +1082,19 @@ int set_rule_source_ip(char *refparam, struct dmctx *ctx, void *data, char *inst
int set_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char buf[64], new[64];
char *pch, *srcip;
char buf[64], new[64], *pch, *srcip;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "49", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "src_ip", &srcip);
strcpy(buf, srcip);
pch = strchr(buf, '/');
if (pch) {
if (pch)
*pch = '\0';
}
snprintf(new, sizeof(new), "%s/%s", buf, value);
dmuci_set_value_by_section((struct uci_section *)data, "src_ip", new);
break;
@ -1085,12 +1106,11 @@ int set_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", "255"))
return FAULT_9007;
break;
case VALUESET:
if (*value == '-')
dmuci_set_value_by_section((struct uci_section *)data, "proto", "");
else
dmuci_set_value_by_section((struct uci_section *)data, "proto", value);
dmuci_set_value_by_section((struct uci_section *)data, "proto", (*value == '-') ? "" : value);
break;
}
return 0;
@ -1098,9 +1118,12 @@ int set_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char *insta
int set_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *v, buffer[64], *tmp;
char buffer[64], *v, *tmp = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", "65535"))
return FAULT_9007;
break;
case VALUESET:
if (*value == '-')
@ -1109,12 +1132,10 @@ int set_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, char *inst
tmp = strchr(v, ':');
if (tmp == NULL)
tmp = strchr(v, '-');
if (tmp == NULL) {
if (tmp == NULL)
snprintf(buffer, sizeof(buffer), "%s", value);
} else {
else
snprintf(buffer, sizeof(buffer), "%s%s", value, tmp);
}
dmuci_set_value_by_section((struct uci_section *)data, "dest_port", buffer);
break;
}
@ -1124,8 +1145,11 @@ int set_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, char *inst
int set_rule_dest_port_range_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *v, *tmp, *buf, buffer[64];
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", "65535"))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "dest_port", &v);
@ -1136,11 +1160,10 @@ int set_rule_dest_port_range_max(char *refparam, struct dmctx *ctx, void *data,
tmp = strchr(v, '-');
if (tmp)
*tmp = '\0';
if (*value == '-') {
if (*value == '-')
snprintf(buffer, sizeof(buffer), "%s", v);
} else {
else
snprintf(buffer, sizeof(buffer), "%s:%s", v, value);
}
dmfree(buf);
dmuci_set_value_by_section((struct uci_section *)data, "dest_port", buffer);
break;
@ -1150,9 +1173,12 @@ int set_rule_dest_port_range_max(char *refparam, struct dmctx *ctx, void *data,
int set_rule_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *v, buffer[64], *tmp;
char buffer[64], *v, *tmp = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", "65535"))
return FAULT_9007;
break;
case VALUESET:
if (*value == '-')
@ -1161,11 +1187,10 @@ int set_rule_source_port(char *refparam, struct dmctx *ctx, void *data, char *in
tmp = strchr(v, ':');
if (tmp == NULL)
tmp = strchr(v, '-');
if (tmp == NULL) {
if (tmp == NULL)
snprintf(buffer, sizeof(buffer), "%s", value);
} else {
else
snprintf(buffer, sizeof(buffer), "%s%s", value, tmp);
}
dmuci_set_value_by_section((struct uci_section *)data, "src_port", buffer);
break;
}
@ -1175,8 +1200,11 @@ int set_rule_source_port(char *refparam, struct dmctx *ctx, void *data, char *in
int set_rule_source_port_range_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *v, *tmp, *buf, buffer[64];
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", "65535"))
return FAULT_9007;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "src_port", &v);
@ -1187,11 +1215,10 @@ int set_rule_source_port_range_max(char *refparam, struct dmctx *ctx, void *data
tmp = strchr(buf, '-');
if (tmp)
*tmp = '\0';
if (*value == '-') {
if (*value == '-')
snprintf(buffer, sizeof(buffer), "%s", v);
} else {
else
snprintf(buffer, sizeof(buffer), "%s:%s", v, value);
}
dmfree(buf);
dmuci_set_value_by_section((struct uci_section *)data, "src_port", buffer);
break;
@ -1201,11 +1228,13 @@ int set_rule_source_port_range_max(char *refparam, struct dmctx *ctx, void *data
int set_rule_icmp_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int i;
size_t length;
char **devices = NULL;
size_t length, i;
switch (action) {
case VALUECHECK:
//TODO
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "icmp_type", "");
@ -1221,6 +1250,7 @@ int set_rule_source_mac(char *refparam, struct dmctx *ctx, void *data, char *ins
{
switch (action) {
case VALUECHECK:
//TODO
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "src_mac", value);
@ -1233,6 +1263,7 @@ int set_time_span_supported_days(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
//TODO
break;
case VALUESET:
break;
@ -1244,6 +1275,7 @@ int set_time_span_days(char *refparam, struct dmctx *ctx, void *data, char *inst
{
switch (action) {
case VALUECHECK:
//TODO
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "weekdays", value);
@ -1256,6 +1288,7 @@ int set_time_span_start_time(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
//TODO
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "start_time", value);
@ -1268,6 +1301,7 @@ int set_time_span_stop_time(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
//TODO
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "stop_time", value);

View file

@ -176,9 +176,8 @@ int browseGRETunnelInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void
*************************************************************/
int addObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value, *v;
char *instance;
struct uci_section *gre_sec = NULL, *dmmap_sec= NULL;
char *value, *v, *instance;
struct uci_section *gre_sec = NULL, *dmmap_sec = NULL;
check_create_dmmap_package("dmmap_network");
instance = get_last_instance_lev2_bbfdm("network", "interface", "dmmap_network", "gretunnel_instance", "proto", "gre");
@ -194,24 +193,23 @@ int addObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char **instan
int delObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
struct uci_section *dmmap_section;
struct uci_section *s = NULL, *ss = NULL, *dmmap_section = NULL;
int found = 0;
struct dmmap_dup *p= (struct dmmap_dup *)data;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(p->config_section), &dmmap_section);
dmuci_set_value_by_section(dmmap_section, "gretunnel_instance", "");
dmuci_set_value_by_section(dmmap_section, "gretunnel_alias", "");
dmuci_delete_by_section(p->config_section, NULL, NULL);
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct dmmap_dup *)data)->config_section), &dmmap_section);
if (dmmap_section != NULL) {
dmuci_set_value_by_section(dmmap_section, "gretunnel_instance", "");
dmuci_set_value_by_section(dmmap_section, "gretunnel_alias", "");
}
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_option_eq("network", "interface", "proto", "gre", s) {
if (found != 0){
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(ss), &dmmap_section);
if(dmmap_section != NULL){
if (dmmap_section != NULL) {
dmuci_set_value_by_section(dmmap_section, "gretunnel_instance", "");
dmuci_set_value_by_section(dmmap_section, "gretunnel_alias", "");
}
@ -222,7 +220,7 @@ int delObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char *instanc
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(ss), &dmmap_section);
if(dmmap_section != NULL){
if (dmmap_section != NULL) {
dmuci_set_value_by_section(dmmap_section, "gretunnel_instance", "");
dmuci_set_value_by_section(dmmap_section, "gretunnel_alias", "");
}
@ -254,16 +252,14 @@ int delObjGREFilter(char *refparam, struct dmctx *ctx, void *data, char *instanc
int addObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value, *v;
char *instance, *ifname;
char *value, *v, *instance, *ifname;
struct uci_section *greiface_sec = NULL, *dmmap_sec= NULL, *route_sec= NULL;
struct dmmap_dup *dm= (struct dmmap_dup *)data;
check_create_dmmap_package("dmmap_network");
instance= get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_network", "interface", "greiface_instance", "gre_tunnel_sect", section_name(dm->config_section));
instance= get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_network", "interface", "greiface_instance", "gre_tunnel_sect", section_name(((struct dmmap_dup *)data)->config_section));
dmuci_add_section("network", "interface", &greiface_sec, &value);
dmasprintf(&ifname, "@%s", section_name(dm->config_section));
dmasprintf(&ifname, "@%s", section_name(((struct dmmap_dup *)data)->config_section));
dmuci_set_value_by_section(greiface_sec, "ifname", ifname);
dmuci_add_section("network", "route", &route_sec, &value);
@ -271,37 +267,38 @@ int addObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *data, char
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_sec, &v);
dmuci_set_value_by_section(dmmap_sec, "section_name", section_name(greiface_sec));
dmuci_set_value_by_section(dmmap_sec, "gre_tunnel_sect", section_name(dm->config_section));
dmuci_set_value_by_section(dmmap_sec, "gre_tunnel_sect", section_name(((struct dmmap_dup *)data)->config_section));
*instancepara = update_instance_bbfdm(dmmap_sec, instance, "greiface_instance");
return 0;
}
int delObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *ss = NULL, *s1 = NULL, *dmmap_section;
struct uci_section *s = NULL, *ss = NULL, *s1 = NULL, *dmmap_section = NULL;
int found = 0;
struct dmmap_dup *p = (struct dmmap_dup *)data;
char *iface = NULL, *atiface = NULL;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(p->config_section), &dmmap_section);
dmuci_set_value_by_section(dmmap_section, "greiface_instance", "");
dmuci_set_value_by_section(dmmap_section, "greiface_alias", "");
if ((s = has_tunnel_interface_route(section_name(p->config_section))) != NULL)
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct dmmap_dup *)data)->config_section), &dmmap_section);
if (dmmap_section != NULL) {
dmuci_set_value_by_section(dmmap_section, "greiface_instance", "");
dmuci_set_value_by_section(dmmap_section, "greiface_alias", "");
}
if ((s = has_tunnel_interface_route(section_name(((struct dmmap_dup *)data)->config_section))) != NULL)
dmuci_delete_by_section(s, NULL, NULL);
dmuci_delete_by_section(p->config_section, NULL, NULL);
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_string(s, "ifname", &iface);
dmasprintf(&atiface, "@%s", section_name(p->config_section));
dmasprintf(&atiface, "@%s", section_name(((struct dmmap_dup *)data)->config_section));
if(!iface || strcmp(iface, atiface) != 0)
continue;
if (found != 0){
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(ss), &dmmap_section);
if(dmmap_section != NULL){
if (dmmap_section != NULL) {
dmuci_set_value_by_section(dmmap_section, "greiface_instance", "");
dmuci_set_value_by_section(dmmap_section, "greiface_alias", "");
}
@ -314,7 +311,7 @@ int delObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *data, char
}
if (ss != NULL){
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(ss), &dmmap_section);
if(dmmap_section != NULL){
if (dmmap_section != NULL) {
dmuci_set_value_by_section(dmmap_section, "greiface_instance", "");
dmuci_set_value_by_section(dmmap_section, "greiface_alias", "");
}
@ -332,7 +329,7 @@ int delObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *data, char
*************************************************************/
static char *get_gre_tunnel_interface_statistics(char *interface, char *key)
{
json_object *res, *diag;
json_object *res = NULL, *diag = NULL;
char *device, *value = "0";
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interface, String}}, 1, &res);
@ -340,7 +337,8 @@ static char *get_gre_tunnel_interface_statistics(char *interface, char *key)
device = dmjson_get_value(res, 1, "device");
if(device[0] != '\0') {
dmubus_call("network.device", "status", UBUS_ARGS{{"name", device, String}}, 1, &diag);
value = dmjson_get_value(diag, 2, "statistics", key);
if (diag)
value = dmjson_get_value(diag, 2, "statistics", key);
}
return value;
}
@ -372,6 +370,8 @@ int set_GRETunnel_Enable(char *refparam, struct dmctx *ctx, void *data, char *in
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -388,24 +388,27 @@ int get_GRETunnel_Status(char *refparam, struct dmctx *ctx, void *data, char *in
int get_GRETunnel_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct dmmap_dup *dm= (struct dmmap_dup *)data;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(dm->config_section), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "gretunnel_alias", value);
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct dmmap_dup *)data)->config_section), &dmmap_section);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "gretunnel_alias", value);
return 0;
}
int set_GRETunnel_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct dmmap_dup *dm= (struct dmmap_dup *)data;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(dm->config_section), &dmmap_section);
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "gretunnel_alias", value);
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct dmmap_dup *)data)->config_section), &dmmap_section);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "gretunnel_alias", value);
break;
}
return 0;
@ -421,6 +424,8 @@ int set_GRETunnel_RemoteEndpoints(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, "4", NULL, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -439,6 +444,8 @@ int set_GRETunnel_KeepAlivePolicy(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, KeepAlivePolicy, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -457,6 +464,8 @@ int set_GRETunnel_KeepAliveTimeout(char *refparam, struct dmctx *ctx, void *data
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -467,21 +476,19 @@ int set_GRETunnel_KeepAliveTimeout(char *refparam, struct dmctx *ctx, void *data
int get_GRETunnel_KeepAliveThreshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct dmmap_dup *dm= (struct dmmap_dup *)data;
dmuci_get_value_by_section_string(dm->config_section, "keepalive", value);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "keepalive", value);
return 0;
}
int set_GRETunnel_KeepAliveThreshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct dmmap_dup *dm= (struct dmmap_dup *)data;
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(dm->config_section, "keepalive", value);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "keepalive", value);
break;
}
return 0;
@ -497,6 +504,8 @@ int set_GRETunnel_DeliveryHeaderProtocol(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, DeliveryHeaderProtocol, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -515,6 +524,8 @@ int set_GRETunnel_DefaultDSCPMark(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -525,20 +536,17 @@ int set_GRETunnel_DefaultDSCPMark(char *refparam, struct dmctx *ctx, void *data,
int get_GRETunnel_ConnectedRemoteEndpoint(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct dmmap_dup *dm= (struct dmmap_dup *)data;
dmuci_get_value_by_section_string(dm->config_section, "peeraddr", value);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "peeraddr", value);
return 0;
}
int get_GRETunnel_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct dmmap_dup *dm= (struct dmmap_dup *)data;
struct uci_section *s;
char *ifname;
int i= 0;
int i = 0;
dmasprintf(&ifname, "@%s", section_name(dm->config_section));
dmasprintf(&ifname, "@%s", section_name(((struct dmmap_dup *)data)->config_section));
uci_foreach_option_eq("network", "interface", "ifname", ifname, s) {
i++;
}
@ -604,6 +612,8 @@ int set_GRETunnelInterface_Enable(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -620,25 +630,27 @@ int get_GRETunnelInterface_Status(char *refparam, struct dmctx *ctx, void *data,
int get_GRETunnelInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section= NULL;
struct dmmap_dup *dm= (struct dmmap_dup *)data;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(dm->config_section), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "greiface_alias", value);
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct dmmap_dup *)data)->config_section), &dmmap_section);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "greiface_alias", value);
return 0;
}
int set_GRETunnelInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct dmmap_dup *dm= (struct dmmap_dup *)data;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(dm->config_section), &dmmap_section);
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "greiface_alias", value);
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct dmmap_dup *)data)->config_section), &dmmap_section);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "greiface_alias", value);
break;
}
return 0;
@ -666,6 +678,8 @@ int set_GRETunnelInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, "1024", NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -684,6 +698,8 @@ int set_GRETunnelInterface_ProtocolIdOverride(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -702,6 +718,8 @@ int set_GRETunnelInterface_UseChecksum(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -720,6 +738,8 @@ int set_GRETunnelInterface_KeyIdentifierGenerationPolicy(char *refparam, struct
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, KeyIdentifierGenerationPolicy, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -738,6 +758,8 @@ int set_GRETunnelInterface_KeyIdentifier(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -756,6 +778,8 @@ int set_GRETunnelInterface_UseSequenceNumber(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -766,37 +790,37 @@ int set_GRETunnelInterface_UseSequenceNumber(char *refparam, struct dmctx *ctx,
int get_GRETunnelInterfaceStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_bytes");
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_bytes");
return 0;
}
int get_GRETunnelInterfaceStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_bytes");
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_bytes");
return 0;
}
int get_GRETunnelInterfaceStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_packets");
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_packets");
return 0;
}
int get_GRETunnelInterfaceStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_packets");
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_packets");
return 0;
}
int get_GRETunnelInterfaceStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_errors");
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "tx_errors");
return 0;
}
int get_GRETunnelInterfaceStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value= get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_errors");
*value = get_gre_tunnel_interface_statistics(section_name(((struct dmmap_dup *)data)->config_section), "rx_errors");
return 0;
}
@ -822,6 +846,8 @@ int set_GREFilter_Enable(char *refparam, struct dmctx *ctx, void *data, char *in
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -846,6 +872,8 @@ int set_GREFilter_Order(char *refparam, struct dmctx *ctx, void *data, char *ins
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -864,6 +892,8 @@ int set_GREFilter_Alias(char *refparam, struct dmctx *ctx, void *data, char *ins
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -882,6 +912,8 @@ int set_GREFilter_Interface(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -900,6 +932,8 @@ int set_GREFilter_AllInterfaces(char *refparam, struct dmctx *ctx, void *data, c
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -918,6 +952,8 @@ int set_GREFilter_VLANIDCheck(char *refparam, struct dmctx *ctx, void *data, cha
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", NULL))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -936,6 +972,8 @@ int set_GREFilter_VLANIDExclude(char *refparam, struct dmctx *ctx, void *data, c
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -954,6 +992,8 @@ int set_GREFilter_DSCPMarkPolicy(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-2", "63"))
return FAULT_9007;
break;
case VALUESET:
//TODO

View file

@ -466,8 +466,7 @@ int get_Device_InterfaceStackNumberOfEntries(char *refparam, struct dmctx *ctx,
struct uci_section *s = NULL;
int cnt = 0;
uci_path_foreach_sections(bbfdm, "dmmap_interface_stack", "interface_stack", s)
{
uci_path_foreach_sections(bbfdm, "dmmap_interface_stack", "interface_stack", s) {
cnt++;
}
dmasprintf(value, "%d", cnt);
@ -489,6 +488,8 @@ int set_InterfaceStack_Alias(char *refparam, struct dmctx *ctx, void *data, char
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
uci_path_foreach_option_eq(bbfdm, "dmmap_interface_stack", "interface_stack", "interface_stack_instance", instance, s) {
@ -501,28 +502,24 @@ int set_InterfaceStack_Alias(char *refparam, struct dmctx *ctx, void *data, char
int get_InterfaceStack_HigherLayer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct interfacestack_data *ifdata = (struct interfacestack_data *) data;
*value = dmstrdup(ifdata->higherlayer);
*value = dmstrdup(((struct interfacestack_data *)data)->higherlayer);
return 0;
}
int get_InterfaceStack_LowerLayer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct interfacestack_data *ifdata = (struct interfacestack_data *) data;
*value = dmstrdup(ifdata->lowerlayer);
*value = dmstrdup(((struct interfacestack_data *)data)->lowerlayer);
return 0;
}
int get_InterfaceStack_HigherAlias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct interfacestack_data *ifdata = (struct interfacestack_data *) data;
*value = dmstrdup(ifdata->higheralias);
*value = dmstrdup(((struct interfacestack_data *)data)->higheralias);
return 0;
}
int get_InterfaceStack_LowerAlias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct interfacestack_data *ifdata = (struct interfacestack_data *) data;
*value = dmstrdup(ifdata->loweralias);
*value = dmstrdup(((struct interfacestack_data *)data)->loweralias);
return 0;
}

View file

@ -84,7 +84,7 @@ DMLEAF tIPInterfaceIPv4AddressParams[] = {
{CUSTOM_PREFIX"FirewallEnabled", &DMWRITE, DMT_BOOL, get_firewall_enabled, set_firewall_enabled, &IPv4INFRM, NULL, BBFDM_BOTH},
{"IPAddress", &DMWRITE, DMT_STRING, get_ipv4_address, set_ipv4_address, &IPv4INFRM, NULL, BBFDM_BOTH},
{"SubnetMask", &DMWRITE, DMT_STRING, get_ipv4_netmask, set_ipv4_netmask, &IPv4INFRM, NULL, BBFDM_BOTH},
{"AddressingType", &DMWRITE, DMT_STRING, get_ipv4_addressing_type, set_ipv4_addressing_type, &IPv4INFRM, NULL, BBFDM_BOTH},
{"AddressingType", &DMREAD, DMT_STRING, get_ipv4_addressing_type, NULL, &IPv4INFRM, NULL, BBFDM_BOTH},
{0}
};
@ -277,6 +277,8 @@ int set_IP_IPv4Enable(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -306,6 +308,8 @@ int set_IP_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -329,6 +333,8 @@ int set_IP_ULAPrefix(char *refparam, struct dmctx *ctx, void *data, char *instan
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "49", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value("network", "globals", "ula_prefix", value);
@ -368,7 +374,7 @@ int set_IPInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -407,6 +413,8 @@ int set_IPInterface_IPv4Enable(char *refparam, struct dmctx *ctx, void *data, ch
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -426,9 +434,10 @@ int get_IPInterface_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, ch
int set_IPInterface_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -459,6 +468,8 @@ int set_IPInterface_Router(char *refparam, struct dmctx *ctx, void *data, char *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -479,7 +490,7 @@ int set_IPInterface_Reset(char *refparam, struct dmctx *ctx, void *data, char *i
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -505,6 +516,8 @@ int set_IPInterface_MaxMTUSize(char *refparam, struct dmctx *ctx, void *data, ch
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "64", "65535"))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "mtu", value);
@ -535,6 +548,8 @@ int set_IPInterface_Loopback(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -637,7 +652,7 @@ int set_firewall_enabled(char *refparam, struct dmctx *ctx, void *data, char *in
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -665,8 +680,11 @@ int get_ipv4_address(char *refparam, struct dmctx *ctx, void *data, char *instan
int set_ipv4_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *proto;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
@ -703,6 +721,8 @@ int set_ipv4_netmask(char *refparam, struct dmctx *ctx, void *data, char *instan
char *proto;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
@ -714,7 +734,7 @@ int set_ipv4_netmask(char *refparam, struct dmctx *ctx, void *data, char *instan
}
/*#Device.IP.Interface.{i}.IPv4Address.{i}.AddressingType!UCI:network/interface,@i-1/proto*/
int get_ipv4_addressing_type (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
int get_ipv4_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", value);
if (strcmp(*value, "static") == 0)
@ -726,25 +746,6 @@ int get_ipv4_addressing_type (char *refparam, struct dmctx *ctx, void *data, cha
return 0;
}
int set_ipv4_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (strcasecmp(value, "static") == 0) {
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "static");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", "0.0.0.0");
}
if (strcasecmp(value, "dhcp") == 0) {
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "dhcp");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", "");
}
return 0;
}
return 0;
}
int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char linker[64] = "", *proto, *device, *mac;
@ -784,6 +785,8 @@ int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, c
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, "1024", NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (value[strlen(value)-1]!='.') {
@ -819,6 +822,8 @@ int set_IPInterfaceIPv6Address_IPAddress(char *refparam, struct dmctx *ctx, void
char *proto;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "45", NULL, IPv6Address))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct ipv6_args *)data)->ip_sec, "proto", &proto);
@ -839,6 +844,8 @@ int set_IPInterfaceIPv6Address_Enable(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -896,6 +903,8 @@ int set_IPInterfaceIPv6Address_Prefix(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -921,6 +930,8 @@ int set_IPInterfaceIPv6Address_PreferredLifetime(char *refparam, struct dmctx *c
switch (action) {
case VALUECHECK:
if (dm_validate_dateTime(value))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct ipv6_args *)data)->ip_sec, "proto", &proto);
@ -953,6 +964,8 @@ int set_IPInterfaceIPv6Address_ValidLifetime(char *refparam, struct dmctx *ctx,
switch (action) {
case VALUECHECK:
if (dm_validate_dateTime(value))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct ipv6_args *)data)->ip_sec, "proto", &proto);
@ -980,6 +993,8 @@ int set_IPInterfaceIPv6Prefix_Enable(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1016,6 +1031,8 @@ int set_IPInterfaceIPv6Prefix_Prefix(char *refparam, struct dmctx *ctx, void *da
char *proto;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "49", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct ipv6prefix_args *)data)->ip_sec, "proto", &proto);
@ -1053,6 +1070,8 @@ int set_IPInterfaceIPv6Prefix_StaticType(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, StaticType, NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1075,6 +1094,8 @@ int set_IPInterfaceIPv6Prefix_ParentPrefix(char *refparam, struct dmctx *ctx, vo
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1092,6 +1113,8 @@ int set_IPInterfaceIPv6Prefix_ChildPrefixBits(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "49", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1114,6 +1137,8 @@ int set_IPInterfaceIPv6Prefix_PreferredLifetime(char *refparam, struct dmctx *ct
{
switch (action) {
case VALUECHECK:
if (dm_validate_dateTime(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1136,6 +1161,8 @@ int set_IPInterfaceIPv6Prefix_ValidLifetime(char *refparam, struct dmctx *ctx, v
{
switch (action) {
case VALUECHECK:
if (dm_validate_dateTime(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1245,7 +1272,7 @@ int set_IPInterfaceTWAMPReflector_Enable(char *refparam, struct dmctx *ctx, void
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -1290,6 +1317,7 @@ int set_IPInterfaceTWAMPReflector_Enable(char *refparam, struct dmctx *ctx, void
int get_IPInterfaceTWAMPReflector_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *enable;
dmuci_get_value_by_section_string((struct uci_section *)data, "enable", &enable);
if (strcmp(enable, "1") == 0)
*value = "Active";
@ -1308,6 +1336,8 @@ int set_IPInterfaceTWAMPReflector_Alias(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "twamp_alias", value);
@ -1326,6 +1356,8 @@ int set_IPInterfaceTWAMPReflector_Port(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, "65535"))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "port", value);
@ -1344,6 +1376,8 @@ int set_IPInterfaceTWAMPReflector_MaximumTTL(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", "255"))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "max_ttl", value);
@ -1362,6 +1396,8 @@ int set_IPInterfaceTWAMPReflector_IPAllowedList(char *refparam, struct dmctx *ct
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, "255", NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "ip_list", value);
@ -1380,6 +1416,8 @@ int set_IPInterfaceTWAMPReflector_PortAllowedList(char *refparam, struct dmctx *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, "255", NULL, NULL, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "port_list", value);
@ -1393,23 +1431,24 @@ int set_IPInterfaceTWAMPReflector_PortAllowedList(char *refparam, struct dmctx *
**************************************************************/
int get_IPInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "ip_int_alias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "ip_int_alias", value);
return 0;
}
int set_IPInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section =NULL;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_set_value_by_section(dmmap_section, "ip_int_alias", value);
return 0;
}
@ -1418,23 +1457,24 @@ int set_IPInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *i
int get_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "ipv4_alias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "ipv4_alias", value);
return 0;
}
int set_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section =NULL;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(((struct ip_args *)data)->ip_sec), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_set_value_by_section(dmmap_section, "ipv4_alias", value);
return 0;
}
@ -1443,7 +1483,7 @@ int set_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance
int get_IPInterfaceIPv6Address_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
char *name;
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "ipv6", "ipv6_instance", instance, dmmap_section) {
@ -1456,7 +1496,7 @@ int get_IPInterfaceIPv6Address_Alias(char *refparam, struct dmctx *ctx, void *da
int set_IPInterfaceIPv6Address_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
char *name;
switch (action) {
@ -1468,7 +1508,8 @@ int set_IPInterfaceIPv6Address_Alias(char *refparam, struct dmctx *ctx, void *da
if(strcmp(name, section_name(((struct ipv6_args *)data)->ip_sec)) == 0)
break;
}
dmuci_set_value_by_section(dmmap_section, "ipv6_alias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "ipv6_alias", value);
return 0;
}
return 0;
@ -1476,7 +1517,7 @@ int set_IPInterfaceIPv6Address_Alias(char *refparam, struct dmctx *ctx, void *da
int get_IPInterfaceIPv6Prefix_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
char *name;
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "ipv6prefix", "ipv6prefix_instance", instance, dmmap_section) {
@ -1489,7 +1530,7 @@ int get_IPInterfaceIPv6Prefix_Alias(char *refparam, struct dmctx *ctx, void *dat
int set_IPInterfaceIPv6Prefix_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
char *name;
switch (action) {
@ -1501,7 +1542,8 @@ int set_IPInterfaceIPv6Prefix_Alias(char *refparam, struct dmctx *ctx, void *dat
if(strcmp(name, section_name(((struct ipv6prefix_args *)data)->ip_sec)) == 0)
break;
}
dmuci_set_value_by_section(dmmap_section, "ipv6prefix_alias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "ipv6prefix_alias", value);
return 0;
}
return 0;
@ -1781,8 +1823,9 @@ int delObjIPInterfaceTWAMPReflector(char *refparam, struct dmctx *ctx, void *dat
/**************************************************************************
* LINKER
***************************************************************************/
int get_linker_ip_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
if(data && ((struct ip_args *)data)->ip_sec) {
int get_linker_ip_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
if (data && ((struct ip_args *)data)->ip_sec) {
dmasprintf(linker,"%s", section_name(((struct ip_args *)data)->ip_sec));
return 0;
} else {
@ -1791,8 +1834,9 @@ int get_linker_ip_interface(char *refparam, struct dmctx *dmctx, void *data, cha
}
}
int get_linker_ipv6_prefix(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
if(((struct ipv6prefix_args *)data)->ip_sec) {
int get_linker_ipv6_prefix(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
if (((struct ipv6prefix_args *)data)->ip_sec) {
dmasprintf(linker,"%s", get_child_prefix_linker(section_name(((struct ipv6prefix_args *)data)->ip_sec)));
return 0;
} else {

View file

@ -93,7 +93,6 @@ int set_ipv4_address(char *refparam, struct dmctx *ctx, void *data, char *instan
int get_ipv4_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ipv4_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_ipv4_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ipv4_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_IPInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_IPInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);

View file

@ -73,6 +73,8 @@ int set_management_server_url(char *refparam, struct dmctx *ctx, void *data, cha
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value("cwmp", "acs", "dhcp_discovery", "disable");
@ -93,7 +95,9 @@ int get_management_server_username(char *refparam, struct dmctx *ctx, void *data
int set_management_server_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "userid", value);
@ -107,7 +111,9 @@ int set_management_server_username(char *refparam, struct dmctx *ctx, void *data
int set_management_server_passwd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "passwd", value);
@ -137,15 +143,12 @@ int set_management_server_periodic_inform_enable(char *refparam, struct dmctx *c
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("cwmp", "acs", "periodic_inform_enable", "1");
else
dmuci_set_value("cwmp", "acs", "periodic_inform_enable", "0");
dmuci_set_value("cwmp", "acs", "periodic_inform_enable", b ? "1" : "0");
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
@ -162,7 +165,9 @@ int get_management_server_periodic_inform_interval(char *refparam, struct dmctx
int set_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "periodic_inform_interval", value);
@ -195,12 +200,12 @@ int set_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx
char buf[16];
switch (action) {
case VALUECHECK:
case VALUECHECK:
if (dm_validate_dateTime(value))
return FAULT_9007;
return 0;
case VALUESET:
if (!(strptime(value, "%Y-%m-%dT%H:%M:%S", &tm))) {
return 0;
}
strptime(value, "%Y-%m-%dT%H:%M:%S", &tm);
snprintf(buf, sizeof(buf), "%ld", mktime(&tm));
dmuci_set_value("cwmp", "acs", "periodic_inform_time", buf);
cwmp_set_end_session(END_SESSION_RELOAD);
@ -214,7 +219,6 @@ int get_management_server_connection_request_url(char *refparam, struct dmctx *c
{
char *ip, *port, *iface;
*value = "";
dmuci_get_option_value_string("cwmp", "cpe", "default_wan_interface", &iface);
network_get_ipaddr(&ip, iface);
dmuci_get_option_value_string("cwmp", "cpe", "port", &port);
@ -236,7 +240,9 @@ int get_management_server_connection_request_username(char *refparam, struct dmc
int set_management_server_connection_request_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "cpe", "userid", value);
@ -251,6 +257,8 @@ int set_management_server_connection_request_passwd(char *refparam, struct dmctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "cpe", "passwd", value);
@ -274,10 +282,7 @@ int get_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *i
dmuci_get_option_value_string("cwmp", "lwn", "enable", &tmp);
string_to_bool(tmp, &b);
if (b)
*value = "UDP";
else
*value = "";
*value = b ? "UDP" : "";
return 0;
}
@ -285,16 +290,15 @@ int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *i
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value,"UDP") ==0) {
if (strcmp(value,"UDP") == 0)
dmuci_set_value("cwmp", "lwn", "enable", "1");
cwmp_set_end_session(END_SESSION_RELOAD);
}
else {
else
dmuci_set_value("cwmp", "lwn", "enable", "0");
cwmp_set_end_session(END_SESSION_RELOAD);
}
cwmp_set_end_session(END_SESSION_RELOAD);
return 0;
}
return 0;
@ -311,6 +315,8 @@ int set_lwn_host(char *refparam, struct dmctx *ctx, void *data, char *instance,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "lwn", "hostname", value);
@ -331,6 +337,8 @@ int set_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *instance,
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "lwn", "port", value);
@ -357,13 +365,14 @@ int set_management_server_http_compression(char *refparam, struct dmctx *ctx, vo
{
switch (action) {
case VALUECHECK:
if (0 == strcasecmp(value, "gzip") || 0 == strcasecmp(value, "deflate") || 0 == strncasecmp(value, "disable", 7)) {
return 0;
}
return FAULT_9007;
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "compression", value);
cwmp_set_end_session(END_SESSION_RELOAD);
if (strcasecmp(value, "gzip") == 0 || strcasecmp(value, "deflate") == 0 || strncasecmp(value, "disable", 7) == 0) {
dmuci_set_value("cwmp", "acs", "compression", value);
cwmp_set_end_session(END_SESSION_RELOAD);
}
return 0;
}
return 0;
@ -378,14 +387,11 @@ int get_management_server_retry_min_wait_interval(char *refparam, struct dmctx *
int set_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int a;
switch (action) {
case VALUECHECK:
a = atoi(value);
if (a <= 65535 && a >= 1) {
return 0;
}
return FAULT_9007;
if (dm_validate_unsignedInt(value, "1", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "retry_min_wait_interval", value);
cwmp_set_end_session(END_SESSION_RELOAD);
@ -403,14 +409,11 @@ int get_management_server_retry_interval_multiplier(char *refparam, struct dmctx
int set_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int a;
switch (action) {
case VALUECHECK:
a = atoi(value);
if (a <= 65535 && a >= 1000) {
return 0;
}
return FAULT_9007;
if (dm_validate_unsignedInt(value, "1000", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "retry_interval_multiplier", value);
cwmp_set_end_session(END_SESSION_RELOAD);
@ -423,12 +426,10 @@ int set_management_server_retry_interval_multiplier(char *refparam, struct dmctx
int get_alias_based_addressing(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "amd_version", value);
if((*value)[0] == '\0'|| atoi(*value) <= AMD_4) {
if ((*value)[0] == '\0'|| atoi(*value) <= AMD_4)
*value = "false";
}
else {
else
*value = "true";
}
return 0;
}
@ -443,10 +444,9 @@ int set_instance_mode(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (0 == strcmp(value, "InstanceNumber") || 0 == strcmp(value, "InstanceAlias") ) {
return 0;
}
return FAULT_9007;
if (dm_validate_string(value, NULL, NULL, InstanceMode, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "cpe", "instance_mode", value);
cwmp_set_end_session(END_SESSION_RELOAD);
@ -481,6 +481,8 @@ int set_stun_enable(char *refparam, struct dmctx *ctx, void *data, char *instanc
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
@ -508,6 +510,8 @@ int set_stun_server_address(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "server_address", value);
@ -527,6 +531,8 @@ int set_stun_server_port(char *refparam, struct dmctx *ctx, void *data, char *in
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "server_port", value);
@ -546,6 +552,8 @@ int set_stun_username(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "username", value);
@ -565,6 +573,8 @@ int set_stun_password(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "password", value);
@ -584,6 +594,8 @@ int set_stun_maximum_keepalive_period(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "max_keepalive", value);
@ -603,6 +615,8 @@ int set_stun_minimum_keepalive_period(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp_stun", "stun", "min_keepalive", value);
@ -612,17 +626,16 @@ int set_stun_minimum_keepalive_period(char *refparam, struct dmctx *ctx, void *d
}
/*#Device.ManagementServer.NATDetected!UCI:cwmp_stun/stun,stun/nat_detected*/
int get_nat_detected(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_nat_detected(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *path = "/etc/rc.d/*icwmp_stund";
char *v;
if (check_file(path)) { //stun is enabled
dmuci_get_varstate_string("cwmp_stun", "stun", "nat_detected", &v);
*value = (*v == '1') ? "true" : "false";
}
else {
} else
*value = "false";
}
return 0;
}
@ -640,6 +653,8 @@ int set_management_server_conn_rep_allowed_jabber_id(char *refparam, struct dmct
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, "32", NULL, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp_xmpp", "xmpp", "allowed_jid", value);
@ -688,6 +703,8 @@ int set_management_server_conn_req_xmpp_connection(char *refparam, struct dmctx
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if ((str = strstr(value, "Device.XMPP.Connection."))) {

View file

@ -45,8 +45,8 @@ DMLEAF tNATPortMappingParams[] = {
{"Status", &DMWRITE, DMT_STRING, get_nat_port_mapping_status, NULL, NULL, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_nat_port_mapping_alias, set_nat_port_mapping_alias, NULL, NULL, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_nat_port_mapping_interface, set_nat_port_mapping_interface, NULL, NULL, BBFDM_BOTH},
{"AllInterfaces", &DMWRITE, DMT_BOOL, get_nat_port_mapping_all_interface, set_nat_port_mapping_all_interface, NULL, NULL, BBFDM_BOTH},
{"LeaseDuration", &DMWRITE, DMT_UNINT, get_nat_port_mapping_lease_duration, set_nat_port_mapping_lease_duration, NULL, NULL, BBFDM_BOTH},
//{"AllInterfaces", &DMWRITE, DMT_BOOL, get_nat_port_mapping_all_interface, set_nat_port_mapping_all_interface, NULL, NULL, BBFDM_BOTH},
//{"LeaseDuration", &DMWRITE, DMT_UNINT, get_nat_port_mapping_lease_duration, set_nat_port_mapping_lease_duration, NULL, NULL, BBFDM_BOTH},
{"RemoteHost", &DMWRITE, DMT_STRING, get_nat_port_mapping_remote_host, set_nat_port_mapping_remote_host, NULL, NULL, BBFDM_BOTH},
{"ExternalPort", &DMWRITE, DMT_UNINT, get_nat_port_mapping_external_port, set_nat_port_mapping_external_port, NULL, NULL, BBFDM_BOTH},
{"ExternalPortEndRange", &DMWRITE, DMT_UNINT, get_nat_port_mapping_external_port_end_range, set_nat_port_mapping_external_port_end_range, NULL, NULL, BBFDM_BOTH},
@ -89,14 +89,16 @@ int delete_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *data, c
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name((struct uci_section *)data), &dmmap_firewall);
if (dmmap_firewall) dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
if (dmmap_firewall)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("firewall", "zone", s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name(ss), &dmmap_firewall);
if (dmmap_firewall) dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
if (dmmap_firewall)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
@ -104,7 +106,8 @@ int delete_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *data, c
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name(ss), &dmmap_firewall);
if(dmmap_firewall) dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
if(dmmap_firewall)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
return 0;
@ -141,14 +144,16 @@ int delete_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data, char *
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name((struct uci_section *)data), &dmmap_firewall);
if (dmmap_firewall) dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
if (dmmap_firewall)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("firewall", "redirect", s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(ss), &dmmap_firewall);
if (dmmap_firewall) dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
if (dmmap_firewall)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
@ -156,7 +161,8 @@ int delete_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data, char *
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(ss), &dmmap_firewall);
if (dmmap_firewall) dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
if (dmmap_firewall)
dmuci_delete_by_section(dmmap_firewall, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
return 0;
@ -173,8 +179,7 @@ int get_nat_interface_setting_number_of_entries(char *refparam, struct dmctx *ct
struct uci_section *s = NULL;
int cnt = 0;
uci_foreach_sections("firewall", "zone", s)
{
uci_foreach_sections("firewall", "zone", s) {
cnt++;
}
dmasprintf(value, "%d", cnt);
@ -187,8 +192,7 @@ int get_nat_port_mapping_number_of_entries(char *refparam, struct dmctx *ctx, vo
struct uci_section *s = NULL;
int cnt = 0;
uci_foreach_sections("firewall", "redirect", s)
{
uci_foreach_sections("firewall", "redirect", s) {
cnt++;
}
dmasprintf(value, "%d", cnt);
@ -209,7 +213,7 @@ int set_nat_interface_setting_enable(char *refparam, struct dmctx *ctx, void *da
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -231,23 +235,27 @@ int get_nat_interface_setting_status(char *refparam, struct dmctx *ctx, void *da
int get_nat_interface_setting_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "interface_setting_alias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "interface_setting_alias", value);
return 0;
}
int set_nat_interface_setting_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_firewall", "zone", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "interface_setting_alias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "interface_setting_alias", value);
return 0;
}
return 0;
@ -281,6 +289,8 @@ int set_nat_interface_setting_interface(char *refparam, struct dmctx *ctx, void
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
strcpy(buf, value);
@ -309,9 +319,10 @@ int get_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *data, c
int set_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -333,23 +344,27 @@ int get_nat_port_mapping_status(char *refparam, struct dmctx *ctx, void *data, c
int get_nat_port_mapping_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name((struct uci_section *)data), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "port_mapping_alias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "port_mapping_alias", value);
return 0;
}
int set_nat_port_mapping_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name((struct uci_section *)data), &dmmap_section);
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "port_mapping_alias", value);
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "port_mapping_alias", value);
return 0;
}
return 0;
@ -391,14 +406,15 @@ int set_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, void *data
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &iface);
if (iface[0] != '\0') {
uci_foreach_sections("firewall", "zone", s)
{
uci_foreach_sections("firewall", "zone", s) {
dmuci_get_value_by_section_string(s, "network", &network);
if (is_strword_in_optionvalue(network, iface)){
if (is_strword_in_optionvalue(network, iface)) {
dmuci_get_value_by_section_string(s, "name", &zone);
dmuci_set_value_by_section((struct uci_section *)data, "src", zone);
break;
@ -412,19 +428,19 @@ int set_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, void *data
int get_nat_port_mapping_all_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0";
//TODO
return 0;
}
int set_nat_port_mapping_all_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
//TODO
return 0;
}
return 0;
@ -433,7 +449,7 @@ int set_nat_port_mapping_all_interface(char *refparam, struct dmctx *ctx, void *
int get_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
// CPE only supports static port forwards
*value = "0";
//TODO
return 0;
}
@ -441,12 +457,12 @@ int set_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
// CPE only supports static port forwards
if (strcmp(value, "0") != 0)
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
// Nothing to set for static port forwards
//TODO
return 0;
}
return 0;
@ -463,6 +479,8 @@ int set_nat_port_mapping_remote_host(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "src_dip", value);
@ -490,8 +508,11 @@ int get_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx, void *
int set_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *dport, buffer[64];
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "src_dport", &dport);
@ -519,8 +540,11 @@ int get_nat_port_mapping_external_port_end_range(char *refparam, struct dmctx *c
int set_nat_port_mapping_external_port_end_range(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *dport, *tmp, buffer[64];
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "src_dport", &dport);
@ -548,6 +572,8 @@ int set_nat_port_mapping_internal_port(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "dest_port", value);
@ -561,32 +587,29 @@ int get_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void *data,
{
char *proto;
dmuci_get_value_by_section_string((struct uci_section *)data, "proto", &proto);
if (strcasecmp(proto, "tcp") == 0)
if (strcmp(proto, "tcp") == 0)
*value = "TCP";
else if (strcasecmp(proto, "udp") == 0)
else if (strcmp(proto, "udp") == 0)
*value = "UDP";
else
*value = "TCP/UDP";
return 0;
return 0;
}
int set_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *v;
switch (action) {
case VALUECHECK:
if (strcasecmp("TCP", value) != 0 && strcasecmp("UDP", value) != 0 && strcasecmp("TCP/UDP", value) != 0)
if (dm_validate_string(value, NULL, NULL, NATProtocol, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (strcasecmp("TCP", value) == 0)
v = "tcp";
dmuci_set_value_by_section((struct uci_section *)data, "proto", "tcp");
else if (strcasecmp("UDP", value) == 0)
v = "udp";
dmuci_set_value_by_section((struct uci_section *)data, "proto", "udp");
else
v = "tcpudp";
dmuci_set_value_by_section((struct uci_section *)data, "proto", v);
dmuci_set_value_by_section((struct uci_section *)data, "proto", "tcpudp");
return 0;
}
return 0;
@ -603,6 +626,8 @@ int set_nat_port_mapping_internal_client(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "dest_ip", value);
@ -622,6 +647,8 @@ int set_nat_port_mapping_description(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "name", value);

View file

@ -51,7 +51,7 @@ DMLEAF tPPPInterfaceParams[] = {
/* *** Device.PPP.Interface.{i}.PPPoE. *** */
DMLEAF tPPPInterfacePPPoEParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"SessionID", &DMREAD, DMT_UNINT, get_PPPInterfacePPPoE_SessionID, NULL, NULL, NULL, BBFDM_BOTH},
//{"SessionID", &DMREAD, DMT_UNINT, get_PPPInterfacePPPoE_SessionID, NULL, NULL, NULL, BBFDM_BOTH},
{"ACName", &DMWRITE, DMT_STRING, get_PPPInterfacePPPoE_ACName, set_PPPInterfacePPPoE_ACName, NULL, NULL, BBFDM_BOTH},
{"ServiceName", &DMWRITE, DMT_STRING, get_PPPInterfacePPPoE_ServiceName, set_PPPInterfacePPPoE_ServiceName, NULL, NULL, BBFDM_BOTH},
{0}
@ -60,20 +60,20 @@ DMLEAF tPPPInterfacePPPoEParams[] = {
/* *** Device.PPP.Interface.{i}.Stats. *** */
DMLEAF tPPPInterfaceStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"BytesReceived", &DMREAD, DMT_UNINT, get_ppp_eth_bytes_received, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesSent", &DMREAD, DMT_UNINT, get_ppp_eth_bytes_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_ppp_eth_pack_received, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, get_ppp_eth_pack_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_ppp_eth_bytes_received, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesSent", &DMREAD, DMT_UNLONG, get_ppp_eth_bytes_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_ppp_eth_pack_received, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_ppp_eth_pack_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_ErrorsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_ErrorsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"UnicastPacketsSent", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_UnicastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"UnicastPacketsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_UnicastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"UnicastPacketsSent", &DMREAD, DMT_UNLONG, get_PPPInterfaceStats_UnicastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"UnicastPacketsReceived", &DMREAD, DMT_UNLONG, get_PPPInterfaceStats_UnicastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_DiscardPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_DiscardPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"MulticastPacketsSent", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_MulticastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"MulticastPacketsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_MulticastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"BroadcastPacketsSent", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_BroadcastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"BroadcastPacketsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_BroadcastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"MulticastPacketsSent", &DMREAD, DMT_UNLONG, get_PPPInterfaceStats_MulticastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"MulticastPacketsReceived", &DMREAD, DMT_UNLONG, get_PPPInterfaceStats_MulticastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"BroadcastPacketsSent", &DMREAD, DMT_UNLONG, get_PPPInterfaceStats_BroadcastPacketsSent, NULL, NULL, NULL, BBFDM_BOTH},
{"BroadcastPacketsReceived", &DMREAD, DMT_UNLONG, get_PPPInterfaceStats_BroadcastPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{"UnknownProtoPacketsReceived", &DMREAD, DMT_UNINT, get_PPPInterfaceStats_UnknownProtoPacketsReceived, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -83,23 +83,27 @@ DMLEAF tPPPInterfaceStatsParams[] = {
**************************************************************/
int get_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "ppp_int_alias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "ppp_int_alias", value);
return 0;
}
int set_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "ppp_int_alias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "ppp_int_alias", value);
return 0;
}
return 0;
@ -125,7 +129,7 @@ int set_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -145,7 +149,7 @@ int get_PPPInterface_Status(char *refparam, struct dmctx *ctx, void *data, char
char *status;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(((struct uci_section *)data)), String}}, 1, &res);
DM_ASSERT(res, *value = "false");
DM_ASSERT(res, *value = "Down");
status = dmjson_get_value(res, 1, "up");
if (strcmp(status, "true") == 0)
*value= "Up";
@ -177,7 +181,7 @@ int set_PPPInterface_Reset(char *refparam, struct dmctx *ctx, void *data, char *
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
@ -209,7 +213,7 @@ int get_ppp_status(char *refparam, struct dmctx *ctx, void *data, char *instance
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(((struct uci_section *)data)), String}}, 1, &res);
DM_ASSERT(res, *value = "");
jobj = dmjson_get_obj(res, 1, "up");
if(jobj) {
if (jobj) {
status = dmjson_get_value(res, 1, "up");
string_to_bool(status, &bstatus);
if (bstatus) {
@ -238,6 +242,8 @@ int set_ppp_username(char *refparam, struct dmctx *ctx, void *data, char *instan
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct uci_section *)data), "username", value);
@ -251,6 +257,8 @@ int set_ppp_password(char *refparam, struct dmctx *ctx, void *data, char *instan
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct uci_section *)data), "password", value);
@ -370,15 +378,12 @@ int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *ins
char *linker;
dmuci_get_value_by_section_string(((struct uci_section *)data), "ifname", &linker);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cATM%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL) {
if (*value == NULL)
adm_entry_get_linker_param(ctx, dm_print_path("%s%cPTM%cLink%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
}
if (*value == NULL) {
if (*value == NULL)
adm_entry_get_linker_param(ctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
}
if (*value == NULL) {
if (*value == NULL)
adm_entry_get_linker_param(ctx, dm_print_path("%s%cWiFi%cSSID%c", dmroot, dm_delim, dm_delim, dm_delim), linker, value);
}
if (*value == NULL)
*value = "";
return 0;
@ -386,10 +391,12 @@ int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *ins
int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *linker;
char *newvalue= NULL;
char *linker, *newvalue = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, NULL, NULL, "1024", NULL, NULL, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if (value[strlen(value)-1]!='.') {
@ -397,8 +404,10 @@ int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *ins
adm_entry_get_linker_value(ctx, newvalue, &linker);
} else
adm_entry_get_linker_value(ctx, value, &linker);
if(linker) dmuci_set_value_by_section(((struct uci_section *)data), "ifname", linker);
else return FAULT_9005;
if(linker)
dmuci_set_value_by_section(((struct uci_section *)data), "ifname", linker);
else
return FAULT_9005;
return 0;
}
return 0;
@ -435,7 +444,6 @@ int get_PPPInterfacePPPoE_ACName(char *refparam, struct dmctx *ctx, void *data,
dmuci_get_value_by_section_string(((struct uci_section *)data), "ac", value);
return 0;
}
*value= "";
return 0;
}
@ -445,6 +453,9 @@ int set_PPPInterfacePPPoE_ACName(char *refparam, struct dmctx *ctx, void *data,
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
dmuci_get_value_by_section_string(((struct uci_section *)data), "proto", &proto);
if (strcmp(proto, "pppoe") != 0)
return FAULT_9001;
@ -465,7 +476,6 @@ int get_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx, void *d
dmuci_get_value_by_section_string(((struct uci_section *)data), "service", value);
return 0;
}
*value= "";
return 0;
}
@ -475,6 +485,9 @@ int set_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
dmuci_get_value_by_section_string(((struct uci_section *)data), "proto", &proto);
if (strcmp(proto, "pppoe") != 0)
return FAULT_9001;
@ -492,7 +505,7 @@ int set_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx, void *d
int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
if(((struct uci_section *)data)) {
dmasprintf(linker,"%s", section_name(((struct uci_section *)data)));
dmasprintf(linker, "%s", section_name(((struct uci_section *)data)));
return 0;
}
*linker = "";

View file

@ -39,10 +39,10 @@ DMLEAF tPTMLinkParams[] = {
/* *** Device.PTM.Link.{i}.Stats. *** */
DMLEAF tPTMLinkStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNINT, get_ptm_stats_bytes_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNINT, get_ptm_stats_bytes_received, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, get_ptm_stats_pack_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_ptm_stats_pack_received, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesSent", &DMREAD, DMT_UNLONG, get_ptm_stats_bytes_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_ptm_stats_bytes_received, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_ptm_stats_pack_sent, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_ptm_stats_pack_received, NULL, NULL, NULL, BBFDM_BOTH},
{0}
};
@ -51,8 +51,8 @@ DMLEAF tPTMLinkStatsParams[] = {
***************************************************************************/
int get_ptm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
if (data && ((struct ptm_args *)data)->ifname){
*linker = ((struct ptm_args *)data)->ifname;
if (data && ((struct ptm_args *)data)->ifname) {
*linker = ((struct ptm_args *)data)->ifname;
return 0;
}
*linker = "" ;
@ -93,7 +93,7 @@ static inline int ubus_ptm_stats(char **value, char *stat_mod, void *data)
{
json_object *res = NULL;
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct ptm_args *)data)->ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
DM_ASSERT(res, *value = "0");
*value = dmjson_get_value(res, 2, "statistics", stat_mod);
return 0;
}
@ -163,7 +163,7 @@ int delete_ptm_link(char *refparam, struct dmctx *ctx, void *data, char *instanc
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(((struct ptm_args *)data)->ptm_sec), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(((struct ptm_args *)data)->ptm_sec, NULL, NULL);
uci_foreach_option_cont("network", "interface", "ifname", ((struct ptm_args *)data)->ifname, s) {
@ -178,7 +178,7 @@ int delete_ptm_link(char *refparam, struct dmctx *ctx, void *data, char *instanc
uci_foreach_sections("dsl", "ptm-device", s) {
if (ss){
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_get_value_by_section_string(ss, "device", &ifname);
dmuci_delete_by_section(ss, NULL, NULL);
@ -194,7 +194,7 @@ int delete_ptm_link(char *refparam, struct dmctx *ctx, void *data, char *instanc
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(ss), &dmmap_section);
if(dmmap_section != NULL)
if (dmmap_section != NULL)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_get_value_by_section_string(ss, "device", &ifname);
dmuci_delete_by_section(ss, NULL, NULL);
@ -216,23 +216,27 @@ int delete_ptm_link(char *refparam, struct dmctx *ctx, void *data, char *instanc
*************************************************************/
int get_ptm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(((struct ptm_args *)data)->ptm_sec), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "ptmlinkalias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "ptmlinkalias", value);
return 0;
}
int set_ptm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_dsl", "ptm-device", section_name(((struct ptm_args *)data)->ptm_sec), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "ptmlinkalias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "ptmlinkalias", value);
return 0;
}
return 0;

File diff suppressed because it is too large Load diff

View file

@ -521,6 +521,8 @@ int set_RoutingRouter_Enable(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -586,7 +588,7 @@ int set_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -633,6 +635,8 @@ int set_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "target", value);
@ -655,6 +659,8 @@ int set_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "netmask", value);
@ -700,6 +706,8 @@ int set_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "15", NULL, IPv4Address))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "gateway", value);
@ -728,6 +736,8 @@ int set_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
@ -754,6 +764,8 @@ int set_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "metric", value);
@ -772,6 +784,8 @@ int set_RoutingRouterIPv6Forwarding_Enable(char *refparam, struct dmctx *ctx, vo
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -799,6 +813,8 @@ int set_RoutingRouterIPv6Forwarding_DestIPPrefix(char *refparam, struct dmctx *c
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "49", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "target", value);
@ -817,6 +833,8 @@ int set_RoutingRouterIPv6Forwarding_ForwardingPolicy(char *refparam, struct dmct
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", NULL))
return FAULT_9007;
break;
case VALUESET:
break;
@ -838,6 +856,8 @@ int set_RoutingRouterIPv6Forwarding_NextHop(char *refparam, struct dmctx *ctx, v
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "45", NULL, IPv6Address))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "gateway", value);
@ -866,6 +886,8 @@ int set_RoutingRouterIPv6Forwarding_Interface(char *refparam, struct dmctx *ctx,
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
@ -899,6 +921,8 @@ int set_RoutingRouterIPv6Forwarding_ForwardingMetric(char *refparam, struct dmct
{
switch (action) {
case VALUECHECK:
if (dm_validate_int(value, "-1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "metric", value);
@ -923,6 +947,8 @@ int set_RoutingRouteInformation_Enable(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
break;
@ -1061,6 +1087,8 @@ int set_RoutingRouter_Alias(char *refparam, struct dmctx *ctx, void *data, char
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "router_alias", value);
@ -1071,7 +1099,7 @@ int set_RoutingRouter_Alias(char *refparam, struct dmctx *ctx, void *data, char
int get_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
if(((struct routingfwdargs *)data)->type == ROUTE_DYNAMIC)
dmmap_section= ((struct routingfwdargs *)data)->routefwdsection;
@ -1079,25 +1107,29 @@ int get_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, void *dat
get_dmmap_section_of_config_section("dmmap_route_forwarding", "route", section_name(((struct routingfwdargs *)data)->routefwdsection), &dmmap_section);
else
get_dmmap_section_of_config_section("dmmap_route_forwarding", "route_disabled", section_name(((struct routingfwdargs *)data)->routefwdsection), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "routealias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "routealias", value);
return 0;
}
int set_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if(((struct routingfwdargs *)data)->type == ROUTE_DYNAMIC)
dmmap_section= ((struct routingfwdargs *)data)->routefwdsection;
dmmap_section = ((struct routingfwdargs *)data)->routefwdsection;
else if (((struct routingfwdargs *)data)->type == ROUTE_STATIC)
get_dmmap_section_of_config_section("dmmap_route_forwarding", "route", section_name(((struct routingfwdargs *)data)->routefwdsection), &dmmap_section);
else
get_dmmap_section_of_config_section("dmmap_route_forwarding", "route_disabled", section_name(((struct routingfwdargs *)data)->routefwdsection), &dmmap_section);
dmuci_set_value_by_section(dmmap_section, "routealias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "routealias", value);
return 0;
}
return 0;
@ -1105,29 +1137,33 @@ int set_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, void *dat
int get_RoutingRouterIPv6Forwarding_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
if(((struct routingfwdargs *)data)->type == ROUTE_DYNAMIC)
dmmap_section = ((struct routingfwdargs *)data)->routefwdsection;
else
get_dmmap_section_of_config_section("dmmap_route_forwarding", "route6", section_name(((struct routingfwdargs *)data)->routefwdsection), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "route6alias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "route6alias", value);
return 0;
}
int set_RoutingRouterIPv6Forwarding_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if(((struct routingfwdargs *)data)->type == ROUTE_DYNAMIC)
dmmap_section = ((struct routingfwdargs *)data)->routefwdsection;
else
get_dmmap_section_of_config_section("dmmap_route_forwarding", "route6", section_name(((struct routingfwdargs *)data)->routefwdsection), &dmmap_section);
dmuci_set_value_by_section(dmmap_section, "route6alias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "route6alias", value);
return 0;
}
return 0;
@ -1210,7 +1246,8 @@ int delete_ipv6Forwarding(char *refparam, struct dmctx *ctx, void *data, char *i
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_route_forwarding", "route6", section_name(((struct routingfwdargs *)data)->routefwdsection), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(((struct routingfwdargs *)data)->routefwdsection, NULL, NULL);
break;
case DEL_ALL:
@ -1329,4 +1366,3 @@ int browseRoutingRouteInformationInterfaceSettingInst(struct dmctx *dmctx, DMNOD
}
return 0;
}

View file

@ -47,7 +47,7 @@ int set_time_enable(char *refparam, struct dmctx *ctx, void *data, char *instanc
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -97,6 +97,8 @@ int set_time_LocalTimeZone(char *refparam, struct dmctx *ctx, void *data, char *
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value("system", "@system[0]", "timezone", value);
@ -204,6 +206,8 @@ int set_time_ntpserver(char *refparam, struct dmctx *ctx, int action, char *valu
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_option_value_list("system", "ntp", "server", &v);

View file

@ -509,17 +509,15 @@ int get_UPnPDevice_Enable(char *refparam, struct dmctx *ctx, void *data, char *i
int set_UPnPDevice_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value("upnpd", "config", "enabled", "");
else
dmuci_set_value("upnpd", "config", "enabled", "0");
dmuci_set_value("upnpd", "config", "enabled", b ? "" : "0");
return 0;
}
return 0;
@ -528,40 +526,29 @@ int set_UPnPDevice_Enable(char *refparam, struct dmctx *ctx, void *data, char *i
int get_upnp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
pid_t pid = get_pid("miniupnpd");
if (pid < 0) {
*value = "Down";
}
else {
*value = "Up";
}
*value = (pid < 0) ? "Down" : "Up";
return 0;
}
int get_UPnPDevice_UPnPMediaServer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *path = "/etc/rc.d/*minidlna";
if (check_file(path))
*value = "1";
else
*value = "0";
*value = (check_file(path)) ? "1" : "0";
return 0;
}
int set_UPnPDevice_UPnPMediaServer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmcmd("/etc/init.d/minidlna", 1, "enable");
else
dmcmd("/etc/init.d/minidlna", 1, "disable");
dmcmd("/etc/init.d/minidlna", 1, b ? "enable" : "disable");
break;
}
return 0;
@ -577,6 +564,8 @@ int set_UPnPDevice_UPnPMediaRenderer(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -595,6 +584,8 @@ int set_UPnPDevice_UPnPWLANAccessPoint(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -613,6 +604,8 @@ int set_UPnPDevice_UPnPQoSDevice (char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -631,6 +624,8 @@ int set_UPnPDevice_UPnPQoSPolicyHolder(char *refparam, struct dmctx *ctx, void *
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -642,27 +637,22 @@ int set_UPnPDevice_UPnPQoSPolicyHolder(char *refparam, struct dmctx *ctx, void *
int get_UPnPDevice_UPnPIGD(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *path = "/etc/rc.d/*miniupnpd";
if (check_file(path))
*value = "1";
else
*value = "0";
*value = (check_file(path)) ? "1" : "0";
return 0;
}
int set_UPnPDevice_UPnPIGD(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmcmd("/etc/init.d/miniupnpd", 1, "enable");
else
dmcmd("/etc/init.d/miniupnpd", 1, "disable");
dmcmd("/etc/init.d/miniupnpd", 1, b ? "enable" : "disable");
break;
}
return 0;
@ -678,6 +668,8 @@ int set_UPnPDevice_UPnPDMBasicMgmt(char *refparam, struct dmctx *ctx, void *data
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -696,6 +688,8 @@ int set_UPnPDevice_UPnPDMConfigurationMgmt(char *refparam, struct dmctx *ctx, vo
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -714,6 +708,8 @@ int set_UPnPDevice_UPnPDMSoftwareMgmt(char *refparam, struct dmctx *ctx, void *d
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
//TODO
@ -870,15 +866,13 @@ int get_UPnPDiscoveryRootDevice_Status(char *refparam, struct dmctx *ctx, void *
int get_UPnPDiscoveryRootDevice_UUID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnpdiscovery *dev = (struct upnpdiscovery *)data;
*value= dev->uuid;
*value = ((struct upnpdiscovery *)data)->uuid;
return 0;
}
int get_UPnPDiscoveryRootDevice_USN(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnpdiscovery *dev = (struct upnpdiscovery *)data;
*value= dev->usn;
*value = ((struct upnpdiscovery *)data)->usn;
return 0;
}
@ -890,8 +884,7 @@ int get_UPnPDiscoveryRootDevice_LeaseTime(char *refparam, struct dmctx *ctx, voi
int get_UPnPDiscoveryRootDevice_Location(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnpdiscovery *dev = (struct upnpdiscovery *)data;
*value= dev->descurl;
*value = ((struct upnpdiscovery *)data)->descurl;
return 0;
}
@ -921,15 +914,13 @@ int get_UPnPDiscoveryDevice_Status(char *refparam, struct dmctx *ctx, void *data
int get_UPnPDiscoveryDevice_UUID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnpdiscovery *dev = (struct upnpdiscovery *)data;
*value= dev->uuid;
*value = ((struct upnpdiscovery *)data)->uuid;
return 0;
}
int get_UPnPDiscoveryDevice_USN(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnpdiscovery *dev = (struct upnpdiscovery *)data;
*value= dev->usn;
*value = ((struct upnpdiscovery *)data)->usn;
return 0;
}
@ -941,8 +932,7 @@ int get_UPnPDiscoveryDevice_LeaseTime(char *refparam, struct dmctx *ctx, void *d
int get_UPnPDiscoveryDevice_Location(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnpdiscovery *dev = (struct upnpdiscovery *)data;
*value= dev->descurl;
*value = ((struct upnpdiscovery *)data)->descurl;
return 0;
}
@ -972,8 +962,7 @@ int get_UPnPDiscoveryService_Status(char *refparam, struct dmctx *ctx, void *dat
int get_UPnPDiscoveryService_USN(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnpdiscovery *dev = (struct upnpdiscovery *)data;
*value= dev->usn;
*value = ((struct upnpdiscovery *)data)->usn;
return 0;
}
@ -985,8 +974,7 @@ int get_UPnPDiscoveryService_LeaseTime(char *refparam, struct dmctx *ctx, void *
int get_UPnPDiscoveryService_Location(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnpdiscovery *dev = (struct upnpdiscovery *)data;
*value= dev->descurl;
*value = ((struct upnpdiscovery *)data)->descurl;
return 0;
}
@ -1010,15 +998,15 @@ int get_UPnPDiscoveryService_LastUpdate(char *refparam, struct dmctx *ctx, void
int get_UPnPDiscoveryService_ParentDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnpdiscovery *dev = (struct upnpdiscovery *)data;
char *rootdevlink = NULL, *devlink = NULL;
adm_entry_get_linker_param(ctx, dm_print_path("%s%cUPnP%cDiscovery%cRootDevice%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), dev->uuid, &rootdevlink);
if(rootdevlink != NULL){
adm_entry_get_linker_param(ctx, dm_print_path("%s%cUPnP%cDiscovery%cRootDevice%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), ((struct upnpdiscovery *)data)->uuid, &rootdevlink);
if (rootdevlink != NULL) {
*value = rootdevlink;
return 0;
}
adm_entry_get_linker_param(ctx, dm_print_path("%s%cUPnP%cDiscovery%cDevice%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), dev->uuid, &devlink);
if(devlink != NULL){
adm_entry_get_linker_param(ctx, dm_print_path("%s%cUPnP%cDiscovery%cDevice%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), ((struct upnpdiscovery *)data)->uuid, &devlink);
if (devlink != NULL) {
*value = devlink;
return 0;
}
@ -1086,8 +1074,7 @@ int get_UPnPDescription_ServiceInstanceNumberOfEntries(char *refparam, struct dm
int get_UPnPDescriptionDeviceDescription_URLBase(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_description_file_info *upnp_desc = (struct upnp_description_file_info *)data;
*value = upnp_desc->desc_url;
*value = ((struct upnp_description_file_info *)data)->desc_url;
return 0;
}
@ -1105,17 +1092,16 @@ int get_UPnPDescriptionDeviceDescription_Host(char *refparam, struct dmctx *ctx,
int get_UPnPDescriptionDeviceInstance_UDN(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst = (struct upnp_device_inst *)data;
*value = upnpdevinst->udn;
*value = ((struct upnp_device_inst *)data)->udn;
return 0;
}
int get_UPnPDescriptionDeviceInstance_ParentDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst= (struct upnp_device_inst *)data;
char *devinstlink = NULL;
adm_entry_get_linker_param(ctx, dm_print_path("%s%cUPnP%cDescription%cDeviceInstance%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), upnpdevinst->parentudn, &devinstlink);
if(devinstlink != NULL){
adm_entry_get_linker_param(ctx, dm_print_path("%s%cUPnP%cDescription%cDeviceInstance%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), ((struct upnp_device_inst *)data)->parentudn, &devinstlink);
if (devinstlink != NULL) {
*value = devinstlink;
return 0;
}
@ -1147,15 +1133,13 @@ int get_UPnPDescriptionDeviceInstance_DiscoveryDevice(char *refparam, struct dmc
int get_UPnPDescriptionDeviceInstance_DeviceType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst= (struct upnp_device_inst *)data;
*value = upnpdevinst->device_type;
*value = ((struct upnp_device_inst *)data)->device_type;
return 0;
}
int get_UPnPDescriptionDeviceInstance_FriendlyName(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst= (struct upnp_device_inst *)data;
*value = upnpdevinst->friendly_name;
*value = ((struct upnp_device_inst *)data)->friendly_name;
return 0;
}
@ -1167,8 +1151,7 @@ int get_UPnPDescriptionDeviceInstance_DeviceCategory(char *refparam, struct dmct
int get_UPnPDescriptionDeviceInstance_Manufacturer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst = (struct upnp_device_inst *)data;
*value = upnpdevinst->manufacturer;
*value = ((struct upnp_device_inst *)data)->manufacturer;
return 0;
}
@ -1180,66 +1163,58 @@ int get_UPnPDescriptionDeviceInstance_ManufacturerOUI(char *refparam, struct dmc
int get_UPnPDescriptionDeviceInstance_ManufacturerURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst = (struct upnp_device_inst *)data;
*value = upnpdevinst->manufacturer_url;
*value = ((struct upnp_device_inst *)data)->manufacturer_url;
return 0;
}
int get_UPnPDescriptionDeviceInstance_ModelDescription(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst = (struct upnp_device_inst *)data;
*value = upnpdevinst->model_description;
*value = ((struct upnp_device_inst *)data)->model_description;
return 0;
}
int get_UPnPDescriptionDeviceInstance_ModelName(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst = (struct upnp_device_inst *)data;
*value = upnpdevinst->model_name;
*value = ((struct upnp_device_inst *)data)->model_name;
return 0;
}
int get_UPnPDescriptionDeviceInstance_ModelNumber(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst= (struct upnp_device_inst *)data;
*value = upnpdevinst->model_number;
*value = ((struct upnp_device_inst *)data)->model_number;
return 0;
}
int get_UPnPDescriptionDeviceInstance_ModelURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst = (struct upnp_device_inst *)data;
*value = upnpdevinst->model_url;
*value = ((struct upnp_device_inst *)data)->model_url;
return 0;
}
int get_UPnPDescriptionDeviceInstance_SerialNumber(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst = (struct upnp_device_inst *)data;
*value = upnpdevinst->serial_number;
*value = ((struct upnp_device_inst *)data)->serial_number;
return 0;
}
int get_UPnPDescriptionDeviceInstance_UPC(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst = (struct upnp_device_inst *)data;
*value = upnpdevinst->upc;
*value = ((struct upnp_device_inst *)data)->upc;
return 0;
}
int get_UPnPDescriptionDeviceInstance_PresentationURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_device_inst *upnpdevinst= (struct upnp_device_inst *)data;
*value = upnpdevinst->preentation_url;
*value = ((struct upnp_device_inst *)data)->preentation_url;
return 0;
}
int get_UPnPDescriptionServiceInstance_ParentDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_service_inst *upnpserviceinst = (struct upnp_service_inst *)data;
char *devinstlink = NULL;
adm_entry_get_linker_param(ctx, dm_print_path("%s%cUPnP%cDescription%cDeviceInstance%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), upnpserviceinst->parentudn, &devinstlink);
if(devinstlink != NULL){
adm_entry_get_linker_param(ctx, dm_print_path("%s%cUPnP%cDescription%cDeviceInstance%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), ((struct upnp_service_inst *)data)->parentudn, &devinstlink);
if (devinstlink != NULL) {
*value = devinstlink;
return 0;
}
@ -1248,16 +1223,15 @@ int get_UPnPDescriptionServiceInstance_ParentDevice(char *refparam, struct dmctx
int get_UPnPDescriptionServiceInstance_ServiceId(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_service_inst *upnpserviceinst = (struct upnp_service_inst *)data;
*value = upnpserviceinst->serviceid;
*value = ((struct upnp_service_inst *)data)->serviceid;
return 0;
}
int get_UPnPDescriptionServiceInstance_ServiceDiscovery(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_service_inst *upnpserviceinst = (struct upnp_service_inst *)data;
char *usn = NULL, *devlink = NULL;
dmasprintf(&usn, "%s::%s", upnpserviceinst->parentudn, upnpserviceinst->servicetype);
dmasprintf(&usn, "%s::%s", ((struct upnp_service_inst *)data)->parentudn, ((struct upnp_service_inst *)data)->servicetype);
if (usn && usn[0]) {
adm_entry_get_linker_param(ctx, dm_print_path("%s%cUPnP%cDiscovery%cService%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), usn, &devlink);
if (devlink != NULL) {
@ -1271,28 +1245,24 @@ int get_UPnPDescriptionServiceInstance_ServiceDiscovery(char *refparam, struct d
int get_UPnPDescriptionServiceInstance_ServiceType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_service_inst *upnpserviceinst = (struct upnp_service_inst *)data;
*value = upnpserviceinst->servicetype;
*value = ((struct upnp_service_inst *)data)->servicetype;
return 0;
}
int get_UPnPDescriptionServiceInstance_SCPDURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_service_inst *upnpserviceinst = (struct upnp_service_inst *)data;
*value = upnpserviceinst->scpdurl;
*value = ((struct upnp_service_inst *)data)->scpdurl;
return 0;
}
int get_UPnPDescriptionServiceInstance_ControlURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_service_inst *upnpserviceinst = (struct upnp_service_inst *)data;
*value = upnpserviceinst->controlurl;
*value = ((struct upnp_service_inst *)data)->controlurl;
return 0;
}
int get_UPnPDescriptionServiceInstance_EventSubURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct upnp_service_inst *upnpserviceinst = (struct upnp_service_inst *)data;
*value = upnpserviceinst->eventsuburl;
*value = ((struct upnp_service_inst *)data)->eventsuburl;
return 0;
}

View file

@ -259,10 +259,9 @@ int browseUSBInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_
{
DIR *dir;
struct dirent *ent;
char *iface_path, *statistics_path, *v, *instnbr = NULL, *instance = NULL;
char *iface_path, *statistics_path, *instnbr = NULL, *instance = NULL;
size_t length;
char **foldersplit;
struct uci_section *s;
struct usb_interface iface= {};
LIST_HEAD(dup_list);
struct sysfs_dmsection *p;
@ -369,25 +368,23 @@ int browseUSBUSBHostsHostInst(struct dmctx *dmctx, DMNODE *parent_node, void *pr
int synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, char *dmmap_package, char *dmmap_section, char *opt_name, char* inst_opt, int is_root, struct list_head *dup_list)
{
struct uci_section *s, *stmp, *dmmap_sect;
FILE *fp;
DIR *dir;
struct dirent *ent;
char *v, *dmmap_file_path, *sysfs_rep_path, *instance= NULL;
char *v, *sysfs_rep_path, *instance = NULL;
struct sysfs_dmsection *p;
regex_t regex1 = {};
regex_t regex2 = {};
regex_t regex1 = {}, regex2 = {};
regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]$", 0);
regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]$", 0);
LIST_HEAD(dup_list_no_inst);
dmmap_file_path = dmmap_file_path_get(dmmap_package);
dmmap_file_path_get(dmmap_package);
sysfs_foreach_file(sysfsrep, dir, ent) {
if(strcmp(ent->d_name, ".")==0 || strcmp(ent->d_name, "..")==0)
continue;
if(regexec(&regex1, ent->d_name, 0, NULL, 0) == 0 || regexec(&regex2, ent->d_name, 0, NULL, 0) ==0){
if (regexec(&regex1, ent->d_name, 0, NULL, 0) == 0 || regexec(&regex2, ent->d_name, 0, NULL, 0) ==0) {
char deviceClassFile[256];
char deviceClass[16];
@ -412,7 +409,7 @@ int synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, char *dmm
/*
* Add system and dmmap sections to the list
*/
if(instance == NULL || strlen(instance) <= 0)
if (instance == NULL || strlen(instance) <= 0)
add_sysfs_sectons_list_paramameter(&dup_list_no_inst, dmmap_sect, ent->d_name, sysfs_rep_path);
else
add_sysfs_sectons_list_paramameter(dup_list, dmmap_sect, ent->d_name, sysfs_rep_path);
@ -466,11 +463,9 @@ int browseUSBUSBHostsHostDeviceInst(struct dmctx *dmctx, DMNODE *parent_node, vo
int browseUSBUSBHostsHostDeviceConfigurationInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
const struct usb_port *usb_dev = prev_data;
struct usb_port port= {};
struct usb_port port = {};
struct uci_section *s;
char *v, *instance, *instnbr = NULL;
char *filepath= NULL;
char nbre[16];
char nbre[16], *v, *instnbr = NULL;
__read_sysfs_usb_port(usb_dev, "bNumConfigurations", nbre, sizeof(nbre));
if(nbre[0] == '0')
@ -593,6 +588,7 @@ int get_USBInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char
*value = "1";
else
*value = "0";
return 0;
}
int set_USBInterface_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
@ -617,6 +613,7 @@ int get_USBInterface_Status(char *refparam, struct dmctx *ctx, void *data, char
*value = "up";
else
*value = "down";
return 0;
}
int get_USBInterface_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
@ -906,6 +903,7 @@ int get_USBUSBHostsHost_Enable(char *refparam, struct dmctx *ctx, void *data, ch
__read_sysfs_usb_port(data, "power/wakeup", up, sizeof(up));
*value = strcmp(up, "enabled") == 0 ? "1" : "0";
return 0;
}
int set_USBUSBHostsHost_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
@ -1017,6 +1015,7 @@ int get_USBUSBHostsHost_USBVersion(char *refparam, struct dmctx *ctx, void *data
dm_read_sysfs_file(file, buf, sizeof(buf));
dmasprintf(value, "%c.%c", buf[1], buf[2]);
return 0;
}
int get_number_devices(char *folderpath, int *nbre)
@ -1030,7 +1029,7 @@ int get_number_devices(char *folderpath, int *nbre)
regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]$", 0);
sysfs_foreach_file(folderpath, dir, ent) {
if(regexec(&regex1, ent->d_name, 0, NULL, 0) == 0 || regexec(&regex2, ent->d_name, 0, NULL, 0) ==0){
if (regexec(&regex1, ent->d_name, 0, NULL, 0) == 0 || regexec(&regex2, ent->d_name, 0, NULL, 0) == 0) {
char deviceClassFile[256];
char deviceClass[16];

View file

@ -72,7 +72,7 @@ int set_userint_remoteaccesss_enable(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -112,9 +112,10 @@ int set_userint_remoteaccesss_port(char *refparam, struct dmctx *ctx, void *data
struct uci_section *ss;
char *rule_name, *owsd;
switch (action)
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, "65535"))
return FAULT_9007;
return 0;
case VALUESET:
uci_foreach_sections("firewall", "rule", ss) {
@ -184,9 +185,11 @@ int set_userint_remoteaccesss_protocol(char *refparam, struct dmctx *ctx, void *
char *rule_name, *name_http;
int found;
switch (action)
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, SupportedProtocols, NULL))
return FAULT_9007;
found = get_supportedprotocols();
if (found) {
if ((strcmp(value, "HTTP") != 0) && (strcmp(value, "HTTPS") != 0))

View file

@ -75,7 +75,7 @@ int add_users_user(char *refparam, struct dmctx *ctx, void *data, char **instanc
int delete_users_user(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *ss = NULL, *dmmap_section;
struct uci_section *s = NULL, *ss = NULL, *dmmap_section = NULL;
int found = 0;
switch (del_action) {
@ -87,7 +87,8 @@ int delete_users_user(char *refparam, struct dmctx *ctx, void *data, char *insta
dmuci_delete_by_section_unnamed((struct uci_section *)data, NULL, NULL);
} else {
get_dmmap_section_of_config_section("dmmap_users", "user", section_name((struct uci_section *)data), &dmmap_section);
dmuci_delete_by_section_unnamed_bbfdm(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section_unnamed_bbfdm(dmmap_section, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
}
break;
@ -95,7 +96,8 @@ int delete_users_user(char *refparam, struct dmctx *ctx, void *data, char *insta
uci_foreach_sections("users", "user", s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_users", "user", section_name(ss), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
@ -103,7 +105,8 @@ int delete_users_user(char *refparam, struct dmctx *ctx, void *data, char *insta
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_users", "user", section_name(ss), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
break;
@ -127,10 +130,11 @@ int get_users_user_number_of_entries(char *refparam, struct dmctx *ctx, void *da
int get_user_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_users", "user", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "user_alias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "user_alias", value);
return 0;
}
@ -170,14 +174,17 @@ int get_user_language(char *refparam, struct dmctx *ctx, void *data, char *insta
int set_user_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_users", "user", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "user_alias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "user_alias", value);
return 0;
}
return 0;
@ -187,6 +194,8 @@ int set_user_enable(char *refparam, struct dmctx *ctx, void *data, char *instanc
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "enabled", value);
@ -199,6 +208,8 @@ int set_user_username(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_rename_section_by_section((struct uci_section *)data, value);
@ -211,6 +222,8 @@ int set_user_password(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "password", value);
@ -223,6 +236,8 @@ int set_user_remote_accessable(char *refparam, struct dmctx *ctx, void *data, ch
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "remote_access", value);
@ -235,6 +250,8 @@ int set_user_language(char *refparam, struct dmctx *ctx, void *data, char *insta
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "16", NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "language", value);

View file

@ -123,15 +123,12 @@ int set_x_iopsys_eu_button_enable(char *refparam, struct dmctx *ctx, void *data,
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "enable", "");
else
dmuci_set_value_by_section((struct uci_section *)data, "enable", "0");
dmuci_set_value_by_section((struct uci_section *)data, "enable", b ? "1" : "0");
return 0;
}
return 0;
@ -139,23 +136,27 @@ int set_x_iopsys_eu_button_enable(char *refparam, struct dmctx *ctx, void *data,
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_x_iopsys_eu_button_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_buttons", "button", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "buttonalias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "buttonalias", value);
return 0;
}
int set_x_iopsys_eu_button_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_buttons", "button", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "buttonalias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "buttonalias", value);
return 0;
}
return 0;

View file

@ -51,9 +51,9 @@ int browseXIopsysEuDropbear(struct dmctx *dmctx, DMNODE *parent_node, void *prev
int get_x_iopsys_eu_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "PasswordAuth", value);
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1') {
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1')
*value = "1";
} else
else
*value = "0";
return 0;
}
@ -64,15 +64,12 @@ int set_x_iopsys_eu_dropbear_password_auth(char *refparam, struct dmctx *ctx, vo
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "PasswordAuth", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "PasswordAuth", "0");
dmuci_set_value_by_section((struct uci_section *)data, "PasswordAuth", b ? "1" : "0");
return 0;
}
return 0;
@ -81,9 +78,9 @@ int set_x_iopsys_eu_dropbear_password_auth(char *refparam, struct dmctx *ctx, vo
int get_x_iopsys_eu_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "RootPasswordAuth", value);
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1') {
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1')
*value = "1";
} else
else
*value = "0";
return 0;
}
@ -94,15 +91,12 @@ int set_x_iopsys_eu_dropbear_root_password_auth(char *refparam, struct dmctx *ct
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "RootPasswordAuth", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "RootPasswordAuth", "0");
dmuci_set_value_by_section((struct uci_section *)data, "RootPasswordAuth", b ? "1" : "0");
return 0;
}
return 0;
@ -136,9 +130,8 @@ int set_x_iopsys_eu_dropbear_port(char *refparam, struct dmctx *ctx, void *data,
int get_x_iopsys_eu_dropbear_root_login(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "RootLogin", value);
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1' ) {
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1' )
*value = "1";
}
else
*value = "0";
return 0;
@ -150,15 +143,12 @@ int set_x_iopsys_eu_dropbear_root_login(char *refparam, struct dmctx *ctx, void
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "RootLogin", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "RootLogin", "0");
dmuci_set_value_by_section((struct uci_section *)data, "RootLogin", b ? "1" : "0");
return 0;
}
return 0;
@ -167,9 +157,8 @@ int set_x_iopsys_eu_dropbear_root_login(char *refparam, struct dmctx *ctx, void
int get_x_iopsys_eu_dropbear_verbose(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "verbose", value);
if ((*value)[0] == '\0' || (*value)[0] == '0' ) {
if ((*value)[0] == '\0' || (*value)[0] == '0' )
*value = "0";
}
else
*value = "1";
return 0;
@ -181,15 +170,12 @@ int set_x_iopsys_eu_dropbear_verbose(char *refparam, struct dmctx *ctx, void *da
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "verbose", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "verbose", "0");
dmuci_set_value_by_section((struct uci_section *)data, "verbose", b ? "1" : "0");
return 0;
}
return 0;
@ -198,9 +184,9 @@ int set_x_iopsys_eu_dropbear_verbose(char *refparam, struct dmctx *ctx, void *da
int get_x_iopsys_eu_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "GatewayPorts", value);
if ((*value)[0] == '\0' || (*value)[0] == '0' ) {
if ((*value)[0] == '\0' || (*value)[0] == '0' )
*value = "0";
} else
else
*value = "1";
return 0;
}
@ -211,15 +197,12 @@ int set_x_iopsys_eu_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, vo
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "GatewayPorts", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "GatewayPorts", "");
dmuci_set_value_by_section((struct uci_section *)data, "GatewayPorts", b ? "1" : "");
return 0;
}
return 0;
@ -355,23 +338,27 @@ int set_x_iopsys_eu_dropbear_banner_file(char *refparam, struct dmctx *ctx, void
int get_x_iopsys_eu_dropbear_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_dropbear", "dropbear", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "dropbearalias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "dropbearalias", value);
return 0;
}
int set_x_iopsys_eu_dropbear_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_dropbear", "dropbear", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "dropbearalias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "dropbearalias", value);
return 0;
}
return 0;

View file

@ -21,14 +21,7 @@ DMLEAF tSe_IceParam[] = {
int get_ice_cloud_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bool b;
dmuci_get_option_value_string("ice", "cloud", "enabled", value);
string_to_bool(*value, &b);
if (b)
*value = "1";
else
*value = "0";
return 0;
}
@ -38,15 +31,12 @@ int set_ice_cloud_enable(char *refparam, struct dmctx *ctx, void *data, char *in
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("ice", "cloud", "enabled", "1");
else
dmuci_set_value("ice", "cloud", "enabled", "0");
dmuci_set_value("ice", "cloud", "enabled", b ? "1" : "0");
return 0;
}
return 0;

View file

@ -190,15 +190,12 @@ int set_igmp_multicast_enable(char *refparam, struct dmctx *ctx, void *data, cha
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("mcpd", "mcpd", "igmp_lan_to_lan_multicast", "1");
else
dmuci_set_value("mcpd", "mcpd", "igmp_lan_to_lan_multicast", "");
dmuci_set_value("mcpd", "mcpd", "igmp_lan_to_lan_multicast", b ? "1" : "");
return 0;
}
return 0;
@ -219,15 +216,12 @@ int set_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, void *data, cha
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("mcpd", "mcpd", "igmp_fast_leave", "1");
else
dmuci_set_value("mcpd", "mcpd", "igmp_fast_leave", "");
dmuci_set_value("mcpd", "mcpd", "igmp_fast_leave", b ? "1" : "");
return 0;
}
return 0;
@ -248,15 +242,12 @@ int set_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, void *data,
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("mcpd", "mcpd", "igmp_join_immediate", "1");
else
dmuci_set_value("mcpd", "mcpd", "igmp_join_immediate", "");
dmuci_set_value("mcpd", "mcpd", "igmp_join_immediate", b ? "1" : "");
return 0;
}
return 0;
@ -277,15 +268,12 @@ int set_igmp_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *i
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if (b)
dmuci_set_value("mcpd", "mcpd", "igmp_proxy_enable", "1");
else
dmuci_set_value("mcpd", "mcpd", "igmp_proxy_enable", "");
dmuci_set_value("mcpd", "mcpd", "igmp_proxy_enable", b ? "1" : "");
return 0;
}
return 0;

View file

@ -70,7 +70,7 @@ int set_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, v
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -247,7 +247,7 @@ int set_port_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, ch
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -276,15 +276,12 @@ int set_port_forwarding_loopback(char *refparam, struct dmctx *ctx, void *data,
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "reflection", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "reflection", "0");
dmuci_set_value_by_section((struct uci_section *)data, "reflection", b ? "1" : "0");
return 0;
}
return 0;
@ -549,20 +546,22 @@ int add_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char **inst
int delete_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *ss = NULL, *dmmap_section;
struct uci_section *s = NULL, *ss = NULL, *dmmap_section = NULL;
int found = 0;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("firewall", "rule", s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(s), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
@ -570,7 +569,8 @@ int delete_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char *in
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(ss), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
break;
@ -601,19 +601,21 @@ int add_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *data,
int delete_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
int found = 0;
struct uci_section *forwardsection = (struct uci_section *)data, *s = NULL, *ss = NULL, *dmmap_section;
struct uci_section *forwardsection = (struct uci_section *)data, *s = NULL, *ss = NULL, *dmmap_section = NULL;
switch (del_action) {
case DEL_INST:
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(forwardsection), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(forwardsection, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_option_eq("firewall", "redirect", "target", "DNAT", s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(s), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
@ -621,7 +623,8 @@ int delete_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *dat
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(ss), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
break;
@ -633,24 +636,28 @@ int delete_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *dat
int get_x_iopsys_eu_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(ipaccsection), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "frulealias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "frulealias", value);
return 0;
}
int set_x_iopsys_eu_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(ipaccsection), &dmmap_section);
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "frulealias", value);
get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name(ipaccsection), &dmmap_section);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "frulealias", value);
return 0;
}
return 0;
@ -659,24 +666,28 @@ int set_x_iopsys_eu_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void
int get_port_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *forwardsection = (struct uci_section *)data;
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(forwardsection), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "forwardalias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "forwardalias", value);
return 0;
}
int set_port_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *forwardsection = (struct uci_section *)data;
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(forwardsection), &dmmap_section);
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(dmmap_section, "forwardalias", value);
get_dmmap_section_of_config_section("dmmap_firewall", "redirect", section_name(forwardsection), &dmmap_section);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "forwardalias", value);
return 0;
}
return 0;

View file

@ -179,15 +179,12 @@ int set_x_iopsys_eu_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "ipv6", "on");
else
dmuci_set_value_by_section((struct uci_section *)data, "ipv6", "off");
dmuci_set_value_by_section((struct uci_section *)data, "ipv6", b ? "on" : "off");
return 0;
}
return 0;
@ -208,15 +205,12 @@ int set_x_iopsys_eu_owsd_listenobj_whitelist_interface(char *refparam, struct dm
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "whitelist_interface_as_origin", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "whitelist_interface_as_origin", "0");
dmuci_set_value_by_section((struct uci_section *)data, "whitelist_interface_as_origin", b ? "1" : "0");
return 0;
}
return 0;
@ -237,15 +231,12 @@ int set_x_iopsys_eu_owsd_listenobj_whitelist_dhcp(char *refparam, struct dmctx *
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section((struct uci_section *)data, "whitelist_dhcp_domains", "1");
else
dmuci_set_value_by_section((struct uci_section *)data, "whitelist_dhcp_domains", "0");
dmuci_set_value_by_section((struct uci_section *)data, "whitelist_dhcp_domains", b ? "1" : "0");
return 0;
}
return 0;
@ -287,23 +278,25 @@ int set_x_iopsys_eu_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, voi
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_x_iopsys_eu_owsd_listenobj_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_owsd", "owsd-listen", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_get_value_by_section_string(dmmap_section, "olistenalias", value);
if (dmmap_section)
dmuci_get_value_by_section_string(dmmap_section, "olistenalias", value);
return 0;
}
int set_x_iopsys_eu_owsd_listenobj_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_section;
struct uci_section *dmmap_section = NULL;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
get_dmmap_section_of_config_section("dmmap_owsd", "owsd-listen", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_set_value_by_section(dmmap_section, "olistenalias", value);
if (dmmap_section)
dmuci_set_value_by_section(dmmap_section, "olistenalias", value);
return 0;
}
return 0;
@ -491,7 +484,7 @@ int add_owsd_listen(char *refparam, struct dmctx *ctx, void *data, char **instan
int delete_owsd_listen_instance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *ss = NULL, *dmmap_section;
struct uci_section *s = NULL, *ss = NULL, *dmmap_section = NULL;
int found = 0;
switch (del_action) {
@ -503,7 +496,8 @@ int delete_owsd_listen_instance(char *refparam, struct dmctx *ctx, void *data, c
dmuci_delete_by_section_unnamed((struct uci_section *)data, NULL, NULL);
} else {
get_dmmap_section_of_config_section("dmmap_owsd", "owsd-listen", section_name((struct uci_section *)data), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section_unnamed_bbfdm(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section_unnamed_bbfdm(dmmap_section, NULL, NULL);
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
}
break;
@ -511,7 +505,8 @@ int delete_owsd_listen_instance(char *refparam, struct dmctx *ctx, void *data, c
uci_foreach_sections("owsd", "owsd-listen", s) {
if (found != 0) {
get_dmmap_section_of_config_section("dmmap_owsd", "listen", section_name(s), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
@ -519,7 +514,8 @@ int delete_owsd_listen_instance(char *refparam, struct dmctx *ctx, void *data, c
}
if (ss != NULL) {
get_dmmap_section_of_config_section("dmmap_owsd", "listen", section_name(ss), &dmmap_section);
if (dmmap_section) dmuci_delete_by_section(dmmap_section, NULL, NULL);
if (dmmap_section)
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(ss, NULL, NULL);
}
return 0;

View file

@ -71,15 +71,12 @@ int set_power_mgmt_param_ethapd(char *refparam, struct dmctx *ctx, void *data, c
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value("power_mgmt", "power_mgmt", "ethapd", "1");
else
dmuci_set_value("power_mgmt", "power_mgmt", "ethapd", "0");
dmuci_set_value("power_mgmt", "power_mgmt", "ethapd", b ? "1" : "0");
return 0;
}
return 0;
@ -91,15 +88,12 @@ int set_power_mgmt_param_eee(char *refparam, struct dmctx *ctx, void *data, char
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value("power_mgmt", "power_mgmt", "eee", "1");
else
dmuci_set_value("power_mgmt", "power_mgmt", "eee", "0");
dmuci_set_value("power_mgmt", "power_mgmt", "eee", b ? "1" : "0");
return 0;
}
return 0;

View file

@ -61,14 +61,15 @@ int get_x_iopsys_eu_wifilife_enable(char *refparam, struct dmctx *ctx, void *dat
int set_x_iopsys_eu_wifilife_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value("wifilife", "@wifilife[0]", "enabled", b?"1":"0");
dmuci_set_value("wifilife", "@wifilife[0]", "enabled", b ? "1" : "0");
return 0;
}
return 0;
@ -85,14 +86,15 @@ int get_wifilife_steering_enable(char *refparam, struct dmctx *ctx, void *data,
int set_wifilife_steering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "enabled", b?"1":"0");
dmuci_set_value_by_section((struct uci_section *)data, "enabled", b ? "1" : "0");
return 0;
}
return 0;
@ -109,14 +111,15 @@ int get_wifilife_steering_legacy_fallback(char *refparam, struct dmctx *ctx, voi
int set_wifilife_steering_legacy_fallback(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "fallback_legacy", b?"1":"0");
dmuci_set_value_by_section((struct uci_section *)data, "fallback_legacy", b ? "1" : "0");
return 0;
}
return 0;

View file

@ -141,7 +141,7 @@ int get_xmpp_connection_nbr_entry(char *refparam, struct dmctx *ctx, void *data,
int get_xmpp_connection_supported_server_connect_algorithms(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "DNS-SRV , ServerTable";
*value = "DNS-SRV,ServerTable";
return 0;
}
@ -158,7 +158,7 @@ int set_connection_enable(char *refparam, struct dmctx *ctx, void *data, char *i
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -180,6 +180,8 @@ int set_xmpp_connection_alias(char *refparam, struct dmctx *ctx, void *data, cha
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "connection_alias", value);
@ -199,6 +201,8 @@ int set_xmpp_connection_username(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "username", value);
@ -218,6 +222,8 @@ int set_xmpp_connection_password(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "password", value);
@ -237,6 +243,8 @@ int set_xmpp_connection_domain(char *refparam, struct dmctx *ctx, void *data, ch
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "domain", value);
@ -245,7 +253,7 @@ int set_xmpp_connection_domain(char *refparam, struct dmctx *ctx, void *data, ch
return 0;
}
/*#Device.XMPP.Connection.{i}.Ressource!UCI:cwmp_xmpp/xmpp_connection,@i-1/resource*/
/*#Device.XMPP.Connection.{i}.Resource!UCI:cwmp_xmpp/xmpp_connection,@i-1/resource*/
int get_xmpp_connection_resource(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "resource", value);
@ -256,6 +264,8 @@ int set_xmpp_connection_resource(char *refparam, struct dmctx *ctx, void *data,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "resource", value);
@ -275,10 +285,11 @@ int set_xmpp_connection_server_connect_algorithm(char *refparam, struct dmctx *c
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, NULL, NULL, ServerConnectAlgorithm))
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "DNS-SRV") == 0 || strcmp(value, "ServerTable") == 0)
dmuci_set_value_by_section((struct uci_section *)data, "serveralgorithm", value);
dmuci_set_value_by_section((struct uci_section *)data, "serveralgorithm", value);
return 0;
}
return 0;
@ -295,6 +306,8 @@ int set_xmpp_connection_keepalive_interval(char *refparam, struct dmctx *ctx, vo
{
switch (action) {
case VALUECHECK:
if (dm_validate_long(value, "-1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "interval", value);
@ -314,6 +327,8 @@ int set_xmpp_connection_server_attempts(char *refparam, struct dmctx *ctx, void
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "attempt", value);
@ -333,6 +348,8 @@ int set_xmpp_connection_retry_initial_interval(char *refparam, struct dmctx *ctx
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "initial_retry_interval", value);
@ -352,6 +369,8 @@ int set_xmpp_connection_retry_interval_multiplier(char *refparam, struct dmctx *
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1000", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "retry_interval_multiplier", value);
@ -371,6 +390,8 @@ int set_xmpp_connection_retry_max_interval(char *refparam, struct dmctx *ctx, vo
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "1", NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "retry_max_interval", value);
@ -392,7 +413,7 @@ int set_xmpp_connection_server_usetls(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -423,7 +444,7 @@ int get_xmpp_connection_status(char *refparam, struct dmctx *ctx, void *data, ch
char *status;
dmuci_get_value_by_section_string((struct uci_section *)data, "enable", &status);
if (strcmp(status,"1") == 0)
if (strcmp(status, "1") == 0)
*value = "Enabled";
else
*value = "Disabled";
@ -449,7 +470,7 @@ int set_xmpp_connection_server_enable(char *refparam, struct dmctx *ctx, void *d
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
@ -471,6 +492,8 @@ int set_xmpp_connection_server_alias(char *refparam, struct dmctx *ctx, void *da
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "64", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "connection_server_alias", value);
@ -490,6 +513,8 @@ int set_xmpp_connection_server_server_address(char *refparam, struct dmctx *ctx,
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, NULL, "256", NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "server_address", value);
@ -509,6 +534,8 @@ int set_xmpp_connection_server_port(char *refparam, struct dmctx *ctx, void *dat
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, "0", "65535"))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((struct uci_section *)data, "port", value);
@ -557,9 +584,9 @@ int browsexmpp_connection_serverInst(struct dmctx *dmctx, DMNODE *parent_node, v
dmuci_get_value_by_section_string(connsection, "connection_instance", &prev_connection_instance);
uci_foreach_option_eq("cwmp_xmpp", "xmpp_connection_server", "id_connection", prev_connection_instance, s) {
iconnectionserver = handle_update_instance(1, dmctx, &iconnectionserver_last, update_instance_alias, 3, s, "connection_server_instance", "connection_server_instance_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, iconnectionserver) == DM_STOP)
break;
iconnectionserver = handle_update_instance(1, dmctx, &iconnectionserver_last, update_instance_alias, 3, s, "connection_server_instance", "connection_server_instance_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, iconnectionserver) == DM_STOP)
break;
}
return 0;
}

View file

@ -1,25 +1,20 @@
#!/usr/bin/python
# Copyright (C) 2019 iopsys Software Solutions AB
# Copyright (C) 2020 iopsys Software Solutions AB
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
import os
import sys
import time
import json
import os, sys, time, json
from collections import OrderedDict
arrtype = {
"string": "DMT_STRING",
"unsignedInt": "DMT_UNINT",
"unsignedLong": "DMT_UNLONG",
"int": "DMT_INT",
"long": "DMT_LONG",
"boolean": "DMT_BOOL",
"dateTime": "DMT_TIME",
"hexBinary": "DMT_HEXBIN",
"base64": "DMT_BASE64",
}
arrTypes = { "string": "DMT_STRING",
"unsignedInt": "DMT_UNINT",
"unsignedLong": "DMT_UNLONG",
"int": "DMT_INT",
"long": "DMT_LONG",
"boolean": "DMT_BOOL",
"dateTime": "DMT_TIME",
"hexBinary": "DMT_HEXBIN",
"base64": "DMT_BASE64"}
def removefile( filename ):
try:
@ -34,19 +29,13 @@ def securemkdir( folder ):
pass
def getlastname( name ):
lastname = name
lastname = lastname.replace(".{i}", "")
namelist = lastname.split('.')
lastname = namelist[-1]
if lastname == "":
lastname = namelist[-2]
return lastname;
return name.replace(".{i}", "").split('.')[-2];
def getname( objname ):
global model_root_name
OBJSname = objname
if (objname.count('.') > 1 and (objname.count('.') != 2 or objname.count('{i}') != 1) ):
OBJSname = objname.replace(dmroot, "", 1)
OBJSname = objname.replace("Device", "", 1)
OBJSname = OBJSname.replace("{i}", "")
OBJSname = OBJSname.replace(".", "")
if (objname.count('.') == 1):
@ -60,58 +49,65 @@ def getname( objname ):
return OBJSname;
def getoptionparam( value, option ):
val = "false"
if isinstance(value,dict):
for k,v in value.items():
if k == option:
return v
return val
if isinstance(value, dict):
for obj, val in value.items():
if obj == option:
return val
return None
def getarrayoptionparam( value, option ):
if isinstance(value, dict):
for obj, val in value.items():
if obj == option and isinstance(val, list):
return val
return None
def getobjectoptionparam( value, option ):
if isinstance(value, dict):
for obj, val in value.items():
print "obj=%s" % obj
print "val=%s" % val
if obj == option and isinstance(val, dict):
return val
return None
def getprotocolsparam( value, option ):
val = "BBFDM_BOTH"
if isinstance(value,dict):
for k,v in value.items():
if k == option and isinstance(v, list):
if len(v) == 2:
if isinstance(value, dict):
for obj, val in value.items():
if obj == option and isinstance(val, list):
if len(val) == 2:
return "BBFDM_BOTH"
elif v[0] == "usp":
elif val[0] == "usp":
return "BBFDM_USP"
else:
return "BBFDM_CWMP"
return val
return "BBFDM_BOTH"
def getargsparam( value ):
val1 = "false"
val2 = "false"
if isinstance(value,dict):
for k,v in value.items():
return k, v
return val1, val2
if isinstance(value, dict):
for obj, val in value.items():
return obj, val
return None, None
def getparamtype( value ):
ptype = None
paramtype = getoptionparam(value, "type")
ptype = arrtype.get(paramtype, None)
if ptype == None:
ptype = "__NA__"
return ptype
return arrTypes.get(paramtype, None)
def objhaschild( value ):
if isinstance(value,dict):
for k,v in value.items():
if isinstance(v,dict):
for k1,v1 in v.items():
if k1 == "type" and v1 == "object":
if isinstance(value, dict):
for obj, val in value.items():
if isinstance(val, dict):
for obj1, val1 in val.items():
if obj1 == "type" and val1 == "object":
return 1
return 0
def objhasparam( value ):
if isinstance(value,dict):
for k,v in value.items():
if isinstance(v,dict):
for k1,v1 in v.items():
if k1 == "type" and v1 != "object":
if isinstance(value, dict):
for obj, val in value.items():
if isinstance(val, dict):
for obj1,val1 in val.items():
if obj1 == "type" and val1 != "object":
return 1
return 0
@ -152,6 +148,15 @@ def get_mapping_param( mappingobj ):
i += 1
return type, command, list_length, value, "", ""
def printGlobalstrCommon( str_exp ):
if "tr104" in sys.argv[1]:
common = "tr104/common.c"
else:
common = "tr181/common.c"
fp = open(common, 'a')
print >> fp, "%s" % str_exp
fp.close()
def get_mapping_obj( mappingobj ):
type = getoptionparam(mappingobj, "type")
uciobj = getoptionparam(mappingobj, "uci")
@ -161,6 +166,122 @@ def get_mapping_obj( mappingobj ):
dmmapfile = getoptionparam(uciobj, "dmmapfile")
return type, file, sectiontype, dmmapfile
def generate_validate_value(dmparam, value):
validate_value = ""
maxsizeparam = "NULL"
itemminparam = "NULL"
itemmaxparam = "NULL"
rangeminparam = "NULL"
rangemaxparam = "NULL"
listparam = getoptionparam(value, "list")
if listparam != None:
datatypeparam = getoptionparam(listparam, "datatype")
maxsizeparam = getoptionparam(listparam, "maxsize")
if maxsizeparam == None: maxsizeparam = "NULL"
itemparam = getoptionparam(listparam, "item")
if itemparam != None:
itemminparam = getoptionparam(itemparam, "min")
if itemminparam == None: itemminparam = "NULL"
itemmaxparam = getoptionparam(itemparam, "max")
if itemmaxparam == None: itemmaxparam = "NULL"
rangeparam = getoptionparam(listparam, "range")
if rangeparam != None:
rangeminparam = getoptionparam(rangeparam, "min")
if rangeminparam == None: rangeminparam = "NULL"
rangemaxparam = getoptionparam(rangeparam, "max")
if rangemaxparam == None: rangemaxparam = "NULL"
enumarationsparam = getarrayoptionparam(listparam, "enumerations")
if enumarationsparam != None:
list_enumarationsparam = enumarationsparam
enum_length = len(list_enumarationsparam)
enumarationsparam = dmparam if datatypeparam == "string" else datatypeparam
str_enum = "char *%s[] = {" % enumarationsparam
for i in range(enum_length):
str_enum += "\"%s\", " % list_enumarationsparam[i]
str_enum += "NULL};"
printGlobalstrCommon(str_enum)
else:
enumarationsparam = "NULL"
patternparam = getarrayoptionparam(listparam, "pattern")
if patternparam != None:
list_patternparam = patternparam
pattern_length = len(list_patternparam)
patternparam = dmparam if datatypeparam == "string" else datatypeparam
str_pattern = "char *%s[] = {" % patternparam
for i in range(pattern_length):
str_pattern += "\"^%s$\", " % list_patternparam[i]
str_pattern += "NULL};"
printGlobalstrCommon(str_pattern)
elif datatypeparam == "IPAddress":
patternparam = "IPAddress"
elif datatypeparam == "IPv6Address":
patternparam = "IPv6Address"
else:
patternparam = "NULL"
if datatypeparam == "unsignedInt":
validate_value += " if (dm_validate_unsignedInt_list(value, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\"))\n" % (itemminparam, itemmaxparam, maxsizeparam, rangeminparam, rangemaxparam)
elif datatypeparam == "int":
validate_value += " if (dm_validate_int_list(value, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\"))\n" % (itemminparam, itemmaxparam, maxsizeparam, rangeminparam, rangemaxparam)
else:
validate_value += " if (dm_validate_string_list(value, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", %s, %s))\n" % (itemminparam, itemmaxparam, maxsizeparam, rangeminparam, rangemaxparam, enumarationsparam, patternparam)
else:
datatypeparam = getoptionparam(value, "datatype")
rangeparam = getoptionparam(value, "range")
if rangeparam != None:
rangeminparam = getoptionparam(rangeparam, "min")
if rangeminparam == None: rangeminparam = "NULL"
rangemaxparam = getoptionparam(rangeparam, "max")
if rangemaxparam == None: rangemaxparam = "NULL"
enumarationsparam = getarrayoptionparam(value, "enumerations")
if enumarationsparam != None:
list_enumarationsparam = enumarationsparam
enum_length = len(list_enumarationsparam)
enumarationsparam = dmparam if datatypeparam == "string" else datatypeparam
str_enum = "char *%s[] = {" % enumarationsparam
for i in range(enum_length):
str_enum += "\"%s\", " % list_enumarationsparam[i]
str_enum += "NULL};"
printGlobalstrCommon(str_enum)
else:
enumarationsparam = "NULL"
patternparam = getarrayoptionparam(value, "pattern")
if patternparam != None:
list_patternparam = patternparam
pattern_length = len(list_patternparam)
patternparam = dmparam if datatypeparam == "string" else datatypeparam
str_pattern = "char *%s[] = {" % patternparam
for i in range(pattern_length):
str_pattern += "\"^%s$\", " % list_patternparam[i]
str_pattern += "NULL};"
printGlobalstrCommon(str_pattern)
elif datatypeparam == "IPAddress":
patternparam = "IPAddress"
elif datatypeparam == "IPv6Address":
patternparam = "IPv6Address"
else:
patternparam = "NULL"
if datatypeparam == "boolean":
validate_value += " if (dm_validate_boolean(value))\n"
elif datatypeparam == "unsignedInt":
validate_value += " if (dm_validate_unsignedInt(value, \"%s\", \"%s\"))\n" % (rangeminparam, rangemaxparam)
elif datatypeparam == "int":
validate_value += " if (dm_validate_int(value, \"%s\", \"%s\"))\n" % (rangeminparam, rangemaxparam)
elif datatypeparam == "unsignedLong":
validate_value += " if (dm_validate_unsignedLong(value, \"%s\", \"%s\"))\n" % (rangeminparam, rangemaxparam)
elif datatypeparam == "long":
validate_value += " if (dm_validate_long(value, \"%s\", \"%s\"))\n" % (rangeminparam, rangemaxparam)
elif datatypeparam == "dateTime":
validate_value += " if (dm_validate_dateTime(value))\n"
elif datatypeparam == "hexBinary":
validate_value += " if (dm_validate_hexBinary(value, \"%s\", \"%s\"))\n" % (rangeminparam, rangemaxparam)
else:
validate_value += " if (dm_validate_string(value, \"%s\", \"%s\", %s, %s))\n" % (rangeminparam, rangemaxparam, enumarationsparam, patternparam)
validate_value += " return FAULT_9007;"
validate_value = validate_value.replace("\"NULL\"", "NULL")
return validate_value
def printheaderObjCommon( objname ):
fp = open('./.objparamarray.c', 'a')
print >> fp, "/* *** %s *** */" % objname
@ -179,7 +300,7 @@ def hprintheaderOBJS( objname ):
def cprinttopfile (fp, filename):
print >> fp, "/*"
print >> fp, " * Copyright (C) 2019 iopsys Software Solutions AB"
print >> fp, " * Copyright (C) 2020 iopsys Software Solutions AB"
print >> fp, " *"
print >> fp, " * This program is free software; you can redistribute it and/or modify"
print >> fp, " * it under the terms of the GNU Lesser General Public License version 2.1"
@ -188,18 +309,12 @@ def cprinttopfile (fp, filename):
print >> fp, " * Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>"
print >> fp, " */"
print >> fp, ""
print >> fp, "#include \"dmbbf.h\""
print >> fp, "#include \"dmcommon.h\""
print >> fp, "#include \"dmuci.h\""
print >> fp, "#include \"dmubus.h\""
print >> fp, "#include \"dmjson.h\""
print >> fp, "#include \"dmentry.h\""
print >> fp, "#include \"%s.h\"" % filename.lower()
print >> fp, ""
def hprinttopfile (fp, filename):
print >> fp, "/*"
print >> fp, " * Copyright (C) 2019 iopsys Software Solutions AB"
print >> fp, " * Copyright (C) 2020 iopsys Software Solutions AB"
print >> fp, " *"
print >> fp, " * This program is free software; you can redistribute it and/or modify"
print >> fp, " * it under the terms of the GNU Lesser General Public License version 2.1"
@ -211,6 +326,8 @@ def hprinttopfile (fp, filename):
print >> fp, "#ifndef __%s_H" % filename.upper()
print >> fp, "#define __%s_H" % filename.upper()
print >> fp, ""
print >> fp, "#include <libbbf_api/dmcommon.h>"
print >> fp, ""
def hprintfootfile (fp, filename):
print >> fp, ""
@ -221,7 +338,7 @@ def cprintAddDelObj( faddobj, fdelobj, name, mappingobj, dmobject ):
fp = open('./.objadddel.c', 'a')
print >> fp, "int %s(char *refparam, struct dmctx *ctx, void *data, char **instance)" % faddobj
print >> fp, "{"
if mappingobj != "false":
if mappingobj != None:
type, file, sectiontype, dmmapfile = get_mapping_obj(mappingobj)
if type == "uci":
print >> fp, " char *inst, *value, *v;"
@ -242,25 +359,25 @@ def cprintAddDelObj( faddobj, fdelobj, name, mappingobj, dmobject ):
print >> fp, ""
print >> fp, "int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)" % fdelobj
print >> fp, "{"
if mappingobj != "false":
if mappingobj != None:
if type == "uci":
print >> fp, " struct uci_section *s = NULL, *ss = NULL, *dmmap_section= NULL;"
print >> fp, " struct uci_section *s = NULL, *ss = NULL, *dmmap_section = NULL;"
print >> fp, " int found = 0;"
print >> fp, ""
print >> fp, " switch (del_action) {"
if mappingobj != "false":
if mappingobj != None:
if type == "uci":
print >> fp, " case DEL_INST:"
print >> fp, " get_dmmap_section_of_config_section(\"%s\", \"%s\", section_name((struct uci_section *)data), &dmmap_section);" % (dmmapfile, sectiontype)
print >> fp, " if(dmmap_section != NULL)"
print >> fp, " if (dmmap_section != NULL)"
print >> fp, " dmuci_delete_by_section(dmmap_section, NULL, NULL);"
print >> fp, " dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);"
print >> fp, " break;"
print >> fp, " case DEL_ALL:"
print >> fp, " uci_foreach_sections(\"%s\", \"%s\", s) {" % (file, sectiontype)
print >> fp, " if (found != 0){"
print >> fp, " if (found != 0) {"
print >> fp, " get_dmmap_section_of_config_section(\"%s\", \"%s\", section_name(ss), &dmmap_section);" % (dmmapfile, sectiontype)
print >> fp, " if(dmmap_section != NULL)"
print >> fp, " if (dmmap_section != NULL)"
print >> fp, " dmuci_delete_by_section(dmmap_section, NULL, NULL);"
print >> fp, " dmuci_delete_by_section(ss, NULL, NULL);"
print >> fp, " }"
@ -269,7 +386,7 @@ def cprintAddDelObj( faddobj, fdelobj, name, mappingobj, dmobject ):
print >> fp, " }"
print >> fp, " if (ss != NULL) {"
print >> fp, " get_dmmap_section_of_config_section(\"%s\", \"%s\", section_name(ss), &dmmap_section);" % (dmmapfile, sectiontype)
print >> fp, " if(dmmap_section != NULL)"
print >> fp, " if (dmmap_section != NULL)"
print >> fp, " dmuci_delete_by_section(dmmap_section, NULL, NULL);"
print >> fp, " dmuci_delete_by_section(ss, NULL, NULL);"
print >> fp, " }"
@ -294,13 +411,21 @@ def hprintAddDelObj( faddobj, fdelobj ):
fp.close()
def cprintBrowseObj( fbrowse, name, mappingobj, dmobject ):
# Open file
fp = open('./.objbrowse.c', 'a')
if mappingobj != "false":
### Mapping Parameter
if mappingobj != None:
type, file, sectiontype, dmmapfile = get_mapping_obj(mappingobj)
print >> fp, "/*#%s!%s:%s/%s/%s*/" % (dmobject, type.upper(), file, sectiontype, dmmapfile)
print >> fp, "int %s(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)" % fbrowse
print >> fp, "{"
if mappingobj != "false":
# Mapping exist
if mappingobj != None:
############################## UCI ########################################
if type == "uci" :
print >> fp, " char *inst = NULL, *inst_last = NULL;"
print >> fp, " struct dmmap_dup *p;"
@ -313,11 +438,21 @@ def cprintBrowseObj( fbrowse, name, mappingobj, dmobject ):
print >> fp, " break;"
print >> fp, " }"
print >> fp, " free_dmmap_config_dup_list(&dup_list);"
############################## UBUS ########################################
elif type == "ubus" :
print >> fp, " "
# Mapping doesn't exist
else:
print >> fp, " //TODO"
print >> fp, " return 0;"
print >> fp, "}"
print >> fp, ""
# Close file
fp.close()
def hprintBrowseObj( fbrowse ):
@ -325,25 +460,38 @@ def hprintBrowseObj( fbrowse ):
print >> fp, "int %s(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);" % fbrowse
fp.close()
def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, parentname, dmparam):
def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, parentname, dmparam, value):
# Open file
fp = open('./.getstevalue.c', 'a')
if mappingparam != "false":
# Generate Validate value
validate_value = ""
if setvalue != "NULL":
validate_value = generate_validate_value(dmparam, value)
# Mapping exist
if mappingparam != None:
count = len(mappingparam)
i = 0
header = ""
mapping = ""
tmpgetvalue = ""
tmpsetvalue = ""
set_value = ""
for element in mappingparam:
type, res1, res2, res3, res4, res5 =get_mapping_param(element)
type, res1, res2, res3, res4, res5 = get_mapping_param(element)
get_value = ""
i += 1
############################## UCI ########################################
if type == "uci":
if res3 != "false":
header = "%s:%s/%s,%s/%s" % (type.upper(), res1, res2, res3, res5)
### Mapping Parameter
if res3 != None:
mapping = "%s:%s/%s,%s/%s" % (type.upper(), res1, res2, res3, res5)
else:
header = "%s:%s/%s,%s/%s" % (type.upper(), res1, res2, res4, res5)
########################## GET VALUE ###############################################
mapping = "%s:%s/%s,%s/%s" % (type.upper(), res1, res2, res4, res5)
### GET VALUE Parameter
if "NumberOfEntries" in dmparam:
get_value += " struct uci_section *s = NULL;\n"
get_value += " int cnt = 0;\n"
@ -357,15 +505,10 @@ def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, par
else:
get_value += " dmuci_get_option_value_string(\"%s\", \"%s\", \"%s\", value);" % (res1, res3, res5)
########################## SET VALUE ###############################################
if typeparam == "boolean":
set_value += " bool b;\n"
### SET VALUE Parameter
set_value += " switch (action) {\n"
set_value += " case VALUECHECK:\n"
if typeparam == "boolean":
set_value += " if (string_to_bool(value, &b))\n"
set_value += " return FAULT_9007;\n"
set_value += "%s\n" % validate_value
set_value += " break;\n"
set_value += " case VALUESET:\n"
if typeparam == "boolean":
@ -378,14 +521,19 @@ def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, par
set_value += " dmuci_set_value_by_section((struct uci_section *)data, \"%s\", value);" % res5
else:
set_value += " dmuci_set_value(\"%s\", \"%s\", \"%s\", value);" % (res1, res3, res5)
############################## UBUS ########################################
elif type == "ubus":
if res3!= "false" and res4 != "false":
header = "%s:%s/%s/%s,%s/%s" % (type.upper(), res1, res2, res3, res4, res5)
### Mapping Parameter
if res3 != None and res4 != None:
mapping = "%s:%s/%s/%s,%s/%s" % (type.upper(), res1, res2, res3, res4, res5)
else:
header = "%s:%s/%s//%s" % (type.upper(), res1, res2, res5)
########################## GET VALUE ###############################################
mapping = "%s:%s/%s//%s" % (type.upper(), res1, res2, res5)
### GET VALUE Parameter
get_value += " json_object *res;\n"
if res3 == "false" and res4 == "false":
if res3 == None and res4 == None:
get_value += " dmubus_call(\"%s\", \"%s\", UBUS_ARGS{}, 0, &res);\n" % (res1, res2)
else:
if i == 2 and res4 == "prev_value":
@ -411,21 +559,27 @@ def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, par
get_value += " *value = dmjson_get_value(res, 1, \"%s\");" % option[0]
if i == 2 and res4 == "@Name":
get_value += "\n }"
########################## SET VALUE ###############################################
set_value += " switch (action) {\n"
set_value += " case VALUECHECK:\n"
set_value += " break;\n"
set_value += " case VALUESET:\n"
set_value += " //TODO"
### SET VALUE Parameter
set_value += " switch (action) {\n"
set_value += " case VALUECHECK:\n"
set_value += "%s\n" % validate_value
set_value += " break;\n"
set_value += " case VALUESET:\n"
set_value += " //TODO"
############################## CLI ########################################
elif type == "cli":
get_value += " dmcmd(\"%s\", %s, %s);" % (res1, res2, res3)
### GET VALUE Parameter
get_value += " dmcmd(\"%s\", %s, %s);" % (res1, res2, res3)
if count == 2 and i == 1:
tmpheader = header
tmpmapping = mapping
tmpgetvalue = get_value
tmpsetvalue = set_value
elif count == 2 and i == 2:
print >> fp, "/*#%s!%s&%s*/" % (parentname+dmparam, tmpheader, header)
print >> fp, "/*#%s!%s&%s*/" % (parentname+dmparam, tmpmapping, mapping)
print >> fp, "int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)" % getvalue
print >> fp, "{"
print >> fp, "%s" % tmpgetvalue
@ -443,7 +597,7 @@ def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, par
print >> fp, "}"
print >> fp, ""
else:
print >> fp, "/*#%s!%s*/" % (parentname+dmparam, header)
print >> fp, "/*#%s!%s*/" % (parentname+dmparam, mapping)
print >> fp, "int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)" % getvalue
print >> fp, "{"
print >> fp, "%s" % get_value
@ -460,6 +614,8 @@ def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, par
print >> fp, "}"
print >> fp, ""
# Mapping doesn't exist
else:
print >> fp, "int %s(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)" % getvalue
print >> fp, "{"
@ -472,6 +628,7 @@ def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, par
print >> fp, "{"
print >> fp, " switch (action) {"
print >> fp, " case VALUECHECK:"
print >> fp, "%s" % validate_value
print >> fp, " break;"
print >> fp, " case VALUESET:"
print >> fp, " //TODO"
@ -480,6 +637,8 @@ def cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, par
print >> fp, " return 0;"
print >> fp, "}"
print >> fp, ""
# Close file
fp.close()
def hprintGetSetValue(getvalue, setvalue):
@ -522,7 +681,7 @@ def printPARAMline( parentname, dmparam, value ):
else:
instance = "FALSE"
cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, parentname, dmparam)
cprintGetSetValue(getvalue, setvalue, mappingparam, instance, typeparam, parentname, dmparam, value)
hprintGetSetValue(getvalue, setvalue)
fp = open('./.objparamarray.c', 'a')
@ -577,12 +736,18 @@ def printOBJline( dmobject, value ):
fp.close()
def printusage():
print "Usage: " + sys.argv[0] + " <json data model>"
print "Usage: " + sys.argv[0] + " <json data model>" + " [Object path]"
print "Examples:"
print " - " + sys.argv[0] + " tr181.json"
print " ==> Generate the C code of all data model in tr181/ folder"
print " - " + sys.argv[0] + " tr104.json"
print " ==> Generate the C code of all data model in tr104/ folder"
print " - " + sys.argv[0] + " tr181.json" + " Device.DeviceInfo."
print " ==> Generate the C code of all data model in tr181/ folder"
print " - " + sys.argv[0] + " tr181.json" + " Device.WiFi."
print " ==> Generate the C code of all data model in tr181/ folder"
print " - " + sys.argv[0] + " tr104.json" + " Device.Services.VoiceService.{i}.Capabilities."
print " ==> Generate the C code of all data model in tr104/ folder"
def object_parse_childs( dmobject , value, nextlevel ):
hasobj = objhaschild(value)
@ -626,7 +791,7 @@ def object_parse_childs( dmobject , value, nextlevel ):
if k1 == "type" and v1 == "object":
object_parse_childs(k , v, 0)
def generatecfromobj(pobj, pvalue, pdir, nextlevel):
def generatecfromobj( pobj, pvalue, pdir, nextlevel ):
securemkdir(pdir)
removetmpfiles()
object_parse_childs(pobj, pvalue, nextlevel)
@ -662,8 +827,8 @@ def generatecfromobj(pobj, pvalue, pdir, nextlevel):
exists = os.path.isfile("./.objbrowse.c")
if exists:
print >> dmfpc, "/*************************************************************"
print >> dmfpc, " * ENTRY METHOD"
print >> dmfpc, "/*************************************************************/"
print >> dmfpc, "* ENTRY METHOD"
print >> dmfpc, "**************************************************************/"
tmpf = open("./.objbrowse.c", "r")
tmpd = tmpf.read()
tmpf.close()
@ -682,8 +847,8 @@ def generatecfromobj(pobj, pvalue, pdir, nextlevel):
exists = os.path.isfile("./.objadddel.c")
if exists:
print >> dmfpc, "/*************************************************************"
print >> dmfpc, " * ADD & DEL OBJ"
print >> dmfpc, "/*************************************************************/"
print >> dmfpc, "* ADD & DEL OBJ"
print >> dmfpc, "**************************************************************/"
tmpf = open("./.objadddel.c", "r")
tmpd = tmpf.read()
tmpf.close()
@ -702,8 +867,8 @@ def generatecfromobj(pobj, pvalue, pdir, nextlevel):
exists = os.path.isfile("./.getstevalue.c")
if exists:
print >> dmfpc, "/*************************************************************"
print >> dmfpc, " * GET & SET PARAM"
print >> dmfpc, "/*************************************************************/"
print >> dmfpc, "* GET & SET PARAM"
print >> dmfpc, "**************************************************************/"
tmpf = open("./.getstevalue.c", "r")
tmpd = tmpf.read()
tmpf.close()
@ -743,36 +908,50 @@ if (sys.argv[1]).lower() == "-h" or (sys.argv[1]).lower() == "--help":
exit(1)
model_root_name = "Root"
json_file = sys.argv[1]
json_file = sys.argv[1] # tr181.json
# load json file
with open(json_file) as file:
data = json.loads(file.read(), object_pairs_hook=OrderedDict)
if "tr181" in sys.argv[1]:
if "tr181" in sys.argv[1]: # TR181 JSON File
gendir = "tr181"
elif "tr104" in sys.argv[1]:
elif "tr104" in sys.argv[1]: # TR104 JSON File
gendir = "tr104"
elif "tr106" in sys.argv[1]:
elif "tr106" in sys.argv[1]: # TR106 JSON File
gendir = "tr106"
else:
gendir = "source_" + time.strftime("%Y-%m-%d_%H-%M-%S")
for i,(key,value) in enumerate(data.items()):
objstart = key
device = key.split(".")
dmroot = device[0]
if dmroot == None:
for obj, value in data.items():
if obj == None:
print "Wrong JSON Data model format!"
exit(1)
generatecfromobj(objstart, value, gendir, 1)
if isinstance(value,dict):
for k,v in value.items():
if isinstance(v,dict):
for k1,v1 in v.items():
if k1 == "type" and v1 == "object":
generatecfromobj(k, v, gendir, 0)
# Generate the object file if it is defined by "sys.argv[2]" argument
if (len(sys.argv) > 2):
if sys.argv[2] != obj:
if isinstance(value, dict):
for obj1, value1 in value.items():
if obj1 == sys.argv[2]:
if isinstance(value1, dict):
for obj2, value2 in value1.items():
if obj2 == "type" and value2 == "object":
generatecfromobj(obj1, value1, gendir, 0)
break
break
break
# Generate the root object tree file if amin does not exist
generatecfromobj(obj, value, gendir, 1)
# Generate the sub object tree file if amin does not exist
if isinstance(value, dict):
for obj1, value1 in value.items():
if isinstance(value1, dict):
for obj2, value2 in value1.items():
if obj2 == "type" and value2 == "object":
generatecfromobj(obj1, value1, gendir, 0)
if (os.path.isdir(gendir)):
print "Source code generated under \"./%s\" folder" % gendir

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -129,6 +129,7 @@ char *DMT_TYPE[] = {
[DMT_STRING] = "xsd:string",
[DMT_UNINT] = "xsd:unsignedInt",
[DMT_INT] = "xsd:int",
[DMT_UNLONG] = "xsd:unsignedLong",
[DMT_LONG] = "xsd:long",
[DMT_BOOL] = "xsd:boolean",
[DMT_TIME] = "xsd:dateTime",
@ -602,10 +603,10 @@ char *update_instance_without_section(int action, char **last_inst, void *argv[]
long instnbr = (long) argv[0];
if (action == INSTANCE_MODE_ALIAS) {
sprintf(buf, "[cpe-%ld]", instnbr);
snprintf(buf, sizeof(buf), "[cpe-%ld]", instnbr);
instance = dmstrdup(buf);
} else {
sprintf(buf, "%ld", instnbr);
snprintf(buf, sizeof(buf), "%ld", instnbr);
instance = dmstrdup(buf);
}
return instance;

View file

@ -11,31 +11,6 @@
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#define _XOPEN_SOURCE /* for strptime */
#include <time.h>
#include <arpa/inet.h>
#include <glob.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <dirent.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <uci.h>
#include <ctype.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <fcntl.h>
#include "dmbbf.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
char *array_notifcation_char[__MAX_notification] = {
@ -48,6 +23,48 @@ char *array_notifcation_char[__MAX_notification] = {
[notification_passive_active_lw] = "6",
};
char *Encapsulation[] = {"LLC", "VCMUX", NULL};
char *LinkType[] = {"EoA", "IPoA", "PPPoA", "CIP", "Unconfigured", NULL};
char *BridgeStandard[] = {"802.1D-2004", "802.1Q-2005", "802.1Q-2011", NULL};
char *BridgeType[] = {"ProviderNetworkPort", "CustomerNetworkPort", "CustomerEdgePort", "CustomerVLANPort", "VLANUnawarePort", NULL};
char *VendorClassIDMode[] = {"Exact", "Prefix", "Suffix", "Substring", NULL};
char *DiagnosticsState[] = {"None", "Requested", "Canceled", "Complete", "Error", NULL};
char *SupportedProtocols[] = {"HTTP", "HTTPS", NULL};
char *InstanceMode[] = {"InstanceNumber", "InstanceAlias", NULL};
char *NATProtocol[] = {"TCP", "UDP", "TCP/UDP", NULL};
char *Config[] = {"High", "Low", "Off", "Advanced", NULL};
char *Target[] = {"Drop", "Accept", "Reject", "Return", "TargetChain", NULL};
char *ServerConnectAlgorithm[] = {"DNS-SRV", "DNS", "ServerTable", "WebSocket", NULL};
char *KeepAlivePolicy[] = {"ICMP", "None", NULL};
char *DeliveryHeaderProtocol[] = {"IPv4", "IPv6", NULL};
char *KeyIdentifierGenerationPolicy[] = {"Disabled", "Provisioned", "CPE_Generated", NULL};
char *PreambleType[] = {"short", "long", "auto", NULL};
char *MFPConfig[] = {"Disabled", "Optional", "Required", NULL};
char *DuplexMode[] = {"Half", "Full", "Auto", NULL};
char *RequestedState[] = {"Idle", "Active", NULL};
char *BulkDataProtocols[] = {"Streaming", "File", "HTTP", NULL};
char *EncodingTypes[] = {"XML", "XDR", "CSV", "JSON", NULL};
char *CSVReportFormat[] = {"ParameterPerRow", "ParameterPerColumn", NULL};
char *RowTimestamp[] = {"Unix-Epoch", "ISO-8601", "None", NULL};
char *JSONReportFormat[] = {"ObjectHierarchy", "NameValuePair", NULL};
char *StaticType[] = {"Static", "Inapplicable", "PrefixDelegation", "Child", NULL};
char *ProtocolVersion[] = {"Any", "IPv4", "IPv6", NULL};
char *ServerSelectionProtocol[] = {"ICMP", "UDP Echo", NULL};
char *DHCPType[] = {"DHCPv4", "DHCPv6", NULL};
char *DropAlgorithm[] = {"RED", "DT", "WRED", "BLUE", NULL};
char *SchedulerAlgorithm[] = {"WFQ", "WRR", "SP", NULL};
char *DTMFMethod[] = {"InBand", "RFC2833", "SIPInfo", NULL};
char *ProfileEnable[] = {"Disabled", "Quiescent", "Enabled", NULL};
char *PIN[] = {"^\\d{4}|\\d{8}$", NULL};
char *DestinationAddress[] = {"^\\d+/\\d+$", NULL};
char *RegulatoryDomain[] = {"^[A-Z][A-Z][ OI]$", NULL};
char *ConformingAction[] = {"^Null$", "^Drop$", "^[0-9]|[1-5][0-9]|6[0-3]$", "^:[0-7]$", "^([0-9]|[1-5][0-9]|6[0-3]):[0-7]$", NULL};
char *IPv4Address[] = {"^((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$", NULL};
char *IPv6Address[] = {"^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$", NULL};
char *IPAddress[] = {"^((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$", "^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$", NULL};
char *MACAddress[] = {"^([0-9A-Fa-f][0-9A-Fa-f]:){5}([0-9A-Fa-f][0-9A-Fa-f])$", NULL};
void compress_spaces(char *str)
{
char *dst = str;
@ -371,9 +388,9 @@ int network_get_ipaddr(char **value, char *iface)
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", iface, String}}, 1, &res);
DM_ASSERT(res, *value = "");
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
*value = dm_ubus_get_value(jobj, 1, "address");
*value = dmjson_get_value(jobj, 1, "address");
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv6-address");
ipv6_value = dm_ubus_get_value(jobj, 1, "address");
ipv6_value = dmjson_get_value(jobj, 1, "address");
if((*value)[0] == '\0' || ipv6_value[0] == '\0') {
if ((*value)[0] == '\0')
@ -869,10 +886,9 @@ struct uci_section *get_dup_section_in_dmmap_eq(char *dmmap_package, char* secti
void synchronize_specific_config_sections_with_dmmap(char *package, char *section_type, char *dmmap_package, struct list_head *dup_list)
{
struct uci_section *s, *stmp, *dmmap_sect;
FILE *fp;
char *v, *dmmap_file_path;
char *v;
dmmap_file_path = dmmap_file_path_get(dmmap_package);
dmmap_file_path_get(dmmap_package);
uci_foreach_sections(package, section_type, s) {
/*
@ -903,10 +919,9 @@ void synchronize_specific_config_sections_with_dmmap(char *package, char *sectio
void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list)
{
struct uci_section *s, *stmp, *dmmap_sect;
FILE *fp;
char *v, *dmmap_file_path;
char *v;
dmmap_file_path = dmmap_file_path_get(dmmap_package);
dmmap_file_path_get(dmmap_package);
uci_foreach_option_eq(package, section_type, option_name, option_value, s) {
/*
@ -937,10 +952,9 @@ void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *sec
void synchronize_specific_config_sections_with_dmmap_eq_no_delete(char *package, char *section_type, char *dmmap_package, char* option_name, char* option_value, struct list_head *dup_list)
{
struct uci_section *s, *dmmap_sect;
FILE *fp;
char *v, *dmmap_file_path;
char *v;
dmmap_file_path = dmmap_file_path_get(dmmap_package);
dmmap_file_path_get(dmmap_package);
uci_foreach_option_eq(package, section_type, option_name, option_value, s) {
/*
@ -964,10 +978,9 @@ void synchronize_specific_config_sections_with_dmmap_eq_no_delete(char *package,
void synchronize_specific_config_sections_with_dmmap_cont(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list)
{
struct uci_section *s, *stmp, *dmmap_sect;
FILE *fp;
char *v, *dmmap_file_path;
char *v;
dmmap_file_path = dmmap_file_path_get(dmmap_package);
dmmap_file_path_get(dmmap_package);
uci_foreach_option_cont(package, section_type, option_name, option_value, s) {
/*
@ -999,11 +1012,10 @@ void synchronize_specific_config_sections_with_dmmap_cont(char *package, char *s
bool synchronize_multi_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, void* additional_attribute, struct list_head *dup_list)
{
struct uci_section *s, *stmp, *dmmap_sect;
FILE *fp;
char *v, *dmmap_file_path, *pack, *sect;
char *v, *pack, *sect;
bool found = false;
dmmap_file_path = dmmap_file_path_get(dmmap_package);
dmmap_file_path_get(dmmap_package);
uci_foreach_option_eq(package, section_type, option_name, option_value, s) {
found = true;
@ -1030,7 +1042,7 @@ bool synchronize_multi_config_sections_with_dmmap_eq(char *package, char *sectio
dmuci_get_value_by_section_string(s, "section_name", &v);
dmuci_get_value_by_section_string(s, "package", &pack);
dmuci_get_value_by_section_string(s, "section", &sect);
if(v!=NULL && strlen(v)>0 && strcmp(package, pack)==0 && strcmp(section_type, sect)== 0){
if (v!=NULL && strlen(v)>0 && strcmp(package, pack)==0 && strcmp(section_type, sect)== 0) {
if(get_origin_section_from_config(package, section_type, v) == NULL){
dmuci_delete_by_section(s, NULL, NULL);
}
@ -1043,11 +1055,10 @@ bool synchronize_multi_config_sections_with_dmmap_eq(char *package, char *sectio
bool synchronize_multi_config_sections_with_dmmap_eq_diff(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, char* opt_diff_name, char* opt_diff_value, void* additional_attribute, struct list_head *dup_list)
{
struct uci_section *s, *stmp, *dmmap_sect;
FILE *fp;
char *v, *dmmap_file_path, *pack, *sect, *optval;
char *v, *pack, *sect, *optval;
bool found= false;
dmmap_file_path = dmmap_file_path_get(dmmap_package);
dmmap_file_path_get(dmmap_package);
uci_foreach_option_eq(package, section_type, option_name, option_value, s) {
found = true;
@ -1101,14 +1112,13 @@ void add_sysfs_sectons_list_paramameter(struct list_head *dup_list, struct uci_s
int synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_package, char *dmmap_section, char *opt_name, char* inst_opt, struct list_head *dup_list)
{
struct uci_section *s, *stmp, *dmmap_sect;
FILE *fp;
DIR *dir;
struct dirent *ent;
char *v, *dmmap_file_path, *sysfs_rep_path, *instance= NULL;
char *v, *sysfs_rep_path, *instance= NULL;
struct sysfs_dmsection *p, *tmp;
LIST_HEAD(dup_list_no_inst);
dmmap_file_path = dmmap_file_path_get(dmmap_package);
dmmap_file_path_get(dmmap_package);
sysfs_foreach_file(sysfsrep, dir, ent) {
if(strcmp(ent->d_name, ".")==0 || strcmp(ent->d_name, "..")==0)
@ -1159,11 +1169,11 @@ void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type
{
struct uci_section* s;
uci_path_foreach_option_eq(bbfdm, dmmap_package, section_type, "section_name", section_name, s){
*dmmap_section= s;
uci_path_foreach_option_eq(bbfdm, dmmap_package, section_type, "section_name", section_name, s) {
*dmmap_section = s;
return;
}
*dmmap_section= NULL;
*dmmap_section = NULL;
}
void get_dmmap_section_of_config_section_eq(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section)
@ -1171,19 +1181,19 @@ void get_dmmap_section_of_config_section_eq(char* dmmap_package, char* section_t
struct uci_section* s;
uci_path_foreach_option_eq(bbfdm, dmmap_package, section_type, opt, value, s){
*dmmap_section= s;
*dmmap_section = s;
return;
}
*dmmap_section= NULL;
*dmmap_section = NULL;
}
void get_config_section_of_dmmap_section(char* package, char* section_type, char *section_name, struct uci_section **config_section)
{
struct uci_section* s;
uci_foreach_sections(package, section_type, s){
if(strcmp(section_name(s), section_name)==0){
*config_section= s;
uci_foreach_sections(package, section_type, s) {
if (strcmp(section_name(s), section_name) == 0) {
*config_section = s;
return;
}
}
@ -1192,9 +1202,7 @@ void get_config_section_of_dmmap_section(char* package, char* section_type, char
void check_create_dmmap_package(char *dmmap_package)
{
FILE *fp;
char *dmmap_file_path = dmmap_file_path_get(dmmap_package);
dmfree(dmmap_file_path);
}
@ -1621,16 +1629,6 @@ int copy_temporary_file_to_original_file(char *f1, char *f2)
return 1;
}
bool match(const char *string, const char *pattern)
{
regex_t re;
if (regcomp(&re, pattern, REG_EXTENDED) != 0) return 0;
int status = regexec(&re, string, 0, NULL, 0);
regfree(&re);
if (status != 0) return false;
return true;
}
static inline int char_is_valid(char c)
{
return c > 0x20 && c < 0x7f;
@ -1718,3 +1716,337 @@ int dm_time_format(time_t ts, char **dst)
*dst = dmstrdup(time_buf);
return 0;
}
bool match(const char *string, const char *pattern)
{
regex_t re;
if (regcomp(&re, pattern, REG_EXTENDED) != 0) return 0;
int status = regexec(&re, string, 0, NULL, 0);
regfree(&re);
if (status != 0) return false;
return true;
}
int dm_validate_string_length(char *value, char *min, char *max)
{
if (min != NULL && max != NULL) {
if ((strlen(value) > atoi(max)) || (strlen(value) < atoi(min))) return -1;
} else if (min != NULL && max == NULL) {
if (strlen(value) < atoi(min)) return -1;
} else if (min == NULL && max != NULL) {
if (strlen(value) > atoi(max)) return -1;
}
return 0;
}
int dm_validate_string_enumeration(char *value, char *enumeration[])
{
for (; *enumeration; enumeration++) {
if (strcmp(*enumeration, value) == 0)
return 0;
}
return -1;
}
int dm_validate_string_pattern(char *value, char *pattern[])
{
for (; *pattern; pattern++) {
if (match(value, *pattern))
return 0;
}
return -1;
}
int dm_validate_string(char *value, char *min, char *max, char *enumeration[], char *pattern[])
{
/* check size */
if (min != NULL || max != NULL) {
if (dm_validate_string_length(value, min, max))
return -1;
}
/* check enumeration */
if (enumeration != NULL) {
if (dm_validate_string_enumeration(value, enumeration))
return -1;
}
/* check pattern */
if (pattern != NULL) {
if (dm_validate_string_pattern(value, pattern))
return -1;
}
return 0;
}
int dm_validate_boolean(char *value)
{
/* check format */
if ((value[0] == '1' && value[1] == '\0') || (value[0] == '0' && value[1] == '\0')
|| (strcasecmp(value, "true") == 0) || (strcasecmp(value, "false") == 0)) {
return 0;
}
return -1;
}
int dm_validate_unsignedInt(char *value, char *min, char *max)
{
unsigned long val = 0, minval = 0, maxval = 0;
char *endval = NULL, *endmin = NULL, *endmax = NULL;
if (min) minval = strtoul(min, &endmin, 10);
if (max) maxval = strtoul(max, &endmax, 10);
/* reset errno to 0 before call */
errno = 0;
val = strtoul(value, &endval, 10);
if ((*endval != 0) || (errno != 0)) return -1;
/* check size */
if (min != NULL && max != NULL) {
if ((val > maxval) || (val < minval)) return -1;
} else if (min != NULL && max == NULL) {
if (val < minval) return -1;
} else if (min == NULL && max != NULL) {
if (val > maxval) return -1;
} else {
if ((val > (unsigned int)UINT_MAX) || (val < 0)) return -1;
}
return 0;
}
int dm_validate_int(char *value, char *min, char *max)
{
long val = 0, minval = 0, maxval = 0;
char *endval = NULL, *endmin = NULL, *endmax = NULL;
if (min) minval = strtol(min, &endmin, 10);
if (max) maxval = strtol(max, &endmax, 10);
/* reset errno to 0 before call */
errno = 0;
val = strtol(value, &endval, 10);
if ((*endval != 0) || (errno != 0)) return -1;
/* check size */
if (min != NULL && max != NULL) {
if ((val > maxval) || (val < minval)) return -1;
} else if (min != NULL && max == NULL) {
if (val < minval) return -1;
} else if (min == NULL && max != NULL) {
if (val > maxval) return -1;
} else {
if ((val > INT_MAX) || (val < INT_MIN)) return -1;
}
return 0;
}
int dm_validate_unsignedLong(char *value, char *min, char *max)
{
unsigned long val = 0, minval = 0, maxval = 0;
char *endval = NULL, *endmin = NULL, *endmax = NULL;
if (min) minval = strtoul(min, &endmin, 10);
if (max) maxval = strtoul(max, &endmax, 10);
/* reset errno to 0 before call */
errno = 0;
val = strtoul(value, &endval, 10);
if ((*endval != 0) || (errno != 0)) return -1;
/* check size */
if (min != NULL && max != NULL) {
if ((val > maxval) || (val < minval)) return -1;
} else if (min != NULL && max == NULL) {
if (val < minval) return -1;
} else if (min == NULL && max != NULL) {
if (val > maxval) return -1;
} else {
if ((val > (unsigned long)ULONG_MAX) || (val < 0)) return -1;
}
return 0;
}
int dm_validate_long(char *value, char *min, char *max)
{
long val = 0, minval = 0, maxval = 0;
char *endval = NULL, *endmin = NULL, *endmax = NULL;
if (min) minval = strtol(min, &endmin, 10);
if (max) maxval = strtol(max, &endmax, 10);
/* reset errno to 0 before call */
errno = 0;
val = strtol(value, &endval, 10);
if ((*endval != 0) || (errno != 0)) return -1;
/* check size */
if (min != NULL && max != NULL) {
if ((val > maxval) || (val < minval)) return -1;
} else if (min != NULL && max == NULL) {
if (val < minval) return -1;
} else if (min == NULL && max != NULL) {
if (val > maxval) return -1;
}
return 0;
}
int dm_validate_dateTime(char *value)
{
/* check format */
struct tm tm;
if (!(strptime(value, "%Y-%m-%dT%H:%M:%S", &tm)))
return -1;
return 0;
}
int dm_validate_hexBinary(char *value, char *min, char *max)
{
/* check format */
int i;
for (i = 0; i < strlen(value); i++) {
if (!isxdigit(value[i]))
return -1;
}
/* check size */
if (min != NULL && max != NULL) {
if (strcmp(min, max) == 0) {
if (strlen(value) != (2 * atoi(max))) return -1;
} else {
if ((strlen(value) > atoi(max)) || (strlen(value) < atoi(min))) return -1;
}
} else if (min != NULL && max == NULL) {
if (strlen(value) < atoi(min)) return -1;
} else if (min == NULL && max != NULL) {
if (strlen(value) > atoi(max)) return -1;
}
return 0;
}
int dm_validate_size_list(char *min_item, char *max_item, int nbr_item)
{
if (min_item != NULL && max_item != NULL) {
if (strcmp(min_item, max_item) == 0) {
if (nbr_item != (2 * atoi(max_item))) return -1;
} else {
if ((nbr_item > atoi(max_item)) || (nbr_item < atoi(min_item))) return -1;
}
} else if (min_item != NULL && max_item == NULL) {
if (nbr_item < atoi(min_item)) return -1;
} else if (min_item == NULL && max_item != NULL) {
if (nbr_item > atoi(max_item)) return -1;
}
return 0;
}
int dm_validate_string_list(char *value, char *min_item, char *max_item, char *max_size, char *min, char *max, char *enumeration[], char *pattern[])
{
char *pch, *pchr;
int nbr_item = 0;
/* check length of list */
if (max_size != NULL) {
if (strlen(value) > atoi(max_size))
return -1;
}
/* copy data in buffer */
char buf[strlen(value)+1];
strncpy(buf, value, sizeof(buf));
buf[strlen(value)] = '\0';
/* for each value, validate string */
for (pch = strtok_r(buf, ",", &pchr); pch != NULL; pch = strtok_r(NULL, ",", &pchr)) {
if (dm_validate_string(pch, min, max, enumeration, pattern))
return -1;
nbr_item ++;
}
/* check size of list */
if (min_item != NULL || max_item != NULL) {
if (dm_validate_size_list(min_item, max_item, nbr_item))
return -1;
}
return 0;
}
int dm_validate_unsignedInt_list(char *value, char *min_item, char *max_item, char *max_size, char *min, char *max)
{
char *pch, *pchr;
int nbr_item = 0;
/* check length of list */
if (max_size != NULL) {
if (strlen(value) > atoi(max_size))
return -1;
}
/* copy data in buffer */
char buf[strlen(value)+1];
strncpy(buf, value, sizeof(buf));
buf[strlen(value)] = '\0';
/* for each value, validate string */
for (pch = strtok_r(buf, ",", &pchr); pch != NULL; pch = strtok_r(NULL, ",", &pchr)) {
if (dm_validate_unsignedInt(pch, min, max))
return -1;
nbr_item ++;
}
/* check size of list */
if (min_item != NULL || max_item != NULL) {
if (dm_validate_size_list(min_item, max_item, nbr_item))
return -1;
}
return 0;
}
int dm_validate_int_list(char *value, char *min_item, char *max_item, char *max_size, char *min, char *max)
{
char *pch, *pchr;
int nbr_item = 0;
/* check length of list */
if (max_size != NULL) {
if (strlen(value) > atoi(max_size))
return -1;
}
/* copy data in buffer */
char buf[strlen(value)+1];
strncpy(buf, value, sizeof(buf));
buf[strlen(value)] = '\0';
/* for each value, validate string */
for (pch = strtok_r(buf, ",", &pchr); pch != NULL; pch = strtok_r(NULL, ",", &pchr)) {
if (dm_validate_int(pch, min, max))
return -1;
nbr_item ++;
}
/* check size of list */
if (min_item != NULL || max_item != NULL) {
if (dm_validate_size_list(min_item, max_item, nbr_item))
return -1;
}
return 0;
}

View file

@ -13,6 +13,7 @@
#ifndef __DM_COMMON_H
#define __DM_COMMON_H
#define _XOPEN_SOURCE /* for strptime */
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
@ -32,6 +33,7 @@
#include <assert.h>
#include <getopt.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/stat.h>
@ -52,6 +54,47 @@
#include "dmubus.h"
#include "dmjson.h"
extern char *Encapsulation[];
extern char *LinkType[];
extern char *BridgeStandard[];
extern char *BridgeType[];
extern char *VendorClassIDMode[];
extern char *DiagnosticsState[];
extern char *SupportedProtocols[];
extern char *InstanceMode[];
extern char *NATProtocol[];
extern char *Config[];
extern char *Target[];
extern char *ServerConnectAlgorithm[];
extern char *KeepAlivePolicy[];
extern char *DeliveryHeaderProtocol[];
extern char *KeyIdentifierGenerationPolicy[];
extern char *PreambleType[];
extern char *MFPConfig[];
extern char *DuplexMode[];
extern char *RequestedState[];
extern char *BulkDataProtocols[];
extern char *EncodingTypes[];
extern char *CSVReportFormat[];
extern char *RowTimestamp[];
extern char *JSONReportFormat[];
extern char *StaticType[];
extern char *ProtocolVersion[];
extern char *ServerSelectionProtocol[];
extern char *DHCPType[];
extern char *DropAlgorithm[];
extern char *SchedulerAlgorithm[];
extern char *DTMFMethod[];
extern char *ProfileEnable[];
extern char *PIN[];
extern char *DestinationAddress[];
extern char *RegulatoryDomain[];
extern char *ConformingAction[];
extern char *IPv4Address[];
extern char *IPv6Address[];
extern char *IPAddress[];
extern char *MACAddress[];
#define NVRAM_FILE "/proc/nvram/WpaKey"
#define MAX_DHCP_LEASES 256
#define MAX_PROC_ROUTING 256
@ -254,11 +297,22 @@ int copy_temporary_file_to_original_file(char *f1, char *f2);
struct uci_section *is_dmmap_section_exist(char* package, char* section);
struct uci_section *is_dmmap_section_exist_eq(char* package, char* section, char* opt, char* value);
int isfolderexist(char *folderpath);
bool match(const char *string, const char *pattern);
char * dmmap_file_path_get(const char *dmmap_package);
int dm_read_sysfs_file(const char *file, char *dst, unsigned len);
int get_net_iface_sysfs(const char *uci_iface, const char *name, char **value);
int get_net_device_sysfs(const char *uci_iface, const char *name, char **value);
char *get_device_from_wifi_iface(const char *wifi_iface, const char *wifi_section);
int dm_time_format(time_t ts, char **dst);
bool match(const char *string, const char *pattern);
int dm_validate_string(char *value, char *min, char *max, char *enumeration[], char *pattern[]);
int dm_validate_boolean(char *value);
int dm_validate_unsignedInt(char *value, char *min, char *max);
int dm_validate_int(char *value, char *min, char *max);
int dm_validate_unsignedLong(char *value, char *min, char *max);
int dm_validate_long(char *value, char *min, char *max);
int dm_validate_dateTime(char *value);
int dm_validate_hexBinary(char *value, char *min, char *max);
int dm_validate_string_list(char *value, char *min_item, char *max_item, char *max_size, char *min, char *max, char *enumeration[], char *pattern[]);
int dm_validate_unsignedInt_list(char *value, char *min_item, char *max_item, char *max_size, char *min, char *max);
int dm_validate_int_list(char *value, char *min_item, char *max_item, char *max_size, char *min, char *max);
#endif

View file

@ -11,6 +11,7 @@
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*/
#include <json-c/json.h>
#include <libubus.h>
#include "dmubus.h"
#include "dmmem.h"
@ -245,8 +246,7 @@ static void dm_ubus_cache_entry_free(struct dm_ubus_cache_entry *entry)
free(entry);
}
int dmubus_call(char *obj, char *method, struct ubus_arg u_args[],
int u_args_size, json_object **req_res)
int dmubus_call(char *obj, char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res)
{
const struct dm_ubus_req req = {
.obj = obj,

View file

@ -14,8 +14,6 @@
#ifndef __DMUBUS_H
#define __DMUBUS_H
#include <json-c/json.h>
#define UBUS_ARGS (struct ubus_arg[])
enum ubus_arg_type {
@ -29,11 +27,7 @@ struct ubus_arg {
enum ubus_arg_type type;
};
#define dm_ubus_get_value(jobj,ARGC,args...) \
dmjson_get_value(jobj, ARGC, ##args)
int dmubus_call(char *obj, char *method, struct ubus_arg u_args[],
int u_args_size, json_object **req_res);
int dmubus_call(char *obj, char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res);
int dmubus_call_set(char *obj, char *method, struct ubus_arg u_args[], int u_args_size);
void dmubus_free();

View file

@ -541,8 +541,6 @@ int dmuci_rename_section(char *package, char *section, char *value)
/**** UCI LOOKUP by section pointer ****/
int dmuci_lookup_ptr_by_section(struct uci_context *ctx, struct uci_ptr *ptr, struct uci_section *s, char *option, char *value)
{
struct uci_element *e;
if (s == NULL || s->package == NULL)
return -1;

View file

@ -181,8 +181,8 @@ int dmuci_delete_by_section_unnamed_bbfdm(struct uci_section *s, char *option, c
char * dmuci_add_section_bbfdm(char *package, char *stype, struct uci_section **s, char **value);
int dmuci_delete_bbfdm(char *package, char *section, char *option, char *value);
int dmuci_add_state_section(char *package, char *stype, struct uci_section **s, char **value);
char * dmuci_set_varstate_value(char *package, char *section, char *option, char *value);
char * dmuci_set_value_bbfdm(char *package, char *section, char *option, char *value);
char *dmuci_set_varstate_value(char *package, char *section, char *option, char *value);
char *dmuci_set_value_bbfdm(char *package, char *section, char *option, char *value);
int dmuci_delete_by_section_bbfdm(struct uci_section *s, char *option, char *value);
int dmuci_rename_section_by_section(struct uci_section *s, char *value);
int dmuci_exit_bbfdm(void);
@ -269,10 +269,9 @@ int dmuci_del_list_value_##UCI_PATH(char *package, char *section, char *option,
char * dmuci_add_section_##UCI_PATH(char *package, char *stype, struct uci_section **s, char **value)\
{\
struct uci_context *save_uci_ctx; \
char *name; \
save_uci_ctx = uci_ctx; \
uci_ctx = uci_ctx_##UCI_PATH; \
name = dmuci_add_section(package, stype, s, value); \
uci_ctx = uci_ctx_##UCI_PATH; \
char *name = dmuci_add_section(package, stype, s, value); \
uci_ctx = save_uci_ctx; \
return name; \
}\

View file

@ -1,19 +1,46 @@
#!/usr/bin/python
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Copyright (C) 2019 iopsys Software Solutions AB
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
# Copyright (C) 2020 iopsys Software Solutions AB
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
import os, sys, time, re, json
import xml.etree.ElementTree as xml
from collections import OrderedDict
from shutil import copyfile
listTypes = ["string",
"unsignedInt",
"unsignedLong",
"int",
"long",
"boolean",
"dateTime",
"hexBinary",
"base64"]
listdataTypes = ["string",
"unsignedInt",
"unsignedLong",
"int",
"long",
"boolean",
"dateTime",
"hexBinary",
"base64",
"IPAddress",
"IPv4Address",
"IPv6Address",
"IPPrefix",
"IPv4Prefix",
"IPv6Prefix",
"MACAddress",
"decimal",
"IoTDeviceType",
"IoTLevelType",
"IoTUnitType",
"IoTEnumSensorType",
"IoTEnumControlType"]
def removefile( filename ):
try:
os.remove(filename)
@ -65,61 +92,130 @@ def getparamtype( dmparam ):
ptype = "__NA__"
return ptype
def getparamrange( dmparam ):
min = None
max = None
for s in dmparam:
if s.tag == "syntax":
for c in s:
for o in c:
if o.tag == "range":
min = o.get("minInclusive")
max = o.get("maxInclusive")
break
if min == None:
min = ""
if max == None:
max = ""
return min, max
def getMinMaxEnumerationUnitPatternparam(paramtype, c):
paramvalmin = None
paramvalmax = None
paramenum = None
paramunit = None
parampattern = None
if paramtype == "string" or paramtype == "hexBinary" or paramtype == "base64":
for cc in c:
if cc.tag == "size":
paramvalmin = cc.get("minLength")
paramvalmax = cc.get("maxLength")
if cc.tag == "enumeration":
if paramenum == None:
paramenum = "\"%s\"" % cc.get('value')
else:
paramenum = "%s, \"%s\"" % (paramenum, cc.get('value'))
if cc.tag == "pattern":
if parampattern == None and cc.get('value') != "":
parampattern = "\"%s\"" % cc.get('value')
elif cc.get('value') != "":
parampattern = "%s,\"%s\"" % (parampattern, cc.get('value'))
def getparamunit( dmparam ):
unit = None
for s in dmparam:
if s.tag == "syntax":
for c in s:
for o in c:
if o.tag == "units":
unit = o.get("value")
break
if unit == None:
unit = ""
return unit
elif paramtype == "unsignedInt" or paramtype == "int" or paramtype == "unsignedLong" or paramtype == "long":
for cc in c:
if cc.tag == "range":
paramvalmin = cc.get("minInclusive")
paramvalmax = cc.get("maxInclusive")
if cc.tag == "units":
paramunit = cc.get("value")
def getparamvalues( dmparam ):
hasvalues = 0
values = ""
return paramvalmin, paramvalmax, paramenum, paramunit, parampattern
def getparamdatatyperef( datatyperef ):
paramvalmin = None
paramvalmax = None
paramenum = None
paramunit = None
parampattern = None
for d in xmlroot1:
if d.tag == "dataType" and d.get("name") == datatyperef:
if d.get("base") != "" and d.get("base") != None and d.get("name") == "Alias":
paramvalmin, paramvalmax, paramenum, paramunit, parampattern = getparamdatatyperef(d.get("base"))
else:
for dd in d:
if dd.tag in listTypes:
paramvalmin, paramvalmax, paramenum, paramunit, parampattern = getMinMaxEnumerationUnitPatternparam(dd.tag, dd)
break
if dd.tag == "size":
paramvalmin = dd.get("minLength")
paramvalmax = dd.get("maxLength")
if dd.tag == "enumeration":
if paramenum == None:
paramenum = "\"%s\"" % dd.get('value')
else:
paramenum = "%s, \"%s\"" % (paramenum, dd.get('value'))
if dd.tag == "pattern" and dd.get('value') != "":
if parampattern == None:
parampattern = "\"%s\"" % dd.get('value')
elif dd.get('value') != "":
parampattern = "%s,\"%s\"" % (parampattern, dd.get('value'))
break
return paramvalmin, paramvalmax, paramenum, paramunit, parampattern
def getparamlist( dmparam ):
minItem = None
maxItem = None
maxsize = None
minItem = dmparam.get("minItems")
maxItem = dmparam.get("maxItems")
for cc in dmparam:
if cc.tag == "size":
maxsize = cc.get("maxLength")
return minItem, maxItem, maxsize
def getparamoption( dmparam ):
datatype = None
paramvalmin = None
paramvalmax = None
paramenum = None
paramunit = None
parampattern = None
listminItem = None
listmaxItem = None
listmaxsize = None
islist = 0
for s in dmparam:
if s.tag == "syntax":
for c in s:
if c.tag == "string":
for a in c:
if a.tag == "enumeration":
hasvalues = 1
for x in c.findall('enumeration'):
if values:
values = "%s, \"%s\"" % (values, x.get('value'))
else:
values = "\"%s\"" % x.get('value')
if c.tag == "list":
islist = 1
listminItem, listmaxItem, listmaxsize = getparamlist(c)
for c in s:
datatype = c.tag if c.tag in listdataTypes else None
if datatype != None:
paramvalmin, paramvalmax, paramenum, paramunit, parampattern = getMinMaxEnumerationUnitPatternparam(datatype, c)
break
if c.tag == "dataType":
datatype = c.get("ref")
paramvalmin, paramvalmax, paramenum, paramunit, parampattern = getparamdatatyperef(c.get("ref"))
break
if islist == 0:
datatype = c.tag if c.tag in listdataTypes else None
if datatype != None:
paramvalmin, paramvalmax, paramenum, paramunit, parampattern = getMinMaxEnumerationUnitPatternparam(datatype, c)
break
if c.tag == "dataType":
datatype = c.get("ref")
paramvalmin, paramvalmax, paramenum, paramunit, parampattern = getparamdatatyperef(datatype)
break
break
return hasvalues, values
return islist, datatype, paramvalmin, paramvalmax, paramenum, paramunit, parampattern, listminItem, listmaxItem, listmaxsize
listmapping = []
def generatelistfromfile(dmobject):
obj = dmobject.get('name').split(".")
if "tr-104" in sys.argv[1]:
pathfilename = "../dmtree/tr104/voice_services.c"
elif obj[1] == "SoftwareModules" or obj[1] == "BulkData" :
pathfilename = "../dmtree/tr157/" + obj[1].lower() + ".c"
else:
pathfilename = "../dmtree/tr181/" + obj[1].lower() + ".c"
exists = os.path.isfile(pathfilename)
@ -169,15 +265,13 @@ def getobjmapping(dmobject):
def objhaschild (parentname, level, check_obj):
hasobj = 0
if check_obj == 0:
model = model2
else:
model = model1
model = model2 if check_obj == 0 else model1
for c in model:
objname = c.get('name')
if c.tag == "object" and parentname in objname and (objname.count('.') - objname.count('{i}')) == level:
hasobj = 1
break;
return hasobj
def objhasparam (dmobject):
@ -186,6 +280,7 @@ def objhasparam (dmobject):
if c.tag == "parameter":
hasparam = 1
break;
return hasparam
def printopenobject (obj):
@ -258,7 +353,7 @@ def printPARAMMaPPING (mapping):
print >> fp, "\"index\": \"%s\"" % var[1]
elif len(var) > 1:
print >> fp, "\"type\": \"%s\"," % var[0]
print >> fp, "\"name\": \"%s\"" % var[1]
print >> fp, "\"name\": \"%s\"" % var[1]
print >> fp, "}"
if len(var) > 1:
print >> fp, "\"option\": {"
@ -273,7 +368,6 @@ def printPARAMMaPPING (mapping):
print >> fp, "\"%s\": \"%s\"" % (args[0], args[1])
print >> fp, "}"
print >> fp, "\"key\": \"%s\"" % config[3]
else:
print >> fp, "\"command\": \"%s\"," % config[0]
print >> fp, "\"args\": \"%s\"" % config[1]
@ -312,6 +406,7 @@ def updatejsontmpfile ():
replace_data_in_file ("}\n},\n}\n}\n},", "}\n}\n}\n}\n},")
replace_data_in_file ("}\n}\n}\n},\n}\n},", "}\n}\n}\n}\n}\n},")
replace_data_in_file ("}\n}\n}\n}\n}\n}\n},", "}\n}\n}\n}\n}\n}\n},")
replace_data_in_file ("}\n}\n}\n},\n}\n}\n}\n},", "}\n}\n}\n}\n}\n}\n}\n},")
replace_data_in_file ("},\n]", "}\n]")
def removetmpfiles():
@ -342,51 +437,78 @@ def printOBJ( dmobject, hasobj, hasparam, bbfdm_type ):
def printPARAM( dmparam, dmobject, bbfdm_type ):
hasmapping, mapping = getparammapping(dmobject, dmparam)
ptype = getparamtype(dmparam)
min, max = getparamrange(dmparam)
unit = getparamunit(dmparam)
hasvalues, values = getparamvalues(dmparam)
if (dmparam.get('access') == "readOnly"):
access = "false"
else:
access = "true"
islist, datatype, paramvalmin, paramvalmax, paramenum, paramunit, parampattern, listminItem, listmaxItem, listmaxsize = getparamoption(dmparam)
fp = open('./.json_tmp', 'a')
print >> fp, "\"%s\" : {" % dmparam.get('name')
print >> fp, "\"type\" : \"%s\"," % ptype
print >> fp, "\"protocols\" : [%s]," % bbfdm_type
if min != "" and max != "":
print >> fp, "\"range\" : {"
print >> fp, "\"min\" : \"%s\"," % min
print >> fp, "\"max\" : \"%s\"" % max
print >> fp, "},"
elif min != "" and max == "":
print >> fp, "\"range\" : {"
print >> fp, "\"min\" : \"%s\"" % min
print >> fp, "},"
elif min == "" and max != "":
print >> fp, "\"range\" : {"
print >> fp, "\"max\" : \"%s\"" % max
print >> fp, "},"
if unit != "":
print >> fp, "\"unit\" : \"%s\"," % unit
print >> fp, "\"type\" : \"%s\"," % getparamtype(dmparam)
print >> fp, "\"read\" : true,"
if hasvalues and hasmapping:
print >> fp, "\"write\" : %s," % access
print >> fp, "\"values\": [%s]," % values
fp.close()
printPARAMMaPPING(mapping)
elif hasvalues and hasmapping == 0:
print >> fp, "\"write\" : %s," % access
print >> fp, "\"values\": [%s]" % values
print >> fp, "}"
fp.close()
elif hasvalues == 0 and hasmapping:
print >> fp, "\"write\" : %s," % access
print >> fp, "\"write\" : %s," % ("false" if dmparam.get('access') == "readOnly" else "true")
print >> fp, "\"protocols\" : [%s]," % bbfdm_type
# create list
if islist == 1:
print >> fp, "\"list\" : {"
# add datatype
print >> fp, ("\"datatype\" : \"%s\"," % datatype) if (listmaxsize != None or listminItem != None or listmaxItem != None or paramvalmin != None or paramvalmax != None or paramunit != None or paramenum != None or parampattern != None or (hasmapping and islist == 0)) else ("\"datatype\" : \"%s\"" % datatype)
if islist == 1:
# add maximum size of list
if listmaxsize != None:
print >> fp, ("\"maxsize\" : %s," % listmaxsize) if (listminItem != None or listmaxItem != None or paramvalmin != None or paramvalmax != None or paramunit != None or paramenum != None or parampattern != None) else ("\"maxsize\" : %s" % listmaxsize)
# add minimun and maximum item values
if listminItem != None and listmaxItem != None:
print >> fp, "\"item\" : {"
print >> fp, "\"min\" : %s," % listminItem
print >> fp, "\"max\" : %s" % listmaxItem
print >> fp, ("},") if (paramvalmin != None or paramvalmax != None or paramunit != None or paramenum != None or parampattern != None) else ("}")
elif listminItem != None and listmaxItem == None:
print >> fp, "\"item\" : {"
print >> fp, "\"min\" : %s" % listminItem
print >> fp, ("},") if (paramvalmin != None or paramvalmax != None or paramunit != None or paramenum != None or parampattern != None) else ("}")
elif listminItem == None and listmaxItem != None:
print >> fp, "\"item\" : {"
print >> fp, "\"max\" : %s" % listmaxItem
print >> fp, ("},") if (paramvalmin != None or paramvalmax != None or paramunit != None or paramenum != None or parampattern != None) else ("}")
# add minimun and maximum values
if paramvalmin != None and paramvalmax != None:
print >> fp, "\"range\" : {"
print >> fp, "\"min\" : %s," % paramvalmin
print >> fp, "\"max\" : %s" % paramvalmax
print >> fp, ("},") if (paramunit != None or paramenum != None or parampattern != None or (hasmapping and islist == 0)) else ("}")
elif paramvalmin != None and paramvalmax == None:
print >> fp, "\"range\" : {"
print >> fp, "\"min\" : %s" % paramvalmin
print >> fp, ("},") if (paramunit != None or paramenum != None or parampattern != None or (hasmapping and islist == 0)) else ("}")
elif paramvalmin == None and paramvalmax != None:
print >> fp, "\"range\" : {"
print >> fp, "\"max\" : %s" % paramvalmax
print >> fp, ("},") if (paramunit != None or paramenum != None or parampattern != None or (hasmapping and islist == 0)) else ("}")
# add unit
if paramunit != None:
print >> fp, ("\"unit\" : \"%s\"," % paramunit) if (paramenum != None or parampattern != None or (hasmapping and islist == 0)) else ("\"unit\" : \"%s\"" % paramunit)
# add enumaration
if paramenum != None:
print >> fp, ("\"enumerations\" : [%s]," % paramenum) if (parampattern != None or (hasmapping and islist == 0)) else ("\"enumerations\" : [%s]" % paramenum)
# add pattern
if parampattern != None:
print >> fp, ("\"pattern\" : [%s]," % parampattern.replace("\\", "\\\\")) if (hasmapping and islist == 0) else ("\"pattern\" : [%s]" % parampattern.replace("\\", "\\\\"))
# close list
if islist == 1:
print >> fp, ("},") if hasmapping else ("}")
# add mapping
if hasmapping:
fp.close()
printPARAMMaPPING(mapping)
else:
print >> fp, "\"write\" : %s" % access
print >> fp, "}"
fp.close()

View file

@ -1,360 +0,0 @@
#!/usr/bin/python
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Copyright (C) 2019 iopsys Software Solutions AB
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
# Copyright (C) 2019 PIVA SOFTWARE <www.pivasoftware.com> - All Rights Reserved
# Author: Mohamed Kallel <mohamed.kallel@pivasoftware.com>
import os, sys, time, re, json
import xml.etree.ElementTree as xml
from collections import OrderedDict
from shutil import copyfile
def removefile( filename ):
try:
os.remove(filename)
except OSError:
pass
def securemkdir( folder ):
try:
os.mkdir(folder)
except:
pass
def getname( objname ):
global model_root_name
OBJSname = objname
if (objname.count('.') > 1 and (objname.count('.') != 2 or objname.count('{i}') != 1) ):
OBJSname = objname.replace(dmroot.get('name'), "", 1)
OBJSname = OBJSname.replace("{i}", "")
OBJSname = OBJSname.replace(".", "")
if (objname.count('.') == 1):
model_root_name = OBJSname
OBJSname = "Root" + OBJSname
return OBJSname
if (objname.count('.') == 2 and objname.count('{i}') == 1):
model_root_name = OBJSname
OBJSname = "Services" + OBJSname
return OBJSname
return OBJSname;
def getparamtype( dmparam ):
ptype = None
for s in dmparam:
if s.tag == "syntax":
for c in s:
if c.tag == "list":
ptype = "string"
break
if c.tag == "dataType":
reftype = c.get("ref")
if "StatsCounter" in reftype:
ptype = "unsignedInt"
break
ptype = "string"
break
ptype = c.tag
break
break
if ptype == None:
ptype = "__NA__"
return ptype
def getparamrange( dmparam ):
min = None
max = None
for s in dmparam:
if s.tag == "syntax":
for c in s:
for o in c:
if o.tag == "range":
min = o.get("minInclusive")
max = o.get("maxInclusive")
break
if min == None:
min = ""
if max == None:
max = ""
return min, max
def getparamunit( dmparam ):
unit = None
for s in dmparam:
if s.tag == "syntax":
for c in s:
for o in c:
if o.tag == "units":
unit = o.get("value")
break
if unit == None:
unit = ""
return unit
def getparamvalues( dmparam ):
hasvalues = 0
values = ""
for s in dmparam:
if s.tag == "syntax":
for c in s:
if c.tag == "string":
for a in c:
if a.tag == "enumeration":
hasvalues = 1
for x in c.findall('enumeration'):
if values:
values = "%s, \"%s\"" % (values, x.get('value'))
else:
values = "\"%s\"" % x.get('value')
break
break
return hasvalues, values
def objhaschild (parentname, level):
hasobj = 0
for c in model:
objname = c.get('name')
if c.tag == "object" and parentname in objname and (objname.count('.') - objname.count('{i}')) == level:
hasobj = 1
break;
return hasobj
def objhasparam (dmobject):
hasparam = 0
for c in dmobject:
if c.tag == "parameter":
hasparam = 1
break;
return hasparam
def printopenobject (obj):
fp = open('./.json_tmp', 'a')
print >> fp, "\"%s\" : {" % obj.get('name')
fp.close()
def printopenfile ():
fp = open('./.json_tmp', 'a')
print >> fp, "{"
fp.close()
def printclosefile ():
fp = open('./.json_tmp', 'a')
print >> fp, "}"
fp.close()
def removelastline ():
file = open("./.json_tmp")
lines = file.readlines()
lines = lines[:-1]
file.close()
w = open("./.json_tmp",'w')
w.writelines(lines)
w.close()
printclosefile ()
def replace_data_in_file( data_in, data_out ):
file_r = open("./.json_tmp", "rt")
file_w = open("./.json_tmp_1", "wt")
text = ''.join(file_r).replace(data_in, data_out)
file_w.write(text)
file_r.close()
file_w.close()
copyfile("./.json_tmp_1", "./.json_tmp")
removefile("./.json_tmp_1")
def updatejsontmpfile ():
replace_data_in_file ("}\n", "},\n")
replace_data_in_file ("},\n},", "}\n},")
replace_data_in_file ("}\n},\n},", "}\n}\n},")
replace_data_in_file ("}\n},\n}\n},", "}\n}\n}\n},")
replace_data_in_file ("}\n},\n}\n}\n},", "}\n}\n}\n}\n},")
replace_data_in_file ("}\n}\n}\n},\n}\n},", "}\n}\n}\n}\n}\n},")
replace_data_in_file ("}\n}\n}\n}\n}\n}\n},", "}\n}\n}\n}\n}\n}\n},")
def removetmpfiles():
removefile("./.json_tmp")
removefile("./.json_tmp_1")
def printOBJ( dmobject, hasobj, hasparam ):
if (dmobject.get('name')).endswith(".{i}."):
fbrowse = "true"
else:
fbrowse = "false"
fp = open('./.json_tmp', 'a')
print >> fp, "\"type\" : \"object\","
if (dmobject.get('access') == "readOnly"):
print >> fp, "\"access\" : \"false\","
else:
print >> fp, "\"access\" : \"true\","
if hasparam or hasobj:
print >> fp, "\"array\" : \"%s\"," % fbrowse
else:
print >> fp, "\"array\" : \"%s\"" % fbrowse
fp.close()
def printPARAM( dmparam ):
ptype = getparamtype(dmparam)
min, max = getparamrange(dmparam)
unit = getparamunit(dmparam)
hasvalues, values = getparamvalues(dmparam)
if (dmparam.get('access') == "readOnly"):
access = "false"
else:
access = "true"
fp = open('./.json_tmp', 'a')
print >> fp, "\"%s\" : {" % dmparam.get('name')
print >> fp, "\"type\" : \"%s\"," % ptype
if min != "" and max != "":
print >> fp, "\"range\" : {"
print >> fp, "\"min\" : \"%s\"," % min
print >> fp, "\"max\" : \"%s\"" % max
print >> fp, "},"
elif min != "" and max == "":
print >> fp, "\"range\" : {"
print >> fp, "\"min\" : \"%s\"" % min
print >> fp, "},"
elif min == "" and max != "":
print >> fp, "\"range\" : {"
print >> fp, "\"max\" : \"%s\"" % max
print >> fp, "},"
if unit != "":
print >> fp, "\"unit\" : \"%s\"," % unit
print >> fp, "\"read\" : \"true\","
if hasvalues:
print >> fp, "\"write\" : \"%s\"," % access
print >> fp, "\"values\": [%s]" % values
else:
print >> fp, "\"write\" : \"%s\"" % access
print >> fp, "}"
fp.close()
def printusage():
print "Usage: " + sys.argv[0] + " <xml data model> [Object path]...[Object path]"
print "Examples:"
print " - " + sys.argv[0] + " tr-181-2-13-0-cwmp-full.xml Device.WiFi."
print " ==> Generate the json file of the sub tree Device.WiFi. in wifi.json"
print " - " + sys.argv[0] + " tr-181-2-13-0-cwmp-full.xml Device.IP.Diagnostics."
print " ==> Generate the json file of the sub tree Device.IP.Diagnostics. in ipdiagnostics.json"
print " - " + sys.argv[0] + " tr-181-2-13-0-cwmp-full.xml Device.WiFi. Device.Time."
print " ==> Generate the json file of the sub tree Device.IP. and Device.WiFi. in time.json and wifi.json"
print " - " + sys.argv[0] + " tr-181-2-13-0-cwmp-full.xml Device."
print " ==> Generate the json file of all data model in rootdevice.json"
print "Example of xml data model file: https://www.broadband-forum.org/cwmp/tr-181-2-13-0-cwmp-full.xml"
def getobjectpointer( objname ):
obj = None
for c in model:
if c.tag == "object" and (c.get('name') == objname or c.get('name') == (objname + "{i}.")):
obj = c
break
return obj
def object_parse_childs( dmobject, level):
hasobj = objhaschild(dmobject.get('name'), level)
hasparam = objhasparam(dmobject)
printOBJ(dmobject, hasobj, hasparam)
if hasparam:
for c in dmobject:
paramname = c.get('name')
if c.tag == "parameter":
printPARAM(c)
if hasobj:
for c in model:
objname = c.get('name')
if c.tag == "object" and dmobject.get('name') in objname and (objname.count('.') - objname.count('{i}')) == level:
printopenobject(c)
object_parse_childs(c, level+1)
printclosefile ()
return;
def generatejsonfromobj(pobj, pdir):
securemkdir(pdir)
removetmpfiles()
dmlevel = (pobj.get('name')).count(".") - (pobj.get('name')).count("{i}.") + 1
printopenfile ()
printopenobject(pobj)
object_parse_childs(pobj, dmlevel)
dmfp = open(pdir + "/" + (getname(pobj.get('name'))).lower() + ".json", "a")
printclosefile ()
printclosefile ()
updatejsontmpfile ()
removelastline ()
with open("./.json_tmp", "r") as f:
obj = json.load(f, object_pairs_hook=OrderedDict)
dump = json.dumps(obj, indent=4)
tabs = re.sub('\n +', lambda match: '\n' + '\t' * (len(match.group().strip('\n')) / 4), dump)
try:
print >> dmfp, "%s" % tabs
dmfp.close()
except:
pass
removetmpfiles()
### main ###
if len(sys.argv) < 3:
printusage()
exit(1)
if (sys.argv[1]).lower() == "-h" or (sys.argv[1]).lower() == "--help":
printusage()
exit(1)
model_root_name = "Root"
tree = xml.parse(sys.argv[1])
xmlroot = tree.getroot()
model = xmlroot
for child in model:
if child.tag == "model":
model = child
if model.tag != "model":
print "Wrong XML Data model format!"
exit(1)
dmroot = None
for c in model:
if c.tag == "object" and c.get("name").count(".") == 1:
dmroot = c
break;
if dmroot == None:
print "Wrong XML Data model format!"
exit(1)
gendir = "source_" + time.strftime("%Y-%m-%d_%H-%M-%S")
isemptytreeargs = 1
if (len(sys.argv) > 2):
for i in range(2, len(sys.argv)):
if sys.argv[i] == "":
continue
isemptytreeargs = 0
objstart = getobjectpointer(sys.argv[i])
if objstart == None:
print "Wrong Object Name! %s" % sys.argv[i]
continue
generatejsonfromobj(objstart, gendir)
if (os.path.isdir(gendir)):
print "Json file generated under \"./%s\"" % gendir
else:
print "No json file generated!"