Create a new libraries 'libbbf_api' && 'libbbf_dm'

This commit is contained in:
Amin Ben Romdhane 2023-03-27 14:14:08 +02:00
parent 83c6b0c77a
commit b8bc5c3423
183 changed files with 325 additions and 421 deletions

View file

@ -2,149 +2,7 @@ cmake_minimum_required(VERSION 3.0)
PROJECT(bbf C)
ADD_DEFINITIONS(-Wall -Werror)
ADD_DEFINITIONS(-D_GNU_SOURCE)
ADD_DEFINITIONS(-DBBF_VENDOR_PREFIX="${BBF_VENDOR_PREFIX}")
OPTION(BBFD_ENABLED "build bbfd daemon with their dependencies" OFF)
IF(${BBF_MAX_OBJECT_INSTANCES})
ADD_DEFINITIONS(-DBBF_MAX_OBJECT_INSTANCES=${BBF_MAX_OBJECT_INSTANCES})
ENDIF()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR} -I${PROJECT_SOURCE_DIR}/dmtree")
OPTION(BBF_TR181 "build with tr181 datamodel" ON)
OPTION(BBF_TR104 "build with tr104 datamodel" ON)
OPTION(BBF_TR143 "build with tr143 datamodel" ON)
OPTION(BBF_TR471 "build with tr471 datamodel" ON)
OPTION(BBF_DOTSO_PLUGIN "build with dotso plugin" ON)
OPTION(BBF_JSON_PLUGIN "build with json plugin" ON)
OPTION(BBF_VENDOR_EXTENSION "build with vendor extension enabled" ON)
OPTION(WITH_WOLFSSL "build with lib wolfssl" OFF)
OPTION(WITH_OPENSSL "build with lib openssl" OFF)
OPTION(WITH_MBEDTLS "build with lib mbedtls" OFF)
IF(NOT WITH_WOLFSSL AND NOT WITH_OPENSSL AND NOT WITH_MBEDTLS)
MESSAGE(FATAL_ERROR "You must enable one of the SSL libraries: {'WOLFSSL','OPENSSL','MBEDTLS'}")
ENDIF()
FILE(GLOB BBF_API_SOURCES ${PROJECT_SOURCE_DIR}/libbbf_api/*.c)
SET(BBF_DM_SOURCES dmentry.c dmdiagnostics.c dmbbfcommon.c)
IF(BBF_TR181)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}/dmtree/tr181")
FILE(GLOB BBF_TR181_SOURCES ${PROJECT_SOURCE_DIR}/dmtree/tr181/*.c)
add_compile_definitions(BBF_TR181)
ENDIF(BBF_TR181)
IF(BBF_TR104)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}/dmtree/tr104")
FILE(GLOB BBF_TR104_SOURCES ${PROJECT_SOURCE_DIR}/dmtree/tr104/*.c)
add_compile_definitions(BBF_TR104)
ENDIF(BBF_TR104)
IF(BBF_TR143)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}/dmtree/tr143")
FILE(GLOB BBF_TR143_SOURCES ${PROJECT_SOURCE_DIR}/dmtree/tr143/*.c)
add_compile_definitions(BBF_TR143)
ENDIF(BBF_TR143)
IF(BBF_TR471)
IF(NOT BBF_TR143)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}/dmtree/tr143")
FILE(GLOB BBF_TR143_SOURCES ${PROJECT_SOURCE_DIR}/dmtree/tr143/diagnostics.c)
ENDIF()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}/dmtree/tr471")
FILE(GLOB BBF_TR471_SOURCES ${PROJECT_SOURCE_DIR}/dmtree/tr471/*.c)
add_compile_definitions(BBF_TR471)
ENDIF(BBF_TR471)
IF(BBF_DOTSO_PLUGIN)
SET(BBF_DOTSO_PLUGIN_SOURCES dmdynamiclibrary.c)
add_compile_definitions(BBFDM_ENABLE_DOTSO_PLUGIN)
ENDIF(BBF_DOTSO_PLUGIN)
IF(BBF_JSON_PLUGIN)
SET(BBF_JSON_PLUGIN_SOURCES dmdynamicjson.c)
add_compile_definitions(BBFDM_ENABLE_JSON_PLUGIN)
endif(BBF_JSON_PLUGIN)
IF(WITH_WOLFSSL)
SET(SSL_LIBS wolfssl)
add_compile_definitions(LWOLFSSL)
ENDIF(WITH_WOLFSSL)
IF(WITH_OPENSSL)
SET(SSL_LIBS ssl)
add_compile_definitions(LOPENSSL)
ENDIF(WITH_OPENSSL)
IF(WITH_MBEDTLS)
SET(SSL_LIBS mbedtls)
add_compile_definitions(LMBEDTLS)
ENDIF(WITH_MBEDTLS)
IF(BBF_VENDOR_EXTENSION)
SET(BBF_VENDOR_EXTENSION_SOURCES dmdynamicvendor.c dmtree/vendor/vendor.c)
ADD_DEFINITIONS(-DBBF_VENDOR_LIST="${BBF_VENDOR_LIST}")
add_compile_definitions(BBF_VENDOR_EXTENSION)
SET(BBF_VENDOR_LIST "iopsys" CACHE STRING "vendor list to be used")
STRING(REPLACE "," ";" VENDOR_LIST ${BBF_VENDOR_LIST})
foreach(VENDOR IN LISTS VENDOR_LIST)
FILE(GLOB_RECURSE BBF_VENDOR_SOURCES ${PROJECT_SOURCE_DIR}/dmtree/vendor/${VENDOR}/*.c)
LIST(APPEND BBF_VENDOR_EXTENSION_SOURCES ${BBF_VENDOR_SOURCES})
STRING(TOUPPER ${VENDOR} VENDOR)
add_compile_definitions(BBF_VENDOR_${VENDOR})
endforeach()
ENDIF(BBF_VENDOR_EXTENSION)
ADD_LIBRARY(bbfdm SHARED ${BBF_API_SOURCES} ${BBF_DM_SOURCES}
${BBF_TR181_SOURCES} ${BBF_TR104_SOURCES} ${BBF_TR143_SOURCES} ${BBF_TR471_SOURCES}
${BBF_DOTSO_PLUGIN_SOURCES}
${BBF_JSON_PLUGIN_SOURCES}
${BBF_VENDOR_EXTENSION_SOURCES})
TARGET_LINK_LIBRARIES(bbfdm uci ubus ubox json-c blobmsg_json dl curl ${SSL_LIBS})
INSTALL(TARGETS bbfdm
LIBRARY DESTINATION usr/lib)
INSTALL(DIRECTORY DESTINATION etc/bbfdm)
INSTALL(DIRECTORY DESTINATION etc/bbfdm/dmmap)
INSTALL(DIRECTORY DESTINATION etc/bbfdm/json)
INSTALL(DIRECTORY DESTINATION usr/share/bbfdm)
INSTALL(DIRECTORY DESTINATION usr/lib/bbfdm)
FILE(GLOB headers include/*.h)
INSTALL(FILES ${headers}
DESTINATION usr/include
)
FILE(GLOB libbbf_api_headers libbbf_api/*.h)
INSTALL(FILES ${libbbf_api_headers}
DESTINATION usr/include/libbbf_api
)
FILE(GLOB libbbfdm_headers *.h)
INSTALL(FILES ${libbbfdm_headers}
DESTINATION usr/include/libbbfdm
)
FILE(GLOB scripts scripts/*)
INSTALL(FILES ${scripts}
PERMISSIONS OWNER_EXECUTE
DESTINATION usr/share/bbfdm
)
# add CPack to project
SET(CPACK_PACKAGE_NAME "libbbf")
SET(CPACK_PACKAGE_VENDOR "iopsys.io")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "libbbf - Datamodel library")
SET(CPACK_PACKAGE_VERSION "1.0.0")
SET(CPACK_GENERATOR STGZ)
include(CPack)
add_subdirectory(libbbf_api)
add_subdirectory(libbbf_dm)

View file

@ -5,7 +5,7 @@ This package comprises of the below libraries:
| Library | Description |
| ------- | ------------------------------------------------- |
| libbbfdm | This provides the mechanism to add new parameters or extend the existing DM tree using json plugin or shared library plugin. |
| libbbf_dm | This provides the mechanism to add new parameters or extend the existing DM tree using json plugin or shared library plugin. |
| libbbf_api | This provides the APIs for UCI, Ubus, JSON, CLI and memory management. |
## Design of bbfdm
@ -42,7 +42,7 @@ This package comprises of the below libraries:
- `json` folder : TR-181 and TR-104 JSON files
- `libbbf_api` folder which contains the source code of all API functions (UCI, Ubus, JSON, CLI and memory management). These API are used for GET/SET/ADD/Delete/Operate calls which can be called in internal or external packages.
All APIs exposed by libbbf_api are presented in this header file [libbbf_api.h](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/include/libbbf_api.h).
All APIs exposed by libbbf_api are presented in this header file [libbbf_api.h](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/libbbf_api/include/libbbf_api.h).
- `scripts` folder which contains the Diagnostics scripts

View file

@ -1,80 +0,0 @@
/*
* Copyright (C) 2020 iopsys Software Solutions AB
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
* Author Omar Kallel <omar.kallel@pivasoftware.com>
*/
#include "dmbbfcommon.h"
int set_bbfdatamodel_type(int bbf_type)
{
bbfdatamodel_type = bbf_type;
return 0;
}
int get_bbfdatamodel_type(void)
{
return bbfdatamodel_type;
}
int bbfdmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value)
{
return dmuci_lookup_ptr(ctx, ptr, package, section, option, value);
}
void bbf_uci_commit_bbfdm(void)
{
dmuci_init_bbfdm();
dmuci_commit_bbfdm();
dmuci_exit_bbfdm();
}
void bbf_uci_revert_bbfdm(void)
{
dmuci_init_bbfdm();
dmuci_revert_bbfdm();
dmuci_exit_bbfdm();
}
void del_list_fault_param(struct param_fault *param_fault)
{
bbf_api_del_list_fault_param(param_fault);
}
int get_dm_type(char *dm_str)
{
if (dm_str == NULL)
return DMT_STRING;
if (DM_STRCMP(dm_str, DMT_TYPE[DMT_STRING]) == 0)
return DMT_STRING;
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_UNINT]) == 0)
return DMT_UNINT;
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_INT]) == 0)
return DMT_INT;
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_UNLONG]) == 0)
return DMT_UNLONG;
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_LONG]) == 0)
return DMT_LONG;
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_BOOL]) == 0)
return DMT_BOOL;
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_TIME]) == 0)
return DMT_TIME;
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_HEXBIN]) == 0)
return DMT_HEXBIN;
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_BASE64]) == 0)
return DMT_BASE64;
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_COMMAND]) == 0)
return DMT_COMMAND;
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_EVENT]) == 0)
return DMT_EVENT;
else
return DMT_STRING;
return DMT_STRING;
}

