Rebase with devel

This commit is contained in:
Vivek Kumar Dutta 2022-07-13 08:12:44 +00:00
parent 4226c94946
commit e6efede8c7
238 changed files with 123451 additions and 38468 deletions

10
.gitignore vendored
View file

@ -40,3 +40,13 @@ tools/__pycache__
*.gcno
*\.log
.libs
m4/
bbf_ubus
memory-report.xml
*.la
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
install_manifest.txt
*.so

View file

@ -2,16 +2,18 @@ include:
- project: 'iopsys/gitlab-ci-pipeline'
file: '/static-code-analysis.yml'
stages:
- static_code_analysis
- unit_test
- functional_test
- memory_test
- uspd
variables:
DEBUG: 'TRUE'
SOURCE_FOLDER: "."
COMMON_IMAGE: iopsys/code-analysis:0.27
RUN_CPPCHECK: "cppcheck --enable=information --error-exitcode=1 -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBFDM_ENABLE_DOTSO_PLUGIN -DBBF_TR181 -DBBF_VENDOR_IOPSYS -DBBF_VENDOR_OPENWRT --inline-suppr -i test/"
stages:
- static_code_analysis
- unit_test
- memory_test
- functional_test
- uspd
run_unit_test:
stage: unit_test
@ -76,28 +78,45 @@ run_memory_test:
script:
- "./gitlab-ci/setup.sh"
- "./gitlab-ci/memory-test.sh"
- echo "BBF_TAR_URL=${CI_JOB_URL}/artifacts/raw/build/libbbf-1.0.0-Linux.sh" >build.env
artifacts:
reports:
dotenv: build.env
when: always
paths:
- timestamp.log
- memory-report-usp-get.xml
- memory-report-usp-operate.xml
- memory-report-usp-schema.xml
- memory-report-usp-instances.xml
- memory-report-cwmp-get.xml
- memory-report-cwmp-operate.xml
- memory-report-cwmp-schema.xml
- memory-report-cwmp-instances.xml
- memory-test-coverage.xml
- build/libbbf-1.0.0-Linux.sh
doxygen:
stage: unit_test
image: iopsys/code-analysis:latest
before_script:
- apt update
- apt --assume-yes install doxygen graphviz
script:
- doxygen Doxyfile
- mv doxygen/html/ public/
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
run_uspd:
stage: uspd
inherit:
variables: false
variables:
UPSTREAM_BBF_SHA: $CI_COMMIT_SHA
SOURCE_FOLDER: "src"
BBF_TAR_URL: $BBF_TAR_URL
allow_failure: false
trigger:
project: iopsys/uspd
branch: bbf_pipeline
strategy: depend
needs:
job: run_memory_test
artifacts: true

138
CMakeLists.txt Normal file
View file

@ -0,0 +1,138 @@
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}")
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_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_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_DOTSO_PLUGIN_SOURCES}
${BBF_JSON_PLUGIN_SOURCES}
${BBF_VENDOR_EXTENSION_SOURCES})
TARGET_LINK_LIBRARIES(bbfdm uci ubus ubox json-c blobmsg_json trace 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}
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)

2533
Doxyfile Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,10 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
libbbfdm_includedir = $(includedir)/libbbfdm
libbbf_api_includedir = $(includedir)/libbbf_api
libbbfdm_tr181_includedir = $(libbbfdm_includedir)
libbbfdm_include_HEADERS = *.h
libbbf_api_include_HEADERS = libbbf_api/*.h
SUBDIRS = bin

458
README.md
View file

@ -1,6 +1,15 @@
# BroadBand Forum Data Models (BBFDM)
`bbfdm` is a data model library implementation which includes a list of objects, parameters and operates used for CPE management through remote control protocols such as [TR-069/CWMP](https://cwmp-data-models.broadband-forum.org/) or [TR-369/USP](https://usp.technology/).
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_api | This provides the APIs for UCI, Ubus, JSON, CLI and memory management. |
| libbbf_ubus | This library helps to expose the datamodel directly over ubus. Application can expose any datamodel(need not be part of "Device."/TR-181) using this library. |
Note: Applications that use libbbf_ubus to expose datamodel, not required to use libbbfdm.
## Design of bbfdm
@ -19,6 +28,7 @@
│   ├── openwrt
│   └── vendor.h
├── libbbf_api
├── libbbf_ubus
├── scripts
└── tools
```
@ -37,12 +47,19 @@
- `libbbf_api` folder which contains the source code of all API functions (UCI, Ubus, JSON, CLI and memory management)
- `libbbf_ubus` folder which contains the source code of all API functions helps in exposing datamodel directly over ubus
- `scripts` folder which contains the Diagnostics scripts
- `tools` folder which contains some tools to generate Data Model in C, JSON, XML and Excel format
- `dm...(.c and .h)` files which contains the `bbfdm` engine (operate, diagnostics) functions
More details available in below documents:
- [activate_firmware.md](./docs/activate_firmware.md)
- [firewall.md](./docs/firewall.md)
- [json_plugin_v1.md](./docs/json_plugin_v1.md)
## How to add support for a new Object/Parameter
As mentioned above, 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 rigth folder.
@ -222,140 +239,20 @@ In this function, there are two functions that need to be defined:
> Note3: you can use [bbf_test plugin](./test/bbf_test/bbf_test.c) as a reference in order to develop any new object/leaf/browse.
## BBF API
## LIBBBF API
`libbbf_api` is a library 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.
The most used one are as follow:
All APIs exposed by libbbf_api are presented in this header file [libbbf_api.h](./include/libbbf_api.h).
#### 1. dmuci_get_option_value_string: execute the uci get value
## LIBBBF UBUS
```bash
int dmuci_get_option_value_string(char *package, char *section, char *option, char **value)
```
**Argument:**
- **package:** package name
- **section:** section name
- **option:** option name
- **value:** the value of the returned option
`Libbbf_ubus` is a library that provides APIs to expose the datamodel constructed with the help of libbbf API over the ubus directly.
#### 2. dmuci_get_value_by_section_string: execute the uci get value
```bash
int dmuci_get_value_by_section_string(struct uci_section *s, char *option, char **value)
```
**Argument:**
- **section:** section name
- **option:** option name
- **value:** the value of the returned option
#### 3. uci_foreach_sections: browse all sections by package and section type
```bash
#define uci_foreach_sections(package, stype, section)
```
**Argument:**
- **package:** package name
- **stype:** section type to browse
- **section:** return section pointer for each loop iteration
#### 4. dmubus_call: execute the ubus call
```bash
int dmubus_call(char *obj, char *method, struct ubus_arg u_args[], int u_args_size, json_object **req_res)
```
**Argument:**
- **obj:** ubus obj
- **method:** ubus method
- **u_args:** ubus arguments
- **u_args_size:** number of ubus arguments
- **req_res:** the json message of the ubus call
#### 5. dmubus_call_set: set the ubus call
```bash
int dmubus_call_set(char *obj, char *method, struct ubus_arg u_args[], int u_args_size);
```
**Argument:**
- **obj:** ubus obj
- **method:** ubus method
- **u_args: ubus** arguments
- **u_args_size:** number of ubus arguments
#### 6. handle_instance: allow to retrieve/attribute the instances from uci config sections
```bash
char *handle_instance(struct dmctx *dmctx, DMNODE *parent_node, struct uci_section *s, char *inst_opt, char *alias_opt);
```
**Argument:**
- **dmctx:** the current dmctx struct passed when calling this object
- **parent_node:** the current node struct passed when calling this object
- **s:** the uci section used to get the instance
- **inst_opt:** the option name of the instance number used for this object
- **alias_opt:** the option name of the instance alias used for this object
#### 7. handle_instance_without_section: allow to attribute instances with constant values
```bash
char *handle_instance_without_section(struct dmctx *dmctx, DMNODE *parent_node, int inst_nbr);
```
**Argument:** the current dmctx struct passed when calling this object
- **dmctx:** the current dmctx struct passed when calling this object
- **parent_node:** the current node struct passed when calling this object
- **inst_nbr:** the instance to attribute for this object
#### 8. DM_LINK_INST_OBJ: link the instance to the data model tree
```bash
int DM_LINK_INST_OBJ(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance)
```
**Argument:**
- **dmctx:** the current dmctx struct passed when calling this object
- **parent_node:** the current node struct passed when calling this object
- **data:** the data transmitted for the next sub object and parameters that can be uci section, json object, or any type of data
- **instance:** the current instance used for this object
All APIs exposed by libbbf_ubus are presented in this header file [libbbf_ubus.h](./include/libbbf_ubus.h).
> Note1: For other funtions, please refer to dmuci, dmubus, dmjson, dmcommon and dmmem (.c and .h) files in the [link](https://dev.iopsys.eu/iopsys/bbf/-/tree/devel/libbbf_api)
> Note2: When developing a new parameters/features in the Data Model, it's highly recommended to use the memory management functions of `libbbf_api` allocate and free because it's freed at the end of each RPCs.
The list of memory management functions of `libbbf_api` are:
```bash
dmmalloc(x)
dmcalloc(n, x)
dmrealloc(x, n)
dmstrdup(x)
dmasprintf(s, format, ...)
dmastrcat(s, b, m)
dmfree(x)
```
> Note3: There are several APIs that have been deprecated and replaced with new ones. the table below summarizes them
| Deprecated API | New API |
| -------------------------------------- | -------------------------------------------------- |
| handle_update_instance | handle_instance or handle_instance_without_section |
| update_instance_alias | handle_instance |
| update_instance_without_section | handle_instance_without_section |
| update_instance | Not Used |
| get_last_instance_bbfdm | Not Used |
| get_last_instance | find_max_instance |
| get_last_instance_lev2_bbfdm_dmmap_opt | Not Used |
| get_last_instance_lev2_bbfdm | Not Used |
| is_section_unnamed | Not Used |
| delete_sections_save_next_sections | Not Used |
| update_dmmap_sections | Not Used |
| check_browse_section | Not Used |
| dmuci_delete_by_section_unnamed | dmuci_delete_by_section |
| dmuci_delete_by_section_unnamed_bbfdm | dmuci_delete_by_section |
> Note: Anyone wants to check out libbbf_api or libbbf_ubus APIs and how to use them, all documentation will be available in their header files [libbbf_api.h](./include/libbbf_api.h) and [libbbf_ubus.h](./include/libbbf_ubus.h).
## BBFDM Vendor
@ -436,7 +333,7 @@ BBF_VENDOR_PREFIX="X_TEST_COM_"
- The directory **'dmtree/vendor/test/'** contains an example of **test** vendor implementation
## BBFDM Dynamic Object/Parameter/Operate
## BBFDM Dynamic Object/Parameter/Operate/Event
`bbfdm` library allows all applications installed on the box to import its own Data Model parameters at run time in two formats:
@ -487,7 +384,8 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
"cwmp",
"usp"
],
"array": false
"array": false,
"access": false
}
```
@ -503,6 +401,7 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
"usp"
],
"array": true,
"access": true,
"mapping": {
"type": "uci",
"uci": {
@ -526,6 +425,7 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
"usp"
],
"array": true,
"access": false,
"mapping": {
"type": "ubus",
"ubus": {
@ -540,7 +440,7 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
**3. Parameter under object with instance:**
- **UCI command:** uci get wireless.@wifi-device[0].country
- **UCI option command:** uci get wireless.@wifi-device[0].country
- **@i:** is the number of instance object
@ -571,6 +471,42 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
}
```
- **UCI list command:** uci get urlfilter.@profile[0].whitelist_url
- **@i:** is the number of instance object
```bash
"WhitelistURL": {
"type": "string",
"version": "2.14",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"list": {
"datatype": "string"
},
"mapping": [
{
"type": "uci",
"uci": {
"file": "urlfilter",
"section": {
"type": "profile",
"index": "@i-1"
},
"list": {
"name": "whitelist_url"
}
}
}
]
}
```
- **UBUS command:** ubus call wifi status | jsonfilter -e @.radios[0].noise
- **@i:** is the number of instance object
@ -600,7 +536,7 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
**4. Parameter without instance:**
- **UCI command:** uci get cwmp.cpe.userid
- **UCI option command:** uci get cwmp.cpe.userid
```bash
"Username": {
@ -629,6 +565,39 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
}
```
- **UCI list command:** uci get urlfilter.globals.blacklist_url
- **@i:** is the number of instance object
```bash
"BlacklistURL": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"list": {
"datatype": "string"
},
"mapping": [
{
"type": "uci",
"uci": {
"file": "urlfilter",
"section": {
"name": "globals"
},
"list": {
"name": "blacklist_url"
}
}
}
]
}
```
- **UBUS command:** ubus call system info | jsonfilter -e @.uptime
```bash
@ -679,6 +648,163 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
}
```
**5. Parameter to map another data model Object:**
- **UCI option command:** uci get urlfilter.@filter[0].profile
- **linker_obj** is the path name of an object that is stacked immediately below this object
```bash
"Profile": {
"type": "string",
"read": true,
"write": true,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "urlfilter",
"section": {
"type": "filter",
"index": "@i-1"
},
"option": {
"name": "profile"
}
},
"linker_obj": "Device.{BBF_VENDOR_PREFIX}URLFilter.Profile."
}
]
}
```
**6. Object with Event and Operate command:**
```bash
{
"Device.X_IOPSYS_Test.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"array": false,
"access": false,
"Push!": {
"type": "event",
"version": "2.13",
"protocols": [
"usp"
],
"data": {
"type": "string",
"read": true,
"write": true,
"version": "2.13",
"protocols": [
"usp"
]
}
},
"Status()": {
"type": "command",
"async": true,
"version": "2.12",
"protocols": [
"usp"
],
"input": {
"Option": {
"type": "string",
"read": "true",
"write": "true",
"protocols": [
"usp"
]
}
},
"output": {
"Result": {
"type": "string",
"read": "true",
"write": "false",
"protocols": [
"usp"
]
}
},
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "test",
"method": "status"
}
}
]
}
}
}
```
- **UBUS command:** ubus call usp operate '{"path":"Device.X_IOPSYS_Test.", "action":"Status()", "input":{"Option":"Last"}}'
```bash
{
"Results": [
{
"path": "Device.X_IOPSYS_Test.Status()",
"result": [
{
"Result": "Success"
}
]
}
]
}
```
- **UBUS command:** ubus call usp get_supported_dm
```bash
{
"parameters": [
{
"parameter": "Device.X_IOPSYS_Test.Push!",
"type": "xsd:event",
"in": [
"data"
]
},
...
]
}
```
- **UBUS command:** ubus call usp list_operate
```bash
{
"parameters": [
{
"parameter": "Device.X_IOPSYS_Test.Status()",
"type": "async",
"in": [
"Option"
],
"out": [
"Result"
]
},
...
]
}
```
> Note1: JSON File can only add vendor or standard objects that are not implemented by `libbbfdm`
> Note2: JSON File is not allowed to overwrite objects/parameters
@ -687,7 +813,7 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
> Note4: Each object definition in JSON file must begin with "Device." and should have the full parent path if it is under another object
- For more examples on JSON files, you can see these links: [X_IOPSYS_EU_MCPD](https://dev.iopsys.eu/feed/broadcom/-/blob/devel/mcpd/files/etc/bbfdm/json/X_IOPSYS_EU_MCPD.json), [UserInterface](/test/files/etc/bbfdm/json/UserInterface.json), [X_IOPSYS_EU_Dropbear](/test/files/etc/bbfdm/json/X_IOPSYS_EU_Dropbear.json)
- For more examples on JSON files, you can see these links: [X_IOPSYS_EU_MCPD](https://dev.iopsys.eu/feed/broadcom/-/blob/devel/mcpd/files/etc/bbfdm/json/X_IOPSYS_EU_MCPD.json), [UserInterface](/test/files/etc/bbfdm/json/UserInterface.json), [X_IOPSYS_EU_Dropbear](/test/files/etc/bbfdm/json/X_IOPSYS_EU_Dropbear.json), [X_IOPSYS_EU_TEST](/test/files/etc/bbfdm/json/X_IOPSYS_EU_TEST.json)
## BBFDM Tools
BBF tools are written in python3 and has below dependencies.
@ -709,6 +835,7 @@ $ pip3 install jsonschema xlwt
|generate_dm.py | Generate list of supported/un-supported parameters based of json input|
|generate_dm_xml.py | Generate list of supported/un-supported parameters in xml format |
|generate_dm_excel.py | Generate list of supported/un-supported parameters in xls format |
|validate_json_plugin.py | Validate json plugin files for dynamic library or standard data model |
> Note: Currently all the tools needs to be executed in tools directory.
@ -719,14 +846,14 @@ It is a [python script](./tools/convert_dm_xml_to_json.py) to convert Data Model
$ ./convert_dm_xml_to_json.py
Usage: ./convert_dm_xml_to_json.py <tr-xxx cwmp xml data model> <tr-xxx usp xml data model> [Object path]
Examples:
- ./convert_dm_xml_to_json.py tr-181-2-14-1-cwmp-full.xml tr-181-2-14-1-usp-full.xml Device.
- ./convert_dm_xml_to_json.py tr-181-2-15-0-cwmp-full.xml tr-181-2-15-0-usp-full.xml Device.
==> Generate the json file of the sub tree Device. in tr181.json
- ./convert_dm_xml_to_json.py tr-104-2-0-2-cwmp-full.xml tr-104-2-0-2-usp-full.xml Device.Services.VoiceService.
==> Generate the json file of the sub tree Device.Services.VoiceService. in tr104.json
- ./convert_dm_xml_to_json.py tr-106-1-2-0-full.xml Device.
==> Generate the json file of the sub tree Device. in tr106.json
Example of xml data model file: https://www.broadband-forum.org/cwmp/tr-181-2-14-1-cwmp-full.xml
Example of xml data model file: https://www.broadband-forum.org/cwmp/tr-181-2-15-0-cwmp-full.xml
```
### XML generator
@ -735,14 +862,14 @@ Example of xml data model file: https://www.broadband-forum.org/cwmp/tr-181-2-14
```bash
$ ./generate_dm_xml.py -h
usage: generate_dm_xml.py [-h] [-r https://dev.iopsys.eu/iopsys/stunc.git^devel] [-v iopsys] [-p X_IOPSYS_EU_] [-d DEVICE_PROTOCOL_DSLFTR069v1] [-m iopsys] [-u 002207] [-c DG400PRIME] [-n DG400PRIME-A]
usage: generate_dm_xml.py [-h] [-r git^https://dev.iopsys.eu/iopsys/stunc.git^devel] [-v iopsys] [-p X_IOPSYS_EU_] [-d DEVICE_PROTOCOL_DSLFTR069v1] [-m iopsys] [-u 002207] [-c DG400PRIME] [-n DG400PRIME-A]
[-s 1.2.3.4] [-f BBF] [-o datamodel.xml]
Script to generate list of supported and non-supported parameter in xml format
optional arguments:
-h, --help show this help message and exit
-r https://dev.iopsys.eu/iopsys/stunc.git^devel, --remote-dm https://dev.iopsys.eu/iopsys/stunc.git^devel
-r git^https://dev.iopsys.eu/iopsys/stunc.git^devel, --remote-dm git^https://dev.iopsys.eu/iopsys/stunc.git^devel
Includes OBJ/PARAM defined under remote repositories defined as bbf plugin
-v iopsys, --vendor-list iopsys
Generate data model tree with vendor extension OBJ/PARAM.
@ -770,21 +897,25 @@ Part of BBF-tools, refer Readme for more examples
More examples:
```bash
$ ./generate_dm_xml.py -v iopsys -v openwrt
$ ./generate_dm_xml.py -v iopsys -p X_IOPSYS_EU_ -r git^https://dev.iopsys.eu/iopsys/stunc.git^devel
$ ./generate_dm_xml.py -f HDM -v iopsys -p X_IOPSYS_EU_ -o iopsys.xml
```
> Note: For the remote data model, *git* is the only proto allowed to use in the *generate_dm_xml.py* script. Therefore, if you want to use vendor extensions from a local repository, you must use the *generate_dm.py* script.
### Excel generator
[Python script](./tools/generate_dm_excel.py) to generat list of supported and un-supported parameters in excel sheet.
```bash
$ ./generate_dm_excel.py -h
usage: generate_dm_excel.py [-h] -d tr181 [-r https://dev.iopsys.eu/iopsys/stunc.git^devel] [-v iopsys] [-p X_IOPSYS_EU_] [-o supported_datamodel.xls]
usage: generate_dm_excel.py [-h] -d tr181 [-r git^https://dev.iopsys.eu/iopsys/stunc.git^devel] [-v iopsys] [-p X_IOPSYS_EU_] [-o supported_datamodel.xls]
Script to generate list of supported and non-supported parameter in xls format
optional arguments:
-h, --help show this help message and exit
-d tr181, --datamodel tr181
-r https://dev.iopsys.eu/iopsys/stunc.git^devel, --remote-dm https://dev.iopsys.eu/iopsys/stunc.git^devel
-r git^https://dev.iopsys.eu/iopsys/stunc.git^devel, --remote-dm git^https://dev.iopsys.eu/iopsys/stunc.git^devel
Includes OBJ/PARAM defined under remote repositories defined as bbf plugin
-v iopsys, --vendor-list iopsys
Generate data model tree with vendor extension OBJ/PARAM
@ -799,8 +930,18 @@ Part of BBF-tools, refer Readme for more examples
More examples:
```bash
$ ./generate_dm_excel.py -d tr181 -v iopsys -v openwrt -o datamodel.xls
$ ./generate_dm_excel.py -d tr181 -d tr104 -v iopsys -v openwrt -o datamodel.xls
$ ./generate_dm_excel.py -d tr181 -d tr104 -v iopsys -o datamodel.xls
$ ./generate_dm_excel.py -d tr181 -v iopsys -p X_IOPSYS_EU_ -r git^https://dev.iopsys.eu/iopsys/xmppc.git^devel -o datamodel_iopsys.xls
```
### Validate JSON plugin
It is a [python script](./tools/validate_json_plugin.py) to validate JSON plugin files for dynamic library or standard data model [TR181](./dmtree/json/tr181.json), [TR104](./dmtree/json/tr104.json), etc..
```bash
$ ./tools/validate_json_plugin.py test/files/etc/bbfdm/json/UserInterface.json
$ ./tools/validate_json_plugin.py test/files/etc/bbfdm/json/X_IOPSYS_EU_TEST.json
$ ./tools/validate_json_plugin.py dmtree/json/tr181.json
```
### Data Model generator
This is a pipeline friendly master script to generate the list of supported and un-supported datamodels in xml and xls formats based on provided input in a json file.
@ -832,6 +973,7 @@ The input json file should be defined as follow:
"plugins": [
{
"repo": "https://dev.iopsys.eu/iopsys/mydatamodel.git",
"proto": "git",
"version": "tag/hash/branch",
"dm_files": [
"src/datamodel.c",
@ -840,6 +982,7 @@ The input json file should be defined as follow:
},
{
"repo": "https://dev.iopsys.eu/iopsys/mybbfplugin.git",
"proto": "git",
"version": "tag/hash/branch",
"dm_files": [
"dm.c"
@ -847,10 +990,27 @@ The input json file should be defined as follow:
},
{
"repo": "https://dev.iopsys.eu/iopsys/mydatamodeljson.git",
"proto": "git",
"version": "tag/hash/branch",
"dm_files": [
"src/plugin/datamodel.json"
]
},
{
"repo": "/home/iopsys/sdk/mypackage/",
"proto": "local",
"dm_files": [
"src/datamodel.c",
"additional_datamodel.c"
]
},
{
"repo": "/src/feeds/mypackage/",
"proto": "local",
"dm_files": [
"datamodel.c",
"src/datamodel.json"
]
}
],
"output": {
@ -868,11 +1028,27 @@ The input json file should be defined as follow:
}
```
> Note1: For the local repository, you must use an absolute path as repo option.
> Note2: If proto is not defined in the json config file, then git is used by default as proto option.
- For more examples of tools input json file, you can see this link: [tools_input.json](./devel/tools/tools_input.json)
## Dependencies
# How to expose datamodel over ubus directly with the help of libbbf APIs
To successfully build libbbfdm, the following libraries are needed:
`Libbbf_ubus` is the library that helps in exposing the datamodel over ubus directly using libbbf_api.
Application using `libbbf_ubus`, shall not use the `libbbfdm` library because all needed operations from `libbbfdm` library has been internally handled in `libbbf_ubus`.
To identify the mechanism of exposing datamodel directly over ubus please refer to the sample code [dmtest.c](./test/dynamicdm_ubus_test/bbf_ubus.c)
For more info you can see the schemas at:
- Raw schema [link](./schemas/dmtest.json)
- Markdown schema [link](./docs/api/dmtest.md)
## Dependencies of of libbbfdm and libbbf_ubus
To successfully build libbbfdm or libbbf_ubus, the following libraries are needed:
| Dependency | Link | License |
| ----------- | ------------------------------------------- | -------------- |
@ -882,4 +1058,4 @@ To successfully build libbbfdm, the following libraries are needed:
| libjson-c | https://s3.amazonaws.com/json-c_releases | MIT |
| libcurl | https://dl.uxnr.de/mirror/curl | MIT |
| libtrace | https://github.com/apietila/libtrace.git | GPLv2 |
| libbbf_api | https://dev.iopsys.eu/iopsys/bbf.git | LGPL 2.1 |
| libwolfssl | https://github.com/wolfSSL/wolfssl | GPL-2.0 |

View file

@ -1,182 +0,0 @@
lib_LTLIBRARIES = libbbf_api.la
libbbf_api_la_SOURCES = \
../libbbf_api/dmbbf.c \
../libbbf_api/dmubus.c \
../libbbf_api/dmjson.c \
../libbbf_api/dmuci.c \
../libbbf_api/dmcommon.c \
../libbbf_api/dmmem.c
libbbf_api_la_CFLAGS = \
$(AM_CFLAGS) \
$(LIBUCI_CFLAGS) \
$(LIBUBOX_CFLAGS) \
$(LIBUBUS_CFLAGS)
libbbf_api_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(LIBUCI_LDFLAGS) \
$(LIBUBOX_LDFLAGS) \
$(LIBUBUS_LDFLAGS)
libbbf_api_la_LIBADD = \
$(AM_LIBS) \
$(LIBUCI_LIBS) \
$(LIBUBOX_LIBS) \
$(LIBUBUS_LIBS) \
$(LIBJSON_LIBS) \
$(LBLOBMSG_LIBS)
lib_LTLIBRARIES += libbbfdm.la
libbbfdm_la_SOURCES = \
../dmentry.c \
../dmdynamiclibrary.c \
../dmdynamicjson.c \
../dmdynamicmem.c \
../dmdiagnostics.c \
../dmbbfcommon.c
if BBF_TR181
libbbfdm_la_SOURCES += \
../dmtree/tr181/device.c \
../dmtree/tr181/deviceinfo.c \
../dmtree/tr181/managementserver.c \
../dmtree/tr181/times.c \
../dmtree/tr181/upnp.c \
../dmtree/tr181/wifi.c \
../dmtree/tr181/ethernet.c \
../dmtree/tr181/atm.c \
../dmtree/tr181/ptm.c \
../dmtree/tr181/bridging.c \
../dmtree/tr181/hosts.c \
../dmtree/tr181/dhcpv4.c \
../dmtree/tr181/ip.c \
../dmtree/tr181/ppp.c \
../dmtree/tr181/nat.c \
../dmtree/tr181/routing.c \
../dmtree/tr181/firewall.c \
../dmtree/tr181/dns.c \
../dmtree/tr181/users.c \
../dmtree/tr181/dhcpv6.c \
../dmtree/tr181/dsl.c \
../dmtree/tr181/fast.c \
../dmtree/tr181/interfacestack.c \
../dmtree/tr181/usb.c \
../dmtree/tr181/gre.c \
../dmtree/tr181/dynamicdns.c \
../dmtree/tr181/security.c \
../dmtree/tr181/lanconfigsecurity.c \
../dmtree/tr181/ieee1905.c \
../dmtree/tr181/qos.c \
../dmtree/tr181/routeradvertisement.c
endif #BBF_TR181
if BBF_TR104
libbbfdm_la_SOURCES += \
../dmtree/tr104/common.c \
../dmtree/tr104/servicesvoiceservicecalllog.c \
../dmtree/tr104/servicesvoiceservicesip.c \
../dmtree/tr104/servicesvoiceservice.c \
../dmtree/tr104/servicesvoiceservicecapabilities.c \
../dmtree/tr104/servicesvoiceservicepots.c \
../dmtree/tr104/servicesvoiceservicevoipprofile.c \
../dmtree/tr104/servicesvoiceservicecallcontrol.c \
../dmtree/tr104/servicesvoiceservicecodecprofile.c \
../dmtree/tr104/servicesvoiceservicereservedports.c \
../dmtree/tr104/servicesvoiceservicedect.c
endif #BBF_TR104
if BBF_TR143
libbbfdm_la_SOURCES += \
../dmtree/tr143/diagnostics.c
endif #BBF_TR143
if BBF_VENDOR_EXTENSION
libbbfdm_la_SOURCES += \
../dmdynamicvendor.c \
../dmtree/vendor/vendor.c
if BBF_VENDOR_IOPSYS
if BBF_TR181
libbbfdm_la_SOURCES += \
../dmtree/vendor/iopsys/tr181/vendor.c \
../dmtree/vendor/iopsys/tr181/device.c \
../dmtree/vendor/iopsys/tr181/deviceinfo.c \
../dmtree/vendor/iopsys/tr181/bridging.c \
../dmtree/vendor/iopsys/tr181/ethernet.c \
../dmtree/vendor/iopsys/tr181/times.c \
../dmtree/vendor/iopsys/tr181/x_iopsys_eu_igmp.c \
../dmtree/vendor/iopsys/tr181/x_iopsys_eu_mld.c
endif #BBF_TR181
if BBF_TR104
libbbfdm_la_SOURCES += \
../dmtree/vendor/iopsys/tr104/servicesvoiceservicecalllog.c \
../dmtree/vendor/iopsys/tr104/servicesvoiceservicedect.c
endif #BBF_TR104
endif #BBF_VENDOR_IOPSYS
if BBF_VENDOR_OPENWRT
if BBF_TR181
libbbfdm_la_SOURCES += \
../dmtree/vendor/openwrt/tr181/vendor.c \
../dmtree/vendor/openwrt/tr181/deviceinfo.c \
../dmtree/vendor/openwrt/tr181/qos.c
endif #BBF_TR181
endif #BBF_VENDOR_OPENWRT
if BBF_VENDOR_TEST
if BBF_TR181
libbbfdm_la_SOURCES += \
../dmtree/vendor/test/tr181/vendor.c \
../dmtree/vendor/test/tr181/deviceinfo.c \
../dmtree/vendor/test/tr181/firewall.c \
../dmtree/vendor/test/tr181/device.c \
../dmtree/vendor/test/tr181/x_test_com_dropbear.c
endif #BBF_TR181
endif #BBF_VENDOR_TEST
endif #BBF_VENDOR_EXTENSION
libbbfdm_la_CFLAGS = \
$(AM_CFLAGS) \
$(LIBUCI_CFLAGS) \
$(LIBUBOX_CFLAGS) \
$(LIBUBUS_CFLAGS)
libbbfdm_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(LIBUCI_LDFLAGS) \
$(LIBUBOX_LDFLAGS) \
$(LIBUBUS_LDFLAGS) \
$(LIBOPENSSL_LIBS) \
$(LIBMBETLS_LIBS)
libbbfdm_la_LIBADD = \
$(AM_LIBS) \
$(LIBUCI_LIBS) \
$(LIBUBOX_LIBS) \
$(LIBUBUS_LIBS) \
$(LIBJSON_LIBS) \
$(LIBTRACE_LIBS) \
$(LBLOBMSG_LIBS) \
$(LIBDLOPEN_LIBS) \
$(LIBCURL_LIBS) \
$(LIBOPENSSL_LIBS) \
$(LIBCRYPTO_LIBS) \
-lbbf_api
libbbfdm_la_CFLAGS+=-I../
libbbfdm_la_CFLAGS+=-I../dmtree
libbbfdm_la_CFLAGS+=-I../dmtree/tr181
libbbfdm_la_CFLAGS+=-I../dmtree/tr104
libbbfdm_la_CFLAGS+=-I../dmtree/tr143

View file

@ -1,126 +0,0 @@
AC_INIT([libbbfdm], [0.1], [mohamed.kallel@pivasoftware.com])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_ARG_ENABLE(tr181, [AS_HELP_STRING([--enable-tr181], [enable tr181 device feature])], AC_DEFINE(BBF_TR181),)
AM_CONDITIONAL([BBF_TR181],[test "x$enable_tr181" = "xyes"])
AC_ARG_ENABLE(tr104, [AS_HELP_STRING([--enable-tr104], [enable tr104 voice feature])], AC_DEFINE(BBF_TR104),)
AM_CONDITIONAL([BBF_TR104],[test "x$enable_tr104" = "xyes"])
AC_ARG_ENABLE(tr143, [AS_HELP_STRING([--enable-tr143], [enable tr143 diagnostics feature])], AC_DEFINE(BBF_TR143),)
AM_CONDITIONAL([BBF_TR143],[test "x$enable_tr143" = "xyes"])
AC_ARG_ENABLE(libopenssl, [AS_HELP_STRING([--enable-libopenssl], [enable libopenssl feature])], AC_DEFINE(LOPENSSL),)
AM_CONDITIONAL([LOPENSSL],[test "x$enable_libopenssl" = "xyes"])
AC_ARG_ENABLE(libmbedtls, [AS_HELP_STRING([--enable-libmbedtls], [enable libmbedtls upnp feature])], AC_DEFINE(LMBEDTLS),)
AM_CONDITIONAL([LMBEDTLS],[test "x$enable_libmbedtls" = "xyes"])
AC_ARG_ENABLE(vendor_extension, [AS_HELP_STRING([--enable-vendor-extension], [enable vendor extension])], AC_DEFINE(BBF_VENDOR_EXTENSION),)
AM_CONDITIONAL([BBF_VENDOR_EXTENSION],[test "x$enable_vendor_extension" = "xyes"])
AC_DEFINE_UNQUOTED(BBF_VENDOR_LIST, "$BBF_VENDOR_LIST")
AC_DEFINE_UNQUOTED(BBF_VENDOR_PREFIX, "$BBF_VENDOR_PREFIX")
case $BBF_VENDOR_LIST in
*openwrt*) vendor_openwrt=yes ;;&
*iopsys*) vendor_iopsys=yes ;;&
*test*) vendor_test=yes ;;&
*) ;;
esac
AM_CONDITIONAL([BBF_VENDOR_IOPSYS],[test "x$vendor_iopsys" = "xyes"])
AM_COND_IF([BBF_VENDOR_IOPSYS], [AC_DEFINE(BBF_VENDOR_IOPSYS)],)
AM_CONDITIONAL([BBF_VENDOR_OPENWRT],[test "x$vendor_openwrt" = "xyes"])
AM_COND_IF([BBF_VENDOR_OPENWRT], [AC_DEFINE(BBF_VENDOR_OPENWRT)],)
AM_CONDITIONAL([BBF_VENDOR_TEST],[test "x$vendor_test" = "xyes"])
AM_COND_IF([BBF_VENDOR_TEST], [AC_DEFINE(BBF_VENDOR_TEST)],)
# checks for programs
AC_PROG_CC
AM_PROG_CC_C_O
LT_INIT
AC_ENABLE_SHARED
LIBJSON_LIBS='-ljson-c'
AC_SUBST([LIBJSON_LIBS])
AC_ARG_WITH([uci-include-path],
[AS_HELP_STRING([--with-uci-include-path],
[location of the uci library headers])],
[LIBUCI_CFLAGS="-I$withval"])
AC_SUBST([LIBUCI_CFLAGS])
AC_ARG_WITH([uci-lib-path],
[AS_HELP_STRING([--with-uci-lib-path], [location of the uci library])], [LIBUCI_LDFLAGS="-L$withval"])
AC_SUBST([LIBUCI_LDFLAGS])
LIBUCI_LIBS='-luci'
AC_SUBST([LIBUCI_LIBS])
LIBTRACE_LIBS='-ltrace'
AC_SUBST([LIBTRACE_LIBS])
AC_ARG_WITH([libubox-include-path],
[AS_HELP_STRING([--with-libubox-include-path],
[location of the libubox library headers])],
[LIBUBOX_CFLAGS="-I$withval"])
AC_SUBST([LIBUBOX_CFLAGS])
AC_ARG_WITH([libubox-lib-path],
[AS_HELP_STRING([--with-libubox-lib-path], [location of the libubox library])], [LIBUBOX_LDFLAGS="-L$withval"])
AC_SUBST([LIBUBOX_LDFLAGS])
LIBUBOX_LIBS='-lubox'
AC_SUBST([LIBUBOX_LIBS])
AC_ARG_WITH([libubus-include-path],
[AS_HELP_STRING([--with-libubus-include-path],
[location of the libubus library headers])],
[LIBUBUS_CFLAGS="-I$withval"])
AC_SUBST([LIBUBUS_CFLAGS])
AC_ARG_WITH([libubus-lib-path],
[AS_HELP_STRING([--with-libubus-lib-path], [location of the libubus library])], [LIBUBOX_LDFLAGS="-L$withval"])
AC_SUBST([LIBUBUS_LDFLAGS])
LIBUBUS_LIBS='-lubus'
AC_SUBST([LIBUBUS_LIBS])
LBLOBMSG_LIBS='-lblobmsg_json'
AC_SUBST([LBLOBMSG_LIBS])
LIBDLOPEN_LIBS='-ldl'
AC_SUBST([LIBDLOPEN_LIBS])
LIBCURL_LIBS='-lcurl'
AC_SUBST([LIBCURL_LIBS])
LIBCRYPTO_LIBS='-lcrypto'
AC_SUBST([LIBCRYPTO_LIBS])
AM_COND_IF([LOPENSSL], [
LIBOPENSSL_LIBS='-lssl'
AC_SUBST([LIBOPENSSL_LIBS])
])
AM_COND_IF([LMBEDTLS], [
LIBMBETLS_LIBS='-lmbedtls'
AC_SUBST([LIBMBETLS_LIBS])
])
# checks for header files
AC_CHECK_HEADERS([stdlib.h string.h])
# checks for typedefs, structures, and compiler characteristics
AC_TYPE_UINT8_T
# Makefiles
AC_CONFIG_FILES([
Makefile
bin/Makefile
])
AC_OUTPUT

View file

@ -56,24 +56,28 @@ int get_dm_type(char *dm_str)
if (dm_str == NULL)
return DMT_STRING;
if (strcmp(dm_str, DMT_TYPE[DMT_STRING]) == 0)
if (DM_STRCMP(dm_str, DMT_TYPE[DMT_STRING]) == 0)
return DMT_STRING;
else if (strcmp(dm_str, DMT_TYPE[DMT_UNINT]) == 0)
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_UNINT]) == 0)
return DMT_UNINT;
else if (strcmp(dm_str, DMT_TYPE[DMT_INT]) == 0)
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_INT]) == 0)
return DMT_INT;
else if (strcmp(dm_str, DMT_TYPE[DMT_UNLONG]) == 0)
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_UNLONG]) == 0)
return DMT_UNLONG;
else if (strcmp(dm_str, DMT_TYPE[DMT_LONG]) == 0)
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_LONG]) == 0)
return DMT_LONG;
else if (strcmp(dm_str, DMT_TYPE[DMT_BOOL]) == 0)
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_BOOL]) == 0)
return DMT_BOOL;
else if (strcmp(dm_str, DMT_TYPE[DMT_TIME]) == 0)
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_TIME]) == 0)
return DMT_TIME;
else if (strcmp(dm_str, DMT_TYPE[DMT_HEXBIN]) == 0)
else if (DM_STRCMP(dm_str, DMT_TYPE[DMT_HEXBIN]) == 0)
return DMT_HEXBIN;
else if (strcmp(dm_str, DMT_TYPE[DMT_BASE64]) == 0)
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;

View file

@ -12,7 +12,7 @@
#ifndef __DMBBFCOMMON_H__
#define __DMBBFCOMMON_H__
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
#include "dmentry.h"
void bbf_uci_commit_bbfdm(void);

View file

@ -9,15 +9,33 @@
*
*/
#include <openssl/sha.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <libtrace.h>
#ifdef LOPENSSL
#include <openssl/sha.h>
#endif
#ifdef LWOLFSSL
#include <wolfssl/options.h>
#include <wolfssl/openssl/sha.h>
#endif
#ifdef LMBEDTLS
#include <mbedtls/sha1.h>
#include <mbedtls/sha256.h>
#include <mbedtls/sha512.h>
#endif
#include "dmentry.h"
#include "dmdiagnostics.h"
#define READ_BUF_SIZE (1024 * 16)
static int read_next;
static struct diagnostic_stats diag_stats = {0};
static const int READ_BUF_SIZE = { 1024 * 16 };
char *get_diagnostics_option(char *sec_name, char *option)
{
@ -57,25 +75,21 @@ void init_diagnostics_operation(char *sec_name, char *operation_path)
if (section)
dmuci_delete_by_section_bbfdm(section, NULL, NULL);
DMCMD("/bin/sh", 2, operation_path, "stop");
dmcmd("/bin/sh", 2, operation_path, "stop");
}
void set_diagnostics_interface_option(struct dmctx *ctx, char *sec_name, char *value)
{
char *linker = NULL;
if (value[0] == 0)
if (!value || *value == 0)
return;
if (strncmp(value, "Device.IP.Interface.", 20) != 0)
return;
adm_entry_get_linker_value(ctx, value, &linker);
if (linker && *linker) {
set_diagnostics_option(sec_name, "interface", linker);
dmfree(linker);
}
set_diagnostics_option(sec_name, "interface", linker ? linker : "");
}
static bool get_response_code_status(const char *url, int response_code)
@ -91,7 +105,7 @@ static bool get_response_code_status(const char *url, int response_code)
}
static void send_transfer_complete_event(const char *command, const char *obj_path, const char *transfer_url,
long res_code, time_t start_t, time_t complete_t, const char *transfer_type)
long res_code, 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};
@ -109,7 +123,10 @@ static void send_transfer_complete_event(const char *command, const char *obj_pa
struct json_object *obj = json_object_new_object();
json_object_object_add(obj, "Command", json_object_new_string(command));
json_object_object_add(obj, "CommandKey", json_object_new_string(""));
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));
@ -199,142 +216,216 @@ const bool validate_file_system_size(const char *file_size)
return true;
}
#if defined(LOPENSSL) || defined(LWOLFSSL)
#define SHA1_DLEN SHA_DIGEST_LENGTH
#define SHA1_CTX SHA_CTX
#define SHA1_UPDATE SHA1_Update
#define SHA1_FINAL SHA1_Final
#else
#define SHA1_DLEN (20)
#define SHA1_CTX mbedtls_sha1_context
#define SHA1_UPDATE mbedtls_sha1_update_ret
#define SHA1_FINAL(X, Y) mbedtls_sha1_finish_ret(Y, X)
#endif
const bool validate_sha1sum_value(const char *file_path, const char *checksum)
{
unsigned char hash[SHA_DIGEST_LENGTH];
unsigned char hash[SHA1_DLEN];
unsigned char buffer[READ_BUF_SIZE];
char sha1_res[1 + SHA_DIGEST_LENGTH * 2];
char sha1_res[1 + SHA1_DLEN * 2];
bool res = false;
int bytes = 0;
SHA_CTX ctx;
SHA1_CTX ctx;
FILE *file = fopen(file_path, "rb");
if (!file)
return false;
#if defined(LOPENSSL) || defined(LWOLFSSL)
if (!SHA1_Init(&ctx))
goto end;
#else
mbedtls_sha1_init(&ctx);
#endif
while ((bytes = fread (buffer, 1, sizeof(buffer), file))) {
if (!SHA1_Update(&ctx, buffer, bytes))
if (!SHA1_UPDATE(&ctx, buffer, bytes))
goto end;
}
if (!SHA1_Final(hash, &ctx))
if (!SHA1_FINAL(hash, &ctx))
goto end;
for (int i = 0; i < SHA_DIGEST_LENGTH; i++)
for (int i = 0; i < SHA1_DLEN; i++)
snprintf(&sha1_res[i * 2], sizeof(sha1_res) - (i * 2), "%02x", hash[i]);
if (strcmp(sha1_res, checksum) == 0)
if (DM_STRCMP(sha1_res, checksum) == 0)
res = true;
end:
fclose(file);
return res;
}
#if defined(LOPENSSL)
#define SHA224_DLEN SHA256_DIGEST_LENGTH
#define SHA224_CTX_t SHA256_CTX
#define SHA224_INIT SHA224_Init
#define SHA224_UPDATE SHA224_Update
#define SHA224_FINAL SHA224_Final
#elif defined(LWOLFSSL)
#define SHA224_DLEN SHA256_DIGEST_LENGTH
#define SHA224_CTX_t SHA256_CTX
#define SHA224_INIT SHA256_Init
#define SHA224_UPDATE SHA256_Update
#define SHA224_FINAL SHA256_Final
#else
#define SHA224_DLEN (32)
#define SHA224_CTX_t mbedtls_sha256_context
#define SHA224_UPDATE mbedtls_sha256_update_ret
#define SHA224_FINAL(X, Y) mbedtls_sha256_finish_ret(Y, X)
#endif
const bool validate_sha224sum_value(const char *file_path, const char *checksum)
{
unsigned char hash[SHA224_DIGEST_LENGTH];
unsigned char hash[SHA224_DLEN];
unsigned char buffer[READ_BUF_SIZE];
char sha224_res[1 + SHA224_DIGEST_LENGTH * 2];
char sha224_res[1 + SHA224_DLEN * 2];
bool res = false;
int bytes = 0;
SHA256_CTX ctx;
SHA224_CTX_t ctx;
FILE *file = fopen(file_path, "rb");
if (!file)
return false;
if (!SHA224_Init(&ctx))
#if defined(LOPENSSL) || defined(LWOLFSSL)
if (!SHA224_INIT(&ctx))
goto end;
#else
mbedtls_sha256_init(&ctx);
if (!mbedtls_sha256_starts_ret(&ctx, 1))
goto end;
#endif
while ((bytes = fread (buffer, 1, sizeof(buffer), file))) {
if (!SHA224_Update(&ctx, buffer, bytes))
if (!SHA224_UPDATE(&ctx, buffer, bytes))
goto end;
}
if (!SHA224_Final(hash, &ctx))
if (!SHA224_FINAL(hash, &ctx))
goto end;
for (int i = 0; i < SHA224_DIGEST_LENGTH; i++)
for (int i = 0; i < SHA224_DLEN; i++)
snprintf(&sha224_res[i * 2], sizeof(sha224_res) - (i * 2), "%02x", hash[i]);
if (strcmp(sha224_res, checksum) == 0)
if (DM_STRCMP(sha224_res, checksum) == 0)
res = true;
end:
fclose(file);
return res;
}
#if defined(LOPENSSL) || defined(LWOLFSSL)
#define SHA256_DLEN SHA256_DIGEST_LENGTH
#define SHA256_CTX_t SHA256_CTX
#define SHA256_UPDATE SHA256_Update
#define SHA256_FINAL SHA256_Final
#else
#define SHA256_DLEN (32)
#define SHA256_CTX_t mbedtls_sha256_context
#define SHA256_UPDATE mbedtls_sha256_update_ret
#define SHA256_FINAL(X, Y) mbedtls_sha256_finish_ret(Y, X)
#endif
const bool validate_sha256sum_value(const char *file_path, const char *checksum)
{
unsigned char hash[SHA256_DIGEST_LENGTH];
unsigned char hash[SHA256_DLEN];
unsigned char buffer[READ_BUF_SIZE];
char sha256_res[1 + SHA256_DIGEST_LENGTH * 2];
char sha256_res[1 + SHA256_DLEN * 2];
bool res = false;
int bytes = 0;
SHA256_CTX ctx;
SHA256_CTX_t ctx;
FILE *file = fopen(file_path, "rb");
if (!file)
return false;
#if defined(LOPENSSL) || defined(LWOLFSSL)
if (!SHA256_Init(&ctx))
goto end;
#else
mbedtls_sha256_init(&ctx);
if (!mbedtls_sha256_starts_ret(&ctx, 0))
goto end;
#endif
while ((bytes = fread (buffer, 1, sizeof(buffer), file))) {
if (!SHA256_Update(&ctx, buffer, bytes))
if (!SHA256_UPDATE(&ctx, buffer, bytes))
goto end;
}
if (!SHA256_Final(hash, &ctx))
if (!SHA256_FINAL(hash, &ctx))
goto end;
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
for (int i = 0; i < SHA256_DLEN; i++)
snprintf(&sha256_res[i * 2], sizeof(sha256_res) - (i * 2), "%02x", hash[i]);
if (strcmp(sha256_res, checksum) == 0)
if (DM_STRCMP(sha256_res, checksum) == 0)
res = true;
end:
fclose(file);
return res;
}
#if defined(LOPENSSL)
#define SHA384_DLEN SHA384_DIGEST_LENGTH
#define SHA384_CTX_t SHA512_CTX
#define SHA384_UPDATE SHA384_Update
#define SHA384_FINAL SHA384_Final
#elif defined(LWOLFSSL)
#define SHA384_DLEN SHA384_DIGEST_LENGTH
#define SHA384_CTX_t SHA384_CTX
#define SHA384_UPDATE SHA384_Update
#define SHA384_FINAL SHA384_Final
#else
#define SHA384_DLEN (64)
#define SHA384_CTX_t mbedtls_sha512_context
#define SHA384_UPDATE mbedtls_sha512_update_ret
#define SHA384_FINAL(X, Y) mbedtls_sha512_finish_ret(Y, X)
#endif
const bool validate_sha384sum_value(const char *file_path, const char *checksum)
{
unsigned char hash[SHA384_DIGEST_LENGTH];
unsigned char hash[SHA384_DLEN];
unsigned char buffer[READ_BUF_SIZE];
char sha384_res[1 + SHA384_DIGEST_LENGTH * 2];
char sha384_res[1 + SHA384_DLEN * 2];
bool res = false;
int bytes = 0;
SHA512_CTX ctx;
SHA384_CTX_t ctx;
FILE *file = fopen(file_path, "rb");
if (!file)
return false;
#if defined(LOPENSSL) || defined(LWOLFSSL)
if (!SHA384_Init(&ctx))
goto end;
#else
mbedtls_sha512_init(&ctx);
if (!mbedtls_sha512_starts_ret(&ctx, 1))
goto end;
#endif
while ((bytes = fread (buffer, 1, sizeof(buffer), file))) {
if (!SHA384_Update(&ctx, buffer, bytes))
if (!SHA384_UPDATE(&ctx, buffer, bytes))
goto end;
}
if (!SHA384_Final(hash, &ctx))
if (!SHA384_FINAL(hash, &ctx))
goto end;
for (int i = 0; i < SHA384_DIGEST_LENGTH; i++)
for (int i = 0; i < SHA384_DLEN; i++)
snprintf(&sha384_res[i * 2], sizeof(sha384_res) - (i * 2), "%02x", hash[i]);
if (strcmp(sha384_res, checksum) == 0)
if (DM_STRCMP(sha384_res, checksum) == 0)
res = true;
end:
@ -343,39 +434,55 @@ end:
return res;
}
#if defined(LOPENSSL) || defined(LWOLFSSL)
#define SHA512_DLEN SHA512_DIGEST_LENGTH
#define SHA512_CTX_t SHA512_CTX
#define SHA512_UPDATE SHA512_Update
#define SHA512_FINAL SHA512_Final
#else
#define SHA512_DLEN (64)
#define SHA512_CTX_t mbedtls_sha512_context
#define SHA512_UPDATE mbedtls_sha512_update_ret
#define SHA512_FINAL(X, Y) mbedtls_sha512_finish_ret(Y, X)
#endif
const bool validate_sha512sum_value(const char *file_path, const char *checksum)
{
unsigned char hash[SHA512_DIGEST_LENGTH];
unsigned char hash[SHA512_DLEN];
unsigned char buffer[READ_BUF_SIZE];
char sha512_res[1 + SHA512_DIGEST_LENGTH * 2];
char sha512_res[1 + SHA512_DLEN * 2];
bool res = false;
int bytes = 0;
SHA512_CTX ctx;
SHA512_CTX_t ctx;
FILE *file = fopen(file_path, "rb");
if (!file)
return false;
#if defined(LOPENSSL) || defined(LWOLFSSL)
if (!SHA512_Init(&ctx))
goto end;
#else
mbedtls_sha512_init(&ctx);
if (!mbedtls_sha512_starts_ret(&ctx, 0))
goto end;
#endif
while ((bytes = fread (buffer, 1, sizeof(buffer), file))) {
if (!SHA512_Update(&ctx, buffer, bytes))
if (!SHA512_UPDATE(&ctx, buffer, bytes))
goto end;
}
if (!SHA512_Final(hash, &ctx))
if (!SHA512_FINAL(hash, &ctx))
goto end;
for (int i = 0; i < SHA512_DIGEST_LENGTH; i++)
for (int i = 0; i < SHA512_DLEN; i++)
snprintf(&sha512_res[i * 2], sizeof(sha512_res) - (i * 2), "%02x", hash[i]);
if (strcmp(sha512_res, checksum) == 0)
if (DM_STRCMP(sha512_res, checksum) == 0)
res = true;
end:
fclose(file);
return res;
}
@ -417,7 +524,7 @@ int bbf_config_backup(const char *url, const char *username, const char *passwor
time_t complete_time = time(NULL);
// Send Transfer Complete Event
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, "Upload");
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time,NULL,"Upload");
// Check if the upload operation was successful
if (!get_response_code_status(url, res_code)) {
@ -444,7 +551,7 @@ int bbf_upload_log(const char *url, const char *username, const char *password,
time_t complete_time = time(NULL);
// Send Transfer Complete Event
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, "Upload");
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time,NULL, "Upload");
// Check if the upload operation was successful
if (!get_response_code_status(url, res_code)) {
@ -463,7 +570,7 @@ int bbf_config_restore(const char *url, const char *username, const char *passwo
// Check the file system size if there is sufficient space for downloading the config file
if (!validate_file_system_size(file_size)) {
res = -1;
goto end;
goto end;
}
// Download the firmware image
@ -472,7 +579,7 @@ int bbf_config_restore(const char *url, const char *username, const char *passwo
time_t complete_time = time(NULL);
// Send Transfer Complete Event
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, "Download");
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, NULL, "Download");
// Check if the download operation was successful
if (!get_response_code_status(url, res_code)) {
@ -500,9 +607,9 @@ end:
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 *bank_id, const char *command, const char *obj_path, const char *commandKey)
{
char fw_image_path[256] = "/tmp/firmware.bin";
char fw_image_path[256] = "/tmp/firmware-XXXXXX";
json_object *json_obj = NULL;
bool activate = false;
int res = 0;
@ -510,7 +617,15 @@ int bbf_fw_image_download(const char *url, const char *auto_activate, const char
// Check the file system size if there is sufficient space for downloading the firmware image
if (!validate_file_system_size(file_size)) {
res = -1;
goto end;
goto end;
}
res = mkstemp(fw_image_path);
if (res == -1) {
goto end;
} else {
close(res); // close the fd, as only filename required
res = 0;
}
// Download the firmware image
@ -518,8 +633,10 @@ int bbf_fw_image_download(const char *url, const char *auto_activate, const char
long res_code = download_file(fw_image_path, url, username, password);
time_t complete_time = time(NULL);
sync();
// Send Transfer Complete Event
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, "Download");
send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time,commandKey, "Download");
// Check if the download operation was successful
if (!get_response_code_status(url, res_code)) {
@ -533,64 +650,36 @@ int bbf_fw_image_download(const char *url, const char *auto_activate, const char
goto end;
}
string_to_bool((char *)auto_activate, &activate);
char *act = (activate) ? "1" : "0";
// Apply Firmware Image
dmubus_call("fwbank", "upgrade", UBUS_ARGS{{"path", fw_image_path, String}, {"auto_activate", auto_activate, Boolean}, {"bank", bank_id, Integer}}, 3, &json_obj);
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) {
if (json_obj == NULL) {
res = -1;
goto end;
}
// Reboot the device if auto activation is true
string_to_bool((char *)auto_activate, &activate);
if (activate) {
sleep(30); // Wait for the image to become available
if (dmubus_call_set("system", "reboot", UBUS_ARGS{}, 0) != 0)
if (dmubus_call_set("system", "reboot", UBUS_ARGS{0}, 0) != 0)
res = -1;
}
end:
// Remove temporary file
if (!json_obj && file_exists(fw_image_path) && strncmp(url, FILE_URI, strlen(FILE_URI)) && remove(fw_image_path))
// 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 void launch_activate_iamge_cb(struct uloop_timeout *t)
{
dmubus_call_set("system", "reboot", UBUS_ARGS{}, 0);
}
static void activate_fw_images(struct activate_image *active_img)
{
int i = 0;
for (i = 0; i < MAX_TIME_WINDOW && *active_img->start_time; i++, active_img++) {
active_img->activate_timer.cb = launch_activate_iamge_cb;
uloop_timeout_set(&active_img->activate_timer, atoi(active_img->start_time) * 1000);
}
}
int bbf_fw_image_activate(const char *bank_id, struct activate_image *active_img)
{
json_object *json_obj = NULL;
dmubus_call("fwbank", "set_bootbank", UBUS_ARGS{{"bank", bank_id, Integer}}, 1, &json_obj);
char *status = dmjson_get_value(json_obj, 1, "success");
if (strcmp(status, "true") != 0)
return -1;
if (*active_img->start_time) {
activate_fw_images(active_img);
} else {
if (dmubus_call_set("system", "reboot", UBUS_ARGS{}, 0) != 0)
return -1;
}
return 0;
}
static void libtrace_cleanup(libtrace_t *trace, libtrace_packet_t *packet)
{
if (trace)
@ -682,7 +771,7 @@ static void http_download_per_packet(libtrace_packet_t *packet)
diag_stats.test_bytes_received = strlen(nexthdr);
val += strlen("Content-Length: ");
pch = strtok_r(val, " \r\n\t", &pchr);
diag_stats.test_bytes_received += atoi(pch);
diag_stats.test_bytes_received += DM_STRTOL(pch);
diag_stats.first_data = 1;
return;
}
@ -707,23 +796,23 @@ static void ftp_download_per_packet(libtrace_packet_t *packet)
gmtime_r(&(ftp_download_ts.tv_sec), &ftp_download_lt);
strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%S", &ftp_download_lt);
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_SIZE_RESPONSE) && strncmp(nexthdr, FTP_SIZE_RESPONSE, strlen(FTP_SIZE_RESPONSE)) == 0) {
if (strcmp(tcp_flag, "PSH ACK ") == 0 && DM_STRLEN(nexthdr) > strlen(FTP_SIZE_RESPONSE) && strncmp(nexthdr, FTP_SIZE_RESPONSE, strlen(FTP_SIZE_RESPONSE)) == 0) {
char *val = strstr(nexthdr,"213");
char *pch, *pchr;
val += strlen("213 ");
pch =strtok_r(val, " \r\n\t", &pchr);
diag_stats.test_bytes_received = atoi(pch);
diag_stats.test_bytes_received = DM_STRTOL(pch);
return;
}
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_PASV_RESPONSE) && strncmp(nexthdr, FTP_PASV_RESPONSE, strlen(FTP_PASV_RESPONSE)) == 0) {
if (strcmp(tcp_flag, "PSH ACK ") == 0 && DM_STRLEN(nexthdr) > strlen(FTP_PASV_RESPONSE) && strncmp(nexthdr, FTP_PASV_RESPONSE, strlen(FTP_PASV_RESPONSE)) == 0) {
diag_stats.ftp_syn = 1;
return;
}
if (diag_stats.random_seq == 0 && strcmp(tcp_flag, "SYN ") == 0 && diag_stats.ftp_syn == 1) {
snprintf(diag_stats.tcpopenrequesttime, sizeof(diag_stats.tcpopenrequesttime), "%s.%06ldZ", s_now, (long) ftp_download_ts.tv_usec);
diag_stats.random_seq = ntohl(tcp->seq);
diag_stats.random_seq = ntohl(tcp->seq);
return;
}
@ -733,7 +822,7 @@ static void ftp_download_per_packet(libtrace_packet_t *packet)
return;
}
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_RETR_REQUEST) && strncmp(nexthdr, FTP_RETR_REQUEST, strlen(FTP_RETR_REQUEST)) == 0) {
if (strcmp(tcp_flag, "PSH ACK ") == 0 && DM_STRLEN(nexthdr) > strlen(FTP_RETR_REQUEST) && strncmp(nexthdr, FTP_RETR_REQUEST, strlen(FTP_RETR_REQUEST)) == 0) {
snprintf(diag_stats.romtime, sizeof(diag_stats.romtime), "%s.%06ldZ", s_now, (long) ftp_download_ts.tv_usec);
return;
}
@ -837,7 +926,7 @@ static void ftp_upload_per_packet(libtrace_packet_t *packet)
if (get_tcp_flag_from_packet(packet, &tcp, tcp_flag, &nexthdr))
return;
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_PASV_RESPONSE) && strncmp(nexthdr, FTP_PASV_RESPONSE, strlen(FTP_PASV_RESPONSE)) == 0) {
if (strcmp(tcp_flag, "PSH ACK ") == 0 && DM_STRLEN(nexthdr) > strlen(FTP_PASV_RESPONSE) && strncmp(nexthdr, FTP_PASV_RESPONSE, strlen(FTP_PASV_RESPONSE)) == 0) {
diag_stats.ftp_syn = 1;
return;
}
@ -849,7 +938,7 @@ static void ftp_upload_per_packet(libtrace_packet_t *packet)
if (strcmp(tcp_flag, "SYN ") == 0 && diag_stats.ftp_syn == 1) {
diag_stats.random_seq = ntohl(tcp->seq);
snprintf(diag_stats.tcpopenrequesttime, sizeof(diag_stats.tcpopenrequesttime), "%s.%06ldZ", s_now, (long) ftp_upload_ts.tv_usec);
return;
return;
}
if (strcmp(tcp_flag, "SYN ACK ") == 0 && diag_stats.random_seq != 0 && (ntohl(tcp->ack_seq) - 1 ) == diag_stats.random_seq) {
@ -858,7 +947,7 @@ static void ftp_upload_per_packet(libtrace_packet_t *packet)
return;
}
if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_STOR_REQUEST) && strncmp(nexthdr, FTP_STOR_REQUEST, strlen(FTP_STOR_REQUEST)) == 0) {
if (strcmp(tcp_flag, "PSH ACK ") == 0 && DM_STRLEN(nexthdr) > strlen(FTP_STOR_REQUEST) && strncmp(nexthdr, FTP_STOR_REQUEST, strlen(FTP_STOR_REQUEST)) == 0) {
snprintf(diag_stats.romtime, sizeof(diag_stats.romtime), "%s.%06ldZ", s_now, (long) ftp_upload_ts.tv_usec);
return;
}
@ -882,7 +971,7 @@ static void ftp_upload_per_packet(libtrace_packet_t *packet)
return;
}
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && strlen(nexthdr) > strlen(FTP_TRANSFERT_COMPLETE) && strncmp(nexthdr, FTP_TRANSFERT_COMPLETE, strlen(FTP_TRANSFERT_COMPLETE)) == 0) {
if ( (strcmp(tcp_flag, "PSH ACK ") == 0 || strcmp(tcp_flag, "FIN PSH ACK ") == 0) && DM_STRLEN(nexthdr) > strlen(FTP_TRANSFERT_COMPLETE) && strncmp(nexthdr, FTP_TRANSFERT_COMPLETE, strlen(FTP_TRANSFERT_COMPLETE)) == 0) {
snprintf(diag_stats.eomtime, sizeof(diag_stats.eomtime), "%s.%06ldZ", s_now, (long) ftp_upload_ts.tv_usec);
read_next = 0;
return;
@ -949,11 +1038,10 @@ static int extract_stats(char *dump_file, int proto, int diagnostic_type)
static char *get_default_gateway_device(void)
{
char *device = "";
FILE *f = fopen(PROC_ROUTE, "r");
if (f != NULL) {
char line[100] = {0}, *p = NULL, *c = NULL, *saveptr = NULL;
char *device = NULL;
while(fgets(line, sizeof(line), f)) {
p = strtok_r(line, " \t", &saveptr);
@ -964,9 +1052,11 @@ static char *get_default_gateway_device(void)
}
}
fclose(f);
return device ? device : "";
}
return device;
return "";
}
int start_upload_download_diagnostic(int diagnostic_type)
@ -982,10 +1072,9 @@ int start_upload_download_diagnostic(int diagnostic_type)
interface = get_diagnostics_option("upload", "interface");
}
if ((url[0] == '\0') ||
(strncmp(url, HTTP_URI, strlen(HTTP_URI)) != 0 &&
if (strncmp(url, HTTP_URI, strlen(HTTP_URI)) != 0 &&
strncmp(url, FTP_URI, strlen(FTP_URI)) != 0 &&
strstr(url,"@") != NULL))
strchr(url,'@') != NULL)
return -1;
device = (interface && *interface) ? get_device(interface) : get_default_gateway_device();

View file

@ -12,7 +12,7 @@
#ifndef __DMDIAGNOSTICS_H__
#define __DMDIAGNOSTICS_H__
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
#include <libubox/uloop.h>
#define HTTP_URI "http"
@ -26,7 +26,7 @@
#define FTP_TRANSFERT_COMPLETE "226 Transfer"
#define FTP_RETR_REQUEST "RETR"
#define FTP_STOR_REQUEST "STOR"
#define CURL_TIMEOUT 100
#define CURL_TIMEOUT 600
#define DMMAP_DIAGNOSTIGS "dmmap_diagnostics"
#define CONFIG_BACKUP "/tmp/bbf_config_backup"
#define MAX_TIME_WINDOW 5
@ -48,12 +48,6 @@ struct diagnostic_stats
uint32_t ftp_syn;
};
struct activate_image
{
struct uloop_timeout activate_timer;
char *start_time;
};
enum diagnostic_protocol {
DIAGNOSTIC_HTTP = 1,
DIAGNOSTIC_FTP
@ -80,7 +74,6 @@ int bbf_config_restore(const char *url, const char *username, const char *passwo
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);
int bbf_fw_image_activate(const char *bank_id, struct activate_image *active_img);
const char *bank_id, const char *command, const char *obj_path, const char *commandKey);
#endif

File diff suppressed because it is too large Load diff

View file

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

View file

@ -9,7 +9,6 @@
*
*/
#include "dmdynamicmem.h"
#include "dmdynamiclibrary.h"
LIST_HEAD(loaded_library_list);
@ -130,12 +129,11 @@ static char *get_path_without_instance(char *path)
res_path[0] = 0;
for (pch = strtok_r(str, ".", &pchr); pch != NULL; pch = strtok_r(NULL, ".", &pchr)) {
if (atoi(pch) == 0)
if (DM_STRTOL(pch) == 0 && strcmp(pch, "{i}") != 0)
pos += snprintf(&res_path[pos], sizeof(res_path) - pos, "%s%s", pch, (pchr != NULL && *pchr != '\0') ? "." : "");
}
if (str)
dm_dynamic_free(str);
dmfree(str);
return dm_dynamic_strdup(&library_memhead, res_path);
}
@ -147,7 +145,7 @@ static int get_dynamic_operate_args(char *refparam, struct dmctx *ctx, void *dat
char *operate_path = get_path_without_instance(refparam);
list_for_each_entry(dyn_operate, &dynamic_operate_list, list) {
if (strcmp(dyn_operate->operate_path, operate_path) == 0) {
if (DM_STRCMP(dyn_operate->operate_path, operate_path) == 0) {
operate_args = (operation_args *)dyn_operate->operate_args;
break;
}
@ -164,7 +162,7 @@ static int dynamic_operate_leaf(char *refparam, struct dmctx *ctx, void *data, c
char *operate_path = get_path_without_instance(refparam);
list_for_each_entry(dyn_operate, &dynamic_operate_list, list) {
if (strcmp(dyn_operate->operate_path, operate_path) == 0) {
if (DM_STRCMP(dyn_operate->operate_path, operate_path) == 0) {
operate_func = (operation)dyn_operate->operate;
break;
}
@ -251,7 +249,7 @@ int load_library_dynamic_arrays(struct dmctx *ctx)
}
//Dynamic Operate is deprecated now. It will be removed later.
DM_MAP_OPERATE *dynamic_operate = NULL;
struct dm_map_operate *dynamic_operate = NULL;
*(void **) (&dynamic_operate) = dlsym(handle, "tDynamicOperate");
if (dynamic_operate) {
@ -266,7 +264,7 @@ int load_library_dynamic_arrays(struct dmctx *ctx)
dmfree(object_path);
char *ret = strrchr(operate_path, '.');
strncpy(parent_path, operate_path, ret - operate_path +1);
DM_STRNCPY(parent_path, operate_path, ret - operate_path + 2);
bool obj_exists = operate_find_root_entry(ctx, parent_path, &dm_entryobj);
if (obj_exists == false || !dm_entryobj)

View file

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

View file

@ -1,93 +0,0 @@
/*
* Copyright (C) 2019 iopsys Software Solutions AB
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#include "dmdynamicmem.h"
inline void *__dm_dynamic_malloc(struct list_head *mem_list, size_t size)
{
struct dm_dynamic_mem *m = malloc(sizeof(struct dm_dynamic_mem) + size);
if (m == NULL) return NULL;
list_add(&m->list, mem_list);
return (void *)m->mem;
}
inline void *__dm_dynamic_calloc(struct list_head *mem_list, int n, size_t size)
{
struct dm_dynamic_mem *m = calloc(n, sizeof(struct dm_dynamic_mem) + size);
if (m == NULL) return NULL;
list_add(&m->list, mem_list);
return (void *)m->mem;
}
inline void *__dm_dynamic_realloc(struct list_head *mem_list, void *n, size_t size)
{
struct dm_dynamic_mem *m = NULL;
if (n != NULL) {
m = container_of(n, struct dm_dynamic_mem, mem);
list_del(&m->list);
}
struct dm_dynamic_mem *new_m = realloc(m, sizeof(struct dm_dynamic_mem) + size);
if (new_m == NULL) {
dm_dynamic_free(m);
return NULL;
} else
m = new_m;
list_add(&m->list, mem_list);
return (void *)m->mem;
}
inline void dm_dynamic_free(void *m)
{
if (m == NULL) return;
struct dm_dynamic_mem *rm;
rm = container_of(m, struct dm_dynamic_mem, mem);
list_del(&rm->list);
free(rm);
}
void dm_dynamic_cleanmem(struct list_head *mem_list)
{
struct dm_dynamic_mem *dmm;
while (mem_list->next != mem_list) {
dmm = list_entry(mem_list->next, struct dm_dynamic_mem, list);
list_del(&dmm->list);
free(dmm);
}
}
char *__dm_dynamic_strdup(struct list_head *mem_list, const char *s)
{
size_t len = strlen(s) + 1;
void *new = __dm_dynamic_malloc(mem_list, len);
if (new == NULL) return NULL;
return (char *) memcpy(new, s, len);
}
int __dm_dynamic_asprintf(struct list_head *mem_list, char **s, const char *format, ...)
{
int size;
char *str = NULL;
va_list arg;
va_start(arg, format);
size = vasprintf(&str, format, arg);
va_end(arg);
if (size < 0 || str == NULL)
return -1;
*s = __dm_dynamic_strdup(mem_list, str);
free(str);
if (*s == NULL)
return -1;
return 0;
}

View file

@ -1,37 +0,0 @@
/*
* Copyright (C) 2019 iopsys Software Solutions AB
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
*/
#ifndef __DM_DYNAMIC_MEM_H
#define __DM_DYNAMIC_MEM_H
#include <libbbf_api/dmcommon.h>
struct dm_dynamic_mem
{
struct list_head list;
char mem[0];
};
void *__dm_dynamic_malloc(struct list_head *mem_list, size_t size);
void *__dm_dynamic_calloc(struct list_head *mem_list, int n, size_t size);
void *__dm_dynamic_realloc(struct list_head *mem_list, void *n, size_t size);
char *__dm_dynamic_strdup(struct list_head *mem_list, const char *s);
int __dm_dynamic_asprintf(struct list_head *mem_list, char **s, const char *format, ...);
void dm_dynamic_free(void *m);
void dm_dynamic_cleanmem(struct list_head *mem_list);
#define dm_dynamic_malloc(m, x) __dm_dynamic_malloc(m, x)
#define dm_dynamic_calloc(m, n, x) __dm_dynamic_calloc(m, n, x)
#define dm_dynamic_realloc(m, x, n) __dm_dynamic_realloc(m, x, n)
#define dm_dynamic_strdup(m, x) __dm_dynamic_strdup(m, x)
#define dm_dynamic_asprintf(m, s, format, ...) __dm_dynamic_asprintf(m, s, format, ## __VA_ARGS__)
#endif //__DM_DYNAMIC_MEM_H

View file

@ -52,7 +52,7 @@ static void overwrite_param(DMOBJ *entryobj, DMLEAF *leaf)
DMLEAF *entryleaf = entryobj->leaf;
for (; (entryleaf && entryleaf->parameter); entryleaf++) {
if (strcmp(entryleaf->parameter, leaf->parameter) == 0) {
if (DM_STRCMP(entryleaf->parameter, leaf->parameter) == 0) {
entryleaf->getvalue = leaf->getvalue;
entryleaf->setvalue = leaf->setvalue;
return;
@ -69,7 +69,7 @@ static void overwrite_obj(DMOBJ *entryobj, DMOBJ *dmobj)
DMOBJ *entrynextobj = entryobj->nextobj;
for (; (entrynextobj && entrynextobj->obj); entrynextobj++) {
if (strcmp(entrynextobj->obj, dmobj->obj) == 0) {
if (DM_STRCMP(entrynextobj->obj, dmobj->obj) == 0) {
entrynextobj->addobj = dmobj->addobj;
entrynextobj->delobj = dmobj->delobj;
@ -113,7 +113,7 @@ static void load_vendor_extension_arrays(struct dmctx *ctx)
for (int j = 0; vendor_map_obj[j].vendor; j++) {
if (strcmp(vendor_map_obj[j].vendor, tokens[idx]) != 0)
if (DM_STRCMP(vendor_map_obj[j].vendor, tokens[idx]) != 0)
continue;
DM_MAP_OBJ *vendor_obj = vendor_map_obj[j].vendor_obj;
@ -137,10 +137,10 @@ static void load_vendor_extension_arrays(struct dmctx *ctx)
dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj = calloc(2, sizeof(DMOBJ *));
dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj[0] = vendor_obj[i].root_obj;
} else {
int idx = get_obj_idx_dynamic_array(dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj);
dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj = realloc(dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj, (idx + 2) * sizeof(DMOBJ *));
dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj[idx] = vendor_obj[i].root_obj;
dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj[idx+1] = NULL;
int obj_idx = get_obj_idx_dynamic_array(dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj);
dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj = realloc(dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj, (obj_idx + 2) * sizeof(DMOBJ *));
dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj[obj_idx] = vendor_obj[i].root_obj;
dm_entryobj->nextdynamicobj[INDX_VENDOR_MOUNT].nextobj[obj_idx+1] = NULL;
}
}
@ -156,10 +156,10 @@ static void load_vendor_extension_arrays(struct dmctx *ctx)
dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf = calloc(2, sizeof(DMLEAF *));
dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf[0] = vendor_obj[i].root_leaf;
} else {
int idx = get_leaf_idx_dynamic_array(dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf);
dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf = realloc(dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf, (idx + 2) * sizeof(DMLEAF *));
dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf[idx] = vendor_obj[i].root_leaf;
dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf[idx+1] = NULL;
int leaf_idx = get_leaf_idx_dynamic_array(dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf);
dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf = realloc(dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf, (leaf_idx + 2) * sizeof(DMLEAF *));
dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf[leaf_idx] = vendor_obj[i].root_leaf;
dm_entryobj->dynamicleaf[INDX_VENDOR_MOUNT].nextleaf[leaf_idx+1] = NULL;
}
}
@ -185,7 +185,7 @@ static void load_vendor_extension_overwrite_arrays(struct dmctx *ctx)
for (int j = 0; vendor_map_obj[j].vendor; j++) {
if (strcmp(vendor_map_obj[j].vendor, tokens[idx]) != 0)
if (DM_STRCMP(vendor_map_obj[j].vendor, tokens[idx]) != 0)
continue;
DM_MAP_OBJ *dynamic_overwrite_obj = vendor_map_obj[j].vendor_obj;
@ -234,8 +234,12 @@ static void exclude_param(struct dmctx *ctx, char *in_param)
DMOBJ *entryobj = NULL;
char obj_prefix[256] = {'\0'};
if (in_param == NULL)
return;
char *ret = strrchr(in_param, '.');
strncpy(obj_prefix, in_param, ret - in_param +1);
if (ret)
DM_STRNCPY(obj_prefix, in_param, ret - in_param + 2);
bool obj_exists = find_root_entry(ctx, obj_prefix, &entryobj);
@ -273,14 +277,14 @@ static void load_vendor_extension_exclude_arrays(struct dmctx *ctx)
for (int j = 0; vendor_map_exclude_obj[j].vendor; j++) {
if (strcmp(vendor_map_exclude_obj[j].vendor, tokens[idx]) != 0)
if (DM_STRCMP(vendor_map_exclude_obj[j].vendor, tokens[idx]) != 0)
continue;
char **dynamic_exclude_obj = vendor_map_exclude_obj[j].vendor_obj;
for (; *dynamic_exclude_obj; dynamic_exclude_obj++) {
if ((*dynamic_exclude_obj)[strlen(*dynamic_exclude_obj) - 1] == '.')
if ((*dynamic_exclude_obj)[DM_STRLEN(*dynamic_exclude_obj) - 1] == '.')
exclude_obj(ctx, *dynamic_exclude_obj);
else
exclude_param(ctx, *dynamic_exclude_obj);

View file

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

228
dmentry.c
View file

@ -16,20 +16,30 @@
#include "dmdynamicjson.h"
#include "dmdynamiclibrary.h"
#include "dmdynamicvendor.h"
#include "dmdynamicmem.h"
#ifdef BBF_TR181
#include "device.h"
#endif /* BBF_TR181 */
#include "dmbbfcommon.h"
LIST_HEAD(head_package_change);
LIST_HEAD(main_memhead);
#ifdef BBFDM_ENABLE_JSON_PLUGIN
static char json_hash[64] = {0};
#endif /* BBFDM_ENABLE_JSON_PLUGIN */
#ifdef BBFDM_ENABLE_DOTSO_PLUGIN
static char library_hash[64] = {0};
#endif /* BBFDM_ENABLE_DOTSO_PLUGIN */
#ifdef BBF_VENDOR_EXTENSION
static bool first_boot = false;
#endif
static void load_dynamic_arrays(struct dmctx *ctx);
int dm_debug_browse_path(char *buff, size_t len)
{
if (!buff)
@ -123,7 +133,7 @@ int usp_fault_map(int fault)
return out_fault;
}
static int dm_ctx_init_custom(struct dmctx *ctx, unsigned int instance_mode, int custom)
static int dm_ctx_init_custom(struct dmctx *ctx, unsigned int instance_mode, DMOBJ *tEntryObj, int custom)
{
if (custom == CTX_INIT_ALL)
bbf_uci_init();
@ -132,7 +142,8 @@ static int dm_ctx_init_custom(struct dmctx *ctx, unsigned int instance_mode, int
INIT_LIST_HEAD(&ctx->set_list_tmp);
INIT_LIST_HEAD(&ctx->list_fault_param);
ctx->instance_mode = instance_mode;
ctx->dm_entryobj = tEntry181Obj;
ctx->dm_entryobj = tEntryObj;
ctx->dm_version = DEFAULT_DMVERSION;
ctx->end_session_flag = 0;
return 0;
}
@ -145,25 +156,50 @@ static int dm_ctx_clean_custom(struct dmctx *ctx, int custom)
DMFREE(ctx->addobj_instance);
if (custom == CTX_INIT_ALL) {
bbf_uci_exit();
dmubus_free();
dmcleanmem();
}
return 0;
}
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)
{
return dm_ctx_init_custom(ctx, instance_mode, tEntryObj, CTX_INIT_ALL);
}
int dm_ctx_init(struct dmctx *ctx, unsigned int instance_mode)
{
return dm_ctx_init_custom(ctx, instance_mode, CTX_INIT_ALL);
#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 */
}
int dm_ctx_clean(struct dmctx *ctx)
{
dmubus_update_cached_entries();
return dm_ctx_clean_custom(ctx, CTX_INIT_ALL);
}
int dm_ctx_init_cache(int time)
{
dmubus_set_caching_time(time);
return 0;
}
int dm_ctx_init_sub(struct dmctx *ctx, unsigned int instance_mode)
{
return dm_ctx_init_custom(ctx, instance_mode, CTX_INIT_SUB);
#ifdef BBF_TR181
return dm_ctx_init_custom(ctx, instance_mode, tEntry181Obj, CTX_INIT_SUB);
#else
return 0;
#endif /* BBF_TR181 */
}
int dm_ctx_clean_sub(struct dmctx *ctx)
@ -171,6 +207,50 @@ int dm_ctx_clean_sub(struct dmctx *ctx)
return dm_ctx_clean_custom(ctx, CTX_INIT_SUB);
}
int dm_get_supported_dm(struct dmctx *ctx, char *path, bool first_level, schema_type_t schema_type)
{
int fault = 0;
int len = DM_STRLEN(path);
// Load dynamic objects and parameters
load_dynamic_arrays(ctx);
if (len == 0) {
path = "";
} else {
if (path[strlen(path) - 1] != '.')
return usp_fault_map(USP_FAULT_INVALID_PATH);
}
ctx->in_param = path;
dmentry_instance_lookup_inparam(ctx);
ctx->stop = false;
ctx->nextlevel = first_level;
switch(schema_type) {
case ALL_SCHEMA:
ctx->isinfo = 1;
ctx->isevent = 1;
ctx->iscommand = 1;
break;
case PARAM_ONLY:
ctx->isinfo = 1;
break;
case EVENT_ONLY:
ctx->isevent = 1;
break;
case COMMAND_ONLY:
ctx->iscommand = 1;
break;
}
fault = dm_entry_get_supported_dm(ctx);
return usp_fault_map(fault);
}
int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, char *arg2)
{
int fault = 0;
@ -184,13 +264,13 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
ctx->stop = false;
switch(cmd) {
case CMD_GET_VALUE:
if (ctx->in_param[0] == '.' && strlen(ctx->in_param) == 1)
if (ctx->in_param[0] == '.' && DM_STRLEN(ctx->in_param) == 1)
fault = FAULT_9005;
else
fault = dm_entry_get_value(ctx);
break;
case CMD_GET_NAME:
if (ctx->in_param[0] == '.' && strlen(ctx->in_param) == 1)
if (ctx->in_param[0] == '.' && DM_STRLEN(ctx->in_param) == 1)
fault = FAULT_9005;
else if (arg1 && string_to_bool(arg1, &ctx->nextlevel) == 0)
fault = dm_entry_get_name(ctx);
@ -207,14 +287,16 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
case CMD_ADD_OBJECT:
fault = dm_entry_add_object(ctx);
if (!fault) {
dmuci_set_value("cwmp", "acs", "ParameterKey", arg1 ? arg1 : "");
dmuci_set_value_varstate("cwmp", "cpe", "ParameterKey", arg1 ? arg1 : "");
dmuci_save_package_varstate("cwmp");
dmuci_change_packages(&head_package_change);
}
break;
case CMD_DEL_OBJECT:
fault = dm_entry_delete_object(ctx);
if (!fault) {
dmuci_set_value("cwmp", "acs", "ParameterKey", arg1 ? arg1 : "");
dmuci_set_value_varstate("cwmp", "cpe", "ParameterKey", arg1 ? arg1 : "");
dmuci_save_package_varstate("cwmp");
dmuci_change_packages(&head_package_change);
}
break;
@ -232,7 +314,7 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
fault = dm_entry_get_schema(ctx);
break;
case CMD_GET_INSTANCES:
if (!arg1 || (arg1 && string_to_bool(arg1, &ctx->nextlevel) == 0))
if (!arg1 || string_to_bool(arg1, &ctx->nextlevel) == 0)
fault = dm_entry_get_instances(ctx);
else
fault = FAULT_9003;
@ -247,10 +329,12 @@ int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1)
{
struct set_tmp *n = NULL, *p = NULL;
int fault = 0;
bool set_success = false;
switch(cmd) {
case CMD_SET_VALUE:
ctx->setaction = VALUESET;
set_success = false;
list_for_each_entry_safe(n, p, &ctx->set_list_tmp, list) {
ctx->in_param = n->name;
ctx->in_value = n->value ? n->value : "";
@ -260,9 +344,11 @@ int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1)
add_list_fault_param(ctx, ctx->in_param, usp_fault_map(fault));
break;
}
set_success = true;
}
if (!fault) {
dmuci_set_value("cwmp", "acs", "ParameterKey", arg1 ? arg1 : "");
if (!fault && set_success == true) {
dmuci_set_value_varstate("cwmp", "cpe", "ParameterKey", arg1 ? arg1 : "");
dmuci_save_package_varstate("cwmp");
dmuci_change_packages(&head_package_change);
dmuci_save();
}
@ -276,9 +362,13 @@ int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1)
int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, char **value)
{
struct dmctx dmctx = {0};
*value = "";
if (!param || !linker || *linker == 0)
return 0;
dm_ctx_init_sub(&dmctx, ctx->instance_mode);
dmctx.in_param = param ? param : "";
dmctx.in_param = param;
dmctx.linker = linker;
dm_entry_get_linker(&dmctx);
@ -297,7 +387,7 @@ int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value)
if (!param || param[0] == '\0')
return 0;
snprintf(linker, sizeof(linker), "%s%c", param, (param[strlen(param) - 1] != '.') ? '.' : '\0');
snprintf(linker, sizeof(linker), "%s%c", param, (param[DM_STRLEN(param) - 1] != '.') ? '.' : '\0');
dm_ctx_init_sub(&dmctx, ctx->instance_mode);
dmctx.in_param = linker;
@ -309,6 +399,28 @@ int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value)
return 0;
}
int dm_entry_validate_allowed_objects(struct dmctx *ctx, char *value, char *objects[])
{
if (!value || !objects)
return -1;
if (*value == '\0')
return 0;
for (; *objects; objects++) {
if (DM_STRNCMP(value, *objects, DM_STRLEN(*objects)) == 0) {
char *linker = NULL;
adm_entry_get_linker_value(ctx, value, &linker);
if (linker && *linker)
return 0;
}
}
return -1;
}
int dm_entry_manage_services(struct blob_buf *bb, bool restart)
{
struct package_change *pc = NULL;
@ -327,6 +439,9 @@ int dm_entry_manage_services(struct blob_buf *bb, bool restart)
}
}
blobmsg_close_array(bb, arr);
dmuci_commit_package_varstate("cwmp");
free_all_list_package_change(&head_package_change);
return 0;
}
@ -337,14 +452,10 @@ int dm_entry_restart_services(void)
bbf_uci_commit_bbfdm();
list_for_each_entry(pc, &head_package_change, list) {
if (strcmp(pc->package, "cwmp") == 0) {
dmuci_init();
dmuci_commit_package("cwmp");
dmuci_exit();
} else {
dmubus_call_set("uci", "commit", UBUS_ARGS{{"config", pc->package, String}}, 1);
}
dmubus_call_set("uci", "commit", UBUS_ARGS{{"config", pc->package, String}}, 1);
}
dmuci_commit_package_varstate("cwmp");
free_all_list_package_change(&head_package_change);
return 0;
@ -359,14 +470,34 @@ int dm_entry_revert_changes(void)
list_for_each_entry(pc, &head_package_change, list) {
dmubus_call_set("uci", "revert", UBUS_ARGS{{"config", pc->package, String}}, 1);
}
dmuci_revert_package_varstate("cwmp");
free_all_list_package_change(&head_package_change);
return 0;
}
#if defined(BBFDM_ENABLE_JSON_PLUGIN) || defined(BBFDM_ENABLE_DOTSO_PLUGIN)
static char* get_folder_path(bool json_path)
{
if (json_path) {
#ifdef BBFDM_ENABLE_JSON_PLUGIN
return JSON_FOLDER_PATH;
#endif /* BBFDM_ENABLE_JSON_PLUGIN */
} else {
#ifdef BBFDM_ENABLE_DOTSO_PLUGIN
return LIBRARY_FOLDER_PATH;
#endif /* BBFDM_ENABLE_DOTSO_PLUGIN */
}
return NULL;
}
static int get_stats_folder(bool json_path, int *count, unsigned long *size)
{
const char *path = json_path ? JSON_FOLDER_PATH : LIBRARY_FOLDER_PATH;
const char *path = get_folder_path(json_path);
if (path == NULL) {
return 0;
}
if (folder_exists(path)) {
struct dirent *entry = NULL;
@ -406,27 +537,43 @@ static int check_stats_folder(bool json_path)
snprintf(buf, sizeof(buf), "count:%d,size:%lu", count, size);
if (strcmp(buf, json_path ? json_hash : library_hash) != 0) {
strncpy(json_path ? json_hash : library_hash, buf, 64);
return 1;
if (json_path) {
#ifdef BBFDM_ENABLE_JSON_PLUGIN
if (DM_STRCMP(buf, json_hash) != 0) {
DM_STRNCPY(json_hash, buf, sizeof(json_hash));
return 1;
}
#endif /* BBFDM_ENABLE_JSON_PLUGIN */
} else {
#ifdef BBFDM_ENABLE_DOTSO_PLUGIN
if (DM_STRCMP(buf, library_hash) != 0) {
DM_STRNCPY(library_hash, buf, sizeof(library_hash));
return 1;
}
#endif /* BBFDM_ENABLE_DOTSO_PLUGIN */
}
return 0;
}
#endif /* (BBFDM_ENABLE_JSON_PLUGIN || BBFDM_ENABLE_DOTSO_PLUGIN) */
void load_dynamic_arrays(struct dmctx *ctx)
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);
load_json_dynamic_arrays(ctx);
}
#endif /* BBFDM_ENABLE_JSON_PLUGIN */
#ifdef BBFDM_ENABLE_DOTSO_PLUGIN
// Load dynamic objects and parameters exposed via a library
if (check_stats_folder(false)) {
free_library_dynamic_arrays(tEntry181Obj);
load_library_dynamic_arrays(ctx);
}
#endif /* BBFDM_ENABLE_DOTSO_PLUGIN */
#ifdef BBF_VENDOR_EXTENSION
// Load objects and parameters exposed via vendor extension
@ -438,16 +585,39 @@ void load_dynamic_arrays(struct dmctx *ctx)
#endif
}
void free_dynamic_arrays(void)
static void free_dynamic_arrays(void)
{
#ifdef BBF_TR181
DMOBJ *root = tEntry181Obj;
DMNODE node = {.current_object = ""};
#ifdef BBFDM_ENABLE_JSON_PLUGIN
free_json_dynamic_arrays(tEntry181Obj);
#endif /* BBFDM_ENABLE_JSON_PLUGIN */
#ifdef BBFDM_ENABLE_DOTSO_PLUGIN
free_library_dynamic_arrays(tEntry181Obj);
#endif /* BBFDM_ENABLE_DOTSO_PLUGIN */
#ifdef BBF_VENDOR_EXTENSION
free_vendor_dynamic_arrays(tEntry181Obj);
#endif
free_dm_browse_node_dynamic_object_tree(&node, root);
dm_dynamic_cleanmem(&main_memhead);
#endif /* BBF_TR181 */
}
void bbf_dm_cleanup(void)
{
dmubus_free();
dm_dynamic_cleanmem(&main_memhead);
free_dynamic_arrays();
}
void dm_cleanup_dynamic_entry(DMOBJ *root)
{
DMNODE node = {.current_object = ""};
dm_dynamic_cleanmem(&main_memhead);
free_dm_browse_node_dynamic_object_tree(&node, root);
}

View file

@ -15,7 +15,7 @@
#ifndef __DMENTRY_H__
#define __DMENTRY_H__
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern struct list_head head_package_change;
extern struct list_head main_memhead;
@ -24,8 +24,16 @@ enum ctx_init_enum {
CTX_INIT_SUB
};
typedef enum {
ALL_SCHEMA,
PARAM_ONLY,
EVENT_ONLY,
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_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, char *arg2);
int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1);
int dm_entry_restart_services(void);
@ -34,8 +42,10 @@ int dm_entry_revert_changes(void);
int usp_fault_map(int fault);
int dm_ctx_clean(struct dmctx *ctx);
int dm_ctx_clean_sub(struct dmctx *ctx);
void load_dynamic_arrays(struct dmctx *ctx);
void free_dynamic_arrays(void);
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);
/**
* @brief dm_debug_browse_path
@ -53,5 +63,6 @@ void free_dynamic_arrays(void);
* object illegal access.
*/
int dm_debug_browse_path(char *buff, size_t len);
void dm_cleanup_dynamic_entry(DMOBJ *root);
#endif

View file

@ -1046,7 +1046,7 @@
"name": "sip_options"
},
"option": {
"name": "rtpstart"
"name": "rtp_start"
}
}
}
@ -1074,7 +1074,7 @@
"name": "sip_options"
},
"option": {
"name": "rtpend"
"name": "rtp_end"
}
}
}
@ -2080,7 +2080,7 @@
"uci": {
"file": "asterisk",
"section": {
"type": "tel_line"
"type": "extension"
},
"dmmapfile": "dmmap_asterisk"
}
@ -2150,7 +2150,7 @@
"uci": {
"file": "asterisk",
"section": {
"type": "tel_line",
"type": "extension",
"index": "@i-1"
},
"option": {
@ -2239,7 +2239,7 @@
"uci": {
"file": "asterisk",
"section": {
"type": "tel_line",
"type": "extension",
"index": "@i-1"
},
"option": {
@ -3558,7 +3558,7 @@
"index": "@i-1"
},
"option": {
"name": "enabled"
"name": "enable"
}
}
}
@ -4136,7 +4136,7 @@
"index": "@i-1"
},
"option": {
"name": "enabled"
"name": "enable"
}
}
}
@ -7744,7 +7744,7 @@
"uci": {
"file": "asterisk",
"section": {
"type": "tel_line"
"type": "line"
},
"dmmapfile": "dmmap_asterisk"
}
@ -7765,11 +7765,11 @@
"uci": {
"file": "asterisk",
"section": {
"type": "tel_line",
"type": "line",
"index": "@i-1"
},
"option": {
"name": "enabled"
"name": "enable"
}
}
}
@ -7837,7 +7837,20 @@
"Connected",
"Alerting",
"Disconnected"
]
],
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "asterisk",
"method": "call_status",
"args": {
"line": "@-1"
},
"key": "call_status"
}
}
]
},
"Origin": {
"type": "string",
@ -7891,11 +7904,11 @@
"uci": {
"file": "asterisk",
"section": {
"type": "tel_line",
"type": "line",
"index": "@i-1"
},
"option": {
"name": "sip_account"
"name": "provider"
}
}
}
@ -7915,7 +7928,22 @@
{
"max": 256
}
]
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "line",
"index": "@i-1"
},
"option": {
"name": "calling_features"
}
}
}
]
},
"Device.Services.VoiceService.{i}.CallControl.Line.{i}.Stats.": {
"type": "object",
@ -8179,7 +8207,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "extension",
"index": "@i-1"
},
"option": {
"name": "enable"
}
}
}
]
},
"QuiescentMode": {
"type": "boolean",
@ -8244,6 +8287,19 @@
"Connected",
"Alerting",
"Disconnected"
],
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "asterisk",
"method": "call_status",
"args": {
"extension": "@-1"
},
"key": "call_status"
}
}
]
},
"Origin": {
@ -8339,7 +8395,22 @@
{
"max": 256
}
]
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "extension",
"index": "@i-1"
},
"option": {
"name": "calling_features"
}
}
}
]
},
"CallWaitingStatus": {
"type": "string",
@ -8684,7 +8755,22 @@
],
"list": {
"datatype": "string"
}
},
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "group",
"index": "@i-1"
},
"option": {
"name": "extensions"
}
}
}
]
},
"RingType": {
"type": "string",
@ -8911,7 +8997,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "incoming_map",
"index": "@i-1"
},
"option": {
"name": "enable"
}
}
}
]
},
"Alias": {
"type": "string",
@ -8950,11 +9051,11 @@
"uci": {
"file": "asterisk",
"section": {
"type": "sip_service_provider",
"type": "incoming_map",
"index": "@i-1"
},
"option": {
"name": "call_lines"
"name": "line"
}
}
}
@ -8974,7 +9075,22 @@
{
"max": 256
}
]
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "incoming_map",
"index": "@i-1"
},
"option": {
"name": "extension"
}
}
}
]
},
"Order": {
"type": "unsignedInt",
@ -9024,7 +9140,7 @@
"uci": {
"file": "asterisk",
"section": {
"type": "sip_service_provider"
"type": "outgoing_map"
},
"dmmapfile": "dmmap_asterisk"
}
@ -9038,7 +9154,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "outgoing_map",
"index": "@i-1"
},
"option": {
"name": "enable"
}
}
}
]
},
"Alias": {
"type": "string",
@ -9101,7 +9232,22 @@
{
"max": 256
}
]
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "outgoing_map",
"index": "@i-1"
},
"option": {
"name": "extension"
}
}
}
]
},
"Line": {
"type": "string",
@ -9117,7 +9263,22 @@
{
"max": 256
}
]
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "outgoing_map",
"index": "@i-1"
},
"option": {
"name": "line"
}
}
}
]
},
"Order": {
"type": "unsignedInt",
@ -9512,7 +9673,7 @@
"max": 64
}
]
},
},
"FacilityActionArgument": {
"type": "string",
"read": true,
@ -9568,7 +9729,7 @@
"uci": {
"file": "asterisk",
"section": {
"type": "advanced_features"
"type": "calling_features"
},
"dmmapfile": "dmmap_asterisk"
}
@ -9598,7 +9759,23 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "caller_id_enable"
}
}
}
]
},
"CallerIDNameEnable": {
"type": "boolean",
@ -9609,7 +9786,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "caller_name_enable"
}
}
}
]
},
"CallWaitingEnable": {
"type": "boolean",
@ -9620,7 +9812,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "call_waiting_enable"
}
}
}
]
},
"CallForwardUnconditionalEnable": {
"type": "boolean",
@ -9631,7 +9838,23 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "call_forward_unconditional"
}
}
}
]
},
"CallForwardUnconditionalNumber": {
"type": "string",
@ -9658,7 +9881,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "call_forward_on_busy"
}
}
}
]
},
"CallForwardOnBusyNumber": {
"type": "string",
@ -9697,7 +9935,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "call_forward_on_no_answer"
}
}
}
]
},
"CallForwardOnNoAnswerNumber": {
"type": "string",
@ -9747,7 +10000,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "mwi_enable"
}
}
}
]
},
"VMWIEnable": {
"type": "boolean",
@ -9791,7 +10059,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "anonymous_call_enable"
}
}
}
]
},
"DoNotDisturbEnable": {
"type": "boolean",
@ -9802,7 +10085,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "dnd_enable"
}
}
}
]
},
"RepeatDialEnable": {
"type": "boolean",
@ -9824,7 +10122,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "voice_mail_enable"
}
}
}
]
},
"CallPickUpEnable": {
"type": "boolean",
@ -9846,7 +10159,22 @@
"cwmp",
"usp"
],
"datatype": "boolean"
"datatype": "boolean",
"mapping": [
{
"type": "uci",
"uci": {
"file": "asterisk",
"section": {
"type": "set",
"index": "@i-1"
},
"option": {
"name": "ccbs_enable"
}
}
}
]
},
"IIFCEnable": {
"type": "boolean",
@ -11457,7 +11785,7 @@
"datatype": "StatsCounter32"
},
"PacketsReceived": {
"type": "unsignedInt",
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.0",
@ -11468,7 +11796,7 @@
"datatype": "StatsCounter64"
},
"PacketsSent": {
"type": "unsignedInt",
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.0",
@ -11501,7 +11829,7 @@
"datatype": "StatsCounter32"
},
"BytesReceived": {
"type": "unsignedInt",
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.0",
@ -11512,7 +11840,7 @@
"datatype": "StatsCounter64"
},
"BytesSent": {
"type": "unsignedInt",
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.0",
@ -12037,7 +12365,7 @@
"datatype": "StatsCounter32"
},
"PacketsReceived": {
"type": "unsignedInt",
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.0",
@ -12048,7 +12376,7 @@
"datatype": "StatsCounter64"
},
"PacketsSent": {
"type": "unsignedInt",
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.0",
@ -12081,7 +12409,7 @@
"datatype": "StatsCounter32"
},
"BytesReceived": {
"type": "unsignedInt",
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.0",
@ -12092,7 +12420,7 @@
"datatype": "StatsCounter64"
},
"BytesSent": {
"type": "unsignedInt",
"type": "unsignedLong",
"read": true,
"write": false,
"version": "2.0",
@ -12557,7 +12885,7 @@
"name": "sip_options"
},
"option": {
"name": "dtmfmode"
"name": "dtmf_mode"
}
}
}
@ -12654,7 +12982,7 @@
"name": "sip_options"
},
"option": {
"name": "rtpstart"
"name": "rtp_start"
}
}
}
@ -12686,7 +13014,7 @@
"name": "sip_options"
},
"option": {
"name": "rtpend"
"name": "rtp_end"
}
}
}
@ -12829,7 +13157,7 @@
"name": "tel_options"
},
"option": {
"name": "jbimpl"
"name": "jb_impl"
}
}
}
@ -12856,7 +13184,7 @@
"name": "tel_options"
},
"option": {
"name": "jbmaxsize"
"name": "jb_maxsize"
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -8,21 +8,20 @@
* Author: Yalu Zhang, yalu.zhang@iopsys.eu
*/
#include "dmdynamicmem.h"
#include "dmentry.h"
#include "common.h"
char *RFPowerControl[] = {"Normal", "Reduced"};
char *ProxyServerTransport[] = {"UDP", "TCP", "TLS", "SCTP"};
char *RegistrarServerTransport[] = {"UDP", "TCP", "TLS", "SCTP"};
char *DTMFMethod[] = {"InBand", "RFC4733", "SIPInfo"};
char *JitterBufferType[] = {"Static", "Dynamic"};
char *KeyingMethods[] = {"Null", "Static", "SDP", "IKE"};
char *RFPowerControl[] = {"Normal", "Reduced", NULL};
char *ProxyServerTransport[] = {"UDP", "TCP", "TLS", "SCTP", NULL};
char *RegistrarServerTransport[] = {"UDP", "TCP", "TLS", "SCTP", NULL};
char *DTMFMethod[] = {"InBand", "RFC4733", "SIPInfo", NULL};
char *JitterBufferType[] = {"Static", "Dynamic", NULL};
char *KeyingMethods[] = {"Null", "Static", "SDP", "IKE", NULL};
char *FacilityAction[] = {"AA_REGISTER", "AA_ERASE", "AA_INTERROGATE", "CA_ACTIVATE", "CCBS_ACTIVATE", "CCBS_DEACTIVATE", "CCBS_INTERROGATE", "CCNR_ACTIVATE", "CCNR_DEACTIVATE", "CCNR_INTERROGATE", "CFB_REGISTER", "CFB_ACTIVATE", "CFB_DEACTIVATE", "CFB_ERASE", "CFB_INTERROGATE", "CFNR_REGISTER", "CFNR_ACTIVATE", "CFNR_DEACTIVATE", "CFNR_ERASE", "CFNR_INTERROGATE", "CFNR_TIMER", "CFT_ACTIVATE", "CFT_DEACTIVATE", "CFT_INTERROGATE", "CFU_REGISTER", "CFU_ACTIVATE", "CFU_DEACTIVATE", "CFU_ERASE", "CFU_INTERROGATE", "CLIR_ACTIVATE", "CLIR_DEACTIVATE", "CLIR_INTERROGATE", "CP_INVOKE", "CW_ACTIVATE", "CW_DEACTIVATE", "CW_INVOKE", "DND_ACTIVATE", "DND_DEACTIVATE", "DND_INTERROGATE", "EXT_INVOKE", "LINE_INVOKE", "MAILBOX_INVOKE", "OCB_ACTIVATE", "OCB_DEACTIVATE", "OCB_INTERROGATE", "PSO_ACTIVATE", "PW_SET", "SCF_ACTIVATE", "SCF_DEACTIVATE", "SCF_INTERROGATE", "SCREJ_ACTIVATE", "SCREJ_DEACTIVATE", "SCREJ_INTERROGATE", "SR_ACTIVATE", "SR_DEACTIVATE", "SR_INTERROGATE", NULL};
struct codec_info supported_codecs[MAX_SUPPORTED_CODECS];
int codecs_num;
extern struct list_head main_memhead;
LIST_HEAD(call_log_list);
static struct stat prev_stat = { 0 };
static int call_log_list_size = 0;
int call_log_count = 0;
@ -30,7 +29,7 @@ int init_supported_codecs(void)
{
json_object *res = NULL;
dmubus_call("voice.asterisk", "codecs", UBUS_ARGS{}, 0, &res);
dmubus_call("voice.asterisk", "codecs", UBUS_ARGS{0}, 0, &res);
if (!res)
return -1;
@ -100,17 +99,68 @@ static void convert_src_dst(char *src_or_dst, size_t buf_size)
int inst;
// Examples, "TELCHAN/5/2", "SIP/sip0-00000000",
if ((token = strstr(src_or_dst, TEL_LINE_PREFIX))) {
inst = atoi(token + strlen(TEL_LINE_PREFIX)) + 1;
snprintf(src_or_dst, buf_size, "Device.Services.VoiceService.1.CallControl.Line.%d", inst);
} else if ((token = strstr(src_or_dst, SIP_ACCOUNT_PREFIX))) {
inst = atoi(token + strlen(SIP_ACCOUNT_PREFIX)) + 1;
if ((token = DM_LSTRSTR(src_or_dst, TEL_LINE_PREFIX))) {
inst = DM_STRTOL(token + strlen(TEL_LINE_PREFIX)) + 1;
snprintf(src_or_dst, buf_size, "Device.Services.VoiceService.1.CallControl.Extension.%d", inst);
} else if ((token = DM_LSTRSTR(src_or_dst, SIP_ACCOUNT_PREFIX))) {
inst = DM_STRTOL(token + strlen(SIP_ACCOUNT_PREFIX)) + 1;
snprintf(src_or_dst, buf_size, "Device.Services.VoiceService.1.SIP.Client.%d", inst);
}
}
// TODO Convert used line from "SIP/sip0-00000000" to sip{i} then to correspond line{i}
static void convert_sip_line(char *sip_line, size_t buf_size)
{
char *token;
// Examples, "SIP/sip0-00000000",
if ((token = DM_LSTRSTR(sip_line, SIP_ACCOUNT_PREFIX))) {
int inst = DM_STRTOL(token + strlen(SIP_ACCOUNT_PREFIX)) + 1;
//snprintf(sip_line, buf_size, "sip%d", inst); // sip{i}
// TODO Convert sip{i} to correspond line{i}, hard mapping at the moment (sip1->line1)
snprintf(sip_line, buf_size, "Device.Services.VoiceService.1.CallControl.Line.%d", inst);
}
}
#define EXTENSION_PREFIX "TELCHAN"
// convert_used_extensions
static void convert_used_extensions(char *used_extensions, size_t buf_size)
{
char *token;
int inst;
char buf[512] = {0};
// Examples, if "TELCHAN/1" else if "TELCHAN\/3&&TELCHAN\/2,,tF(hangup,h,2)" else "PJSIP/57007@sip2,,gT",
if ((token = DM_LSTRSTR(used_extensions, TEL_LINE_PREFIX))) {
inst = DM_STRTOL(token + strlen(TEL_LINE_PREFIX)) + 1;
snprintf(used_extensions, buf_size, "Device.Services.VoiceService.1.CallControl.Extension.%d", inst);
} else {
unsigned pos = 0;
if ((token = DM_LSTRSTR(used_extensions, EXTENSION_PREFIX))) {
do {
token += strlen(EXTENSION_PREFIX);
inst = DM_STRTOL(token+2) + 1;
pos += snprintf(&buf[pos], sizeof(buf) - pos, "Device.Services.VoiceService.1.CallControl.Extension.%d,", inst);
}while ((token = DM_LSTRSTR(token, EXTENSION_PREFIX)));
}
if (pos) {
buf[pos - 1] = 0;
}
token = (buf[0] != '\0') ? dmstrdup(buf) : "";
snprintf(used_extensions, buf_size, "%s", token);
}
}
// return true is having successful responses 2xx
bool sip_response_checker(char *response_code) {
int code;
code = atoi(response_code);
if (code>=200 && code<=299) {
return true;
}
return false;
}
#define CALL_LOG_FILE "/var/log/asterisk/cdr-csv/Master.csv"
#define CALL_LOG_FILE_OLD "/var/log/asterisk/cdr-csv/Master_old.csv"
#define SEPARATOR "\",\""
#define SEPARATOR_SIZE strlen(SEPARATOR)
int init_call_log(void)
@ -121,9 +171,8 @@ int init_call_log(void)
cdr.calling_num, cdr.called_num, cdr.start_time, end_time); \
continue; \
}
static struct stat prev_stat = { 0 };
struct stat cur_stat;
int res = 0, i = 0, j = 0;
int res = 0, i = 0;
struct call_log_entry *entry;
struct list_head *pos = NULL;
FILE *fp = NULL;
@ -137,32 +186,30 @@ int init_call_log(void)
prev_stat = cur_stat;
}
}
// Master.csv
fp = fopen(CALL_LOG_FILE, "r");
if (!fp) {
BBF_DEBUG("Call log file %s doesn't exist\n", CALL_LOG_FILE);
res = -1;
goto __ret;
}
for (j=0; j<=1; j++) {
// loop for two log files
if (j == 1) {
// Master.csv
if (fp)
// close the old one if exist
fclose(fp);
fp = fopen(CALL_LOG_FILE, "r");
if (!fp) {
BBF_DEBUG("Call log file %s doesn't exist\n", CALL_LOG_FILE);
res = -1;
goto __ret;
}
struct call_log_entry buf_cdr = { {NULL, NULL}, };
DM_STRNCPY(buf_cdr.sessionId, "First", sizeof(buf_cdr.sessionId));
bool line_record = false;
do {
if(fgets(line, sizeof(line), fp) != NULL) {
line_record = true;
} else if (!line_record) {
// empty file, jump out without write
continue;
} else {
// Master_old.csv
fp = fopen(CALL_LOG_FILE_OLD, "r");
if (!fp) {
BBF_DEBUG("Call log file %s doesn't exist\n", CALL_LOG_FILE_OLD);
// continue to Master.csv if _old not exist
continue;
}
line_record = false; // reaching the end, no new record from file.
// last buf need to be written.
}
while (fgets(line, sizeof(line), fp) != NULL) {
struct call_log_entry cdr = { {NULL, NULL}, };
struct call_log_entry cdr = { {NULL, NULL}, };
if ( line_record ){
char end_time[sizeof(cdr.start_time)] = "";
char *token, *end;
/*
@ -188,277 +235,292 @@ int init_call_log(void)
* "1598364701.4",""
*/
// calling number
token = strstr(line, SEPARATOR);
token = DM_LSTRSTR(line, SEPARATOR);
CHECK_RESULT(token);
token += SEPARATOR_SIZE;
end = strstr(token, SEPARATOR);
end = DM_LSTRSTR(token, SEPARATOR);
CHECK_RESULT(end);
strncpy(cdr.calling_num, token, end - token);
DM_STRNCPY(cdr.calling_num, token, end - token + 1);
// called number
token = end + SEPARATOR_SIZE;
end = strstr(token, SEPARATOR);
end = DM_LSTRSTR(token, SEPARATOR);
CHECK_RESULT(end);
strncpy(cdr.called_num, token, end - token);
DM_STRNCPY(cdr.called_num, token, end - token + 1);
// source
token = end + SEPARATOR_SIZE; // sip0 in the last example
token = strstr(token, SEPARATOR);
token = DM_LSTRSTR(token, SEPARATOR);
CHECK_RESULT(token);
token += SEPARATOR_SIZE; // ""8001"" <8001> in the last example
token = strstr(token, SEPARATOR);
token = DM_LSTRSTR(token, SEPARATOR);
CHECK_RESULT(token);
token += SEPARATOR_SIZE; // TELCHAN/5/1 in the last example
end = strstr(token, SEPARATOR);
end = DM_LSTRSTR(token, SEPARATOR);
CHECK_RESULT(end);
strncpy(cdr.source, token, end - token);
DM_STRNCPY(cdr.source, token, end - token + 1);
// destination
token = end + SEPARATOR_SIZE; // SIP/sip0-00000001 in the last example
end = strstr(token, SEPARATOR);
end = DM_LSTRSTR(token, SEPARATOR);
CHECK_RESULT(end);
strncpy(cdr.destination, token, end - token);
DM_STRNCPY(cdr.destination, token, end - token + 1);
// start time and end time
token = end + SEPARATOR_SIZE; // Dial in the last example
token = strstr(token, SEPARATOR);
token = DM_LSTRSTR(token, SEPARATOR);
CHECK_RESULT(token);
token += SEPARATOR_SIZE; // SIP/7001@sip0,,gT in the last example
token = strstr(token, SEPARATOR);
CHECK_RESULT(token);
token += SEPARATOR_SIZE; // The first date
end = strstr(token, "\",,\"");
end = DM_LSTRSTR(token, SEPARATOR);
CHECK_RESULT(end);
DM_STRNCPY(cdr.used_extensions, token, end - token + 1);
token = end + SEPARATOR_SIZE; // The first date
end = DM_LSTRSTR(token, "\",,\"");
if (end) {
// Not answered, e.g. "2020-08-27 11:02:40",,"2020-08-27 11:02:40",21,11,
strncpy(cdr.start_time, token, end - token);
DM_STRNCPY(cdr.start_time, token, end - token + 1);
token = end + 4;
} else {
// Answered, e.g. "2020-08-25 16:11:41","2020-08-25 16:11:50","2020-08-25 16:12:02",21,11,
end = strstr(token, SEPARATOR);
end = DM_LSTRSTR(token, SEPARATOR);
CHECK_RESULT(end);
strncpy(cdr.start_time, token, end - token);
token = strstr(end + SEPARATOR_SIZE, SEPARATOR); // Skip the middle date and come to the last date
DM_STRNCPY(cdr.start_time, token, end - token + 1);
token = DM_LSTRSTR(end + SEPARATOR_SIZE, SEPARATOR); // Skip the middle date and come to the last date
CHECK_RESULT(token);
token += SEPARATOR_SIZE;
}
end = strstr(token, "\",");
end = DM_LSTRSTR(token, "\",");
CHECK_RESULT(end);
strncpy(end_time, token, end - token);
DM_STRNCPY(end_time, token, end - token + 1);
// termination cause
token = strstr(end + 2, ",\""); // ANSWERED in the last example
token = DM_LSTRSTR(end + 2, ",\""); // ANSWERED in the last example
CHECK_RESULT(token);
token += 2;
end = strstr(token, SEPARATOR);
end = DM_LSTRSTR(token, "\",");
CHECK_RESULT(end);
strncpy(cdr.termination_cause, token, end - token);
DM_STRNCPY(cdr.termination_cause, token, end - token + 1);
// session id
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.sessionId, token, end - token);
DM_STRNCPY(cdr.sessionId, token, end - token + 1);
// SIP IP Address
token = strstr(token, ",\"");
token = DM_LSTRSTR(token, ",\"");
CHECK_RESULT(token);
token += 2;
end = strstr(token, "\",");
end = DM_LSTRSTR(token, "\",");
CHECK_RESULT(end);
strncpy(cdr.sipIpAddress, token, end - token);
DM_STRNCPY(cdr.sipIpAddress, token, end - token + 1);
// Far End IP Address
token = strstr(token, ",\"");
token = DM_LSTRSTR(token, ",\"");
CHECK_RESULT(token);
token += 2;
end = strstr(token, "\",");
end = DM_LSTRSTR(token, "\",");
CHECK_RESULT(end);
strncpy(cdr.farEndIPAddress, token, end - token);
DM_STRNCPY(cdr.farEndIPAddress, token, end - token + 1);
// Sip Response Code
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.sipResponseCode, token, end - token);
DM_STRNCPY(cdr.sipResponseCode, token, end - token + 1);
// Codec
token = strstr(token, ",\"");
token = DM_LSTRSTR(token, ",\"");
CHECK_RESULT(token);
token += 2;
end = strstr(token, "\",");
end = DM_LSTRSTR(token, "\",");
CHECK_RESULT(end);
strncpy(cdr.codec, token, end - token);
DM_STRNCPY(cdr.codec, token, end - token + 1);
// RTP statistic values
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.localBurstDensity, token, end - token);
DM_STRNCPY(cdr.localBurstDensity, token, end - token + 1);
// for incoming unanswered call cdr does not contain RTP stats
if (strcasecmp(cdr.localBurstDensity, "\"DOCUMENTATION\"") == 0) {
cdr.localBurstDensity[0] = '\0';
} else {
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.remoteBurstDensity, token, end - token);
DM_STRNCPY(cdr.remoteBurstDensity, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.localBurstDuration, token, end - token);
DM_STRNCPY(cdr.localBurstDuration, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.remoteBurstDuration, token, end - token);
DM_STRNCPY(cdr.remoteBurstDuration, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.localGapDensity, token, end - token);
DM_STRNCPY(cdr.localGapDensity, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.remoteGapDensity, token, end - token);
DM_STRNCPY(cdr.remoteGapDensity, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.localGapDuration, token, end - token);
DM_STRNCPY(cdr.localGapDuration, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.remoteGapDuration, token, end - token);
DM_STRNCPY(cdr.remoteGapDuration, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.localJbRate, token, end - token);
DM_STRNCPY(cdr.localJbRate, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.remoteJbRate, token, end - token);
DM_STRNCPY(cdr.remoteJbRate, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.localJbMax, token, end - token);
DM_STRNCPY(cdr.localJbMax, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.remoteJbMax, token, end - token);
DM_STRNCPY(cdr.remoteJbMax, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.localJbNominal, token, end - token);
DM_STRNCPY(cdr.localJbNominal, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.remoteJbNominal, token, end - token);
DM_STRNCPY(cdr.remoteJbNominal, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.localJbAbsMax, token, end - token);
DM_STRNCPY(cdr.localJbAbsMax, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.remoteJbAbsMax, token, end - token);
DM_STRNCPY(cdr.remoteJbAbsMax, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.jbAvg, token, end - token);
DM_STRNCPY(cdr.jbAvg, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.uLossRate, token, end - token);
DM_STRNCPY(cdr.uLossRate, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.discarded, token, end - token);
DM_STRNCPY(cdr.discarded, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.lost, token, end - token);
DM_STRNCPY(cdr.lost, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.rxpkts, token, end - token);
DM_STRNCPY(cdr.rxpkts, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.txpkts, token, end - token);
DM_STRNCPY(cdr.txpkts, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.jitter, token, end - token);
DM_STRNCPY(cdr.jitter, token, end - token + 1);
token = strstr(token, ",");
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = strstr(token, ",");
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
strncpy(cdr.maxJitter, token, end - token);
DM_STRNCPY(cdr.maxJitter, token, end - token + 1);
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
DM_STRNCPY(cdr.averageRoundTripDelay, token, end - token + 1);
token = DM_LSTRSTR(token, ",");
CHECK_RESULT(token);
token += 1;
end = DM_LSTRSTR(token, ",");
CHECK_RESULT(end);
DM_STRNCPY(cdr.averageFarEndInterarrivalJitter, token, end - token + 1);
}
// Skip invalid call logs
if (cdr.calling_num[0] == '\0' || cdr.called_num[0] == '\0' ||
@ -490,19 +552,27 @@ int init_call_log(void)
line, cdr.start_time, end_time);
continue;
}
// Determine the call direction and used line
char *tel_line = NULL;
if ((tel_line = strcasestr(cdr.source, "TELCHAN")) != NULL) {
char *used_line = NULL;
if ((used_line = strcasestr(cdr.source, "TELCHAN")) != NULL) {
DM_STRNCPY(cdr.direction, "Outgoing", sizeof(cdr.direction));
} else if ((tel_line = strcasestr(cdr.destination, "TELCHAN")) != NULL) {
used_line = strcasestr(cdr.destination, "SIP/sip");
DM_STRNCPY(cdr.used_extensions, cdr.source, sizeof(cdr.used_extensions));
} else if ((used_line = strcasestr(cdr.destination, "TELCHAN")) != NULL) {
DM_STRNCPY(cdr.direction, "Incoming", sizeof(cdr.direction));
used_line = strcasestr(cdr.source, "SIP/sip");
} else if ( ((used_line = strcasestr(cdr.source, "SIP/sip")) != NULL) && ((used_line = strcasestr(cdr.destination, "SIP/sip")) != NULL) ) {
DM_STRNCPY(cdr.direction, "", sizeof(cdr.direction)); //TODO fix this section for 3-way, call forward
} else {
BBF_DEBUG("Invalid CDR: [%s]\ndirection = [%s]\n", line, cdr.direction);
continue;
}
DM_STRNCPY(cdr.used_line, tel_line, sizeof(cdr.used_line));
if (used_line == NULL){
// for internal call with extension number 0000/1111/2222/333
DM_STRNCPY(cdr.used_line, "", sizeof(cdr.used_line));
} else {
DM_STRNCPY(cdr.used_line, used_line, sizeof(cdr.used_line)); // "SIP/sip0-00000000"
}
/*
* Convert the termination cause to a value specified in TR-104.
*
@ -524,37 +594,56 @@ int init_call_log(void)
else
DM_STRNCPY(cdr.termination_cause, "LocalInternalError", sizeof(cdr.termination_cause));
// Convert source and destination
convert_src_dst(cdr.source, sizeof(cdr.source));
convert_src_dst(cdr.destination, sizeof(cdr.destination));
convert_src_dst(cdr.used_line, sizeof(cdr.used_line));
convert_src_dst(cdr.source, sizeof(cdr.source)); // CallControl.Extension.{i} or SIP.Client.{i}
convert_src_dst(cdr.destination, sizeof(cdr.destination)); // CallControl.Extension.{i} or SIP.Client.{i}
// Convert used line to line{i}
// TODO correspond CallControl.Line.{i}
convert_sip_line(cdr.used_line, sizeof(cdr.used_line));
convert_used_extensions(cdr.used_extensions, sizeof(cdr.used_extensions));
// Find out an existing call log entry or create a new one
if (i < call_log_list_size) {
if (i > 0) {
pos = pos->next;
entry = list_entry(pos, struct call_log_entry, list);
} else {
entry = list_first_entry(&call_log_list, struct call_log_entry, list);
pos = &entry->list;
}
} else {
entry = dm_dynamic_malloc(&main_memhead, sizeof(struct call_log_entry));
if (!entry)
return -1;
list_add_tail(&entry->list, &call_log_list);
call_log_list_size++;
// check session id with the record in buf
// skip for the first record, and put into buf
if (strcmp(buf_cdr.sessionId, "First")==0) {
buf_cdr = cdr; // first record to buf
continue;
}
// if having the same session id and the same starting time, then skip writing and modify the buf
if ( (strcmp(cdr.sessionId, buf_cdr.sessionId)==0) && (strcmp(cdr.start_time, buf_cdr.start_time)==0) ) {
if ( (!sip_response_checker(buf_cdr.sipResponseCode)) && ( sip_response_checker(cdr.sipResponseCode) || strcmp(cdr.sipResponseCode, buf_cdr.sipResponseCode)>0) ) {
buf_cdr = cdr; // drop the previous record as same session id and the current response code has a higher priority
}
continue; // continue for next record, and see if still having the same seesion id.
} // if having a different session id, then writing the buf to entry, and move the current to buf.
} // if only last buf left. write directly.
// Find out an existing call log entry or create a new one
if (i < call_log_list_size) {
if (i > 0) {
pos = pos->next;
entry = list_entry(pos, struct call_log_entry, list);
} else {
entry = list_first_entry(&call_log_list, struct call_log_entry, list);
pos = &entry->list;
}
} else {
entry = dm_dynamic_malloc(&main_memhead, sizeof(struct call_log_entry));
if (!entry)
return -1;
// Fill out the entry
struct list_head tmp = entry->list;
memcpy(entry, &cdr, sizeof(*entry));
entry->list = tmp;
// Increase the call log count
i++;
list_add_tail(&entry->list, &call_log_list);
call_log_list_size++;
}
}
// Fill out the entry with the record in buf
struct list_head tmp = entry->list;
memcpy(entry, &buf_cdr, sizeof(*entry));
entry->list = tmp;
// Increase the call log count
i++;
// put current record to buf
buf_cdr = cdr;
} while (line_record);
// The total number of call logs could be less than the list size in case that old call logs have been removed
call_log_count = i;
@ -602,3 +691,66 @@ const char *get_codec_name(const char *codec_profile)
return NULL;
}
/*Get the Alias parameter value by section*/
int get_Alias_value_by_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value, char *service_name, char* service_inst)
{
struct uci_section *s = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap", service_name, service_inst, instance, s) {
dmuci_get_value_by_section_string(s, "alias", value);
break;
}
if ((*value)[0] == '\0')
dmasprintf(value, "cpe-%s", instance);
return 0;
}
/*Set the Alias paramter value by section*/
int set_Alias_value_by_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action, char *service_name, char* service_inst)
{
struct uci_section *s = NULL, *dmmap = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 64, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
uci_path_foreach_option_eq(bbfdm, "dmmap", service_name, service_inst, instance, s) {
dmuci_set_value_by_section_bbfdm(s, "alias", value);
return 0;
}
dmuci_add_section_bbfdm("dmmap", service_name, &dmmap);
dmuci_set_value_by_section(dmmap, service_inst, instance);
dmuci_set_value_by_section(dmmap, "alias", value);
break;
}
return 0;
}
/*Get Alias parameter value by section string*/
int get_Alias_value_by_inst(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value, char *alias_inst)
{
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, alias_inst, value);
if ((*value)[0] == '\0')
dmasprintf(value, "cpe-%s", instance);
return 0;
}
/*Set Alias parameter value by section string*/
int set_Alias_value_by_inst(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action, char *alias_inst)
{
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 64, NULL, NULL))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, alias_inst, value);
break;
}
return 0;
}

View file

@ -8,7 +8,7 @@
* Author: Yalu Zhang, yalu.zhang@iopsys.eu
*/
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
#define TR104_UCI_PACKAGE "asterisk"
#define DEFAULT_SIP_PORT_STR "5060"
@ -25,8 +25,8 @@ struct codec_info {
struct call_log_entry {
struct list_head list;
char calling_num[20], called_num[20];
char source[64], destination[64], used_line[64];
char calling_num[256], called_num[256];
char source[256], destination[256], used_line[256], used_extensions[256];
char direction[16];
char start_time[32];
char duration[8];
@ -60,6 +60,8 @@ struct call_log_entry {
char txpkts[20];
char jitter[20];
char maxJitter[20];
char averageRoundTripDelay[20];
char averageFarEndInterarrivalJitter[20];
};
#define MAX_SUPPORTED_CODECS 8
@ -75,8 +77,13 @@ extern char *RegistrarServerTransport[];
extern char *DTMFMethod[];
extern char *JitterBufferType[];
extern char *KeyingMethods[];
extern char *FacilityAction[];
int init_supported_codecs(void);
int init_call_log(void);
const char *get_codec_uci_name(const char *codec);
const char *get_codec_name(const char *codec_profile);
int get_Alias_value_by_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value, char *service_name, char* service_inst);
int set_Alias_value_by_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action, char *service_name, char* service_inst);
int get_Alias_value_by_inst(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value, char *alias_inst);
int set_Alias_value_by_inst(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action, char *alias_inst);

View file

@ -234,6 +234,13 @@ static int set_service_alias(char *refparam, struct dmctx *ctx, void *data, char
return 0;
}
static int get_ServicesVoiceService_CallLogNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int cnt = get_number_of_entries(ctx, data, instance, browseServicesVoiceServiceCallLogInst);
dmasprintf(value, "%d", cnt);
return 0;
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
@ -262,5 +269,6 @@ DMOBJ tServicesVoiceServiceObj[] = {
DMLEAF tServicesVoiceServiceParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_service_alias, set_service_alias, BBFDM_BOTH},
{"CallLogNumberOfEntries", &DMREAD, DMT_UNINT, get_ServicesVoiceService_CallLogNumberOfEntries, NULL, BBFDM_BOTH},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __SERVICESVOICESERVICE_H
#define __SERVICESVOICESERVICE_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tServicesObj[];
extern DMOBJ tServicesVoiceServiceObj[];

File diff suppressed because it is too large Load diff

View file

@ -11,13 +11,17 @@
#ifndef __SERVICESVOICESERVICECALLCONTROL_H
#define __SERVICESVOICESERVICECALLCONTROL_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tServicesVoiceServiceCallControlObj[];
extern DMLEAF tServicesVoiceServiceCallControlLineParams[];
extern DMLEAF tServicesVoiceServiceCallControlIncomingMapParams[];
extern DMLEAF tServicesVoiceServiceCallControlOutgoingMapParams[];
extern DMLEAF tServicesVoiceServiceCallControlGroupParams[];
extern DMLEAF tServicesVoiceServiceCallControlExtensionParams[];
extern DMLEAF tServicesVoiceServiceCallControlNumberingPlanParams[];
extern DMOBJ tServicesVoiceServiceCallControlNumberingPlanObj[];
extern DMLEAF tServicesVoiceServiceCallControlNumberingPlanPrefixInfoParams[];
extern DMOBJ tServicesVoiceServiceCallControlCallingFeaturesObj[];
extern DMOBJ tServicesVoiceServiceCallControlCallingFeaturesSetObj[];
extern DMLEAF tServicesVoiceServiceCallControlCallingFeaturesSetParams[];

View file

@ -80,6 +80,17 @@ static int get_ServicesVoiceServiceCallLog_UsedLine(char *refparam, struct dmctx
return 0;
}
static int get_ServicesVoiceServiceCallLog_UsedExtensions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct call_log_entry *entry = (struct call_log_entry *)data;
if (entry) {
*value = dmstrdup(entry->used_extensions);
}
return 0;
}
static int get_ServicesVoiceServiceCallLog_Direction(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct call_log_entry *entry = (struct call_log_entry *)data;
@ -193,6 +204,31 @@ static int get_ServicesVoiceServiceCallLog_Src_MaxJitter(char *refparam, struct
return 0;
}
static int get_ServicesVoiceServiceCallLog_Src_AverageRoundTripDelay(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct call_log_entry *entry = (struct call_log_entry *)data;
*value = (entry) ? dmstrdup(entry->averageRoundTripDelay) : "0";
return 0;
}
static int get_ServicesVoiceServiceCallLog_Src_AverageFarEndInterarrivalJitter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct call_log_entry *entry = (struct call_log_entry *)data;
*value = (entry) ? dmstrdup(entry->averageFarEndInterarrivalJitter) : "0";
return 0;
}
/* Get Alias - Device.Services.VoiceService.{i}.CallLog.{i}. */
static int get_ServicesVoiceServiceCallLog_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_Alias_value_by_name(refparam, ctx, data, instance, value, "callLog", "callLog_inst");
}
/* Set Alias - Device.Services.VoiceService.{i}.CallLog.{i}. */
static int set_ServicesVoiceServiceCallLog_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_Alias_value_by_name(refparam, ctx, data, instance, value, action, "callLog", "callLog_inst");
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
@ -210,10 +246,12 @@ DMLEAF tServicesVoiceServiceCallLogParams[] = {
{"Source", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCallLog_Source, NULL, BBFDM_BOTH},
{"Destination", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCallLog_Destination, NULL, BBFDM_BOTH},
{"UsedLine", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCallLog_UsedLine, NULL, BBFDM_BOTH},
{"UsedExtensions", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCallLog_UsedExtensions, NULL, BBFDM_BOTH},
{"Direction", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCallLog_Direction, NULL, BBFDM_BOTH},
{"Start", &DMREAD, DMT_TIME, get_ServicesVoiceServiceCallLog_Start, NULL, BBFDM_BOTH},
{"Duration", &DMREAD, DMT_UNINT, get_ServicesVoiceServiceCallLog_Duration, NULL, BBFDM_BOTH},
{"CallTerminationCause", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCallLog_CallTerminationCause, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceCallLog_Alias, set_ServicesVoiceServiceCallLog_Alias, BBFDM_BOTH},
{0}
};
@ -291,5 +329,7 @@ DMLEAF tServicesVoiceServiceCallLogSessionSourceRTPParams[] = {
{"FarEndInterarrivalJitter", &DMREAD, DMT_INT, get_ServicesVoiceServiceCallLog_Src_FarEndInterarrivalJitter, NULL, BBFDM_BOTH},
{"FarEndPacketLossRate", &DMREAD, DMT_UNINT, get_ServicesVoiceServiceCallLog_Src_FarEndPacketLossRate, NULL, BBFDM_BOTH},
{"MaxJitter", &DMREAD, DMT_INT, get_ServicesVoiceServiceCallLog_Src_MaxJitter, NULL, BBFDM_BOTH},
{"AverageRoundTripDelay", &DMREAD, DMT_INT, get_ServicesVoiceServiceCallLog_Src_AverageRoundTripDelay, NULL, BBFDM_BOTH},
{"AverageFarEndInterarrivalJitter", &DMREAD, DMT_INT, get_ServicesVoiceServiceCallLog_Src_AverageFarEndInterarrivalJitter, NULL, BBFDM_BOTH},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __SERVICESVOICESERVICECALLLOG_H
#define __SERVICESVOICESERVICECALLLOG_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tServicesVoiceServiceCallLogObj[];
extern DMLEAF tServicesVoiceServiceCallLogParams[];

View file

@ -57,17 +57,15 @@ static int get_ServicesVoiceServiceCapabilities_MaxSessionsPerLine(char *refpara
return 0;
}
static int get_ServicesVoiceServiceCapabilities_MaxSessionsPerExtension(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "2";
return 0;
}
static int get_ServicesVoiceServiceCapabilities_MaxSessionCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *max_line;
db_get_value_string("hw", "board", "VoicePorts", &max_line);
if (max_line && *max_line) {
int max_session = 2 * atoi(max_line);
dmasprintf(value, "%d", max_session);
} else
*value = "-1";
*value = "4";
return 0;
}
@ -172,6 +170,16 @@ static int get_ServicesVoiceServiceCapabilitiesCodec_PacketizationPeriod(char *r
return 0;
}
static int get_ServicesVoiceServiceCapabilities_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_Alias_value_by_name(refparam, ctx, data, instance, value, "Capabilities", "Capabilities_inst");
}
static int set_ServicesVoiceServiceCapabilities_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_Alias_value_by_name(refparam, ctx, data, instance, value, action, "Capabilities", "Capabilities_inst");
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
@ -188,6 +196,7 @@ DMLEAF tServicesVoiceServiceCapabilitiesParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"MaxLineCount", &DMREAD, DMT_INT, get_ServicesVoiceServiceCapabilities_MaxLineCount, NULL, BBFDM_BOTH},
{"MaxSessionsPerLine", &DMREAD, DMT_INT, get_ServicesVoiceServiceCapabilities_MaxSessionsPerLine, NULL, BBFDM_BOTH},
{"MaxSessionsPerExtension", &DMREAD, DMT_INT, get_ServicesVoiceServiceCapabilities_MaxSessionsPerExtension, NULL, BBFDM_BOTH},
{"MaxSessionCount", &DMREAD, DMT_INT, get_ServicesVoiceServiceCapabilities_MaxSessionCount, NULL, BBFDM_BOTH},
{"NetworkConnectionModes", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCapabilities_NetworkConnectionModes, NULL, BBFDM_BOTH},
{"UserConnectionModes", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCapabilities_UserConnectionModes, NULL, BBFDM_BOTH},
@ -229,6 +238,7 @@ DMLEAF tServicesVoiceServiceCapabilitiesCodecParams[] = {
{"Codec", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCapabilitiesCodec_Codec, NULL, BBFDM_BOTH},
{"BitRate", &DMREAD, DMT_UNINT, get_ServicesVoiceServiceCapabilitiesCodec_BitRate, NULL, BBFDM_BOTH},
{"PacketizationPeriod", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCapabilitiesCodec_PacketizationPeriod, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceCapabilities_Alias, set_ServicesVoiceServiceCapabilities_Alias, BBFDM_BOTH},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __SERVICESVOICESERVICECAPABILITIES_H
#define __SERVICESVOICESERVICECAPABILITIES_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tServicesVoiceServiceCapabilitiesObj[];
extern DMLEAF tServicesVoiceServiceCapabilitiesParams[];

View file

@ -8,7 +8,6 @@
* Author: Yalu Zhang, yalu.zhang@iopsys.eu
*/
#include "dmentry.h"
#include "servicesvoiceservicecodecprofile.h"
#include "common.h"
@ -18,12 +17,10 @@
/*#Device.Services.VoiceService.{i}.CodecProfile.{i}.Codec!UCI:asterisk/codec_profile,@i-1/name*/
static int get_ServicesVoiceServiceCodecProfile_Codec(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker;
char *linker = NULL;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "name", &linker);
adm_entry_get_linker_param(ctx, "Device.Services.VoiceService.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
@ -48,6 +45,18 @@ static int set_ServicesVoiceServiceCodecProfile_PacketizationPeriod(char *refpar
return 0;
}
/*Get Device.Services.VoiceService.{i}.CodecProfile.{i}. Alias*/
static int get_ServicesVoiceServiceCodecProfile_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_Alias_value_by_inst(refparam, ctx, data, instance, value, "codecprofilealias");
}
/*Set Device.Services.VoiceService.{i}.CodecProfile.{i}. Alias*/
static int set_ServicesVoiceServiceCodecProfile_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_Alias_value_by_inst(refparam, ctx, data, instance, value, action, "codecprofilealias");
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
@ -56,6 +65,7 @@ DMLEAF tServicesVoiceServiceCodecProfileParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Codec", &DMREAD, DMT_STRING, get_ServicesVoiceServiceCodecProfile_Codec, NULL, BBFDM_BOTH},
{"PacketizationPeriod", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceCodecProfile_PacketizationPeriod, set_ServicesVoiceServiceCodecProfile_PacketizationPeriod, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceCodecProfile_Alias, set_ServicesVoiceServiceCodecProfile_Alias, BBFDM_BOTH},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __SERVICESVOICESERVICECODECPROFILE_H
#define __SERVICESVOICESERVICECODECPROFILE_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMLEAF tServicesVoiceServiceCodecProfileParams[];

View file

@ -10,6 +10,15 @@
#include "servicesvoiceservicedect.h"
/**************************************************************************
* LINKER
***************************************************************************/
static int get_voice_service_dect_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
*linker = data ? dmjson_get_value((json_object *)data, 1, "ipui") : "";
return 0;
}
/*************************************************************
* ENTRY METHOD
**************************************************************/
@ -18,10 +27,11 @@ static int browseServicesVoiceServiceDECTBaseInst(struct dmctx *dmctx, DMNODE *p
{
json_object *res = NULL, *obj = NULL, *arrobj = NULL;
char *inst = NULL;
int id = 0, i = 0;
dmubus_call("dect", "status", UBUS_ARGS{}, 0, &res);
dmubus_call("dect", "status", UBUS_ARGS{0}, 0, &res);
if (res) {
int id = 0, i = 0;
dmjson_foreach_obj_in_array(res, arrobj, obj, i, 1, "base") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
@ -38,13 +48,22 @@ static int browseServicesVoiceServiceDECTPortableInst(struct dmctx *dmctx, DMNOD
{
json_object *res = NULL, *obj = NULL, *arrobj = NULL;
char *inst = NULL;
int id = 0, i = 0;
dmubus_call("dect", "status", UBUS_ARGS{}, 0, &res);
dmubus_call("dect", "status", UBUS_ARGS{0}, 0, &res);
if (res) {
dmjson_foreach_obj_in_array(res, arrobj, obj, i, 1, "handsets") {
int id = 0, i = 0;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
dmjson_foreach_obj_in_array(res, arrobj, obj, i, 1, "handsets") {
char *str_id = dmjson_get_value(obj, 1, "id");
/* Use the id from the UBUS call if it is found */
if (str_id && *str_id) {
id = DM_STRTOL(str_id);
} else {
id++;
}
inst = handle_instance_without_section(dmctx, parent_node, id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)obj, inst) == DM_STOP)
break;
@ -60,9 +79,9 @@ static int browseServicesVoiceServiceDECTPortableInst(struct dmctx *dmctx, DMNOD
static int get_ServicesVoiceServiceDECT_BaseNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
size_t num = 0;
json_object *res, *base;
json_object *res = NULL, *base;
dmubus_call("dect", "status", UBUS_ARGS{}, 0, &res);
dmubus_call("dect", "status", UBUS_ARGS{0}, 0, &res);
DM_ASSERT(res, *value = "0");
json_object_object_get_ex(res, "base", &base);
@ -77,9 +96,9 @@ static int get_ServicesVoiceServiceDECT_BaseNumberOfEntries(char *refparam, stru
static int get_ServicesVoiceServiceDECT_PortableNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
size_t num = 0;
json_object *res, *handsets;
json_object *res = NULL, *handsets;
dmubus_call("dect", "status", UBUS_ARGS{}, 0, &res);
dmubus_call("dect", "status", UBUS_ARGS{0}, 0, &res);
DM_ASSERT(res, *value = "0");
json_object_object_get_ex(res, "handsets", &handsets);
@ -310,12 +329,13 @@ static int get_ServicesVoiceServiceDECTPortable_IPUI(char *refparam, struct dmct
static int get_ServicesVoiceServiceDECTPortable_IPEI(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *ipui = dmjson_get_value((json_object *)data, 1, "ipui");
char buff[14] = {0};
*value = "";
// Check for N type PUT
if (ipui[0] == '0') {
strcpy(buff, &ipui[1]);
char buff[14] = {0};
DM_STRNCPY(buff, &ipui[1], sizeof(buff));
dmasprintf(value, "%s0", buff);
}
@ -345,8 +365,7 @@ static int get_ServicesVoiceServiceDECTPortable_BaseAttachedTo(char *refparam, s
/*#Device.Services.VoiceService.{i}.DECT.Portable.{i}.PortableType!UBUS:dect/status//handsets[@i-1].portable_type*/
static int get_ServicesVoiceServiceDECTPortable_PortableType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "portable_type");
*value = dmjson_get_value((json_object *)data, 1, "portable_type");
return 0;
}
@ -397,7 +416,7 @@ static int get_ServicesVoiceServiceDECTPortable_LastUpdateDateTime(char *refpara
DMOBJ tServicesVoiceServiceDECTObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Base", &DMREAD, NULL, NULL, NULL, browseServicesVoiceServiceDECTBaseInst, NULL, NULL, NULL, tServicesVoiceServiceDECTBaseParams, NULL, BBFDM_BOTH, LIST_KEY{"RFPI", "Name", "Alias", NULL}},
{"Portable", &DMREAD, NULL, NULL, NULL, browseServicesVoiceServiceDECTPortableInst, NULL, NULL, NULL, tServicesVoiceServiceDECTPortableParams, NULL, BBFDM_BOTH, LIST_KEY{"IPEI", "Alias", NULL}},
{"Portable", &DMREAD, NULL, NULL, NULL, browseServicesVoiceServiceDECTPortableInst, NULL, NULL, NULL, tServicesVoiceServiceDECTPortableParams, get_voice_service_dect_linker, BBFDM_BOTH, LIST_KEY{"IPEI", "Alias", NULL}},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __SERVICESVOICESERVICEDECT_H
#define __SERVICESVOICESERVICEDECT_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tServicesVoiceServiceDECTObj[];
extern DMLEAF tServicesVoiceServiceDECTParams[];

View file

@ -11,30 +11,38 @@
#include "servicesvoiceservicepots.h"
#include "common.h"
/**************************************************************************
* LINKER
***************************************************************************/
static int get_voice_service_pots_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
*linker = data ? section_name(((struct dmmap_dup *)data)->config_section) : "";
return 0;
}
/*************************************************************
* ENTRY METHOD
**************************************************************/
/*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.!UCI:asterisk/tel_line/dmmap_asterisk*/
/*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.!UCI:asterisk/extension/dmmap_asterisk*/
static int browseServicesVoiceServicePOTSFXSInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *inst = NULL;
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("asterisk", "tel_line", "dmmap_asterisk", &dup_list);
synchronize_specific_config_sections_with_dmmap("asterisk", "extension", "dmmap_asterisk", &dup_list);
list_for_each_entry(p, &dup_list, list) {
char *line_name = NULL;
dmuci_get_value_by_section_string(p->config_section, "name", &line_name);
if (line_name && (*line_name == '\0' || strcasestr(line_name, "DECT") == NULL)) {
char *line_type = NULL;
dmuci_get_value_by_section_string(p->config_section, "type", &line_type);
if (line_type && (strcasecmp(line_type, "fxs") == 0)) {
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "fxsinstance", "fxsalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
break;
}
if (line_name && *line_name)
dmfree(line_name);
if (line_type && *line_type)
dmfree(line_type);
}
free_dmmap_config_dup_list(&dup_list);
return 0;
@ -121,7 +129,7 @@ static int get_ServicesVoiceServicePOTSFXS_TerminalType(char *refparam, struct d
return 0;
}
/*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.VoiceProcessing.TransmitGain!UCI:asterisk/tel_line,@i-1/txgain*/
/*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.VoiceProcessing.TransmitGain!UCI:asterisk/extension,@i-1/txgain*/
static int get_ServicesVoiceServicePOTSFXSVoiceProcessing_TransmitGain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "txgain", "0");
@ -142,7 +150,7 @@ static int set_ServicesVoiceServicePOTSFXSVoiceProcessing_TransmitGain(char *ref
return 0;
}
/*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.VoiceProcessing.ReceiveGain!UCI:asterisk/tel_line,@i-1/rxgain*/
/*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.VoiceProcessing.ReceiveGain!UCI:asterisk/extension,@i-1/rxgain*/
static int get_ServicesVoiceServicePOTSFXSVoiceProcessing_ReceiveGain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "rxgain", "0");
@ -163,7 +171,7 @@ static int set_ServicesVoiceServicePOTSFXSVoiceProcessing_ReceiveGain(char *refp
return 0;
}
/*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.VoiceProcessing.EchoCancellationEnable!UCI:asterisk/tel_line,@i-1/echo_cancel*/
/*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.VoiceProcessing.EchoCancellationEnable!UCI:asterisk/extension,@i-1/echo_cancel*/
static int get_ServicesVoiceServicePOTSFXSVoiceProcessing_EchoCancellationEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "echo_cancel", "1");
@ -187,13 +195,24 @@ static int set_ServicesVoiceServicePOTSFXSVoiceProcessing_EchoCancellationEnable
return 0;
}
/*Get Device.Services.VoiceService.{i}.POTS.FXS.{i}. Alias*/
static int get_ServicesVoiceServicePOTSFXS_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_Alias_value_by_inst(refparam, ctx, data, instance, value, "clientalias");
}
/*Set Device.Services.VoiceService.{i}.POTS.FXS.{i}. Alias*/
static int set_ServicesVoiceServicePOTSFXS_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_Alias_value_by_inst(refparam, ctx, data, instance, value, action, "clientalias");
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
/* *** Device.Services.VoiceService.{i}.POTS. *** */
DMOBJ tServicesVoiceServicePOTSObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"FXS", &DMREAD, NULL, NULL, NULL, browseServicesVoiceServicePOTSFXSInst, NULL, NULL, tServicesVoiceServicePOTSFXSObj, tServicesVoiceServicePOTSFXSParams, NULL, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
{"FXS", &DMREAD, NULL, NULL, NULL, browseServicesVoiceServicePOTSFXSInst, NULL, NULL, tServicesVoiceServicePOTSFXSObj, tServicesVoiceServicePOTSFXSParams, get_voice_service_pots_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
{0}
};
@ -218,6 +237,7 @@ DMLEAF tServicesVoiceServicePOTSFXSParams[] = {
{"ClipGeneration", &DMWRITE, DMT_BOOL, get_ServicesVoiceServicePOTSFXS_ClipGeneration, set_ServicesVoiceServicePOTSFXS_ClipGeneration, BBFDM_BOTH},
{"Active", &DMREAD, DMT_BOOL, get_ServicesVoiceServicePOTSFXS_Active, NULL, BBFDM_BOTH},
{"TerminalType", &DMREAD, DMT_STRING, get_ServicesVoiceServicePOTSFXS_TerminalType, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_ServicesVoiceServicePOTSFXS_Alias, set_ServicesVoiceServicePOTSFXS_Alias, BBFDM_BOTH},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __SERVICESVOICESERVICEPOTS_H
#define __SERVICESVOICESERVICEPOTS_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tServicesVoiceServicePOTSObj[];
extern DMLEAF tServicesVoiceServicePOTSParams[];

View file

@ -18,8 +18,8 @@ static int get_reserved_port_range(char **value)
{
char *start = NULL, *end = NULL;
dmuci_get_option_value_string("asterisk", "sip_options", "rtpstart", &start);
dmuci_get_option_value_string("asterisk", "sip_options", "rtpend", &end);
dmuci_get_option_value_string("asterisk", "sip_options", "rtp_start", &start);
dmuci_get_option_value_string("asterisk", "sip_options", "rtp_end", &end);
if (start && *start && end && *end) {
dmasprintf(value, "%s-%s", start, end);
dmfree(start);
@ -29,13 +29,13 @@ static int get_reserved_port_range(char **value)
return 0;
}
/*#Device.Services.VoiceService.{i}.ReservedPorts.WANPortRange!UCI:asterisk/sip_advanced,sip_options/rtpstart*/
/*#Device.Services.VoiceService.{i}.ReservedPorts.WANPortRange!UCI:asterisk/sip_advanced,sip_options/rtp_start*/
static int get_ServicesVoiceServiceReservedPorts_WANPortRange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_reserved_port_range(value);
}
/*#Device.Services.VoiceService.{i}.ReservedPorts.LANPortRange!UCI:asterisk/sip_advanced,sip_options/rtpend*/
/*#Device.Services.VoiceService.{i}.ReservedPorts.LANPortRange!UCI:asterisk/sip_advanced,sip_options/rtp_end*/
static int get_ServicesVoiceServiceReservedPorts_LANPortRange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_reserved_port_range(value);

View file

@ -11,7 +11,7 @@
#ifndef __SERVICESVOICESERVICERESERVEDPORTS_H
#define __SERVICESVOICESERVICERESERVEDPORTS_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMLEAF tServicesVoiceServiceReservedPortsParams[];

View file

@ -11,7 +11,6 @@
#include "servicesvoiceservice.h"
#include "servicesvoiceservicesip.h"
#include "common.h"
#include "dmentry.h"
/**************************************************************************
* LINKER
@ -32,12 +31,14 @@ static int browseServicesVoiceServiceSIPClientInst(struct dmctx *dmctx, DMNODE *
}
/*#Device.Services.VoiceService.{i}.SIP.Client.{i}.Contact.{i}.*/
/*
static int browseServicesVoiceServiceSIPClientContactInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
// prev_data is from its parent node SIP.Client.{i}. i.e. the UCI section of asterisk.sip_service_provider
DM_LINK_INST_OBJ(dmctx, parent_node, prev_data, "1");
return 0;
}
*/
/*#Device.Services.VoiceService.{i}.SIP.Network.{i}.!UCI:asterisk/sip_service_provider/dmmap_asterisk*/
static int browseServicesVoiceServiceSIPNetworkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
@ -79,24 +80,8 @@ static int addObjServicesVoiceServiceSIPClient(char *refparam, struct dmctx *ctx
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "", "sip_service_provider");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "name", value);
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "enabled", "0");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "codec0", "alaw");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "ptime_alaw", "20");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cbbs_key", "5");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cbbs_maxretry", "5");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cbbs_retrytime", "300");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cbbs_waittime", "30");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "autoframing", "1");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cfim_on", "*21*");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cfim_off", "#21#");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cfbs_on", "*61*");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cfbs_off", "#61#");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cw_on", "*43*");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cw_off", "#43#");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "cw_status", "*#43#");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "call_return", "*69");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "redial", "*66");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "is_fax", "0");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "enable", "0");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "support_fax", "0");
dmuci_set_value(TR104_UCI_PACKAGE, new_sec_name, "transport", "udp");
dmuci_add_section_bbfdm("dmmap_asterisk", "sip_service_provider", &dmmap);
@ -124,6 +109,7 @@ static int delObjServicesVoiceServiceSIPNetwork(char *refparam, struct dmctx *ct
return 0;
}
/*
static int addObjServicesVoiceServiceSIPClientContact(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
//TODO
@ -161,14 +147,15 @@ static int delObjServicesVoiceServiceSIPNetworkFQDNServer(char *refparam, struct
}
return 0;
}
*/
/*************************************************************
* GET & SET PARAM
**************************************************************/
/*#Device.Services.VoiceService.{i}.SIP.Client.{i}.Enable!UCI:asterisk/sip_service_provider,@i-1/enabled*/
/*#Device.Services.VoiceService.{i}.SIP.Client.{i}.Enable!UCI:asterisk/sip_service_provider,@i-1/enable*/
static int get_ServicesVoiceServiceSIPClient_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enabled", "1");
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enable", "1");
return 0;
}
@ -183,7 +170,7 @@ static int set_ServicesVoiceServiceSIPClient_Enable(char *refparam, struct dmctx
break;
case VALUESET:
string_to_bool(value, &b);
dmuci_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, "enable", b ? "1" : "0");
break;
}
return 0;
@ -194,7 +181,7 @@ static int get_ServicesVoiceServiceSIPClient_Status(char *refparam, struct dmctx
struct uci_section *section = ((struct dmmap_dup *)data)->config_section;
char *enabled = NULL;
dmuci_get_value_by_section_string(section, "enabled", &enabled);
dmuci_get_value_by_section_string(section, "enable", &enabled);
if (enabled && *enabled == '0') {
*value = "Disabled";
@ -203,7 +190,7 @@ static int get_ServicesVoiceServiceSIPClient_Status(char *refparam, struct dmctx
// Get registration status from ubus
json_object *res = NULL, *sip = NULL, *client = NULL;
dmubus_call("voice.asterisk", "status", UBUS_ARGS{}, 0, &res);
dmubus_call("voice.asterisk", "status", UBUS_ARGS{0}, 0, &res);
if (res) {
sip = dmjson_get_obj(res, 1, "sip");
if (sip) {
@ -304,7 +291,7 @@ static int set_ServicesVoiceServiceSIPClient_RegisterURI(char *refparam, struct
return FAULT_9007;
break;
case VALUESET:
value_domain = strchr(value, '@');
value_domain = DM_STRCHR(value, '@');
if (value_domain) {
value_domain++;
value_user = dmstrdup(value);
@ -319,118 +306,10 @@ static int set_ServicesVoiceServiceSIPClient_RegisterURI(char *refparam, struct
return 0;
}
static int get_ServicesVoiceServiceSIPClientContact_Origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "Static";
return 0;
}
/*#Device.Services.VoiceService.{i}.SIP.Client.{i}.Contact.Port!UCI:asterisk/sip_advanced,sip_options/bindport*/
static int get_ServicesVoiceServiceSIPClientContact_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "bindport", "0");
return 0;
}
static int set_ServicesVoiceServiceSIPClientContact_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, RANGE_ARGS{{"0","65535"}}, 1))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value("asterisk", "sip_options", "bindport", value);
break;
}
return 0;
}
/*#Device.Services.VoiceService.{i}.SIP.Client.{i}.Contact.ExpireTime!UCI:asterisk/sip_advanced,sip_options/defaultexpiry*/
static int get_ServicesVoiceServiceSIPClientContact_ExpireTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *section = ((struct dmmap_dup *)data)->config_section;
json_object *res = NULL, *sip = NULL, *client = NULL;
*value = "0001-01-01T00:00:00Z";
if (!section) {
BBF_DEBUG("section shall NOT be null\n");
return 0;
}
dmubus_call("voice.asterisk", "status", UBUS_ARGS{}, 0, &res);
if (res) {
sip = dmjson_get_obj(res, 1, "sip");
if (sip) {
client = dmjson_get_obj(sip, 1, section->e.name);
if (client) {
char *last_reg_time = dmjson_get_value(client, 1, "last_successful_registration");
if (last_reg_time && *last_reg_time) {
struct tm tm_last = { 0, };
// The format of last_reg_time is like "Wed, 26 Aug 2020 11:50:13"
if (strptime(last_reg_time, "%a, %d %b %Y %H:%M:%S", &tm_last)) {
char *period_str = NULL, buf[sizeof "AAAA-MM-JJTHH:MM:SSZ"];
int period = 0;
// Let mktime determine the DST setting according to the system configuration
tm_last.tm_isdst = -1;
time_t time_last = mktime(&tm_last), time_expires;
dmuci_get_option_value_string(TR104_UCI_PACKAGE, "sip_options", "defaultexpiry", &period_str);
if (period_str && *period_str) {
period = atoi(period_str);
dmfree(period_str);
}
if (period <= 0) {
BBF_DEBUG("Use default registration expires\n");
period = atoi(DEFAULT_SIP_REGISTER_EXPIRY_STR);
}
time_expires = time_last + period;
if (strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%SZ", gmtime(&time_expires)) == 0)
return -1;
*value = dmstrdup(buf);
} else {
BBF_DEBUG("Unexpected time format: %s\n", last_reg_time);
}
}
}
}
}
return 0;
}
static int get_ServicesVoiceServiceSIPClientContact_UserAgent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *section = ((struct dmmap_dup *)data)->config_section;
json_object *res = NULL, *sip = NULL, *client = NULL;
if (!section) {
BBF_DEBUG("section shall NOT be null\n");
return 0;
}
dmubus_call("voice.asterisk", "status", UBUS_ARGS{}, 0, &res);
if (res) {
sip = dmjson_get_obj(res, 1, "sip");
if (sip) {
client = dmjson_get_obj(sip, 1, section->e.name);
if (client)
*value = dmjson_get_value(client, 1, "useragent");
}
} else {
BBF_DEBUG("dmubus_call() failed\n");
}
return 0;
}
/*#Device.Services.VoiceService.{i}.SIP.Network.{i}.Enable!UCI:asterisk/sip_service_provider,@i-1/enabled*/
/*#Device.Services.VoiceService.{i}.SIP.Network.{i}.Enable!UCI:asterisk/sip_service_provider,@i-1/enable*/
static int get_ServicesVoiceServiceSIPNetwork_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enabled", "1");
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "enable", "1");
return 0;
}
@ -445,7 +324,7 @@ static int set_ServicesVoiceServiceSIPNetwork_Enable(char *refparam, struct dmct
break;
case VALUESET:
string_to_bool(value, &b);
dmuci_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, "enable", b ? "1" : "0");
break;
}
return 0;
@ -461,7 +340,7 @@ static int get_server_address(struct uci_section *section, char *option, char **
{
dmuci_get_value_by_section_string(section, option, value);
if (*value && **value) {
char *port = strchr(*value, ':');
char *port = DM_STRCHR(*value, ':');
if (port) {
char *server = dmstrdup(*value);
if (server) {
@ -480,7 +359,7 @@ static int set_server_address(struct uci_section *section, char *option, char *v
char *old_value = NULL;
dmuci_get_value_by_section_string(section, option, &old_value);
char *port = (old_value && *old_value) ? strchr(old_value, ':') : NULL;
char *port = (old_value && *old_value) ? DM_STRCHR(old_value, ':') : NULL;
if (port) {
char new_value[32] = {0};
@ -503,7 +382,7 @@ static int get_server_port(struct uci_section *section, char *option, char **val
dmuci_get_value_by_section_string(section, option, &domain);
if (domain && *domain) {
port = strchr(domain, ':');
port = DM_STRCHR(domain, ':');
if (port)
port++;
}
@ -521,7 +400,7 @@ static int set_server_port(struct uci_section *section, char *option, char *valu
char *old_value = NULL, new_value[32] = {0};
dmuci_get_value_by_section_string(section, option, &old_value);
char *tmp = old_value ? strchr(old_value, ':') : NULL;
char *tmp = old_value ? DM_STRCHR(old_value, ':') : NULL;
if (tmp)
*tmp = '\0';
@ -926,7 +805,7 @@ static int set_ServicesVoiceServiceSIPNetwork_CodecList(char *refparam, struct d
static int get_ServicesVoiceServiceSIPNetworkFQDNServer_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("asterisk", "sip_options", "srvlookup", value);
*value = (strcmp(*value, "yes") == 0) ? "1" : "0";
*value = (DM_LSTRCMP(*value, "yes") == 0) ? "1" : "0";
return 0;
}
@ -993,6 +872,43 @@ static int set_ServicesVoiceServiceSIPNetworkFQDNServer_Port(char *refparam, str
return 0;
}
/*Get Device.Services.VoiceService.{i}.SIP.Network.{i}. Alias*/
static int get_ServicesVoiceServiceSIPNetwork_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_Alias_value_by_inst(refparam, ctx, data, instance, value, "networkalias");
}
/*Set Device.Services.VoiceService.{i}.SIP.Network.{i}. Alias*/
static int set_ServicesVoiceServiceSIPNetwork_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_Alias_value_by_inst(refparam, ctx, data, instance, value, action, "networkalias");
}
/*Get Device.Services.VoiceService.{i}.SIP.Network.{i}.FQDNServer. Alias*/
static int get_ServicesVoiceServiceSIPNetworkFQDNServer_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_Alias_value_by_name(refparam, ctx, data, instance, value, "FQDNServer", "FQDNServer_inst");
}
/*Set Device.Services.VoiceService.{i}.SIP.Network.{i}.FQDNServer. Alias*/
static int set_ServicesVoiceServiceSIPNetworkFQDNServer_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_Alias_value_by_name(refparam, ctx, data, instance, value, action, "FQDNServer", "FQDNServer_inst");
}
/*Get Device.Services.VoiceService.{i}.SIP.Client.{i}. Alias*/
static int get_ServicesVoiceServiceSIPClient_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_Alias_value_by_name(refparam, ctx, data, instance, value, "SIPClient", "SIPClient_inst");
}
/*Set Device.Services.VoiceService.{i}.SIP.Client.{i}. Alias*/
static int set_ServicesVoiceServiceSIPClient_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_Alias_value_by_name(refparam, ctx, data, instance, value, action, "SIPClient", "SIPClient_inst");
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
@ -1007,7 +923,7 @@ DMOBJ tServicesVoiceServiceSIPObj[] = {
/* *** Device.Services.VoiceService.{i}.SIP.Client.{i}. *** */
DMOBJ tServicesVoiceServiceSIPClientObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Contact", &DMWRITE, addObjServicesVoiceServiceSIPClientContact, delObjServicesVoiceServiceSIPClientContact, NULL, browseServicesVoiceServiceSIPClientContactInst, NULL, NULL, NULL, tServicesVoiceServiceSIPClientContactParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
// {"Contact", &DMWRITE, addObjServicesVoiceServiceSIPClientContact, delObjServicesVoiceServiceSIPClientContact, NULL, browseServicesVoiceServiceSIPClientContactInst, NULL, NULL, NULL, tServicesVoiceServiceSIPClientContactParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
{0}
};
@ -1019,23 +935,15 @@ DMLEAF tServicesVoiceServiceSIPClientParams[] = {
{"AuthUserName", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceSIPClient_AuthUserName, set_ServicesVoiceServiceSIPClient_AuthUserName, BBFDM_BOTH},
{"AuthPassword", &DMWRITE, DMT_STRING, get_empty, set_ServicesVoiceServiceSIPClient_AuthPassword, BBFDM_BOTH},
{"RegisterURI", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceSIPClient_RegisterURI, set_ServicesVoiceServiceSIPClient_RegisterURI, BBFDM_BOTH},
{0}
};
/* *** Device.Services.VoiceService.{i}.SIP.Client.{i}.Contact.{i}. *** */
DMLEAF tServicesVoiceServiceSIPClientContactParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Origin", &DMREAD, DMT_STRING, get_ServicesVoiceServiceSIPClientContact_Origin, NULL, BBFDM_BOTH},
{"Port", &DMWRITE, DMT_UNINT, get_ServicesVoiceServiceSIPClientContact_Port, set_ServicesVoiceServiceSIPClientContact_Port, BBFDM_BOTH},
{"ExpireTime", &DMREAD, DMT_TIME, get_ServicesVoiceServiceSIPClientContact_ExpireTime, NULL, BBFDM_BOTH},
{"UserAgent", &DMREAD, DMT_STRING, get_ServicesVoiceServiceSIPClientContact_UserAgent, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceSIPClient_Alias, set_ServicesVoiceServiceSIPClient_Alias, BBFDM_BOTH},
{0}
};
/* *** Device.Services.VoiceService.{i}.SIP.Network.{i}. *** */
DMOBJ tServicesVoiceServiceSIPNetworkObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"FQDNServer", &DMWRITE, addObjServicesVoiceServiceSIPNetworkFQDNServer, delObjServicesVoiceServiceSIPNetworkFQDNServer, NULL, browseServicesVoiceServiceSIPNetworkFQDNServerInst, NULL, NULL, NULL, tServicesVoiceServiceSIPNetworkFQDNServerParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Domain", NULL}},
{"FQDNServer", &DMWRITE, NULL, NULL, NULL, browseServicesVoiceServiceSIPNetworkFQDNServerInst, NULL, NULL, NULL, tServicesVoiceServiceSIPNetworkFQDNServerParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Domain", NULL}},
//{"FQDNServer", &DMWRITE, addObjServicesVoiceServiceSIPNetworkFQDNServer, delObjServicesVoiceServiceSIPNetworkFQDNServer, NULL, browseServicesVoiceServiceSIPNetworkFQDNServerInst, NULL, NULL, NULL, tServicesVoiceServiceSIPNetworkFQDNServerParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Domain", NULL}},
{0}
};
@ -1059,6 +967,7 @@ DMLEAF tServicesVoiceServiceSIPNetworkParams[] = {
{"RegisterExpires", &DMWRITE, DMT_UNINT, get_ServicesVoiceServiceSIPNetwork_RegisterExpires, set_ServicesVoiceServiceSIPNetwork_RegisterExpires, BBFDM_BOTH},
{"DSCPMark", &DMWRITE, DMT_UNINT, get_ServicesVoiceServiceSIPNetwork_DSCPMark, set_ServicesVoiceServiceSIPNetwork_DSCPMark, BBFDM_BOTH},
{"CodecList", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceSIPNetwork_CodecList, set_ServicesVoiceServiceSIPNetwork_CodecList, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceSIPNetwork_Alias, set_ServicesVoiceServiceSIPNetwork_Alias, BBFDM_BOTH},
{0}
};
@ -1069,5 +978,6 @@ DMLEAF tServicesVoiceServiceSIPNetworkFQDNServerParams[] = {
{"Origin", &DMREAD, DMT_STRING, get_ServicesVoiceServiceSIPNetworkFQDNServer_Origin, NULL, BBFDM_BOTH},
{"Domain", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceSIPNetworkFQDNServer_Domain, set_ServicesVoiceServiceSIPNetworkFQDNServer_Domain, BBFDM_BOTH},
{"Port", &DMWRITE, DMT_UNINT, get_ServicesVoiceServiceSIPNetworkFQDNServer_Port, set_ServicesVoiceServiceSIPNetworkFQDNServer_Port, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceSIPNetworkFQDNServer_Alias, set_ServicesVoiceServiceSIPNetworkFQDNServer_Alias, BBFDM_BOTH},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __SERVICESVOICESERVICESIP_H
#define __SERVICESVOICESERVICESIP_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tServicesVoiceServiceSIPObj[];
extern DMOBJ tServicesVoiceServiceSIPClientObj[];

View file

@ -14,12 +14,12 @@
/*************************************************************
* GET & SET PARAM
**************************************************************/
/*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.DTMFMethod!UCI:asterisk/sip_advanced,sip_options/dtmfmode*/
/*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.DTMFMethod!UCI:asterisk/sip_advanced,sip_options/dtmf_mode*/
static int get_ServicesVoiceServiceVoIPProfile_DTMFMethod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *method = NULL;
dmuci_get_option_value_string(TR104_UCI_PACKAGE, "sip_options", "dtmfmode", &method);
dmuci_get_option_value_string(TR104_UCI_PACKAGE, "sip_options", "dtmf_mode", &method);
if (method && *method) {
if (strcasecmp(method, "inband") == 0)
*value = "InBand";
@ -48,17 +48,17 @@ static int set_ServicesVoiceServiceVoIPProfile_DTMFMethod(char *refparam, struct
new_value = "rfc4733";
else if (strcasecmp(value, "SIPInfo") == 0)
new_value = "info";
dmuci_set_value(TR104_UCI_PACKAGE, "sip_options", "dtmfmode", new_value);
dmuci_set_value(TR104_UCI_PACKAGE, "sip_options", "dtmf_mode", new_value);
break;
}
return 0;
}
/*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.LocalPortMin!UCI:asterisk/sip_advanced,sip_options/rtpstart*/
/*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.LocalPortMin!UCI:asterisk/sip_advanced,sip_options/rtp_start*/
static int get_ServicesVoiceServiceVoIPProfileRTP_LocalPortMin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "rtpstart", "1024");
*value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "rtp_start", "1024");
return 0;
}
@ -70,16 +70,16 @@ static int set_ServicesVoiceServiceVoIPProfileRTP_LocalPortMin(char *refparam, s
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value("asterisk", "sip_options", "rtpstart", value);
dmuci_set_value("asterisk", "sip_options", "rtp_start", value);
break;
}
return 0;
}
/*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.LocalPortMax!UCI:asterisk/sip_advanced,sip_options/rtpend*/
/*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.LocalPortMax!UCI:asterisk/sip_advanced,sip_options/rtp_end*/
static int get_ServicesVoiceServiceVoIPProfileRTP_LocalPortMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "rtpend", "1024");
*value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "rtp_end", "1024");
return 0;
}
@ -91,7 +91,7 @@ static int set_ServicesVoiceServiceVoIPProfileRTP_LocalPortMax(char *refparam, s
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value("asterisk", "sip_options", "rtpend", value);
dmuci_set_value("asterisk", "sip_options", "rtp_end", value);
break;
}
return 0;
@ -139,12 +139,12 @@ static int set_ServicesVoiceServiceVoIPProfileRTP_TelephoneEventPayloadType(char
return 0;
}
/*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.JitterBufferType!UCI:asterisk/tel_advanced,tel_options/jbimpl*/
/*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.JitterBufferType!UCI:asterisk/tel_advanced,tel_options/jb_impl*/
static int get_ServicesVoiceServiceVoIPProfileRTP_JitterBufferType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *tmp = NULL;
dmuci_get_option_value_string("asterisk", "tel_options", "jbimpl", &tmp);
dmuci_get_option_value_string("asterisk", "tel_options", "jb_impl", &tmp);
if (tmp && *tmp) {
if (strcasecmp(tmp, "adaptive") == 0)
*value = "Dynamic";
@ -165,16 +165,16 @@ static int set_ServicesVoiceServiceVoIPProfileRTP_JitterBufferType(char *refpara
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value("asterisk", "tel_options", "jbimpl", (strcasecmp(value, "Dynamic") == 0) ? "adaptive" : "fixed");
dmuci_set_value("asterisk", "tel_options", "jb_impl", (strcasecmp(value, "Dynamic") == 0) ? "adaptive" : "fixed");
break;
}
return 0;
}
/*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.JitterBufferMaxSize!UCI:asterisk/tel_advanced,tel_options/jbmaxsize*/
/*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.JitterBufferMaxSize!UCI:asterisk/tel_advanced,tel_options/jb_maxsize*/
static int get_ServicesVoiceServiceVoIPProfileRTP_JitterBufferMaxSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_option_value_fallback_def("asterisk", "tel_options", "jbmaxsize", "0");
*value = dmuci_get_option_value_fallback_def("asterisk", "tel_options", "jb_maxsize", "0");
return 0;
}
@ -186,7 +186,7 @@ static int set_ServicesVoiceServiceVoIPProfileRTP_JitterBufferMaxSize(char *refp
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value("asterisk", "tel_options", "jbmaxsize", value);
dmuci_set_value("asterisk", "tel_options", "jb_maxsize", value);
break;
}
return 0;
@ -277,6 +277,18 @@ static int set_ServicesVoiceServiceVoIPProfileRTPSRTP_EncryptionKeySizes(char *r
return 0;
}
/*Get Device.Services.VoiceService.{i}.VoIPProfile.{i}. Alias*/
static int get_ServicesVoiceServiceVoIPProfile_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_Alias_value_by_inst(refparam, ctx, data, instance, value, "clientalias");
}
/*Set Device.Services.VoiceService.{i}.VoIPProfile.{i}. Alias*/
static int set_ServicesVoiceServiceVoIPProfile_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_Alias_value_by_inst(refparam, ctx, data, instance, value, action, "clientalias");
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
@ -290,6 +302,7 @@ DMOBJ tServicesVoiceServiceVoIPProfileObj[] = {
DMLEAF tServicesVoiceServiceVoIPProfileParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"DTMFMethod", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceVoIPProfile_DTMFMethod, set_ServicesVoiceServiceVoIPProfile_DTMFMethod, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_ServicesVoiceServiceVoIPProfile_Alias, set_ServicesVoiceServiceVoIPProfile_Alias, BBFDM_BOTH},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __SERVICESVOICESERVICEVOIPPROFILE_H
#define __SERVICESVOICESERVICEVOIPPROFILE_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tServicesVoiceServiceVoIPProfileObj[];
extern DMLEAF tServicesVoiceServiceVoIPProfileParams[];

View file

@ -9,7 +9,6 @@
*
*/
#include "dmentry.h"
#include "dmdiagnostics.h"
#include "dmbbfcommon.h"
#include "diagnostics.h"
@ -44,7 +43,7 @@ static int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "Requested") == 0) {
if (DM_LSTRCMP(value, "Requested") == 0) {
IPPING_STOP
set_diagnostics_option("ipping", "DiagnosticState", value);
bbf_set_end_session_flag(ctx, BBF_END_SESSION_IPPING_DIAGNOSTIC);
@ -58,17 +57,21 @@ static int get_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data,
{
char *linker = get_diagnostics_option("ipping", "interface");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
static int set_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
return 0;
case VALUESET:
IPPING_STOP
@ -277,7 +280,7 @@ static int set_IPDiagnosticsTraceRoute_DiagnosticsState(char *refparam, struct d
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "Requested") == 0) {
if (DM_LSTRCMP(value, "Requested") == 0) {
TRACEROUTE_STOP
set_diagnostics_option("traceroute", "DiagnosticState", value);
bbf_set_end_session_flag(ctx, BBF_END_SESSION_TRACEROUTE_DIAGNOSTIC);
@ -291,17 +294,21 @@ static int get_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *c
{
char *linker = get_diagnostics_option("traceroute", "interface");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
static int set_IPDiagnosticsTraceRoute_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
return 0;
case VALUESET:
TRACEROUTE_STOP
@ -520,7 +527,7 @@ static int set_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam,
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "Requested") == 0) {
if (DM_LSTRCMP(value, "Requested") == 0) {
DOWNLOAD_DIAGNOSTIC_STOP
set_diagnostics_option("download", "DiagnosticState", value);
bbf_set_end_session_flag(ctx, BBF_END_SESSION_DOWNLOAD_DIAGNOSTIC);
@ -533,18 +540,22 @@ static int set_IPDiagnosticsDownloadDiagnostics_DiagnosticsState(char *refparam,
static int get_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker = get_diagnostics_option("download", "interface");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
return 0;
}
static int set_IPDiagnosticsDownloadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
return 0;
case VALUESET:
DOWNLOAD_DIAGNOSTIC_STOP
@ -846,7 +857,7 @@ static int set_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, s
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "Requested") == 0) {
if (DM_LSTRCMP(value, "Requested") == 0) {
UPLOAD_DIAGNOSTIC_STOP
set_diagnostics_option("upload", "DiagnosticState", value);
bbf_set_end_session_flag(ctx, BBF_END_SESSION_UPLOAD_DIAGNOSTIC);
@ -859,18 +870,22 @@ static int set_IPDiagnosticsUploadDiagnostics_DiagnosticsState(char *refparam, s
static int get_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker = get_diagnostics_option("upload", "interface");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
return 0;
}
static int set_IPDiagnosticsUploadDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
return 0;
case VALUESET:
UPLOAD_DIAGNOSTIC_STOP
@ -1189,7 +1204,7 @@ static int set_IPDiagnosticsUDPEchoDiagnostics_DiagnosticsState(char *refparam,
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "Requested") == 0) {
if (DM_LSTRCMP(value, "Requested") == 0) {
UDPECHO_STOP;
set_diagnostics_option("udpechodiag", "DiagnosticState", value);
bbf_set_end_session_flag(ctx, BBF_END_SESSION_UDPECHO_DIAGNOSTIC);
@ -1203,17 +1218,21 @@ static int get_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct
{
char *linker = get_diagnostics_option("udpechodiag", "interface");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
static int set_IPDiagnosticsUDPEchoDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
return 0;
case VALUESET:
UDPECHO_STOP;
@ -1248,7 +1267,7 @@ static int set_IPDiagnosticsUDPEchoDiagnostics_Host(char *refparam, struct dmctx
static int get_IPDiagnosticsUDPEchoDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_diagnostics_option_fallback_def("udpechodiag", "port", "1");
*value = get_diagnostics_option_fallback_def("udpechodiag", "port", "7");
return 0;
}
@ -1448,7 +1467,7 @@ static int set_IPDiagnosticsServerSelectionDiagnostics_DiagnosticsState(char *re
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "Requested") == 0) {
if (DM_LSTRCMP(value, "Requested") == 0) {
SERVERSELECTION_STOP
set_diagnostics_option("serverselection", "DiagnosticState", value);
bbf_set_end_session_flag(ctx, BBF_END_SESSION_SERVERSELECTION_DIAGNOSTIC);
@ -1462,17 +1481,21 @@ static int get_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam,
{
char *linker = get_diagnostics_option("serverselection", "interface");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
static int set_IPDiagnosticsServerSelectionDiagnostics_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
return 0;
case VALUESET:
SERVERSELECTION_STOP
@ -2076,9 +2099,6 @@ static int operate_IPDiagnostics_UDPEchoDiagnostics(char *refparam, struct dmctx
return CMD_INVALID_ARGUMENTS;
char *udpecho_port = dmjson_get_value((json_object *)value, 1, "Port");
if (udpecho_port[0] == '\0')
return CMD_INVALID_ARGUMENTS;
char *udpecho_interface = dmjson_get_value((json_object *)value, 1, "Interface");
char *udpecho_proto = dmjson_get_value((json_object *)value, 1, "ProtocolVersion");
char *udpecho_nbofrepetition = dmjson_get_value((json_object *)value, 1, "NumberOfRepetitions");
@ -2157,9 +2177,6 @@ static int operate_IPDiagnostics_ServerSelectionDiagnostics(char *refparam, stru
char *port = dmjson_get_value((json_object *)value, 1, "Port");
char *proto = dmjson_get_value((json_object *)value, 1, "Protocol");
if (strcmp(proto, "ICMP") && port[0] == '\0')
return CMD_INVALID_ARGUMENTS;
char *protocol_version = dmjson_get_value((json_object *)value, 1, "ProtocolVersion");
char *interface = dmjson_get_value((json_object *)value, 1, "Interface");
char *nbofrepetition = dmjson_get_value((json_object *)value, 1, "NumberOfRepetitions");

View file

@ -12,7 +12,7 @@
#ifndef __DIAGNOSTICS_H
#define __DIAGNOSTICS_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tIPDiagnosticsObj[];
extern DMLEAF tIPDiagnosticsParams[];

View file

@ -9,7 +9,6 @@
*
*/
#include "dmentry.h"
#include "atm.h"
struct atm_args
@ -42,19 +41,23 @@ static inline int init_atm_link(struct atm_args *args, struct dmmap_dup *s, char
**************************************************************/
void remove_device_from_interface(struct uci_section *interface_s, char *device)
{
char *curr_device = NULL, *pch = NULL, *spch = NULL;
char *curr_device = NULL;
char new_device[64] = {0};
unsigned pos = 0;
dmuci_get_value_by_section_string(interface_s, "device", &curr_device);
new_device[0] = '\0';
for (pch = strtok_r(curr_device, " ", &spch); pch; pch = strtok_r(NULL, " ", &spch)) {
if (strcmp(pch, device) == 0)
continue;
if (device != NULL) {
char *pch = NULL, *spch = NULL;
for (pch = strtok_r(curr_device, " ", &spch); pch; pch = strtok_r(NULL, " ", &spch)) {
pos += snprintf(&new_device[pos], sizeof(new_device) - pos, "%s ", pch);
if (strcmp(pch, device) == 0)
continue;
pos += snprintf(&new_device[pos], sizeof(new_device) - pos, "%s ", pch);
}
}
if (pos)
@ -203,7 +206,7 @@ static int get_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data,
dmuci_get_value_by_section_string((((struct atm_args *)data)->sections)->config_section, "encapsulation", &encapsulation);
*value = (strcmp(encapsulation, "vcmux") == 0) ? "VCMUX" : "LLC";
*value = (DM_LSTRCMP(encapsulation, "vcmux") == 0) ? "VCMUX" : "LLC";
return 0;
}
@ -215,7 +218,7 @@ static int set_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data,
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "encapsulation", (strcmp(value, "LLC") == 0) ? "llc" : "vcmux");
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "encapsulation", (DM_LSTRCMP(value, "LLC") == 0) ? "llc" : "vcmux");
return 0;
}
return 0;
@ -227,13 +230,13 @@ static int get_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char
char *link_type;
dmuci_get_value_by_section_string((((struct atm_args *)data)->sections)->config_section, "link_type", &link_type);
if (strcmp(link_type, "eoa") == 0)
if (DM_LSTRCMP(link_type, "eoa") == 0)
*value = "EoA";
else if (strcmp(link_type, "ipoa") == 0)
else if (DM_LSTRCMP(link_type, "ipoa") == 0)
*value = "IPoA";
else if (strcmp(link_type, "pppoa") == 0)
else if (DM_LSTRCMP(link_type, "pppoa") == 0)
*value = "PPPoA";
else if (strcmp(link_type, "cip") == 0)
else if (DM_LSTRCMP(link_type, "cip") == 0)
*value = "CIP";
else
*value = "Unconfigured";
@ -248,13 +251,13 @@ static int set_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "EoA") == 0)
if (DM_LSTRCMP(value, "EoA") == 0)
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "link_type", "eoa");
else if (strcmp(value, "IPoA") == 0)
else if (DM_LSTRCMP(value, "IPoA") == 0)
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "link_type", "ipoa");
else if (strcmp(value, "PPPoA") == 0)
else if (DM_LSTRCMP(value, "PPPoA") == 0)
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "link_type", "pppoa");
else if (strcmp(value, "CIP") == 0)
else if (DM_LSTRCMP(value, "CIP") == 0)
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "link_type", "cip");
else
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->config_section, "link_type", "");
@ -269,12 +272,11 @@ static int get_atm_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
char atm_file[128];
dmuci_get_value_by_section_string((((struct atm_args *)data)->sections)->dmmap_section, "atm_ll_link", &linker);
if (linker != NULL)
adm_entry_get_linker_param(ctx, "Device.DSL.Channel.", linker, value);
adm_entry_get_linker_param(ctx, "Device.DSL.Channel.", linker, value);
if (*value != NULL && (*value)[0] != '\0')
return 0;
snprintf(atm_file, sizeof(atm_file), "/sys/class/net/atm%d", atoi(instance) - 1);
snprintf(atm_file, sizeof(atm_file), "/sys/class/net/atm%ld", DM_STRTOL(instance) - 1);
if (folder_exists(atm_file)) {
*value = "Device.DSL.Channel.1";
dmuci_set_value_by_section((((struct atm_args *)data)->sections)->dmmap_section, "atm_ll_link", "dsl_channel_1");
@ -286,7 +288,7 @@ static int set_atm_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
{
switch (action) {
case VALUECHECK:
if (strncmp(value, "Device.DSL.Channel.1", strlen("Device.DSL.Channel.1")) != 0)
if (DM_LSTRNCMP(value, "Device.DSL.Channel.1", strlen("Device.DSL.Channel.1")) != 0)
return FAULT_9007;
break;
case VALUESET:
@ -394,36 +396,36 @@ static int set_atm_alias(char *refparam, struct dmctx *ctx, void *data, char *in
/*** ATM. ***/
DMOBJ tATMObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Link", &DMWRITE, add_atm_link, delete_atm_link, NULL, browseAtmLinkInst, NULL, NULL, tATMLinkObj, tATMLinkParams, get_atm_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
{"Link", &DMWRITE, add_atm_link, delete_atm_link, NULL, browseAtmLinkInst, NULL, NULL, tATMLinkObj, tATMLinkParams, get_atm_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.0"},
{0}
};
/*** ATM.Link. ***/
DMOBJ tATMLinkObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tATMLinkStatsParams, NULL, BBFDM_BOTH},
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tATMLinkStatsParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{0}
};
DMLEAF tATMLinkParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_atm_alias, set_atm_alias, BBFDM_BOTH},
{"Enable", &DMWRITE, DMT_BOOL, get_atm_enable, set_atm_enable, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_atm_link_name, NULL, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_atm_status, NULL, BBFDM_BOTH},
{"LowerLayers", &DMWRITE, DMT_STRING, get_atm_lower_layer, set_atm_lower_layer, BBFDM_BOTH},
{"LinkType", &DMWRITE, DMT_STRING, get_atm_link_type, set_atm_link_type, BBFDM_BOTH},
{"DestinationAddress", &DMWRITE, DMT_STRING, get_atm_destination_address, set_atm_destination_address, BBFDM_BOTH},
{"Encapsulation", &DMWRITE, DMT_STRING, get_atm_encapsulation, set_atm_encapsulation, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_atm_alias, set_atm_alias, BBFDM_BOTH, "2.0"},
{"Enable", &DMWRITE, DMT_BOOL, get_atm_enable, set_atm_enable, BBFDM_BOTH, "2.0"},
{"Name", &DMREAD, DMT_STRING, get_atm_link_name, NULL, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_atm_status, NULL, BBFDM_BOTH, "2.0"},
{"LowerLayers", &DMWRITE, DMT_STRING, get_atm_lower_layer, set_atm_lower_layer, BBFDM_BOTH, "2.0"},
{"LinkType", &DMWRITE, DMT_STRING, get_atm_link_type, set_atm_link_type, BBFDM_BOTH, "2.0"},
{"DestinationAddress", &DMWRITE, DMT_STRING, get_atm_destination_address, set_atm_destination_address, BBFDM_BOTH, "2.0"},
{"Encapsulation", &DMWRITE, DMT_STRING, get_atm_encapsulation, set_atm_encapsulation, BBFDM_BOTH, "2.0"},
{0}
};
/*** ATM.Link.Stats. ***/
DMLEAF tATMLinkStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNLONG, get_atm_stats_bytes_sent, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_atm_stats_bytes_received, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_atm_stats_pack_sent, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_atm_stats_pack_received, NULL, BBFDM_BOTH},
{"BytesSent", &DMREAD, DMT_UNLONG, get_atm_stats_bytes_sent, NULL, BBFDM_BOTH, "2.0"},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_atm_stats_bytes_received, NULL, BBFDM_BOTH, "2.0"},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_atm_stats_pack_sent, NULL, BBFDM_BOTH, "2.0"},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_atm_stats_pack_received, NULL, BBFDM_BOTH, "2.0"},
{0}
};

View file

@ -12,7 +12,7 @@
#ifndef __ATM_H
#define __ATM_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tATMObj[];
extern DMOBJ tATMLinkObj[];

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,7 @@
#ifndef __BRIDGING_H
#define __BRIDGING_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tBridgingObj[];
extern DMLEAF tBridgingParams[];

View file

@ -57,7 +57,7 @@ static int get_Device_InterfaceStackNumberOfEntries(char *refparam, struct dmctx
static int get_Device_RootDataModelVersion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "2.14";
*value = DEFAULT_DMVERSION;
return 0;
}
@ -66,7 +66,7 @@ static int get_Device_RootDataModelVersion(char *refparam, struct dmctx *ctx, vo
*************************************************************/
static int operate_Device_Reboot(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return !dmubus_call_set("system", "reboot", UBUS_ARGS{}, 0) ? CMD_SUCCESS : CMD_FAIL;
return !dmubus_call_set("system", "reboot", UBUS_ARGS{0}, 0) ? CMD_SUCCESS : CMD_FAIL;
}
static int operate_Device_FactoryReset(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
@ -86,48 +86,51 @@ DMOBJ tEntry181Obj[] = {
/* *** Device. *** */
DMOBJ tDeviceObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDeviceInfoObj, tDeviceInfoParams, NULL, BBFDM_BOTH},
{"ManagementServer", &DMREAD, NULL, NULL, "file:/etc/config/cwmp", NULL, NULL, NULL, NULL, tManagementServerParams, NULL, BBFDM_BOTH},
{"Time", &DMREAD, NULL, NULL, "file:/etc/config/system", NULL, NULL, NULL, NULL, tTimeParams, NULL, BBFDM_BOTH},
{"UPnP", &DMREAD, NULL, NULL, "file:/etc/config/upnpd", NULL, NULL, NULL, tUPnPObj, NULL, NULL, BBFDM_BOTH},
{"WiFi", &DMREAD, NULL, NULL, "file:/etc/config/wireless", NULL, NULL, NULL, tWiFiObj, tWiFiParams, NULL, BBFDM_BOTH},
{"Bridging", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tBridgingObj, tBridgingParams, NULL, BBFDM_BOTH},
{"IP", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tIPObj, tIPParams, NULL, BBFDM_BOTH},
{"Ethernet", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tEthernetObj, tEthernetParams, NULL, BBFDM_BOTH},
{"DSL", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tDSLObj, tDSLParams, NULL, BBFDM_BOTH},
{"FAST", &DMREAD, NULL, NULL, "ubus:fast", NULL, NULL, NULL, tFASTObj, tFASTParams, NULL, BBFDM_BOTH},
{"ATM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tATMObj, NULL, NULL, BBFDM_BOTH},
{"PTM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tPTMObj, NULL, NULL, BBFDM_BOTH},
{"DHCPv4", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcp.sh,/etc/config/dhcp", NULL, NULL, NULL, tDHCPv4Obj, tDHCPv4Params, NULL, BBFDM_BOTH},
{"DHCPv6", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcpv6.sh,/etc/config/dhcp", NULL, NULL, NULL, tDHCPv6Obj, tDHCPv6Params, NULL, BBFDM_BOTH},
{"Hosts", &DMREAD, NULL, NULL, "ubus:topology->hosts", NULL, NULL, NULL, tHostsObj, tHostsParams, NULL, BBFDM_BOTH},
{"NAT", &DMREAD, NULL, NULL, "file:/etc/config/firewall", NULL, NULL, NULL, tNATObj, tNATParams, NULL, BBFDM_BOTH},
{"PPP", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/ppp.sh,/etc/config/network", NULL, NULL, NULL, tPPPObj, tPPPParams, NULL, BBFDM_BOTH},
{"Routing", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tRoutingObj, tRoutingParams, NULL, BBFDM_BOTH},
{"Firewall", &DMREAD, NULL, NULL, "file:/etc/config/firewall", NULL, NULL, NULL, tFirewallObj, tFirewallParams, NULL, BBFDM_BOTH},
{"DNS", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tDNSObj, tDNSParams, NULL, BBFDM_BOTH},
{"Users", &DMREAD, NULL, NULL, "file:/etc/config/users", NULL, NULL, NULL, tUsersObj, tUsersParams, NULL, BBFDM_BOTH},
{"IEEE1905", &DMREAD, NULL, NULL, "file:/etc/config/ieee1905;ubus:ieee1905->info", NULL, NULL, NULL, tIEEE1905Obj, tIEEE1905Params, NULL, BBFDM_BOTH},
{"InterfaceStack", &DMREAD, NULL, NULL, "file:/etc/config/network", browseInterfaceStackInst, NULL, NULL, NULL, tInterfaceStackParams, NULL, BBFDM_BOTH},
{"USB", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tUSBObj, tUSBParams, NULL, BBFDM_BOTH},
{"GRE", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/gre.sh,/etc/config/network", NULL, NULL, NULL, tGREObj, tGREParams, NULL, BBFDM_BOTH},
{"DynamicDNS", &DMREAD, NULL, NULL, "file:/etc/config/ddns", NULL, NULL, NULL, tDynamicDNSObj, tDynamicDNSParams, NULL, BBFDM_BOTH},
{"QoS", &DMREAD, NULL, NULL, "file:/etc/config/qos", NULL, NULL, NULL, tQoSObj, tQoSParams, NULL, BBFDM_BOTH},
{"LANConfigSecurity", &DMREAD, NULL, NULL, "file:/etc/config/users", NULL, NULL, NULL, NULL, tLANConfigSecurityParams, NULL, BBFDM_BOTH},
{"Security", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tSecurityObj, tSecurityParams, NULL, BBFDM_BOTH},
{"RouterAdvertisement", &DMREAD, NULL, NULL, "file:/etc/config/dhcp", NULL, NULL, NULL, tRouterAdvertisementObj, tRouterAdvertisementParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDeviceInfoObj, tDeviceInfoParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"ManagementServer", &DMREAD, NULL, NULL, "file:/etc/config/cwmp", NULL, NULL, NULL, tManagementServerObj, tManagementServerParams, NULL, BBFDM_CWMP, NULL, "2.1"},
{"Time", &DMREAD, NULL, NULL, "file:/etc/config/system", NULL, NULL, NULL, NULL, tTimeParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"UPnP", &DMREAD, NULL, NULL, "file:/etc/config/upnpd", NULL, NULL, NULL, tUPnPObj, NULL, NULL, BBFDM_BOTH, NULL, "2.0"},
{"WiFi", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tWiFiObj, tWiFiParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"Bridging", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tBridgingObj, tBridgingParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"IP", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tIPObj, tIPParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"Ethernet", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tEthernetObj, tEthernetParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"DSL", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tDSLObj, tDSLParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"FAST", &DMREAD, NULL, NULL, "ubus:fast", NULL, NULL, NULL, tFASTObj, tFASTParams, NULL, BBFDM_BOTH, NULL, "2.11"},
{"ATM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tATMObj, NULL, NULL, BBFDM_BOTH, NULL, "2.0"},
{"PTM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tPTMObj, NULL, NULL, BBFDM_BOTH, NULL, "2.0"},
{"DHCPv4", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcp.sh,/etc/config/dhcp", NULL, NULL, NULL, tDHCPv4Obj, tDHCPv4Params, NULL, BBFDM_BOTH, NULL, "2.0"},
{"DHCPv6", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcpv6.sh,/etc/config/dhcp", NULL, NULL, NULL, tDHCPv6Obj, tDHCPv6Params, NULL, BBFDM_BOTH, NULL, "2.2"},
{"Hosts", &DMREAD, NULL, NULL, "file:/etc/config/hosts", NULL, NULL, NULL, tHostsObj, tHostsParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"NAT", &DMREAD, NULL, NULL, "file:/etc/config/firewall", NULL, NULL, NULL, tNATObj, tNATParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"PPP", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/ppp.sh,/etc/config/network", NULL, NULL, NULL, tPPPObj, tPPPParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"Routing", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tRoutingObj, tRoutingParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"Firewall", &DMREAD, NULL, NULL, "file:/etc/config/firewall", NULL, NULL, NULL, tFirewallObj, tFirewallParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"DNS", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tDNSObj, tDNSParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"Users", &DMREAD, NULL, NULL, "file:/etc/config/users", NULL, NULL, NULL, tUsersObj, tUsersParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"IEEE1905", &DMREAD, NULL, NULL, "file:/etc/config/ieee1905", NULL, NULL, NULL, tIEEE1905Obj, tIEEE1905Params, NULL, BBFDM_BOTH, NULL, "2.9"},
{"InterfaceStack", &DMREAD, NULL, NULL, "file:/etc/config/network", browseInterfaceStackInst, NULL, NULL, NULL, tInterfaceStackParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"USB", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tUSBObj, tUSBParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"GRE", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/gre.sh,/etc/config/network", NULL, NULL, NULL, tGREObj, tGREParams, NULL, BBFDM_BOTH, NULL, "2.8"},
{"DynamicDNS", &DMREAD, NULL, NULL, "file:/etc/config/ddns", NULL, NULL, NULL, tDynamicDNSObj, tDynamicDNSParams, NULL, BBFDM_BOTH, NULL, "2.10"},
{"QoS", &DMREAD, NULL, NULL, "file:/etc/config/qos", NULL, NULL, NULL, tQoSObj, tQoSParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"LANConfigSecurity", &DMREAD, NULL, NULL, "file:/etc/config/users", NULL, NULL, NULL, NULL, tLANConfigSecurityParams, NULL, BBFDM_BOTH, NULL, "2.0"},
#if defined(LOPENSSL) || defined(LMBEDTLS) || defined(LWOLFSSL)
{"Security", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tSecurityObj, tSecurityParams, NULL, BBFDM_BOTH, NULL, "2.4"},
#endif
{"RouterAdvertisement", &DMREAD, NULL, NULL, "file:/etc/config/dhcp", NULL, NULL, NULL, tRouterAdvertisementObj, tRouterAdvertisementParams, NULL, BBFDM_BOTH, NULL, "2.2"},
#ifdef BBF_TR104
{"Services", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tServicesObj, NULL, NULL, BBFDM_BOTH},
{"Services", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tServicesObj, NULL, NULL, BBFDM_BOTH, NULL, "2.0"},
#endif
{0}
};
DMLEAF tDeviceParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"InterfaceStackNumberOfEntries", &DMREAD, DMT_UNINT, get_Device_InterfaceStackNumberOfEntries, NULL, BBFDM_BOTH},
{"RootDataModelVersion", &DMREAD, DMT_STRING, get_Device_RootDataModelVersion, NULL, BBFDM_BOTH},
{"Reboot()", &DMSYNC, DMT_COMMAND, NULL, operate_Device_Reboot, BBFDM_USP},
{"FactoryReset()", &DMSYNC, DMT_COMMAND, NULL, operate_Device_FactoryReset, BBFDM_USP},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"InterfaceStackNumberOfEntries", &DMREAD, DMT_UNINT, get_Device_InterfaceStackNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
{"RootDataModelVersion", &DMREAD, DMT_STRING, get_Device_RootDataModelVersion, NULL, BBFDM_BOTH, "2.4"},
{"Reboot()", &DMSYNC, DMT_COMMAND, NULL, operate_Device_Reboot, BBFDM_USP, "2.12"},
{"FactoryReset()", &DMSYNC, DMT_COMMAND, NULL, operate_Device_FactoryReset, BBFDM_USP, "2.12"},
//{"Boot!", &DMREAD, DMT_EVENT, NULL, NULL, BBFDM_USP, "2.12"},
{0}
};

View file

@ -13,7 +13,7 @@
#ifndef __DEVICE_H
#define __DEVICE_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tEntry181Obj[];
extern DMOBJ tDeviceObj[];

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,7 @@
#ifndef __DEVICE_INFO_H
#define __DEVICE_INFO_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMLEAF tDeviceInfoParams[];
extern DMLEAF tDeviceInfoVendorConfigFileParams[];

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@
#ifndef __DHCP_H
#define __DHCP_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tDHCPv4Obj[];
extern DMOBJ tDHCPv4ServerObj[];
@ -39,7 +39,6 @@ extern DMLEAF tDHCPv4RelayForwardingParams[];
int set_section_order(char *package, char *dmpackage, char* sect_type, struct uci_section *dmmap_sect, struct uci_section *conf, int set_force, char* order);
int get_value_in_mac_format(struct uci_section *s, char *option_name, bool type, char **value);
int set_DHCP_Interface(struct dmctx *ctx, char *value, struct uci_section *config_s, struct uci_section *dmmap_s, char *dmmap_name, char *proto, int action);
bool tag_option_exists(char *dmmap_package, char *section, char *opt_check, char *value_check, char *tag_name, char *tag_value);
char *generate_tag_option(char *dmmap_package, char *section, char *opt_check, char *value_check, char *tag_name);

View file

@ -9,15 +9,14 @@
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include "dmentry.h"
#include "dhcpv4.h"
#include "dhcpv6.h"
struct dhcpv6_client_args
{
struct dmmap_dup *dhcp_client_sections;
char *ip;
struct uci_section *iface_s;
struct uci_section *dmmap_s;
};
struct dhcpv6_args
@ -40,6 +39,57 @@ struct dhcpv6_client_option_args {
char *value;
};
/*************************************************************
* COMMON FUNCTIONS
**************************************************************/
static bool is_dhcpv6_client_section_exist(char *sec_name)
{
struct uci_section *s = NULL;
uci_path_foreach_option_eq(bbfdm, "dmmap_dhcpv6", "interface", "iface_name", sec_name, s) {
return true;
}
return false;
}
static void dmmap_synchronizeDHCPv6Client(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *s = NULL, *stmp = NULL;
uci_path_foreach_sections_safe(bbfdm, "dmmap_dhcpv6", "interface", stmp, s) {
struct uci_section *iface_s = NULL;
char *added_by_controller = NULL;
char *iface_name = NULL;
dmuci_get_value_by_section_string(s, "added_by_controller", &added_by_controller);
if (DM_LSTRCMP(added_by_controller, "1") == 0)
continue;
dmuci_get_value_by_section_string(s, "iface_name", &iface_name);
if (DM_STRLEN(iface_name))
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
if (!iface_s)
dmuci_delete_by_section(s, NULL, NULL);
}
uci_foreach_sections("network", "interface", s) {
struct uci_section *ppp_s = NULL;
char *proto = NULL;
dmuci_get_value_by_section_string(s, "proto", &proto);
if (DM_LSTRCMP(proto, "dhcpv6") != 0)
continue;
if (is_dhcpv6_client_section_exist(section_name(s)))
continue;
dmuci_add_section_bbfdm("dmmap_dhcpv6", "interface", &ppp_s);
dmuci_set_value_by_section(ppp_s, "iface_name", section_name(s));
}
}
static struct uci_section *get_dhcpv6_classifier(char *classifier_name, const char *network)
{
struct uci_section *s = NULL;
@ -47,7 +97,7 @@ static struct uci_section *get_dhcpv6_classifier(char *classifier_name, const ch
uci_foreach_sections("dhcp", classifier_name, s) {
dmuci_get_value_by_section_string(s, "networkid", &v);
if (strcmp(v, network) == 0)
if (DM_STRCMP(v, network) == 0)
return s;
}
return NULL;
@ -56,8 +106,8 @@ static struct uci_section *get_dhcpv6_classifier(char *classifier_name, const ch
static int get_value_in_date_time_format(json_object *json_obj, char *option_name, char **value)
{
const char *option_value = dmjson_get_value(json_obj, 1, option_name);
if (option_value && *option_value != '\0' && atoi(option_value) > 0) {
time_t time_value = atoi(option_value);
if (option_value && *option_value != '\0' && DM_STRTOL(option_value) > 0) {
time_t time_value = DM_STRTOL(option_value);
char s_now[sizeof "AAAA-MM-JJTHH:MM:SSZ"];
if (strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%SZ", gmtime(&time_value)) == 0)
return -1;
@ -90,35 +140,27 @@ static inline int init_dhcpv6_args(struct dhcpv6_args *args, struct dmmap_dup *s
/*#Device.DHCPv6.Client.{i}.!UCI:network/interface/dmmap_dhcpv6*/
static int browseDHCPv6ClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct dhcpv6_client_args dhcpv6_client_arg = {0};
struct dhcpv6_client_args curr_dhcpv6_client_args = {0};
struct uci_section *dmmap_s = NULL;
char *inst = NULL;
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap_eq("network", "interface", "dmmap_dhcpv6", "proto", "dhcpv6", &dup_list);
list_for_each_entry(p, &dup_list, list) {
char *ipv6addr = NULL;
dmmap_synchronizeDHCPv6Client(dmctx, parent_node, prev_data, prev_instance);
uci_path_foreach_sections(bbfdm, "dmmap_dhcpv6", "interface", dmmap_s) {
struct uci_section *iface_s = NULL;
char *iface_name = NULL;
dmuci_get_value_by_section_string(p->config_section, "ip6addr", &ipv6addr);
if (ipv6addr && ipv6addr[0] == '\0') {
json_object *res = NULL;
dmuci_get_value_by_section_string(dmmap_s, "iface_name", &iface_name);
if (DM_STRLEN(iface_name))
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(p->config_section), String}}, 1, &res);
if (res) {
json_object *jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv6-address");
ipv6addr = dmjson_get_value(jobj, 1, "address");
}
}
curr_dhcpv6_client_args.iface_s = iface_s;
curr_dhcpv6_client_args.dmmap_s = dmmap_s;
dhcpv6_client_arg.dhcp_client_sections = p;
dhcpv6_client_arg.ip = dmstrdup(ipv6addr ? ipv6addr : "");
inst = handle_instance(dmctx, parent_node, dmmap_s, "bbf_dhcpv6client_instance", "bbf_dhcpv6client_alias");
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "bbf_dhcpv6client_instance", "bbf_dhcpv6client_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&dhcpv6_client_arg, inst) == DM_STOP)
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_dhcpv6_client_args, inst) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}
@ -135,7 +177,7 @@ static int browseDHCPv6ServerPoolInst(struct dmctx *dmctx, DMNODE *parent_node,
// skip the section if option ignore = '1'
dmuci_get_value_by_section_string(p->config_section, "ignore", &ignore);
if (ignore && strcmp(ignore, "1") == 0)
if (ignore && DM_LSTRCMP(ignore, "1") == 0)
continue;
dmuci_get_value_by_section_string(p->config_section, "interface", &interface);
@ -144,7 +186,7 @@ static int browseDHCPv6ServerPoolInst(struct dmctx *dmctx, DMNODE *parent_node,
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "dhcpv6_serv_pool_instance", "dhcpv6_serv_pool_alias");
dmuci_get_value_by_section_string(p->dmmap_section, "order", &v);
if (v == NULL || strlen(v) == 0)
if (v == NULL || DM_STRLEN(v) == 0)
set_section_order("dhcp", "dmmap_dhcpv6", "dhcp", p->dmmap_section, p->config_section, 0, inst);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_dhcp6_args, inst) == DM_STOP)
@ -163,10 +205,11 @@ static int browseDHCPv6ServerPoolClientInst(struct dmctx *dmctx, DMNODE *parent_
int i = 0;
char *inst = NULL, *device;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(dhcp_arg->dhcp_sections->config_section), String}}, 1, &res1);
char *if_name = section_name(dhcp_arg->dhcp_sections->config_section);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res1);
if (!res1) return 0;
device = dmjson_get_value(res1, 1, "device");
dmubus_call("dhcp", "ipv6leases", UBUS_ARGS{}, 0, &res);
dmubus_call("dhcp", "ipv6leases", UBUS_ARGS{0}, 0, &res);
if (!res) return 0;
dev_obj = dmjson_get_obj(res, 1, "device");
if (!dev_obj) return 0;
@ -279,20 +322,13 @@ static int browseDHCPv6ServerPoolClientIPv6PrefixInst(struct dmctx *dmctx, DMNOD
**************************************************************/
static int addObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
struct uci_section *s = NULL, *dmmap_sect = NULL;
char dhcpv6_s[32];
snprintf(dhcpv6_s, sizeof(dhcpv6_s), "dhcpv6_intf_%s", *instance);
dmuci_add_section("network", "interface", &s);
dmuci_rename_section_by_section(s, dhcpv6_s);
dmuci_set_value_by_section(s, "proto", "dhcpv6");
dmuci_set_value_by_section(s, "disabled", "1");
dmuci_set_value_by_section(s, "reqaddress", "force");
dmuci_set_value_by_section(s, "reqprefix", "no");
struct uci_section *dmmap_sect = NULL;
dmuci_add_section_bbfdm("dmmap_dhcpv6", "interface", &dmmap_sect);
dmuci_set_value_by_section(dmmap_sect, "section_name", dhcpv6_s);
dmuci_set_value_by_section(dmmap_sect, "proto", "dhcpv6");
dmuci_set_value_by_section(dmmap_sect, "disabled", "1");
dmuci_set_value_by_section(dmmap_sect, "reqaddress", "force");
dmuci_set_value_by_section(dmmap_sect, "reqprefix", "no");
dmuci_set_value_by_section(dmmap_sect, "added_by_controller", "1");
dmuci_set_value_by_section(dmmap_sect, "bbf_dhcpv6client_instance", *instance);
return 0;
@ -300,34 +336,50 @@ static int addObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, cha
static int delObjDHCPv6Client(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *s_tmp = NULL;
char *added_by_controller = NULL;
struct uci_section *s = NULL, *stmp = NULL;
switch (del_action) {
case DEL_INST:
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "added_by_controller", &added_by_controller);
if (added_by_controller && strcmp(added_by_controller, "1") == 0) {
dmuci_delete_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, NULL, NULL);
} else {
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "proto", "none");
}
dmuci_delete_by_section(((struct dhcpv6_client_args *)data)->dmmap_s, NULL, NULL);
dmuci_delete_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->dmmap_section, NULL, NULL);
if (((struct dhcpv6_client_args *)data)->iface_s) {
char *device = NULL;
dmuci_get_value_by_section_string(((struct dhcpv6_client_args *)data)->iface_s, "device", &device);
if (device && DM_STRCHR(device, '@')) {
dmuci_delete_by_section(((struct dhcpv6_client_args *)data)->iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "proto", "none");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqaddress", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqprefix", "");
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->iface_s, "reqopts", "");
}
}
break;
case DEL_ALL:
uci_foreach_option_eq_safe("network", "interface", "proto", "dhcpv6", s_tmp, s) {
struct uci_section *dmmap_section = NULL;
uci_path_foreach_sections_safe(bbfdm, "dmmap_dhcpv6", "interface", stmp, s) {
struct uci_section *iface_s = NULL;
char *iface_name = NULL;
get_dmmap_section_of_config_section("dmmap_dhcpv6", "interface", section_name(s), &dmmap_section);
dmuci_get_value_by_section_string(s, "iface_name", &iface_name);
if (DM_STRLEN(iface_name))
get_config_section_of_dmmap_section("network", "interface", iface_name, &iface_s);
dmuci_get_value_by_section_string(dmmap_section, "added_by_controller", &added_by_controller);
if (added_by_controller && strcmp(added_by_controller, "1") == 0) {
dmuci_delete_by_section(s, NULL, NULL);
} else {
dmuci_set_value_by_section(s, "proto", "none");
if (iface_s) {
char *device = NULL;
dmuci_get_value_by_section_string(iface_s, "device", &device);
if (device && DM_STRCHR(device, '@')) {
dmuci_delete_by_section(iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(iface_s, "proto", "none");
dmuci_set_value_by_section(iface_s, "reqaddress", "");
dmuci_set_value_by_section(iface_s, "reqprefix", "");
dmuci_set_value_by_section(iface_s, "reqopts", "");
}
}
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(s, NULL, NULL);
}
break;
}
@ -366,7 +418,7 @@ static int delObjDHCPv6ServerPool(char *refparam, struct dmctx *ctx, void *data,
char *dhcpv6 = NULL;
dmuci_get_value_by_section_string(s, "dhcpv6", &dhcpv6);
if (strcmp(dhcpv6, "server") == 0) {
if (DM_LSTRCMP(dhcpv6, "server") == 0) {
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_dhcpv6", "dhcp", section_name(s), &dmmap_section);
@ -433,14 +485,17 @@ static int get_DHCPv6_ClientNumberOfEntries(char *refparam, struct dmctx *ctx, v
/*#Device.DHCPv6.Client.{i}.Enable!UCI:network/interface,@i-1/disabled*/
static int get_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
char *disabled = NULL;
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "disabled", &disabled);
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "disabled", &disabled);
*value = (disabled[0] == '1') ? "0" : "1";
return 0;
}
static int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
bool b;
switch (action) {
@ -450,7 +505,9 @@ static int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "disabled", b ? "0" : "1");
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "disabled", b ? "0" : "1");
if (dhcpv6_client->iface_s)
dmuci_set_value_by_section(dhcpv6_client->iface_s, "disabled", b ? "0" : "1");
return 0;
}
return 0;
@ -458,7 +515,7 @@ static int set_DHCPv6Client_Enable(char *refparam, struct dmctx *ctx, void *data
static int get_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->dmmap_section, "bbf_dhcpv6client_alias", value);
dmuci_get_value_by_section_string(((struct dhcpv6_client_args *)data)->dmmap_s, "bbf_dhcpv6client_alias", value);
if ((*value)[0] == '\0')
dmasprintf(value, "cpe-%s", instance);
return 0;
@ -472,7 +529,7 @@ static int set_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data,
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->dmmap_section, "bbf_dhcpv6client_alias", value);
dmuci_set_value_by_section(((struct dhcpv6_client_args *)data)->dmmap_s, "bbf_dhcpv6client_alias", value);
break;
}
return 0;
@ -480,56 +537,149 @@ static int set_DHCPv6Client_Alias(char *refparam, struct dmctx *ctx, void *data,
static int get_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dhcpv6_s = (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section;
char *device = NULL;
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
char *iface_name = NULL;
dmuci_get_value_by_section_string(dhcpv6_s, "device", &device);
char *parent_s = (device && *device) ? strchr(device, '@') : NULL;
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "iface_name", &iface_name);
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", iface_name, value);
char *linker = dmstrdup(parent_s ? parent_s + 1 : dhcpv6_s ? section_name(dhcpv6_s) : "");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
if (*value == NULL)
*value = "";
if ((!(*value) || (*value)[0] == 0) && dhcpv6_client->iface_s) {
char *device = NULL;
dmuci_get_value_by_section_string(dhcpv6_client->iface_s, "device", &device);
iface_name = (device && *device) ? DM_STRCHR(device, '@') : NULL;
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", iface_name ? iface_name + 1 : "", value);
}
return 0;
}
static int set_DHCPv6Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_DHCP_Interface(ctx, value, (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->dmmap_section, "dmmap_dhcpv6", "dhcpv6", action);
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
struct uci_section *interface_s = NULL;
char *curr_iface_name = NULL;
char *linker = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
break;
case VALUESET:
// Get linker
adm_entry_get_linker_value(ctx, value, &linker);
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "iface_name", &curr_iface_name);
// Get the corresponding network config
if (linker && *linker != 0)
get_config_section_of_dmmap_section("network", "interface", linker, &interface_s);
// break if interface section is not found
if (interface_s && (strcmp(section_name(interface_s), curr_iface_name) == 0))
break;
if (dhcpv6_client->iface_s) {
char *device = NULL;
dmuci_get_value_by_section_string(dhcpv6_client->iface_s, "device", &device);
if (device && DM_STRCHR(device, '@')) {
dmuci_delete_by_section(dhcpv6_client->iface_s, NULL, NULL);
} else {
dmuci_set_value_by_section(dhcpv6_client->iface_s, "proto", "none");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqaddress", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqprefix", "");
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqopts", "");
}
}
if (!linker || *linker == 0) {
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "added_by_controller", "1");
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", "");
} else {
char *reqaddress = NULL;
char *reqprefix = NULL;
char *reqopts = NULL;
// Get the current value of requested parameters
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqaddress", &reqaddress);
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqprefix", &reqprefix);
dmuci_get_value_by_section_string(dhcpv6_client->dmmap_s, "reqopts", &reqopts);
if (interface_s) {
struct uci_section *iface_s = NULL;
char iface_name[32];
char *proto = NULL;
dmuci_get_value_by_section_string(interface_s, "proto", &proto);
if (DM_LSTRNCMP(proto, "dhcp", 4) == 0) {
char dev_name[32];
snprintf(iface_name, sizeof(iface_name), "%s_6", linker);
snprintf(dev_name, sizeof(dev_name), "@%s", linker);
// Create a new interface section
dmuci_add_section("network", "interface", &iface_s);
dmuci_rename_section_by_section(iface_s, iface_name);
dmuci_set_value_by_section(iface_s, "device", dev_name);
}
// Update proto option of config section
dmuci_set_value_by_section(iface_s ? iface_s : interface_s, "proto", "dhcpv6");
dmuci_set_value_by_section(iface_s ? iface_s : interface_s, "reqaddress", reqaddress);
dmuci_set_value_by_section(iface_s ? iface_s : interface_s, "reqprefix", reqprefix);
dmuci_set_value_by_section(iface_s ? iface_s : interface_s, "reqopts", reqopts);
// Update dmmap section
dmuci_set_value_by_section_bbfdm(dhcpv6_client->dmmap_s, "iface_name", iface_s ? iface_name : linker);
}
}
break;
}
return 0;
}
/*#Device.DHCPv6.Client.{i}.Status!UCI:network/interface,@i-1/disabled*/
static int get_DHCPv6Client_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *disabled = NULL;
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "disabled", &disabled);
*value = (disabled[0] == '1') ? "Disabled" : "Enabled";
get_DHCPv6Client_Enable(refparam, ctx, data, instance, value);
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
return 0;
}
/*#Device.DHCPv6.Client.{i}.DUID!UBUS:network.interface/status/interface,@Name/data.passthru*/
static int get_DHCPv6Client_DUID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *dhcpv6_s = (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section;
json_object *res = NULL;
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->iface_s;
if (dhcpv6_s) {
json_object *res = NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", dhcpv6_s ? section_name(dhcpv6_s) : "", String}}, 1, &res);
*value = res ? dmjson_get_value(res, 2, "data", "passthru") : "";
char *if_name = section_name(dhcpv6_s);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
*value = res ? dmjson_get_value(res, 2, "data", "passthru") : "";
}
return 0;
}
/*#Device.DHCPv6.Client.{i}.RequestAddresses!UCI:network/interface,@i-1/reqaddress*/
static int get_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
char *reqaddress = NULL;
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqaddress", &reqaddress);
*value = (reqaddress && strcmp(reqaddress, "none") == 0) ? "0" : "1";
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqaddress", &reqaddress);
*value = (reqaddress && DM_LSTRCMP(reqaddress, "none") == 0) ? "0" : "1";
return 0;
}
static int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
bool b;
switch (action) {
@ -539,7 +689,9 @@ static int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx,
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqaddress", b ? "force" : "none");
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "reqaddress", b ? "force" : "none");
if (dhcpv6_client->iface_s)
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqaddress", b ? "force" : "none");
break;
}
return 0;
@ -548,15 +700,17 @@ static int set_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx,
/*#Device.DHCPv6.Client.{i}.RequestPrefixes!UCI:network/interface,@i-1/reqprefix*/
static int get_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
char *reqprefix = NULL;
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqprefix", &reqprefix);
*value = (reqprefix && strcmp(reqprefix, "auto") == 0) ? "1" : "0";
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqprefix", &reqprefix);
*value = (reqprefix && DM_LSTRCMP(reqprefix, "auto") == 0) ? "1" : "0";
return 0;
}
static int set_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
bool b;
switch (action) {
@ -566,7 +720,9 @@ static int set_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, v
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqprefix", b ? "auto" : "no");
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "reqprefix", b ? "auto" : "no");
if (dhcpv6_client->iface_s)
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqprefix", b ? "auto" : "no");
return 0;
}
return 0;
@ -580,7 +736,7 @@ static int get_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data,
static int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dhcpv6_s = (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section;
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->iface_s;
bool b;
switch (action) {
@ -591,7 +747,10 @@ static int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data,
case VALUESET:
string_to_bool(value, &b);
if (!b) break;
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", dhcpv6_s ? section_name(dhcpv6_s) : "", String}}, 1);
if (dhcpv6_s) {
char *if_name = section_name(dhcpv6_s);
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", if_name, String}}, 1);
}
break;
}
return 0;
@ -600,19 +759,25 @@ static int set_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data,
/*#Device.DHCPv6.Client.{i}.RequestedOptions!UCI:network/interface,@i-1/reqopts*/
static int get_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqopts", value);
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
dmuci_get_value_by_section_string(dhcpv6_client->iface_s ? dhcpv6_client->iface_s : dhcpv6_client->dmmap_s, "reqopts", value);
return 0;
}
static int set_DHCPv6Client_RequestedOptions(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct dhcpv6_client_args *dhcpv6_client = (struct dhcpv6_client_args *)data;
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt_list(value, -1, -1, -1, RANGE_ARGS{{NULL,NULL}}, 1))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section((((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section, "reqopts", value);
dmuci_set_value_by_section(dhcpv6_client->dmmap_s, "reqopts", value);
if (dhcpv6_client->iface_s)
dmuci_set_value_by_section(dhcpv6_client->iface_s, "reqopts", value);
break;
}
return 0;
@ -656,7 +821,7 @@ static int get_DHCPv6Server_PoolNumberOfEntries(char *refparam, struct dmctx *ct
static int get_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "dhcpv6", value);
*value = (*value && strcmp(*value, "disabled") == 0) ? "0" : "1";
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "0" : "1";
return 0;
}
@ -681,7 +846,7 @@ static int set_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *
static int get_DHCPv6ServerPool_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "dhcpv6", value);
*value = (*value && strcmp(*value, "disabled") == 0) ? "Disabled" : "Enabled";
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
return 0;
}
@ -730,30 +895,28 @@ static int set_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *d
static int get_DHCPv6ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker;
linker = dmstrdup(((struct dhcpv6_args *)data)->interface);
char *linker = dmstrdup(((struct dhcpv6_args *)data)->interface);
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
if (*value == NULL)
*value = "";
dmfree(linker);
return 0;
}
static int set_DHCPv6ServerPool_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
char *linker = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
if (linker && *linker) {
dmuci_set_value_by_section((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "interface", linker);
dmfree(linker);
}
dmuci_set_value_by_section((((struct dhcpv6_args *)data)->dhcp_sections)->config_section, "interface", linker ? linker : "");
break;
}
return 0;
@ -768,7 +931,7 @@ static int get_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx,
dmuci_get_value_by_section_string(vendorclassidclassifier, "vendorclass", &vcid);
if (vcid && *vcid)
convert_string_to_hex(vcid, hex);
convert_string_to_hex(vcid, hex, sizeof(hex));
*value = (*hex) ? dmstrdup(hex) : "";
return 0;
@ -785,7 +948,7 @@ static int set_DHCPv6ServerPool_VendorClassID(char *refparam, struct dmctx *ctx,
return FAULT_9007;
break;
case VALUESET:
convert_hex_to_string(value, res);
convert_hex_to_string(value, res, sizeof(res));
vendorclassidclassifier = get_dhcpv6_classifier("vendorclass", ((struct dhcpv6_args *)data)->interface);
if (!vendorclassidclassifier) {
@ -807,7 +970,7 @@ static int get_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, v
dmuci_get_value_by_section_string(userclassidclassifier, "userclass", &ucid);
if (ucid && *ucid)
convert_string_to_hex(ucid, hex);
convert_string_to_hex(ucid, hex, sizeof(hex));
*value = (*hex) ? dmstrdup(hex) : "";
return 0;
@ -824,7 +987,7 @@ static int set_DHCPv6ServerPool_UserClassID(char *refparam, struct dmctx *ctx, v
return FAULT_9007;
break;
case VALUESET:
convert_hex_to_string(value, res);
convert_hex_to_string(value, res, sizeof(res));
userclassidclassifier = get_dhcpv6_classifier("userclass", ((struct dhcpv6_args *)data)->interface);
if (!userclassidclassifier) {
@ -861,7 +1024,7 @@ static int set_DHCPv6ServerPool_SourceAddress(char *refparam, struct dmctx *ctx,
return 0;
}
static int get_DHCPv6ServerPool_SourceAddressMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) //TODO: return wrong value
static int get_DHCPv6ServerPool_SourceAddressMask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *classifier_s = get_dhcpv6_classifier("mac", ((struct dhcpv6_args *)data)->interface);
if (classifier_s == NULL) {
@ -907,7 +1070,7 @@ static int get_DHCPv6ServerPoolClient_Alias(char *refparam, struct dmctx *ctx, v
uci_path_foreach_sections(bbfdm, "dmmap", "dhcpv6clients", s) {
char *srcaddr;
dmuci_get_value_by_section_string(s, "srcaddr", &srcaddr);
if (strcmp(src_addr, srcaddr) == 0) {
if (DM_STRCMP(src_addr, srcaddr) == 0) {
dmuci_get_value_by_section_string(s, "alias", value);
break;
}
@ -981,8 +1144,8 @@ static int get_DHCPv6ServerPoolClientIPv6Prefix_PreferredLifetime(char *refparam
*value = "0001-01-01T00:00:00Z";
char *preferred = dmjson_get_value(((struct clientv6_args *)data)->clientparam, 1, "preferred-lifetime");
if (preferred && *preferred != '\0' && atoi(preferred) > 0) {
time_t time_value = atoi(preferred);
if (preferred && *preferred != '\0' && DM_STRTOL(preferred) > 0) {
time_t time_value = DM_STRTOL(preferred);
char s_now[sizeof "AAAA-MM-JJTHH:MM:SSZ"];
if (strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%SZ", gmtime(&time_value)) == 0)
return -1;
@ -997,8 +1160,8 @@ static int get_DHCPv6ServerPoolClientIPv6Prefix_ValidLifetime(char *refparam, st
*value = "0001-01-01T00:00:00Z";
char *valid = dmjson_get_value(((struct clientv6_args *)data)->clientparam, 1, "valid-lifetime");
if (valid && *valid != '\0' && atoi(valid) > 0) {
time_t time_value = atoi(valid);
if (valid && *valid != '\0' && DM_STRTOL(valid) > 0) {
time_t time_value = DM_STRTOL(valid);
char s_now[sizeof "AAAA-MM-JJTHH:MM:SSZ"];
if (strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%SZ", gmtime(&time_value)) == 0)
return -1;
@ -1020,7 +1183,7 @@ static int get_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx,
uci_foreach_element(dhcp_option_list, e) {
char **buf = strsplit(e->name, ",", &length);
if (buf && *buf && strcmp(buf[0], dhcpv6_client_s->option_tag) == 0) {
if (buf && *buf && DM_STRCMP(buf[0], dhcpv6_client_s->option_tag) == 0) {
*value = "1";
return 0;
}
@ -1053,7 +1216,7 @@ static int set_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx,
uci_foreach_element(dhcp_option_list, e) {
char **buf = strsplit(e->name, ",", &length);
if (buf && *buf && strcmp(buf[0], dhcpv6_client_s->option_tag) == 0) {
if (buf && *buf && DM_STRCMP(buf[0], dhcpv6_client_s->option_tag) == 0) {
option_enabled = true;
if (!b)
dmuci_del_list_value_by_section(dhcpv6_client_s->client_sect, "dhcp_option", opt_value);
@ -1108,10 +1271,11 @@ static int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, voi
if (dm_validate_unsignedInt(value, RANGE_ARGS{{"0","65535"}}, 1))
return FAULT_9007;
if (dhcpv6_client_s->option_tag && strcmp(dhcpv6_client_s->option_tag, value) == 0)
if (dhcpv6_client_s->option_tag && DM_STRCMP(dhcpv6_client_s->option_tag, value) == 0)
break;
if (tag_option_exists("dmmap_dhcpv6", "servpool_option", "section_name", section_name(dhcpv6_client_s->client_sect), "option_tag", value))
char *name = section_name(dhcpv6_client_s->client_sect);
if (tag_option_exists("dmmap_dhcpv6", "servpool_option", "section_name", name, "option_tag", value))
return FAULT_9007;
break;
@ -1124,7 +1288,7 @@ static int set_DHCPv6ServerPoolOption_Tag(char *refparam, struct dmctx *ctx, voi
uci_foreach_element(dhcp_option_list, e) {
char **buf = strsplit(e->name, ",", &length);
if (buf && *buf && strcmp(buf[0], dhcpv6_client_s->option_tag) == 0) {
if (buf && *buf && DM_STRCMP(buf[0], dhcpv6_client_s->option_tag) == 0) {
option_enabled = true;
break;
}
@ -1152,7 +1316,7 @@ static int get_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, v
char hex[256] = {0};
if (tag_value && *tag_value)
convert_string_to_hex(tag_value, hex);
convert_string_to_hex(tag_value, hex, sizeof(hex));
*value = (*hex) ? dmstrdup(hex) : "";
return 0;
@ -1179,14 +1343,14 @@ static int set_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, v
uci_foreach_element(dhcp_option_list, e) {
char **buf = strsplit(e->name, ",", &length);
if (buf && *buf && strcmp(buf[0], dhcpv6_client_s->option_tag) == 0) {
if (buf && *buf && DM_STRCMP(buf[0], dhcpv6_client_s->option_tag) == 0) {
option_enabled = true;
break;
}
}
}
convert_hex_to_string(value, res);
convert_hex_to_string(value, res, sizeof(res));
if (option_enabled) {
char new_tag_value[512] = {0}, old_tag_value[128] = {0};
@ -1208,9 +1372,12 @@ static int set_DHCPv6ServerPoolOption_Value(char *refparam, struct dmctx *ctx, v
*************************************************************/
static int operate_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dhcpv6_s = (((struct dhcpv6_client_args *)data)->dhcp_client_sections)->config_section;
struct uci_section *dhcpv6_s = ((struct dhcpv6_client_args *)data)->iface_s;
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", section_name(dhcpv6_s), String}}, 1);
if (dhcpv6_s) {
char *if_name = section_name(dhcpv6_s);
dmubus_call_set("network.interface", "renew", UBUS_ARGS{{"interface", if_name, String}}, 1);
}
return CMD_SUCCESS;
}
@ -1220,143 +1387,143 @@ static int operate_DHCPv6Client_Renew(char *refparam, struct dmctx *ctx, void *d
***********************************************************************************************************************************/
/* *** Device.DHCPv6. *** */
DMOBJ tDHCPv6Obj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Client", &DMWRITE, addObjDHCPv6Client, delObjDHCPv6Client, NULL, browseDHCPv6ClientInst, NULL, NULL, NULL, tDHCPv6ClientParams, NULL, BBFDM_BOTH, LIST_KEY{"Interface", "Alias", NULL}},
{"Server", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDHCPv6ServerObj, tDHCPv6ServerParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Client", &DMWRITE, addObjDHCPv6Client, delObjDHCPv6Client, NULL, browseDHCPv6ClientInst, NULL, NULL, NULL, tDHCPv6ClientParams, NULL, BBFDM_BOTH, LIST_KEY{"Interface", "Alias", NULL}, "2.2"},
{"Server", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDHCPv6ServerObj, tDHCPv6ServerParams, NULL, BBFDM_BOTH, NULL, "2.2"},
{0}
};
DMLEAF tDHCPv6Params[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ClientNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6_ClientNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ClientNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6_ClientNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
DMLEAF tDHCPv6ClientParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv6Client_Enable, set_DHCPv6Client_Enable, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6Client_Alias, set_DHCPv6Client_Alias, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_DHCPv6Client_Interface, set_DHCPv6Client_Interface, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_DHCPv6Client_Status, NULL, BBFDM_BOTH},
{"DUID", &DMREAD, DMT_HEXBIN, get_DHCPv6Client_DUID, NULL, BBFDM_BOTH},
{"RequestAddresses", &DMWRITE, DMT_BOOL, get_DHCPv6Client_RequestAddresses, set_DHCPv6Client_RequestAddresses, BBFDM_BOTH},
{"RequestPrefixes", &DMWRITE, DMT_BOOL, get_DHCPv6Client_RequestPrefixes, set_DHCPv6Client_RequestPrefixes, BBFDM_BOTH},
//{"RapidCommit", &DMWRITE, DMT_BOOL, get_DHCPv6Client_RapidCommit, set_DHCPv6Client_RapidCommit, BBFDM_BOTH},
{"Renew", &DMWRITE, DMT_BOOL, get_DHCPv6Client_Renew, set_DHCPv6Client_Renew, BBFDM_CWMP},
//{"SuggestedT1", &DMWRITE, DMT_INT, get_DHCPv6Client_SuggestedT1, set_DHCPv6Client_SuggestedT1, BBFDM_BOTH},
//{"SuggestedT2", &DMWRITE, DMT_INT, get_DHCPv6Client_SuggestedT2, set_DHCPv6Client_SuggestedT2, BBFDM_BOTH},
//{"SupportedOptions", &DMREAD, DMT_STRING, get_DHCPv6Client_SupportedOptions, NULL, BBFDM_BOTH},
{"RequestedOptions", &DMWRITE, DMT_STRING, get_DHCPv6Client_RequestedOptions, set_DHCPv6Client_RequestedOptions, BBFDM_BOTH},
//{"ServerNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_ServerNumberOfEntries, NULL, BBFDM_BOTH},
//{"SentOptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_SentOptionNumberOfEntries, NULL, BBFDM_BOTH},
//{"ReceivedOptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_ReceivedOptionNumberOfEntries, NULL, BBFDM_BOTH},
{"Renew()", &DMSYNC, DMT_COMMAND, NULL, operate_DHCPv6Client_Renew, BBFDM_USP},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv6Client_Enable, set_DHCPv6Client_Enable, BBFDM_BOTH, "2.2"},
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6Client_Alias, set_DHCPv6Client_Alias, BBFDM_BOTH, "2.2"},
{"Interface", &DMWRITE, DMT_STRING, get_DHCPv6Client_Interface, set_DHCPv6Client_Interface, BBFDM_BOTH, "2.2"},
{"Status", &DMREAD, DMT_STRING, get_DHCPv6Client_Status, NULL, BBFDM_BOTH, "2.2"},
{"DUID", &DMREAD, DMT_HEXBIN, get_DHCPv6Client_DUID, NULL, BBFDM_BOTH, "2.2"},
{"RequestAddresses", &DMWRITE, DMT_BOOL, get_DHCPv6Client_RequestAddresses, set_DHCPv6Client_RequestAddresses, BBFDM_BOTH, "2.2"},
{"RequestPrefixes", &DMWRITE, DMT_BOOL, get_DHCPv6Client_RequestPrefixes, set_DHCPv6Client_RequestPrefixes, BBFDM_BOTH, "2.2"},
//{"RapidCommit", &DMWRITE, DMT_BOOL, get_DHCPv6Client_RapidCommit, set_DHCPv6Client_RapidCommit, BBFDM_BOTH, "2.2"},
{"Renew", &DMWRITE, DMT_BOOL, get_DHCPv6Client_Renew, set_DHCPv6Client_Renew, BBFDM_CWMP, "2.2"},
//{"SuggestedT1", &DMWRITE, DMT_INT, get_DHCPv6Client_SuggestedT1, set_DHCPv6Client_SuggestedT1, BBFDM_BOTH, "2.2"},
//{"SuggestedT2", &DMWRITE, DMT_INT, get_DHCPv6Client_SuggestedT2, set_DHCPv6Client_SuggestedT2, BBFDM_BOTH, "2.2"},
//{"SupportedOptions", &DMREAD, DMT_STRING, get_DHCPv6Client_SupportedOptions, NULL, BBFDM_BOTH, "2.2"},
{"RequestedOptions", &DMWRITE, DMT_STRING, get_DHCPv6Client_RequestedOptions, set_DHCPv6Client_RequestedOptions, BBFDM_BOTH, "2.2"},
//{"ServerNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_ServerNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
//{"SentOptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_SentOptionNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
//{"ReceivedOptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Client_ReceivedOptionNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{"Renew()", &DMSYNC, DMT_COMMAND, NULL, operate_DHCPv6Client_Renew, BBFDM_USP, "2.12"},
{0}
};
/* *** Device.DHCPv6.Server. *** */
DMOBJ tDHCPv6ServerObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Pool", &DMWRITE, addObjDHCPv6ServerPool, delObjDHCPv6ServerPool, NULL, browseDHCPv6ServerPoolInst, NULL, NULL, tDHCPv6ServerPoolObj, tDHCPv6ServerPoolParams, NULL, BBFDM_BOTH, LIST_KEY{"Order", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Pool", &DMWRITE, addObjDHCPv6ServerPool, delObjDHCPv6ServerPool, NULL, browseDHCPv6ServerPoolInst, NULL, NULL, tDHCPv6ServerPoolObj, tDHCPv6ServerPoolParams, NULL, BBFDM_BOTH, LIST_KEY{"Order", "Alias", NULL}, "2.2"},
{0}
};
DMLEAF tDHCPv6ServerParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv6Server_Enable, set_DHCPv6Server_Enable, BBFDM_BOTH},
{"PoolNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Server_PoolNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv6Server_Enable, set_DHCPv6Server_Enable, BBFDM_BOTH, "2.2"},
{"PoolNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6Server_PoolNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.DHCPv6.Server.Pool.{i}. *** */
DMOBJ tDHCPv6ServerPoolObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Client", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientInst, NULL, NULL, tDHCPv6ServerPoolClientObj, tDHCPv6ServerPoolClientParams, NULL, BBFDM_BOTH, LIST_KEY{"SourceAddress", "Alias", NULL}},
{"Option", &DMWRITE, addObjDHCPv6ServerPoolOption, delObjDHCPv6ServerPoolOption, NULL, browseDHCPv6ServerPoolOptionInst, NULL, NULL, NULL, tDHCPv6ServerPoolOptionParams, NULL, BBFDM_BOTH, LIST_KEY{"Tag", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Client", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientInst, NULL, NULL, tDHCPv6ServerPoolClientObj, tDHCPv6ServerPoolClientParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}, "2.2"},
{"Option", &DMWRITE, addObjDHCPv6ServerPoolOption, delObjDHCPv6ServerPoolOption, NULL, browseDHCPv6ServerPoolOptionInst, NULL, NULL, NULL, tDHCPv6ServerPoolOptionParams, NULL, BBFDM_BOTH, LIST_KEY{"Tag", "Alias", NULL}, "2.2"},
{0}
};
DMLEAF tDHCPv6ServerPoolParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_Enable, set_DHCPv6ServerPool_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_DHCPv6ServerPool_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_Alias, set_DHCPv6ServerPool_Alias, BBFDM_BOTH},
{"Order", &DMWRITE, DMT_UNINT, get_DHCPv6ServerPool_Order, set_DHCPv6ServerPool_Order, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_Interface, set_DHCPv6ServerPool_Interface, BBFDM_BOTH},
//{"DUID", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPool_DUID, set_DHCPv6ServerPool_DUID, BBFDM_BOTH},
//{"DUIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_DUIDExclude, set_DHCPv6ServerPool_DUIDExclude, BBFDM_BOTH},
{"VendorClassID", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPool_VendorClassID, set_DHCPv6ServerPool_VendorClassID, BBFDM_BOTH},
//{"VendorClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_VendorClassIDExclude, set_DHCPv6ServerPool_VendorClassIDExclude, BBFDM_BOTH},
{"UserClassID", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPool_UserClassID, set_DHCPv6ServerPool_UserClassID, BBFDM_BOTH},
//{"UserClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_UserClassIDExclude, set_DHCPv6ServerPool_UserClassIDExclude, BBFDM_BOTH},
{"SourceAddress", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_SourceAddress, set_DHCPv6ServerPool_SourceAddress, BBFDM_BOTH},
{"SourceAddressMask", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_SourceAddressMask, set_DHCPv6ServerPool_SourceAddressMask, BBFDM_BOTH},
//{"SourceAddressExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_SourceAddressExclude, set_DHCPv6ServerPool_SourceAddressExclude, BBFDM_BOTH},
//{"IANAEnable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_IANAEnable, set_DHCPv6ServerPool_IANAEnable, BBFDM_BOTH},
//{"IANAManualPrefixes", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_IANAManualPrefixes, set_DHCPv6ServerPool_IANAManualPrefixes, BBFDM_BOTH},
//{"IANAPrefixes", &DMREAD, DMT_STRING, get_DHCPv6ServerPool_IANAPrefixes, NULL, BBFDM_BOTH},
//{"IAPDEnable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_IAPDEnable, set_DHCPv6ServerPool_IAPDEnable, BBFDM_BOTH},
//{"IAPDManualPrefixes", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_IAPDManualPrefixes, set_DHCPv6ServerPool_IAPDManualPrefixes, BBFDM_BOTH},
//{"IAPDPrefixes", &DMREAD, DMT_STRING, get_DHCPv6ServerPool_IAPDPrefixes, NULL, BBFDM_BOTH},
//{"IAPDAddLength", &DMWRITE, DMT_UNINT, get_DHCPv6ServerPool_IAPDAddLength, set_DHCPv6ServerPool_IAPDAddLength, BBFDM_BOTH},
{"ClientNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPool_ClientNumberOfEntries, NULL, BBFDM_BOTH},
{"OptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPool_OptionNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_Enable, set_DHCPv6ServerPool_Enable, BBFDM_BOTH, "2.2"},
{"Status", &DMREAD, DMT_STRING, get_DHCPv6ServerPool_Status, NULL, BBFDM_BOTH, "2.2"},
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_Alias, set_DHCPv6ServerPool_Alias, BBFDM_BOTH, "2.2"},
{"Order", &DMWRITE, DMT_UNINT, get_DHCPv6ServerPool_Order, set_DHCPv6ServerPool_Order, BBFDM_BOTH, "2.2"},
{"Interface", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_Interface, set_DHCPv6ServerPool_Interface, BBFDM_BOTH, "2.2"},
//{"DUID", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPool_DUID, set_DHCPv6ServerPool_DUID, BBFDM_BOTH, "2.2"},
//{"DUIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_DUIDExclude, set_DHCPv6ServerPool_DUIDExclude, BBFDM_BOTH, "2.2"},
{"VendorClassID", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPool_VendorClassID, set_DHCPv6ServerPool_VendorClassID, BBFDM_BOTH, "2.2"},
//{"VendorClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_VendorClassIDExclude, set_DHCPv6ServerPool_VendorClassIDExclude, BBFDM_BOTH, "2.2"},
{"UserClassID", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPool_UserClassID, set_DHCPv6ServerPool_UserClassID, BBFDM_BOTH, "2.2"},
//{"UserClassIDExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_UserClassIDExclude, set_DHCPv6ServerPool_UserClassIDExclude, BBFDM_BOTH, "2.2"},
{"SourceAddress", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_SourceAddress, set_DHCPv6ServerPool_SourceAddress, BBFDM_BOTH, "2.2"},
{"SourceAddressMask", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_SourceAddressMask, set_DHCPv6ServerPool_SourceAddressMask, BBFDM_BOTH, "2.2"},
//{"SourceAddressExclude", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_SourceAddressExclude, set_DHCPv6ServerPool_SourceAddressExclude, BBFDM_BOTH, "2.2"},
//{"IANAEnable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_IANAEnable, set_DHCPv6ServerPool_IANAEnable, BBFDM_BOTH, "2.2"},
//{"IANAManualPrefixes", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_IANAManualPrefixes, set_DHCPv6ServerPool_IANAManualPrefixes, BBFDM_BOTH, "2.2"},
//{"IANAPrefixes", &DMREAD, DMT_STRING, get_DHCPv6ServerPool_IANAPrefixes, NULL, BBFDM_BOTH, "2.2"},
//{"IAPDEnable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPool_IAPDEnable, set_DHCPv6ServerPool_IAPDEnable, BBFDM_BOTH, "2.2"},
//{"IAPDManualPrefixes", &DMWRITE, DMT_STRING, get_DHCPv6ServerPool_IAPDManualPrefixes, set_DHCPv6ServerPool_IAPDManualPrefixes, BBFDM_BOTH, "2.2"},
//{"IAPDPrefixes", &DMREAD, DMT_STRING, get_DHCPv6ServerPool_IAPDPrefixes, NULL, BBFDM_BOTH, "2.2"},
//{"IAPDAddLength", &DMWRITE, DMT_UNINT, get_DHCPv6ServerPool_IAPDAddLength, set_DHCPv6ServerPool_IAPDAddLength, BBFDM_BOTH, "2.2"},
{"ClientNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPool_ClientNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{"OptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPool_OptionNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.DHCPv6.Server.Pool.{i}.Client.{i}. *** */
DMOBJ tDHCPv6ServerPoolClientObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"IPv6Address", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientIPv6AddressInst, NULL, NULL, NULL, tDHCPv6ServerPoolClientIPv6AddressParams, NULL, BBFDM_BOTH, LIST_KEY{"IPAddress", NULL}},
{"IPv6Prefix", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientIPv6PrefixInst, NULL, NULL, NULL, tDHCPv6ServerPoolClientIPv6PrefixParams, NULL, BBFDM_BOTH, LIST_KEY{"Prefix", NULL}},
//{"Option", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientOptionInst, NULL, NULL, NULL, tDHCPv6ServerPoolClientOptionParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"IPv6Address", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientIPv6AddressInst, NULL, NULL, NULL, tDHCPv6ServerPoolClientIPv6AddressParams, NULL, BBFDM_BOTH, LIST_KEY{"IPAddress", NULL}, "2.2"},
{"IPv6Prefix", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientIPv6PrefixInst, NULL, NULL, NULL, tDHCPv6ServerPoolClientIPv6PrefixParams, NULL, BBFDM_BOTH, LIST_KEY{"Prefix", NULL}, "2.2"},
//{"Option", &DMREAD, NULL, NULL, NULL, browseDHCPv6ServerPoolClientOptionInst, NULL, NULL, NULL, tDHCPv6ServerPoolClientOptionParams, NULL, BBFDM_BOTH, NULL, "2.2"},
{0}
};
DMLEAF tDHCPv6ServerPoolClientParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolClient_Alias, set_DHCPv6ServerPoolClient_Alias, BBFDM_BOTH},
//{"SourceAddress", &DMREAD, DMT_STRING, get_DHCPv6ServerPoolClient_SourceAddress, NULL, BBFDM_BOTH},
//{"Active", &DMREAD, DMT_BOOL, get_DHCPv6ServerPoolClient_Active, NULL, BBFDM_BOTH},
{"IPv6AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClient_IPv6AddressNumberOfEntries, NULL, BBFDM_BOTH},
{"IPv6PrefixNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClient_IPv6PrefixNumberOfEntries, NULL, BBFDM_BOTH},
//{"OptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClient_OptionNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolClient_Alias, set_DHCPv6ServerPoolClient_Alias, BBFDM_BOTH, "2.2"},
//{"SourceAddress", &DMREAD, DMT_STRING, get_DHCPv6ServerPoolClient_SourceAddress, NULL, BBFDM_BOTH, "2.2"},
//{"Active", &DMREAD, DMT_BOOL, get_DHCPv6ServerPoolClient_Active, NULL, BBFDM_BOTH, "2.2"},
{"IPv6AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClient_IPv6AddressNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{"IPv6PrefixNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClient_IPv6PrefixNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
//{"OptionNumberOfEntries", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClient_OptionNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.DHCPv6.Server.Pool.{i}.Client.{i}.IPv6Address.{i}. *** */
DMLEAF tDHCPv6ServerPoolClientIPv6AddressParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"IPAddress", &DMREAD, DMT_STRING, get_DHCPv6ServerPoolClientIPv6Address_IPAddress, NULL, BBFDM_BOTH},
{"PreferredLifetime", &DMREAD, DMT_TIME, get_DHCPv6ServerPoolClientIPv6Address_PreferredLifetime, NULL, BBFDM_BOTH},
{"ValidLifetime", &DMREAD, DMT_TIME, get_DHCPv6ServerPoolClientIPv6Address_ValidLifetime, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"IPAddress", &DMREAD, DMT_STRING, get_DHCPv6ServerPoolClientIPv6Address_IPAddress, NULL, BBFDM_BOTH, "2.2"},
{"PreferredLifetime", &DMREAD, DMT_TIME, get_DHCPv6ServerPoolClientIPv6Address_PreferredLifetime, NULL, BBFDM_BOTH, "2.2"},
{"ValidLifetime", &DMREAD, DMT_TIME, get_DHCPv6ServerPoolClientIPv6Address_ValidLifetime, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.DHCPv6.Server.Pool.{i}.Client.{i}.IPv6Prefix.{i}. *** */
DMLEAF tDHCPv6ServerPoolClientIPv6PrefixParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Prefix", &DMREAD, DMT_STRING, get_DHCPv6ServerPoolClientIPv6Prefix_Prefix, NULL, BBFDM_BOTH},
{"PreferredLifetime", &DMREAD, DMT_TIME, get_DHCPv6ServerPoolClientIPv6Prefix_PreferredLifetime, NULL, BBFDM_BOTH},
{"ValidLifetime", &DMREAD, DMT_TIME, get_DHCPv6ServerPoolClientIPv6Prefix_ValidLifetime, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Prefix", &DMREAD, DMT_STRING, get_DHCPv6ServerPoolClientIPv6Prefix_Prefix, NULL, BBFDM_BOTH, "2.2"},
{"PreferredLifetime", &DMREAD, DMT_TIME, get_DHCPv6ServerPoolClientIPv6Prefix_PreferredLifetime, NULL, BBFDM_BOTH, "2.2"},
{"ValidLifetime", &DMREAD, DMT_TIME, get_DHCPv6ServerPoolClientIPv6Prefix_ValidLifetime, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.DHCPv6.Server.Pool.{i}.Client.{i}.Option.{i}. *** */
DMLEAF tDHCPv6ServerPoolClientOptionParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"Tag", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClientOption_Tag, NULL, BBFDM_BOTH},
//{"Value", &DMREAD, DMT_HEXBIN, get_DHCPv6ServerPoolClientOption_Value, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"Tag", &DMREAD, DMT_UNINT, get_DHCPv6ServerPoolClientOption_Tag, NULL, BBFDM_BOTH, "2.2"},
//{"Value", &DMREAD, DMT_HEXBIN, get_DHCPv6ServerPoolClientOption_Value, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.DHCPv6.Server.Pool.{i}.Option.{i}. *** */
DMLEAF tDHCPv6ServerPoolOptionParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPoolOption_Enable, set_DHCPv6ServerPoolOption_Enable, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolOption_Alias, set_DHCPv6ServerPoolOption_Alias, BBFDM_BOTH},
{"Tag", &DMWRITE, DMT_UNINT, get_DHCPv6ServerPoolOption_Tag, set_DHCPv6ServerPoolOption_Tag, BBFDM_BOTH},
{"Value", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPoolOption_Value, set_DHCPv6ServerPoolOption_Value, BBFDM_BOTH},
//{"PassthroughClient", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolOption_PassthroughClient, set_DHCPv6ServerPoolOption_PassthroughClient, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_DHCPv6ServerPoolOption_Enable, set_DHCPv6ServerPoolOption_Enable, BBFDM_BOTH, "2.2"},
{"Alias", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolOption_Alias, set_DHCPv6ServerPoolOption_Alias, BBFDM_BOTH, "2.2"},
{"Tag", &DMWRITE, DMT_UNINT, get_DHCPv6ServerPoolOption_Tag, set_DHCPv6ServerPoolOption_Tag, BBFDM_BOTH, "2.2"},
{"Value", &DMWRITE, DMT_HEXBIN, get_DHCPv6ServerPoolOption_Value, set_DHCPv6ServerPoolOption_Value, BBFDM_BOTH, "2.2"},
//{"PassthroughClient", &DMWRITE, DMT_STRING, get_DHCPv6ServerPoolOption_PassthroughClient, set_DHCPv6ServerPoolOption_PassthroughClient, BBFDM_BOTH, "2.2"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __DHCPV6_H
#define __DHCPV6_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tDHCPv6Obj[];
extern DMLEAF tDHCPv6Params[];

View file

@ -8,7 +8,6 @@
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include "dmentry.h"
#include "dmdiagnostics.h"
#include "dmbbfcommon.h"
#include "dns.h"
@ -24,7 +23,7 @@ static unsigned char is_dns_server_in_dmmap(char *chk_ip, char *chk_interface)
uci_path_foreach_sections(bbfdm, "dmmap_dns", "dns_server", s) {
dmuci_get_value_by_section_string(s, "ip", &ip);
dmuci_get_value_by_section_string(s, "interface", &interface);
if (strcmp(interface, chk_interface) == 0 && strcmp(ip, chk_ip) == 0) {
if (DM_STRCMP(interface, chk_interface) == 0 && DM_STRCMP(ip, chk_ip) == 0) {
return 1;
}
}
@ -34,35 +33,50 @@ static unsigned char is_dns_server_in_dmmap(char *chk_ip, char *chk_interface)
static int dmmap_synchronizeDNSClientRelayServer(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *jobj = NULL, *arrobj = NULL;
struct uci_list *v;
struct uci_list *dns_list;
struct uci_element *e = NULL;
struct uci_section *s = NULL, *sdns = NULL, *stmp = NULL, *ss;
char *ipdns = NULL, *str, *vip = NULL, *viface;
struct uci_section *s = NULL, *stmp = NULL;
char *ipdns = NULL;
int j = 0;
uci_path_foreach_sections_safe(bbfdm, "dmmap_dns", "dns_server", stmp, s) {
dmuci_get_value_by_section_string(s, "ip", &vip);
dmuci_get_value_by_section_string(s, "interface", &viface);
int found = 0;
struct uci_section *ss = NULL;
char *added_by_controller = NULL;
char *ip = NULL;
char *iface = NULL;
bool found = false;
dmuci_get_value_by_section_string(s, "added_by_controller", &added_by_controller);
if (DM_LSTRCMP(added_by_controller, "1") == 0)
continue;
dmuci_get_value_by_section_string(s, "ip", &ip);
dmuci_get_value_by_section_string(s, "interface", &iface);
uci_foreach_sections("network", "interface", ss) {
if (strcmp(section_name(ss), viface) != 0)
if (strcmp(section_name(ss), iface) != 0)
continue;
dmuci_get_value_by_section_list(ss, "dns", &v);
if (v != NULL) {
uci_foreach_element(v, e) {
if (strcmp(e->name, vip) == 0) {
found = 1;
dmuci_get_value_by_section_list(ss, "dns", &dns_list);
if (dns_list != NULL) {
uci_foreach_element(dns_list, e) {
if (DM_STRCMP(e->name, ip) == 0) {
found = true;
break;
}
}
}
if (found)
break;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(ss), String}}, 1, &jobj);
char *if_name = section_name(ss);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &jobj);
if (!jobj) break;
dmjson_foreach_value_in_array(jobj, arrobj, ipdns, j, 1, "dns-server") {
if (strcmp(ipdns, vip) == 0) {
found = 1;
if (DM_STRCMP(ipdns, ip) == 0) {
found = true;
break;
}
}
@ -74,30 +88,40 @@ static int dmmap_synchronizeDNSClientRelayServer(struct dmctx *dmctx, DMNODE *pa
}
uci_foreach_sections("network", "interface", s) {
dmuci_get_value_by_section_list(s, "dns", &v);
if (v != NULL) {
uci_foreach_element(v, e) {
struct uci_section *dns_s = NULL;
char *peerdns = NULL;
dmuci_get_value_by_section_list(s, "dns", &dns_list);
if (dns_list != NULL) {
uci_foreach_element(dns_list, e) {
if (is_dns_server_in_dmmap(e->name, section_name(s)))
continue;
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &sdns);
dmuci_set_value_by_section(sdns, "ip", e->name);
dmuci_set_value_by_section(sdns, "interface", section_name(s));
dmuci_set_value_by_section(sdns, "enable", "1");
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &dns_s);
dmuci_set_value_by_section(dns_s, "ip", e->name);
dmuci_set_value_by_section(dns_s, "interface", section_name(s));
dmuci_set_value_by_section(dns_s, "enable", "1");
}
}
dmuci_get_value_by_section_string(s, "peerdns", &str);
if (str[0] == '0')
dmuci_get_value_by_section_string(s, "peerdns", &peerdns);
if (peerdns[0] == '0')
continue;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &jobj);
char *if_name = section_name(s);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &jobj);
if (!jobj) break;
dmjson_foreach_value_in_array(jobj, arrobj, ipdns, j, 1, "dns-server") {
if (ipdns[0] == '\0' || is_dns_server_in_dmmap(ipdns, section_name(s)))
continue;
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &sdns);
dmuci_set_value_by_section(sdns, "ip", ipdns);
dmuci_set_value_by_section(sdns, "interface", section_name(s));
dmuci_set_value_by_section(sdns, "enable", "1");
dmuci_set_value_by_section(sdns, "peerdns", "1");
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &dns_s);
dmuci_set_value_by_section(dns_s, "ip", ipdns);
dmuci_set_value_by_section(dns_s, "interface", section_name(s));
dmuci_set_value_by_section(dns_s, "enable", "1");
dmuci_set_value_by_section(dns_s, "peerdns", "1");
}
}
return 0;
@ -144,12 +168,10 @@ static int add_dns_server(char *refparam, struct dmctx *ctx, void *data, char **
{
struct uci_section *s = NULL;
dmuci_add_list_value("network", "lan", "dns", "0.0.0.0");
dmuci_add_section_bbfdm("dmmap_dns", "dns_server", &s);
dmuci_set_value_by_section(s, "enable", "0");
dmuci_set_value_by_section(s, "ip", "0.0.0.0");
dmuci_set_value_by_section(s, "interface", "lan");
dmuci_set_value_by_section(s, "enable", "1");
dmuci_set_value_by_section(s, "added_by_controller", "1");
dmuci_set_value_by_section(s, "dns_server_instance", *instance);
return 0;
}
@ -250,12 +272,19 @@ static int get_server_dns_server(char *refparam, struct dmctx *ctx, void *data,
static int get_dns_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker;
char *linker = NULL;
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &linker);
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
if (*value == NULL)
*value = "";
if (!(*value) || (*value)[0] == 0) {
char *device = NULL;
dmuci_get_option_value_string("network", linker, "device", &device);
if (DM_STRLEN(device)) {
char *sec_name = DM_STRCHR(device, '@');
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", sec_name ? sec_name + 1 : "", value);
}
}
return 0;
}
@ -266,7 +295,7 @@ static int get_dns_type(char *refparam, struct dmctx *ctx, void *data, char *ins
dmuci_get_value_by_section_string((struct uci_section *)data, "peerdns", &v);
if (*v == '1') {
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &v);
if (strchr(v, ':') == NULL)
if (DM_STRCHR(v, ':') == NULL)
*value = "DHCPv4";
else
*value = "DHCPv6";
@ -336,8 +365,6 @@ static int get_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx,
{
char *linker = get_diagnostics_option("nslookup", "interface");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
@ -429,30 +456,35 @@ static int set_client_enable(char *refparam, struct dmctx *ctx, void *data, char
static int set_dns_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *str, *ip, *interface;
bool b, ob;
char *interface = NULL;
char *peerdns = NULL;
char *ip = NULL;
bool b;
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
// If peerdns = '1' then it is a dynamic dns and not allowed to disable it
dmuci_get_value_by_section_string((struct uci_section *)data, "peerdns", &peerdns);
if (peerdns && peerdns[0] == '1')
return FAULT_9008;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "enable", &str);
string_to_bool(value, &b);
string_to_bool(str, &ob);
if (ob == b)
return 0;
dmuci_get_value_by_section_string((struct uci_section *)data, "peerdns", &str);
if (str[0] == '1')
return 0;
dmuci_set_value_by_section((struct uci_section *)data, "enable", b ? "1" : "0");
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &interface);
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &ip);
if (b == 1)
dmuci_add_list_value("network", interface, "dns", ip);
else
dmuci_del_list_value("network", interface, "dns", ip);
if (DM_STRLEN(interface) && DM_STRLEN(ip)) {
if (b == true)
dmuci_add_list_value("network", interface, "dns", ip);
else
dmuci_del_list_value("network", interface, "dns", ip);
}
break;
}
return 0;
@ -474,45 +506,36 @@ static int set_server_alias(char *refparam, struct dmctx *ctx, void *data, char
static int set_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *str, *oip, *interface;
struct uci_list *v;
struct uci_element *e = NULL;
int count = 0;
char *dns[32] = {0};
struct uci_list *dns_list = NULL;
char *interface = NULL;
char *peerdns = NULL;
char *oip = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 45, NULL, IPAddress))
return FAULT_9007;
// If peerdns = '1' then it is a dynamic dns and not allowed to set this parameter
dmuci_get_value_by_section_string((struct uci_section *)data, "peerdns", &peerdns);
if (peerdns && peerdns[0] == '1')
return FAULT_9008;
break;
case VALUESET:
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &oip);
if (strcmp(oip, value) == 0)
if (DM_STRCMP(oip, value) == 0)
return 0;
dmuci_get_value_by_section_string((struct uci_section *)data, "peerdns", &str);
if (str[0] == '1')
return 0;
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &interface);
dmuci_get_option_value_list("network", interface, "dns", &v);
if (v) {
uci_foreach_element(v, e) {
if (strcmp(e->name, oip)==0)
dns[count] = dmstrdup(value);
else
dns[count] = dmstrdup(e->name);
count++;
}
}
dmuci_delete("network", interface, "dns", NULL);
dmuci_get_value_by_section_string((struct uci_section *)data, "enable", &str);
if (str[0] == '1') {
int i = 0;
for (i = 0; i < count; i++) {
dmuci_add_list_value("network", interface, "dns", dns[i] ? dns[i] : "");
dmfree(dns[i]);
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &interface);
if (DM_STRLEN(interface)) {
dmuci_get_option_value_list("network", interface, "dns", &dns_list);
if (value_exists_in_uci_list(dns_list, oip)) {
dmuci_del_list_value("network", interface, "dns", oip);
dmuci_add_list_value("network", interface, "dns", value);
}
}
dmuci_set_value_by_section((struct uci_section *)data, "ip", value);
break;
}
@ -521,30 +544,51 @@ static int set_dns_server(char *refparam, struct dmctx *ctx, void *data, char *i
static int set_dns_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *str, *interface, *ip, *linker = NULL;
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
struct uci_list *dns_list = NULL;
char *interface = NULL;
char *peerdns = NULL;
char *linker = NULL;
char *oip = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
// If peerdns = '1' then it is a dynamic dns and not allowed to set this parameter
dmuci_get_value_by_section_string((struct uci_section *)data, "peerdns", &peerdns);
if (peerdns && peerdns[0] == '1')
return FAULT_9008;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
if (linker == NULL || linker[0] == '\0')
return 0;
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &interface);
if (strcmp(interface, linker) == 0)
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &oip);
if (!linker || linker[0] == 0) {
dmuci_del_list_value("network", interface, "dns", oip);
dmuci_set_value_by_section((struct uci_section *)data, "interface", "");
return 0;
dmuci_get_value_by_section_string((struct uci_section *)data, "peerdns", &str);
if (str[0] == '1')
}
if (DM_STRCMP(interface, linker) == 0)
return 0;
dmuci_get_value_by_section_string((struct uci_section *)data, "ip", &ip);
dmuci_del_list_value("network", interface, "dns", ip);
dmuci_get_value_by_section_string((struct uci_section *)data, "enable", &str);
if (str[0] == '1')
dmuci_add_list_value("network", linker, "dns", ip);
dmuci_set_value_by_section((struct uci_section *)data, "interface", interface);
if (DM_STRLEN(interface)) {
dmuci_get_option_value_list("network", interface, "dns", &dns_list);
if (value_exists_in_uci_list(dns_list, oip)) {
dmuci_del_list_value("network", interface, "dns", oip);
dmuci_add_list_value("network", linker, "dns", oip);
}
}
dmuci_set_value_by_section((struct uci_section *)data, "interface", linker);
break;
}
return 0;
@ -589,7 +633,7 @@ static int set_nslookupdiagnostics_diagnostics_state(char *refparam, struct dmct
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value, "Requested") == 0) {
if (DM_LSTRCMP(value, "Requested") == 0) {
NSLOOKUP_STOP
set_diagnostics_option("nslookup", "DiagnosticState", value);
bbf_set_end_session_flag(ctx, BBF_END_SESSION_NSLOOKUP_DIAGNOSTIC);
@ -601,10 +645,16 @@ static int set_nslookupdiagnostics_diagnostics_state(char *refparam, struct dmct
static int set_nslookupdiagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
return 0;
case VALUESET:
NSLOOKUP_STOP
@ -778,114 +828,114 @@ static int operate_DNSDiagnostics_NSLookupDiagnostics(char *refparam, struct dmc
***********************************************************************************************************************************/
/* *** Device.DNS. *** */
DMOBJ tDNSObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Client", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDNSClientObj, tDNSClientParams, NULL, BBFDM_BOTH},
{"Relay", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDNSRelayObj, tDNSRelayParams, NULL, BBFDM_BOTH},
{"Diagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDNSDiagnosticsObj, tDNSDiagnosticsParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Client", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDNSClientObj, tDNSClientParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"Relay", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDNSRelayObj, tDNSRelayParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"Diagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDNSDiagnosticsObj, tDNSDiagnosticsParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{0}
};
DMLEAF tDNSParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"SupportedRecordTypes", &DMREAD, DMT_STRING, get_dns_supported_record_types, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"SupportedRecordTypes", &DMREAD, DMT_STRING, get_dns_supported_record_types, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.DNS.Client. *** */
DMOBJ tDNSClientObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Server", &DMWRITE, add_dns_server, delete_dns_server, NULL, browseDNSServerInst, NULL, NULL, NULL, tDNSClientServerParams, NULL, BBFDM_BOTH, LIST_KEY{"DNSServer", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Server", &DMWRITE, add_dns_server, delete_dns_server, NULL, browseDNSServerInst, NULL, NULL, NULL, tDNSClientServerParams, NULL, BBFDM_BOTH, LIST_KEY{"DNSServer", "Alias", NULL}, "2.0"},
{0}
};
DMLEAF tDNSClientParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_client_enable, set_client_enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_client_status, NULL, BBFDM_BOTH},
{"ServerNumberOfEntries", &DMREAD, DMT_UNINT, get_client_server_number_of_entries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_client_enable, set_client_enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_client_status, NULL, BBFDM_BOTH, "2.0"},
{"ServerNumberOfEntries", &DMREAD, DMT_UNINT, get_client_server_number_of_entries, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DNS.Client.Server.{i}. *** */
DMLEAF tDNSClientServerParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_server_enable, set_dns_enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_server_status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_server_alias, set_server_alias, BBFDM_BOTH},
{"DNSServer", &DMWRITE, DMT_STRING, get_server_dns_server, set_dns_server, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_dns_interface, set_dns_interface, BBFDM_BOTH},
{"Type", &DMREAD, DMT_STRING, get_dns_type, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_server_enable, set_dns_enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_server_status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_server_alias, set_server_alias, BBFDM_BOTH, "2.0"},
{"DNSServer", &DMWRITE, DMT_STRING, get_server_dns_server, set_dns_server, BBFDM_BOTH, "2.0"},
{"Interface", &DMWRITE, DMT_STRING, get_dns_interface, set_dns_interface, BBFDM_BOTH, "2.0"},
{"Type", &DMREAD, DMT_STRING, get_dns_type, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DNS.Relay. *** */
DMOBJ tDNSRelayObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Forwarding", &DMWRITE, add_dns_server, delete_dns_server, NULL, browseDNSServerInst, NULL, NULL, NULL, tDNSRelayForwardingParams, NULL, BBFDM_BOTH, LIST_KEY{"DNSServer", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Forwarding", &DMWRITE, add_dns_server, delete_dns_server, NULL, browseDNSServerInst, NULL, NULL, NULL, tDNSRelayForwardingParams, NULL, BBFDM_BOTH, LIST_KEY{"DNSServer", "Alias", NULL}, "2.0"},
{0}
};
DMLEAF tDNSRelayParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_relay_enable, set_relay_enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_relay_status, NULL, BBFDM_BOTH},
{"ForwardNumberOfEntries", &DMREAD, DMT_UNINT, get_relay_forward_number_of_entries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_relay_enable, set_relay_enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_relay_status, NULL, BBFDM_BOTH, "2.0"},
{"ForwardNumberOfEntries", &DMREAD, DMT_UNINT, get_relay_forward_number_of_entries, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DNS.Relay.Forwarding.{i}. *** */
DMLEAF tDNSRelayForwardingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_forwarding_enable, set_dns_enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_forwarding_status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_forwarding_alias, set_forwarding_alias, BBFDM_BOTH},
{"DNSServer", &DMWRITE, DMT_STRING, get_forwarding_dns_server, set_dns_server, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_dns_interface, set_dns_interface, BBFDM_BOTH},
{"Type", &DMREAD, DMT_STRING, get_dns_type, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_forwarding_enable, set_dns_enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_forwarding_status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_forwarding_alias, set_forwarding_alias, BBFDM_BOTH, "2.0"},
{"DNSServer", &DMWRITE, DMT_STRING, get_forwarding_dns_server, set_dns_server, BBFDM_BOTH, "2.0"},
{"Interface", &DMWRITE, DMT_STRING, get_dns_interface, set_dns_interface, BBFDM_BOTH, "2.0"},
{"Type", &DMREAD, DMT_STRING, get_dns_type, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DNS.Diagnostics. *** */
DMOBJ tDNSDiagnosticsObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"NSLookupDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDNSDiagnosticsNSLookupDiagnosticsObj, tDNSDiagnosticsNSLookupDiagnosticsParams, NULL, BBFDM_CWMP},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"NSLookupDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDNSDiagnosticsNSLookupDiagnosticsObj, tDNSDiagnosticsNSLookupDiagnosticsParams, NULL, BBFDM_CWMP, NULL, "2.0"},
{0}
};
DMLEAF tDNSDiagnosticsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"NSLookupDiagnostics()", &DMASYNC, DMT_COMMAND, get_operate_args_DNSDiagnostics_NSLookupDiagnostics, operate_DNSDiagnostics_NSLookupDiagnostics, BBFDM_USP},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version, version*/
{"NSLookupDiagnostics()", &DMASYNC, DMT_COMMAND, get_operate_args_DNSDiagnostics_NSLookupDiagnostics, operate_DNSDiagnostics_NSLookupDiagnostics, BBFDM_USP, "2.12"},
{0}
};
/* *** Device.DNS.Diagnostics.NSLookupDiagnostics. *** */
DMOBJ tDNSDiagnosticsNSLookupDiagnosticsObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Result", &DMREAD, NULL, NULL, NULL, browseResultInst, NULL, NULL, NULL, tDNSDiagnosticsNSLookupDiagnosticsResultParams, NULL, BBFDM_CWMP},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Result", &DMREAD, NULL, NULL, NULL, browseResultInst, NULL, NULL, NULL, tDNSDiagnosticsNSLookupDiagnosticsResultParams, NULL, BBFDM_CWMP, NULL, "2.0"},
{0}
};
DMLEAF tDNSDiagnosticsNSLookupDiagnosticsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"DiagnosticsState", &DMWRITE, DMT_STRING, get_nslookupdiagnostics_diagnostics_state, set_nslookupdiagnostics_diagnostics_state, BBFDM_CWMP},
{"Interface", &DMWRITE, DMT_STRING, get_nslookupdiagnostics_interface, set_nslookupdiagnostics_interface, BBFDM_CWMP},
{"HostName", &DMWRITE, DMT_STRING, get_nslookupdiagnostics_host_name, set_nslookupdiagnostics_host_name, BBFDM_CWMP},
{"DNSServer", &DMWRITE, DMT_STRING, get_nslookupdiagnostics_d_n_s_server, set_nslookupdiagnostics_d_n_s_server, BBFDM_CWMP},
{"Timeout", &DMWRITE, DMT_UNINT, get_nslookupdiagnostics_timeout, set_nslookupdiagnostics_timeout, BBFDM_CWMP},
{"NumberOfRepetitions", &DMWRITE, DMT_UNINT, get_nslookupdiagnostics_number_of_repetitions, set_nslookupdiagnostics_number_of_repetitions, BBFDM_CWMP},
{"SuccessCount", &DMREAD, DMT_UNINT, get_nslookupdiagnostics_success_count, NULL, BBFDM_CWMP},
{"ResultNumberOfEntries", &DMREAD, DMT_UNINT, get_nslookupdiagnostics_result_number_of_entries, NULL, BBFDM_CWMP},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"DiagnosticsState", &DMWRITE, DMT_STRING, get_nslookupdiagnostics_diagnostics_state, set_nslookupdiagnostics_diagnostics_state, BBFDM_CWMP, "2.0"},
{"Interface", &DMWRITE, DMT_STRING, get_nslookupdiagnostics_interface, set_nslookupdiagnostics_interface, BBFDM_CWMP, "2.0"},
{"HostName", &DMWRITE, DMT_STRING, get_nslookupdiagnostics_host_name, set_nslookupdiagnostics_host_name, BBFDM_CWMP, "2.0"},
{"DNSServer", &DMWRITE, DMT_STRING, get_nslookupdiagnostics_d_n_s_server, set_nslookupdiagnostics_d_n_s_server, BBFDM_CWMP, "2.0"},
{"Timeout", &DMWRITE, DMT_UNINT, get_nslookupdiagnostics_timeout, set_nslookupdiagnostics_timeout, BBFDM_CWMP, "2.0"},
{"NumberOfRepetitions", &DMWRITE, DMT_UNINT, get_nslookupdiagnostics_number_of_repetitions, set_nslookupdiagnostics_number_of_repetitions, BBFDM_CWMP, "2.0"},
{"SuccessCount", &DMREAD, DMT_UNINT, get_nslookupdiagnostics_success_count, NULL, BBFDM_CWMP, "2.0"},
{"ResultNumberOfEntries", &DMREAD, DMT_UNINT, get_nslookupdiagnostics_result_number_of_entries, NULL, BBFDM_CWMP, "2.0"},
{0}
};
/* *** Device.DNS.Diagnostics.NSLookupDiagnostics.Result.{i}. *** */
DMLEAF tDNSDiagnosticsNSLookupDiagnosticsResultParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Status", &DMREAD, DMT_STRING, get_result_status, NULL, BBFDM_CWMP},
{"AnswerType", &DMREAD, DMT_STRING, get_result_answer_type, NULL, BBFDM_CWMP},
{"HostNameReturned", &DMREAD, DMT_STRING, get_result_host_name_returned, NULL, BBFDM_CWMP},
{"IPAddresses", &DMREAD, DMT_STRING, get_result_i_p_addresses, NULL, BBFDM_CWMP},
{"DNSServerIP", &DMREAD, DMT_STRING, get_result_d_n_s_server_i_p, NULL, BBFDM_CWMP},
{"ResponseTime", &DMREAD, DMT_UNINT, get_result_response_time, NULL, BBFDM_CWMP},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Status", &DMREAD, DMT_STRING, get_result_status, NULL, BBFDM_CWMP, "2.0"},
{"AnswerType", &DMREAD, DMT_STRING, get_result_answer_type, NULL, BBFDM_CWMP, "2.0"},
{"HostNameReturned", &DMREAD, DMT_STRING, get_result_host_name_returned, NULL, BBFDM_CWMP, "2.0"},
{"IPAddresses", &DMREAD, DMT_STRING, get_result_i_p_addresses, NULL, BBFDM_CWMP, "2.0"},
{"DNSServerIP", &DMREAD, DMT_STRING, get_result_d_n_s_server_i_p, NULL, BBFDM_CWMP, "2.0"},
{"ResponseTime", &DMREAD, DMT_UNINT, get_result_response_time, NULL, BBFDM_CWMP, "2.0"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef _DNS_H
#define _DNS_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tDNSObj[];
extern DMLEAF tDNSParams[];

View file

@ -8,7 +8,6 @@
* Author: AMIN Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include "dmentry.h"
#include "dsl.h"
struct dsl_line_args
@ -72,7 +71,7 @@ static struct uci_section *update_create_dmmap_dsl_line(char *curr_id)
if (!s) {
char instance[16];
snprintf(instance, sizeof(instance), "%d", atoi(curr_id));
snprintf(instance, sizeof(instance), "%ld", DM_STRTOL(curr_id));
dmuci_add_section_bbfdm("dmmap", "dsl_line", &s);
dmuci_set_value_by_section_bbfdm(s, "id", curr_id);
dmuci_set_value_by_section_bbfdm(s, "dsl_line_instance", instance);
@ -90,7 +89,7 @@ static struct uci_section *update_create_dmmap_dsl_channel(char *curr_id)
if (!s) {
char instance[16];
snprintf(instance, sizeof(instance), "%d", atoi(curr_id));
snprintf(instance, sizeof(instance), "%ld", DM_STRTOL(curr_id));
dmuci_add_section_bbfdm("dmmap", "dsl_channel", &s);
dmuci_set_value_by_section_bbfdm(s, "id", curr_id);
dmuci_set_value_by_section_bbfdm(s, "dsl_channel_instance", instance);
@ -108,7 +107,7 @@ static int browseDSLLineInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
char *inst = NULL;
int entries = 0;
dmubus_call("dsl", "status", UBUS_ARGS{}, 0, &res);
dmubus_call("dsl", "status", UBUS_ARGS{0}, 0, &res);
while (res) {
line_obj = dmjson_select_obj_in_array_idx(res, entries, 1, "line");
if(line_obj) {
@ -136,7 +135,7 @@ static int browseDSLChannelInst(struct dmctx *dmctx, DMNODE *parent_node, void *
char *inst = NULL;
int entries_line = 0, entries_channel = 0;
dmubus_call("dsl", "status", UBUS_ARGS{}, 0, &res);
dmubus_call("dsl", "status", UBUS_ARGS{0}, 0, &res);
while (res) {
line_obj = dmjson_select_obj_in_array_idx(res, entries_line, 1, "line");
while (line_obj) {
@ -171,7 +170,7 @@ static char *get_dsl_value_without_argument(char *command1, char *id, char *comm
char command[16], *value = "0";
snprintf(command, sizeof(command), "%s.%s", command1, id);
dmubus_call(command, command2, UBUS_ARGS{}, 0, &res);
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
if (!res) return "";
value = dmjson_get_value(res, 1, key);
return value;
@ -183,7 +182,7 @@ static char *get_dsl_value_without_argument_and_with_two_key(char *command1, cha
char command[16], *value = "0";
snprintf(command, sizeof(command), "%s.%s", command1, id);
dmubus_call(command, command2, UBUS_ARGS{}, 0, &res);
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
if (!res) return "";
value = dmjson_get_value(res, 2, key1, key2);
return value;
@ -207,7 +206,7 @@ static char *get_dsl_value_array_without_argument(char *command1, char *id, char
char command[16], *value= "0";
snprintf(command, sizeof(command), "%s.%s", command1, id);
dmubus_call(command, command2, UBUS_ARGS{}, 0, &res);
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
if (!res) return "";
value = dmjson_get_value_array_all(res, ",", 1, key);
return value;
@ -217,17 +216,17 @@ int get_line_linkstatus(char *method, char *id, char **value)
{
char *link_status = get_dsl_value_without_argument(method, id, "status", "link_status");
if (strcmp(link_status, "up") == 0)
if (DM_LSTRCMP(link_status, "up") == 0)
*value = "Up";
else if (strcmp(link_status, "initializing") == 0)
else if (DM_LSTRCMP(link_status, "initializing") == 0)
*value = "Initializing";
else if (strcmp(link_status, "no_signal") == 0)
else if (DM_LSTRCMP(link_status, "no_signal") == 0)
*value = "NoSignal";
else if (strcmp(link_status, "disabled") == 0)
else if (DM_LSTRCMP(link_status, "disabled") == 0)
*value = "Disabled";
else if (strcmp(link_status, "establishing") == 0)
else if (DM_LSTRCMP(link_status, "establishing") == 0)
*value = "EstablishingLink";
else if (strcmp(link_status, "error") == 0)
else if (DM_LSTRCMP(link_status, "error") == 0)
*value = "Error";
else
*value = link_status;
@ -255,7 +254,7 @@ static int get_DSL_ChannelNumberOfEntries(char *refparam, struct dmctx *ctx, voi
static int get_DSLLine_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *status = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "status");
*value = (strcmp(status, "up") == 0) ? "1" : "0";
*value = (DM_LSTRCMP(status, "up") == 0) ? "1" : "0";
return 0;
}
@ -276,7 +275,7 @@ static int set_DSLLine_Enable(char *refparam, struct dmctx *ctx, void *data, cha
static int get_DSLLine_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *status = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "status");
*value = (strcmp(status, "up") == 0) ? "Up" : "Down";
*value = (DM_LSTRCMP(status, "up") == 0) ? "Up" : "Down";
return 0;
}
@ -351,55 +350,55 @@ static char *get_dsl_standard(char *str)
{
char *dsl_standard;
if(strcmp(str, "gdmt_annexa") == 0)
if(DM_LSTRCMP(str, "gdmt_annexa") == 0)
dsl_standard = "G.992.1_Annex_A";
else if(strcmp(str, "gdmt_annexb") == 0)
else if(DM_LSTRCMP(str, "gdmt_annexb") == 0)
dsl_standard = "G.992.1_Annex_B";
else if(strcmp(str, "gdmt_annexc") == 0)
else if(DM_LSTRCMP(str, "gdmt_annexc") == 0)
dsl_standard = "G.992.1_Annex_C";
else if(strcmp(str, "t1413") == 0)
else if(DM_LSTRCMP(str, "t1413") == 0)
dsl_standard = "T1.413";
else if(strcmp(str, "t1413_i2") == 0)
else if(DM_LSTRCMP(str, "t1413_i2") == 0)
dsl_standard = "T1.413i2";
else if(strcmp(str, "glite") == 0)
else if(DM_LSTRCMP(str, "glite") == 0)
dsl_standard = "G.992.2";
else if(strcmp(str, "etsi_101_388") == 0)
else if(DM_LSTRCMP(str, "etsi_101_388") == 0)
dsl_standard = "ETSI_101_388";
else if(strcmp(str, "adsl2_annexa") == 0)
else if(DM_LSTRCMP(str, "adsl2_annexa") == 0)
dsl_standard = "G.992.3_Annex_A";
else if(strcmp(str, "adsl2_annexb") == 0)
else if(DM_LSTRCMP(str, "adsl2_annexb") == 0)
dsl_standard = "G.992.3_Annex_B";
else if(strcmp(str, "adsl2_annexc") == 0)
else if(DM_LSTRCMP(str, "adsl2_annexc") == 0)
dsl_standard = "G.992.3_Annex_C";
else if(strcmp(str, "adsl2_annexi") == 0)
else if(DM_LSTRCMP(str, "adsl2_annexi") == 0)
dsl_standard = "G.992.3_Annex_I";
else if(strcmp(str, "adsl2_annexj") == 0)
else if(DM_LSTRCMP(str, "adsl2_annexj") == 0)
dsl_standard = "G.992.3_Annex_J";
else if(strcmp(str, "adsl2_annexl") == 0)
else if(DM_LSTRCMP(str, "adsl2_annexl") == 0)
dsl_standard = "G.992.3_Annex_L";
else if(strcmp(str, "adsl2_annexm") == 0)
else if(DM_LSTRCMP(str, "adsl2_annexm") == 0)
dsl_standard = "G.992.3_Annex_M";
else if(strcmp(str, "splitterless_adsl2") == 0)
else if(DM_LSTRCMP(str, "splitterless_adsl2") == 0)
dsl_standard = "G.992.4";
else if(strcmp(str, "adsl2p_annexa") == 0)
else if(DM_LSTRCMP(str, "adsl2p_annexa") == 0)
dsl_standard = "G.992.5_Annex_A";
else if(strcmp(str, "adsl2p_annexb") == 0)
else if(DM_LSTRCMP(str, "adsl2p_annexb") == 0)
dsl_standard = "G.992.5_Annex_B";
else if(strcmp(str, "adsl2p_annexc") == 0)
else if(DM_LSTRCMP(str, "adsl2p_annexc") == 0)
dsl_standard = "G.992.5_Annex_C";
else if(strcmp(str, "adsl2p_annexi") == 0)
else if(DM_LSTRCMP(str, "adsl2p_annexi") == 0)
dsl_standard = "G.992.5_Annex_I";
else if(strcmp(str, "adsl2p_annexj") == 0)
else if(DM_LSTRCMP(str, "adsl2p_annexj") == 0)
dsl_standard = "G.992.5_Annex_J";
else if(strcmp(str, "adsl2p_annexm") == 0)
else if(DM_LSTRCMP(str, "adsl2p_annexm") == 0)
dsl_standard = "G.992.5_Annex_M";
else if(strcmp(str, "vdsl") == 0)
else if(DM_LSTRCMP(str, "vdsl") == 0)
dsl_standard = "G.993.1";
else if(strcmp(str, "vdsl2_annexa") == 0)
else if(DM_LSTRCMP(str, "vdsl2_annexa") == 0)
dsl_standard = "G.993.2_Annex_A";
else if(strcmp(str, "vdsl2_annexb") == 0)
else if(DM_LSTRCMP(str, "vdsl2_annexb") == 0)
dsl_standard = "G.993.2_Annex_B";
else if(strcmp(str, "vdsl2_annexc") == 0)
else if(DM_LSTRCMP(str, "vdsl2_annexc") == 0)
dsl_standard = "G.993.2_Annex_C";
else
dsl_standard = str;
@ -489,17 +488,17 @@ static int get_DSLLine_XTSUsed(char *refparam, struct dmctx *ctx, void *data, ch
static int get_DSLLine_LineEncoding(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *line_encoding = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "line_encoding");
if(strcmp(line_encoding, "dmt") == 0)
if(DM_LSTRCMP(line_encoding, "dmt") == 0)
*value = "DMT";
else if(strcmp(line_encoding, "cap") == 0)
else if(DM_LSTRCMP(line_encoding, "cap") == 0)
*value = "CAP";
else if(strcmp(line_encoding, "2b1q") == 0)
else if(DM_LSTRCMP(line_encoding, "2b1q") == 0)
*value = "2B1Q";
else if(strcmp(line_encoding, "43bt") == 0)
else if(DM_LSTRCMP(line_encoding, "43bt") == 0)
*value = "43BT";
else if(strcmp(line_encoding, "pam") == 0)
else if(DM_LSTRCMP(line_encoding, "pam") == 0)
*value = "PAM";
else if(strcmp(line_encoding, "qam") == 0)
else if(DM_LSTRCMP(line_encoding, "qam") == 0)
*value = "QAM";
else
*value = line_encoding;
@ -517,7 +516,7 @@ static int get_DSLLine_AllowedProfiles(char *refparam, struct dmctx *ctx, void *
static int get_DSLLine_CurrentProfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *current_profile = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "current_profile");
*value = (current_profile && strcmp(current_profile, "unknown") == 0) ? "" : current_profile;
*value = (current_profile && DM_LSTRCMP(current_profile, "unknown") == 0) ? "" : current_profile;
return 0;
}
@ -525,15 +524,15 @@ static int get_DSLLine_CurrentProfile(char *refparam, struct dmctx *ctx, void *d
static int get_DSLLine_PowerManagementState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *power_mng_state = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "power_management_state");
if(strcmp(power_mng_state, "l0") == 0)
if(DM_LSTRCMP(power_mng_state, "l0") == 0)
*value = "L0";
else if(strcmp(power_mng_state, "l1") == 0)
else if(DM_LSTRCMP(power_mng_state, "l1") == 0)
*value = "L1";
else if(strcmp(power_mng_state, "l2") == 0)
else if(DM_LSTRCMP(power_mng_state, "l2") == 0)
*value = "L2";
else if(strcmp(power_mng_state, "l3") == 0)
else if(DM_LSTRCMP(power_mng_state, "l3") == 0)
*value = "L3";
else if(strcmp(power_mng_state, "l4") == 0)
else if(DM_LSTRCMP(power_mng_state, "l4") == 0)
*value = "L4";
else
*value = power_mng_state;
@ -716,9 +715,14 @@ static int get_DSLLine_XTURVendor(char *refparam, struct dmctx *ctx, void *data,
}
/*#Device.DSL.Line.{i}.XTURCountry!UBUS:dsl.line.1/status//xtur_country*/
/*#Device.DSL.Line.{i}.XTURCountry!UCI:dsl/oem-parameters,oem/country_code*/
static int get_DSLLine_XTURCountry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "xtur_country");
if ((*value)[0] == '0' || (*value)[0] == '\0')
*value = dmuci_get_option_value_fallback_def("dsl", "oem", "country_code", "0000");
return 0;
}
@ -929,7 +933,7 @@ static int get_DSLLineStatsQuarterHour_SeverelyErroredSecs(char *refparam, struc
static int get_DSLChannel_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *status = get_dsl_value_without_argument("dsl.channel", ((struct dsl_channel_args*)data)->id, "status", "status");
*value = (strcmp(status, "up") == 0) ? "1" : "0";
*value = (DM_LSTRCMP(status, "up") == 0) ? "1" : "0";
return 0;
}
@ -950,17 +954,17 @@ static int set_DSLChannel_Enable(char *refparam, struct dmctx *ctx, void *data,
static int get_DSLChannel_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *status = get_dsl_value_without_argument("dsl.channel", ((struct dsl_channel_args*)data)->id, "status", "status");
if (strcmp(status, "up") == 0)
if (DM_LSTRCMP(status, "up") == 0)
*value = "Up";
else if (strcmp(status, "down") == 0)
else if (DM_LSTRCMP(status, "down") == 0)
*value = "Down";
else if (strcmp(status, "dormant") == 0)
else if (DM_LSTRCMP(status, "dormant") == 0)
*value = "Dormant";
else if (strcmp(status, "not_present") == 0)
else if (DM_LSTRCMP(status, "not_present") == 0)
*value = "NotPresent";
else if (strcmp(status, "lower_layer_down") == 0)
else if (DM_LSTRCMP(status, "lower_layer_down") == 0)
*value = "LowerLayerDown";
else if (strcmp(status, "error") == 0)
else if (DM_LSTRCMP(status, "error") == 0)
*value = "Error";
else
*value = "Unknown";
@ -998,10 +1002,9 @@ static int get_DSLChannel_Name(char *refparam, struct dmctx *ctx, void *data, ch
static int get_DSLChannel_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char linker[8];
snprintf(linker, sizeof(linker), "line_%s", ((struct dsl_line_args *)data)->id);
adm_entry_get_linker_param(ctx, "Device.DSL.Line.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
adm_entry_get_linker_param(ctx, "Device.DSL.Line.", linker, value);
return 0;
}
@ -1009,13 +1012,13 @@ static char *get_dsl_link_encapsulation_standard(char *str)
{
char *dsl_link_encapsulation_standard = "";
if(strcmp(str, "adsl2_atm") == 0)
if(DM_LSTRCMP(str, "adsl2_atm") == 0)
dsl_link_encapsulation_standard = "G.992.3_Annex_K_ATM";
else if(strcmp(str, "adsl2_ptm") == 0)
else if(DM_LSTRCMP(str, "adsl2_ptm") == 0)
dsl_link_encapsulation_standard = "G.992.3_Annex_K_PTM";
else if(strcmp(str, "vdsl2_atm") == 0)
else if(DM_LSTRCMP(str, "vdsl2_atm") == 0)
dsl_link_encapsulation_standard = "G.993.2_Annex_K_ATM";
else if(strcmp(str, "vdsl2_ptm") == 0)
else if(DM_LSTRCMP(str, "vdsl2_ptm") == 0)
dsl_link_encapsulation_standard = "G.993.2_Annex_K_PTM";
else
dsl_link_encapsulation_standard = "G.994.1";
@ -1051,7 +1054,7 @@ static int get_DSLChannel_LinkEncapsulationSupported(char *refparam, struct dmct
static int get_DSLChannel_LinkEncapsulationUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *link_encapsulation_used = get_dsl_value_without_argument("dsl.channel", ((struct dsl_channel_args*)data)->id, "status", "link_encapsulation_used");
*value = (strcmp(link_encapsulation_used, "auto") != 0) ? get_dsl_link_encapsulation_standard(link_encapsulation_used) : "G.993.2_Annex_K_PTM";
*value = (DM_LSTRCMP(link_encapsulation_used, "auto") != 0) ? get_dsl_link_encapsulation_standard(link_encapsulation_used) : "G.993.2_Annex_K_PTM";
return 0;
}
@ -1451,266 +1454,266 @@ static int get_DSLChannelStatsQuarterHour_XTUCCRCErrors(char *refparam, struct d
***********************************************************************************************************************************/
/* *** Device.DSL. *** */
DMOBJ tDSLObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Line", &DMREAD, NULL, NULL, NULL, browseDSLLineInst, NULL, NULL, tDSLLineObj, tDSLLineParams, get_dsl_line_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
{"Channel", &DMREAD, NULL, NULL, NULL, browseDSLChannelInst, NULL, NULL, tDSLChannelObj, tDSLChannelParams, get_dsl_channel_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Line", &DMREAD, NULL, NULL, NULL, browseDSLLineInst, NULL, NULL, tDSLLineObj, tDSLLineParams, get_dsl_line_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.0"},
{"Channel", &DMREAD, NULL, NULL, NULL, browseDSLChannelInst, NULL, NULL, tDSLChannelObj, tDSLChannelParams, get_dsl_channel_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.0"},
{0}
};
DMLEAF tDSLParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"LineNumberOfEntries", &DMREAD, DMT_UNINT, get_DSL_LineNumberOfEntries, NULL, BBFDM_BOTH},
{"ChannelNumberOfEntries", &DMREAD, DMT_UNINT, get_DSL_ChannelNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"LineNumberOfEntries", &DMREAD, DMT_UNINT, get_DSL_LineNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
{"ChannelNumberOfEntries", &DMREAD, DMT_UNINT, get_DSL_ChannelNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Line.{i}. *** */
DMOBJ tDSLLineObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsObj, tDSLLineStatsParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsObj, tDSLLineStatsParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{0}
};
DMLEAF tDSLLineParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_DSLLine_Enable, set_DSLLine_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_DSLLine_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_DSLLine_Alias, set_DSLLine_Alias, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_DSLLine_Name, NULL, BBFDM_BOTH},
{"LowerLayers", &DMWRITE, DMT_STRING, get_DSLLine_LowerLayers, set_DSLLine_LowerLayers, BBFDM_BOTH},
{"Upstream", &DMREAD, DMT_BOOL, get_DSLLine_Upstream, NULL, BBFDM_BOTH},
{"FirmwareVersion", &DMREAD, DMT_STRING, get_DSLLine_FirmwareVersion, NULL, BBFDM_BOTH},
{"LinkStatus", &DMREAD, DMT_STRING, get_DSLLine_LinkStatus, NULL, BBFDM_BOTH},
{"StandardsSupported", &DMREAD, DMT_STRING, get_DSLLine_StandardsSupported, NULL, BBFDM_BOTH},
{"XTSE", &DMREAD, DMT_HEXBIN, get_DSLLine_XTSE, NULL, BBFDM_BOTH},
{"StandardUsed", &DMREAD, DMT_STRING, get_DSLLine_StandardUsed, NULL, BBFDM_BOTH},
{"XTSUsed", &DMREAD, DMT_HEXBIN, get_DSLLine_XTSUsed, NULL, BBFDM_BOTH},
{"LineEncoding", &DMREAD, DMT_STRING, get_DSLLine_LineEncoding, NULL, BBFDM_BOTH},
{"AllowedProfiles", &DMREAD, DMT_STRING, get_DSLLine_AllowedProfiles, NULL, BBFDM_BOTH},
{"CurrentProfile", &DMREAD, DMT_STRING, get_DSLLine_CurrentProfile, NULL, BBFDM_BOTH},
{"PowerManagementState", &DMREAD, DMT_STRING, get_DSLLine_PowerManagementState, NULL, BBFDM_BOTH},
{"SuccessFailureCause", &DMREAD, DMT_UNINT, get_DSLLine_SuccessFailureCause, NULL, BBFDM_BOTH},
{"UPBOKLERPb", &DMREAD, DMT_STRING, get_DSLLine_UPBOKLERPb, NULL, BBFDM_BOTH},
{"RXTHRSHds", &DMREAD, DMT_INT, get_DSLLine_RXTHRSHds, NULL, BBFDM_BOTH},
{"ACTRAMODEds", &DMREAD, DMT_UNINT, get_DSLLine_ACTRAMODEds, NULL, BBFDM_BOTH},
{"ACTRAMODEus", &DMREAD, DMT_UNINT, get_DSLLine_ACTRAMODEus, NULL, BBFDM_BOTH},
{"SNRMROCus", &DMREAD, DMT_UNINT, get_DSLLine_SNRMROCus, NULL, BBFDM_BOTH},
{"LastStateTransmittedDownstream", &DMREAD, DMT_UNINT, get_DSLLine_LastStateTransmittedDownstream, NULL, BBFDM_BOTH},
{"LastStateTransmittedUpstream", &DMREAD, DMT_UNINT, get_DSLLine_LastStateTransmittedUpstream, NULL, BBFDM_BOTH},
{"US0MASK", &DMREAD, DMT_UNINT, get_DSLLine_US0MASK, NULL, BBFDM_BOTH},
{"TRELLISds", &DMREAD, DMT_INT, get_DSLLine_TRELLISds, NULL, BBFDM_BOTH},
{"TRELLISus", &DMREAD, DMT_INT, get_DSLLine_TRELLISus, NULL, BBFDM_BOTH},
{"ACTSNRMODEds", &DMREAD, DMT_UNINT, get_DSLLine_ACTSNRMODEds, NULL, BBFDM_BOTH},
{"ACTSNRMODEus", &DMREAD, DMT_UNINT, get_DSLLine_ACTSNRMODEus, NULL, BBFDM_BOTH},
{"LineNumber", &DMREAD, DMT_INT, get_DSLLine_LineNumber, NULL, BBFDM_BOTH},
{"UpstreamMaxBitRate", &DMREAD, DMT_UNINT, get_DSLLine_UpstreamMaxBitRate, NULL, BBFDM_BOTH},
{"DownstreamMaxBitRate", &DMREAD, DMT_UNINT, get_DSLLine_DownstreamMaxBitRate, NULL, BBFDM_BOTH},
{"UpstreamNoiseMargin", &DMREAD, DMT_INT, get_DSLLine_UpstreamNoiseMargin, NULL, BBFDM_BOTH},
{"DownstreamNoiseMargin", &DMREAD, DMT_INT, get_DSLLine_DownstreamNoiseMargin, NULL, BBFDM_BOTH},
{"SNRMpbus", &DMREAD, DMT_STRING, get_DSLLine_SNRMpbus, NULL, BBFDM_BOTH},
{"SNRMpbds", &DMREAD, DMT_STRING, get_DSLLine_SNRMpbds, NULL, BBFDM_BOTH},
{"UpstreamAttenuation", &DMREAD, DMT_INT, get_DSLLine_UpstreamAttenuation, NULL, BBFDM_BOTH},
{"DownstreamAttenuation", &DMREAD, DMT_INT, get_DSLLine_DownstreamAttenuation, NULL, BBFDM_BOTH},
{"UpstreamPower", &DMREAD, DMT_INT, get_DSLLine_UpstreamPower, NULL, BBFDM_BOTH},
{"DownstreamPower", &DMREAD, DMT_INT, get_DSLLine_DownstreamPower, NULL, BBFDM_BOTH},
{"XTURVendor", &DMREAD, DMT_HEXBIN, get_DSLLine_XTURVendor, NULL, BBFDM_BOTH},
{"XTURCountry", &DMREAD, DMT_HEXBIN, get_DSLLine_XTURCountry, NULL, BBFDM_BOTH},
{"XTURANSIStd", &DMREAD, DMT_UNINT, get_DSLLine_XTURANSIStd, NULL, BBFDM_BOTH},
{"XTURANSIRev", &DMREAD, DMT_UNINT, get_DSLLine_XTURANSIRev, NULL, BBFDM_BOTH},
{"XTUCVendor", &DMREAD, DMT_HEXBIN, get_DSLLine_XTUCVendor, NULL, BBFDM_BOTH},
{"XTUCCountry", &DMREAD, DMT_HEXBIN, get_DSLLine_XTUCCountry, NULL, BBFDM_BOTH},
{"XTUCANSIStd", &DMREAD, DMT_UNINT, get_DSLLine_XTUCANSIStd, NULL, BBFDM_BOTH},
{"XTUCANSIRev", &DMREAD, DMT_UNINT, get_DSLLine_XTUCANSIRev, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_DSLLine_Enable, set_DSLLine_Enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_DSLLine_Status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_DSLLine_Alias, set_DSLLine_Alias, BBFDM_BOTH, "2.0"},
{"Name", &DMREAD, DMT_STRING, get_DSLLine_Name, NULL, BBFDM_BOTH, "2.0"},
{"LowerLayers", &DMWRITE, DMT_STRING, get_DSLLine_LowerLayers, set_DSLLine_LowerLayers, BBFDM_BOTH, "2.0"},
{"Upstream", &DMREAD, DMT_BOOL, get_DSLLine_Upstream, NULL, BBFDM_BOTH, "2.0"},
{"FirmwareVersion", &DMREAD, DMT_STRING, get_DSLLine_FirmwareVersion, NULL, BBFDM_BOTH, "2.0"},
{"LinkStatus", &DMREAD, DMT_STRING, get_DSLLine_LinkStatus, NULL, BBFDM_BOTH, "2.0"},
{"StandardsSupported", &DMREAD, DMT_STRING, get_DSLLine_StandardsSupported, NULL, BBFDM_BOTH, "2.0"},
{"XTSE", &DMREAD, DMT_HEXBIN, get_DSLLine_XTSE, NULL, BBFDM_BOTH, "2.8"},
{"StandardUsed", &DMREAD, DMT_STRING, get_DSLLine_StandardUsed, NULL, BBFDM_BOTH, "2.0"},
{"XTSUsed", &DMREAD, DMT_HEXBIN, get_DSLLine_XTSUsed, NULL, BBFDM_BOTH, "2.8"},
{"LineEncoding", &DMREAD, DMT_STRING, get_DSLLine_LineEncoding, NULL, BBFDM_BOTH, "2.0"},
{"AllowedProfiles", &DMREAD, DMT_STRING, get_DSLLine_AllowedProfiles, NULL, BBFDM_BOTH, "2.0"},
{"CurrentProfile", &DMREAD, DMT_STRING, get_DSLLine_CurrentProfile, NULL, BBFDM_BOTH, "2.0"},
{"PowerManagementState", &DMREAD, DMT_STRING, get_DSLLine_PowerManagementState, NULL, BBFDM_BOTH, "2.0"},
{"SuccessFailureCause", &DMREAD, DMT_UNINT, get_DSLLine_SuccessFailureCause, NULL, BBFDM_BOTH, "2.0"},
{"UPBOKLERPb", &DMREAD, DMT_STRING, get_DSLLine_UPBOKLERPb, NULL, BBFDM_BOTH, "2.8"},
{"RXTHRSHds", &DMREAD, DMT_INT, get_DSLLine_RXTHRSHds, NULL, BBFDM_BOTH, "2.8"},
{"ACTRAMODEds", &DMREAD, DMT_UNINT, get_DSLLine_ACTRAMODEds, NULL, BBFDM_BOTH, "2.8"},
{"ACTRAMODEus", &DMREAD, DMT_UNINT, get_DSLLine_ACTRAMODEus, NULL, BBFDM_BOTH, "2.8"},
{"SNRMROCus", &DMREAD, DMT_UNINT, get_DSLLine_SNRMROCus, NULL, BBFDM_BOTH, "2.8"},
{"LastStateTransmittedDownstream", &DMREAD, DMT_UNINT, get_DSLLine_LastStateTransmittedDownstream, NULL, BBFDM_BOTH, "2.0"},
{"LastStateTransmittedUpstream", &DMREAD, DMT_UNINT, get_DSLLine_LastStateTransmittedUpstream, NULL, BBFDM_BOTH, "2.0"},
{"US0MASK", &DMREAD, DMT_UNINT, get_DSLLine_US0MASK, NULL, BBFDM_BOTH, "2.0"},
{"TRELLISds", &DMREAD, DMT_INT, get_DSLLine_TRELLISds, NULL, BBFDM_BOTH, "2.0"},
{"TRELLISus", &DMREAD, DMT_INT, get_DSLLine_TRELLISus, NULL, BBFDM_BOTH, "2.0"},
{"ACTSNRMODEds", &DMREAD, DMT_UNINT, get_DSLLine_ACTSNRMODEds, NULL, BBFDM_BOTH, "2.0"},
{"ACTSNRMODEus", &DMREAD, DMT_UNINT, get_DSLLine_ACTSNRMODEus, NULL, BBFDM_BOTH, "2.0"},
{"LineNumber", &DMREAD, DMT_INT, get_DSLLine_LineNumber, NULL, BBFDM_BOTH, "2.0"},
{"UpstreamMaxBitRate", &DMREAD, DMT_UNINT, get_DSLLine_UpstreamMaxBitRate, NULL, BBFDM_BOTH, "2.0"},
{"DownstreamMaxBitRate", &DMREAD, DMT_UNINT, get_DSLLine_DownstreamMaxBitRate, NULL, BBFDM_BOTH, "2.0"},
{"UpstreamNoiseMargin", &DMREAD, DMT_INT, get_DSLLine_UpstreamNoiseMargin, NULL, BBFDM_BOTH, "2.0"},
{"DownstreamNoiseMargin", &DMREAD, DMT_INT, get_DSLLine_DownstreamNoiseMargin, NULL, BBFDM_BOTH, "2.0"},
{"SNRMpbus", &DMREAD, DMT_STRING, get_DSLLine_SNRMpbus, NULL, BBFDM_BOTH, "2.0"},
{"SNRMpbds", &DMREAD, DMT_STRING, get_DSLLine_SNRMpbds, NULL, BBFDM_BOTH, "2.0"},
{"UpstreamAttenuation", &DMREAD, DMT_INT, get_DSLLine_UpstreamAttenuation, NULL, BBFDM_BOTH, "2.0"},
{"DownstreamAttenuation", &DMREAD, DMT_INT, get_DSLLine_DownstreamAttenuation, NULL, BBFDM_BOTH, "2.0"},
{"UpstreamPower", &DMREAD, DMT_INT, get_DSLLine_UpstreamPower, NULL, BBFDM_BOTH, "2.0"},
{"DownstreamPower", &DMREAD, DMT_INT, get_DSLLine_DownstreamPower, NULL, BBFDM_BOTH, "2.0"},
{"XTURVendor", &DMREAD, DMT_HEXBIN, get_DSLLine_XTURVendor, NULL, BBFDM_BOTH, "2.0"},
{"XTURCountry", &DMREAD, DMT_HEXBIN, get_DSLLine_XTURCountry, NULL, BBFDM_BOTH, "2.0"},
{"XTURANSIStd", &DMREAD, DMT_UNINT, get_DSLLine_XTURANSIStd, NULL, BBFDM_BOTH, "2.0"},
{"XTURANSIRev", &DMREAD, DMT_UNINT, get_DSLLine_XTURANSIRev, NULL, BBFDM_BOTH, "2.0"},
{"XTUCVendor", &DMREAD, DMT_HEXBIN, get_DSLLine_XTUCVendor, NULL, BBFDM_BOTH, "2.0"},
{"XTUCCountry", &DMREAD, DMT_HEXBIN, get_DSLLine_XTUCCountry, NULL, BBFDM_BOTH, "2.0"},
{"XTUCANSIStd", &DMREAD, DMT_UNINT, get_DSLLine_XTUCANSIStd, NULL, BBFDM_BOTH, "2.0"},
{"XTUCANSIRev", &DMREAD, DMT_UNINT, get_DSLLine_XTUCANSIRev, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Line.{i}.Stats. *** */
DMOBJ tDSLLineStatsObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Total", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsTotalParams, NULL, BBFDM_BOTH},
{"Showtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsShowtimeParams, NULL, BBFDM_BOTH},
{"LastShowtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsLastShowtimeParams, NULL, BBFDM_BOTH},
{"CurrentDay", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsCurrentDayParams, NULL, BBFDM_BOTH},
{"QuarterHour", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsQuarterHourParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Total", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsTotalParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"Showtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsShowtimeParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"LastShowtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsLastShowtimeParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"CurrentDay", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsCurrentDayParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"QuarterHour", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLLineStatsQuarterHourParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{0}
};
DMLEAF tDSLLineStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNLONG, get_DSLLineStats_BytesSent, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_DSLLineStats_BytesReceived, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_DSLLineStats_PacketsSent, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_DSLLineStats_PacketsReceived, NULL, BBFDM_BOTH},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_DSLLineStats_ErrorsSent, NULL, BBFDM_BOTH},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_DSLLineStats_ErrorsReceived, NULL, BBFDM_BOTH},
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_DSLLineStats_DiscardPacketsSent, NULL, BBFDM_BOTH},
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_DSLLineStats_DiscardPacketsReceived, NULL, BBFDM_BOTH},
{"TotalStart", &DMREAD, DMT_UNINT, get_DSLLineStats_TotalStart, NULL, BBFDM_BOTH},
{"ShowtimeStart", &DMREAD, DMT_UNINT, get_DSLLineStats_ShowtimeStart, NULL, BBFDM_BOTH},
{"LastShowtimeStart", &DMREAD, DMT_UNINT, get_DSLLineStats_LastShowtimeStart, NULL, BBFDM_BOTH},
{"CurrentDayStart", &DMREAD, DMT_UNINT, get_DSLLineStats_CurrentDayStart, NULL, BBFDM_BOTH},
{"QuarterHourStart", &DMREAD, DMT_UNINT, get_DSLLineStats_QuarterHourStart, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"BytesSent", &DMREAD, DMT_UNLONG, get_DSLLineStats_BytesSent, NULL, BBFDM_BOTH, "2.0"},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_DSLLineStats_BytesReceived, NULL, BBFDM_BOTH, "2.0"},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_DSLLineStats_PacketsSent, NULL, BBFDM_BOTH, "2.0"},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_DSLLineStats_PacketsReceived, NULL, BBFDM_BOTH, "2.0"},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_DSLLineStats_ErrorsSent, NULL, BBFDM_BOTH, "2.0"},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_DSLLineStats_ErrorsReceived, NULL, BBFDM_BOTH, "2.0"},
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_DSLLineStats_DiscardPacketsSent, NULL, BBFDM_BOTH, "2.0"},
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_DSLLineStats_DiscardPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
{"TotalStart", &DMREAD, DMT_UNINT, get_DSLLineStats_TotalStart, NULL, BBFDM_BOTH, "2.0"},
{"ShowtimeStart", &DMREAD, DMT_UNINT, get_DSLLineStats_ShowtimeStart, NULL, BBFDM_BOTH, "2.0"},
{"LastShowtimeStart", &DMREAD, DMT_UNINT, get_DSLLineStats_LastShowtimeStart, NULL, BBFDM_BOTH, "2.0"},
{"CurrentDayStart", &DMREAD, DMT_UNINT, get_DSLLineStats_CurrentDayStart, NULL, BBFDM_BOTH, "2.0"},
{"QuarterHourStart", &DMREAD, DMT_UNINT, get_DSLLineStats_QuarterHourStart, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Line.{i}.Stats.Total. *** */
DMLEAF tDSLLineStatsTotalParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsTotal_ErroredSecs, NULL, BBFDM_BOTH},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsTotal_SeverelyErroredSecs, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsTotal_ErroredSecs, NULL, BBFDM_BOTH, "2.0"},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsTotal_SeverelyErroredSecs, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Line.{i}.Stats.Showtime. *** */
DMLEAF tDSLLineStatsShowtimeParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsShowtime_ErroredSecs, NULL, BBFDM_BOTH},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsShowtime_SeverelyErroredSecs, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsShowtime_ErroredSecs, NULL, BBFDM_BOTH, "2.0"},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsShowtime_SeverelyErroredSecs, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Line.{i}.Stats.LastShowtime. *** */
DMLEAF tDSLLineStatsLastShowtimeParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsLastShowtime_ErroredSecs, NULL, BBFDM_BOTH},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsLastShowtime_SeverelyErroredSecs, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsLastShowtime_ErroredSecs, NULL, BBFDM_BOTH, "2.0"},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsLastShowtime_SeverelyErroredSecs, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Line.{i}.Stats.CurrentDay. *** */
DMLEAF tDSLLineStatsCurrentDayParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsCurrentDay_ErroredSecs, NULL, BBFDM_BOTH},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsCurrentDay_SeverelyErroredSecs, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsCurrentDay_ErroredSecs, NULL, BBFDM_BOTH, "2.0"},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsCurrentDay_SeverelyErroredSecs, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Line.{i}.Stats.QuarterHour. *** */
DMLEAF tDSLLineStatsQuarterHourParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsQuarterHour_ErroredSecs, NULL, BBFDM_BOTH},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsQuarterHour_SeverelyErroredSecs, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsQuarterHour_ErroredSecs, NULL, BBFDM_BOTH, "2.0"},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_DSLLineStatsQuarterHour_SeverelyErroredSecs, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Channel.{i}. *** */
DMOBJ tDSLChannelObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsObj, tDSLChannelStatsParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsObj, tDSLChannelStatsParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{0}
};
DMLEAF tDSLChannelParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_DSLChannel_Enable, set_DSLChannel_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_DSLChannel_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_DSLChannel_Alias, set_DSLChannel_Alias, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_DSLChannel_Name, NULL, BBFDM_BOTH},
{"LowerLayers", &DMREAD, DMT_STRING, get_DSLChannel_LowerLayers, NULL, BBFDM_BOTH},
{"LinkEncapsulationSupported", &DMREAD, DMT_STRING, get_DSLChannel_LinkEncapsulationSupported, NULL, BBFDM_BOTH},
{"LinkEncapsulationUsed", &DMREAD, DMT_STRING, get_DSLChannel_LinkEncapsulationUsed, NULL, BBFDM_BOTH},
{"LPATH", &DMREAD, DMT_UNINT, get_DSLChannel_LPATH, NULL, BBFDM_BOTH},
{"INTLVDEPTH", &DMREAD, DMT_UNINT, get_DSLChannel_INTLVDEPTH, NULL, BBFDM_BOTH},
{"INTLVBLOCK", &DMREAD, DMT_INT, get_DSLChannel_INTLVBLOCK, NULL, BBFDM_BOTH},
{"ActualInterleavingDelay", &DMREAD, DMT_UNINT, get_DSLChannel_ActualInterleavingDelay, NULL, BBFDM_BOTH},
{"ACTINP", &DMREAD, DMT_INT, get_DSLChannel_ACTINP, NULL, BBFDM_BOTH},
{"INPREPORT", &DMREAD, DMT_BOOL, get_DSLChannel_INPREPORT, NULL, BBFDM_BOTH},
{"NFEC", &DMREAD, DMT_INT, get_DSLChannel_NFEC, NULL, BBFDM_BOTH},
{"RFEC", &DMREAD, DMT_INT, get_DSLChannel_RFEC, NULL, BBFDM_BOTH},
{"LSYMB", &DMREAD, DMT_INT, get_DSLChannel_LSYMB, NULL, BBFDM_BOTH},
{"UpstreamCurrRate", &DMREAD, DMT_UNINT, get_DSLChannel_UpstreamCurrRate, NULL, BBFDM_BOTH},
{"DownstreamCurrRate", &DMREAD, DMT_UNINT, get_DSLChannel_DownstreamCurrRate, NULL, BBFDM_BOTH},
{"ACTNDR", &DMREAD, DMT_UNINT, get_DSLChannel_ACTNDR, NULL, BBFDM_BOTH},
{"ACTINPREIN", &DMREAD, DMT_UNINT, get_DSLChannel_ACTINPREIN, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_DSLChannel_Enable, set_DSLChannel_Enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_DSLChannel_Status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_DSLChannel_Alias, set_DSLChannel_Alias, BBFDM_BOTH, "2.0"},
{"Name", &DMREAD, DMT_STRING, get_DSLChannel_Name, NULL, BBFDM_BOTH, "2.0"},
{"LowerLayers", &DMREAD, DMT_STRING, get_DSLChannel_LowerLayers, NULL, BBFDM_BOTH, "2.0"},
{"LinkEncapsulationSupported", &DMREAD, DMT_STRING, get_DSLChannel_LinkEncapsulationSupported, NULL, BBFDM_BOTH, "2.0"},
{"LinkEncapsulationUsed", &DMREAD, DMT_STRING, get_DSLChannel_LinkEncapsulationUsed, NULL, BBFDM_BOTH, "2.0"},
{"LPATH", &DMREAD, DMT_UNINT, get_DSLChannel_LPATH, NULL, BBFDM_BOTH, "2.0"},
{"INTLVDEPTH", &DMREAD, DMT_UNINT, get_DSLChannel_INTLVDEPTH, NULL, BBFDM_BOTH, "2.0"},
{"INTLVBLOCK", &DMREAD, DMT_INT, get_DSLChannel_INTLVBLOCK, NULL, BBFDM_BOTH, "2.0"},
{"ActualInterleavingDelay", &DMREAD, DMT_UNINT, get_DSLChannel_ActualInterleavingDelay, NULL, BBFDM_BOTH, "2.0"},
{"ACTINP", &DMREAD, DMT_INT, get_DSLChannel_ACTINP, NULL, BBFDM_BOTH, "2.0"},
{"INPREPORT", &DMREAD, DMT_BOOL, get_DSLChannel_INPREPORT, NULL, BBFDM_BOTH, "2.0"},
{"NFEC", &DMREAD, DMT_INT, get_DSLChannel_NFEC, NULL, BBFDM_BOTH, "2.0"},
{"RFEC", &DMREAD, DMT_INT, get_DSLChannel_RFEC, NULL, BBFDM_BOTH, "2.0"},
{"LSYMB", &DMREAD, DMT_INT, get_DSLChannel_LSYMB, NULL, BBFDM_BOTH, "2.0"},
{"UpstreamCurrRate", &DMREAD, DMT_UNINT, get_DSLChannel_UpstreamCurrRate, NULL, BBFDM_BOTH, "2.0"},
{"DownstreamCurrRate", &DMREAD, DMT_UNINT, get_DSLChannel_DownstreamCurrRate, NULL, BBFDM_BOTH, "2.0"},
{"ACTNDR", &DMREAD, DMT_UNINT, get_DSLChannel_ACTNDR, NULL, BBFDM_BOTH, "2.8"},
{"ACTINPREIN", &DMREAD, DMT_UNINT, get_DSLChannel_ACTINPREIN, NULL, BBFDM_BOTH, "2.8"},
{0}
};
/* *** Device.DSL.Channel.{i}.Stats. *** */
DMOBJ tDSLChannelStatsObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Total", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsTotalParams, NULL, BBFDM_BOTH},
{"Showtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsShowtimeParams, NULL, BBFDM_BOTH},
{"LastShowtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsLastShowtimeParams, NULL, BBFDM_BOTH},
{"CurrentDay", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsCurrentDayParams, NULL, BBFDM_BOTH},
{"QuarterHour", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsQuarterHourParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Total", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsTotalParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"Showtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsShowtimeParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"LastShowtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsLastShowtimeParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"CurrentDay", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsCurrentDayParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{"QuarterHour", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tDSLChannelStatsQuarterHourParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{0}
};
DMLEAF tDSLChannelStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNLONG, get_DSLChannelStats_BytesSent, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_DSLChannelStats_BytesReceived, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_DSLChannelStats_PacketsSent, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_DSLChannelStats_PacketsReceived, NULL, BBFDM_BOTH},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_DSLChannelStats_ErrorsSent, NULL, BBFDM_BOTH},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_DSLChannelStats_ErrorsReceived, NULL, BBFDM_BOTH},
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_DSLChannelStats_DiscardPacketsSent, NULL, BBFDM_BOTH},
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_DSLChannelStats_DiscardPacketsReceived, NULL, BBFDM_BOTH},
{"TotalStart", &DMREAD, DMT_UNINT, get_DSLChannelStats_TotalStart, NULL, BBFDM_BOTH},
{"ShowtimeStart", &DMREAD, DMT_UNINT, get_DSLChannelStats_ShowtimeStart, NULL, BBFDM_BOTH},
{"LastShowtimeStart", &DMREAD, DMT_UNINT, get_DSLChannelStats_LastShowtimeStart, NULL, BBFDM_BOTH},
{"CurrentDayStart", &DMREAD, DMT_UNINT, get_DSLChannelStats_CurrentDayStart, NULL, BBFDM_BOTH},
{"QuarterHourStart", &DMREAD, DMT_UNINT, get_DSLChannelStats_QuarterHourStart, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"BytesSent", &DMREAD, DMT_UNLONG, get_DSLChannelStats_BytesSent, NULL, BBFDM_BOTH, "2.0"},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_DSLChannelStats_BytesReceived, NULL, BBFDM_BOTH, "2.0"},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_DSLChannelStats_PacketsSent, NULL, BBFDM_BOTH, "2.0"},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_DSLChannelStats_PacketsReceived, NULL, BBFDM_BOTH, "2.0"},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_DSLChannelStats_ErrorsSent, NULL, BBFDM_BOTH, "2.0"},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_DSLChannelStats_ErrorsReceived, NULL, BBFDM_BOTH, "2.0"},
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_DSLChannelStats_DiscardPacketsSent, NULL, BBFDM_BOTH, "2.0"},
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_DSLChannelStats_DiscardPacketsReceived, NULL, BBFDM_BOTH, "2.0"},
{"TotalStart", &DMREAD, DMT_UNINT, get_DSLChannelStats_TotalStart, NULL, BBFDM_BOTH, "2.0"},
{"ShowtimeStart", &DMREAD, DMT_UNINT, get_DSLChannelStats_ShowtimeStart, NULL, BBFDM_BOTH, "2.0"},
{"LastShowtimeStart", &DMREAD, DMT_UNINT, get_DSLChannelStats_LastShowtimeStart, NULL, BBFDM_BOTH, "2.0"},
{"CurrentDayStart", &DMREAD, DMT_UNINT, get_DSLChannelStats_CurrentDayStart, NULL, BBFDM_BOTH, "2.0"},
{"QuarterHourStart", &DMREAD, DMT_UNINT, get_DSLChannelStats_QuarterHourStart, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Channel.{i}.Stats.Total. *** */
DMLEAF tDSLChannelStatsTotalParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"XTURFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTURFECErrors, NULL, BBFDM_BOTH},
{"XTUCFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTUCFECErrors, NULL, BBFDM_BOTH},
{"XTURHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTURHECErrors, NULL, BBFDM_BOTH},
{"XTUCHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTUCHECErrors, NULL, BBFDM_BOTH},
{"XTURCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTURCRCErrors, NULL, BBFDM_BOTH},
{"XTUCCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTUCCRCErrors, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"XTURFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTURFECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTUCFECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTURHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTURHECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTUCHECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTURCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTURCRCErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsTotal_XTUCCRCErrors, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Channel.{i}.Stats.Showtime. *** */
DMLEAF tDSLChannelStatsShowtimeParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"XTURFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTURFECErrors, NULL, BBFDM_BOTH},
{"XTUCFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTUCFECErrors, NULL, BBFDM_BOTH},
{"XTURHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTURHECErrors, NULL, BBFDM_BOTH},
{"XTUCHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTUCHECErrors, NULL, BBFDM_BOTH},
{"XTURCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTURCRCErrors, NULL, BBFDM_BOTH},
{"XTUCCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTUCCRCErrors, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"XTURFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTURFECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTUCFECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTURHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTURHECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTUCHECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTURCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTURCRCErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsShowtime_XTUCCRCErrors, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Channel.{i}.Stats.LastShowtime. *** */
DMLEAF tDSLChannelStatsLastShowtimeParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"XTURFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTURFECErrors, NULL, BBFDM_BOTH},
{"XTUCFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTUCFECErrors, NULL, BBFDM_BOTH},
{"XTURHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTURHECErrors, NULL, BBFDM_BOTH},
{"XTUCHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTUCHECErrors, NULL, BBFDM_BOTH},
{"XTURCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTURCRCErrors, NULL, BBFDM_BOTH},
{"XTUCCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTUCCRCErrors, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"XTURFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTURFECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTUCFECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTURHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTURHECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTUCHECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTURCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTURCRCErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsLastShowtime_XTUCCRCErrors, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Channel.{i}.Stats.CurrentDay. *** */
DMLEAF tDSLChannelStatsCurrentDayParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"XTURFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTURFECErrors, NULL, BBFDM_BOTH},
{"XTUCFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTUCFECErrors, NULL, BBFDM_BOTH},
{"XTURHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTURHECErrors, NULL, BBFDM_BOTH},
{"XTUCHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTUCHECErrors, NULL, BBFDM_BOTH},
{"XTURCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTURCRCErrors, NULL, BBFDM_BOTH},
{"XTUCCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTUCCRCErrors, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"XTURFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTURFECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTUCFECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTURHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTURHECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTUCHECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTURCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTURCRCErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsCurrentDay_XTUCCRCErrors, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.DSL.Channel.{i}.Stats.QuarterHour. *** */
DMLEAF tDSLChannelStatsQuarterHourParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"XTURFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTURFECErrors, NULL, BBFDM_BOTH},
{"XTUCFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTUCFECErrors, NULL, BBFDM_BOTH},
{"XTURHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTURHECErrors, NULL, BBFDM_BOTH},
{"XTUCHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTUCHECErrors, NULL, BBFDM_BOTH},
{"XTURCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTURCRCErrors, NULL, BBFDM_BOTH},
{"XTUCCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTUCCRCErrors, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"XTURFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTURFECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCFECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTUCFECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTURHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTURHECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCHECErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTUCHECErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTURCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTURCRCErrors, NULL, BBFDM_BOTH, "2.0"},
{"XTUCCRCErrors", &DMREAD, DMT_UNINT, get_DSLChannelStatsQuarterHour_XTUCCRCErrors, NULL, BBFDM_BOTH, "2.0"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __DSL_H
#define __DSL_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tDSLObj[];
extern DMLEAF tDSLParams[];

File diff suppressed because it is too large Load diff

View file

@ -11,7 +11,7 @@
#ifndef __DYNAMICDNS_H
#define __DYNAMICDNS_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tDynamicDNSObj[];
extern DMLEAF tDynamicDNSParams[];

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,7 @@
#ifndef __ETHERNET_H
#define __ETHERNET_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tEthernetObj[];
extern DMLEAF tEthernetParams[];
@ -28,8 +28,9 @@ extern DMLEAF tEthernetVLANTerminationParams[];
extern DMLEAF tEthernetVLANTerminationStatsParams[];
extern DMLEAF tEthernetRMONStatsParams[];
struct uci_section *get_device_section(char *dev_name);
bool ethernet_check_section_in_curr_section(char *curr_section, char *section);
bool ethernet_name_exists_in_devices(char *name);
struct uci_section *ethernet___get_device_section(char *dev_name);
bool ethernet___check_vlan_termination_section(const char *name);
bool ethernet___check_section_in_curr_section(const char *curr_section, const char *section);
bool ethernet___name_exists_in_devices(char *name);
#endif //__ETHERNET_H

View file

@ -8,7 +8,6 @@
* Author: Jani Juvan <jani.juvan@iopsys.eu>
*/
#include "dmentry.h"
#include "dsl.h"
#include "fast.h"
@ -52,7 +51,7 @@ static struct uci_section *update_create_dmmap_fast_line(char *curr_id)
if (!s) {
char instance[16];
snprintf(instance, sizeof(instance), "%d", atoi(curr_id));
snprintf(instance, sizeof(instance), "%ld", DM_STRTOL(curr_id));
dmuci_add_section_bbfdm("dmmap", "fast_line", &s);
dmuci_set_value_by_section_bbfdm(s, "id", curr_id);
dmuci_set_value_by_section_bbfdm(s, "fast_line_instance", instance);
@ -71,7 +70,7 @@ static int browseFASTLineInst(struct dmctx *dmctx, DMNODE *parent_node, void *pr
char *inst = NULL;
int entries = 0;
dmubus_call("fast", "status", UBUS_ARGS{}, 0, &res);
dmubus_call("fast", "status", UBUS_ARGS{0}, 0, &res);
while (res) {
line_obj = dmjson_select_obj_in_array_idx(res, entries, 1, "line");
if(line_obj) {
@ -100,7 +99,7 @@ static char *get_fast_value_without_argument(char *command1, char *id, char *com
char command[16], *value = "0";
snprintf(command, sizeof(command), "%s.%s", command1, id);
dmubus_call(command, command2, UBUS_ARGS{}, 0, &res);
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
if (!res) return "";
value = dmjson_get_value(res, 1, key);
return value;
@ -112,7 +111,7 @@ static char *get_fast_value_without_argument_and_with_two_key(char *command1, ch
char command[16], *value = "0";
snprintf(command, sizeof(command), "%s.%s", command1, id);
dmubus_call(command, command2, UBUS_ARGS{}, 0, &res);
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
if (!res) return "";
value = dmjson_get_value(res, 2, key1, key2);
return value;
@ -124,7 +123,7 @@ static char *get_fast_value_array_without_argument(char *command1, char *id, cha
char command[16], *value= "0";
snprintf(command, sizeof(command), "%s.%s", command1, id);
dmubus_call(command, command2, UBUS_ARGS{}, 0, &res);
dmubus_call(command, command2, UBUS_ARGS{0}, 0, &res);
if (!res) return "";
value = dmjson_get_value_array_all(res, ",", 1, key);
return value;
@ -144,7 +143,7 @@ static int get_FAST_LineNumberOfEntries(char *refparam, struct dmctx *ctx, void
static int get_FASTLine_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *status = get_fast_value_without_argument("fast.line", ((struct fast_line_args*)data)->id, "status", "status");
*value = (strcmp(status, "up") == 0) ? "1" : "0";
*value = (DM_LSTRCMP(status, "up") == 0) ? "1" : "0";
return 0;
}
@ -165,7 +164,7 @@ static int set_FASTLine_Enable(char *refparam, struct dmctx *ctx, void *data, ch
static int get_FASTLine_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *status = get_fast_value_without_argument("fast.line", ((struct fast_line_args*)data)->id, "status", "status");
*value = (strcmp(status, "up") == 0) ? "Up" : "Down";
*value = (DM_LSTRCMP(status, "up") == 0) ? "Up" : "Down";
return 0;
}
@ -244,12 +243,12 @@ static int get_FASTLine_AllowedProfiles(char *refparam, struct dmctx *ctx, void
unsigned pos = 0, idx = 0;
snprintf(ubus_name, sizeof(ubus_name), "fast.line.%s", ((struct fast_line_args*)data)->id);
dmubus_call(ubus_name, "status", UBUS_ARGS{}, 0, &res);
dmubus_call(ubus_name, "status", UBUS_ARGS{0}, 0, &res);
DM_ASSERT(res, *value = "");
list_profile[0] = 0;
dmjson_foreach_value_in_array(res, allowed_profiles, profile, idx, 1, "allowed_profiles") {
if (profile && (strcmp(profile, "106a") == 0 || strcmp(profile, "212a") == 0))
if (profile && (DM_LSTRCMP(profile, "106a") == 0 || DM_LSTRCMP(profile, "212a") == 0))
pos += snprintf(&list_profile[pos], sizeof(list_profile) - pos, "%s,", profile);
}
@ -265,7 +264,7 @@ static int get_FASTLine_AllowedProfiles(char *refparam, struct dmctx *ctx, void
static int get_FASTLine_CurrentProfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *current_profile = get_fast_value_without_argument("fast.line", ((struct fast_line_args*)data)->id, "status", "current_profile");
*value = (current_profile && strcmp(current_profile, "unknown") == 0) ? "" : current_profile;
*value = (current_profile && DM_LSTRCMP(current_profile, "unknown") == 0) ? "" : current_profile;
return 0;
}
@ -273,13 +272,13 @@ static int get_FASTLine_CurrentProfile(char *refparam, struct dmctx *ctx, void *
static int get_FASTLine_PowerManagementState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *power_mng_state = get_fast_value_without_argument("fast.line", ((struct fast_line_args*)data)->id, "status", "power_management_state");
if(strcmp(power_mng_state, "l0") == 0)
if(DM_LSTRCMP(power_mng_state, "l0") == 0)
*value = "L0";
else if(strcmp(power_mng_state, "l1") == 0)
else if(DM_LSTRCMP(power_mng_state, "l1") == 0)
*value = "L2.1";
else if(strcmp(power_mng_state, "l2") == 0)
else if(DM_LSTRCMP(power_mng_state, "l2") == 0)
*value = "L2.2";
else if(strcmp(power_mng_state, "l3") == 0)
else if(DM_LSTRCMP(power_mng_state, "l3") == 0)
*value = "L3";
else
*value = power_mng_state;
@ -900,169 +899,169 @@ static int get_FASTLineStatsQuarterHour_SuccessTIGA(char *refparam, struct dmctx
***********************************************************************************************************************************/
/* *** Device.FAST. *** */
DMOBJ tFASTObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Line", &DMREAD, NULL, NULL, NULL, browseFASTLineInst, NULL, NULL, tFASTLineObj, tFASTLineParams, get_fast_line_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Line", &DMREAD, NULL, NULL, NULL, browseFASTLineInst, NULL, NULL, tFASTLineObj, tFASTLineParams, get_fast_line_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.11"},
{0}
};
DMLEAF tFASTParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"LineNumberOfEntries", &DMREAD, DMT_UNINT, get_FAST_LineNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"LineNumberOfEntries", &DMREAD, DMT_UNINT, get_FAST_LineNumberOfEntries, NULL, BBFDM_BOTH, "2.11"},
{0}
};
/* *** Device.FAST.Line.{i}. *** */
DMOBJ tFASTLineObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsObj, tFASTLineStatsParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsObj, tFASTLineStatsParams, NULL, BBFDM_BOTH, NULL, "2.11"},
{0}
};
DMLEAF tFASTLineParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_FASTLine_Enable, set_FASTLine_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_FASTLine_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_FASTLine_Alias, set_FASTLine_Alias, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_FASTLine_Name, NULL, BBFDM_BOTH},
{"LowerLayers", &DMWRITE, DMT_STRING, get_FASTLine_LowerLayers, set_FASTLine_LowerLayers, BBFDM_BOTH},
{"Upstream", &DMREAD, DMT_BOOL, get_FASTLine_Upstream, NULL, BBFDM_BOTH},
{"FirmwareVersion", &DMREAD, DMT_STRING, get_FASTLine_FirmwareVersion, NULL, BBFDM_BOTH},
{"LinkStatus", &DMREAD, DMT_STRING, get_FASTLine_LinkStatus, NULL, BBFDM_BOTH},
{"AllowedProfiles", &DMREAD, DMT_STRING, get_FASTLine_AllowedProfiles, NULL, BBFDM_BOTH},
{"CurrentProfile", &DMREAD, DMT_STRING, get_FASTLine_CurrentProfile, NULL, BBFDM_BOTH},
{"PowerManagementState", &DMREAD, DMT_STRING, get_FASTLine_PowerManagementState, NULL, BBFDM_BOTH},
{"SuccessFailureCause", &DMREAD, DMT_UNINT, get_FASTLine_SuccessFailureCause, NULL, BBFDM_BOTH},
{"UPBOKLER", &DMREAD, DMT_UNINT, get_FASTLine_UPBOKLER, NULL, BBFDM_BOTH},
{"UPBOKLE", &DMREAD, DMT_UNINT, get_FASTLine_UPBOKLE, NULL, BBFDM_BOTH},
{"LineNumber", &DMREAD, DMT_INT, get_FASTLine_LineNumber, NULL, BBFDM_BOTH},
{"UpstreamMaxBitRate", &DMREAD, DMT_UNINT, get_FASTLine_UpstreamMaxBitRate, NULL, BBFDM_BOTH},
{"DownstreamMaxBitRate", &DMREAD, DMT_UNINT, get_FASTLine_DownstreamMaxBitRate, NULL, BBFDM_BOTH},
{"UpstreamNoiseMargin", &DMREAD, DMT_INT, get_FASTLine_UpstreamNoiseMargin, NULL, BBFDM_BOTH},
{"DownstreamNoiseMargin", &DMREAD, DMT_INT, get_FASTLine_DownstreamNoiseMargin, NULL, BBFDM_BOTH},
{"UpstreamAttenuation", &DMREAD, DMT_INT, get_FASTLine_UpstreamAttenuation, NULL, BBFDM_BOTH},
{"DownstreamAttenuation", &DMREAD, DMT_INT, get_FASTLine_DownstreamAttenuation, NULL, BBFDM_BOTH},
{"UpstreamPower", &DMREAD, DMT_INT, get_FASTLine_UpstreamPower, NULL, BBFDM_BOTH},
{"DownstreamPower", &DMREAD, DMT_INT, get_FASTLine_DownstreamPower, NULL, BBFDM_BOTH},
{"SNRMRMCds", &DMREAD, DMT_INT, get_FASTLine_SNRMRMCds, NULL, BBFDM_BOTH},
{"SNRMRMCus", &DMREAD, DMT_INT, get_FASTLine_SNRMRMCus, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_FASTLine_Enable, set_FASTLine_Enable, BBFDM_BOTH, "2.11"},
{"Status", &DMREAD, DMT_STRING, get_FASTLine_Status, NULL, BBFDM_BOTH, "2.11"},
{"Alias", &DMWRITE, DMT_STRING, get_FASTLine_Alias, set_FASTLine_Alias, BBFDM_BOTH, "2.11"},
{"Name", &DMREAD, DMT_STRING, get_FASTLine_Name, NULL, BBFDM_BOTH, "2.11"},
{"LowerLayers", &DMWRITE, DMT_STRING, get_FASTLine_LowerLayers, set_FASTLine_LowerLayers, BBFDM_BOTH, "2.11"},
{"Upstream", &DMREAD, DMT_BOOL, get_FASTLine_Upstream, NULL, BBFDM_BOTH, "2.11"},
{"FirmwareVersion", &DMREAD, DMT_STRING, get_FASTLine_FirmwareVersion, NULL, BBFDM_BOTH, "2.11"},
{"LinkStatus", &DMREAD, DMT_STRING, get_FASTLine_LinkStatus, NULL, BBFDM_BOTH, "2.11"},
{"AllowedProfiles", &DMREAD, DMT_STRING, get_FASTLine_AllowedProfiles, NULL, BBFDM_BOTH, "2.11"},
{"CurrentProfile", &DMREAD, DMT_STRING, get_FASTLine_CurrentProfile, NULL, BBFDM_BOTH, "2.11"},
{"PowerManagementState", &DMREAD, DMT_STRING, get_FASTLine_PowerManagementState, NULL, BBFDM_BOTH, "2.11"},
{"SuccessFailureCause", &DMREAD, DMT_UNINT, get_FASTLine_SuccessFailureCause, NULL, BBFDM_BOTH, "2.11"},
{"UPBOKLER", &DMREAD, DMT_UNINT, get_FASTLine_UPBOKLER, NULL, BBFDM_BOTH, "2.11"},
{"UPBOKLE", &DMREAD, DMT_UNINT, get_FASTLine_UPBOKLE, NULL, BBFDM_BOTH, "2.11"},
{"LineNumber", &DMREAD, DMT_INT, get_FASTLine_LineNumber, NULL, BBFDM_BOTH, "2.11"},
{"UpstreamMaxBitRate", &DMREAD, DMT_UNINT, get_FASTLine_UpstreamMaxBitRate, NULL, BBFDM_BOTH, "2.11"},
{"DownstreamMaxBitRate", &DMREAD, DMT_UNINT, get_FASTLine_DownstreamMaxBitRate, NULL, BBFDM_BOTH, "2.11"},
{"UpstreamNoiseMargin", &DMREAD, DMT_INT, get_FASTLine_UpstreamNoiseMargin, NULL, BBFDM_BOTH, "2.11"},
{"DownstreamNoiseMargin", &DMREAD, DMT_INT, get_FASTLine_DownstreamNoiseMargin, NULL, BBFDM_BOTH, "2.11"},
{"UpstreamAttenuation", &DMREAD, DMT_INT, get_FASTLine_UpstreamAttenuation, NULL, BBFDM_BOTH, "2.11"},
{"DownstreamAttenuation", &DMREAD, DMT_INT, get_FASTLine_DownstreamAttenuation, NULL, BBFDM_BOTH, "2.11"},
{"UpstreamPower", &DMREAD, DMT_INT, get_FASTLine_UpstreamPower, NULL, BBFDM_BOTH, "2.11"},
{"DownstreamPower", &DMREAD, DMT_INT, get_FASTLine_DownstreamPower, NULL, BBFDM_BOTH, "2.11"},
{"SNRMRMCds", &DMREAD, DMT_INT, get_FASTLine_SNRMRMCds, NULL, BBFDM_BOTH, "2.11"},
{"SNRMRMCus", &DMREAD, DMT_INT, get_FASTLine_SNRMRMCus, NULL, BBFDM_BOTH, "2.11"},
{0}
};
/* *** Device.FAST.Line.{i}.Stats. *** */
DMOBJ tFASTLineStatsObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Total", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsTotalParams, NULL, BBFDM_BOTH},
{"Showtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsShowtimeParams, NULL, BBFDM_BOTH},
{"LastShowtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsLastShowtimeParams, NULL, BBFDM_BOTH},
{"CurrentDay", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsCurrentDayParams, NULL, BBFDM_BOTH},
{"QuarterHour", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsQuarterHourParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Total", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsTotalParams, NULL, BBFDM_BOTH, NULL, "2.11"},
{"Showtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsShowtimeParams, NULL, BBFDM_BOTH, NULL, "2.11"},
{"LastShowtime", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsLastShowtimeParams, NULL, BBFDM_BOTH, NULL, "2.11"},
{"CurrentDay", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsCurrentDayParams, NULL, BBFDM_BOTH, NULL, "2.11"},
{"QuarterHour", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tFASTLineStatsQuarterHourParams, NULL, BBFDM_BOTH, NULL, "2.11"},
{0}
};
DMLEAF tFASTLineStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNLONG, get_FASTLineStats_BytesSent, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_FASTLineStats_BytesReceived, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_FASTLineStats_PacketsSent, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_FASTLineStats_PacketsReceived, NULL, BBFDM_BOTH},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_FASTLineStats_ErrorsSent, NULL, BBFDM_BOTH},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_FASTLineStats_ErrorsReceived, NULL, BBFDM_BOTH},
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_FASTLineStats_DiscardPacketsSent, NULL, BBFDM_BOTH},
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_FASTLineStats_DiscardPacketsReceived, NULL, BBFDM_BOTH},
{"TotalStart", &DMREAD, DMT_UNINT, get_FASTLineStats_TotalStart, NULL, BBFDM_BOTH},
{"ShowtimeStart", &DMREAD, DMT_UNINT, get_FASTLineStats_ShowtimeStart, NULL, BBFDM_BOTH},
{"LastShowtimeStart", &DMREAD, DMT_UNINT, get_FASTLineStats_LastShowtimeStart, NULL, BBFDM_BOTH},
{"CurrentDayStart", &DMREAD, DMT_UNINT, get_FASTLineStats_CurrentDayStart, NULL, BBFDM_BOTH},
{"QuarterHourStart", &DMREAD, DMT_UNINT, get_FASTLineStats_QuarterHourStart, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"BytesSent", &DMREAD, DMT_UNLONG, get_FASTLineStats_BytesSent, NULL, BBFDM_BOTH, "2.11"},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_FASTLineStats_BytesReceived, NULL, BBFDM_BOTH, "2.11"},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_FASTLineStats_PacketsSent, NULL, BBFDM_BOTH, "2.11"},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_FASTLineStats_PacketsReceived, NULL, BBFDM_BOTH, "2.11"},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_FASTLineStats_ErrorsSent, NULL, BBFDM_BOTH, "2.11"},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_FASTLineStats_ErrorsReceived, NULL, BBFDM_BOTH, "2.11"},
{"DiscardPacketsSent", &DMREAD, DMT_UNINT, get_FASTLineStats_DiscardPacketsSent, NULL, BBFDM_BOTH, "2.11"},
{"DiscardPacketsReceived", &DMREAD, DMT_UNINT, get_FASTLineStats_DiscardPacketsReceived, NULL, BBFDM_BOTH, "2.11"},
{"TotalStart", &DMREAD, DMT_UNINT, get_FASTLineStats_TotalStart, NULL, BBFDM_BOTH, "2.11"},
{"ShowtimeStart", &DMREAD, DMT_UNINT, get_FASTLineStats_ShowtimeStart, NULL, BBFDM_BOTH, "2.11"},
{"LastShowtimeStart", &DMREAD, DMT_UNINT, get_FASTLineStats_LastShowtimeStart, NULL, BBFDM_BOTH, "2.11"},
{"CurrentDayStart", &DMREAD, DMT_UNINT, get_FASTLineStats_CurrentDayStart, NULL, BBFDM_BOTH, "2.11"},
{"QuarterHourStart", &DMREAD, DMT_UNINT, get_FASTLineStats_QuarterHourStart, NULL, BBFDM_BOTH, "2.11"},
{0}
};
/* *** Device.FAST.Line.{i}.Stats.Total. *** */
DMLEAF tFASTLineStatsTotalParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_ErroredSecs, NULL, BBFDM_BOTH},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SeverelyErroredSecs, NULL, BBFDM_BOTH},
{"LOSS", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_LOSS, NULL, BBFDM_BOTH},
{"LORS", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_LORS, NULL, BBFDM_BOTH},
{"UAS", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_UAS, NULL, BBFDM_BOTH},
{"RTXUC", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_RTXUC, NULL, BBFDM_BOTH},
{"RTXTX", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_RTXTX, NULL, BBFDM_BOTH},
{"SuccessBSW", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SuccessBSW, NULL, BBFDM_BOTH},
{"SuccessSRA", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SuccessSRA, NULL, BBFDM_BOTH},
{"SuccessFRA", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SuccessFRA, NULL, BBFDM_BOTH},
{"SuccessRPA", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SuccessRPA, NULL, BBFDM_BOTH},
{"SuccessTIGA", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SuccessTIGA, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_ErroredSecs, NULL, BBFDM_BOTH, "2.11"},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SeverelyErroredSecs, NULL, BBFDM_BOTH, "2.11"},
{"LOSS", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_LOSS, NULL, BBFDM_BOTH, "2.11"},
{"LORS", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_LORS, NULL, BBFDM_BOTH, "2.11"},
{"UAS", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_UAS, NULL, BBFDM_BOTH, "2.11"},
{"RTXUC", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_RTXUC, NULL, BBFDM_BOTH, "2.11"},
{"RTXTX", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_RTXTX, NULL, BBFDM_BOTH, "2.11"},
{"SuccessBSW", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SuccessBSW, NULL, BBFDM_BOTH, "2.11"},
{"SuccessSRA", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SuccessSRA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessFRA", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SuccessFRA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessRPA", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SuccessRPA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessTIGA", &DMREAD, DMT_UNINT, get_FASTLineStatsTotal_SuccessTIGA, NULL, BBFDM_BOTH, "2.11"},
{0}
};
/* *** Device.FAST.Line.{i}.Stats.Showtime. *** */
DMLEAF tFASTLineStatsShowtimeParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_ErroredSecs, NULL, BBFDM_BOTH},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SeverelyErroredSecs, NULL, BBFDM_BOTH},
{"LOSS", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_LOSS, NULL, BBFDM_BOTH},
{"LORS", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_LORS, NULL, BBFDM_BOTH},
{"UAS", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_UAS, NULL, BBFDM_BOTH},
{"RTXUC", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_RTXUC, NULL, BBFDM_BOTH},
{"RTXTX", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_RTXTX, NULL, BBFDM_BOTH},
{"SuccessBSW", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SuccessBSW, NULL, BBFDM_BOTH},
{"SuccessSRA", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SuccessSRA, NULL, BBFDM_BOTH},
{"SuccessFRA", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SuccessFRA, NULL, BBFDM_BOTH},
{"SuccessRPA", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SuccessRPA, NULL, BBFDM_BOTH},
{"SuccessTIGA", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SuccessTIGA, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_ErroredSecs, NULL, BBFDM_BOTH, "2.11"},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SeverelyErroredSecs, NULL, BBFDM_BOTH, "2.11"},
{"LOSS", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_LOSS, NULL, BBFDM_BOTH, "2.11"},
{"LORS", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_LORS, NULL, BBFDM_BOTH, "2.11"},
{"UAS", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_UAS, NULL, BBFDM_BOTH, "2.11"},
{"RTXUC", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_RTXUC, NULL, BBFDM_BOTH, "2.11"},
{"RTXTX", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_RTXTX, NULL, BBFDM_BOTH, "2.11"},
{"SuccessBSW", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SuccessBSW, NULL, BBFDM_BOTH, "2.11"},
{"SuccessSRA", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SuccessSRA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessFRA", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SuccessFRA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessRPA", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SuccessRPA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessTIGA", &DMREAD, DMT_UNINT, get_FASTLineStatsShowtime_SuccessTIGA, NULL, BBFDM_BOTH, "2.11"},
{0}
};
/* *** Device.FAST.Line.{i}.Stats.LastShowtime. *** */
DMLEAF tFASTLineStatsLastShowtimeParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_ErroredSecs, NULL, BBFDM_BOTH},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SeverelyErroredSecs, NULL, BBFDM_BOTH},
{"LOSS", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_LOSS, NULL, BBFDM_BOTH},
{"LORS", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_LORS, NULL, BBFDM_BOTH},
{"UAS", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_UAS, NULL, BBFDM_BOTH},
{"RTXUC", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_RTXUC, NULL, BBFDM_BOTH},
{"RTXTX", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_RTXTX, NULL, BBFDM_BOTH},
{"SuccessBSW", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SuccessBSW, NULL, BBFDM_BOTH},
{"SuccessSRA", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SuccessSRA, NULL, BBFDM_BOTH},
{"SuccessFRA", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SuccessFRA, NULL, BBFDM_BOTH},
{"SuccessRPA", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SuccessRPA, NULL, BBFDM_BOTH},
{"SuccessTIGA", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SuccessTIGA, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_ErroredSecs, NULL, BBFDM_BOTH, "2.11"},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SeverelyErroredSecs, NULL, BBFDM_BOTH, "2.11"},
{"LOSS", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_LOSS, NULL, BBFDM_BOTH, "2.11"},
{"LORS", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_LORS, NULL, BBFDM_BOTH, "2.11"},
{"UAS", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_UAS, NULL, BBFDM_BOTH, "2.11"},
{"RTXUC", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_RTXUC, NULL, BBFDM_BOTH, "2.11"},
{"RTXTX", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_RTXTX, NULL, BBFDM_BOTH, "2.11"},
{"SuccessBSW", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SuccessBSW, NULL, BBFDM_BOTH, "2.11"},
{"SuccessSRA", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SuccessSRA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessFRA", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SuccessFRA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessRPA", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SuccessRPA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessTIGA", &DMREAD, DMT_UNINT, get_FASTLineStatsLastShowtime_SuccessTIGA, NULL, BBFDM_BOTH, "2.11"},
{0}
};
/* *** Device.FAST.Line.{i}.Stats.CurrentDay. *** */
DMLEAF tFASTLineStatsCurrentDayParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_ErroredSecs, NULL, BBFDM_BOTH},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SeverelyErroredSecs, NULL, BBFDM_BOTH},
{"LOSS", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_LOSS, NULL, BBFDM_BOTH},
{"LORS", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_LORS, NULL, BBFDM_BOTH},
{"UAS", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_UAS, NULL, BBFDM_BOTH},
{"RTXUC", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_RTXUC, NULL, BBFDM_BOTH},
{"RTXTX", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_RTXTX, NULL, BBFDM_BOTH},
{"SuccessBSW", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SuccessBSW, NULL, BBFDM_BOTH},
{"SuccessSRA", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SuccessSRA, NULL, BBFDM_BOTH},
{"SuccessFRA", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SuccessFRA, NULL, BBFDM_BOTH},
{"SuccessRPA", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SuccessRPA, NULL, BBFDM_BOTH},
{"SuccessTIGA", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SuccessTIGA, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_ErroredSecs, NULL, BBFDM_BOTH, "2.11"},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SeverelyErroredSecs, NULL, BBFDM_BOTH, "2.11"},
{"LOSS", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_LOSS, NULL, BBFDM_BOTH, "2.11"},
{"LORS", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_LORS, NULL, BBFDM_BOTH, "2.11"},
{"UAS", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_UAS, NULL, BBFDM_BOTH, "2.11"},
{"RTXUC", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_RTXUC, NULL, BBFDM_BOTH, "2.11"},
{"RTXTX", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_RTXTX, NULL, BBFDM_BOTH, "2.11"},
{"SuccessBSW", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SuccessBSW, NULL, BBFDM_BOTH, "2.11"},
{"SuccessSRA", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SuccessSRA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessFRA", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SuccessFRA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessRPA", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SuccessRPA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessTIGA", &DMREAD, DMT_UNINT, get_FASTLineStatsCurrentDay_SuccessTIGA, NULL, BBFDM_BOTH, "2.11"},
{0}
};
/* *** Device.FAST.Line.{i}.Stats.QuarterHour. *** */
DMLEAF tFASTLineStatsQuarterHourParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_ErroredSecs, NULL, BBFDM_BOTH},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SeverelyErroredSecs, NULL, BBFDM_BOTH},
{"LOSS", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_LOSS, NULL, BBFDM_BOTH},
{"LORS", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_LORS, NULL, BBFDM_BOTH},
{"UAS", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_UAS, NULL, BBFDM_BOTH},
{"RTXUC", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_RTXUC, NULL, BBFDM_BOTH},
{"RTXTX", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_RTXTX, NULL, BBFDM_BOTH},
{"SuccessBSW", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SuccessBSW, NULL, BBFDM_BOTH},
{"SuccessSRA", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SuccessSRA, NULL, BBFDM_BOTH},
{"SuccessFRA", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SuccessFRA, NULL, BBFDM_BOTH},
{"SuccessRPA", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SuccessRPA, NULL, BBFDM_BOTH},
{"SuccessTIGA", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SuccessTIGA, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_ErroredSecs, NULL, BBFDM_BOTH, "2.11"},
{"SeverelyErroredSecs", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SeverelyErroredSecs, NULL, BBFDM_BOTH, "2.11"},
{"LOSS", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_LOSS, NULL, BBFDM_BOTH, "2.11"},
{"LORS", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_LORS, NULL, BBFDM_BOTH, "2.11"},
{"UAS", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_UAS, NULL, BBFDM_BOTH, "2.11"},
{"RTXUC", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_RTXUC, NULL, BBFDM_BOTH, "2.11"},
{"RTXTX", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_RTXTX, NULL, BBFDM_BOTH, "2.11"},
{"SuccessBSW", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SuccessBSW, NULL, BBFDM_BOTH, "2.11"},
{"SuccessSRA", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SuccessSRA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessFRA", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SuccessFRA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessRPA", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SuccessRPA, NULL, BBFDM_BOTH, "2.11"},
{"SuccessTIGA", &DMREAD, DMT_UNINT, get_FASTLineStatsQuarterHour_SuccessTIGA, NULL, BBFDM_BOTH, "2.11"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __FAST_H
#define __FAST_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tFASTObj[];
extern DMLEAF tFASTParams[];

View file

@ -9,9 +9,32 @@
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include "dmentry.h"
#include "firewall.h"
/*************************************************************
* COMMON FUNCTIONS
**************************************************************/
static void create_portmapping_section(bool b)
{
struct uci_section *s = NULL;
dmuci_add_section("firewall", "include", &s);
dmuci_rename_section_by_section(s, "portmapping");
dmuci_set_value_by_section(s, "enabled", b ? "0" : "1");
dmuci_set_value_by_section(s, "path", "/etc/firewall.portmapping");
dmuci_set_value_by_section(s, "reload", "1");
}
static char *get_rule_perm(char *refparam, struct dmctx *dmctx, void *data, char *instance)
{
char *rule_perm = NULL;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "is_rule", &rule_perm);
return rule_perm;
}
struct dm_permession_s DMRule = {"1", &get_rule_perm};
/*************************************************************
* ENTRY METHOD
**************************************************************/
@ -40,15 +63,33 @@ static int browseRuleInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_d
struct dmmap_dup *p = NULL;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("firewall", "rule", "dmmap_firewall", &dup_list);
// Forwarding sections
synchronize_specific_config_sections_with_dmmap("firewall", "forwarding", "dmmap_firewall", &dup_list);
list_for_each_entry(p, &dup_list, list) {
dmuci_set_value_by_section(p->dmmap_section, "is_rule", "0");
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "firewall_chain_rule_instance", "firewall_chain_rule_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
break;
goto end;
}
free_dmmap_config_dup_list(&dup_list);
// Rule sections
synchronize_specific_config_sections_with_dmmap("firewall", "rule", "dmmap_firewall", &dup_list);
list_for_each_entry(p, &dup_list, list) {
dmuci_set_value_by_section(p->dmmap_section, "is_rule", "1");
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "firewall_chain_rule_instance", "firewall_chain_rule_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, inst) == DM_STOP)
goto end;
}
free_dmmap_config_dup_list(&dup_list);
end:
return 0;
}
@ -70,6 +111,7 @@ static int add_firewall_rule(char *refparam, struct dmctx *ctx, void *data, char
dmuci_rename_section_by_section(s, s_name);
dmuci_set_value_by_section(s, "enabled", "0");
dmuci_set_value_by_section(s, "target", "DROP");
dmuci_set_value_by_section(s, "proto", "0");
dmuci_add_section_bbfdm("dmmap_firewall", "rule", &dmmap_firewall_rule);
dmuci_set_value_by_section(dmmap_firewall_rule, "section_name", s_name);
@ -106,11 +148,7 @@ static int delete_firewall_rule(char *refparam, struct dmctx *ctx, void *data, c
**************************************************************/
static int get_firewall_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *path = "/etc/rc.d/*firewall";
if (check_file(path))
*value = "1";
else
*value = "0";
*value = dmuci_get_option_value_fallback_def("firewall", "globals", "enabled", "1");
return 0;
}
@ -167,17 +205,25 @@ static int get_level_chain(char *refparam, struct dmctx *ctx, void *data, char *
static int get_level_port_mapping_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
char *v;
bool portmapping_sec_exists = false;
char *enable = NULL;
uci_foreach_sections("firewall", "zone", s) {
dmuci_get_value_by_section_string(s, "masq", &v);
if (*v == '1') {
*value = "1";
return 0;
uci_foreach_sections("firewall", "include", s) {
if (strncmp(section_name(s), "portmapping", 11) == 0) {
portmapping_sec_exists = true ;
dmuci_get_value_by_section_string(s, "enabled", &enable);
if (*enable == '0') {
*value = "1";
break;
}
}
}
*value = "0";
return 0;
if (portmapping_sec_exists == false)
*value = "1";
return 0;
}
static int get_level_default_log_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
@ -196,6 +242,20 @@ static int get_level_default_log_policy(char *refparam, struct dmctx *ctx, void
return 0;
}
static int get_level_default_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *input = NULL;
dmuci_get_option_value_string("firewall", "@defaults[0]", "input", &input);
if (!input || *input == 0) {
*value = "Drop";
return 0;
}
*value = (*input == 'A') ? "Accept" : (*input == 'R') ? "Reject" : "Drop";
return 0;
}
static int get_chain_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "1";
@ -273,19 +333,26 @@ static int get_rule_description(char *refparam, struct dmctx *ctx, void *data, c
/*#Device.Firewall.Chain.{i}.Rule.{i}.Target!UCI:firewall/rule,@i-1/target*/
static int get_rule_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *v;
char *target;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "target", &v);
if (strcasecmp(v, "Accept") == 0)
*value = "Accept";
else if (strcasecmp(v, "Reject") == 0)
*value = "Reject";
else if (strcasecmp(v, "Drop") == 0)
*value = "Drop";
else if (strcasecmp(v, "MARK") == 0)
*value = "Return";
else
*value = v;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "target", &target);
if (DM_STRLEN(target) == 0) {
char *rule_perm = NULL;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "is_rule", &rule_perm);
*value = (DM_LSTRCMP(rule_perm, "1") == 0) ? "Drop" : "Accept";
} else {
if (strcasecmp(target, "Accept") == 0)
*value = "Accept";
else if (strcasecmp(target, "Reject") == 0)
*value = "Reject";
else if (strcasecmp(target, "Drop") == 0)
*value = "Drop";
else if (strcasecmp(target, "MARK") == 0)
*value = "Return";
else
*value = target;
}
return 0;
}
@ -310,9 +377,9 @@ static int get_FirewallChainRule_ExpiryDate(char *refparam, struct dmctx *ctx, v
char *expiry_date = NULL;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "expiry", &expiry_date);
if (expiry_date && *expiry_date != '\0' && atoi(expiry_date) > 0) {
if (expiry_date && *expiry_date != '\0' && DM_STRTOL(expiry_date) > 0) {
char expiry[sizeof "AAAA-MM-JJTHH:MM:SSZ"];
time_t time_value = atoi(expiry_date);
time_t time_value = DM_STRTOL(expiry_date);
strftime(expiry, sizeof expiry, "%Y-%m-%dT%H:%M:%SZ", gmtime(&time_value));
*value = dmstrdup(expiry);
@ -334,7 +401,7 @@ static int set_FirewallChainRule_ExpiryDate(char *refparam, struct dmctx *ctx, v
break;
case VALUESET:
strptime(value, "%Y-%m-%dT%H:%M:%SZ", &tm);
snprintf(expiry_date, sizeof(expiry_date), "%ld", timegm(&tm));
snprintf(expiry_date, sizeof(expiry_date), "%lld", (long long)timegm(&tm));
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "expiry", expiry_date);
break;
}
@ -350,7 +417,7 @@ static int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *da
if (src == NULL || *src == '\0')
return 0;
if (strcmp(src, "*") == 0) {
if (DM_LSTRCMP(src, "*") == 0) {
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "src", &src);
} else {
struct uci_section *s = NULL;
@ -358,7 +425,7 @@ static int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *da
uci_foreach_sections("firewall", "zone", s) {
dmuci_get_value_by_section_string(s, "name", &zone_name);
if (zone_name && strcmp(zone_name, src) == 0) {
if (zone_name && DM_STRCMP(zone_name, src) == 0) {
dmuci_get_value_by_section_list(s, "network", &net_list);
break;
}
@ -372,7 +439,7 @@ static int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *da
src_iface[0] = 0;
uci_foreach_element(net_list, e) {
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", e->name, &ifaceobj);
if (ifaceobj)
if (ifaceobj && *ifaceobj)
pos += snprintf(&src_iface[pos], sizeof(src_iface) - pos, "%s,", ifaceobj);
}
@ -380,7 +447,7 @@ static int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *da
src_iface[pos - 1] = 0;
} else {
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", src, &ifaceobj);
if (ifaceobj)
if (ifaceobj && *ifaceobj)
DM_STRNCPY(src_iface, ifaceobj, sizeof(src_iface));
}
@ -405,7 +472,7 @@ static int get_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data
if (dest == NULL || *dest == '\0')
return 0;
if (strcmp(dest, "*") == 0) {
if (DM_LSTRCMP(dest, "*") == 0) {
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "dest", &dest);
} else {
struct uci_section *s = NULL;
@ -413,7 +480,7 @@ static int get_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data
uci_foreach_sections("firewall", "zone", s) {
dmuci_get_value_by_section_string(s, "name", &zone_name);
if (zone_name && strcmp(zone_name, dest) == 0) {
if (zone_name && DM_STRCMP(zone_name, dest) == 0) {
dmuci_get_value_by_section_list(s, "network", &net_list);
break;
}
@ -427,7 +494,7 @@ static int get_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data
dst_iface[0] = 0;
uci_foreach_element(net_list, e) {
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", e->name, &ifaceobj);
if (ifaceobj)
if (ifaceobj && *ifaceobj)
pos += snprintf(&dst_iface[pos], sizeof(dst_iface) - pos, "%s,", ifaceobj);
}
@ -435,7 +502,7 @@ static int get_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data
dst_iface[pos - 1] = 0;
} else {
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", dest, &ifaceobj);
if (ifaceobj)
if (ifaceobj && *ifaceobj)
DM_STRNCPY(dst_iface, ifaceobj, sizeof(dst_iface));
}
@ -474,7 +541,7 @@ static int get_rule_dest_ip(char *refparam, struct dmctx *ctx, void *data, char
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dest_ip", &destip);
DM_STRNCPY(buf, destip, sizeof(buf));
pch = strchr(buf, '/');
pch = DM_STRCHR(buf, '/');
if (pch) *pch = '\0';
*value = dmstrdup(buf);
return 0;
@ -489,14 +556,14 @@ static int get_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, cha
if (*destip == '\0')
return 0;
pch = strchr(destip, '/');
pch = DM_STRCHR(destip, '/');
if (pch) {
*value = destip;
} else {
char *family;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "family", &family);
dmasprintf(value, "%s/%s", destip, strcmp(family, "ipv6") == 0 ? "128" : "32");
dmasprintf(value, "%s/%s", destip, DM_LSTRCMP(family, "ipv6") == 0 ? "128" : "32");
}
return 0;
}
@ -508,7 +575,7 @@ static int get_rule_source_ip(char *refparam, struct dmctx *ctx, void *data, cha
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_ip", &srcip);
DM_STRNCPY(buf, srcip, sizeof(buf));
pch = strchr(buf, '/');
pch = DM_STRCHR(buf, '/');
if (pch)
*pch = '\0';
*value = dmstrdup(buf);
@ -524,14 +591,14 @@ static int get_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, c
if (*srcip == '\0')
return 0;
pch = strchr(srcip, '/');
pch = DM_STRCHR(srcip, '/');
if (pch) {
*value = srcip;
} else {
char *family;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "family", &family);
dmasprintf(value, "%s/%s", srcip, strcmp(family, "ipv6") == 0 ? "128" : "32");
dmasprintf(value, "%s/%s", srcip, DM_LSTRCMP(family, "ipv6") == 0 ? "128" : "32");
}
return 0;
}
@ -539,24 +606,32 @@ static int get_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, c
/*#Device.Firewall.Chain.{i}.Rule.{i}.Protocol!UCI:firewall/rule,@i-1/proto*/
static int get_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
FILE *fp;
char *v, buf[256], protocol[32], protocol_nbr[16];
char *proto = NULL, buf[256], protocol[32], protocol_nbr[16];
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "proto", &v);
*value = "-1";
if (*v == '\0' || *v == '0') {
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "proto", &proto);
if (!proto || *proto == 0 || strchr(proto, ' ')) {
*value = "255";
return 0;
}
if (isdigit_str(v)) {
*value = v;
if (*proto == '0' || strcmp(proto, "all") == 0) {
*value = "-1";
return 0;
}
fp = fopen("/etc/protocols", "r");
if (isdigit_str(proto)) {
*value = proto;
return 0;
}
FILE *fp = fopen("/etc/protocols", "r");
if (fp == NULL)
return 0;
while (fgets (buf , 256 , fp) != NULL) {
sscanf(buf, "%31s %15s", protocol, protocol_nbr);
if (strcmp(protocol, v) == 0) {
if (DM_STRCMP(protocol, proto) == 0) {
*value = dmstrdup(protocol_nbr);
fclose(fp);
return 0;
@ -573,9 +648,9 @@ static int get_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, cha
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dest_port", &v);
v = dmstrdup(v);
tmp = strchr(v, ':');
tmp = DM_STRCHR(v, ':');
if (tmp == NULL)
tmp = strchr(v, '-');
tmp = DM_STRCHR(v, '-');
if (tmp)
*tmp = '\0';
if (*v == '\0') {
@ -592,9 +667,9 @@ static int get_rule_dest_port_range_max(char *refparam, struct dmctx *ctx, void
char *tmp, *v;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dest_port", &v);
tmp = strchr(v, ':');
tmp = DM_STRCHR(v, ':');
if (tmp == NULL)
tmp = strchr(v, '-');
tmp = DM_STRCHR(v, '-');
*value = (tmp) ? tmp+1 : "-1";
return 0;
}
@ -606,9 +681,9 @@ static int get_rule_source_port(char *refparam, struct dmctx *ctx, void *data, c
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_port", &v);
v = dmstrdup(v);
tmp = strchr(v, ':');
tmp = DM_STRCHR(v, ':');
if (tmp == NULL)
tmp = strchr(v, '-');
tmp = DM_STRCHR(v, '-');
if (tmp)
*tmp = '\0';
if (*v == '\0') {
@ -625,9 +700,9 @@ static int get_rule_source_port_range_max(char *refparam, struct dmctx *ctx, voi
char *tmp, *v;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_port", &v);
tmp = strchr(v, ':');
tmp = DM_STRCHR(v, ':');
if (tmp == NULL)
tmp = strchr(v, '-');
tmp = DM_STRCHR(v, '-');
*value = (tmp) ? tmp+1 : "-1";
return 0;
}
@ -642,7 +717,7 @@ static int set_firewall_enable(char *refparam, struct dmctx *ctx, void *data, ch
break;
case VALUESET:
string_to_bool(value, &b);
dmcmd("/etc/init.d/firewall", 1, b ? "enable" : "disable");
dmuci_set_value("firewall", "globals", "enabled", b ? "1" : "0");
break;
}
return 0;
@ -722,9 +797,8 @@ static int set_level_description(char *refparam, struct dmctx *ctx, void *data,
static int set_level_port_mapping_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
bool b, portmapping_sec_exists = false;
struct uci_section *s = NULL;
char *v, *v2;
switch (action) {
case VALUECHECK:
@ -733,23 +807,46 @@ static int set_level_port_mapping_enabled(char *refparam, struct dmctx *ctx, voi
break;
case VALUESET:
string_to_bool(value, &b);
if (b) {
uci_foreach_sections("firewall", "zone", s) {
dmuci_get_value_by_section_string(s, "src", &v);
dmuci_get_value_by_section_string(s, "name", &v2);
if (strcasestr(v, "wan") || strcasestr(v2, "wan")) {
dmuci_set_value_by_section(s, "masq", "1");
return 0;
}
uci_foreach_sections("firewall", "include", s) {
if (strncmp(section_name(s), "portmapping", 11) == 0) {
portmapping_sec_exists = true;
break;
}
}
if (portmapping_sec_exists == true) {
dmuci_set_value_by_section(s, "enabled", b ? "0" : "1");
} else {
uci_foreach_sections("firewall", "zone", s) {
dmuci_set_value_by_section(s, "masq", "");
}
create_portmapping_section(b);
}
break;
}
return 0;
return 0;
}
static int set_level_default_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *DefaultPolicy[] = {"Drop", "Accept", "Reject", NULL};
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, -1, DefaultPolicy, NULL))
return FAULT_9007;
break;
case VALUESET:
if (DM_LSTRCMP(value, "Drop") == 0) {
dmuci_set_value("firewall", "@defaults[0]", "input", "DROP");
dmuci_set_value("firewall", "@defaults[0]", "output", "DROP");
} else if (DM_LSTRCMP(value, "Accept") == 0) {
dmuci_set_value("firewall", "@defaults[0]", "input", "ACCEPT");
dmuci_set_value("firewall", "@defaults[0]", "output", "ACCEPT");
} else {
dmuci_set_value("firewall", "@defaults[0]", "input", "REJECT");
dmuci_set_value("firewall", "@defaults[0]", "output", "REJECT");
}
break;
}
return 0;
}
static int set_level_default_log_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
@ -830,7 +927,7 @@ static int set_rule_enable(char *refparam, struct dmctx *ctx, void *data, char *
break;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "" : "0");
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "1" : "0");
break;
}
return 0;
@ -917,6 +1014,7 @@ static int set_rule_log(char *refparam, struct dmctx *ctx, void *data, char *ins
static int set_rule_interface(struct dmctx *ctx, void *data, char *type, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
char *iface = NULL, *option = NULL;
switch (action) {
@ -924,11 +1022,7 @@ static int set_rule_interface(struct dmctx *ctx, void *data, char *type, char *v
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (*value == '\0')
break;
adm_entry_get_linker_value(ctx, value, &iface);
if (iface == NULL || iface[0] == '\0')
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
break;
@ -936,7 +1030,7 @@ static int set_rule_interface(struct dmctx *ctx, void *data, char *type, char *v
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, type, &option);
if (*value == '\0') {
dmuci_set_value_by_section((option && strcmp(option, "*") == 0) ? ((struct dmmap_dup *)data)->dmmap_section : ((struct dmmap_dup *)data)->config_section, type, "");
dmuci_set_value_by_section((option && DM_LSTRCMP(option, "*") == 0) ? ((struct dmmap_dup *)data)->dmmap_section : ((struct dmmap_dup *)data)->config_section, type, "");
} else {
adm_entry_get_linker_value(ctx, value, &iface);
if (iface && iface[0] != '\0') {
@ -949,7 +1043,7 @@ static int set_rule_interface(struct dmctx *ctx, void *data, char *type, char *v
char *zone_name;
dmuci_get_value_by_section_string(s, "name", &zone_name);
dmuci_set_value_by_section((option && strcmp(option, "*") == 0) ? ((struct dmmap_dup *)data)->dmmap_section : ((struct dmmap_dup *)data)->config_section, type, zone_name);
dmuci_set_value_by_section((option && DM_LSTRCMP(option, "*") == 0) ? ((struct dmmap_dup *)data)->dmmap_section : ((struct dmmap_dup *)data)->config_section, type, zone_name);
break;
}
}
@ -1045,11 +1139,11 @@ static int set_rule_i_p_version(char *refparam, struct dmctx *ctx, void *data, c
return FAULT_9007;
break;
case VALUESET:
if (strcmp(value, "4") == 0)
if (DM_LSTRCMP(value, "4") == 0)
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "family", "ipv4");
else if (strcmp(value, "6") == 0)
else if (DM_LSTRCMP(value, "6") == 0)
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "family", "ipv6");
else if (strcmp(value, "-1") == 0)
else if (DM_LSTRCMP(value, "-1") == 0)
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "family", "");
break;
}
@ -1068,7 +1162,7 @@ static int set_rule_dest_ip(char *refparam, struct dmctx *ctx, void *data, char
case VALUESET:
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dest_ip", &destip);
DM_STRNCPY(buf, destip, sizeof(buf));
pch = strchr(buf, '/');
pch = DM_STRCHR(buf, '/');
if (pch)
snprintf(new, sizeof(new), "%s%s", value, pch);
else
@ -1090,11 +1184,13 @@ static int set_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, cha
break;
case VALUESET:
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dest_ip", &destip);
pch = strchr(destip, '/');
pch = DM_STRCHR(destip, '/');
if (pch)
*pch = '\0';
pch = strchr(value, '/');
pch = DM_STRCHR(value, '/');
if (pch == NULL)
return FAULT_9007;
snprintf(new, sizeof(new), "%s%s", destip, pch);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "dest_ip", new);
@ -1115,7 +1211,7 @@ static int set_rule_source_ip(char *refparam, struct dmctx *ctx, void *data, cha
case VALUESET:
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_ip", &srcip);
DM_STRNCPY(buf, srcip, sizeof(buf));
pch = strchr(buf, '/');
pch = DM_STRCHR(buf, '/');
if (pch)
snprintf(new, sizeof(new), "%s%s", value, pch);
else
@ -1137,11 +1233,13 @@ static int set_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, c
break;
case VALUESET:
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_ip", &srcip);
pch = strchr(srcip, '/');
pch = DM_STRCHR(srcip, '/');
if (pch)
*pch = '\0';
pch = strchr(value, '/');
pch = DM_STRCHR(value, '/');
if (pch == NULL)
return FAULT_9007;
snprintf(new, sizeof(new), "%s%s", srcip, pch);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_ip", new);
@ -1158,7 +1256,7 @@ static int set_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "proto", (*value == '-') ? "" : value);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "proto", (*value == '-') ? "0" : value);
break;
}
return 0;
@ -1177,9 +1275,9 @@ static int set_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, cha
if (*value == '-')
value = "";
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dest_port", &v);
tmp = strchr(v, ':');
tmp = DM_STRCHR(v, ':');
if (tmp == NULL)
tmp = strchr(v, '-');
tmp = DM_STRCHR(v, '-');
if (tmp == NULL)
snprintf(buffer, sizeof(buffer), "%s", value);
else
@ -1203,9 +1301,9 @@ static int set_rule_dest_port_range_max(char *refparam, struct dmctx *ctx, void
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dest_port", &v);
buf = dmstrdup(v);
v = buf;
tmp = strchr(buf, ':');
tmp = DM_STRCHR(buf, ':');
if (tmp == NULL)
tmp = strchr(v, '-');
tmp = DM_STRCHR(v, '-');
if (tmp)
*tmp = '\0';
if (*value == '-')
@ -1232,9 +1330,9 @@ static int set_rule_source_port(char *refparam, struct dmctx *ctx, void *data, c
if (*value == '-')
value = "";
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_port", &v);
tmp = strchr(v, ':');
tmp = DM_STRCHR(v, ':');
if (tmp == NULL)
tmp = strchr(v, '-');
tmp = DM_STRCHR(v, '-');
if (tmp == NULL)
snprintf(buffer, sizeof(buffer), "%s", value);
else
@ -1258,9 +1356,9 @@ static int set_rule_source_port_range_max(char *refparam, struct dmctx *ctx, voi
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_port", &v);
buf = dmstrdup(v);
v = buf;
tmp = strchr(buf, ':');
tmp = DM_STRCHR(buf, ':');
if (tmp == NULL)
tmp = strchr(buf, '-');
tmp = DM_STRCHR(buf, '-');
if (tmp)
*tmp = '\0';
if (*value == '-')
@ -1279,77 +1377,78 @@ static int set_rule_source_port_range_max(char *refparam, struct dmctx *ctx, voi
***********************************************************************************************************************************/
/* *** Device.Firewall. *** */
DMOBJ tFirewallObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Level", &DMREAD, NULL, NULL, NULL, browseLevelInst, NULL, NULL, NULL, tFirewallLevelParams, NULL, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
{"Chain", &DMREAD, NULL, NULL, NULL, browseChainInst, NULL, NULL, tFirewallChainObj, tFirewallChainParams, NULL, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Level", &DMREAD, NULL, NULL, NULL, browseLevelInst, NULL, NULL, NULL, tFirewallLevelParams, NULL, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.2"},
{"Chain", &DMREAD, NULL, NULL, NULL, browseChainInst, NULL, NULL, tFirewallChainObj, tFirewallChainParams, NULL, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.2"},
{0}
};
DMLEAF tFirewallParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_firewall_enable, set_firewall_enable, BBFDM_BOTH},
{"Config", &DMWRITE, DMT_STRING, get_firewall_config, set_firewall_config, BBFDM_BOTH},
{"AdvancedLevel", &DMWRITE, DMT_STRING, get_firewall_advanced_level, set_firewall_advanced_level, BBFDM_BOTH},
{"LevelNumberOfEntries", &DMREAD, DMT_UNINT, get_firewall_level_number_of_entries, NULL, BBFDM_BOTH},
{"ChainNumberOfEntries", &DMREAD, DMT_UNINT, get_firewall_chain_number_of_entries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_firewall_enable, set_firewall_enable, BBFDM_BOTH, "2.2"},
{"Config", &DMWRITE, DMT_STRING, get_firewall_config, set_firewall_config, BBFDM_BOTH, "2.0"},
{"AdvancedLevel", &DMWRITE, DMT_STRING, get_firewall_advanced_level, set_firewall_advanced_level, BBFDM_BOTH, "2.2"},
{"LevelNumberOfEntries", &DMREAD, DMT_UNINT, get_firewall_level_number_of_entries, NULL, BBFDM_BOTH, "2.2"},
{"ChainNumberOfEntries", &DMREAD, DMT_UNINT, get_firewall_chain_number_of_entries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.Firewall.Level.{i}. *** */
DMLEAF tFirewallLevelParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_level_alias, set_level_alias, BBFDM_BOTH},
{"Name", &DMWRITE, DMT_STRING, get_level_name, set_level_name, BBFDM_BOTH},
{"Description", &DMWRITE, DMT_STRING, get_level_description, set_level_description, BBFDM_BOTH},
{"Chain", &DMREAD, DMT_STRING, get_level_chain, NULL, BBFDM_BOTH},
{"PortMappingEnabled", &DMWRITE, DMT_BOOL, get_level_port_mapping_enabled, set_level_port_mapping_enabled, BBFDM_BOTH},
{"DefaultLogPolicy", &DMWRITE, DMT_BOOL, get_level_default_log_policy, set_level_default_log_policy, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Alias", &DMWRITE, DMT_STRING, get_level_alias, set_level_alias, BBFDM_BOTH, "2.2"},
{"Name", &DMWRITE, DMT_STRING, get_level_name, set_level_name, BBFDM_BOTH, "2.2"},
{"Description", &DMWRITE, DMT_STRING, get_level_description, set_level_description, BBFDM_BOTH, "2.2"},
{"Chain", &DMREAD, DMT_STRING, get_level_chain, NULL, BBFDM_BOTH, "2.2"},
{"PortMappingEnabled", &DMWRITE, DMT_BOOL, get_level_port_mapping_enabled, set_level_port_mapping_enabled, BBFDM_BOTH, "2.2"},
{"DefaultPolicy", &DMWRITE, DMT_STRING, get_level_default_policy, set_level_default_policy, BBFDM_BOTH, "2.2"},
{"DefaultLogPolicy", &DMWRITE, DMT_BOOL, get_level_default_log_policy, set_level_default_log_policy, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.Firewall.Chain.{i}. *** */
DMOBJ tFirewallChainObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Rule", &DMWRITE, add_firewall_rule, delete_firewall_rule, NULL, browseRuleInst, NULL, NULL, NULL, tFirewallChainRuleParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
{0}
};
DMLEAF tFirewallChainParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_chain_enable, set_chain_enable, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_chain_alias, set_chain_alias, BBFDM_BOTH},
{"Name", &DMWRITE, DMT_STRING, get_chain_name, set_chain_name, BBFDM_BOTH},
{"Creator", &DMREAD, DMT_STRING, get_chain_creator, NULL, BBFDM_BOTH},
{"RuleNumberOfEntries", &DMREAD, DMT_UNINT, get_chain_rule_number_of_entries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_chain_enable, set_chain_enable, BBFDM_BOTH, "2.2"},
{"Alias", &DMWRITE, DMT_STRING, get_chain_alias, set_chain_alias, BBFDM_BOTH, "2.2"},
{"Name", &DMWRITE, DMT_STRING, get_chain_name, set_chain_name, BBFDM_BOTH, "2.2"},
{"Creator", &DMREAD, DMT_STRING, get_chain_creator, NULL, BBFDM_BOTH, "2.2"},
{"RuleNumberOfEntries", &DMREAD, DMT_UNINT, get_chain_rule_number_of_entries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.Firewall.Chain.{i}.Rule.{i}. *** */
DMLEAF tFirewallChainRuleParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_rule_enable, set_rule_enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_rule_status, NULL, BBFDM_BOTH},
{"Order", &DMWRITE, DMT_UNINT, get_rule_order, set_rule_order, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_rule_alias, set_rule_alias, BBFDM_BOTH},
{"Description", &DMWRITE, DMT_STRING, get_rule_description, set_rule_description, BBFDM_BOTH},
{"Target", &DMWRITE, DMT_STRING, get_rule_target, set_rule_target, BBFDM_BOTH},
//{"TargetChain", &DMWRITE, DMT_STRING, get_rule_target_chain, set_rule_target_chain, BBFDM_BOTH},
{"Log", &DMWRITE, DMT_BOOL, get_rule_log, set_rule_log, BBFDM_BOTH},
{"CreationDate", &DMREAD, DMT_TIME, get_FirewallChainRule_CreationDate, NULL, BBFDM_BOTH},
{"ExpiryDate", &DMWRITE, DMT_TIME, get_FirewallChainRule_ExpiryDate, set_FirewallChainRule_ExpiryDate, BBFDM_BOTH},
{"SourceInterface", &DMWRITE, DMT_STRING, get_rule_source_interface, set_rule_source_interface, BBFDM_BOTH},
{"SourceAllInterfaces", &DMWRITE, DMT_BOOL, get_rule_source_all_interfaces, set_rule_source_all_interfaces, BBFDM_BOTH},
{"DestInterface", &DMWRITE, DMT_STRING, get_rule_dest_interface, set_rule_dest_interface, BBFDM_BOTH},
{"DestAllInterfaces", &DMWRITE, DMT_BOOL, get_rule_dest_all_interfaces, set_rule_dest_all_interfaces, BBFDM_BOTH},
{"IPVersion", &DMWRITE, DMT_INT, get_rule_i_p_version, set_rule_i_p_version, BBFDM_BOTH},
{"DestIP", &DMWRITE, DMT_STRING, get_rule_dest_ip, set_rule_dest_ip, BBFDM_BOTH},
{"DestMask", &DMWRITE, DMT_STRING, get_rule_dest_mask, set_rule_dest_mask, BBFDM_BOTH},
{"SourceIP", &DMWRITE, DMT_STRING, get_rule_source_ip, set_rule_source_ip, BBFDM_BOTH},
{"SourceMask", &DMWRITE, DMT_STRING, get_rule_source_mask, set_rule_source_mask, BBFDM_BOTH},
{"Protocol", &DMWRITE, DMT_INT, get_rule_protocol, set_rule_protocol, BBFDM_BOTH},
{"DestPort", &DMWRITE, DMT_INT, get_rule_dest_port, set_rule_dest_port, BBFDM_BOTH},
{"DestPortRangeMax", &DMWRITE, DMT_INT, get_rule_dest_port_range_max, set_rule_dest_port_range_max, BBFDM_BOTH},
{"SourcePort", &DMWRITE, DMT_INT, get_rule_source_port, set_rule_source_port, BBFDM_BOTH},
{"SourcePortRangeMax", &DMWRITE, DMT_INT, get_rule_source_port_range_max, set_rule_source_port_range_max, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMRule, DMT_BOOL, get_rule_enable, set_rule_enable, BBFDM_BOTH, "2.2"},
{"Status", &DMRule, DMT_STRING, get_rule_status, NULL, BBFDM_BOTH, "2.2"},
{"Order", &DMWRITE, DMT_UNINT, get_rule_order, set_rule_order, BBFDM_BOTH, "2.2"},
{"Alias", &DMWRITE, DMT_STRING, get_rule_alias, set_rule_alias, BBFDM_BOTH, "2.2"},
{"Description", &DMRule, DMT_STRING, get_rule_description, set_rule_description, BBFDM_BOTH, "2.2"},
{"Target", &DMRule, DMT_STRING, get_rule_target, set_rule_target, BBFDM_BOTH, "2.2"},
//{"TargetChain", &DMRule, DMT_STRING, get_rule_target_chain, set_rule_target_chain, BBFDM_BOTH, "2.2"},
{"Log", &DMRule, DMT_BOOL, get_rule_log, set_rule_log, BBFDM_BOTH, "2.2"},
{"CreationDate", &DMRule, DMT_TIME, get_FirewallChainRule_CreationDate, NULL, BBFDM_BOTH, "2.2"},
{"ExpiryDate", &DMRule, DMT_TIME, get_FirewallChainRule_ExpiryDate, set_FirewallChainRule_ExpiryDate, BBFDM_BOTH, "2.2"},
{"SourceInterface", &DMRule, DMT_STRING, get_rule_source_interface, set_rule_source_interface, BBFDM_BOTH, "2.2"},
{"SourceAllInterfaces", &DMRule, DMT_BOOL, get_rule_source_all_interfaces, set_rule_source_all_interfaces, BBFDM_BOTH, "2.2"},
{"DestInterface", &DMRule, DMT_STRING, get_rule_dest_interface, set_rule_dest_interface, BBFDM_BOTH, "2.2"},
{"DestAllInterfaces", &DMWRITE, DMT_BOOL, get_rule_dest_all_interfaces, set_rule_dest_all_interfaces, BBFDM_BOTH, "2.2"},
{"IPVersion", &DMRule, DMT_INT, get_rule_i_p_version, set_rule_i_p_version, BBFDM_BOTH, "2.2"},
{"DestIP", &DMRule, DMT_STRING, get_rule_dest_ip, set_rule_dest_ip, BBFDM_BOTH, "2.2"},
{"DestMask", &DMRule, DMT_STRING, get_rule_dest_mask, set_rule_dest_mask, BBFDM_BOTH, "2.2"},
{"SourceIP", &DMRule, DMT_STRING, get_rule_source_ip, set_rule_source_ip, BBFDM_BOTH, "2.2"},
{"SourceMask", &DMRule, DMT_STRING, get_rule_source_mask, set_rule_source_mask, BBFDM_BOTH, "2.2"},
{"Protocol", &DMRule, DMT_INT, get_rule_protocol, set_rule_protocol, BBFDM_BOTH, "2.2"},
{"DestPort", &DMRule, DMT_INT, get_rule_dest_port, set_rule_dest_port, BBFDM_BOTH, "2.2"},
{"DestPortRangeMax", &DMRule, DMT_INT, get_rule_dest_port_range_max, set_rule_dest_port_range_max, BBFDM_BOTH, "2.2"},
{"SourcePort", &DMRule, DMT_INT, get_rule_source_port, set_rule_source_port, BBFDM_BOTH, "2.2"},
{"SourcePortRangeMax", &DMRule, DMT_INT, get_rule_source_port_range_max, set_rule_source_port_range_max, BBFDM_BOTH, "2.2"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef _FIREWALL_H
#define _FIREWALL_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tFirewallObj[];
extern DMLEAF tFirewallParams[];

View file

@ -147,7 +147,7 @@ static int delObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *dat
dmuci_get_value_by_section_string(s, "device", &device);
snprintf(device_buf, sizeof(device_buf), "@%s", section_name(((struct dmmap_dup *)data)->config_section));
if (!device || strcmp(device, device_buf) != 0)
if (!device || DM_STRCMP(device, device_buf) != 0)
continue;
get_dmmap_section_of_config_section("dmmap_network", "interface", section_name(s), &dmmap_section);
@ -352,105 +352,105 @@ static int get_GRETunnelInterfaceStats_ErrorsReceived(char *refparam, struct dmc
***********************************************************************************************************************************/
/* *** Device.GRE. *** */
DMOBJ tGREObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Tunnel", &DMWRITE, addObjGRETunnel, delObjGRETunnel, NULL, browseGRETunnelInst, NULL, NULL, tGRETunnelObj, tGRETunnelParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
//{"Filter", &DMWRITE, addObjGREFilter, delObjGREFilter, NULL, browseGREFilterInst, NULL, NULL, NULL, tGREFilterParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Tunnel", &DMWRITE, addObjGRETunnel, delObjGRETunnel, NULL, browseGRETunnelInst, NULL, NULL, tGRETunnelObj, tGRETunnelParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}, "2.8"},
//{"Filter", &DMWRITE, addObjGREFilter, delObjGREFilter, NULL, browseGREFilterInst, NULL, NULL, NULL, tGREFilterParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}, "2.8"},
{0}
};
DMLEAF tGREParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"TunnelNumberOfEntries", &DMREAD, DMT_UNINT, get_GRE_TunnelNumberOfEntries, NULL, BBFDM_BOTH},
//{"FilterNumberOfEntries", &DMREAD, DMT_UNINT, get_GRE_FilterNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version, version*/
{"TunnelNumberOfEntries", &DMREAD, DMT_UNINT, get_GRE_TunnelNumberOfEntries, NULL, BBFDM_BOTH, "2.8"},
//{"FilterNumberOfEntries", &DMREAD, DMT_UNINT, get_GRE_FilterNumberOfEntries, NULL, BBFDM_BOTH, "2.8"},
{0}
};
/* *** Device.GRE.Tunnel.{i}. *** */
DMOBJ tGRETunnelObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tGRETunnelStatsParams, NULL, BBFDM_BOTH},
{"Interface", &DMWRITE, addObjGRETunnelInterface, delObjGRETunnelInterface, NULL, browseGRETunnelInterfaceInst, NULL, NULL, tGRETunnelInterfaceObj, tGRETunnelInterfaceParams, NULL, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tGRETunnelStatsParams, NULL, BBFDM_BOTH, NULL, "2.8"},
{"Interface", &DMWRITE, addObjGRETunnelInterface, delObjGRETunnelInterface, NULL, browseGRETunnelInterfaceInst, NULL, NULL, tGRETunnelInterfaceObj, tGRETunnelInterfaceParams, NULL, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.8"},
{0}
};
DMLEAF tGRETunnelParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"Enable", &DMWRITE, DMT_BOOL, get_GRETunnel_Enable, set_GRETunnel_Enable, BBFDM_BOTH},
//{"Status", &DMREAD, DMT_STRING, get_GRETunnel_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_GRETunnel_Alias, set_GRETunnel_Alias, BBFDM_BOTH},
//{"RemoteEndpoints", &DMWRITE, DMT_STRING, get_GRETunnel_RemoteEndpoints, set_GRETunnel_RemoteEndpoints, BBFDM_BOTH},
//{"KeepAlivePolicy", &DMWRITE, DMT_STRING, get_GRETunnel_KeepAlivePolicy, set_GRETunnel_KeepAlivePolicy, BBFDM_BOTH},
//{"KeepAliveTimeout", &DMWRITE, DMT_UNINT, get_GRETunnel_KeepAliveTimeout, set_GRETunnel_KeepAliveTimeout, BBFDM_BOTH},
{"KeepAliveThreshold", &DMWRITE, DMT_UNINT, get_GRETunnel_KeepAliveThreshold, set_GRETunnel_KeepAliveThreshold, BBFDM_BOTH},
//{"DeliveryHeaderProtocol", &DMWRITE, DMT_STRING, get_GRETunnel_DeliveryHeaderProtocol, set_GRETunnel_DeliveryHeaderProtocol, BBFDM_BOTH},
//{"DefaultDSCPMark", &DMWRITE, DMT_UNINT, get_GRETunnel_DefaultDSCPMark, set_GRETunnel_DefaultDSCPMark, BBFDM_BOTH},
{"ConnectedRemoteEndpoint", &DMREAD, DMT_STRING, get_GRETunnel_ConnectedRemoteEndpoint, NULL, BBFDM_BOTH},
{"InterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_GRETunnel_InterfaceNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"Enable", &DMWRITE, DMT_BOOL, get_GRETunnel_Enable, set_GRETunnel_Enable, BBFDM_BOTH, "2.8"},
//{"Status", &DMREAD, DMT_STRING, get_GRETunnel_Status, NULL, BBFDM_BOTH, "2.8"},
{"Alias", &DMWRITE, DMT_STRING, get_GRETunnel_Alias, set_GRETunnel_Alias, BBFDM_BOTH, "2.8"},
//{"RemoteEndpoints", &DMWRITE, DMT_STRING, get_GRETunnel_RemoteEndpoints, set_GRETunnel_RemoteEndpoints, BBFDM_BOTH, "2.8"},
//{"KeepAlivePolicy", &DMWRITE, DMT_STRING, get_GRETunnel_KeepAlivePolicy, set_GRETunnel_KeepAlivePolicy, BBFDM_BOTH, "2.8"},
//{"KeepAliveTimeout", &DMWRITE, DMT_UNINT, get_GRETunnel_KeepAliveTimeout, set_GRETunnel_KeepAliveTimeout, BBFDM_BOTH, "2.8"},
{"KeepAliveThreshold", &DMWRITE, DMT_UNINT, get_GRETunnel_KeepAliveThreshold, set_GRETunnel_KeepAliveThreshold, BBFDM_BOTH, "2.8"},
//{"DeliveryHeaderProtocol", &DMWRITE, DMT_STRING, get_GRETunnel_DeliveryHeaderProtocol, set_GRETunnel_DeliveryHeaderProtocol, BBFDM_BOTH, "2.8"},
//{"DefaultDSCPMark", &DMWRITE, DMT_UNINT, get_GRETunnel_DefaultDSCPMark, set_GRETunnel_DefaultDSCPMark, BBFDM_BOTH, "2.8"},
{"ConnectedRemoteEndpoint", &DMREAD, DMT_STRING, get_GRETunnel_ConnectedRemoteEndpoint, NULL, BBFDM_BOTH, "2.8"},
{"InterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_GRETunnel_InterfaceNumberOfEntries, NULL, BBFDM_BOTH, "2.8"},
{0}
};
/* *** Device.GRE.Tunnel.{i}.Stats. *** */
DMLEAF tGRETunnelStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"KeepAliveSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_KeepAliveSent, NULL, BBFDM_BOTH},
//{"KeepAliveReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_KeepAliveReceived, NULL, BBFDM_BOTH},
{"BytesSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_BytesSent, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_BytesReceived, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_PacketsSent, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_PacketsReceived, NULL, BBFDM_BOTH},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_ErrorsSent, NULL, BBFDM_BOTH},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_ErrorsReceived, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"KeepAliveSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_KeepAliveSent, NULL, BBFDM_BOTH, "2.8"},
//{"KeepAliveReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_KeepAliveReceived, NULL, BBFDM_BOTH, "2.8"},
{"BytesSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_BytesSent, NULL, BBFDM_BOTH, "2.8"},
{"BytesReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_BytesReceived, NULL, BBFDM_BOTH, "2.8"},
{"PacketsSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_PacketsSent, NULL, BBFDM_BOTH, "2.8"},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_PacketsReceived, NULL, BBFDM_BOTH, "2.8"},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_GRETunnelStats_ErrorsSent, NULL, BBFDM_BOTH, "2.8"},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_GRETunnelStats_ErrorsReceived, NULL, BBFDM_BOTH, "2.8"},
{0}
};
/* *** Device.GRE.Tunnel.{i}.Interface.{i}. *** */
DMOBJ tGRETunnelInterfaceObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tGRETunnelInterfaceStatsParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tGRETunnelInterfaceStatsParams, NULL, BBFDM_BOTH, NULL, "2.8"},
{0}
};
DMLEAF tGRETunnelInterfaceParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"Enable", &DMWRITE, DMT_BOOL, get_GRETunnelInterface_Enable, set_GRETunnelInterface_Enable, BBFDM_BOTH},
//{"Status", &DMREAD, DMT_STRING, get_GRETunnelInterface_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_GRETunnelInterface_Alias, set_GRETunnelInterface_Alias, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_GRETunnelInterface_Name, NULL, BBFDM_BOTH},
//{"LastChange", &DMREAD, DMT_UNINT, get_GRETunnelInterface_LastChange, NULL, BBFDM_BOTH},
//{"LowerLayers", &DMWRITE, DMT_STRING, get_GRETunnelInterface_LowerLayers, set_GRETunnelInterface_LowerLayers, BBFDM_BOTH},
//{"ProtocolIdOverride", &DMWRITE, DMT_UNINT, get_GRETunnelInterface_ProtocolIdOverride, set_GRETunnelInterface_ProtocolIdOverride, BBFDM_BOTH},
//{"UseChecksum", &DMWRITE, DMT_BOOL, get_GRETunnelInterface_UseChecksum, set_GRETunnelInterface_UseChecksum, BBFDM_BOTH},
//{"KeyIdentifierGenerationPolicy", &DMWRITE, DMT_STRING, get_GRETunnelInterface_KeyIdentifierGenerationPolicy, set_GRETunnelInterface_KeyIdentifierGenerationPolicy, BBFDM_BOTH},
//{"KeyIdentifier", &DMWRITE, DMT_UNINT, get_GRETunnelInterface_KeyIdentifier, set_GRETunnelInterface_KeyIdentifier, BBFDM_BOTH},
//{"UseSequenceNumber", &DMWRITE, DMT_BOOL, get_GRETunnelInterface_UseSequenceNumber, set_GRETunnelInterface_UseSequenceNumber, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"Enable", &DMWRITE, DMT_BOOL, get_GRETunnelInterface_Enable, set_GRETunnelInterface_Enable, BBFDM_BOTH, "2.8"},
//{"Status", &DMREAD, DMT_STRING, get_GRETunnelInterface_Status, NULL, BBFDM_BOTH, "2.8"},
{"Alias", &DMWRITE, DMT_STRING, get_GRETunnelInterface_Alias, set_GRETunnelInterface_Alias, BBFDM_BOTH, "2.8"},
{"Name", &DMREAD, DMT_STRING, get_GRETunnelInterface_Name, NULL, BBFDM_BOTH, "2.8"},
//{"LastChange", &DMREAD, DMT_UNINT, get_GRETunnelInterface_LastChange, NULL, BBFDM_BOTH, "2.8"},
//{"LowerLayers", &DMWRITE, DMT_STRING, get_GRETunnelInterface_LowerLayers, set_GRETunnelInterface_LowerLayers, BBFDM_BOTH, "2.8"},
//{"ProtocolIdOverride", &DMWRITE, DMT_UNINT, get_GRETunnelInterface_ProtocolIdOverride, set_GRETunnelInterface_ProtocolIdOverride, BBFDM_BOTH, "2.8"},
//{"UseChecksum", &DMWRITE, DMT_BOOL, get_GRETunnelInterface_UseChecksum, set_GRETunnelInterface_UseChecksum, BBFDM_BOTH, "2.8"},
//{"KeyIdentifierGenerationPolicy", &DMWRITE, DMT_STRING, get_GRETunnelInterface_KeyIdentifierGenerationPolicy, set_GRETunnelInterface_KeyIdentifierGenerationPolicy, BBFDM_BOTH, "2.8"},
//{"KeyIdentifier", &DMWRITE, DMT_UNINT, get_GRETunnelInterface_KeyIdentifier, set_GRETunnelInterface_KeyIdentifier, BBFDM_BOTH, "2.8"},
//{"UseSequenceNumber", &DMWRITE, DMT_BOOL, get_GRETunnelInterface_UseSequenceNumber, set_GRETunnelInterface_UseSequenceNumber, BBFDM_BOTH, "2.8"},
{0}
};
/* *** Device.GRE.Tunnel.{i}.Interface.{i}.Stats. *** */
DMLEAF tGRETunnelInterfaceStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_BytesSent, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_BytesReceived, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_PacketsSent, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_PacketsReceived, NULL, BBFDM_BOTH},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_ErrorsSent, NULL, BBFDM_BOTH},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_ErrorsReceived, NULL, BBFDM_BOTH},
//{"DiscardChecksumReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_DiscardChecksumReceived, NULL, BBFDM_BOTH},
//{"DiscardSequenceNumberReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_DiscardSequenceNumberReceived, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"BytesSent", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_BytesSent, NULL, BBFDM_BOTH, "2.8"},
{"BytesReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_BytesReceived, NULL, BBFDM_BOTH, "2.8"},
{"PacketsSent", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_PacketsSent, NULL, BBFDM_BOTH, "2.8"},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_PacketsReceived, NULL, BBFDM_BOTH, "2.8"},
{"ErrorsSent", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_ErrorsSent, NULL, BBFDM_BOTH, "2.8"},
{"ErrorsReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_ErrorsReceived, NULL, BBFDM_BOTH, "2.8"},
//{"DiscardChecksumReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_DiscardChecksumReceived, NULL, BBFDM_BOTH, "2.8"},
//{"DiscardSequenceNumberReceived", &DMREAD, DMT_UNINT, get_GRETunnelInterfaceStats_DiscardSequenceNumberReceived, NULL, BBFDM_BOTH, "2.8"},
{0}
};
/* *** Device.GRE.Filter.{i}. *** */
DMLEAF tGREFilterParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"Enable", &DMWRITE, DMT_BOOL, get_GREFilter_Enable, set_GREFilter_Enable, BBFDM_BOTH},
//{"Status", &DMREAD, DMT_STRING, get_GREFilter_Status, NULL, BBFDM_BOTH},
//{"Order", &DMWRITE, DMT_UNINT, get_GREFilter_Order, set_GREFilter_Order, BBFDM_BOTH},
//{"Alias", &DMWRITE, DMT_STRING, get_GREFilter_Alias, set_GREFilter_Alias, BBFDM_BOTH},
//{"Interface", &DMWRITE, DMT_STRING, get_GREFilter_Interface, set_GREFilter_Interface, BBFDM_BOTH},
//{"AllInterfaces", &DMWRITE, DMT_BOOL, get_GREFilter_AllInterfaces, set_GREFilter_AllInterfaces, BBFDM_BOTH},
//{"VLANIDCheck", &DMWRITE, DMT_INT, get_GREFilter_VLANIDCheck, set_GREFilter_VLANIDCheck, BBFDM_BOTH},
//{"VLANIDExclude", &DMWRITE, DMT_BOOL, get_GREFilter_VLANIDExclude, set_GREFilter_VLANIDExclude, BBFDM_BOTH},
//{"DSCPMarkPolicy", &DMWRITE, DMT_INT, get_GREFilter_DSCPMarkPolicy, set_GREFilter_DSCPMarkPolicy, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"Enable", &DMWRITE, DMT_BOOL, get_GREFilter_Enable, set_GREFilter_Enable, BBFDM_BOTH, "2.8"},
//{"Status", &DMREAD, DMT_STRING, get_GREFilter_Status, NULL, BBFDM_BOTH, "2.8"},
//{"Order", &DMWRITE, DMT_UNINT, get_GREFilter_Order, set_GREFilter_Order, BBFDM_BOTH, "2.8"},
//{"Alias", &DMWRITE, DMT_STRING, get_GREFilter_Alias, set_GREFilter_Alias, BBFDM_BOTH, "2.8"},
//{"Interface", &DMWRITE, DMT_STRING, get_GREFilter_Interface, set_GREFilter_Interface, BBFDM_BOTH, "2.8"},
//{"AllInterfaces", &DMWRITE, DMT_BOOL, get_GREFilter_AllInterfaces, set_GREFilter_AllInterfaces, BBFDM_BOTH, "2.8"},
//{"VLANIDCheck", &DMWRITE, DMT_INT, get_GREFilter_VLANIDCheck, set_GREFilter_VLANIDCheck, BBFDM_BOTH, "2.8"},
//{"VLANIDExclude", &DMWRITE, DMT_BOOL, get_GREFilter_VLANIDExclude, set_GREFilter_VLANIDExclude, BBFDM_BOTH, "2.8"},
//{"DSCPMarkPolicy", &DMWRITE, DMT_INT, get_GREFilter_DSCPMarkPolicy, set_GREFilter_DSCPMarkPolicy, BBFDM_BOTH, "2.8"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __GRE_H
#define __GRE_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tGREObj[];
extern DMLEAF tGREParams[];

View file

@ -9,7 +9,6 @@
*/
#include "hosts.h"
#include "dmentry.h"
/*************************************************************
* ENTRY METHOD
@ -21,7 +20,7 @@ static int browseHostsHostInst(struct dmctx *dmctx, DMNODE *parent_node, void *p
char *inst = NULL;
int id = 0, i = 0;
dmubus_call("topology", "hosts", UBUS_ARGS{}, 0, &res);
dmubus_call("topology", "hosts", UBUS_ARGS{0}, 0, &res);
dmjson_foreach_obj_in_array(res, arrobj, host_obj, i, 1, "hosts") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)host_obj, inst) == DM_STOP)
@ -98,17 +97,15 @@ static int get_HostsHost_DHCPClient(char *refparam, struct dmctx *ctx, void *dat
{
char *linker = dmjson_get_value((json_object *)data, 1, "macaddr");
adm_entry_get_linker_param(ctx, "Device.DHCPv4.Server.Pool.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
static int get_HostsHost_AssociatedDevice(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker = dmjson_get_value((json_object *)data, 1, "macaddr");
char *linker = dmjson_get_value((json_object *)data, 1, "link_macaddr");
adm_entry_get_linker_param(ctx, "Device.WiFi.AccessPoint.", linker, value);
if (*value == NULL)
*value = "";
if (!(*value) || (*value)[0] == 0)
adm_entry_get_linker_param(ctx, "Device.WiFi.DataElements.Network.Device.", linker, value);
return 0;
}
@ -116,12 +113,16 @@ static int get_HostsHost_Layer1Interface(char *refparam, struct dmctx *ctx, void
{
char *linker = dmjson_get_value((json_object *)data, 1, "device");
char *type = dmjson_get_value((json_object *)data, 1, "interface_type");
if (strcmp(type, "Wi-Fi") == 0)
if (DM_LSTRCMP(type, "Wi-Fi") == 0) {
adm_entry_get_linker_param(ctx, "Device.WiFi.Radio.", linker, value);
else
if (!(*value) || (*value)[0] == 0) {
char *device = dmjson_get_value((json_object *)data, 1, "parent_device");
struct uci_section *iface_s = get_dup_section_in_config_opt("wireless", "wifi-iface", "ifname", device);
dmuci_get_value_by_section_string(iface_s, "device", &linker);
adm_entry_get_linker_param(ctx, "Device.WiFi.Radio.", linker, value);
}
} else
adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
@ -129,8 +130,6 @@ static int get_HostsHost_Layer3Interface(char *refparam, struct dmctx *ctx, void
{
char *linker = dmjson_get_value((json_object *)data, 1, "network");
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
@ -225,63 +224,63 @@ static int get_HostsHostWANStats_PacketsReceived(char *refparam, struct dmctx *c
***********************************************************************************************************************************/
/* *** Device.Hosts. *** */
DMOBJ tHostsObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Host", &DMREAD, NULL, NULL, NULL, browseHostsHostInst, NULL, NULL, tHostsHostObj, tHostsHostParams, get_linker_host, BBFDM_BOTH, LIST_KEY{"PhysAddress", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Host", &DMREAD, NULL, NULL, NULL, browseHostsHostInst, NULL, NULL, tHostsHostObj, tHostsHostParams, get_linker_host, BBFDM_BOTH, LIST_KEY{"PhysAddress", NULL}, "2.0"},
{0}
};
DMLEAF tHostsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"HostNumberOfEntries", &DMREAD, DMT_UNINT, get_Hosts_HostNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"HostNumberOfEntries", &DMREAD, DMT_UNINT, get_Hosts_HostNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.Hosts.Host.{i}. *** */
DMOBJ tHostsHostObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"IPv4Address", &DMREAD, NULL, NULL, NULL, browseHostsHostIPv4AddressInst, NULL, NULL, NULL, tHostsHostIPv4AddressParams, NULL, BBFDM_BOTH, LIST_KEY{"IPAddress", NULL}},
{"IPv6Address", &DMREAD, NULL, NULL, NULL, browseHostsHostIPv6AddressInst, NULL, NULL, NULL, tHostsHostIPv6AddressParams, NULL, BBFDM_BOTH, LIST_KEY{"IPAddress", NULL}},
{"WANStats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tHostsHostWANStatsParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"IPv4Address", &DMREAD, NULL, NULL, NULL, browseHostsHostIPv4AddressInst, NULL, NULL, NULL, tHostsHostIPv4AddressParams, NULL, BBFDM_BOTH, LIST_KEY{"IPAddress", NULL}, "2.2"},
{"IPv6Address", &DMREAD, NULL, NULL, NULL, browseHostsHostIPv6AddressInst, NULL, NULL, NULL, tHostsHostIPv6AddressParams, NULL, BBFDM_BOTH, LIST_KEY{"IPAddress", NULL}, "2.2"},
{"WANStats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tHostsHostWANStatsParams, NULL, BBFDM_BOTH, NULL, "2.12"},
{0}
};
DMLEAF tHostsHostParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"PhysAddress", &DMREAD, DMT_STRING, get_HostsHost_PhysAddress, NULL, BBFDM_BOTH},
{"IPAddress", &DMREAD, DMT_STRING, get_HostsHost_IPAddress, NULL, BBFDM_BOTH},
{"DHCPClient", &DMREAD, DMT_STRING, get_HostsHost_DHCPClient, NULL, BBFDM_BOTH},
{"AssociatedDevice", &DMREAD, DMT_STRING, get_HostsHost_AssociatedDevice, NULL, BBFDM_BOTH},
{"Layer1Interface", &DMREAD, DMT_STRING, get_HostsHost_Layer1Interface, NULL, BBFDM_BOTH},
{"Layer3Interface", &DMREAD, DMT_STRING, get_HostsHost_Layer3Interface, NULL, BBFDM_BOTH},
{"InterfaceType", &DMREAD, DMT_STRING, get_HostsHost_InterfaceType, NULL, BBFDM_BOTH},
{"HostName", &DMREAD, DMT_STRING, get_HostsHost_HostName, NULL, BBFDM_BOTH},
{"Active", &DMREAD, DMT_BOOL, get_HostsHost_Active, NULL, BBFDM_BOTH},
{"ActiveLastChange", &DMREAD, DMT_TIME, get_HostsHost_ActiveLastChange, NULL, BBFDM_BOTH},
{"IPv4AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_HostsHost_IPv4AddressNumberOfEntries, NULL, BBFDM_BOTH},
{"IPv6AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_HostsHost_IPv6AddressNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"PhysAddress", &DMREAD, DMT_STRING, get_HostsHost_PhysAddress, NULL, BBFDM_BOTH, "2.0"},
{"IPAddress", &DMREAD, DMT_STRING, get_HostsHost_IPAddress, NULL, BBFDM_BOTH, "2.0"},
{"DHCPClient", &DMREAD, DMT_STRING, get_HostsHost_DHCPClient, NULL, BBFDM_BOTH, "2.0"},
{"AssociatedDevice", &DMREAD, DMT_STRING, get_HostsHost_AssociatedDevice, NULL, BBFDM_BOTH, "2.2"},
{"Layer1Interface", &DMREAD, DMT_STRING, get_HostsHost_Layer1Interface, NULL, BBFDM_BOTH, "2.0"},
{"Layer3Interface", &DMREAD, DMT_STRING, get_HostsHost_Layer3Interface, NULL, BBFDM_BOTH, "2.0"},
{"InterfaceType", &DMREAD, DMT_STRING, get_HostsHost_InterfaceType, NULL, BBFDM_BOTH, "2.0"},
{"HostName", &DMREAD, DMT_STRING, get_HostsHost_HostName, NULL, BBFDM_BOTH, "2.0"},
{"Active", &DMREAD, DMT_BOOL, get_HostsHost_Active, NULL, BBFDM_BOTH, "2.0"},
{"ActiveLastChange", &DMREAD, DMT_TIME, get_HostsHost_ActiveLastChange, NULL, BBFDM_BOTH, "2.10"},
{"IPv4AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_HostsHost_IPv4AddressNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{"IPv6AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_HostsHost_IPv6AddressNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.Hosts.Host.{i}.IPv4Address.{i}. *** */
DMLEAF tHostsHostIPv4AddressParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"IPAddress", &DMREAD, DMT_STRING, get_HostsHostIPv4Address_IPAddress, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"IPAddress", &DMREAD, DMT_STRING, get_HostsHostIPv4Address_IPAddress, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.Hosts.Host.{i}.IPv6Address.{i}. *** */
DMLEAF tHostsHostIPv6AddressParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"IPAddress", &DMREAD, DMT_STRING, get_HostsHostIPv6Address_IPAddress, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"IPAddress", &DMREAD, DMT_STRING, get_HostsHostIPv6Address_IPAddress, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.Hosts.Host.{i}.WANStats. *** */
DMLEAF tHostsHostWANStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNINT, get_HostsHostWANStats_BytesSent, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNINT, get_HostsHostWANStats_BytesReceived, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, get_HostsHostWANStats_PacketsSent, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_HostsHostWANStats_PacketsReceived, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"BytesSent", &DMREAD, DMT_UNINT, get_HostsHostWANStats_BytesSent, NULL, BBFDM_BOTH, "2.12"},
{"BytesReceived", &DMREAD, DMT_UNINT, get_HostsHostWANStats_BytesReceived, NULL, BBFDM_BOTH, "2.12"},
{"PacketsSent", &DMREAD, DMT_UNINT, get_HostsHostWANStats_PacketsSent, NULL, BBFDM_BOTH, "2.12"},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_HostsHostWANStats_PacketsReceived, NULL, BBFDM_BOTH, "2.12"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __HOSTS_H
#define __HOSTS_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tHostsObj[];
extern DMLEAF tHostsParams[];

View file

@ -9,9 +9,23 @@
* Author: Nevadita Chatterjee <nevadita.chatterjee@iopsys.eu>
*/
#include "dmentry.h"
#include "ieee1905.h"
struct ieee1905_device_nonieee1905neighbor_args
{
char *mac_addr;
char *neighbor;
};
/**************************************************************************
* LINKER
***************************************************************************/
static int get_linker_IEEE1905Device(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{
*linker = dmjson_get_value((json_object *)data, 1, "ieee1905id");
return 0;
}
/*************************************************************
* ENTRY METHOD
**************************************************************/
@ -22,7 +36,7 @@ static int browseIEEE1905ALInterfaceInst(struct dmctx *dmctx, DMNODE *parent_nod
char *inst = NULL;
int id = 0, i = 0;
dmubus_call("ieee1905", "info", UBUS_ARGS{}, 0, &res);
dmubus_call("ieee1905", "info", UBUS_ARGS{0}, 0, &res);
dmjson_foreach_obj_in_array(res, arrobj, interface_obj, i, 1, "interface") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)interface_obj, inst) == DM_STOP)
@ -95,7 +109,7 @@ static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceInst(struct dmctx *dmctx
char *inst = NULL;
int id = 0, i = 0;
dmubus_call("ieee1905", "info", UBUS_ARGS{}, 0, &res);
dmubus_call("ieee1905", "info", UBUS_ARGS{0}, 0, &res);
dmjson_foreach_obj_in_array(res, arrobj, device_obj, i, 2, "topology", "device") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)device_obj, inst) == DM_STOP)
@ -168,13 +182,22 @@ static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceInterfaceInst(struct dmc
static int browseIEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905NeighborInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *arrobj = NULL, *non1905_neighbor = NULL, *device = (json_object *)prev_data;
struct ieee1905_device_nonieee1905neighbor_args curr_nonieee1905neighbor_args = {0};
char *inst = NULL;
int id = 0, i = 0;
dmjson_foreach_obj_in_array(device, arrobj, non1905_neighbor, i, 1, "non1905_neighbors") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)non1905_neighbor, inst) == DM_STOP)
break;
json_object *neighbor_val = NULL;
char *neighbor = NULL;
int j = 0;
curr_nonieee1905neighbor_args.mac_addr = dmjson_get_value(non1905_neighbor, 1, "interface_macaddress");
dmjson_foreach_value_in_array(non1905_neighbor, neighbor_val, neighbor, j, 1, "neighbors") {
curr_nonieee1905neighbor_args.neighbor = neighbor;
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_nonieee1905neighbor_args, inst) == DM_STOP)
break;
}
}
return 0;
}
@ -286,7 +309,7 @@ static int get_linker_topology_interface(char *refparam, struct dmctx *dmctx, vo
static int ubus_ieee1905_info(const char *option, char **value)
{
json_object *res = NULL;
dmubus_call("ieee1905", "info", UBUS_ARGS{}, 0, &res);
dmubus_call("ieee1905", "info", UBUS_ARGS{0}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, option);
return 0;
@ -295,7 +318,7 @@ static int ubus_ieee1905_info(const char *option, char **value)
static int ubus_ieee1905_info_options(const char *option1, const char *option2, char **value)
{
json_object *res = NULL;
dmubus_call("ieee1905", "info", UBUS_ARGS{}, 0, &res);
dmubus_call("ieee1905", "info", UBUS_ARGS{0}, 0, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 2, option1, option2);
return 0;
@ -303,35 +326,35 @@ static int ubus_ieee1905_info_options(const char *option1, const char *option2,
static char *get_datamodel_media_type(const char *media)
{
if (!strcmp(media, "IEEE 802_3U_FAST_ETHERNET"))
if (!DM_LSTRCMP(media, "IEEE 802_3U_FAST_ETHERNET"))
return "IEEE 802.3u";
else if (!strcmp(media, "IEEE 802_3AB_GIGABIT_ETHERNET"))
else if (!DM_LSTRCMP(media, "IEEE 802_3AB_GIGABIT_ETHERNET"))
return "IEEE 802.3ab";
else if (!strcmp(media, "IEEE 802_11B_2_4_GHZ"))
else if (!DM_LSTRCMP(media, "IEEE 802_11B_2_4_GHZ"))
return "IEEE 802.11b";
else if (!strcmp(media, "IEEE 802_11G_2_4_GHZ"))
else if (!DM_LSTRCMP(media, "IEEE 802_11G_2_4_GHZ"))
return "IEEE 802.11g";
else if (!strcmp(media, "IEEE 802_11A_5_GHZ"))
else if (!DM_LSTRCMP(media, "IEEE 802_11A_5_GHZ"))
return "IEEE 802.11a";
else if (!strcmp(media, "IEEE 802_11N_2_4_GHZ"))
else if (!DM_LSTRCMP(media, "IEEE 802_11N_2_4_GHZ"))
return "IEEE 802.11n 2.4";
else if (!strcmp(media, "IEEE 802_11N_5_GHZ"))
else if (!DM_LSTRCMP(media, "IEEE 802_11N_5_GHZ"))
return "IEEE 802.11n 5.0";
else if (!strcmp(media, "IEEE 802_11AC_5_GHZ"))
else if (!DM_LSTRCMP(media, "IEEE 802_11AC_5_GHZ"))
return "IEEE 802.11ac";
else if (!strcmp(media, "IEEE 802_11AX_2_4_GHZ"))
else if (!DM_LSTRCMP(media, "IEEE 802_11AX_2_4_GHZ"))
return "IEEE 802.11ax 2.4";
else if (!strcmp(media, "IEEE 802_11AX_5_GHZ"))
else if (!DM_LSTRCMP(media, "IEEE 802_11AX_5_GHZ"))
return "IEEE 802.11ax 5.0";
else if (!strcmp(media, "IEEE 802_11AD_60_GHZ"))
else if (!DM_LSTRCMP(media, "IEEE 802_11AD_60_GHZ"))
return "IEEE 802.11ad";
else if (!strcmp(media, "IEEE 802_11AF_GHZ"))
else if (!DM_LSTRCMP(media, "IEEE 802_11AF_GHZ"))
return "IEEE 802.11af";
else if (!strcmp(media, "IEEE 1901_WAVELET"))
else if (!DM_LSTRCMP(media, "IEEE 1901_WAVELET"))
return "IEEE 1901 Wavelet";
else if (!strcmp(media, "IEEE 1901_FFT"))
else if (!DM_LSTRCMP(media, "IEEE 1901_FFT"))
return "IEEE 1901 FFT";
else if (!strcmp(media, "IEEE MOCA_V1_1"))
else if (!DM_LSTRCMP(media, "IEEE MOCA_V1_1"))
return "MoCAv1.1";
else
return (char *)media;
@ -379,7 +402,7 @@ static int get_IEEE1905AL_RegistrarFreqBand(char *refparam, struct dmctx *ctx, v
char list_bands[64], *band = NULL;
unsigned pos = 0, idx = 0;
dmubus_call("ieee1905", "info", UBUS_ARGS{}, 0, &res);
dmubus_call("ieee1905", "info", UBUS_ARGS{0}, 0, &res);
DM_ASSERT(res, *value = "");
list_bands[0] = 0;
@ -415,6 +438,20 @@ static int get_IEEE1905ALInterface_Status(char *refparam, struct dmctx *ctx, voi
return 0;
}
/*#Device.IEEE1905.AL.Interface.{i}.LowerLayers!UBUS:ieee1905/info//interface[@i-1].ifname*/
static int get_IEEE1905ALInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker = dmjson_get_value((json_object *)data, 1, "ifname");
adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", linker, value);
if (!(*value) || (*value)[0] == 0)
adm_entry_get_linker_param(ctx, "Device.WiFi.AccessPoint.", linker, value);
if (!(*value) || (*value)[0] == 0)
adm_entry_get_linker_param(ctx, "Device.WiFi.Radio.", linker, value);
return 0;
}
#if 0
static int get_IEEE1905ALInterface_InterfaceStackReference(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
@ -645,6 +682,7 @@ static int get_IEEE1905ALForwardingTable_SetForwardingEnabled(char *refparam, st
static int set_IEEE1905ALForwardingTable_SetForwardingEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int res = 0;
bool b;
switch (action) {
@ -654,7 +692,14 @@ static int set_IEEE1905ALForwardingTable_SetForwardingEnabled(char *refparam, st
break;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value("ieee1905", "forwarding_table", "forwarding_enabled", b ? "1" : "0");
res = dmuci_set_value("ieee1905", "forwarding_table", "forwarding_enabled", b ? "1" : "0");
if (res) {
struct uci_section *s = NULL;
dmuci_add_section("ieee1905", "forwarding_table", &s);
dmuci_rename_section_by_section(s, "forwarding_table");
dmuci_set_value("ieee1905", "forwarding_table", "forwarding_enabled", b ? "1" : "0");
}
break;
}
return 0;
@ -1112,7 +1157,8 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905Device_InterfaceNumberOfEntries(
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.NonIEEE1905NeighborNumberOfEntries!UBUS:ieee1905/info//topology.device[@i-1].num_neighbor_non1905*/
static int get_IEEE1905ALNetworkTopologyIEEE1905Device_NonIEEE1905NeighborNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value((json_object *)data, 1, "num_neighbor_non1905");
int cnt = get_number_of_entries(ctx, data, instance, browseIEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905NeighborInst);
dmasprintf(value, "%d", cnt);
return 0;
}
@ -1272,15 +1318,15 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_Role(char *refpa
{
char *role = dmjson_get_value((json_object *)data, 1, "role");
if (!strcmp(role, "ap"))
if (!DM_LSTRCMP(role, "ap"))
*value = "AP";
else if (!strcmp(role, "sta"))
else if (!DM_LSTRCMP(role, "sta"))
*value = "non-AP/non-PCP STA";
else if (!strcmp(role, "p2p_client"))
else if (!DM_LSTRCMP(role, "p2p_client"))
*value = "Wi-Fi P2P Client";
else if (!strcmp(role, "p2p_go"))
else if (!DM_LSTRCMP(role, "p2p_go"))
*value = "Wi-Fi P2P Group Owner";
else if (!strcmp(role, "pcp"))
else if (!DM_LSTRCMP(role, "pcp"))
*value = "802.11adPCP";
else
*value = role;
@ -1292,7 +1338,7 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_Role(char *refpa
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_APChannelBand(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *val = dmjson_get_value((json_object *)data, 1, "bandwidth");
int bw = atoi(val);
int bw = DM_STRTOL(val);
switch (bw) {
case 20:
@ -1322,7 +1368,7 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_FrequencyIndex1(
{
char *val = dmjson_get_value((json_object *)data, 1, "freq_seg0_idx");
char freq_str[3] = {0};
int freq = atoi(val);
int freq = DM_STRTOL(val);
snprintf(freq_str, 3, "%02x", freq);
@ -1336,7 +1382,7 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_FrequencyIndex2(
{
char *val = dmjson_get_value((json_object *)data, 1, "freq_seg1_idx");
char freq_str[3] = {0};
int freq = atoi(val);
int freq = DM_STRTOL(val);
snprintf(freq_str, 3, "%02x", freq);
*value = dmstrdup(freq_str);
@ -1347,17 +1393,15 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_FrequencyIndex2(
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.NonIEEE1905Neighbor.{i}.LocalInterface!UBUS:ieee1905/info//topology.device[@i-1].non1905_neighbors[@i-1].interface_macaddress*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905Neighbor_LocalInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker = dmjson_get_value((json_object *)data, 1, "interface_macaddress");
char *linker = ((struct ieee1905_device_nonieee1905neighbor_args *)data)->mac_addr;
adm_entry_get_linker_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.NonIEEE1905Neighbor.{i}.NeighborInterfaceId!UBUS:ieee1905/info//topology.device[@i-1].non1905_neighbors[@i-1].neighbors*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905Neighbor_NeighborInterfaceId(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value_array_all((json_object *)data, ",", 1, "neighbors");
*value = (data && ((struct ieee1905_device_nonieee1905neighbor_args *)data)->neighbor) ? ((struct ieee1905_device_nonieee1905neighbor_args *)data)->neighbor : "";
return 0;
}
@ -1386,8 +1430,6 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_LocalInte
{
char *linker = dmjson_get_value((json_object *)data, 1, "macaddress");
adm_entry_get_linker_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
@ -1475,13 +1517,28 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_RSS
return 0;
}
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.BridgingTuple.{i}.InterfaceList!UBUS:ieee1905/info//topology.device[@i-1].bridge_tuples[@i-1].macaddress*/
/*#Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.BridgingTuple.{i}.InterfaceList!UBUS:ieee1905/info//topology.device[@i-1].bridge_tuples[@i-1].tuple*/
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTuple_InterfaceList(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker = dmjson_get_value((json_object *)data, 1, "macaddress");
adm_entry_get_linker_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.", linker, value);
if (*value == NULL)
*value = "";
json_object *json_obj = NULL;
char *mac_addr = NULL;
char buf[4096] = {0};
unsigned pos = 0;
int idx = 0;
buf[0] = 0;
dmjson_foreach_value_in_array((json_object *)data, json_obj, mac_addr, idx, 1, "tuple") {
char *linker = NULL;
adm_entry_get_linker_param(ctx, "Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.", mac_addr, &linker);
if (DM_STRLEN(linker) && (sizeof(buf) - pos) > 0)
pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", linker);
}
if (pos)
buf[pos - 1] = 0;
*value = (buf[0] != '\0') ? dmstrdup(buf) : "";
return 0;
}
@ -1543,313 +1600,314 @@ static int get_IEEE1905ALNetworkingRegistrar_Registrar60(char *refparam, struct
***********************************************************************************************************************************/
/* *** Device.IEEE1905. *** */
DMOBJ tIEEE1905Obj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"AL", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALObj, tIEEE1905ALParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"AL", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALObj, tIEEE1905ALParams, NULL, BBFDM_BOTH, NULL, "2.9"},
{0}
};
DMLEAF tIEEE1905Params[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Version", &DMREAD, DMT_STRING, get_IEEE1905_Version, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Version", &DMREAD, DMT_STRING, get_IEEE1905_Version, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL. *** */
DMOBJ tIEEE1905ALObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Interface", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALInterfaceInst, NULL, NULL, tIEEE1905ALInterfaceObj, tIEEE1905ALInterfaceParams, NULL, BBFDM_BOTH, LIST_KEY{"InterfaceId", NULL}},
{"ForwardingTable", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALForwardingTableObj, tIEEE1905ALForwardingTableParams, NULL, BBFDM_BOTH},
{"NetworkTopology", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyObj, tIEEE1905ALNetworkTopologyParams, NULL, BBFDM_BOTH},
{"Security", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALSecurityParams, NULL, BBFDM_BOTH},
{"NetworkingRegistrar", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALNetworkingRegistrarParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Interface", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALInterfaceInst, NULL, NULL, tIEEE1905ALInterfaceObj, tIEEE1905ALInterfaceParams, NULL, BBFDM_BOTH, LIST_KEY{"InterfaceId", NULL}, "2.9"},
{"ForwardingTable", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALForwardingTableObj, tIEEE1905ALForwardingTableParams, NULL, BBFDM_BOTH, NULL, "2.9"},
{"NetworkTopology", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyObj, tIEEE1905ALNetworkTopologyParams, NULL, BBFDM_BOTH, NULL, "2.9"},
{"Security", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALSecurityParams, NULL, BBFDM_BOTH, NULL, "2.9"},
{"NetworkingRegistrar", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALNetworkingRegistrarParams, NULL, BBFDM_BOTH, NULL, "2.9"},
{0}
};
DMLEAF tIEEE1905ALParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"IEEE1905Id", &DMREAD, DMT_STRING, get_IEEE1905AL_IEEE1905Id, NULL, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_IEEE1905AL_Status, NULL, BBFDM_BOTH},
{"RegistrarFreqBand", &DMREAD, DMT_STRING, get_IEEE1905AL_RegistrarFreqBand, NULL, BBFDM_BOTH},
{"InterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905AL_InterfaceNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"IEEE1905Id", &DMREAD, DMT_STRING, get_IEEE1905AL_IEEE1905Id, NULL, BBFDM_BOTH, "2.9"},
{"Status", &DMREAD, DMT_STRING, get_IEEE1905AL_Status, NULL, BBFDM_BOTH, "2.9"},
{"RegistrarFreqBand", &DMREAD, DMT_STRING, get_IEEE1905AL_RegistrarFreqBand, NULL, BBFDM_BOTH, "2.9"},
{"InterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905AL_InterfaceNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.Interface.{i}. *** */
DMOBJ tIEEE1905ALInterfaceObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"VendorProperties", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALInterfaceVendorPropertiesInst, NULL, NULL, NULL, tIEEE1905ALInterfaceVendorPropertiesParams, NULL, BBFDM_BOTH},
{"Link", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALInterfaceLinkInst, NULL, NULL, tIEEE1905ALInterfaceLinkObj, tIEEE1905ALInterfaceLinkParams, NULL, BBFDM_BOTH, LIST_KEY{"InterfaceId", "IEEE1905Id", NULL}},
{0}
};
DMLEAF tIEEE1905ALInterfaceParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"InterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_InterfaceId, NULL, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_Status, NULL, BBFDM_BOTH},
//{"InterfaceStackReference", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_InterfaceStackReference, NULL, BBFDM_BOTH},
{"MediaType", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_MediaType, NULL, BBFDM_BOTH},
//{"GenericPhyOUI", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_GenericPhyOUI, NULL, BBFDM_BOTH},
//{"GenericPhyVariant", &DMREAD, DMT_HEXBIN, get_IEEE1905ALInterface_GenericPhyVariant, NULL, BBFDM_BOTH},
//{"GenericPhyURL", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_GenericPhyURL, NULL, BBFDM_BOTH},
//{"SetIntfPowerStateEnabled", &DMWRITE, DMT_BOOL, get_IEEE1905ALInterface_SetIntfPowerStateEnabled, set_IEEE1905ALInterface_SetIntfPowerStateEnabled, BBFDM_BOTH},
{"PowerState", &DMWRITE, DMT_STRING, get_IEEE1905ALInterface_PowerState, set_IEEE1905ALInterface_PowerState, BBFDM_BOTH},
{"VendorPropertiesNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALInterface_VendorPropertiesNumberOfEntries, NULL, BBFDM_BOTH},
{"LinkNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALInterface_LinkNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"InterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_InterfaceId, NULL, BBFDM_BOTH, "2.9"},
{"Status", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_Status, NULL, BBFDM_BOTH, "2.9"},
{"LowerLayers", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_LowerLayers, NULL, BBFDM_BOTH, "2.9"},
//{"InterfaceStackReference", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_InterfaceStackReference, NULL, BBFDM_BOTH, "2.9"},
{"MediaType", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_MediaType, NULL, BBFDM_BOTH, "2.9"},
//{"GenericPhyOUI", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_GenericPhyOUI, NULL, BBFDM_BOTH, "2.9"},
//{"GenericPhyVariant", &DMREAD, DMT_HEXBIN, get_IEEE1905ALInterface_GenericPhyVariant, NULL, BBFDM_BOTH, "2.9"},
//{"GenericPhyURL", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_GenericPhyURL, NULL, BBFDM_BOTH, "2.9"},
//{"SetIntfPowerStateEnabled", &DMWRITE, DMT_BOOL, get_IEEE1905ALInterface_SetIntfPowerStateEnabled, set_IEEE1905ALInterface_SetIntfPowerStateEnabled, BBFDM_BOTH, "2.9"},
{"PowerState", &DMWRITE, DMT_STRING, get_IEEE1905ALInterface_PowerState, set_IEEE1905ALInterface_PowerState, BBFDM_BOTH, "2.9"},
{"VendorPropertiesNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALInterface_VendorPropertiesNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{"LinkNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALInterface_LinkNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.Interface.{i}.VendorProperties.{i}. *** */
DMLEAF tIEEE1905ALInterfaceVendorPropertiesParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"OUI", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceVendorProperties_OUI, NULL, BBFDM_BOTH},
{"Information", &DMREAD, DMT_HEXBIN, get_IEEE1905ALInterfaceVendorProperties_Information, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"OUI", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceVendorProperties_OUI, NULL, BBFDM_BOTH, "2.9"},
{"Information", &DMREAD, DMT_HEXBIN, get_IEEE1905ALInterfaceVendorProperties_Information, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.Interface.{i}.Link.{i}. *** */
DMOBJ tIEEE1905ALInterfaceLinkObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Metric", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALInterfaceLinkMetricParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Metric", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE1905ALInterfaceLinkMetricParams, NULL, BBFDM_BOTH, NULL, "2.9"},
{0}
};
DMLEAF tIEEE1905ALInterfaceLinkParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"InterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceLink_InterfaceId, NULL, BBFDM_BOTH},
{"IEEE1905Id", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceLink_IEEE1905Id, NULL, BBFDM_BOTH},
{"MediaType", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceLink_MediaType, NULL, BBFDM_BOTH},
//{"GenericPhyOUI", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceLink_GenericPhyOUI, NULL, BBFDM_BOTH},
//{"GenericPhyVariant", &DMREAD, DMT_HEXBIN, get_IEEE1905ALInterfaceLink_GenericPhyVariant, NULL, BBFDM_BOTH},
//{"GenericPhyURL", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceLink_GenericPhyURL, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"InterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceLink_InterfaceId, NULL, BBFDM_BOTH, "2.9"},
{"IEEE1905Id", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceLink_IEEE1905Id, NULL, BBFDM_BOTH, "2.9"},
{"MediaType", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceLink_MediaType, NULL, BBFDM_BOTH, "2.9"},
//{"GenericPhyOUI", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceLink_GenericPhyOUI, NULL, BBFDM_BOTH, "2.9"},
//{"GenericPhyVariant", &DMREAD, DMT_HEXBIN, get_IEEE1905ALInterfaceLink_GenericPhyVariant, NULL, BBFDM_BOTH, "2.9"},
//{"GenericPhyURL", &DMREAD, DMT_STRING, get_IEEE1905ALInterfaceLink_GenericPhyURL, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.Interface.{i}.Link.{i}.Metric. *** */
DMLEAF tIEEE1905ALInterfaceLinkMetricParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"IEEE802dot1Bridge", &DMREAD, DMT_BOOL, get_IEEE1905ALInterfaceLinkMetric_IEEE802dot1Bridge, NULL, BBFDM_BOTH},
{"PacketErrors", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_PacketErrors, NULL, BBFDM_BOTH},
{"PacketErrorsReceived", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_PacketErrorsReceived, NULL, BBFDM_BOTH},
{"TransmittedPackets", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_TransmittedPackets, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_PacketsReceived, NULL, BBFDM_BOTH},
{"MACThroughputCapacity", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_MACThroughputCapacity, NULL, BBFDM_BOTH},
//{"LinkAvailability", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_LinkAvailability, NULL, BBFDM_BOTH},
{"PHYRate", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_PHYRate, NULL, BBFDM_BOTH},
{"RSSI", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_RSSI, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"IEEE802dot1Bridge", &DMREAD, DMT_BOOL, get_IEEE1905ALInterfaceLinkMetric_IEEE802dot1Bridge, NULL, BBFDM_BOTH, "2.9"},
{"PacketErrors", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_PacketErrors, NULL, BBFDM_BOTH, "2.9"},
{"PacketErrorsReceived", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_PacketErrorsReceived, NULL, BBFDM_BOTH, "2.9"},
{"TransmittedPackets", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_TransmittedPackets, NULL, BBFDM_BOTH, "2.9"},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_PacketsReceived, NULL, BBFDM_BOTH, "2.9"},
{"MACThroughputCapacity", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_MACThroughputCapacity, NULL, BBFDM_BOTH, "2.9"},
//{"LinkAvailability", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_LinkAvailability, NULL, BBFDM_BOTH, "2.9"},
{"PHYRate", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_PHYRate, NULL, BBFDM_BOTH, "2.9"},
{"RSSI", &DMREAD, DMT_UNINT, get_IEEE1905ALInterfaceLinkMetric_RSSI, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.ForwardingTable. *** */
DMOBJ tIEEE1905ALForwardingTableObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"ForwardingRule", &DMWRITE, addObjIEEE1905ALForwardingTableForwardingRule, delObjIEEE1905ALForwardingTableForwardingRule, NULL, browseIEEE1905ALForwardingTableForwardingRuleInst, NULL, NULL, NULL, tIEEE1905ALForwardingTableForwardingRuleParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"ForwardingRule", &DMWRITE, addObjIEEE1905ALForwardingTableForwardingRule, delObjIEEE1905ALForwardingTableForwardingRule, NULL, browseIEEE1905ALForwardingTableForwardingRuleInst, NULL, NULL, NULL, tIEEE1905ALForwardingTableForwardingRuleParams, NULL, BBFDM_BOTH, NULL, "2.9"},
{0}
};
DMLEAF tIEEE1905ALForwardingTableParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"SetForwardingEnabled", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTable_SetForwardingEnabled, set_IEEE1905ALForwardingTable_SetForwardingEnabled, BBFDM_BOTH},
{"ForwardingRuleNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALForwardingTable_ForwardingRuleNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"SetForwardingEnabled", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTable_SetForwardingEnabled, set_IEEE1905ALForwardingTable_SetForwardingEnabled, BBFDM_BOTH, "2.9"},
{"ForwardingRuleNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALForwardingTable_ForwardingRuleNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}. *** */
DMLEAF tIEEE1905ALForwardingTableForwardingRuleParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"InterfaceList", &DMWRITE, DMT_STRING, get_IEEE1905ALForwardingTableForwardingRule_InterfaceList, set_IEEE1905ALForwardingTableForwardingRule_InterfaceList, BBFDM_BOTH},
{"MACDestinationAddress", &DMWRITE, DMT_STRING, get_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddress, set_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddress, BBFDM_BOTH},
{"MACDestinationAddressFlag", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddressFlag, set_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddressFlag, BBFDM_BOTH},
{"MACSourceAddress", &DMWRITE, DMT_STRING, get_IEEE1905ALForwardingTableForwardingRule_MACSourceAddress, set_IEEE1905ALForwardingTableForwardingRule_MACSourceAddress, BBFDM_BOTH},
{"MACSourceAddressFlag", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTableForwardingRule_MACSourceAddressFlag, set_IEEE1905ALForwardingTableForwardingRule_MACSourceAddressFlag, BBFDM_BOTH},
{"EtherType", &DMWRITE, DMT_UNINT, get_IEEE1905ALForwardingTableForwardingRule_EtherType, set_IEEE1905ALForwardingTableForwardingRule_EtherType, BBFDM_BOTH},
{"EtherTypeFlag", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTableForwardingRule_EtherTypeFlag, set_IEEE1905ALForwardingTableForwardingRule_EtherTypeFlag, BBFDM_BOTH},
{"Vid", &DMWRITE, DMT_UNINT, get_IEEE1905ALForwardingTableForwardingRule_Vid, set_IEEE1905ALForwardingTableForwardingRule_Vid, BBFDM_BOTH},
{"VidFlag", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTableForwardingRule_VidFlag, set_IEEE1905ALForwardingTableForwardingRule_VidFlag, BBFDM_BOTH},
{"PCP", &DMWRITE, DMT_UNINT, get_IEEE1905ALForwardingTableForwardingRule_PCP, set_IEEE1905ALForwardingTableForwardingRule_PCP, BBFDM_BOTH},
{"PCPFlag", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTableForwardingRule_PCPFlag, set_IEEE1905ALForwardingTableForwardingRule_PCPFlag, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"InterfaceList", &DMWRITE, DMT_STRING, get_IEEE1905ALForwardingTableForwardingRule_InterfaceList, set_IEEE1905ALForwardingTableForwardingRule_InterfaceList, BBFDM_BOTH, "2.9"},
{"MACDestinationAddress", &DMWRITE, DMT_STRING, get_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddress, set_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddress, BBFDM_BOTH, "2.9"},
{"MACDestinationAddressFlag", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddressFlag, set_IEEE1905ALForwardingTableForwardingRule_MACDestinationAddressFlag, BBFDM_BOTH, "2.9"},
{"MACSourceAddress", &DMWRITE, DMT_STRING, get_IEEE1905ALForwardingTableForwardingRule_MACSourceAddress, set_IEEE1905ALForwardingTableForwardingRule_MACSourceAddress, BBFDM_BOTH, "2.9"},
{"MACSourceAddressFlag", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTableForwardingRule_MACSourceAddressFlag, set_IEEE1905ALForwardingTableForwardingRule_MACSourceAddressFlag, BBFDM_BOTH, "2.9"},
{"EtherType", &DMWRITE, DMT_UNINT, get_IEEE1905ALForwardingTableForwardingRule_EtherType, set_IEEE1905ALForwardingTableForwardingRule_EtherType, BBFDM_BOTH, "2.9"},
{"EtherTypeFlag", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTableForwardingRule_EtherTypeFlag, set_IEEE1905ALForwardingTableForwardingRule_EtherTypeFlag, BBFDM_BOTH, "2.9"},
{"Vid", &DMWRITE, DMT_UNINT, get_IEEE1905ALForwardingTableForwardingRule_Vid, set_IEEE1905ALForwardingTableForwardingRule_Vid, BBFDM_BOTH, "2.9"},
{"VidFlag", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTableForwardingRule_VidFlag, set_IEEE1905ALForwardingTableForwardingRule_VidFlag, BBFDM_BOTH, "2.9"},
{"PCP", &DMWRITE, DMT_UNINT, get_IEEE1905ALForwardingTableForwardingRule_PCP, set_IEEE1905ALForwardingTableForwardingRule_PCP, BBFDM_BOTH, "2.9"},
{"PCPFlag", &DMWRITE, DMT_BOOL, get_IEEE1905ALForwardingTableForwardingRule_PCPFlag, set_IEEE1905ALForwardingTableForwardingRule_PCPFlag, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology. *** */
DMOBJ tIEEE1905ALNetworkTopologyObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
//{"ChangeLog", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyChangeLogInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyChangeLogParams, NULL, BBFDM_BOTH},
{"IEEE1905Device", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceInst, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceObj, tIEEE1905ALNetworkTopologyIEEE1905DeviceParams, NULL, BBFDM_BOTH, LIST_KEY{"IEEE1905Id", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
//{"ChangeLog", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyChangeLogInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyChangeLogParams, NULL, BBFDM_BOTH, NULL, "2.9"},
{"IEEE1905Device", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceInst, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceObj, tIEEE1905ALNetworkTopologyIEEE1905DeviceParams, get_linker_IEEE1905Device, BBFDM_BOTH, LIST_KEY{"IEEE1905Id", NULL}, "2.9"},
{0}
};
DMLEAF tIEEE1905ALNetworkTopologyParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_IEEE1905ALNetworkTopology_Enable, set_IEEE1905ALNetworkTopology_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopology_Status, NULL, BBFDM_BOTH},
{"MaxChangeLogEntries", &DMWRITE, DMT_UNINT, get_IEEE1905ALNetworkTopology_MaxChangeLogEntries, set_IEEE1905ALNetworkTopology_MaxChangeLogEntries, BBFDM_BOTH},
{"LastChange", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopology_LastChange, NULL, BBFDM_BOTH},
{"IEEE1905DeviceNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopology_IEEE1905DeviceNumberOfEntries, NULL, BBFDM_BOTH},
{"ChangeLogNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopology_ChangeLogNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_IEEE1905ALNetworkTopology_Enable, set_IEEE1905ALNetworkTopology_Enable, BBFDM_BOTH, "2.9"},
{"Status", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopology_Status, NULL, BBFDM_BOTH, "2.9"},
{"MaxChangeLogEntries", &DMWRITE, DMT_UNINT, get_IEEE1905ALNetworkTopology_MaxChangeLogEntries, set_IEEE1905ALNetworkTopology_MaxChangeLogEntries, BBFDM_BOTH, "2.9"},
{"LastChange", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopology_LastChange, NULL, BBFDM_BOTH, "2.9"},
{"IEEE1905DeviceNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopology_IEEE1905DeviceNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{"ChangeLogNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopology_ChangeLogNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.ChangeLog.{i}. *** */
DMLEAF tIEEE1905ALNetworkTopologyChangeLogParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"TimeStamp", &DMREAD, DMT_TIME, get_IEEE1905ALNetworkTopologyChangeLog_TimeStamp, NULL, BBFDM_BOTH},
//{"EventType", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyChangeLog_EventType, NULL, BBFDM_BOTH},
//{"ReporterDeviceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyChangeLog_ReporterDeviceId, NULL, BBFDM_BOTH},
//{"ReporterInterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyChangeLog_ReporterInterfaceId, NULL, BBFDM_BOTH},
//{"NeighborType", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyChangeLog_NeighborType, NULL, BBFDM_BOTH},
//{"NeighborId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyChangeLog_NeighborId, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"TimeStamp", &DMREAD, DMT_TIME, get_IEEE1905ALNetworkTopologyChangeLog_TimeStamp, NULL, BBFDM_BOTH, "2.9"},
//{"EventType", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyChangeLog_EventType, NULL, BBFDM_BOTH, "2.9"},
//{"ReporterDeviceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyChangeLog_ReporterDeviceId, NULL, BBFDM_BOTH, "2.9"},
//{"ReporterInterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyChangeLog_ReporterInterfaceId, NULL, BBFDM_BOTH, "2.9"},
//{"NeighborType", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyChangeLog_NeighborType, NULL, BBFDM_BOTH, "2.9"},
//{"NeighborId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyChangeLog_NeighborId, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}. *** */
DMOBJ tIEEE1905ALNetworkTopologyIEEE1905DeviceObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"IPv4Address", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIPv4AddressInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceIPv4AddressParams, NULL, BBFDM_BOTH, LIST_KEY{"MACAddress", "IPv4Address", NULL}},
{"IPv6Address", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIPv6AddressInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceIPv6AddressParams, NULL, BBFDM_BOTH, LIST_KEY{"MACAddress", "IPv6Address", NULL}},
{"VendorProperties", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceVendorPropertiesInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceVendorPropertiesParams, NULL, BBFDM_BOTH},
{"Interface", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceInterfaceInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceInterfaceParams, get_linker_topology_interface, BBFDM_BOTH, LIST_KEY{"InterfaceId", NULL}},
{"NonIEEE1905Neighbor", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905NeighborInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905NeighborParams, NULL, BBFDM_BOTH, LIST_KEY{"LocalInterface", "NeighborInterfaceId", NULL}},
//{"L2Neighbor", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceL2NeighborInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceL2NeighborParams, NULL, BBFDM_BOTH, (const char*[]){"LocalInterface", "NeighborInterfaceId", NULL}},
{"IEEE1905Neighbor", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborInst, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborObj, tIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborParams, NULL, BBFDM_BOTH, LIST_KEY{"LocalInterface", "NeighborDeviceId", NULL}},
{"BridgingTuple", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTupleInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTupleParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"IPv4Address", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIPv4AddressInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceIPv4AddressParams, NULL, BBFDM_BOTH, LIST_KEY{"MACAddress", "IPv4Address", NULL}, "2.9"},
{"IPv6Address", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIPv6AddressInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceIPv6AddressParams, NULL, BBFDM_BOTH, LIST_KEY{"MACAddress", "IPv6Address", NULL}, "2.9"},
{"VendorProperties", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceVendorPropertiesInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceVendorPropertiesParams, NULL, BBFDM_BOTH, NULL, "2.9"},
{"Interface", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceInterfaceInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceInterfaceParams, get_linker_topology_interface, BBFDM_BOTH, LIST_KEY{"InterfaceId", NULL}, "2.9"},
{"NonIEEE1905Neighbor", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905NeighborInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905NeighborParams, NULL, BBFDM_BOTH, LIST_KEY{"LocalInterface", "NeighborInterfaceId", NULL}, "2.9"},
//{"L2Neighbor", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceL2NeighborInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceL2NeighborParams, NULL, BBFDM_BOTH, (const char*[]){"LocalInterface", "NeighborInterfaceId", NULL}, "2.9"},
{"IEEE1905Neighbor", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborInst, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborObj, tIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborParams, NULL, BBFDM_BOTH, LIST_KEY{"LocalInterface", "NeighborDeviceId", NULL}, "2.9"},
{"BridgingTuple", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTupleInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTupleParams, NULL, BBFDM_BOTH, NULL, "2.9"},
{0}
};
DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"IEEE1905Id", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_IEEE1905Id, NULL, BBFDM_BOTH},
{"Version", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_Version, NULL, BBFDM_BOTH},
//{"RegistrarFreqBand", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_RegistrarFreqBand, NULL, BBFDM_BOTH},
{"FriendlyName", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_FriendlyName, NULL, BBFDM_BOTH},
{"ManufacturerName", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_ManufacturerName, NULL, BBFDM_BOTH},
{"ManufacturerModel", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_ManufacturerModel, NULL, BBFDM_BOTH},
{"ControlURL", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_ControlURL, NULL, BBFDM_BOTH},
//{"AssocWiFiNetworkDeviceRef", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_AssocWiFiNetworkDeviceRef, NULL, BBFDM_BOTH},
{"VendorPropertiesNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_VendorPropertiesNumberOfEntries, NULL, BBFDM_BOTH},
{"IPv4AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_IPv4AddressNumberOfEntries, NULL, BBFDM_BOTH},
{"IPv6AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_IPv6AddressNumberOfEntries, NULL, BBFDM_BOTH},
{"InterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_InterfaceNumberOfEntries, NULL, BBFDM_BOTH},
{"NonIEEE1905NeighborNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_NonIEEE1905NeighborNumberOfEntries, NULL, BBFDM_BOTH},
{"IEEE1905NeighborNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_IEEE1905NeighborNumberOfEntries, NULL, BBFDM_BOTH},
{"L2NeighborNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_L2NeighborNumberOfEntries, NULL, BBFDM_BOTH},
{"BridgingTupleNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_BridgingTupleNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"IEEE1905Id", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_IEEE1905Id, NULL, BBFDM_BOTH, "2.9"},
{"Version", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_Version, NULL, BBFDM_BOTH, "2.9"},
//{"RegistrarFreqBand", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_RegistrarFreqBand, NULL, BBFDM_BOTH, "2.9"},
{"FriendlyName", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_FriendlyName, NULL, BBFDM_BOTH, "2.9"},
{"ManufacturerName", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_ManufacturerName, NULL, BBFDM_BOTH, "2.9"},
{"ManufacturerModel", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_ManufacturerModel, NULL, BBFDM_BOTH, "2.9"},
{"ControlURL", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_ControlURL, NULL, BBFDM_BOTH, "2.9"},
//{"AssocWiFiNetworkDeviceRef", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905Device_AssocWiFiNetworkDeviceRef, NULL, BBFDM_BOTH, "2.13"},
{"VendorPropertiesNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_VendorPropertiesNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{"IPv4AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_IPv4AddressNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{"IPv6AddressNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_IPv6AddressNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{"InterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_InterfaceNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{"NonIEEE1905NeighborNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_NonIEEE1905NeighborNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{"IEEE1905NeighborNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_IEEE1905NeighborNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{"L2NeighborNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_L2NeighborNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{"BridgingTupleNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905Device_BridgingTupleNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv4Address.{i}. *** */
DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceIPv4AddressParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"MACAddress", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_MACAddress, NULL, BBFDM_BOTH},
{"IPv4Address", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_IPv4Address, NULL, BBFDM_BOTH},
{"IPv4AddressType", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_IPv4AddressType, NULL, BBFDM_BOTH},
{"DHCPServer", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_DHCPServer, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"MACAddress", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_MACAddress, NULL, BBFDM_BOTH, "2.9"},
{"IPv4Address", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_IPv4Address, NULL, BBFDM_BOTH, "2.9"},
{"IPv4AddressType", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_IPv4AddressType, NULL, BBFDM_BOTH, "2.9"},
{"DHCPServer", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv4Address_DHCPServer, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IPv6Address.{i}. *** */
DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceIPv6AddressParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"MACAddress", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_MACAddress, NULL, BBFDM_BOTH},
{"IPv6Address", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_IPv6Address, NULL, BBFDM_BOTH},
{"IPv6AddressType", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_IPv6AddressType, NULL, BBFDM_BOTH},
{"IPv6AddressOrigin", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_IPv6AddressOrigin, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"MACAddress", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_MACAddress, NULL, BBFDM_BOTH, "2.9"},
{"IPv6Address", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_IPv6Address, NULL, BBFDM_BOTH, "2.9"},
{"IPv6AddressType", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_IPv6AddressType, NULL, BBFDM_BOTH, "2.9"},
{"IPv6AddressOrigin", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIPv6Address_IPv6AddressOrigin, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.VendorProperties.{i}. *** */
DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceVendorPropertiesParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"MessageType", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceVendorProperties_MessageType, NULL, BBFDM_BOTH},
{"OUI", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceVendorProperties_OUI, NULL, BBFDM_BOTH},
{"Information", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceVendorProperties_Information, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"MessageType", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceVendorProperties_MessageType, NULL, BBFDM_BOTH, "2.9"},
{"OUI", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceVendorProperties_OUI, NULL, BBFDM_BOTH, "2.9"},
{"Information", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceVendorProperties_Information, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.Interface.{i}. *** */
DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceInterfaceParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"InterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_InterfaceId, NULL, BBFDM_BOTH},
{"MediaType", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_MediaType, NULL, BBFDM_BOTH},
{"PowerState", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_PowerState, NULL, BBFDM_BOTH},
//{"GenericPhyOUI", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_GenericPhyOUI, NULL, BBFDM_BOTH},
//{"GenericPhyVariant", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_GenericPhyVariant, NULL, BBFDM_BOTH},
//{"GenericPhyURL", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_GenericPhyURL, NULL, BBFDM_BOTH},
{"NetworkMembership", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_NetworkMembership, NULL, BBFDM_BOTH},
{"Role", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_Role, NULL, BBFDM_BOTH},
{"APChannelBand", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_APChannelBand, NULL, BBFDM_BOTH},
{"FrequencyIndex1", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_FrequencyIndex1, NULL, BBFDM_BOTH},
{"FrequencyIndex2", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_FrequencyIndex2, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"InterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_InterfaceId, NULL, BBFDM_BOTH, "2.9"},
{"MediaType", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_MediaType, NULL, BBFDM_BOTH, "2.9"},
{"PowerState", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_PowerState, NULL, BBFDM_BOTH, "2.9"},
//{"GenericPhyOUI", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_GenericPhyOUI, NULL, BBFDM_BOTH, "2.9"},
//{"GenericPhyVariant", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_GenericPhyVariant, NULL, BBFDM_BOTH, "2.9"},
//{"GenericPhyURL", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_GenericPhyURL, NULL, BBFDM_BOTH, "2.9"},
{"NetworkMembership", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_NetworkMembership, NULL, BBFDM_BOTH, "2.9"},
{"Role", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_Role, NULL, BBFDM_BOTH, "2.9"},
{"APChannelBand", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_APChannelBand, NULL, BBFDM_BOTH, "2.9"},
{"FrequencyIndex1", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_FrequencyIndex1, NULL, BBFDM_BOTH, "2.9"},
{"FrequencyIndex2", &DMREAD, DMT_HEXBIN, get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_FrequencyIndex2, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.NonIEEE1905Neighbor.{i}. *** */
DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905NeighborParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"LocalInterface", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905Neighbor_LocalInterface, NULL, BBFDM_BOTH},
{"NeighborInterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905Neighbor_NeighborInterfaceId, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"LocalInterface", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905Neighbor_LocalInterface, NULL, BBFDM_BOTH, "2.9"},
{"NeighborInterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceNonIEEE1905Neighbor_NeighborInterfaceId, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.L2Neighbor.{i}. *** */
DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceL2NeighborParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"LocalInterface", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceL2Neighbor_LocalInterface, NULL, BBFDM_BOTH},
//{"NeighborInterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceL2Neighbor_NeighborInterfaceId, NULL, BBFDM_BOTH},
//{"BehindInterfaceIds", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceL2Neighbor_BehindInterfaceIds, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"LocalInterface", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceL2Neighbor_LocalInterface, NULL, BBFDM_BOTH, "2.9"},
//{"NeighborInterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceL2Neighbor_NeighborInterfaceId, NULL, BBFDM_BOTH, "2.9"},
//{"BehindInterfaceIds", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceL2Neighbor_BehindInterfaceIds, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}. *** */
DMOBJ tIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Metric", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetricInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetricParams, NULL, BBFDM_BOTH, LIST_KEY{"NeighborMACAddress", NULL}},
{"Metric", &DMREAD, NULL, NULL, NULL, browseIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetricInst, NULL, NULL, NULL, tIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetricParams, NULL, BBFDM_BOTH, LIST_KEY{"NeighborMACAddress", NULL}, "2.9"},
{0}
};
DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"LocalInterface", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_LocalInterface, NULL, BBFDM_BOTH},
{"NeighborDeviceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_NeighborDeviceId, NULL, BBFDM_BOTH},
{"MetricNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_MetricNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"LocalInterface", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_LocalInterface, NULL, BBFDM_BOTH, "2.9"},
{"NeighborDeviceId", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_NeighborDeviceId, NULL, BBFDM_BOTH, "2.9"},
{"MetricNumberOfEntries", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_MetricNumberOfEntries, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.IEEE1905Neighbor.{i}.Metric.{i}. *** */
DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetricParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"NeighborMACAddress", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_NeighborMACAddress, NULL, BBFDM_BOTH},
{"IEEE802dot1Bridge", &DMREAD, DMT_BOOL, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_IEEE802dot1Bridge, NULL, BBFDM_BOTH},
{"PacketErrors", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PacketErrors, NULL, BBFDM_BOTH},
{"PacketErrorsReceived", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PacketErrorsReceived, NULL, BBFDM_BOTH},
{"TransmittedPackets", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_TransmittedPackets, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PacketsReceived, NULL, BBFDM_BOTH},
{"MACThroughputCapacity", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_MACThroughputCapacity, NULL, BBFDM_BOTH},
{"LinkAvailability", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_LinkAvailability, NULL, BBFDM_BOTH},
{"PHYRate", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PHYRate, NULL, BBFDM_BOTH},
{"RSSI", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_RSSI, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"NeighborMACAddress", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_NeighborMACAddress, NULL, BBFDM_BOTH, "2.9"},
{"IEEE802dot1Bridge", &DMREAD, DMT_BOOL, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_IEEE802dot1Bridge, NULL, BBFDM_BOTH, "2.9"},
{"PacketErrors", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PacketErrors, NULL, BBFDM_BOTH, "2.9"},
{"PacketErrorsReceived", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PacketErrorsReceived, NULL, BBFDM_BOTH, "2.9"},
{"TransmittedPackets", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_TransmittedPackets, NULL, BBFDM_BOTH, "2.9"},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PacketsReceived, NULL, BBFDM_BOTH, "2.9"},
{"MACThroughputCapacity", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_MACThroughputCapacity, NULL, BBFDM_BOTH, "2.9"},
{"LinkAvailability", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_LinkAvailability, NULL, BBFDM_BOTH, "2.9"},
{"PHYRate", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_PHYRate, NULL, BBFDM_BOTH, "2.9"},
{"RSSI", &DMREAD, DMT_UNINT, get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905NeighborMetric_RSSI, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkTopology.IEEE1905Device.{i}.BridgingTuple.{i}. *** */
DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTupleParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"InterfaceList", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTuple_InterfaceList, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"InterfaceList", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTuple_InterfaceList, NULL, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.Security. *** */
DMLEAF tIEEE1905ALSecurityParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"SetupMethod", &DMWRITE, DMT_STRING, get_IEEE1905ALSecurity_SetupMethod, set_IEEE1905ALSecurity_SetupMethod, BBFDM_BOTH},
{"Password", &DMWRITE, DMT_STRING, get_empty, set_IEEE1905ALSecurity_Password, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"SetupMethod", &DMWRITE, DMT_STRING, get_IEEE1905ALSecurity_SetupMethod, set_IEEE1905ALSecurity_SetupMethod, BBFDM_BOTH, "2.9"},
{"Password", &DMWRITE, DMT_STRING, get_empty, set_IEEE1905ALSecurity_Password, BBFDM_BOTH, "2.9"},
{0}
};
/* *** Device.IEEE1905.AL.NetworkingRegistrar. *** */
DMLEAF tIEEE1905ALNetworkingRegistrarParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Registrar2dot4", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkingRegistrar_Registrar2dot4, NULL, BBFDM_BOTH},
{"Registrar5", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkingRegistrar_Registrar5, NULL, BBFDM_BOTH},
{"Registrar60", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkingRegistrar_Registrar60, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Registrar2dot4", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkingRegistrar_Registrar2dot4, NULL, BBFDM_BOTH, "2.9"},
{"Registrar5", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkingRegistrar_Registrar5, NULL, BBFDM_BOTH, "2.9"},
{"Registrar60", &DMREAD, DMT_STRING, get_IEEE1905ALNetworkingRegistrar_Registrar60, NULL, BBFDM_BOTH, "2.9"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __IEEE1905_H
#define __IEEE1905_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tIEEE1905Obj[];
extern DMLEAF tIEEE1905Params[];

View file

@ -8,7 +8,6 @@
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include "dmentry.h"
#include "ethernet.h"
#include "interfacestack.h"
@ -124,14 +123,14 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
/* Higher layers are Device.IP.Interface.{i}. */
uci_foreach_sections("network", "interface", s) {
char *proto, *device;
char *proto, *device_s;
dmuci_get_value_by_section_string(s, "proto", &proto);
dmuci_get_value_by_section_string(s, "device", &device);
dmuci_get_value_by_section_string(s, "device", &device_s);
if (strcmp(section_name(s), "loopback") == 0 ||
*proto == '\0' ||
strchr(device, '@'))
DM_STRCHR(device_s, '@'))
continue;
// The higher layer is Device.IP.Interface.{i}.
@ -143,7 +142,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
higheralias = get_alias_by_section("dmmap_network", "interface", s, "ip_int_alias");
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *higheralias ? higheralias : *layer_inst ? "cpe-" : "", (*higheralias == '\0' && *layer_inst) ? layer_inst : "");
if (strstr(proto, "ppp")) {
if (DM_LSTRSTR(proto, "ppp")) {
// The lower layer is Device.PPP.Interface.{i}.
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "interface", "section_name", section_name(s), "ppp_int_instance", "ppp_int_alias");
if (*layer_inst == '\0')
@ -156,6 +155,11 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
char *value = NULL;
int found = 0;
char *device = get_device(section_name(s));
/* If the device value is empty, then get its value directly from device option */
if (*device == '\0')
dmuci_get_value_by_section_string(s, "device", &device);
if (device[0] != '\0') {
struct uci_section *vlan_sect = NULL;
adm_entry_get_linker_param(dmctx, "Device.Ethernet.VLANTermination.", device, &value);
@ -174,7 +178,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
if (device[0] != '\0') {
DM_STRNCPY(linker, device, sizeof(linker));
char *vid = strchr(linker, '.');
char *vid = DM_STRCHR(linker, '.');
if (vid) *vid = '\0';
} else {
struct uci_section *ss = NULL;
@ -203,7 +207,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
uci_foreach_sections("network", "interface", s) {
char *proto;
dmuci_get_value_by_section_string(s, "proto", &proto);
if (!strstr(proto, "ppp"))
if (!DM_LSTRSTR(proto, "ppp"))
continue;
// The higher layer is Device.PPP.Interface.{i}.
@ -219,6 +223,11 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
int found = 0;
// The lower layer is Device.Ethernet.VLANTermination.{i}.
char *ppp_device = get_device(section_name(s));
/* If the device value is empty, then get its value directly from device option */
if (*ppp_device == '\0')
dmuci_get_value_by_section_string(s, "device", &ppp_device);
if (ppp_device[0] != '\0') {
struct uci_section *vlan_sect = NULL;
adm_entry_get_linker_param(dmctx, "Device.Ethernet.VLANTermination.", ppp_device, &value);
@ -235,7 +244,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
// The lower layer is Device.Ethernet.Link.{i}.
char linker[32] = {0};
DM_STRNCPY(linker, ppp_device, sizeof(linker));
char *vid = strchr(linker, '.');
char *vid = DM_STRCHR(linker, '.');
if (vid) *vid = '\0';
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", linker, &value);
loweralias = get_alias_by_section("dmmap", "link", s, "link_alias");
@ -253,10 +262,19 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
/* Higher layers are Device.Ethernet.VLANTermination.{i}. */
uci_foreach_sections("network", "device", s) {
char *type, *name, *value = NULL;
struct uci_section *dmmap_section = NULL;
char *type, *name, *ifname, *is_vlan, *value = NULL;
get_dmmap_section_of_config_section("dmmap_network", "device", section_name(s), &dmmap_section);
dmuci_get_value_by_section_string(dmmap_section, "is_vlan_ter", &is_vlan);
dmuci_get_value_by_section_string(s, "type", &type);
dmuci_get_value_by_section_string(s, "name", &name);
if (strcmp(type, "bridge") == 0 || strcmp(type, "untagged") == 0)
dmuci_get_value_by_section_string(s, "ifname", &ifname);
if (DM_LSTRCMP(type, "bridge") == 0 ||
DM_LSTRCMP(type, "untagged") == 0 ||
(*name == 0 && DM_LSTRCMP(is_vlan, "1") != 0) ||
(*name != 0 && !ethernet___check_vlan_termination_section(name)))
continue;
// The higher layer is Device.Ethernet.VLANTermination.{i}.
@ -269,19 +287,40 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
higheralias = get_alias_by_section("dmmap_network", "device", s, "vlan_term_alias");
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *higheralias ? higheralias : *layer_inst ? "cpe-" : "", (*higheralias == '\0' && *layer_inst) ? layer_inst : "");
// The lower layer is Device.Ethernet.Link.{i}.
char *vid = strchr(name, '.');
if (vid) *vid = '\0';
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", name, &value);
if (value == NULL)
value = "";
// The lower layer can be Device.Ethernet.VLANTermination.{i}. or Device.Ethernet.Link.{i}.
if (DM_LSTRNCMP(type, "8021ad", 6) == 0) {
// The lower layer is Device.Ethernet.VLANTermination.{i}.
struct uci_section *vlan_sect = NULL;
char *inner_vid = NULL;
char dev_name[32] = {0};
struct uci_section *link_s = NULL;
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", name, &link_s);
dmuci_get_value_by_section_string(link_s, "link_instance", &layer_inst);
dmuci_get_value_by_section_string(link_s, "link_alias", &loweralias);
dmuci_get_value_by_section_string(s, "inner_vid", &inner_vid);
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value);
snprintf(dev_name, sizeof(dev_name), "%s.%s", ifname, inner_vid);
adm_entry_get_linker_param(dmctx, "Device.Ethernet.VLANTermination.", dev_name, &value);
uci_foreach_option_eq("network", "device", "name", dev_name, vlan_sect) {
loweralias = get_alias_by_section("dmmap_network", "device", vlan_sect, "vlan_term_alias");
layer_inst = get_instance_by_section(dmctx->instance_mode, "dmmap_network", "device", "section_name", section_name(vlan_sect), "vlan_term_instance", "vlan_term_alias");
break;
}
} else {
// The lower layer is Device.Ethernet.Link.{i}.
struct uci_section *link_s = NULL;
bool is_ifname = false;
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", name, &value);
if (!value || *value == 0) {
is_ifname = true;
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Link.", ifname, &value);
}
get_dmmap_section_of_config_section_eq("dmmap", "link", "device", is_ifname ? ifname : name, &link_s);
dmuci_get_value_by_section_string(link_s, "link_instance", &layer_inst);
dmuci_get_value_by_section_string(link_s, "link_alias", &loweralias);
}
snprintf(buf_lowerlayer, sizeof(buf_lowerlayer), "%s", value ? value : "");
snprintf(buf_loweralias, sizeof(buf_loweralias), "%s%s", *loweralias ? loweralias : *layer_inst ? "cpe-" : "", (*loweralias == '\0' && *layer_inst) ? layer_inst : "");
if (create_and_link_interface_stack_instance(dmctx, parent_node, buf_higherlayer, buf_lowerlayer, buf_higheralias, buf_loweralias, &instance))
@ -304,10 +343,10 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
char *linker, *value = NULL, *device_s_type = NULL;
dmuci_get_value_by_section_string(s, "device", &linker);
struct uci_section *br_device_s = get_device_section(linker);
struct uci_section *br_device_s = ethernet___get_device_section(linker);
if (br_device_s) dmuci_get_value_by_section_string(br_device_s, "type", &device_s_type);
if (br_device_s && strcmp(device_s_type, "bridge") == 0) {
if (br_device_s && DM_LSTRCMP(device_s_type, "bridge") == 0) {
// The lower layer is Device.Bridging.Bridge.{i}.Port.{i}.
struct uci_section *dmmap_section, *port = NULL;
@ -319,12 +358,12 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
dmuci_get_value_by_section_string(dmmap_section, "bridge_instance", &br_inst);
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, port) {
dmuci_get_value_by_section_string(port, "management", &mg);
if (mg && strcmp(mg, "1") == 0) {
char *device, linker[512] = {0};
if (mg && DM_LSTRCMP(mg, "1") == 0) {
char *device, linker_buf[512] = {0};
dmuci_get_value_by_section_string(port, "port", &device);
snprintf(linker, sizeof(linker), "br_%s:%s+%s", br_inst, section_name(port), device);
adm_entry_get_linker_param(dmctx, "Device.Bridging.Bridge.", linker, &value);
snprintf(linker_buf, sizeof(linker_buf), "br_%s:%s+%s", br_inst, section_name(port), device);
adm_entry_get_linker_param(dmctx, "Device.Bridging.Bridge.", linker_buf, &value);
dmuci_get_value_by_section_string(port, "bridge_port_alias", &loweralias);
dmuci_get_value_by_section_string(port, "bridge_port_instance", &layer_inst);
break;
@ -333,9 +372,9 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
}
} else {
// The lower layer is Device.Ethernet.Interface.{i}.
char *vid = strchr(linker, '.');
char *vid = DM_STRCHR(linker, '.');
if (vid) *vid = '\0';
char *macvlan = strchr(linker, '_');
char *macvlan = DM_STRCHR(linker, '_');
if (macvlan)
*macvlan = '\0';
struct uci_section *eth_port_sect = NULL, *eth_port_dmms = NULL;
@ -379,7 +418,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
char *mg = NULL;
dmuci_get_value_by_section_string(port, "management", &mg);
if (mg && strcmp(mg, "1") == 0) {
if (mg && DM_LSTRCMP(mg, "1") == 0) {
char *device, linker[512] = {0};
dmuci_get_value_by_section_string(port, "port", &device);
@ -400,7 +439,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
uci_path_foreach_option_eq(bbfdm, "dmmap_bridge_port", "bridge_port", "br_inst", br_inst, sd) {
char *mg = NULL;
dmuci_get_value_by_section_string(sd, "management", &mg);
if (mg && strcmp(mg, "1") == 0)
if (mg && DM_LSTRCMP(mg, "1") == 0)
continue;
char *vb = NULL, *device, linker[512] = {0};
@ -455,7 +494,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
// The lower layer is Device.ATM.Link.{i}.
if (!found && value == NULL) {
char *tag = strchr(device, '.');
char *tag = DM_STRCHR(device, '.');
if (tag) *tag = '\0';
adm_entry_get_linker_param(dmctx, "Device.ATM.Link.", device, &value);
}
@ -473,7 +512,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
// The lower layer is Device.PTM.Link.{i}.
if (!found && value == NULL) {
char *tag = strchr(device, '.');
char *tag = DM_STRCHR(device, '.');
if (tag) *tag = '\0';
adm_entry_get_linker_param(dmctx, "Device.PTM.Link.", device, &value);
}
@ -491,7 +530,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
// The lower layer is Device.Ethernet.Interface.{i}.
if (!found && value == NULL) {
char *tag = strchr(device, '.');
char *tag = DM_STRCHR(device, '.');
if (tag) *tag = '\0';
adm_entry_get_linker_param(dmctx, "Device.Ethernet.Interface.", device, &value);
}
@ -515,7 +554,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
goto end;
// The lower layer is Device.WiFi.Radio.{i}.
if(strcmp(package, "wireless") == 0) {
if(DM_LSTRCMP(package, "wireless") == 0) {
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *loweralias ? loweralias : *bridge_port_inst ? "cpe-" : "", (*loweralias == '\0' && *bridge_port_inst) ? bridge_port_inst : "");
@ -548,7 +587,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
}
// The lower layer is Device.DSL.Channel.{i}.
if(strcmp(package, "dsl:atm") == 0) {
if(DM_LSTRCMP(package, "dsl:atm") == 0) {
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *loweralias ? loweralias : *bridge_port_inst ? "cpe-" : "", (*loweralias == '\0' && *bridge_port_inst) ? bridge_port_inst : "");
@ -570,7 +609,7 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
}
// The lower layer is Device.DSL.Line.{i}.
if(strcmp(package, "dsl:ptm") == 0) {
if(DM_LSTRCMP(package, "dsl:ptm") == 0) {
snprintf(buf_higheralias, sizeof(buf_higheralias), "%s%s", *loweralias ? loweralias : *bridge_port_inst ? "cpe-" : "", (*loweralias == '\0' && *bridge_port_inst) ? bridge_port_inst : "");
@ -621,6 +660,7 @@ static int set_InterfaceStack_Alias(char *refparam, struct dmctx *ctx, void *dat
return FAULT_9007;
break;
case VALUESET:
// cppcheck-suppress unknownMacro
uci_path_foreach_option_eq(bbfdm, "dmmap_interface_stack", "interface_stack", "interface_stack_instance", instance, s)
dmuci_set_value_by_section(s, "interface_stack_alias", value);
break;
@ -657,11 +697,11 @@ static int get_InterfaceStack_LowerAlias(char *refparam, struct dmctx *ctx, void
***********************************************************************************************************************************/
/* *** Device.InterfaceStack.{i}. *** */
DMLEAF tInterfaceStackParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Alias", &DMWRITE, DMT_STRING, get_InterfaceStack_Alias, set_InterfaceStack_Alias, BBFDM_BOTH},
{"HigherLayer", &DMREAD, DMT_STRING, get_InterfaceStack_HigherLayer, NULL, BBFDM_BOTH},
{"LowerLayer", &DMREAD, DMT_STRING, get_InterfaceStack_LowerLayer, NULL, BBFDM_BOTH},
{"HigherAlias", &DMREAD, DMT_STRING, get_InterfaceStack_HigherAlias, NULL, BBFDM_BOTH},
{"LowerAlias", &DMREAD, DMT_STRING, get_InterfaceStack_LowerAlias, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Alias", &DMWRITE, DMT_STRING, get_InterfaceStack_Alias, set_InterfaceStack_Alias, BBFDM_BOTH, "2.3"},
{"HigherLayer", &DMREAD, DMT_STRING, get_InterfaceStack_HigherLayer, NULL, BBFDM_BOTH, "2.0"},
{"LowerLayer", &DMREAD, DMT_STRING, get_InterfaceStack_LowerLayer, NULL, BBFDM_BOTH, "2.0"},
{"HigherAlias", &DMREAD, DMT_STRING, get_InterfaceStack_HigherAlias, NULL, BBFDM_BOTH, "2.0"},
{"LowerAlias", &DMREAD, DMT_STRING, get_InterfaceStack_LowerAlias, NULL, BBFDM_BOTH, "2.0"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __INTERFACESTACK_H
#define __INTERFACESTACK_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMLEAF tInterfaceStackParams[];

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,7 @@
#ifndef __IP_H
#define __IP_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tIPObj[];
extern DMLEAF tIPParams[];

View file

@ -35,6 +35,7 @@ static int set_LANConfigSecurity_ConfigPassword(char *refparam, struct dmctx *ct
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
DMLEAF tLANConfigSecurityParams[] = {
{"ConfigPassword", &DMWRITE, DMT_STRING, get_LANConfigSecurity_ConfigPassword, set_LANConfigSecurity_ConfigPassword, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ConfigPassword", &DMWRITE, DMT_STRING, get_LANConfigSecurity_ConfigPassword, set_LANConfigSecurity_ConfigPassword, BBFDM_BOTH, "2.0"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __LANCONFIGSECURITY_H
#define __LANCONFIGSECURITY_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMLEAF tLANConfigSecurityParams[];

View file

@ -17,18 +17,22 @@
/*#Device.ManagementServer.URL!UCI:cwmp/acs,acs/url*/
static int get_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *dhcp = NULL, *url = NULL, *provisioning_value = NULL;
char *dhcp = NULL, *url = NULL, *dhcp_url = NULL;
bool discovery = false;
dmuci_get_option_value_string("cwmp", "acs", "dhcp_discovery", &dhcp);
dmuci_get_option_value_string("cwmp", "acs", "url", &url);
varstate_get_value_string("cwmp", "acs", "dhcp_url", &provisioning_value);
dmuci_get_option_value_string("cwmp", "acs", "dhcp_url", &dhcp_url);
if ( ((dhcp && strcmp(dhcp, "enable") == 0 ) || ((url == NULL) || (url[0] == '\0'))) && ((provisioning_value != NULL) && (provisioning_value[0] != '\0')) )
*value = provisioning_value;
else if ((url != NULL) && (url[0] != '\0'))
discovery = dmuci_string_to_boolean(dhcp);
if ((discovery == true) && (DM_STRLEN(dhcp_url) != 0))
*value = dhcp_url;
else if (DM_STRLEN(url) != 0)
*value = url;
else
*value = dmstrdup("http://192.168.1.1:8080/openacs/acs");
*value = "";
return 0;
}
@ -133,7 +137,7 @@ static int set_management_server_delay_reboot(char *refparam, struct dmctx *ctx,
/*#Device.ManagementServer.ParameterKey!UCI:cwmp/acs,acs/ParameterKey*/
static int get_management_server_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "ParameterKey", value);
dmuci_get_option_value_string_varstate("cwmp", "cpe", "ParameterKey", value);
return 0;
}
@ -208,7 +212,7 @@ static int set_management_server_periodic_inform_time(char *refparam, struct dmc
static int network_get_ipaddr(char *iface, int ipver, char **value)
{
json_object *res, *jobj;
json_object *res = NULL, *jobj = NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", iface, String}}, 1, &res);
DM_ASSERT(res, *value = "");
@ -227,23 +231,55 @@ static int network_get_ipaddr(char *iface, int ipver, char **value)
return 0;
}
static void get_management_ip_port(char **listen_addr)
{
char *ip = NULL, *port = NULL, *interface = NULL, *if_name = NULL, *version = NULL;
dmuci_get_option_value_string("cwmp", "cpe", "default_wan_interface", &interface);
dmuci_get_option_value_string("cwmp", "cpe", "interface", &if_name);
dmuci_get_option_value_string("cwmp", "acs", "ip_version", &version);
dmuci_get_option_value_string("cwmp", "cpe", "port", &port);
if (network_get_ipaddr(interface, *version == '6' ? 6 : 4, &ip) == -1) {
if (if_name[0] == '\0')
return;
ip = (*version == '6') ? get_ipv6(if_name) : ioctl_get_ipv4(if_name);
}
if (ip[0] != '\0' && port[0] != '\0') {
dmasprintf(listen_addr, "%s:%s", ip, port);
}
}
/*#Device.ManagementServer.ConnectionRequestURL!UCI:cwmp/cpe,cpe/port*/
static int get_management_server_connection_request_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *ip = NULL, *port = NULL, *iface = NULL, *ip_version = NULL;
char *mgmt_addr = NULL;
get_management_ip_port(&mgmt_addr);
dmuci_get_option_value_string("cwmp", "cpe", "default_wan_interface", &iface);
dmuci_get_option_value_string("cwmp", "acs", "ip_version", &ip_version);
network_get_ipaddr(iface, ip_version&&ip_version[0]=='6'?6:4, &ip);
dmuci_get_option_value_string("cwmp", "cpe", "port", &port);
if (ip[0] != '\0' && port[0] != '\0') {
if (mgmt_addr != NULL) {
char *path;
dmuci_get_option_value_string("cwmp", "cpe", "path", &path);
dmasprintf(value, "http://%s:%s/%s", ip, port, path ? path : "");
dmasprintf(value, "http://%s/%s", mgmt_addr, path ? path : "");
}
return 0;
}
static int get_upd_cr_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *stunc_enabled;
bool enabled;
dmuci_get_option_value_string("stunc", "stunc", "enabled", &stunc_enabled);
enabled = dmuci_string_to_boolean(stunc_enabled);
if (enabled == true)
dmuci_get_option_value_string_varstate("stunc", "stunc", "crudp_address", value);
else
get_management_ip_port(value);
return 0;
}
@ -333,7 +369,7 @@ static int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data,
return FAULT_9007;
return 0;
case VALUESET:
if (strcmp(value,"UDP") == 0)
if (DM_LSTRCMP(value,"UDP") == 0)
dmuci_set_value("cwmp", "lwn", "enable", "1");
else
dmuci_set_value("cwmp", "lwn", "enable", "0");
@ -420,7 +456,19 @@ static int set_management_server_http_compression(char *refparam, struct dmctx *
/*#Device.ManagementServer.CWMPRetryMinimumWaitInterval!UCI:cwmp/acs,acs/retry_min_wait_interval*/
static int get_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_option_value_fallback_def("cwmp", "acs", "retry_min_wait_interval", "5");
char *dhcp = NULL, *dhcp_retry_min_wait_interval = NULL;
bool discovery = false;
dmuci_get_option_value_string("cwmp", "acs", "dhcp_discovery", &dhcp);
dmuci_get_option_value_string("cwmp", "acs", "dhcp_retry_min_wait_interval", &dhcp_retry_min_wait_interval);
discovery = dmuci_string_to_boolean(dhcp);
if ((discovery == true) && (DM_STRLEN(dhcp_retry_min_wait_interval) != 0))
*value = dhcp_retry_min_wait_interval;
else
*value = dmuci_get_option_value_fallback_def("cwmp", "acs", "retry_min_wait_interval", "5");
return 0;
}
@ -442,7 +490,19 @@ static int set_management_server_retry_min_wait_interval(char *refparam, struct
/*#Device.ManagementServer.CWMPRetryIntervalMultiplier!UCI:cwmp/acs,acs/retry_interval_multiplier*/
static int get_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_option_value_fallback_def("cwmp", "acs", "retry_interval_multiplier", "2000");
char *dhcp = NULL, *dhcp_retry_interval_multiplier = NULL;
bool discovery = false;
dmuci_get_option_value_string("cwmp", "acs", "dhcp_discovery", &dhcp);
dmuci_get_option_value_string("cwmp", "acs", "dhcp_retry_interval_multiplier", &dhcp_retry_interval_multiplier);
discovery = dmuci_string_to_boolean(dhcp);
if ((discovery == true) && (DM_STRLEN(dhcp_retry_interval_multiplier) != 0))
*value = dhcp_retry_interval_multiplier;
else
*value = dmuci_get_option_value_fallback_def("cwmp", "acs", "retry_interval_multiplier", "2000");
return 0;
}
@ -465,7 +525,7 @@ static int set_management_server_retry_interval_multiplier(char *refparam, struc
static int get_alias_based_addressing(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *res = dmuci_get_option_value_fallback_def("cwmp", "cpe", "amd_version", "5");
*value = (atoi(res) <= AMD_4) ? "false" : "true";
*value = (DM_STRTOL(res) <= AMD_4) ? "false" : "true";
return 0;
}
@ -491,127 +551,172 @@ static int set_instance_mode(char *refparam, struct dmctx *ctx, void *data, char
return 0;
}
/*
* XMPP parameters
*/
/*#Device.ManagementServer.ConnReqAllowedJabberIDs!UCI:xmpp/xmpp,xmpp/allowed_jid*/
static int get_management_server_conn_rep_allowed_jabber_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("xmpp", "xmpp", "allowed_jid", value);
return 0;
}
static int set_management_server_conn_rep_allowed_jabber_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, -1, 32, -1, -1, 256, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("xmpp", "xmpp", "allowed_jid", value);
return 0;
}
return 0;
}
static int get_management_server_conn_req_jabber_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
char *username, *domain, *resource, *tmpPtr = NULL, *strResponse = NULL;
uci_foreach_sections("xmpp", "xmpp_connection", s) {
dmuci_get_value_by_section_string(s, "username", &username);
dmuci_get_value_by_section_string(s, "domain", &domain);
dmuci_get_value_by_section_string(s, "resource", &resource);
if(*username != '\0' || *domain != '\0' || *resource != '\0') {
if(!strResponse)
dmasprintf(&strResponse, "%s@%s/%s", username, domain, resource);
else {
tmpPtr = dmstrdup(strResponse);
dmfree(strResponse);
dmasprintf(&strResponse, "%s,%s@%s/%s", tmpPtr, username, domain, resource);
dmfree(tmpPtr);
}
}
}
*value = strResponse ? strResponse : "";
return 0;
}
static int get_management_server_conn_req_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *id;
dmuci_get_option_value_string("xmpp", "xmpp", "id", &id);
if (*id != '\0' && *id != '0') dmasprintf(value, "Device.XMPP.Connection.%s", id);
return 0;
}
static int set_management_server_conn_req_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *str, *xmpp_id;
struct uci_section *s = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, -1, NULL, NULL))
return FAULT_9007;
return 0;
case VALUESET:
if ((str = strstr(value, "Device.XMPP.Connection."))) {
value = dmstrdup(str + sizeof("Device.XMPP.Connection.") - 1); //MEM WILL BE FREED IN DMMEMCLEAN
}
uci_foreach_sections("xmpp", "connection", s) {
dmuci_get_value_by_section_string(s, "xmpp_id", &xmpp_id);
if(strcmp(value, xmpp_id) == 0) {
dmuci_set_value("xmpp", "xmpp", "id", value);
break;
}
}
return 0;
}
return 0;
}
static int get_management_server_supported_conn_req_methods(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "HTTP,XMPP,STUN";
return 0;
}
static int get_management_server_instance_wildcard_supported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "true";
return 0;
}
static int get_management_server_enable_cwmp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "enable", value);
if ((*value)[0] == '\0')
*value = "1";
return 0;
}
static int set_management_server_enable_cwmp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value("cwmp", "cpe", "enable", b ? "1" : "0");
return 0;
}
return 0;
}
static int get_nat_detected(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *v;
bool en = 0;
dmuci_get_option_value_string("stunc", "stunc", "enabled", &v);
en = dmuci_string_to_boolean(v);
if (en == true) { //stunc is enabled
dmuci_get_option_value_string_varstate("stunc", "stunc", "nat_detected", &v);
en = dmuci_string_to_boolean(v);
*value = (en == true) ? "1" : "0";
} else {
*value = "0";
}
return 0;
}
static int get_heart_beat_policy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_option_value_fallback_def("cwmp", "acs", "heartbeat_enable", "0");
return 0;
}
static int set_heart_beat_policy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (dm_validate_boolean(value))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "heartbeat_enable", value);
bbf_set_end_session_flag(ctx, BBF_END_SESSION_RELOAD);
return 0;
}
return 0;
}
static int get_heart_beat_policy_reporting_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmuci_get_option_value_fallback_def("cwmp", "acs", "heartbeat_interval", "30");
return 0;
}
static int set_heart_beat_policy_reporting_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, RANGE_ARGS{{"20",NULL}}, 1))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "heartbeat_interval", value);
bbf_set_end_session_flag(ctx, BBF_END_SESSION_RELOAD);
return 0;
}
return 0;
}
static int get_heart_beat_policy_initiation_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "heartbeat_time", value);
return 0;
}
static int set_heart_beat_policy_initiation_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (dm_validate_dateTime(value))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("cwmp", "acs", "heartbeat_time", value);
bbf_set_end_session_flag(ctx, BBF_END_SESSION_RELOAD);
return 0;
}
return 0;
}
/**********************************************************************************************************************************
* OBJ & PARAM DEFINITION
***********************************************************************************************************************************/
/*** ManagementServer. ***/
DMLEAF tManagementServerParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"URL", &DMWRITE, DMT_STRING, get_management_server_url, set_management_server_url, BBFDM_CWMP},
{"Username", &DMWRITE, DMT_STRING, get_management_server_username, set_management_server_username, BBFDM_CWMP},
{"Password", &DMWRITE, DMT_STRING, get_empty, set_management_server_passwd, BBFDM_CWMP},
{"ScheduleReboot", &DMWRITE, DMT_TIME, get_management_server_schedule_reboot, set_management_server_schedule_reboot, BBFDM_CWMP},
{"DelayReboot", &DMWRITE, DMT_INT, get_management_server_delay_reboot, set_management_server_delay_reboot, BBFDM_CWMP},
{"PeriodicInformEnable", &DMWRITE, DMT_BOOL, get_management_server_periodic_inform_enable, set_management_server_periodic_inform_enable, BBFDM_CWMP},
{"PeriodicInformInterval", &DMWRITE, DMT_UNINT, get_management_server_periodic_inform_interval, set_management_server_periodic_inform_interval, BBFDM_CWMP},
{"PeriodicInformTime", &DMWRITE, DMT_TIME, get_management_server_periodic_inform_time, set_management_server_periodic_inform_time, BBFDM_CWMP},
{"ParameterKey", &DMREAD, DMT_STRING, get_management_server_key, NULL, BBFDM_CWMP},
{"ConnectionRequestURL", &DMREAD, DMT_STRING, get_management_server_connection_request_url, NULL, BBFDM_CWMP},
{"ConnectionRequestUsername", &DMWRITE, DMT_STRING, get_management_server_connection_request_username, set_management_server_connection_request_username, BBFDM_CWMP},
{"ConnectionRequestPassword", &DMWRITE, DMT_STRING, get_empty, set_management_server_connection_request_passwd, BBFDM_CWMP},
{"UpgradesManaged", &DMWRITE, DMT_BOOL, get_upgrades_managed, set_upgrades_managed, BBFDM_CWMP},
{"HTTPCompressionSupported", &DMREAD, DMT_STRING, get_management_server_http_compression_supportted, NULL, BBFDM_CWMP},
{"HTTPCompression", &DMWRITE, DMT_STRING, get_management_server_http_compression, set_management_server_http_compression, BBFDM_CWMP},
{"LightweightNotificationProtocolsSupported", &DMREAD, DMT_STRING, get_lwn_protocol_supported, NULL, BBFDM_CWMP},
{"LightweightNotificationProtocolsUsed", &DMWRITE, DMT_STRING, get_lwn_protocol_used, set_lwn_protocol_used, BBFDM_CWMP},
{"UDPLightweightNotificationHost", &DMWRITE, DMT_STRING, get_lwn_host, set_lwn_host, BBFDM_CWMP},
{"UDPLightweightNotificationPort", &DMWRITE, DMT_UNINT, get_lwn_port, set_lwn_port, BBFDM_CWMP},
{"CWMPRetryMinimumWaitInterval", &DMWRITE, DMT_UNINT, get_management_server_retry_min_wait_interval, set_management_server_retry_min_wait_interval, BBFDM_CWMP},
{"CWMPRetryIntervalMultiplier", &DMWRITE, DMT_UNINT, get_management_server_retry_interval_multiplier, set_management_server_retry_interval_multiplier, BBFDM_CWMP},
{"AliasBasedAddressing", &DMREAD, DMT_BOOL, get_alias_based_addressing, NULL, BBFDM_CWMP},
{"InstanceMode", &DMWRITE, DMT_STRING, get_instance_mode, set_instance_mode, BBFDM_CWMP},
{"ConnReqAllowedJabberIDs", &DMWRITE, DMT_STRING, get_management_server_conn_rep_allowed_jabber_id, set_management_server_conn_rep_allowed_jabber_id, BBFDM_CWMP},
{"ConnReqJabberID", &DMREAD, DMT_STRING, get_management_server_conn_req_jabber_id, NULL, BBFDM_CWMP},
{"ConnReqXMPPConnection", &DMWRITE, DMT_STRING, get_management_server_conn_req_xmpp_connection, set_management_server_conn_req_xmpp_connection, BBFDM_CWMP},
{"SupportedConnReqMethods", &DMREAD, DMT_STRING, get_management_server_supported_conn_req_methods, NULL, BBFDM_CWMP},
DMOBJ tManagementServerObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"HeartbeatPolicy", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tHeartbeatPolicyParams, NULL, BBFDM_CWMP, NULL, "2.12"},
{0}
};
/*** ManagementServer. ***/
DMLEAF tManagementServerParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"URL", &DMWRITE, DMT_STRING, get_management_server_url, set_management_server_url, BBFDM_CWMP},
{"Username", &DMWRITE, DMT_STRING, get_management_server_username, set_management_server_username, BBFDM_CWMP, "2.0"},
{"Password", &DMWRITE, DMT_STRING, get_empty, set_management_server_passwd, BBFDM_CWMP, "2.0"},
{"ScheduleReboot", &DMWRITE, DMT_TIME, get_management_server_schedule_reboot, set_management_server_schedule_reboot, BBFDM_CWMP, "2.10"},
{"DelayReboot", &DMWRITE, DMT_INT, get_management_server_delay_reboot, set_management_server_delay_reboot, BBFDM_CWMP, "2.10"},
{"PeriodicInformEnable", &DMWRITE, DMT_BOOL, get_management_server_periodic_inform_enable, set_management_server_periodic_inform_enable, BBFDM_CWMP, "2.0"},
{"PeriodicInformInterval", &DMWRITE, DMT_UNINT, get_management_server_periodic_inform_interval, set_management_server_periodic_inform_interval, BBFDM_CWMP, "2.0"},
{"PeriodicInformTime", &DMWRITE, DMT_TIME, get_management_server_periodic_inform_time, set_management_server_periodic_inform_time, BBFDM_CWMP, "2.0"},
{"ParameterKey", &DMREAD, DMT_STRING, get_management_server_key, NULL, BBFDM_CWMP, "2.0"},
{"ConnectionRequestURL", &DMREAD, DMT_STRING, get_management_server_connection_request_url, NULL, BBFDM_CWMP, "2.0"},
{"ConnectionRequestUsername", &DMWRITE, DMT_STRING, get_management_server_connection_request_username, set_management_server_connection_request_username, BBFDM_CWMP, "2.0"},
{"ConnectionRequestPassword", &DMWRITE, DMT_STRING, get_empty, set_management_server_connection_request_passwd, BBFDM_CWMP, "2.0"},
{"UpgradesManaged", &DMWRITE, DMT_BOOL, get_upgrades_managed, set_upgrades_managed, BBFDM_CWMP, "2.0"},
{"HTTPCompressionSupported", &DMREAD, DMT_STRING, get_management_server_http_compression_supportted, NULL, BBFDM_CWMP, "2.7"},
{"HTTPCompression", &DMWRITE, DMT_STRING, get_management_server_http_compression, set_management_server_http_compression, BBFDM_CWMP, "2.7"},
{"LightweightNotificationProtocolsSupported", &DMREAD, DMT_STRING, get_lwn_protocol_supported, NULL, BBFDM_CWMP, "2.7"},
{"LightweightNotificationProtocolsUsed", &DMWRITE, DMT_STRING, get_lwn_protocol_used, set_lwn_protocol_used, BBFDM_CWMP, "2.7"},
{"UDPLightweightNotificationHost", &DMWRITE, DMT_STRING, get_lwn_host, set_lwn_host, BBFDM_CWMP, "2.7"},
{"UDPLightweightNotificationPort", &DMWRITE, DMT_UNINT, get_lwn_port, set_lwn_port, BBFDM_CWMP, "2.7"},
{"CWMPRetryMinimumWaitInterval", &DMWRITE, DMT_UNINT, get_management_server_retry_min_wait_interval, set_management_server_retry_min_wait_interval, BBFDM_CWMP, "2.0"},
{"CWMPRetryIntervalMultiplier", &DMWRITE, DMT_UNINT, get_management_server_retry_interval_multiplier, set_management_server_retry_interval_multiplier, BBFDM_CWMP, "2.0"},
{"AliasBasedAddressing", &DMREAD, DMT_BOOL, get_alias_based_addressing, NULL, BBFDM_CWMP, "2.3"},
{"InstanceMode", &DMWRITE, DMT_STRING, get_instance_mode, set_instance_mode, BBFDM_CWMP, "2.3"},
{"SupportedConnReqMethods", &DMREAD, DMT_STRING, get_management_server_supported_conn_req_methods, NULL, BBFDM_CWMP, "2.7"},
{"InstanceWildcardsSupported", &DMREAD, DMT_BOOL, get_management_server_instance_wildcard_supported, NULL, BBFDM_CWMP, "2.12"},
{"EnableCWMP", &DMWRITE, DMT_BOOL, get_management_server_enable_cwmp, set_management_server_enable_cwmp, BBFDM_CWMP, "2.12"},
{"UDPConnectionRequestAddress", &DMREAD, DMT_STRING, get_upd_cr_address, NULL, BBFDM_CWMP, "2.0"},
{"NATDetected", &DMREAD, DMT_BOOL, get_nat_detected, NULL, BBFDM_CWMP, "2.0"},
{0}
};
DMLEAF tHeartbeatPolicyParams[] = {
{"Enable", &DMWRITE, DMT_BOOL, get_heart_beat_policy_enable, set_heart_beat_policy_enable, BBFDM_CWMP, "2.12"},
{"ReportingInterval", &DMWRITE, DMT_UNINT, get_heart_beat_policy_reporting_interval, set_heart_beat_policy_reporting_interval, BBFDM_CWMP, "2.12"},
{"InitiationTime", &DMWRITE, DMT_TIME, get_heart_beat_policy_initiation_time, set_heart_beat_policy_initiation_time, BBFDM_CWMP, "2.12"},
{0}
};

View file

@ -12,8 +12,9 @@
#ifndef __MANAGEMENT_SERVER_H
#define __MANAGEMENT_SERVER_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMLEAF tManagementServerParams[];
extern DMLEAF tHeartbeatPolicyParams[];
extern DMOBJ tManagementServerObj[];
#endif

View file

@ -10,7 +10,6 @@
*
*/
#include "dmentry.h"
#include "nat.h"
/*************************************************************
@ -45,7 +44,7 @@ static int browsePortMappingInst(struct dmctx *dmctx, DMNODE *parent_node, void
synchronize_specific_config_sections_with_dmmap("firewall", "redirect", "dmmap_firewall", &dup_list);
list_for_each_entry(p, &dup_list, list) {
dmuci_get_value_by_section_string(p->config_section, "target", &target);
if (*target != '\0' && strcmp(target, "DNAT") != 0)
if (*target != '\0' && DM_LSTRCMP(target, "DNAT") != 0)
continue;
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "port_mapping_instance", "port_mapping_alias");
@ -63,18 +62,22 @@ static int browsePortMappingInst(struct dmctx *dmctx, DMNODE *parent_node, void
static int add_NAT_InterfaceSetting(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
struct uci_section *s = NULL, *dmmap_firewall = NULL;
char name[32];
char zone_name[16] = {0};
char name[16] = {0};
snprintf(name, sizeof(name), "iface_set_%s", *instance);
snprintf(zone_name, sizeof(zone_name), "zone_iface_%s", *instance);
snprintf(name, sizeof(name), "iface_%s", *instance);
dmuci_add_section("firewall", "zone", &s);
dmuci_rename_section_by_section(s, zone_name);
dmuci_set_value_by_section(s, "input", "REJECT");
dmuci_set_value_by_section(s, "output", "ACCEPT");
dmuci_set_value_by_section(s, "forward", "REJECT");
dmuci_set_value_by_section(s, "name", name);
dmuci_add_section_bbfdm("dmmap_firewall", "zone", &dmmap_firewall);
dmuci_set_value_by_section(dmmap_firewall, "section_name", section_name(s));
dmuci_set_value_by_section(dmmap_firewall, "section_name", zone_name);
dmuci_set_value_by_section(dmmap_firewall, "added_by_controller", "1");
dmuci_set_value_by_section(dmmap_firewall, "interface_setting_instance", *instance);
return 0;
}
@ -117,6 +120,7 @@ static int add_NAT_PortMapping(char *refparam, struct dmctx *ctx, void *data, ch
dmuci_add_section_bbfdm("dmmap_firewall", "redirect", &dmmap_firewall);
dmuci_set_value_by_section(dmmap_firewall, "section_name", s_name);
dmuci_set_value_by_section(dmmap_firewall, "port_mapping_instance", *instance);
dmuci_set_value_by_section(dmmap_firewall, "enabled", "0");
return 0;
}
@ -233,7 +237,7 @@ static int get_nat_interface_setting_interface(char *refparam, struct dmctx *ctx
uci_foreach_element(v, e) {
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", e->name, &ifaceobj); // MEM WILL BE FREED IN DMMEMCLEAN
if (ifaceobj)
if (ifaceobj && *ifaceobj)
pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", ifaceobj);
}
}
@ -248,22 +252,24 @@ static int get_nat_interface_setting_interface(char *refparam, struct dmctx *ctx
static int set_nat_interface_setting_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
char *iface, *pch, *pchr, buf[256] = "";
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
return 0;
case VALUESET:
DM_STRNCPY(buf, value, sizeof(buf));
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "network", "");
for(pch = strtok_r(buf, ",", &pchr); pch != NULL; pch = strtok_r(NULL, ",", &pchr)) {
adm_entry_get_linker_value(ctx, pch, &iface);
if (iface && *iface) {
dmuci_add_list_value_by_section(((struct dmmap_dup *)data)->config_section, "network", iface);
dmfree(iface);
}
dmuci_add_list_value_by_section(((struct dmmap_dup *)data)->config_section, "network", iface);
}
return 0;
}
@ -273,9 +279,7 @@ static int set_nat_interface_setting_interface(char *refparam, struct dmctx *ctx
/*#Device.NAT.PortMapping.{i}.Enable!UCI:firewall/redirect,@i-1/enabled*/
static int get_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *val;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "enabled", &val);
*value = (*val == '0') ? "0" : "1";
*value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->dmmap_section, "enabled", "1");
return 0;
}
@ -290,8 +294,8 @@ static int set_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->dmmap_section, "enabled", b ? "1" : "0");
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", b ? "1" : "0");
return 0;
}
return 0;
}
@ -299,9 +303,8 @@ static int set_nat_port_mapping_enable(char *refparam, struct dmctx *ctx, void *
/*#Device.NAT.PortMapping.{i}.Status!UCI:firewall/redirect,@i-1/enabled*/
static int get_nat_port_mapping_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *val;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "enabled", &val);
*value = (*val == '1') ? "Enabled" : "Disabled";
get_nat_port_mapping_enable(refparam, ctx, data, instance, value);
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
return 0;
}
@ -336,14 +339,14 @@ static int get_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, voi
unsigned pos = 0;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_dip", &src_dip);
if (src_dip && strcmp(src_dip, "*") == 0)
if (src_dip && DM_LSTRCMP(src_dip, "*") == 0)
return 0;
buf[0] = 0;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src", &zone_name);
uci_foreach_sections("firewall", "zone", s) {
dmuci_get_value_by_section_string(s, "name", &name);
if (zone_name && name && strcmp(zone_name, name) == 0) {
if (zone_name && name && DM_STRCMP(zone_name, name) == 0) {
dmuci_get_value_by_section_list(s, "network", &v);
break;
}
@ -355,7 +358,7 @@ static int get_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, voi
uci_foreach_element(v, e) {
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", e->name, &ifaceobj); // MEM WILL BE FREED IN DMMEMCLEAN
if (ifaceobj)
if (ifaceobj && *ifaceobj)
pos += snprintf(&buf[pos], sizeof(buf) - pos, "%s,", ifaceobj);
}
}
@ -370,27 +373,50 @@ static int get_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, voi
static int set_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *iface = NULL, *network, *zone;
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
char *iface = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &iface);
if (iface && *iface) {
struct uci_section *s = NULL;
bool zone_enable, sect_enable;
uci_foreach_sections("firewall", "zone", s) {
char *network = NULL;
dmuci_get_value_by_section_string(s, "network", &network);
if (is_strword_in_optionvalue(network, iface)) {
dmuci_get_value_by_section_string(s, "name", &zone);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src", zone);
char *zone_name = NULL;
char *zone_masq = NULL;
char *val = NULL;
dmuci_get_value_by_section_string(s, "name", &zone_name);
dmuci_get_value_by_section_string(s, "masq", &zone_masq);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src", zone_name);
// set this section enable parameter based on the configured zone masq value
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->dmmap_section, "enabled", &val);
sect_enable = (*val == '1') ? true : false;
zone_enable = (*zone_masq == '1') ? true : false;
sect_enable = sect_enable && zone_enable;
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "enabled", sect_enable ? "1" : "0");
break;
}
}
dmfree(iface);
} else {
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src", "");
}
break;
}
@ -435,8 +461,8 @@ static int get_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx
char *expiry_date = NULL;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "expiry", &expiry_date);
if (expiry_date && *expiry_date != '\0' && atoi(expiry_date) > 0) {
dmasprintf(value, "%ld", atoi(expiry_date) - time(NULL));
if (expiry_date && *expiry_date != '\0' && DM_STRTOL(expiry_date) > 0) {
dmasprintf(value, "%lld", (long long)(DM_STRTOL(expiry_date) - time(NULL)));
} else {
*value = "0";
}
@ -453,10 +479,10 @@ static int set_nat_port_mapping_lease_duration(char *refparam, struct dmctx *ctx
return FAULT_9007;
break;
case VALUESET:
if (value && atoi(value) == 0)
if (!value || DM_STRTOL(value) == 0)
break;
snprintf(expiry_date, sizeof(expiry_date), "%ld", atoi(value) + time(NULL));
snprintf(expiry_date, sizeof(expiry_date), "%lld", (long long)(DM_STRTOL(value) + time(NULL)));
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "expiry", expiry_date);
break;
}
@ -494,7 +520,7 @@ static int get_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx,
return 0;
}
char *tmp = src_dport ? strchr(src_dport, ':') : NULL;
char *tmp = src_dport ? DM_STRCHR(src_dport, ':') : NULL;
if (tmp)
*tmp = '\0';
*value = src_dport;
@ -512,7 +538,7 @@ static int set_nat_port_mapping_external_port(char *refparam, struct dmctx *ctx,
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_dport", &src_dport);
src_dport = src_dport ? strchr(src_dport, ':') : NULL;
src_dport = src_dport ? DM_STRCHR(src_dport, ':') : NULL;
if (src_dport == NULL)
snprintf(buffer, sizeof(buffer), "%s", value);
else
@ -528,7 +554,7 @@ static int get_nat_port_mapping_external_port_end_range(char *refparam, struct d
{
char *src_dport = NULL;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_dport", &src_dport);
char *tmp = src_dport ? strchr(src_dport, ':') : NULL;
char *tmp = src_dport ? DM_STRCHR(src_dport, ':') : NULL;
*value = tmp ? tmp + 1 : "0";
return 0;
}
@ -536,19 +562,39 @@ static int get_nat_port_mapping_external_port_end_range(char *refparam, struct d
static int set_nat_port_mapping_external_port_end_range(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *src_dport = NULL, *tmp = NULL, buffer[64];
uint16_t sport, dport;
switch (action) {
case VALUECHECK:
if (dm_validate_unsignedInt(value, RANGE_ARGS{{"0","65535"}}, 1))
return FAULT_9007;
return 0;
case VALUESET:
// Add check to check if the endrange > src_dport
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_dport", &src_dport);
tmp = src_dport ? strchr(src_dport, ':') : NULL;
tmp = src_dport ? DM_STRCHR(src_dport, ':') : NULL;
if (tmp)
*tmp = '\0';
snprintf(buffer, sizeof(buffer), "%s:%s", src_dport, value);
sport = DM_STRTOL(src_dport);
dport = DM_STRTOL(value);
if (dport != 0 && dport < sport)
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_dport", &src_dport);
tmp = src_dport ? DM_STRCHR(src_dport, ':') : NULL;
if (tmp)
*tmp = '\0';
sport = DM_STRTOL(src_dport);
dport = DM_STRTOL(value);
if (dport) // if not 0
snprintf(buffer, sizeof(buffer), "%d:%d", sport, dport);
else
snprintf(buffer, sizeof(buffer), "%d", sport);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_dport", buffer);
return 0;
}
@ -581,7 +627,7 @@ static int get_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void
{
char *proto = NULL;
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "proto", &proto);
*value = (proto && strcmp(proto, "udp") == 0) ? "UDP" : "TCP";
*value = (proto && DM_LSTRCMP(proto, "udp") == 0) ? "UDP" : "TCP";
return 0;
}
@ -593,7 +639,7 @@ static int set_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "proto", (strcmp("UDP", value) == 0) ? "udp" : "tcp");
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "proto", (DM_LSTRCMP(value, "UDP") == 0) ? "udp" : "tcp");
return 0;
}
return 0;
@ -646,44 +692,44 @@ static int set_nat_port_mapping_description(char *refparam, struct dmctx *ctx, v
***********************************************************************************************************************************/
/* *** Device.NAT. *** */
DMOBJ tNATObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"InterfaceSetting", &DMWRITE, add_NAT_InterfaceSetting, delete_NAT_InterfaceSetting, NULL, browseInterfaceSettingInst, NULL, NULL, NULL, tNATInterfaceSettingParams, NULL, BBFDM_BOTH, LIST_KEY{"Interface", "Alias", NULL}},
{"PortMapping", &DMWRITE, add_NAT_PortMapping, delete_NAT_PortMapping, NULL, browsePortMappingInst, NULL, NULL, NULL, tNATPortMappingParams, NULL, BBFDM_BOTH, LIST_KEY{"RemoteHost", "ExternalPort", "Protocol", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"InterfaceSetting", &DMWRITE, add_NAT_InterfaceSetting, delete_NAT_InterfaceSetting, NULL, browseInterfaceSettingInst, NULL, NULL, NULL, tNATInterfaceSettingParams, NULL, BBFDM_BOTH, LIST_KEY{"Interface", "Alias", NULL}, "2.0"},
{"PortMapping", &DMWRITE, add_NAT_PortMapping, delete_NAT_PortMapping, NULL, browsePortMappingInst, NULL, NULL, NULL, tNATPortMappingParams, NULL, BBFDM_BOTH, LIST_KEY{"RemoteHost", "ExternalPort", "Protocol", "Alias", NULL}, "2.0"},
{0}
};
DMLEAF tNATParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"InterfaceSettingNumberOfEntries", &DMREAD, DMT_UNINT, get_nat_interface_setting_number_of_entries, NULL, BBFDM_BOTH},
{"PortMappingNumberOfEntries", &DMREAD, DMT_UNINT, get_nat_port_mapping_number_of_entries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"InterfaceSettingNumberOfEntries", &DMREAD, DMT_UNINT, get_nat_interface_setting_number_of_entries, NULL, BBFDM_BOTH, "2.0"},
{"PortMappingNumberOfEntries", &DMREAD, DMT_UNINT, get_nat_port_mapping_number_of_entries, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.NAT.InterfaceSetting.{i}. *** */
DMLEAF tNATInterfaceSettingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_nat_interface_setting_enable, set_nat_interface_setting_enable, BBFDM_BOTH},
{"Status", &DMWRITE, DMT_STRING, get_nat_interface_setting_status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_nat_interface_setting_alias, set_nat_interface_setting_alias, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_nat_interface_setting_interface, set_nat_interface_setting_interface, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_nat_interface_setting_enable, set_nat_interface_setting_enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_nat_interface_setting_status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_nat_interface_setting_alias, set_nat_interface_setting_alias, BBFDM_BOTH, "2.0"},
{"Interface", &DMWRITE, DMT_STRING, get_nat_interface_setting_interface, set_nat_interface_setting_interface, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.NAT.PortMapping.{i}. *** */
DMLEAF tNATPortMappingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_nat_port_mapping_enable, set_nat_port_mapping_enable, BBFDM_BOTH},
{"Status", &DMWRITE, DMT_STRING, get_nat_port_mapping_status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_nat_port_mapping_alias, set_nat_port_mapping_alias, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_nat_port_mapping_interface, set_nat_port_mapping_interface, BBFDM_BOTH},
{"AllInterfaces", &DMWRITE, DMT_BOOL, get_nat_port_mapping_all_interface, set_nat_port_mapping_all_interface, BBFDM_BOTH},
{"LeaseDuration", &DMWRITE, DMT_UNINT, get_nat_port_mapping_lease_duration, set_nat_port_mapping_lease_duration, BBFDM_BOTH},
{"RemoteHost", &DMWRITE, DMT_STRING, get_nat_port_mapping_remote_host, set_nat_port_mapping_remote_host, BBFDM_BOTH},
{"ExternalPort", &DMWRITE, DMT_UNINT, get_nat_port_mapping_external_port, set_nat_port_mapping_external_port, BBFDM_BOTH},
{"ExternalPortEndRange", &DMWRITE, DMT_UNINT, get_nat_port_mapping_external_port_end_range, set_nat_port_mapping_external_port_end_range, BBFDM_BOTH},
{"InternalPort", &DMWRITE, DMT_UNINT, get_nat_port_mapping_internal_port, set_nat_port_mapping_internal_port, BBFDM_BOTH},
{"Protocol", &DMWRITE, DMT_STRING, get_nat_port_mapping_protocol, set_nat_port_mapping_protocol, BBFDM_BOTH},
{"InternalClient", &DMWRITE, DMT_STRING, get_nat_port_mapping_internal_client, set_nat_port_mapping_internal_client, BBFDM_BOTH},
{"Description", &DMWRITE, DMT_STRING, get_nat_port_mapping_description, set_nat_port_mapping_description, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_nat_port_mapping_enable, set_nat_port_mapping_enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_nat_port_mapping_status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_nat_port_mapping_alias, set_nat_port_mapping_alias, BBFDM_BOTH, "2.0"},
{"Interface", &DMWRITE, DMT_STRING, get_nat_port_mapping_interface, set_nat_port_mapping_interface, BBFDM_BOTH, "2.0"},
{"AllInterfaces", &DMWRITE, DMT_BOOL, get_nat_port_mapping_all_interface, set_nat_port_mapping_all_interface, BBFDM_BOTH, "2.0"},
{"LeaseDuration", &DMWRITE, DMT_UNINT, get_nat_port_mapping_lease_duration, set_nat_port_mapping_lease_duration, BBFDM_BOTH, "2.0"},
{"RemoteHost", &DMWRITE, DMT_STRING, get_nat_port_mapping_remote_host, set_nat_port_mapping_remote_host, BBFDM_BOTH, "2.0"},
{"ExternalPort", &DMWRITE, DMT_UNINT, get_nat_port_mapping_external_port, set_nat_port_mapping_external_port, BBFDM_BOTH, "2.0"},
{"ExternalPortEndRange", &DMWRITE, DMT_UNINT, get_nat_port_mapping_external_port_end_range, set_nat_port_mapping_external_port_end_range, BBFDM_BOTH, "2.0"},
{"InternalPort", &DMWRITE, DMT_UNINT, get_nat_port_mapping_internal_port, set_nat_port_mapping_internal_port, BBFDM_BOTH, "2.0"},
{"Protocol", &DMWRITE, DMT_STRING, get_nat_port_mapping_protocol, set_nat_port_mapping_protocol, BBFDM_BOTH, "2.0"},
{"InternalClient", &DMWRITE, DMT_STRING, get_nat_port_mapping_internal_client, set_nat_port_mapping_internal_client, BBFDM_BOTH, "2.0"},
{"Description", &DMWRITE, DMT_STRING, get_nat_port_mapping_description, set_nat_port_mapping_description, BBFDM_BOTH, "2.0"},
{0}
};

View file

@ -13,7 +13,7 @@
#ifndef __NAT_H
#define __NAT_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tNATObj[];
extern DMLEAF tNATParams[];

File diff suppressed because it is too large Load diff

View file

@ -12,7 +12,7 @@
#ifndef __PPP_H
#define __PPP_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
#define IPCP 0
#define IPCPv6 1
@ -26,4 +26,7 @@ extern DMLEAF tPPPInterfaceIPCPParams[];
extern DMLEAF tPPPInterfaceIPv6CPParams[];
extern DMLEAF tPPPInterfaceStatsParams[];
void ppp___update_sections(struct uci_section *s_from, struct uci_section *s_to);
void ppp___reset_options(struct uci_section *ppp_s);
#endif

View file

@ -9,7 +9,6 @@
*
*/
#include "dmentry.h"
#include "atm.h"
#include "ptm.h"
@ -193,10 +192,7 @@ static int find_lower_layer_by_dmmap_link(struct dmctx *ctx, void *data, char* d
char *linker = NULL;
dmuci_get_value_by_section_string((((struct ptm_args *)data)->sections)->dmmap_section, "ptm_ll_link", &linker);
if (linker != NULL)
adm_entry_get_linker_param(ctx, dm_object, linker, value);
if (*value == NULL)
*value = "";
adm_entry_get_linker_param(ctx, dm_object, linker, value);
return 0;
}
@ -204,7 +200,7 @@ static int get_ptm_dsl_channel(struct dmctx *ctx, void *data, char *instance, ch
{
char *ptm_file = NULL;
dmasprintf(&ptm_file, "/sys/class/net/ptm%d", atoi(instance) - 1);
dmasprintf(&ptm_file, "/sys/class/net/ptm%ld", DM_STRTOL(instance) - 1);
if (folder_exists(ptm_file)) {
*value = "Device.DSL.Channel.1";
dmuci_set_value_by_section((((struct ptm_args *)data)->sections)->dmmap_section, "ptm_ll_link", "fast_line_1");
@ -217,13 +213,13 @@ static int get_ptm_fast_line(struct dmctx *ctx, void *data, char *instance, char
{
json_object *res = NULL, *line_obj = NULL;
dmubus_call("fast", "status", UBUS_ARGS{}, 0, &res);
dmubus_call("fast", "status", UBUS_ARGS{0}, 0, &res);
if (!res)
return 0;
line_obj = dmjson_select_obj_in_array_idx(res, 0, 1, "line");
if (!line_obj)
return 0;
if ( strcmp(dmjson_get_value(line_obj, 1, "status"), "up") == 0) {
if ( DM_LSTRCMP(dmjson_get_value(line_obj, 1, "status"), "up") == 0) {
*value = "Device.FAST.Line.1";
dmuci_set_value_by_section((((struct ptm_args *)data)->sections)->dmmap_section, "ptm_ll_link", "fast_line_1");
}
@ -246,11 +242,11 @@ static int set_ptm_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
{
switch (action) {
case VALUECHECK:
if (strncmp(value, "Device.DSL.Channel.1", strlen("Device.DSL.Channel.1")) != 0 && strncmp(value, "Device.FAST.Line.1", strlen("Device.FAST.Line.1")) != 0)
if (DM_LSTRNCMP(value, "Device.DSL.Channel.1", strlen("Device.DSL.Channel.1")) != 0 && DM_LSTRNCMP(value, "Device.FAST.Line.1", strlen("Device.FAST.Line.1")) != 0)
return FAULT_9007;
break;
case VALUESET:
if (strcmp(value, "Device.DSL.Channel.1") == 0)
if (DM_LSTRCMP(value, "Device.DSL.Channel.1") == 0)
dmuci_set_value_by_section((((struct ptm_args *)data)->sections)->dmmap_section, "ptm_ll_link", "dsl_channel_1");
else
dmuci_set_value_by_section((((struct ptm_args *)data)->sections)->dmmap_section, "ptm_ll_link", "fast_line_1");
@ -299,34 +295,34 @@ static int get_ptm_stats_pack_sent(char *refparam, struct dmctx *ctx, void *data
***********************************************************************************************************************************/
/* *** Device.PTM. *** */
DMOBJ tPTMObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Link", &DMWRITE, add_ptm_link, delete_ptm_link, NULL, browsePtmLinkInst, NULL, NULL, tPTMLinkObj, tPTMLinkParams, get_ptm_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Link", &DMWRITE, add_ptm_link, delete_ptm_link, NULL, browsePtmLinkInst, NULL, NULL, tPTMLinkObj, tPTMLinkParams, get_ptm_linker, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.0"},
{0}
};
/* *** Device.PTM.Link.{i}. *** */
DMOBJ tPTMLinkObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tPTMLinkStatsParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tPTMLinkStatsParams, NULL, BBFDM_BOTH, NULL, "2.0"},
{0}
};
DMLEAF tPTMLinkParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_ptm_enable, set_ptm_enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_ptm_status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_ptm_alias, set_ptm_alias, BBFDM_BOTH},
{"Name", &DMREAD, DMT_STRING, get_ptm_link_name, NULL, BBFDM_BOTH},
{"LowerLayers", &DMWRITE, DMT_STRING, get_ptm_lower_layer, set_ptm_lower_layer, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_ptm_enable, set_ptm_enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_ptm_status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_ptm_alias, set_ptm_alias, BBFDM_BOTH, "2.0"},
{"Name", &DMREAD, DMT_STRING, get_ptm_link_name, NULL, BBFDM_BOTH, "2.0"},
{"LowerLayers", &DMWRITE, DMT_STRING, get_ptm_lower_layer, set_ptm_lower_layer, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.PTM.Link.{i}.Stats. *** */
DMLEAF tPTMLinkStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNLONG, get_ptm_stats_bytes_sent, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_ptm_stats_bytes_received, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_ptm_stats_pack_sent, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_ptm_stats_pack_received, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"BytesSent", &DMREAD, DMT_UNLONG, get_ptm_stats_bytes_sent, NULL, BBFDM_BOTH, "2.0"},
{"BytesReceived", &DMREAD, DMT_UNLONG, get_ptm_stats_bytes_received, NULL, BBFDM_BOTH, "2.0"},
{"PacketsSent", &DMREAD, DMT_UNLONG, get_ptm_stats_pack_sent, NULL, BBFDM_BOTH, "2.0"},
{"PacketsReceived", &DMREAD, DMT_UNLONG, get_ptm_stats_pack_received, NULL, BBFDM_BOTH, "2.0"},
{0}
};

View file

@ -12,7 +12,7 @@
#ifndef __PTM_H
#define __PTM_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tPTMObj[];
extern DMOBJ tPTMLinkObj[];

View file

@ -9,7 +9,6 @@
* Author: Rohit Topno <r.topno@gxgroup.eu>
*/
#include "dmentry.h"
#include "qos.h"
/*************************************************************
@ -34,7 +33,7 @@ static int browseQoSClassificationInst(struct dmctx *dmctx, DMNODE *parent_node,
//synchronizing option src_ip of uci classify section to src_mask/src_ip of dmmap's classify section
dmuci_get_value_by_section_string(p->config_section, "src_ip", &value);
//checking if src_ip is an ip-prefix or ip address and synchronizing accordingly
ret = strstr(value, "/");
ret = DM_LSTRSTR(value, "/");
if (ret)
dmuci_set_value_by_section_bbfdm(p->dmmap_section, "src_mask", value);
else
@ -43,7 +42,7 @@ static int browseQoSClassificationInst(struct dmctx *dmctx, DMNODE *parent_node,
//synchronizing option dest_ip of uci classify section to dest_mask/dest_ip of dmmap's classify section
dmuci_get_value_by_section_string(p->config_section, "dest_ip", &value);
//checking if src_ip is an ip-prefix or ip address and synchronizing accordingly
ret = strstr(value, "/");
ret = DM_LSTRSTR(value, "/");
if (ret)
dmuci_set_value_by_section_bbfdm(p->dmmap_section, "dest_mask", value);
else
@ -134,12 +133,16 @@ static int browseQoSShaperInst(struct dmctx *dmctx, DMNODE *parent_node, void *p
static int addObjQoSClassification(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
struct uci_section *dmmap = NULL, *s = NULL;
char buf[32] = {0};
snprintf(buf, sizeof(buf), "classify_%s", *instance);
dmuci_add_section("qos", "classify", &s);
dmuci_rename_section_by_section(s, buf);
dmuci_set_value_by_section(s, "enable", "0");
dmuci_add_section_bbfdm("dmmap_qos", "classify", &dmmap);
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
dmuci_set_value_by_section(dmmap, "section_name", buf);
dmuci_set_value_by_section(dmmap, "classify_instance", *instance);
return 0;
}
@ -341,33 +344,38 @@ static int get_QInterface(char *refparam, struct dmctx *ctx, void *data, char *i
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ifname", &ifname);
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", ifname, value);
if (*value == NULL)
if (!(*value) || (*value)[0] == 0)
adm_entry_get_linker_param(ctx, "Device.PPP.Interface.", ifname, value);
if (*value == NULL)
if (!(*value) || (*value)[0] == 0)
adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", ifname, value);
if (*value == NULL)
if (!(*value) || (*value)[0] == 0)
adm_entry_get_linker_param(ctx, "Device.WiFi.Radio.", ifname, value);
if (*value == NULL)
*value = "";
return 0;
}
static int set_QInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {
"Device.IP.Interface.",
"Device.PPP.Interface.",
"Device.Ethernet.Interface.",
"Device.WiFi.Radio.",
NULL};
char *linker = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
if (linker && *linker) {
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", linker);
dmfree(linker);
}
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "ifname", linker ? linker : "");
break;
}
return 0;
@ -813,7 +821,7 @@ static int get_QoSClassification_SourceClientID(char *refparam, struct dmctx *ct
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_client_id", &srcclid);
if (srcclid && *srcclid)
convert_string_to_hex(srcclid, hex);
convert_string_to_hex(srcclid, hex, sizeof(hex));
*value = (*hex) ? dmstrdup(hex) : "";
return 0;
@ -829,7 +837,7 @@ static int set_QoSClassification_SourceClientID(char *refparam, struct dmctx *ct
return FAULT_9007;
break;
case VALUESET:
convert_hex_to_string(value, res);
convert_hex_to_string(value, res, sizeof(res));
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_client_id", res);
break;
}
@ -843,7 +851,7 @@ static int get_QoSClassification_DestClientID(char *refparam, struct dmctx *ctx,
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dst_client_id", &dstclid);
if (dstclid && *dstclid)
convert_string_to_hex(dstclid, hex);
convert_string_to_hex(dstclid, hex, sizeof(hex));
*value = (*hex) ? dmstrdup(hex) : "";
return 0;
@ -859,7 +867,7 @@ static int set_QoSClassification_DestClientID(char *refparam, struct dmctx *ctx,
return FAULT_9007;
break;
case VALUESET:
convert_hex_to_string(value, res);
convert_hex_to_string(value, res, sizeof(res));
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "dst_client_id", res);
break;
}
@ -873,7 +881,7 @@ static int get_QoSClassification_SourceUserClassID(char *refparam, struct dmctx
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "src_user_class_id", &srcusrclid);
if (srcusrclid && *srcusrclid)
convert_string_to_hex(srcusrclid, hex);
convert_string_to_hex(srcusrclid, hex, sizeof(hex));
*value = (*hex) ? dmstrdup(hex) : "";
return 0;
@ -889,7 +897,7 @@ static int set_QoSClassification_SourceUserClassID(char *refparam, struct dmctx
return FAULT_9007;
break;
case VALUESET:
convert_hex_to_string(value, res);
convert_hex_to_string(value, res, sizeof(res));
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "src_user_class_id", res);
break;
}
@ -903,7 +911,7 @@ static int get_QoSClassification_DestUserClassID(char *refparam, struct dmctx *c
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "dst_user_class_id", &dstusrclid);
if (dstusrclid && *dstusrclid)
convert_string_to_hex(dstusrclid, hex);
convert_string_to_hex(dstusrclid, hex, sizeof(hex));
*value = (*hex) ? dmstrdup(hex) : "";
return 0;
@ -919,7 +927,7 @@ static int set_QoSClassification_DestUserClassID(char *refparam, struct dmctx *c
return FAULT_9007;
break;
case VALUESET:
convert_hex_to_string(value, res);
convert_hex_to_string(value, res, sizeof(res));
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "dst_user_class_id", res);
break;
}
@ -1087,7 +1095,7 @@ static int get_QoSClassification_Policer(char *refparam, struct dmctx *ctx, void
static int set_QoSClassification_Policer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *dmmap_s = NULL;
char *linker = NULL, link_inst[8] = {0};
char *linker = NULL;
switch (action) {
case VALUECHECK:
@ -1095,13 +1103,14 @@ static int set_QoSClassification_Policer(char *refparam, struct dmctx *ctx, void
return FAULT_9007;
break;
case VALUESET:
if (strncmp(value, "Device.QoS.Policer.", 19) != 0)
return 0;
if (DM_LSTRNCMP(value, "Device.QoS.Policer.", 19) == 0 && strlen(value) >= 20) {
char link_inst[8] = {0};
snprintf(link_inst, sizeof(link_inst), "%c", value[19]); // TODO implementation need to be revisited
get_dmmap_section_of_config_section_eq("dmmap_qos", "policer", "policer_instance", link_inst, &dmmap_s);
dmuci_get_value_by_section_string(dmmap_s, "section_name", &linker);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "policer", linker);
}
snprintf(link_inst, sizeof(link_inst), "%c", value[19]);
get_dmmap_section_of_config_section_eq("dmmap_qos", "policer", "policer_instance", link_inst, &dmmap_s);
dmuci_get_value_by_section_string(dmmap_s, "section_name", &linker);
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "policer", linker);
break;
}
return 0;
@ -1261,9 +1270,9 @@ static int set_QoSPolicer_PeakBurstSize(char *refparam, struct dmctx *ctx, void
static int get_QoSPolicer_MeterType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "meter_type", value);
if (strncmp(*value, "1", 1) == 0)
if (DM_LSTRNCMP(*value, "1", 1) == 0)
*value = "SingleRateThreeColor";
else if (strncmp(*value, "2", 1) == 0)
else if (DM_LSTRNCMP(*value, "2", 1) == 0)
*value = "TwoRateThreeColor";
else
*value = "SimpleTokenBucket";
@ -1275,15 +1284,15 @@ static int set_QoSPolicer_MeterType(char *refparam, struct dmctx *ctx, void *dat
{
switch (action) {
case VALUECHECK:
if ((strcmp("SimpleTokenBucket", value) != 0) && (strcmp("SingleRateThreeColor", value) != 0) && (strcmp("TwoRateThreeColor", value) != 0))
if ((DM_LSTRCMP(value, "SimpleTokenBucket") != 0) && (DM_LSTRCMP(value, "SingleRateThreeColor") != 0) && (DM_LSTRCMP(value, "TwoRateThreeColor") != 0))
return FAULT_9007;
break;
case VALUESET:
if (strcmp("SimpleTokenBucket", value) == 0)
if (DM_LSTRCMP(value, "SimpleTokenBucket") == 0)
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "meter_type", "0");
else if (strcmp("SingleRateThreeColor", value) == 0)
else if (DM_LSTRCMP(value, "SingleRateThreeColor") == 0)
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "meter_type", "1");
else if (strcmp("TwoRateThreeColor", value) == 0)
else if (DM_LSTRCMP(value, "TwoRateThreeColor") == 0)
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "meter_type", "2");
break;
}
@ -1504,7 +1513,7 @@ static int set_QoSQueueStats_Enable(char *refparam, struct dmctx *ctx, void *dat
static int get_QoSQueueStats_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
get_QoSQueueStats_Enable(refparam, ctx, data, instance, value);
*value = (strcmp(*value, "1") == 0) ? "Enabled" : "Disabled";
*value = (DM_LSTRCMP(*value, "1") == 0) ? "Enabled" : "Disabled";
return 0;
}
@ -1533,40 +1542,30 @@ static int set_QoSQueueStats_Alias(char *refparam, struct dmctx *ctx, void *data
static int get_QoSQueueStats_Queue(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *queue_link;
char *queue_link = NULL;
dmuci_get_value_by_section_string((struct uci_section *)data, "queue", &queue_link);
adm_entry_get_linker_param(ctx, "Device.QoS.Queue.", queue_link, value);
if (*value == NULL)
*value = "";
return 0;
}
static int set_QoSQueueStats_Queue(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *queue_link = NULL;
char *allowed_objects[] = {"Device.QoS.Queue.", NULL};
char *linker = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (value == NULL || *value == '\0')
break;
if (strncmp(value, "Device.QoS.Queue.", 17) != 0)
return FAULT_9007;
adm_entry_get_linker_value(ctx, value, &queue_link);
if (queue_link == NULL || *queue_link == '\0')
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
break;
case VALUESET:
if (value == NULL || *value == '\0')
break;
adm_entry_get_linker_value(ctx, value, &queue_link);
dmuci_set_value_by_section((struct uci_section *)data, "queue", queue_link);
adm_entry_get_linker_value(ctx, value, &linker);
dmuci_set_value_by_section((struct uci_section *)data, "queue", linker ? linker : "");
break;
}
return 0;
@ -1574,41 +1573,39 @@ static int set_QoSQueueStats_Queue(char *refparam, struct dmctx *ctx, void *data
static int get_QoSQueueStats_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *intf_link;
char *intf_link = NULL;
dmuci_get_value_by_section_string((struct uci_section *)data, "interface", &intf_link);
adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", intf_link, value);
if (*value == NULL)
if (!(*value) || (*value)[0] == 0)
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", intf_link, value);
if (*value == NULL)
if (!(*value) || (*value)[0] == 0)
adm_entry_get_linker_param(ctx, "Device.PPP.Interface.", intf_link, value);
if (*value == NULL)
*value = "";
return 0;
}
static int set_QoSQueueStats_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *intf_link = NULL;
char *allowed_objects[] = {
"Device.Ethernet.Interface.",
"Device.IP.Interface.",
"Device.PPP.Interface.",
NULL};
char *linker = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (value == NULL || *value == '\0')
break;
adm_entry_get_linker_value(ctx, value, &intf_link);
if (intf_link == NULL || *intf_link == '\0')
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
break;
case VALUESET:
if (value == NULL || *value == '\0')
break;
adm_entry_get_linker_value(ctx, value, &intf_link);
dmuci_set_value_by_section((struct uci_section *)data, "interface", intf_link);
adm_entry_get_linker_value(ctx, value, &linker);
dmuci_set_value_by_section((struct uci_section *)data, "interface", linker ? linker : "");
break;
}
return 0;
@ -1761,243 +1758,243 @@ static int set_QoSShaper_ShapingBurstSize(char *refparam, struct dmctx *ctx, voi
***********************************************************************************************************************************/
/* *** Device.QoS. *** */
DMOBJ tQoSObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Classification", &DMWRITE, addObjQoSClassification, delObjQoSClassification, NULL, browseQoSClassificationInst, NULL, NULL, NULL, tQoSClassificationParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
{"QueueStats", &DMWRITE, addObjQoSQueueStats, delObjQoSQueueStats, NULL, browseQoSQueueStatsInst, NULL, NULL, NULL, tQoSQueueStatsParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Queue", "Interface", NULL}},
//{"App", &DMWRITE, addObjQoSApp, delObjQoSApp, NULL, browseQoSAppInst, NULL, NULL, NULL, tQoSAppParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
//{"Flow", &DMWRITE, addObjQoSFlow, delObjQoSFlow, NULL, browseQoSFlowInst, NULL, NULL, NULL, tQoSFlowParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
{"Policer", &DMWRITE, addObjQoSPolicer, delObjQoSPolicer, NULL, browseQoSPolicerInst, NULL, NULL, NULL, tQoSPolicerParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
{"Queue", &DMWRITE, addObjQoSQueue, delObjQoSQueue, NULL, browseQoSQueueInst, NULL, NULL, NULL, tQoSQueueParams, get_linker_qqueue, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
{"Shaper", &DMWRITE, addObjQoSShaper, delObjQoSShaper, NULL, browseQoSShaperInst, NULL, NULL, NULL, tQoSShaperParams, NULL, BBFDM_BOTH, LIST_KEY{"Interface", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Classification", &DMWRITE, addObjQoSClassification, delObjQoSClassification, NULL, browseQoSClassificationInst, NULL, NULL, NULL, tQoSClassificationParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}, "2.0"},
{"QueueStats", &DMWRITE, addObjQoSQueueStats, delObjQoSQueueStats, NULL, browseQoSQueueStatsInst, NULL, NULL, NULL, tQoSQueueStatsParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Queue", "Interface", NULL}, "2.0"},
//{"App", &DMWRITE, addObjQoSApp, delObjQoSApp, NULL, browseQoSAppInst, NULL, NULL, NULL, tQoSAppParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}, "2.0"},
//{"Flow", &DMWRITE, addObjQoSFlow, delObjQoSFlow, NULL, browseQoSFlowInst, NULL, NULL, NULL, tQoSFlowParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}, "2.0"},
{"Policer", &DMWRITE, addObjQoSPolicer, delObjQoSPolicer, NULL, browseQoSPolicerInst, NULL, NULL, NULL, tQoSPolicerParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}, "2.0"},
{"Queue", &DMWRITE, addObjQoSQueue, delObjQoSQueue, NULL, browseQoSQueueInst, NULL, NULL, NULL, tQoSQueueParams, get_linker_qqueue, BBFDM_BOTH, LIST_KEY{"Alias", NULL}, "2.0"},
{"Shaper", &DMWRITE, addObjQoSShaper, delObjQoSShaper, NULL, browseQoSShaperInst, NULL, NULL, NULL, tQoSShaperParams, NULL, BBFDM_BOTH, LIST_KEY{"Interface", "Alias", NULL}, "2.0"},
{0}
};
DMLEAF tQoSParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"ClassificationNumberOfEntries", &DMREAD, DMT_UNINT, get_QClassificationNumberOfEntries, NULL, BBFDM_BOTH},
{"QueueStatsNumberOfEntries", &DMREAD, DMT_UNINT, get_QQueueStatsNumberOfEntries, NULL, BBFDM_BOTH},
{"ShaperNumberOfEntries", &DMREAD, DMT_UNINT, get_QShaperNumberOfEntries, NULL, BBFDM_BOTH},
{"QueueNumberOfEntries", &DMREAD, DMT_UNINT, get_QQueueNumberOfEntries, NULL, BBFDM_BOTH},
//{"MaxClassificationEntries", &DMREAD, DMT_UNINT, get_QMaxClassificationEntries, NULL, BBFDM_BOTH},
//{"MaxAppEntries", &DMREAD, DMT_UNINT, get_QMaxAppEntries, NULL, BBFDM_BOTH},
//{"AppNumberOfEntries", &DMREAD, DMT_UNINT, get_QAppNumberOfEntries, NULL, BBFDM_BOTH},
//{"MaxFlowEntries", &DMREAD, DMT_UNINT, get_QMaxFlowEntries, NULL, BBFDM_BOTH},
//{"FlowNumberOfEntries", &DMREAD, DMT_UNINT, get_QFlowNumberOfEntries, NULL, BBFDM_BOTH},
//{"MaxPolicerEntries", &DMREAD, DMT_UNINT, get_QMaxPolicerEntries, NULL, BBFDM_BOTH},
{"PolicerNumberOfEntries", &DMREAD, DMT_UNINT, get_QPolicerNumberOfEntries, NULL, BBFDM_BOTH},
//{"MaxQueueEntries", &DMREAD, DMT_UNINT, get_QMaxQueueEntries, NULL, BBFDM_BOTH},
//{"MaxShaperEntries", &DMREAD, DMT_UNINT, get_QMaxShaperEntries, NULL, BBFDM_BOTH},
//{"DefaultForwardingPolicy", &DMWRITE, DMT_UNINT, get_QDefaultForwardingPolicy, set_QDefaultForwardingPolicy, BBFDM_BOTH},
//{"DefaultTrafficClass", &DMWRITE, DMT_UNINT, get_QDefaultTrafficClass, set_QDefaultTrafficClass, BBFDM_BOTH},
//{"DefaultPolicer", &DMWRITE, DMT_STRING, get_QDefaultPolicer, set_QDefaultPolicer, BBFDM_BOTH},
//{"DefaultQueue", &DMWRITE, DMT_STRING, get_QDefaultQueue, set_QDefaultQueue, BBFDM_BOTH},
//{"DefaultDSCPMark", &DMWRITE, DMT_INT, get_QDefaultDSCPMark, set_QDefaultDSCPMark, BBFDM_BOTH},
//{"DefaultEthernetPriorityMark", &DMWRITE, DMT_INT, get_QDefaultEthernetPriorityMark, set_QDefaultEthernetPriorityMark, BBFDM_BOTH},
//{"DefaultInnerEthernetPriorityMark", &DMWRITE, DMT_INT, get_QDefaultInnerEthernetPriorityMark, set_QDefaultInnerEthernetPriorityMark, BBFDM_BOTH},
//{"AvailableAppList", &DMREAD, DMT_STRING, get_QAvailableAppList, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ClassificationNumberOfEntries", &DMREAD, DMT_UNINT, get_QClassificationNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
{"QueueStatsNumberOfEntries", &DMREAD, DMT_UNINT, get_QQueueStatsNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
{"ShaperNumberOfEntries", &DMREAD, DMT_UNINT, get_QShaperNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
{"QueueNumberOfEntries", &DMREAD, DMT_UNINT, get_QQueueNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
//{"MaxClassificationEntries", &DMREAD, DMT_UNINT, get_QMaxClassificationEntries, NULL, BBFDM_BOTH, "2.0"},
//{"MaxAppEntries", &DMREAD, DMT_UNINT, get_QMaxAppEntries, NULL, BBFDM_BOTH, "2.0"},
//{"AppNumberOfEntries", &DMREAD, DMT_UNINT, get_QAppNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
//{"MaxFlowEntries", &DMREAD, DMT_UNINT, get_QMaxFlowEntries, NULL, BBFDM_BOTH, "2.0"},
//{"FlowNumberOfEntries", &DMREAD, DMT_UNINT, get_QFlowNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
//{"MaxPolicerEntries", &DMREAD, DMT_UNINT, get_QMaxPolicerEntries, NULL, BBFDM_BOTH, "2.0"},
{"PolicerNumberOfEntries", &DMREAD, DMT_UNINT, get_QPolicerNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
//{"MaxQueueEntries", &DMREAD, DMT_UNINT, get_QMaxQueueEntries, NULL, BBFDM_BOTH, "2.0"},
//{"MaxShaperEntries", &DMREAD, DMT_UNINT, get_QMaxShaperEntries, NULL, BBFDM_BOTH, "2.0"},
//{"DefaultForwardingPolicy", &DMWRITE, DMT_UNINT, get_QDefaultForwardingPolicy, set_QDefaultForwardingPolicy, BBFDM_BOTH, "2.0"},
//{"DefaultTrafficClass", &DMWRITE, DMT_UNINT, get_QDefaultTrafficClass, set_QDefaultTrafficClass, BBFDM_BOTH, "2.0"},
//{"DefaultPolicer", &DMWRITE, DMT_STRING, get_QDefaultPolicer, set_QDefaultPolicer, BBFDM_BOTH, "2.0"},
//{"DefaultQueue", &DMWRITE, DMT_STRING, get_QDefaultQueue, set_QDefaultQueue, BBFDM_BOTH, "2.0"},
//{"DefaultDSCPMark", &DMWRITE, DMT_INT, get_QDefaultDSCPMark, set_QDefaultDSCPMark, BBFDM_BOTH, "2.0"},
//{"DefaultEthernetPriorityMark", &DMWRITE, DMT_INT, get_QDefaultEthernetPriorityMark, set_QDefaultEthernetPriorityMark, BBFDM_BOTH, "2.0"},
//{"DefaultInnerEthernetPriorityMark", &DMWRITE, DMT_INT, get_QDefaultInnerEthernetPriorityMark, set_QDefaultInnerEthernetPriorityMark, BBFDM_BOTH, "2.7"},
//{"AvailableAppList", &DMREAD, DMT_STRING, get_QAvailableAppList, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.QoS.Classification.{i}. *** */
DMLEAF tQoSClassificationParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_QoSClassification_Enable, set_QoSClassification_Enable, BBFDM_BOTH},
//{"Status", &DMREAD, DMT_STRING, get_QoSClassification_Status, NULL, BBFDM_BOTH},
//{"Order", &DMWRITE, DMT_UNINT, get_QoSClassification_Order, set_QoSClassification_Order, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_QoSClassification_Alias, set_QoSClassification_Alias, BBFDM_BOTH},
//{"DHCPType", &DMWRITE, DMT_STRING, get_QoSClassification_DHCPType, set_QoSClassification_DHCPType, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_QoSClassification_Interface, set_QoSClassification_Interface, BBFDM_BOTH},
//{"AllInterfaces", &DMWRITE, DMT_BOOL, get_QoSClassification_AllInterfaces, set_QoSClassification_AllInterfaces, BBFDM_BOTH},
{"DestIP", &DMWRITE, DMT_STRING, get_QoSClassification_DestIP, set_QoSClassification_DestIP, BBFDM_BOTH},
{"DestMask", &DMWRITE, DMT_STRING, get_QoSClassification_DestMask, set_QoSClassification_DestMask, BBFDM_BOTH},
//{"DestIPExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestIPExclude, set_QoSClassification_DestIPExclude, BBFDM_BOTH},
{"SourceIP", &DMWRITE, DMT_STRING, get_QoSClassification_SourceIP, set_QoSClassification_SourceIP, BBFDM_BOTH},
{"SourceMask", &DMWRITE, DMT_STRING, get_QoSClassification_SourceMask, set_QoSClassification_SourceMask, BBFDM_BOTH},
//{"SourceIPExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceIPExclude, set_QoSClassification_SourceIPExclude, BBFDM_BOTH},
{"Protocol", &DMWRITE, DMT_INT, get_QoSClassification_Protocol, set_QoSClassification_Protocol, BBFDM_BOTH},
//{"ProtocolExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_ProtocolExclude, set_QoSClassification_ProtocolExclude, BBFDM_BOTH},
{"DestPort", &DMWRITE, DMT_INT, get_QoSClassification_DestPort, set_QoSClassification_DestPort, BBFDM_BOTH},
{"DestPortRangeMax", &DMWRITE, DMT_INT, get_QoSClassification_DestPortRangeMax, set_QoSClassification_DestPortRangeMax, BBFDM_BOTH},
//{"DestPortExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestPortExclude, set_QoSClassification_DestPortExclude, BBFDM_BOTH},
{"SourcePort", &DMWRITE, DMT_INT, get_QoSClassification_SourcePort, set_QoSClassification_SourcePort, BBFDM_BOTH},
{"SourcePortRangeMax", &DMWRITE, DMT_INT, get_QoSClassification_SourcePortRangeMax, set_QoSClassification_SourcePortRangeMax, BBFDM_BOTH},
//{"SourcePortExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourcePortExclude, set_QoSClassification_SourcePortExclude, BBFDM_BOTH},
{"SourceMACAddress", &DMWRITE, DMT_STRING, get_QoSClassification_SourceMACAddress, set_QoSClassification_SourceMACAddress, BBFDM_BOTH},
//{"SourceMACMask", &DMWRITE, DMT_STRING, get_QoSClassification_SourceMACMask, set_QoSClassification_SourceMACMask, BBFDM_BOTH},
//{"SourceMACExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceMACExclude, set_QoSClassification_SourceMACExclude, BBFDM_BOTH},
{"DestMACAddress", &DMWRITE, DMT_STRING, get_QoSClassification_DestMACAddress, set_QoSClassification_DestMACAddress, BBFDM_BOTH},
//{"DestMACMask", &DMWRITE, DMT_STRING, get_QoSClassification_DestMACMask, set_QoSClassification_DestMACMask, BBFDM_BOTH},
//{"DestMACExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestMACExclude, set_QoSClassification_DestMACExclude, BBFDM_BOTH},
{"Ethertype", &DMWRITE, DMT_INT, get_QoSClassification_Ethertype, set_QoSClassification_Ethertype, BBFDM_BOTH},
//{"EthertypeExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_EthertypeExclude, set_QoSClassification_EthertypeExclude, BBFDM_BOTH},
//{"SSAP", &DMWRITE, DMT_INT, get_QoSClassification_SSAP, set_QoSClassification_SSAP, BBFDM_BOTH},
//{"SSAPExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SSAPExclude, set_QoSClassification_SSAPExclude, BBFDM_BOTH},
//{"DSAP", &DMWRITE, DMT_INT, get_QoSClassification_DSAP, set_QoSClassification_DSAP, BBFDM_BOTH},
//{"DSAPExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DSAPExclude, set_QoSClassification_DSAPExclude, BBFDM_BOTH},
//{"LLCControl", &DMWRITE, DMT_INT, get_QoSClassification_LLCControl, set_QoSClassification_LLCControl, BBFDM_BOTH},
//{"LLCControlExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_LLCControlExclude, set_QoSClassification_LLCControlExclude, BBFDM_BOTH},
//{"SNAPOUI", &DMWRITE, DMT_INT, get_QoSClassification_SNAPOUI, set_QoSClassification_SNAPOUI, BBFDM_BOTH},
//{"SNAPOUIExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SNAPOUIExclude, set_QoSClassification_SNAPOUIExclude, BBFDM_BOTH},
{"SourceVendorClassID", &DMWRITE, DMT_STRING, get_QoSClassification_SourceVendorClassID, set_QoSClassification_SourceVendorClassID, BBFDM_BOTH},
//{"SourceVendorClassIDv6", &DMWRITE, DMT_HEXBIN, get_QoSClassification_SourceVendorClassIDv6, set_QoSClassification_SourceVendorClassIDv6, BBFDM_BOTH},
//{"SourceVendorClassIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceVendorClassIDExclude, set_QoSClassification_SourceVendorClassIDExclude, BBFDM_BOTH},
//{"SourceVendorClassIDMode", &DMWRITE, DMT_STRING, get_QoSClassification_SourceVendorClassIDMode, set_QoSClassification_SourceVendorClassIDMode, BBFDM_BOTH},
{"DestVendorClassID", &DMWRITE, DMT_STRING, get_QoSClassification_DestVendorClassID, set_QoSClassification_DestVendorClassID, BBFDM_BOTH},
//{"DestVendorClassIDv6", &DMWRITE, DMT_HEXBIN, get_QoSClassification_DestVendorClassIDv6, set_QoSClassification_DestVendorClassIDv6, BBFDM_BOTH},
//{"DestVendorClassIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestVendorClassIDExclude, set_QoSClassification_DestVendorClassIDExclude, BBFDM_BOTH},
//{"DestVendorClassIDMode", &DMWRITE, DMT_STRING, get_QoSClassification_DestVendorClassIDMode, set_QoSClassification_DestVendorClassIDMode, BBFDM_BOTH},
{"SourceClientID", &DMWRITE, DMT_HEXBIN, get_QoSClassification_SourceClientID, set_QoSClassification_SourceClientID, BBFDM_BOTH},
//{"SourceClientIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceClientIDExclude, set_QoSClassification_SourceClientIDExclude, BBFDM_BOTH},
{"DestClientID", &DMWRITE, DMT_HEXBIN, get_QoSClassification_DestClientID, set_QoSClassification_DestClientID, BBFDM_BOTH},
//{"DestClientIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestClientIDExclude, set_QoSClassification_DestClientIDExclude, BBFDM_BOTH},
{"SourceUserClassID", &DMWRITE, DMT_HEXBIN, get_QoSClassification_SourceUserClassID, set_QoSClassification_SourceUserClassID, BBFDM_BOTH},
//{"SourceUserClassIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceUserClassIDExclude, set_QoSClassification_SourceUserClassIDExclude, BBFDM_BOTH},
{"DestUserClassID", &DMWRITE, DMT_HEXBIN, get_QoSClassification_DestUserClassID, set_QoSClassification_DestUserClassID, BBFDM_BOTH},
//{"DestUserClassIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestUserClassIDExclude, set_QoSClassification_DestUserClassIDExclude, BBFDM_BOTH},
//{"SourceVendorSpecificInfo", &DMWRITE, DMT_HEXBIN, get_QoSClassification_SourceVendorSpecificInfo, set_QoSClassification_SourceVendorSpecificInfo, BBFDM_BOTH},
//{"SourceVendorSpecificInfoExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceVendorSpecificInfoExclude, set_QoSClassification_SourceVendorSpecificInfoExclude, BBFDM_BOTH},
//{"SourceVendorSpecificInfoEnterprise", &DMWRITE, DMT_UNINT, get_QoSClassification_SourceVendorSpecificInfoEnterprise, set_QoSClassification_SourceVendorSpecificInfoEnterprise, BBFDM_BOTH},
//{"SourceVendorSpecificInfoSubOption", &DMWRITE, DMT_INT, get_QoSClassification_SourceVendorSpecificInfoSubOption, set_QoSClassification_SourceVendorSpecificInfoSubOption, BBFDM_BOTH},
//{"DestVendorSpecificInfo", &DMWRITE, DMT_HEXBIN, get_QoSClassification_DestVendorSpecificInfo, set_QoSClassification_DestVendorSpecificInfo, BBFDM_BOTH},
//{"DestVendorSpecificInfoExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestVendorSpecificInfoExclude, set_QoSClassification_DestVendorSpecificInfoExclude, BBFDM_BOTH},
//{"DestVendorSpecificInfoEnterprise", &DMWRITE, DMT_UNINT, get_QoSClassification_DestVendorSpecificInfoEnterprise, set_QoSClassification_DestVendorSpecificInfoEnterprise, BBFDM_BOTH},
//{"DestVendorSpecificInfoSubOption", &DMWRITE, DMT_INT, get_QoSClassification_DestVendorSpecificInfoSubOption, set_QoSClassification_DestVendorSpecificInfoSubOption, BBFDM_BOTH},
//{"TCPACK", &DMWRITE, DMT_BOOL, get_QoSClassification_TCPACK, set_QoSClassification_TCPACK, BBFDM_BOTH},
//{"TCPACKExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_TCPACKExclude, set_QoSClassification_TCPACKExclude, BBFDM_BOTH},
{"IPLengthMin", &DMWRITE, DMT_UNINT, get_QoSClassification_IPLengthMin, set_QoSClassification_IPLengthMin, BBFDM_BOTH},
{"IPLengthMax", &DMWRITE, DMT_UNINT, get_QoSClassification_IPLengthMax, set_QoSClassification_IPLengthMax, BBFDM_BOTH},
//{"IPLengthExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_IPLengthExclude, set_QoSClassification_IPLengthExclude, BBFDM_BOTH},
{"DSCPCheck", &DMWRITE, DMT_INT, get_QoSClassification_DSCPCheck, set_QoSClassification_DSCPCheck, BBFDM_BOTH},
//{"DSCPExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DSCPExclude, set_QoSClassification_DSCPExclude, BBFDM_BOTH},
{"DSCPMark", &DMWRITE, DMT_INT, get_QoSClassification_DSCPMark, set_QoSClassification_DSCPMark, BBFDM_BOTH},
{"EthernetPriorityCheck", &DMWRITE, DMT_INT, get_QoSClassification_EthernetPriorityCheck, set_QoSClassification_EthernetPriorityCheck, BBFDM_BOTH},
//{"EthernetPriorityExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_EthernetPriorityExclude, set_QoSClassification_EthernetPriorityExclude, BBFDM_BOTH},
//{"EthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSClassification_EthernetPriorityMark, set_QoSClassification_EthernetPriorityMark, BBFDM_BOTH},
//{"InnerEthernetPriorityCheck", &DMWRITE, DMT_INT, get_QoSClassification_InnerEthernetPriorityCheck, set_QoSClassification_InnerEthernetPriorityCheck, BBFDM_BOTH},
//{"InnerEthernetPriorityExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_InnerEthernetPriorityExclude, set_QoSClassification_InnerEthernetPriorityExclude, BBFDM_BOTH},
//{"InnerEthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSClassification_InnerEthernetPriorityMark, set_QoSClassification_InnerEthernetPriorityMark, BBFDM_BOTH},
//{"EthernetDEICheck", &DMWRITE, DMT_INT, get_QoSClassification_EthernetDEICheck, set_QoSClassification_EthernetDEICheck, BBFDM_BOTH},
//{"EthernetDEIExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_EthernetDEIExclude, set_QoSClassification_EthernetDEIExclude, BBFDM_BOTH},
{"VLANIDCheck", &DMWRITE, DMT_INT, get_QoSClassification_VLANIDCheck, set_QoSClassification_VLANIDCheck, BBFDM_BOTH},
//{"VLANIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_VLANIDExclude, set_QoSClassification_VLANIDExclude, BBFDM_BOTH},
//{"OutOfBandInfo", &DMWRITE, DMT_INT, get_QoSClassification_OutOfBandInfo, set_QoSClassification_OutOfBandInfo, BBFDM_BOTH},
//{"ForwardingPolicy", &DMWRITE, DMT_UNINT, get_QoSClassification_ForwardingPolicy, set_QoSClassification_ForwardingPolicy, BBFDM_BOTH},
{"TrafficClass", &DMWRITE, DMT_INT, get_QoSClassification_TrafficClass, set_QoSClassification_TrafficClass, BBFDM_BOTH},
{"Policer", &DMWRITE, DMT_STRING, get_QoSClassification_Policer, set_QoSClassification_Policer, BBFDM_BOTH},
//{"App", &DMWRITE, DMT_STRING, get_QoSClassification_App, set_QoSClassification_App, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_QoSClassification_Enable, set_QoSClassification_Enable, BBFDM_BOTH, "2.0"},
//{"Status", &DMREAD, DMT_STRING, get_QoSClassification_Status, NULL, BBFDM_BOTH, "2.0"},
//{"Order", &DMWRITE, DMT_UNINT, get_QoSClassification_Order, set_QoSClassification_Order, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_QoSClassification_Alias, set_QoSClassification_Alias, BBFDM_BOTH, "2.0"},
//{"DHCPType", &DMWRITE, DMT_STRING, get_QoSClassification_DHCPType, set_QoSClassification_DHCPType, BBFDM_BOTH, "2.2"},
{"Interface", &DMWRITE, DMT_STRING, get_QoSClassification_Interface, set_QoSClassification_Interface, BBFDM_BOTH, "2.0"},
//{"AllInterfaces", &DMWRITE, DMT_BOOL, get_QoSClassification_AllInterfaces, set_QoSClassification_AllInterfaces, BBFDM_BOTH, "2.0"},
{"DestIP", &DMWRITE, DMT_STRING, get_QoSClassification_DestIP, set_QoSClassification_DestIP, BBFDM_BOTH, "2.0"},
{"DestMask", &DMWRITE, DMT_STRING, get_QoSClassification_DestMask, set_QoSClassification_DestMask, BBFDM_BOTH, "2.0"},
//{"DestIPExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestIPExclude, set_QoSClassification_DestIPExclude, BBFDM_BOTH, "2.0"},
{"SourceIP", &DMWRITE, DMT_STRING, get_QoSClassification_SourceIP, set_QoSClassification_SourceIP, BBFDM_BOTH, "2.0"},
{"SourceMask", &DMWRITE, DMT_STRING, get_QoSClassification_SourceMask, set_QoSClassification_SourceMask, BBFDM_BOTH, "2.0"},
//{"SourceIPExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceIPExclude, set_QoSClassification_SourceIPExclude, BBFDM_BOTH, "2.0"},
{"Protocol", &DMWRITE, DMT_INT, get_QoSClassification_Protocol, set_QoSClassification_Protocol, BBFDM_BOTH, "2.0"},
//{"ProtocolExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_ProtocolExclude, set_QoSClassification_ProtocolExclude, BBFDM_BOTH, "2.0"},
{"DestPort", &DMWRITE, DMT_INT, get_QoSClassification_DestPort, set_QoSClassification_DestPort, BBFDM_BOTH, "2.0"},
{"DestPortRangeMax", &DMWRITE, DMT_INT, get_QoSClassification_DestPortRangeMax, set_QoSClassification_DestPortRangeMax, BBFDM_BOTH, "2.0"},
//{"DestPortExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestPortExclude, set_QoSClassification_DestPortExclude, BBFDM_BOTH, "2.0"},
{"SourcePort", &DMWRITE, DMT_INT, get_QoSClassification_SourcePort, set_QoSClassification_SourcePort, BBFDM_BOTH, "2.0"},
{"SourcePortRangeMax", &DMWRITE, DMT_INT, get_QoSClassification_SourcePortRangeMax, set_QoSClassification_SourcePortRangeMax, BBFDM_BOTH, "2.0"},
//{"SourcePortExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourcePortExclude, set_QoSClassification_SourcePortExclude, BBFDM_BOTH, "2.0"},
{"SourceMACAddress", &DMWRITE, DMT_STRING, get_QoSClassification_SourceMACAddress, set_QoSClassification_SourceMACAddress, BBFDM_BOTH, "2.0"},
//{"SourceMACMask", &DMWRITE, DMT_STRING, get_QoSClassification_SourceMACMask, set_QoSClassification_SourceMACMask, BBFDM_BOTH, "2.0"},
//{"SourceMACExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceMACExclude, set_QoSClassification_SourceMACExclude, BBFDM_BOTH, "2.0"},
{"DestMACAddress", &DMWRITE, DMT_STRING, get_QoSClassification_DestMACAddress, set_QoSClassification_DestMACAddress, BBFDM_BOTH, "2.0"},
//{"DestMACMask", &DMWRITE, DMT_STRING, get_QoSClassification_DestMACMask, set_QoSClassification_DestMACMask, BBFDM_BOTH, "2.0"},
//{"DestMACExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestMACExclude, set_QoSClassification_DestMACExclude, BBFDM_BOTH, "2.0"},
{"Ethertype", &DMWRITE, DMT_INT, get_QoSClassification_Ethertype, set_QoSClassification_Ethertype, BBFDM_BOTH, "2.0"},
//{"EthertypeExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_EthertypeExclude, set_QoSClassification_EthertypeExclude, BBFDM_BOTH, "2.0"},
//{"SSAP", &DMWRITE, DMT_INT, get_QoSClassification_SSAP, set_QoSClassification_SSAP, BBFDM_BOTH, "2.0"},
//{"SSAPExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SSAPExclude, set_QoSClassification_SSAPExclude, BBFDM_BOTH, "2.0"},
//{"DSAP", &DMWRITE, DMT_INT, get_QoSClassification_DSAP, set_QoSClassification_DSAP, BBFDM_BOTH, "2.0"},
//{"DSAPExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DSAPExclude, set_QoSClassification_DSAPExclude, BBFDM_BOTH, "2.0"},
//{"LLCControl", &DMWRITE, DMT_INT, get_QoSClassification_LLCControl, set_QoSClassification_LLCControl, BBFDM_BOTH, "2.0"},
//{"LLCControlExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_LLCControlExclude, set_QoSClassification_LLCControlExclude, BBFDM_BOTH, "2.0"},
//{"SNAPOUI", &DMWRITE, DMT_INT, get_QoSClassification_SNAPOUI, set_QoSClassification_SNAPOUI, BBFDM_BOTH, "2.0"},
//{"SNAPOUIExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SNAPOUIExclude, set_QoSClassification_SNAPOUIExclude, BBFDM_BOTH, "2.0"},
{"SourceVendorClassID", &DMWRITE, DMT_STRING, get_QoSClassification_SourceVendorClassID, set_QoSClassification_SourceVendorClassID, BBFDM_BOTH, "2.0"},
//{"SourceVendorClassIDv6", &DMWRITE, DMT_HEXBIN, get_QoSClassification_SourceVendorClassIDv6, set_QoSClassification_SourceVendorClassIDv6, BBFDM_BOTH, "2.2"},
//{"SourceVendorClassIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceVendorClassIDExclude, set_QoSClassification_SourceVendorClassIDExclude, BBFDM_BOTH, "2.0"},
//{"SourceVendorClassIDMode", &DMWRITE, DMT_STRING, get_QoSClassification_SourceVendorClassIDMode, set_QoSClassification_SourceVendorClassIDMode, BBFDM_BOTH, "2.0"},
{"DestVendorClassID", &DMWRITE, DMT_STRING, get_QoSClassification_DestVendorClassID, set_QoSClassification_DestVendorClassID, BBFDM_BOTH, "2.0"},
//{"DestVendorClassIDv6", &DMWRITE, DMT_HEXBIN, get_QoSClassification_DestVendorClassIDv6, set_QoSClassification_DestVendorClassIDv6, BBFDM_BOTH, "2.2"},
//{"DestVendorClassIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestVendorClassIDExclude, set_QoSClassification_DestVendorClassIDExclude, BBFDM_BOTH, "2.0"},
//{"DestVendorClassIDMode", &DMWRITE, DMT_STRING, get_QoSClassification_DestVendorClassIDMode, set_QoSClassification_DestVendorClassIDMode, BBFDM_BOTH, "2.0"},
{"SourceClientID", &DMWRITE, DMT_HEXBIN, get_QoSClassification_SourceClientID, set_QoSClassification_SourceClientID, BBFDM_BOTH, "2.0"},
//{"SourceClientIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceClientIDExclude, set_QoSClassification_SourceClientIDExclude, BBFDM_BOTH, "2.0"},
{"DestClientID", &DMWRITE, DMT_HEXBIN, get_QoSClassification_DestClientID, set_QoSClassification_DestClientID, BBFDM_BOTH, "2.0"},
//{"DestClientIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestClientIDExclude, set_QoSClassification_DestClientIDExclude, BBFDM_BOTH, "2.0"},
{"SourceUserClassID", &DMWRITE, DMT_HEXBIN, get_QoSClassification_SourceUserClassID, set_QoSClassification_SourceUserClassID, BBFDM_BOTH, "2.0"},
//{"SourceUserClassIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceUserClassIDExclude, set_QoSClassification_SourceUserClassIDExclude, BBFDM_BOTH, "2.0"},
{"DestUserClassID", &DMWRITE, DMT_HEXBIN, get_QoSClassification_DestUserClassID, set_QoSClassification_DestUserClassID, BBFDM_BOTH, "2.0"},
//{"DestUserClassIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestUserClassIDExclude, set_QoSClassification_DestUserClassIDExclude, BBFDM_BOTH, "2.0"},
//{"SourceVendorSpecificInfo", &DMWRITE, DMT_HEXBIN, get_QoSClassification_SourceVendorSpecificInfo, set_QoSClassification_SourceVendorSpecificInfo, BBFDM_BOTH, "2.0"},
//{"SourceVendorSpecificInfoExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_SourceVendorSpecificInfoExclude, set_QoSClassification_SourceVendorSpecificInfoExclude, BBFDM_BOTH, "2.0"},
//{"SourceVendorSpecificInfoEnterprise", &DMWRITE, DMT_UNINT, get_QoSClassification_SourceVendorSpecificInfoEnterprise, set_QoSClassification_SourceVendorSpecificInfoEnterprise, BBFDM_BOTH, "2.0"},
//{"SourceVendorSpecificInfoSubOption", &DMWRITE, DMT_INT, get_QoSClassification_SourceVendorSpecificInfoSubOption, set_QoSClassification_SourceVendorSpecificInfoSubOption, BBFDM_BOTH, "2.0"},
//{"DestVendorSpecificInfo", &DMWRITE, DMT_HEXBIN, get_QoSClassification_DestVendorSpecificInfo, set_QoSClassification_DestVendorSpecificInfo, BBFDM_BOTH, "2.0"},
//{"DestVendorSpecificInfoExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DestVendorSpecificInfoExclude, set_QoSClassification_DestVendorSpecificInfoExclude, BBFDM_BOTH, "2.0"},
//{"DestVendorSpecificInfoEnterprise", &DMWRITE, DMT_UNINT, get_QoSClassification_DestVendorSpecificInfoEnterprise, set_QoSClassification_DestVendorSpecificInfoEnterprise, BBFDM_BOTH, "2.0"},
//{"DestVendorSpecificInfoSubOption", &DMWRITE, DMT_INT, get_QoSClassification_DestVendorSpecificInfoSubOption, set_QoSClassification_DestVendorSpecificInfoSubOption, BBFDM_BOTH, "2.0"},
//{"TCPACK", &DMWRITE, DMT_BOOL, get_QoSClassification_TCPACK, set_QoSClassification_TCPACK, BBFDM_BOTH, "2.0"},
//{"TCPACKExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_TCPACKExclude, set_QoSClassification_TCPACKExclude, BBFDM_BOTH, "2.0"},
{"IPLengthMin", &DMWRITE, DMT_UNINT, get_QoSClassification_IPLengthMin, set_QoSClassification_IPLengthMin, BBFDM_BOTH, "2.0"},
{"IPLengthMax", &DMWRITE, DMT_UNINT, get_QoSClassification_IPLengthMax, set_QoSClassification_IPLengthMax, BBFDM_BOTH, "2.0"},
//{"IPLengthExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_IPLengthExclude, set_QoSClassification_IPLengthExclude, BBFDM_BOTH, "2.0"},
{"DSCPCheck", &DMWRITE, DMT_INT, get_QoSClassification_DSCPCheck, set_QoSClassification_DSCPCheck, BBFDM_BOTH, "2.0"},
//{"DSCPExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_DSCPExclude, set_QoSClassification_DSCPExclude, BBFDM_BOTH, "2.0"},
{"DSCPMark", &DMWRITE, DMT_INT, get_QoSClassification_DSCPMark, set_QoSClassification_DSCPMark, BBFDM_BOTH, "2.0"},
{"EthernetPriorityCheck", &DMWRITE, DMT_INT, get_QoSClassification_EthernetPriorityCheck, set_QoSClassification_EthernetPriorityCheck, BBFDM_BOTH, "2.0"},
//{"EthernetPriorityExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_EthernetPriorityExclude, set_QoSClassification_EthernetPriorityExclude, BBFDM_BOTH, "2.0"},
//{"EthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSClassification_EthernetPriorityMark, set_QoSClassification_EthernetPriorityMark, BBFDM_BOTH, "2.0"},
//{"InnerEthernetPriorityCheck", &DMWRITE, DMT_INT, get_QoSClassification_InnerEthernetPriorityCheck, set_QoSClassification_InnerEthernetPriorityCheck, BBFDM_BOTH, "2.7"},
//{"InnerEthernetPriorityExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_InnerEthernetPriorityExclude, set_QoSClassification_InnerEthernetPriorityExclude, BBFDM_BOTH, "2.7"},
//{"InnerEthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSClassification_InnerEthernetPriorityMark, set_QoSClassification_InnerEthernetPriorityMark, BBFDM_BOTH, "2.7"},
//{"EthernetDEICheck", &DMWRITE, DMT_INT, get_QoSClassification_EthernetDEICheck, set_QoSClassification_EthernetDEICheck, BBFDM_BOTH, "2.7"},
//{"EthernetDEIExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_EthernetDEIExclude, set_QoSClassification_EthernetDEIExclude, BBFDM_BOTH, "2.7"},
{"VLANIDCheck", &DMWRITE, DMT_INT, get_QoSClassification_VLANIDCheck, set_QoSClassification_VLANIDCheck, BBFDM_BOTH, "2.0"},
//{"VLANIDExclude", &DMWRITE, DMT_BOOL, get_QoSClassification_VLANIDExclude, set_QoSClassification_VLANIDExclude, BBFDM_BOTH, "2.0"},
//{"OutOfBandInfo", &DMWRITE, DMT_INT, get_QoSClassification_OutOfBandInfo, set_QoSClassification_OutOfBandInfo, BBFDM_BOTH, "2.0"},
//{"ForwardingPolicy", &DMWRITE, DMT_UNINT, get_QoSClassification_ForwardingPolicy, set_QoSClassification_ForwardingPolicy, BBFDM_BOTH, "2.0"},
{"TrafficClass", &DMWRITE, DMT_INT, get_QoSClassification_TrafficClass, set_QoSClassification_TrafficClass, BBFDM_BOTH, "2.0"},
{"Policer", &DMWRITE, DMT_STRING, get_QoSClassification_Policer, set_QoSClassification_Policer, BBFDM_BOTH, "2.0"},
//{"App", &DMWRITE, DMT_STRING, get_QoSClassification_App, set_QoSClassification_App, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.QoS.App.{i}. *** */
DMLEAF tQoSAppParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"Enable", &DMWRITE, DMT_BOOL, get_QoSApp_Enable, set_QoSApp_Enable, BBFDM_BOTH},
//{"Status", &DMREAD, DMT_STRING, get_QoSApp_Status, NULL, BBFDM_BOTH},
//{"Alias", &DMWRITE, DMT_STRING, get_QoSApp_Alias, set_QoSApp_Alias, BBFDM_BOTH},
//{"ProtocolIdentifier", &DMWRITE, DMT_STRING, get_QoSApp_ProtocolIdentifier, set_QoSApp_ProtocolIdentifier, BBFDM_BOTH},
//{"Name", &DMWRITE, DMT_STRING, get_QoSApp_Name, set_QoSApp_Name, BBFDM_BOTH},
//{"DefaultForwardingPolicy", &DMWRITE, DMT_UNINT, get_QoSApp_DefaultForwardingPolicy, set_QoSApp_DefaultForwardingPolicy, BBFDM_BOTH},
//{"DefaultTrafficClass", &DMWRITE, DMT_UNINT, get_QoSApp_DefaultTrafficClass, set_QoSApp_DefaultTrafficClass, BBFDM_BOTH},
//{"DefaultPolicer", &DMWRITE, DMT_STRING, get_QoSApp_DefaultPolicer, set_QoSApp_DefaultPolicer, BBFDM_BOTH},
//{"DefaultDSCPMark", &DMWRITE, DMT_INT, get_QoSApp_DefaultDSCPMark, set_QoSApp_DefaultDSCPMark, BBFDM_BOTH},
//{"DefaultEthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSApp_DefaultEthernetPriorityMark, set_QoSApp_DefaultEthernetPriorityMark, BBFDM_BOTH},
//{"DefaultInnerEthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSApp_DefaultInnerEthernetPriorityMark, set_QoSApp_DefaultInnerEthernetPriorityMark, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"Enable", &DMWRITE, DMT_BOOL, get_QoSApp_Enable, set_QoSApp_Enable, BBFDM_BOTH, "2.0"},
//{"Status", &DMREAD, DMT_STRING, get_QoSApp_Status, NULL, BBFDM_BOTH, "2.0"},
//{"Alias", &DMWRITE, DMT_STRING, get_QoSApp_Alias, set_QoSApp_Alias, BBFDM_BOTH, "2.0"},
//{"ProtocolIdentifier", &DMWRITE, DMT_STRING, get_QoSApp_ProtocolIdentifier, set_QoSApp_ProtocolIdentifier, BBFDM_BOTH, "2.0"},
//{"Name", &DMWRITE, DMT_STRING, get_QoSApp_Name, set_QoSApp_Name, BBFDM_BOTH, "2.0"},
//{"DefaultForwardingPolicy", &DMWRITE, DMT_UNINT, get_QoSApp_DefaultForwardingPolicy, set_QoSApp_DefaultForwardingPolicy, BBFDM_BOTH, "2.0"},
//{"DefaultTrafficClass", &DMWRITE, DMT_UNINT, get_QoSApp_DefaultTrafficClass, set_QoSApp_DefaultTrafficClass, BBFDM_BOTH, "2.0"},
//{"DefaultPolicer", &DMWRITE, DMT_STRING, get_QoSApp_DefaultPolicer, set_QoSApp_DefaultPolicer, BBFDM_BOTH, "2.0"},
//{"DefaultDSCPMark", &DMWRITE, DMT_INT, get_QoSApp_DefaultDSCPMark, set_QoSApp_DefaultDSCPMark, BBFDM_BOTH, "2.0"},
//{"DefaultEthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSApp_DefaultEthernetPriorityMark, set_QoSApp_DefaultEthernetPriorityMark, BBFDM_BOTH, "2.0"},
//{"DefaultInnerEthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSApp_DefaultInnerEthernetPriorityMark, set_QoSApp_DefaultInnerEthernetPriorityMark, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.QoS.Flow.{i}. *** */
DMLEAF tQoSFlowParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"Enable", &DMWRITE, DMT_BOOL, get_QoSFlow_Enable, set_QoSFlow_Enable, BBFDM_BOTH},
//{"Status", &DMREAD, DMT_STRING, get_QoSFlow_Status, NULL, BBFDM_BOTH},
//{"Alias", &DMWRITE, DMT_STRING, get_QoSFlow_Alias, set_QoSFlow_Alias, BBFDM_BOTH},
//{"Type", &DMWRITE, DMT_STRING, get_QoSFlow_Type, set_QoSFlow_Type, BBFDM_BOTH},
//{"TypeParameters", &DMWRITE, DMT_STRING, get_QoSFlow_TypeParameters, set_QoSFlow_TypeParameters, BBFDM_BOTH},
//{"Name", &DMWRITE, DMT_STRING, get_QoSFlow_Name, set_QoSFlow_Name, BBFDM_BOTH},
//{"App", &DMWRITE, DMT_STRING, get_QoSFlow_App, set_QoSFlow_App, BBFDM_BOTH},
//{"ForwardingPolicy", &DMWRITE, DMT_UNINT, get_QoSFlow_ForwardingPolicy, set_QoSFlow_ForwardingPolicy, BBFDM_BOTH},
//{"TrafficClass", &DMWRITE, DMT_UNINT, get_QoSFlow_TrafficClass, set_QoSFlow_TrafficClass, BBFDM_BOTH},
//{"Policer", &DMWRITE, DMT_STRING, get_QoSFlow_Policer, set_QoSFlow_Policer, BBFDM_BOTH},
//{"DSCPMark", &DMWRITE, DMT_INT, get_QoSFlow_DSCPMark, set_QoSFlow_DSCPMark, BBFDM_BOTH},
//{"EthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSFlow_EthernetPriorityMark, set_QoSFlow_EthernetPriorityMark, BBFDM_BOTH},
//{"InnerEthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSFlow_InnerEthernetPriorityMark, set_QoSFlow_InnerEthernetPriorityMark, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"Enable", &DMWRITE, DMT_BOOL, get_QoSFlow_Enable, set_QoSFlow_Enable, BBFDM_BOTH, "2.0"},
//{"Status", &DMREAD, DMT_STRING, get_QoSFlow_Status, NULL, BBFDM_BOTH, "2.0"},
//{"Alias", &DMWRITE, DMT_STRING, get_QoSFlow_Alias, set_QoSFlow_Alias, BBFDM_BOTH, "2.0"},
//{"Type", &DMWRITE, DMT_STRING, get_QoSFlow_Type, set_QoSFlow_Type, BBFDM_BOTH, "2.0"},
//{"TypeParameters", &DMWRITE, DMT_STRING, get_QoSFlow_TypeParameters, set_QoSFlow_TypeParameters, BBFDM_BOTH, "2.0"},
//{"Name", &DMWRITE, DMT_STRING, get_QoSFlow_Name, set_QoSFlow_Name, BBFDM_BOTH, "2.0"},
//{"App", &DMWRITE, DMT_STRING, get_QoSFlow_App, set_QoSFlow_App, BBFDM_BOTH, "2.0"},
//{"ForwardingPolicy", &DMWRITE, DMT_UNINT, get_QoSFlow_ForwardingPolicy, set_QoSFlow_ForwardingPolicy, BBFDM_BOTH, "2.0"},
//{"TrafficClass", &DMWRITE, DMT_UNINT, get_QoSFlow_TrafficClass, set_QoSFlow_TrafficClass, BBFDM_BOTH, "2.0"},
//{"Policer", &DMWRITE, DMT_STRING, get_QoSFlow_Policer, set_QoSFlow_Policer, BBFDM_BOTH, "2.0"},
//{"DSCPMark", &DMWRITE, DMT_INT, get_QoSFlow_DSCPMark, set_QoSFlow_DSCPMark, BBFDM_BOTH, "2.0"},
//{"EthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSFlow_EthernetPriorityMark, set_QoSFlow_EthernetPriorityMark, BBFDM_BOTH, "2.0"},
//{"InnerEthernetPriorityMark", &DMWRITE, DMT_INT, get_QoSFlow_InnerEthernetPriorityMark, set_QoSFlow_InnerEthernetPriorityMark, BBFDM_BOTH, "2.7"},
{0}
};
/* *** Device.QoS.Policer.{i}. *** */
DMLEAF tQoSPolicerParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_QoSPolicer_Enable, set_QoSPolicer_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_QoSPolicer_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_QoSPolicer_Alias, set_QoSPolicer_Alias, BBFDM_BOTH},
{"CommittedRate", &DMWRITE, DMT_UNINT, get_QoSPolicer_CommittedRate, set_QoSPolicer_CommittedRate, BBFDM_BOTH},
{"CommittedBurstSize", &DMWRITE, DMT_UNINT, get_QoSPolicer_CommittedBurstSize, set_QoSPolicer_CommittedBurstSize, BBFDM_BOTH},
{"ExcessBurstSize", &DMWRITE, DMT_UNINT, get_QoSPolicer_ExcessBurstSize, set_QoSPolicer_ExcessBurstSize, BBFDM_BOTH},
{"PeakRate", &DMWRITE, DMT_UNINT, get_QoSPolicer_PeakRate, set_QoSPolicer_PeakRate, BBFDM_BOTH},
{"PeakBurstSize", &DMWRITE, DMT_UNINT, get_QoSPolicer_PeakBurstSize, set_QoSPolicer_PeakBurstSize, BBFDM_BOTH},
{"MeterType", &DMWRITE, DMT_STRING, get_QoSPolicer_MeterType, set_QoSPolicer_MeterType, BBFDM_BOTH},
{"PossibleMeterTypes", &DMREAD, DMT_STRING, get_QoSPolicer_PossibleMeterTypes, NULL, BBFDM_BOTH},
//{"ConformingAction", &DMWRITE, DMT_STRING, get_QoSPolicer_ConformingAction, set_QoSPolicer_ConformingAction, BBFDM_BOTH},
//{"PartialConformingAction", &DMWRITE, DMT_STRING, get_QoSPolicer_PartialConformingAction, set_QoSPolicer_PartialConformingAction, BBFDM_BOTH},
//{"NonConformingAction", &DMWRITE, DMT_STRING, get_QoSPolicer_NonConformingAction, set_QoSPolicer_NonConformingAction, BBFDM_BOTH},
//{"TotalCountedPackets", &DMREAD, DMT_UNINT, get_QoSPolicer_TotalCountedPackets, NULL, BBFDM_BOTH},
//{"TotalCountedBytes", &DMREAD, DMT_UNINT, get_QoSPolicer_TotalCountedBytes, NULL, BBFDM_BOTH},
//{"ConformingCountedPackets", &DMREAD, DMT_UNINT, get_QoSPolicer_ConformingCountedPackets, NULL, BBFDM_BOTH},
//{"ConformingCountedBytes", &DMREAD, DMT_UNINT, get_QoSPolicer_ConformingCountedBytes, NULL, BBFDM_BOTH},
//{"PartiallyConformingCountedPackets", &DMREAD, DMT_UNINT, get_QoSPolicer_PartiallyConformingCountedPackets, NULL, BBFDM_BOTH},
//{"PartiallyConformingCountedBytes", &DMREAD, DMT_UNINT, get_QoSPolicer_PartiallyConformingCountedBytes, NULL, BBFDM_BOTH},
//{"NonConformingCountedPackets", &DMREAD, DMT_UNINT, get_QoSPolicer_NonConformingCountedPackets, NULL, BBFDM_BOTH},
//{"NonConformingCountedBytes", &DMREAD, DMT_UNINT, get_QoSPolicer_NonConformingCountedBytes, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_QoSPolicer_Enable, set_QoSPolicer_Enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_QoSPolicer_Status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_QoSPolicer_Alias, set_QoSPolicer_Alias, BBFDM_BOTH, "2.0"},
{"CommittedRate", &DMWRITE, DMT_UNINT, get_QoSPolicer_CommittedRate, set_QoSPolicer_CommittedRate, BBFDM_BOTH, "2.0"},
{"CommittedBurstSize", &DMWRITE, DMT_UNINT, get_QoSPolicer_CommittedBurstSize, set_QoSPolicer_CommittedBurstSize, BBFDM_BOTH, "2.0"},
{"ExcessBurstSize", &DMWRITE, DMT_UNINT, get_QoSPolicer_ExcessBurstSize, set_QoSPolicer_ExcessBurstSize, BBFDM_BOTH, "2.0"},
{"PeakRate", &DMWRITE, DMT_UNINT, get_QoSPolicer_PeakRate, set_QoSPolicer_PeakRate, BBFDM_BOTH, "2.0"},
{"PeakBurstSize", &DMWRITE, DMT_UNINT, get_QoSPolicer_PeakBurstSize, set_QoSPolicer_PeakBurstSize, BBFDM_BOTH, "2.0"},
{"MeterType", &DMWRITE, DMT_STRING, get_QoSPolicer_MeterType, set_QoSPolicer_MeterType, BBFDM_BOTH, "2.0"},
{"PossibleMeterTypes", &DMREAD, DMT_STRING, get_QoSPolicer_PossibleMeterTypes, NULL, BBFDM_BOTH, "2.0"},
//{"ConformingAction", &DMWRITE, DMT_STRING, get_QoSPolicer_ConformingAction, set_QoSPolicer_ConformingAction, BBFDM_BOTH, "2.0"},
//{"PartialConformingAction", &DMWRITE, DMT_STRING, get_QoSPolicer_PartialConformingAction, set_QoSPolicer_PartialConformingAction, BBFDM_BOTH, "2.0"},
//{"NonConformingAction", &DMWRITE, DMT_STRING, get_QoSPolicer_NonConformingAction, set_QoSPolicer_NonConformingAction, BBFDM_BOTH, "2.0"},
//{"TotalCountedPackets", &DMREAD, DMT_UNINT, get_QoSPolicer_TotalCountedPackets, NULL, BBFDM_BOTH, "2.0"},
//{"TotalCountedBytes", &DMREAD, DMT_UNINT, get_QoSPolicer_TotalCountedBytes, NULL, BBFDM_BOTH, "2.0"},
//{"ConformingCountedPackets", &DMREAD, DMT_UNINT, get_QoSPolicer_ConformingCountedPackets, NULL, BBFDM_BOTH, "2.0"},
//{"ConformingCountedBytes", &DMREAD, DMT_UNINT, get_QoSPolicer_ConformingCountedBytes, NULL, BBFDM_BOTH, "2.0"},
//{"PartiallyConformingCountedPackets", &DMREAD, DMT_UNINT, get_QoSPolicer_PartiallyConformingCountedPackets, NULL, BBFDM_BOTH, "2.0"},
//{"PartiallyConformingCountedBytes", &DMREAD, DMT_UNINT, get_QoSPolicer_PartiallyConformingCountedBytes, NULL, BBFDM_BOTH, "2.0"},
//{"NonConformingCountedPackets", &DMREAD, DMT_UNINT, get_QoSPolicer_NonConformingCountedPackets, NULL, BBFDM_BOTH, "2.0"},
//{"NonConformingCountedBytes", &DMREAD, DMT_UNINT, get_QoSPolicer_NonConformingCountedBytes, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.QoS.Queue.{i}. *** */
DMLEAF tQoSQueueParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_QoSQueue_Enable, set_QoSQueue_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_QoSQueue_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_QoSQueue_Alias, set_QoSQueue_Alias, BBFDM_BOTH},
{"TrafficClasses", &DMWRITE, DMT_STRING, get_QoSQueue_TrafficClasses, set_QoSQueue_TrafficClasses, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_QoSQueue_Interface, set_QoSQueue_Interface, BBFDM_BOTH},
//{"AllInterfaces", &DMWRITE, DMT_BOOL, get_QoSQueue_AllInterfaces, set_QoSQueue_AllInterfaces, BBFDM_BOTH},
//{"HardwareAssisted", &DMREAD, DMT_BOOL, get_QoSQueue_HardwareAssisted, NULL, BBFDM_BOTH},
//{"BufferLength", &DMREAD, DMT_UNINT, get_QoSQueue_BufferLength, NULL, BBFDM_BOTH},
{"Weight", &DMWRITE, DMT_UNINT, get_QoSQueue_Weight, set_QoSQueue_Weight, BBFDM_BOTH},
{"Precedence", &DMWRITE, DMT_UNINT, get_QoSQueue_Precedence, set_QoSQueue_Precedence, BBFDM_BOTH},
//{"REDThreshold", &DMWRITE, DMT_UNINT, get_QoSQueue_REDThreshold, set_QoSQueue_REDThreshold, BBFDM_BOTH},
//{"REDPercentage", &DMWRITE, DMT_UNINT, get_QoSQueue_REDPercentage, set_QoSQueue_REDPercentage, BBFDM_BOTH},
//{"DropAlgorithm", &DMWRITE, DMT_STRING, get_QoSQueue_DropAlgorithm, set_QoSQueue_DropAlgorithm, BBFDM_BOTH},
{"SchedulerAlgorithm", &DMWRITE, DMT_STRING, get_QoSQueue_SchedulerAlgorithm, set_QoSQueue_SchedulerAlgorithm, BBFDM_BOTH},
{"ShapingRate", &DMWRITE, DMT_INT, get_QoSQueue_ShapingRate, set_QoSQueue_ShapingRate, BBFDM_BOTH},
{"ShapingBurstSize", &DMWRITE, DMT_UNINT, get_QoSQueue_ShapingBurstSize, set_QoSQueue_ShapingBurstSize, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_QoSQueue_Enable, set_QoSQueue_Enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_QoSQueue_Status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_QoSQueue_Alias, set_QoSQueue_Alias, BBFDM_BOTH, "2.0"},
{"TrafficClasses", &DMWRITE, DMT_STRING, get_QoSQueue_TrafficClasses, set_QoSQueue_TrafficClasses, BBFDM_BOTH, "2.0"},
{"Interface", &DMWRITE, DMT_STRING, get_QoSQueue_Interface, set_QoSQueue_Interface, BBFDM_BOTH, "2.0"},
//{"AllInterfaces", &DMWRITE, DMT_BOOL, get_QoSQueue_AllInterfaces, set_QoSQueue_AllInterfaces, BBFDM_BOTH, "2.0"},
//{"HardwareAssisted", &DMREAD, DMT_BOOL, get_QoSQueue_HardwareAssisted, NULL, BBFDM_BOTH, "2.0"},
//{"BufferLength", &DMREAD, DMT_UNINT, get_QoSQueue_BufferLength, NULL, BBFDM_BOTH, "2.0"},
{"Weight", &DMWRITE, DMT_UNINT, get_QoSQueue_Weight, set_QoSQueue_Weight, BBFDM_BOTH, "2.0"},
{"Precedence", &DMWRITE, DMT_UNINT, get_QoSQueue_Precedence, set_QoSQueue_Precedence, BBFDM_BOTH, "2.0"},
//{"REDThreshold", &DMWRITE, DMT_UNINT, get_QoSQueue_REDThreshold, set_QoSQueue_REDThreshold, BBFDM_BOTH, "2.0"},
//{"REDPercentage", &DMWRITE, DMT_UNINT, get_QoSQueue_REDPercentage, set_QoSQueue_REDPercentage, BBFDM_BOTH, "2.0"},
//{"DropAlgorithm", &DMWRITE, DMT_STRING, get_QoSQueue_DropAlgorithm, set_QoSQueue_DropAlgorithm, BBFDM_BOTH, "2.0"},
{"SchedulerAlgorithm", &DMWRITE, DMT_STRING, get_QoSQueue_SchedulerAlgorithm, set_QoSQueue_SchedulerAlgorithm, BBFDM_BOTH, "2.0"},
{"ShapingRate", &DMWRITE, DMT_INT, get_QoSQueue_ShapingRate, set_QoSQueue_ShapingRate, BBFDM_BOTH, "2.0"},
{"ShapingBurstSize", &DMWRITE, DMT_UNINT, get_QoSQueue_ShapingBurstSize, set_QoSQueue_ShapingBurstSize, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.QoS.QueueStats.{i}. *** */
DMLEAF tQoSQueueStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_QoSQueueStats_Enable, set_QoSQueueStats_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_QoSQueueStats_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_QoSQueueStats_Alias, set_QoSQueueStats_Alias, BBFDM_BOTH},
{"Queue", &DMWRITE, DMT_STRING, get_QoSQueueStats_Queue, set_QoSQueueStats_Queue, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_QoSQueueStats_Interface, set_QoSQueueStats_Interface, BBFDM_BOTH},
{"OutputPackets", &DMREAD, DMT_UNINT, get_QoSQueueStats_OutputPackets, NULL, BBFDM_BOTH},
{"OutputBytes", &DMREAD, DMT_UNINT, get_QoSQueueStats_OutputBytes, NULL, BBFDM_BOTH},
{"DroppedPackets", &DMREAD, DMT_UNINT, get_QoSQueueStats_DroppedPackets, NULL, BBFDM_BOTH},
{"DroppedBytes", &DMREAD, DMT_UNINT, get_QoSQueueStats_DroppedBytes, NULL, BBFDM_BOTH},
//{"QueueOccupancyPackets", &DMREAD, DMT_UNINT, get_QoSQueueStats_QueueOccupancyPackets, NULL, BBFDM_BOTH},
//{"QueueOccupancyPercentage", &DMREAD, DMT_UNINT, get_QoSQueueStats_QueueOccupancyPercentage, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_QoSQueueStats_Enable, set_QoSQueueStats_Enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_QoSQueueStats_Status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_QoSQueueStats_Alias, set_QoSQueueStats_Alias, BBFDM_BOTH, "2.0"},
{"Queue", &DMWRITE, DMT_STRING, get_QoSQueueStats_Queue, set_QoSQueueStats_Queue, BBFDM_BOTH, "2.0"},
{"Interface", &DMWRITE, DMT_STRING, get_QoSQueueStats_Interface, set_QoSQueueStats_Interface, BBFDM_BOTH, "2.0"},
{"OutputPackets", &DMREAD, DMT_UNINT, get_QoSQueueStats_OutputPackets, NULL, BBFDM_BOTH, "2.0"},
{"OutputBytes", &DMREAD, DMT_UNINT, get_QoSQueueStats_OutputBytes, NULL, BBFDM_BOTH, "2.0"},
{"DroppedPackets", &DMREAD, DMT_UNINT, get_QoSQueueStats_DroppedPackets, NULL, BBFDM_BOTH, "2.0"},
{"DroppedBytes", &DMREAD, DMT_UNINT, get_QoSQueueStats_DroppedBytes, NULL, BBFDM_BOTH, "2.0"},
//{"QueueOccupancyPackets", &DMREAD, DMT_UNINT, get_QoSQueueStats_QueueOccupancyPackets, NULL, BBFDM_BOTH, "2.0"},
//{"QueueOccupancyPercentage", &DMREAD, DMT_UNINT, get_QoSQueueStats_QueueOccupancyPercentage, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.QoS.Shaper.{i}. *** */
DMLEAF tQoSShaperParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_QoSShaper_Enable, set_QoSShaper_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_QoSShaper_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_QoSShaper_Alias, set_QoSShaper_Alias, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_QoSShaper_Interface, set_QoSShaper_Interface, BBFDM_BOTH},
{"ShapingRate", &DMWRITE, DMT_INT, get_QoSShaper_ShapingRate, set_QoSShaper_ShapingRate, BBFDM_BOTH},
{"ShapingBurstSize", &DMWRITE, DMT_UNINT, get_QoSShaper_ShapingBurstSize, set_QoSShaper_ShapingBurstSize, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_QoSShaper_Enable, set_QoSShaper_Enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_QoSShaper_Status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_QoSShaper_Alias, set_QoSShaper_Alias, BBFDM_BOTH, "2.0"},
{"Interface", &DMWRITE, DMT_STRING, get_QoSShaper_Interface, set_QoSShaper_Interface, BBFDM_BOTH, "2.0"},
{"ShapingRate", &DMWRITE, DMT_INT, get_QoSShaper_ShapingRate, set_QoSShaper_ShapingRate, BBFDM_BOTH, "2.0"},
{"ShapingBurstSize", &DMWRITE, DMT_UNINT, get_QoSShaper_ShapingBurstSize, set_QoSShaper_ShapingBurstSize, BBFDM_BOTH, "2.0"},
{0}
};

View file

@ -11,8 +11,7 @@
#ifndef __QOS_H
#define __QOS_H
#include <libbbf_api/dmcommon.h>
#include "dmentry.h"
#include "libbbf_api/dmcommon.h"
extern DMOBJ tQoSObj[];
extern DMLEAF tQoSParams[];

View file

@ -59,7 +59,7 @@ static int browseRouterAdvertisementInterfaceSettingInst(struct dmctx *dmctx, DM
// skip the section if option ignore = '1'
dmuci_get_value_by_section_string(p->config_section, "ignore", &ignore);
if (ignore && strcmp(ignore, "1") == 0)
if (ignore && DM_LSTRCMP(ignore, "1") == 0)
continue;
inst = handle_instance(dmctx, parent_node, p->dmmap_section, "radv_intf_instance", "radv_intf_alias");
@ -225,7 +225,7 @@ static int get_RouterAdvertisement_InterfaceSettingNumberOfEntries(char *refpara
static int get_RouterAdvertisementInterfaceSetting_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ra", value);
*value = (*value && strcmp(*value, "disabled") == 0) ? "0" : "1";
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "0" : "1";
return 0;
}
@ -250,7 +250,7 @@ static int set_RouterAdvertisementInterfaceSetting_Enable(char *refparam, struct
static int get_RouterAdvertisementInterfaceSetting_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "ra", value);
*value = (*value && strcmp(*value, "disabled") == 0) ? "Disabled" : "Enabled";
*value = (*value && DM_LSTRCMP(*value, "disabled") == 0) ? "Disabled" : "Enabled";
return 0;
}
@ -283,26 +283,26 @@ static int get_RouterAdvertisementInterfaceSetting_Interface(char *refparam, str
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "interface", &linker);
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value);
if (*value == NULL)
*value = "";
return 0;
}
static int set_RouterAdvertisementInterfaceSetting_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
char *linker = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, -1, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
break;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
if (linker && *linker) {
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", linker);
dmfree(linker);
}
dmuci_set_value_by_section(((struct dmmap_dup *)data)->config_section, "interface", linker ? linker : "");
break;
}
return 0;
@ -329,7 +329,7 @@ static int get_RouterAdvertisementInterfaceSetting_Prefixes(char *refparam, stru
uci_path_foreach_option_eq(bbfdm, "dmmap_network_ipv6_prefix", "intf_ipv6_prefix", "section_name", interface, dmmap_s) {
dmuci_get_value_by_section_string(dmmap_s, "address", &address);
if (address && strcmp(address, ipv6_prefix) == 0) {
if (address && DM_STRCMP(address, ipv6_prefix) == 0) {
dmuci_get_value_by_section_string(dmmap_s, "ipv6_prefix_instance", &ipv6_prefix_inst);
break;
}
@ -661,7 +661,7 @@ static int get_RouterAdvertisementInterfaceSettingOption_Value(char *refparam, s
char hex[65535] = {0};
if (option_value && *option_value)
convert_string_to_hex(option_value, hex);
convert_string_to_hex(option_value, hex, sizeof(hex));
*value = (*hex) ? dmstrdup(hex) : "";
return 0;
@ -679,7 +679,7 @@ static int set_RouterAdvertisementInterfaceSettingOption_Value(char *refparam, s
return FAULT_9007;
break;
case VALUESET:
convert_hex_to_string(value, res);
convert_hex_to_string(value, res, sizeof(res));
dmuci_get_value_by_section_list(radv_option_s->config_sect, "dns", &dns_list);
if (value_exists_in_uci_list(dns_list, radv_option_s->option_value)) {
@ -699,54 +699,54 @@ static int set_RouterAdvertisementInterfaceSettingOption_Value(char *refparam, s
/* *** Device.RouterAdvertisement. *** */
DMOBJ tRouterAdvertisementObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"InterfaceSetting", &DMWRITE, addObjRouterAdvertisementInterfaceSetting, delObjRouterAdvertisementInterfaceSetting, NULL, browseRouterAdvertisementInterfaceSettingInst, NULL, NULL, tRouterAdvertisementInterfaceSettingObj, tRouterAdvertisementInterfaceSettingParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Interface", NULL}},
{"InterfaceSetting", &DMWRITE, addObjRouterAdvertisementInterfaceSetting, delObjRouterAdvertisementInterfaceSetting, NULL, browseRouterAdvertisementInterfaceSettingInst, NULL, NULL, tRouterAdvertisementInterfaceSettingObj, tRouterAdvertisementInterfaceSettingParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Interface", NULL}, "2.2"},
{0}
};
DMLEAF tRouterAdvertisementParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_RouterAdvertisement_Enable, set_RouterAdvertisement_Enable, BBFDM_BOTH},
{"InterfaceSettingNumberOfEntries", &DMREAD, DMT_UNINT, get_RouterAdvertisement_InterfaceSettingNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_RouterAdvertisement_Enable, set_RouterAdvertisement_Enable, BBFDM_BOTH, "2.2"},
{"InterfaceSettingNumberOfEntries", &DMREAD, DMT_UNINT, get_RouterAdvertisement_InterfaceSettingNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.RouterAdvertisement.InterfaceSetting.{i}. *** */
DMOBJ tRouterAdvertisementInterfaceSettingObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Option", &DMWRITE, addObjRouterAdvertisementInterfaceSettingOption, delObjRouterAdvertisementInterfaceSettingOption, NULL, browseRouterAdvertisementInterfaceSettingOptionInst, NULL, NULL, NULL, tRouterAdvertisementInterfaceSettingOptionParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Tag", NULL}},
{"Option", &DMWRITE, addObjRouterAdvertisementInterfaceSettingOption, delObjRouterAdvertisementInterfaceSettingOption, NULL, browseRouterAdvertisementInterfaceSettingOptionInst, NULL, NULL, NULL, tRouterAdvertisementInterfaceSettingOptionParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", "Tag", NULL}, "2.2"},
{0}
};
DMLEAF tRouterAdvertisementInterfaceSettingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_Enable, set_RouterAdvertisementInterfaceSetting_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Alias, set_RouterAdvertisementInterfaceSetting_Alias, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Interface, set_RouterAdvertisementInterfaceSetting_Interface, BBFDM_BOTH},
//{"ManualPrefixes", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_ManualPrefixes, set_RouterAdvertisementInterfaceSetting_ManualPrefixes, BBFDM_BOTH},
{"Prefixes", &DMREAD, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Prefixes, NULL, BBFDM_BOTH},
{"MaxRtrAdvInterval", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval, set_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval, BBFDM_BOTH},
{"MinRtrAdvInterval", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval, set_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval, BBFDM_BOTH},
{"AdvDefaultLifetime", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime, set_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime, BBFDM_BOTH},
{"AdvManagedFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvManagedFlag, set_RouterAdvertisementInterfaceSetting_AdvManagedFlag, BBFDM_BOTH},
{"AdvOtherConfigFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag, set_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag, BBFDM_BOTH},
{"AdvMobileAgentFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag, set_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag, BBFDM_BOTH},
{"AdvPreferredRouterFlag", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag, set_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag, BBFDM_BOTH},
//{"AdvNDProxyFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvNDProxyFlag, set_RouterAdvertisementInterfaceSetting_AdvNDProxyFlag, BBFDM_BOTH},
{"AdvLinkMTU", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvLinkMTU, set_RouterAdvertisementInterfaceSetting_AdvLinkMTU, BBFDM_BOTH},
{"AdvReachableTime", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvReachableTime, set_RouterAdvertisementInterfaceSetting_AdvReachableTime, BBFDM_BOTH},
{"AdvRetransTimer", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvRetransTimer, set_RouterAdvertisementInterfaceSetting_AdvRetransTimer, BBFDM_BOTH},
{"AdvCurHopLimit", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvCurHopLimit, set_RouterAdvertisementInterfaceSetting_AdvCurHopLimit, BBFDM_BOTH},
{"OptionNumberOfEntries", &DMREAD, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_OptionNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_Enable, set_RouterAdvertisementInterfaceSetting_Enable, BBFDM_BOTH, "2.2"},
{"Status", &DMREAD, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Status, NULL, BBFDM_BOTH, "2.2"},
{"Alias", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Alias, set_RouterAdvertisementInterfaceSetting_Alias, BBFDM_BOTH, "2.2"},
{"Interface", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Interface, set_RouterAdvertisementInterfaceSetting_Interface, BBFDM_BOTH, "2.2"},
//{"ManualPrefixes", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_ManualPrefixes, set_RouterAdvertisementInterfaceSetting_ManualPrefixes, BBFDM_BOTH, "2.2"},
{"Prefixes", &DMREAD, DMT_STRING, get_RouterAdvertisementInterfaceSetting_Prefixes, NULL, BBFDM_BOTH, "2.2"},
{"MaxRtrAdvInterval", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval, set_RouterAdvertisementInterfaceSetting_MaxRtrAdvInterval, BBFDM_BOTH, "2.2"},
{"MinRtrAdvInterval", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval, set_RouterAdvertisementInterfaceSetting_MinRtrAdvInterval, BBFDM_BOTH, "2.2"},
{"AdvDefaultLifetime", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime, set_RouterAdvertisementInterfaceSetting_AdvDefaultLifetime, BBFDM_BOTH, "2.2"},
{"AdvManagedFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvManagedFlag, set_RouterAdvertisementInterfaceSetting_AdvManagedFlag, BBFDM_BOTH, "2.2"},
{"AdvOtherConfigFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag, set_RouterAdvertisementInterfaceSetting_AdvOtherConfigFlag, BBFDM_BOTH, "2.2"},
{"AdvMobileAgentFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag, set_RouterAdvertisementInterfaceSetting_AdvMobileAgentFlag, BBFDM_BOTH, "2.2"},
{"AdvPreferredRouterFlag", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag, set_RouterAdvertisementInterfaceSetting_AdvPreferredRouterFlag, BBFDM_BOTH, "2.2"},
//{"AdvNDProxyFlag", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSetting_AdvNDProxyFlag, set_RouterAdvertisementInterfaceSetting_AdvNDProxyFlag, BBFDM_BOTH, "2.2"},
{"AdvLinkMTU", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvLinkMTU, set_RouterAdvertisementInterfaceSetting_AdvLinkMTU, BBFDM_BOTH, "2.2"},
{"AdvReachableTime", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvReachableTime, set_RouterAdvertisementInterfaceSetting_AdvReachableTime, BBFDM_BOTH, "2.2"},
{"AdvRetransTimer", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvRetransTimer, set_RouterAdvertisementInterfaceSetting_AdvRetransTimer, BBFDM_BOTH, "2.2"},
{"AdvCurHopLimit", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_AdvCurHopLimit, set_RouterAdvertisementInterfaceSetting_AdvCurHopLimit, BBFDM_BOTH, "2.2"},
{"OptionNumberOfEntries", &DMREAD, DMT_UNINT, get_RouterAdvertisementInterfaceSetting_OptionNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.RouterAdvertisement.InterfaceSetting.{i}.Option.{i}. *** */
DMLEAF tRouterAdvertisementInterfaceSettingOptionParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSettingOption_Enable, set_RouterAdvertisementInterfaceSettingOption_Enable, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSettingOption_Alias, set_RouterAdvertisementInterfaceSettingOption_Alias, BBFDM_BOTH},
{"Tag", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSettingOption_Tag, set_RouterAdvertisementInterfaceSettingOption_Tag, BBFDM_BOTH},
{"Value", &DMWRITE, DMT_HEXBIN, get_RouterAdvertisementInterfaceSettingOption_Value, set_RouterAdvertisementInterfaceSettingOption_Value, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_RouterAdvertisementInterfaceSettingOption_Enable, set_RouterAdvertisementInterfaceSettingOption_Enable, BBFDM_BOTH, "2.2"},
{"Alias", &DMWRITE, DMT_STRING, get_RouterAdvertisementInterfaceSettingOption_Alias, set_RouterAdvertisementInterfaceSettingOption_Alias, BBFDM_BOTH, "2.2"},
{"Tag", &DMWRITE, DMT_UNINT, get_RouterAdvertisementInterfaceSettingOption_Tag, set_RouterAdvertisementInterfaceSettingOption_Tag, BBFDM_BOTH, "2.2"},
{"Value", &DMWRITE, DMT_HEXBIN, get_RouterAdvertisementInterfaceSettingOption_Value, set_RouterAdvertisementInterfaceSettingOption_Value, BBFDM_BOTH, "2.2"},
{0}
};

View file

@ -11,7 +11,7 @@
#ifndef __ROUTERADVERTISEMENT_H
#define __ROUTERADVERTISEMENT_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern DMOBJ tRouterAdvertisementObj[];
extern DMLEAF tRouterAdvertisementParams[];

View file

@ -10,7 +10,6 @@
*
*/
#include "dmentry.h"
#include "routing.h"
struct proc_routing {
@ -70,7 +69,10 @@ static bool is_proc_route_in_config(struct proc_routing *proute)
char *mask;
dmuci_get_value_by_section_string(s, "netmask", &mask);
if (mask[0] == '\0' || strcmp(proute->mask, mask) == 0)
if (DM_STRLEN(mask) == 0)
return true;
if (DM_STRCMP(proute->mask, mask) == 0)
return true;
}
@ -78,7 +80,10 @@ static bool is_proc_route_in_config(struct proc_routing *proute)
char *mask;
dmuci_get_value_by_section_string(s, "netmask", &mask);
if (mask[0] == '\0' || strcmp(proute->mask, mask) == 0)
if (DM_STRLEN(mask) == 0)
return true;
if (DM_STRCMP(proute->mask, mask) == 0)
return true;
}
@ -88,7 +93,7 @@ static bool is_proc_route_in_config(struct proc_routing *proute)
dmuci_get_value_by_section_string(s, "target", &target);
dmuci_get_value_by_section_string(s, "gateway", &gateway);
dmuci_get_value_by_section_string(s, "device", &device);
if (strcmp(target, proute->destination) == 0 && strcmp(gateway, proute->gateway) == 0 && strcmp(device, proute->iface) == 0)
if (DM_STRCMP(target, proute->destination) == 0 && DM_STRCMP(gateway, proute->gateway) == 0 && DM_STRCMP(device, proute->iface) == 0)
return true;
}
@ -108,7 +113,7 @@ static bool is_proc_route6_in_config(char *cdev, char *cip, char *cgw)
dmuci_get_value_by_section_string(s, "interface", &intf_r);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", intf_r, String}}, 1, &jobj);
char *dev_r = (jobj) ? dmjson_get_value(jobj, 1, "device") : "";
if (strcmp(cdev, dev_r) == 0 && strcmp(cgw, gw_r) == 0 && strcmp(cip, ip_r) == 0)
if (DM_STRCMP(cdev, dev_r) == 0 && DM_STRCMP(cgw, gw_r) == 0 && DM_STRCMP(cip, ip_r) == 0)
return true;
}
@ -121,7 +126,7 @@ static bool is_proc_route6_in_config(char *cdev, char *cip, char *cgw)
dmuci_get_value_by_section_string(s, "interface", &intf_r6);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", intf_r6, String}}, 1, &jobj);
char *dev_r6 = (jobj) ? dmjson_get_value(jobj, 1, "device") : "";
if (strcmp(cdev, dev_r6) == 0 && strcmp(cgw, gw_r6) == 0 && strcmp(cip, ip_r6) == 0)
if (DM_STRCMP(cdev, dev_r6) == 0 && DM_STRCMP(cgw, gw_r6) == 0 && DM_STRCMP(cip, ip_r6) == 0)
return true;
}
@ -131,7 +136,7 @@ static bool is_proc_route6_in_config(char *cdev, char *cip, char *cgw)
dmuci_get_value_by_section_string(s, "target", &ip_r6d);
dmuci_get_value_by_section_string(s, "gateway", &gw_r6d);
dmuci_get_value_by_section_string(s, "device", &dev_r6d);
if (strcmp(cdev, dev_r6d) == 0 && strcmp(cgw, gw_r6d) == 0 && strcmp(cip, ip_r6d) == 0)
if (DM_STRCMP(cdev, dev_r6d) == 0 && DM_STRCMP(cgw, gw_r6d) == 0 && DM_STRCMP(cip, ip_r6d) == 0)
return true;
}
@ -144,15 +149,15 @@ static void parse_proc_route_line(char *line, struct proc_routing *proute)
proute->iface = strtok_r(line, " \t", &spch);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->destination);
hex_to_ip(pch, proute->destination, sizeof(proute->destination));
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->gateway);
hex_to_ip(pch, proute->gateway, sizeof(proute->gateway));
proute->flags = strtok_r(NULL, " \t", &spch);
proute->refcnt = strtok_r(NULL, " \t", &spch);
proute->use = strtok_r(NULL, " \t", &spch);
proute->metric = strtok_r(NULL, " \t", &spch);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->mask);
hex_to_ip(pch, proute->mask, sizeof(proute->mask));
proute->mtu = strtok_r(NULL, " \t", &spch);
proute->window = strtok_r(NULL, " \t", &spch);
proute->irtt = strtok_r(NULL, " \t\n\r", &spch);
@ -171,7 +176,7 @@ static int parse_proc_route6_line(const char *line, char *ipstr, char *gwstr, ch
&gw[0], &gw[1], &gw[2], &gw[3], metric,
&refcnt, &use, &flags, dev);
if (strcmp(dev, "lo") == 0)
if (DM_LSTRCMP(dev, "lo") == 0)
return -1;
ip[0] = htonl(ip[0]);
@ -212,7 +217,7 @@ static int dmmap_synchronizeRoutingRouterIPv4Forwarding(struct dmctx *dmctx, DMN
continue;
}
parse_proc_route_line(line, &proute);
if ((strcmp(iface, proute.iface) == 0) && strcmp(target, proute.destination) == 0) {
if ((DM_STRCMP(iface, proute.iface) == 0) && DM_STRCMP(target, proute.destination) == 0) {
found = true;
break;
}
@ -236,13 +241,14 @@ static int dmmap_synchronizeRoutingRouterIPv4Forwarding(struct dmctx *dmctx, DMN
continue;
iface = "";
uci_foreach_sections("network", "interface", s) {
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &jobj);
char *if_name = section_name(s);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &jobj);
if (!jobj) {
fclose(fp);
return 0;
}
str = dmjson_get_value(jobj, 1, "l3_device");
if (strcmp(str, proute.iface) == 0) {
if (DM_STRCMP(str, proute.iface) == 0) {
iface = section_name(s);
break;
}
@ -283,7 +289,7 @@ static int dmmap_synchronizeRoutingRouterIPv6Forwarding(struct dmctx *dmctx, DMN
if (parse_proc_route6_line(buf, ipstr, gwstr, dev, &metric))
continue;
if (strcmp(iface, dev) == 0 && strcmp(ipstr, target) == 0) {
if (DM_STRCMP(iface, dev) == 0 && DM_STRCMP(ipstr, target) == 0) {
found = 1;
break;
}
@ -310,13 +316,14 @@ static int dmmap_synchronizeRoutingRouterIPv6Forwarding(struct dmctx *dmctx, DMN
uci_foreach_sections("network", "interface", s) {
json_object *jobj = NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &jobj);
char *if_name = section_name(s);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &jobj);
if (!jobj) {
fclose(fp);
return 0;
}
char *str = dmjson_get_value(jobj, 1, "device");
if (strcmp(str, dev) == 0) {
if (DM_STRCMP(str, dev) == 0) {
iface = section_name(s);
break;
}
@ -452,17 +459,18 @@ static int browseRoutingRouteInformationInterfaceSettingInst(struct dmctx *dmctx
{
struct uci_section *s = NULL;
char *inst = NULL;
int id = 0, i = 0;
int id = 0, i;
uci_foreach_sections("network", "interface", s) {
char *proto = NULL, *ip6addr = NULL;
dmuci_get_value_by_section_string(s, "proto", &proto);
dmuci_get_value_by_section_string(s, "ip6addr", &ip6addr);
if ((proto && strcmp(proto, "dhcpv6") == 0) || (ip6addr && ip6addr[0] != '\0')) {
if ((proto && DM_LSTRCMP(proto, "dhcpv6") == 0) || (ip6addr && ip6addr[0] != '\0')) {
json_object *res = NULL, *route_obj = NULL, *arrobj = NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
char *if_name = section_name(s);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
dmjson_foreach_obj_in_array(res, arrobj, route_obj, i, 1, "route") {
inst = handle_instance_without_section(dmctx, parent_node, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)route_obj, inst) == DM_STOP)
@ -643,7 +651,7 @@ static int get_router_ipv4forwarding_origin(char *refparam, struct dmctx *ctx, v
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interface, String}}, 1, &res);
DM_ASSERT(res, *value = "DHCPv4");
char *proto = dmjson_get_value(res, 1, "proto");
*value = (proto && strncmp(proto, "ppp", 3) == 0) ? "IPCP" : "DHCPv4";
*value = (proto && DM_LSTRNCMP(proto, "ppp", 3) == 0) ? "IPCP" : "DHCPv4";
}
return 0;
}
@ -674,29 +682,27 @@ static int get_RoutingRouterForwarding_Interface(char *refparam, struct dmctx *c
char *linker = NULL;
dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "interface", &linker);
if (linker && linker[0] != '\0') {
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
}
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
static int set_RoutingRouterForwarding_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *allowed_objects[] = {"Device.IP.Interface.", NULL};
char *linker = NULL;
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, 256, NULL, NULL))
return FAULT_9007;
if (dm_entry_validate_allowed_objects(ctx, value, allowed_objects))
return FAULT_9007;
return 0;
case VALUESET:
adm_entry_get_linker_value(ctx, value, &linker);
if (linker && *linker) {
dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "interface", linker);
dmfree(linker);
}
dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "interface", linker ? linker : "");
return 0;
}
return 0;
@ -887,10 +893,11 @@ static int get_RoutingRouteInformation_InterfaceSettingNumberOfEntries(char *ref
dmuci_get_value_by_section_string(s, "proto", &proto);
dmuci_get_value_by_section_string(s, "ip6addr", &ip6addr);
if ((proto && strcmp(proto, "dhcpv6") == 0) || (ip6addr && ip6addr[0] != '\0')) {
if ((proto && DM_LSTRCMP(proto, "dhcpv6") == 0) || (ip6addr && ip6addr[0] != '\0')) {
json_object *res = NULL, *routes = NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &res);
char *if_name = section_name(s);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
DM_ASSERT(res, *value = "0");
json_object_object_get_ex(res, "route", &routes);
nbre_routes = (routes) ? json_object_array_length(routes) : 0;
@ -913,7 +920,7 @@ static int get_RoutingRouteInformationInterfaceSetting_Status(char *refparam, st
uci_foreach_sections("network", "route6", s) {
dmuci_get_value_by_section_string(s, "target", &ip_target);
dmuci_get_value_by_section_string(s, "gateway", &gateway);
if(strcmp(ip_target, buf) == 0 && strcmp(nexthop, gateway) == 0) {
if(DM_STRCMP(ip_target, buf) == 0 && DM_STRCMP(nexthop, gateway) == 0) {
*value = "ForwardingEntryCreated";
return 0;
}
@ -940,7 +947,7 @@ static int get_RoutingRouteInformationInterfaceSetting_Interface(char *refparam,
if (parse_proc_route6_line(buf, ipstr, gwstr, dev, &metric))
continue;
if((strcmp(source, ipstr) == 0) && (strcmp(nexthop, gwstr) == 0))
if((DM_STRCMP(source, ipstr) == 0) && (DM_STRCMP(nexthop, gwstr) == 0))
break;
}
fclose(fp);
@ -948,20 +955,19 @@ static int get_RoutingRouteInformationInterfaceSetting_Interface(char *refparam,
uci_foreach_sections("network", "interface", s) {
json_object *jobj = NULL;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(s), String}}, 1, &jobj);
char *if_name = section_name(s);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &jobj);
if (!jobj) return 0;
char *str = dmjson_get_value(jobj, 1, "device");
if (strcmp(str, dev) == 0) {
if (DM_STRCMP(str, dev) == 0) {
iface = section_name(s);
break;
}
}
if (iface[0] != '\0') {
if (iface && *iface != 0)
adm_entry_get_linker_param(ctx, "Device.IP.Interface.", iface, value);
if (*value == NULL)
*value = "";
}
return 0;
}
@ -976,10 +982,10 @@ static int get_RoutingRouteInformationInterfaceSetting_RouteLifetime(char *refpa
*value = "0001-01-01T00:00:00Z";
char *valid = dmjson_get_value((struct json_object *)data, 1, "valid");
if (valid && *valid != '\0' && atoi(valid) > 0) {
if (valid && *valid != '\0' && DM_STRTOL(valid) > 0) {
char local_time[32] = {0};
if (get_shift_utc_time(atoi(valid), local_time, sizeof(local_time)) == -1)
if (get_shift_utc_time(DM_STRTOL(valid), local_time, sizeof(local_time)) == -1)
return 0;
*value = dmstrdup(local_time);
}
@ -1225,89 +1231,89 @@ static int delete_ipv6Forwarding(char *refparam, struct dmctx *ctx, void *data,
***********************************************************************************************************************************/
/* *** Device.Routing. *** */
DMOBJ tRoutingObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Router", &DMREAD, NULL, NULL, NULL, browseRouterInst, NULL, NULL, tRoutingRouterObj, tRoutingRouterParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}},
{"RouteInformation", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tRoutingRouteInformationObj, tRoutingRouteInformationParams, NULL, BBFDM_BOTH},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Router", &DMREAD, NULL, NULL, NULL, browseRouterInst, NULL, NULL, tRoutingRouterObj, tRoutingRouterParams, NULL, BBFDM_BOTH, LIST_KEY{"Alias", NULL}, "2.0"},
{"RouteInformation", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tRoutingRouteInformationObj, tRoutingRouteInformationParams, NULL, BBFDM_BOTH, NULL, "2.2"},
{0}
};
DMLEAF tRoutingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"RouterNumberOfEntries", &DMREAD, DMT_UNINT, get_router_nbr_entry, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"RouterNumberOfEntries", &DMREAD, DMT_UNINT, get_router_nbr_entry, NULL, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.Routing.Router.{i}. *** */
DMOBJ tRoutingRouterObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"IPv4Forwarding", &DMWRITE, add_ipv4forwarding, delete_ipv4forwarding, NULL, browseIPv4ForwardingInst, NULL, NULL, NULL, tRoutingRouterIPv4ForwardingParams, NULL, BBFDM_BOTH, LIST_KEY{"DestIPAddress", "DestSubnetMask", "ForwardingPolicy", "GatewayIPAddress", "Interface", "ForwardingMetric", "Alias", NULL}},
{"IPv6Forwarding", &DMWRITE, add_ipv6Forwarding, delete_ipv6Forwarding, NULL, browseIPv6ForwardingInst, NULL, NULL, NULL, tRoutingRouterIPv6ForwardingParams, NULL, BBFDM_BOTH, LIST_KEY{"DestIPPrefix", "ForwardingPolicy", "NextHop", "Interface", "ForwardingMetric", "Alias", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"IPv4Forwarding", &DMWRITE, add_ipv4forwarding, delete_ipv4forwarding, NULL, browseIPv4ForwardingInst, NULL, NULL, NULL, tRoutingRouterIPv4ForwardingParams, NULL, BBFDM_BOTH, LIST_KEY{"DestIPAddress", "DestSubnetMask", "ForwardingPolicy", "GatewayIPAddress", "Interface", "ForwardingMetric", "Alias", NULL}, "2.0"},
{"IPv6Forwarding", &DMWRITE, add_ipv6Forwarding, delete_ipv6Forwarding, NULL, browseIPv6ForwardingInst, NULL, NULL, NULL, tRoutingRouterIPv6ForwardingParams, NULL, BBFDM_BOTH, LIST_KEY{"DestIPPrefix", "ForwardingPolicy", "NextHop", "Interface", "ForwardingMetric", "Alias", NULL}, "2.2"},
{0}
};
DMLEAF tRoutingRouterParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_RoutingRouter_Enable, set_RoutingRouter_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_RoutingRouter_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_RoutingRouter_Alias, set_RoutingRouter_Alias, BBFDM_BOTH},
{"IPv4ForwardingNumberOfEntries", &DMREAD, DMT_UNINT, get_RoutingRouter_IPv4ForwardingNumberOfEntries, NULL, BBFDM_BOTH},
{"IPv6ForwardingNumberOfEntries", &DMREAD, DMT_UNINT, get_RoutingRouter_IPv6ForwardingNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_RoutingRouter_Enable, set_RoutingRouter_Enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_RoutingRouter_Status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_RoutingRouter_Alias, set_RoutingRouter_Alias, BBFDM_BOTH, "2.0"},
{"IPv4ForwardingNumberOfEntries", &DMREAD, DMT_UNINT, get_RoutingRouter_IPv4ForwardingNumberOfEntries, NULL, BBFDM_BOTH, "2.0"},
{"IPv6ForwardingNumberOfEntries", &DMREAD, DMT_UNINT, get_RoutingRouter_IPv6ForwardingNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.Routing.Router.{i}.IPv4Forwarding.{i}. *** */
DMLEAF tRoutingRouterIPv4ForwardingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMRouting, DMT_BOOL, get_router_ipv4forwarding_enable, set_router_ipv4forwarding_enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_router_ipv4forwarding_status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_router_ipv4forwarding_alias, set_router_ipv4forwarding_alias, BBFDM_BOTH},
{"StaticRoute", &DMREAD, DMT_BOOL, get_router_ipv4forwarding_static_route, NULL, BBFDM_BOTH},
{"DestIPAddress", &DMRouting, DMT_STRING, get_router_ipv4forwarding_destip, set_router_ipv4forwarding_destip, BBFDM_BOTH},
{"DestSubnetMask", &DMRouting, DMT_STRING, get_router_ipv4forwarding_destmask, set_router_ipv4forwarding_destmask, BBFDM_BOTH},
{"ForwardingPolicy", &DMRouting, DMT_INT, get_router_ipv4forwarding_forwarding_policy, set_router_ipv4forwarding_forwarding_policy, BBFDM_BOTH},
{"GatewayIPAddress", &DMRouting, DMT_STRING, get_router_ipv4forwarding_gatewayip, set_router_ipv4forwarding_gatewayip, BBFDM_BOTH},
{"Interface", &DMRouting, DMT_STRING, get_RoutingRouterForwarding_Interface, set_RoutingRouterForwarding_Interface, BBFDM_BOTH},
{"Origin", &DMREAD, DMT_STRING, get_router_ipv4forwarding_origin, NULL, BBFDM_BOTH},
{"ForwardingMetric", &DMRouting, DMT_INT, get_router_ipv4forwarding_metric, set_router_ipv4forwarding_metric, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMRouting, DMT_BOOL, get_router_ipv4forwarding_enable, set_router_ipv4forwarding_enable, BBFDM_BOTH, "2.0"},
{"Status", &DMREAD, DMT_STRING, get_router_ipv4forwarding_status, NULL, BBFDM_BOTH, "2.0"},
{"Alias", &DMWRITE, DMT_STRING, get_router_ipv4forwarding_alias, set_router_ipv4forwarding_alias, BBFDM_BOTH, "2.0"},
{"StaticRoute", &DMREAD, DMT_BOOL, get_router_ipv4forwarding_static_route, NULL, BBFDM_BOTH, "2.0"},
{"DestIPAddress", &DMRouting, DMT_STRING, get_router_ipv4forwarding_destip, set_router_ipv4forwarding_destip, BBFDM_BOTH, "2.0"},
{"DestSubnetMask", &DMRouting, DMT_STRING, get_router_ipv4forwarding_destmask, set_router_ipv4forwarding_destmask, BBFDM_BOTH, "2.0"},
{"ForwardingPolicy", &DMRouting, DMT_INT, get_router_ipv4forwarding_forwarding_policy, set_router_ipv4forwarding_forwarding_policy, BBFDM_BOTH, "2.0"},
{"GatewayIPAddress", &DMRouting, DMT_STRING, get_router_ipv4forwarding_gatewayip, set_router_ipv4forwarding_gatewayip, BBFDM_BOTH, "2.0"},
{"Interface", &DMRouting, DMT_STRING, get_RoutingRouterForwarding_Interface, set_RoutingRouterForwarding_Interface, BBFDM_BOTH, "2.0"},
{"Origin", &DMREAD, DMT_STRING, get_router_ipv4forwarding_origin, NULL, BBFDM_BOTH, "2.2"},
{"ForwardingMetric", &DMRouting, DMT_INT, get_router_ipv4forwarding_metric, set_router_ipv4forwarding_metric, BBFDM_BOTH, "2.0"},
{0}
};
/* *** Device.Routing.Router.{i}.IPv6Forwarding.{i}. *** */
DMLEAF tRoutingRouterIPv6ForwardingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMRouting, DMT_BOOL, get_RoutingRouterIPv6Forwarding_Enable, set_RoutingRouterIPv6Forwarding_Enable, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_RoutingRouterIPv6Forwarding_Status, NULL, BBFDM_BOTH},
{"Alias", &DMWRITE, DMT_STRING, get_RoutingRouterIPv6Forwarding_Alias, set_RoutingRouterIPv6Forwarding_Alias, BBFDM_BOTH},
{"DestIPPrefix", &DMRouting, DMT_STRING, get_RoutingRouterIPv6Forwarding_DestIPPrefix, set_RoutingRouterIPv6Forwarding_DestIPPrefix, BBFDM_BOTH},
{"ForwardingPolicy", &DMRouting, DMT_INT, get_RoutingRouterIPv6Forwarding_ForwardingPolicy, set_RoutingRouterIPv6Forwarding_ForwardingPolicy, BBFDM_BOTH},
{"NextHop", &DMRouting, DMT_STRING, get_RoutingRouterIPv6Forwarding_NextHop, set_RoutingRouterIPv6Forwarding_NextHop, BBFDM_BOTH},
{"Interface", &DMRouting, DMT_STRING, get_RoutingRouterForwarding_Interface, set_RoutingRouterForwarding_Interface, BBFDM_BOTH},
{"Origin", &DMREAD, DMT_STRING, get_RoutingRouterIPv6Forwarding_Origin, NULL, BBFDM_BOTH},
{"ForwardingMetric", &DMRouting, DMT_INT, get_RoutingRouterIPv6Forwarding_ForwardingMetric, set_RoutingRouterIPv6Forwarding_ForwardingMetric, BBFDM_BOTH},
{"ExpirationTime", &DMREAD, DMT_TIME, get_RoutingRouterIPv6Forwarding_ExpirationTime, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMRouting, DMT_BOOL, get_RoutingRouterIPv6Forwarding_Enable, set_RoutingRouterIPv6Forwarding_Enable, BBFDM_BOTH, "2.2"},
{"Status", &DMREAD, DMT_STRING, get_RoutingRouterIPv6Forwarding_Status, NULL, BBFDM_BOTH, "2.2"},
{"Alias", &DMWRITE, DMT_STRING, get_RoutingRouterIPv6Forwarding_Alias, set_RoutingRouterIPv6Forwarding_Alias, BBFDM_BOTH, "2.2"},
{"DestIPPrefix", &DMRouting, DMT_STRING, get_RoutingRouterIPv6Forwarding_DestIPPrefix, set_RoutingRouterIPv6Forwarding_DestIPPrefix, BBFDM_BOTH, "2.2"},
{"ForwardingPolicy", &DMRouting, DMT_INT, get_RoutingRouterIPv6Forwarding_ForwardingPolicy, set_RoutingRouterIPv6Forwarding_ForwardingPolicy, BBFDM_BOTH, "2.2"},
{"NextHop", &DMRouting, DMT_STRING, get_RoutingRouterIPv6Forwarding_NextHop, set_RoutingRouterIPv6Forwarding_NextHop, BBFDM_BOTH, "2.2"},
{"Interface", &DMRouting, DMT_STRING, get_RoutingRouterForwarding_Interface, set_RoutingRouterForwarding_Interface, BBFDM_BOTH, "2.2"},
{"Origin", &DMREAD, DMT_STRING, get_RoutingRouterIPv6Forwarding_Origin, NULL, BBFDM_BOTH, "2.2"},
{"ForwardingMetric", &DMRouting, DMT_INT, get_RoutingRouterIPv6Forwarding_ForwardingMetric, set_RoutingRouterIPv6Forwarding_ForwardingMetric, BBFDM_BOTH, "2.2"},
{"ExpirationTime", &DMREAD, DMT_TIME, get_RoutingRouterIPv6Forwarding_ExpirationTime, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.Routing.RouteInformation. *** */
DMOBJ tRoutingRouteInformationObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"InterfaceSetting", &DMREAD, NULL, NULL, NULL, browseRoutingRouteInformationInterfaceSettingInst, NULL, NULL, NULL, tRoutingRouteInformationInterfaceSettingParams, NULL, BBFDM_BOTH, LIST_KEY{"Interface", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"InterfaceSetting", &DMREAD, NULL, NULL, NULL, browseRoutingRouteInformationInterfaceSettingInst, NULL, NULL, NULL, tRoutingRouteInformationInterfaceSettingParams, NULL, BBFDM_BOTH, LIST_KEY{"Interface", NULL}, "2.2"},
{0}
};
DMLEAF tRoutingRouteInformationParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Enable", &DMWRITE, DMT_BOOL, get_RoutingRouteInformation_Enable, set_RoutingRouteInformation_Enable, BBFDM_BOTH},
{"InterfaceSettingNumberOfEntries", &DMREAD, DMT_UNINT, get_RoutingRouteInformation_InterfaceSettingNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Enable", &DMWRITE, DMT_BOOL, get_RoutingRouteInformation_Enable, set_RoutingRouteInformation_Enable, BBFDM_BOTH, "2.2"},
{"InterfaceSettingNumberOfEntries", &DMREAD, DMT_UNINT, get_RoutingRouteInformation_InterfaceSettingNumberOfEntries, NULL, BBFDM_BOTH, "2.2"},
{0}
};
/* *** Device.Routing.RouteInformation.InterfaceSetting.{i}. *** */
DMLEAF tRoutingRouteInformationInterfaceSettingParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"Status", &DMREAD, DMT_STRING, get_RoutingRouteInformationInterfaceSetting_Status, NULL, BBFDM_BOTH},
{"Interface", &DMREAD, DMT_STRING, get_RoutingRouteInformationInterfaceSetting_Interface, NULL, BBFDM_BOTH},
{"SourceRouter", &DMREAD, DMT_STRING, get_RoutingRouteInformationInterfaceSetting_SourceRouter, NULL, BBFDM_BOTH},
{"RouteLifetime", &DMREAD, DMT_TIME, get_RoutingRouteInformationInterfaceSetting_RouteLifetime, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"Status", &DMREAD, DMT_STRING, get_RoutingRouteInformationInterfaceSetting_Status, NULL, BBFDM_BOTH, "2.2"},
{"Interface", &DMREAD, DMT_STRING, get_RoutingRouteInformationInterfaceSetting_Interface, NULL, BBFDM_BOTH, "2.2"},
{"SourceRouter", &DMREAD, DMT_STRING, get_RoutingRouteInformationInterfaceSetting_SourceRouter, NULL, BBFDM_BOTH, "2.2"},
{"RouteLifetime", &DMREAD, DMT_TIME, get_RoutingRouteInformationInterfaceSetting_RouteLifetime, NULL, BBFDM_BOTH, "2.2"},
{0}
};

View file

@ -13,7 +13,7 @@
#ifndef __ROUTING_H
#define __ROUTING_H
#include <libbbf_api/dmcommon.h>
#include "libbbf_api/dmcommon.h"
extern struct dm_permession_s DMRouting;

View file

@ -10,17 +10,31 @@
#include "security.h"
#if defined(LOPENSSL) || defined(LWOLFSSL) || defined(LMBEDTLS)
#define DATE_LEN 128
#define MAX_CERT 32
#ifdef LMBEDTLS
#include <mbedtls/x509_crt.h>
#include <mbedtls/base64.h>
#endif
#ifdef LOPENSSL
#include <openssl/x509.h>
#include <openssl/pem.h>
#endif
#ifdef LWOLFSSL
#include <wolfssl/options.h>
#include <wolfssl/openssl/x509.h>
#include <wolfssl/openssl/pem.h>
#endif
static char certifcates_paths[MAX_CERT][256];
struct certificate_profile {
char *path;
#ifdef LOPENSSL
X509 *openssl_cert;
#elif LMBEDTLS
mbedtls_x509_crt mbdtls_cert;
#ifdef LMBEDTLS
mbedtls_x509_crt cert;
#else
X509 *cert;
#endif
struct uci_section *dmmap_sect;
};
@ -29,82 +43,22 @@ struct certificate_profile {
* INIT
**************************************************************/
void init_certificate(char *path,
#ifdef LOPENSSL
X509 *cert,
#elif LMBEDTLS
#ifdef LMBEDTLS
mbedtls_x509_crt cert,
#else
X509 *cert,
#endif
struct uci_section *dmsect, struct certificate_profile *certprofile)
{
certprofile->path = path;
#ifdef LOPENSSL
certprofile->openssl_cert = cert;
#elif LMBEDTLS
certprofile->mbdtls_cert = cert;
#endif
certprofile->cert = cert;
certprofile->dmmap_sect = dmsect;
}
/*************************************************************
* COMMON FUNCTIONS
**************************************************************/
#ifdef LOPENSSL
static char *get_certificate_sig_alg(int sig_nid)
{
switch(sig_nid) {
case NID_sha256WithRSAEncryption:
return LN_sha256WithRSAEncryption;
case NID_sha384WithRSAEncryption:
return LN_sha384WithRSAEncryption;
case NID_sha512WithRSAEncryption:
return LN_sha512WithRSAEncryption;
case NID_sha224WithRSAEncryption:
return LN_sha224WithRSAEncryption;
case NID_sha512_224WithRSAEncryption:
return LN_sha512_224WithRSAEncryption;
case NID_sha512_256WithRSAEncryption:
return LN_sha512_224WithRSAEncryption;
case NID_pbeWithMD2AndDES_CBC:
return LN_pbeWithMD2AndDES_CBC;
case NID_pbeWithMD5AndDES_CBC:
return LN_pbeWithMD5AndDES_CBC;
case NID_pbeWithMD2AndRC2_CBC:
return LN_pbeWithMD5AndDES_CBC;
case NID_pbeWithMD5AndRC2_CBC:
return LN_pbeWithMD5AndRC2_CBC;
case NID_pbeWithSHA1AndDES_CBC:
return LN_pbeWithSHA1AndDES_CBC;
case NID_pbeWithSHA1AndRC2_CBC:
return LN_pbeWithSHA1AndDES_CBC;
case NID_pbe_WithSHA1And128BitRC4:
return LN_pbe_WithSHA1And128BitRC4;
case NID_pbe_WithSHA1And40BitRC4:
return LN_pbe_WithSHA1And40BitRC4;
case NID_pbe_WithSHA1And3_Key_TripleDES_CBC:
return LN_pbe_WithSHA1And3_Key_TripleDES_CBC;
case NID_pbe_WithSHA1And2_Key_TripleDES_CBC:
return LN_pbe_WithSHA1And2_Key_TripleDES_CBC;
case NID_pbe_WithSHA1And128BitRC2_CBC:
return LN_pbe_WithSHA1And128BitRC2_CBC;
case NID_pbe_WithSHA1And40BitRC2_CBC:
return LN_pbe_WithSHA1And40BitRC2_CBC;
case NID_sm3WithRSAEncryption:
return LN_sm3WithRSAEncryption;
case NID_shaWithRSAEncryption:
return LN_shaWithRSAEncryption;
case NID_md2WithRSAEncryption:
return LN_md2WithRSAEncryption;
case NID_md4WithRSAEncryption:
return LN_md4WithRSAEncryption;
case NID_md5WithRSAEncryption:
return LN_md5WithRSAEncryption;
case NID_sha1WithRSAEncryption:
return LN_sha1WithRSAEncryption;
default:
return "";
}
}
#elif LMBEDTLS
#ifdef LMBEDTLS
static char *get_certificate_md(mbedtls_md_type_t sig_md)
{
switch(sig_md) {
@ -152,18 +106,41 @@ static char *get_certificate_pk(mbedtls_pk_type_t sig_pk)
}
return "";
}
#else
static char *get_certificate_sig_alg(int sig_nid)
{
switch(sig_nid) {
case NID_sha256WithRSAEncryption:
return "sha256WithRSAEncryption";
case NID_sha384WithRSAEncryption:
return "sha384WithRSAEncryption";
case NID_sha512WithRSAEncryption:
return "sha512WithRSAEncryption";
case NID_sha224WithRSAEncryption:
return "sha224WithRSAEncryption";
case NID_md5WithRSAEncryption:
return "md5WithRSAEncryption";
case NID_sha1WithRSAEncryption:
return "sha1WithRSAEncryption";
default:
return "";
}
return "";
}
#endif
static char *generate_serial_number(char *text, int length)
{
int i, j;
char *hex = (char *)dmcalloc(100, sizeof(char));
unsigned pos = 0;
for (i = 0, j = 0; i < length; ++i, j += 3) {
sprintf(hex + j, "%02x", text[i] & 0xff);
if (i < length-1)
sprintf(hex + j + 2, "%c", ':');
for (int i = 0; i < length; i++) {
pos += snprintf(&hex[pos], 100 - pos, "%02x:", text[i] & 0xff);
}
if (pos)
hex[pos - 1] = 0;
return hex;
}
@ -172,14 +149,14 @@ static void get_certificate_paths(void)
struct uci_section *s = NULL;
int cidx;
for (cidx=0; cidx<MAX_CERT; cidx++)
for (cidx = 0; cidx < MAX_CERT; cidx++)
memset(certifcates_paths[cidx], '\0', 256);
cidx = 0;
uci_foreach_sections("owsd", "owsd-listen", s) {
uci_foreach_sections("nginx", "server", s) {
char *cert;
dmuci_get_value_by_section_string(s, "cert", &cert);
dmuci_get_value_by_section_string(s, "ssl_certificate", &cert);
if (*cert == '\0')
continue;
if (cidx >= MAX_CERT)
@ -222,61 +199,56 @@ static void get_certificate_paths(void)
**************************************************************/
static int browseSecurityCertificateInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
#if defined(LOPENSSL) || defined(LMBEDTLS)
char *inst = NULL;
struct uci_section *dmmap_sect = NULL;
struct certificate_profile certificateprofile = {};
int i, status;
get_certificate_paths();
int i;
for (i = 0; i < MAX_CERT; i++) {
if(!strlen(certifcates_paths[i]))
for (i = 0, status = DM_OK; i < MAX_CERT && status != DM_STOP; i++) {
if(!DM_STRLEN(certifcates_paths[i]))
break;
#ifdef LOPENSSL
#ifdef LMBEDTLS
mbedtls_x509_crt cert;
mbedtls_x509_crt_init(&cert);
if (mbedtls_x509_crt_parse_file(&cert, certifcates_paths[i]) < 0)
continue;
#else
FILE *fp = fopen(certifcates_paths[i], "r");
if (fp == NULL)
continue;
X509 *cert = PEM_read_X509(fp, NULL, NULL, NULL);
if (!cert) {
fclose(fp);
continue;
}
#endif
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_security", "security_certificate", "path", certifcates_paths[i])) == NULL) {
dmuci_add_section_bbfdm("dmmap_security", "security_certificate", &dmmap_sect);
dmuci_set_value_by_section_bbfdm(dmmap_sect, "path", certifcates_paths[i]);
}
init_certificate(certifcates_paths[i], cert, dmmap_sect, &certificateprofile);
inst = handle_instance(dmctx, parent_node, dmmap_sect, "security_certificate_instance", "security_certificate_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&certificateprofile, inst) == DM_STOP)
break;
status = DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&certificateprofile, inst);
#ifdef LMBEDTLS
mbedtls_x509_crt_free(&cert);
#else
X509_free(cert);
cert = NULL;
fclose(fp);
fp = NULL;
#elif LMBEDTLS
mbedtls_x509_crt cacert;
mbedtls_x509_crt_init( &cacert );
int ret = mbedtls_x509_crt_parse_file( &cacert, certifcates_paths[i]);
if (ret < 0)
continue;
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_security", "security_certificate", "path", certifcates_paths[i])) == NULL) {
dmuci_add_section_bbfdm("dmmap_security", "security_certificate", &dmmap_sect);
dmuci_set_value_by_section_bbfdm(dmmap_sect, "path", certifcates_paths[i]);
}
init_certificate(certifcates_paths[i], cacert, dmmap_sect, &certificateprofile);
inst = handle_instance(dmctx, parent_node, dmmap_sect, "security_certificate_instance", "security_certificate_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&certificateprofile, inst) == DM_STOP)
break;
#endif
}
#endif
return 0;
}
@ -292,121 +264,147 @@ static int get_Security_CertificateNumberOfEntries(char *refparam, struct dmctx
static int get_SecurityCertificate_LastModif(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
struct certificate_profile *cert_profile = (struct certificate_profile *)data;
char buf[sizeof("AAAA-MM-JJTHH:MM:SSZ")] = "0001-01-01T00:00:00Z";
struct stat b;
char t[sizeof("AAAA-MM-JJTHH:MM:SSZ")] = "0001-01-01T00:00:00Z";
if (!stat(cert_profile->path, &b))
strftime(t, sizeof(t), "%Y-%m-%dT%H:%M:%SZ", gmtime(&b.st_mtime));
*value = dmstrdup(t);
strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%SZ", gmtime(&b.st_mtime));
*value = dmstrdup(buf);
return 0;
}
static int get_SecurityCertificate_SerialNumber(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
#ifdef LOPENSSL
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
ASN1_INTEGER *serial = X509_get_serialNumber(cert_profile->openssl_cert);
struct certificate_profile *cert_profile = (struct certificate_profile *)data;
#ifdef LMBEDTLS
*value = generate_serial_number((char *)cert_profile->cert.serial.p, cert_profile->cert.serial.len);
#else
ASN1_INTEGER *serial = X509_get_serialNumber(cert_profile->cert);
*value = generate_serial_number((char *)serial->data, serial->length);
#elif LMBEDTLS
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
*value = generate_serial_number(cert_profile->mbdtls_cert.serial.p, cert_profile->mbdtls_cert.serial.len);
#endif
return 0;
}
static int get_SecurityCertificate_Issuer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
#ifdef LOPENSSL
struct certificate_profile *cert_profile = (struct certificate_profile *)data;
char buf[256] = {0};
X509_NAME_oneline(X509_get_issuer_name(cert_profile->openssl_cert), buf, sizeof(buf));
#ifdef LMBEDTLS
if (mbedtls_x509_dn_gets(buf, sizeof(buf), &cert_profile->cert.issuer) < 0)
return -1;
*value = dmstrdup(buf);
#else
X509_NAME_oneline(X509_get_issuer_name(cert_profile->cert), buf, sizeof(buf));
*value = dmstrdup(buf);
if (*value[0] == '/')
(*value)++;
*value = replace_char(*value, '/', ' ');
#elif LMBEDTLS
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
size_t olen;
unsigned char issuer[4096];
int ret2 = mbedtls_base64_encode(issuer, 4096, &olen, cert_profile->mbdtls_cert.issuer.val.p, cert_profile->mbdtls_cert.issuer.val.len );
if(ret2 != 0)
return 0;
*value = decode64(issuer);
#endif
return 0;
}
static int get_SecurityCertificate_NotBefore(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0001-01-01T00:00:00Z";
#ifdef LOPENSSL
struct tm not_before_time;
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
struct certificate_profile *cert_profile = (struct certificate_profile *)data;
#ifdef LMBEDTLS
dmasprintf(value, "%04d-%02d-%02dT%02d:%02d:%02dZ", cert_profile->cert.valid_from.year,
cert_profile->cert.valid_from.mon,
cert_profile->cert.valid_from.day,
cert_profile->cert.valid_from.hour,
cert_profile->cert.valid_from.min,
cert_profile->cert.valid_from.sec);
#else
char not_before_str[DATE_LEN];
const ASN1_TIME *not_before = X509_get0_notBefore(cert_profile->openssl_cert);
ASN1_TIME_to_tm(not_before, &not_before_time);
strftime(not_before_str, sizeof(not_before_str), "%Y-%m-%dT%H:%M:%SZ", &not_before_time);
*value = dmstrdup(not_before_str);
#elif LMBEDTLS
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
dmasprintf(value, "%d-%d-%dT%d:%d:%dZ", cert_profile->mbdtls_cert.valid_from.year, cert_profile->mbdtls_cert.valid_from.mon, cert_profile->mbdtls_cert.valid_from.day, cert_profile->mbdtls_cert.valid_from.hour, cert_profile->mbdtls_cert.valid_from.min, cert_profile->mbdtls_cert.valid_from.sec);
struct tm tm;
const ASN1_TIME *not_before = X509_get0_notBefore(cert_profile->cert);
#ifdef LWOLFSSL
ASN1_TIME_to_string((ASN1_TIME *)not_before, not_before_str, DATE_LEN);
if (!strptime(not_before_str, "%b %d %H:%M:%S %Y", &tm))
return -1;
#else
ASN1_TIME_to_tm(not_before, &tm);
#endif
strftime(not_before_str, sizeof(not_before_str), "%Y-%m-%dT%H:%M:%SZ", &tm);
*value = dmstrdup(not_before_str);
#endif
return 0;
}
static int get_SecurityCertificate_NotAfter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0001-01-01T00:00:00Z";
#ifdef LOPENSSL
struct tm not_after_time;
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
struct certificate_profile *cert_profile = (struct certificate_profile *)data;
#ifdef LMBEDTLS
dmasprintf(value, "%04d-%02d-%02dT%02d:%02d:%02dZ", cert_profile->cert.valid_to.year,
cert_profile->cert.valid_to.mon,
cert_profile->cert.valid_to.day,
cert_profile->cert.valid_to.hour,
cert_profile->cert.valid_to.min,
cert_profile->cert.valid_to.sec);
#else
char not_after_str[DATE_LEN];
const ASN1_TIME *not_after = X509_get0_notAfter(cert_profile->openssl_cert);
ASN1_TIME_to_tm(not_after, &not_after_time);
strftime(not_after_str, sizeof(not_after_str), "%Y-%m-%dT%H:%M:%SZ", &not_after_time);
*value = dmstrdup(not_after_str);
#elif LMBEDTLS
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
dmasprintf(value, "%d-%d-%dT%d:%d:%dZ", cert_profile->mbdtls_cert.valid_to.year, cert_profile->mbdtls_cert.valid_to.mon, cert_profile->mbdtls_cert.valid_to.day, cert_profile->mbdtls_cert.valid_to.hour, cert_profile->mbdtls_cert.valid_to.min, cert_profile->mbdtls_cert.valid_to.sec);
struct tm tm;
const ASN1_TIME *not_after = X509_get0_notAfter(cert_profile->cert);
#ifdef LWOLFSSL
ASN1_TIME_to_string((ASN1_TIME *)not_after, not_after_str, DATE_LEN);
if (!strptime(not_after_str, "%b %d %H:%M:%S %Y", &tm))
return -1;
#else
ASN1_TIME_to_tm((ASN1_TIME *)not_after, &tm);
#endif
strftime(not_after_str, sizeof(not_after_str), "%Y-%m-%dT%H:%M:%SZ", &tm);
*value = dmstrdup(not_after_str);
#endif
return 0;
}
static int get_SecurityCertificate_Subject(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
#ifdef LOPENSSL
struct certificate_profile *cert_profile = (struct certificate_profile *)data;
char buf[256] = {0};
X509_NAME_oneline(X509_get_subject_name(cert_profile->openssl_cert), buf, sizeof(buf));
#if LMBEDTLS
if (mbedtls_x509_dn_gets(buf, sizeof(buf), &cert_profile->cert.subject) < 0)
return -1;
*value = dmstrdup(buf);
#else
X509_NAME_oneline(X509_get_subject_name(cert_profile->cert), buf, sizeof(buf));
*value = dmstrdup(buf);
if (*value[0] == '/')
(*value)++;
*value = replace_char(*value, '/', ' ');
#elif LMBEDTLS
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
size_t olen;
unsigned char issuer[4096];
int ret2 = mbedtls_base64_encode(issuer, 4096, &olen, cert_profile->mbdtls_cert.subject.val.p, cert_profile->mbdtls_cert.subject.val.len );
if(ret2 != 0)
return 0;
*value = decode64(issuer);
#endif
return 0;
}
static int get_SecurityCertificate_SignatureAlgorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
#ifdef LOPENSSL
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
*value = dmstrdup(get_certificate_sig_alg(X509_get_signature_nid(cert_profile->openssl_cert)));
#elif LMBEDTLS
struct certificate_profile *cert_profile = (struct certificate_profile*)data;
dmasprintf(value, "%sWith%sEncryptionn", get_certificate_md(cert_profile->mbdtls_cert.sig_md), get_certificate_pk(cert_profile->mbdtls_cert.sig_pk));
struct certificate_profile *cert_profile = (struct certificate_profile *)data;
#ifdef LMBEDTLS
dmasprintf(value, "%sWith%sEncryption", get_certificate_md(cert_profile->cert.sig_md), get_certificate_pk(cert_profile->cert.sig_pk));
#else
*value = dmstrdup(get_certificate_sig_alg(X509_get_signature_nid(cert_profile->cert)));
#endif
return 0;
}
@ -415,28 +413,30 @@ static int get_SecurityCertificate_SignatureAlgorithm(char *refparam, struct dmc
***********************************************************************************************************************************/
/* *** Device.Security. *** */
DMOBJ tSecurityObj[] = {
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
{"Certificate", &DMREAD, NULL, NULL, NULL, browseSecurityCertificateInst, NULL, NULL, NULL, tSecurityCertificateParams, NULL, BBFDM_BOTH, LIST_KEY{"SerialNumber", "Issuer", NULL}},
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys, version*/
{"Certificate", &DMREAD, NULL, NULL, NULL, browseSecurityCertificateInst, NULL, NULL, NULL, tSecurityCertificateParams, NULL, BBFDM_BOTH, LIST_KEY{"SerialNumber", "Issuer", NULL}, "2.4"},
{0}
};
DMLEAF tSecurityParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
{"CertificateNumberOfEntries", &DMREAD, DMT_UNINT, get_Security_CertificateNumberOfEntries, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"CertificateNumberOfEntries", &DMREAD, DMT_UNINT, get_Security_CertificateNumberOfEntries, NULL, BBFDM_BOTH, "2.4"},
{0}
};
/* *** Device.Security.Certificate.{i}. *** */
DMLEAF tSecurityCertificateParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
//{"Enable", &DMWRITE, DMT_BOOL, get_SecurityCertificate_Enable, set_SecurityCertificate_Enable, BBFDM_BOTH},
{"LastModif", &DMREAD, DMT_TIME, get_SecurityCertificate_LastModif, NULL, BBFDM_BOTH},
{"SerialNumber", &DMREAD, DMT_STRING, get_SecurityCertificate_SerialNumber, NULL, BBFDM_BOTH},
{"Issuer", &DMREAD, DMT_STRING, get_SecurityCertificate_Issuer, NULL, BBFDM_BOTH},
{"NotBefore", &DMREAD, DMT_TIME, get_SecurityCertificate_NotBefore, NULL, BBFDM_BOTH},
{"NotAfter", &DMREAD, DMT_TIME, get_SecurityCertificate_NotAfter, NULL, BBFDM_BOTH},
{"Subject", &DMREAD, DMT_STRING, get_SecurityCertificate_Subject, NULL, BBFDM_BOTH},
//{"SubjectAlt", &DMREAD, DMT_STRING, get_SecurityCertificate_SubjectAlt, NULL, BBFDM_BOTH},
{"SignatureAlgorithm", &DMREAD, DMT_STRING, get_SecurityCertificate_SignatureAlgorithm, NULL, BBFDM_BOTH},
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
//{"Enable", &DMWRITE, DMT_BOOL, get_SecurityCertificate_Enable, set_SecurityCertificate_Enable, BBFDM_BOTH, "2.4"},
{"LastModif", &DMREAD, DMT_TIME, get_SecurityCertificate_LastModif, NULL, BBFDM_BOTH, "2.4"},
{"SerialNumber", &DMREAD, DMT_STRING, get_SecurityCertificate_SerialNumber, NULL, BBFDM_BOTH, "2.4"},
{"Issuer", &DMREAD, DMT_STRING, get_SecurityCertificate_Issuer, NULL, BBFDM_BOTH, "2.4"},
{"NotBefore", &DMREAD, DMT_TIME, get_SecurityCertificate_NotBefore, NULL, BBFDM_BOTH, "2.4"},
{"NotAfter", &DMREAD, DMT_TIME, get_SecurityCertificate_NotAfter, NULL, BBFDM_BOTH, "2.4"},
{"Subject", &DMREAD, DMT_STRING, get_SecurityCertificate_Subject, NULL, BBFDM_BOTH, "2.4"},
//{"SubjectAlt", &DMREAD, DMT_STRING, get_SecurityCertificate_SubjectAlt, NULL, BBFDM_BOTH, "2.4"},
{"SignatureAlgorithm", &DMREAD, DMT_STRING, get_SecurityCertificate_SignatureAlgorithm, NULL, BBFDM_BOTH, "2.4"},
{0}
};
#endif

View file

@ -11,20 +11,13 @@
#ifndef __SECURITY_H
#define __SECURITY_H
#include <libbbf_api/dmcommon.h>
#ifdef LOPENSSL
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/pem.h>
#include <openssl/obj_mac.h>
#elif LMBEDTLS
#include <mbedtls/x509.h>
#include <mbedtls/x509_crt.h>
#endif
#if defined(LOPENSSL) || defined(LWOLFSSL) || defined(LMBEDTLS)
#include "libbbf_api/dmcommon.h"
extern DMOBJ tSecurityObj[];
extern DMLEAF tSecurityParams[];
extern DMLEAF tSecurityCertificateParams[];
#endif
#endif //__SECURITY_H

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