From 839d68bd1f159f79ddcaf82f559e0bae2417baef Mon Sep 17 00:00:00 2001 From: tpaul627 <69359527+tpaul627@users.noreply.github.com> Date: Fri, 25 Jul 2025 20:13:14 +0530 Subject: [PATCH 01/11] RDKEMW-6328: set AVHijack rfc to false (#208) --- .../parodusClient/waldb/data-model/data-model-generic.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index 7a0d81180..e3c9469fb 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -4345,7 +4345,7 @@ - + From c1760d3fc35655603c7fea45f86421149cbc8659 Mon Sep 17 00:00:00 2001 From: madhubabutt <114217841+madhubabutt@users.noreply.github.com> Date: Tue, 29 Jul 2025 20:00:52 +0530 Subject: [PATCH 02/11] RDKEMW-6193 Code Coverage support for tr69hostif (#211) Co-authored-by: mtirum011 --- .github/workflows/code-coverage.yml | 52 +++++++++++++++++++++++ run_ut.sh | 28 ++++++++---- src/unittest/stubs/ds/audioOutputPort.hpp | 2 +- src/unittest/stubs/ds/host.hpp | 2 +- 4 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/code-coverage.yml diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 000000000..2e29b0b79 --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -0,0 +1,52 @@ +name: Code Coverage + +on: + pull_request: + branches: [ main ] + +jobs: + execute-unit-code-coverage-report-on-release: + name: Test coverage report for release + runs-on: ubuntu-latest + container: + image: ghcr.io/rdkcentral/docker-rdk-ci:latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run unit tests with coverage flags enabled + run: | + sh run_ut.sh --enable-cov + - name: Caculate the code coverage summary + run: | + lcov --list tr69hostif_coverage.info | grep "Lines\|Total" > /tmp/coverage_summary.txt + cd - + + - name: Update the coverage report to Pull request using actions + uses: actions/github-script@v4 + with: + script: | + const fs = require('fs'); + const lcov_result = fs.readFileSync('/tmp/coverage_summary.txt', 'utf8'); + + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: + '## Code Coverage Summary \n' + + ' ' + + '```' + + lcov_result + + '```' + }); + - name: Generate the html report + run: | + genhtml tr69hostif_coverage.info --output-directory /tmp/coverage_report + cd - + - name: Upload the coverage report to Pull request using actions + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: /tmp/coverage_report diff --git a/run_ut.sh b/run_ut.sh index c6143381c..92abdfec0 100644 --- a/run_ut.sh +++ b/run_ut.sh @@ -18,6 +18,17 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################################ + +ENABLE_COV=false + +if [ "x$1" = "x--enable-cov" ]; then + echo "Enabling coverage options" + export CXXFLAGS="-g -O0 -fprofile-arcs -ftest-coverage" + export CFLAGS="-g -O0 -fprofile-arcs -ftest-coverage" + export LDFLAGS="-lgcov --coverage" + ENABLE_COV=true +fi + apt-get update apt-get -y install libtinyxml2-dev apt-get -y install libsoup-3.0-dev @@ -57,12 +68,6 @@ make ./dm_gtest echo "********************" - -lcov --capture --directory . --output-file coverage.info -lcov --remove coverage.info '/usr/*' --output-file coverage.filtered.info -genhtml coverage.filtered.info --output-directory out - - echo "**** Compiling DeviceInfo gtest ****" cd $TOP_DIR/src/hostif/profiles/DeviceInfo/gtest rm devieInfo_gtest @@ -70,7 +75,12 @@ make ./devieInfo_gtest echo "********************" +cd $TOP_DIR -lcov --capture --directory . --output-file coverage.info -lcov --remove coverage.info '/usr/*' --output-file coverage.filtered.info -genhtml coverage.filtered.info --output-directory out +if [ "$ENABLE_COV" = true ]; then + lcov --capture --directory . --output-file coverage.info + lcov --remove coverage.info '/usr/*' '*/gtest/*' '*/mocks/*' --output-file filtered.info + lcov --extract filtered.info '*/src/hostif*' --output-file tr69hostif_coverage.info + lcov --list tr69hostif_coverage.info +fi + diff --git a/src/unittest/stubs/ds/audioOutputPort.hpp b/src/unittest/stubs/ds/audioOutputPort.hpp index 073740291..2821f7ad7 100644 --- a/src/unittest/stubs/ds/audioOutputPort.hpp +++ b/src/unittest/stubs/ds/audioOutputPort.hpp @@ -173,7 +173,7 @@ class AudioOutputPort : public Enumerable { void setSAD(std::vector sad_list); void enableARC(dsAudioARCTypes_t type, bool enable); void enableMS12Config(const dsMS12FEATURE_t feature,const bool enable){} - dsError_t enableLEConfig(const bool enable); + dsError_t enableLEConfig(const bool enable) { return dsERR_NONE; }; bool GetLEConfig(); void setAudioDelay(const uint32_t audioDelayMs); void setAudioDelayOffset(const uint32_t audioDelayOffsetMs); diff --git a/src/unittest/stubs/ds/host.hpp b/src/unittest/stubs/ds/host.hpp index a18c55f71..95ed08b3f 100644 --- a/src/unittest/stubs/ds/host.hpp +++ b/src/unittest/stubs/ds/host.hpp @@ -83,7 +83,7 @@ class Host { AudioOutputPort &getAudioOutputPort(const std::string &name){}; AudioOutputPort &getAudioOutputPort(int id){}; void notifyPowerChange(const int mode); - float getCPUTemperature(); + float getCPUTemperature() { return 42.5f; }; uint32_t getVersion(void); void setVersion(uint32_t versionNumber); void getHostEDID(std::vector &edid) const; From d3eda5205f0cb00c7ab8bbcccb70a31a7ce29a45 Mon Sep 17 00:00:00 2001 From: shibu-kv Date: Tue, 29 Jul 2025 09:02:34 -0700 Subject: [PATCH 03/11] Changelog updates for release 1.2.2 --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98e67ffa2..76809d9ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.2.2](https://github.com/rdkcentral/tr69hostif/compare/1.2.1...1.2.2) + +- RDKEMW-6193 Code Coverage support for tr69hostif [`#211`](https://github.com/rdkcentral/tr69hostif/pull/211) +- RDKEMW-6328: set AVHijack rfc to false [`#208`](https://github.com/rdkcentral/tr69hostif/pull/208) +- RDK-58323: Canary firmware updates [`#199`](https://github.com/rdkcentral/tr69hostif/pull/199) +- Merge tag '1.2.1' into develop [`17d019b`](https://github.com/rdkcentral/tr69hostif/commit/17d019b0bed5e8cc9c1f4fe68520c08fc530ff00) + #### [1.2.1](https://github.com/rdkcentral/tr69hostif/compare/1.2.0...1.2.1) +> 18 July 2025 + - RDK-58526 : Default IPControl RFC for EU partners [`#203`](https://github.com/rdkcentral/tr69hostif/pull/203) - RDK-57868 : Default IPControl RFC for EU partners [`#200`](https://github.com/rdkcentral/tr69hostif/pull/200) - RDK-57867 : Default the IUI layer separation RFC globally for EntOS [`#193`](https://github.com/rdkcentral/tr69hostif/pull/193) +- 1.2.1 release changelog updates [`fe9e71f`](https://github.com/rdkcentral/tr69hostif/commit/fe9e71f712ffef234215145461d767ae7d1691a4) - Merge tag '1.2.0' into develop [`9b98df0`](https://github.com/rdkcentral/tr69hostif/commit/9b98df0330008138a47b6f18a4314df6f0a7adc1) #### [1.2.0](https://github.com/rdkcentral/tr69hostif/compare/1.1.9...1.2.0) From 5916d051062aa0ba792685d21259342ca4a89a5c Mon Sep 17 00:00:00 2001 From: nmuthu523 Date: Wed, 30 Jul 2025 14:52:25 +0000 Subject: [PATCH 04/11] RDKEMW-4344 : Include the missed RFCs in RDKE. Reason for change: Include DebugMode and TR069support RFC's with default valuse as false. Priority: P1 Test Procedure: Follow the steps provided in description. Risks: Low Signed-off-by:Natraj Muthusamy --- .../parodusClient/waldb/data-model/data-model-generic.xml | 8 ++++++++ .../parodusClient/waldb/data-model/data-model-stb.xml | 8 ++++++++ .../parodusClient/waldb/data-model/data-model-tv.xml | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml index e3c9469fb..e97e68f0e 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-generic.xml @@ -342,6 +342,14 @@ + + + + + + + + diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml b/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml index 6ab3a6bf8..ede3d12ff 100755 --- a/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-stb.xml @@ -461,6 +461,14 @@ + + + + + + + + diff --git a/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml b/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml index 96c2790d9..bffa5bc07 100644 --- a/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml +++ b/src/hostif/parodusClient/waldb/data-model/data-model-tv.xml @@ -367,6 +367,14 @@ + + + + + + + + From 61a1355641b0ca47ae0d24b65f6a66b80210a9d5 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Fri, 1 Aug 2025 14:18:33 +0530 Subject: [PATCH 05/11] Update hostIf_msgHandler.cpp --- src/hostif/handlers/src/hostIf_msgHandler.cpp | 81 ++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index d2d1e3931..803c1de7f 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -137,13 +137,51 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) ret = pMsgHandler->handleGetMsg(stMsgData); auto endTime = std::chrono::high_resolution_clock::now(); auto timeTaken = std::chrono::duration_cast(endTime - startTime).count(); + char paramValueStr[128] = {0}; + switch (stMsgData->paramtype) { + case hostIf_StringType: + snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + break; + case hostIf_IntegerType: { + int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%d", val); + break; + } + case hostIf_UnsignedIntType: { + unsigned int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%u", val); + break; + } + case hostIf_BooleanType: { + bool val = false; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%s", val ? "true" : "false"); + break; + } + case hostIf_DateTimeType: + snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + break; + case hostIf_UnsignedLongType: { + unsigned long val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%lu", val); + break; + } + default: + snprintf(paramValueStr, sizeof(paramValueStr), ""); + break; + } + + // Calculate time taken in microseconds RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] ret: %d, paramName: %s, paramValue: %s, timeTaken: %lld us\n", __FUNCTION__, __LINE__, ret, stMsgData->paramName, - stMsgData->paramValue, + paramValueStr, timeTaken); // Telemetry and debug log if processing time > 5 second (1,000,000 us) if (timeTaken > 5000000) { @@ -224,11 +262,50 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) auto endTime = std::chrono::high_resolution_clock::now(); auto timeTakenset = std::chrono::duration_cast(endTime - startTime).count(); + char paramValueStr[128] = {0}; + switch (stMsgData->paramtype) { + case hostIf_StringType: + snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + break; + case hostIf_IntegerType: { + int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%d", val); + break; + } + case hostIf_UnsignedIntType: { + unsigned int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%u", val); + break; + } + case hostIf_BooleanType: { + bool val = false; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%s", val ? "true" : "false"); + break; + } + case hostIf_DateTimeType: + snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + break; + case hostIf_UnsignedLongType: { + unsigned long val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, sizeof(paramValueStr), "%lu", val); + break; + } + default: + snprintf(paramValueStr, sizeof(paramValueStr), ""); + break; + } + + + RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] ret: %d, paramName: %s, paramValue: %s, timeTaken: %lld us\n", __FUNCTION__, __LINE__, ret, stMsgData->paramName, - stMsgData->paramValue, + paramValueStr, timeTakenset); // Telemetry and debug log if processing time > 5 seconds (5,000,000 us) if (timeTakenset > 5000000) { From 49c85aa9151b4d926bfa60fa66dc54889d265679 Mon Sep 17 00:00:00 2001 From: Aravindan NC <35158113+AravindanNC@users.noreply.github.com> Date: Mon, 4 Aug 2025 12:36:21 -0400 Subject: [PATCH 06/11] RDKEMW-6520: tr69hostif service starts before iarmbusd --- tr69hostif.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tr69hostif.service b/tr69hostif.service index 3a256e0d3..946b03e33 100644 --- a/tr69hostif.service +++ b/tr69hostif.service @@ -18,7 +18,7 @@ ########################################################################## [Unit] Description=TR69 Host Interface Daemon -After=lighttpd.service securemount.service +After=lighttpd.service securemount.service iarmbusd.service [Service] Type=notify From e1aff4bdcf2cb24d0d53f80ed82045ac8192de7e Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Tue, 5 Aug 2025 13:29:18 +0530 Subject: [PATCH 07/11] Update hostIf_msgHandler.cpp --- src/hostif/handlers/src/hostIf_msgHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index 803c1de7f..6b31bcdd1 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -140,7 +140,7 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) char paramValueStr[128] = {0}; switch (stMsgData->paramtype) { case hostIf_StringType: - snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); break; case hostIf_IntegerType: { int val = 0; @@ -161,7 +161,7 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) break; } case hostIf_DateTimeType: - snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); break; case hostIf_UnsignedLongType: { unsigned long val = 0; From 0f467d83d0f7e116874c7694713dfd7332187cb8 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Tue, 5 Aug 2025 14:43:21 +0530 Subject: [PATCH 08/11] Update hostIf_msgHandler.cpp --- src/hostif/handlers/src/hostIf_msgHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index 6b31bcdd1..7319f4e6d 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -265,7 +265,7 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) char paramValueStr[128] = {0}; switch (stMsgData->paramtype) { case hostIf_StringType: - snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); break; case hostIf_IntegerType: { int val = 0; @@ -286,7 +286,7 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) break; } case hostIf_DateTimeType: - snprintf(paramValueStr, sizeof(paramValueStr), "%s", stMsgData->paramValue); + snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); break; case hostIf_UnsignedLongType: { unsigned long val = 0; From b273a3a8f9cb9a3d570fcbc20a09b7ca97c88daf Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Wed, 6 Aug 2025 12:38:45 +0530 Subject: [PATCH 09/11] Update hostIf_msgHandler.cpp --- src/hostif/handlers/src/hostIf_msgHandler.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index 7319f4e6d..e3a5a06f7 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -82,6 +82,8 @@ static std::atomic loggedGet1000Within5Min {false}; static std::atomic loggedSet200Within1Min {false}; static std::atomic loggedSet1000Within5Min {false}; +#define PARAM_VALUE_STR_SIZE 128 + int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) { LOG_ENTRY_EXIT; @@ -137,40 +139,42 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) ret = pMsgHandler->handleGetMsg(stMsgData); auto endTime = std::chrono::high_resolution_clock::now(); auto timeTaken = std::chrono::duration_cast(endTime - startTime).count(); - char paramValueStr[128] = {0}; + char paramValueStr[PARAM_VALUE_STR_SIZE] = {0}; switch (stMsgData->paramtype) { case hostIf_StringType: - snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", stMsgData->paramValue); + //snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); break; case hostIf_IntegerType: { int val = 0; memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%d", val); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%d", val); break; } case hostIf_UnsignedIntType: { unsigned int val = 0; memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%u", val); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%u", val); break; } case hostIf_BooleanType: { bool val = false; memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%s", val ? "true" : "false"); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", val ? "true" : "false"); break; } case hostIf_DateTimeType: - snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); + //snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", stMsgData->paramValue); break; case hostIf_UnsignedLongType: { unsigned long val = 0; memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%lu", val); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%lu", val); break; } default: - snprintf(paramValueStr, sizeof(paramValueStr), ""); + snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, ""); break; } From 6844bc988ecb174f2c01f3ed6ba54105cb0f0ac3 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 7 Aug 2025 16:00:26 +0530 Subject: [PATCH 10/11] Update hostIf_msgHandler.h --- src/hostif/handlers/include/hostIf_msgHandler.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hostif/handlers/include/hostIf_msgHandler.h b/src/hostif/handlers/include/hostIf_msgHandler.h index cc9512838..a385cf586 100644 --- a/src/hostif/handlers/include/hostIf_msgHandler.h +++ b/src/hostif/handlers/include/hostIf_msgHandler.h @@ -98,6 +98,8 @@ void hostIf_Print_msgData(HOSTIF_MsgData_t *stMsgData); void hostIf_Free_stMsgData (HOSTIF_MsgData_t *stMsgData); +void paramValueToString(const HOSTIF_MsgData_t *stMsgData, char *paramValueStr, size_t strSize); + bool hostIf_initalize_ConfigManger(); bool hostIf_ConfigProperties_Init(); class msgHandler { From 05c52c6c5bb363bb3f56eb62e20f766efb795bfb Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 7 Aug 2025 16:32:05 +0530 Subject: [PATCH 11/11] Update hostIf_msgHandler.cpp --- src/hostif/handlers/src/hostIf_msgHandler.cpp | 121 +++++++----------- 1 file changed, 46 insertions(+), 75 deletions(-) diff --git a/src/hostif/handlers/src/hostIf_msgHandler.cpp b/src/hostif/handlers/src/hostIf_msgHandler.cpp index e3a5a06f7..a73572299 100644 --- a/src/hostif/handlers/src/hostIf_msgHandler.cpp +++ b/src/hostif/handlers/src/hostIf_msgHandler.cpp @@ -84,6 +84,50 @@ static std::atomic loggedSet1000Within5Min {false}; #define PARAM_VALUE_STR_SIZE 128 + +void paramValueToString(const HOSTIF_MsgData_t *stMsgData, char *paramValueStr, size_t strSize) +{ + if (!stMsgData || !paramValueStr || strSize == 0) { + if (paramValueStr && strSize > 0) + snprintf(paramValueStr, strSize, ""); + return; + } + + switch (stMsgData->paramtype) { + case hostIf_StringType: + case hostIf_DateTimeType: + snprintf(paramValueStr, strSize, "%s", (const char*)stMsgData->paramValue); + break; + case hostIf_IntegerType: { + int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, strSize, "%d", val); + break; + } + case hostIf_UnsignedIntType: { + unsigned int val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, strSize, "%u", val); + break; + } + case hostIf_BooleanType: { + bool val = false; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, strSize, "%s", val ? "true" : "false"); + break; + } + case hostIf_UnsignedLongType: { + unsigned long val = 0; + memcpy(&val, stMsgData->paramValue, sizeof(val)); + snprintf(paramValueStr, strSize, "%lu", val); + break; + } + default: + snprintf(paramValueStr, strSize, ""); + break; + } +} + int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) { LOG_ENTRY_EXIT; @@ -140,44 +184,7 @@ int hostIf_GetMsgHandler(HOSTIF_MsgData_t *stMsgData) auto endTime = std::chrono::high_resolution_clock::now(); auto timeTaken = std::chrono::duration_cast(endTime - startTime).count(); char paramValueStr[PARAM_VALUE_STR_SIZE] = {0}; - switch (stMsgData->paramtype) { - case hostIf_StringType: - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", stMsgData->paramValue); - //snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); - break; - case hostIf_IntegerType: { - int val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%d", val); - break; - } - case hostIf_UnsignedIntType: { - unsigned int val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%u", val); - break; - } - case hostIf_BooleanType: { - bool val = false; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", val ? "true" : "false"); - break; - } - case hostIf_DateTimeType: - //snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%s", stMsgData->paramValue); - break; - case hostIf_UnsignedLongType: { - unsigned long val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, "%lu", val); - break; - } - default: - snprintf(paramValueStr, PARAM_VALUE_STR_SIZE, ""); - break; - } - + paramValueToString(stMsgData, paramValueStr, sizeof(paramValueStr)); // Calculate time taken in microseconds @@ -267,43 +274,7 @@ int hostIf_SetMsgHandler(HOSTIF_MsgData_t *stMsgData) auto timeTakenset = std::chrono::duration_cast(endTime - startTime).count(); char paramValueStr[128] = {0}; - switch (stMsgData->paramtype) { - case hostIf_StringType: - snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); - break; - case hostIf_IntegerType: { - int val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%d", val); - break; - } - case hostIf_UnsignedIntType: { - unsigned int val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%u", val); - break; - } - case hostIf_BooleanType: { - bool val = false; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%s", val ? "true" : "false"); - break; - } - case hostIf_DateTimeType: - snprintf(paramValueStr, sizeof(paramValueStr), "%.*s", (int)sizeof(paramValueStr) - 1, stMsgData->paramValue); - break; - case hostIf_UnsignedLongType: { - unsigned long val = 0; - memcpy(&val, stMsgData->paramValue, sizeof(val)); - snprintf(paramValueStr, sizeof(paramValueStr), "%lu", val); - break; - } - default: - snprintf(paramValueStr, sizeof(paramValueStr), ""); - break; - } - - + paramValueToString(stMsgData, paramValueStr, sizeof(paramValueStr)); RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s:%d] ret: %d, paramName: %s, paramValue: %s, timeTaken: %lld us\n",