View file

@ -1,27 +0,0 @@
/*
* Copyright (C) 2020 iopsys Software Solutions AB
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
* Author Omar Kallel <omar.kallel@pivasoftware.com>
*/
#ifndef __DMBBFCOMMON_H__
#define __DMBBFCOMMON_H__
#include "libbbf_api/dmcommon.h"
#include "dmentry.h"
void bbf_uci_commit_bbfdm(void);
void bbf_uci_revert_bbfdm(void);
int set_bbfdatamodel_type(int bbf_type);
int get_bbfdatamodel_type(void);
void del_list_fault_param(struct param_fault *param_fault);
int bbfdmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value);
int get_dm_type(char *dm_str);
#endif //__DMBBFCOMMON_H__

View file

@ -28,7 +28,7 @@ The **DM_MAP_OBJ** structure contains three arguments:
For the other tables, they are defined in the same way as the Object and Parameter definition described above.
> Note1: Shared library can only add vendor or standard objects that are not implemented by `libbbfdm`
> Note1: Shared library can only add vendor or standard objects that are not implemented by `libbbf_dm`
> Note2: Shared library is not allowed to overwrite objects/parameters
@ -470,7 +470,7 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
}
```
> Note1: JSON File can only add vendor or standard objects that are not implemented by `libbbfdm`
> Note1: JSON File can only add vendor or standard objects that are not implemented by `libbbf_dm`
> Note2: JSON File is not allowed to overwrite objects/parameters

View file

@ -2,7 +2,7 @@
As mentioned in README, all Data Models are stored in the **'dmtree'** folder. In order to implement a new object/parameter, you need to expand its get/set/add/delete functions and then save them in the right folder.
`bbfdm` library offers a tool to generate templates of the source code from json files placed under **'dmtree/json'**. So, any developer can fill these json files ([tr181](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/dmtree/json/tr181.json) or [tr104](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/dmtree/json/tr104.json)) with mapping field according to UCI, UBUS or CLI commands then generate the source code in C.
`bbfdm` library offers a tool to generate templates of the source code from json files placed under **'dmtree/json'**. So, any developer can fill these json files ([tr181](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/libbbf_dm/dmtree/json/tr181.json) or [tr104](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/libbbf_dm/dmtree/json/tr104.json)) with mapping field according to UCI, UBUS or CLI commands then generate the source code in C.
```bash
$ ./convert_dm_json_to_c.py

