mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
bbf: enhance the code
- remove unused argument from dmuci_add_section() and dmuci_add_section_bbfdm() functions - use snprintf instead of dmasptintf - change function name: add_list_paramameter -> add_list_parameter
This commit is contained in:
parent
b8bd13a367
commit
18643f29b3
47 changed files with 714 additions and 859 deletions
|
|
@ -640,7 +640,7 @@ int dm_entry_upnp_update_version_configuration(struct dmctx *dmctx)
|
|||
|
||||
dmuci_get_section_type(UPNP_CFG, "@dm[0]", &tmp);
|
||||
if (!tmp || tmp[0] == '\0') {
|
||||
dmuci_add_section(UPNP_CFG, "dm", &s, &tmp);
|
||||
dmuci_add_section(UPNP_CFG, "dm", &s);
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%d", version);
|
||||
dmuci_set_value(UPNP_CFG, "@dm[0]", "current_configuration_version", buf);
|
||||
|
|
@ -693,7 +693,7 @@ int dm_entry_upnp_check_versiononchange_param(struct dmctx *pctx)
|
|||
dmuci_set_value(UPNP_CFG, p->key, "version", buf);
|
||||
}
|
||||
else {
|
||||
dmuci_add_section(UPNP_CFG, "parameter_version", &s, &tmp);
|
||||
dmuci_add_section(UPNP_CFG, "parameter_version", &s);
|
||||
if (s != NULL) {
|
||||
dmuci_set_value_by_section(s, "version", buf);
|
||||
dmuci_set_value_by_section(s, "parameter", p->name);
|
||||
|
|
@ -720,7 +720,7 @@ int upnp_state_variables_init(struct dmctx *dmctx)
|
|||
|
||||
dmuci_get_section_type(UPNP_CFG, "@dm[0]", &tmp);
|
||||
if (!tmp || tmp[0] == '\0') {
|
||||
dmuci_add_section(UPNP_CFG, "dm", &s, &tmp);
|
||||
dmuci_add_section(UPNP_CFG, "dm", &s);
|
||||
}
|
||||
dmuci_get_option_value_string(UPNP_CFG, "@dm[0]", "supported_datamodel_version", &v);
|
||||
n = atoi(v);
|
||||
|
|
|
|||
|
|
@ -357,15 +357,13 @@ static int add_obj(char *refparam, struct dmctx *ctx, void *data, char **instanc
|
|||
}
|
||||
|
||||
if(arg2 && arg3 && arg4) {
|
||||
char *inst = NULL, *sect_name = NULL, *v;
|
||||
struct uci_section *section = NULL, *dmmap = NULL;
|
||||
|
||||
check_create_dmmap_package(arg4);
|
||||
inst = get_last_instance_bbfdm(arg4, arg3, buf_instance);
|
||||
dmuci_add_section(arg2, arg3, §ion, §_name);
|
||||
char *inst = get_last_instance_bbfdm(arg4, arg3, buf_instance);
|
||||
dmuci_add_section(arg2, arg3, §ion);
|
||||
|
||||
dmuci_add_section_bbfdm(arg4, arg3, &dmmap, &v);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", sect_name);
|
||||
dmuci_add_section_bbfdm(arg4, arg3, &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(section));
|
||||
*instance = update_instance(inst, 4, dmmap, buf_instance, arg4, arg3);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
122
dmoperate.c
122
dmoperate.c
|
|
@ -297,12 +297,12 @@ static void fill_wireless_scan_results(struct dmctx *dmctx, char *radio)
|
|||
dmasprintf(&signal_stregth, "Result.%d.SignalStrength", wifi_neighbor_count);
|
||||
dmasprintf(&noise, "Result.%d.Noise", wifi_neighbor_count);
|
||||
|
||||
add_list_paramameter(dmctx, ssid, neighboring.ssid, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, bssid, neighboring.bssid, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, channel, neighboring.channel, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, frequency, neighboring.frequency, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, signal_stregth, neighboring.signal_strength, DMT_TYPE[DMT_INT], NULL, 0);
|
||||
add_list_paramameter(dmctx, noise, neighboring.noise, DMT_TYPE[DMT_INT], NULL, 0);
|
||||
add_list_parameter(dmctx, ssid, neighboring.ssid, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, bssid, neighboring.bssid, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, channel, neighboring.channel, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, frequency, neighboring.frequency, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, signal_stregth, neighboring.signal_strength, DMT_TYPE[DMT_INT], NULL, 0);
|
||||
add_list_parameter(dmctx, noise, neighboring.noise, DMT_TYPE[DMT_INT], NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -362,14 +362,14 @@ static opr_ret_t ip_diagnostics_ipping(struct dmctx *dmctx, char *path, json_obj
|
|||
ipping.minimum_response_time_detailed = get_diagnostics_option("ipping", "MinimumResponseTimeDetailed");
|
||||
ipping.maximum_response_time_detailed = get_diagnostics_option("ipping", "MaximumResponseTimeDetailed");
|
||||
|
||||
add_list_paramameter(dmctx, dmstrdup("SuccessCount"), ipping.success_count, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("FailureCount"), ipping.failure_count, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("AverageResponseTime"), ipping.average_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("MinimumResponseTime"), ipping.minimum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("MaximumResponseTime"), ipping.maximum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("AverageResponseTimeDetailed"), ipping.average_response_time_detailed, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("MinimumResponseTimeDetailed"), ipping.minimum_response_time_detailed, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("MaximumResponseTimeDetailed"), ipping.maximum_response_time_detailed, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("SuccessCount"), ipping.success_count, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("FailureCount"), ipping.failure_count, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("AverageResponseTime"), ipping.average_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("MinimumResponseTime"), ipping.minimum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("MaximumResponseTime"), ipping.maximum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("AverageResponseTimeDetailed"), ipping.average_response_time_detailed, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("MinimumResponseTimeDetailed"), ipping.minimum_response_time_detailed, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("MaximumResponseTimeDetailed"), ipping.maximum_response_time_detailed, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
@ -412,7 +412,7 @@ static opr_ret_t ip_diagnostics_traceroute(struct dmctx *dmctx, char *path, json
|
|||
alloc_uci_ctx_bbfdm();
|
||||
|
||||
traceroute.response_time = get_diagnostics_option("traceroute", "ResponseTime");
|
||||
add_list_paramameter(dmctx, dmstrdup("ResponseTime"), traceroute.response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("ResponseTime"), traceroute.response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
|
||||
uci_path_foreach_sections(bbfdm, DMMAP_DIAGNOSTIGS, "RouteHops", s) {
|
||||
dmasprintf(&host, "RouteHops.%d.Host", i);
|
||||
|
|
@ -424,10 +424,10 @@ static opr_ret_t ip_diagnostics_traceroute(struct dmctx *dmctx, char *path, json
|
|||
dmuci_get_value_by_section_string(s, "ip", &traceroute.host_address);
|
||||
dmuci_get_value_by_section_string(s, "time", &traceroute.rttimes);
|
||||
|
||||
add_list_paramameter(dmctx, host, traceroute.host_name, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, host_address, traceroute.host_address, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, errorcode, "0", DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, rttimes, traceroute.rttimes, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, host, traceroute.host_name, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, host_address, traceroute.host_address, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, errorcode, "0", DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, rttimes, traceroute.rttimes, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
@ -474,18 +474,18 @@ static opr_ret_t ip_diagnostics_download(struct dmctx *dmctx, char *path, json_o
|
|||
download.tcp_open_request_time = get_diagnostics_option("download", "TCPOpenRequestTime");
|
||||
download.tcp_open_response_time = get_diagnostics_option("download", "TCPOpenResponseTime");
|
||||
|
||||
add_list_paramameter(dmctx, dmstrdup("ROMTime"), download.romtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("BOMTime"), download.bomtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("EOMTime"), download.eomtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TestBytesReceived"), download.test_bytes_received, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TotalBytesReceived"), download.total_bytes_received, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TotalBytesSent"), download.total_bytes_sent, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TestBytesReceivedUnderFullLoading"), download.test_bytes_received_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TotalBytesReceivedUnderFullLoading"), download.total_bytes_received_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TotalBytesSentUnderFullLoading"), download.total_bytes_sent_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("PeriodOfFullLoading"), download.period_of_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TCPOpenRequestTime"), download.tcp_open_request_time, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TCPOpenResponseTime"), download.tcp_open_response_time, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("ROMTime"), download.romtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("BOMTime"), download.bomtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("EOMTime"), download.eomtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TestBytesReceived"), download.test_bytes_received, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TotalBytesReceived"), download.total_bytes_received, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TotalBytesSent"), download.total_bytes_sent, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TestBytesReceivedUnderFullLoading"), download.test_bytes_received_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TotalBytesReceivedUnderFullLoading"), download.total_bytes_received_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TotalBytesSentUnderFullLoading"), download.total_bytes_sent_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("PeriodOfFullLoading"), download.period_of_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TCPOpenRequestTime"), download.tcp_open_request_time, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TCPOpenResponseTime"), download.tcp_open_response_time, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
@ -534,18 +534,18 @@ static opr_ret_t ip_diagnostics_upload(struct dmctx *dmctx, char *path, json_obj
|
|||
upload.tcp_open_request_time = get_diagnostics_option("upload", "TCPOpenRequestTime");
|
||||
upload.tcp_open_response_time = get_diagnostics_option("upload", "TCPOpenResponseTime");
|
||||
|
||||
add_list_paramameter(dmctx, dmstrdup("ROMTime"), upload.romtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("BOMTime"), upload.bomtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("EOMTime"), upload.eomtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TestBytesSent"), upload.test_bytes_sent, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TotalBytesReceived"), upload.total_bytes_received, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TotalBytesSent"), upload.total_bytes_sent, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TestBytesSentUnderFullLoading"), upload.test_bytes_sent_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TotalBytesReceivedUnderFullLoading"), upload.total_bytes_received_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TotalBytesSentUnderFullLoading"), upload.total_bytes_sent_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("PeriodOfFullLoading"), upload.period_of_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TCPOpenRequestTime"), upload.tcp_open_request_time, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("TCPOpenResponseTime"), upload.tcp_open_response_time, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("ROMTime"), upload.romtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("BOMTime"), upload.bomtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("EOMTime"), upload.eomtime, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TestBytesSent"), upload.test_bytes_sent, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TotalBytesReceived"), upload.total_bytes_received, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TotalBytesSent"), upload.total_bytes_sent, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TestBytesSentUnderFullLoading"), upload.test_bytes_sent_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TotalBytesReceivedUnderFullLoading"), upload.total_bytes_received_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TotalBytesSentUnderFullLoading"), upload.total_bytes_sent_under_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("PeriodOfFullLoading"), upload.period_of_full_loading, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TCPOpenRequestTime"), upload.tcp_open_request_time, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("TCPOpenResponseTime"), upload.tcp_open_response_time, DMT_TYPE[DMT_TIME], NULL, 0);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
@ -596,11 +596,11 @@ static opr_ret_t ip_diagnostics_udpecho(struct dmctx *dmctx, char *path, json_ob
|
|||
udpecho.minimum_response_time = get_diagnostics_option("udpechodiag", "MinimumResponseTime");
|
||||
udpecho.maximum_response_time = get_diagnostics_option("udpechodiag", "MaximumResponseTime");
|
||||
|
||||
add_list_paramameter(dmctx, dmstrdup("SuccessCount"), udpecho.success_count, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("FailureCount"), udpecho.failure_count, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("AverageResponseTime"), udpecho.average_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("MinimumResponseTime"), udpecho.minimum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("MaximumResponseTime"), udpecho.maximum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("SuccessCount"), udpecho.success_count, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("FailureCount"), udpecho.failure_count, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("AverageResponseTime"), udpecho.average_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("MinimumResponseTime"), udpecho.minimum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("MaximumResponseTime"), udpecho.maximum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
@ -646,10 +646,10 @@ static opr_ret_t ip_diagnostics_serverselection(struct dmctx *dmctx, char *path,
|
|||
serverselection.minimum_response_time = get_diagnostics_option("serverselection", "MinimumResponseTime");
|
||||
serverselection.maximum_response_time = get_diagnostics_option("serverselection", "MaximumResponseTime");
|
||||
|
||||
add_list_paramameter(dmctx, dmstrdup("FastestHost"), serverselection.fasthost, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("AverageResponseTime"), serverselection.average_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("MinimumResponseTime"), serverselection.minimum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("MaximumResponseTime"), serverselection.maximum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("FastestHost"), serverselection.fasthost, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("AverageResponseTime"), serverselection.average_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("MinimumResponseTime"), serverselection.minimum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("MaximumResponseTime"), serverselection.maximum_response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
@ -687,7 +687,7 @@ static opr_ret_t ip_diagnostics_nslookup(struct dmctx *dmctx, char *path, json_o
|
|||
|
||||
nslookup.success_count = get_diagnostics_option("nslookup", "SuccessCount");
|
||||
char *param_success_count = dmstrdup("SuccessCount");
|
||||
add_list_paramameter(dmctx, param_success_count, nslookup.success_count, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, param_success_count, nslookup.success_count, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
|
||||
uci_path_foreach_sections(bbfdm, DMMAP_DIAGNOSTIGS, "NSLookupResult", s) {
|
||||
dmasprintf(&status, "Result.%d.Status", i);
|
||||
|
|
@ -704,12 +704,12 @@ static opr_ret_t ip_diagnostics_nslookup(struct dmctx *dmctx, char *path, json_o
|
|||
dmuci_get_value_by_section_string(s, "DNSServerIP", &nslookup.dns_server_ip);
|
||||
dmuci_get_value_by_section_string(s, "ResponseTime", &nslookup.response_time);
|
||||
|
||||
add_list_paramameter(dmctx, status, nslookup.status, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, answertype, nslookup.answer_type, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, hostname, nslookup.hostname_returned, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, ipaddress, nslookup.ip_addresses, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, dnsserverip, nslookup.dns_server_ip, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_paramameter(dmctx, responsetime, nslookup.response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
add_list_parameter(dmctx, status, nslookup.status, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, answertype, nslookup.answer_type, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, hostname, nslookup.hostname_returned, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, ipaddress, nslookup.ip_addresses, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, dnsserverip, nslookup.dns_server_ip, DMT_TYPE[DMT_STRING], NULL, 0);
|
||||
add_list_parameter(dmctx, responsetime, nslookup.response_time, DMT_TYPE[DMT_UNINT], NULL, 0);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
@ -1189,14 +1189,14 @@ void operate_list_cmds(struct dmctx *dmctx)
|
|||
param = dmstrdup(operate_helper[i].name);
|
||||
type = (char *)operate_helper[i].type;
|
||||
args = &operate_helper[i].args;
|
||||
add_list_paramameter(dmctx, param, (char *)args, type, NULL, 0);
|
||||
add_list_parameter(dmctx, param, (char *)args, type, NULL, 0);
|
||||
}
|
||||
|
||||
for (; (dynamic_operate && dynamic_operate->name); dynamic_operate++) {
|
||||
param = dmstrdup(dynamic_operate->name);
|
||||
type = (char *)dynamic_operate->type;
|
||||
args = &dynamic_operate->args;
|
||||
add_list_paramameter(dmctx, param, (char *)args, type, NULL, 0);
|
||||
add_list_parameter(dmctx, param, (char *)args, type, NULL, 0);
|
||||
}
|
||||
|
||||
if (save_pointer)dynamic_operate = save_pointer;
|
||||
|
|
|
|||
|
|
@ -272,8 +272,7 @@ int upnp_configuration_set_ipv4_defaultgateway(char *refparam, struct dmctx *ctx
|
|||
|
||||
int upnp_configuration_ipinterface_createinstance(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *value=NULL;
|
||||
char *iface_instance=NULL, ib[8], ip_name[32];
|
||||
char *iface_instance =NULL, ib[8], ip_name[32];
|
||||
char *p = ip_name;
|
||||
struct uci_section *iface_sec = NULL;
|
||||
|
||||
|
|
@ -282,7 +281,8 @@ int upnp_configuration_ipinterface_createinstance(char *refparam, struct dmctx *
|
|||
dmstrappendstr(p, "ip_interface_");
|
||||
dmstrappendstr(p, ib);
|
||||
dmstrappendend(p);
|
||||
dmuci_add_section("network", "interface", &iface_sec, &value);
|
||||
|
||||
dmuci_add_section("network", "interface", &iface_sec);
|
||||
dmuci_set_value("network", ip_name, "", "interface");
|
||||
dmuci_set_value("network", ip_name, "proto", "dhcp");
|
||||
*instance = update_instance(iface_instance, 4, iface_sec, "upnp_ip_iface_instance", "network", "interface");
|
||||
|
|
|
|||
|
|
@ -228,8 +228,8 @@ int upnp_deviceinfo_set_provisionning_code(char *refparam, struct dmctx *ctx, vo
|
|||
* MultiInstance objects browsing functions
|
||||
*
|
||||
*************************************************/
|
||||
int upnp_deviceinfo_networkinterface_createinstance(char *refparam, struct dmctx *ctx, void *data, char **instance){
|
||||
char *value = NULL;
|
||||
int upnp_deviceinfo_networkinterface_createinstance(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *iface_instance = NULL, ib[8], ip_name[32];
|
||||
char *p = ip_name;
|
||||
struct uci_section *iface_sec = NULL;
|
||||
|
|
@ -240,7 +240,8 @@ int upnp_deviceinfo_networkinterface_createinstance(char *refparam, struct dmctx
|
|||
dmstrappendstr(p, ib);
|
||||
dmstrappendend(p);
|
||||
snprintf(ib, sizeof(ib), "%d", iface_instance ? atoi(iface_instance)+1 : 1);
|
||||
dmuci_add_section("network", "interface", &iface_sec, &value);
|
||||
|
||||
dmuci_add_section("network", "interface", &iface_sec);
|
||||
dmuci_set_value("network", ip_name, "", "interface");
|
||||
dmuci_set_value("network", ip_name, "proto", "dhcp");
|
||||
*instance = update_instance(iface_instance, 4, iface_sec, "upnp_iface_int_instance", "network", "interface");
|
||||
|
|
|
|||
|
|
@ -120,14 +120,12 @@ static int browseServicesVoiceServiceCodecProfileInst(struct dmctx *dmctx, DMNOD
|
|||
**************************************************************/
|
||||
static int addObjServicesVoiceServiceVoIPProfile(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_asterisk");
|
||||
inst = get_last_instance_bbfdm("dmmap_asterisk", "sip_service_provider", "clientinstance");
|
||||
dmuci_add_section("asterisk", "sip_service_provider", &s, &value);
|
||||
char *inst = get_last_instance_bbfdm("dmmap_asterisk", "sip_service_provider", "clientinstance");
|
||||
dmuci_add_section("asterisk", "sip_service_provider", &s);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_asterisk", "sip_service_provider", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_asterisk", "sip_service_provider", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap, "clientinstance", "dmmap_asterisk", "sip_service_provider");
|
||||
return 0;
|
||||
|
|
@ -169,14 +167,12 @@ static int delObjServicesVoiceServiceVoIPProfile(char *refparam, struct dmctx *c
|
|||
|
||||
static int addObjServicesVoiceServiceCodecProfile(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_asterisk");
|
||||
inst = get_last_instance_bbfdm("dmmap_asterisk", "codec_profile", "codecprofileinstance");
|
||||
dmuci_add_section("asterisk", "codec_profile", &s, &value);
|
||||
char *inst = get_last_instance_bbfdm("dmmap_asterisk", "codec_profile", "codecprofileinstance");
|
||||
dmuci_add_section("asterisk", "codec_profile", &s);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_asterisk", "codec_profile", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_asterisk", "codec_profile", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap, "codecprofileinstance", "dmmap_asterisk", "codec_profile");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -213,14 +213,12 @@ static int delObjServicesVoiceServiceCallControlCallingFeaturesSet(char *refpara
|
|||
|
||||
static int addObjServicesVoiceServiceCallControlCallingFeaturesSetSCREJ(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_asterisk");
|
||||
inst = get_last_instance_bbfdm("dmmap_asterisk", "call_filter_rule_incoming", "screjinstance");
|
||||
dmuci_add_section("asterisk", "call_filter_rule_incoming", &s, &value);
|
||||
char *inst = get_last_instance_bbfdm("dmmap_asterisk", "call_filter_rule_incoming", "screjinstance");
|
||||
dmuci_add_section("asterisk", "call_filter_rule_incoming", &s);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_asterisk", "call_filter_rule_incoming", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_asterisk", "call_filter_rule_incoming", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap, "screjinstance", "dmmap_asterisk", "call_filter_rule_incoming");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -86,12 +86,10 @@ static int browseServicesVoiceServiceSIPNetworkFQDNServerInst(struct dmctx *dmct
|
|||
**************************************************************/
|
||||
static int addObjServicesVoiceServiceSIPClient(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *v;
|
||||
char new_sec_name[16], value[32];
|
||||
struct uci_section *dmmap = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_asterisk");
|
||||
inst = get_last_instance_bbfdm("dmmap_asterisk", "sip_service_provider", "clientinstance");
|
||||
char *inst = get_last_instance_bbfdm("dmmap_asterisk", "sip_service_provider", "clientinstance");
|
||||
snprintf(new_sec_name, sizeof(new_sec_name), "sip%d", (inst) ? atoi(inst) : 0);
|
||||
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "", "sip_service_provider");
|
||||
TR104_DEBUG("section name is [%s]. last inst = [%s]\n", new_sec_name, inst);
|
||||
|
|
@ -119,7 +117,7 @@ static int addObjServicesVoiceServiceSIPClient(char *refparam, struct dmctx *ctx
|
|||
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "is_fax", "0");
|
||||
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "transport", "udp");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_asterisk", "sip_service_provider", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_asterisk", "sip_service_provider", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", new_sec_name);
|
||||
*instance = update_instance(inst, 4, dmmap, "clientinstance", "dmmap_asterisk", "sip_service_provider");
|
||||
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ static int get_SoftwareModulesExecEnv_Alias(char *refparam, struct dmctx *ctx, v
|
|||
static int set_SoftwareModulesExecEnv_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *s = NULL, *dmmap = NULL;
|
||||
char *name, *v;
|
||||
char *name;
|
||||
int found = 0;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -238,7 +238,7 @@ static int set_SoftwareModulesExecEnv_Alias(char *refparam, struct dmctx *ctx, v
|
|||
found = 1;
|
||||
}
|
||||
if (!found) {
|
||||
dmuci_add_section_bbfdm("dmmap", "environment", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap", "environment", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "name", name);
|
||||
dmuci_set_value_by_section(dmmap, "alias", value);
|
||||
}
|
||||
|
|
@ -383,7 +383,7 @@ static int get_SoftwareModulesDeploymentUnit_Alias(char *refparam, struct dmctx
|
|||
static int set_SoftwareModulesDeploymentUnit_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *s = NULL, *dmmap = NULL;
|
||||
char *du_name, *du_env, *environment, *name, *v;
|
||||
char *du_name, *du_env, *environment, *name;
|
||||
int found = 0;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -404,7 +404,7 @@ static int set_SoftwareModulesDeploymentUnit_Alias(char *refparam, struct dmctx
|
|||
}
|
||||
}
|
||||
if (!found) {
|
||||
dmuci_add_section_bbfdm("dmmap", "deployment_unit", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap", "deployment_unit", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "name", name);
|
||||
dmuci_set_value_by_section(dmmap, "environment", environment);
|
||||
dmuci_set_value_by_section(dmmap, "alias", value);
|
||||
|
|
@ -554,7 +554,7 @@ static int get_SoftwareModulesExecutionUnit_Alias(char *refparam, struct dmctx *
|
|||
static int set_SoftwareModulesExecutionUnit_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *s = NULL, *dmmap = NULL;
|
||||
char *eu_euid, *eu_env, *environment, *euid, *v;
|
||||
char *eu_euid, *eu_env, *environment, *euid;
|
||||
int found = 0;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -575,7 +575,7 @@ static int set_SoftwareModulesExecutionUnit_Alias(char *refparam, struct dmctx *
|
|||
}
|
||||
}
|
||||
if (!found) {
|
||||
dmuci_add_section_bbfdm("dmmap", "execution_unit", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap", "execution_unit", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "euid", euid);
|
||||
dmuci_set_value_by_section(dmmap, "environment", environment);
|
||||
dmuci_set_value_by_section(dmmap, "alias", value);
|
||||
|
|
|
|||
|
|
@ -234,12 +234,11 @@ static int get_atm_status(char *refparam, struct dmctx *ctx, void *data, char *i
|
|||
*************************************************************/
|
||||
static int add_atm_link(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *instance = NULL, *atm_device = NULL, *v = NULL;
|
||||
struct uci_section *dmmap_atm = NULL;
|
||||
char atm_device[16];
|
||||
|
||||
check_create_dmmap_package("dmmap_dsl");
|
||||
instance = get_last_instance_bbfdm("dmmap_dsl", "atm-device", "atmlinkinstance");
|
||||
dmasprintf(&atm_device, "atm%d", instance ? atoi(instance) : 0);
|
||||
char *instance = get_last_instance_bbfdm("dmmap_dsl", "atm-device", "atmlinkinstance");
|
||||
snprintf(atm_device, sizeof(atm_device), "atm%d", instance ? atoi(instance) : 0);
|
||||
|
||||
dmuci_set_value("dsl", atm_device, "", "atm-device");
|
||||
dmuci_set_value("dsl", atm_device, "name", "ATM");
|
||||
|
|
@ -250,7 +249,7 @@ static int add_atm_link(char *refparam, struct dmctx *ctx, void *data, char **in
|
|||
dmuci_set_value("dsl", atm_device, "encapsulation", "llc");
|
||||
dmuci_set_value("dsl", atm_device, "qos_class", "ubr");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dsl", "atm-device", &dmmap_atm, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_dsl", "atm-device", &dmmap_atm);
|
||||
dmuci_set_value_by_section(dmmap_atm, "section_name", atm_device);
|
||||
*instancepara = update_instance(instance, 4, dmmap_atm, "atmlinkinstance", "dmmap_dsl", "atm-device");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -136,7 +136,6 @@ static int get_last_inst(char *config, char *section, char *option1, char *optio
|
|||
int instance, max = 0;
|
||||
char *tmp;
|
||||
|
||||
check_create_dmmap_package(config);
|
||||
uci_path_foreach_option_eq(bbfdm, config, section, option1, br_inst, s) {
|
||||
dmuci_get_value_by_section_string(s, option2, &tmp);
|
||||
if (tmp[0] == '\0')
|
||||
|
|
@ -312,8 +311,7 @@ static int dmmap_synchronizeBridgingBridgeVLAN(struct dmctx *dmctx, DMNODE *pare
|
|||
if (is_bridge_vlan_vid_exist(br_args->br_inst, vid)) break;
|
||||
|
||||
struct uci_section *sbr_vlan = NULL;
|
||||
char *name;
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_vlan", "bridge_vlan", &sbr_vlan, &name);
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_vlan", "bridge_vlan", &sbr_vlan);
|
||||
dmuci_set_value_by_section(sbr_vlan, "vid", vid);
|
||||
dmuci_set_value_by_section(sbr_vlan, "br_inst", br_args->br_inst);
|
||||
dmuci_set_value_by_section(sbr_vlan, "interface", section_name(br_args->bridge_sec));
|
||||
|
|
@ -371,8 +369,7 @@ static int dmmap_synchronizeBridgingBridgeVLANPort(struct dmctx *dmctx, DMNODE *
|
|||
break;
|
||||
|
||||
struct uci_section *sbr_vlanport = NULL;
|
||||
char *sbr_name;
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_vlanport", "bridge_vlanport", &sbr_vlanport, &sbr_name);
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_vlanport", "bridge_vlanport", &sbr_vlanport);
|
||||
dmuci_set_value_by_section(sbr_vlanport, "name", pch);
|
||||
dmuci_set_value_by_section(sbr_vlanport, "br_inst", br_args->br_inst);
|
||||
dmuci_set_value_by_section(sbr_vlanport, "device_name", section_name(ss));
|
||||
|
|
@ -475,8 +472,7 @@ static int dmmap_synchronizeBridgingBridgePort(struct dmctx *dmctx, DMNODE *pare
|
|||
if (strcmp(s_user, "1") != 0) {
|
||||
if (!is_bridge_port_management_in_dmmap(br_args->br_inst)) {
|
||||
struct uci_section *sbr_port = NULL;
|
||||
char *sbr_name;
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_port", "bridge_port", &sbr_port, &sbr_name);
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_port", "bridge_port", &sbr_port);
|
||||
dmuci_set_value_by_section(sbr_port, "br_inst", br_args->br_inst);
|
||||
dmuci_set_value_by_section(sbr_port, "interface", section_name(br_args->bridge_sec));
|
||||
dmuci_set_value_by_section(sbr_port, "management", "1");
|
||||
|
|
@ -500,8 +496,7 @@ static int dmmap_synchronizeBridgingBridgePort(struct dmctx *dmctx, DMNODE *pare
|
|||
}
|
||||
|
||||
struct uci_section *sbr_port = NULL;
|
||||
char *sbr_name;
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_port", "bridge_port", &sbr_port, &sbr_name);
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_port", "bridge_port", &sbr_port);
|
||||
dmuci_set_value_by_section(sbr_port, "device", pch);
|
||||
dmuci_set_value_by_section(sbr_port, "br_inst", br_args->br_inst);
|
||||
dmuci_set_value_by_section(sbr_port, "interface", section_name(br_args->bridge_sec));
|
||||
|
|
@ -529,8 +524,7 @@ static int dmmap_synchronizeBridgingBridgePort(struct dmctx *dmctx, DMNODE *pare
|
|||
}
|
||||
|
||||
struct uci_section *sbr_port = NULL;
|
||||
char *sbr_name;
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_port", "bridge_port", &sbr_port, &sbr_name);
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_port", "bridge_port", &sbr_port);
|
||||
dmuci_set_value_by_section(sbr_port, "device", ifname);
|
||||
dmuci_set_value_by_section(sbr_port, "br_inst", br_args->br_inst);
|
||||
dmuci_set_value_by_section(sbr_port, "interface", section_name(br_args->bridge_sec));
|
||||
|
|
@ -816,10 +810,10 @@ static void remove_vlanport_section(struct uci_section *vlanport_dmmap_sec, stru
|
|||
**************************************************************/
|
||||
static int addObjBridgingBridge(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char bridge_name[32], *last_inst, *v;
|
||||
struct uci_section *dmmap_bridge = NULL;
|
||||
char bridge_name[32];
|
||||
|
||||
last_inst = get_last_instance_lev2_bbfdm("network", "interface", "dmmap_network", "bridge_instance", "type", "bridge");
|
||||
char *last_inst = get_last_instance_lev2_bbfdm("network", "interface", "dmmap_network", "bridge_instance", "type", "bridge");
|
||||
snprintf(bridge_name, sizeof(bridge_name), "bridge_%d", last_inst ? atoi(last_inst)+1 : 1);
|
||||
|
||||
// Add interface bridge section
|
||||
|
|
@ -827,7 +821,7 @@ static int addObjBridgingBridge(char *refparam, struct dmctx *ctx, void *data, c
|
|||
dmuci_set_value("network", bridge_name, "type", "bridge");
|
||||
|
||||
// Add dmmap section
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_bridge, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_bridge);
|
||||
dmuci_set_value_by_section(dmmap_bridge, "section_name", bridge_name);
|
||||
dmuci_set_value_by_section(dmmap_bridge, "added_by_user", "1");
|
||||
*instance = update_instance(last_inst, 4, dmmap_bridge, "bridge_instance", "dmmap_network", "interface");
|
||||
|
|
@ -913,14 +907,13 @@ static int delObjBridgingBridge(char *refparam, struct dmctx *ctx, void *data, c
|
|||
|
||||
static int addObjBridgingBridgePort(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *br_port_s;
|
||||
char *v;
|
||||
struct uci_section *br_port_s = NULL;
|
||||
|
||||
int inst = get_last_inst("dmmap_bridge_port", "bridge_port", "br_inst", "bridge_port_instance", ((struct bridge_args *)data)->br_inst);
|
||||
dmasprintf(instance, "%d", inst+1);
|
||||
|
||||
// Add dmmap section for devices
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_port", "bridge_port", &br_port_s, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_port", "bridge_port", &br_port_s);
|
||||
dmuci_set_value_by_section(br_port_s, "br_inst", ((struct bridge_args *)data)->br_inst);
|
||||
dmuci_set_value_by_section(br_port_s, "bridge_port_instance", *instance);
|
||||
dmuci_set_value_by_section(br_port_s, "interface", section_name(((struct bridge_args *)data)->bridge_sec));
|
||||
|
|
@ -1001,20 +994,19 @@ static int delObjBridgingBridgePort(char *refparam, struct dmctx *ctx, void *dat
|
|||
static int addObjBridgingBridgeVLANPort(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s = NULL, *br_vlanport_s = NULL;
|
||||
char *s_name, *br_vlanport_name, *device_name;
|
||||
char device_name[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_bridge_vlanport");
|
||||
int inst = get_last_inst("dmmap_bridge_vlanport", "bridge_vlanport", "br_inst", "bridge_vlanport_instance", ((struct bridge_args *)data)->br_inst);
|
||||
dmasprintf(instance, "%d", inst+1);
|
||||
dmasprintf(&device_name, "br_%s_port_%s", ((struct bridge_args *)data)->br_inst, *instance);
|
||||
snprintf(device_name, sizeof(device_name), "br_%s_port_%s", ((struct bridge_args *)data)->br_inst, *instance);
|
||||
|
||||
// Add device section
|
||||
dmuci_add_section("network", "device", &s, &s_name);
|
||||
dmuci_add_section("network", "device", &s);
|
||||
dmuci_rename_section_by_section(s, device_name);
|
||||
dmuci_set_value_by_section(s, "type", "8021q");
|
||||
|
||||
// Add dmmap section
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_vlanport", "bridge_vlanport", &br_vlanport_s, &br_vlanport_name);
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_vlanport", "bridge_vlanport", &br_vlanport_s);
|
||||
dmuci_set_value_by_section(br_vlanport_s, "br_inst", ((struct bridge_args *)data)->br_inst);
|
||||
dmuci_set_value_by_section(br_vlanport_s, "bridge_vlanport_instance", *instance);
|
||||
dmuci_set_value_by_section(br_vlanport_s, "device_name", device_name);
|
||||
|
|
@ -1056,11 +1048,11 @@ static int delObjBridgingBridgeVLANPort(char *refparam, struct dmctx *ctx, void
|
|||
static int addObjBridgingBridgeVLAN(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *br_vlan_s = NULL;
|
||||
char *v;
|
||||
|
||||
int inst = get_last_inst("dmmap_bridge_vlan", "bridge_vlan", "br_inst", "bridge_vlan_instance", ((struct bridge_args *)data)->br_inst);
|
||||
dmasprintf(instance, "%d", inst+1);
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_vlan", "bridge_vlan", &br_vlan_s, &v);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_bridge_vlan", "bridge_vlan", &br_vlan_s);
|
||||
dmuci_set_value_by_section(br_vlan_s, "br_inst", ((struct bridge_args *)data)->br_inst);
|
||||
dmuci_set_value_by_section(br_vlan_s, "bridge_vlan_instance", *instance);
|
||||
dmuci_set_value_by_section(br_vlan_s, "interface", section_name(((struct bridge_args *)data)->bridge_sec));
|
||||
|
|
@ -2266,7 +2258,6 @@ static int browseBridgingBridgePortInst(struct dmctx *dmctx, DMNODE *parent_node
|
|||
struct uci_section *s = NULL, *deviceport_s = NULL;
|
||||
char *inst = NULL, *max_inst = NULL, *device;
|
||||
|
||||
check_create_dmmap_package("dmmap_bridge_port");
|
||||
dmmap_synchronizeBridgingBridgePort(dmctx, parent_node, prev_data, prev_instance);
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_args->br_inst, s) {
|
||||
get_bridge_port_device_section(s, &deviceport_s);
|
||||
|
|
@ -2294,7 +2285,6 @@ static int browseBridgingBridgeVLANInst(struct dmctx *dmctx, DMNODE *parent_node
|
|||
struct uci_section *s = NULL;
|
||||
char *inst = NULL, *max_inst = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_bridge_vlan");
|
||||
dmmap_synchronizeBridgingBridgeVLAN(dmctx, parent_node, prev_data, prev_instance);
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_vlan", "bridge_vlan", "br_inst", br_args->br_inst, s) {
|
||||
init_bridge_vlan_args(&curr_bridge_vlan_args, s, br_args->bridge_sec, br_args->br_inst);
|
||||
|
|
@ -2320,7 +2310,6 @@ static int browseBridgingBridgeVLANPortInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
struct uci_section *s = NULL, *device_s = NULL;
|
||||
char *inst = NULL, *max_inst = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_bridge_vlanport");
|
||||
dmmap_synchronizeBridgingBridgeVLANPort(dmctx, parent_node, prev_data, prev_instance);
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_vlanport", "bridge_vlanport", "br_inst", br_args->br_inst, s) {
|
||||
get_bridge_vlanport_device_section(s, &device_s);
|
||||
|
|
|
|||
|
|
@ -428,7 +428,6 @@ static int get_DeviceInfoProcessor_Alias(char *refparam, struct dmctx *ctx, void
|
|||
static int set_DeviceInfoProcessor_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *s = NULL, *dmmap = NULL;
|
||||
char *v;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
|
|
@ -440,7 +439,7 @@ static int set_DeviceInfoProcessor_Alias(char *refparam, struct dmctx *ctx, void
|
|||
dmuci_set_value_by_section_bbfdm(s, "alias", value);
|
||||
return 0;
|
||||
}
|
||||
dmuci_add_section_bbfdm("dmmap", "processor", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap", "processor", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "processor_inst", instance);
|
||||
dmuci_set_value_by_section(dmmap, "alias", value);
|
||||
break;
|
||||
|
|
@ -509,7 +508,6 @@ static int get_DeviceInfoSupportedDataModel_Alias(char *refparam, struct dmctx *
|
|||
static int set_DeviceInfoSupportedDataModel_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *s = NULL, *dmmap = NULL;
|
||||
char *v;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
|
|
@ -521,7 +519,7 @@ static int set_DeviceInfoSupportedDataModel_Alias(char *refparam, struct dmctx *
|
|||
dmuci_set_value_by_section_bbfdm(s, "alias", value);
|
||||
return 0;
|
||||
}
|
||||
dmuci_add_section_bbfdm("dmmap", "data_model", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap", "data_model", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "data_model_inst", instance);
|
||||
dmuci_set_value_by_section(dmmap, "alias", value);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -149,18 +149,16 @@ int set_section_order(char *package, char *dmpackage, char* sect_type, struct uc
|
|||
/*******************ADD-DEL OBJECT*********************/
|
||||
static int add_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *value, *v;
|
||||
char *instance;
|
||||
struct uci_section *s = NULL, *dmmap_dhcp = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcp");
|
||||
instance = get_last_instance_bbfdm("dmmap_dhcp", "dhcp", "dhcp_instance");
|
||||
dmuci_add_section("dhcp", "dhcp", &s, &value);
|
||||
char *instance = get_last_instance_bbfdm("dmmap_dhcp", "dhcp", "dhcp_instance");
|
||||
|
||||
dmuci_add_section("dhcp", "dhcp", &s);
|
||||
dmuci_set_value_by_section(s, "start", "100");
|
||||
dmuci_set_value_by_section(s, "leasetime", "12h");
|
||||
dmuci_set_value_by_section(s, "limit", "150");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp", "dhcp", &dmmap_dhcp, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp", "dhcp", &dmmap_dhcp);
|
||||
dmuci_set_value_by_section(dmmap_dhcp, "section_name", section_name(s));
|
||||
*instancepara = update_instance(instance, 4, dmmap_dhcp, "dhcp_instance", "dmmap_dhcp", "dhcp");
|
||||
return 0;
|
||||
|
|
@ -210,16 +208,15 @@ static int delete_dhcp_server(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
|
||||
static int add_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *value, *v, *instance;
|
||||
struct uci_section *s = NULL, *dmmap_dhcp_host= NULL;
|
||||
struct uci_section *s = NULL, *dmmap_dhcp_host = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcp");
|
||||
instance = get_last_instance_lev2_bbfdm("dhcp", "host", "dmmap_dhcp", "ldhcpinstance", "dhcp", ((struct dhcp_args *)data)->interface);
|
||||
dmuci_add_section("dhcp", "host", &s, &value);
|
||||
char *instance = get_last_instance_lev2_bbfdm("dhcp", "host", "dmmap_dhcp", "ldhcpinstance", "dhcp", ((struct dhcp_args *)data)->interface);
|
||||
|
||||
dmuci_add_section("dhcp", "host", &s);
|
||||
dmuci_set_value_by_section(s, "dhcp", ((struct dhcp_args *)data)->interface);
|
||||
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp", "host", &dmmap_dhcp_host, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp", "host", &dmmap_dhcp_host);
|
||||
dmuci_set_value_by_section(dmmap_dhcp_host, "section_name", section_name(s));
|
||||
dmuci_set_value_by_section(dmmap_dhcp_host, "dhcp", ((struct dhcp_args *)data)->interface);
|
||||
*instancepara = update_instance(instance, 4, dmmap_dhcp_host, "ldhcpinstance", "dmmap_dhcp", "host");
|
||||
|
|
@ -270,21 +267,21 @@ static int delete_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *da
|
|||
|
||||
static int addObjDHCPv4Client(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s, *dmmap_sect;
|
||||
char *wan_eth, *value, *wanname, *instancepara, *v;
|
||||
struct uci_section *s = NULL, *dmmap_sect = NULL;
|
||||
char *wan_eth, wanname[16];
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcp_client");
|
||||
instancepara = get_last_instance_bbfdm("dmmap_dhcp_client", "interface", "bbf_dhcpv4client_instance");
|
||||
char *inst_para = get_last_instance_bbfdm("dmmap_dhcp_client", "interface", "bbf_dhcpv4client_instance");
|
||||
dmuci_get_option_value_string("ports", "WAN", "ifname", &wan_eth);
|
||||
dmasprintf(&wanname, "%s.1", wan_eth);
|
||||
dmuci_add_section("network", "interface", &s, &value);
|
||||
snprintf(wanname, sizeof(wanname), "%s.1", wan_eth);
|
||||
|
||||
dmuci_add_section("network", "interface", &s);
|
||||
dmuci_set_value_by_section(s, "proto", "dhcp");
|
||||
dmuci_set_value_by_section(s, "ifname", wanname);
|
||||
dmuci_set_value_by_section(s, "type", "anywan");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_client", "interface", &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_client", "interface", &dmmap_sect);
|
||||
dmuci_set_value_by_section(dmmap_sect, "section_name", section_name(s));
|
||||
*instance = update_instance(instancepara, 4, dmmap_sect, "bbf_dhcpv4client_instance", "dmmap_dhcp_client", "interface");
|
||||
*instance = update_instance(inst_para, 4, dmmap_sect, "bbf_dhcpv4client_instance", "dmmap_dhcp_client", "interface");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -368,21 +365,19 @@ static int delObjDHCPv4Client(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
static int addObjDHCPv4ClientSentOption(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct dhcp_client_args *dhcp_client_args = (struct dhcp_client_args*)data;
|
||||
struct uci_section *dmmap_sect;
|
||||
struct uci_section *dmmap_sect = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
char *value, *instancepara;
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcp_client");
|
||||
instancepara = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_dhcp_client", "send_option", "bbf_dhcpv4_sentopt_instance", "section_name", section_name(dhcp_client_args->dhcp_client_conf));
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_client", "send_option", &dmmap_sect, &value);
|
||||
if(dhcp_client_args->dhcp_client_conf != NULL)
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcp_client_args->dhcp_client_conf));
|
||||
char *inst_para = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_dhcp_client", "send_option", "bbf_dhcpv4_sentopt_instance", "section_name", section_name(dhcp_client_args->dhcp_client_conf));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_client", "send_option", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcp_client_args->dhcp_client_conf));
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", "0");
|
||||
|
||||
browse_args.option = "section_name";
|
||||
browse_args.value = section_name(dhcp_client_args->dhcp_client_conf);
|
||||
|
||||
*instance = update_instance(instancepara, 6, dmmap_sect, "bbf_dhcpv4_sentopt_instance", "dmmap_dhcp_client", "send_option", check_browse_section, (void *)&browse_args);
|
||||
*instance = update_instance(inst_para, 6, dmmap_sect, "bbf_dhcpv4_sentopt_instance", "dmmap_dhcp_client", "send_option", check_browse_section, (void *)&browse_args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -417,21 +412,19 @@ static int delObjDHCPv4ClientSentOption(char *refparam, struct dmctx *ctx, void
|
|||
static int addObjDHCPv4ClientReqOption(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct dhcp_client_args *dhcp_client_args = (struct dhcp_client_args*)data;
|
||||
struct uci_section *dmmap_sect;
|
||||
struct uci_section *dmmap_sect = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
char *value, *instancepara;
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcp_client");
|
||||
instancepara = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_dhcp_client", "req_option", "bbf_dhcpv4_sentopt_instance", "section_name", section_name(dhcp_client_args->dhcp_client_conf));
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_client", "req_option", &dmmap_sect, &value);
|
||||
if(dhcp_client_args->dhcp_client_conf != NULL)
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcp_client_args->dhcp_client_conf));
|
||||
char *inst_para = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_dhcp_client", "req_option", "bbf_dhcpv4_sentopt_instance", "section_name", section_name(dhcp_client_args->dhcp_client_conf));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_client", "req_option", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcp_client_args->dhcp_client_conf));
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", "0");
|
||||
|
||||
browse_args.option = "section_name";
|
||||
browse_args.value = section_name(dhcp_client_args->dhcp_client_conf);
|
||||
|
||||
*instance = update_instance(instancepara, 6, dmmap_sect, "bbf_dhcpv4_sentopt_instance", "dmmap_dhcp_client", "req_option", check_browse_section, (void *)&browse_args);
|
||||
*instance = update_instance(inst_para, 6, dmmap_sect, "bbf_dhcpv4_sentopt_instance", "dmmap_dhcp_client", "req_option", check_browse_section, (void *)&browse_args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -464,21 +457,19 @@ static int delObjDHCPv4ClientReqOption(char *refparam, struct dmctx *ctx, void *
|
|||
static int addObjDHCPv4ServerPoolOption(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct dhcp_args *dhcp_arg = (struct dhcp_args*)data;
|
||||
struct uci_section *dmmap_sect;
|
||||
struct uci_section *dmmap_sect = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
char *value, *instancepara;
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcp");
|
||||
instancepara = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_dhcp", "servpool_option", "bbf_dhcpv4_servpool_option_instance", "section_name", section_name(dhcp_arg->dhcp_sec));
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp", "servpool_option", &dmmap_sect, &value);
|
||||
if(dhcp_arg->dhcp_sec != NULL)
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcp_arg->dhcp_sec));
|
||||
char *inst_para = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_dhcp", "servpool_option", "bbf_dhcpv4_servpool_option_instance", "section_name", section_name(dhcp_arg->dhcp_sec));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp", "servpool_option", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcp_arg->dhcp_sec));
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", "0");
|
||||
|
||||
browse_args.option = "section_name";
|
||||
browse_args.value = section_name(dhcp_arg->dhcp_sec);
|
||||
|
||||
*instance = update_instance(instancepara, 6, dmmap_sect, "bbf_dhcpv4_servpool_option_instance", "dmmap_dhcp", "servpool_option", check_browse_section, (void *)&browse_args);
|
||||
*instance = update_instance(inst_para, 6, dmmap_sect, "bbf_dhcpv4_servpool_option_instance", "dmmap_dhcp", "servpool_option", check_browse_section, (void *)&browse_args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -511,16 +502,16 @@ static int delObjDHCPv4ServerPoolOption(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int addObjDHCPv4RelayForwarding(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s, *dmmap_sect;
|
||||
char *value, *instancepara, *v;
|
||||
struct uci_section *s = NULL, *dmmap_sect = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcp_relay");
|
||||
instancepara = get_last_instance_bbfdm("dmmap_dhcp_relay", "interface", "bbf_dhcpv4relay_instance");
|
||||
dmuci_add_section("network", "interface", &s, &value);
|
||||
char *inst_para = get_last_instance_bbfdm("dmmap_dhcp_relay", "interface", "bbf_dhcpv4relay_instance");
|
||||
|
||||
dmuci_add_section("network", "interface", &s);
|
||||
dmuci_set_value_by_section(s, "proto", "relay");
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_relay", "interface", &dmmap_sect, &v);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_relay", "interface", &dmmap_sect);
|
||||
dmuci_set_value_by_section(dmmap_sect, "section_name", section_name(s));
|
||||
*instance = update_instance(instancepara, 4, dmmap_sect, "bbf_dhcpv4relay_instance", "dmmap_dhcp_relay", "interface");
|
||||
*instance = update_instance(inst_para, 4, dmmap_sect, "bbf_dhcpv4relay_instance", "dmmap_dhcp_relay", "interface");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -974,7 +965,7 @@ static int get_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *
|
|||
static int set_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *s = NULL, *dhcp_section = NULL;
|
||||
char *min, *max, *val, *local_value, *pch, *spch = NULL;
|
||||
char *min, *max, *local_value, *pch, *spch = NULL;
|
||||
unsigned int n_min, n_max, n_ip, ipexist= 0;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -1002,7 +993,7 @@ static int set_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *
|
|||
if (n_ip < n_min || n_ip > n_max)
|
||||
continue;
|
||||
|
||||
dmuci_add_section("dhcp", "host", &dhcp_section, &val);
|
||||
dmuci_add_section("dhcp", "host", &dhcp_section);
|
||||
dmuci_set_value_by_section(dhcp_section, "dhcp", ((struct dhcp_args *)data)->interface);
|
||||
dmuci_set_value_by_section(dhcp_section, "ip", pch);
|
||||
}
|
||||
|
|
@ -1387,7 +1378,7 @@ static int set_dhcp_client_alias(char *refparam, struct dmctx *ctx, void *data,
|
|||
{
|
||||
const struct client_args *args = data;
|
||||
struct uci_section *s = NULL, *dmmap = NULL;
|
||||
char *macaddr, *v;
|
||||
char *macaddr;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
|
|
@ -1400,7 +1391,7 @@ static int set_dhcp_client_alias(char *refparam, struct dmctx *ctx, void *data,
|
|||
dmuci_set_value_by_section_bbfdm(s, "alias", value);
|
||||
return 0;
|
||||
}
|
||||
dmuci_add_section_bbfdm("dmmap", "dhcpv4clients", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap", "dhcpv4clients", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "macaddr", macaddr);
|
||||
dmuci_set_value_by_section(dmmap, "alias", value);
|
||||
break;
|
||||
|
|
@ -2846,11 +2837,10 @@ static int browseDHCPv4ClientSentOptionInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
dmuci_get_value_by_section_string(dhcp_client_args->dhcp_client_conf, "sendopts", &v);
|
||||
|
||||
if (v) sentopts = strsplit(v, " ", &length);
|
||||
check_create_dmmap_package("dmmap_dhcp_client");
|
||||
for (i = 0; i < length; i++) {
|
||||
if (sentopts[i]) buf = strsplit(sentopts[i], ":", &lgh2);
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_eq("dmmap_dhcp_client", "send_option", section_name(dhcp_client_args->dhcp_client_conf), "option_tag", buf[0])) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_client", "send_option", &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_client", "send_option", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", buf[0]);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcp_client_args->dhcp_client_conf));
|
||||
}
|
||||
|
|
@ -2902,10 +2892,9 @@ static int browseDHCPv4ClientReqOptionInst(struct dmctx *dmctx, DMNODE *parent_n
|
|||
if (dhcp_client_args->dhcp_client_conf != NULL)
|
||||
dmuci_get_value_by_section_string(dhcp_client_args->dhcp_client_conf, "reqopts", &v);
|
||||
if (v) reqtopts = strsplit(v, " ", &length);
|
||||
check_create_dmmap_package("dmmap_dhcp_client");
|
||||
for (i = 0; i < length; i++) {
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_eq("dmmap_dhcp_client", "req_option", section_name(dhcp_client_args->dhcp_client_conf), "option_tag", reqtopts[i])) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_client", "req_option", &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp_client", "req_option", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", reqtopts[i]);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcp_client_args->dhcp_client_conf));
|
||||
}
|
||||
|
|
@ -2938,7 +2927,7 @@ static int browseDHCPv4ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
struct dhcp_args *curr_dhcp_args = (struct dhcp_args*)prev_data;
|
||||
struct uci_section *dmmap_sect;
|
||||
struct browse_args browse_args = {0};
|
||||
char **tagvalue = NULL, *inst, *max_inst = NULL, *optionvalue = NULL, *tmp, *tag, *value, *v;
|
||||
char **tagvalue = NULL, *inst, *max_inst = NULL, *optionvalue = NULL, *tmp, *tag, *value;
|
||||
size_t length;
|
||||
int j;
|
||||
struct dhcp_client_option_args dhcp_client_opt_args = {0};
|
||||
|
|
@ -2948,7 +2937,7 @@ static int browseDHCPv4ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
uci_foreach_element(dhcp_options_list, e) {
|
||||
tagvalue = strsplit(e->name, ",", &length);
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_eq("dmmap_dhcp", "servpool_option", section_name(curr_dhcp_args->dhcp_sec), "option_tag", tagvalue[0])) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp", "servpool_option", &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_dhcp", "servpool_option", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", tagvalue[0]);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(curr_dhcp_args->dhcp_sec));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,18 +209,17 @@ static int browseDHCPv6ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_
|
|||
struct dhcpv6_args *curr_dhcp_args = (struct dhcpv6_args*)prev_data;
|
||||
struct uci_section *dmmap_sect;
|
||||
struct browse_args browse_args = {0};
|
||||
char **tagvalue = NULL, *inst, *max_inst = NULL, *optionvalue= NULL, *tmp, *tag, *value, *v;
|
||||
char **tagvalue = NULL, *inst, *max_inst = NULL, *optionvalue= NULL, *tmp, *tag, *value;
|
||||
size_t length;
|
||||
int j;
|
||||
struct dhcpv6_client_option_args dhcp_client_opt_args = {0};
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcpv6");
|
||||
dmuci_get_value_by_section_list(curr_dhcp_args->dhcp_sec, "dhcp_option", &dhcp_options_list);
|
||||
if (dhcp_options_list != NULL) {
|
||||
uci_foreach_element(dhcp_options_list, e) {
|
||||
tagvalue= strsplit(e->name, ",", &length);
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_eq("dmmap_dhcpv6", "servpool_option", section_name(curr_dhcp_args->dhcp_sec), "option_tag", tagvalue[0])) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_dhcpv6", "servpool_option", &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_dhcpv6", "servpool_option", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", tagvalue[0]);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(curr_dhcp_args->dhcp_sec));
|
||||
}
|
||||
|
|
@ -306,18 +305,18 @@ static int browseDHCPv6ServerPoolClientIPv6PrefixInst(struct dmctx *dmctx, DMNOD
|
|||
|
||||
static int addObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s, *dmmap_sect;
|
||||
char *value, *instancepara, *v;
|
||||
struct uci_section *s = NULL, *dmmap_sect = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcpv6");
|
||||
instancepara = get_last_instance_bbfdm("dmmap_dhcpv6", "interface", "bbf_dhcpv6client_instance");
|
||||
dmuci_add_section("network", "interface", &s, &value);
|
||||
char *inst_para = get_last_instance_bbfdm("dmmap_dhcpv6", "interface", "bbf_dhcpv6client_instance");
|
||||
|
||||
dmuci_add_section("network", "interface", &s);
|
||||
dmuci_set_value_by_section(s, "proto", "dhcpv6");
|
||||
dmuci_set_value_by_section(s, "ifname", "@wan");
|
||||
dmuci_set_value_by_section(s, "type", "anywan");
|
||||
dmuci_add_section_bbfdm("dmmap_dhcpv6", "interface", &dmmap_sect, &v);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcpv6", "interface", &dmmap_sect);
|
||||
dmuci_set_value_by_section(dmmap_sect, "section_name", section_name(s));
|
||||
*instance = update_instance(instancepara, 4, dmmap_sect, "bbf_dhcpv6client_instance", "dmmap_dhcpv6", "interface");
|
||||
*instance = update_instance(inst_para, 4, dmmap_sect, "bbf_dhcpv6client_instance", "dmmap_dhcpv6", "interface");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -369,20 +368,19 @@ static int delObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
|
||||
static int addObjDHCPv6ServerPool(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *value, *v, *instancepara;
|
||||
struct uci_section *s = NULL, *dmmap_dhcp= NULL;
|
||||
struct uci_section *s = NULL, *dmmap_dhcp = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcpv6");
|
||||
instancepara = get_last_instance_bbfdm("dmmap_dhcpv6", "dhcp", "dhcpv6_serv_pool_instance");
|
||||
dmuci_add_section("dhcp", "dhcp", &s, &value);
|
||||
char *inst_para = get_last_instance_bbfdm("dmmap_dhcpv6", "dhcp", "dhcpv6_serv_pool_instance");
|
||||
|
||||
dmuci_add_section("dhcp", "dhcp", &s);
|
||||
dmuci_set_value_by_section(s, "dhcpv6", "server");
|
||||
dmuci_set_value_by_section(s, "start", "100");
|
||||
dmuci_set_value_by_section(s, "leasetime", "12h");
|
||||
dmuci_set_value_by_section(s, "limit", "150");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcpv6", "dhcp", &dmmap_dhcp, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_dhcpv6", "dhcp", &dmmap_dhcp);
|
||||
dmuci_set_value_by_section(dmmap_dhcp, "section_name", section_name(s));
|
||||
*instance = update_instance(instancepara, 4, dmmap_dhcp, "dhcpv6_serv_pool_instance", "dmmap_dhcpv6", "dhcp");
|
||||
*instance = update_instance(inst_para, 4, dmmap_dhcp, "dhcpv6_serv_pool_instance", "dmmap_dhcpv6", "dhcp");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -436,19 +434,17 @@ static int addObjDHCPv6ServerPoolOption(char *refparam, struct dmctx *ctx, void
|
|||
struct dhcpv6_args *dhcp_arg = (struct dhcpv6_args*)data;
|
||||
struct uci_section *dmmap_sect;
|
||||
struct browse_args browse_args = {0};
|
||||
char *value, *instancepara;
|
||||
|
||||
check_create_dmmap_package("dmmap_dhcpv6");
|
||||
instancepara = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_dhcpv6", "servpool_option", "bbf_dhcpv6_servpool_option_instance", "section_name", section_name(dhcp_arg->dhcp_sec));
|
||||
dmuci_add_section_bbfdm("dmmap_dhcpv6", "servpool_option", &dmmap_sect, &value);
|
||||
if (dhcp_arg->dhcp_sec != NULL)
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcp_arg->dhcp_sec));
|
||||
char *inst_para = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_dhcpv6", "servpool_option", "bbf_dhcpv6_servpool_option_instance", "section_name", section_name(dhcp_arg->dhcp_sec));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dhcpv6", "servpool_option", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(dhcp_arg->dhcp_sec));
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "option_tag", "0");
|
||||
|
||||
browse_args.option = "section_name";
|
||||
browse_args.value = section_name(dhcp_arg->dhcp_sec);
|
||||
|
||||
*instance = update_instance(instancepara, 6, dmmap_sect, "bbf_dhcpv6_servpool_option_instance", "dmmap_dhcpv6", "servpool_option", check_browse_section, (void *)&browse_args);
|
||||
*instance = update_instance(inst_para, 6, dmmap_sect, "bbf_dhcpv6_servpool_option_instance", "dmmap_dhcpv6", "servpool_option", check_browse_section, (void *)&browse_args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -949,7 +945,7 @@ static int get_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx,
|
|||
static int set_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *vendorclassidclassifier = NULL;
|
||||
char *name, res[256] = {0};
|
||||
char res[256] = {0};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
|
|
@ -961,7 +957,7 @@ static int set_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx,
|
|||
|
||||
vendorclassidclassifier = get_dhcpv6_classifier("vendorclass", ((struct dhcpv6_args *)data)->interface);
|
||||
if (!vendorclassidclassifier) {
|
||||
dmuci_add_section("dhcp", "vendorclass", &vendorclassidclassifier, &name);
|
||||
dmuci_add_section("dhcp", "vendorclass", &vendorclassidclassifier);
|
||||
dmuci_set_value_by_section(vendorclassidclassifier, "networkid", ((struct dhcpv6_args *)data)->interface);
|
||||
}
|
||||
dmuci_set_value_by_section(vendorclassidclassifier, "vendorclass", res);
|
||||
|
|
@ -988,7 +984,7 @@ static int get_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, v
|
|||
static int set_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *userclassidclassifier = NULL;
|
||||
char *name, res[256] = {0};
|
||||
char res[256] = {0};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
|
|
@ -1000,7 +996,7 @@ static int set_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, v
|
|||
|
||||
userclassidclassifier = get_dhcpv6_classifier("userclass", ((struct dhcpv6_args *)data)->interface);
|
||||
if (!userclassidclassifier) {
|
||||
dmuci_add_section("dhcp", "userclass", &userclassidclassifier, &name);
|
||||
dmuci_add_section("dhcp", "userclass", &userclassidclassifier);
|
||||
dmuci_set_value_by_section(userclassidclassifier, "networkid", ((struct dhcpv6_args *)data)->interface);
|
||||
}
|
||||
dmuci_set_value_by_section(userclassidclassifier, "userclass", res);
|
||||
|
|
@ -1162,7 +1158,7 @@ static int get_DHCPv6ServerPoolClient_Alias(char *refparam, struct dmctx *ctx, v
|
|||
static int set_DHCPv6ServerPoolClient_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *s = NULL, *dmmap = NULL;
|
||||
char *src_addr = "", *v;
|
||||
char *src_addr = "";
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
|
|
@ -1174,7 +1170,7 @@ static int set_DHCPv6ServerPoolClient_Alias(char *refparam, struct dmctx *ctx, v
|
|||
dmuci_set_value_by_section_bbfdm(s, "alias", value);
|
||||
return 0;
|
||||
}
|
||||
dmuci_add_section_bbfdm("dmmap", "dhcpv6clients", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap", "dhcpv6clients", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "srcaddr", src_addr);
|
||||
dmuci_set_value_by_section(dmmap, "alias", value);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -34,10 +34,9 @@ static int dmmap_synchronizeDNSClientRelayServer(struct dmctx *dmctx, DMNODE *pa
|
|||
struct uci_list *v;
|
||||
struct uci_element *e;
|
||||
struct uci_section *s = NULL, *sdns = NULL, *stmp, *ss;
|
||||
char *ipdns, *str, *vip = NULL, *viface, *name;
|
||||
char *ipdns, *str, *vip = NULL, *viface;
|
||||
int j, found;
|
||||
|
||||
check_create_dmmap_package("dmmap_dns");
|
||||
uci_path_foreach_sections_safe(bbfdm, "dmmap_dns", "dns_server", stmp, s) {
|
||||
dmuci_get_value_by_section_string(s, "ip", &vip);
|
||||
dmuci_get_value_by_section_string(s, "interface", &viface);
|
||||
|
|
@ -77,7 +76,7 @@ static int dmmap_synchronizeDNSClientRelayServer(struct dmctx *dmctx, DMNODE *pa
|
|||
uci_foreach_element(v, e) {
|
||||
if (is_dns_server_in_dmmap(e->name, section_name(s)))
|
||||
continue;
|
||||
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &sdns, &name);
|
||||
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &sdns);
|
||||
dmuci_set_value_by_section(sdns, "ip", e->name);
|
||||
dmuci_set_value_by_section(sdns, "interface", section_name(s));
|
||||
dmuci_set_value_by_section(sdns, "enable", "1");
|
||||
|
|
@ -91,7 +90,7 @@ static int dmmap_synchronizeDNSClientRelayServer(struct dmctx *dmctx, DMNODE *pa
|
|||
dmjson_foreach_value_in_array(jobj, arrobj, ipdns, j, 1, "dns-server") {
|
||||
if (ipdns[0] == '\0' || is_dns_server_in_dmmap(ipdns, section_name(s)))
|
||||
continue;
|
||||
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &sdns, &name);
|
||||
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &sdns);
|
||||
dmuci_set_value_by_section(sdns, "ip", ipdns);
|
||||
dmuci_set_value_by_section(sdns, "interface", section_name(s));
|
||||
dmuci_set_value_by_section(sdns, "enable", "1");
|
||||
|
|
@ -156,15 +155,15 @@ static int browseResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev
|
|||
static int add_client_server(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *v, *inst;
|
||||
|
||||
check_create_dmmap_package("dmmap_dns");
|
||||
inst = get_last_instance_bbfdm("dmmap_dns", "dns_server", "dns_server_instance");
|
||||
char *inst = get_last_instance_bbfdm("dmmap_dns", "dns_server", "dns_server_instance");
|
||||
dmuci_add_list_value("network", "lan", "dns", "0.0.0.0");
|
||||
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &s, &v);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &s);
|
||||
dmuci_set_value_by_section(s, "ip", "0.0.0.0");
|
||||
dmuci_set_value_by_section(s, "interface", "lan");
|
||||
dmuci_set_value_by_section(s, "enable", "1");
|
||||
|
||||
*instance = update_instance(inst, 4, s, "dns_server_instance", "dmmap_dns", "dns_server");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -172,15 +171,15 @@ static int add_client_server(char *refparam, struct dmctx *ctx, void *data, char
|
|||
static int add_relay_forwarding(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *v, *inst;
|
||||
|
||||
check_create_dmmap_package("dmmap_dns");
|
||||
inst = get_last_instance_bbfdm("dmmap_dns", "dns_server", "dns_server_instance");
|
||||
char *inst = get_last_instance_bbfdm("dmmap_dns", "dns_server", "dns_server_instance");
|
||||
dmuci_add_list_value("network", "lan", "dns", "0.0.0.0");
|
||||
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &s, &v);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &s);
|
||||
dmuci_set_value_by_section(s, "ip", "0.0.0.0");
|
||||
dmuci_set_value_by_section(s, "interface", "lan");
|
||||
dmuci_set_value_by_section(s, "enable", "1");
|
||||
|
||||
*instance = update_instance(inst, 4, s, "dns_server_instance", "dmmap_dns", "dns_server");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,17 +66,17 @@ static inline int init_dsl_channel(struct dsl_channel_args *args, struct uci_sec
|
|||
static struct uci_section *update_create_dmmap_dsl_line(char *curr_id)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *name, *instance;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap", "dsl_line", "id", curr_id, s) {
|
||||
return s;
|
||||
}
|
||||
if (!s) {
|
||||
dmasprintf(&instance, "%d", atoi(curr_id));
|
||||
dmuci_add_section_bbfdm("dmmap", "dsl_line", &s, &name);
|
||||
char instance[16];
|
||||
|
||||
snprintf(instance, sizeof(instance), "%d", atoi(curr_id));
|
||||
dmuci_add_section_bbfdm("dmmap", "dsl_line", &s);
|
||||
dmuci_set_value_by_section_bbfdm(s, "id", curr_id);
|
||||
dmuci_set_value_by_section_bbfdm(s, "dsl_line_instance", instance);
|
||||
dmfree(instance);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
|
@ -84,17 +84,17 @@ static struct uci_section *update_create_dmmap_dsl_line(char *curr_id)
|
|||
static struct uci_section *update_create_dmmap_dsl_channel(char *curr_id)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *name, *instance;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap", "dsl_channel", "id", curr_id, s) {
|
||||
return s;
|
||||
}
|
||||
if (!s) {
|
||||
dmasprintf(&instance, "%d", atoi(curr_id));
|
||||
dmuci_add_section_bbfdm("dmmap", "dsl_channel", &s, &name);
|
||||
char instance[16];
|
||||
|
||||
snprintf(instance, sizeof(instance), "%d", atoi(curr_id));
|
||||
dmuci_add_section_bbfdm("dmmap", "dsl_channel", &s);
|
||||
dmuci_set_value_by_section_bbfdm(s, "id", curr_id);
|
||||
dmuci_set_value_by_section_bbfdm(s, "dsl_channel_instance", instance);
|
||||
dmfree(instance);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,11 +55,10 @@ static int browseDynamicDNSClientInst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
static int dmmap_synchronizeDynamicDNSServer(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *s = NULL, *sddns = NULL, *stmp = NULL, *ss = NULL;
|
||||
char *service_name = NULL, *dmmap_service_name = NULL, *name = NULL, *retry_interval = NULL, *retry_unit = NULL;
|
||||
char *service_name = NULL, *dmmap_service_name = NULL, *retry_interval = NULL, *retry_unit = NULL;
|
||||
char *enabled = NULL, *dns_server = NULL, *use_https = NULL, *check_interval = NULL, *check_unit = NULL, *retry_count = NULL;
|
||||
int found;
|
||||
|
||||
check_create_dmmap_package("dmmap_ddns");
|
||||
uci_path_foreach_sections_safe(bbfdm, "dmmap_ddns", "ddns_server", stmp, s) {
|
||||
dmuci_get_value_by_section_string(s, "service_name", &dmmap_service_name);
|
||||
found = 0;
|
||||
|
|
@ -110,7 +109,7 @@ static int dmmap_synchronizeDynamicDNSServer(struct dmctx *dmctx, DMNODE *parent
|
|||
if (found)
|
||||
continue;
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_ddns", "ddns_server", &sddns, &name);
|
||||
dmuci_add_section_bbfdm("dmmap_ddns", "ddns_server", &sddns);
|
||||
dmuci_set_value_by_section(sddns, "section_name", section_name(s));
|
||||
dmuci_set_value_by_section(sddns, "enabled", enabled);
|
||||
dmuci_set_value_by_section(sddns, "service_name", service_name);
|
||||
|
|
@ -154,15 +153,13 @@ static int browseDynamicDNSClientHostnameInst(struct dmctx *dmctx, DMNODE *paren
|
|||
*************************************************************/
|
||||
static int addObjDynamicDNSClient(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char inst[8], *last_inst, *value, *v, *s_name;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
char s_name[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_ddns");
|
||||
last_inst = get_last_instance_bbfdm("dmmap_ddns", "service", "clientinstance");
|
||||
snprintf(inst, sizeof(inst), "%s", last_inst ? last_inst : "1");
|
||||
dmasprintf(&s_name, "Ddns_%d", atoi(inst)+1);
|
||||
char *last_inst = get_last_instance_bbfdm("dmmap_ddns", "service", "clientinstance");
|
||||
snprintf(s_name, sizeof(s_name), "Ddns_%s", last_inst ? last_inst : "1");
|
||||
|
||||
dmuci_add_section("ddns", "service", &s, &value);
|
||||
dmuci_add_section("ddns", "service", &s);
|
||||
dmuci_rename_section_by_section(s, s_name);
|
||||
dmuci_set_value_by_section(s, "enabled", "1");
|
||||
dmuci_set_value_by_section(s, "use_syslog", "0");
|
||||
|
|
@ -175,7 +172,7 @@ static int addObjDynamicDNSClient(char *refparam, struct dmctx *ctx, void *data,
|
|||
dmuci_set_value_by_section(s, "retry_unit", "value");
|
||||
dmuci_set_value_by_section(s, "ip_source", "interface");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_ddns", "service", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_ddns", "service", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
*instance = update_instance(last_inst, 4, dmmap, "clientinstance", "dmmap_ddns", "service");
|
||||
return 0;
|
||||
|
|
@ -217,14 +214,13 @@ static int delObjDynamicDNSClient(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int addObjDynamicDNSServer(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char inst[8], *last_inst, *value, *v, *s_name;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
char s_name[16];
|
||||
|
||||
check_create_dmmap_package("dmmap_ddns");
|
||||
last_inst = get_last_instance_bbfdm("dmmap_ddns", "ddns_server", "serverinstance");
|
||||
snprintf(inst, sizeof(inst), "%s", last_inst ? last_inst : "1");
|
||||
dmasprintf(&s_name, "server_%d", atoi(inst)+1);
|
||||
dmuci_add_section("ddns", "service", &s, &value);
|
||||
char *last_inst = get_last_instance_bbfdm("dmmap_ddns", "ddns_server", "serverinstance");
|
||||
snprintf(s_name, sizeof(s_name), "server_%s", last_inst ? last_inst : "1");
|
||||
|
||||
dmuci_add_section("ddns", "service", &s);
|
||||
dmuci_rename_section_by_section(s, s_name);
|
||||
dmuci_set_value_by_section(s, "service_name", s_name);
|
||||
dmuci_set_value_by_section(s, "enabled", "1");
|
||||
|
|
@ -238,7 +234,7 @@ static int addObjDynamicDNSServer(char *refparam, struct dmctx *ctx, void *data,
|
|||
dmuci_set_value_by_section(s, "retry_unit", "value");
|
||||
dmuci_set_value_by_section(s, "ip_source", "interface");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_ddns", "ddns_server", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_ddns", "ddns_server", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
*instance = update_instance(last_inst, 4, dmmap, "serverinstance", "dmmap_ddns", "ddns_server");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ static int is_name_exist_in_devices(char *name)
|
|||
static void add_new_dmmap_section(char *macaddr, char*interface, char *section_name)
|
||||
{
|
||||
struct uci_section *dmmap = NULL;
|
||||
char *v;
|
||||
dmuci_add_section_bbfdm(DMMAP, "link", &dmmap, &v);
|
||||
|
||||
dmuci_add_section_bbfdm(DMMAP, "link", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "mac", macaddr);
|
||||
dmuci_set_value_by_section(dmmap, "device", interface);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name);
|
||||
|
|
@ -336,18 +336,18 @@ static int get_linker_vlan_term(char *refparam, struct dmctx *dmctx, void *data,
|
|||
**************************************************************/
|
||||
static int addObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *v, *val, *interface_name;
|
||||
struct uci_section *s = NULL, *dmmap_link = NULL;
|
||||
char interface_name[32];
|
||||
|
||||
inst = get_last_instance_bbfdm(DMMAP, "link", "link_instance");
|
||||
dmasprintf(&interface_name, "link_%d", inst ? atoi(inst)+1 : 1);
|
||||
char *inst = get_last_instance_bbfdm(DMMAP, "link", "link_instance");
|
||||
snprintf(interface_name, sizeof(interface_name), "link_%d", inst ? atoi(inst)+1 : 1);
|
||||
|
||||
/* Add device section */
|
||||
dmuci_add_section("network", "interface", &s, &val);
|
||||
dmuci_add_section("network", "interface", &s);
|
||||
dmuci_rename_section_by_section(s, interface_name);
|
||||
|
||||
/* Add link section in dmmap file */
|
||||
dmuci_add_section_bbfdm(DMMAP, "link", &dmmap_link, &v);
|
||||
dmuci_add_section_bbfdm(DMMAP, "link", &dmmap_link);
|
||||
dmuci_set_value_by_section(dmmap_link, "section_name", interface_name);
|
||||
*instance = update_instance(inst, 4, dmmap_link, "link_instance", "dmmap", "link");
|
||||
return 0;
|
||||
|
|
@ -398,20 +398,19 @@ static int delObjEthernetLink(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
|
||||
static int addObjEthernetVLANTermination(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *device_name, *val, *v;
|
||||
struct uci_section *s = NULL, *dmmap_network = NULL;
|
||||
char device_name[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_network");
|
||||
inst = get_vlan_last_instance_bbfdm("dmmap_network", "device", "vlan_term_instance");
|
||||
dmasprintf(&device_name, "vlan_ter_%d", inst ? atoi(inst)+1 : 1);
|
||||
char *inst = get_vlan_last_instance_bbfdm("dmmap_network", "device", "vlan_term_instance");
|
||||
snprintf(device_name, sizeof(device_name), "vlan_ter_%d", inst ? atoi(inst)+1 : 1);
|
||||
|
||||
// Add device section
|
||||
dmuci_add_section("network", "device", &s, &val);
|
||||
dmuci_add_section("network", "device", &s);
|
||||
dmuci_rename_section_by_section(s, device_name);
|
||||
dmuci_set_value_by_section(s, "type", "8021q");
|
||||
|
||||
// Add device section in dmmap_network file
|
||||
dmuci_add_section_bbfdm("dmmap_network", "device", &dmmap_network, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_network", "device", &dmmap_network);
|
||||
dmuci_set_value_by_section(dmmap_network, "section_name", device_name);
|
||||
*instance = update_instance(inst, 4, dmmap_network, "vlan_term_instance", "dmmap_network", "device");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -15,12 +15,11 @@
|
|||
/***************************** Browse Functions ***********************************/
|
||||
static int browseLevelInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *s;
|
||||
char *v, *max_inst = NULL;
|
||||
struct uci_section *s = NULL;
|
||||
char *max_inst = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_firewall");
|
||||
s = is_dmmap_section_exist("dmmap_firewall", "level");
|
||||
if (!s) dmuci_add_section_bbfdm("dmmap_firewall", "level", &s, &v);
|
||||
if (!s) dmuci_add_section_bbfdm("dmmap_firewall", "level", &s);
|
||||
handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
s, "firewall_level_instance", "firewall_level_alias", "dmmap_firewall", "level");
|
||||
DM_LINK_INST_OBJ(dmctx, parent_node, s, "1");
|
||||
|
|
@ -29,12 +28,11 @@ static int browseLevelInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_
|
|||
|
||||
static int browseChainInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *s;
|
||||
char *v, *max_inst = NULL;
|
||||
struct uci_section *s = NULL;
|
||||
char *max_inst = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_firewall");
|
||||
s = is_dmmap_section_exist("dmmap_firewall", "chain");
|
||||
if (!s) dmuci_add_section_bbfdm("dmmap_firewall", "chain", &s, &v);
|
||||
if (!s) dmuci_add_section_bbfdm("dmmap_firewall", "chain", &s);
|
||||
handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
s, "firewall_chain_instance", "firewall_chain_alias", "dmmap_firewall", "chain");
|
||||
DM_LINK_INST_OBJ(dmctx, parent_node, s, "1");
|
||||
|
|
@ -63,20 +61,19 @@ static int browseRuleInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_d
|
|||
|
||||
static int add_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s, *dmmap_firewall_rule;
|
||||
char *last_inst = NULL, *sect_name = NULL, *v;
|
||||
struct uci_section *s = NULL, *dmmap_firewall_rule = NULL;
|
||||
|
||||
last_inst = get_last_instance_bbfdm("dmmap_firewall", "rule", "firewall_chain_rule_instance");
|
||||
char *last_inst = get_last_instance_bbfdm("dmmap_firewall", "rule", "firewall_chain_rule_instance");
|
||||
|
||||
dmuci_add_section("firewall", "rule", &s, §_name);
|
||||
dmuci_add_section("firewall", "rule", &s);
|
||||
dmuci_set_value_by_section(s, "name", "-");
|
||||
dmuci_set_value_by_section(s, "enabled", "0");
|
||||
dmuci_set_value_by_section(s, "dest", "");
|
||||
dmuci_set_value_by_section(s, "src", "");
|
||||
dmuci_set_value_by_section(s, "target", "DROP");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_firewall", "rule", &dmmap_firewall_rule, &v);
|
||||
dmuci_set_value_by_section(dmmap_firewall_rule, "section_name", sect_name);
|
||||
dmuci_add_section_bbfdm("dmmap_firewall", "rule", &dmmap_firewall_rule);
|
||||
dmuci_set_value_by_section(dmmap_firewall_rule, "section_name", section_name(s));
|
||||
*instance = update_instance(last_inst, 4, dmmap_firewall_rule, "firewall_chain_rule_instance", "dmmap_firewall", "rule");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,16 +78,14 @@ static int browseGRETunnelInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node
|
|||
*************************************************************/
|
||||
static int addObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
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");
|
||||
char *instance = get_last_instance_lev2_bbfdm("network", "interface", "dmmap_network", "gretunnel_instance", "proto", "gre");
|
||||
|
||||
dmuci_add_section("network", "interface", &gre_sec, &value);
|
||||
dmuci_add_section("network", "interface", &gre_sec);
|
||||
dmuci_set_value_by_section(gre_sec, "proto", "gre");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_sec, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_sec);
|
||||
dmuci_set_value_by_section(dmmap_sec, "section_name", section_name(gre_sec));
|
||||
*instancepara = update_instance(instance, 4, dmmap_sec, "gretunnel_instance", "dmmap_network", "interface");
|
||||
return 0;
|
||||
|
|
@ -135,24 +133,23 @@ static int delObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
|
||||
static int addObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *value, *v, *instance, *ifname;
|
||||
struct uci_section *greiface_sec = NULL, *dmmap_sec= NULL, *route_sec= NULL;
|
||||
struct uci_section *greiface_sec = NULL, *dmmap_sec = NULL, *route_sec = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
char ifname[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_network");
|
||||
instance= get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_network", "interface", "greiface_instance", "gre_tunnel_sect", section_name(((struct dmmap_dup *)data)->config_section));
|
||||
char *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(((struct dmmap_dup *)data)->config_section));
|
||||
dmuci_add_section("network", "interface", &greiface_sec);
|
||||
snprintf(ifname, sizeof(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);
|
||||
dmuci_add_section("network", "route", &route_sec);
|
||||
dmuci_set_value_by_section(route_sec, "interface", section_name(greiface_sec));
|
||||
|
||||
browse_args.option = "gre_tunnel_sect";
|
||||
browse_args.value = section_name(((struct dmmap_dup *)data)->config_section);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_sec, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_sec);
|
||||
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(((struct dmmap_dup *)data)->config_section));
|
||||
*instancepara = update_instance(instance, 6, dmmap_sec, "greiface_instance", "dmmap_network", "interface", check_browse_section, (void *)&browse_args);
|
||||
|
|
|
|||
|
|
@ -292,14 +292,12 @@ static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetricIn
|
|||
**************************************************************/
|
||||
static int addObjIEEE1905ALForwardingTableForwardingRule(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_forwarding_rule");
|
||||
inst = get_last_instance_bbfdm("dmmap_forwarding_rule", "forwarding_rule", "forwardingruleinstance");
|
||||
dmuci_add_section("ieee1905", "forwarding_rule", &s, &value);
|
||||
char *inst = get_last_instance_bbfdm("dmmap_forwarding_rule", "forwarding_rule", "forwardingruleinstance");
|
||||
dmuci_add_section("ieee1905", "forwarding_rule", &s);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_forwarding_rule", "forwarding_rule", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_forwarding_rule", "forwarding_rule", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap, "forwardingruleinstance", "dmmap_forwarding_rule", "forwarding_rule");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -74,16 +74,16 @@ static char *get_alias_by_section_option_condition(char *dmmap_config, char *sec
|
|||
static struct uci_section *create_dmmap_interface_stack_section(char *curr_inst)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *name;
|
||||
|
||||
check_create_dmmap_package("dmmap_interface_stack");
|
||||
uci_path_foreach_option_eq(bbfdm, "dmmap_interface_stack", "interface_stack", "interface_stack_instance", curr_inst, s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
if (!s) {
|
||||
dmuci_add_section_bbfdm("dmmap_interface_stack", "interface_stack", &s, &name);
|
||||
dmuci_add_section_bbfdm("dmmap_interface_stack", "interface_stack", &s);
|
||||
dmuci_set_value_by_section_bbfdm(s, "interface_stack_instance", curr_inst);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,22 +69,22 @@ static int get_ip_iface_sysfs(const struct uci_section *data, const char *name,
|
|||
static void create_firewall_zone_config(char *iface)
|
||||
{
|
||||
struct uci_section *s;
|
||||
char *value, *name;
|
||||
char name[16];
|
||||
|
||||
dmuci_add_section("firewall", "zone", &s, &value);
|
||||
dmasprintf(&name, "fwl_%s", iface);
|
||||
snprintf(name, sizeof(name), "fwl_%s", iface);
|
||||
|
||||
dmuci_add_section("firewall", "zone", &s);
|
||||
dmuci_set_value_by_section(s, "name", name);
|
||||
dmuci_set_value_by_section(s, "input", "DROP");
|
||||
dmuci_set_value_by_section(s, "forward", "DROP");
|
||||
dmuci_set_value_by_section(s, "output", "ACCEPT");
|
||||
dmuci_set_value_by_section(s, "network", iface);
|
||||
dmfree(name);
|
||||
}
|
||||
|
||||
static struct uci_section *update_dmmap_network_interface(char *dmmap_file_name, char *dmmap_sec_name, char *parent_section, char *section_name, char *option, char *value, bool assign)
|
||||
{
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
char *sec_name, *name, *opt_value;
|
||||
char *sec_name, *opt_value;
|
||||
|
||||
uci_path_foreach_option_eq(bbfdm, dmmap_file_name, dmmap_sec_name, "parent_section", parent_section, dmmap_section) {
|
||||
dmuci_get_value_by_section_string(dmmap_section, "section_name", &sec_name);
|
||||
|
|
@ -94,7 +94,7 @@ static struct uci_section *update_dmmap_network_interface(char *dmmap_file_name,
|
|||
}
|
||||
|
||||
if (!dmmap_section) {
|
||||
dmuci_add_section_bbfdm(dmmap_file_name, dmmap_sec_name, &dmmap_section, &name);
|
||||
dmuci_add_section_bbfdm(dmmap_file_name, dmmap_sec_name, &dmmap_section);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_section, "parent_section", parent_section);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_section, "section_name", section_name);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_section, option, value);
|
||||
|
|
@ -233,7 +233,7 @@ static void synchronize_intf_ipv6_prefix_sections_with_dmmap(void)
|
|||
static char *get_ip_interface_last_instance(char *package, char *section, char* dmmap_package, char *opt_inst)
|
||||
{
|
||||
struct uci_section *s = NULL, *dmmap_section = NULL;
|
||||
char *instance = NULL, *last_inst = NULL, *v = NULL, *proto, *ifname;
|
||||
char *instance = NULL, *last_inst = NULL, *proto, *ifname;
|
||||
|
||||
uci_foreach_sections(package, section, s) {
|
||||
|
||||
|
|
@ -247,7 +247,7 @@ static char *get_ip_interface_last_instance(char *package, char *section, char*
|
|||
|
||||
get_dmmap_section_of_config_section(dmmap_package, section, section_name(s), &dmmap_section);
|
||||
if (dmmap_section == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, section, &dmmap_section, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, section, &dmmap_section);
|
||||
dmuci_set_value_by_section(dmmap_section, "section_name", section_name(s));
|
||||
}
|
||||
instance = update_instance(last_inst, 4, dmmap_section, opt_inst, dmmap_package, section);
|
||||
|
|
@ -379,11 +379,11 @@ static void set_ip_interface_ifname_option(struct uci_section *section, char *li
|
|||
|
||||
// if device dosn't exist ==> create a new device section
|
||||
if (!device_exists) {
|
||||
char device_name[32], *val;
|
||||
char device_name[32];
|
||||
|
||||
snprintf(device_name, sizeof(device_name), "dev_ip_int_%s", instance);
|
||||
|
||||
dmuci_add_section("network", "device", &s, &val);
|
||||
dmuci_add_section("network", "device", &s);
|
||||
dmuci_rename_section_by_section(s, device_name);
|
||||
dmuci_set_value_by_section(s, "type", "untagged");
|
||||
dmuci_set_value_by_section(s, "ifname", linker);
|
||||
|
|
@ -614,16 +614,16 @@ end:
|
|||
**************************************************************/
|
||||
static int addObjIPInterface(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *last_inst = NULL, *v, ip_name[32] = {0};
|
||||
struct uci_section *dmmap_ip_interface;
|
||||
char ip_name[32] = {0};
|
||||
|
||||
last_inst = get_ip_interface_last_instance("network", "interface", "dmmap_network", "ip_int_instance");
|
||||
char *last_inst = get_ip_interface_last_instance("network", "interface", "dmmap_network", "ip_int_instance");
|
||||
snprintf(ip_name, sizeof(ip_name), "ip_interface_%d", last_inst ? atoi(last_inst) + 1 : 1);
|
||||
|
||||
dmuci_set_value("network", ip_name, "", "interface");
|
||||
dmuci_set_value("network", ip_name, "proto", "static");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_ip_interface, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_ip_interface);
|
||||
dmuci_set_value_by_section(dmmap_ip_interface, "section_name", ip_name);
|
||||
*instance = update_instance(last_inst, 4, dmmap_ip_interface, "ip_int_instance", "dmmap_network", "interface");
|
||||
return 0;
|
||||
|
|
@ -663,7 +663,7 @@ static int addObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
if (strcmp(proto, "static") != 0)
|
||||
return FAULT_9001;
|
||||
|
||||
char *last_inst = NULL, *ip_inst, *v, ipv4_name[64] = {0}, buf[32] = {0};
|
||||
char *last_inst = NULL, *ip_inst, ipv4_name[64] = {0}, buf[32] = {0};
|
||||
struct uci_section *dmmap_ip_interface = NULL, *dmmap_ip_interface_ipv4;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
|
|
@ -683,7 +683,7 @@ static int addObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
|
|||
browse_args.option = "parent_section";
|
||||
browse_args.value = section_name((struct uci_section *)data);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_network_ipv4", "intf_ipv4", &dmmap_ip_interface_ipv4, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_network_ipv4", "intf_ipv4", &dmmap_ip_interface_ipv4);
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv4, "parent_section", section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv4, "section_name", ipv4_name);
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv4, "address", "0.0.0.0");
|
||||
|
|
@ -752,7 +752,7 @@ static int addObjIPInterfaceIPv6Address(char *refparam, struct dmctx *ctx, void
|
|||
if (strcmp(proto, "static") != 0 || (strcmp(proto, "static") == 0 && interface_section_with_dhcpv6_exists(section_name((struct uci_section *)data))))
|
||||
return FAULT_9001;
|
||||
|
||||
char *last_inst = NULL, *ip_inst, *v, ipv6_name[64] = {0}, buf[32] = {0};
|
||||
char *last_inst = NULL, *ip_inst, ipv6_name[64] = {0}, buf[32] = {0};
|
||||
struct uci_section *dmmap_ip_interface = NULL, *dmmap_ip_interface_ipv6;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
|
|
@ -771,7 +771,7 @@ static int addObjIPInterfaceIPv6Address(char *refparam, struct dmctx *ctx, void
|
|||
browse_args.option = "parent_section";
|
||||
browse_args.value = section_name((struct uci_section *)data);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_network_ipv6", "intf_ipv6", &dmmap_ip_interface_ipv6, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_network_ipv6", "intf_ipv6", &dmmap_ip_interface_ipv6);
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv6, "parent_section", section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv6, "section_name", ipv6_name);
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv6, "address", "::");
|
||||
|
|
@ -838,7 +838,7 @@ static int addObjIPInterfaceIPv6Prefix(char *refparam, struct dmctx *ctx, void *
|
|||
if (strcmp(proto, "static") != 0 || (strcmp(proto, "static") == 0 && interface_section_with_dhcpv6_exists(section_name((struct uci_section *)data))))
|
||||
return FAULT_9001;
|
||||
|
||||
char *last_inst = NULL, *ip_inst, *v, ipv6_prefix_name[64] = {0}, buf[32] = {0};
|
||||
char *last_inst = NULL, *ip_inst, ipv6_prefix_name[64] = {0}, buf[32] = {0};
|
||||
struct uci_section *dmmap_ip_interface = NULL, *dmmap_ip_interface_ipv6_prefix;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
|
|
@ -857,7 +857,7 @@ static int addObjIPInterfaceIPv6Prefix(char *refparam, struct dmctx *ctx, void *
|
|||
browse_args.option = "parent_section";
|
||||
browse_args.value = section_name((struct uci_section *)data);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_network_ipv6_prefix", "intf_ipv6_prefix", &dmmap_ip_interface_ipv6_prefix, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_network_ipv6_prefix", "intf_ipv6_prefix", &dmmap_ip_interface_ipv6_prefix);
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv6_prefix, "parent_section", section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv6_prefix, "section_name", ipv6_prefix_name);
|
||||
dmuci_set_value_by_section(dmmap_ip_interface_ipv6_prefix, "address", "::/64");
|
||||
|
|
|
|||
|
|
@ -19,19 +19,19 @@
|
|||
**************************************************************/
|
||||
static int add_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *value, *v, *inst, name[32];
|
||||
struct uci_section *s = NULL, *dmmap_firewall = NULL;
|
||||
char name[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_firewall");
|
||||
inst = get_last_instance_bbfdm("dmmap_firewall", "zone", "interface_setting_instance");
|
||||
char *inst = get_last_instance_bbfdm("dmmap_firewall", "zone", "interface_setting_instance");
|
||||
snprintf(name, sizeof(name), "iface_set_%d", inst ? (atoi(inst)+1) : 1);
|
||||
dmuci_add_section("firewall", "zone", &s, &value);
|
||||
|
||||
dmuci_add_section("firewall", "zone", &s);
|
||||
dmuci_set_value_by_section(s, "input", "REJECT");
|
||||
dmuci_set_value_by_section(s, "output", "ACCEPT");
|
||||
dmuci_set_value_by_section(s, "forward", "REJECT");
|
||||
dmuci_set_value_by_section(s, "name", name);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_firewall", "zone", &dmmap_firewall, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_firewall", "zone", &dmmap_firewall);
|
||||
dmuci_set_value_by_section(dmmap_firewall, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap_firewall, "interface_setting_instance", "dmmap_firewall", "zone");
|
||||
return 0;
|
||||
|
|
@ -74,18 +74,18 @@ static int delete_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
static int add_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *value, *v, *inst, name[32];
|
||||
struct uci_section *s = NULL, *dmmap_firewall = NULL;
|
||||
char name[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_firewall");
|
||||
inst = get_last_instance_bbfdm("dmmap_firewall", "redirect", "port_mapping_instance");
|
||||
char *inst = get_last_instance_bbfdm("dmmap_firewall", "redirect", "port_mapping_instance");
|
||||
snprintf(name, sizeof(name), "port_map_%d", inst ? (atoi(inst)+1) : 1);
|
||||
dmuci_add_section("firewall", "redirect", &s, &value);
|
||||
|
||||
dmuci_add_section("firewall", "redirect", &s);
|
||||
dmuci_set_value_by_section(s, "name", name);
|
||||
dmuci_set_value_by_section(s, "target", "DNAT");
|
||||
dmuci_set_value_by_section(s, "enabled", "0");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_firewall", "redirect", &dmmap_firewall, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_firewall", "redirect", &dmmap_firewall);
|
||||
dmuci_set_value_by_section(dmmap_firewall, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap_firewall, "port_mapping_instance", "dmmap_firewall", "redirect");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -401,18 +401,18 @@ static int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *d
|
|||
**************************************************************/
|
||||
static int add_ppp_interface(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char name[16] = {0};
|
||||
char *inst, *v;
|
||||
struct uci_section *dmmap_ppp = NULL;
|
||||
char name[16] = {0};
|
||||
|
||||
check_create_dmmap_package("dmmap_network");
|
||||
inst = get_last_instance_lev2_bbfdm("network", "interface", "dmmap_network", "ppp_int_instance", "proto", "ppp");
|
||||
char *inst = get_last_instance_lev2_bbfdm("network", "interface", "dmmap_network", "ppp_int_instance", "proto", "ppp");
|
||||
snprintf(name, sizeof(name), "ppp_%d", inst ? (atoi(inst)+1) : 1);
|
||||
|
||||
dmuci_set_value("network", name, "", "interface");
|
||||
dmuci_set_value("network", name, "proto", "ppp");
|
||||
dmuci_set_value("network", name, "username", name);
|
||||
dmuci_set_value("network", name, "password", name);
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_ppp, &v);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_network", "interface", &dmmap_ppp);
|
||||
dmuci_set_value_by_section(dmmap_ppp, "section_name", name);
|
||||
*instance = update_instance(inst, 4, dmmap_ppp, "ppp_int_instance", "dmmap_network", "interface");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -131,19 +131,19 @@ static int get_ptm_status(char *refparam, struct dmctx *ctx, void *data, char *i
|
|||
*************************************************************/
|
||||
static int add_ptm_link(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *instance = NULL, *ptm_device = NULL, *v = NULL, *instance_update = NULL;
|
||||
struct uci_section *dmmap_ptm = NULL;
|
||||
char ptm_device[16];
|
||||
|
||||
char *instance = get_last_instance_bbfdm("dmmap_dsl", "ptm-device", "ptmlinkinstance");
|
||||
snprintf(ptm_device, sizeof(ptm_device), "ptm%d", instance ? atoi(instance) : 0);
|
||||
|
||||
check_create_dmmap_package("dmmap_dsl");
|
||||
instance = get_last_instance_bbfdm("dmmap_dsl", "ptm-device", "ptmlinkinstance");
|
||||
dmasprintf(&ptm_device, "ptm%d", instance ? atoi(instance) : 0);
|
||||
dmasprintf(&instance_update, "%d", instance ? atoi(instance)+ 1 : 1);
|
||||
dmuci_set_value("dsl", ptm_device, "", "ptm-device");
|
||||
dmuci_set_value("dsl", ptm_device, "name", "PTM");
|
||||
dmuci_set_value("dsl", ptm_device, "device", ptm_device);
|
||||
dmuci_set_value("dsl", ptm_device, "priority", "1");
|
||||
dmuci_set_value("dsl", ptm_device, "portid", "1");
|
||||
dmuci_add_section_bbfdm("dmmap_dsl", "ptm-device", &dmmap_ptm, &v);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dsl", "ptm-device", &dmmap_ptm);
|
||||
dmuci_set_value_by_section(dmmap_ptm, "section_name", ptm_device);
|
||||
*instancepara = update_instance(instance, 4, dmmap_ptm, "ptmlinkinstance", "dmmap_dsl", "ptm-device");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -166,16 +166,14 @@ int os_browseQoSShaperInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_
|
|||
*************************************************************/
|
||||
int os_addObjQoSClassification(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_qos");
|
||||
inst = get_last_instance_bbfdm("dmmap_qos", "classify", "classify_instance");
|
||||
dmuci_add_section("qos", "classify", &s, &value);
|
||||
//adding Classification object's parameter entries with default values
|
||||
char *inst = get_last_instance_bbfdm("dmmap_qos", "classify", "classify_instance");
|
||||
|
||||
dmuci_add_section("qos", "classify", &s);
|
||||
dmuci_set_value_by_section(s, "enable", "0");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "classify", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "classify", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap, "classify_instance", "dmmap_qos", "classify");
|
||||
return 0;
|
||||
|
|
@ -281,13 +279,11 @@ int delObjQoSPolicer(char *refparam, struct dmctx *ctx, void *data, char *instan
|
|||
|
||||
int os_addObjQoSPolicer(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_qos");
|
||||
inst = get_last_instance_bbfdm("dmmap_qos", "policer", "policer_instance");
|
||||
dmuci_add_section("qos", "policer", &s, &value);
|
||||
char *inst = get_last_instance_bbfdm("dmmap_qos", "policer", "policer_instance");
|
||||
|
||||
dmuci_add_section("qos", "policer", &s);
|
||||
dmuci_set_value_by_section(s, "enable", "0");
|
||||
dmuci_set_value_by_section(s, "committed_rate", "0");
|
||||
dmuci_set_value_by_section(s, "committed_burst_size", "0");
|
||||
|
|
@ -297,7 +293,7 @@ int os_addObjQoSPolicer(char *refparam, struct dmctx *ctx, void *data, char **in
|
|||
dmuci_set_value_by_section(s, "meter_type", "0");
|
||||
dmuci_set_value_by_section(s, "name", section_name(s));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "policer", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "policer", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap, "policer_instance", "dmmap_qos", "policer");
|
||||
return 0;
|
||||
|
|
@ -364,12 +360,11 @@ int os_delObjQoSPolicer(char *refparam, struct dmctx *ctx, void *data, char *ins
|
|||
|
||||
int os_addObjQoSQueue(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_qos");
|
||||
inst = get_last_instance_bbfdm("dmmap_qos", "queue", "queueinstance");
|
||||
dmuci_add_section("qos", "queue", &s, &value);
|
||||
char *inst = get_last_instance_bbfdm("dmmap_qos", "queue", "queueinstance");
|
||||
|
||||
dmuci_add_section("qos", "queue", &s);
|
||||
dmuci_set_value_by_section(s, "enable", "false");
|
||||
dmuci_set_value_by_section(s, "weight", "0");
|
||||
dmuci_set_value_by_section(s, "precedence", "0");
|
||||
|
|
@ -378,7 +373,7 @@ int os_addObjQoSQueue(char *refparam, struct dmctx *ctx, void *data, char **inst
|
|||
dmuci_set_value_by_section(s, "rate", "0");
|
||||
dmuci_set_value_by_section(s, "traffic_class", "0");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "queue", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "queue", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap, "queueinstance", "dmmap_qos", "queue");
|
||||
return 0;
|
||||
|
|
@ -446,18 +441,16 @@ int os_delObjQoSQueueStats(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
|
||||
int os_addObjQoSShaper(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_qos");
|
||||
inst = get_last_instance_bbfdm("dmmap_qos", "shaper", "shaperinstance");
|
||||
dmuci_add_section("qos", "shaper", &s, &value);
|
||||
char *inst = get_last_instance_bbfdm("dmmap_qos", "shaper", "shaperinstance");
|
||||
|
||||
dmuci_add_section("qos", "shaper", &s);
|
||||
dmuci_set_value_by_section(s, "enable", "0");
|
||||
dmuci_set_value_by_section(s, "burst_size", "0");
|
||||
dmuci_set_value_by_section(s, "rate", "0");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "shaper", &dmmap, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "shaper", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap, "shaperinstance", "dmmap_qos", "shaper");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -117,16 +117,17 @@ struct uci_section *get_dup_qos_stats_section_in_dmmap(char *dmmap_package, char
|
|||
int os_browseQoSQueueStatsInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *dmmap_sect;
|
||||
char *questatsout[256], *inst = NULL, *max_inst = NULL, *v, *lastinstancestore = NULL, dev[50] = "", user[50] = "";
|
||||
char *questatsout[256], *inst = NULL, *max_inst = NULL, *lastinstancestore = NULL, dev[50] = "", user[50] = "";
|
||||
int length, i, ret;
|
||||
struct queuestats queuests = {0}, emptyquestats = {0};
|
||||
regex_t regex1 = {}, regex2 = {};
|
||||
|
||||
regcomp(®ex1, "^qdisc noqueue [0-9]*: dev [[:alnum:]]* [[:alnum:]]* refcnt [0-9]*", 0);
|
||||
regcomp(®ex2, "^qdisc pfifo_fast [0-9]*: dev [[:alnum:]]* [[:alnum:]]* refcnt [0-9]*", 0);
|
||||
check_create_dmmap_package("dmmap_qos");
|
||||
|
||||
command_exec_output_to_array("tc -s qdisc", questatsout, &length);
|
||||
for (i = 0; i < length; i++){
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
switch (i%3) {
|
||||
case 0: ret = regexec(®ex1, questatsout[i], 0, NULL, 0);
|
||||
if (ret == 0)
|
||||
|
|
@ -142,12 +143,13 @@ int os_browseQoSQueueStatsInst(struct dmctx *dmctx, DMNODE *parent_node, void *p
|
|||
break;
|
||||
case 2: sscanf(questatsout[i], " backlog %db %dp requeues %d\n", &queuests.backlog_b, &queuests.backlog_p, &queuests.backlog_requeues);
|
||||
if ((dmmap_sect = get_dup_qos_stats_section_in_dmmap("dmmap_qos", "qos_queue_stats", queuests.dev)) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "qos_queue_stats", &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "qos_queue_stats", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "dev_link", queuests.dev);
|
||||
}
|
||||
|
||||
queuests.dmsect= dmmap_sect;
|
||||
|
||||
if(lastinstancestore != NULL && max_inst != NULL)
|
||||
if (lastinstancestore != NULL && max_inst != NULL)
|
||||
max_inst = dmstrdup(lastinstancestore);
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
|
|
@ -157,14 +159,16 @@ int os_browseQoSQueueStatsInst(struct dmctx *dmctx, DMNODE *parent_node, void *p
|
|||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&queuests, inst) == DM_STOP)
|
||||
goto end;
|
||||
|
||||
queuests = emptyquestats;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
regfree(®ex1);
|
||||
regfree(®ex2);
|
||||
end:
|
||||
return 0;
|
||||
end:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int os_browseQoSShaperInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
|
|
@ -176,20 +180,16 @@ int os_browseQoSShaperInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_
|
|||
int os_addObjQoSClassification(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s, *dmmap_qos_classify;
|
||||
char *last_inst = NULL, *sect_name = NULL, *qos_comment, *v;
|
||||
char ib[8];
|
||||
last_inst = get_last_instance_bbfdm("dmmap_qos", "classify", "classifinstance");
|
||||
if (last_inst)
|
||||
snprintf(ib, sizeof(ib), "%s", last_inst);
|
||||
else
|
||||
snprintf(ib, sizeof(ib), "%s", "1");
|
||||
dmasprintf(&qos_comment, "QoS classify %d", atoi(ib)+1);
|
||||
char qos_comment[32];
|
||||
|
||||
dmuci_add_section("qos", "classify", &s, §_name);
|
||||
char *last_inst = get_last_instance_bbfdm("dmmap_qos", "classify", "classifinstance");
|
||||
snprintf(qos_comment, sizeof(qos_comment), "QoS classify %s", (last_inst) ? last_inst : "1");
|
||||
|
||||
dmuci_add_section("qos", "classify", &s);
|
||||
dmuci_set_value_by_section(s, "comment", qos_comment);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "classify", &dmmap_qos_classify, &v);
|
||||
dmuci_set_value_by_section(dmmap_qos_classify, "section_name", sect_name);
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "classify", &dmmap_qos_classify);
|
||||
dmuci_set_value_by_section(dmmap_qos_classify, "section_name", section_name(s));
|
||||
*instance = update_instance(last_inst, 4, dmmap_qos_classify, "classifinstance", "dmmap_qos", "classify");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -298,20 +298,14 @@ int os_delObjQoSPolicer(char *refparam, struct dmctx *ctx, void *data, char *ins
|
|||
#if 0
|
||||
int os_addObjQoSQueue(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s, *dmmap_qos_class;
|
||||
char *last_inst = NULL, *sect_name = NULL, *v;
|
||||
char ib[8];
|
||||
struct uci_section *s = NULL;, *dmmap_qos_class = NULL;
|
||||
|
||||
last_inst = get_last_instance_bbfdm("dmmap_qos", "class", "queueinstance");
|
||||
if (last_inst)
|
||||
snprintf(ib, sizeof(ib), "%s", last_inst);
|
||||
else
|
||||
snprintf(ib, sizeof(ib), "%s", "1");
|
||||
char *last_inst = get_last_instance_bbfdm("dmmap_qos", "class", "queueinstance");
|
||||
|
||||
dmuci_add_section("qos", "class", &s, §_name);
|
||||
dmuci_add_section("qos", "class", &s);
|
||||
dmuci_set_value_by_section(s, "packetsize", "1000");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "class", &dmmap_qos_class, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "class", &dmmap_qos_class);
|
||||
dmuci_set_value_by_section(dmmap_qos_class, "section_name", sect_name);
|
||||
*instance = update_instance(last_inst, 4, dmmap_qos_class, "queueinstance", "dmmap_qos", "class");
|
||||
return 0;
|
||||
|
|
@ -396,20 +390,14 @@ int os_delObjQoSShaper(char *refparam, struct dmctx *ctx, void *data, char *inst
|
|||
int addObjQoSShaper(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s, *dmmap_qos_class;
|
||||
char *last_inst = NULL, *sect_name = NULL, *v;
|
||||
char ib[8];
|
||||
|
||||
last_inst= get_last_instance_bbfdm_without_update("dmmap_qos", "class", "shaperinstance");
|
||||
if (last_inst)
|
||||
snprintf(ib, sizeof(ib), "%s", last_inst);
|
||||
else
|
||||
snprintf(ib, sizeof(ib), "%s", "1");
|
||||
char *last_inst = get_last_instance_bbfdm_without_update("dmmap_qos", "class", "shaperinstance");
|
||||
|
||||
dmuci_add_section("qos", "class", &s, §_name);
|
||||
dmuci_add_section("qos", "class", &s);
|
||||
dmuci_set_value_by_section(s, "limitrate", "1000");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "class", &dmmap_qos_class, &v);
|
||||
dmuci_set_value_by_section(dmmap_qos_class, "section_name", sect_name);
|
||||
dmuci_add_section_bbfdm("dmmap_qos", "class", &dmmap_qos_class);
|
||||
dmuci_set_value_by_section(dmmap_qos_class, "section_name", section_name(s));
|
||||
*instance = update_instance(last_inst, 4, dmmap_qos_class, "shaperinstance", "dmmap_qos", "class");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,10 +264,9 @@ static int dmmap_synchronizeRoutingRouterIPv4Forwarding(struct dmctx *dmctx, DMN
|
|||
struct proc_routing proute = {0};
|
||||
json_object *jobj;
|
||||
FILE* fp = NULL;
|
||||
char *target, *iface, *name, *instance, *str, line[MAX_PROC_ROUTING];
|
||||
int found, last_inst, lines;
|
||||
char *target, *iface, *str, line[MAX_PROC_ROUTING];
|
||||
int found, lines;
|
||||
|
||||
check_create_dmmap_package("dmmap_route_forwarding");
|
||||
uci_path_foreach_sections_safe(bbfdm, "dmmap_route_forwarding", "route_dynamic", stmp, s) {
|
||||
dmuci_get_value_by_section_string(s, "target", &target);
|
||||
dmuci_get_value_by_section_string(s, "device", &iface);
|
||||
|
|
@ -316,9 +315,10 @@ static int dmmap_synchronizeRoutingRouterIPv4Forwarding(struct dmctx *dmctx, DMN
|
|||
break;
|
||||
}
|
||||
}
|
||||
last_inst = get_forwarding_last_inst();
|
||||
dmasprintf(&instance, "%d", last_inst+1);
|
||||
dmuci_add_section_bbfdm("dmmap_route_forwarding", "route_dynamic", &s, &name);
|
||||
char instance[16];
|
||||
|
||||
snprintf(instance, sizeof(instance), "%d", get_forwarding_last_inst() + 1);
|
||||
dmuci_add_section_bbfdm("dmmap_route_forwarding", "route_dynamic", &s);
|
||||
dmuci_set_value_by_section_bbfdm(s, "target", proute.destination);
|
||||
dmuci_set_value_by_section_bbfdm(s, "netmask", proute.mask);
|
||||
dmuci_set_value_by_section_bbfdm(s, "metric", proute.metric);
|
||||
|
|
@ -326,7 +326,6 @@ static int dmmap_synchronizeRoutingRouterIPv4Forwarding(struct dmctx *dmctx, DMN
|
|||
dmuci_set_value_by_section_bbfdm(s, "device", proute.iface);
|
||||
dmuci_set_value_by_section_bbfdm(s, "interface", iface);
|
||||
dmuci_set_value_by_section_bbfdm(s, "routeinstance", instance);
|
||||
dmfree(instance);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
|
@ -340,12 +339,11 @@ static int dmmap_synchronizeRoutingRouterIPv6Forwarding(struct dmctx *dmctx, DMN
|
|||
char ipbuf[INET6_ADDRSTRLEN];
|
||||
unsigned int ip[4], gw[4];
|
||||
unsigned int flags, refcnt, use, metric, prefix;
|
||||
char *iface, *str, *target, *name, *instance;
|
||||
char *iface, *str, *target;
|
||||
json_object *jobj;
|
||||
FILE* fp = NULL;
|
||||
int found, last_inst;
|
||||
int found;
|
||||
|
||||
check_create_dmmap_package("dmmap_route_forwarding");
|
||||
uci_path_foreach_sections_safe(bbfdm, "dmmap_route_forwarding", "route6_dynamic", stmp, s) {
|
||||
dmuci_get_value_by_section_string(s, "target", &target);
|
||||
dmuci_get_value_by_section_string(s, "device", &iface);
|
||||
|
|
@ -414,9 +412,10 @@ static int dmmap_synchronizeRoutingRouterIPv6Forwarding(struct dmctx *dmctx, DMN
|
|||
break;
|
||||
}
|
||||
}
|
||||
last_inst = get_forwarding6_last_inst();
|
||||
dmasprintf(&instance, "%d", last_inst+1);
|
||||
dmuci_add_section_bbfdm("dmmap_route_forwarding", "route6_dynamic", &s, &name);
|
||||
char instance[16];
|
||||
|
||||
snprintf(instance, sizeof(instance), "%d", get_forwarding6_last_inst() + 1);
|
||||
dmuci_add_section_bbfdm("dmmap_route_forwarding", "route6_dynamic", &s);
|
||||
dmuci_set_value_by_section_bbfdm(s, "target", ipstr);
|
||||
dmuci_set_value_by_section_bbfdm(s, "gateway", gwstr);
|
||||
dmuci_set_value_by_section_bbfdm(s, "interface", iface);
|
||||
|
|
@ -424,7 +423,6 @@ static int dmmap_synchronizeRoutingRouterIPv6Forwarding(struct dmctx *dmctx, DMN
|
|||
snprintf(buf, sizeof(buf), "%u", metric);
|
||||
dmuci_set_value_by_section_bbfdm(s, "metric", buf);
|
||||
dmuci_set_value_by_section_bbfdm(s, "route6instance", instance);
|
||||
dmfree(instance);
|
||||
}
|
||||
fclose(fp);
|
||||
return 0;
|
||||
|
|
@ -1102,19 +1100,16 @@ struct dm_permession_s DMRouting = {"0", &get_routing_perm};
|
|||
**************************************************************/
|
||||
static int add_ipv4forwarding(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *value, *v, instance[8];
|
||||
struct uci_section *s = NULL;
|
||||
struct uci_section *dmmap_route = NULL;
|
||||
int last_inst;
|
||||
struct uci_section *s = NULL, *dmmap_route = NULL;
|
||||
char instance[16];
|
||||
|
||||
check_create_dmmap_package("dmmap_route_forwarding");
|
||||
last_inst = get_forwarding_last_inst();
|
||||
snprintf(instance, sizeof(instance), "%d", last_inst);
|
||||
dmuci_add_section("network", "route", &s, &value);
|
||||
snprintf(instance, sizeof(instance), "%d", get_forwarding_last_inst());
|
||||
|
||||
dmuci_add_section("network", "route", &s);
|
||||
dmuci_set_value_by_section(s, "metric", "0");
|
||||
dmuci_set_value_by_section(s, "interface", "lan");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_route_forwarding", "route", &dmmap_route, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_route_forwarding", "route", &dmmap_route);
|
||||
dmuci_set_value_by_section(dmmap_route, "section_name", section_name(s));
|
||||
*instancepara = update_instance(instance, 4, dmmap_route, "routeinstance", "dmmap_route_forwarding", "route");
|
||||
return 0;
|
||||
|
|
@ -1142,19 +1137,16 @@ static int delete_ipv4forwarding(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int add_ipv6Forwarding(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *value, *v, instance[8];
|
||||
struct uci_section *s = NULL;
|
||||
struct uci_section *dmmap_route = NULL;
|
||||
int last_inst;
|
||||
struct uci_section *s = NULL, *dmmap_route = NULL;
|
||||
char instance[16];
|
||||
|
||||
check_create_dmmap_package("dmmap_route_forwarding");
|
||||
last_inst = get_forwarding6_last_inst();
|
||||
snprintf(instance, sizeof(instance), "%d", last_inst);
|
||||
dmuci_add_section("network", "route6", &s, &value);
|
||||
snprintf(instance, sizeof(instance), "%d", get_forwarding6_last_inst());
|
||||
|
||||
dmuci_add_section("network", "route6", &s);
|
||||
dmuci_set_value_by_section(s, "metric", "0");
|
||||
dmuci_set_value_by_section(s, "interface", "lan");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_route_forwarding", "route6", &dmmap_route, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_route_forwarding", "route6", &dmmap_route);
|
||||
dmuci_set_value_by_section(dmmap_route, "section_name", section_name(s));
|
||||
*instancepara = update_instance(instance, 4, dmmap_route, "route6instance", "dmmap_route_forwarding", "route6");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -209,14 +209,13 @@ static void get_certificate_paths(void)
|
|||
static int browseSecurityCertificateInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
#if defined(LOPENSSL) || defined(LMBEDTLS)
|
||||
char *inst = NULL, *max_inst = NULL, *v = NULL;
|
||||
char *inst = NULL, *max_inst = NULL;
|
||||
struct uci_section *dmmap_sect = NULL;
|
||||
struct certificate_profile certificateprofile = {};
|
||||
|
||||
check_create_dmmap_package("dmmap_security");
|
||||
get_certificate_paths();
|
||||
int i;
|
||||
for (i=0; i < MAX_CERT; i++) {
|
||||
for (i = 0; i < MAX_CERT; i++) {
|
||||
if(!strlen(certifcates_paths[i]))
|
||||
break;
|
||||
#ifdef LOPENSSL
|
||||
|
|
@ -229,8 +228,9 @@ static int browseSecurityCertificateInst(struct dmctx *dmctx, DMNODE *parent_nod
|
|||
fclose(fp);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_security", "security_certificate", "path", certifcates_paths[i])) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_security", "security_certificate", &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_security", "security_certificate", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "path", certifcates_paths[i]);
|
||||
}
|
||||
init_certificate(certifcates_paths[i], cert, dmmap_sect, &certificateprofile);
|
||||
|
|
@ -251,8 +251,9 @@ static int browseSecurityCertificateInst(struct dmctx *dmctx, DMNODE *parent_nod
|
|||
int ret = mbedtls_x509_crt_parse_file( &cacert, certifcates_paths[i]);
|
||||
if (ret < 0)
|
||||
continue;
|
||||
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_security", "security_certificate", "path", certifcates_paths[i])) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_security", "security_certificate", &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_security", "security_certificate", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "path", certifcates_paths[i]);
|
||||
}
|
||||
init_certificate(certifcates_paths[i], cacert, dmmap_sect, &certificateprofile);
|
||||
|
|
|
|||
|
|
@ -100,50 +100,48 @@ static int browseUPnPDiscoveryRootDeviceInst(struct dmctx *dmctx, DMNODE *parent
|
|||
{
|
||||
json_object *res = NULL, *devices = NULL, *device = NULL;
|
||||
struct upnpdiscovery upnp_dev = {};
|
||||
char *descurl = NULL, *st = NULL, *usn = NULL, *is_root_device = NULL, *inst = NULL, *max_inst = NULL, *v = NULL;
|
||||
char *descurl = NULL, *st = NULL, *usn = NULL, *is_root_device = NULL, *inst = NULL, *max_inst = NULL;
|
||||
char **stparams = NULL, **uuid, **urn;
|
||||
int i;
|
||||
size_t length;
|
||||
struct uci_section* dmmap_sect= NULL;
|
||||
struct uci_section* dmmap_sect = NULL;
|
||||
int i;
|
||||
|
||||
dmubus_call("upnpc", "discovery", UBUS_ARGS{{}}, 0, &res);
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "devices", &devices);
|
||||
if (devices == NULL)
|
||||
return 0;
|
||||
size_t nbre_devices = json_object_array_length(devices);
|
||||
size_t nbre_devices = (devices) ? json_object_array_length(devices) : 0;
|
||||
|
||||
if (nbre_devices > 0) {
|
||||
check_create_dmmap_package("dmmap_upnp");
|
||||
for (i = 0; i < nbre_devices; i++) {
|
||||
device = json_object_array_get_idx(devices, i);
|
||||
is_root_device = dmjson_get_value(device, 1, "is_root_device");
|
||||
if(strcmp(is_root_device, "0") == 0)
|
||||
continue;
|
||||
descurl = dmjson_get_value(device, 1, "descurl");
|
||||
st = dmjson_get_value(device, 1, "st");
|
||||
usn = dmjson_get_value(device, 1, "usn");
|
||||
stparams = strsplit_by_str(usn, "::");
|
||||
uuid = strsplit(stparams[0], ":", &length);
|
||||
urn = strsplit(stparams[1], ":", &length);
|
||||
dmasprintf(&upnp_dev.descurl, "%s", descurl);
|
||||
dmasprintf(&upnp_dev.st, "%s", st);
|
||||
dmasprintf(&upnp_dev.usn, "%s", usn);
|
||||
dmasprintf(&upnp_dev.uuid, "%s", uuid[1]);
|
||||
dmasprintf(&upnp_dev.urn, "%s", urn[1]);
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_root_device", "uuid", uuid[1])) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_root_device", &dmmap_sect, &v);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "uuid", uuid[1]);
|
||||
}
|
||||
upnp_dev.dmmap_sect = dmmap_sect;
|
||||
for (i = 0; i < nbre_devices; i++) {
|
||||
device = json_object_array_get_idx(devices, i);
|
||||
is_root_device = dmjson_get_value(device, 1, "is_root_device");
|
||||
if(strcmp(is_root_device, "0") == 0)
|
||||
continue;
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_root_device_instance", "upnp_root_device_alias", "dmmap_upnp", "upnp_root_device");
|
||||
descurl = dmjson_get_value(device, 1, "descurl");
|
||||
st = dmjson_get_value(device, 1, "st");
|
||||
usn = dmjson_get_value(device, 1, "usn");
|
||||
stparams = strsplit_by_str(usn, "::");
|
||||
uuid = strsplit(stparams[0], ":", &length);
|
||||
urn = strsplit(stparams[1], ":", &length);
|
||||
dmasprintf(&upnp_dev.descurl, "%s", descurl);
|
||||
dmasprintf(&upnp_dev.st, "%s", st);
|
||||
dmasprintf(&upnp_dev.usn, "%s", usn);
|
||||
dmasprintf(&upnp_dev.uuid, "%s", uuid[1]);
|
||||
dmasprintf(&upnp_dev.urn, "%s", urn[1]);
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_dev, inst) == DM_STOP)
|
||||
return 0;
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_root_device", "uuid", uuid[1])) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_root_device", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "uuid", uuid[1]);
|
||||
}
|
||||
|
||||
upnp_dev.dmmap_sect = dmmap_sect;
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_root_device_instance", "upnp_root_device_alias", "dmmap_upnp", "upnp_root_device");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_dev, inst) == DM_STOP)
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -152,47 +150,44 @@ static int browseUPnPDiscoveryDeviceInst(struct dmctx *dmctx, DMNODE *parent_nod
|
|||
{
|
||||
json_object *res = NULL, *devices = NULL, *device = NULL;
|
||||
struct upnpdiscovery upnp_dev = {};
|
||||
char *descurl = NULL, *st = NULL, *usn = NULL, *inst = NULL, *max_inst = NULL, *v = NULL;
|
||||
char **stparams= NULL, **uuid, **urn;
|
||||
int i;
|
||||
char *descurl = NULL, *st = NULL, *usn = NULL, *inst = NULL, *max_inst = NULL;
|
||||
char **stparams = NULL, **uuid, **urn;
|
||||
size_t lengthuuid, lengthurn;
|
||||
struct uci_section* dmmap_sect= NULL;
|
||||
struct uci_section* dmmap_sect = NULL;
|
||||
int i;
|
||||
|
||||
dmubus_call("upnpc", "discovery", UBUS_ARGS{{}}, 0, &res);
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "devices", &devices);
|
||||
if (devices == NULL)
|
||||
return 0;
|
||||
size_t nbre_devices = json_object_array_length(devices);
|
||||
size_t nbre_devices = (devices) ? json_object_array_length(devices) : 0;
|
||||
|
||||
if (nbre_devices > 0) {
|
||||
check_create_dmmap_package("dmmap_upnp");
|
||||
for(i=0; i<nbre_devices; i++){
|
||||
device= json_object_array_get_idx(devices, i);
|
||||
descurl = dmjson_get_value(device, 1, "descurl");
|
||||
st = dmjson_get_value(device, 1, "st");
|
||||
usn = dmjson_get_value(device, 1, "usn");
|
||||
stparams = strsplit_by_str(usn, "::");
|
||||
uuid = strsplit(stparams[0], ":", &lengthuuid);
|
||||
urn = strsplit(stparams[1], ":", &lengthurn);
|
||||
dmasprintf(&upnp_dev.descurl, "%s", descurl?descurl:"");
|
||||
dmasprintf(&upnp_dev.st, "%s", st?st:"");
|
||||
dmasprintf(&upnp_dev.usn, "%s", usn?usn:"");
|
||||
dmasprintf(&upnp_dev.uuid, "%s", lengthuuid>0?uuid[1]:"");
|
||||
dmasprintf(&upnp_dev.urn, "%s", lengthurn>0?urn[1]:"");
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_device", "uuid", uuid[1])) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_device", &dmmap_sect, &v);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "uuid", uuid[1]);
|
||||
}
|
||||
upnp_dev.dmmap_sect = dmmap_sect;
|
||||
for (i = 0; i < nbre_devices; i++) {
|
||||
device= json_object_array_get_idx(devices, i);
|
||||
descurl = dmjson_get_value(device, 1, "descurl");
|
||||
st = dmjson_get_value(device, 1, "st");
|
||||
usn = dmjson_get_value(device, 1, "usn");
|
||||
stparams = strsplit_by_str(usn, "::");
|
||||
uuid = strsplit(stparams[0], ":", &lengthuuid);
|
||||
urn = strsplit(stparams[1], ":", &lengthurn);
|
||||
dmasprintf(&upnp_dev.descurl, "%s", descurl?descurl:"");
|
||||
dmasprintf(&upnp_dev.st, "%s", st?st:"");
|
||||
dmasprintf(&upnp_dev.usn, "%s", usn?usn:"");
|
||||
dmasprintf(&upnp_dev.uuid, "%s", lengthuuid>0?uuid[1]:"");
|
||||
dmasprintf(&upnp_dev.urn, "%s", lengthurn>0?urn[1]:"");
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_evice_instance", "upnp_device_alias", "dmmap_upnp", "upnp_device");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_dev, inst) == DM_STOP)
|
||||
return 0;
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_device", "uuid", uuid[1])) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_device", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "uuid", uuid[1]);
|
||||
}
|
||||
|
||||
upnp_dev.dmmap_sect = dmmap_sect;
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_evice_instance", "upnp_device_alias", "dmmap_upnp", "upnp_device");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_dev, inst) == DM_STOP)
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -201,85 +196,78 @@ static int browseUPnPDiscoveryServiceInst(struct dmctx *dmctx, DMNODE *parent_no
|
|||
{
|
||||
json_object *res = NULL, *services = NULL, *service = NULL;
|
||||
struct upnpdiscovery upnp_dev = {};
|
||||
char *descurl = NULL, *st = NULL, *usn = NULL, *inst = NULL, *max_inst = NULL, *v = NULL;
|
||||
char *descurl = NULL, *st = NULL, *usn = NULL, *inst = NULL, *max_inst = NULL;
|
||||
char **stparams = NULL, **uuid, **urn;
|
||||
int i;
|
||||
size_t lengthuuid, lengthurn;
|
||||
struct uci_section* dmmap_sect = NULL;
|
||||
int i;
|
||||
|
||||
dmubus_call("upnpc", "discovery", UBUS_ARGS{{}}, 0, &res);
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "services", &services);
|
||||
if (services == NULL)
|
||||
return 0;
|
||||
size_t nbre_services = json_object_array_length(services);
|
||||
size_t nbre_services = (services) ? json_object_array_length(services) : 0;
|
||||
|
||||
if (nbre_services > 0) {
|
||||
check_create_dmmap_package("dmmap_upnp");
|
||||
for (i = 0; i < nbre_services; i++){
|
||||
service = json_object_array_get_idx(services, i);
|
||||
descurl = dmjson_get_value(service, 1, "descurl");
|
||||
st = dmjson_get_value(service, 1, "st");
|
||||
usn = dmjson_get_value(service, 1, "usn");
|
||||
stparams = strsplit_by_str(usn, "::");
|
||||
uuid = strsplit(stparams[0], ":", &lengthuuid);
|
||||
urn = strsplit(stparams[1], ":", &lengthurn);
|
||||
dmasprintf(&upnp_dev.descurl, "%s", descurl?descurl:"");
|
||||
dmasprintf(&upnp_dev.st, "%s", st?st:"");
|
||||
dmasprintf(&upnp_dev.usn, "%s", usn?usn:"");
|
||||
dmasprintf(&upnp_dev.uuid, "%s", lengthuuid>0?uuid[1]:"");
|
||||
dmasprintf(&upnp_dev.urn, "%s", lengthurn>0?urn[1]:"");
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_service", "usn", usn)) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_service", &dmmap_sect, &v);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "usn", usn);
|
||||
}
|
||||
upnp_dev.dmmap_sect = dmmap_sect;
|
||||
for (i = 0; i < nbre_services; i++){
|
||||
service = json_object_array_get_idx(services, i);
|
||||
descurl = dmjson_get_value(service, 1, "descurl");
|
||||
st = dmjson_get_value(service, 1, "st");
|
||||
usn = dmjson_get_value(service, 1, "usn");
|
||||
stparams = strsplit_by_str(usn, "::");
|
||||
uuid = strsplit(stparams[0], ":", &lengthuuid);
|
||||
urn = strsplit(stparams[1], ":", &lengthurn);
|
||||
dmasprintf(&upnp_dev.descurl, "%s", descurl?descurl:"");
|
||||
dmasprintf(&upnp_dev.st, "%s", st?st:"");
|
||||
dmasprintf(&upnp_dev.usn, "%s", usn?usn:"");
|
||||
dmasprintf(&upnp_dev.uuid, "%s", lengthuuid>0?uuid[1]:"");
|
||||
dmasprintf(&upnp_dev.urn, "%s", lengthurn>0?urn[1]:"");
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_service_instance", "upnp_service_alias", "dmmap_upnp", "upnp_service");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_dev, inst) == DM_STOP)
|
||||
return 0;
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_service", "usn", usn)) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_service", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "usn", usn);
|
||||
}
|
||||
|
||||
upnp_dev.dmmap_sect = dmmap_sect;
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_service_instance", "upnp_service_alias", "dmmap_upnp", "upnp_service");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_dev, inst) == DM_STOP)
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int browseUPnPDescriptionDeviceDescriptionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
json_object *res = NULL, *descriptions = NULL, *description = NULL;
|
||||
struct upnp_description_file_info upnp_desc= {};
|
||||
char *descurl = NULL, *inst = NULL, *max_inst = NULL, *v = NULL;
|
||||
int i;
|
||||
json_object *res = NULL, *descriptions = NULL, *description = NULL;
|
||||
struct upnp_description_file_info upnp_desc = {};
|
||||
char *descurl = NULL, *inst = NULL, *max_inst = NULL;
|
||||
struct uci_section* dmmap_sect = NULL;
|
||||
int i;
|
||||
|
||||
dmubus_call("upnpc", "description", UBUS_ARGS{{}}, 0, &res);
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "descriptions", &descriptions);
|
||||
if (descriptions == NULL)
|
||||
return 0;
|
||||
size_t nbre_descriptions = json_object_array_length(descriptions);
|
||||
size_t nbre_descriptions = (descriptions) ? json_object_array_length(descriptions) : 0;
|
||||
|
||||
if (nbre_descriptions > 0) {
|
||||
check_create_dmmap_package("dmmap_upnp");
|
||||
for (i = 0; i < nbre_descriptions; i++) {
|
||||
description = json_object_array_get_idx(descriptions, i);
|
||||
descurl = dmjson_get_value(description, 1, "descurl");
|
||||
dmasprintf(&upnp_desc.desc_url, "%s", descurl?descurl:"");
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_description", "descurl", descurl)) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_description", &dmmap_sect, &v);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "descurl", descurl);
|
||||
}
|
||||
upnp_desc.dmmap_sect = dmmap_sect;
|
||||
for (i = 0; i < nbre_descriptions; i++) {
|
||||
description = json_object_array_get_idx(descriptions, i);
|
||||
descurl = dmjson_get_value(description, 1, "descurl");
|
||||
dmasprintf(&upnp_desc.desc_url, "%s", descurl?descurl:"");
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_service_instance", "upnp_service_alias", "dmmap_upnp", "upnp_description");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_desc, inst) == DM_STOP)
|
||||
return 0;
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_description", "descurl", descurl)) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_description", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "descurl", descurl);
|
||||
}
|
||||
upnp_desc.dmmap_sect = dmmap_sect;
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_service_instance", "upnp_service_alias", "dmmap_upnp", "upnp_description");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_desc, inst) == DM_STOP)
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -288,88 +276,82 @@ static int browseUPnPDescriptionDeviceInstanceInst(struct dmctx *dmctx, DMNODE *
|
|||
{
|
||||
json_object *res = NULL, *devices_instances = NULL, *device_inst = NULL;
|
||||
struct upnp_device_inst upnp_dev_inst = {};
|
||||
char *inst = NULL, *max_inst = NULL, *v;
|
||||
int i;
|
||||
char *inst = NULL, *max_inst = NULL;
|
||||
struct uci_section* dmmap_sect = NULL;
|
||||
int i;
|
||||
|
||||
dmubus_call("upnpc", "description", UBUS_ARGS{{}}, 0, &res);
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "devicesinstances", &devices_instances);
|
||||
if (devices_instances == NULL)
|
||||
return 0;
|
||||
size_t nbre_devices_inst = json_object_array_length(devices_instances);
|
||||
size_t nbre_devices_inst = (devices_instances) ? json_object_array_length(devices_instances) : 0;
|
||||
|
||||
if (nbre_devices_inst > 0) {
|
||||
check_create_dmmap_package("dmmap_upnp");
|
||||
for (i = 0; i < nbre_devices_inst; i++){
|
||||
device_inst = json_object_array_get_idx(devices_instances, i);
|
||||
dmasprintf(&upnp_dev_inst.parentudn, "%s", dmjson_get_value(device_inst, 1, "parent_dev"));
|
||||
dmasprintf(&upnp_dev_inst.device_type, "%s", dmjson_get_value(device_inst, 1, "deviceType"));
|
||||
dmasprintf(&upnp_dev_inst.friendly_name, "%s", dmjson_get_value(device_inst, 1, "friendlyName"));
|
||||
dmasprintf(&upnp_dev_inst.manufacturer, "%s", dmjson_get_value(device_inst, 1, "manufacturer"));
|
||||
dmasprintf(&upnp_dev_inst.manufacturer_url, "%s", dmjson_get_value(device_inst, 1, "manufacturerURL"));
|
||||
dmasprintf(&upnp_dev_inst.model_description, "%s", dmjson_get_value(device_inst, 1, "modelDescription"));
|
||||
dmasprintf(&upnp_dev_inst.model_name, "%s", dmjson_get_value(device_inst, 1, "modelName"));
|
||||
dmasprintf(&upnp_dev_inst.model_number, "%s", dmjson_get_value(device_inst, 1, "modelNumber"));
|
||||
dmasprintf(&upnp_dev_inst.model_url, "%s", dmjson_get_value(device_inst, 1, "modelURL"));
|
||||
dmasprintf(&upnp_dev_inst.serial_number, "%s", dmjson_get_value(device_inst, 1, "serialNumber"));
|
||||
dmasprintf(&upnp_dev_inst.udn, "%s", dmjson_get_value(device_inst, 1, "UDN"));
|
||||
dmasprintf(&upnp_dev_inst.upc, "%s", dmjson_get_value(device_inst, 1, "UPC"));
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_device_inst", "udn", dmjson_get_value(device_inst, 1, "UDN"))) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_device_inst", &dmmap_sect, &v);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "udn", dmjson_get_value(device_inst, 1, "UDN"));
|
||||
}
|
||||
upnp_dev_inst.dmmap_sect = dmmap_sect;
|
||||
for (i = 0; i < nbre_devices_inst; i++){
|
||||
device_inst = json_object_array_get_idx(devices_instances, i);
|
||||
dmasprintf(&upnp_dev_inst.parentudn, "%s", dmjson_get_value(device_inst, 1, "parent_dev"));
|
||||
dmasprintf(&upnp_dev_inst.device_type, "%s", dmjson_get_value(device_inst, 1, "deviceType"));
|
||||
dmasprintf(&upnp_dev_inst.friendly_name, "%s", dmjson_get_value(device_inst, 1, "friendlyName"));
|
||||
dmasprintf(&upnp_dev_inst.manufacturer, "%s", dmjson_get_value(device_inst, 1, "manufacturer"));
|
||||
dmasprintf(&upnp_dev_inst.manufacturer_url, "%s", dmjson_get_value(device_inst, 1, "manufacturerURL"));
|
||||
dmasprintf(&upnp_dev_inst.model_description, "%s", dmjson_get_value(device_inst, 1, "modelDescription"));
|
||||
dmasprintf(&upnp_dev_inst.model_name, "%s", dmjson_get_value(device_inst, 1, "modelName"));
|
||||
dmasprintf(&upnp_dev_inst.model_number, "%s", dmjson_get_value(device_inst, 1, "modelNumber"));
|
||||
dmasprintf(&upnp_dev_inst.model_url, "%s", dmjson_get_value(device_inst, 1, "modelURL"));
|
||||
dmasprintf(&upnp_dev_inst.serial_number, "%s", dmjson_get_value(device_inst, 1, "serialNumber"));
|
||||
dmasprintf(&upnp_dev_inst.udn, "%s", dmjson_get_value(device_inst, 1, "UDN"));
|
||||
dmasprintf(&upnp_dev_inst.upc, "%s", dmjson_get_value(device_inst, 1, "UPC"));
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_device_inst_instance", "upnp_device_inst_alias", "dmmap_upnp", "upnp_device_inst");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_dev_inst, inst) == DM_STOP)
|
||||
return 0;
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_device_inst", "udn", dmjson_get_value(device_inst, 1, "UDN"))) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_device_inst", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "udn", dmjson_get_value(device_inst, 1, "UDN"));
|
||||
}
|
||||
|
||||
upnp_dev_inst.dmmap_sect = dmmap_sect;
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_device_inst_instance", "upnp_device_inst_alias", "dmmap_upnp", "upnp_device_inst");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_dev_inst, inst) == DM_STOP)
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int browseUPnPDescriptionServiceInstanceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
json_object *res = NULL, *services_instances = NULL, *service_inst = NULL;
|
||||
json_object *res = NULL, *services_instances = NULL, *service_inst = NULL;
|
||||
struct upnp_service_inst upnp_services_inst = {};
|
||||
char *inst = NULL, *max_inst = NULL, *v;
|
||||
int i;
|
||||
char *inst = NULL, *max_inst = NULL;
|
||||
struct uci_section* dmmap_sect = NULL;
|
||||
int i;
|
||||
|
||||
dmubus_call("upnpc", "description", UBUS_ARGS{{}}, 0, &res);
|
||||
if (res == NULL)
|
||||
return 0;
|
||||
json_object_object_get_ex(res, "servicesinstances", &services_instances);
|
||||
if (services_instances == NULL)
|
||||
return 0;
|
||||
size_t nbre_devices_inst = json_object_array_length(services_instances);
|
||||
size_t nbre_devices_inst = (services_instances) ? json_object_array_length(services_instances) : 0;
|
||||
|
||||
if (nbre_devices_inst > 0) {
|
||||
check_create_dmmap_package("dmmap_upnp");
|
||||
for (i = 0; i < nbre_devices_inst; i++) {
|
||||
service_inst = json_object_array_get_idx(services_instances, i);
|
||||
dmasprintf(&upnp_services_inst.parentudn, "%s", dmjson_get_value(service_inst, 1, "parent_dev"));
|
||||
dmasprintf(&upnp_services_inst.serviceid, "%s", dmjson_get_value(service_inst, 1, "serviceId"));
|
||||
dmasprintf(&upnp_services_inst.servicetype, "%s", dmjson_get_value(service_inst, 1, "serviceType"));
|
||||
dmasprintf(&upnp_services_inst.scpdurl, "%s", dmjson_get_value(service_inst, 1, "SCPDURL"));
|
||||
dmasprintf(&upnp_services_inst.controlurl, "%s", dmjson_get_value(service_inst, 1, "controlURL"));
|
||||
dmasprintf(&upnp_services_inst.eventsuburl, "%s", dmjson_get_value(service_inst, 1, "eventSubURL"));
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_service_inst", "serviceid", dmjson_get_value(service_inst, 1, "serviceId"))) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_service_inst", &dmmap_sect, &v);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "serviceid", dmjson_get_value(service_inst, 1, "serviceId"));
|
||||
}
|
||||
upnp_services_inst.dmmap_sect = dmmap_sect;
|
||||
for (i = 0; i < nbre_devices_inst; i++) {
|
||||
service_inst = json_object_array_get_idx(services_instances, i);
|
||||
dmasprintf(&upnp_services_inst.parentudn, "%s", dmjson_get_value(service_inst, 1, "parent_dev"));
|
||||
dmasprintf(&upnp_services_inst.serviceid, "%s", dmjson_get_value(service_inst, 1, "serviceId"));
|
||||
dmasprintf(&upnp_services_inst.servicetype, "%s", dmjson_get_value(service_inst, 1, "serviceType"));
|
||||
dmasprintf(&upnp_services_inst.scpdurl, "%s", dmjson_get_value(service_inst, 1, "SCPDURL"));
|
||||
dmasprintf(&upnp_services_inst.controlurl, "%s", dmjson_get_value(service_inst, 1, "controlURL"));
|
||||
dmasprintf(&upnp_services_inst.eventsuburl, "%s", dmjson_get_value(service_inst, 1, "eventSubURL"));
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_service_inst_instance", "upnp_service_inst_alias", "dmmap_upnp", "upnp_service_inst");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_services_inst, inst) == DM_STOP)
|
||||
return 0;
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_upnp", "upnp_service_inst", "serviceid", dmjson_get_value(service_inst, 1, "serviceId"))) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_upnp", "upnp_service_inst", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "serviceid", dmjson_get_value(service_inst, 1, "serviceId"));
|
||||
}
|
||||
|
||||
upnp_services_inst.dmmap_sect = dmmap_sect;
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
dmmap_sect, "upnp_service_inst_instance", "upnp_service_inst_alias", "dmmap_upnp", "upnp_service_inst");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &upnp_services_inst, inst) == DM_STOP)
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,17 +182,19 @@ static int browseUSBPortInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
|
|||
|
||||
regcomp(®ex1, "^[0-9][0-9]*-[0-9]*[0-9]$", 0);
|
||||
regcomp(®ex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]$", 0);
|
||||
check_create_dmmap_package("dmmap_usb");
|
||||
|
||||
synchronize_system_folders_with_dmmap_opt(SYSFS_USB_DEVICES_PATH,
|
||||
"dmmap_usb", "dmmap_port", "port_link", "usb_port_instance", &dup_list);
|
||||
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
if(regexec(®ex1, p->sysfs_folder_name, 0, NULL, 0) != 0 &&
|
||||
regexec(®ex2, p->sysfs_folder_name, 0, NULL, 0) !=0 &&
|
||||
strstr(p->sysfs_folder_name, "usb") != p->sysfs_folder_name) {
|
||||
|
||||
if (regexec(®ex1, p->sysfs_folder_name, 0, NULL, 0) != 0 &&
|
||||
regexec(®ex2, p->sysfs_folder_name, 0, NULL, 0) !=0 &&
|
||||
strstr(p->sysfs_folder_name, "usb") != p->sysfs_folder_name) {
|
||||
dmuci_delete_by_section_unnamed_bbfdm(p->dm, NULL, NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
init_usb_port(p->dm, p->sysfs_folder_name, p->sysfs_folder_path, &port);
|
||||
|
||||
inst = handle_update_instance(1, dmctx, &max_inst, update_instance_alias, 5,
|
||||
|
|
@ -214,8 +216,9 @@ static int browseUSBUSBHostsHostInst(struct dmctx *dmctx, DMNODE *parent_node, v
|
|||
struct usb_port port= {};
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
check_create_dmmap_package("dmmap_usb");
|
||||
synchronize_system_folders_with_dmmap_opt(SYSFS_USB_DEVICES_PATH, "dmmap_usb", "dmmap_host", "port_link", "usb_host_instance", &dup_list);
|
||||
synchronize_system_folders_with_dmmap_opt(SYSFS_USB_DEVICES_PATH,
|
||||
"dmmap_usb", "dmmap_host", "port_link", "usb_host_instance", &dup_list);
|
||||
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
if(!strstr(p->sysfs_folder_name, "usb"))
|
||||
continue;
|
||||
|
|
@ -246,7 +249,6 @@ static int synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, ch
|
|||
regcomp(®ex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]$", 0);
|
||||
|
||||
LIST_HEAD(dup_list_no_inst);
|
||||
dmmap_file_path_get(dmmap_package);
|
||||
|
||||
sysfs_foreach_file(sysfsrep, dir, ent) {
|
||||
if(strcmp(ent->d_name, ".")==0 || strcmp(ent->d_name, "..")==0)
|
||||
|
|
@ -270,7 +272,7 @@ static int synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, ch
|
|||
*/
|
||||
dmasprintf(&sysfs_rep_path, "%s/%s", sysfsrep, ent->d_name);
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt(dmmap_package, dmmap_section, opt_name, sysfs_rep_path)) == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, dmmap_section, &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, dmmap_section, &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, opt_name, sysfs_rep_path);
|
||||
}
|
||||
dmuci_get_value_by_section_string(dmmap_sect, inst_opt, &instance);
|
||||
|
|
@ -312,20 +314,27 @@ static int browseUSBUSBHostsHostDeviceInst(struct dmctx *dmctx, DMNODE *parent_n
|
|||
struct sysfs_dmsection *p;
|
||||
char *instance = NULL, *instnbr = NULL, *parent_host_instance = NULL;
|
||||
struct usb_port port= {};
|
||||
struct usb_port *prev_port= (struct usb_port *)prev_data;
|
||||
struct usb_port *prev_port = (struct usb_port *)prev_data;
|
||||
LIST_HEAD(dup_list);
|
||||
|
||||
check_create_dmmap_package("dmmap_usb");
|
||||
synchronize_usb_devices_with_dmmap_opt_recursively(prev_port->folder_path, "dmmap_usb", "dmmap_host_device", "port_link", "usb_host_device_instance", 1, &dup_list);
|
||||
|
||||
synchronize_usb_devices_with_dmmap_opt_recursively(prev_port->folder_path,
|
||||
"dmmap_usb", "dmmap_host_device", "port_link", "usb_host_device_instance", 1, &dup_list);
|
||||
|
||||
list_for_each_entry(p, &dup_list, list) {
|
||||
|
||||
init_usb_port(p->dm, p->sysfs_folder_name, p->sysfs_folder_path, &port);
|
||||
|
||||
if (p->dm && prev_port->dmsect ) {
|
||||
dmuci_get_value_by_section_string(prev_port->dmsect, "usb_host_instance", &parent_host_instance);
|
||||
dmuci_set_value_by_section_bbfdm(p->dm, "usb_host_device_parent_host_instance", parent_host_instance);
|
||||
}
|
||||
port.dmsect= prev_port->dmsect;
|
||||
|
||||
port.dmsect = prev_port->dmsect;
|
||||
|
||||
instance = handle_update_instance(2, dmctx, &instnbr, update_instance_alias, 5,
|
||||
p->dm, "usb_host_device_instance", "usb_host_device_alias", "dmmap_usb", "dmmap_host_device");
|
||||
|
||||
if (DM_LINK_INST_OBJ(dmctx, parent_node, &port, instance) == DM_STOP)
|
||||
break;
|
||||
}
|
||||
|
|
@ -337,17 +346,16 @@ static int browseUSBUSBHostsHostDeviceConfigurationInst(struct dmctx *dmctx, DMN
|
|||
{
|
||||
const struct usb_port *usb_dev = prev_data;
|
||||
struct usb_port port = {};
|
||||
struct uci_section *s;
|
||||
char nbre[16], *v, *max_inst = NULL;
|
||||
struct uci_section *s = NULL;
|
||||
char nbre[16], *max_inst = NULL;
|
||||
|
||||
__read_sysfs_usb_port(usb_dev, "bNumConfigurations", nbre, sizeof(nbre));
|
||||
if(nbre[0] == '0')
|
||||
return 0;
|
||||
|
||||
check_create_dmmap_package("dmmap_usb");
|
||||
s = is_dmmap_section_exist("dmmap_usb", "usb_device_conf");
|
||||
if (!s)
|
||||
dmuci_add_section_bbfdm("dmmap_usb", "usb_device_conf", &s, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_usb", "usb_device_conf", &s);
|
||||
dmuci_set_value_by_section_bbfdm(s, "usb_parent_device", usb_dev->folder_path);
|
||||
|
||||
init_usb_port(s, usb_dev->folder_name, usb_dev->folder_path, &port);
|
||||
|
|
@ -365,21 +373,23 @@ static int browseUSBUSBHostsHostDeviceConfigurationInterfaceInst(struct dmctx *d
|
|||
struct dirent *ent;
|
||||
struct usb_port *usb_dev = (struct usb_port*)prev_data;
|
||||
struct usb_port port = {0};
|
||||
char *sysfs_rep_path, *v, *inst = NULL, *max_inst = NULL;
|
||||
struct uci_section *dmmap_sect;
|
||||
char *sysfs_rep_path, *inst = NULL, *max_inst = NULL;
|
||||
struct uci_section *dmmap_sect = NULL;
|
||||
regex_t regex1 = {};
|
||||
regex_t regex2 = {};
|
||||
|
||||
regcomp(®ex1, "^[0-9][0-9]*-[0-9]*[0-9]:[0-9][0-9]*\\.[0-9]*[0-9]$", 0);
|
||||
regcomp(®ex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]:[0-9][0-9]*\\.[0-9]*[0-9]$", 0);
|
||||
check_create_dmmap_package("dmmap_usb");
|
||||
|
||||
sysfs_foreach_file(usb_dev->folder_path, dir, ent) {
|
||||
if(strcmp(ent->d_name, ".")==0 || strcmp(ent->d_name, "..")==0)
|
||||
|
||||
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
|
||||
continue;
|
||||
if(regexec(®ex1, ent->d_name, 0, NULL, 0) == 0 || regexec(®ex2, ent->d_name, 0, NULL, 0) ==0) {
|
||||
|
||||
if (regexec(®ex1, ent->d_name, 0, NULL, 0) == 0 || regexec(®ex2, ent->d_name, 0, NULL, 0) == 0) {
|
||||
dmasprintf(&sysfs_rep_path, "%s/%s", usb_dev->folder_path, ent->d_name);
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_usb", "usb_device_conf_interface", "port_link", sysfs_rep_path)) == NULL) {
|
||||
dmuci_add_section_bbfdm("dmmap_usb", "usb_device_conf_interface", &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_usb", "usb_device_conf_interface", &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "port_link", sysfs_rep_path);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@
|
|||
static void add_default_rule(char *port, char *enable, char *owsd)
|
||||
{
|
||||
struct uci_section *ss;
|
||||
char *ret;
|
||||
|
||||
dmuci_add_section("firewall", "rule", &ss, &ret);
|
||||
dmuci_add_section("firewall", "rule", &ss);
|
||||
dmuci_set_value_by_section(ss, "name", "juci-remote-access");
|
||||
dmuci_set_value_by_section(ss, "src", "wan");
|
||||
dmuci_set_value_by_section(ss, "proto", "tcp");
|
||||
|
|
|
|||
|
|
@ -34,19 +34,18 @@ static int browseUserInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_d
|
|||
|
||||
static int add_users_user(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
struct uci_section *s, *dmmap_user;
|
||||
char ib[8], *last_inst = NULL, *sect_name = NULL, *username, *v;
|
||||
struct uci_section *s = NULL, *dmmap_user = NULL;
|
||||
char username[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_users");
|
||||
last_inst = get_last_instance_bbfdm("dmmap_users", "user", "user_instance");
|
||||
snprintf(ib, sizeof(ib), "%s", last_inst ? last_inst : "1");
|
||||
dmasprintf(&username, "user_%d", atoi(ib)+1);
|
||||
dmuci_add_section("users", "user", &s, §_name);
|
||||
char *last_inst = get_last_instance_bbfdm("dmmap_users", "user", "user_instance");
|
||||
snprintf(username, sizeof(username), "user_%d", last_inst ? atoi(last_inst) + 1 : 1);
|
||||
|
||||
dmuci_add_section("users", "user", &s);
|
||||
dmuci_rename_section_by_section(s, username);
|
||||
dmuci_set_value_by_section(s, "enabled", "1");
|
||||
dmuci_set_value_by_section(s, "password", username);
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_users", "user", &dmmap_user, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_users", "user", &dmmap_user);
|
||||
dmuci_set_value_by_section(dmmap_user, "section_name", username);
|
||||
*instance = update_instance(last_inst, 4, dmmap_user, "user_instance", "dmmap_users", "user");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1818,19 +1818,19 @@ static int get_ap_ssid_ref(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
**************************************************************/
|
||||
static int add_wifi_ssid(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *value, *v, *inst, ssid[32] = {0};
|
||||
struct uci_section *s = NULL, *dmmap_wifi = NULL;
|
||||
char ssid[32] = {0};
|
||||
|
||||
check_create_dmmap_package("dmmap_wireless");
|
||||
inst = get_last_instance_bbfdm("dmmap_wireless", "wifi-iface", "ssidinstance");
|
||||
char *inst = get_last_instance_bbfdm("dmmap_wireless", "wifi-iface", "ssidinstance");
|
||||
snprintf(ssid, sizeof(ssid), "iopsys_%d", inst ? (atoi(inst)+1) : 1);
|
||||
dmuci_add_section("wireless", "wifi-iface", &s, &value);
|
||||
|
||||
dmuci_add_section("wireless", "wifi-iface", &s);
|
||||
dmuci_set_value_by_section(s, "ssid", ssid);
|
||||
dmuci_set_value_by_section(s, "network", "lan");
|
||||
dmuci_set_value_by_section(s, "mode", "ap");
|
||||
dmuci_set_value_by_section(s, "disabled", "0");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_wireless", "wifi-iface", &dmmap_wifi, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_wireless", "wifi-iface", &dmmap_wifi);
|
||||
dmuci_set_value_by_section(dmmap_wifi, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap_wifi, "ssidinstance", "dmmap_wireless", "wifi-iface");
|
||||
return 0;
|
||||
|
|
@ -1869,19 +1869,19 @@ static int delete_wifi_ssid(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
static int add_wifi_accesspoint(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *value, *v, *inst, ssid[32] = {0};
|
||||
struct uci_section *s = NULL, *dmmap_wifi = NULL;
|
||||
char ssid[32] = {0};
|
||||
|
||||
check_create_dmmap_package("dmmap_wireless");
|
||||
inst = get_last_instance_bbfdm("dmmap_wireless", "wifi-iface", "ap_instance");
|
||||
char *inst = get_last_instance_bbfdm("dmmap_wireless", "wifi-iface", "ap_instance");
|
||||
snprintf(ssid, sizeof(ssid), "iopsys_%d", inst ? (atoi(inst)+1) : 1);
|
||||
dmuci_add_section("wireless", "wifi-iface", &s, &value);
|
||||
|
||||
dmuci_add_section("wireless", "wifi-iface", &s);
|
||||
dmuci_set_value_by_section(s, "ssid", ssid);
|
||||
dmuci_set_value_by_section(s, "network", "lan");
|
||||
dmuci_set_value_by_section(s, "mode", "ap");
|
||||
dmuci_set_value_by_section(s, "disabled", "0");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_wireless", "wifi-iface", &dmmap_wifi, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_wireless", "wifi-iface", &dmmap_wifi);
|
||||
dmuci_set_value_by_section(dmmap_wifi, "section_name", section_name(s));
|
||||
*instance = update_instance(inst, 4, dmmap_wifi, "ap_instance", "dmmap_wireless", "wifi-iface");
|
||||
return 0;
|
||||
|
|
@ -1920,19 +1920,19 @@ static int delete_wifi_accesspoint(char *refparam, struct dmctx *ctx, void *data
|
|||
|
||||
static int addObjWiFiEndPoint(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *value, *v, *instancepara, *instancepara1, *instancepara2;
|
||||
struct uci_section *endpoint_sec = NULL, *dmmap_sec= NULL;
|
||||
char *instancepara, *instancepara1, *instancepara2;
|
||||
struct uci_section *endpoint_sec = NULL, *dmmap_sec = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_wireless");
|
||||
instancepara1 = get_last_instance_lev2_bbfdm("wireless", "wifi-iface", "dmmap_wireless", "endpointinstance", "mode", "wet")?get_last_instance_lev2_bbfdm("wireless", "wifi-iface", "dmmap_wireless", "endpointinstance", "mode", "wet"):"0";
|
||||
instancepara2 = get_last_instance_lev2_bbfdm("wireless", "wifi-iface", "dmmap_wireless", "endpointinstance", "mode", "sta")?get_last_instance_lev2_bbfdm("wireless", "wifi-iface", "dmmap_wireless", "endpointinstance", "mode", "sta"):"0";
|
||||
instancepara = atoi(instancepara1)>atoi(instancepara2)?dmstrdup(instancepara1):dmstrdup(instancepara2);
|
||||
dmuci_add_section("wireless", "wifi-iface", &endpoint_sec, &value);
|
||||
|
||||
dmuci_add_section("wireless", "wifi-iface", &endpoint_sec);
|
||||
dmuci_set_value_by_section(endpoint_sec, "device", "wl1");
|
||||
dmuci_set_value_by_section(endpoint_sec, "mode", "wet");
|
||||
dmuci_set_value_by_section(endpoint_sec, "network", "lan");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_wireless", "wifi-iface", &dmmap_sec, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_wireless", "wifi-iface", &dmmap_sec);
|
||||
dmuci_set_value_by_section(dmmap_sec, "section_name", section_name(endpoint_sec));
|
||||
*instance = update_instance(instancepara, 4, dmmap_sec, "endpointinstance", "dmmap_wireless", "wifi-iface");
|
||||
return 0;
|
||||
|
|
@ -2071,18 +2071,16 @@ static int browseWiFiEndPointInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
|
||||
static int browseWiFiEndPointProfileInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *s= NULL;
|
||||
char *v, *max_inst = NULL, *ep_instance;
|
||||
struct uci_section *s = NULL;
|
||||
char *max_inst = NULL, *ep_instance;
|
||||
struct wifi_enp_args *ep_args = (struct wifi_enp_args *)prev_data;
|
||||
struct uci_section *dmmap_section = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_wireless");
|
||||
|
||||
get_dmmap_section_of_config_section("dmmap_wireless", "wifi-iface", section_name(ep_args->wifi_enp_sec), &dmmap_section);
|
||||
dmuci_get_value_by_section_string(dmmap_section, "endpointinstance", &ep_instance);
|
||||
s = is_dmmap_section_exist_eq("dmmap_wireless", "ep_profile", "ep_key", ep_instance);
|
||||
if(!s)
|
||||
dmuci_add_section_bbfdm("dmmap_wireless", "ep_profile", &s, &v);
|
||||
if (!s)
|
||||
dmuci_add_section_bbfdm("dmmap_wireless", "ep_profile", &s);
|
||||
dmuci_set_value_by_section_bbfdm(s, "ep_key", ep_instance);
|
||||
|
||||
handle_update_instance(2, dmctx, &max_inst, update_instance_alias, 5,
|
||||
|
|
|
|||
|
|
@ -326,13 +326,11 @@ static int set_x_iopsys_eu_dropbear_alias(char *refparam, struct dmctx *ctx, voi
|
|||
/***** ADD DEL OBJ *******/
|
||||
int add_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *value, *v, *instance;
|
||||
struct uci_section *dropbear_sec = NULL, *dmmap_sec= NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_dropbear");
|
||||
instance = get_last_instance_bbfdm("dmmap_dropbear", "dropbear", "dropbearinstance");
|
||||
char *instance = get_last_instance_bbfdm("dmmap_dropbear", "dropbear", "dropbearinstance");
|
||||
|
||||
dmuci_add_section("dropbear", "dropbear", &dropbear_sec, &value);
|
||||
dmuci_add_section("dropbear", "dropbear", &dropbear_sec);
|
||||
dmuci_set_value_by_section(dropbear_sec, "verbose", "0");
|
||||
dmuci_set_value_by_section(dropbear_sec, "Port", "22");
|
||||
dmuci_set_value_by_section(dropbear_sec, "RootLogin", "1");
|
||||
|
|
@ -340,7 +338,7 @@ int add_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char **
|
|||
dmuci_set_value_by_section(dropbear_sec, "SSHKeepAlive", "300");
|
||||
dmuci_set_value_by_section(dropbear_sec, "IdleTimeout", "0");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_dropbear", "dropbear", &dmmap_sec, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_dropbear", "dropbear", &dmmap_sec);
|
||||
dmuci_set_value_by_section(dmmap_sec, "section_name", section_name(dropbear_sec));
|
||||
*instancepara = update_instance(instance, 4, dmmap_sec, "dropbearinstance", "dmmap_dropbear", "dropbear");
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ static void sync_mcast_dmmap_iface_sec(struct uci_list *proxy_iface, char *s_mod
|
|||
int found = 0;
|
||||
char key[1024] = "";
|
||||
char *s_name;
|
||||
char *v;
|
||||
|
||||
uci_foreach_element(proxy_iface, e) {
|
||||
char *p_ifname = dmstrdup(e->name);
|
||||
|
|
@ -72,7 +71,7 @@ static void sync_mcast_dmmap_iface_sec(struct uci_list *proxy_iface, char *s_mod
|
|||
|
||||
if (found == 0) {
|
||||
// add entry in dmmap for this
|
||||
dmuci_add_section_bbfdm(dmmap_package, dmmap_sec, &d_sec, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, dmmap_sec, &d_sec);
|
||||
dmuci_set_value_by_section_bbfdm(d_sec, "section_name", section_name(s));
|
||||
dmuci_set_value_by_section_bbfdm(d_sec, "ifname", key);
|
||||
dmuci_set_value_by_section_bbfdm(d_sec, "upstream", up_iface);
|
||||
|
|
@ -103,7 +102,6 @@ void synchronize_specific_config_sections_with_dmmap_mcast_iface(char *package,
|
|||
struct uci_section *s, *stmp;
|
||||
char *v;
|
||||
|
||||
dmmap_file_path_get(dmmap_package);
|
||||
uci_foreach_option_eq(package, section_type, "proto", proto, s) {
|
||||
if (strcmp(section_name(s), section_name((struct uci_section *)data)) != 0)
|
||||
continue;
|
||||
|
|
@ -147,7 +145,6 @@ void synchronize_specific_config_sections_with_dmmap_mcast_filter(char *package,
|
|||
struct uci_section *s, *dmmap_sect, *d_sec, *stmp;
|
||||
char *v, *s_name;
|
||||
|
||||
dmmap_file_path_get(dmmap_package);
|
||||
uci_foreach_option_eq(package, section_type, "proto", proto, s) {
|
||||
if (strcmp(section_name(s), section_name((struct uci_section *)data)) != 0)
|
||||
continue;
|
||||
|
|
@ -173,7 +170,7 @@ void synchronize_specific_config_sections_with_dmmap_mcast_filter(char *package,
|
|||
|
||||
if (found == 0) {
|
||||
// add entry in dmmap for this
|
||||
dmuci_add_section_bbfdm(dmmap_package, dmmap_sec, &d_sec, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, dmmap_sec, &d_sec);
|
||||
dmuci_set_value_by_section_bbfdm(d_sec, "section_name", section_name(s));
|
||||
dmuci_set_value_by_section_bbfdm(d_sec, "ipaddr", ip_addr);
|
||||
dmuci_set_value_by_section_bbfdm(d_sec, "enable", "1");
|
||||
|
|
@ -271,15 +268,14 @@ int get_mcast_snooping_interface_val(char *value, char *ifname, size_t s_ifname)
|
|||
|
||||
static int add_igmp_proxy_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v, *s_name;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
char s_name[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_mcast");
|
||||
inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy", "proxy_instance", "proto", "igmp");
|
||||
dmasprintf(&s_name, "igmp_proxy_%d", inst ? atoi(inst)+1 : 1);
|
||||
char *inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy", "proxy_instance", "proto", "igmp");
|
||||
snprintf(s_name, sizeof(s_name), "igmp_proxy_%d", inst ? atoi(inst)+1 : 1);
|
||||
|
||||
dmuci_add_section("mcast", "proxy", &s, &value);
|
||||
dmuci_add_section("mcast", "proxy", &s);
|
||||
dmuci_rename_section_by_section(s, s_name);
|
||||
dmuci_set_value_by_section(s, "enable", "0");
|
||||
dmuci_set_value_by_section(s, "proto", "igmp");
|
||||
|
|
@ -290,8 +286,8 @@ static int add_igmp_proxy_obj(char *refparam, struct dmctx *ctx, void *data, cha
|
|||
browse_args.option = "proto";
|
||||
browse_args.value = "igmp";
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy", &dmmap, &v);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", s_name);
|
||||
dmuci_set_value_by_section(dmmap, "proto", "igmp");
|
||||
*instance = update_instance(inst, 6, dmmap, "proxy_instance", "dmmap_mcast", "proxy", check_browse_section, (void *)&browse_args);
|
||||
|
||||
|
|
@ -370,15 +366,14 @@ static int browse_igmp_proxy_inst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
|
||||
static int add_igmp_snooping_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v, *s_name;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
char s_name[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_mcast");
|
||||
inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "snooping", "snooping_instance", "proto", "igmp");
|
||||
dmasprintf(&s_name, "igmp_snoop_%d", inst ? atoi(inst)+1 : 1);
|
||||
char *inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "snooping", "snooping_instance", "proto", "igmp");
|
||||
snprintf(s_name, sizeof(s_name), "igmp_snoop_%d", inst ? atoi(inst)+1 : 1);
|
||||
|
||||
dmuci_add_section("mcast", "snooping", &s, &value);
|
||||
dmuci_add_section("mcast", "snooping", &s);
|
||||
dmuci_rename_section_by_section(s, s_name);
|
||||
dmuci_set_value_by_section(s, "enable", "0");
|
||||
dmuci_set_value_by_section(s, "proto", "igmp");
|
||||
|
|
@ -389,8 +384,8 @@ static int add_igmp_snooping_obj(char *refparam, struct dmctx *ctx, void *data,
|
|||
browse_args.option = "proto";
|
||||
browse_args.value = "igmp";
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "snooping", &dmmap, &v);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "snooping", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", s_name);
|
||||
dmuci_set_value_by_section(dmmap, "proto", "igmp");
|
||||
*instance = update_instance(inst, 6, dmmap, "snooping_instance", "dmmap_mcast", "snooping", check_browse_section, (void *)&browse_args);
|
||||
|
||||
|
|
@ -511,14 +506,13 @@ static int browse_igmp_cgrp_inst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
|
||||
static int add_igmps_filter_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *last_inst, *v;
|
||||
struct uci_section *dmmap_igmps_filter = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "snooping_filter", "filter_instance",
|
||||
char *last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "snooping_filter", "filter_instance",
|
||||
"section_name", section_name((struct uci_section *)data));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "snooping_filter", &dmmap_igmps_filter, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "snooping_filter", &dmmap_igmps_filter);
|
||||
dmuci_set_value_by_section(dmmap_igmps_filter, "section_name", section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_igmps_filter, "enable", "0");
|
||||
|
||||
|
|
@ -946,14 +940,13 @@ int set_mcast_snooping_interface(char *refparam, struct dmctx *ctx, void *data,
|
|||
static int add_igmpp_interface_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
// This section works but commented for now as it is tested not much yet.
|
||||
char *last_inst, *v;
|
||||
struct uci_section *dmmap_igmpp_interface = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy_interface", "iface_instance",
|
||||
char *last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy_interface", "iface_instance",
|
||||
"section_name", section_name((struct uci_section *)data));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_interface", &dmmap_igmpp_interface, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_interface", &dmmap_igmpp_interface);
|
||||
dmuci_set_value_by_section(dmmap_igmpp_interface, "section_name",
|
||||
section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_igmpp_interface, "upstream", "0");
|
||||
|
|
@ -1087,14 +1080,13 @@ static int browse_igmpp_interface_inst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
|
||||
static int add_igmpp_filter_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *last_inst, *v;
|
||||
struct uci_section *dmmap_igmpp_filter = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy_filter", "filter_instance",
|
||||
char *last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy_filter", "filter_instance",
|
||||
"section_name", section_name((struct uci_section *)data));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_filter", &dmmap_igmpp_filter, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_filter", &dmmap_igmpp_filter);
|
||||
dmuci_set_value_by_section(dmmap_igmpp_filter, "section_name",
|
||||
section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_igmpp_filter, "enable", "0");
|
||||
|
|
|
|||
|
|
@ -15,15 +15,14 @@
|
|||
|
||||
static int add_mld_proxy_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v, *s_name;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
char s_name[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_mcast");
|
||||
inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy", "proxy_instance", "proto", "mld");
|
||||
dmasprintf(&s_name, "mld_proxy_%d", inst ? atoi(inst)+1 : 1);
|
||||
char *inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy", "proxy_instance", "proto", "mld");
|
||||
snprintf(s_name, sizeof(s_name), "mld_proxy_%d", inst ? atoi(inst)+1 : 1);
|
||||
|
||||
dmuci_add_section("mcast", "proxy", &s, &value);
|
||||
dmuci_add_section("mcast", "proxy", &s);
|
||||
dmuci_rename_section_by_section(s, s_name);
|
||||
dmuci_set_value_by_section(s, "enable", "0");
|
||||
dmuci_set_value_by_section(s, "proto", "mld");
|
||||
|
|
@ -34,11 +33,10 @@ static int add_mld_proxy_obj(char *refparam, struct dmctx *ctx, void *data, char
|
|||
browse_args.option = "proto";
|
||||
browse_args.value = "mld";
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy", &dmmap, &v);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", s_name);
|
||||
dmuci_set_value_by_section(dmmap, "proto", "mld");
|
||||
*instance = update_instance(inst, 6, dmmap, "proxy_instance", "dmmap_mcast", "proxy", check_browse_section, (void *)&browse_args);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -114,15 +112,14 @@ static int browse_mld_proxy_inst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
|
||||
static int add_mld_snooping_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *inst, *value, *v, *s_name;
|
||||
struct uci_section *dmmap = NULL, *s = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
char s_name[32];
|
||||
|
||||
check_create_dmmap_package("dmmap_mcast");
|
||||
inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "snooping", "snooping_instance", "proto", "mld");
|
||||
dmasprintf(&s_name, "mld_snoop_%d", inst ? atoi(inst)+1 : 1);
|
||||
char *inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "snooping", "snooping_instance", "proto", "mld");
|
||||
snprintf(s_name, sizeof(s_name), "mld_snoop_%d", inst ? atoi(inst)+1 : 1);
|
||||
|
||||
dmuci_add_section("mcast", "snooping", &s, &value);
|
||||
dmuci_add_section("mcast", "snooping", &s);
|
||||
dmuci_rename_section_by_section(s, s_name);
|
||||
dmuci_set_value_by_section(s, "enable", "0");
|
||||
dmuci_set_value_by_section(s, "proto", "mld");
|
||||
|
|
@ -133,11 +130,10 @@ static int add_mld_snooping_obj(char *refparam, struct dmctx *ctx, void *data, c
|
|||
browse_args.option = "proto";
|
||||
browse_args.value = "mld";
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "snooping", &dmmap, &v);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "snooping", &dmmap);
|
||||
dmuci_set_value_by_section(dmmap, "section_name", s_name);
|
||||
dmuci_set_value_by_section(dmmap, "proto", "mld");
|
||||
*instance = update_instance(inst, 6, dmmap, "snooping_instance", "dmmap_mcast", "snooping", check_browse_section, (void *)&browse_args);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -250,14 +246,13 @@ static int browse_mldp_cgrp_inst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
|
||||
static int add_mlds_filter_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *last_inst, *v;
|
||||
struct uci_section *dmmap_mlds_filter = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "snooping_filter", "filter_instance",
|
||||
char *last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "snooping_filter", "filter_instance",
|
||||
"section_name", section_name((struct uci_section *)data));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "snooping_filter", &dmmap_mlds_filter, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "snooping_filter", &dmmap_mlds_filter);
|
||||
dmuci_set_value_by_section(dmmap_mlds_filter, "section_name", section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_mlds_filter, "enable", "0");
|
||||
|
||||
|
|
@ -323,14 +318,13 @@ static int set_mld_snooping_version(char *refparam, struct dmctx *ctx, void *dat
|
|||
static int add_mldp_interface_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
// This section works but commented for now as it is tested not much yet.
|
||||
char *last_inst, *v;
|
||||
struct uci_section *dmmap_mldp_interface = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy_interface", "iface_instance",
|
||||
char *last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy_interface", "iface_instance",
|
||||
"section_name", section_name((struct uci_section *)data));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_interface", &dmmap_mldp_interface, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_interface", &dmmap_mldp_interface);
|
||||
dmuci_set_value_by_section(dmmap_mldp_interface, "section_name", section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_mldp_interface, "upstream", "0");
|
||||
dmuci_set_value_by_section(dmmap_mldp_interface, "snooping_mode", "0");
|
||||
|
|
@ -424,14 +418,13 @@ static int browse_mldp_interface_inst(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
|
||||
static int add_mldp_filter_obj(char *refparam, struct dmctx *ctx, void *data, char **instance)
|
||||
{
|
||||
char *last_inst, *v;
|
||||
struct uci_section *dmmap_mldp_filter = NULL;
|
||||
struct browse_args browse_args = {0};
|
||||
|
||||
last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy_filter", "filter_instance",
|
||||
char *last_inst = get_last_instance_lev2_bbfdm_dmmap_opt("dmmap_mcast", "proxy_filter", "filter_instance",
|
||||
"section_name", section_name((struct uci_section *)data));
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_filter", &dmmap_mldp_filter, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_mcast", "proxy_filter", &dmmap_mldp_filter);
|
||||
dmuci_set_value_by_section(dmmap_mldp_filter, "section_name", section_name((struct uci_section *)data));
|
||||
dmuci_set_value_by_section(dmmap_mldp_filter, "enable", "0");
|
||||
|
||||
|
|
|
|||
|
|
@ -390,18 +390,16 @@ static int set_x_iopsys_eu_owsd_virtualhost_ca(char *refparam, struct dmctx *ctx
|
|||
/***** ADD DEL OBJ *******/
|
||||
static int add_owsd_listen(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
|
||||
{
|
||||
char *value, *v, *instance;
|
||||
struct uci_section *listen_sec = NULL, *dmmap_sec = NULL;
|
||||
|
||||
check_create_dmmap_package("dmmap_owsd");
|
||||
instance = get_last_instance_bbfdm("dmmap_owsd", "owsd-listen", "olisteninstance");
|
||||
char *instance = get_last_instance_bbfdm("dmmap_owsd", "owsd-listen", "olisteninstance");
|
||||
|
||||
dmuci_add_section("owsd", "owsd-listen", &listen_sec, &value);
|
||||
dmuci_add_section("owsd", "owsd-listen", &listen_sec);
|
||||
dmuci_set_value_by_section(listen_sec, "ipv6", "on");
|
||||
dmuci_set_value_by_section(listen_sec, "whitelist_interface_as_origin", "1");
|
||||
dmuci_add_list_value_by_section(listen_sec, "origin", "*");
|
||||
|
||||
dmuci_add_section_bbfdm("dmmap_owsd", "owsd-listen", &dmmap_sec, &v);
|
||||
dmuci_add_section_bbfdm("dmmap_owsd", "owsd-listen", &dmmap_sec);
|
||||
dmuci_set_value_by_section(dmmap_sec, "section_name", section_name(listen_sec));
|
||||
*instancepara = update_instance(instance, 4, dmmap_sec, "olisteninstance", "dmmap_owsd", "owsd-listen");
|
||||
|
||||
|
|
|
|||
|
|
@ -127,9 +127,9 @@ opr_ret_t dynamicDeviceOperate(struct dmctx *dmctx, char *path, json_object *inp
|
|||
char *param_download = (char *) dmjson_get_value(ubus_res, 1, "download");
|
||||
char *param_upload = (char *) dmjson_get_value(ubus_res, 1, "upload");
|
||||
|
||||
add_list_paramameter(dmctx, dmstrdup("Latency"), param_latency, "string", NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("Download"), param_download, "string", NULL, 0);
|
||||
add_list_paramameter(dmctx, dmstrdup("Upload"), param_upload, "string", NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("Latency"), param_latency, "string", NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("Download"), param_download, "string", NULL, 0);
|
||||
add_list_parameter(dmctx, dmstrdup("Upload"), param_upload, "string", NULL, 0);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -406,15 +406,13 @@ def cprintAddDelObj( faddobj, fdelobj, name, mappingobj, dmobject ):
|
|||
if mappingobj != None:
|
||||
type, file, sectiontype, dmmapfile, path, ref = get_mapping_obj(mappingobj)
|
||||
if type == "uci":
|
||||
print(" char *inst, *value, *v;", file=fp)
|
||||
print(" struct uci_section *dmmap = NULL, *s = NULL;", file=fp)
|
||||
print("", file=fp)
|
||||
print(" check_create_dmmap_package(\"%s\");" % dmmapfile, file=fp)
|
||||
print(" inst = get_last_instance_bbfdm(\"%s\", \"%s\", \"%s\");" % (dmmapfile, sectiontype, name+"instance"), file=fp)
|
||||
print(" dmuci_add_section(\"%s\", \"%s\", &s, &value);" % (file, sectiontype), file=fp)
|
||||
print(" char *inst = get_last_instance_bbfdm(\"%s\", \"%s\", \"%s\");" % (dmmapfile, sectiontype, name+"instance"), file=fp)
|
||||
print(" dmuci_add_section(\"%s\", \"%s\", &s);" % (file, sectiontype), file=fp)
|
||||
print(" //dmuci_set_value_by_section(s, \"option\", \"value\");", file=fp)
|
||||
print("", file=fp)
|
||||
print(" dmuci_add_section_bbfdm(\"%s\", \"%s\", &dmmap, &v);" % (dmmapfile, sectiontype), file=fp)
|
||||
print(" dmuci_add_section_bbfdm(\"%s\", \"%s\", &dmmap);" % (dmmapfile, sectiontype), file=fp)
|
||||
print(" dmuci_set_value_by_section(dmmap, \"section_name\", section_name(s));", file=fp)
|
||||
print(" *instance = update_instance(inst, 4, dmmap, \"%s\");" % (name+"instance"), file=fp)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -768,14 +768,13 @@ char *get_last_instance_lev2_bbfdm_dmmap_opt(char *dmmap_package, char *section,
|
|||
|
||||
char *get_last_instance_lev2_bbfdm(char *package, char *section, char* dmmap_package, char *opt_inst, char *opt_check, char *value_check)
|
||||
{
|
||||
struct uci_section *s, *dmmap_section;
|
||||
char *instance = NULL, *last_inst = NULL, *v = NULL;
|
||||
struct uci_section *s = NULL, *dmmap_section = NULL;
|
||||
char *instance = NULL, *last_inst = NULL;
|
||||
|
||||
check_create_dmmap_package(dmmap_package);
|
||||
uci_foreach_option_cont(package, section, opt_check, value_check, s) {
|
||||
get_dmmap_section_of_config_section(dmmap_package, section, section_name(s), &dmmap_section);
|
||||
if (dmmap_section == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, section, &dmmap_section, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, section, &dmmap_section);
|
||||
dmuci_set_value_by_section(dmmap_section, "section_name", section_name(s));
|
||||
}
|
||||
instance = update_instance(last_inst, 4, dmmap_section, opt_inst, dmmap_package, section);
|
||||
|
|
@ -812,7 +811,7 @@ int get_empty(char *refparam, struct dmctx *ctx, void *data, char *instance, cha
|
|||
return 0;
|
||||
}
|
||||
|
||||
void add_list_paramameter(struct dmctx *ctx, char *param_name, char *param_data, char *param_type, char *param_version, unsigned int flags)
|
||||
void add_list_parameter(struct dmctx *ctx, char *param_name, char *param_data, char *param_type, char *param_version, unsigned int flags)
|
||||
{
|
||||
struct dm_parameter *dm_parameter;
|
||||
struct list_head *ilist;
|
||||
|
|
@ -828,7 +827,7 @@ void add_list_paramameter(struct dmctx *ctx, char *param_name, char *param_data,
|
|||
dm_parameter = dmcalloc(1, sizeof(struct dm_parameter));
|
||||
_list_add(&dm_parameter->list, ilist->prev, ilist);
|
||||
dm_parameter->name = param_name;
|
||||
dm_parameter->data = param_data ? param_data : ""; //allocate memory in function
|
||||
dm_parameter->data = param_data ? param_data : "";
|
||||
dm_parameter->type = param_type;
|
||||
dm_parameter->version = param_version;
|
||||
dm_parameter->flags = flags;
|
||||
|
|
@ -1057,13 +1056,13 @@ static int remove_parameter_notification(char *param)
|
|||
|
||||
static int set_parameter_notification(struct dmctx *ctx, char *param, char *value)
|
||||
{
|
||||
char *tmp = NULL, *buf = NULL, *pch, *new_param;
|
||||
char *tmp = NULL, *pch, *new_param;
|
||||
char *notification = NULL;
|
||||
struct uci_section *s;
|
||||
dmuci_get_section_type("cwmp", "@notifications[0]", &tmp);
|
||||
update_param_instance_alias(ctx, param, &new_param);
|
||||
if (!tmp || tmp[0] == '\0') {
|
||||
dmuci_add_section("cwmp", "notifications", &s, &buf);
|
||||
dmuci_add_section("cwmp", "notifications", &s);
|
||||
} else {
|
||||
remove_parameter_notification(new_param);
|
||||
}
|
||||
|
|
@ -1147,7 +1146,7 @@ static char *check_value_by_type(char *value, int type)
|
|||
int i = 0, len = strlen(value);
|
||||
char buf[len + 1];
|
||||
|
||||
strncpy(buf, value, sizeof(buf) - 1);
|
||||
strcpy(buf, value);
|
||||
buf[len] = 0;
|
||||
|
||||
switch (type) {
|
||||
|
|
@ -1174,14 +1173,14 @@ static char *check_value_by_type(char *value, int type)
|
|||
return "0";
|
||||
break;
|
||||
case DMT_HEXBIN:
|
||||
while (buf[i]) {
|
||||
while (buf[i] != 0) {
|
||||
if (isxdigit(buf[i]) == 0)
|
||||
return "0";
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case DMT_BASE64:
|
||||
while (buf[i]) {
|
||||
while (buf[i] != 0) {
|
||||
if (is64digit(buf[i]) == 0)
|
||||
return "0";
|
||||
i++;
|
||||
|
|
@ -1313,7 +1312,7 @@ static int get_value_param(DMPARAM_ARGS)
|
|||
|
||||
value = (value && *value) ? check_value_by_type(value, type) : get_default_value_by_type(type);
|
||||
|
||||
add_list_paramameter(dmctx, full_param, value, DMT_TYPE[type], NULL, 0);
|
||||
add_list_parameter(dmctx, full_param, value, DMT_TYPE[type], NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1336,7 +1335,7 @@ static int mparam_get_value_in_param(DMPARAM_ARGS)
|
|||
|
||||
value = (value && *value) ? check_value_by_type(value, type) : get_default_value_by_type(type);
|
||||
|
||||
add_list_paramameter(dmctx, full_param, value, DMT_TYPE[type], NULL, 0);
|
||||
add_list_parameter(dmctx, full_param, value, DMT_TYPE[type], NULL, 0);
|
||||
dmctx->stop = true;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1402,7 +1401,7 @@ static int mparam_get_name(DMPARAM_ARGS)
|
|||
if (permission->get_permission != NULL)
|
||||
perm = permission->get_permission(refparam, dmctx, data, instance);
|
||||
|
||||
add_list_paramameter(dmctx, refparam, perm, DMT_TYPE[type], NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, perm, DMT_TYPE[type], NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1414,7 +1413,7 @@ static int mobj_get_name(DMOBJECT_ARGS)
|
|||
if (permission->get_permission != NULL)
|
||||
perm = permission->get_permission(refparam, dmctx, data, instance);
|
||||
|
||||
add_list_paramameter(dmctx, refparam, perm, "xsd:object", NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, perm, "xsd:object", NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1435,7 +1434,7 @@ static int mparam_get_name_in_param(DMPARAM_ARGS)
|
|||
if (permission->get_permission != NULL)
|
||||
perm = permission->get_permission(refparam, dmctx, data, instance);
|
||||
|
||||
add_list_paramameter(dmctx, refparam, perm, DMT_TYPE[type], NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, perm, DMT_TYPE[type], NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1454,7 +1453,7 @@ static int mparam_get_name_in_obj(DMPARAM_ARGS)
|
|||
if (permission->get_permission != NULL)
|
||||
perm = permission->get_permission(refparam, dmctx, data, instance);
|
||||
|
||||
add_list_paramameter(dmctx, refparam, perm, DMT_TYPE[type], NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, perm, DMT_TYPE[type], NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1475,7 +1474,7 @@ static int mobj_get_name_in_obj(DMOBJECT_ARGS)
|
|||
if (permission->get_permission != NULL)
|
||||
perm = permission->get_permission(refparam, dmctx, data, instance);
|
||||
|
||||
add_list_paramameter(dmctx, refparam, perm, "xsd:object", NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, perm, "xsd:object", NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1508,7 +1507,7 @@ static int mobj_get_schema_name(DMOBJECT_ARGS)
|
|||
if (node->obj)
|
||||
unique_keys = node->obj->unique_keys;
|
||||
|
||||
add_list_paramameter(dmctx, refparam, perm, "xsd:object", (char *) unique_keys, 0);
|
||||
add_list_parameter(dmctx, refparam, perm, "xsd:object", (char *) unique_keys, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1518,7 +1517,7 @@ static int mparam_get_schema_name(DMPARAM_ARGS)
|
|||
char *perm = permission->val;
|
||||
dmastrcat(&refparam, node->current_object, lastname);
|
||||
|
||||
add_list_paramameter(dmctx, refparam, perm, DMT_TYPE[type], NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, perm, DMT_TYPE[type], NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1562,7 +1561,7 @@ static int mobj_get_instances_in_obj(DMOBJECT_ARGS)
|
|||
|
||||
if (name) {
|
||||
name[strlen(name) - 1] = 0;
|
||||
add_list_paramameter(dmctx, name, NULL, "xsd:object", NULL, 0);
|
||||
add_list_parameter(dmctx, name, NULL, "xsd:object", NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1631,7 +1630,7 @@ static int mparam_get_notification(DMPARAM_ARGS)
|
|||
} else {
|
||||
value = check_parameter_forced_notification(refparam);
|
||||
}
|
||||
add_list_paramameter(dmctx, refparam, value, DMT_TYPE[type], NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, value, DMT_TYPE[type], NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1655,7 +1654,7 @@ static int mparam_get_notification_in_param(DMPARAM_ARGS)
|
|||
} else {
|
||||
value = check_parameter_forced_notification(refparam);
|
||||
}
|
||||
add_list_paramameter(dmctx, refparam, value, DMT_TYPE[type], NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, value, DMT_TYPE[type], NULL, 0);
|
||||
dmctx->stop = 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2210,7 +2209,7 @@ static int upnp_set_parameter_onchange(struct dmctx *ctx, char *param, char *onc
|
|||
|
||||
dmuci_get_section_type(UPNP_CFG, "@notifications[0]", &tmp);
|
||||
if (!tmp || tmp[0] == '\0') {
|
||||
dmuci_add_section(UPNP_CFG, "notifications", &s, &tmp);
|
||||
dmuci_add_section(UPNP_CFG, "notifications", &s);
|
||||
}
|
||||
|
||||
dmuci_del_list_value(UPNP_CFG, "@notifications[0]",onchange, param);
|
||||
|
|
@ -2362,7 +2361,7 @@ int dm_entry_upnp_update_attribute_values_update(struct dmctx *dmctx)
|
|||
|
||||
dmuci_get_section_type(UPNP_CFG, "@dm[0]", &tmp);
|
||||
if (!tmp || tmp[0] == '\0') {
|
||||
dmuci_add_section(UPNP_CFG, "dm", &s, &tmp);
|
||||
dmuci_add_section(UPNP_CFG, "dm", &s);
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%d", version);
|
||||
dmuci_set_value(UPNP_CFG, "@dm[0]", "attribute_values_version", buf);
|
||||
|
|
@ -2420,7 +2419,7 @@ static int mobj_upnp_get_instances(DMOBJECT_ARGS)
|
|||
dmctx->stop = 1;
|
||||
return FAULT_UPNP_703;
|
||||
}
|
||||
add_list_paramameter(dmctx, refparam, NULL, NULL, NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, NULL, NULL, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2470,7 +2469,7 @@ static int mparam_upnp_get_supportedparams(DMPARAM_ARGS)
|
|||
return FAULT_UPNP_703;
|
||||
}
|
||||
dmctx->findparam = 1;
|
||||
add_list_paramameter(dmctx, refparam, NULL, NULL, NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, NULL, NULL, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -2480,7 +2479,7 @@ static int mparam_upnp_get_supportedparams(DMPARAM_ARGS)
|
|||
dmctx->stop = 1;
|
||||
return FAULT_UPNP_703;
|
||||
}
|
||||
add_list_paramameter(dmctx, refparam, NULL, NULL, NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, NULL, NULL, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
return FAULT_UPNP_703;
|
||||
|
|
@ -2501,7 +2500,7 @@ static int mobj_upnp_get_supportedparams(DMOBJECT_ARGS)
|
|||
dmctx->stop = 1;
|
||||
return FAULT_UPNP_703;
|
||||
}
|
||||
add_list_paramameter(dmctx, refparam, NULL, NULL, NULL, 0);
|
||||
add_list_parameter(dmctx, refparam, NULL, NULL, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
return FAULT_UPNP_703;
|
||||
|
|
@ -2566,7 +2565,7 @@ static int mparam_upnp_structured_get_value_in_param(DMPARAM_ARGS)
|
|||
}
|
||||
dmctx->findparam = 1;
|
||||
(get_cmd)(full_param, dmctx, data, instance, &value);
|
||||
add_list_paramameter(dmctx, full_param, value, DMT_TYPE[type], NULL, 0);
|
||||
add_list_parameter(dmctx, full_param, value, DMT_TYPE[type], NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2631,7 +2630,7 @@ static int upnp_get_value_param(DMPARAM_ARGS)
|
|||
return FAULT_UPNP_703;
|
||||
}
|
||||
(get_cmd)(full_param, dmctx, data, instance, &value);
|
||||
add_list_paramameter(dmctx, full_param, value, NULL, NULL, 0);
|
||||
add_list_parameter(dmctx, full_param, value, NULL, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2656,7 +2655,7 @@ static int mparam_upnp_get_value_in_param(DMPARAM_ARGS)
|
|||
return FAULT_UPNP_703;
|
||||
}
|
||||
(get_cmd)(full_param, dmctx, data, instance, &value);
|
||||
add_list_paramameter(dmctx, full_param, value, NULL, NULL, 0);
|
||||
add_list_parameter(dmctx, full_param, value, NULL, NULL, 0);
|
||||
dmctx->stop = 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2922,7 +2921,7 @@ static int mparam_upnp_get_attributes(DMPARAM_ARGS)
|
|||
get_parameter_version(dmctx, refparam, &version, &s);
|
||||
flags |= UPNP_DMT_TYPE[type];
|
||||
|
||||
add_list_paramameter(dmctx, refparam, perm, NULL, version, flags);
|
||||
add_list_parameter(dmctx, refparam, perm, NULL, version, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2962,7 +2961,7 @@ static int mobj_upnp_get_attributes(DMOBJECT_ARGS)
|
|||
else if (node->obj->browseinstobj)
|
||||
flags |= (NODE_DATA_ATTRIBUTE_MULTIINSTANCE | NODE_DATA_ATTRIBUTE_TYPEPTR);
|
||||
|
||||
add_list_paramameter(dmctx, refparam, perm, NULL, version, flags);
|
||||
add_list_parameter(dmctx, refparam, perm, NULL, version, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -3107,7 +3106,7 @@ static int mparam_upnp_get_acldata(DMPARAM_ARGS)
|
|||
|
||||
dmctx->stop = 1;
|
||||
|
||||
add_list_paramameter(dmctx, refparam, NULL, NULL, NULL, flags);
|
||||
add_list_parameter(dmctx, refparam, NULL, NULL, NULL, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -3131,7 +3130,7 @@ static int mobj_upnp_get_acldata(DMOBJECT_ARGS)
|
|||
dmctx->stop = 1;
|
||||
flags |= DM_FACTORIZED;
|
||||
|
||||
add_list_paramameter(dmctx, refparam, NULL, NULL, NULL, flags);
|
||||
add_list_parameter(dmctx, refparam, NULL, NULL, NULL, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ char *update_instance(char *max_inst, int argc, ...);
|
|||
char *update_instance_alias(int action, char **last_inst, char **max_inst, void *argv[]);
|
||||
char *update_instance_without_section(int action, char **last_inst, char **max_inst, void *argv[]);
|
||||
int get_empty(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
void add_list_paramameter(struct dmctx *ctx, char *param_name, char *param_data, char *param_type, char *param_version, unsigned int flags);
|
||||
void add_list_parameter(struct dmctx *ctx, char *param_name, char *param_data, char *param_type, char *param_version, unsigned int flags);
|
||||
void api_del_list_parameter(struct dm_parameter *dm_parameter);
|
||||
void free_all_list_parameter(struct dmctx *ctx);
|
||||
void add_set_list_tmp(struct dmctx *ctx, char *param, char *value, unsigned int flags);
|
||||
|
|
|
|||
|
|
@ -395,29 +395,8 @@ int network_get_ipaddr(char **value, char *iface)
|
|||
return 0;
|
||||
}
|
||||
|
||||
char *dmmap_file_path_get(const char *dmmap_package)
|
||||
{
|
||||
char *path;
|
||||
int rc;
|
||||
|
||||
rc = dmasprintf(&path, "/etc/bbfdm/%s", dmmap_package);
|
||||
if (rc == -1)
|
||||
return NULL;
|
||||
|
||||
if (access(path, F_OK)) {
|
||||
/*
|
||||
*File does not exist
|
||||
**/
|
||||
FILE *fp = fopen(path, "w"); // new empty file
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
void update_section_list(char *config, char *section, char *option, int number, char *filter, char *option1, char *val1, char *option2, char *val2)
|
||||
{
|
||||
char *add_value;
|
||||
struct uci_section *s = NULL;
|
||||
int i = 0;
|
||||
|
||||
|
|
@ -432,16 +411,10 @@ void update_section_list(char *config, char *section, char *option, int number,
|
|||
}
|
||||
}
|
||||
while (i < number) {
|
||||
dmuci_add_section_bbfdm(config, section, &s, &add_value);
|
||||
if (option)
|
||||
dmuci_set_value_by_section_bbfdm(s, option, filter);
|
||||
|
||||
if (option1)
|
||||
dmuci_set_value_by_section_bbfdm(s, option1, val1);
|
||||
|
||||
if (option2)
|
||||
dmuci_set_value_by_section_bbfdm(s, option2, val2);
|
||||
|
||||
dmuci_add_section_bbfdm(config, section, &s);
|
||||
dmuci_set_value_by_section_bbfdm(s, option, filter);
|
||||
dmuci_set_value_by_section_bbfdm(s, option1, val1);
|
||||
dmuci_set_value_by_section_bbfdm(s, option2, val2);
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -455,16 +428,10 @@ void update_section_list(char *config, char *section, char *option, int number,
|
|||
}
|
||||
}
|
||||
while (i < number) {
|
||||
dmuci_add_section(config, section, &s, &add_value);
|
||||
if (option)
|
||||
dmuci_set_value_by_section(s, option, filter);
|
||||
|
||||
if (option1)
|
||||
dmuci_set_value_by_section(s, option1, val1);
|
||||
|
||||
if (option2)
|
||||
dmuci_set_value_by_section(s, option2, val2);
|
||||
|
||||
dmuci_add_section(config, section, &s);
|
||||
dmuci_set_value_by_section(s, option, filter);
|
||||
dmuci_set_value_by_section(s, option1, val1);
|
||||
dmuci_set_value_by_section(s, option2, val2);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
@ -625,14 +592,12 @@ void synchronize_specific_config_sections_with_dmmap(char *package, char *sectio
|
|||
struct uci_section *s, *stmp, *dmmap_sect;
|
||||
char *v;
|
||||
|
||||
dmmap_file_path_get(dmmap_package);
|
||||
|
||||
uci_foreach_sections(package, section_type, s) {
|
||||
/*
|
||||
* create/update corresponding dmmap section that have same config_section link and using param_value_array
|
||||
*/
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap(dmmap_package, section_type, section_name(s))) == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(s));
|
||||
}
|
||||
|
||||
|
|
@ -657,14 +622,12 @@ void synchronize_specific_config_sections_with_dmmap_eq(char *package, char *sec
|
|||
struct uci_section *s, *stmp, *dmmap_sect;
|
||||
char *v;
|
||||
|
||||
dmmap_file_path_get(dmmap_package);
|
||||
|
||||
uci_foreach_option_eq(package, section_type, option_name, option_value, s) {
|
||||
/*
|
||||
* create/update corresponding dmmap section that have same config_section link and using param_value_array
|
||||
*/
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap(dmmap_package, section_type, section_name(s))) == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(s));
|
||||
}
|
||||
|
||||
|
|
@ -689,14 +652,12 @@ void synchronize_specific_config_sections_with_dmmap_eq_no_delete(char *package,
|
|||
struct uci_section *s, *dmmap_sect;
|
||||
char *v;
|
||||
|
||||
dmmap_file_path_get(dmmap_package);
|
||||
|
||||
uci_foreach_option_eq(package, section_type, option_name, option_value, s) {
|
||||
/*
|
||||
* create/update corresponding dmmap section that have same config_section link and using param_value_array
|
||||
*/
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap(dmmap_package, section_type, section_name(s))) == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(s));
|
||||
}
|
||||
}
|
||||
|
|
@ -715,14 +676,12 @@ void synchronize_specific_config_sections_with_dmmap_cont(char *package, char *s
|
|||
struct uci_section *s, *stmp, *dmmap_sect;
|
||||
char *v;
|
||||
|
||||
dmmap_file_path_get(dmmap_package);
|
||||
|
||||
uci_foreach_option_cont(package, section_type, option_name, option_value, s) {
|
||||
/*
|
||||
* create/update corresponding dmmap section that have same config_section link and using param_value_array
|
||||
*/
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap(dmmap_package, section_type, section_name(s))) == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, "section_name", section_name(s));
|
||||
}
|
||||
|
||||
|
|
@ -762,11 +721,8 @@ int synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_packag
|
|||
struct sysfs_dmsection *p, *tmp;
|
||||
LIST_HEAD(dup_list_no_inst);
|
||||
|
||||
|
||||
dmmap_file_path_get(dmmap_package);
|
||||
|
||||
sysfs_foreach_file(sysfsrep, dir, ent) {
|
||||
if(strcmp(ent->d_name, ".")==0 || strcmp(ent->d_name, "..")==0)
|
||||
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
|
|
@ -774,7 +730,7 @@ int synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_packag
|
|||
*/
|
||||
dmasprintf(&sysfs_rep_path, "%s/%s", sysfsrep, ent->d_name);
|
||||
if ((dmmap_sect = get_dup_section_in_dmmap_opt(dmmap_package, dmmap_section, opt_name, sysfs_rep_path)) == NULL) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, dmmap_section, &dmmap_sect, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, dmmap_section, &dmmap_sect);
|
||||
dmuci_set_value_by_section_bbfdm(dmmap_sect, opt_name, sysfs_rep_path);
|
||||
}
|
||||
|
||||
|
|
@ -855,10 +811,24 @@ void get_config_section_of_dmmap_section(char* package, char* section_type, char
|
|||
*config_section = NULL;
|
||||
}
|
||||
|
||||
void check_create_dmmap_package(char *dmmap_package)
|
||||
char *check_create_dmmap_package(const char *dmmap_package)
|
||||
{
|
||||
char *dmmap_file_path = dmmap_file_path_get(dmmap_package);
|
||||
dmfree(dmmap_file_path);
|
||||
char *path;
|
||||
int rc;
|
||||
|
||||
rc = dmasprintf(&path, "/etc/bbfdm/%s", dmmap_package);
|
||||
if (rc == -1)
|
||||
return NULL;
|
||||
|
||||
if (access(path, F_OK)) {
|
||||
/*
|
||||
*File does not exist
|
||||
**/
|
||||
FILE *fp = fopen(path, "w"); // new empty file
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
int is_section_unnamed(char *section_name)
|
||||
|
|
@ -920,12 +890,11 @@ void delete_sections_save_next_sections(char* dmmap_package, char *section_type,
|
|||
|
||||
void update_dmmap_sections(struct list_head *dup_list, char *instancename, char* dmmap_package, char *section_type)
|
||||
{
|
||||
struct uci_section *dm_sect;
|
||||
char *v;
|
||||
struct uci_section *dm_sect = NULL;
|
||||
struct dmmap_sect *p = NULL;
|
||||
|
||||
list_for_each_entry(p, dup_list, list) {
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dm_sect, &v);
|
||||
dmuci_add_section_bbfdm(dmmap_package, section_type, &dm_sect);
|
||||
dmuci_set_value_by_section(dm_sect, "section_name", p->section_name);
|
||||
dmuci_set_value_by_section(dm_sect, instancename, p->instance);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type
|
|||
void get_dmmap_section_of_config_section_eq(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section);
|
||||
void get_dmmap_section_of_config_section_cont(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section);
|
||||
void get_config_section_of_dmmap_section(char* package, char* section_type, char *section_name, struct uci_section **config_section);
|
||||
void check_create_dmmap_package(char *dmmap_package);
|
||||
char *check_create_dmmap_package(const char *dmmap_package);
|
||||
int is_section_unnamed(char *section_name);
|
||||
void delete_sections_save_next_sections(char* dmmap_package, char *section_type, char *instancename, char *section_name, int instance, struct list_head *dup_list);
|
||||
void update_dmmap_sections(struct list_head *dup_list, char *instancename, char* dmmap_package, char *section_type);
|
||||
|
|
@ -305,7 +305,6 @@ int command_exec_output_to_array(char *cmd, char **output, int *length);
|
|||
int bbf_api_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);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ int dmuci_del_list_value(char *package, char *section, char *option, char *value
|
|||
}
|
||||
|
||||
/****** UCI ADD *******/
|
||||
char *dmuci_add_section(char *package, char *stype, struct uci_section **s, char **value)
|
||||
char *dmuci_add_section(char *package, char *stype, struct uci_section **s)
|
||||
{
|
||||
struct uci_ptr ptr = {0};
|
||||
char *fname, *val = "";
|
||||
|
|
@ -442,7 +442,6 @@ char *dmuci_add_section(char *package, char *stype, struct uci_section **s, char
|
|||
&& uci_add_section(uci_ctx, ptr.p, stype, s) == UCI_OK)
|
||||
val = dmstrdup((*s)->e.name);
|
||||
|
||||
*value = val;
|
||||
return val;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,12 +217,12 @@ int dmuci_del_list_value_##UCI_PATH(char *package, char *section, char *option,
|
|||
uci_ctx = save_uci_ctx; \
|
||||
return res; \
|
||||
}\
|
||||
char * dmuci_add_section_##UCI_PATH(char *package, char *stype, struct uci_section **s, char **value)\
|
||||
char *dmuci_add_section_##UCI_PATH(char *package, char *stype, struct uci_section **s)\
|
||||
{\
|
||||
struct uci_context *save_uci_ctx; \
|
||||
save_uci_ctx = uci_ctx; \
|
||||
uci_ctx = uci_ctx_##UCI_PATH; \
|
||||
char *name = dmuci_add_section(package, stype, s, value); \
|
||||
char *name = dmuci_add_section(package, stype, s); \
|
||||
uci_ctx = save_uci_ctx; \
|
||||
return name; \
|
||||
}\
|
||||
|
|
@ -298,7 +298,7 @@ int dmuci_get_option_value_list(char *package, char *section, char *option, stru
|
|||
char *dmuci_set_value(char *package, char *section, char *option, char *value);
|
||||
int dmuci_add_list_value(char *package, char *section, char *option, char *value);
|
||||
int dmuci_del_list_value(char *package, char *section, char *option, char *value);
|
||||
char *dmuci_add_section(char *package, char *stype, struct uci_section **s, char **value);
|
||||
char *dmuci_add_section(char *package, char *stype, struct uci_section **s);
|
||||
int dmuci_delete(char *package, char *section, char *option, char *value);
|
||||
int dmuci_get_value_by_section_string(struct uci_section *s, char *option, char **value);
|
||||
char *dmuci_get_value_by_section_fallback_def(struct uci_section *s, char *option, char *default_value);
|
||||
|
|
@ -315,7 +315,7 @@ int dmuci_commit_package(char *package);
|
|||
int dmuci_get_option_value_string_bbfdm(char *package, char *section, char *option, char **value);
|
||||
char *dmuci_set_value_bbfdm(char *package, char *section, char *option, char *value);
|
||||
char *dmuci_set_value_by_section_bbfdm(struct uci_section *s, char *option, char *value);
|
||||
char * dmuci_add_section_bbfdm(char *package, char *stype, struct uci_section **s, char **value);
|
||||
char *dmuci_add_section_bbfdm(char *package, char *stype, struct uci_section **s);
|
||||
int dmuci_delete_bbfdm(char *package, char *section, char *option, char *value);
|
||||
int dmuci_delete_by_section_unnamed_bbfdm(struct uci_section *s, char *option, char *value);
|
||||
int dmuci_delete_by_section_bbfdm(struct uci_section *s, char *option, char *value);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue