Move TR-471 Data Model to tr471d

This commit is contained in:
Amin Ben Romdhane 2024-05-16 14:31:00 +02:00
parent c35c1da0b2
commit 3a2ffcf318
14 changed files with 128 additions and 1982 deletions

View file

@ -113,5 +113,6 @@ 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.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 |

View file

@ -342,6 +342,97 @@ int bbfdm_get_reference_linker(struct dmctx *ctx, char *reference_path, struct d
return 0;
}
static char *bbfdm_get_reference_value(char *reference_path)
{
unsigned int reference_path_dot_num = count_occurrences(reference_path, '.');
json_object *res = NULL;
json_object *in_args = json_object_new_object();
json_object_object_add(in_args, "proto", json_object_new_string("usp"));
json_object_object_add(in_args, "instance_mode", json_object_new_string("0"));
json_object_object_add(in_args, "format", json_object_new_string("raw"));
dmubus_call("bbfdm", "get",
UBUS_ARGS{
{"path", reference_path, String},
{"optional", json_object_to_json_string(in_args), Table}
},
2, &res);
json_object_put(in_args);
if (!res)
return NULL;
json_object *res_array = dmjson_get_obj(res, 1, "results");
if (!res_array)
return NULL;
size_t nbre_obj = json_object_array_length(res_array);
if (nbre_obj == 0)
return NULL;
for (size_t i = 0; i < nbre_obj; i++) {
json_object *res_obj = json_object_array_get_idx(res_array, i);
char *fault = dmjson_get_value(res_obj, 1, "fault");
if (DM_STRLEN(fault))
return NULL;
char *path = dmjson_get_value(res_obj, 1, "path");
unsigned int path_dot_num = count_occurrences(path, '.');
if (path_dot_num > reference_path_dot_num)
continue;
json_object *flags_array = dmjson_get_obj(res_obj, 1, "flags");
if (flags_array) {
size_t nbre_falgs = json_object_array_length(flags_array);
for (size_t j = 0; j < nbre_falgs; j++) {
json_object *flag_obj = json_object_array_get_idx(flags_array, j);
const char *flag = json_object_get_string(flag_obj);
if (DM_LSTRCMP(flag, "Linker") == 0) {
char *data = dmjson_get_value(res_obj, 1, "data");
return data ? dmstrdup(data) : "";
}
}
}
}
return NULL;
}
int bbfdm_operate_reference_linker(struct dmctx *ctx, char *reference_path, char **reference_value)
{
if (!ctx) {
BBF_ERR("%s: ctx should not be null", __func__);
return -1;
}
if (DM_STRLEN(reference_path) == 0) {
BBF_ERR("%s: reference path should not be empty", __func__);
return -1;
}
if (!reference_value) {
BBF_ERR("%s: reference_value should not be null", __func__);
return -1;
}
adm_entry_get_reference_value(ctx, reference_path, reference_value);
if (DM_STRLEN(*reference_value) != 0)
return 0;
if (is_micro_service == true) // It's a micro-service instance
*reference_value = bbfdm_get_reference_value(reference_path);
return 0;
}
__attribute__ ((deprecated)) int bbf_validate_string(char *value, int min_length, int max_length, char *enumeration[], char *pattern[])
{
struct dmctx ctx = {0};

View file

@ -2480,7 +2480,7 @@ char *diagnostics_get_interface_name(struct dmctx *ctx, char *value)
if (strncmp(value, "Device.IP.Interface.", 20) != 0)
return "";
adm_entry_get_reference_value(ctx, value, &linker);
bbfdm_operate_reference_linker(ctx, value, &linker);
return linker ? linker : "";
}

View file