View file

@ -119,7 +119,7 @@ $ ./generate_dm_excel.py -d tr181 -v iopsys -p X_IOPSYS_EU_ -r git^https://dev.i
```
## Validate JSON plugin
It is a [python script](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/tools/validate_json_plugin.py) to validate JSON plugin files for dynamic library or standard data model [TR181](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/dmtree/json/tr181.json), [TR104](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/dmtree/json/tr104.json), etc..
It is a [python script](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/tools/validate_json_plugin.py) to validate JSON plugin files for dynamic library or standard data model [TR181](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/libbbf_dm/dmtree/json/tr181.json), [TR104](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/libbbf_dm/dmtree/json/tr104.json), etc..
```bash
$ ./tools/validate_json_plugin.py test/files/etc/bbfdm/json/UserInterface.json
@ -151,7 +151,7 @@ The parameters/keys used in tools_input.json file are mostly self-explanatory bu
| | default: This contains the generic definition which has the capability to define more descriptive DM objects/parameters |
| output.file_format | xls: An excel file listing the supported and unsupported DM objects/parameters |
> Note: To add more description about the vendor extended DM objects/parameters, it is required to add the definition of the required/related DM objects/parameters in a json file (The json structure should follow same format as given in [tr181.json](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/dmtree/json/tr181.json)), The same json file need to be defined in dm_json_files list.
> Note: To add more description about the vendor extended DM objects/parameters, it is required to add the definition of the required/related DM objects/parameters in a json file (The json structure should follow same format as given in [tr181.json](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/libbbf_dm/dmtree/json/tr181.json)), The same json file need to be defined in dm_json_files list.
The input json file should be defined as follow:
@ -169,8 +169,8 @@ The input json file should be defined as follow:
"test"
],
"dm_json_files": [
"../dmtree/json/tr181.json",
"../dmtree/json/tr104.json"
"../libbbf_dm/dmtree/json/tr181.json",
"../libbbf_dm/dmtree/json/tr104.json"
]
"vendor_prefix": "X_IOPSYS_EU_",
"plugins": [

View file

@ -28,13 +28,13 @@ The **DM_MAP_OBJ** structure contains three arguments:
Each entry in the exclude table is a string which could be a path of object or parameter that need to be excluded from the tree
The following [link](https://dev.iopsys.eu/iopsys/bbf/-/blob/devel/dmtree/vendor/test/tr181/vendor.c) contains example of Extend, Overwrite and Exclude table.
The following [link](https://dev.iopsys.eu/iopsys/bbf/-/blob/devel/libbbf_dm/dmtree/vendor/test/tr181/vendor.c) contains example of Extend, Overwrite and Exclude table.
### 3. Adding vendor and standard objects/Parameters
Implement the new vendor/standard objects and parameters as defined above in the first section.
Example: [Custom Vendor Object Dropbear](https://dev.iopsys.eu/iopsys/bbf/-/blob/devel/dmtree/vendor/test/tr181/x_test_com_dropbear.c)
Example: [Custom Vendor Object Dropbear](https://dev.iopsys.eu/iopsys/bbf/-/blob/devel/libbbf_dm/dmtree/vendor/test/tr181/x_test_com_dropbear.c)
### 4. link vendor tables to the main tree
@ -48,7 +48,7 @@ To register the new vendor tables, you need to link them in the main three table
These tables are defined in the file **'dmtree/vendor/vendor.c'**.
Example: [Link vendor tables to the main tree](https://dev.iopsys.eu/iopsys/bbf/-/blob/devel/dmtree/vendor/vendor.c)
Example: [Link vendor tables to the main tree](https://dev.iopsys.eu/iopsys/bbf/-/blob/devel/libbbf_dm/dmtree/vendor/vendor.c)
### 5. Enable vendor
@ -68,7 +68,7 @@ BBF_VENDOR_LIST="iopsys,test"
BBF_VENDOR_PREFIX="X_TEST_COM_"
```
> Note1: The `libbbfdm` vendor list can support multi-vendor with comma seperated.
> Note1: The `libbbf_dm` vendor list can support multi-vendor with comma seperated.
> Note2: If multi vendors are supported and there is a object/parameter that is implmented by multi customers in different way, the implemented object/parameter of the first vendor name in the **BBF_VENDOR_LIST** will be considered.

View file

@ -11,9 +11,3 @@ numprocs_start=1
startretries=0
priority=2
command=/bin/bash -c "/usr/sbin/rpcd"
[program:bbf_ubus]
autorestart=false
numprocs_start=2
priority=3
command=/bin/bash -c "/usr/bin/valgrind --xml=yes --xml-file=./memory-report.xml --leak-check=full --show-reachable=yes --show-leak-kinds=all --errors-for-leak-kinds=all --error-exitcode=1 --track-origins=yes --leak-resolution=high --show-error-list=yes --child-silent-after-fork=yes ./test/dynamicdm_ubus_test/bbf_ubus"

View file

@ -12,6 +12,6 @@ cp -r ./test/files/var/* /var/
cp -r ./test/files/tmp/* /tmp/
cp -r ./test/files/lib/* /lib/
apt install -y iproute2
apt update && apt install -y iproute2
ls /etc/config/

View file

@ -18,11 +18,11 @@ exec_cmd_verbose pylint -d R,C,W0603 tools/*.py
echo "********* Validate JSON Plugin *********"
echo "Validate BBF TR-181 JSON Plugin"
./tools/validate_json_plugin.py dmtree/json/tr181.json
./tools/validate_json_plugin.py libbbf_dm/dmtree/json/tr181.json
check_ret $?
echo "Validate BBF TR-104 JSON Plugin"
./tools/validate_json_plugin.py dmtree/json/tr104.json
./tools/validate_json_plugin.py libbbf_dm/dmtree/json/tr104.json
check_ret $?
echo "Validate X_IOPSYS_EU_Dropbear JSON Plugin"

52
libbbf_api/CMakeLists.txt Normal file
View file

@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.0)
PROJECT(libbbf_api)
ADD_DEFINITIONS(-Wall -Werror)
ADD_DEFINITIONS(-D_GNU_SOURCE)
ADD_DEFINITIONS(-DBBF_VENDOR_PREFIX="${BBF_VENDOR_PREFIX}")
IF(${BBF_MAX_OBJECT_INSTANCES})
ADD_DEFINITIONS(-DBBF_MAX_OBJECT_INSTANCES=${BBF_MAX_OBJECT_INSTANCES})
ENDIF()
OPTION(BBF_DOTSO_PLUGIN "build with dotso plugin" ON)
OPTION(BBF_JSON_PLUGIN "build with json plugin" ON)
OPTION(BBF_VENDOR_EXTENSION "build with vendor extension enabled" ON)
IF(BBF_DOTSO_PLUGIN)
SET(BBF_DOTSO_PLUGIN_SOURCES dm_plugin/dmdynamiclibrary.c)
add_compile_definitions(BBFDM_ENABLE_DOTSO_PLUGIN)
ENDIF(BBF_DOTSO_PLUGIN)
IF(BBF_JSON_PLUGIN)
SET(BBF_JSON_PLUGIN_SOURCES dm_plugin/dmdynamicjson.c)
add_compile_definitions(BBFDM_ENABLE_JSON_PLUGIN)
endif(BBF_JSON_PLUGIN)
IF(BBF_VENDOR_EXTENSION)
SET(BBF_VENDOR_EXTENSION_SOURCES dm_plugin/dmdynamicvendor.c)
ADD_DEFINITIONS(-DBBF_VENDOR_LIST="${BBF_VENDOR_LIST}")
add_compile_definitions(BBF_VENDOR_EXTENSION)
SET(BBF_VENDOR_LIST "iopsys" CACHE STRING "vendor list to be used")
STRING(REPLACE "," ";" VENDOR_LIST ${BBF_VENDOR_LIST})
ENDIF(BBF_VENDOR_EXTENSION)
FILE(GLOB BBF_API_SOURCES *.c)
ADD_LIBRARY(bbf_api SHARED ${BBF_API_SOURCES} ${BBF_DOTSO_PLUGIN_SOURCES} ${BBF_JSON_PLUGIN_SOURCES} ${BBF_VENDOR_EXTENSION_SOURCES})
TARGET_LINK_LIBRARIES(bbf_api uci ubus ubox json-c blobmsg_json dl)
INSTALL(TARGETS bbf_api
LIBRARY DESTINATION usr/lib)
FILE(GLOB libbbf_api_headers *.h)
INSTALL(FILES ${libbbf_api_headers}
DESTINATION usr/include/libbbf_api
)
FILE(GLOB libbbf_api_include_headers include/*.h)
INSTALL(FILES ${libbbf_api_include_headers}
DESTINATION usr/include
)

View file

@ -10,7 +10,6 @@
*/
#include "dmdynamicjson.h"
#include "dmentry.h"
#define MAX_DM_LENGTH (1024)
#define json_object_get_string(x) (char *)json_object_get_string(x)

View file

@ -12,7 +12,7 @@
#ifndef __DMENTRYJSON_H__
#define __DMENTRYJSON_H__
#include "libbbf_api/dmcommon.h"
#include "../dmcommon.h"
#define JSON_FOLDER_PATH "/etc/bbfdm/json"

View file

@ -12,7 +12,7 @@
#ifndef __DMENTRYLIBRARY_H__
#define __DMENTRYLIBRARY_H__
#include "libbbf_api/dmcommon.h"
#include "../dmcommon.h"
#define LIBRARY_FOLDER_PATH "/usr/lib/bbfdm"

View file

@ -10,7 +10,6 @@
*/
#include "dmdynamicvendor.h"
#include "dmtree/vendor/vendor.h"
static void dm_browse_node_vendor_object_tree(DMNODE *parent_node, DMOBJ *entryobj)
{
@ -109,9 +108,9 @@ static void load_vendor_extension_arrays(struct dmctx *ctx)
for (int idx = length - 1; idx >= 0; idx--) {
DM_MAP_VENDOR *vendor_map_obj = tVendorExtension;
DM_MAP_VENDOR *vendor_map_obj = ctx->dm_vendor_extension[0];
for (int j = 0; vendor_map_obj[j].vendor; j++) {
for (int j = 0; vendor_map_obj && vendor_map_obj[j].vendor; j++) {
if (DM_STRCMP(vendor_map_obj[j].vendor, tokens[idx]) != 0)
continue;
@ -181,9 +180,9 @@ static void load_vendor_extension_overwrite_arrays(struct dmctx *ctx)
for (int idx = length - 1; idx >= 0; idx--) {
DM_MAP_VENDOR *vendor_map_obj = tVendorExtensionOverwrite;
DM_MAP_VENDOR *vendor_map_obj = ctx->dm_vendor_extension[1];
for (int j = 0; vendor_map_obj[j].vendor; j++) {
for (int j = 0; vendor_map_obj && vendor_map_obj[j].vendor; j++) {
if (DM_STRCMP(vendor_map_obj[j].vendor, tokens[idx]) != 0)
continue;
@ -273,9 +272,9 @@ static void load_vendor_extension_exclude_arrays(struct dmctx *ctx)
for (int idx = length - 1; idx >= 0; idx--) {
DM_MAP_VENDOR_EXCLUDE *vendor_map_exclude_obj = tVendorExtensionExclude;
DM_MAP_VENDOR_EXCLUDE *vendor_map_exclude_obj = ctx->dm_vendor_extension_exclude;
for (int j = 0; vendor_map_exclude_obj[j].vendor; j++) {
for (int j = 0; vendor_map_exclude_obj && vendor_map_exclude_obj[j].vendor; j++) {
if (DM_STRCMP(vendor_map_exclude_obj[j].vendor, tokens[idx]) != 0)
continue;

View file

@ -12,7 +12,7 @@
#ifndef __DMENTRYVENDOR_H__
#define __DMENTRYVENDOR_H__
#include "libbbf_api/dmcommon.h"
#include "../dmcommon.h"
void load_vendor_dynamic_arrays(struct dmctx *ctx);
void free_vendor_dynamic_arrays(DMOBJ *dm_entryobj);

View file

@ -176,6 +176,16 @@ struct dm_parameter {
char *additional_data;
};
typedef struct dm_map_vendor {
char *vendor;
struct dm_map_obj *vendor_obj;
} DM_MAP_VENDOR;
typedef struct dm_map_vendor_exclude {
char *vendor;
char **vendor_obj;
} DM_MAP_VENDOR_EXCLUDE;
struct dmctx
{
bool stop;
@ -189,6 +199,8 @@ struct dmctx
struct list_head list_fault_param;
struct list_head list_json_parameter;
DMOBJ *dm_entryobj;
DM_MAP_VENDOR *dm_vendor_extension[2];
DM_MAP_VENDOR_EXCLUDE *dm_vendor_extension_exclude;
bool nextlevel;
bool iswildcard;
int faultcode;
@ -231,16 +243,6 @@ typedef struct dm_map_obj {
struct dm_leaf_s *root_leaf;
} DM_MAP_OBJ;
typedef struct dm_map_vendor {
char *vendor;
struct dm_map_obj *vendor_obj;
} DM_MAP_VENDOR;
typedef struct dm_map_vendor_exclude {
char *vendor;
char **vendor_obj;
} DM_MAP_VENDOR_EXCLUDE;
enum operate_ret_status {
CMD_SUCCESS,
CMD_INVALID_ARGUMENTS,

View file

@ -13,15 +13,9 @@
*/
#include "dmentry.h"
#include "dmdynamicjson.h"
#include "dmdynamiclibrary.h"
#include "dmdynamicvendor.h"
#ifdef BBF_TR181
#include "device.h"
#endif /* BBF_TR181 */
#include "dmbbfcommon.h"
#include "dm_plugin/dmdynamicjson.h"
#include "dm_plugin/dmdynamiclibrary.h"
#include "dm_plugin/dmdynamicvendor.h"
LIST_HEAD(head_package_change);
LIST_HEAD(main_memhead);
@ -133,7 +127,8 @@ int usp_fault_map(int fault)
return out_fault;
}
static int dm_ctx_init_custom(struct dmctx *ctx, unsigned int instance_mode, DMOBJ *tEntryObj, int custom)
static int dm_ctx_init_custom(struct dmctx *ctx, unsigned int instance_mode, DMOBJ *tEntryObj,
DM_MAP_VENDOR *tVendorExtension[], DM_MAP_VENDOR_EXCLUDE *tVendorExtensionExclude, int custom)
{
if (custom == CTX_INIT_ALL)
bbf_uci_init();
@ -143,6 +138,9 @@ static int dm_ctx_init_custom(struct dmctx *ctx, unsigned int instance_mode, DMO
INIT_LIST_HEAD(&ctx->list_fault_param);
ctx->instance_mode = instance_mode;
ctx->dm_entryobj = tEntryObj;
ctx->dm_vendor_extension[0] = tVendorExtension ? tVendorExtension[0] : NULL;
ctx->dm_vendor_extension[1] = tVendorExtension ? tVendorExtension[1] : NULL;
ctx->dm_vendor_extension_exclude = tVendorExtensionExclude;
ctx->dm_version = DEFAULT_DMVERSION;
return 0;
}
@ -165,19 +163,15 @@ void dm_config_ubus(struct ubus_context *ctx)
dmubus_configure(ctx);
}
int dm_ctx_init_entry(struct dmctx *ctx, DMOBJ *tEntryObj, unsigned int instance_mode)
int dm_ctx_init_entry(struct dmctx *ctx, DMOBJ *tEntryObj, DM_MAP_VENDOR *tVendorExtension[], DM_MAP_VENDOR_EXCLUDE *tVendorExtensionExclude, unsigned int instance_mode)
{
return dm_ctx_init_custom(ctx, instance_mode, tEntryObj, CTX_INIT_ALL);
return dm_ctx_init_custom(ctx, instance_mode, tEntryObj, tVendorExtension, tVendorExtensionExclude, CTX_INIT_ALL);
}
int dm_ctx_init(struct dmctx *ctx, unsigned int instance_mode)
int dm_ctx_init(struct dmctx *ctx, DMOBJ *tEntryObj, DM_MAP_VENDOR *tVendorExtension[], DM_MAP_VENDOR_EXCLUDE *tVendorExtensionExclude, unsigned int instance_mode)
{
#ifdef BBF_TR181
dmubus_clean_endlife_entries();
return dm_ctx_init_custom(ctx, instance_mode, tEntry181Obj, CTX_INIT_ALL);
#else
return 0;
#endif /* BBF_TR181 */
return dm_ctx_init_custom(ctx, instance_mode, tEntryObj, tVendorExtension, tVendorExtensionExclude, CTX_INIT_ALL);
}
int dm_ctx_clean(struct dmctx *ctx)
@ -192,13 +186,9 @@ int dm_ctx_init_cache(int time)
return 0;
}
int dm_ctx_init_sub(struct dmctx *ctx, unsigned int instance_mode)
int dm_ctx_init_sub(struct dmctx *ctx, DMOBJ *tEntryObj, DM_MAP_VENDOR *tVendorExtension[], DM_MAP_VENDOR_EXCLUDE *tVendorExtensionExclude, unsigned int instance_mode)
{
#ifdef BBF_TR181
return dm_ctx_init_custom(ctx, instance_mode, tEntry181Obj, CTX_INIT_SUB);
#else
return 0;
#endif /* BBF_TR181 */
return dm_ctx_init_custom(ctx, instance_mode, tEntryObj, tVendorExtension, tVendorExtensionExclude, CTX_INIT_SUB);
}
int dm_ctx_clean_sub(struct dmctx *ctx)
@ -380,7 +370,7 @@ int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, cha
if (!param || !linker || *linker == 0)
return 0;
dm_ctx_init_sub(&dmctx, ctx->instance_mode);
dm_ctx_init_sub(&dmctx, ctx->dm_entryobj, ctx->dm_vendor_extension, ctx->dm_vendor_extension_exclude, ctx->instance_mode);
dmctx.in_param = param;
dmctx.linker = linker;
@ -402,7 +392,7 @@ int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value)
snprintf(linker, sizeof(linker), "%s%c", param, (param[DM_STRLEN(param) - 1] != '.') ? '.' : '\0');
dm_ctx_init_sub(&dmctx, ctx->instance_mode);
dm_ctx_init_sub(&dmctx, ctx->dm_entryobj, ctx->dm_vendor_extension, ctx->dm_vendor_extension_exclude, ctx->instance_mode);
dmctx.in_param = linker;
dm_entry_get_linker_value(&dmctx);
@ -453,7 +443,7 @@ int dm_entry_manage_services(struct blob_buf *bb, bool restart)
}
blobmsg_close_array(bb, arr);
bbf_uci_commit_bbfdm();
dmuci_commit_bbfdm();
free_all_list_package_change(&head_package_change);
return 0;
@ -463,7 +453,7 @@ int dm_entry_restart_services(void)
{
struct package_change *pc = NULL;
bbf_uci_commit_bbfdm();
dmuci_commit_bbfdm();
list_for_each_entry(pc, &head_package_change, list) {
dmubus_call_set("uci", "commit", UBUS_ARGS{{"config", pc->package, String}}, 1);
@ -478,7 +468,7 @@ int dm_entry_revert_changes(void)
{
struct package_change *pc = NULL;
bbf_uci_revert_bbfdm();
dmuci_revert_bbfdm();
list_for_each_entry(pc, &head_package_change, list) {
dmubus_call_set("uci", "revert", UBUS_ARGS{{"config", pc->package, String}}, 1);
@ -574,7 +564,7 @@ static void load_dynamic_arrays(struct dmctx *ctx)
#ifdef BBFDM_ENABLE_JSON_PLUGIN
// Load dynamic objects and parameters exposed via a JSON file
if (check_stats_folder(true)) {
free_json_dynamic_arrays(tEntry181Obj);
free_json_dynamic_arrays(ctx->dm_entryobj);
load_json_dynamic_arrays(ctx);
}
#endif /* BBFDM_ENABLE_JSON_PLUGIN */
@ -582,7 +572,7 @@ static void load_dynamic_arrays(struct dmctx *ctx)
#ifdef BBFDM_ENABLE_DOTSO_PLUGIN
// Load dynamic objects and parameters exposed via a library
if (check_stats_folder(false)) {
free_library_dynamic_arrays(tEntry181Obj);
free_library_dynamic_arrays(ctx->dm_entryobj);
load_library_dynamic_arrays(ctx);
}
#endif /* BBFDM_ENABLE_DOTSO_PLUGIN */
@ -590,40 +580,36 @@ static void load_dynamic_arrays(struct dmctx *ctx)
#ifdef BBF_VENDOR_EXTENSION
// Load objects and parameters exposed via vendor extension
if (first_boot == false) {
free_vendor_dynamic_arrays(tEntry181Obj);
free_vendor_dynamic_arrays(ctx->dm_entryobj);
load_vendor_dynamic_arrays(ctx);
first_boot = true;
}
#endif
}
static void free_dynamic_arrays(void)
static void free_dynamic_arrays(DMOBJ *tEntryObj)
{
#ifdef BBF_TR181
DMOBJ *root = tEntry181Obj;
DMNODE node = {.current_object = ""};
#ifdef BBFDM_ENABLE_JSON_PLUGIN
free_json_dynamic_arrays(tEntry181Obj);
free_json_dynamic_arrays(tEntryObj);
#endif /* BBFDM_ENABLE_JSON_PLUGIN */
#ifdef BBFDM_ENABLE_DOTSO_PLUGIN
free_library_dynamic_arrays(tEntry181Obj);
free_library_dynamic_arrays(tEntryObj);
#endif /* BBFDM_ENABLE_DOTSO_PLUGIN */
#ifdef BBF_VENDOR_EXTENSION
free_vendor_dynamic_arrays(tEntry181Obj);
free_vendor_dynamic_arrays(tEntryObj);
#endif
free_dm_browse_node_dynamic_object_tree(&node, root);
#endif /* BBF_TR181 */
free_dm_browse_node_dynamic_object_tree(&node, tEntryObj);
}
void bbf_dm_cleanup(void)
void bbf_dm_cleanup(DMOBJ *tEntryObj)
{
dmubus_free();
dm_dynamic_cleanmem(&main_memhead);
free_dynamic_arrays();
free_dynamic_arrays(tEntryObj);
}
void dm_cleanup_dynamic_entry(DMOBJ *root)
@ -633,3 +619,10 @@ void dm_cleanup_dynamic_entry(DMOBJ *root)
dm_dynamic_cleanmem(&main_memhead);
free_dm_browse_node_dynamic_object_tree(&node, root);
}
int set_bbfdatamodel_type(int bbf_type)
{
bbfdatamodel_type = bbf_type;
return 0;
}

View file

@ -15,7 +15,7 @@
#ifndef __DMENTRY_H__
#define __DMENTRY_H__
#include "libbbf_api/dmcommon.h"
#include "dmcommon.h"
extern struct list_head head_package_change;
extern struct list_head main_memhead;
@ -31,9 +31,9 @@ typedef enum {
COMMAND_ONLY
} schema_type_t;
int dm_ctx_init(struct dmctx *ctx, unsigned int instance_mode);
int dm_ctx_init_sub(struct dmctx *ctx, unsigned int instance_mode);
int dm_ctx_init_entry(struct dmctx *ctx, DMOBJ tEntryObj[], unsigned int instance_mode);
int dm_ctx_init(struct dmctx *ctx, DMOBJ *tEntryObj, DM_MAP_VENDOR *tVendorExtension[], DM_MAP_VENDOR_EXCLUDE *tVendorExtensionExclude, unsigned int instance_mode);
int dm_ctx_init_sub(struct dmctx *ctx, DMOBJ *tEntryObj, DM_MAP_VENDOR *tVendorExtension[], DM_MAP_VENDOR_EXCLUDE *tVendorExtensionExclude, unsigned int instance_mode);
int dm_ctx_init_entry(struct dmctx *ctx, DMOBJ *tEntryObj, DM_MAP_VENDOR *tVendorExtension[], DM_MAP_VENDOR_EXCLUDE *tVendorExtensionExclude, unsigned int instance_mode);
int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, char *arg2);
int dm_entry_apply(struct dmctx *ctx, int cmd);
int dm_entry_restart_services(void);
@ -45,7 +45,7 @@ int dm_ctx_clean_sub(struct dmctx *ctx);
int dm_get_supported_dm(struct dmctx *ctx, char *path, bool first_level, schema_type_t schema_type);
void dm_config_ubus(struct ubus_context *ctx);
int dm_ctx_init_cache(int time);
void bbf_dm_cleanup(void);
void bbf_dm_cleanup(DMOBJ *tEntryObj);
/**
* @brief dm_debug_browse_path
@ -64,5 +64,6 @@ void bbf_dm_cleanup(void);
*/
int dm_debug_browse_path(char *buff, size_t len);
void dm_cleanup_dynamic_entry(DMOBJ *root);
int set_bbfdatamodel_type(int bbf_type);
#endif

111
libbbf_dm/CMakeLists.txt Normal file
View file

@ -0,0 +1,111 @@
cmake_minimum_required(VERSION 3.0)
PROJECT(libbbf_dm)
ADD_DEFINITIONS(-Wall -Werror)
ADD_DEFINITIONS(-D_GNU_SOURCE)
ADD_DEFINITIONS(-DBBF_VENDOR_PREFIX="${BBF_VENDOR_PREFIX}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SOURCE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree")
OPTION(BBF_TR181 "build with tr181 datamodel" ON)
OPTION(BBF_TR104 "build with tr104 datamodel" ON)
OPTION(BBF_TR143 "build with tr143 datamodel" ON)
OPTION(BBF_TR471 "build with tr471 datamodel" ON)
OPTION(BBF_VENDOR_EXTENSION "build with vendor extension enabled" ON)
OPTION(WITH_WOLFSSL "build with lib wolfssl" OFF)
OPTION(WITH_OPENSSL "build with lib openssl" OFF)
OPTION(WITH_MBEDTLS "build with lib mbedtls" OFF)
IF(NOT WITH_WOLFSSL AND NOT WITH_OPENSSL AND NOT WITH_MBEDTLS)
MESSAGE(FATAL_ERROR "You must enable one of the SSL libraries: {'WOLFSSL','OPENSSL','MBEDTLS'}")
ENDIF()
SET(BBF_DM_SOURCES dmdiagnostics.c)
IF(BBF_TR181)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr181")
FILE(GLOB BBF_TR181_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr181/*.c)
add_compile_definitions(BBF_TR181)
ENDIF(BBF_TR181)
IF(BBF_TR104)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr104")
FILE(GLOB BBF_TR104_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr104/*.c)
add_compile_definitions(BBF_TR104)
ENDIF(BBF_TR104)
IF(BBF_TR143)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr143")
FILE(GLOB BBF_TR143_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr143/*.c)
add_compile_definitions(BBF_TR143)
ENDIF(BBF_TR143)
IF(BBF_TR471)
IF(NOT BBF_TR143)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr143")
FILE(GLOB BBF_TR143_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr143/diagnostics.c)
ENDIF()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr471")
FILE(GLOB BBF_TR471_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/tr471/*.c)
add_compile_definitions(BBF_TR471)
ENDIF(BBF_TR471)
IF(WITH_WOLFSSL)
SET(SSL_LIBS wolfssl)
add_compile_definitions(LWOLFSSL)
ENDIF(WITH_WOLFSSL)
IF(WITH_OPENSSL)
SET(SSL_LIBS ssl)
add_compile_definitions(LOPENSSL)
ENDIF(WITH_OPENSSL)
IF(WITH_MBEDTLS)
SET(SSL_LIBS mbedtls)
add_compile_definitions(LMBEDTLS)
ENDIF(WITH_MBEDTLS)
IF(BBF_VENDOR_EXTENSION)
SET(BBF_VENDOR_EXTENSION_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/vendor/vendor.c)
ADD_DEFINITIONS(-DBBF_VENDOR_LIST="${BBF_VENDOR_LIST}")
add_compile_definitions(BBF_VENDOR_EXTENSION)
SET(BBF_VENDOR_LIST "iopsys" CACHE STRING "vendor list to be used")
STRING(REPLACE "," ";" VENDOR_LIST ${BBF_VENDOR_LIST})
foreach(VENDOR IN LISTS VENDOR_LIST)
FILE(GLOB_RECURSE BBF_VENDOR_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dmtree/vendor/${VENDOR}/*.c)
LIST(APPEND BBF_VENDOR_EXTENSION_SOURCES ${BBF_VENDOR_SOURCES})
STRING(TOUPPER ${VENDOR} VENDOR)
add_compile_definitions(BBF_VENDOR_${VENDOR})
endforeach()
ENDIF(BBF_VENDOR_EXTENSION)
ADD_LIBRARY(bbf_dm SHARED ${BBF_DM_SOURCES} ${BBF_TR181_SOURCES} ${BBF_TR104_SOURCES} ${BBF_TR143_SOURCES} ${BBF_TR471_SOURCES} ${BBF_VENDOR_EXTENSION_SOURCES})
TARGET_LINK_LIBRARIES(bbf_dm uci ubus ubox json-c blobmsg_json curl bbf_api ${SSL_LIBS})
INSTALL(TARGETS bbf_dm
LIBRARY DESTINATION usr/lib)
INSTALL(DIRECTORY DESTINATION etc/bbfdm)
INSTALL(DIRECTORY DESTINATION etc/bbfdm/dmmap)
INSTALL(DIRECTORY DESTINATION etc/bbfdm/json)
INSTALL(DIRECTORY DESTINATION usr/lib/bbfdm)
FILE(GLOB root_device dmtree/tr181/device.h dmtree/vendor/vendor.h)
INSTALL(FILES ${root_device}
DESTINATION usr/include/libbbf_dm
)
IF(BBF_TR143)
INSTALL(DIRECTORY DESTINATION usr/share/bbfdm)
FILE(GLOB scripts scripts/*)
INSTALL(FILES ${scripts}
PERMISSIONS OWNER_EXECUTE
DESTINATION usr/share/bbfdm
)
ENDIF(BBF_TR143)

View file

@ -27,7 +27,6 @@
#include <mbedtls/sha512.h>
#endif
#include "dmentry.h"
#include "dmdiagnostics.h"
#define READ_BUF_SIZE (1024 * 16)

View file

@ -10,7 +10,6 @@
*/
#include "dmdiagnostics.h"
#include "dmbbfcommon.h"
#include "diagnostics.h"
#ifdef BBF_TR471
#include "iplayercap.h"

View file

@ -9,7 +9,6 @@
*/
#include "dmdiagnostics.h"
#include "dmbbfcommon.h"
#include "dns.h"
/*************************************************************

View file

@ -9,7 +9,6 @@
*/
#include "gatewayinfo.h"
#include "dmbbfcommon.h"
static int get_manufacturer_oui(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{

View file

@ -8,7 +8,6 @@
* Author: Suvendhu Hansa <suvendhu.hansa@iopsys.eu>
*/
#include "include/libbbf_api.h"
#include "mqtt.h"
static bool duplicate_entry_exist(char *name, char *section_type)
@ -37,13 +36,13 @@ static int addMQTTBroker(char *refparam, struct dmctx *ctx, void *data, char **i
snprintf(sec_name, sizeof(sec_name), "broker_%s", *instance);
if (bbf_uci_add_section("mosquitto", "listener", &s) == 0) {
bbf_uci_rename_section(s, sec_name);
bbf_uci_set_value_by_section(s, "enabled", "0");
bbf_uci_set_value_by_section(s, "port", "1883");
bbf_uci_add_section_bbfdm("dmmap_mqtt", "listener", &dmmap_broker);
bbf_uci_set_value_by_section(dmmap_broker, "section_name", sec_name);
bbf_uci_set_value_by_section(dmmap_broker, "listener_instance", *instance);
if (dmuci_add_section("mosquitto", "listener", &s) == 0) {
dmuci_rename_section_by_section(s, sec_name);
dmuci_set_value_by_section(s, "enabled", "0");
dmuci_set_value_by_section(s, "port", "1883");
dmuci_add_section_bbfdm("dmmap_mqtt", "listener", &dmmap_broker);
dmuci_set_value_by_section(dmmap_broker, "section_name", sec_name);
dmuci_set_value_by_section(dmmap_broker, "listener_instance", *instance);
}
return 0;
@ -55,15 +54,15 @@ static int delMQTTBroker(char *refparam, struct dmctx *ctx, void *data, char *in
switch (del_action) {
case DEL_INST:
bbf_uci_delete_section_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
bbf_uci_delete_section_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
dmuci_delete_by_section(((struct dmmap_dup *)data)->config_section, NULL, NULL);
dmuci_delete_by_section(((struct dmmap_dup *)data)->dmmap_section, NULL, NULL);
break;
case DEL_ALL:
bbf_uci_foreach_sections_safe("mosquitto", "listener", stmp, s) {
uci_foreach_sections_safe("mosquitto", "listener", stmp, s) {
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_mqtt", "listener", section_name(s), &dmmap_section);
bbf_uci_delete_section_by_section(s, NULL, NULL);
bbf_uci_delete_section_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(s, NULL, NULL);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
}
break;
}
@ -96,14 +95,14 @@ static int browseMQTTBrokerInst(struct dmctx *dmctx, DMNODE *parent_node, void *
**************************************************************/
static int get_MQTT_BrokerNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int cnt = bbf_get_number_of_entries(ctx, data, instance, browseMQTTBrokerInst);
int cnt = get_number_of_entries(ctx, data, instance, browseMQTTBrokerInst);
dmasprintf(value, "%d", cnt);
return 0;
}
static int get_MQTTBroker_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bbf_uci_get_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "listener_alias", value);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "listener_alias", value);
if ((*value)[0] == '\0')
dmasprintf(value, "cpe-%s", instance);
return 0;
@ -117,7 +116,7 @@ static int set_MQTTBroker_Alias(char *refparam, struct dmctx *ctx, void *data, c
return FAULT_9007;
break;
case VALUESET:
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "listener_alias", value);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "listener_alias", value);
return 0;
}
return 0;
@ -125,7 +124,7 @@ static int set_MQTTBroker_Alias(char *refparam, struct dmctx *ctx, void *data, c
static int get_MQTTBroker_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = bbf_uci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enabled", "0");
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enabled", "0");
return 0;
}
@ -139,7 +138,7 @@ static int set_MQTTBroker_Enable(char *refparam, struct dmctx *ctx, void *data,
break;
case VALUESET:
string_to_bool(value, &b);
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "1" : "0");
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "1" : "0");
break;
}
return 0;
@ -147,7 +146,7 @@ static int set_MQTTBroker_Enable(char *refparam, struct dmctx *ctx, void *data,
static int get_MQTTBroker_Name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bbf_uci_get_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "section_name", value);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "section_name", value);
return 0;
}
@ -181,11 +180,11 @@ static int set_MQTTBroker_Name(char *refparam, struct dmctx *ctx, void *data, ch
break;
// Update mosquitto config
if (0 != bbf_uci_rename_section(((struct dmmap_dup *)data)->config_section, value))
if (0 != dmuci_rename_section_by_section(((struct dmmap_dup *)data)->config_section, value))
return FAULT_9001;
// Update dmmap_mqtt file
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "section_name", value);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "section_name", value);
break;
}
@ -194,7 +193,7 @@ static int set_MQTTBroker_Name(char *refparam, struct dmctx *ctx, void *data, ch
static int get_MQTTBroker_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bbf_uci_get_value_by_section(((struct dmmap_dup *)data)->config_section, "port", value);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "port", value);
return 0;
}
@ -206,7 +205,7 @@ static int set_MQTTBroker_Port(char *refparam, struct dmctx *ctx, void *data, ch
return FAULT_9007;
break;
case VALUESET:
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "port", value);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "port", value);
break;
}
return 0;
@ -216,7 +215,7 @@ static int get_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *dat
{
char *intf = NULL;
bbf_uci_get_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", &intf);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface", &intf);
if (DM_STRLEN(intf) == 0)
return 0;
@ -241,7 +240,7 @@ static int set_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *dat
case VALUESET:
adm_entry_get_linker_value(ctx, value, &iface);
if (DM_STRLEN(iface) != 0)
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", iface);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", iface);
break;
}
return 0;
@ -249,7 +248,7 @@ static int set_MQTTBroker_Interface(char *refparam, struct dmctx *ctx, void *dat
static int get_MQTTBroker_Username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bbf_uci_get_value_by_section(((struct dmmap_dup *)data)->config_section, "username", value);
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "username", value);
return 0;
}
@ -265,7 +264,7 @@ static int set_MQTTBroker_Username(char *refparam, struct dmctx *ctx, void *data
return FAULT_9007;
break;
case VALUESET:
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "username", value);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "username", value);
break;
}
return 0;
@ -285,7 +284,7 @@ static int set_MQTTBroker_Password(char *refparam, struct dmctx *ctx, void *data
return FAULT_9007;
break;
case VALUESET:
bbf_uci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "password", value);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "password", value);
break;
}
return 0;

Some files were not shown because too many files have changed in this diff Show more