Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • SNMP Protocol Implementation: Operates as AgentX subagent providing SNMP GET, SET, and GETNEXT operations for remote network management with support for both SNMPv2 and SNMPv3 protocols
  • MIB-to-DataModel Translation: Implements dynamic MIB object handling by translating SNMP OIDs to RDK-B data model parameters through XML-defined mappings enabling consistent access across subsystems
  • Multi-Subsystem Coverage: Provides MIB implementations for WiFi, Firewall, MoCA, Hotspot, Device Management, DNS, NTP, TR-069, VLAN, and vendor-specific extensions through custom handler modules
  • AgentX Protocol Support: Integrates with master SNMP daemon via AgentX protocol enabling distributed SNMP agent architecture and supporting multiple subagents on the same device
  • Dynamic MIB Loading: Loads MIB mapping configurations from XML files at runtime allowing flexible MIB extensions without code recompilation

Design

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
```

Prerequisites and Dependencies

Build-Time Flags and Configuration:

...

  • Threading Architecture: Single-threaded with net-snmp event loop
  • Main Thread: Handles AgentX protocol communication, SNMP request processing, MIB handler callbacks, and CCSP message bus synchronous calls
  • Synchronization: No explicit synchronization required due to single-threaded design

Component State Flow

Initialization to Active State

...

  • AgentX connection failure triggering reconnection attempts with exponential backoff
  • SNMP request handling context switch from idle to active processing state
  • CCSP message bus call timeout handling with parameter access retry logic

Call Flow

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)
```

Internal Modules

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/ClassDescriptionKey Files
SNMP Subagent ProcessMain executable implementing AgentX subagent protocol with master daemon communication, event loop management, privilege dropping, and process lifecycle controlccsp_snmp_subagent.c
SNMP Plugin CoreCentral plugin manager responsible for MIB XML loading, MIB helper object creation, handler registration coordination, and plugin lifecycle managementCcspSnmpPlugin.c
MIB Helper FrameworkCore MIB processing framework providing OID registration, handler dispatch, caching infrastructure, and base implementation for scalar and table MIB objectsccsp_mib_helper.c, ccsp_mib_helper.h
Scalar HelperImplements scalar MIB object handling including GET/SET operations, value validation, type conversion, and parameter access control for single-instance OIDsccsp_scalar_helper.c, ccsp_scalar_helper_access.c, ccsp_scalar_helper_control.c, ccsp_scalar_helper.h, ccsp_scalar_helper_internal.h
Table HelperImplements tabular MIB object handling including row enumeration, index management, table caching, and multi-instance object operations for SNMP tablesccsp_table_helper.c, ccsp_table_helper_access.c, ccsp_table_helper_control.c, ccsp_table_helper.h, ccsp_table_helper_internal.h
MIB UtilitiesUtility functions for OID manipulation, data type conversion, parameter name parsing, and common MIB operation helpersccsp_mib_utilities.c, ccsp_mib_utilities.h
MIB DefinitionsCommon MIB-related constants, macros, and data structure definitions shared across all MIB handlersccsp_mib_definitions.h
WiFi MIB HandlerHandles RDKB-RG-WiFi-MIB operations for wireless access point configuration, client association, security settings, and WiFi statistics with OneWiFi and legacy WiFi stack supportrg_wifi_handler.c
Device Management HandlerHandles RDKB-RG-MIB-DeviceMgmt operations for device information, firmware management, reboot control, configuration backup/restore, and device status monitoringrg_devmgmt_handler.c, rg_devmgmt_handler.h
Firewall MIB HandlerHandles RDKB-RG-MIB-Firewall operations for firewall rule management, port forwarding, DMZ configuration, and security policy controlrg_firewall_handler.c
MoCA MIB HandlerHandles RDKB-RG-MIB-MoCA operations for MoCA interface status, node information, network topology, and MoCA performance statisticsrg_moca_handler.c
Hotspot MIB HandlerHandles RDKB-RG-MIB-Hotspot operations for public WiFi hotspot configuration, SSID management, client access control, and hotspot statusrg_hotspot_handler.c
Diagnostics HandlerHandles diagnostic MIB operations for ping tests, traceroute, device diagnostics, and network troubleshooting commandsrg_diag_handler.c
WAN DNS HandlerHandles RDKB-RG-MIB-WanDns operations for DNS server configuration, DNS forwarding settings, and DNS query statisticsrg_wandns_handler.c
NTP Server HandlerHandles RDKB-RG-MIB-NTP operations for NTP server configuration, time synchronization settings, and NTP client statusrg_ntpserver_handler.c
IP Management HandlerHandles IP address management MIB operations for IPv4/IPv6 addressing, DHCP client/server, and IP interface configurationrg_ipmgmt_handler.c
COSA API IntegrationCCSP Object Access API providing abstraction layer for component discovery, parameter get/set operations, table row operations, and commit handling through CCSP message buscosa_api.c, cosa_api.h
SNMP Common UtilitiesCommon utility functions for data model access including wrapper functions for get/set operations shared across multiple MIB handlersccsp_snmp_common.c, ccsp_snmp_common.h

