From 694f363934e4e1e8808d3df6f038bab6b7e52eb6 Mon Sep 17 00:00:00 2001 From: Amin Ben Romdhane Date: Thu, 16 May 2024 16:52:39 +0200 Subject: [PATCH] Move TR-143 Data Model to tr143d --- README.md | 1 + bbfdmd/ubus/bbfdmd.c | 21 +- bbfdmd/ubus/plugin.c | 25 +- libbbfdm/CMakeLists.txt | 49 +- libbbfdm/dmtree/tr143/diagnostics.c | 2676 --------------------- libbbfdm/dmtree/tr143/diagnostics.h | 33 - libbbfdm/dmtree/tr181/ip.c | 6 - libbbfdm/scripts/bbf_activate_handler.sh | 2 +- libbbfdm/scripts/bbf_diag/ipping | 223 -- libbbfdm/scripts/bbf_diag/serverselection | 243 -- libbbfdm/scripts/bbf_diag/udpecho | 201 -- libbbfdm/scripts/download | 235 -- libbbfdm/scripts/traceroute | 180 -- libbbfdm/scripts/upload | 236 -- tools/tools_input.json | 8 + 15 files changed, 59 insertions(+), 4080 deletions(-) delete mode 100644 libbbfdm/dmtree/tr143/diagnostics.c delete mode 100644 libbbfdm/dmtree/tr143/diagnostics.h delete mode 100755 libbbfdm/scripts/bbf_diag/ipping delete mode 100755 libbbfdm/scripts/bbf_diag/serverselection delete mode 100755 libbbfdm/scripts/bbf_diag/udpecho delete mode 100755 libbbfdm/scripts/download delete mode 100755 libbbfdm/scripts/traceroute delete mode 100755 libbbfdm/scripts/upload diff --git a/README.md b/README.md index 1a3c2091..7ada7f3f 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ All supported tools are presented in this file[BBFDM Tools](./tools/README.md) | Device.SSH. | sshmngr | https://dev.iopsys.eu/network/sshmngr.git | | Device.USB. | usbmngr | https://dev.iopsys.eu/system/usbmngr.git | | Device.Bridging. | bridgemngr | https://dev.iopsys.eu/network/bridgemngr.git | +| Device.IP.Diagnostics. | tr143 | https://dev.iopsys.eu/bbf/tr143d.git | | Device.IP.Diagnostics.IPLayerCapacityMetrics. | tr471 | https://dev.iopsys.eu/bbf/tr471d.git | | Device.X_IOPSYS_EU_IGMP. | mcastmngr | https://dev.iopsys.eu/hal/mcastmngr.git | | Device.X_IOPSYS_EU_MLD. | mcastmngr | https://dev.iopsys.eu/hal/mcastmngr.git | diff --git a/bbfdmd/ubus/bbfdmd.c b/bbfdmd/ubus/bbfdmd.c index 03d008dd..2ae8100c 100644 --- a/bbfdmd/ubus/bbfdmd.c +++ b/bbfdmd/ubus/bbfdmd.c @@ -1528,14 +1528,14 @@ static int _parse_daemon_output_options(bbfdm_config_t *config, json_object *dae strncpyt(config->out_root_obj, BBFDM_DEFAULT_UBUS_OBJ, sizeof(config->out_root_obj)); } - // for main process ubus object name - if (is_micro_service == false) { - opt_val = dmjson_get_value(daemon_obj, 2, "output", "name"); - if (strlen(opt_val)) { - strncpyt(config->out_name, opt_val, sizeof(config->out_name)); - } else { - strncpyt(config->out_name, BBFDM_DEFAULT_UBUS_OBJ, sizeof(config->out_name)); - } + opt_val = dmjson_get_value(daemon_obj, 2, "output", "name"); + if (strlen(opt_val)) { + snprintf(config->out_name, sizeof(config->out_name), "%s%s%s", + is_micro_service ? config->out_root_obj : opt_val, + is_micro_service ? "." : "", + is_micro_service ? opt_val : ""); + } else { + snprintf(config->out_name, sizeof(config->out_name), "%s", is_micro_service ? "" : BBFDM_DEFAULT_UBUS_OBJ); } return 0; @@ -1842,7 +1842,10 @@ int main(int argc, char **argv) goto exit; } - snprintf(log_level, sizeof(log_level), "bbfdm.%s", bbfdm_ctx.config.service_name); + snprintf(log_level, sizeof(log_level), "bbfdm%s%s", + is_micro_service ? "." : "", + is_micro_service ? bbfdm_ctx.config.service_name : ""); + openlog(log_level, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); if (cli_argc) { diff --git a/bbfdmd/ubus/plugin.c b/bbfdmd/ubus/plugin.c index 64d301a7..35c082d4 100644 --- a/bbfdmd/ubus/plugin.c +++ b/bbfdmd/ubus/plugin.c @@ -33,6 +33,8 @@ static uint8_t find_number_of_objects(DM_MAP_OBJ *dynamic_obj) static void fill_dotso_micro_service_out_args(bbfdm_config_t *config, DMOBJ *entryobj, char *parent_dm, int *idx) { + char ms_name[128] = {0}; + if (!config || !entryobj || !parent_dm || !idx || *idx >= MAX_OBJS) return; @@ -45,13 +47,16 @@ static void fill_dotso_micro_service_out_args(bbfdm_config_t *config, DMOBJ *ent strncpyt(config->out_objects[(*idx)++], entryobj->obj, sizeof(config->out_objects[0])); - int len = DM_STRLEN(config->out_name); + int len = DM_STRLEN(ms_name); if (len == 0) { - snprintf(config->out_name, sizeof(config->out_name), "%s.%s", config->out_root_obj, entryobj->obj); + snprintf(ms_name, sizeof(ms_name), "%s.%s", config->out_root_obj, entryobj->obj); } else { - snprintf(config->out_name + len, sizeof(config->out_name) - len, "_%s", entryobj->obj); + snprintf(ms_name + len, sizeof(ms_name) - len, "_%s", entryobj->obj); } } + + if (DM_STRLEN(config->out_name) == 0) + strncpyt(config->out_name, ms_name, sizeof(config->out_name)); } int load_dotso_plugin(void **lib_handle, const char *file_path, bbfdm_config_t *config, DMOBJ **main_entry) @@ -129,7 +134,7 @@ int free_dotso_plugin(void *lib_handle) return 0; } -static void fill_json_micro_service_out_args(bbfdm_config_t *config, char *parent_dm, char *obj, int idx) +static void fill_json_micro_service_out_args(bbfdm_config_t *config, char *parent_dm, char *obj, int idx, char *ms_name, size_t ms_name_len) { if (!config || !obj || idx >= MAX_OBJS) return; @@ -137,11 +142,11 @@ static void fill_json_micro_service_out_args(bbfdm_config_t *config, char *paren strncpyt(config->out_parent_dm, parent_dm, sizeof(config->out_parent_dm)); strncpyt(config->out_objects[idx], obj, sizeof(config->out_objects[idx])); - int len = DM_STRLEN(config->out_name); + int len = DM_STRLEN(ms_name); if (len == 0) { - snprintf(config->out_name, sizeof(config->out_name), "%s.%s", config->out_root_obj, obj); + snprintf(ms_name, ms_name_len, "%s.%s", config->out_root_obj, obj); } else { - snprintf(config->out_name + len, sizeof(config->out_name) - len, "_%s", obj); + snprintf(ms_name + len, ms_name_len - len, "_%s", obj); } } @@ -150,6 +155,7 @@ int load_json_plugin(struct list_head *json_plugin, struct list_head *json_list, { DMOBJ *dm_entryobj = NULL; int json_plugin_version = JSON_VERSION_0; + char ms_name[128] = {0}; uint8_t idx = 0; if (!file_path || !strlen(file_path) || !main_entry) { @@ -202,7 +208,7 @@ int load_json_plugin(struct list_head *json_plugin, struct list_head *json_list, // Fill out arguments if it is running as micro-service if (is_micro_service == true) - fill_json_micro_service_out_args(config, obj_prefix, obj_name, idx); + fill_json_micro_service_out_args(config, obj_prefix, obj_name, idx, ms_name, sizeof(ms_name)); // Remove '.' from object prefix if (obj_prefix[obj_prefix_len - 1] == '.') @@ -227,6 +233,9 @@ int load_json_plugin(struct list_head *json_plugin, struct list_head *json_list, idx++; } + if (DM_STRLEN(config->out_name) == 0) + strncpyt(config->out_name, ms_name, sizeof(config->out_name)); + *main_entry = dm_entryobj; return 0; } diff --git a/libbbfdm/CMakeLists.txt b/libbbfdm/CMakeLists.txt index c8271281..8fb95927 100644 --- a/libbbfdm/CMakeLists.txt +++ b/libbbfdm/CMakeLists.txt @@ -8,7 +8,6 @@ ADD_DEFINITIONS(-DBBF_VENDOR_PREFIX="${BBF_VENDOR_PREFIX}") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SOURCE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree") OPTION(BBF_TR181 "build with tr181 datamodel" ON) -OPTION(BBF_TR143 "build with tr143 datamodel" ON) OPTION(BBF_WIFI_DATAELEMENTS "build with wifi dataelements datamodel" ON) SET(BBF_DM_SOURCES dmlayer.c) @@ -22,13 +21,7 @@ IF(BBF_TR181) ENDIF(BBF_WIFI_DATAELEMENTS) ENDIF(BBF_TR181) -IF(BBF_TR143) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr143") - FILE(GLOB BBF_TR143_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr143/*.c) - add_compile_definitions(BBF_TR143) -ENDIF(BBF_TR143) - -ADD_LIBRARY(bbfdm SHARED ${BBF_DM_SOURCES} ${BBF_TR181_SOURCES} ${BBF_TR143_SOURCES}) +ADD_LIBRARY(bbfdm SHARED ${BBF_DM_SOURCES} ${BBF_TR181_SOURCES}) TARGET_LINK_LIBRARIES(bbfdm uci ubus ubox json-c blobmsg_json m bbfdm-api ssl crypto) @@ -42,29 +35,27 @@ INSTALL(DIRECTORY DESTINATION etc/bbfdm) INSTALL(DIRECTORY DESTINATION etc/bbfdm/dmmap) INSTALL(DIRECTORY DESTINATION usr/share/bbfdm/plugins) -IF(BBF_TR143) - INSTALL(DIRECTORY DESTINATION usr/share/bbfdm) - INSTALL(DIRECTORY DESTINATION usr/libexec/rpcd) - FILE(GLOB scripts scripts/*) +INSTALL(DIRECTORY DESTINATION usr/share/bbfdm) +INSTALL(DIRECTORY DESTINATION usr/libexec/rpcd) +FILE(GLOB scripts scripts/*) - FOREACH(script ${scripts}) - IF(IS_DIRECTORY ${script}) - INSTALL(DIRECTORY ${script} - DESTINATION usr/share/bbfdm/scripts - ) - ELSE() - INSTALL(FILES ${script} - PERMISSIONS OWNER_EXECUTE - DESTINATION usr/share/bbfdm/scripts - ) - ENDIF() - ENDFOREACH() +FOREACH(script ${scripts}) + IF(IS_DIRECTORY ${script}) + INSTALL(DIRECTORY ${script} + DESTINATION usr/share/bbfdm/scripts + ) + ELSE() + INSTALL(FILES ${script} + PERMISSIONS OWNER_EXECUTE + DESTINATION usr/share/bbfdm/scripts + ) + ENDIF() +ENDFOREACH() - INSTALL(FILES scripts/bbf.diag - PERMISSIONS OWNER_EXECUTE - DESTINATION usr/libexec/rpcd - ) -ENDIF(BBF_TR143) +INSTALL(FILES scripts/bbf.diag + PERMISSIONS OWNER_EXECUTE + DESTINATION usr/libexec/rpcd +) string(REPLACE "," ";" VENDOR_LIST ${BBF_VENDOR_LIST}) diff --git a/libbbfdm/dmtree/tr143/diagnostics.c b/libbbfdm/dmtree/tr143/diagnostics.c deleted file mode 100644 index cb922614..00000000 --- a/libbbfdm/dmtree/tr143/diagnostics.c +++ /dev/null @@ -1,2676 +0,0 @@ -/* - * Copyright (C) 2019 iopsys Software Solutions AB - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation - * - * Author: Amin Ben Ramdhane - * - */ - -#include "diagnostics.h" - -#define TRACEROUTE_DIAGNOSTIC_PATH BBFDM_SCRIPTS_PATH"/traceroute" -#define DOWNLOAD_DIAGNOSTIC_PATH BBFDM_SCRIPTS_PATH"/download" -#define UPLOAD_DIAGNOSTIC_PATH BBFDM_SCRIPTS_PATH"/upload" - -/************************************************************* -* COMMON FUNCTIONS -**************************************************************/ -static int get_diag_enable_true(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = "1"; - return 0; -} - -static void stop_traceroute_diagnostics(void) -{ - char cmd[256] = {0}; - - snprintf(cmd, sizeof(cmd), "sh %s '{\"proto\":\"both_proto\",\"cancel\":\"1\"}'", TRACEROUTE_DIAGNOSTIC_PATH); - system(cmd); -} - -/************************************************************* -* GET & SET PARAM -**************************************************************/ -/* - * *** Device.IP.Diagnostics.IPPing. *** - */ - -static int get_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - char *val = diagnostics_get_option_fallback_def("ipping", "DiagnosticState", "None"); - if (DM_STRSTR(val, "Requested") != NULL) - *value = dmstrdup("Requested"); - else - *value = dmstrdup(val); - - return 0; -} - -static int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, DiagnosticsState, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - if (DM_LSTRCMP(value, "Requested") == 0) { - diagnostics_set_option("ipping", "DiagnosticState", value); - } else if (DM_LSTRCMP(value, "Canceled") == 0) { - diagnostics_set_option("ipping", "DiagnosticState", "None"); - dmubus_call_set("bbf.diag", "ipping", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - } - return 0; - } - return 0; -} - -static int get_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - char *linker = diagnostics_get_option("ipping", "interface"); - _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); - return 0; -} - -static int set_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *allowed_objects[] = {"Device.IP.Interface.", NULL}; - struct dm_reference reference = {0}; - - bbfdm_get_reference_linker(ctx, value, &reference); - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, reference.path, -1, 256, NULL, NULL)) - return FAULT_9007; - - if (dm_validate_allowed_objects(ctx, &reference, allowed_objects)) - return FAULT_9007; - - return 0; - case VALUESET: - diagnostics_reset_state("ipping"); - dmubus_call_set("bbf.diag", "ipping", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("ipping", "interface", reference.value); - return 0; - } - return 0; -} - -static int get_ip_ping_protocolversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "ProtocolVersion", "Any"); - return 0; -} - -static int set_ip_ping_protocolversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *ProtocolVersion[] = {"Any", "IPv4", "IPv6", NULL}; - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, ProtocolVersion, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("ipping"); - dmubus_call_set("bbf.diag", "ipping", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("ipping", "ProtocolVersion", value); - return 0; - } - return 0; -} - -static int get_ip_ping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("ipping", "Host"); - return 0; -} - -static int set_ip_ping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, 256, NULL, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("ipping"); - dmubus_call_set("bbf.diag", "ipping", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("ipping", "Host", value); - return 0; - } - return 0; -} - -static int get_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "NumberOfRepetitions", "3"); - return 0; -} - -static int set_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1",NULL}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("ipping"); - dmubus_call_set("bbf.diag", "ipping", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("ipping", "NumberOfRepetitions", value); - return 0; - } - return 0; -} - -static int get_ip_ping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "Timeout", "1000"); - return 0; -} - -static int set_ip_ping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1",NULL}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("ipping"); - dmubus_call_set("bbf.diag", "ipping", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("ipping", "Timeout", value); - return 0; - } - return 0; -} - -static int get_ip_ping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "DataBlockSize", "64"); - return 0; -} - -static int set_ip_ping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1","65535"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("ipping"); - dmubus_call_set("bbf.diag", "ipping", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("ipping", "DataBlockSize", value); - return 0; - } - return 0; -} - -static int get_ip_ping_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "DSCP", "0"); - return 0; -} - -static int set_ip_ping_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"0","63"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("ipping"); - dmubus_call_set("bbf.diag", "ipping", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("ipping", "DSCP", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsIPPing_IPAddressUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("ipping", "IPAddressUsed"); - return 0; -} - -static int get_ip_ping_success_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "SuccessCount", "0"); - return 0; -} - -static int get_ip_ping_failure_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "FailureCount", "0"); - return 0; -} - -static int get_ip_ping_average_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "AverageResponseTime", "0"); - return 0; -} - -static int get_ip_ping_min_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "MinimumResponseTime", "0"); - return 0; -} - -static int get_ip_ping_max_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "MaximumResponseTime", "0"); - return 0; -} - -static int get_ip_ping_AverageResponseTimeDetailed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "AverageResponseTimeDetailed", "0"); - return 0; -} - -static int get_ip_ping_MinimumResponseTimeDetailed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "MinimumResponseTimeDetailed", "0"); - return 0; -} - -static int get_ip_ping_MaximumResponseTimeDetailed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("ipping", "MaximumResponseTimeDetailed", "0"); - return 0; -} - -/* - * *** Device.IP.Diagnostics.TraceRoute. *** - */ - -static int get_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - char *val = diagnostics_get_option_fallback_def("traceroute", "DiagnosticState", "None"); - if (DM_STRSTR(val, "Requested") != NULL) - *value = dmstrdup("Requested"); - else - *value = dmstrdup(val); - - return 0; -} - -static int set_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, DiagnosticsState, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - if (DM_LSTRCMP(value, "Requested") == 0) { - diagnostics_set_option("traceroute", "DiagnosticState", value); - } else if (DM_LSTRCMP(value, "Canceled") == 0) { - diagnostics_set_option("traceroute", "DiagnosticState", "None"); - stop_traceroute_diagnostics(); - } - return 0; - } - return 0; -} - -static int get_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - char *linker = diagnostics_get_option("traceroute", "interface"); - _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); - return 0; -} - -static int set_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *allowed_objects[] = {"Device.IP.Interface.", NULL}; - struct dm_reference reference = {0}; - - bbfdm_get_reference_linker(ctx, value, &reference); - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, reference.path, -1, 256, NULL, NULL)) - return FAULT_9007; - - if (dm_validate_allowed_objects(ctx, &reference, allowed_objects)) - return FAULT_9007; - - return 0; - case VALUESET: - diagnostics_reset_state("traceroute"); - stop_traceroute_diagnostics(); - diagnostics_set_option("traceroute", "interface", reference.value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsTraceRoute_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("traceroute", "ProtocolVersion", "Any"); - return 0; -} - -static int set_IPDiagnosticsTraceRoute_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *ProtocolVersion[] = {"Any", "IPv4", "IPv6", NULL}; - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, ProtocolVersion, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("traceroute"); - stop_traceroute_diagnostics(); - diagnostics_set_option("traceroute", "ProtocolVersion", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsTraceRoute_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("traceroute", "Host"); - return 0; -} - -static int set_IPDiagnosticsTraceRoute_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, 256, NULL, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("traceroute"); - stop_traceroute_diagnostics(); - diagnostics_set_option("traceroute", "Host", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsTraceRoute_NumberOfTries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("traceroute", "NumberOfTries", "3"); - return 0; -} - -static int set_IPDiagnosticsTraceRoute_NumberOfTries(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1","3"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("traceroute"); - stop_traceroute_diagnostics(); - diagnostics_set_option("traceroute", "NumberOfTries", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsTraceRoute_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("traceroute", "Timeout", "5000"); - return 0; -} - -static int set_IPDiagnosticsTraceRoute_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1",NULL}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("traceroute"); - stop_traceroute_diagnostics(); - diagnostics_set_option("traceroute", "Timeout", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsTraceRoute_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("traceroute", "DataBlockSize", "38"); - return 0; -} - -static int set_IPDiagnosticsTraceRoute_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1","65535"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("traceroute"); - stop_traceroute_diagnostics(); - diagnostics_set_option("traceroute", "DataBlockSize", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsTraceRoute_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("traceroute", "DSCP", "0"); - return 0; -} - -static int set_IPDiagnosticsTraceRoute_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"0","63"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("traceroute"); - stop_traceroute_diagnostics(); - diagnostics_set_option("traceroute", "DSCP", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsTraceRoute_MaxHopCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("traceroute", "MaxHops", "30"); - return 0; -} - -static int set_IPDiagnosticsTraceRoute_MaxHopCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1","64"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("traceroute"); - stop_traceroute_diagnostics(); - diagnostics_set_option("traceroute", "MaxHops", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsTraceRoute_ResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("traceroute", "ResponseTime", "0"); - return 0; -} - -static int get_IPDiagnosticsTraceRoute_IPAddressUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("traceroute", "IPAddressUsed"); - return 0; -} - -static int get_IPDiagnosticsTraceRoute_RouteHopsNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("traceroute", "NumberOfHops", "0"); - return 0; -} - -static int get_IPDiagnosticsTraceRouteRouteHops_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - dmuci_get_value_by_section_string((struct uci_section *)data, "host", value); - return 0; -} - -static int get_IPDiagnosticsTraceRouteRouteHops_HostAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - dmuci_get_value_by_section_string((struct uci_section *)data, "ip", value); - return 0; -} - -static int get_IPDiagnosticsTraceRouteRouteHops_ErrorCode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = "0"; - return 0; -} - -static int get_IPDiagnosticsTraceRouteRouteHops_RTTimes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - dmuci_get_value_by_section_string((struct uci_section *)data, "time", value); - return 0; -} - -/* - * *** Device.IP.Diagnostics.DownloadDiagnostics. *** - */ - -static int get_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "DiagnosticState", "None"); - return 0; -} - -static int set_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, DiagnosticsState, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - if (DM_LSTRCMP(value, "Requested") == 0) - diagnostics_set_option("download", "DiagnosticState", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - char *linker = diagnostics_get_option("download", "interface"); - _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); - return 0; -} - -static int set_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *allowed_objects[] = {"Device.IP.Interface.", NULL}; - struct dm_reference reference = {0}; - - bbfdm_get_reference_linker(ctx, value, &reference); - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, reference.path, -1, 256, NULL, NULL)) - return FAULT_9007; - - if (dm_validate_allowed_objects(ctx, &reference, allowed_objects)) - return FAULT_9007; - - return 0; - case VALUESET: - diagnostics_reset_state("download"); - diagnostics_set_option("download", "interface", reference.value); - } - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_DownloadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("download", "url"); - return 0; -} - -static int set_IPDiagnosticsDownloadDiagnostics_DownloadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, 256, NULL, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("download"); - diagnostics_set_option("download", "url", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_DownloadTransports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = "HTTP,FTP"; - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_DownloadDiagnosticMaxConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = "1"; - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "DSCP", "0"); - return 0; -} - -static int set_IPDiagnosticsDownloadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"0","63"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("download"); - diagnostics_set_option("download", "DSCP", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "ethernetpriority", "0"); - return 0; -} - -static int set_IPDiagnosticsDownloadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"0","7"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("download"); - diagnostics_set_option("download", "ethernetpriority", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "ProtocolVersion", "Any"); - return 0; -} - -static int set_IPDiagnosticsDownloadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *ProtocolVersion[] = {"Any", "IPv4", "IPv6", NULL}; - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, ProtocolVersion, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("download"); - diagnostics_set_option("download", "ProtocolVersion", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "NumberOfConnections", "1"); - return 0; -} - -static int set_IPDiagnosticsDownloadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1",NULL}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("download"); - diagnostics_set_option("download", "NumberOfConnections", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_IPAddressUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("download", "IPAddressUsed"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "ROMTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "BOMTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "EOMTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_TestBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "TestBytesReceived", "0"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "TotalBytesReceived", "0"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "TotalBytesSent", "0"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_TestBytesReceivedUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "TestBytesReceived", "0"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_TotalBytesReceivedUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "TotalBytesReceived", "0"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_TotalBytesSentUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "TotalBytesSent", "0"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_PeriodOfFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "PeriodOfFullLoading", "0"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "TCPOpenRequestTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "TCPOpenResponseTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_PerConnectionResultNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - bool b; - char *tmp = diagnostics_get_option("download", "EnablePerConnection"); - string_to_bool(tmp, &b); - *value = (b) ? "1" : "0"; - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("download", "EnablePerConnection", "0"); - return 0; -} - -static int set_IPDiagnosticsDownloadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_boolean(ctx, value)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("download"); - diagnostics_set_option("download", "EnablePerConnection", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "ROMtime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "BOMtime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "EOMtime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TestBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TestBytesReceived", "0"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TotalBytesReceived", "0"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TotalBytesSent", "0"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TCPOpenRequestTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TCPOpenResponseTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -/* - * *** Device.IP.Diagnostics.UploadDiagnostics. *** - */ - -static int get_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "DiagnosticState", "None"); - return 0; -} - -static int set_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, DiagnosticsState, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - if (DM_LSTRCMP(value, "Requested") == 0) - diagnostics_set_option("upload", "DiagnosticState", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - char *linker = diagnostics_get_option("upload", "interface"); - _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); - return 0; -} - -static int set_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *allowed_objects[] = {"Device.IP.Interface.", NULL}; - struct dm_reference reference = {0}; - - bbfdm_get_reference_linker(ctx, value, &reference); - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, reference.path, -1, 256, NULL, NULL)) - return FAULT_9007; - - if (dm_validate_allowed_objects(ctx, &reference, allowed_objects)) - return FAULT_9007; - - return 0; - case VALUESET: - diagnostics_reset_state("upload"); - diagnostics_set_option("upload", "interface", reference.value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_UploadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("upload", "url"); - return 0; -} - -static int set_IPDiagnosticsUploadDiagnostics_UploadURL(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, 256, NULL, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("upload"); - diagnostics_set_option("upload", "url", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_UploadTransports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = "HTTP,FTP"; - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "DSCP", "0"); - return 0; -} - -static int set_IPDiagnosticsUploadDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"0","63"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("upload"); - diagnostics_set_option("upload", "DSCP", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "ethernetpriority", "0"); - return 0; -} - -static int set_IPDiagnosticsUploadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"0","7"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("upload"); - diagnostics_set_option("upload", "ethernetpriority", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_TestFileLength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TestFileLength", "0"); - return 0; -} - -static int set_IPDiagnosticsUploadDiagnostics_TestFileLength(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{NULL,NULL}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("upload"); - diagnostics_set_option("upload", "TestFileLength", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "ProtocolVersion", "Any"); - return 0; -} - -static int set_IPDiagnosticsUploadDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *ProtocolVersion[] = {"Any", "IPv4", "IPv6", NULL}; - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, ProtocolVersion, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("upload"); - diagnostics_set_option("upload", "ProtocolVersion", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "NumberOfConnections", "1"); - return 0; -} - -static int set_IPDiagnosticsUploadDiagnostics_NumberOfConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1",NULL}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("upload"); - diagnostics_set_option("upload", "NumberOfConnections", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_IPAddressUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("upload", "IPAddressUsed"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "ROMTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "BOMTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "EOMTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_TestBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TestBytesSent", "0"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TotalBytesReceived", "0"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TotalBytesSent", "0"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_TestBytesSentUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TestBytesSent", "0"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_TotalBytesReceivedUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TotalBytesReceived", "0"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_TotalBytesSentUnderFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TotalBytesSent", "0"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_PeriodOfFullLoading(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload","PeriodOfFullLoading", "0"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TCPOpenRequestTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TCPOpenResponseTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_PerConnectionResultNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - bool b; - char *tmp = diagnostics_get_option("upload", "EnablePerConnection"); - string_to_bool(tmp, &b); - *value = (b) ? "1" : "0"; - return 0; -} - -static int get_IPDiagnosticsUploadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "EnablePerConnection", "0"); - return 0; -} - -static int set_IPDiagnosticsUploadDiagnostics_EnablePerConnectionResults(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_boolean(ctx, value)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("upload"); - diagnostics_set_option("upload", "EnablePerConnection", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_ROMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "ROMtime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "BOMtime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "EOMtime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TestBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TestBytesSent", "0"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TotalBytesReceived", "0"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TotalBytesSent", "0"); - return 0; - -} - -static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TCPOpenRequestTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TCPOpenRequestTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TCPOpenResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("upload", "TCPOpenResponseTime", "0001-01-01T00:00:00.000000Z"); - return 0; -} - -/* - * *** Device.IP.Diagnostics.UDPEchoDiagnostics. *** - */ - -static int get_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - char *val = diagnostics_get_option_fallback_def("udpechodiag", "DiagnosticState", "None"); - if (DM_STRSTR(val, "Requested") != NULL) - *value = dmstrdup("Requested"); - else - *value = dmstrdup(val); - - return 0; -} - -static int set_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, DiagnosticsState, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - if (DM_LSTRCMP(value, "Requested") == 0) { - diagnostics_set_option("udpechodiag", "DiagnosticState", value); - } else if (DM_LSTRCMP(value, "Canceled") == 0) { - diagnostics_set_option("udpechodiag", "DiagnosticState", "None"); - dmubus_call_set("bbf.diag", "udpecho", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - } - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - char *linker = diagnostics_get_option("udpechodiag", "interface"); - _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); - return 0; -} - -static int set_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *allowed_objects[] = {"Device.IP.Interface.", NULL}; - struct dm_reference reference = {0}; - - bbfdm_get_reference_linker(ctx, value, &reference); - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, reference.path, -1, 256, NULL, NULL)) - return FAULT_9007; - - if (dm_validate_allowed_objects(ctx, &reference, allowed_objects)) - return FAULT_9007; - - return 0; - case VALUESET: - diagnostics_reset_state("udpechodiag"); - dmubus_call_set("bbf.diag", "udpecho", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("udpechodiag", "interface", reference.value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("udpechodiag", "Host"); - return 0; -} - -static int set_IPDiagnosticsUDPEchoDiagnostics_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, 256, NULL, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("udpechodiag"); - dmubus_call_set("bbf.diag", "udpecho", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("udpechodiag", "Host", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "port", "7"); - return 0; -} - -static int set_IPDiagnosticsUDPEchoDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1","65535"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("udpechodiag"); - dmubus_call_set("bbf.diag", "udpecho", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("udpechodiag", "port", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "NumberOfRepetitions", "1"); - return 0; -} - -static int set_IPDiagnosticsUDPEchoDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1",NULL}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("udpechodiag"); - dmubus_call_set("bbf.diag", "udpecho", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("udpechodiag", "NumberOfRepetitions", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "Timeout", "5000"); - return 0; -} - -static int set_IPDiagnosticsUDPEchoDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1",NULL}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("udpechodiag"); - dmubus_call_set("bbf.diag", "udpecho", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("udpechodiag", "Timeout", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "DataBlockSize", "24"); - return 0; -} - -static int set_IPDiagnosticsUDPEchoDiagnostics_DataBlockSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1","65535"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("udpechodiag"); - dmubus_call_set("bbf.diag", "udpecho", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("udpechodiag", "DataBlockSize", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "DSCP", "0"); - return 0; -} - -static int set_IPDiagnosticsUDPEchoDiagnostics_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"0","63"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("udpechodiag"); - dmubus_call_set("bbf.diag", "udpecho", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("udpechodiag", "DSCP", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_InterTransmissionTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "InterTransmissionTime", "1000"); - return 0; -} - -static int set_IPDiagnosticsUDPEchoDiagnostics_InterTransmissionTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1","65535"}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("udpechodiag"); - dmubus_call_set("bbf.diag", "udpecho", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("udpechodiag", "InterTransmissionTime", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "ProtocolVersion", "Any"); - return 0; -} - -static int set_IPDiagnosticsUDPEchoDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *ProtocolVersion[] = {"Any", "IPv4", "IPv6", NULL}; - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, ProtocolVersion, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("udpechodiag"); - dmubus_call_set("bbf.diag", "udpecho", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("udpechodiag", "ProtocolVersion", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_IPAddressUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("udpechodiag", "IPAddressUsed"); - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_SuccessCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "SuccessCount", "0"); - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_FailureCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "FailureCount", "0"); - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_AverageResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "AverageResponseTime", "0"); - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_MinimumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "MinimumResponseTime", "0"); - return 0; -} - -static int get_IPDiagnosticsUDPEchoDiagnostics_MaximumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("udpechodiag", "MaximumResponseTime", "0"); - return 0; -} - -/* - * *** Device.IP.Diagnostics.ServerSelectionDiagnostics. *** - */ - -static int get_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - char *val = diagnostics_get_option_fallback_def("serverselection", "DiagnosticState", "None"); - if (DM_STRSTR(val, "Requested") != NULL) - *value = dmstrdup("Requested"); - else - *value = dmstrdup(val); - - return 0; -} - -static int set_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, DiagnosticsState, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - if (DM_LSTRCMP(value, "Requested") == 0) { - diagnostics_set_option("serverselection", "DiagnosticState", value); - } else if (DM_LSTRCMP(value, "Canceled") == 0) { - diagnostics_set_option("serverselection", "DiagnosticState", "None"); - dmubus_call_set("bbf.diag", "serverselection", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - } - return 0; - } - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - char *linker = diagnostics_get_option("serverselection", "interface"); - _bbfdm_get_references(ctx, "Device.IP.Interface.", "Name", linker, value); - return 0; -} - -static int set_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *allowed_objects[] = {"Device.IP.Interface.", NULL}; - struct dm_reference reference = {0}; - - bbfdm_get_reference_linker(ctx, value, &reference); - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, reference.path, -1, 256, NULL, NULL)) - return FAULT_9007; - - if (dm_validate_allowed_objects(ctx, &reference, allowed_objects)) - return FAULT_9007; - - return 0; - case VALUESET: - diagnostics_reset_state("serverselection"); - dmubus_call_set("bbf.diag", "serverselection", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("serverselection", "interface", reference.value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("serverselection", "ProtocolVersion", "Any"); - return 0; -} - -static int set_IPDiagnosticsServerSelectionDiagnostics_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *ProtocolVersion[] = {"Any", "IPv4", "IPv6", NULL}; - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, ProtocolVersion, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("serverselection"); - dmubus_call_set("bbf.diag", "serverselection", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("serverselection", "ProtocolVersion", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("serverselection", "Protocol", "ICMP"); - return 0; -} - -static int set_IPDiagnosticsServerSelectionDiagnostics_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char *ServerSelectionProtocol[] = {"ICMP", "UDP Echo", NULL}; - - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string(ctx, value, -1, -1, ServerSelectionProtocol, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("serverselection"); - dmubus_call_set("bbf.diag", "serverselection", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("serverselection", "Protocol", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_HostList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("serverselection", "HostList"); - return 0; -} - -static int set_IPDiagnosticsServerSelectionDiagnostics_HostList(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_string_list(ctx, value, -1, 10, -1, -1, 256, NULL, NULL)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("serverselection"); - dmubus_call_set("bbf.diag", "serverselection", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("serverselection", "HostList", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("serverselection", "NumberOfRepetitions", "3"); - return 0; -} - -static int set_IPDiagnosticsServerSelectionDiagnostics_NumberOfRepetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1",NULL}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("serverselection"); - dmubus_call_set("bbf.diag", "serverselection", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("serverselection", "NumberOfRepetitions", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("serverselection", "Timeout", "1000"); - return 0; -} - -static int set_IPDiagnosticsServerSelectionDiagnostics_Timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - switch (action) { - case VALUECHECK: - if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"1",NULL}}, 1)) - return FAULT_9007; - return 0; - case VALUESET: - diagnostics_reset_state("serverselection"); - dmubus_call_set("bbf.diag", "serverselection", UBUS_ARGS{{"cancel", "1", String},{"proto", "both_proto", String}}, 2); - diagnostics_set_option("serverselection", "Timeout", value); - return 0; - } - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_FastestHost(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("serverselection", "FastestHost"); - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_MinimumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("serverselection", "MinimumResponseTime", "0"); - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_AverageResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("serverselection", "AverageResponseTime", "0"); - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_MaximumResponseTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option_fallback_def("serverselection", "MaximumResponseTime", "0"); - return 0; -} - -static int get_IPDiagnosticsServerSelectionDiagnostics_IPAddressUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = diagnostics_get_option("serverselection", "IPAddressUsed"); - return 0; -} - -/************************************************************* -* ENTRY METHOD -**************************************************************/ -static int browseIPDiagnosticsTraceRouteRouteHopsInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) -{ - struct uci_section *s = NULL; - char *inst = NULL; - - uci_path_foreach_sections(bbfdm, DMMAP_DIAGNOSTIGS, "RouteHops", s) { - inst = handle_instance(dmctx, parent_node, s, "routehop_instance", "routehop_alias"); - if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, inst) == DM_STOP) - break; - } - return 0; -} - -static int browseIPDiagnosticsDownloadDiagnosticsPerConnectionResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) -{ - struct uci_section *s = NULL; - char *inst = NULL; - - uci_path_foreach_sections(bbfdm, DMMAP_DIAGNOSTIGS, "DownloadPerConnection", s) { - inst = handle_instance(dmctx, parent_node, s, "perconnection_instance", "perconnection_alias"); - if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, inst) == DM_STOP) - break; - } - return 0; -} - -static int browseIPDiagnosticsUploadDiagnosticsPerConnectionResultInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) -{ - struct uci_section *s = NULL; - char *inst = NULL; - - uci_path_foreach_sections(bbfdm, DMMAP_DIAGNOSTIGS, "UploadPerConnection", s) { - inst = handle_instance(dmctx, parent_node, s, "perconnection_instance", "perconnection_alias"); - if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, inst) == DM_STOP) - break; - } - return 0; -} - -/************************************************************* - * OPERATE COMMANDS - *************************************************************/ -static operation_args ip_diagnostics_ipping_args = { - .in = (const char *[]) { - "Interface", - "ProtocolVersion", - "Host", - "NumberOfRepetitions", - "Timeout", - "DataBlockSize", - "DSCP", - NULL - }, - .out = (const char *[]) { - "Status", - "IPAddressUsed", - "SuccessCount", - "FailureCount", - "AverageResponseTime", - "MinimumResponseTime", - "MaximumResponseTime", - "AverageResponseTimeDetailed", - "MinimumResponseTimeDetailed", - "MaximumResponseTimeDetailed", - NULL - } -}; - -static int get_operate_args_IPDiagnostics_IPPing(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = (char *)&ip_diagnostics_ipping_args; - return 0; -} - -static int operate_IPDiagnostics_IPPing(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - json_object *res = NULL; - - char *ipping_host = dmjson_get_value((json_object *)value, 1, "Host"); - if (ipping_host[0] == '\0') { - bbfdm_set_fault_message(ctx, "IPPing: 'Host' input should be defined"); - return USP_FAULT_INVALID_ARGUMENT; - } - - char *ip_interface = dmjson_get_value((json_object *)value, 1, "Interface"); - char *ipping_interface = diagnostics_get_interface_name(ctx, ip_interface); - char *ipping_proto = dmjson_get_value((json_object *)value, 1, "ProtocolVersion"); - char *ipping_nbofrepetition = dmjson_get_value((json_object *)value, 1, "NumberOfRepetitions"); - char *ipping_timeout = dmjson_get_value((json_object *)value, 1, "Timeout"); - char *ipping_datablocksize = dmjson_get_value((json_object *)value, 1, "DataBlockSize"); - char *ipping_dscp = dmjson_get_value((json_object *)value, 1, "DSCP"); - char *proto = (ctx->dm_type == BBFDM_USP) ? "usp" : "both_proto"; - - dmubus_call_blocking("bbf.diag", "ipping", - UBUS_ARGS{ - {"host", ipping_host, String}, - {"iface", ipping_interface, String}, - {"ip_proto", ipping_proto, String}, - {"nbr_of_rep", ipping_nbofrepetition, String}, - {"timeout", ipping_timeout, String}, - {"data_size", ipping_datablocksize, String}, - {"dscp", ipping_dscp, String}, - {"proto", proto, String} - }, - 8, &res); - - if (res == NULL) { - bbfdm_set_fault_message(ctx, "IPPing: ubus 'bbf.diag ipping' method doesn't exist"); - return USP_FAULT_COMMAND_FAILURE; - } - - char *ipping_status = dmjson_get_value(res, 1, "Status"); - char *ipping_ip_address_used = dmjson_get_value(res, 1, "IPAddressUsed"); - char *ipping_success_count = dmjson_get_value(res, 1, "SuccessCount"); - char *ipping_failure_count = dmjson_get_value(res, 1, "FailureCount"); - char *ipping_average_response_time = dmjson_get_value(res, 1, "AverageResponseTime"); - char *ipping_minimum_response_time = dmjson_get_value(res, 1, "MinimumResponseTime"); - char *ipping_maximum_response_time = dmjson_get_value(res, 1, "MaximumResponseTime"); - char *ipping_average_response_time_detailed = dmjson_get_value(res, 1, "AverageResponseTimeDetailed"); - char *ipping_minimum_response_time_detailed = dmjson_get_value(res, 1, "MinimumResponseTimeDetailed"); - char *ipping_maximum_response_time_detailed = dmjson_get_value(res, 1, "MaximumResponseTimeDetailed"); - - add_list_parameter(ctx, dmstrdup("Status"), dmstrdup(ipping_status), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("IPAddressUsed"), dmstrdup(ipping_ip_address_used), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("SuccessCount"), dmstrdup(ipping_success_count), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("FailureCount"), dmstrdup(ipping_failure_count), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("AverageResponseTime"), dmstrdup(ipping_average_response_time), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("MinimumResponseTime"), dmstrdup(ipping_minimum_response_time), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("MaximumResponseTime"), dmstrdup(ipping_maximum_response_time), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("AverageResponseTimeDetailed"), dmstrdup(ipping_average_response_time_detailed), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("MinimumResponseTimeDetailed"), dmstrdup(ipping_minimum_response_time_detailed), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("MaximumResponseTimeDetailed"), dmstrdup(ipping_maximum_response_time_detailed), DMT_TYPE[DMT_UNINT], NULL); - - if (res != NULL) - json_object_put(res); - - return 0; -} - -static operation_args ip_diagnostics_trace_route_args = { - .in = (const char *[]) { - "Interface", - "ProtocolVersion", - "Host", - "NumberOfTries", - "Timeout", - "DataBlockSize", - "DSCP", - "MaxHopCount", - NULL - }, - .out = (const char *[]) { - "Status", - "IPAddressUsed", - "ResponseTime", - "RouteHops.{i}.Host", - "RouteHops.{i}.HostAddress", - "RouteHops.{i}.ErrorCode", - "RouteHops.{i}.RTTimes", - NULL - } -}; - -static int get_operate_args_IPDiagnostics_TraceRoute(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = (char *)&ip_diagnostics_trace_route_args; - return 0; -} - -static int operate_IPDiagnostics_TraceRoute(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - json_object *arr_route_hops = NULL, *route_hops_obj = NULL; - char *route_hops_host[2] = {0}; - char *route_hops_host_address[2] = {0}; - char *route_hops_rttimes[2] = {0}; - char *route_hops_errorcode = NULL; - char input[2048] = {0}; - char output[2048] = {0}; - char cmd[2096] = {0}; - int idx = 0; - - char *host = dmjson_get_value((json_object *)value, 1, "Host"); - if (host[0] == '\0') { - bbfdm_set_fault_message(ctx, "TraceRoute: 'Host' input should be defined"); - return USP_FAULT_INVALID_ARGUMENT; - } - - char *ip_interface = dmjson_get_value((json_object *)value, 1, "Interface"); - char *interface = diagnostics_get_interface_name(ctx, ip_interface); - char *ip_proto = dmjson_get_value((json_object *)value, 1, "ProtocolVersion"); - char *nboftries = dmjson_get_value((json_object *)value, 1, "NumberOfTries"); - char *timeout = dmjson_get_value((json_object *)value, 1, "Timeout"); - char *datablocksize = dmjson_get_value((json_object *)value, 1, "DataBlockSize"); - char *dscp = dmjson_get_value((json_object *)value, 1, "DSCP"); - char *maxhops = dmjson_get_value((json_object *)value, 1, "MaxHopCount"); - - snprintf(input, sizeof(input), "'{\"host\": \"%s\",\"iface\":\"%s\",\"ip_proto\":\"%s\",\"nbr_of_tries\":\"%s\",\"timeout\":\"%s\",\"data_size\":\"%s\",\"dscp\":\"%s\",\"max_hop_cnt\":\"%s\",\"proto\":\"%s\"}'", - host, - interface, - ip_proto, - nboftries, - timeout, - datablocksize, - dscp, - maxhops, - (ctx->dm_type == BBFDM_USP) ? "usp" : "both_proto"); - - snprintf(cmd, sizeof(cmd), "sh %s %s", TRACEROUTE_DIAGNOSTIC_PATH, input); - - if (run_cmd(cmd, output, sizeof(output)) != 0) { - bbfdm_set_fault_message(ctx, "TraceRoute: 'sh %s {input}' command failed to run", TRACEROUTE_DIAGNOSTIC_PATH); - return USP_FAULT_COMMAND_FAILURE; - } - - json_object *res = (DM_STRLEN(output)) ? json_tokener_parse(output) : NULL; - - if (res == NULL) { - bbfdm_set_fault_message(ctx, "TraceRoute: there is no output from '%s' script", TRACEROUTE_DIAGNOSTIC_PATH); - return USP_FAULT_COMMAND_FAILURE; - } - - char *status = dmjson_get_value(res, 1, "Status"); - char *ip_address_used = dmjson_get_value(res, 1, "IPAddressUsed"); - char *response_time = dmjson_get_value(res, 1, "ResponseTime"); - add_list_parameter(ctx, dmstrdup("Status"), dmstrdup(status), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("IPAddressUsed"), dmstrdup(ip_address_used), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("ResponseTime"), dmstrdup(response_time), DMT_TYPE[DMT_UNINT], NULL); - - dmjson_foreach_obj_in_array(res, arr_route_hops, route_hops_obj, idx, 1, "RouteHops") { - int i = idx + 1; - - dmasprintf(&route_hops_host[0], "RouteHops.%d.Host", i); - dmasprintf(&route_hops_host_address[0], "RouteHops.%d.HostAddress", i); - dmasprintf(&route_hops_rttimes[0], "RouteHops.%d.RTTimes", i); - dmasprintf(&route_hops_errorcode, "RouteHops.%d.ErrorCode", i); - - route_hops_host[1] = dmjson_get_value(route_hops_obj, 1, "Host"); - route_hops_host_address[1] = dmjson_get_value(route_hops_obj, 1, "HostAddress"); - route_hops_rttimes[1] = dmjson_get_value(route_hops_obj, 1, "RTTimes"); - - add_list_parameter(ctx, route_hops_host[0], dmstrdup(route_hops_host[1]), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, route_hops_host_address[0], dmstrdup(route_hops_host_address[1]), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, route_hops_rttimes[0], dmstrdup(route_hops_rttimes[1]), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, route_hops_errorcode, "0", DMT_TYPE[DMT_UNINT], NULL); - } - - if (res != NULL) - json_object_put(res); - - return 0; -} - -static operation_args ip_diagnostics_download_args = { - .in = (const char *[]) { - "Interface", - "DownloadURL", - "DSCP", - "EthernetPriority", - "TimeBasedTestDuration", - "TimeBasedTestMeasurementInterval", - "TimeBasedTestMeasurementOffset", - "ProtocolVersion", - "NumberOfConnections", - "EnablePerConnectionResults", - NULL - }, - .out = (const char *[]) { - "Status", - "IPAddressUsed", - "ROMTime", - "BOMTime", - "EOMTime", - "TestBytesReceived", - "TotalBytesReceived", - "TotalBytesSent", - "TestBytesReceivedUnderFullLoading", - "TotalBytesReceivedUnderFullLoading", - "TotalBytesSentUnderFullLoading", - "PeriodOfFullLoading", - "TCPOpenRequestTime", - "TCPOpenResponseTime", - "PerConnectionResult.{i}.ROMTime", - "PerConnectionResult.{i}.BOMTime", - "PerConnectionResult.{i}.EOMTime", - "PerConnectionResult.{i}.TestBytesReceived", - "PerConnectionResult.{i}.TotalBytesReceived", - "PerConnectionResult.{i}.TotalBytesSent", - "PerConnectionResult.{i}.TCPOpenRequestTime", - "PerConnectionResult.{i}.TCPOpenResponseTime", - "IncrementalResult.{i}.TestBytesReceived", - "IncrementalResult.{i}.TotalBytesReceived", - "IncrementalResult.{i}.TotalBytesSent", - "IncrementalResult.{i}.StartTime", - "IncrementalResult.{i}.EndTime", - NULL - } -}; - -static int get_operate_args_IPDiagnostics_DownloadDiagnostics(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = (char *)&ip_diagnostics_download_args; - return 0; -} - -static int operate_IPDiagnostics_DownloadDiagnostics(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char input[2048] = {0}; - char output[2048] = {0}; - char cmd[2096] = {0}; - char *download_url = dmjson_get_value((json_object *)value, 1, "DownloadURL"); - - if (download_url[0] == '\0') { - bbfdm_set_fault_message(ctx, "DownloadDiagnostics: 'DownloadURL' input should be defined"); - return USP_FAULT_INVALID_ARGUMENT; - } - - if (strncmp(download_url, HTTP_URI, strlen(HTTP_URI)) != 0 && - strncmp(download_url, FTP_URI, strlen(FTP_URI)) != 0 && - strchr(download_url,'@') != NULL) { - bbfdm_set_fault_message(ctx, "DownloadDiagnostics: '%s' DownloadURL is not a correct url value", download_url); - return USP_FAULT_INVALID_ARGUMENT; - } - - char *ip_interface = dmjson_get_value((json_object *)value, 1, "Interface"); - char *download_interface = diagnostics_get_interface_name(ctx, ip_interface); - char *download_dscp = dmjson_get_value((json_object *)value, 1, "DSCP"); - char *download_ethernet_priority = dmjson_get_value((json_object *)value, 1, "EthernetPriority"); - char *download_proto = dmjson_get_value((json_object *)value, 1, "ProtocolVersion"); - char *download_num_of_connections = dmjson_get_value((json_object *)value, 1, "NumberOfConnections"); - char *download_enable_per_connection_results = dmjson_get_value((json_object *)value, 1, "EnablePerConnectionResults"); - - snprintf(input, sizeof(input), "'{\"url\": \"%s\",\"iface\":\"%s\",\"dscp\":\"%s\",\"eth_prio\":\"%s\",\"ip_proto\":\"%s\",\"num_of_con\":\"%s\",\"enable_per_con\":\"%s\",\"proto\":\"%s\"}'", - download_url, - download_interface, - download_dscp, - download_ethernet_priority, - download_proto, - download_num_of_connections, - download_enable_per_connection_results, - (ctx->dm_type == BBFDM_USP) ? "usp" : "both_proto"); - - snprintf(cmd, sizeof(cmd), "sh %s %s", DOWNLOAD_DIAGNOSTIC_PATH, input); - - if (run_cmd(cmd, output, sizeof(output)) != 0) { - bbfdm_set_fault_message(ctx, "DownloadDiagnostics: 'sh %s {input}' command failed to run", DOWNLOAD_DIAGNOSTIC_PATH); - return USP_FAULT_COMMAND_FAILURE; - } - - json_object *res = (DM_STRLEN(output)) ? json_tokener_parse(output) : NULL; - - if (res == NULL) { - bbfdm_set_fault_message(ctx, "DownloadDiagnostics: there is no output from '%s' script", DOWNLOAD_DIAGNOSTIC_PATH); - return USP_FAULT_COMMAND_FAILURE; - } - - char *status = dmjson_get_value(res, 1, "Status"); - char *ip_address_used = dmjson_get_value(res, 1, "IPAddressUsed"); - char *rom_time = dmjson_get_value(res, 1, "ROMTime"); - char *bom_time = dmjson_get_value(res, 1, "BOMTime"); - char *eom_time = dmjson_get_value(res, 1, "EOMTime"); - char *test_bytes_received = dmjson_get_value(res, 1, "TestBytesReceived"); - char *total_bytes_received = dmjson_get_value(res, 1, "TotalBytesReceived"); - char *total_bytes_sent = dmjson_get_value(res, 1, "TotalBytesSent"); - char *period_of_full_loading = dmjson_get_value(res, 1, "PeriodOfFullLoading"); - char *tcp_open_request_time = dmjson_get_value(res, 1, "TCPOpenRequestTime"); - char *tcp_open_response_time = dmjson_get_value(res, 1, "TCPOpenResponseTime"); - - add_list_parameter(ctx, dmstrdup("Status"), dmstrdup(status), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("IPAddressUsed"), dmstrdup(ip_address_used), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("ROMTime"), rom_time[0] != 0 ? dmstrdup(rom_time) : "0001-01-01T00:00:00.000000Z", DMT_TYPE[DMT_TIME], NULL); - add_list_parameter(ctx, dmstrdup("BOMTime"), bom_time[0] != 0 ? dmstrdup(bom_time) : "0001-01-01T00:00:00.000000Z", DMT_TYPE[DMT_TIME], NULL); - add_list_parameter(ctx, dmstrdup("EOMTime"), eom_time[0] != 0 ? dmstrdup(eom_time) : "0001-01-01T00:00:00.000000Z", DMT_TYPE[DMT_TIME], NULL); - add_list_parameter(ctx, dmstrdup("TestBytesReceived"), dmstrdup(test_bytes_received), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TotalBytesReceived"), dmstrdup(total_bytes_received), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TotalBytesSent"), dmstrdup(total_bytes_sent), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TestBytesReceivedUnderFullLoading"), dmstrdup(test_bytes_received), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TotalBytesReceivedUnderFullLoading"), dmstrdup(total_bytes_received), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TotalBytesSentUnderFullLoading"), dmstrdup(total_bytes_sent), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("PeriodOfFullLoading"), dmstrdup(period_of_full_loading), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TCPOpenRequestTime"), tcp_open_request_time[0] != 0 ? dmstrdup(tcp_open_request_time) : "0001-01-01T00:00:00.000000Z", DMT_TYPE[DMT_TIME], NULL); - add_list_parameter(ctx, dmstrdup("TCPOpenResponseTime"), tcp_open_response_time[0] != 0 ? dmstrdup(tcp_open_response_time) : "0001-01-01T00:00:00.000000Z", DMT_TYPE[DMT_TIME], NULL); - - if (res != NULL) - json_object_put(res); - - return 0; -} - -static operation_args ip_diagnostics_upload_args = { - .in = (const char *[]) { - "Interface", - "UploadURL", - "DSCP", - "EthernetPriority", - "TestFileLength", - "TimeBasedTestDuration", - "TimeBasedTestMeasurementInterval", - "TimeBasedTestMeasurementOffset", - "ProtocolVersion", - "NumberOfConnections", - "EnablePerConnectionResults", - NULL - }, - .out = (const char *[]) { - "Status", - "IPAddressUsed", - "ROMTime", - "BOMTime", - "EOMTime", - "TestBytesSent", - "TotalBytesReceived", - "TotalBytesSent", - "TestBytesSentUnderFullLoading", - "TotalBytesReceivedUnderFullLoading", - "TotalBytesSentUnderFullLoading", - "PeriodOfFullLoading", - "TCPOpenRequestTime", - "TCPOpenResponseTime", - "PerConnectionResult.{i}.ROMTime", - "PerConnectionResult.{i}.BOMTime", - "PerConnectionResult.{i}.EOMTime", - "PerConnectionResult.{i}.TestBytesSent", - "PerConnectionResult.{i}.TotalBytesReceived", - "PerConnectionResult.{i}.TotalBytesSent", - "PerConnectionResult.{i}.TCPOpenRequestTime", - "PerConnectionResult.{i}.TCPOpenResponseTime", - "IncrementalResult.{i}.TestBytesSent", - "IncrementalResult.{i}.TotalBytesReceived", - "IncrementalResult.{i}.TotalBytesSent", - "IncrementalResult.{i}.StartTime", - "IncrementalResult.{i}.EndTime", - NULL - } -}; - -static int get_operate_args_IPDiagnostics_UploadDiagnostics(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = (char *)&ip_diagnostics_upload_args; - return 0; -} - -static int operate_IPDiagnostics_UploadDiagnostics(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - char input[2048] = {0}; - char output[2048] = {0}; - char cmd[2096] = {0}; - char *upload_url = dmjson_get_value((json_object *)value, 1, "UploadURL"); - - if (upload_url[0] == '\0') { - bbfdm_set_fault_message(ctx, "UploadDiagnostics: 'UploadURL' input should be defined"); - return USP_FAULT_INVALID_ARGUMENT; - } - - if (strncmp(upload_url, HTTP_URI, strlen(HTTP_URI)) != 0 && - strncmp(upload_url, FTP_URI, strlen(FTP_URI)) != 0 && - strchr(upload_url,'@') != NULL) - return USP_FAULT_INVALID_ARGUMENT; - - char *upload_test_file_length = dmjson_get_value((json_object *)value, 1, "TestFileLength"); - if (upload_test_file_length[0] == '\0') { - bbfdm_set_fault_message(ctx, "UploadDiagnostics: 'TestFileLength' input should be defined"); - return USP_FAULT_INVALID_ARGUMENT; - } - - char *ip_interface = dmjson_get_value((json_object *)value, 1, "Interface"); - char *upload_interface = diagnostics_get_interface_name(ctx, ip_interface); - char *upload_dscp = dmjson_get_value((json_object *)value, 1, "DSCP"); - char *upload_ethernet_priority = dmjson_get_value((json_object *)value, 1, "EthernetPriority"); - char *upload_proto = dmjson_get_value((json_object *)value, 1, "ProtocolVersion"); - char *upload_num_of_connections = dmjson_get_value((json_object *)value, 1, "NumberOfConnections"); - char *upload_enable_per_connection_results = dmjson_get_value((json_object *)value, 1, "EnablePerConnectionResults"); - - snprintf(input, sizeof(input), "'{\"url\": \"%s\",\"iface\":\"%s\",\"dscp\":\"%s\",\"eth_prio\":\"%s\",\"file_length\":\"%s\",\"ip_proto\":\"%s\",\"num_of_con\":\"%s\",\"enable_per_con\":\"%s\",\"proto\":\"%s\"}'", - upload_url, - upload_interface, - upload_dscp, - upload_ethernet_priority, - upload_test_file_length, - upload_proto, - upload_num_of_connections, - upload_enable_per_connection_results, - (ctx->dm_type == BBFDM_USP) ? "usp" : "both_proto"); - - snprintf(cmd, sizeof(cmd), "sh %s %s", UPLOAD_DIAGNOSTIC_PATH, input); - - if (run_cmd(cmd, output, sizeof(output)) != 0) { - bbfdm_set_fault_message(ctx, "UploadDiagnostics: 'sh %s {input}' command failed to run", UPLOAD_DIAGNOSTIC_PATH); - return USP_FAULT_COMMAND_FAILURE; - } - - json_object *res = (DM_STRLEN(output)) ? json_tokener_parse(output) : NULL; - - if (res == NULL) { - bbfdm_set_fault_message(ctx, "UploadDiagnostics: there is no output from '%s' script", UPLOAD_DIAGNOSTIC_PATH); - return USP_FAULT_COMMAND_FAILURE; - } - - char *upload_status = dmjson_get_value(res, 1, "Status"); - char *upload_ip_address_used = dmjson_get_value(res, 1, "IPAddressUsed"); - char *upload_rom_time = dmjson_get_value(res, 1, "ROMTime"); - char *upload_bom_time = dmjson_get_value(res, 1, "BOMTime"); - char *upload_eom_time = dmjson_get_value(res, 1, "EOMTime"); - char *upload_test_bytes_sent = dmjson_get_value(res, 1, "TestBytesSent"); - char *upload_total_bytes_received = dmjson_get_value(res, 1, "TotalBytesReceived"); - char *upload_total_bytes_sent = dmjson_get_value(res, 1, "TotalBytesSent"); - char *upload_period_of_full_loading = dmjson_get_value(res, 1, "PeriodOfFullLoading"); - char *upload_tcp_open_request_time = dmjson_get_value(res, 1, "TCPOpenRequestTime"); - char *upload_tcp_open_response_time = dmjson_get_value(res, 1, "TCPOpenResponseTime"); - - add_list_parameter(ctx, dmstrdup("Status"), dmstrdup(upload_status), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("IPAddressUsed"), dmstrdup(upload_ip_address_used), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("ROMTime"), upload_rom_time[0] != 0 ? dmstrdup(upload_rom_time) : "0001-01-01T00:00:00.000000Z", DMT_TYPE[DMT_TIME], NULL); - add_list_parameter(ctx, dmstrdup("BOMTime"), upload_bom_time[0] != 0 ? dmstrdup(upload_bom_time) : "0001-01-01T00:00:00.000000Z", DMT_TYPE[DMT_TIME], NULL); - add_list_parameter(ctx, dmstrdup("EOMTime"), upload_eom_time[0] != 0 ? dmstrdup(upload_eom_time) : "0001-01-01T00:00:00.000000Z", DMT_TYPE[DMT_TIME], NULL); - add_list_parameter(ctx, dmstrdup("TestBytesSent"), dmstrdup(upload_test_bytes_sent), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TotalBytesReceived"), dmstrdup(upload_total_bytes_received), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TotalBytesSent"), dmstrdup(upload_total_bytes_sent), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TestBytesSentUnderFullLoading"), dmstrdup(upload_test_bytes_sent), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TotalBytesReceivedUnderFullLoading"), dmstrdup(upload_total_bytes_received), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TotalBytesSentUnderFullLoading"), dmstrdup(upload_total_bytes_sent), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("PeriodOfFullLoading"), dmstrdup(upload_period_of_full_loading), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("TCPOpenRequestTime"), upload_tcp_open_request_time[0] != 0 ? dmstrdup(upload_tcp_open_request_time) : "0001-01-01T00:00:00.000000Z", DMT_TYPE[DMT_TIME], NULL); - add_list_parameter(ctx, dmstrdup("TCPOpenResponseTime"), upload_tcp_open_response_time[0] != 0 ? dmstrdup(upload_tcp_open_response_time) : "0001-01-01T00:00:00.000000Z", DMT_TYPE[DMT_TIME], NULL); - - if (res != NULL) - json_object_put(res); - - return 0; -} - -static operation_args ip_diagnostics_udpecho_args = { - .in = (const char *[]) { - "Interface", - "Host", - "Port", - "NumberOfRepetitions", - "Timeout", - "DataBlockSize", - "DSCP", - "InterTransmissionTime", - "ProtocolVersion", - "EnableIndividualPacketResults", - NULL - }, - .out = (const char *[]) { - "Status", - "IPAddressUsed", - "SuccessCount", - "FailureCount", - "AverageResponseTime", - "MinimumResponseTime", - "MaximumResponseTime", - "IndividualPacketResult.{i}.PacketSuccess", - "IndividualPacketResult.{i}.PacketSendTime", - "IndividualPacketResult.{i}.PacketReceiveTime", - "IndividualPacketResult.{i}.TestGenSN", - "IndividualPacketResult.{i}.TestRespSN", - "IndividualPacketResult.{i}.TestRespRcvTimeStamp", - "IndividualPacketResult.{i}.TestRespReplyTimeStamp", - "IndividualPacketResult.{i}.TestRespReplyFailureCount", - NULL - } -}; - -static int get_operate_args_IPDiagnostics_UDPEchoDiagnostics(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = (char *)&ip_diagnostics_udpecho_args; - return 0; -} - -static int operate_IPDiagnostics_UDPEchoDiagnostics(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - json_object *res = NULL; - - char *udpecho_host = dmjson_get_value((json_object *)value, 1, "Host"); - if (udpecho_host[0] == '\0') { - bbfdm_set_fault_message(ctx, "UDPEchoDiagnostics: 'Host' input should be defined"); - return USP_FAULT_INVALID_ARGUMENT; - } - - char *udpecho_port = dmjson_get_value((json_object *)value, 1, "Port"); - char *ip_interface = dmjson_get_value((json_object *)value, 1, "Interface"); - char *udpecho_interface = diagnostics_get_interface_name(ctx, ip_interface); - char *udpecho_proto = dmjson_get_value((json_object *)value, 1, "ProtocolVersion"); - char *udpecho_nbofrepetition = dmjson_get_value((json_object *)value, 1, "NumberOfRepetitions"); - char *udpecho_timeout = dmjson_get_value((json_object *)value, 1, "Timeout"); - char *udpecho_datablocksize = dmjson_get_value((json_object *)value, 1, "DataBlockSize"); - char *udpecho_dscp = dmjson_get_value((json_object *)value, 1, "DSCP"); - char *udpecho_inter_transmission_time = dmjson_get_value((json_object *)value, 1, "InterTransmissionTime"); - char *proto = (ctx->dm_type == BBFDM_USP) ? "usp" : "both_proto"; - - dmubus_call_blocking("bbf.diag", "udpecho", - UBUS_ARGS{ - {"host", udpecho_host, String}, - {"port", udpecho_port, String}, - {"iface", udpecho_interface, String}, - {"ip_proto", udpecho_proto, String}, - {"nbr_of_rep", udpecho_nbofrepetition, String}, - {"timeout", udpecho_timeout, String}, - {"data_size", udpecho_datablocksize, String}, - {"dscp", udpecho_dscp, String}, - {"inter_trans_time", udpecho_inter_transmission_time, String}, - {"proto", proto, String} - }, - 10, &res); - - if (res == NULL) { - bbfdm_set_fault_message(ctx, "UDPEchoDiagnostics: ubus 'bbf.diag udpecho' method doesn't exist"); - return USP_FAULT_COMMAND_FAILURE; - } - - char *status = dmjson_get_value(res, 1, "Status"); - char *ip_address_used = dmjson_get_value(res, 1, "IPAddressUsed"); - char *udpecho_success_count = dmjson_get_value(res, 1, "SuccessCount"); - char *udpecho_failure_count = dmjson_get_value(res, 1, "FailureCount"); - char *udpecho_average_response_time = dmjson_get_value(res, 1, "AverageResponseTime"); - char *udpecho_minimum_response_time = dmjson_get_value(res, 1, "MinimumResponseTime"); - char *udpecho_maximum_response_time = dmjson_get_value(res, 1, "MaximumResponseTime"); - - add_list_parameter(ctx, dmstrdup("Status"), dmstrdup(status), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("IPAddressUsed"), dmstrdup(ip_address_used), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("SuccessCount"), dmstrdup(udpecho_success_count), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("FailureCount"), dmstrdup(udpecho_failure_count), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("AverageResponseTime"), dmstrdup(udpecho_average_response_time), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("MinimumResponseTime"), dmstrdup(udpecho_minimum_response_time), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("MaximumResponseTime"), dmstrdup(udpecho_maximum_response_time), DMT_TYPE[DMT_UNINT], NULL); - - if (res != NULL) - json_object_put(res); - - return 0; -} - -static operation_args ip_diagnostics_server_selection_args = { - .in = (const char *[]) { - "Interface", - "ProtocolVersion", - "Protocol", - "HostList", - "NumberOfRepetitions", - "Timeout", - NULL - }, - .out = (const char *[]) { - "Status", - "FastestHost", - "MinimumResponseTime", - "AverageResponseTime", - "MaximumResponseTime", - "IPAddressUsed", - NULL - } -}; - -static int get_operate_args_IPDiagnostics_ServerSelectionDiagnostics(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) -{ - *value = (char *)&ip_diagnostics_server_selection_args; - return 0; -} - -static int operate_IPDiagnostics_ServerSelectionDiagnostics(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) -{ - json_object *res = NULL; - - char *hostlist = dmjson_get_value((json_object *)value, 1, "HostList"); - if (hostlist[0] == '\0') { - bbfdm_set_fault_message(ctx, "ServerSelectionDiagnostics: 'HostList' input should be defined"); - return USP_FAULT_INVALID_ARGUMENT; - } - - char *port = dmjson_get_value((json_object *)value, 1, "Port"); - char *protocol_used = dmjson_get_value((json_object *)value, 1, "Protocol"); - char *protocol_version = dmjson_get_value((json_object *)value, 1, "ProtocolVersion"); - char *ip_interface = dmjson_get_value((json_object *)value, 1, "Interface"); - char *interface = diagnostics_get_interface_name(ctx, ip_interface); - char *nbofrepetition = dmjson_get_value((json_object *)value, 1, "NumberOfRepetitions"); - char *timeout = dmjson_get_value((json_object *)value, 1, "Timeout"); - char *proto = (ctx->dm_type == BBFDM_USP) ? "usp" : "both_proto"; - - dmubus_call_blocking("bbf.diag", "serverselection", - UBUS_ARGS{ - {"hostlist", hostlist, String}, - {"port", port, String}, - {"iface", interface, String}, - {"ip_proto", protocol_version, String}, - {"nbr_of_rep", nbofrepetition, String}, - {"timeout", timeout, String}, - {"protocol_used", protocol_used, String}, - {"proto", proto, String} - }, - 8, &res); - - if (res == NULL) { - bbfdm_set_fault_message(ctx, "ServerSelectionDiagnostics: ubus 'bbf.diag serverselection' method doesn't exist"); - return USP_FAULT_COMMAND_FAILURE; - } - - char *status = dmjson_get_value(res, 1, "Status"); - char *fasthost = dmjson_get_value(res, 1, "FastestHost"); - char *average_response_time = dmjson_get_value(res, 1, "AverageResponseTime"); - char *minimum_response_time = dmjson_get_value(res, 1, "MinimumResponseTime"); - char *maximum_response_time = dmjson_get_value(res, 1, "MaximumResponseTime"); - char *ip_address_used = dmjson_get_value(res, 1, "IPAddressUsed"); - - add_list_parameter(ctx, dmstrdup("Status"), dmstrdup(status), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("FastestHost"), dmstrdup(fasthost), DMT_TYPE[DMT_STRING], NULL); - add_list_parameter(ctx, dmstrdup("AverageResponseTime"), dmstrdup(average_response_time), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("MinimumResponseTime"), dmstrdup(minimum_response_time), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("MaximumResponseTime"), dmstrdup(maximum_response_time), DMT_TYPE[DMT_UNINT], NULL); - add_list_parameter(ctx, dmstrdup("IPAddressUsed"), dmstrdup(ip_address_used), DMT_TYPE[DMT_STRING], NULL); - - if (res != NULL) - json_object_put(res); - - return 0; -} - -/********************************************************************************************************************************** -* OBJ & LEAF DEFINITION -***********************************************************************************************************************************/ -/* *** Device.IP.Diagnostics. *** */ -DMOBJ tIPDiagnosticsObj[] = { -/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/ -{"IPPing", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIPDiagnosticsIPPingParams, NULL, BBFDM_CWMP}, -{"TraceRoute", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPDiagnosticsTraceRouteObj, tIPDiagnosticsTraceRouteParams, NULL, BBFDM_CWMP}, -{"DownloadDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPDiagnosticsDownloadDiagnosticsObj, tIPDiagnosticsDownloadDiagnosticsParams, NULL, BBFDM_CWMP}, -{"UploadDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPDiagnosticsUploadDiagnosticsObj, tIPDiagnosticsUploadDiagnosticsParams, NULL, BBFDM_CWMP}, -{"UDPEchoDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIPDiagnosticsUDPEchoDiagnosticsParams, NULL, BBFDM_CWMP}, -{"ServerSelectionDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIPDiagnosticsServerSelectionDiagnosticsParams, NULL, BBFDM_CWMP}, -{0} -}; - -DMLEAF tIPDiagnosticsParams[] = { -/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/ -{"IPv4PingSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv6PingSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv4TraceRouteSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv6TraceRouteSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv4DownloadDiagnosticsSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv6DownloadDiagnosticsSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv4UploadDiagnosticsSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv6UploadDiagnosticsSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv4UDPEchoDiagnosticsSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv6UDPEchoDiagnosticsSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv4ServerSelectionDiagnosticsSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPv6ServerSelectionDiagnosticsSupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH}, -{"IPPing()", &DMASYNC, DMT_COMMAND, get_operate_args_IPDiagnostics_IPPing, operate_IPDiagnostics_IPPing, BBFDM_USP}, -{"TraceRoute()", &DMASYNC, DMT_COMMAND, get_operate_args_IPDiagnostics_TraceRoute, operate_IPDiagnostics_TraceRoute, BBFDM_USP}, -{"DownloadDiagnostics()", &DMASYNC, DMT_COMMAND, get_operate_args_IPDiagnostics_DownloadDiagnostics, operate_IPDiagnostics_DownloadDiagnostics, BBFDM_USP}, -{"UploadDiagnostics()", &DMASYNC, DMT_COMMAND, get_operate_args_IPDiagnostics_UploadDiagnostics, operate_IPDiagnostics_UploadDiagnostics, BBFDM_USP}, -{"UDPEchoDiagnostics()", &DMASYNC, DMT_COMMAND, get_operate_args_IPDiagnostics_UDPEchoDiagnostics, operate_IPDiagnostics_UDPEchoDiagnostics, BBFDM_USP}, -{"ServerSelectionDiagnostics()", &DMASYNC, DMT_COMMAND, get_operate_args_IPDiagnostics_ServerSelectionDiagnostics, operate_IPDiagnostics_ServerSelectionDiagnostics, BBFDM_USP}, -{0} -}; - -/* *** Device.IP.Diagnostics.IPPing. *** */ -DMLEAF tIPDiagnosticsIPPingParams[] = { -/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/ -{"DiagnosticsState", &DMWRITE, DMT_STRING, get_ip_ping_diagnostics_state, set_ip_ping_diagnostics_state, BBFDM_CWMP}, -{"Interface", &DMWRITE, DMT_STRING, get_ip_ping_interface, set_ip_ping_interface, BBFDM_CWMP, DM_FLAG_REFERENCE}, -{"ProtocolVersion", &DMWRITE, DMT_STRING, get_ip_ping_protocolversion, set_ip_ping_protocolversion, BBFDM_CWMP}, -{"Host", &DMWRITE, DMT_STRING, get_ip_ping_host, set_ip_ping_host, BBFDM_CWMP}, -{"NumberOfRepetitions", &DMWRITE, DMT_UNINT, get_ip_ping_repetition_number, set_ip_ping_repetition_number, BBFDM_CWMP}, -{"Timeout", &DMWRITE, DMT_UNINT, get_ip_ping_timeout, set_ip_ping_timeout, BBFDM_CWMP}, -{"DataBlockSize", &DMWRITE, DMT_UNINT, get_ip_ping_block_size, set_ip_ping_block_size, BBFDM_CWMP}, -{"DSCP", &DMWRITE, DMT_UNINT, get_ip_ping_DSCP, set_ip_ping_DSCP, BBFDM_CWMP}, -{"IPAddressUsed", &DMREAD, DMT_STRING, get_IPDiagnosticsIPPing_IPAddressUsed, NULL, BBFDM_CWMP}, -{"SuccessCount", &DMREAD, DMT_UNINT, get_ip_ping_success_count, NULL, BBFDM_CWMP}, -{"FailureCount", &DMREAD, DMT_UNINT, get_ip_ping_failure_count, NULL, BBFDM_CWMP}, -{"AverageResponseTime", &DMREAD, DMT_UNINT, get_ip_ping_average_response_time, NULL, BBFDM_CWMP}, -{"MinimumResponseTime", &DMREAD, DMT_UNINT, get_ip_ping_min_response_time, NULL, BBFDM_CWMP}, -{"MaximumResponseTime", &DMREAD, DMT_UNINT, get_ip_ping_max_response_time, NULL, BBFDM_CWMP}, -{"AverageResponseTimeDetailed", &DMREAD, DMT_UNINT, get_ip_ping_AverageResponseTimeDetailed, NULL, BBFDM_CWMP}, -{"MinimumResponseTimeDetailed", &DMREAD, DMT_UNINT, get_ip_ping_MinimumResponseTimeDetailed, NULL, BBFDM_CWMP}, -{"MaximumResponseTimeDetailed", &DMREAD, DMT_UNINT, get_ip_ping_MaximumResponseTimeDetailed, NULL, BBFDM_CWMP}, -{0} -}; - -/* *** Device.IP.Diagnostics.TraceRoute. *** */ -DMOBJ tIPDiagnosticsTraceRouteObj[] = { -/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/ -{"RouteHops", &DMREAD, NULL, NULL, NULL, browseIPDiagnosticsTraceRouteRouteHopsInst, NULL, NULL, NULL, tIPDiagnosticsTraceRouteRouteHopsParams, NULL, BBFDM_CWMP}, -{0} -}; - -DMLEAF tIPDiagnosticsTraceRouteParams[] = { -/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/ -{"DiagnosticsState", &DMWRITE, DMT_STRING, get_IPDiagnosticsTraceRoute_DiagnosticsState, set_IPDiagnosticsTraceRoute_DiagnosticsState, BBFDM_CWMP}, -{"Interface", &DMWRITE, DMT_STRING, get_IPDiagnosticsTraceRoute_Interface, set_IPDiagnosticsTraceRoute_Interface, BBFDM_CWMP, DM_FLAG_REFERENCE}, -{"ProtocolVersion", &DMWRITE, DMT_STRING, get_IPDiagnosticsTraceRoute_ProtocolVersion, set_IPDiagnosticsTraceRoute_ProtocolVersion, BBFDM_CWMP}, -{"Host", &DMWRITE, DMT_STRING, get_IPDiagnosticsTraceRoute_Host, set_IPDiagnosticsTraceRoute_Host, BBFDM_CWMP}, -{"NumberOfTries", &DMWRITE, DMT_UNINT, get_IPDiagnosticsTraceRoute_NumberOfTries, set_IPDiagnosticsTraceRoute_NumberOfTries, BBFDM_CWMP}, -{"Timeout", &DMWRITE, DMT_UNINT, get_IPDiagnosticsTraceRoute_Timeout, set_IPDiagnosticsTraceRoute_Timeout, BBFDM_CWMP}, -{"DataBlockSize", &DMWRITE, DMT_UNINT, get_IPDiagnosticsTraceRoute_DataBlockSize, set_IPDiagnosticsTraceRoute_DataBlockSize, BBFDM_CWMP}, -{"DSCP", &DMWRITE, DMT_UNINT, get_IPDiagnosticsTraceRoute_DSCP, set_IPDiagnosticsTraceRoute_DSCP, BBFDM_CWMP}, -{"MaxHopCount", &DMWRITE, DMT_UNINT, get_IPDiagnosticsTraceRoute_MaxHopCount, set_IPDiagnosticsTraceRoute_MaxHopCount, BBFDM_CWMP}, -{"ResponseTime", &DMREAD, DMT_UNINT, get_IPDiagnosticsTraceRoute_ResponseTime, NULL, BBFDM_CWMP}, -{"IPAddressUsed", &DMREAD, DMT_STRING, get_IPDiagnosticsTraceRoute_IPAddressUsed, NULL, BBFDM_CWMP}, -{"RouteHopsNumberOfEntries", &DMREAD, DMT_UNINT, get_IPDiagnosticsTraceRoute_RouteHopsNumberOfEntries, NULL, BBFDM_CWMP}, -{0} -}; - -/* *** Device.IP.Diagnostics.TraceRoute.RouteHops.{i}. *** */ -DMLEAF tIPDiagnosticsTraceRouteRouteHopsParams[] = { -/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/ -{"Host", &DMREAD, DMT_STRING, get_IPDiagnosticsTraceRouteRouteHops_Host, NULL, BBFDM_CWMP}, -{"HostAddress", &DMREAD, DMT_STRING, get_IPDiagnosticsTraceRouteRouteHops_HostAddress, NULL, BBFDM_CWMP}, -{"ErrorCode", &DMREAD, DMT_UNINT, get_IPDiagnosticsTraceRouteRouteHops_ErrorCode, NULL, BBFDM_CWMP}, -{"RTTimes", &DMREAD, DMT_STRING, get_IPDiagnosticsTraceRouteRouteHops_RTTimes, NULL, BBFDM_CWMP}, -{0} -}; - -/* *** Device.IP.Diagnostics.DownloadDiagnostics. *** */ -DMOBJ tIPDiagnosticsDownloadDiagnosticsObj[] = { -/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/ -{"PerConnectionResult", &DMREAD, NULL, NULL, NULL, browseIPDiagnosticsDownloadDiagnosticsPerConnectionResultInst, NULL, NULL, NULL, tIPDiagnosticsDownloadDiagnosticsPerConnectionResultParams, NULL, BBFDM_CWMP}, -{0} -}; - -DMLEAF tIPDiagnosticsDownloadDiagnosticsParams[] = { -/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/ -{"DiagnosticsState", &DMWRITE, DMT_STRING, get_IPDiagnosticsDownloadDiagnostics_DiagnosticsState, set_IPDiagnosticsDownloadDiagnostics_DiagnosticsState, BBFDM_CWMP}, -{"Interface", &DMWRITE, DMT_STRING, get_IPDiagnosticsDownloadDiagnostics_Interface, set_IPDiagnosticsDownloadDiagnostics_Interface, BBFDM_CWMP, DM_FLAG_REFERENCE}, -{"DownloadURL", &DMWRITE, DMT_STRING, get_IPDiagnosticsDownloadDiagnostics_DownloadURL, set_IPDiagnosticsDownloadDiagnostics_DownloadURL, BBFDM_CWMP}, -{"DownloadTransports", &DMREAD, DMT_STRING, get_IPDiagnosticsDownloadDiagnostics_DownloadTransports, NULL, BBFDM_CWMP}, -{"DownloadDiagnosticMaxConnections", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_DownloadDiagnosticMaxConnections,NULL, BBFDM_CWMP}, -{"DSCP", &DMWRITE, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_DSCP, set_IPDiagnosticsDownloadDiagnostics_DSCP, BBFDM_CWMP}, -{"EthernetPriority", &DMWRITE, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_EthernetPriority, set_IPDiagnosticsDownloadDiagnostics_EthernetPriority, BBFDM_CWMP}, -{"ProtocolVersion", &DMWRITE, DMT_STRING, get_IPDiagnosticsDownloadDiagnostics_ProtocolVersion, set_IPDiagnosticsDownloadDiagnostics_ProtocolVersion, BBFDM_CWMP}, -{"NumberOfConnections", &DMWRITE, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_NumberOfConnections, set_IPDiagnosticsDownloadDiagnostics_NumberOfConnections, BBFDM_CWMP}, -{"IPAddressUsed", &DMREAD, DMT_STRING, get_IPDiagnosticsDownloadDiagnostics_IPAddressUsed, NULL, BBFDM_CWMP}, -{"ROMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsDownloadDiagnostics_ROMTime, NULL, BBFDM_CWMP}, -{"BOMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsDownloadDiagnostics_BOMTime, NULL, BBFDM_CWMP}, -{"EOMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsDownloadDiagnostics_EOMTime, NULL, BBFDM_CWMP}, -{"TestBytesReceived", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_TestBytesReceived, NULL, BBFDM_CWMP}, -{"TotalBytesReceived", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_TotalBytesReceived, NULL, BBFDM_CWMP}, -{"TotalBytesSent", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_TotalBytesSent, NULL, BBFDM_CWMP}, -{"TestBytesReceivedUnderFullLoading", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_TestBytesReceivedUnderFullLoading, NULL, BBFDM_CWMP}, -{"TotalBytesReceivedUnderFullLoading", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_TotalBytesReceivedUnderFullLoading, NULL, BBFDM_CWMP}, -{"TotalBytesSentUnderFullLoading", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_TotalBytesSentUnderFullLoading, NULL, BBFDM_CWMP}, -{"PeriodOfFullLoading", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_PeriodOfFullLoading, NULL, BBFDM_CWMP}, -{"TCPOpenRequestTime", &DMREAD, DMT_TIME, get_IPDiagnosticsDownloadDiagnostics_TCPOpenRequestTime, NULL, BBFDM_CWMP}, -{"TCPOpenResponseTime", &DMREAD, DMT_TIME, get_IPDiagnosticsDownloadDiagnostics_TCPOpenResponseTime, NULL, BBFDM_CWMP}, -{"PerConnectionResultNumberOfEntries", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnostics_PerConnectionResultNumberOfEntries, NULL, BBFDM_CWMP}, -{"EnablePerConnectionResults", &DMWRITE, DMT_BOOL, get_IPDiagnosticsDownloadDiagnostics_EnablePerConnectionResults, set_IPDiagnosticsDownloadDiagnostics_EnablePerConnectionResults, BBFDM_CWMP}, -{0} -}; - -/* *** Device.IP.Diagnostics.DownloadDiagnostics.PerConnectionResult.{i}. *** */ -DMLEAF tIPDiagnosticsDownloadDiagnosticsPerConnectionResultParams[] = { -/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/ -{"ROMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_ROMTime, NULL, BBFDM_CWMP}, -{"BOMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_BOMTime, NULL, BBFDM_CWMP}, -{"EOMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_EOMTime, NULL, BBFDM_CWMP}, -{"TestBytesReceived", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TestBytesReceived, NULL, BBFDM_CWMP}, -{"TotalBytesReceived", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TotalBytesReceived, NULL, BBFDM_CWMP}, -{"TotalBytesSent", &DMREAD, DMT_UNINT, get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TotalBytesSent, NULL, BBFDM_CWMP}, -{"TCPOpenRequestTime", &DMREAD, DMT_TIME, get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TCPOpenRequestTime, NULL, BBFDM_CWMP}, -{"TCPOpenResponseTime", &DMREAD, DMT_TIME, get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TCPOpenResponseTime, NULL, BBFDM_CWMP}, -{0} -}; - -/* *** Device.IP.Diagnostics.UploadDiagnostics. *** */ -DMOBJ tIPDiagnosticsUploadDiagnosticsObj[] = { -/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/ -{"PerConnectionResult", &DMREAD, NULL, NULL, NULL, browseIPDiagnosticsUploadDiagnosticsPerConnectionResultInst, NULL, NULL, NULL, tIPDiagnosticsUploadDiagnosticsPerConnectionResultParams, NULL, BBFDM_CWMP}, -{0} -}; - -DMLEAF tIPDiagnosticsUploadDiagnosticsParams[] = { -/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/ -{"DiagnosticsState", &DMWRITE, DMT_STRING, get_IPDiagnosticsUploadDiagnostics_DiagnosticsState, set_IPDiagnosticsUploadDiagnostics_DiagnosticsState, BBFDM_CWMP}, -{"Interface", &DMWRITE, DMT_STRING, get_IPDiagnosticsUploadDiagnostics_Interface, set_IPDiagnosticsUploadDiagnostics_Interface, BBFDM_CWMP, DM_FLAG_REFERENCE}, -{"UploadURL", &DMWRITE, DMT_STRING, get_IPDiagnosticsUploadDiagnostics_UploadURL, set_IPDiagnosticsUploadDiagnostics_UploadURL, BBFDM_CWMP}, -{"UploadTransports", &DMREAD, DMT_STRING, get_IPDiagnosticsUploadDiagnostics_UploadTransports, NULL, BBFDM_CWMP}, -{"DSCP", &DMWRITE, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_DSCP, set_IPDiagnosticsUploadDiagnostics_DSCP, BBFDM_CWMP}, -{"EthernetPriority", &DMWRITE, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_EthernetPriority, set_IPDiagnosticsUploadDiagnostics_EthernetPriority, BBFDM_CWMP}, -{"TestFileLength", &DMWRITE, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_TestFileLength, set_IPDiagnosticsUploadDiagnostics_TestFileLength, BBFDM_CWMP}, -{"ProtocolVersion", &DMWRITE, DMT_STRING, get_IPDiagnosticsUploadDiagnostics_ProtocolVersion, set_IPDiagnosticsUploadDiagnostics_ProtocolVersion, BBFDM_CWMP}, -{"NumberOfConnections", &DMWRITE, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_NumberOfConnections, set_IPDiagnosticsUploadDiagnostics_NumberOfConnections, BBFDM_CWMP}, -{"IPAddressUsed", &DMREAD, DMT_STRING, get_IPDiagnosticsUploadDiagnostics_IPAddressUsed, NULL, BBFDM_CWMP}, -{"ROMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsUploadDiagnostics_ROMTime, NULL, BBFDM_CWMP}, -{"BOMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsUploadDiagnostics_BOMTime, NULL, BBFDM_CWMP}, -{"EOMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsUploadDiagnostics_EOMTime, NULL, BBFDM_CWMP}, -{"TestBytesSent", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_TestBytesSent, NULL, BBFDM_CWMP}, -{"TotalBytesReceived", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_TotalBytesReceived, NULL, BBFDM_CWMP}, -{"TotalBytesSent", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_TotalBytesSent, NULL, BBFDM_CWMP}, -{"TestBytesSentUnderFullLoading", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_TestBytesSentUnderFullLoading, NULL, BBFDM_CWMP}, -{"TotalBytesReceivedUnderFullLoading", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_TotalBytesReceivedUnderFullLoading, NULL, BBFDM_CWMP}, -{"TotalBytesSentUnderFullLoading", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_TotalBytesSentUnderFullLoading, NULL, BBFDM_CWMP}, -{"PeriodOfFullLoading", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_PeriodOfFullLoading, NULL, BBFDM_CWMP}, -{"TCPOpenRequestTime", &DMREAD, DMT_TIME, get_IPDiagnosticsUploadDiagnostics_TCPOpenRequestTime, NULL, BBFDM_CWMP}, -{"TCPOpenResponseTime", &DMREAD, DMT_TIME, get_IPDiagnosticsUploadDiagnostics_TCPOpenResponseTime, NULL, BBFDM_CWMP}, -{"PerConnectionResultNumberOfEntries", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnostics_PerConnectionResultNumberOfEntries, NULL, BBFDM_CWMP}, -{"EnablePerConnectionResults", &DMWRITE, DMT_BOOL, get_IPDiagnosticsUploadDiagnostics_EnablePerConnectionResults, set_IPDiagnosticsUploadDiagnostics_EnablePerConnectionResults, BBFDM_CWMP}, -{0} -}; - -/* *** Device.IP.Diagnostics.UploadDiagnostics.PerConnectionResult.{i}. *** */ -DMLEAF tIPDiagnosticsUploadDiagnosticsPerConnectionResultParams[] = { -/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/ -{"ROMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_ROMTime, NULL, BBFDM_CWMP}, -{"BOMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_BOMTime, NULL, BBFDM_CWMP}, -{"EOMTime", &DMREAD, DMT_TIME, get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_EOMTime, NULL, BBFDM_CWMP}, -{"TestBytesSent", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TestBytesSent, NULL, BBFDM_CWMP}, -{"TotalBytesReceived", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TotalBytesReceived, NULL, BBFDM_CWMP}, -{"TotalBytesSent", &DMREAD, DMT_UNINT, get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TotalBytesSent, NULL, BBFDM_CWMP}, -{"TCPOpenRequestTime", &DMREAD, DMT_TIME, get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TCPOpenRequestTime, NULL, BBFDM_CWMP}, -{"TCPOpenResponseTime", &DMREAD, DMT_TIME, get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TCPOpenResponseTime, NULL, BBFDM_CWMP}, -{0} -}; - -/* *** Device.IP.Diagnostics.UDPEchoDiagnostics. *** */ -DMLEAF tIPDiagnosticsUDPEchoDiagnosticsParams[] = { -/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/ -{"DiagnosticsState", &DMWRITE, DMT_STRING, get_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState, set_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState, BBFDM_CWMP}, -{"Interface", &DMWRITE, DMT_STRING, get_IPDiagnosticsUDPEchoDiagnostics_Interface, set_IPDiagnosticsUDPEchoDiagnostics_Interface, BBFDM_CWMP, DM_FLAG_REFERENCE}, -{"Host", &DMWRITE, DMT_STRING, get_IPDiagnosticsUDPEchoDiagnostics_Host, set_IPDiagnosticsUDPEchoDiagnostics_Host, BBFDM_CWMP}, -{"Port", &DMWRITE, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_Port, set_IPDiagnosticsUDPEchoDiagnostics_Port, BBFDM_CWMP}, -{"NumberOfRepetitions", &DMWRITE, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_NumberOfRepetitions, set_IPDiagnosticsUDPEchoDiagnostics_NumberOfRepetitions, BBFDM_CWMP}, -{"Timeout", &DMWRITE, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_Timeout, set_IPDiagnosticsUDPEchoDiagnostics_Timeout, BBFDM_CWMP}, -{"DataBlockSize", &DMWRITE, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_DataBlockSize, set_IPDiagnosticsUDPEchoDiagnostics_DataBlockSize, BBFDM_CWMP}, -{"DSCP", &DMWRITE, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_DSCP, set_IPDiagnosticsUDPEchoDiagnostics_DSCP, BBFDM_CWMP}, -{"InterTransmissionTime", &DMWRITE, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_InterTransmissionTime, set_IPDiagnosticsUDPEchoDiagnostics_InterTransmissionTime, BBFDM_CWMP}, -{"ProtocolVersion", &DMWRITE, DMT_STRING, get_IPDiagnosticsUDPEchoDiagnostics_ProtocolVersion, set_IPDiagnosticsUDPEchoDiagnostics_ProtocolVersion, BBFDM_CWMP}, -{"IPAddressUsed", &DMREAD, DMT_STRING, get_IPDiagnosticsUDPEchoDiagnostics_IPAddressUsed, NULL, BBFDM_CWMP}, -{"SuccessCount", &DMREAD, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_SuccessCount, NULL, BBFDM_CWMP}, -{"FailureCount", &DMREAD, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_FailureCount, NULL, BBFDM_CWMP}, -{"AverageResponseTime", &DMREAD, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_AverageResponseTime, NULL, BBFDM_CWMP}, -{"MinimumResponseTime", &DMREAD, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_MinimumResponseTime, NULL, BBFDM_CWMP}, -{"MaximumResponseTime", &DMREAD, DMT_UNINT, get_IPDiagnosticsUDPEchoDiagnostics_MaximumResponseTime, NULL, BBFDM_CWMP}, -{0} -}; - -/* *** Device.IP.Diagnostics.ServerSelectionDiagnostics. *** */ -DMLEAF tIPDiagnosticsServerSelectionDiagnosticsParams[] = { -/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/ -{"DiagnosticsState", &DMWRITE, DMT_STRING, get_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState, set_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState, BBFDM_CWMP}, -{"Interface", &DMWRITE, DMT_STRING, get_IPDiagnosticsServerSelectionDiagnostics_Interface, set_IPDiagnosticsServerSelectionDiagnostics_Interface, BBFDM_CWMP, DM_FLAG_REFERENCE}, -{"ProtocolVersion", &DMWRITE, DMT_STRING, get_IPDiagnosticsServerSelectionDiagnostics_ProtocolVersion, set_IPDiagnosticsServerSelectionDiagnostics_ProtocolVersion, BBFDM_CWMP}, -{"Protocol", &DMWRITE, DMT_STRING, get_IPDiagnosticsServerSelectionDiagnostics_Protocol, set_IPDiagnosticsServerSelectionDiagnostics_Protocol, BBFDM_CWMP}, -{"HostList", &DMWRITE, DMT_STRING, get_IPDiagnosticsServerSelectionDiagnostics_HostList, set_IPDiagnosticsServerSelectionDiagnostics_HostList, BBFDM_CWMP}, -{"NumberOfRepetitions", &DMWRITE, DMT_UNINT, get_IPDiagnosticsServerSelectionDiagnostics_NumberOfRepetitions, set_IPDiagnosticsServerSelectionDiagnostics_NumberOfRepetitions, BBFDM_CWMP}, -{"Timeout", &DMWRITE, DMT_UNINT, get_IPDiagnosticsServerSelectionDiagnostics_Timeout, set_IPDiagnosticsServerSelectionDiagnostics_Timeout, BBFDM_CWMP}, -{"FastestHost", &DMREAD, DMT_STRING, get_IPDiagnosticsServerSelectionDiagnostics_FastestHost, NULL, BBFDM_CWMP}, -{"MinimumResponseTime", &DMREAD, DMT_UNINT, get_IPDiagnosticsServerSelectionDiagnostics_MinimumResponseTime, NULL, BBFDM_CWMP}, -{"AverageResponseTime", &DMREAD, DMT_UNINT, get_IPDiagnosticsServerSelectionDiagnostics_AverageResponseTime, NULL, BBFDM_CWMP}, -{"MaximumResponseTime", &DMREAD, DMT_UNINT, get_IPDiagnosticsServerSelectionDiagnostics_MaximumResponseTime, NULL, BBFDM_CWMP}, -{"IPAddressUsed", &DMREAD, DMT_STRING, get_IPDiagnosticsServerSelectionDiagnostics_IPAddressUsed, NULL, BBFDM_CWMP}, -{0} -}; diff --git a/libbbfdm/dmtree/tr143/diagnostics.h b/libbbfdm/dmtree/tr143/diagnostics.h deleted file mode 100644 index 993c58b9..00000000 --- a/libbbfdm/dmtree/tr143/diagnostics.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2019 iopsys Software Solutions AB - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 2.1 - * as published by the Free Software Foundation - * - * Author: Amin Ben Ramdhane - * - */ - -#ifndef __DIAGNOSTICS_H -#define __DIAGNOSTICS_H - -#include "libbbfdm-api/dmcommon.h" - -extern DMOBJ tIPDiagnosticsObj[]; -extern DMLEAF tIPDiagnosticsParams[]; -extern DMLEAF tIPDiagnosticsIPPingParams[]; -extern DMOBJ tIPDiagnosticsTraceRouteObj[]; -extern DMLEAF tIPDiagnosticsTraceRouteParams[]; -extern DMLEAF tIPDiagnosticsTraceRouteRouteHopsParams[]; -extern DMOBJ tIPDiagnosticsDownloadDiagnosticsObj[]; -extern DMLEAF tIPDiagnosticsDownloadDiagnosticsParams[]; -extern DMLEAF tIPDiagnosticsDownloadDiagnosticsPerConnectionResultParams[]; -extern DMOBJ tIPDiagnosticsUploadDiagnosticsObj[]; -extern DMLEAF tIPDiagnosticsUploadDiagnosticsParams[]; -extern DMLEAF tIPDiagnosticsUploadDiagnosticsPerConnectionResultParams[]; -extern DMLEAF tIPDiagnosticsUDPEchoConfigParams[]; -extern DMLEAF tIPDiagnosticsUDPEchoDiagnosticsParams[]; -extern DMLEAF tIPDiagnosticsServerSelectionDiagnosticsParams[]; - -#endif //__DIAGNOSTICS_H diff --git a/libbbfdm/dmtree/tr181/ip.c b/libbbfdm/dmtree/tr181/ip.c index 6a4869b4..9d18ee50 100644 --- a/libbbfdm/dmtree/tr181/ip.c +++ b/libbbfdm/dmtree/tr181/ip.c @@ -12,9 +12,6 @@ #include "dmlayer.h" #include "ip.h" -#if defined(BBF_TR143) -#include "diagnostics.h" -#endif struct intf_ip_args { @@ -2211,9 +2208,6 @@ static int operate_IPInterface_Reset(char *refparam, struct dmctx *ctx, void *da DMOBJ tIPObj[] = { /* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/ {"Interface", &DMWRITE, addObjIPInterface, delObjIPInterface, NULL, browseIPInterfaceInst, NULL, NULL, tIPInterfaceObj, tIPInterfaceParams, NULL, BBFDM_BOTH, NULL}, -#if defined(BBF_TR143) -{"Diagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPDiagnosticsObj, tIPDiagnosticsParams, NULL, BBFDM_BOTH, NULL}, -#endif {0} }; diff --git a/libbbfdm/scripts/bbf_activate_handler.sh b/libbbfdm/scripts/bbf_activate_handler.sh index 62e1e7dc..86193101 100755 --- a/libbbfdm/scripts/bbf_activate_handler.sh +++ b/libbbfdm/scripts/bbf_activate_handler.sh @@ -3,7 +3,7 @@ # Script to activate image in specified time. # # Copyright © 2022 IOPSYS Software Solutions AB -# Author: Amin Ben Ramdhane +# Author: Amin Ben Romdhane # ROOT="$(dirname "${0}")" diff --git a/libbbfdm/scripts/bbf_diag/ipping b/libbbfdm/scripts/bbf_diag/ipping deleted file mode 100755 index 1bf42aa0..00000000 --- a/libbbfdm/scripts/bbf_diag/ipping +++ /dev/null @@ -1,223 +0,0 @@ -#!/bin/sh -# Copyright (C) 2022 iopsys Software Solutions AB -# Author: MOHAMED Kallel -# Author: AMIN Ben Ramdhane - -. /usr/share/libubox/jshn.sh -. /usr/share/bbfdm/scripts/bbf_api - -ipping_list() { - json_add_object "ipping" - json_add_string "host" "str" - json_add_string "iface" "str" - json_add_string "ip_proto" "str" - json_add_string "nbr_of_rep" "str" - json_add_string "timeout" "str" - json_add_string "data_size" "str" - json_add_string "dscp" "str" - json_add_string "proto" "str" - json_add_string "cancel" "str" - json_close_object -} - -ipping_error() { - json_init - json_add_string "Status" "$1" - json_add_string "IPAddressUsed" "" - json_add_int "MinimumResponseTime" "9999" - json_add_int "AverageResponseTime" "0" - json_add_int "MaximumResponseTime" "0" - json_add_int "MinimumResponseTimeDetailed" "999999999" - json_add_int "AverageResponseTimeDetailed" "0" - json_add_int "MaximumResponseTimeDetailed" "0" - json_add_int "SuccessCount" "0" - json_add_int "FailureCount" "$2" - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "$3" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.DiagnosticState="$1" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.IPAddressUsed="" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.SuccessCount=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.FailureCount="$2" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.AverageResponseTime=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MinimumResponseTime=9999 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MaximumResponseTime=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.AverageResponseTimeDetailed=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MinimumResponseTimeDetailed=999999999 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MaximumResponseTimeDetailed=0 - $UCI_COMMIT_BBF_DMMAP - } -} - -ipping_launch() { - input="$1" - - json_load "${input}" - - json_get_var host host - json_get_var iface iface - json_get_var ip_proto ip_proto - json_get_var nbr_of_rep nbr_of_rep - json_get_var timeout timeout - json_get_var dsize data_size - json_get_var dscp dscp - json_get_var proto proto - json_get_var cancel cancel - - if [ "${proto}" = "both_proto" ]; then - old_pid=$(cat /tmp/ipping_pid) - [ -n "${old_pid}" ] && { - cmd=$(cat /proc/$old_pid/cmdline) - } - - if [[ "${cmd}" = *ipping* ]]; then - kill -9 $old_pid - fi - - if [ "${cancel}" -eq "1" ]; then - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.DiagnosticState="None" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.IPAddressUsed="" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.SuccessCount=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.FailureCount="0" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.AverageResponseTime=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MinimumResponseTime=9999 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MaximumResponseTime=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.AverageResponseTimeDetailed=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MinimumResponseTimeDetailed=999999999 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MaximumResponseTimeDetailed=0 - $UCI_COMMIT_BBF_DMMAP - - json_init - json_add_string "Status" "None" - json_add_string "IPAddressUsed" "" - json_add_int "MinimumResponseTime" "9999" - json_add_int "AverageResponseTime" "0" - json_add_int "MaximumResponseTime" "0" - json_add_int "MinimumResponseTimeDetailed" "999999999" - json_add_int "AverageResponseTimeDetailed" "0" - json_add_int "MaximumResponseTimeDetailed" "0" - json_add_int "SuccessCount" "0" - json_add_int "FailureCount" "0" - json_dump - - return - else - echo $$ > /tmp/ipping_pid - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.DiagnosticState="Requested_running" - $UCI_COMMIT_BBF_DMMAP - fi - fi - - # Assign default value - [ -z "${nbr_of_rep}" ] && nbr_of_rep=3 - [ -z "${dsize}" ] && dsize=64 - [ -n "${iface}" ] && device=$(ifstatus "${iface}" | jsonfilter -e @.l3_device) && device="-I $device" || device="" - ip_addr_used=$(get_ip_addr_used "${ip_proto}" "${iface}") - if [ "$ip_proto" = "IPv4" ]; then ip_proto="-4"; elif [ "$ip_proto" = "IPv6" ]; then ip_proto="-6"; else ip_proto=""; fi - [ -z "${timeout}" ] && timeout=1 || timeout=$((timeout/1000)) - - # Fail if host is empty - [ -z "${host}" ] && { - ipping_error "Error_Internal" "${nbr_of_rep}" "${proto}" - return - } - - micros=1000 - success_count=0 - avg_time_sum=0 - avg_time_sum_det=0 - min=9999999 - min_det=999999999 - max=0 - max_det=0 - idx=0 - - while [ $idx -lt "${nbr_of_rep}" ]; do - idx=$((idx+1)) - - res=$(ping -q ${ip_proto} -c 1 -s ${dsize} -W ${timeout} ${device} "${host}" 2>&1) - - ba=$(echo "$res" | grep -E "bad address|unknown host|Name does not resolve") - [ -n "$ba" ] && { - ipping_error "Error_CannotResolveHostName" "${nbr_of_rep}" "${proto}" - return - } - - stc=$(echo "$res" | grep "received") - [ -z "$stc" ] && { - ipping_error "Error_Other" "${nbr_of_rep}" "${proto}" - return - } - - times=$(echo "$res" | grep "min/avg/max") - [ -z "$times" ] && continue - sc1=$(echo "$stc" | awk '{print $4}') - sc1=${sc1:-0} - success_count=$((success_count+sc1)) - times=$(echo "$times" | awk -F'=' '{ print $2 }') - min_time=$(echo "$times" | awk -F'[=/ ]' '{ print $2 }') - avg_time=$(echo "$times" | awk -F'[=/ ]' '{ print $3 }') - max_time=$(echo "$times" | awk -F'[=/ ]' '{ print $4 }') - min_time=${min_time:-0} - avg_time=${avg_time:-0} - max_time=${max_time:-0} - min_time_det=$(echo "$min_time" "$micros" | awk '{printf "%3.0f\n",$1*$2}') - avg_time_det=$(echo "$avg_time" "$micros" | awk '{printf "%3.0f\n",$1*$2}') - max_time_det=$(echo "$max_time" "$micros" | awk '{printf "%3.0f\n",$1*$2}') - min_time=$(awk "BEGIN{print $min_time * 1000}") - avg_time=$(awk "BEGIN{print $avg_time * 1000}") - max_time=$(awk "BEGIN{print $max_time * 1000}") - [ "$min_time" -lt $min ] && min=$min_time - [ "$max_time" -gt $max ] && max=$max_time - avg_time_sum=$((avg_time_sum+avg_time)) - [ "$min_time_det" -lt $min_det ] && min_det=$min_time_det - [ "$max_time_det" -gt $max_det ] && max_det=$max_time_det - avg_time_sum_det=$((avg_time_sum_det+avg_time_det)) - done - - failure_count=$((nbr_of_rep-success_count)) - [ $success_count -gt 0 ] && avg_time=$((avg_time_sum/success_count)) || avg_time=0 - [ $success_count -gt 0 ] && avg_time_det=$((avg_time_sum_det/success_count)) || avg_time_det=0 - avg_time=$(awk "BEGIN{print int($avg_time / 1000)}") - min_time=$(awk "BEGIN{print int($min / 1000)}") - max_time=$(awk "BEGIN{print int($max / 1000)}") - min_time_det=$min_det - max_time_det=$max_det - - json_init - json_add_string "Status" "Complete" - json_add_string "IPAddressUsed" "${ip_addr_used}" - json_add_int "MinimumResponseTime" "${min_time}" - json_add_int "AverageResponseTime" "${avg_time}" - json_add_int "MaximumResponseTime" "${max_time}" - json_add_int "MinimumResponseTimeDetailed" "${min_time_det}" - json_add_int "AverageResponseTimeDetailed" "${avg_time_det}" - json_add_int "MaximumResponseTimeDetailed" "${max_time_det}" - json_add_int "SuccessCount" "${success_count}" - json_add_int "FailureCount" "${failure_count}" - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "${proto}" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.DiagnosticState="Complete" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.IPAddressUsed="${ip_addr_used}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.SuccessCount="${success_count}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.FailureCount="${failure_count}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MinimumResponseTime="${min_time}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.AverageResponseTime="${avg_time}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MaximumResponseTime="${max_time}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MinimumResponseTimeDetailed="${min_time_det}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.AverageResponseTimeDetailed="${avg_time_det}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.MaximumResponseTimeDetailed="${max_time_det}" - $UCI_COMMIT_BBF_DMMAP - } -} - -if [ "$1" = "list" ]; then - ipping_list -elif [ -n "$1" ]; then - ipping_launch "$1" -else - ipping_error "Error_Internal" "1" -fi diff --git a/libbbfdm/scripts/bbf_diag/serverselection b/libbbfdm/scripts/bbf_diag/serverselection deleted file mode 100755 index d49199df..00000000 --- a/libbbfdm/scripts/bbf_diag/serverselection +++ /dev/null @@ -1,243 +0,0 @@ -#!/bin/sh -# Copyright (C) 2022 iopsys Software Solutions AB -# Author: AMIN Ben Ramdhane - -. /usr/share/libubox/jshn.sh -. /usr/share/bbfdm/scripts/bbf_api - -serverselection_list() { - json_add_object "serverselection" - json_add_string "hostlist" "str" - json_add_string "port" "str" - json_add_string "iface" "str" - json_add_string "ip_proto" "str" - json_add_string "nbr_of_rep" "str" - json_add_string "timeout" "str" - json_add_string "protocol_used" "str" - json_add_string "proto" "str" - json_add_string "cancel" "str" - json_close_object -} - -serverselection_error() { - json_init - json_add_string "Status" "$1" - json_add_string "FastestHost" "" - json_add_string "IPAddressUsed" "" - json_add_int "MinimumResponseTime" "9999" - json_add_int "AverageResponseTime" "0" - json_add_int "MaximumResponseTime" "0" - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "$3" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.DiagnosticState="$1" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.FastestHost="" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.MinimumResponseTime=9999 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.AverageResponseTime=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.MaximumResponseTime=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.IPAddressUsed="" - $UCI_COMMIT_BBF_DMMAP - } -} - -serverselection_launch() { - input="$1" - - json_load "${input}" - - json_get_var hostlist hostlist - json_get_var port port - json_get_var iface iface - json_get_var ip_proto ip_proto - json_get_var nbr_of_rep nbr_of_rep - json_get_var timeout timeout - json_get_var protocol_used protocol_used - json_get_var proto proto - json_get_var cancel cancel - - if [ "${proto}" = "both_proto" ]; then - old_pid=$(cat /tmp/serverselection_pid) - - [ -n "${old_pid}" ] && { - cmd=$(cat /proc/$old_pid/cmdline) - } - - if [[ "${cmd}" = *serverselection* ]]; then - kill -9 $old_pid - fi - - if [ "${cancel}" -eq "1" ]; then - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.DiagnosticState="None" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.FastestHost="" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.MinimumResponseTime=9999 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.AverageResponseTime=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.MaximumResponseTime=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.IPAddressUsed="" - $UCI_COMMIT_BBF_DMMAP - - json_init - json_add_string "Status" "None" - json_add_string "FastestHost" "" - json_add_string "IPAddressUsed" "" - json_add_int "MinimumResponseTime" "9999" - json_add_int "AverageResponseTime" "0" - json_add_int "MaximumResponseTime" "0" - json_dump - - return - else - echo $$ > /tmp/serverselection_pid - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.DiagnosticState="Requested_running" - $UCI_COMMIT_BBF_DMMAP - fi - fi - - # Assign default value - [ -z "${nbr_of_rep}" ] && nbr_of_rep=3 - [ -z "${port}" ] && port=7 - [ -z "${protocol_used}" ] && protocol_used="ICMP" - ip_addr_used=$(get_ip_addr_used "${ip_proto}" "${iface}") - [ -z "${timeout}" ] && timeout=1 || timeout=$((timeout/1000)) - - # Fail if hostlist is empty - [ -z "${hostlist}" ] && { - serverselection_error "Error_Internal" "${nbr_of_rep}" "${proto}" - return - } - - micros=1000 - success_count=0 - avg_time_sum=0 - avg_time_host=9999999 - min=9999999 - max=0 - i=0 - - for host in $(echo "$hostlist" | tr "," "\n"); do - if [ "$protocol_used" = "ICMP" ]; then - if [ "$ip_proto" = "IPv4" ]; then ip_proto="-4"; elif [ "$ip_proto" = "IPv6" ]; then ip_proto="-6"; else ip_proto=""; fi - [ -n "${iface}" ] && device=$(ifstatus "${iface}" | jsonfilter -e @.l3_device) && device="-I $device" || device="" - - while [ $i -lt "$nbr_of_rep" ]; do - i=$((i+1)) - - res=$(ping -q ${ip_proto} -c 1 -W ${timeout} ${device} "${host}" 2>&1) - - ba=$(echo "$res" | grep "bad address") - [ -n "$ba" ] && { - serverselection_error "Error_CannotResolveHostName" "${nbr_of_rep}" "${proto}" - return - } - - ba=$(echo "$res" | grep "unknown host") - [ -n "$ba" ] && { - serverselection_error "Error_CannotResolveHostName" "${nbr_of_rep}" "${proto}" - return - } - - stc=$(echo "$res" | grep "received") - [ -z "$stc" ] && { - serverselection_error "Error_Other" "${nbr_of_rep}" "${proto}" - return - } - - times=$(echo "$res" | grep "min/avg/max") - [ -z "$times" ] && break - - sc1=$(echo "$stc" | awk '{print $4}') - sc1=${sc1:-0} - success_count=$((success_count+sc1)) - times=$(echo "$times" | awk -F'=' '{ print $2 }') - min_time=$(echo "$times" | awk -F'[=/ ]' '{ print $2 }') - avg_time=$(echo "$times" | awk -F'[=/ ]' '{ print $3 }') - max_time=$(echo "$times" | awk -F'[=/ ]' '{ print $4 }') - min_time=${min_time:-0} - avg_time=${avg_time:-0} - max_time=${max_time:-0} - min_time=$(echo "$min_time" "$micros" | awk '{printf "%3.0f\n",$1*$2}') - avg_time=$(echo "$avg_time" "$micros" | awk '{printf "%3.0f\n",$1*$2}') - max_time=$(echo "$max_time" "$micros" | awk '{printf "%3.0f\n",$1*$2}') - [ "$min_time" -lt "$min" ] && min="$min_time" - [ "$max_time" -gt "$max" ] && max="$max_time" - avg_time_sum=$((avg_time_sum+avg_time)) - done - else - if [ "$ip_proto" = "IPv4" ]; then ip_proto="--protocol 4"; elif [ "$ip_proto" = "IPv6" ]; then ip_proto="--protocol 6"; else ip_proto=""; fi - [ -n "${iface}" ] && device=$(ifstatus "${iface}" | jsonfilter -e @.l3_device) && device="-i $device" || device="" - - while [ $i -lt "$nbr_of_rep" ]; do - i=$((i+1)) - - res=$(udpechoclientd -c 1 -t $timeout --host "$host" --port "$port" $ip_proto $device 2>&1) - - ba=$(echo "$res" | grep "Can't Resolve Host Name") - [ -n "$ba" ] && { - serverselection_error "Error_CannotResolveHostName" "${nbr_of_rep}" "${proto}" - return - } - - ba=$(echo "$res" | grep "RCVD") - [ -z "$ba" ] && { - serverselection_error "Error_CannotResolveHostName" "${nbr_of_rep}" "${proto}" - return - } - - times=$(echo "$res" | grep "rtt") - [ -z "$times" ] && continue - - sc1=$(echo "$res" | grep "Rcvd" | awk -F': ' '{print $3}' | awk -F'(' '{ print $1 }') - sc1=${sc1:-0} - success_count=$((success_count+sc1)) - max_time=$(echo "$times" | awk -F': ' '{ print $2 }' | awk -F'ms' '{ print $1 }') - min_time=$(echo "$times" | awk -F': ' '{ print $3 }' | awk -F'ms' '{ print $1 }') - avg_time=$(echo "$times" | awk -F': ' '{ print $4 }' | awk -F'ms' '{ print $1 }') - min_time=${min_time:-0} - avg_time=${avg_time:-0} - max_time=${max_time:-0} - min_time=$(echo "$min_time" $micros | awk '{printf "%3.0f\n",$1*$2}') - avg_time=$(echo "$avg_time" $micros | awk '{printf "%3.0f\n",$1*$2}') - max_time=$(echo "$max_time" $micros | awk '{printf "%3.0f\n",$1*$2}') - [ "$min_time" -lt "$min" ] && min="$min_time" - [ "$max_time" -gt "$max" ] && max="$max_time" - avg_time_sum=$((avg_time_sum+avg_time)) - done - fi - - [ $success_count -gt 0 ] && avg_time=$((avg_time_sum/success_count)) || avg_time=0 - [ "$avg_time" != "0" ] && [ $avg_time -lt $avg_time_host ] && avg_time_host="$avg_time" && min_time_host="$min" && max_time_host="$max" && fasthost="$host" - success_count=0 - avg_time_sum=0 - min=9999999 - max=0 - i=0 - done - - json_init - json_add_string "Status" "Complete" - json_add_string "FastestHost" "${fasthost}" - json_add_string "IPAddressUsed" "${ip_addr_used}" - json_add_int "MinimumResponseTime" "${min_time}" - json_add_int "AverageResponseTime" "${avg_time}" - json_add_int "MaximumResponseTime" "${max_time}" - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "${proto}" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.DiagnosticState="Complete" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.FastestHost="${fasthost}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.IPAddressUsed="${ip_addr_used}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.MinimumResponseTime="${min_time_host}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.AverageResponseTime="${avg_time_host}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.MaximumResponseTime="${max_time_host}" - $UCI_COMMIT_BBF_DMMAP - } -} - -if [ "$1" = "list" ]; then - serverselection_list -elif [ -n "$1" ]; then - serverselection_launch "$1" -else - serverselection_error "Error_Internal" "1" -fi diff --git a/libbbfdm/scripts/bbf_diag/udpecho b/libbbfdm/scripts/bbf_diag/udpecho deleted file mode 100755 index 21a29453..00000000 --- a/libbbfdm/scripts/bbf_diag/udpecho +++ /dev/null @@ -1,201 +0,0 @@ -#!/bin/sh -# Copyright (C) 2022 iopsys Software Solutions AB -# Author: AMIN Ben Ramdhane - -. /usr/share/libubox/jshn.sh -. /usr/share/bbfdm/scripts/bbf_api - -udpecho_list() { - json_add_object "udpecho" - json_add_string "host" "str" - json_add_string "port" "str" - json_add_string "iface" "str" - json_add_string "ip_proto" "str" - json_add_string "nbr_of_rep" "str" - json_add_string "timeout" "str" - json_add_string "data_size" "str" - json_add_string "dscp" "str" - json_add_string "inter_trans_time" "str" - json_add_string "proto" "str" - json_add_string "cancel" "str" - json_close_object -} - -udpecho_error() { - json_init - json_add_string "Status" "$1" - json_add_string "IPAddressUsed" "" - json_add_int "SuccessCount" "0" - json_add_int "FailureCount" "$2" - json_add_int "MinimumResponseTime" "9999" - json_add_int "AverageResponseTime" "0" - json_add_int "MaximumResponseTime" "0" - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "$3" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.DiagnosticState="$1" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.SuccessCount=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.FailureCount="$2" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.MinimumResponseTime=9999 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.AverageResponseTime=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.MaximumResponseTime=0 - $UCI_COMMIT_BBF_DMMAP - } -} - -udpecho_launch() { - input="$1" - - json_load "${input}" - - json_get_var host host - json_get_var port port - json_get_var iface iface - json_get_var ip_proto ip_proto - json_get_var nbr_of_rep nbr_of_rep - json_get_var timeout timeout - json_get_var dsize data_size - json_get_var dscp dscp - json_get_var inter_time inter_trans_time - json_get_var proto proto - json_get_var cancel cancel - - [ "${proto}" = "both_proto" ] && { - old_pid=$(cat /tmp/udpecho_pid) - - [ -n "${old_pid}" ] && { - cmd=$(cat /proc/$old_pid/cmdline) - } - - if [[ "${cmd}" = *udpecho* ]]; then - kill -9 $old_pid - fi - - if [ "${cancel}" -eq "1" ]; then - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.DiagnosticState="None" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.SuccessCount="0" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.FailureCount="0" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.MinimumResponseTime="9999" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.AverageResponseTime="0" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.MaximumResponseTime="0" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.IPAddressUsed="" - $UCI_COMMIT_BBF_DMMAP - - json_init - json_add_string "Status" "None" - json_add_string "IPAddressUsed" "" - json_add_int "SuccessCount" "0" - json_add_int "FailureCount" "0" - json_add_int "MinimumResponseTime" "9999" - json_add_int "AverageResponseTime" "0" - json_add_int "MaximumResponseTime" "0" - json_dump - - return - else - echo $$ > /tmp/udpecho_pid - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.DiagnosticState="Requested_running" - $UCI_COMMIT_BBF_DMMAP - fi - } - - # Assign default value - [ -z "${nbr_of_rep}" ] && nbr_of_rep=1 - [ -z "${port}" ] && port=7 - [ -z "${dsize}" ] && dsize=24 - [ -z "${dscp}" ] && dscp=0 - [ -n "${iface}" ] && device=$(ifstatus "${iface}" | jsonfilter -e @.l3_device) && device="-i $device" || device="" - ip_addr_used=$(get_ip_addr_used "${ip_proto}" "${iface}") - if [ "$ip_proto" = "IPv4" ]; then ip_proto="--protocol 4"; elif [ "$ip_proto" = "IPv6" ]; then ip_proto="--protocol 6"; else ip_proto=""; fi - [ -z "${timeout}" ] && timeout=1 || timeout=$((timeout/1000)) - [ -z "${inter_time}" ] && inter_time=1 || inter_time=$((inter_time/1000)) - tos=$((dscp<<2)) - - # Fail if host is empty - [ -z "${host}" ] && { - udpecho_error "Error_Internal" "${nbr_of_rep}" "${proto}" - return - } - - micros=1000 - success_count=0 - avg_time_sum=0 - min=9999999 - max=0 - i=0 - - while [ $i -lt "$nbr_of_rep" ]; do - i=$((i+1)) - - res=$(udpechoclientd -c 1 -t $timeout --host "$host" --data-length "$dsize" --port "$port" $ip_proto $device 2>&1) - - ba=$(echo "$res" | grep "Can't Resolve Host Name") - [ -n "$ba" ] && { - udpecho_error "Error_CannotResolveHostName" "${nbr_of_rep}" "${proto}" - return - } - - ba=$(echo "$res" | grep "RCVD") - [[ -z "$ba" && $((nbr_of_rep-i)) == 0 ]] && { - udpecho_error "Complete" "${nbr_of_rep}" "${proto}" - return - } - - times=$(echo "$res" | grep "rtt") - [ -z "$times" ] && continue - - sc1=$(echo "$res" | grep "Rcvd" | awk -F': ' '{print $3}' | awk -F'(' '{ print $1 }') - [ "$sc1" != 0 ] && sc1=1 || sc1=0 - - success_count=$((success_count+sc1)) - max_time=$(echo "$times" | awk -F': ' '{ print $2 }' | awk -F'ms' '{ print $1 }') - min_time=$(echo "$times" | awk -F': ' '{ print $3 }' | awk -F'ms' '{ print $1 }') - avg_time=$(echo "$times" | awk -F': ' '{ print $4 }' | awk -F'ms' '{ print $1 }') - min_time=${min_time:-0} - avg_time=${avg_time:-0} - max_time=${max_time:-0} - min_time=$(echo "$min_time" "$micros" | awk '{printf "%3.0f\n",$1*$2}') - avg_time=$(echo "$avg_time" "$micros" | awk '{printf "%3.0f\n",$1*$2}') - max_time=$(echo "$max_time" "$micros" | awk '{printf "%3.0f\n",$1*$2}') - [ "$min_time" -lt "$min" ] && min="$min_time" - [ "$max_time" -gt "$max" ] && max="$max_time" - avg_time_sum=$((avg_time_sum+avg_time)) - sleep $inter_time - done - - failure_count=$((nbr_of_rep-success_count)) - [ $success_count -gt 0 ] && avg_time=$((avg_time_sum/success_count)) || avg_time=0 - min_time=$min - max_time=$max - - json_init - json_add_string "Status" "Complete" - json_add_string "IPAddressUsed" "${ip_addr_used}" - json_add_int "SuccessCount" "${success_count}" - json_add_int "FailureCount" "${failure_count}" - json_add_int "MinimumResponseTime" "${min_time}" - json_add_int "AverageResponseTime" "${avg_time}" - json_add_int "MaximumResponseTime" "${max_time}" - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "${proto}" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.DiagnosticState="Complete" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.IPAddressUsed="${ip_addr_used}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.SuccessCount="${success_count}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.FailureCount="${failure_count}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.MinimumResponseTime="${min_time}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.AverageResponseTime="${avg_time}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.MaximumResponseTime="${max_time}" - $UCI_COMMIT_BBF_DMMAP - } -} - -if [ "$1" = "list" ]; then - udpecho_list -elif [ -n "$1" ]; then - udpecho_launch "$1" -else - udpecho_error "Error_Internal" "1" -fi diff --git a/libbbfdm/scripts/download b/libbbfdm/scripts/download deleted file mode 100755 index 3c2173b9..00000000 --- a/libbbfdm/scripts/download +++ /dev/null @@ -1,235 +0,0 @@ -#!/bin/sh -# Copyright (C) 2022 iopsys Software Solutions AB -# Author: IMEN Bhiri -# Author: AMIN Ben Ramdhane - -. /usr/share/libubox/jshn.sh - -ROOT="$(dirname "${0}")" -. "${ROOT}"/bbf_api - -DOWNLOAD_TIMEOUT=1800 - -download_error() { - json_init - json_add_string "Status" "$1" - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "$2" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.DiagnosticState="$1" - } - - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.Status="complete" - $UCI_COMMIT_BBF_DMMAP -} - -download_launch() { - input="$1" - - json_load "${input}" - - json_get_var url url - json_get_var iface iface - json_get_var dscp dscp - json_get_var eth_prio eth_prio - json_get_var ip_proto ip_proto - json_get_var num_of_con num_of_con - json_get_var enable_per_con enable_per_con - json_get_var proto proto - - # Check if a download process is already running - download_s=$(uci_get_bbf_dmmap dmmap_diagnostics.download) - if [ -z "${download_s}" ]; then - [ ! -f /etc/bbfdm/dmmap/dmmap_diagnostics ] && touch /etc/bbfdm/dmmap/dmmap_diagnostics - $UCI_ADD_BBF_DMMAP dmmap_diagnostics download - $UCI_RENAME_BBF_DMMAP dmmap_diagnostics.@download[0]='download' - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.Status="running" - $UCI_COMMIT_BBF_DMMAP - else - Status=$(uci_get_bbf_dmmap dmmap_diagnostics.download.Status) - [ "${Status}" = "running" ] && { - return - } - - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.Status="running" - $UCI_COMMIT_BBF_DMMAP - fi - - # Assign default value - [ -n "${iface}" ] && device=$(ifstatus "${iface}" | jsonfilter -e @.l3_device) || device=$(route -n | grep 'UG[ \t]' | awk '{print $8}') - ip_addr_used=$(get_ip_addr_used "${ip_proto}" "${iface}") - if [ "$ip_proto" = "IPv4" ]; then ip_proto="--ipv4"; elif [ "$ip_proto" = "IPv6" ]; then ip_proto="--ipv6"; else ip_proto=""; fi - - # Fail if url is empty - [ -z "${url}" ] && { - download_error "Error_InitConnectionFailed" "${proto}" - return - } - - [ "${url:0:7}" != "http://" ] && [ "${url:0:6}" != "ftp://" ] && { - download_error "Error_Other" "${proto}" - return - } - - format='{ "size_download": "%{size_download}", - "size_header": "%{size_header}", - "time_appconnect": "%{time_appconnect}", - "time_connect": "%{time_connect}", - "time_pretransfer": "%{time_pretransfer}", - "time_starttransfer": "%{time_starttransfer}", - "time_total": "%{time_total}", - "exitcode": "%{exitcode}" }' - - tx_bytes_start=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes) - rx_bytes_start=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes) - - time_start=$(date +"%s.282646") # It should be like that time_start=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded - res=$(curl ${ip_proto} --fail --silent --max-time ${DOWNLOAD_TIMEOUT} -w "${format}" "${url}" --output /dev/null) - time_end=$(date +"%s.282646") # It should be like that time_end=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded - - tx_bytes_end=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes) - rx_bytes_end=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes) - - logger -t "bbf_download" "########### ${url} ==> ${res} ###########" - json_load "${res}" - json_get_var size_download size_download - json_get_var size_header size_header - json_get_var time_appconnect time_appconnect - json_get_var time_connect time_connect - json_get_var time_pretransfer time_pretransfer - json_get_var time_starttransfer time_starttransfer - json_get_var time_total time_total - json_get_var exitcode exitcode - - [ "$exitcode" = "6" ] && { - download_error "Error_CannotResolveHostName" "${proto}" - return - } - - [ "$exitcode" = "7" ] && { - download_error "Error_InitConnectionFailed" "${proto}" - return - } - - [ "$exitcode" = "22" ] && { - download_error "Error_NoResponse" "${proto}" - return - } - - [ "$exitcode" = "27" ] && { - download_error "Error_IncorrectSize" "${proto}" - return - } - - [ "$exitcode" = "28" ] && { - download_error "Error_Timeout" "${proto}" - return - } - - [ "$exitcode" != "0" ] && { - download_error "Error_Other" "${proto}" - return - } - - tcp_open_request_time=$(echo "${time_start}" "${time_appconnect}" | awk '{printf "%.6f", $1 + $2}') - tcp_open_response_time=$(echo "${time_start}" "${time_connect}" | awk '{printf "%.6f", $1 + $2}') - rom_time=$(echo "${time_start}" "${time_pretransfer}" | awk '{printf "%.6f", $1 + $2}') - bom_time=$(echo "${time_start}" "${time_starttransfer}" | awk '{printf "%.6f", $1 + $2}') - eom_time=$(echo "${time_start}" "${time_total}" | awk '{printf "%.6f", $1 + $2}') - - separator_idx=$(expr index "${tcp_open_request_time}" .) - TCPOpenRequestTime_MicroSec=${tcp_open_request_time:$separator_idx} - TCPOpenRequestTime_Sec=${tcp_open_request_time:0:$((separator_idx-1))} - - separator_idx=$(expr index "${tcp_open_response_time}" .) - TCPOpenResponseTime_MicroSec=${tcp_open_response_time:$separator_idx} - TCPOpenResponseTime_Sec=${tcp_open_response_time:0:$((separator_idx-1))} - - separator_idx=$(expr index "${rom_time}" .) - ROMTime_MicroSec=${rom_time:$separator_idx} - ROMTime_Sec=${rom_time:0:$((separator_idx-1))} - - separator_idx=$(expr index "${bom_time}" .) - BOMTime_MicroSec=${bom_time:$separator_idx} - BOMTime_Sec=${bom_time:0:$((separator_idx-1))} - - separator_idx=$(expr index "${eom_time}" .) - EOMTime_MicroSec=${eom_time:$separator_idx} - EOMTime_Sec=${eom_time:0:$((separator_idx-1))} - - TCPOpenRequestTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenRequestTime_MicroSec}Z" -d @"${TCPOpenRequestTime_Sec}") - TCPOpenResponseTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenResponseTime_MicroSec}Z" -d @"${TCPOpenResponseTime_Sec}") - ROMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${ROMTime_MicroSec}Z" -d @"${ROMTime_Sec}") - BOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${BOMTime_MicroSec}Z" -d @"${BOMTime_Sec}") - EOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${EOMTime_MicroSec}Z" -d @"${EOMTime_Sec}") - - tx_bytes=$((tx_bytes_end-tx_bytes_start)) - rx_bytes=$((rx_bytes_end-rx_bytes_start)) - test_rx_bytes=$((size_download+size_header)) - period_time=$(echo "${time_end}" "${time_start}" | awk '{printf ($1 - $2) * 1000000}') - - json_init - json_add_string "Status" "Complete" - json_add_string "IPAddressUsed" "${ip_addr_used}" - json_add_string "ROMTime" "${ROMTime}" - json_add_string "BOMTime" "${BOMTime}" - json_add_string "EOMTime" "${EOMTime}" - json_add_int "TestBytesReceived" "${test_rx_bytes}" - json_add_int "TotalBytesReceived" "${rx_bytes}" - json_add_int "TotalBytesSent" "${tx_bytes}" - json_add_int "PeriodOfFullLoading" "${period_time}" - json_add_string "TCPOpenRequestTime" "${TCPOpenRequestTime}" - json_add_string "TCPOpenResponseTime" "${TCPOpenResponseTime}" - if [ "$enable_per_con" = "true" ] || [ "$enable_per_con" = "1" ]; then - json_add_array "DownloadPerConnection" - json_add_object "" - json_add_string "ROMTime" "${ROMTime}" - json_add_string "BOMTime" "${BOMTime}" - json_add_string "EOMTime" "${EOMTime}" - json_add_int "TestBytesReceived" "${test_rx_bytes}" - json_add_int "TotalBytesReceived" "${rx_bytes}" - json_add_int "TotalBytesSent" "${tx_bytes}" - json_add_string "TCPOpenRequestTime" "${TCPOpenRequestTime}" - json_add_string "TCPOpenResponseTime" "${TCPOpenResponseTime}" - json_close_object - fi - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "${proto}" == "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.DiagnosticState="Complete" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.IPAddressUsed="${ip_addr_used}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.ROMTime="${ROMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.BOMTime="${BOMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.EOMTime="${EOMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.TestBytesReceived="${test_rx_bytes}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.TotalBytesReceived="${rx_bytes}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.TotalBytesSent="${tx_bytes}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.PeriodOfFullLoading="${period_time}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.TCPOpenRequestTime="${TCPOpenRequestTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.TCPOpenResponseTime="${TCPOpenResponseTime}" - if [ "$enable_per_con" = "true" ] || [ "$enable_per_con" = "1" ]; then - $UCI_ADD_BBF_DMMAP dmmap_diagnostics DownloadPerConnection - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@DownloadPerConnection[0].ROMTime="${ROMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@DownloadPerConnection[0].BOMTime="${BOMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@DownloadPerConnection[0].EOMTime="${EOMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@DownloadPerConnection[0].TestBytesReceived="${test_rx_bytes}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@DownloadPerConnection[0].TotalBytesReceived="${rx_bytes}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@DownloadPerConnection[0].TotalBytesSent="${tx_bytes}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@DownloadPerConnection[0].TCPOpenRequestTime="${TCPOpenRequestTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@DownloadPerConnection[0].TCPOpenResponseTime="${TCPOpenResponseTime}" - else - $UCI_DELETE_BBF_DMMAP dmmap_diagnostics.@DownloadPerConnection[0] - fi - } - - $UCI_SET_BBF_DMMAP dmmap_diagnostics.download.Status="complete" - $UCI_COMMIT_BBF_DMMAP -} - -if [ -n "$1" ]; then - download_launch "$1" -else - download_error "Error_Internal" -fi diff --git a/libbbfdm/scripts/traceroute b/libbbfdm/scripts/traceroute deleted file mode 100755 index c3833870..00000000 --- a/libbbfdm/scripts/traceroute +++ /dev/null @@ -1,180 +0,0 @@ -#!/bin/sh -# Copyright (C) 2022 iopsys Software Solutions AB -# Author: AMIN Ben Ramdhane - -. /usr/share/libubox/jshn.sh - -ROOT="$(dirname "${0}")" -. "${ROOT}"/bbf_api - -get_traceroute_log_file() { - IDX=1 - LOG_FILE="/tmp/traceroute_$IDX.log" - - while [ -e ${LOG_FILE} ]; do - IDX=$((IDX+1)) - LOG_FILE="/tmp/traceroute_$IDX.log"; - done - - echo ${LOG_FILE} -} - -traceroute_error() { - json_init - json_add_string "Status" "$1" - json_add_string "IPAddressUsed" "$2" - json_add_int "ResponseTime" "0" - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "$3" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.DiagnosticState="$1" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.IPAddressUsed="$2" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.ResponseTime=0 - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.NumberOfHops=0 - - $UCI_COMMIT_BBF_DMMAP - } -} - -traceroute_launch() { - input="$1" - - json_load "${input}" - - json_get_var host host - json_get_var iface iface - json_get_var ip_proto ip_proto - json_get_var cnt nbr_of_tries - json_get_var timeout timeout - json_get_var dsize data_size - json_get_var dscp dscp - json_get_var maxhop max_hop_cnt - json_get_var proto proto - json_get_var cancel cancel - - LOG_FILE=$(get_traceroute_log_file) - - # Assign default value - [ -z "${cnt}" ] && cnt=1 - [ -z "${maxhop}" ] && maxhop=30 - [ -n "${iface}" ] && device=$(ifstatus "${iface}" | jsonfilter -e @.l3_device) && device="-i $device" || device="" - ip_addr_used=$(get_ip_addr_used "${ip_proto}" "${iface}") - if [ "$ip_proto" = "IPv4" ]; then ip_proto="-4"; elif [ "$ip_proto" = "IPv6" ]; then ip_proto="-6"; else ip_proto=""; fi - [ -z "${timeout}" ] && timeout=5 || timeout=$((timeout/1000)) - - # Clear all route hops instances - [ "$proto" = "both_proto" ] && { - old_pid=$(cat /tmp/traceroute_pid) - - [ -n "${old_pid}" ] && { - cmd=$(cat /proc/$old_pid/cmdline) - } - - if [[ "${cmd}" = *traceroute* ]]; then - kill -9 ${old_pid} - fi - - res=$($UCI_SHOW_BBF_DMMAP dmmap_diagnostics | grep -E "=RouteHops$" | cut -d= -f 1) - for i in $res; do - $UCI_DELETE_BBF_DMMAP "${i}" - done - - if [ "${cancel}" -eq "1" ]; then - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.DiagnosticState="None" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.IPAddressUsed="" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.NumberOfHops="0" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.ResponseTime="0" - $UCI_COMMIT_BBF_DMMAP - - json_init - json_add_string "Status" "None" - json_add_string "IPAddressUsed" "" - json_add_int "ResponseTime" "0" - json_dump - - return - else - echo $$ > /tmp/traceroute_pid - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.DiagnosticState="Requested_running" - $UCI_COMMIT_BBF_DMMAP - fi - } - - # Fail if host is empty - [ -z "${host}" ] && { - traceroute_error "Error_Internal" "${ip_addr_used}" "${proto}" - return - } - - [ -z "${dsize}" ] && dsize="38" - - res=$(traceroute -m ${maxhop} -w ${timeout} -q ${cnt} ${ip_proto} ${device} "${host}" "${dsize}" 2>&1 >"${LOG_FILE}") - error_code="$?" - - ba=$(echo "$res" | grep "bad address") - [ -n "$ba" ] && { - traceroute_error "Error_CannotResolveHostName" "${ip_addr_used}" "${proto}" - return - } - - [ "$error_code" != "0" ] && { - traceroute_error "Error_Other" "${ip_addr_used}" "${proto}" - return - } - - i=-2 - resp_time=0 - json_init - json_add_array "RouteHops" - - while read _ host ip time _; do - [ "$host" = "*" ] || [ "$ip" = "*" ] && continue - i=$((i+1)) - [ "$i" = "-1" ] && continue; - ip=${ip#(}; ip=${ip%)} - time=${time%.*} - resp_time="${time}" - - json_add_object "" - json_add_string "Host" "${host}" - json_add_string "HostAddress" "${ip}" - json_add_int "RTTimes" "${time}" - json_add_int "ErrorCode" "0" - json_close_object - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "$proto" = "both_proto" ] && { - $UCI_ADD_BBF_DMMAP dmmap_diagnostics RouteHops - $UCI_RENAME_BBF_DMMAP dmmap_diagnostics.@RouteHops[$i]="route_hops_${i}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@RouteHops[$i].host="${host}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@RouteHops[$i].ip="${ip}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@RouteHops[$i].time="${time}" - } - - done < "${LOG_FILE}" - - rm -f "${LOG_FILE}" - i=$((i+1)) - - json_close_array - json_add_string "Status" "Complete" - json_add_string "IPAddressUsed" "${ip_addr_used}" - json_add_int "ResponseTime" "${resp_time}" - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "$proto" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.DiagnosticState="Complete" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.IPAddressUsed="${ip_addr_used}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.NumberOfHops="${i}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.ResponseTime="${resp_time}" - $UCI_COMMIT_BBF_DMMAP - } -} - -if [ -n "$1" ]; then - traceroute_launch "$1" -else - traceroute_error "Error_Internal" -fi diff --git a/libbbfdm/scripts/upload b/libbbfdm/scripts/upload deleted file mode 100755 index 49229ce0..00000000 --- a/libbbfdm/scripts/upload +++ /dev/null @@ -1,236 +0,0 @@ -#!/bin/sh -# Copyright (C) 2022 iopsys Software Solutions AB -# Author: IMEN Bhiri -# Author: AMIN Ben Ramdhane - -. /usr/share/libubox/jshn.sh - -ROOT="$(dirname "${0}")" -. "${ROOT}"/bbf_api - -UPLOAD_TIMEOUT=1800 - -upload_error() { - json_init - json_add_string "Status" "$1" - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "$2" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.DiagnosticState="$1" - } - - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.Status="complete" - $UCI_COMMIT_BBF_DMMAP -} - -upload_launch() { - input="$1" - - json_load "${input}" - - json_get_var url url - json_get_var iface iface - json_get_var dscp dscp - json_get_var eth_prio eth_prio - json_get_var file_length file_length - json_get_var ip_proto ip_proto - json_get_var num_of_con num_of_con - json_get_var enable_per_con enable_per_con - json_get_var proto proto - - # Check if an upload process is already running - upload_s=$(uci_get_bbf_dmmap dmmap_diagnostics.upload) - if [ -z "${upload_s}" ]; then - [ ! -f /etc/bbfdm/dmmap/dmmap_diagnostics ] && touch /etc/bbfdm/dmmap/dmmap_diagnostics - $UCI_ADD_BBF_DMMAP dmmap_diagnostics upload - $UCI_RENAME_BBF_DMMAP dmmap_diagnostics.@upload[0]='upload' - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.Status="running" - $UCI_COMMIT_BBF_DMMAP - else - Status=$(uci_get_bbf_dmmap dmmap_diagnostics.upload.Status) - [ "${Status}" = "running" ] && { - return - } - - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.Status="running" - $UCI_COMMIT_BBF_DMMAP - fi - - # Assign default value - [ -n "${iface}" ] && device=$(ifstatus "${iface}" | jsonfilter -e @.l3_device) || device=$(route -n | grep 'UG[ \t]' | awk '{print $8}') - ip_addr_used=$(get_ip_addr_used "${ip_proto}" "${iface}") - if [ "$ip_proto" = "IPv4" ]; then ip_proto="--ipv4"; elif [ "$ip_proto" = "IPv6" ]; then ip_proto="--ipv6"; else ip_proto=""; fi - - # Fail if url is empty - [ -z "${url}" ] && { - upload_error "Error_InitConnectionFailed" "${proto}" - return - } - - [ "${url:0:7}" != "http://" ] && [ "${url:0:6}" != "ftp://" ] && { - upload_error "Error_Other" "${proto}" - return - } - - format='{ "size_upload":"%{size_upload}", "time_appconnect":"%{time_appconnect}", "time_connect":"%{time_connect}", "time_pretransfer":"%{time_pretransfer}", "time_starttransfer":"%{time_starttransfer}", "time_total":"%{time_total}", "exitcode":"%{exitcode}" }' - - len_mb=$((file_length/(1000*1000))) - if [ $len_mb -gt 0 ]; then - bs="1MB" - count="$len_mb" - else - bs="$file_length" - count="1" - fi - - tx_bytes_start=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes) - rx_bytes_start=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes) - - time_start=$(date +"%s.282646") # It should be like that time_start=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded - res=$(dd if=/dev/zero bs="${bs}" count=${count} 2>/dev/null | curl ${ip_proto} --fail --silent --max-time ${UPLOAD_TIMEOUT} -T - "${url}" -w "${format}"|grep -wo '{.*}') - time_end=$(date +"%s.282646") # It should be like that time_end=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded - - tx_bytes_end=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes) - rx_bytes_end=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes) - - logger -t "bbf_upload" "# ${url} => ${res} #" - json_load "${res}" - json_get_var size_upload size_upload - json_get_var time_appconnect time_appconnect - json_get_var time_connect time_connect - json_get_var time_pretransfer time_pretransfer - json_get_var time_starttransfer time_starttransfer - json_get_var time_total time_total - json_get_var exitcode exitcode - - [ "$exitcode" = "6" ] && { - upload_error "Error_CannotResolveHostName" "${proto}" - return - } - - [ "$exitcode" = "7" ] && { - upload_error "Error_InitConnectionFailed" "${proto}" - return - } - - [ "$exitcode" = "22" ] && { - upload_error "Error_NoResponse" "${proto}" - return - } - - [ "$exitcode" = "27" ] && { - upload_error "Error_IncorrectSize" "${proto}" - return - } - - [ "$exitcode" = "28" ] && { - upload_error "Error_Timeout" "${proto}" - return - } - - [ "$exitcode" != "0" ] && { - upload_error "Error_Other" "${proto}" - return - } - - tcp_open_request_time=$(echo "${time_start}" "${time_appconnect}" | awk '{printf "%.6f", $1 + $2}') - tcp_open_response_time=$(echo "${time_start}" "${time_connect}" | awk '{printf "%.6f", $1 + $2}') - rom_time=$(echo "${time_start}" "${time_pretransfer}" | awk '{printf "%.6f", $1 + $2}') - bom_time=$(echo "${time_start}" "${time_starttransfer}" | awk '{printf "%.6f", $1 + $2}') - eom_time=$(echo "${time_start}" "${time_total}" | awk '{printf "%.6f", $1 + $2}') - - separator_idx=$(expr index "${tcp_open_request_time}" .) - TCPOpenRequestTime_MicroSec=${tcp_open_request_time:$separator_idx} - TCPOpenRequestTime_Sec=${tcp_open_request_time:0:$((separator_idx-1))} - - separator_idx=$(expr index "${tcp_open_response_time}" .) - TCPOpenResponseTime_MicroSec=${tcp_open_response_time:$separator_idx} - TCPOpenResponseTime_Sec=${tcp_open_response_time:0:$((separator_idx-1))} - - separator_idx=$(expr index "${rom_time}" .) - ROMTime_MicroSec=${rom_time:$separator_idx} - ROMTime_Sec=${rom_time:0:$((separator_idx-1))} - - separator_idx=$(expr index "${bom_time}" .) - BOMTime_MicroSec=${bom_time:$separator_idx} - BOMTime_Sec=${bom_time:0:$((separator_idx-1))} - - separator_idx=$(expr index "${eom_time}" .) - EOMTime_MicroSec=${eom_time:$separator_idx} - EOMTime_Sec=${eom_time:0:$((separator_idx-1))} - - TCPOpenRequestTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenRequestTime_MicroSec}Z" -d @"${TCPOpenRequestTime_Sec}") - TCPOpenResponseTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenResponseTime_MicroSec}Z" -d @"${TCPOpenResponseTime_Sec}") - ROMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${ROMTime_MicroSec}Z" -d @"${ROMTime_Sec}") - BOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${BOMTime_MicroSec}Z" -d @"${BOMTime_Sec}") - EOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${EOMTime_MicroSec}Z" -d @"${EOMTime_Sec}") - - tx_bytes=$((tx_bytes_end-tx_bytes_start)) - rx_bytes=$((rx_bytes_end-rx_bytes_start)) - period_time=$(echo "${time_end}" "${time_start}" | awk '{printf ($1 - $2) * 1000000}') - - json_init - json_add_string "Status" "Complete" - json_add_string "IPAddressUsed" "${ip_addr_used}" - json_add_string "ROMTime" "${ROMTime}" - json_add_string "BOMTime" "${BOMTime}" - json_add_string "EOMTime" "${EOMTime}" - json_add_int "TestBytesSent" "${size_upload}" - json_add_int "TotalBytesReceived" "${rx_bytes}" - json_add_int "TotalBytesSent" "${tx_bytes}" - json_add_int "PeriodOfFullLoading" "${period_time}" - json_add_string "TCPOpenRequestTime" "${TCPOpenRequestTime}" - json_add_string "TCPOpenResponseTime" "${TCPOpenResponseTime}" - if [ "$enable_per_con" = "true" ] || [ "$enable_per_con" = "1" ]; then - json_add_array "UploadPerConnection" - json_add_object "" - json_add_string "ROMTime" "${ROMTime}" - json_add_string "BOMTime" "${BOMTime}" - json_add_string "EOMTime" "${EOMTime}" - json_add_int "TestBytesSent" "${size_upload}" - json_add_int "TotalBytesReceived" "${rx_bytes}" - json_add_int "TotalBytesSent" "${tx_bytes}" - json_add_string "TCPOpenRequestTime" "${TCPOpenRequestTime}" - json_add_string "TCPOpenResponseTime" "${TCPOpenResponseTime}" - json_close_object - fi - json_dump - - # Store data in dmmap_diagnostics for both protocols (cwmp/usp) - [ "${proto}" = "both_proto" ] && { - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.DiagnosticState="Complete" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.IPAddressUsed="${ip_addr_used}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.ROMTime="${ROMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.BOMTime="${BOMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.EOMTime="${EOMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.TestBytesSent="${size_upload}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.TotalBytesReceived="${rx_bytes}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.TotalBytesSent="${tx_bytes}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.PeriodOfFullLoading="${period_time}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.TCPOpenRequestTime="${TCPOpenRequestTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.TCPOpenResponseTime="${TCPOpenResponseTime}" - if [ "$enable_per_con" = "true" ] || [ "$enable_per_con" = "1" ]; then - $UCI_ADD_BBF_DMMAP dmmap_diagnostics UploadPerConnection - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@UploadPerConnection[0].ROMTime="${ROMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@UploadPerConnection[0].BOMTime="${BOMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@UploadPerConnection[0].EOMTime="${EOMTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@UploadPerConnection[0].TestBytesSent="${size_upload}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@UploadPerConnection[0].TotalBytesReceived="${rx_bytes}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@UploadPerConnection[0].TotalBytesSent="${tx_bytes}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@UploadPerConnection[0].TCPOpenRequestTime="${TCPOpenRequestTime}" - $UCI_SET_BBF_DMMAP dmmap_diagnostics.@UploadPerConnection[0].TCPOpenResponseTime="${TCPOpenResponseTime}" - else - $UCI_DELETE_BBF_DMMAP dmmap_diagnostics.@UploadPerConnection[0] - fi - } - - $UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.Status="complete" - $UCI_COMMIT_BBF_DMMAP -} - -if [ -n "$1" ]; then - upload_launch "$1" -else - upload_error "Error_Internal" -fi diff --git a/tools/tools_input.json b/tools/tools_input.json index b64ce6b3..47c05d20 100644 --- a/tools/tools_input.json +++ b/tools/tools_input.json @@ -230,6 +230,14 @@ "src/*.c" ] }, + { + "repo": "https://dev.iopsys.eu/bbf/tr143d.git", + "proto": "git", + "version": "devel", + "dm_files": [ + "src/diagnostics.c" + ] + }, { "repo": "https://dev.iopsys.eu/bbf/tr471d.git", "proto": "git",