From b5ebaeca30fbf8f8b9f578eb9a5d51a273640d0a Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Thu, 9 Jun 2022 17:45:08 +0100 Subject: [PATCH] cmake: update vendor parser --- CMakeLists.txt | 138 ++++++------------------------ dmtree/vendor/openwrt/tr181/qos.c | 3 +- 2 files changed, 28 insertions(+), 113 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95a24750..7cc6103d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,85 +18,39 @@ OPTION(WITH_WOLFSSL "build with lib wolfssl" OFF) OPTION(WITH_OPENSSL "build with lib openssl" OFF) OPTION(WITH_MBEDTLS "build with lib mbedtls" OFF) -SET(BBF_API_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/dmapi.c) +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(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() - IF(BBF_TR181) - SET(BBF_TR181_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) - add_compile_definitions(BBF_TR181) + FILE(GLOB BBF_TR181_SOURCES ${PROJECT_SOURCE_DIR}/dmtree/tr181/*.c) + add_compile_definitions(BBF_TR181) ENDIF(BBF_TR181) IF(BBF_TR104) - SET(BBF_TR104_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) - add_compile_definitions(BBF_TR104) + FILE(GLOB BBF_TR104_SOURCES ${PROJECT_SOURCE_DIR}/dmtree/tr104/*.c) + add_compile_definitions(BBF_TR104) ENDIF(BBF_TR104) IF(BBF_TR143) - SET(BBF_TR143_SOURCES dmtree/tr143/diagnostics.c) - add_compile_definitions(BBF_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) + 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) + SET(BBF_JSON_PLUGIN_SOURCES dmdynamicjson.c) + add_compile_definitions(BBFDM_ENABLE_JSON_PLUGIN) endif(BBF_JSON_PLUGIN) IF(WITH_WOLFSSL) @@ -106,13 +60,11 @@ ENDIF(WITH_WOLFSSL) IF(WITH_OPENSSL) SET(SSL_LIBS ssl) - SET(CRYPTO_LIBS crypto) add_compile_definitions(LOPENSSL) ENDIF(WITH_OPENSSL) IF(WITH_MBEDTLS) SET(SSL_LIBS mbedtls) - SET(CRYPTO_LIBS mbedcrypto) add_compile_definitions(LMBEDTLS) ENDIF(WITH_MBEDTLS) @@ -123,62 +75,24 @@ IF(BBF_VENDOR_EXTENSION) SET(BBF_VENDOR_LIST "iopsys" CACHE STRING "vendor list to be used") - IF(BBF_VENDOR_LIST MATCHES "(.*)iopsys(.*)") - add_compile_definitions(BBF_VENDOR_IOPSYS) + STRING(REPLACE "," ";" VENDOR_LIST ${BBF_VENDOR_LIST}) - IF(BBF_TR181) - SET(BBF_VENDOR_IOPSYS_TR181_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) - SET(BBF_VENDOR_IOPSYS_TR104_SOURCES dmtree/vendor/iopsys/tr104/servicesvoiceservicecallcontrol.c - dmtree/vendor/iopsys/tr104/servicesvoiceservicecalllog.c - dmtree/vendor/iopsys/tr104/servicesvoiceservicedect.c) - ENDIF(BBF_TR104) - - ENDIF(BBF_VENDOR_LIST MATCHES "(.*)iopsys(.*)") - - IF(BBF_VENDOR_LIST MATCHES "(.*)openwrt(.*)") - add_compile_definitions(BBF_VENDOR_OPENWRT) - - IF(BBF_TR181) - SET(BBF_VENDOR_OPENWRT_TR181_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_LIST MATCHES "(.*)openwrt(.*)") - - IF(BBF_VENDOR_LIST MATCHES "(.*)test(.*)") - add_compile_definitions(BBF_VENDOR_TEST) - - IF(BBF_TR181) - SET(BBF_VENDOR_TEST_TR181_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_LIST MATCHES "(.*)test(.*)") + 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} - ${BBF_VENDOR_IOPSYS_TR181_SOURCES} ${BBF_VENDOR_IOPSYS_TR104_SOURCES} - ${BBF_VENDOR_OPENWRT_TR181_SOURCES} - ${BBF_VENDOR_TEST_TR181_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} ${CRYPTO_LIBS}) +TARGET_LINK_LIBRARIES(bbfdm uci ubus ubox json-c blobmsg_json trace dl curl ${SSL_LIBS}) INSTALL(TARGETS bbfdm LIBRARY DESTINATION "/usr/lib") diff --git a/dmtree/vendor/openwrt/tr181/qos.c b/dmtree/vendor/openwrt/tr181/qos.c index 5e04af29..1e0278a9 100644 --- a/dmtree/vendor/openwrt/tr181/qos.c +++ b/dmtree/vendor/openwrt/tr181/qos.c @@ -96,6 +96,7 @@ static int openwrt__browseQoSQueueStatsInst(struct dmctx *dmctx, DMNODE *parent_ int length = 0; struct queuestats queuests = {0}, emptyquestats = {0}; regex_t regex1 = {}, regex2 = {}; + int ret = 0; regcomp(®ex1, "^qdisc noqueue [0-9]*: dev [[:alnum:]]* [[:alnum:]]* refcnt [0-9]*", 0); regcomp(®ex2, "^qdisc pfifo_fast [0-9]*: dev [[:alnum:]]* [[:alnum:]]* refcnt [0-9]*", 0); @@ -105,7 +106,7 @@ static int openwrt__browseQoSQueueStatsInst(struct dmctx *dmctx, DMNODE *parent_ for (int i = 0; i < length; i++) { switch (i%3) { case 0: - int ret = regexec(®ex1, questatsout[i], 0, NULL, 0); + ret = regexec(®ex1, questatsout[i], 0, NULL, 0); if (ret == 0) sscanf(questatsout[i], "qdisc noqueue %d: dev %49s %49s refcnt %d\n", &queuests.noqueue, dev, user, &queuests.refcnt); else {