Component Interactions

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.

Interaction Matrix

Target Component/LayerInteraction PurposeKey APIs/Endpoints
External Systems

Network Management SystemSNMP-based remote monitoring and configuration of gateway deviceSNMPv2/v3 protocol via master daemon
Master SNMP Daemon (snmpd)AgentX subagent protocol communication for SNMP request delegationAgentX 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 parametersCcspBaseIf_discComponentSupportingNamespace() via RBus path eRT.com.cisco.spvtg.ccsp.CR
CcspPandMAccess to Device.* parameters including device information, LAN settings, and general platform configurationCcspBaseIf_getParameterValues(), CcspBaseIf_setParameterValues()
CcspWiFiAgent/OneWifiWiFi MIB operations for access point configuration, associated devices, security settings, and wireless statisticsDevice.WiFi.* parameters via message bus
CcspMoCAAgentMoCA MIB operations for interface status, associated devices, and MoCA network topologyDevice.MoCA.* parameters via message bus
CcspTr069PaTR-069 management server parameters for ACS connection, parameter attributes, and device provisioningDevice.ManagementServer.* parameters via message bus
CcspFirewallFirewall MIB operations for security rules, port forwarding, and firewall configurationDevice.Firewall.*, Device.NAT.* parameters via message bus
CcspWanManagerWAN interface configuration and device control parametersDevice.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 accessCCSP_Message_Bus_Init(), CcspBaseIf_* API family
syscfgPersistent configuration storage for system settings including SNMP v2 support flagssyscfg_get(), syscfg_set()
syseventEvent notification system for system state changes and inter-process communicationsysevent_get(), sysevent_set()
Privilege ManagerSecurity service for dropping root privileges after initializationdrop_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.

IPC Flow Patterns

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
```

Implementation Details

Major HAL APIs Integration

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.

Key Implementation Logic

  • 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

  • Component discovery implementation in 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

  • Timeout handling for message bus calls with configurable retry
  • 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()

  • Debug level configuration in set_debug_level() function
  • net-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()

  • Capability configuration through privilege manager library

Key Configuration Files

Configuration FilePurposeOverride Mechanisms
config/snmpd.confMaster SNMP daemon configuration including community strings, AgentX settings, and plugin loading directivesSystem integrator configuration
/tmp/ccsp_msg.cfgCCSP message bus configuration specifying component names, RBus paths, and subsystem prefixesCopied from /usr/ccsp/ccsp_msg.cfg at startup
Mib2DmMapping/CcspRDKBMibList.xmlMaster index of MIB mapping XML files to be loaded by the pluginBuild-time selection between CcspRDKBMibList.xml and CcspMibList.xml via RDKB_MIB flag
Mib2DmMapping/Ccsp_RDKB-RG-WiFi-MIB.xmlMIB-to-DataModel mapping for WiFi subsystem including access point and associated device parametersXML preprocessing directives for feature-specific includes
Mib2DmMapping/Ccsp_RDKB-RG-MIB-DeviceMgmt.xmlMIB-to-DataModel mapping for device management operations including reboot, reset, and firmware managementPlatform-specific parameter mappings
Mib2DmMapping/Ccsp_RDKB-RG-MIB-Firewall.xmlMIB-to-DataModel mapping for firewall configuration and port forwarding rulesSecurity feature flag conditionals
Mib2DmMapping/Ccsp_RDKB-RG-MIB-MoCA.xmlMIB-to-DataModel mapping for MoCA interface status and network topologyMoCA availability conditionals
Mib2DmMapping/Ccsp_RDKB-RG-MIB-Hotspot.xmlMIB-to-DataModel mapping for public WiFi hotspot configuration and managementHotspot feature flag conditionals
/var/tmp/snmp_subagent_v2.pidProcess ID file for SNMPv2 subagent instanceGenerated at runtime
/var/tmp/snmp_subagent_v3.pidProcess ID file for SNMPv3 subagent instanceGenerated at runtime