mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Feature #13372: move diagnostics api part to libbbfdm-api
This commit is contained in:
parent
147168fcd5
commit
8f0e8f3d24
30 changed files with 1051 additions and 1055 deletions
|
|
@ -19,7 +19,7 @@ FILE(GLOB BBF_API_SOURCES *.c plugin/*.c)
|
|||
|
||||
ADD_LIBRARY(bbfdm-api SHARED ${BBF_API_SOURCES})
|
||||
|
||||
TARGET_LINK_LIBRARIES(bbfdm-api uci ubus ubox json-c blobmsg_json dl)
|
||||
TARGET_LINK_LIBRARIES(bbfdm-api uci ubus ubox json-c blobmsg_json dl curl)
|
||||
|
||||
INSTALL(TARGETS bbfdm-api
|
||||
LIBRARY DESTINATION usr/lib)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "dmcommon.h"
|
||||
|
||||
char *Encapsulation[] = {"LLC", "VCMUX", NULL};
|
||||
|
|
@ -2391,6 +2393,146 @@ bool validate_blob_message(struct blob_attr *src, struct blob_attr *dst)
|
|||
return res;
|
||||
}
|
||||
|
||||
char *diagnostics_get_option(char *sec_name, char *option)
|
||||
{
|
||||
char *value = NULL;
|
||||
dmuci_get_option_value_string_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, option, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
char *diagnostics_get_option_fallback_def(char *sec_name, char *option, char *default_value)
|
||||
{
|
||||
char *value = diagnostics_get_option(sec_name, option);
|
||||
return (*value != '\0') ? value : default_value;
|
||||
}
|
||||
|
||||
void diagnostics_set_option(char *sec_name, char *option, char *value)
|
||||
{
|
||||
check_create_dmmap_package(DMMAP_DIAGNOSTIGS);
|
||||
struct uci_section *section = dmuci_walk_section_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
|
||||
if (!section)
|
||||
dmuci_set_value_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, "", sec_name);
|
||||
|
||||
dmuci_set_value_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, option, value);
|
||||
}
|
||||
|
||||
void diagnostics_reset_state(char *sec_name)
|
||||
{
|
||||
char *diag_state = diagnostics_get_option(sec_name, "DiagnosticState");
|
||||
if (strcmp(diag_state, "Requested") != 0) {
|
||||
diagnostics_set_option(sec_name, "DiagnosticState", "None");
|
||||
}
|
||||
}
|
||||
|
||||
char *diagnostics_get_interface_name(struct dmctx *ctx, char *value)
|
||||
{
|
||||
char *linker = NULL;
|
||||
|
||||
if (!value || *value == 0)
|
||||
return "";
|
||||
|
||||
if (strncmp(value, "Device.IP.Interface.", 20) != 0)
|
||||
return "";
|
||||
|
||||
adm_entry_get_reference_value(ctx, value, &linker);
|
||||
return linker ? linker : "";
|
||||
}
|
||||
|
||||
long download_file(char *file_path, const char *url, const char *username, const char *password)
|
||||
{
|
||||
long res_code = 0;
|
||||
|
||||
if (!file_path || !url)
|
||||
return -1;
|
||||
|
||||
if (strncmp(url, FILE_URI, strlen(FILE_URI)) == 0) {
|
||||
|
||||
const char *curr_path = (!strncmp(url, FILE_LOCALHOST_URI, strlen(FILE_LOCALHOST_URI))) ? url + strlen(FILE_LOCALHOST_URI) : url + strlen(FILE_URI);
|
||||
|
||||
if (!file_exists(curr_path))
|
||||
return -1;
|
||||
|
||||
DM_STRNCPY(file_path, curr_path, 256);
|
||||
} else {
|
||||
|
||||
CURL *curl = curl_easy_init();
|
||||
if (curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
if (username) curl_easy_setopt(curl, CURLOPT_USERNAME, username);
|
||||
if (password) curl_easy_setopt(curl, CURLOPT_PASSWORD, password);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 600);
|
||||
|
||||
FILE *fp = fopen(file_path, "wb");
|
||||
if (fp) {
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
|
||||
curl_easy_perform(curl);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &res_code);
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
}
|
||||
|
||||
return res_code;
|
||||
}
|
||||
|
||||
long upload_file(const char *file_path, const char *url, const char *username, const char *password)
|
||||
{
|
||||
long res_code = 0;
|
||||
|
||||
if (!file_path || !url)
|
||||
return -1;
|
||||
|
||||
if (strncmp(url, FILE_URI, strlen(FILE_URI)) == 0) {
|
||||
char dst_path[2046] = {0};
|
||||
char buff[BUFSIZ] = {0};
|
||||
FILE *sfp, *dfp;
|
||||
int n, count=0;
|
||||
|
||||
sfp = fopen(file_path, "rb");
|
||||
if (sfp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(dst_path, sizeof(dst_path), "%s", url + strlen(FILE_URI));
|
||||
dfp = fopen(dst_path, "wb");
|
||||
if (dfp == NULL) {
|
||||
fclose(sfp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ((n = fread(buff, 1, BUFSIZ, sfp)) != 0) {
|
||||
fwrite(buff, 1, n, dfp);
|
||||
count+=n;
|
||||
}
|
||||
|
||||
fclose(sfp);
|
||||
fclose(dfp);
|
||||
} else {
|
||||
CURL *curl = curl_easy_init();
|
||||
if (curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
if (username) curl_easy_setopt(curl, CURLOPT_USERNAME, username);
|
||||
if (password) curl_easy_setopt(curl, CURLOPT_PASSWORD, password);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 600);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
FILE *fp = fopen(file_path, "rb");
|
||||
if (fp) {
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, fp);
|
||||
curl_easy_perform(curl);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &res_code);
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
}
|
||||
|
||||
return res_code;
|
||||
}
|
||||
|
||||
/**********************
|
||||
*
|
||||
* Deprecated functions
|
||||
|
|
|
|||
|
|
@ -67,41 +67,41 @@
|
|||
#include "dmjson.h"
|
||||
#include "dmentry.h"
|
||||
|
||||
extern char *Encapsulation[];
|
||||
extern char *LinkType[];
|
||||
extern char *BridgeStandard[];
|
||||
extern char *BridgeType[];
|
||||
extern char *VendorClassIDMode[];
|
||||
extern char *Encapsulation[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *LinkType[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *BridgeStandard[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *BridgeType[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *VendorClassIDMode[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *DiagnosticsState[];
|
||||
extern char *SupportedProtocols[];
|
||||
extern char *InstanceMode[];
|
||||
extern char *NATProtocol[];
|
||||
extern char *Config[];
|
||||
extern char *Target[];
|
||||
extern char *ServerConnectAlgorithm[];
|
||||
extern char *KeepAlivePolicy[];
|
||||
extern char *DeliveryHeaderProtocol[];
|
||||
extern char *KeyIdentifierGenerationPolicy[];
|
||||
extern char *PreambleType[];
|
||||
extern char *MFPConfig[];
|
||||
extern char *DuplexMode[];
|
||||
extern char *RequestedState[];
|
||||
extern char *BulkDataProtocols[];
|
||||
extern char *EncodingTypes[];
|
||||
extern char *CSVReportFormat[];
|
||||
extern char *RowTimestamp[];
|
||||
extern char *JSONReportFormat[];
|
||||
extern char *StaticType[];
|
||||
extern char *ProtocolVersion[];
|
||||
extern char *ServerSelectionProtocol[];
|
||||
extern char *DHCPType[];
|
||||
extern char *DropAlgorithm[];
|
||||
extern char *SchedulerAlgorithm[];
|
||||
extern char *ProfileEnable[];
|
||||
extern char *PIN[];
|
||||
extern char *DestinationAddress[];
|
||||
extern char *RegulatoryDomain[];
|
||||
extern char *ConformingAction[];
|
||||
extern char *SupportedProtocols[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *InstanceMode[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *NATProtocol[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *Config[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *Target[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *ServerConnectAlgorithm[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *KeepAlivePolicy[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *DeliveryHeaderProtocol[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *KeyIdentifierGenerationPolicy[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *PreambleType[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *MFPConfig[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *DuplexMode[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *RequestedState[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *BulkDataProtocols[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *EncodingTypes[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *CSVReportFormat[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *RowTimestamp[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *JSONReportFormat[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *StaticType[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *ProtocolVersion[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *ServerSelectionProtocol[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *DHCPType[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *DropAlgorithm[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *SchedulerAlgorithm[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *ProfileEnable[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *PIN[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *DestinationAddress[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *RegulatoryDomain[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *ConformingAction[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *IPv4Address[];
|
||||
extern char *IPv6Address[];
|
||||
extern char *IPAddress[];
|
||||
|
|
@ -109,19 +109,19 @@ extern char *MACAddress[];
|
|||
extern char *IPPrefix[];
|
||||
extern char *IPv4Prefix[];
|
||||
extern char *IPv6Prefix[];
|
||||
extern char *SupportedOperatingChannelBandwidth[];
|
||||
extern char *SupportedStandards[];
|
||||
extern char *SupportedFrequencyBands[];
|
||||
extern char *Provider_Bridge_Type[];
|
||||
extern char *AdvPreferredRouterFlag[];
|
||||
extern char *PowerState[];
|
||||
extern char *FW_Mode[];
|
||||
extern char *AKMsAllowed[];
|
||||
extern char *CellularDataPreference[];
|
||||
extern char *IPLayerCapacityRole[];
|
||||
extern char *UDPPayloadContent[];
|
||||
extern char *IPLayerCapacityTestType[];
|
||||
extern char *RateAdjAlgorithm[];
|
||||
extern char *SupportedOperatingChannelBandwidth[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *SupportedStandards[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *SupportedFrequencyBands[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *Provider_Bridge_Type[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *AdvPreferredRouterFlag[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *PowerState[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *FW_Mode[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *AKMsAllowed[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *CellularDataPreference[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *IPLayerCapacityRole[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *UDPPayloadContent[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *IPLayerCapacityTestType[]; // To be removed later!!!!!!!!!!!!
|
||||
extern char *RateAdjAlgorithm[]; // To be removed later!!!!!!!!!!!!
|
||||
|
||||
#define CRONTABS_ROOT "/etc/crontabs/root"
|
||||
#define ACTIVATE_HANDLER_FILE "/usr/share/bbfdm/bbf_activate_handler.sh"
|
||||
|
|
@ -136,6 +136,11 @@ extern char *RateAdjAlgorithm[];
|
|||
#define SYSTEM_CERT_PATH "/etc/ssl/certs"
|
||||
#define BOARD_JSON_FILE "/etc/board.json"
|
||||
#define DMMAP "dmmap"
|
||||
#define DMMAP_DIAGNOSTIGS "dmmap_diagnostics"
|
||||
#define HTTP_URI "http"
|
||||
#define FTP_URI "ftp"
|
||||
#define FILE_URI "file://"
|
||||
#define FILE_LOCALHOST_URI "file://localhost"
|
||||
#define IS_BIG_ENDIAN (*(uint16_t *)"\0\xff" < 0x100)
|
||||
|
||||
#define DM_ASSERT(X, Y) \
|
||||
|
|
@ -328,6 +333,15 @@ bool validate_blob_message(struct blob_attr *src, struct blob_attr *dst);
|
|||
void strip_lead_trail_whitespace(char *str);
|
||||
int dm_buf_to_file(char *buf, const char *filename);
|
||||
|
||||
char *diagnostics_get_option(char *sec_name, char *option);
|
||||
char *diagnostics_get_option_fallback_def(char *sec_name, char *option, char *default_value);
|
||||
void diagnostics_set_option(char *sec_name, char *option, char *value);
|
||||
void diagnostics_reset_state(char *sec_name);
|
||||
char *diagnostics_get_interface_name(struct dmctx *ctx, char *value);
|
||||
|
||||
long download_file(char *file_path, const char *url, const char *username, const char *password);
|
||||
long upload_file(const char *file_path, const char *url, const char *username, const char *password);
|
||||
|
||||
/* Deprecated functions */
|
||||
__attribute__ ((deprecated("Use bbfdm_validate_string"))) int dm_validate_string(char *value, int min_length, int max_length, char *enumeration[], char *pattern[]);
|
||||
__attribute__ ((deprecated("Use bbfdm_validate_boolean"))) int dm_validate_boolean(char *value);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ 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 dmcommon.c dmlayer.c)
|
||||
SET(BBF_DM_SOURCES dmlayer.c)
|
||||
|
||||
IF(BBF_TR181)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr181")
|
||||
|
|
@ -41,7 +41,7 @@ ENDIF(BBF_TR471)
|
|||
|
||||
ADD_LIBRARY(bbfdm SHARED ${BBF_DM_SOURCES} ${BBF_TR181_SOURCES} ${BBF_TR143_SOURCES} ${BBF_TR471_SOURCES})
|
||||
|
||||
TARGET_LINK_LIBRARIES(bbfdm uci ubus ubox json-c blobmsg_json curl m bbfdm-api ssl crypto)
|
||||
TARGET_LINK_LIBRARIES(bbfdm uci ubus ubox json-c blobmsg_json bbfdm-api ssl crypto)
|
||||
|
||||
INSTALL(TARGETS bbfdm
|
||||
LIBRARY DESTINATION usr/lib)
|
||||
|
|
|
|||
|
|
@ -1,548 +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: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
#include "dmcommon.h"
|
||||
|
||||
#define READ_BUF_SIZE (1024 * 16)
|
||||
|
||||
char *get_diagnostics_option(char *sec_name, char *option)
|
||||
{
|
||||
char *value;
|
||||
dmuci_get_option_value_string_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, option, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
char *get_diagnostics_option_fallback_def(char *sec_name, char *option, char *default_value)
|
||||
{
|
||||
char *value = get_diagnostics_option(sec_name, option);
|
||||
return (*value != '\0') ? value : default_value;
|
||||
}
|
||||
|
||||
void set_diagnostics_option(char *sec_name, char *option, char *value)
|
||||
{
|
||||
check_create_dmmap_package(DMMAP_DIAGNOSTIGS);
|
||||
struct uci_section *section = dmuci_walk_section_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
|
||||
if (!section)
|
||||
dmuci_set_value_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, "", sec_name);
|
||||
|
||||
dmuci_set_value_bbfdm(DMMAP_DIAGNOSTIGS, sec_name, option, value);
|
||||
}
|
||||
|
||||
void reset_diagnostic_state(char *sec_name)
|
||||
{
|
||||
char *diag_state = get_diagnostics_option(sec_name, "DiagnosticState");
|
||||
if (strcmp(diag_state, "Requested") != 0) {
|
||||
set_diagnostics_option(sec_name, "DiagnosticState", "None");
|
||||
}
|
||||
}
|
||||
|
||||
char *get_diagnostics_interface_option(struct dmctx *ctx, char *value)
|
||||
{
|
||||
char *linker = NULL;
|
||||
|
||||
if (!value || *value == 0)
|
||||
return "";
|
||||
|
||||
if (strncmp(value, "Device.IP.Interface.", 20) != 0)
|
||||
return "";
|
||||
|
||||
adm_entry_get_reference_value(ctx, value, &linker);
|
||||
return linker ? linker : "";
|
||||
}
|
||||
|
||||
static bool get_response_code_status(const char *url, int response_code)
|
||||
{
|
||||
if ((strncmp(url, HTTP_URI, strlen(HTTP_URI)) == 0 && response_code != 200) ||
|
||||
(strncmp(url, FTP_URI, strlen(FTP_URI)) == 0 && response_code != 226) ||
|
||||
(strncmp(url, FILE_URI, strlen(FILE_URI)) == 0 && response_code != 0) ||
|
||||
(strncmp(url, HTTP_URI, strlen(HTTP_URI)) && strncmp(url, FTP_URI, strlen(FTP_URI)) && strncmp(url, FILE_URI, strlen(FILE_URI)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void send_transfer_complete_event(const char *command, const char *obj_path, const char *transfer_url,
|
||||
char *fault_string, time_t start_t, time_t complete_t,const char *commandKey, const char *transfer_type)
|
||||
{
|
||||
char start_time[32] = {0};
|
||||
char complete_time[32] = {0};
|
||||
unsigned fault_code = 0;
|
||||
|
||||
strftime(start_time, sizeof(start_time), "%Y-%m-%dT%H:%M:%SZ", gmtime(&start_t));
|
||||
strftime(complete_time, sizeof(complete_time), "%Y-%m-%dT%H:%M:%SZ", gmtime(&complete_t));
|
||||
|
||||
if (DM_STRLEN(fault_string) != 0)
|
||||
fault_code = USP_FAULT_GENERAL_FAILURE;
|
||||
|
||||
struct json_object *obj = json_object_new_object();
|
||||
|
||||
json_object_object_add(obj, "Command", json_object_new_string(command));
|
||||
if(commandKey)
|
||||
json_object_object_add(obj, "CommandKey", json_object_new_string(commandKey));
|
||||
else
|
||||
json_object_object_add(obj, "CommandKey", json_object_new_string(""));
|
||||
json_object_object_add(obj, "Requestor", json_object_new_string(""));
|
||||
json_object_object_add(obj, "TransferType", json_object_new_string(transfer_type));
|
||||
json_object_object_add(obj, "Affected", json_object_new_string(obj_path));
|
||||
json_object_object_add(obj, "TransferURL", json_object_new_string(transfer_url));
|
||||
json_object_object_add(obj, "StartTime", json_object_new_string(start_time));
|
||||
json_object_object_add(obj, "CompleteTime", json_object_new_string(complete_time));
|
||||
json_object_object_add(obj, "FaultCode", json_object_new_uint64(fault_code));
|
||||
json_object_object_add(obj, "FaultString", json_object_new_string(fault_string));
|
||||
|
||||
dmubus_call_set("bbfdm", "notify_event", UBUS_ARGS{{"name", "Device.LocalAgent.TransferComplete!", String}, {"input", json_object_to_json_string(obj), Table}}, 2);
|
||||
|
||||
json_object_put(obj);
|
||||
}
|
||||
|
||||
static long download_file(char *file_path, const char *url, const char *username, const char *password)
|
||||
{
|
||||
long res_code = 0;
|
||||
|
||||
if (strncmp(url, FILE_URI, strlen(FILE_URI)) == 0) {
|
||||
|
||||
const char *curr_path = (!strncmp(url, FILE_LOCALHOST_URI, strlen(FILE_LOCALHOST_URI))) ? url + strlen(FILE_LOCALHOST_URI) : url + strlen(FILE_URI);
|
||||
|
||||
if (!file_exists(curr_path))
|
||||
return -1;
|
||||
|
||||
DM_STRNCPY(file_path, curr_path, 256);
|
||||
} else {
|
||||
|
||||
CURL *curl = curl_easy_init();
|
||||
if (curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, username);
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, password);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, CURL_TIMEOUT);
|
||||
|
||||
FILE *fp = fopen(file_path, "wb");
|
||||
if (fp) {
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
|
||||
curl_easy_perform(curl);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &res_code);
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
}
|
||||
|
||||
return res_code;
|
||||
}
|
||||
|
||||
static long upload_file(const char *file_path, const char *url, const char *username, const char *password)
|
||||
{
|
||||
long res_code = 0;
|
||||
|
||||
if (strncmp(url, FILE_URI, strlen(FILE_URI)) == 0) {
|
||||
char dst_path[2046] = {0};
|
||||
char buff[BUFSIZ] = {0};
|
||||
FILE *sfp, *dfp;
|
||||
int n, count=0;
|
||||
|
||||
sfp = fopen(file_path, "rb");
|
||||
if (sfp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(dst_path, sizeof(dst_path), "%s", url+strlen(FILE_URI));
|
||||
dfp = fopen(dst_path, "wb");
|
||||
if (dfp == NULL) {
|
||||
fclose(sfp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ((n = fread(buff, 1, BUFSIZ, sfp)) != 0) {
|
||||
fwrite(buff, 1, n, dfp);
|
||||
count+=n;
|
||||
}
|
||||
|
||||
fclose(sfp);
|
||||
fclose(dfp);
|
||||
} else {
|
||||
CURL *curl = curl_easy_init();
|
||||
if (curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, username);
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, password);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, CURL_TIMEOUT);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
||||
FILE *fp = fopen(file_path, "rb");
|
||||
if (fp) {
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, fp);
|
||||
curl_easy_perform(curl);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &res_code);
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
}
|
||||
|
||||
return res_code;
|
||||
}
|
||||
|
||||
const bool validate_file_system_size(const char *file_size)
|
||||
{
|
||||
if (file_size && *file_size) {
|
||||
unsigned long f_size = strtoul(file_size, NULL, 10);
|
||||
unsigned long fs_available_size = file_system_size("/tmp", FS_SIZE_AVAILABLE);
|
||||
|
||||
if (fs_available_size < f_size)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const bool validate_hash_value(const char *algo, const char *file_path, const char *checksum)
|
||||
{
|
||||
unsigned char buffer[READ_BUF_SIZE] = {0};
|
||||
char hash[BUFSIZ] = {0};
|
||||
bool res = false;
|
||||
unsigned int bytes = 0;
|
||||
FILE *file;
|
||||
|
||||
EVP_MD_CTX *mdctx;
|
||||
const EVP_MD *md;
|
||||
unsigned char md_value[EVP_MAX_MD_SIZE];
|
||||
|
||||
file = fopen(file_path, "rb");
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
md = EVP_get_digestbyname(algo);
|
||||
mdctx = EVP_MD_CTX_create();
|
||||
EVP_DigestInit_ex(mdctx, md, NULL);
|
||||
|
||||
if (md == NULL)
|
||||
goto end;
|
||||
|
||||
while ((bytes = fread (buffer, 1, sizeof(buffer), file))) {
|
||||
EVP_DigestUpdate(mdctx, buffer, bytes);
|
||||
}
|
||||
|
||||
bytes = 0;
|
||||
EVP_DigestFinal_ex(mdctx, md_value, &bytes);
|
||||
|
||||
for (int i = 0; i < bytes; i++)
|
||||
snprintf(&hash[i * 2], sizeof(hash) - (i * 2), "%02x", md_value[i]);
|
||||
|
||||
if (DM_STRCMP(hash, checksum) == 0)
|
||||
res = true;
|
||||
|
||||
end:
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
EVP_cleanup();
|
||||
|
||||
fclose(file);
|
||||
return res;
|
||||
}
|
||||
|
||||
const bool validate_checksum_value(const char *file_path, const char *checksum_algorithm, const char *checksum)
|
||||
{
|
||||
if (checksum && *checksum) {
|
||||
|
||||
if (strcmp(checksum_algorithm, "SHA-1") == 0)
|
||||
return validate_hash_value("SHA1", file_path, checksum);
|
||||
else if (strcmp(checksum_algorithm, "SHA-224") == 0)
|
||||
return validate_hash_value("SHA224", file_path, checksum);
|
||||
else if (strcmp(checksum_algorithm, "SHA-256") == 0)
|
||||
return validate_hash_value("SHA256", file_path, checksum);
|
||||
else if (strcmp(checksum_algorithm, "SHA-384") == 0)
|
||||
return validate_hash_value("SHA384", file_path, checksum);
|
||||
else if (strcmp(checksum_algorithm, "SHA-512") == 0)
|
||||
return validate_hash_value("SHA512", file_path, checksum);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int bbf_config_backup(const char *url, const char *username, const char *password,
|
||||
char *config_name, const char *command, const char *obj_path)
|
||||
{
|
||||
int res = 0;
|
||||
char fault_msg[128] = {0};
|
||||
time_t complete_time = 0;
|
||||
time_t start_time = time(NULL);
|
||||
|
||||
// Export config file to backup file
|
||||
if (dmuci_export_package(config_name, CONFIG_BACKUP)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Failed to export the configurations");
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Upload the config file
|
||||
long res_code = upload_file(CONFIG_BACKUP, url, username, password);
|
||||
complete_time = time(NULL);
|
||||
|
||||
// Check if the upload operation was successful
|
||||
if (!get_response_code_status(url, res_code)) {
|
||||
res = -1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Upload operation is failed, fault code (%ld)", res_code);
|
||||
}
|
||||
|
||||
end:
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Upload");
|
||||
|
||||
// Remove temporary file
|
||||
if (file_exists(CONFIG_BACKUP) && remove(CONFIG_BACKUP))
|
||||
res = -1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int bbf_upload_log(const char *url, const char *username, const char *password,
|
||||
char *config_name, const char *command, const char *obj_path)
|
||||
{
|
||||
int res = 0;
|
||||
char fault_msg[128] = {0};
|
||||
|
||||
// Upload the config file
|
||||
time_t start_time = time(NULL);
|
||||
long res_code = upload_file(config_name, url, username, password);
|
||||
time_t complete_time = time(NULL);
|
||||
|
||||
// Check if the upload operation was successful
|
||||
if (!get_response_code_status(url, res_code)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Upload operation is failed, fault code (%ld)", res_code);
|
||||
res = -1;
|
||||
}
|
||||
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Upload");
|
||||
return res;
|
||||
}
|
||||
int bbf_config_restore(const char *url, const char *username, const char *password,
|
||||
const char *file_size, const char *checksum_algorithm, const char *checksum,
|
||||
const char *command, const char *obj_path)
|
||||
{
|
||||
char config_restore[256] = "/tmp/bbf_config_restore";
|
||||
int res = 0;
|
||||
char fault_msg[128] = {0};
|
||||
time_t complete_time = 0;
|
||||
time_t start_time = time(NULL);
|
||||
|
||||
// Check the file system size if there is sufficient space for downloading the config file
|
||||
if (!validate_file_system_size(file_size)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Available memory space is less than required for the operation");
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Download the firmware image
|
||||
long res_code = download_file(config_restore, url, username, password);
|
||||
complete_time = time(NULL);
|
||||
|
||||
// Check if the download operation was successful
|
||||
if (!get_response_code_status(url, res_code)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Upload operation is failed, fault code (%ld)", res_code);
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Validate the CheckSum value according to its algorithm
|
||||
if (!validate_checksum_value(config_restore, checksum_algorithm, checksum)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Checksum of the downloaded file is mismatched");
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Apply config file
|
||||
if (dmuci_import(NULL, config_restore)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Failed to import the configurations");
|
||||
res = -1;
|
||||
}
|
||||
|
||||
end:
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Download");
|
||||
|
||||
// Remove temporary file
|
||||
if (file_exists(config_restore) && strncmp(url, FILE_URI, strlen(FILE_URI)) && remove(config_restore))
|
||||
res = -1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
struct sysupgrade_ev_data {
|
||||
const char *bank_id;
|
||||
bool status;
|
||||
};
|
||||
|
||||
static void dmubus_receive_sysupgrade(struct ubus_context *ctx, struct ubus_event_handler *ev,
|
||||
const char *type, struct blob_attr *msg)
|
||||
{
|
||||
struct dmubus_event_data *data;
|
||||
struct blob_attr *msg_attr;
|
||||
|
||||
if (!msg || !ev)
|
||||
return;
|
||||
|
||||
data = container_of(ev, struct dmubus_event_data, ev);
|
||||
if (data == NULL)
|
||||
return;
|
||||
|
||||
struct sysupgrade_ev_data *ev_data = (struct sysupgrade_ev_data *)data->ev_data;
|
||||
if (ev_data == NULL)
|
||||
return;
|
||||
|
||||
size_t msg_len = (size_t)blobmsg_data_len(msg);
|
||||
__blob_for_each_attr(msg_attr, blobmsg_data(msg), msg_len) {
|
||||
if (DM_STRCMP("bank_id", blobmsg_name(msg_attr)) == 0) {
|
||||
char *attr_val = (char *)blobmsg_data(msg_attr);
|
||||
if (DM_STRCMP(attr_val, ev_data->bank_id) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
if (DM_STRCMP("status", blobmsg_name(msg_attr)) == 0) {
|
||||
char *attr_val = (char *)blobmsg_data(msg_attr);
|
||||
if (DM_STRCMP(attr_val, "Downloading") == 0)
|
||||
return;
|
||||
else if (DM_STRCMP(attr_val, "Available") == 0)
|
||||
ev_data->status = true;
|
||||
else
|
||||
ev_data->status = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
uloop_end();
|
||||
return;
|
||||
}
|
||||
|
||||
int bbf_fw_image_download(const char *url, const char *auto_activate, const char *username, const char *password,
|
||||
const char *file_size, const char *checksum_algorithm, const char *checksum,
|
||||
const char *bank_id, const char *command, const char *obj_path, const char *commandKey)
|
||||
{
|
||||
char fw_image_path[256] = "/tmp/firmware-XXXXXX";
|
||||
json_object *json_obj = NULL;
|
||||
bool activate = false, valid = false;
|
||||
int res = 0;
|
||||
char fault_msg[128] = {0};
|
||||
time_t complete_time = 0;
|
||||
time_t start_time = time(NULL);
|
||||
|
||||
// Check the file system size if there is sufficient space for downloading the firmware image
|
||||
if (!validate_file_system_size(file_size)) {
|
||||
res = -1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Available memory space is lower than required for downloading");
|
||||
goto end;
|
||||
}
|
||||
|
||||
res = mkstemp(fw_image_path);
|
||||
if (res == -1) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Operation failed due to some internal failure");
|
||||
goto end;
|
||||
} else {
|
||||
close(res); // close the fd, as only filename required
|
||||
res = 0;
|
||||
}
|
||||
|
||||
// Download the firmware image
|
||||
long res_code = download_file(fw_image_path, url, username, password);
|
||||
complete_time = time(NULL);
|
||||
|
||||
// Check if the download operation was successful
|
||||
if (!get_response_code_status(url, res_code)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Download operation is failed, fault code (%ld)", res_code);
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Validate the CheckSum value according to its algorithm
|
||||
if (!validate_checksum_value(fw_image_path, checksum_algorithm, checksum)) {
|
||||
res = -1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Checksum of the file is not matched with the specified value");
|
||||
goto end;
|
||||
}
|
||||
|
||||
string_to_bool((char *)auto_activate, &activate);
|
||||
char *act = (activate) ? "1" : "0";
|
||||
|
||||
dmubus_call_blocking("system", "validate_firmware_image", UBUS_ARGS{{"path", fw_image_path, String}}, 1, &json_obj);
|
||||
if (json_obj == NULL) {
|
||||
res = -1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Failed in validation of the file");
|
||||
goto end;
|
||||
}
|
||||
|
||||
char *val = dmjson_get_value(json_obj, 1, "valid");
|
||||
string_to_bool(val, &valid);
|
||||
json_object_put(json_obj);
|
||||
json_obj = NULL;
|
||||
if (valid == false) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "File is not a valid firmware image");
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Apply Firmware Image
|
||||
dmubus_call_blocking("fwbank", "upgrade", UBUS_ARGS{{"path", fw_image_path, String}, {"auto_activate", act, Boolean}, {"bank", bank_id, Integer}}, 3, &json_obj);
|
||||
if (json_obj == NULL) {
|
||||
res = 1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Internal error occurred when applying the firmware");
|
||||
goto end;
|
||||
}
|
||||
|
||||
struct sysupgrade_ev_data ev_data = {
|
||||
.bank_id = bank_id,
|
||||
.status = false,
|
||||
};
|
||||
|
||||
dmubus_wait_for_event("sysupgrade", 120, &ev_data, dmubus_receive_sysupgrade, NULL);
|
||||
|
||||
if (ev_data.status == false) {
|
||||
res = 1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Failed to apply the downloaded image file");
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Reboot the device if auto activation is true
|
||||
if (activate) {
|
||||
// Send the transfer complete after image applied
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, commandKey, "Download");
|
||||
|
||||
sleep(5); // added additional buffer for TransferComplete! event
|
||||
if (dmubus_call_set("system", "reboot", UBUS_ARGS{0}, 0) != 0)
|
||||
res = -1;
|
||||
sleep(10); // Wait for reboot to take action
|
||||
}
|
||||
|
||||
end:
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, commandKey, "Download");
|
||||
|
||||
// Remove temporary file if ubus upgrade failed and file exists
|
||||
if (!json_obj && file_exists(fw_image_path) && strncmp(url, FILE_URI, strlen(FILE_URI))) {
|
||||
remove(fw_image_path);
|
||||
res = -1;
|
||||
}
|
||||
|
||||
if (json_obj != NULL)
|
||||
json_object_put(json_obj);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -1,62 +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: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __DMCOMMON_H__
|
||||
#define __DMCOMMON_H__
|
||||
|
||||
#include "libbbfdm-api/dmcommon.h"
|
||||
#include <libubox/uloop.h>
|
||||
|
||||
#include "dmlayer.h"
|
||||
|
||||
#define HTTP_URI "http"
|
||||
#define FTP_URI "ftp"
|
||||
#define FILE_URI "file://"
|
||||
#define FILE_LOCALHOST_URI "file://localhost"
|
||||
#define default_date_format "AAAA-MM-JJTHH:MM:SS.000000Z"
|
||||
#define default_date_size sizeof(default_date_format) + 1
|
||||
#define FTP_SIZE_RESPONSE "213"
|
||||
#define FTP_PASV_RESPONSE "227 Entering Passive"
|
||||
#define FTP_TRANSFERT_COMPLETE "226 Transfer"
|
||||
#define FTP_RETR_REQUEST "RETR"
|
||||
#define FTP_STOR_REQUEST "STOR"
|
||||
#define CURL_TIMEOUT 600
|
||||
#define DMMAP_DIAGNOSTIGS "dmmap_diagnostics"
|
||||
#define CONFIG_BACKUP "/tmp/bbf_config_backup"
|
||||
#define MAX_TIME_WINDOW 5
|
||||
|
||||
enum diagnostic_protocol {
|
||||
DIAGNOSTIC_HTTP = 1,
|
||||
DIAGNOSTIC_FTP
|
||||
};
|
||||
|
||||
enum diagnostic_type {
|
||||
DOWNLOAD_DIAGNOSTIC = 1,
|
||||
UPLOAD_DIAGNOSTIC
|
||||
};
|
||||
|
||||
char *get_diagnostics_option(char *sec_name, char *option);
|
||||
char *get_diagnostics_option_fallback_def(char *sec_name, char *option, char *default_value);
|
||||
void set_diagnostics_option(char *sec_name, char *option, char *value);
|
||||
void reset_diagnostic_state(char *sec_name);
|
||||
char *get_diagnostics_interface_option(struct dmctx *ctx, char *value);
|
||||
int bbf_upload_log(const char *url, const char *username, const char *password,
|
||||
char *config_name, const char *command, const char *obj_path);
|
||||
int bbf_config_backup(const char *url, const char *username, const char *password,
|
||||
char *config_name, const char *command, const char *obj_path);
|
||||
int bbf_config_restore(const char *url, const char *username, const char *password,
|
||||
const char *file_size, const char *checksum_algorithm, const char *checksum,
|
||||
const char *command, const char *obj_path);
|
||||
int bbf_fw_image_download(const char *url, const char *auto_activate, const char *username, const char *password,
|
||||
const char *file_size, const char *checksum_algorithm, const char *checksum,
|
||||
const char *bank_id, const char *command, const char *obj_path, const char *commandKey);
|
||||
|
||||
#endif //__DMCOMMON_H__
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -161,11 +161,12 @@ static int get_atm_destination_address(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
static int set_atm_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Destination_Address[] = {"^\\d+/\\d+$", NULL};
|
||||
char *vpi = NULL, *vci = NULL, *spch;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, 256, NULL, DestinationAddress))
|
||||
if (bbfdm_validate_string(ctx, value, -1, 256, NULL, Destination_Address))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
|
|
@ -201,9 +202,11 @@ static int get_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int set_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *encapsulation[] = {"LLC", "VCMUX", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Encapsulation, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, encapsulation, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
|
|
@ -234,9 +237,11 @@ static int get_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
static int set_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Link_Type[] = {"EoA", "IPoA", "PPPoA", "CIP", "Unconfigured", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, LinkType, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Link_Type, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "dmlayer.h"
|
||||
#include "bridging.h"
|
||||
|
||||
struct bridge_args
|
||||
|
|
@ -1546,9 +1546,11 @@ static int get_BridgingBridge_Standard(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
static int set_BridgingBridge_Standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Bridge_Standard[] = {"802.1D-2004", "802.1Q-2005", "802.1Q-2011", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, BridgeStandard, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Bridge_Standard, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@
|
|||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "deviceinfo.h"
|
||||
#include "sys/statvfs.h"
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
#include "deviceinfo.h"
|
||||
|
||||
extern struct list_head global_memhead;
|
||||
|
||||
|
|
@ -20,7 +22,9 @@ LIST_HEAD(process_list);
|
|||
static int process_count = 0;
|
||||
|
||||
#define PROCPS_BUFSIZE 1024
|
||||
#define CONFIG_BACKUP "/tmp/bbf_config_backup"
|
||||
#define DEF_VENDOR_LOG_FILE "/tmp/.vend_log"
|
||||
#define MAX_TIME_WINDOW 5
|
||||
|
||||
struct process_entry {
|
||||
struct list_head list;
|
||||
|
|
@ -376,6 +380,400 @@ static int get_number_of_cpus(void)
|
|||
return max ? DM_STRTOL(max+1)+1 : 0;
|
||||
}
|
||||
|
||||
static bool get_response_code_status(const char *url, int response_code)
|
||||
{
|
||||
if ((strncmp(url, HTTP_URI, strlen(HTTP_URI)) == 0 && response_code != 200) ||
|
||||
(strncmp(url, FTP_URI, strlen(FTP_URI)) == 0 && response_code != 226) ||
|
||||
(strncmp(url, FILE_URI, strlen(FILE_URI)) == 0 && response_code != 0) ||
|
||||
(strncmp(url, HTTP_URI, strlen(HTTP_URI)) && strncmp(url, FTP_URI, strlen(FTP_URI)) && strncmp(url, FILE_URI, strlen(FILE_URI)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void send_transfer_complete_event(const char *command, const char *obj_path, const char *transfer_url,
|
||||
char *fault_string, time_t start_t, time_t complete_t,const char *commandKey, const char *transfer_type)
|
||||
{
|
||||
char start_time[32] = {0};
|
||||
char complete_time[32] = {0};
|
||||
unsigned fault_code = 0;
|
||||
|
||||
strftime(start_time, sizeof(start_time), "%Y-%m-%dT%H:%M:%SZ", gmtime(&start_t));
|
||||
strftime(complete_time, sizeof(complete_time), "%Y-%m-%dT%H:%M:%SZ", gmtime(&complete_t));
|
||||
|
||||
if (DM_STRLEN(fault_string) != 0)
|
||||
fault_code = USP_FAULT_GENERAL_FAILURE;
|
||||
|
||||
struct json_object *obj = json_object_new_object();
|
||||
|
||||
json_object_object_add(obj, "Command", json_object_new_string(command));
|
||||
if(commandKey)
|
||||
json_object_object_add(obj, "CommandKey", json_object_new_string(commandKey));
|
||||
else
|
||||
json_object_object_add(obj, "CommandKey", json_object_new_string(""));
|
||||
json_object_object_add(obj, "Requestor", json_object_new_string(""));
|
||||
json_object_object_add(obj, "TransferType", json_object_new_string(transfer_type));
|
||||
json_object_object_add(obj, "Affected", json_object_new_string(obj_path));
|
||||
json_object_object_add(obj, "TransferURL", json_object_new_string(transfer_url));
|
||||
json_object_object_add(obj, "StartTime", json_object_new_string(start_time));
|
||||
json_object_object_add(obj, "CompleteTime", json_object_new_string(complete_time));
|
||||
json_object_object_add(obj, "FaultCode", json_object_new_uint64(fault_code));
|
||||
json_object_object_add(obj, "FaultString", json_object_new_string(fault_string));
|
||||
|
||||
dmubus_call_set("bbfdm", "notify_event", UBUS_ARGS{{"name", "Device.LocalAgent.TransferComplete!", String}, {"input", json_object_to_json_string(obj), Table}}, 2);
|
||||
|
||||
json_object_put(obj);
|
||||
}
|
||||
|
||||
const bool validate_file_system_size(const char *file_size)
|
||||
{
|
||||
if (file_size && *file_size) {
|
||||
unsigned long f_size = strtoul(file_size, NULL, 10);
|
||||
unsigned long fs_available_size = file_system_size("/tmp", FS_SIZE_AVAILABLE);
|
||||
|
||||
if (fs_available_size < f_size)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const bool validate_hash_value(const char *algo, const char *file_path, const char *checksum)
|
||||
{
|
||||
unsigned char buffer[1024 * 16] = {0};
|
||||
char hash[BUFSIZ] = {0};
|
||||
bool res = false;
|
||||
unsigned int bytes = 0;
|
||||
FILE *file;
|
||||
|
||||
EVP_MD_CTX *mdctx;
|
||||
const EVP_MD *md;
|
||||
unsigned char md_value[EVP_MAX_MD_SIZE];
|
||||
|
||||
file = fopen(file_path, "rb");
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
md = EVP_get_digestbyname(algo);
|
||||
mdctx = EVP_MD_CTX_create();
|
||||
EVP_DigestInit_ex(mdctx, md, NULL);
|
||||
|
||||
if (md == NULL)
|
||||
goto end;
|
||||
|
||||
while ((bytes = fread (buffer, 1, sizeof(buffer), file))) {
|
||||
EVP_DigestUpdate(mdctx, buffer, bytes);
|
||||
}
|
||||
|
||||
bytes = 0;
|
||||
EVP_DigestFinal_ex(mdctx, md_value, &bytes);
|
||||
|
||||
for (int i = 0; i < bytes; i++)
|
||||
snprintf(&hash[i * 2], sizeof(hash) - (i * 2), "%02x", md_value[i]);
|
||||
|
||||
if (DM_STRCMP(hash, checksum) == 0)
|
||||
res = true;
|
||||
|
||||
end:
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
EVP_cleanup();
|
||||
|
||||
fclose(file);
|
||||
return res;
|
||||
}
|
||||
|
||||
const bool validate_checksum_value(const char *file_path, const char *checksum_algorithm, const char *checksum)
|
||||
{
|
||||
if (checksum && *checksum) {
|
||||
|
||||
if (strcmp(checksum_algorithm, "SHA-1") == 0)
|
||||
return validate_hash_value("SHA1", file_path, checksum);
|
||||
else if (strcmp(checksum_algorithm, "SHA-224") == 0)
|
||||
return validate_hash_value("SHA224", file_path, checksum);
|
||||
else if (strcmp(checksum_algorithm, "SHA-256") == 0)
|
||||
return validate_hash_value("SHA256", file_path, checksum);
|
||||
else if (strcmp(checksum_algorithm, "SHA-384") == 0)
|
||||
return validate_hash_value("SHA384", file_path, checksum);
|
||||
else if (strcmp(checksum_algorithm, "SHA-512") == 0)
|
||||
return validate_hash_value("SHA512", file_path, checksum);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int bbf_config_backup(const char *url, const char *username, const char *password,
|
||||
char *config_name, const char *command, const char *obj_path)
|
||||
{
|
||||
int res = 0;
|
||||
char fault_msg[128] = {0};
|
||||
time_t complete_time = 0;
|
||||
time_t start_time = time(NULL);
|
||||
|
||||
// Export config file to backup file
|
||||
if (dmuci_export_package(config_name, CONFIG_BACKUP)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Failed to export the configurations");
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Upload the config file
|
||||
long res_code = upload_file(CONFIG_BACKUP, url, username, password);
|
||||
complete_time = time(NULL);
|
||||
|
||||
// Check if the upload operation was successful
|
||||
if (!get_response_code_status(url, res_code)) {
|
||||
res = -1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Upload operation is failed, fault code (%ld)", res_code);
|
||||
}
|
||||
|
||||
end:
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Upload");
|
||||
|
||||
// Remove temporary file
|
||||
if (file_exists(CONFIG_BACKUP) && remove(CONFIG_BACKUP))
|
||||
res = -1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int bbf_upload_log(const char *url, const char *username, const char *password,
|
||||
char *config_name, const char *command, const char *obj_path)
|
||||
{
|
||||
int res = 0;
|
||||
char fault_msg[128] = {0};
|
||||
|
||||
// Upload the config file
|
||||
time_t start_time = time(NULL);
|
||||
long res_code = upload_file(config_name, url, username, password);
|
||||
time_t complete_time = time(NULL);
|
||||
|
||||
// Check if the upload operation was successful
|
||||
if (!get_response_code_status(url, res_code)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Upload operation is failed, fault code (%ld)", res_code);
|
||||
res = -1;
|
||||
}
|
||||
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Upload");
|
||||
return res;
|
||||
}
|
||||
int bbf_config_restore(const char *url, const char *username, const char *password,
|
||||
const char *file_size, const char *checksum_algorithm, const char *checksum,
|
||||
const char *command, const char *obj_path)
|
||||
{
|
||||
char config_restore[256] = "/tmp/bbf_config_restore";
|
||||
int res = 0;
|
||||
char fault_msg[128] = {0};
|
||||
time_t complete_time = 0;
|
||||
time_t start_time = time(NULL);
|
||||
|
||||
// Check the file system size if there is sufficient space for downloading the config file
|
||||
if (!validate_file_system_size(file_size)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Available memory space is less than required for the operation");
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Download the firmware image
|
||||
long res_code = download_file(config_restore, url, username, password);
|
||||
complete_time = time(NULL);
|
||||
|
||||
// Check if the download operation was successful
|
||||
if (!get_response_code_status(url, res_code)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Upload operation is failed, fault code (%ld)", res_code);
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Validate the CheckSum value according to its algorithm
|
||||
if (!validate_checksum_value(config_restore, checksum_algorithm, checksum)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Checksum of the downloaded file is mismatched");
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Apply config file
|
||||
if (dmuci_import(NULL, config_restore)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Failed to import the configurations");
|
||||
res = -1;
|
||||
}
|
||||
|
||||
end:
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Download");
|
||||
|
||||
// Remove temporary file
|
||||
if (file_exists(config_restore) && strncmp(url, FILE_URI, strlen(FILE_URI)) && remove(config_restore))
|
||||
res = -1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
struct sysupgrade_ev_data {
|
||||
const char *bank_id;
|
||||
bool status;
|
||||
};
|
||||
|
||||
static void dmubus_receive_sysupgrade(struct ubus_context *ctx, struct ubus_event_handler *ev,
|
||||
const char *type, struct blob_attr *msg)
|
||||
{
|
||||
struct dmubus_event_data *data;
|
||||
struct blob_attr *msg_attr;
|
||||
|
||||
if (!msg || !ev)
|
||||
return;
|
||||
|
||||
data = container_of(ev, struct dmubus_event_data, ev);
|
||||
if (data == NULL)
|
||||
return;
|
||||
|
||||
struct sysupgrade_ev_data *ev_data = (struct sysupgrade_ev_data *)data->ev_data;
|
||||
if (ev_data == NULL)
|
||||
return;
|
||||
|
||||
size_t msg_len = (size_t)blobmsg_data_len(msg);
|
||||
__blob_for_each_attr(msg_attr, blobmsg_data(msg), msg_len) {
|
||||
if (DM_STRCMP("bank_id", blobmsg_name(msg_attr)) == 0) {
|
||||
char *attr_val = (char *)blobmsg_data(msg_attr);
|
||||
if (DM_STRCMP(attr_val, ev_data->bank_id) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
if (DM_STRCMP("status", blobmsg_name(msg_attr)) == 0) {
|
||||
char *attr_val = (char *)blobmsg_data(msg_attr);
|
||||
if (DM_STRCMP(attr_val, "Downloading") == 0)
|
||||
return;
|
||||
else if (DM_STRCMP(attr_val, "Available") == 0)
|
||||
ev_data->status = true;
|
||||
else
|
||||
ev_data->status = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
uloop_end();
|
||||
return;
|
||||
}
|
||||
|
||||
static int bbf_fw_image_download(const char *url, const char *auto_activate, const char *username, const char *password,
|
||||
const char *file_size, const char *checksum_algorithm, const char *checksum,
|
||||
const char *bank_id, const char *command, const char *obj_path, const char *commandKey)
|
||||
{
|
||||
char fw_image_path[256] = "/tmp/firmware-XXXXXX";
|
||||
json_object *json_obj = NULL;
|
||||
bool activate = false, valid = false;
|
||||
int res = 0;
|
||||
char fault_msg[128] = {0};
|
||||
time_t complete_time = 0;
|
||||
time_t start_time = time(NULL);
|
||||
|
||||
// Check the file system size if there is sufficient space for downloading the firmware image
|
||||
if (!validate_file_system_size(file_size)) {
|
||||
res = -1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Available memory space is lower than required for downloading");
|
||||
goto end;
|
||||
}
|
||||
|
||||
res = mkstemp(fw_image_path);
|
||||
if (res == -1) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Operation failed due to some internal failure");
|
||||
goto end;
|
||||
} else {
|
||||
close(res); // close the fd, as only filename required
|
||||
res = 0;
|
||||
}
|
||||
|
||||
// Download the firmware image
|
||||
long res_code = download_file(fw_image_path, url, username, password);
|
||||
complete_time = time(NULL);
|
||||
|
||||
// Check if the download operation was successful
|
||||
if (!get_response_code_status(url, res_code)) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Download operation is failed, fault code (%ld)", res_code);
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Validate the CheckSum value according to its algorithm
|
||||
if (!validate_checksum_value(fw_image_path, checksum_algorithm, checksum)) {
|
||||
res = -1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Checksum of the file is not matched with the specified value");
|
||||
goto end;
|
||||
}
|
||||
|
||||
string_to_bool((char *)auto_activate, &activate);
|
||||
char *act = (activate) ? "1" : "0";
|
||||
|
||||
dmubus_call_blocking("system", "validate_firmware_image", UBUS_ARGS{{"path", fw_image_path, String}}, 1, &json_obj);
|
||||
if (json_obj == NULL) {
|
||||
res = -1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Failed in validation of the file");
|
||||
goto end;
|
||||
}
|
||||
|
||||
char *val = dmjson_get_value(json_obj, 1, "valid");
|
||||
string_to_bool(val, &valid);
|
||||
json_object_put(json_obj);
|
||||
json_obj = NULL;
|
||||
if (valid == false) {
|
||||
snprintf(fault_msg, sizeof(fault_msg), "File is not a valid firmware image");
|
||||
res = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Apply Firmware Image
|
||||
dmubus_call_blocking("fwbank", "upgrade", UBUS_ARGS{{"path", fw_image_path, String}, {"auto_activate", act, Boolean}, {"bank", bank_id, Integer}}, 3, &json_obj);
|
||||
if (json_obj == NULL) {
|
||||
res = 1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Internal error occurred when applying the firmware");
|
||||
goto end;
|
||||
}
|
||||
|
||||
struct sysupgrade_ev_data ev_data = {
|
||||
.bank_id = bank_id,
|
||||
.status = false,
|
||||
};
|
||||
|
||||
dmubus_wait_for_event("sysupgrade", 120, &ev_data, dmubus_receive_sysupgrade, NULL);
|
||||
|
||||
if (ev_data.status == false) {
|
||||
res = 1;
|
||||
snprintf(fault_msg, sizeof(fault_msg), "Failed to apply the downloaded image file");
|
||||
goto end;
|
||||
}
|
||||
|
||||
// Reboot the device if auto activation is true
|
||||
if (activate) {
|
||||
// Send the transfer complete after image applied
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, commandKey, "Download");
|
||||
|
||||
sleep(5); // added additional buffer for TransferComplete! event
|
||||
if (dmubus_call_set("system", "reboot", UBUS_ARGS{0}, 0) != 0)
|
||||
res = -1;
|
||||
sleep(10); // Wait for reboot to take action
|
||||
}
|
||||
|
||||
end:
|
||||
// Send the transfer complete event
|
||||
send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, commandKey, "Download");
|
||||
|
||||
// Remove temporary file if ubus upgrade failed and file exists
|
||||
if (!json_obj && file_exists(fw_image_path) && strncmp(url, FILE_URI, strlen(FILE_URI))) {
|
||||
remove(fw_image_path);
|
||||
res = -1;
|
||||
}
|
||||
|
||||
if (json_obj != NULL)
|
||||
json_object_put(json_obj);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int dmmap_synchronizeVcfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
|
||||
{
|
||||
struct uci_section *s = NULL, *stmp = NULL;
|
||||
|
|
@ -1390,6 +1788,7 @@ static int get_operate_args_DeviceInfoFirmwareImage_Activate(char *refparam, str
|
|||
|
||||
static int operate_DeviceInfoFirmwareImage_Activate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *FW_Mode[] = {"AnyTime", "Immediately", "WhenIdle", "ConfirmationNeeded", NULL};
|
||||
char *start_time[MAX_TIME_WINDOW] = {0};
|
||||
char *end_time[MAX_TIME_WINDOW] = {0};
|
||||
char *mode[MAX_TIME_WINDOW] = {0};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "dns.h"
|
||||
|
||||
/* Returns dnsmasq section name belongs to LAN network */
|
||||
|
|
@ -421,44 +420,44 @@ static int get_forwarding_dns_server(char *refparam, struct dmctx *ctx, void *da
|
|||
|
||||
static int get_nslookupdiagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("nslookup", "DiagnosticState", "None");
|
||||
*value = diagnostics_get_option_fallback_def("nslookup", "DiagnosticState", "None");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *linker = get_diagnostics_option("nslookup", "interface");
|
||||
char *linker = diagnostics_get_option("nslookup", "interface");
|
||||
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_nslookupdiagnostics_host_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("nslookup", "HostName");
|
||||
*value = diagnostics_get_option("nslookup", "HostName");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_nslookupdiagnostics_d_n_s_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("nslookup", "DNSServer");
|
||||
*value = diagnostics_get_option("nslookup", "DNSServer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_nslookupdiagnostics_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("nslookup", "Timeout", "5000");
|
||||
*value = diagnostics_get_option_fallback_def("nslookup", "Timeout", "5000");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_nslookupdiagnostics_number_of_repetitions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("nslookup", "NumberOfRepetitions", "1");
|
||||
*value = diagnostics_get_option_fallback_def("nslookup", "NumberOfRepetitions", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_nslookupdiagnostics_success_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("nslookup", "SuccessCount", "0");
|
||||
*value = diagnostics_get_option_fallback_def("nslookup", "SuccessCount", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -693,7 +692,7 @@ static int set_nslookupdiagnostics_diagnostics_state(char *refparam, struct dmct
|
|||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_LSTRCMP(value, "Requested") == 0)
|
||||
set_diagnostics_option("nslookup", "DiagnosticState", value);
|
||||
diagnostics_set_option("nslookup", "DiagnosticState", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -716,8 +715,8 @@ static int set_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx,
|
|||
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("nslookup");
|
||||
set_diagnostics_option("nslookup", "interface", reference.value);
|
||||
diagnostics_reset_state("nslookup");
|
||||
diagnostics_set_option("nslookup", "interface", reference.value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -731,8 +730,8 @@ static int set_nslookupdiagnostics_host_name(char *refparam, struct dmctx *ctx,
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("nslookup");
|
||||
set_diagnostics_option("nslookup", "HostName", value);
|
||||
diagnostics_reset_state("nslookup");
|
||||
diagnostics_set_option("nslookup", "HostName", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -746,8 +745,8 @@ static int set_nslookupdiagnostics_d_n_s_server(char *refparam, struct dmctx *ct
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("nslookup");
|
||||
set_diagnostics_option("nslookup", "DNSServer", value);
|
||||
diagnostics_reset_state("nslookup");
|
||||
diagnostics_set_option("nslookup", "DNSServer", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -761,8 +760,8 @@ static int set_nslookupdiagnostics_timeout(char *refparam, struct dmctx *ctx, vo
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("nslookup");
|
||||
set_diagnostics_option("nslookup", "Timeout", value);
|
||||
diagnostics_reset_state("nslookup");
|
||||
diagnostics_set_option("nslookup", "Timeout", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -776,8 +775,8 @@ static int set_nslookupdiagnostics_number_of_repetitions(char *refparam, struct
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("nslookup");
|
||||
set_diagnostics_option("nslookup", "NumberOfRepetitions", value);
|
||||
diagnostics_reset_state("nslookup");
|
||||
diagnostics_set_option("nslookup", "NumberOfRepetitions", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -958,9 +958,11 @@ static int get_DynamicDNSServer_Protocol(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int set_DynamicDNSServer_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Supported_Protocols[] = {"HTTP", "HTTPS", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, SupportedProtocols, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Supported_Protocols, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "dmlayer.h"
|
||||
#include "ethernet.h"
|
||||
|
||||
struct eth_port_args
|
||||
|
|
@ -610,9 +611,11 @@ static int get_EthernetInterface_DuplexMode(char *refparam, struct dmctx *ctx, v
|
|||
|
||||
static int set_EthernetInterface_DuplexMode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Duplex_Mode[] = {"Half", "Full", "Auto", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, DuplexMode, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Duplex_Mode, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#ifndef __ETHERNET_H
|
||||
#define __ETHERNET_H
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "libbbfdm-api/dmcommon.h"
|
||||
|
||||
extern DMOBJ tEthernetObj[];
|
||||
extern DMLEAF tEthernetParams[];
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
* Author: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
|
||||
*/
|
||||
|
||||
#include "dmlayer.h"
|
||||
#include "firewall.h"
|
||||
|
||||
struct rule_sec
|
||||
|
|
@ -1268,9 +1269,11 @@ static int set_firewall_enable(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
|
||||
static int set_firewall_config(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *config[] = {"High", "Low", "Off", "Advanced", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Config, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, config, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
@ -1531,6 +1534,8 @@ static int set_rule_description(char *refparam, struct dmctx *ctx, void *data, c
|
|||
|
||||
static int set_rule_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Target[] = {"Drop", "Accept", "Reject", "Return", "TargetChain", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Target, NULL))
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#ifndef _FIREWALL_H
|
||||
#define _FIREWALL_H
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "libbbfdm-api/dmcommon.h"
|
||||
|
||||
extern DMOBJ tFirewallObj[];
|
||||
extern DMLEAF tFirewallParams[];
|
||||
|
|
|
|||
|
|
@ -620,9 +620,11 @@ static int get_IEEE1905ALInterface_PowerState(char *refparam, struct dmctx *ctx,
|
|||
|
||||
static int set_IEEE1905ALInterface_PowerState(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Power_State[] = {"On", "Power_Save", "Off", "Unsupported", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, PowerState, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Power_State, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "dmlayer.h"
|
||||
#include "ip.h"
|
||||
#if defined(BBF_TR143) || defined(BBF_TR471)
|
||||
#include "diagnostics.h"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#ifndef __IP_H
|
||||
#define __IP_H
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "libbbfdm-api/dmcommon.h"
|
||||
|
||||
extern DMOBJ tIPObj[];
|
||||
extern DMLEAF tIPParams[];
|
||||
|
|
|
|||
|
|
@ -633,9 +633,11 @@ static int get_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int set_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *NAT_Protocol[] = {"TCP", "UDP", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, NATProtocol, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, NAT_Protocol, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "packetcapture.h"
|
||||
|
||||
#define PACKET_CAPTURE_DIAGNOSTIC_PATH "/usr/share/bbfdm/packetcapture"
|
||||
|
|
@ -73,7 +72,7 @@ int operate_Device_packetCapture(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
char *intf = dmjson_get_value((json_object *)value, 1, "Interface");
|
||||
if (intf[0] != '\0') {
|
||||
intf = get_diagnostics_interface_option(ctx, intf);
|
||||
intf = diagnostics_get_interface_name(ctx, intf);
|
||||
if (DM_STRLEN(intf) == 0)
|
||||
return USP_FAULT_INVALID_ARGUMENT;
|
||||
}
|
||||
|
|
@ -157,7 +156,7 @@ int operate_Device_packetCapture(char *refparam, struct dmctx *ctx, void *data,
|
|||
**************************************************************/
|
||||
static int get_PacketCapture_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("packetcapture", "DiagnosticState", "None");
|
||||
*value = diagnostics_get_option_fallback_def("packetcapture", "DiagnosticState", "None");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -170,14 +169,14 @@ static int set_PacketCapture_DiagnosticsState(char *refparam, struct dmctx *ctx,
|
|||
break;
|
||||
case VALUESET:
|
||||
if (DM_LSTRCMP(value, "Requested") == 0)
|
||||
set_diagnostics_option("packetcapture", "DiagnosticState", value);
|
||||
diagnostics_set_option("packetcapture", "DiagnosticState", value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_PacketCapture_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *linker = get_diagnostics_option("packetcapture", "Interface");
|
||||
char *linker = diagnostics_get_option("packetcapture", "Interface");
|
||||
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -199,15 +198,15 @@ static int set_PacketCapture_Interface(char *refparam, struct dmctx *ctx, void *
|
|||
|
||||
break;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("packetcapture");
|
||||
set_diagnostics_option("packetcapture", "Interface", reference.value);
|
||||
diagnostics_reset_state("packetcapture");
|
||||
diagnostics_set_option("packetcapture", "Interface", reference.value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_PacketCapture_Format(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("packetcapture", "Format");
|
||||
*value = diagnostics_get_option("packetcapture", "Format");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -222,15 +221,15 @@ static int set_PacketCapture_Format(char *refparam, struct dmctx *ctx, void *dat
|
|||
|
||||
break;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("packetcapture");
|
||||
set_diagnostics_option("packetcapture", "Format", value);
|
||||
diagnostics_reset_state("packetcapture");
|
||||
diagnostics_set_option("packetcapture", "Format", value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_PacketCapture_Duration(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("packetcapture", "Duration", "1");
|
||||
*value = diagnostics_get_option_fallback_def("packetcapture", "Duration", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -242,15 +241,15 @@ static int set_PacketCapture_Duration(char *refparam, struct dmctx *ctx, void *d
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("packetcapture");
|
||||
set_diagnostics_option("packetcapture", "Duration", value);
|
||||
diagnostics_reset_state("packetcapture");
|
||||
diagnostics_set_option("packetcapture", "Duration", value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_PacketCapture_PacketCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("packetcapture", "PacketCount", "0");
|
||||
*value = diagnostics_get_option_fallback_def("packetcapture", "PacketCount", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -262,15 +261,15 @@ static int set_PacketCapture_PacketCount(char *refparam, struct dmctx *ctx, void
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("packetcapture");
|
||||
set_diagnostics_option("packetcapture", "PacketCount", value);
|
||||
diagnostics_reset_state("packetcapture");
|
||||
diagnostics_set_option("packetcapture", "PacketCount", value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_PacketCapture_FileTarget(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("packetcapture", "FileTarget");
|
||||
*value = diagnostics_get_option("packetcapture", "FileTarget");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -282,15 +281,15 @@ static int set_PacketCapture_FileTarget(char *refparam, struct dmctx *ctx, void
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("packetcapture");
|
||||
set_diagnostics_option("packetcapture", "FileTarget", value);
|
||||
diagnostics_reset_state("packetcapture");
|
||||
diagnostics_set_option("packetcapture", "FileTarget", value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_PacketCapture_FilterExpression(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("packetcapture", "FilterExpression");
|
||||
*value = diagnostics_get_option("packetcapture", "FilterExpression");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -302,15 +301,15 @@ static int set_PacketCapture_FilterExpression(char *refparam, struct dmctx *ctx,
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("packetcapture");
|
||||
set_diagnostics_option("packetcapture", "FilterExpression", value);
|
||||
diagnostics_reset_state("packetcapture");
|
||||
diagnostics_set_option("packetcapture", "FilterExpression", value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_PacketCapture_Username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("packetcapture", "Username");
|
||||
*value = diagnostics_get_option("packetcapture", "Username");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -322,8 +321,8 @@ static int set_PacketCapture_Username(char *refparam, struct dmctx *ctx, void *d
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("packetcapture");
|
||||
set_diagnostics_option("packetcapture", "Username", value);
|
||||
diagnostics_reset_state("packetcapture");
|
||||
diagnostics_set_option("packetcapture", "Username", value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -342,8 +341,8 @@ static int set_PacketCapture_Password(char *refparam, struct dmctx *ctx, void *d
|
|||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("packetcapture");
|
||||
set_diagnostics_option("packetcapture", "Password", value);
|
||||
diagnostics_reset_state("packetcapture");
|
||||
diagnostics_set_option("packetcapture", "Password", value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "dmlayer.h"
|
||||
#include "ppp.h"
|
||||
|
||||
struct ppp_args
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef __PPP_H
|
||||
#define __PPP_H
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "libbbfdm-api/dmcommon.h"
|
||||
|
||||
#define IPCP 0
|
||||
#define IPCPv6 1
|
||||
|
|
|
|||
|
|
@ -1619,9 +1619,11 @@ static int get_QoSQueue_SchedulerAlgorithm(char *refparam, struct dmctx *ctx, vo
|
|||
|
||||
static int set_QoSQueue_SchedulerAlgorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Scheduler_Algorithm[] = {"WFQ", "WRR", "SP", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, SchedulerAlgorithm, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Scheduler_Algorithm, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
|
|||
|
|
@ -488,9 +488,11 @@ static int get_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag(char *
|
|||
|
||||
static int set_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Adv_Preferred_RouterFlag[] = {"High", "Medium", "Low", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, AdvPreferredRouterFlag, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Adv_Preferred_RouterFlag, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "ip.h"
|
||||
#include "dmlayer.h"
|
||||
#include "routing.h"
|
||||
|
||||
struct route_args {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "selftest.h"
|
||||
|
||||
#define DIAG_BIN "/usr/sbin/self-diagnostics"
|
||||
|
|
@ -85,7 +84,7 @@ int operate_Device_SelfTest(char *refparam, struct dmctx *ctx, void *data, char
|
|||
add_list_parameter(ctx, dmstrdup("Results"), result, DMT_TYPE[DMT_STRING], NULL);
|
||||
|
||||
if (ctx->dm_type != BBFDM_USP) {
|
||||
set_diagnostics_option("selftest", "DiagnosticState", "Complete");
|
||||
diagnostics_set_option("selftest", "DiagnosticState", "Complete");
|
||||
dmuci_commit_package_bbfdm(DMMAP_DIAGNOSTIGS);
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +93,7 @@ int operate_Device_SelfTest(char *refparam, struct dmctx *ctx, void *data, char
|
|||
err:
|
||||
add_list_parameter(ctx, dmstrdup("Status"), dmstrdup("Error_Internal"), DMT_TYPE[DMT_STRING], NULL);
|
||||
if (ctx->dm_type != BBFDM_USP) {
|
||||
set_diagnostics_option("selftest", "DiagnosticState", "Error");
|
||||
diagnostics_set_option("selftest", "DiagnosticState", "Error");
|
||||
dmuci_commit_package_bbfdm(DMMAP_DIAGNOSTIGS);
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +105,7 @@ err:
|
|||
**************************************************************/
|
||||
static int get_SelfTest_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("selftest", "DiagnosticState", "None");
|
||||
*value = diagnostics_get_option_fallback_def("selftest", "DiagnosticState", "None");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +118,7 @@ static int set_SelfTest_DiagnosticsState(char *refparam, struct dmctx *ctx, void
|
|||
break;
|
||||
case VALUESET:
|
||||
if (DM_LSTRCMP(value, "Requested") == 0)
|
||||
set_diagnostics_option("selftest", "DiagnosticState", value);
|
||||
diagnostics_set_option("selftest", "DiagnosticState", value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#define MAX_POWER_INDEX 64
|
||||
#define UBUS_OBJ_LEN 32
|
||||
|
||||
static char *MFP_Config[] = {"Disabled", "Optional", "Required", NULL};
|
||||
|
||||
struct radio_obj
|
||||
{
|
||||
char obj_name[15];
|
||||
|
|
@ -1054,6 +1056,7 @@ static int get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, str
|
|||
|
||||
static int set_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Supported_Operating_Channel_Bandwidth[] = {"20MHz", "40MHz", "80MHz", "160MHz", "320MHz", "80+80MHz", "Auto", NULL};
|
||||
char *supported_bandwidths = NULL;
|
||||
char *curr_htmode = NULL;
|
||||
char htmode[32];
|
||||
|
|
@ -1061,7 +1064,7 @@ static int set_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx
|
|||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, SupportedOperatingChannelBandwidth, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Supported_Operating_Channel_Bandwidth, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
// Get the list of all supported operating channel bandwidths
|
||||
|
|
@ -1104,9 +1107,11 @@ static int get_WiFiRadio_PreambleType(char *refparam, struct dmctx *ctx, void *d
|
|||
|
||||
static int set_WiFiRadio_PreambleType(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Preamble_Type[] = {"short", "long", "auto", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, PreambleType, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Preamble_Type, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
@ -1271,9 +1276,11 @@ static int get_WiFiRadio_RegulatoryDomain(char *refparam, struct dmctx *ctx, voi
|
|||
|
||||
static int set_WiFiRadio_RegulatoryDomain(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Regulatory_Domain[] = {"^[A-Z][A-Z]$", "^[A-Z][A-Z][ OI]$", NULL};
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, 2, 3, NULL, RegulatoryDomain))
|
||||
if (bbfdm_validate_string(ctx, value, 2, 3, NULL, Regulatory_Domain))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
@ -2087,7 +2094,7 @@ static int set_WiFiAccessPointSecurity_MFPConfig(char *refparam, struct dmctx *c
|
|||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, MFPConfig, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, MFP_Config, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
/*Here we also need to validate the encyption algo whether the MFP can be set*/
|
||||
|
|
@ -2635,7 +2642,7 @@ static int set_WiFiEndPointProfileSecurity_MFPConfig(char *refparam, struct dmct
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, MFPConfig, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, MFP_Config, NULL))
|
||||
return FAULT_9007;
|
||||
break;
|
||||
case VALUESET:
|
||||
|
|
@ -3328,11 +3335,12 @@ static int get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
|
||||
static int set_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Supported_Frequency_Bands[] = {"2.4GHz", "5GHz", "6GHz", NULL};
|
||||
char *supported_frequency_bands = NULL;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, SupportedFrequencyBands, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Supported_Frequency_Bands, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
// Get the list of all supported frequency bands
|
||||
|
|
@ -3491,6 +3499,7 @@ static int get_radio_operating_standard(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *Supported_Standards[] = {"a", "b", "g", "n", "ac", "ax", "be", NULL};
|
||||
char *supported_standards = NULL;
|
||||
char *bandwidth = NULL;
|
||||
char *pch, *spch;
|
||||
|
|
@ -3498,7 +3507,7 @@ static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string_list(ctx, value, -1, -1, -1, -1, -1, SupportedStandards, NULL))
|
||||
if (bbfdm_validate_string_list(ctx, value, -1, -1, -1, -1, -1, Supported_Standards, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
// Get the list of all supported standards
|
||||
|
|
|
|||
|
|
@ -9,11 +9,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "iplayercap.h"
|
||||
|
||||
#define IPLAYER_CAP_DIAGNOSTIC_PATH "/usr/share/bbfdm/iplayercap"
|
||||
|
||||
static char *Protocol_Version[] = {"Any", "IPv4", "IPv6", NULL};
|
||||
static char *IPLayerCapacity_Role[] = {"Receiver", "Sender", NULL};
|
||||
static char *UDP_Payload_Content[] = {"zeroes", "random", NULL};
|
||||
static char *IPLayerCapacity_TestType[] = {"Search", "Fixed", NULL};
|
||||
static char *RateAdj_Algorithm[] = {"B", "C", NULL};
|
||||
|
||||
/*
|
||||
* *** Device.IP.Diagnostics.IPLayerCapacityMetrics. ***
|
||||
*/
|
||||
|
|
@ -46,7 +51,7 @@ static int browseIPLayerCapacityIncrementalResultInst(struct dmctx *dmctx, DMNOD
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_DiagnosticsState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("iplayercapacity", "DiagnosticState", "None");
|
||||
*value = diagnostics_get_option_fallback_def("iplayercapacity", "DiagnosticState", "None");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +64,7 @@ static int set_IPDiagnosticsIPLayerCapacity_DiagnosticsState(char *refparam, str
|
|||
return 0;
|
||||
case VALUESET:
|
||||
if (DM_LSTRCMP(value, "Requested") == 0)
|
||||
set_diagnostics_option("iplayercapacity", "DiagnosticState", value);
|
||||
diagnostics_set_option("iplayercapacity", "DiagnosticState", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -97,7 +102,7 @@ int get_IPDiagnosticsIPLayerCapacity_SupportedMetrics(char *refparam, struct dmc
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *linker = get_diagnostics_option("iplayercapacity", "interface");
|
||||
char *linker = diagnostics_get_option("iplayercapacity", "interface");
|
||||
adm_entry_get_reference_param(ctx, "Device.IP.Interface.*.Name", linker, value);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -119,8 +124,8 @@ static int set_IPDiagnosticsIPLayerCapacity_Interface(char *refparam, struct dmc
|
|||
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "interface", reference.value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "interface", reference.value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -128,7 +133,7 @@ static int set_IPDiagnosticsIPLayerCapacity_Interface(char *refparam, struct dmc
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_Role(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "Role");
|
||||
*value = diagnostics_get_option("iplayercapacity", "Role");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -136,13 +141,13 @@ static int set_IPDiagnosticsIPLayerCapacity_Role(char *refparam, struct dmctx *c
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, IPLayerCapacityRole, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, IPLayerCapacity_Role, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "Role", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "Role", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -150,7 +155,7 @@ static int set_IPDiagnosticsIPLayerCapacity_Role(char *refparam, struct dmctx *c
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_Host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "Host");
|
||||
*value = diagnostics_get_option("iplayercapacity", "Host");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -162,8 +167,8 @@ static int set_IPDiagnosticsIPLayerCapacity_Host(char *refparam, struct dmctx *c
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "Host", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "Host", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -171,7 +176,7 @@ static int set_IPDiagnosticsIPLayerCapacity_Host(char *refparam, struct dmctx *c
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "Port");
|
||||
*value = diagnostics_get_option("iplayercapacity", "Port");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -183,8 +188,8 @@ static int set_IPDiagnosticsIPLayerCapacity_Port(char *refparam, struct dmctx *c
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "Port", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "Port", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -192,7 +197,7 @@ static int set_IPDiagnosticsIPLayerCapacity_Port(char *refparam, struct dmctx *c
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_JumboFramesPermitted(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "JumboFramesPermitted");
|
||||
*value = diagnostics_get_option("iplayercapacity", "JumboFramesPermitted");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -206,9 +211,9 @@ static int set_IPDiagnosticsIPLayerCapacity_JumboFramesPermitted(char *refparam,
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
string_to_bool(value, &b);
|
||||
set_diagnostics_option("iplayercapacity", "JumboFramesPermitted", b ? "1" : "0");
|
||||
diagnostics_set_option("iplayercapacity", "JumboFramesPermitted", b ? "1" : "0");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -216,7 +221,7 @@ static int set_IPDiagnosticsIPLayerCapacity_JumboFramesPermitted(char *refparam,
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_DSCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "DSCP");
|
||||
*value = diagnostics_get_option("iplayercapacity", "DSCP");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -228,8 +233,8 @@ static int set_IPDiagnosticsIPLayerCapacity_DSCP(char *refparam, struct dmctx *c
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "DSCP", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "DSCP", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -237,7 +242,7 @@ static int set_IPDiagnosticsIPLayerCapacity_DSCP(char *refparam, struct dmctx *c
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_ProtocolVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "ProtocolVersion");
|
||||
*value = diagnostics_get_option("iplayercapacity", "ProtocolVersion");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -245,12 +250,12 @@ static int set_IPDiagnosticsIPLayerCapacity_ProtocolVersion(char *refparam, stru
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, ProtocolVersion, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, Protocol_Version, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "ProtocolVersion", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "ProtocolVersion", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -258,7 +263,7 @@ static int set_IPDiagnosticsIPLayerCapacity_ProtocolVersion(char *refparam, stru
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_UDPPayloadContent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "UDPPayloadContent");
|
||||
*value = diagnostics_get_option("iplayercapacity", "UDPPayloadContent");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -266,12 +271,12 @@ static int set_IPDiagnosticsIPLayerCapacity_UDPPayloadContent(char *refparam, st
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, UDPPayloadContent, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, UDP_Payload_Content, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "UDPPayloadContent", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "UDPPayloadContent", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -279,7 +284,7 @@ static int set_IPDiagnosticsIPLayerCapacity_UDPPayloadContent(char *refparam, st
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_TestType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "TestType");
|
||||
*value = diagnostics_get_option("iplayercapacity", "TestType");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -287,12 +292,12 @@ static int set_IPDiagnosticsIPLayerCapacity_TestType(char *refparam, struct dmct
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, IPLayerCapacityTestType, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, IPLayerCapacity_TestType, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "TestType", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "TestType", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -300,7 +305,7 @@ static int set_IPDiagnosticsIPLayerCapacity_TestType(char *refparam, struct dmct
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_IPDVEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "IPDVEnable");
|
||||
*value = diagnostics_get_option("iplayercapacity", "IPDVEnable");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -314,9 +319,9 @@ static int set_IPDiagnosticsIPLayerCapacity_IPDVEnable(char *refparam, struct dm
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
string_to_bool(value, &b);
|
||||
set_diagnostics_option("iplayercapacity", "IPDVEnable", b ? "1" : "0");
|
||||
diagnostics_set_option("iplayercapacity", "IPDVEnable", b ? "1" : "0");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -324,7 +329,7 @@ static int set_IPDiagnosticsIPLayerCapacity_IPDVEnable(char *refparam, struct dm
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_StartSendingRateIndex(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "StartSendingRateIndex");
|
||||
*value = diagnostics_get_option("iplayercapacity", "StartSendingRateIndex");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -337,8 +342,8 @@ static int set_IPDiagnosticsIPLayerCapacity_StartSendingRateIndex(char *refparam
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "StartSendingRateIndex", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "StartSendingRateIndex", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -346,7 +351,7 @@ static int set_IPDiagnosticsIPLayerCapacity_StartSendingRateIndex(char *refparam
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_NumberFirstModeTestSubIntervals(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "NumberFirstModeTestSubIntervals");
|
||||
*value = diagnostics_get_option("iplayercapacity", "NumberFirstModeTestSubIntervals");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -358,8 +363,8 @@ static int set_IPDiagnosticsIPLayerCapacity_NumberFirstModeTestSubIntervals(char
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "NumberFirstModeTestSubIntervals", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "NumberFirstModeTestSubIntervals", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -367,7 +372,7 @@ static int set_IPDiagnosticsIPLayerCapacity_NumberFirstModeTestSubIntervals(char
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_NumberTestSubIntervals(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "NumberTestSubIntervals");
|
||||
*value = diagnostics_get_option("iplayercapacity", "NumberTestSubIntervals");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -383,8 +388,8 @@ static int set_IPDiagnosticsIPLayerCapacity_NumberTestSubIntervals(char *refpara
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "NumberTestSubIntervals", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "NumberTestSubIntervals", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -392,7 +397,7 @@ static int set_IPDiagnosticsIPLayerCapacity_NumberTestSubIntervals(char *refpara
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_TestSubInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "TestSubInterval");
|
||||
*value = diagnostics_get_option("iplayercapacity", "TestSubInterval");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -405,8 +410,8 @@ static int set_IPDiagnosticsIPLayerCapacity_TestSubInterval(char *refparam, stru
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "TestSubInterval", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "TestSubInterval", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -414,7 +419,7 @@ static int set_IPDiagnosticsIPLayerCapacity_TestSubInterval(char *refparam, stru
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_StatusFeedbackInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "StatusFeedbackInterval");
|
||||
*value = diagnostics_get_option("iplayercapacity", "StatusFeedbackInterval");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -426,8 +431,8 @@ static int set_IPDiagnosticsIPLayerCapacity_StatusFeedbackInterval(char *refpara
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "StatusFeedbackInterval", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "StatusFeedbackInterval", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -435,7 +440,7 @@ static int set_IPDiagnosticsIPLayerCapacity_StatusFeedbackInterval(char *refpara
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_SeqErrThresh(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "SeqErrThresh");
|
||||
*value = diagnostics_get_option("iplayercapacity", "SeqErrThresh");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -447,8 +452,8 @@ static int set_IPDiagnosticsIPLayerCapacity_SeqErrThresh(char *refparam, struct
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "SeqErrThresh", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "SeqErrThresh", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -456,7 +461,7 @@ static int set_IPDiagnosticsIPLayerCapacity_SeqErrThresh(char *refparam, struct
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_ReordDupIgnoreEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "ReordDupIgnoreEnable");
|
||||
*value = diagnostics_get_option("iplayercapacity", "ReordDupIgnoreEnable");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -470,9 +475,9 @@ static int set_IPDiagnosticsIPLayerCapacity_ReordDupIgnoreEnable(char *refparam,
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
string_to_bool(value, &b);
|
||||
set_diagnostics_option("iplayercapacity", "ReordDupIgnoreEnable", b ? "1" : "0");
|
||||
diagnostics_set_option("iplayercapacity", "ReordDupIgnoreEnable", b ? "1" : "0");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -480,7 +485,7 @@ static int set_IPDiagnosticsIPLayerCapacity_ReordDupIgnoreEnable(char *refparam,
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_LowerThresh(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "LowerThresh");
|
||||
*value = diagnostics_get_option("iplayercapacity", "LowerThresh");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -492,8 +497,8 @@ static int set_IPDiagnosticsIPLayerCapacity_LowerThresh(char *refparam, struct d
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "LowerThresh", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "LowerThresh", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -501,7 +506,7 @@ static int set_IPDiagnosticsIPLayerCapacity_LowerThresh(char *refparam, struct d
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_UpperThresh(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "UpperThresh");
|
||||
*value = diagnostics_get_option("iplayercapacity", "UpperThresh");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -513,8 +518,8 @@ static int set_IPDiagnosticsIPLayerCapacity_UpperThresh(char *refparam, struct d
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "UpperThresh", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "UpperThresh", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -522,7 +527,7 @@ static int set_IPDiagnosticsIPLayerCapacity_UpperThresh(char *refparam, struct d
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_HighSpeedDelta(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "HighSpeedDelta");
|
||||
*value = diagnostics_get_option("iplayercapacity", "HighSpeedDelta");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -534,8 +539,8 @@ static int set_IPDiagnosticsIPLayerCapacity_HighSpeedDelta(char *refparam, struc
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "HighSpeedDelta", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "HighSpeedDelta", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -543,7 +548,7 @@ static int set_IPDiagnosticsIPLayerCapacity_HighSpeedDelta(char *refparam, struc
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_RateAdjAlgorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "RateAdjAlgorithm");
|
||||
*value = diagnostics_get_option("iplayercapacity", "RateAdjAlgorithm");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -551,12 +556,12 @@ static int set_IPDiagnosticsIPLayerCapacity_RateAdjAlgorithm(char *refparam, str
|
|||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, RateAdjAlgorithm, NULL))
|
||||
if (bbfdm_validate_string(ctx, value, -1, -1, RateAdj_Algorithm, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "RateAdjAlgorithm", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "RateAdjAlgorithm", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -570,8 +575,8 @@ static int set_IPDiagnosticsIPLayerCapacity_SlowAdjThresh(char *refparam, struct
|
|||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
reset_diagnostic_state("iplayercapacity");
|
||||
set_diagnostics_option("iplayercapacity", "SlowAdjThresh", value);
|
||||
diagnostics_reset_state("iplayercapacity");
|
||||
diagnostics_set_option("iplayercapacity", "SlowAdjThresh", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -579,169 +584,169 @@ static int set_IPDiagnosticsIPLayerCapacity_SlowAdjThresh(char *refparam, struct
|
|||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_SlowAdjThresh(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "SlowAdjThresh");
|
||||
*value = diagnostics_get_option("iplayercapacity", "SlowAdjThresh");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_BOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("iplayercapacity", "BOMTime", "0001-01-01T00:00:00.000000Z");
|
||||
*value = diagnostics_get_option_fallback_def("iplayercapacity", "BOMTime", "0001-01-01T00:00:00.000000Z");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_EOMTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("iplayercapacity", "EOMTime", "0001-01-01T00:00:00.000000Z");
|
||||
*value = diagnostics_get_option_fallback_def("iplayercapacity", "EOMTime", "0001-01-01T00:00:00.000000Z");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_TmaxUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "TmaxUsed");
|
||||
*value = diagnostics_get_option("iplayercapacity", "TmaxUsed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_TestInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "TestInterval");
|
||||
*value = diagnostics_get_option("iplayercapacity", "TestInterval");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_MaxIPLayerCapacity(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "MaxIPLayerCapacity");
|
||||
*value = diagnostics_get_option("iplayercapacity", "MaxIPLayerCapacity");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_TimeOfMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option_fallback_def("iplayercapacity", "TimeOfMax", "0001-01-01T00:00:00.000000Z");
|
||||
*value = diagnostics_get_option_fallback_def("iplayercapacity", "TimeOfMax", "0001-01-01T00:00:00.000000Z");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_MaxETHCapacityNoFCS(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "MaxETHCapacityNoFCS");
|
||||
*value = diagnostics_get_option("iplayercapacity", "MaxETHCapacityNoFCS");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_MaxETHCapacityWithFCS(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "MaxETHCapacityWithFCS");
|
||||
*value = diagnostics_get_option("iplayercapacity", "MaxETHCapacityWithFCS");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_MaxETHCapacityWithFCSVLAN(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "MaxETHCapacityWithFCSVLAN");
|
||||
*value = diagnostics_get_option("iplayercapacity", "MaxETHCapacityWithFCSVLAN");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_LossRatioAtMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "LossRatioAtMax");
|
||||
*value = diagnostics_get_option("iplayercapacity", "LossRatioAtMax");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_RTTRangeAtMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "RTTRangeAtMax");
|
||||
*value = diagnostics_get_option("iplayercapacity", "RTTRangeAtMax");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_PDVRangeAtMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "PDVRangeAtMax");
|
||||
*value = diagnostics_get_option("iplayercapacity", "PDVRangeAtMax");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_MinOnewayDelayAtMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "MinOnewayDelayAtMax");
|
||||
*value = diagnostics_get_option("iplayercapacity", "MinOnewayDelayAtMax");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_ReorderedRatioAtMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "ReorderedRatioAtMax");
|
||||
*value = diagnostics_get_option("iplayercapacity", "ReorderedRatioAtMax");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_ReplicatedRatioAtMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "ReplicatedRatioAtMax");
|
||||
*value = diagnostics_get_option("iplayercapacity", "ReplicatedRatioAtMax");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_InterfaceEthMbpsAtMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "InterfaceEthMbpsAtMax");
|
||||
*value = diagnostics_get_option("iplayercapacity", "InterfaceEthMbpsAtMax");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_IPLayerCapacitySummary(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "IPLayerCapacitySummary");
|
||||
*value = diagnostics_get_option("iplayercapacity", "IPLayerCapacitySummary");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_LossRatioSummary(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "LossRatioSummary");
|
||||
*value = diagnostics_get_option("iplayercapacity", "LossRatioSummary");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_RTTRangeSummary(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "RTTRangeSummary");
|
||||
*value = diagnostics_get_option("iplayercapacity", "RTTRangeSummary");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_PDVRangeSummary(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "PDVRangeSummary");
|
||||
*value = diagnostics_get_option("iplayercapacity", "PDVRangeSummary");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_MinOnewayDelaySummary(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "MinOnewayDelaySummary");
|
||||
*value = diagnostics_get_option("iplayercapacity", "MinOnewayDelaySummary");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_MinRTTSummary(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "MinRTTSummary");
|
||||
*value = diagnostics_get_option("iplayercapacity", "MinRTTSummary");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_ReorderedRatioSummary(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "ReorderedRatioSummary");
|
||||
*value = diagnostics_get_option("iplayercapacity", "ReorderedRatioSummary");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_ReplicatedRatioSummary(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "ReplicatedRatioSummary");
|
||||
*value = diagnostics_get_option("iplayercapacity", "ReplicatedRatioSummary");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_InterfaceEthMbpsSummary(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "InterfaceEthMbpsSummary");
|
||||
*value = diagnostics_get_option("iplayercapacity", "InterfaceEthMbpsSummary");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_TmaxRTTUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "TmaxRTTUsed");
|
||||
*value = diagnostics_get_option("iplayercapacity", "TmaxRTTUsed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IPDiagnosticsIPLayerCapacity_TimestampResolutionUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = get_diagnostics_option("iplayercapacity", "TimestampResolutionUsed");
|
||||
*value = diagnostics_get_option("iplayercapacity", "TimestampResolutionUsed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -985,9 +990,9 @@ int operate_IPDiagnostics_IPLayerCapacity(char *refparam, struct dmctx *ctx, voi
|
|||
}
|
||||
|
||||
char *ip_interface = dmjson_get_value((json_object *)value, 1, "Interface");
|
||||
char *interface = get_diagnostics_interface_option(ctx, ip_interface);
|
||||
char *interface = diagnostics_get_interface_name(ctx, ip_interface);
|
||||
char *role = dmjson_get_value((json_object *)value, 1, "Role");
|
||||
if (role[0] != '\0' && bbfdm_validate_string(ctx, role, -1, -1, IPLayerCapacityRole, NULL))
|
||||
if (role[0] != '\0' && bbfdm_validate_string(ctx, role, -1, -1, IPLayerCapacity_Role, NULL))
|
||||
return USP_FAULT_INVALID_ARGUMENT;
|
||||
|
||||
char *port = dmjson_get_value((json_object *)value, 1, "Port");
|
||||
|
|
@ -1003,15 +1008,15 @@ int operate_IPDiagnostics_IPLayerCapacity(char *refparam, struct dmctx *ctx, voi
|
|||
return USP_FAULT_INVALID_ARGUMENT;
|
||||
|
||||
char *ip_proto = dmjson_get_value((json_object *)value, 1, "ProtocolVersion");
|
||||
if (ip_proto[0] != '\0' && bbfdm_validate_string(ctx, ip_proto, -1, -1, ProtocolVersion, NULL))
|
||||
if (ip_proto[0] != '\0' && bbfdm_validate_string(ctx, ip_proto, -1, -1, Protocol_Version, NULL))
|
||||
return USP_FAULT_INVALID_ARGUMENT;
|
||||
|
||||
char *content = dmjson_get_value((json_object *)value, 1, "UDPPayloadContent");
|
||||
if (content[0] != '\0' && bbfdm_validate_string(ctx, content, -1, -1, UDPPayloadContent, NULL))
|
||||
if (content[0] != '\0' && bbfdm_validate_string(ctx, content, -1, -1, UDP_Payload_Content, NULL))
|
||||
return USP_FAULT_INVALID_ARGUMENT;
|
||||
|
||||
char *test_type = dmjson_get_value((json_object *)value, 1, "TestType");
|
||||
if (test_type[0] != '\0' && bbfdm_validate_string(ctx, test_type, -1, -1, IPLayerCapacityTestType, NULL))
|
||||
if (test_type[0] != '\0' && bbfdm_validate_string(ctx, test_type, -1, -1, IPLayerCapacity_TestType, NULL))
|
||||
return USP_FAULT_INVALID_ARGUMENT;
|
||||
|
||||
char *ipdv = dmjson_get_value((json_object *)value, 1, "IPDVEnable");
|
||||
|
|
@ -1063,7 +1068,7 @@ int operate_IPDiagnostics_IPLayerCapacity(char *refparam, struct dmctx *ctx, voi
|
|||
return USP_FAULT_INVALID_ARGUMENT;
|
||||
|
||||
char *rate_adj = dmjson_get_value((json_object *)value, 1, "RateAdjAlgorithm");
|
||||
if (rate_adj[0] != '\0' && bbfdm_validate_string(ctx, rate_adj, -1, -1, RateAdjAlgorithm, NULL))
|
||||
if (rate_adj[0] != '\0' && bbfdm_validate_string(ctx, rate_adj, -1, -1, RateAdj_Algorithm, NULL))
|
||||
return USP_FAULT_INVALID_ARGUMENT;
|
||||
|
||||
snprintf(input, sizeof(input), "'{\"host\": \"%s\",\"interface\":\"%s\",\"role\":\"%s\",\"port\":\"%s\",\"jumbo_frames\":\"%s\",\"proto_ver\":\"%s\",\"udp_content\":\"%s\",\"test_type\":\"%s\",\"ipdv_enable\":\"%s\",\"DSCP\":\"%s\",\"rate_index\":\"%s\",\"mode_subintervals\":\"%s\",\"test_subinterval\":\"%s\",\"feedback_interval\":\"%s\",\"seq_err_thresh\":\"%s\",\"dup_ignore\":\"%s\",\"lower_thresh\":\"%s\",\"upper_thresh\":\"%s\",\"high_speed_delta\":\"%s\",\"algorithm\":\"%s\",\"slow_adj_thresh\":\"%s\",\"num_interval\":\"%s\",\"proto\":\"%s\"}'",
|
||||
|
|
|
|||
2
libbbfdm/dmtree/vendor/iopsys/bridging.c
vendored
2
libbbfdm/dmtree/vendor/iopsys/bridging.c
vendored
|
|
@ -9,7 +9,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "dmcommon.h"
|
||||
#include "dmlayer.h"
|
||||
#include "bridging.h"
|
||||
|
||||
struct bridge_port_args
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue