...
The SNMP Protocol Agent follows a modular architecture designed around the net-snmp library's AgentX subagent model with clear separation between protocol handling, MIB translation, and data model access. The design emphasizes extensibility through XML-driven MIB mappings and handler-based subsystem implementations. The architecture operates in three primary layers: the SNMP protocol layer handling AgentX communication with the master daemon, the translation layer processing MIB-to-DataModel conversions through XML configurations, and the integration layer managing CCSP message bus interactions for parameter access.
...
| Markdown |
|---|
```mermaid
graph TD
subgraph ExternalInterface ["External Interface"]
AgentXProtocol[AgentX Protocol]
MasterSNMPD[Master SNMP Daemon<br/>snmpd]
end
subgraph SNMPAgent ["SNMP Protocol Agent (C/net-snmp)"]
subgraph MainProcess ["Main Process"]
SubAgent[SNMP Subagent Process<br/>source/SnmpPlugin/ccsp_snmp_subagent.c]
Init[Initialization<br/>init_ccsp_snmp_plugin]
MIBLoader[MIB XML Loader<br/>source/SnmpPlugin/CcspSnmpPlugin.c]
end
subgraph PluginCore ["SNMP Plugin Core"]
MIBHelper[MIB Helper<br/>source/SnmpPlugin/ccsp_mib_helper.c]
ScalarHelper[Scalar Handler<br/>source/SnmpPlugin/ccsp_scalar_helper.c]
TableHelper[Table Handler<br/>source/SnmpPlugin/ccsp_table_helper.c]
MIBUtil[MIB Utilities<br/>source/SnmpPlugin/ccsp_mib_utilities.c]
end
subgraph CustomHandlers ["Custom MIB Handlers"]
Handlers[Subsystem Handlers<br/>WiFi, DeviceMgmt, Firewall,<br/>MoCA, Hotspot, Diagnostics,<br/>DNS, NTP, IP Management<br/>source/custom/*.c]
end
subgraph Integration ["CCSP Integration"]
CosaAPI[COSA API<br/>source/SnmpPlugin/cosa_api.c]
SNMPCommon[SNMP Common<br/>source/custom/ccsp_snmp_common.c]
end
subgraph Configuration ["Configuration"]
MIBMappings[(MIB XML Mappings<br/>Mib2DmMapping/*.xml)]
SNMPConf[SNMP Config<br/>config/snmpd.conf]
end
SubAgent --> Init
Init --> MIBLoader
MIBLoader --> MIBHelper
MIBHelper --> ScalarHelper
MIBHelper --> TableHelper
MIBHelper --> MIBUtil
ScalarHelper --> CustomHandlers
TableHelper --> CustomHandlers
CustomHandlers --> CosaAPI
CustomHandlers --> SNMPCommon
CosaAPI --> MessageBus
SNMPCommon --> MessageBus
MIBLoader --> MIBMappings
SubAgent --> SNMPConf
end
MessageBus[(CCSP Message Bus<br/>RBus)]
AgentXProtocol --> MasterSNMPD
MasterSNMPD --> SubAgent
``` |
Build-Time Flags and Configuration:
...
Initialization to Active State
...
Initialization Call Flow:
...
| Markdown |
|---|
```mermaid
sequenceDiagram
participant NMS as Network Mgmt System
participant MasterSNMP as Master SNMP Daemon
participant SubAgent as SNMP Subagent
participant Handler as MIB Handler
participant CCSP as CCSP Message Bus
participant Component as RDK-B Component
NMS->>MasterSNMP: SNMP SET Request (OID, Value)
MasterSNMP->>SubAgent: AgentX SET Request
SubAgent->>Handler: Handler SET Callback (Reserve Phase)
Handler->>Handler: Validate Value Format
Handler-->>SubAgent: Validation Result
SubAgent->>Handler: Handler SET Callback (Commit Phase)
Handler->>CCSP: Cosa_FindDestComp(parameter)
CCSP-->>Handler: Component Name, RBus Path
Handler->>Handler: Convert SNMP Value to DataModel Type
Handler->>CCSP: Cosa_SetParamValues(component, path, param, value)
CCSP->>CCSP: CcspBaseIf_setParameterValues()
CCSP->>Component: RBus Method Call (setParameterValues)
Component-->>CCSP: Set Result
CCSP->>Component: CcspBaseIf_setCommit() if auto-commit enabled
Component-->>CCSP: Commit Result
CCSP-->>Handler: Operation Status
Handler-->>SubAgent: SET Success/Failure
SubAgent->>MasterSNMP: AgentX Response
MasterSNMP->>NMS: SNMP Response (Success/Error)
``` |
The SNMP Protocol Agent is organized into specialized modules separating core SNMP protocol handling, MIB translation logic, custom subsystem handlers, and CCSP integration. Each module encapsulates specific functionality with defined interfaces for inter-module communication and extension.
| Module/Class | Description | Key Files |
|---|---|---|
| SNMP Subagent Process | Main executable implementing AgentX subagent protocol with master daemon communication, event loop management, privilege dropping, and process lifecycle control | ccsp_snmp_subagent.c |
| SNMP Plugin Core | Central plugin manager responsible for MIB XML loading, MIB helper object creation, handler registration coordination, and plugin lifecycle management | CcspSnmpPlugin.c |
| MIB Helper Framework | Core MIB processing framework providing OID registration, handler dispatch, caching infrastructure, and base implementation for scalar and table MIB objects | ccsp_mib_helper.c, ccsp_mib_helper.h |
| Scalar Helper | Implements scalar MIB object handling including GET/SET operations, value validation, type conversion, and parameter access control for single-instance OIDs | ccsp_scalar_helper.c, ccsp_scalar_helper_access.c, ccsp_scalar_helper_control.c, ccsp_scalar_helper.h, ccsp_scalar_helper_internal.h |
| Table Helper | Implements tabular MIB object handling including row enumeration, index management, table caching, and multi-instance object operations for SNMP tables | ccsp_table_helper.c, ccsp_table_helper_access.c, ccsp_table_helper_control.c, ccsp_table_helper.h, ccsp_table_helper_internal.h |
| MIB Utilities | Utility functions for OID manipulation, data type conversion, parameter name parsing, and common MIB operation helpers | ccsp_mib_utilities.c, ccsp_mib_utilities.h |
| MIB Definitions | Common MIB-related constants, macros, and data structure definitions shared across all MIB handlers | ccsp_mib_definitions.h |
| WiFi MIB Handler | Handles RDKB-RG-WiFi-MIB operations for wireless access point configuration, client association, security settings, and WiFi statistics with OneWiFi and legacy WiFi stack support | rg_wifi_handler.c |
| Device Management Handler | Handles RDKB-RG-MIB-DeviceMgmt operations for device information, firmware management, reboot control, configuration backup/restore, and device status monitoring | rg_devmgmt_handler.c, rg_devmgmt_handler.h |
| Firewall MIB Handler | Handles RDKB-RG-MIB-Firewall operations for firewall rule management, port forwarding, DMZ configuration, and security policy control | rg_firewall_handler.c |
| MoCA MIB Handler | Handles RDKB-RG-MIB-MoCA operations for MoCA interface status, node information, network topology, and MoCA performance statistics | rg_moca_handler.c |
| Hotspot MIB Handler | Handles RDKB-RG-MIB-Hotspot operations for public WiFi hotspot configuration, SSID management, client access control, and hotspot status | rg_hotspot_handler.c |
| Diagnostics Handler | Handles diagnostic MIB operations for ping tests, traceroute, device diagnostics, and network troubleshooting commands | rg_diag_handler.c |
| WAN DNS Handler | Handles RDKB-RG-MIB-WanDns operations for DNS server configuration, DNS forwarding settings, and DNS query statistics | rg_wandns_handler.c |
| NTP Server Handler | Handles RDKB-RG-MIB-NTP operations for NTP server configuration, time synchronization settings, and NTP client status | rg_ntpserver_handler.c |
| IP Management Handler | Handles IP address management MIB operations for IPv4/IPv6 addressing, DHCP client/server, and IP interface configuration | rg_ipmgmt_handler.c |
| COSA API Integration | CCSP Object Access API providing abstraction layer for component discovery, parameter get/set operations, table row operations, and commit handling through CCSP message bus | cosa_api.c, cosa_api.h |
| SNMP Common Utilities | Common utility functions for data model access including wrapper functions for get/set operations shared across multiple MIB handlers | ccsp_snmp_common.c, ccsp_snmp_common.h |
The SNMP Protocol Agent maintains interactions with network management systems, the master SNMP daemon, RDK-B middleware components, and system services. These interactions span multiple protocols including AgentX for SNMP communication, RBus for middleware integration, and direct API calls for system configuration access.
| Target Component/Layer | Interaction Purpose | Key APIs/Endpoints |
|---|---|---|
| External Systems | ||
| Network Management System | SNMP-based remote monitoring and configuration of gateway device | SNMPv2/v3 protocol via master daemon |
| Master SNMP Daemon (snmpd) | AgentX subagent protocol communication for SNMP request delegation | AgentX protocol over tcp:127.0.0.1:705 |
| RDK-B Middleware Components | ||
| Component Registry (CcspCr) | Component discovery to locate which component owns specific data model parameters | CcspBaseIf_discComponentSupportingNamespace() via RBus path eRT.com.cisco.spvtg.ccsp.CR |
| CcspPandM | Access to Device.* parameters including device information, LAN settings, and general platform configuration | CcspBaseIf_getParameterValues(), CcspBaseIf_setParameterValues() |
| CcspWiFiAgent/OneWifi | WiFi MIB operations for access point configuration, associated devices, security settings, and wireless statistics | Device.WiFi.* parameters via message bus |
| CcspMoCAAgent | MoCA MIB operations for interface status, associated devices, and MoCA network topology | Device.MoCA.* parameters via message bus |
| CcspTr069Pa | TR-069 management server parameters for ACS connection, parameter attributes, and device provisioning | Device.ManagementServer.* parameters via message bus |
| CcspFirewall | Firewall MIB operations for security rules, port forwarding, and firewall configuration | Device.Firewall.*, Device.NAT.* parameters via message bus |
| CcspWanManager | WAN interface configuration and device control parameters | Device.X_CISCO_COM_DeviceControl.* parameters (when FEATURE_RDKB_WAN_MANAGER enabled) |
| System & Platform Services | ||
| CCSP Message Bus (RBus) | Primary IPC mechanism for all RDK-B component communication and data model access | CCSP_Message_Bus_Init(), CcspBaseIf_* API family |
| syscfg | Persistent configuration storage for system settings including SNMP v2 support flags | syscfg_get(), syscfg_set() |
| sysevent | Event notification system for system state changes and inter-process communication | sysevent_get(), sysevent_set() |
| Privilege Manager | Security service for dropping root privileges after initialization | drop_root_caps(), init_capability(), update_process_caps() |
...
The SNMP Protocol Agent does not publish events to other components. It operates in response mode, processing incoming SNMP requests and translating them to data model operations. State changes in RDK-B components are reflected through standard data model change notifications subscribed by management systems through SNMP traps configured in the master daemon.
Primary IPC Flow - SNMP GET Request to Data Model Parameter:
...
| Markdown |
|---|
```mermaid
sequenceDiagram
participant SubAgent as SNMP Subagent
participant Bus as Message Bus
participant CR as Component Registry
SubAgent->>SubAgent: Cosa_FindDestComp(parameter_name)
SubAgent->>Bus: Connect to RBus (if not connected)
Bus-->>SubAgent: Connection Handle
SubAgent->>CR: CcspBaseIf_discComponentSupportingNamespace()<br/>via RBus path: eRT.com.cisco.spvtg.ccsp.CR
Note over CR: Query component database<br/>Match parameter namespace
CR-->>SubAgent: Component Name (e.g., com.cisco.spvtg.ccsp.pam)<br/>RBus Path (e.g., /com/cisco/spvtg/ccsp/pam)
Note over SubAgent: Cache component info<br/>for subsequent requests
``` |
The SNMP Protocol Agent does not directly integrate with HAL APIs. It operates at the middleware layer translating SNMP requests to data model parameter operations. Target RDK-B components invoked through message bus calls are responsible for HAL interactions as needed.
MIB XML Parsing and Loading: The component loads MIB mapping configurations at startup by parsing CcspRDKBMibList.xml to determine which MIB XML files to load, then processing each XML file to extract OID-to-parameter mappings, data types, and handler bindings using the ansc_xml_dom_parser library
XML parsing implementation in source/SnmpPlugin/CcspSnmpPlugin.c function init_ccsp_snmp_plugin()
MIB helper object creation and handler registration in source/SnmpPlugin/ccsp_mib_helper.c
OID Translation and Parameter Discovery: Each SNMP request triggers OID lookup in loaded MIB mappings to identify the corresponding data model parameter, followed by component discovery through the Component Registry to determine which RDK-B component owns that parameter
OID-to-parameter mapping lookup in source/SnmpPlugin/ccsp_mib_utilities.c
source/SnmpPlugin/cosa_api.c function Cosa_FindDestComp()Caching of component discovery results to minimize registry queries
Data Type Conversion: The component implements bidirectional conversion between SNMP data types (INTEGER, OCTET_STR, IPADDRESS, COUNTER, GAUGE, TIMETICKS) and data model types (string, int, unsignedInt, boolean, dateTime, base64) ensuring proper value representation
Type conversion logic in source/SnmpPlugin/ccsp_mib_utilities.c and source/SnmpPlugin/ccsp_scalar_helper.c
Special handling for complex types like MAC addresses, IP addresses, and enumerations
Error Handling Strategy: SNMP error codes are generated based on CCSP message bus operation results with proper mapping of CCSP error codes to SNMP error codes (noError, noSuchName, badValue, genErr, noAccess)
Error mapping implementation in MIB helper functions
Fallback to default values when parameter access fails for read operations
Logging & Debugging: The component uses RDK Logger when available, falling back to AnscTrace logging for development builds with configurable log levels through CCSPDBG environment variable
Logger initialization in source/SnmpPlugin/CcspSnmpPlugin.c using RDK_LOGGER_INIT()
set_debug_level() functionnet-snmp debug token registration for protocol-level debugging
Privilege Management: After initialization and AgentX connection establishment, the component drops root privileges using the privilege manager API retaining only necessary capabilities for operation
Privilege dropping implementation in source/SnmpPlugin/ccsp_snmp_subagent.c function drop_root()
| Configuration File | Purpose | Override Mechanisms |
|---|---|---|
config/snmpd.conf | Master SNMP daemon configuration including community strings, AgentX settings, and plugin loading directives | System integrator configuration |
/tmp/ccsp_msg.cfg | CCSP message bus configuration specifying component names, RBus paths, and subsystem prefixes | Copied from /usr/ccsp/ccsp_msg.cfg at startup |
Mib2DmMapping/CcspRDKBMibList.xml | Master index of MIB mapping XML files to be loaded by the plugin | Build-time selection between CcspRDKBMibList.xml and CcspMibList.xml via RDKB_MIB flag |
Mib2DmMapping/Ccsp_RDKB-RG-WiFi-MIB.xml | MIB-to-DataModel mapping for WiFi subsystem including access point and associated device parameters | XML preprocessing directives for feature-specific includes |
Mib2DmMapping/Ccsp_RDKB-RG-MIB-DeviceMgmt.xml | MIB-to-DataModel mapping for device management operations including reboot, reset, and firmware management | Platform-specific parameter mappings |
Mib2DmMapping/Ccsp_RDKB-RG-MIB-Firewall.xml | MIB-to-DataModel mapping for firewall configuration and port forwarding rules | Security feature flag conditionals |
Mib2DmMapping/Ccsp_RDKB-RG-MIB-MoCA.xml | MIB-to-DataModel mapping for MoCA interface status and network topology | MoCA availability conditionals |
Mib2DmMapping/Ccsp_RDKB-RG-MIB-Hotspot.xml | MIB-to-DataModel mapping for public WiFi hotspot configuration and management | Hotspot feature flag conditionals |
/var/tmp/snmp_subagent_v2.pid | Process ID file for SNMPv2 subagent instance | Generated at runtime |
/var/tmp/snmp_subagent_v3.pid | Process ID file for SNMPv3 subagent instance | Generated at runtime |