@ -306,6 +306,7 @@ int bbf_get_reference_args(char *value, struct dm_reference *reference_args); //
int bbfdm_get_references(struct dmctx *ctx, int match_action, const char *base_path, char *key_name, char *key_value, char *out, size_t out_len);
int _bbfdm_get_references(struct dmctx *ctx, const char *base_path, char *key_name, char *key_value, char **value);
int bbfdm_get_reference_linker(struct dmctx *ctx, char *reference_path, struct dm_reference *reference_args);
int bbfdm_operate_reference_linker(struct dmctx *ctx, char *reference_path, char **reference_value);
char *base64_decode(const char *src);
void string_to_mac(const char *str, size_t str_len, char *out, size_t out_len);
bool folder_exists(const char *path);

View file

@ -652,7 +652,7 @@ int _bbfdm_get_references(struct dmctx *ctx, const char *base_path, char *key_na
/*********************************************************************//**
**
** bbf_get_linker_from_reference
** bbfdm_get_reference_linker
**
** This API is used to get the reference arguments in order to set external linker
**
@ -665,6 +665,23 @@ int _bbfdm_get_references(struct dmctx *ctx, const char *base_path, char *key_na
**************************************************************************/
int bbfdm_get_reference_linker(struct dmctx *ctx, char *reference_path, struct dm_reference *reference_args);
/*********************************************************************//**
**
** bbfdm_operate_reference_linker
**
** This API is used to retrieve the linker value associated with a given reference path
** Note: This API is only allowed to be used during an operate command.
**
** \param ctx - Pointer to bbf context structure
** \param reference_path - reference path
** \param reference_value - Pointer to a string where the linker value of the given reference path will be stored
**
** \return 0 if operation is successful, -1 otherwise
**
** Note: This API is only allowed to be used during operate command
**************************************************************************/
int bbfdm_operate_reference_linker(struct dmctx *ctx, char *reference_path, char **reference_value);
/*********************************************************************//**
**
** bbfdm_validate_string

View file

@ -9,7 +9,6 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SOURCE_DIR} -I${CMAKE_CURRENT_SOUR
OPTION(BBF_TR181 "build with tr181 datamodel" ON)
OPTION(BBF_TR143 "build with tr143 datamodel" ON)
OPTION(BBF_TR471 "build with tr471 datamodel" ON)
OPTION(BBF_WIFI_DATAELEMENTS "build with wifi dataelements datamodel" ON)
SET(BBF_DM_SOURCES dmlayer.c)
@ -29,17 +28,7 @@ IF(BBF_TR143)
add_compile_definitions(BBF_TR143)
ENDIF(BBF_TR143)
IF(BBF_TR471)
IF(NOT 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/diagnostics.c)
ENDIF()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr471")
FILE(GLOB BBF_TR471_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr471/*.c)
add_compile_definitions(BBF_TR471)
ENDIF(BBF_TR471)
ADD_LIBRARY(bbfdm SHARED ${BBF_DM_SOURCES} ${BBF_TR181_SOURCES} ${BBF_TR143_SOURCES} ${BBF_TR471_SOURCES})
ADD_LIBRARY(bbfdm SHARED ${BBF_DM_SOURCES} ${BBF_TR181_SOURCES} ${BBF_TR143_SOURCES})
TARGET_LINK_LIBRARIES(bbfdm uci ubus ubox json-c blobmsg_json m bbfdm-api ssl crypto)

View file

@ -10,15 +10,10 @@
*/
#include "diagnostics.h"
#ifdef BBF_TR471
#include "iplayercap.h"
#endif
#ifdef BBF_TR143
#define TRACEROUTE_DIAGNOSTIC_PATH BBFDM_SCRIPTS_PATH"/traceroute"
#define DOWNLOAD_DIAGNOSTIC_PATH BBFDM_SCRIPTS_PATH"/download"
#define UPLOAD_DIAGNOSTIC_PATH BBFDM_SCRIPTS_PATH"/upload"
#endif
/*************************************************************
* COMMON FUNCTIONS
@ -40,7 +35,6 @@ static void stop_traceroute_diagnostics(void)
/*************************************************************
* GET & SET PARAM
**************************************************************/
#ifdef BBF_TR143
/*
* *** Device.IP.Diagnostics.IPPing. ***
*/
@ -2445,7 +2439,6 @@ static int operate_IPDiagnostics_ServerSelectionDiagnostics(char *refparam, stru
return 0;
}
#endif
/**********************************************************************************************************************************
* OBJ & LEAF DEFINITION
@ -2453,23 +2446,17 @@ static int operate_IPDiagnostics_ServerSelectionDiagnostics(char *refparam, stru
/* *** Device.IP.Diagnostics. *** */
DMOBJ tIPDiagnosticsObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
#ifdef BBF_TR143
{"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},
#endif
#ifdef BBF_TR471
{"IPLayerCapacityMetrics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPLayerCapacityObj, tIPLayerCapacityParams, NULL, BBFDM_CWMP},
#endif
{0}
};
DMLEAF tIPDiagnosticsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
#ifdef BBF_TR143
{"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},
@ -2488,20 +2475,9 @@ DMLEAF tIPDiagnosticsParams[] = {
{"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},
#endif
#ifdef BBF_TR471
{"IPLayerCapacitySupported", &DMREAD, DMT_BOOL, get_diag_enable_true, NULL, BBFDM_BOTH},
{"IPLayerMaxConnections", &DMREAD, DMT_UNINT, get_IPDiagnosticsIPLayerCapacity_MaxConnections, NULL, BBFDM_USP},
{"IPLayerMaxIncrementalResult", &DMREAD, DMT_UNINT, get_IPDiagnosticsIPLayerCapacity_MaxIncrementalResult, NULL, BBFDM_USP},
{"IPLayerCapSupportedSoftwareVersion", &DMREAD, DMT_STRING, get_IPDiagnosticsIPLayerCapacity_SoftwareVersion, NULL, BBFDM_USP},
{"IPLayerCapSupportedControlProtocolVersion", &DMREAD, DMT_UNINT, get_IPDiagnosticsIPLayerCapacity_ControlProtocolVersion, NULL, BBFDM_USP},
{"IPLayerCapSupportedMetrics", &DMREAD, DMT_STRING, get_IPDiagnosticsIPLayerCapacity_SupportedMetrics, NULL, BBFDM_USP},
{"IPLayerCapacity()", &DMASYNC, DMT_COMMAND, get_operate_args_IPDiagnostics_IPLayerCapacity, operate_IPDiagnostics_IPLayerCapacity, BBFDM_USP},
#endif
{0}
};
#ifdef BBF_TR143
/* *** Device.IP.Diagnostics.IPPing. *** */
DMLEAF tIPDiagnosticsIPPingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
@ -2698,4 +2674,3 @@ DMLEAF tIPDiagnosticsServerSelectionDiagnosticsParams[] = {
{"IPAddressUsed", &DMREAD, DMT_STRING, get_IPDiagnosticsServerSelectionDiagnostics_IPAddressUsed, NULL, BBFDM_CWMP},
{0}
};
#endif

View file

@ -14,12 +14,8 @@
#include "libbbfdm-api/dmcommon.h"
#if defined(BBF_TR143) || defined(BBF_TR471)
extern DMOBJ tIPDiagnosticsObj[];
extern DMLEAF tIPDiagnosticsParams[];
#endif
#ifdef BBF_TR143
extern DMLEAF tIPDiagnosticsIPPingParams[];
extern DMOBJ tIPDiagnosticsTraceRouteObj[];
extern DMLEAF tIPDiagnosticsTraceRouteParams[];
@ -33,6 +29,5 @@ extern DMLEAF tIPDiagnosticsUploadDiagnosticsPerConnectionResultParams[];
extern DMLEAF tIPDiagnosticsUDPEchoConfigParams[];
extern DMLEAF tIPDiagnosticsUDPEchoDiagnosticsParams[];
extern DMLEAF tIPDiagnosticsServerSelectionDiagnosticsParams[];
#endif
#endif
#endif //__DIAGNOSTICS_H

View file

@ -12,7 +12,7 @@
#include "dmlayer.h"
#include "ip.h"
#if defined(BBF_TR143) || defined(BBF_TR471)
#if defined(BBF_TR143)
#include "diagnostics.h"
#endif
@ -2211,7 +2211,7 @@ 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) || defined(BBF_TR471)
#if defined(BBF_TR143)
{"Diagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPDiagnosticsObj, tIPDiagnosticsParams, NULL, BBFDM_BOTH, NULL},
#endif
{0}

File diff suppressed because it is too large Load diff

View file

@ -1,31 +0,0 @@
/*
* Copyright (C) 2023 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: Suvendhu Hansa <suvendhu.hansa@iopsys.eu>
*
*/
#ifndef __IPLAYERCAP_H
#define __IPLAYERCAP_H
#include "libbbfdm-api/dmcommon.h"
extern DMOBJ tIPLayerCapacityObj[];
extern DMLEAF tIPLayerCapacityParams[];
extern DMLEAF tIPLayerCapacityModalResultParams[];
extern DMLEAF tIPLayerCapacityIncrementalResultParams[];
int operate_IPDiagnostics_IPLayerCapacity(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_operate_args_IPDiagnostics_IPLayerCapacity(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsIPLayerCapacity_SoftwareVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsIPLayerCapacity_MaxConnections(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsIPLayerCapacity_MaxIncrementalResult(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsIPLayerCapacity_ControlProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_IPDiagnosticsIPLayerCapacity_SupportedMetrics(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif

View file

@ -1,463 +0,0 @@
#!/bin/sh
# Copyright (C) 2023 iopsys Software Solutions AB
# Author: Suvendhu Hansa <suvendhu.hansa@iopsys.eu>
. /usr/share/libubox/jshn.sh
ROOT="$(dirname "${0}")"
. "${ROOT}"/bbf_api
clear_iplayercapacity_output() {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.DiagnosticState="${1}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.SoftwareVersion=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.BOMTime=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.EOMTime=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.TmaxUsed=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.TestInterval=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.TmaxRTTUsed=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.TimestampResolutionUsed=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MaxIPLayerCapacity=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.TimeOfMax=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MaxETHCapacityNoFCS=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MaxETHCapacityWithFCS=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MaxETHCapacityWithFCSVLAN=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.LossRatioAtMax=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.RTTRangeAtMax=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.PDVRangeAtMax=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MinOnewayDelayAtMax=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.ReorderedRatioAtMax=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.ReplicatedRatioAtMax=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.InterfaceEthMbpsAtMax=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.IPLayerCapacitySummary=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.LossRatioSummary=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.RTTRangeSummary=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.PDVRangeSummary=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MinOnewayDelaySummary=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MinRTTSummary=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.ReorderedRatioSummary=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.ReplicatedRatioSummary=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.InterfaceEthMbpsSummary=""
}
iplayercap_error() {
json_init
json_add_string "Status" "$1"
json_dump
# Store data in dmmap
[ "$2" = "both_proto" ] && {
clear_iplayercapacity_output "$1"
# Clear all incremental & modal result instances
res=$($UCI_SHOW_BBF_DMMAP dmmap_diagnostics | grep -E "=modalresult$" | cut -d= -f 1)
for i in $res; do
$UCI_DELETE_BBF_DMMAP "${i}"
done
res=$($UCI_SHOW_BBF_DMMAP dmmap_diagnostics | grep -E "=incrementalresult$" | cut -d= -f 1)
for i in $res; do
$UCI_DELETE_BBF_DMMAP "${i}"
done
$UCI_COMMIT_BBF_DMMAP
}
}
iplayercap_launch() {
input="$1"
options=""
json_load "${input}"
json_get_var interface interface
json_get_var role role
json_get_var host host
json_get_var port port
json_get_var jumbo_frames jumbo_frames
json_get_var DSCP DSCP
json_get_var proto_ver proto_ver
json_get_var udp_content udp_content
json_get_var test_type test_type
json_get_var ipdv_enable ipdv_enable
json_get_var rate_index rate_index
json_get_var num_interval num_interval
json_get_var mode_subintervals mode_subintervals
json_get_var test_subinterval test_subinterval
json_get_var feedback_interval feedback_interval
json_get_var seq_err_thresh seq_err_thresh
json_get_var dup_ignore dup_ignore
json_get_var lower_thresh lower_thresh
json_get_var upper_thresh upper_thresh
json_get_var high_speed_delta high_speed_delta
json_get_var algorithm algorithm
json_get_var slow_adj_thresh slow_adj_thresh
json_get_var proto proto
[ "${proto}" = "both_proto" ] && {
old_pid=$(cat /tmp/iplayercap_pid)
[ -n "${old_pid}" ] && {
cmd=$(cat /proc/$old_pid/cmdline)
}
if [[ "${cmd}" = *iplayercap* ]]; then
kill -9 $old_pid
fi
# Clear all incremental & modal result instances
res=$($UCI_SHOW_BBF_DMMAP dmmap_diagnostics | grep -E "=modalresult$" | cut -d= -f 1)
for i in $res; do
$UCI_DELETE_BBF_DMMAP "${i}"
done
res=$($UCI_SHOW_BBF_DMMAP dmmap_diagnostics | grep -E "=incrementalresult$" | cut -d= -f 1)
for i in $res; do
$UCI_DELETE_BBF_DMMAP "${i}"
done
if [ "${cancel}" -eq "1" ]; then
clear_iplayercapacity_output "None"
$UCI_COMMIT_BBF_DMMAP
return
else
echo $$ > /tmp/iplayercap_pid
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.DiagnosticState="Requested_running"
$UCI_COMMIT_BBF_DMMAP
fi
}
# Fail if host is empty
[ -z "${host}" ] && {
iplayercap_error "Error_Internal" "${proto}"
return
}
# Assign default value
[ -z "${test_type}" ] && test_type="Search"
[ -z "${test_subinterval}" ] && test_subinterval=1000
[ -z "${feedback_interval}" ] && feedback_interval=50
[ -z "${seq_err_thresh}" ] && seq_err_thresh=10
[ -z "${dup_ignore}" ] && dup_ignore=1
[ -z "${lower_thresh}" ] && lower_thresh=30
[ -z "${upper_thresh}" ] && upper_thresh=90
[ -z "${high_speed_delta}" ] && high_speed_delta=10
[ -z "${slow_adj_thresh}" ] && slow_adj_thresh=3
[ -z "${num_interval}" ] && num_interval=10
if [ -z "${role}" ] || [ "${role}" = "Sender" ]; then
options="$options -u"
else
options="$options -d"
fi
if [ -n "${jumbo_frames}" ] && [ "${jumbo_frames}" -eq 0 ]; then
options="$options -j"
fi
if [ -n "${DSCP}" ] && [ "${DSCP}" -gt 0 ]; then
options="$options -m $DSCP"
fi
if [ "${proto_ver}" = "IPv4" ]; then
options="$options -4"
elif [ "${proto_ver}" = "IPv6" ]; then
options="$options -6"
fi
if [ "${udp_content}" = "random" ]; then
options="$options -X"
fi
if [ -n "${ipdv_enable}" ] && [ "${ipdv_enable}" -eq 1 ]; then
options="$options -o"
fi
if [ -n "${rate_index}" ]; then
options="$options -I @${rate_index}"
fi
if [ -n "${algorithm}" ]; then
options="$options -A ${algorithm}"
fi
if [ -n "${interface}" ]; then
options="$options -E ${interface}"
fi
if [ -n "${port}" ]; then
options="$options -p ${port}"
fi
test_subinterval=$(( test_subinterval/1000 ))
t_val=$(( test_subinterval*num_interval ))
if [ "${t_val}" -lt 5 ] || [ "${t_val}" -gt 60 ]; then
iplayercap_error "Error_Internal" "${proto}"
return
fi
if [ -n "${mode_subintervals}" ] && [ "${mode_subintervals}" -gt 0 ]; then
if [ "${mode_subintervals}" -lt ${num_interval} ]; then
options="$options -i ${mode_subintervals}"
else
iplayercap_error "Error_Internal" "${proto}"
return
fi
fi
options="$options -P ${test_subinterval} -t ${t_val} -F ${feedback_interval}"
if [ "${test_type}" = "Search" ]; then
options="$options -q ${seq_err_thresh} -L ${lower_thresh} -U ${upper_thresh} -h ${high_speed_delta} -c ${slow_adj_thresh}"
if [ "${dup_ignore}" -eq 0 ]; then
options="$options -R"
fi
fi
cmd="udpst ${options} -f jsonf ${host}"
output=$(${cmd} 2>&1)
if [ "$?" -eq 127 ] || [ "$?" -eq 255 ]; then
iplayercap_error "Error_Internal" "${proto}"
return
fi
json_init
json_load "$output"
[ "${proto}" = "both_proto" ] && {
json_get_var err ErrorStatus
if [ "${err}" -ne 0 ]; then
iplayercap_error "Error_Internal" "${proto}"
return
fi
json_select IPLayerCapSupported
if [ "$?" -ne 0 ]; then
iplayercap_error "Error_Internal" "${proto}"
return
fi
json_get_var version SoftwareVersion
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.SoftwareVersion="${version}"
json_select ..
json_select Output
if [ "$?" -ne 0 ]; then
iplayercap_error "Error_Internal" "${proto}"
return
fi
json_get_var Status Status
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.DiagnosticState="${Status}"
json_get_var BOMTime BOMTime
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.BOMTime="${BOMTime}"
json_get_var EOMTime EOMTime
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.EOMTime="${EOMTime}"
json_get_var TmaxUsed TmaxUsed
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.TmaxUsed="${TmaxUsed}"
json_get_var TestInterval TestInterval
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.TestInterval="${TestInterval}"
json_get_var TmaxRTTUsed TmaxRTTUsed
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.TmaxRTTUsed="${TmaxRTTUsed}"
json_get_var TimestampResolutionUsed TimestampResolutionUsed
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.TimestampResolutionUsed="${TimestampResolutionUsed}"
json_select AtMax
if [ "$?" -ne 0 ]; then
iplayercap_error "Error_Internal" "${proto}"
return
fi
json_get_var MaxIPLayerCapacity MaxIPLayerCapacity
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MaxIPLayerCapacity="${MaxIPLayerCapacity}"
json_get_var TimeOfMax TimeOfMax
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.TimeOfMax="${TimeOfMax}"
json_get_var MaxETHCapacityNoFCS MaxETHCapacityNoFCS
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MaxETHCapacityNoFCS="${MaxETHCapacityNoFCS}"
json_get_var MaxETHCapacityWithFCS MaxETHCapacityWithFCS
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MaxETHCapacityWithFCS="${MaxETHCapacityWithFCS}"
json_get_var MaxETHCapacityWithFCSVLAN MaxETHCapacityWithFCSVLAN
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MaxETHCapacityWithFCSVLAN="${MaxETHCapacityWithFCSVLAN}"
json_get_var LossRatioAtMax LossRatioAtMax
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.LossRatioAtMax="${LossRatioAtMax}"
json_get_var RTTRangeAtMax RTTRangeAtMax
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.RTTRangeAtMax="${RTTRangeAtMax}"
json_get_var PDVRangeAtMax PDVRangeAtMax
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.PDVRangeAtMax="${PDVRangeAtMax}"
json_get_var MinOnewayDelayAtMax MinOnewayDelayAtMax
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MinOnewayDelayAtMax="${MinOnewayDelayAtMax}"
json_get_var ReorderedRatioAtMax ReorderedRatioAtMax
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.ReorderedRatioAtMax="${ReorderedRatioAtMax}"
json_get_var ReplicatedRatioAtMax ReplicatedRatioAtMax
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.ReplicatedRatioAtMax="${ReplicatedRatioAtMax}"
json_get_var InterfaceEthMbps InterfaceEthMbps
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.InterfaceEthMbpsAtMax="${InterfaceEthMbps}"
json_select ..
json_select Summary
if [ "$?" -ne 0 ]; then
iplayercap_error "Error_Internal" "${proto}"
return
fi
json_get_var IPLayerCapacitySummary IPLayerCapacitySummary
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.IPLayerCapacitySummary="${IPLayerCapacitySummary}"
json_get_var LossRatioSummary LossRatioSummary
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.LossRatioSummary="${LossRatioSummary}"
json_get_var RTTRangeSummary RTTRangeSummary
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.RTTRangeSummary="${RTTRangeSummary}"
json_get_var PDVRangeSummary PDVRangeSummary
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.PDVRangeSummary="${PDVRangeSummary}"
json_get_var MinOnewayDelaySummary MinOnewayDelaySummary
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MinOnewayDelaySummary="${MinOnewayDelaySummary}"
json_get_var MinRTTSummary MinRTTSummary
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.MinRTTSummary="${MinRTTSummary}"
json_get_var ReorderedRatioSummary ReorderedRatioSummary
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.ReorderedRatioSummary="${ReorderedRatioSummary}"
json_get_var ReplicatedRatioSummary ReplicatedRatioSummary
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.ReplicatedRatioSummary="${ReplicatedRatioSummary}"
json_get_var InterfaceEthMbps InterfaceEthMbps
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.InterfaceEthMbpsSummary="${InterfaceEthMbps}"
json_select ..
failed=0
if json_is_a ModalResult array; then
json_select ModalResult
if [ "$?" -eq 0 ]; then
idx=1
inst=0
while json_is_a ${idx} object
do
json_select ${idx}
if [ "$?" -ne 0 ]; then
iplayercap_error "Error_Internal" "${proto}"
failed=1
break
fi
json_get_var TimeOfMax TimeOfMax
json_get_var MaxIPLayerCapacity MaxIPLayerCapacity
json_get_var MaxETHCapacityNoFCS MaxETHCapacityNoFCS
json_get_var MaxETHCapacityWithFCS MaxETHCapacityWithFCS
json_get_var MaxETHCapacityWithFCSVLAN MaxETHCapacityWithFCSVLAN
json_get_var LossRatioAtMax LossRatioAtMax
json_get_var RTTRangeAtMax RTTRangeAtMax
json_get_var PDVRangeAtMax PDVRangeAtMax
json_get_var MinOnewayDelayAtMax MinOnewayDelayAtMax
json_get_var ReorderedRatioAtMax ReorderedRatioAtMax
json_get_var ReplicatedRatioAtMax ReplicatedRatioAtMax
json_get_var InterfaceEthMbps InterfaceEthMbps
sec=$($UCI_ADD_BBF_DMMAP dmmap_diagnostics modalresult)
$UCI_RENAME_BBF_DMMAP dmmap_diagnostics.@modalresult[${inst}]="modalresult_${inst}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.MaxIPLayerCapacity="${MaxIPLayerCapacity}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.TimeOfMax="${TimeOfMax}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.MaxETHCapacityNoFCS="${MaxETHCapacityNoFCS}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.MaxETHCapacityWithFCS="${MaxETHCapacityWithFCS}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.MaxETHCapacityWithFCSVLAN="${MaxETHCapacityWithFCSVLAN}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.LossRatioAtMax="${LossRatioAtMax}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.RTTRangeAtMax="${RTTRangeAtMax}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.PDVRangeAtMax="${PDVRangeAtMax}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.MinOnewayDelayAtMax="${MinOnewayDelayAtMax}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.ReorderedRatioAtMax="${ReorderedRatioAtMax}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.ReplicatedRatioAtMax="${ReplicatedRatioAtMax}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.modalresult_${inst}.InterfaceEthMbpsAtMax="${InterfaceEthMbps}"
idx=$(( idx + 1 ))
inst=$(( inst + 1))
json_select ..
done
json_select ..
fi
fi
if [ "${failed}" -eq 1 ]; then
return
fi
if json_is_a IncrementalResult array; then
json_select IncrementalResult
if [ "$?" -eq 0 ]; then
idx=1
inst=0
while json_is_a ${idx} object
do
json_select ${idx}
if [ "$?" -ne 0 ]; then
iplayercap_error "Error_Internal" "${proto}"
failed=1
break
fi
json_get_var TimeOfSubInterval TimeOfSubInterval
json_get_var IPLayerCapacity IPLayerCapacity
json_get_var LossRatio LossRatio
json_get_var RTTRange RTTRange
json_get_var PDVRange PDVRange
json_get_var MinOnewayDelay MinOnewayDelay
json_get_var ReorderedRatio ReorderedRatio
json_get_var ReplicatedRatio ReplicatedRatio
json_get_var InterfaceEthMbps InterfaceEthMbps
sec=$($UCI_ADD_BBF_DMMAP dmmap_diagnostics incrementalresult)
$UCI_RENAME_BBF_DMMAP dmmap_diagnostics.@incrementalresult[${inst}]="incrementalresult_${inst}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.incrementalresult_${inst}.IPLayerCapacity="${IPLayerCapacity}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.incrementalresult_${inst}.TimeOfSubInterval="${TimeOfSubInterval}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.incrementalresult_${inst}.LossRatio="${LossRatio}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.incrementalresult_${inst}.RTTRange="${RTTRange}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.incrementalresult_${inst}.PDVRange="${PDVRange}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.incrementalresult_${inst}.MinOnewayDelay="${MinOnewayDelay}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.incrementalresult_${inst}.ReorderedRatio="${ReorderedRatio}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.incrementalresult_${inst}.ReplicatedRatio="${ReplicatedRatio}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.incrementalresult_${inst}.InterfaceEthMbps="${InterfaceEthMbps}"
idx=$(( idx + 1 ))
inst=$(( inst + 1))
json_select ..
done
json_select ..
fi
fi
if [ "${failed}" -eq 1 ]; then
return
fi
$UCI_COMMIT_BBF_DMMAP
}
json_dump
}
[ ! -f /etc/bbfdm/dmmap/dmmap_diagnostics ] && touch /etc/bbfdm/dmmap/dmmap_diagnostics
if [ -n "$1" ]; then
iplayercap_launch "$1"
else
iplayercap_error "Error_Internal" "${proto}"
fi

View file

@ -1291,6 +1291,8 @@ static void test_api_bbfdm_add_del_library_object(void **state)
static void test_api_bbfdm_valid_standard_operate(void **state)
{
// TODO: To be used later with micro-service
#if 0
struct dmctx *ctx = (struct dmctx *) *state;
struct dm_parameter *n;
int fault = 0;
@ -1319,6 +1321,7 @@ static void test_api_bbfdm_valid_standard_operate(void **state)
assert_string_equal(n->type, "xsd:unsignedInt");
}
}
#endif
}
static void test_api_bbfdm_valid_standard_list_operate(void **state)

View file

@ -229,6 +229,14 @@
"dm_files": [
"src/*.c"
]
},
{
"repo": "https://dev.iopsys.eu/bbf/tr471d.git",
"proto": "git",
"version": "devel",
"dm_files": [
"src/iplayercap.c"
]
}
],
"output": {
@ -243,4 +251,4 @@
"output_dir": "./out",
"output_file_prefix": "datamodel"
}
}
}