...
PSM_Get_Record_Value2() and PSM_Set_Record_Value2() APIs with automatic retry logic (up to 3 attempts on NULL responses), supporting multiple CCSP data types (ccsp_string, ccsp_int, ccsp_unsignedInt, ccsp_boolean, ccsp_long, ccsp_unsignedLong, ccsp_float, ccsp_double, ccsp_byte)psmcli [subsys <prefix> | nosubsys] <command> <parameters...>get, set, del, getdetail, setdetail, getallinst, getinstcntExample: psmcli get dmsb.l2net.1.Name
Bridge Utilities (bridge_utils): Linux bridge management toolkit implementing network bridge operations via brctl commands (brctl addbr, brctl addif, brctl delif, brctl delbr) and VLAN configuration using vconfig (vconfig add for802.1Q tagging), PSM parameter namespace dmsb.l2net.* for persistent configuration storage, sysevent integration for runtime coordination, platform capability detection through file system checks (/etc/onewifi_enabled for OneWifi, /sys/module/openvswitch for OpenVSwitch, /etc/WFO_enabled for WiFi Offload), supports MoCA isolation with separate bridge instances when MoCA is not disabled via NO_MOCA_FEATURE_SUPPORT flag
bridge_util <operation> <instance_number>multinet-up, multinet-down, multinet-start, multinet-stop, multinet-restart, multinet-syncMembers, add-port, del-port, lnf-setup, lnf-down, meshbhaul-setup, meshonboard-setup, meshethbhaul-up, meshethbhaul-downExample: bridge_util multinet-start 1
Service Control (ServiceCtrl): RBus-based daemon implementing service restart management through data element Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.ServiceCtrl.ServiceRestartList with queue-based request processing using pthread mutexes and condition variables for thread synchronization, automatically daemonizes via fork()/setsid() pattern, spawns dedicated worker thread (spawn_svc_restart_queue_loop()) for sequential service restart execution preventing race conditions, maintains restart queue using custom queue_t data structure with queue_push/queue_pop operations protected by pthread_mutex_lock
Interface: RBus RBUS_ELEMENT_TYPE_PROPERTY with ServiceControl_SetStringHandler
DHCP Client Utilities (dhcp_client_utils): Unified API library abstracting multiple DHCP client implementations (udhcpc, dibbler, ti_dhcp6c, ti_udhcpc) providing process lifecycle management functions collect_waiting_process() using waitpid() with WNOHANG and configurable timeout intervals, signal_process() for sending signals via kill(), fork()/execv() pattern for client spawning, zombie process collection with COLLECT_WAIT_INTERVAL_MS polling, sysevent notification integration for DHCP events
Core APIs: signal_process(), collect_waiting_process(), client-specific wrappers
Event Subscription Utility (EventSubscription): RBus event monitoring tool using rbusEvent_Subscribe() for event registration with custom callback handler eventReceiveHandler(), type-aware value extraction supporting RBUS_STRING, RBUS_BOOLEAN, RBUS_INT8, RBUS_INT16, RBUS_INT32, RBUS_UINT8, RBUS_UINT16, RBUS_UINT32, RBUS_DOUBLE, RBUS_BYTES through rbusValue_GetType() and type-specific getter functions (rbusValue_GetBoolean(), rbusValue_GetInt8(), etc.), continuous event loop processing with user data preservation across callback invocations
event_subscriber <component_name> <event_name>Example: event_subscriber MyComponent Device.WiFi.Status
Firmware Download Check (FwDownloadChk): Firmware download memory validation implementing multi-factor availability check combining firmware image size extraction via HTTP Content-Length header parsing using libcurl, current available memory reading from /proc/meminfo (MemAvailable field), syscfg-based configuration thresholds (FwDwld_AvlMem_RsrvThreshold in MB, FwDwld_ImageProcMemPercent for processing overhead percentage), calculates required_kB = firmware_kB + reserve_threshold_kB + (firmware_kB * image_proc_percent / 100), publishes telemetry event t2_event_d("XCONF_Dwld_Ignored_Not_EnoughMem", 1) when memory insufficient, structured logging to /rdklogs/logs/xconf.txt.0 with timestamps
FwDownloadChkReturns: Exit code 1 (proceed), 0 (block), -1 (error)
WebConfig Decoder (webcfg_decoder): WebConfig multipart document decoder supporting msgpack binary deserialization using msgpack_unpack_next() with MSGPACK_OBJECT_MAP parsing, base64 decoding via trower-base64 library, HTTP fetch using libcurl for cloud configuration retrieval, RBus method invocation Device.X_RDK_WebConfig.FetchCachedBlob for offline cache access via rbusMethod_InvokeAsync(), handles MSGPACK_OBJECT_NIL, MSGPACK_OBJECT_BOOLEAN, MSGPACK_OBJECT_POSITIVE_INTEGER, MSGPACK_OBJECT_STR and nested structures, outputs decoded JSON structures to stdout for debugging
webcfg_decoder -b <filename> (base64 decode)webcfg_decoder -m <filename> (msgpack decode)webcfg_decoder -c <url> <subdoc> <token_file> <interface> (cloud fetch)webcfg_decoder -f <subdocname> (cache fetch via RBus)Example: webcfg_decoder -f portforwarding
Message Queue Utility (msgq_util): POSIX message queue wrapper for gateway state machine IPC using mq_open() on queue /gwmgr_smqueue, mq_send() for posting 24 defined event types (GM_EVENT_STA_MODE_CONNECTED=0, GM_EVENT_AP_MODE_CONNECTED=1, GM_EVENT_WAN_PRIMARY_UP=6, GM_EVENT_WAN_PRIMARY_DOWN=7, etc.), blocking send operations with error handling for queue full conditions
msgq_util <event_number>Example: msgq_util 6 (sends GM_EVENT_WAN_PRIMARY_UP)
Time Conversion Utilities (LTime/TimeConv): Timestamp conversion library using getOffset() function retrieving timezone offset from sysevent parameters (ipv4-timeoffset, ipv6-timeoffset) or platform HAL platform_hal_getTimeOffSet(), applies offset via gmtime_r() for UTC-adjusted local time calculation, strftime() for formatted output with DATE_FMT_H (hour), DATE_FMT_M (minute) formats, supports UTC_ENABLE conditional compilation for UTC time handling
LTime [H|M|O]H (hour format), M (minute format), O (raw offset in seconds), no args (formatted timestamp)Example: LTime O (outputs timezone offset)
Memory Fragmentation Calculator (MemFrag_Calc): Memory fragmentation analysis using Linux buddyinfo data (11-column format) parsing, calculates free page distribution across order-0 through order-10 memory blocks using power-of-2 array (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 pages), computes overallFragmentation = sum(fragmentation_percentages) / 11 and averageFragmentation = sum(fragmentation_percentages_orders_3_to_10) / 8, outputs two integer percentages to stdout for telemetry ingestion
MemFrag_Calc <buddyinfo_data>Example: MemFrag_Calc "100,50,25,12,6,3,1,0,0,0,0" (outputs "overall avg")
Parental Control Device Blocker (parcon): Parental control MAC address block list manager for device access restriction, validates MAC address format, writes validated MAC addresses to /tmp/.pcmd with file locking via flock(fileno(fp), LOCK_EX) preventing concurrent access race conditions, triggers firewall restart through sysevent set firewall-restart to apply blocking rules, logs all operations to /rdklogs/logs/Parcon.txt with timestamps, clears block list when invoked without arguments allowing all devices
parcon <mac_address1> <mac_address2> .../tmp/.pcmd for firewall consumptionExample: parcon AA:BB:CC:DD:EE:FF 11:22:33:44:55:66 (blocks two devices)
LED Control (SetLED): Hardware LED state management interfacing with platform HAL platform_hal_setLed() function accepting LEDMGMT_PARAMS structure with LED color (0-4 supported values), state (0=solid/1=blink), and blink interval in seconds, validates input parameters with bounds checking (color range 0-4, state values 0-1, non-negative interval), returns error codes on validation failure or HAL operation errors
SetLED <color> <state> <interval>Example: SetLED 1 1 2 (color 1, blinking, 2-second interval)
Firmware Bank Info (FwBankInfo): Bootloader firmware bank information query using platform_hal_GetFirmwareBankInfo() for both ACTIVE_BANK and INACTIVE_BANK, extracts firmware name and state into FW_BANK_INFO structure, publishes to telemetry system via t2_event_s("FW_ACTIVEBANK_split", buffer) and t2_event_s("FW_INACTIVEBANK_split", buffer) with comma-separated name,state format, logs to /rdklogs/logs/SelfHeal.txt.0, publishes error events t2_event_d("SYS_ERROR_FW_ACTIVEBANK_FETCHFAILED", 1) on HAL failures
FwBankInfoQueries both banks and publishes telemetry events automatically
Multipart Root (multipartRoot): Multipart firmware/configuration document creator using msgpack binary serialization via msgpack_packer for encoding subdocument metadata (name, version, binary data), accepts root version and variable subdocument arguments, generates multipart binary buffer using generateMultipartBuffer(), writes output to /nvram/multipart.bin, supports subdocument argument parsing and JSON-to-msgpack conversion for structured configuration documents
multipartRoot <root_version> <subdoc_args...>Example: multipartRoot 1.0 subdoc1.bin subdoc2.bin
Notify Lease (Notify_Lease): DHCP lease file monitoring daemon using inotify API (inotify_init(), inotify_add_watch()) for /nvram/dnsmasq.leases with IN_MODIFY event mask, daemonizes via fork()/exit() pattern, spawns monitoring thread using pthread_create() running MonitorDHCPLeaseFile() function, triggers lease synchronization script /etc/utopia/service.d/service_lan/dhcp_lease_sync.sh on every file modification event, continuous event loop with read(inotifyFd, buf, BUF_LEN) blocking on inotify file descriptor, waits for lease file existence with 5-second polling if not present at startup
Notify_Lease (daemon)The miscellaneous-broadband component follows a modular, loosely-coupled architecture where each utility operates as an independent executable or library with well-defined responsibilities. The design philosophy emphasizes minimal dependencies between utilities, allowing selective compilation and deployment based on platform requirements specified through configure-time flags. Each utility interface design promotes reusability and integration, providing command-line interfaces for administrative operations, library APIs for programmatic access, or daemon processes for runtime services. The architecture enables platform vendors to customize the utility suite by enabling only required modules through autoconf-based build configuration.
...
| Markdown |
|---|
```mermaid
graph TB
%% External Actors
Admin[<b>Administrator/Scripts</b><br/>CLI Invocation]
%% Utility Categories
subgraph Utilities[" "]
direction TB
subgraph Core["<b>Core Utilities</b>"]
Psmcli["psmcli<br/><i>PSM CLI</i>"]
ServiceCtrl["ServiceCtrl<br/><i>Service Restart Daemon</i>"]
EventSub["event_subscriber<br/><i>Event Monitor</i>"]
end
subgraph Network["<b>Network & Security</b>"]
BridgeUtils["bridge_utils<br/><i>Bridge Manager</i>"]
DHCPUtils["dhcp_client_utils<br/><i>DHCP Client Library</i>"]
Parcon["parcon<br/><i>Device Blocker</i>"]
NotifyLease["Notify_Lease<br/><i>Lease Monitor</i>"]
end
subgraph Config["<b>Configuration</b>"]
WebCfgDecoder["webcfg_decoder<br/><i>WebConfig Parser</i>"]
MsgQ["msgq_util<br/><i>State Machine IPC</i>"]
end
subgraph Firmware["<b>Firmware Management</b>"]
FwDownloadChk["FwDownloadChk<br/><i>Memory Validator</i>"]
FwBankInfo["FwBankInfo<br/><i>Bank Query</i>"]
MultipartRoot["multipartRoot<br/><i>Multipart Creator</i>"]
end
subgraph Diagnostic["<b>Diagnostics</b>"]
LTime["LTime<br/><i>Time utility</i>"]
MemFragCalc["MemFrag_Calc<br/><i>Fragmentation</i>"]
SetLED["SetLED<br/><i>LED Control</i>"]
end
end
%% System Interfaces
subgraph SystemAPIs[" "]
direction LR
RBus["<b>RBus</b><br/>Message Bus"]
PSM["<b>PSM</b><br/>Persistent Storage"]
Sysevent["<b>Sysevent</b><br/>Event System"]
Syscfg["<b>Syscfg</b><br/>Config Store"]
Kernel["<b>Linux Kernel</b><br/>Network/FS/Proc"]
HAL["<b>Platform HAL</b><br/>Hardware Abstraction"]
end
%% Connections
Admin -.->|invoke| Core
Admin -.->|invoke| Network
Admin -.->|invoke| Config
Admin -.->|invoke| Firmware
Admin -.->|invoke| Diagnostic
ServiceCtrl --> RBus
EventSub --> RBus
WebCfgDecoder --> RBus
Psmcli --> PSM
BridgeUtils --> PSM
BridgeUtils --> Sysevent
DHCPUtils --> Sysevent
Parcon --> Sysevent
FwDownloadChk --> Syscfg
SetLED --> HAL
FwBankInfo --> HAL
BridgeUtils --> Kernel
DHCPUtils --> Kernel
Parcon --> Kernel
NotifyLease --> Kernel
MemFragCalc --> Kernel
WebCfgDecoder --> Kernel
MsgQ --> Kernel
%% Styling
classDef coreStyle fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef netStyle fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef configStyle fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef fwStyle fill:#fff3e0,stroke:#f57c00,stroke-width:2px
classDef diagStyle fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef apiStyle fill:#fff9c4,stroke:#f57f17,stroke-width:2px
classDef adminStyle fill:#ffebee,stroke:#d32f2f,stroke-width:2px
class Psmcli,ServiceCtrl,EventSub coreStyle
class BridgeUtils,DHCPUtils,Parcon,NotifyLease netStyle
class WebCfgDecoder,MsgQ configStyle
class FwDownloadChk,FwBankInfo,MultipartRoot fwStyle
class LTime,MemFragCalc,SetLED diagStyle
class RBus,PSM,Sysevent,Syscfg,Kernel,HAL apiStyle
class Admin adminStyle
``` |
Build-Time Flags and Configuration:
...
ServiceControl_Rbus_Init(), component lifecycle coordination, infinite sleep loop maintaining daemon processrbus_open(), event subscription setup with rbusEvent_Subscribe(), infinite event processing loop, signal handler for graceful SIGINT shutdown with rbusEvent_Unsubscribe()svc_restart_queue_loop()): Dedicated detached thread created via spawn_svc_restart_queue_loop() with PTHREAD_CREATE_DETACHED attribute, processes service restart queue using pthread_cond_wait() on svcCond condition variable, executes systemctl restart commands sequentially via v_secure_system() for queued services, waits on condition variable when queue empty (svc_queue_wakeup flag false), terminates when exit_svc_queue_loop flag setMonitorDHCPLeaseFile()): Spawned via pthread_create() with default joinable attributes, initializes inotify file descriptor with inotify_init(), adds watch on /nvram/dnsmasq.leases with IN_MODIFY event mask using inotify_add_watch(), infinite blocking read loop on inotify file descriptor, triggers /etc/utopia/service.d/service_lan/dhcp_lease_sync.sh script on every IN_MODIFY event, handles file existence polling with 5-second sleep intervals when lease file not presenteventReceiveHandler() invoked asynchronously by RBus library on subscribed event arrival, type-aware event value extraction supporting multiple RBus data types (RBUS_STRING, RBUS_BOOLEAN, RBUS_INT8, RBUS_UINT8, RBUS_INT16, RBUS_UINT16, RBUS_INT32, RBUS_UINT32, RBUS_DOUBLE, RBUS_BYTES), user data preserved across callback invocations via subscription->userData, graceful unsubscribe on SIGINT via handle_sigint() signal handlersvcMutex (pthread_mutex_t) protects service restart queue operations including queue_push/queue_pop and queue_count access, gVarMutex (pthread_mutex_t) protects global variable access including exit_svc_queue_loop and svc_queue_wakeup flagssvcCond (pthread_cond_t) used for thread coordination with pthread_cond_wait() in worker thread and pthread_cond_signal() in queue push operations, implements producer-consumer pattern for service restart queueflock(fileno(fp), LOCK_EX) for exclusive lock on /tmp/.pcmd file preventing concurrent firewall rule modifications, automatic unlock via flock(fileno(fp), LOCK_UN) before file closesvc_queue_wakeup) and exit flag (exit_svc_queue_loop) used for lock-free thread signaling patternsInitialization to Active State
...
Initialization Call Flow:
...
| Markdown |
|---|
```mermaid
sequenceDiagram
participant Client as Client/Caller
participant Comp as CcspMisc Utility
participant MsgBus as Message Bus
participant PSM as PSM/Syscfg
participant HAL as HAL/Kernel
Client->>Comp: Request (CLI/RBus/Event)
Comp->>Comp: Validate Request Parameters
alt PSM Operation (Psmcli)
Comp->>MsgBus: PSM Get/Set Request
MsgBus->>PSM: Forward Request
PSM-->>MsgBus: PSM Response
MsgBus-->>Comp: Response Data
else Service Restart (ServiceCtrl)
Comp->>Comp: Queue Restart Request
Comp->>Comp: Worker Thread Processes Queue
Comp->>HAL: Execute Service Restart
HAL-->>Comp: Operation Status
Comp->>MsgBus: Publish Status Event
else Bridge Configuration (bridge_utils)
Comp->>PSM: Read Bridge Config
PSM-->>Comp: Configuration Data
Comp->>HAL: Apply Network Configuration
HAL-->>Comp: Configuration Status
else Event Monitoring (EventSubscription)
MsgBus->>Comp: Event Notification
Comp->>Comp: Display Event Data
end
Comp-->>Client: Response/Event
``` |
The miscellaneous-broadband component consists of multiple independent utilities, each serving specific operational needs within the RDK-B ecosystem.
| Module/Class | Description | Key Files |
|---|---|---|
| Psmcli | Command-line interface for PSM operations supporting get, set, getdetail, and delete operations with type-specific parameter handling. Provides direct access to persistent storage for administration and debugging. | psmcli.c, ccsp_psmcli.h |
| ServiceCtrl | RBus-based daemon providing service restart management through standardized interface. Implements queue-based restart processing with mutex-protected concurrent access and RBus method handlers. | servicecontrol_main.c, servicecontrol_apis.c, servicecontrol_rbus_handler_apis.c, servicecontrol_dml.c |
| bridge_utils | Network bridge management utility supporting creation, configuration, and deletion of Linux bridges with VLAN tagging, member interface management, and MoCA isolation support. Integrates with PSM for configuration storage and sysevent for runtime coordination. | bridge_util.c, bridge_util_generic.c, bridge_creation.c, main.c |
| dhcp_client_utils | Common library abstracting multiple DHCP client implementations (udhcpc, dibbler, ti_dhcp6c) providing unified API for client lifecycle management, process control, and event notification. | dhcp_client_common.c, udhcpc_client_utils.c, dhcpv4_client_utils.c, dhcpv6_client_utils.c, dibbler_client_utils.c, ti_dhcp6c_client_utils.c, ti_udhcpc_client_utils.c |
| EventSubscription | RBus event subscription utility for CLI-based event monitoring. Subscribes to specified RBus events and displays received event data with type-aware value extraction supporting string, boolean, and numeric types. | event_subscriber.c |
| FwDownloadChk | Firmware download memory validation utility checking available system memory against firmware size plus configurable thresholds. Prevents firmware download attempts when insufficient memory exists, reducing failed upgrade attempts. | fw_download_check.c, fw_download_check.h |
| webcfg_decoder | WebConfig blob fetch and decode utility supporting both HTTP download and RBus-based cache retrieval. Decodes msgpack-encoded multipart documents with base64 decoding and structured output for debugging WebConfig operations. | main.c |
| msgq_util | POSIX message queue wrapper providing gateway state machine messaging capabilities. Implements message send/receive operations for inter-process event communication with defined event enumeration. | msgq_util.c |
| LTime | Local time retrieval utility providing current timestamp output in seconds since epoch. Supports optional UTC time handling when UTC_ENABLE flag is set. | LTime.c |
| TimeConv | Time format conversion library providing conversion between different time representations. Supports UTC time conversion when UTC_ENABLE build flag is enabled. | time_conversion.c, time_conversion.h |
| MemFrag_Calc | Memory fragmentation analysis utility calculating fragmentation metrics from /proc meminfo. Used for system diagnostics and telemetry reporting. | MemFragCalc.c |
| FwBankInfo | Firmware bank information query utility extracting bootloader firmware bank details. Provides active/inactive bank identification for dual-bank firmware management. | FwBank_Info.c |
| parcon | Parental control device blocking utility managing MAC address block lists for firewall-based device access restriction. Validates MAC addresses, writes block list to /tmp/.pcmd, and triggers firewall restart via sysevent. | parcon.c |
| multipartRoot | Multipart firmware image handling utility for processing split firmware images during upgrade operations. | multipartRoot.c |
| SetLED | LED control utility providing command-line interface for hardware LED state management. Interfaces with platform HAL for LED hardware control. | SetLED.c |
| Notify_Lease | DHCP lease notification monitoring utility tracking DHCP lease acquisition and renewal events. Conditionally compiled when notifylease feature is enabled. | Notify_Lease.c |
The miscellaneous-broadband utilities interact with various RDK-B components, system services, and external systems to provide their respective functionalities.
| Target Component/Layer | Interaction Purpose | Key APIs/Endpoints |
|---|---|---|
| RDK-B Middleware Components | ||
| RBus Message Bus | Event subscription, method invocation, parameter get/set operations | CCSP_Message_Bus_Init(), rbus_open(), rbusEvent_Subscribe(), rbusMethod_InvokeAsync() |
| CcspPsm | Persistent parameter storage and retrieval for configuration data | PSM_Get_Record_Value2(), PSM_Set_Record_Value2(), PSM_Del_Record() |
| CcspPandM | Bridge configuration coordination, service state synchronization | RBus events: Device.X_CISCO_COM_DeviceControl.*, PSM parameters: dmsb.l2net.* |
| CcspWiFi | WiFi interface bridge membership configuration | PSM parameters: dmsb.l2net.*.Members.WiFi, Sysevent: WiFi interface notifications |
| System Services | ||
| Sysevent | System-wide event notification for network configuration changes | sysevent_open(), sysevent_get(), sysevent_set(), sysevent_set_options() events: bridge-status, multinet-*, wan-status |
| Syscfg | Secure configuration storage for firmware and system parameters | syscfg_init(), syscfg_get(), syscfg_set(), syscfg_commit() keys: xconf_url, FwDwld_AvlMem_RsrvThreshold |
| Hardware Abstraction Layer | ||
| Platform HAL | LED hardware control operations | Platform-specific LED HAL APIs for state control |
| Linux Kernel | ||
| Network Stack | Bridge creation, VLAN configuration, interface management | socket(), ioctl(SIOCBRADDBR), ioctl(BRCADDIF), netlink sockets for interface operations |
| Process Management | DHCP client process lifecycle control | fork(), execv(), waitpid(), kill(), signal handling |
| File System | Memory information, system status, log file access | /proc/meminfo, /proc/net/*, /sys/class/net/*, /rdklogs/logs/* |
| POSIX Message Queues | Inter-process messaging for gateway state machine | mq_open(), mq_send(), mq_receive(), mq_close(), queue: /gwsm_queue |
| External Systems | ||
| XCONF Server | Firmware image download URL and metadata retrieval | HTTP GET with curl library, Content-Length header parsing |
| WebConfig Server | Configuration document fetch and processing | HTTP GET/POST with curl, msgpack deserialization, base64 decoding |
| Telemetry System | Diagnostic event reporting | t2_event_s() for telemetry marker publication |
| Configuration Sources | ||
| PSM Database | Bridge configurations, network parameters, persistent state | Namespace: dmsb.l2net.*, dmsb.MultiLAN.* for bridge and network settings |
| Command Line | Direct utility invocation by administrators and scripts | Standard argc/argv parsing, getopt for option processing |
...
| Event Name | Event Topic/Path | Trigger Condition | Subscriber Components |
|---|---|---|---|
| Service_Restart_Complete | ServiceCtrl RBus method response | Service restart operation completes successfully or with error | Requesting component (CcspPandM, WebPA) |
| Bridge_Status_Change | bridge-status sysevent | Bridge creation or deletion completes | Network management components, WiFi, routing services |
| DHCP_Lease_Event | Sysevent notifications | DHCP lease acquisition or renewal detected | Network monitoring, device tracking components |
| Network_Device_Status | RBus event publication | Device presence or network status change detected | Telemetry services, monitoring components |
Primary IPC Flow - Service Restart Request:
...
| Markdown |
|---|
```mermaid
sequenceDiagram
participant User as User/Script
participant Psmcli as psmcli
participant MsgBus as Message Bus
participant PSM as PSM Service
User->>Psmcli: CLI Command (get/set)
Psmcli->>Psmcli: Parse Arguments
Psmcli->>MsgBus: Connect to RBus
MsgBus-->>Psmcli: Connection Established
Psmcli->>MsgBus: PSM Request (Get/Set)
MsgBus->>PSM: Forward Request
PSM->>PSM: Access Database
PSM-->>MsgBus: Response Data
MsgBus-->>Psmcli: Response Data
Psmcli->>Psmcli: Format Output
Psmcli-->>User: Display Result (stdout)
Psmcli->>MsgBus: Disconnect
``` |
Queue-Based Service Management (ServiceCtrl): Producer-consumer pattern with dedicated worker thread processing service restart requests sequentially, ensuring serialized systemctl operations to prevent race conditions and maintain system stability during bulk restart operations.
Main implementation in servicecontrol_main.c - process daemonization via fork()/setsid() pattern, signal handler installation (SIGTERM, SIGINT, SIGUSR1, SIGUSR2, SIGSEGV), RBus connection via ServiceControl_Rbus_Init(), infinite sleep loop maintaining daemon lifetime
servicecontrol_apis.c - svc_restart_queue_loop() function spawned with PTHREAD_CREATE_DETACHED attribute, processes queue using pthread_cond_wait() blocking until requests arrive, executes v_secure_system("systemctl restart %s") for each queued service name, uses mutex-protected queue operations (queue_push/queue_pop) preventing concurrent modificationRBus handler in servicecontrol_rbus_handler_apis.c - ServiceControl_SetStringHandler() receives restart requests via RBus method call Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.ServiceCtrl.ServiceRestartList, validates service names, enqueues requests with pthread_cond_signal() to wake worker thread
Event Processing: Multiple event handling patterns implemented across utilities, each optimized for specific operational requirements including RBus event callbacks, inotify file system monitoring, and queue-based asynchronous processing.
RBus Event Callback Processing (EventSubscription): Implemented in event_subscriber.c using eventReceiveHandler() callback function invoked asynchronously by RBus dispatcher thread when subscribed events arrive, extracts event data via rbusObject_GetValue() with NULL key to get root value, performs type-aware value extraction using rbusValue_GetType() to determine data type (RBUS_STRING, RBUS_BOOLEAN, RBUS_INT8/16/32, RBUS_UINT8/16/32, RBUS_DOUBLE, RBUS_BYTES), calls type-specific getter functions (rbusValue_GetBoolean(), rbusValue_GetInt8(), rbusValue_ToString(), etc.) to extract actual values, displays formatted event data to stdout for monitoring/debugging, preserves user data across callback invocations via subscription->userData pointer, implements SIGINT handler handle_sigint() for graceful unsubscribe via rbusEvent_Unsubscribe() before exit
Notify_Lease.c using Linux inotify API with MonitorDHCPLeaseFile() thread function, initializes inotify instance via inotify_init(), registers file watch on /nvram/dnsmasq.leases using inotify_add_watch() with IN_MODIFY event mask, enters infinite blocking loop with read(inotifyFd, buf, BUF_LEN) waiting for file modification events, triggers lease synchronization script /etc/utopia/service.d/service_lan/dhcp_lease_sync.sh via v_secure_system() on every file modification, handles missing file scenario with 5-second polling loop using sleep(5) and access() checking file existence before adding watchQueue-Based Asynchronous Processing (ServiceCtrl): Worker thread blocks on pthread_cond_wait(&svcCond, &svcMutex) waiting for queue wakeup signal, processes queue in while loop checking queue_count(svc_queue), pops service name from queue with queue_pop(svc_queue), executes restart operation, signals completion, returns to wait state when queue empty (svc_queue_wakeup flag set to false)
Error Handling Strategy: Comprehensive error detection and recovery mechanisms across all utilities ensuring robustness with defensive programming practices, explicit error code checking, resource cleanup, and telemetry integration for operational visibility.
Return Code Validation: Every system call and API function checked for error returns with explicit validation - PSM operations retry up to 3 times on NULL response in psmcli, curl operations check CURLE_OK status in FwDownloadChk, file operations check for NULL file pointer in parcon with error logging via v_secure_system("echo Error: ... >> /rdklogs/logs/Parcon.txt"), HAL API calls verify non-error status codes with fallback telemetry event publication on failure
rbus_close() on connection failures, memory free for dynamically allocated queue data preventing memory leaks, flock unlock via flock(fileno(fp), LOCK_UN) before file close in parconTelemetry Integration: Operational error reporting via T2 telemetry system - FwDownloadChk publishes t2_event_d("XCONF_Dwld_Ignored_Not_EnoughMem", 1) when memory insufficient, FwBankInfo publishes t2_event_d("SYS_ERROR_FW_ACTIVEBANK_FETCHFAILED", 1) on HAL failures, provides visibility into field operational issues for remote diagnostics and proactive issue detection
Logging & Debugging: Multi-tier logging strategy with component-specific log files, structured log formatting, runtime debug control, and integration with RDK Logger framework when available for centralized log management.
Component-Specific Log Files: Dedicated log files under /rdklogs/logs/ - parcon writes to /rdklogs/logs/Parcon.txt with v_secure_system("echo message >> /rdklogs/logs/Parcon.txt") pattern including entry/exit timestamps via date command, FwDownloadChk uses custom xconf_log_write() function writing to /rdklogs/logs/xconf.txt.0 with timestamped INFO/ERROR levels formatted as "YYYY-MM-DD HH:MM:SS [LEVEL] message" using strftime() and localtime_r(), FwBankInfo outputs to /rdklogs/logs/SelfHeal.txt.0
ServiceControl_Log_Init() initializes logger with debug configuration from /etc/debug.ini or override path, uses severity macros SvcCtrlDebug(), SvcCtrlInfo(), SvcCtrlWarning(), SvcCtrlError() for categorized logging with function name tracking via __FUNCTION__ macro/nvram/psmcli_debug_level file containing log level name (NONE, EMERG, ALERT, CRIT, ERROR, WARN, NOTICE, INFO, DEBUG, TRACE), parsed at startup via psmcli_get_debug_level() function, conditional compilation with _DEBUG preprocessor flag enabling additional verbose output, trace macros CcspTraceDebug(), CcspTraceWarning() for development buildsThe miscellaneous-broadband component relies on multiple configuration sources including PSM parameters, syscfg keys, and file-based configurations.
...