Skip to content

feat: Add ismodulerestarted parameter to DeviceFingerPrint section#78

Closed
jayasrikadiyal wants to merge 1 commit into
developfrom
66-add-ismodulerestarted-parameter
Closed

feat: Add ismodulerestarted parameter to DeviceFingerPrint section#78
jayasrikadiyal wants to merge 1 commit into
developfrom
66-add-ismodulerestarted-parameter

Conversation

@jayasrikadiyal
Copy link
Copy Markdown

Resolves #66.

Summary

Adds a new read-only boolean TR-181 parameter ismodulerestarted under Device.DeviceInfo.X_RDKCENTRAL-COM_DeviceFingerPrint that indicates whether the cujo-agent has been restarted since system boot.

Implementation

  • CosaAdvSecIsAgentRestarted() in cosa_adv_security_internal.c: Reads the cujo-agent PID from /tmp/cujo-agent.pid, then reads /proc/<pid>/stat to get the process start time (field 22, in clock ticks). Compares this with system uptime via sysinfo(). If the agent started after boot (start time > 0 seconds), it is considered restarted.
  • DML handler: Added ismodulerestarted case in DeviceFingerPrint_GetParamBoolValue using the standard strcmp_s pattern.
  • TR-181 XML: Added the parameter as a read-only boolean in TR181-AdvSecurity.xml.
  • Unit tests: Added test cases for the new parameter in CcspAdvSecurityDmlTest.cpp.

Files Changed

File Change
source/AdvSecurityDml/cosa_adv_security_internal.c Added CosaAdvSecIsAgentRestarted() function
source/AdvSecurityDml/cosa_adv_security_internal.h Added function declaration
source/AdvSecurityDml/cosa_adv_security_dml.c Added ismodulerestarted handling in GetParamBoolValue
config/TR181-AdvSecurity.xml Added parameter definition
source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityDmlTest.cpp Added unit tests

Testing

  • Parameter accessible via: dmcli eRT getv Device.DeviceInfo.X_RDKCENTRAL-COM_DeviceFingerPrint.ismodulerestarted
  • Returns true if cujo-agent runtime < system uptime (agent restarted since boot)
  • Returns false if agent has been running since boot or is not running

Add a new read-only boolean TR-181 parameter 'ismodulerestarted' under
Device.DeviceInfo.X_RDKCENTRAL-COM_DeviceFingerPrint that indicates whether
the cujo-agent has been restarted since system boot.

The parameter compares the cujo-agent process start time (from /proc/<pid>/stat)
against the system uptime. If the agent started after boot (start time > 0
seconds after boot), it is considered restarted.

Changes:
- Add CosaAdvSecIsAgentRestarted() in cosa_adv_security_internal.c
- Add declaration in cosa_adv_security_internal.h
- Add ismodulerestarted case in DeviceFingerPrint_GetParamBoolValue
- Add parameter definition in TR181-AdvSecurity.xml (read-only boolean)
- Add unit tests for the new parameter

Resolves #66
@jayasrikadiyal jayasrikadiyal requested review from a team as code owners May 22, 2026 23:36
Copilot AI review requested due to automatic review settings May 22, 2026 23:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new read-only TR-181 boolean parameter Device.DeviceInfo.X_RDKCENTRAL-COM_DeviceFingerPrint.ismodulerestarted intended to indicate whether cujo-agent has restarted since system boot.

Changes:

  • Introduces CosaAdvSecIsAgentRestarted() to infer restart status from /tmp/cujo-agent.pid and /proc/<pid>/stat.
  • Wires ismodulerestarted into DeviceFingerPrint_GetParamBoolValue.
  • Updates TR-181 XML and adds a unit test for the new parameter.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
source/AdvSecurityDml/cosa_adv_security_internal.c Adds restart-detection helper based on PID + /proc start time and uptime.
source/AdvSecurityDml/cosa_adv_security_internal.h Declares the new helper function.
source/AdvSecurityDml/cosa_adv_security_dml.c Exposes ismodulerestarted via the DeviceFingerPrint boolean getter.
config/TR181-AdvSecurity.xml Adds the new read-only TR-181 parameter definition.
source/test/CcspAdvSecurityDmlTest/CcspAdvSecurityDmlTest.cpp Adds a unit test covering the new parameter dispatch path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3618 to +3625
agent_start_sec = (long)(starttime / (unsigned long long)clk_tck);

/* If agent started after boot (agent_start_sec > 0), it has been restarted */
if (agent_start_sec > 0)
{
CcspTraceInfo(("%s: Agent restarted. Agent start=%ld sec after boot, system uptime=%ld sec\n",
__FUNCTION__, agent_start_sec, uptime_sec));
return TRUE;
Comment on lines +3553 to +3562
/* Remove trailing newline */
pid_str[strcspn(pid_str, "\n")] = '\0';
if (pid_str[0] == '\0')
{
return FALSE;
}

/* Read /proc/<pid>/stat to get process start time */
snprintf(proc_path, sizeof(proc_path), "/proc/%s/stat", pid_str);
fp = fopen(proc_path, "r");
Comment on lines +3560 to +3566
/* Read /proc/<pid>/stat to get process start time */
snprintf(proc_path, sizeof(proc_path), "/proc/%s/stat", pid_str);
fp = fopen(proc_path, "r");
if (fp == NULL)
{
CcspTraceInfo(("%s: Cannot open %s, agent process not found\n", __FUNCTION__, proc_path));
return FALSE;
Comment on lines +164 to +167
BOOL result = DeviceFingerPrint_GetParamBoolValue(NULL, (char*)ParamName, &resultBool);

EXPECT_TRUE(result);

@jayasrikadiyal jayasrikadiyal deleted the 66-add-ismodulerestarted-parameter branch May 26, 2026 03:39
@github-actions github-actions Bot locked and limited conversation to collaborators May 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement one new DMCLI Parameter In Fingerprint Section. Parameter Name : ismodulerestarted

2 participants