# mothishree/onewifi architecture

> Architecture diagram of the GitHub repository mothishree/onewifi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mothishree/onewifi
- Repository: https://github.com/mothishree/onewifi

## Overview

#### Purpose and process entry
OneWifi is the RDK-B WiFi-management component for gateways and extenders. It manages radios, VAPs, clients, security, mesh, telemetry, and optimization while translating management-plane requests into WiFi HAL operations. The service-support process entry and lifecycle are in:
- `source/dml/wifi_ssp/ssp_main.c`
- `source/dml/wifi_ssp/ssp_loop.c`
- `scripts/onewifi.service`

#### Central orchestration and event control
`wifi_mgr` owns global WiFi state, discovered capabilities, and subsystem handles. `wifi_ctrl` is the asynchronous control boundary: it accepts queued configuration, HAL, timer, and application events, then executes hardware-facing apply flows. This separates request handlers from potentially slow or stateful radio/VAP operations.
- `source/core/wifi_mgr.c`
- `source/core/wifi_ctrl.c`
- `source/core/wifi_ctrl_queue_handlers.c`

#### Configuration ingress: TR-181 and WebConfig
Northbound management has two primary paths. TR-181/DML exposes `Device.WiFi.*` through RBus/CCSP callbacks. Cloud WebConfig accepts JSON subdocuments, decodes and validates them, and translates bulk updates into the internal model. Both converge on manager/database/control flows rather than calling hardware directly.
- `source/dml/tr_181/ml/cosa_wifi_dml.c`
- `source/webconfig/wifi_decoder.c`
- `source/core/wifi_ctrl_webconfig.c`

Schemas and persistent interface contracts are rooted in:
- `config/TR181-WiFi-USGv2.XML`
- `config/subdoc_schemas_1_4/`
- `config/rdkb-wifi.ovsschema`

#### State, persistence, and consistency boundary
The database layer owns WiFi configuration/state persistence and database APIs; OVSDB support includes cache, table, update, and synchronous client primitives. Configuration writes are persisted before or alongside control events, while runtime/HAL outcomes update operational state. PSM is an external RDK-B persistence dependency.
- `source/db/wifi_db.c`
- `source/db/wifi_db_apis.c`
- `lib/ovsdb/ovsdb_cache.c`

#### Southbound WiFi and VAP services
The core converts normalized state into WiFi HAL actions and handles HAL-originated events. VAP service implementations encapsulate service-specific behavior for private, public, and mesh VAPs, keeping those policies out of generic control processing. Platform adapters isolate RDK-B, Linux, OpenWrt, DBus, and bus-specific differences.
- `source/core/wifi_data_plane.c`
- `source/core/services/vap_svc.c`
- `source/services/wifi_services_mgr.c`

Material runtime dependencies are the WiFi HAL, hostapd/wpa_supplicant and Linux networking beneath it; RBus/CCSP provide inter-component control.

#### Modular applications, measurement, and telemetry
An application manager loads enabled feature modules and routes relevant events. Major modules include EasyMesh, station management, CAC/DFS, CSI/motion sensing, Blaster measurement, analytics, harvester, and client/link-quality steering. Statistics collection is a distinct periodic path that produces measurements and supports telemetry serialization/reporting.
- `source/apps/wifi_apps_mgr.c`
- `source/apps/em/wifi_em.c`
- `source/stats/wifi_monitor.c`

Telemetry/data-pipeline integration is represented by:
- `lib/datapipeline/dppline.c`
- `config/WifiSingleClient.avsc`

#### Primary runtime flow
Startup initializes platform/bus support, manager state, database, HAL-facing control, and enabled apps. At runtime: **TR-181/RBus or WebConfig JSON → validation/translation → manager and DB update → queued control event → HAL/VAP apply → state/cache update and notifications**. The reverse path is **hardware event → control queue → state/database update → applications, DML/RBus, and telemetry consumers**. Build targets support Linux and OpenWrt variants, with optional mesh, WiFi 7/MLO, and feature applications.
- `build/linux/makefile.common`
- `build/openwrt/Makefile_package`
- `configure.ac`

Main entry points: [`source/core/wifi_ctrl.c`](https://github.com/mothishree/onewifi/blob/develop/source/core/wifi_ctrl.c) (WiFi control), [`source/db/wifi_db.c`](https://github.com/mothishree/onewifi/blob/develop/source/db/wifi_db.c) (WiFi database), [`source/dml/wifi_ssp/ssp_main.c`](https://github.com/mothishree/onewifi/blob/develop/source/dml/wifi_ssp/ssp_main.c) (Service process), [`source/dml/tr_181/ml/cosa_wifi_dml.c`](https://github.com/mothishree/onewifi/blob/develop/source/dml/tr_181/ml/cosa_wifi_dml.c) (TR-181 DML)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_northbound["Management ingress"]
  node_tr181["TR-181 DML<br/>RBus/CCSP handler<br/>[cosa_wifi_dml.c]"]
  node_webconfig["WebConfig decoder<br/>JSON ingress<br/>[wifi_decoder.c]"]
  node_contracts["Management schemas<br/>interface contracts"]
end

subgraph group_core["Core control"]
  node_ssp["Service process<br/>RDK-B service entry<br/>[ssp_main.c]"]
  node_mgr["WiFi manager<br/>global state manager<br/>[wifi_mgr.c]"]
  node_ctrl["WiFi control<br/>async controller<br/>[wifi_ctrl.c]"]
  node_db[("WiFi database<br/>persistence API<br/>[wifi_db.c]")]
  node_ovsdb[("OVSDB cache<br/>OVSDB support<br/>[ovsdb_cache.c]")]
end

subgraph group_southbound["WiFi runtime"]
  node_data_plane["WiFi data plane<br/>HAL adapter<br/>[wifi_data_plane.c]"]
  node_vap_services["VAP services<br/>service policies<br/>[vap_svc.c]"]
  node_platform_services["Platform adapters<br/>runtime adapters"]
  node_wifi_hal{{"WiFi HAL<br/>external hardware API"}}
  node_network_stack{{"hostapd / Linux networking<br/>external network runtime"}}
end

subgraph group_extensions["Apps and telemetry"]
  node_apps["Application manager<br/>feature module host<br/>[wifi_apps_mgr.c]"]
  node_easymesh["EasyMesh module<br/>feature application<br/>[wifi_em.c]"]
  node_stats["Statistics monitor<br/>periodic measurement<br/>[wifi_monitor.c]"]
  node_datapipeline["Data pipeline<br/>telemetry integration<br/>[dppline.c]"]
end

node_psm[("PSM<br/>external persistence")]

node_ssp -->|"initializes"| node_mgr
node_ssp -->|"initializes"| node_db
node_ssp -->|"starts"| node_ctrl
node_ssp -->|"loads enabled apps"| node_apps
node_tr181 -->|"management updates"| node_mgr
node_tr181 -->|"reads and writes state"| node_db
node_webconfig -->|"translated updates"| node_ctrl
node_contracts -.->|"defines model"| node_tr181
node_contracts -.->|"defines subdocuments"| node_webconfig
node_mgr -->|"configuration and state"| node_db
node_db -->|"cache and table operations"| node_ovsdb
node_db -->|"persistent settings"| node_psm
node_mgr -->|"normalized state and events"| node_ctrl
node_ctrl -->|"apply operations"| node_data_plane
node_ctrl -->|"VAP policy apply"| node_vap_services
node_data_plane -->|"HAL calls and events"| node_wifi_hal
node_vap_services -->|"platform-specific services"| node_platform_services
node_wifi_hal -->|"configures radios and VAPs"| node_network_stack
node_wifi_hal -->|"hardware events"| node_ctrl
node_ctrl -->|"operational state update"| node_db
node_ctrl -->|"runtime events"| node_apps
node_apps -->|"routes feature events"| node_easymesh
node_stats -->|"measurements"| node_datapipeline
node_ctrl -->|"state and event inputs"| node_stats
node_db -.->|"state notifications"| node_tr181

click node_ssp "https://github.com/mothishree/onewifi/blob/develop/source/dml/wifi_ssp/ssp_main.c"
click node_mgr "https://github.com/mothishree/onewifi/blob/develop/source/core/wifi_mgr.c"
click node_ctrl "https://github.com/mothishree/onewifi/blob/develop/source/core/wifi_ctrl.c"
click node_tr181 "https://github.com/mothishree/onewifi/blob/develop/source/dml/tr_181/ml/cosa_wifi_dml.c"
click node_webconfig "https://github.com/mothishree/onewifi/blob/develop/source/webconfig/wifi_decoder.c"
click node_contracts "https://github.com/mothishree/onewifi/blob/develop/config/TR181-WiFi-USGv2.XML"
click node_db "https://github.com/mothishree/onewifi/blob/develop/source/db/wifi_db.c"
click node_ovsdb "https://github.com/mothishree/onewifi/blob/develop/lib/ovsdb/ovsdb_cache.c"
click node_data_plane "https://github.com/mothishree/onewifi/blob/develop/source/core/wifi_data_plane.c"
click node_vap_services "https://github.com/mothishree/onewifi/blob/develop/source/core/services/vap_svc.c"
click node_platform_services "https://github.com/mothishree/onewifi/blob/develop/source/services/wifi_services_mgr.c"
click node_apps "https://github.com/mothishree/onewifi/blob/develop/source/apps/wifi_apps_mgr.c"
click node_easymesh "https://github.com/mothishree/onewifi/blob/develop/source/apps/em/wifi_em.c"
click node_stats "https://github.com/mothishree/onewifi/blob/develop/source/stats/wifi_monitor.c"
click node_datapipeline "https://github.com/mothishree/onewifi/blob/develop/lib/datapipeline/dppline.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tr181,node_webconfig,node_contracts toneBlue
class node_ssp,node_mgr,node_ctrl,node_db,node_ovsdb toneAmber
class node_data_plane,node_vap_services,node_platform_services,node_wifi_hal,node_network_stack toneMint
class node_apps,node_easymesh,node_stats,node_datapipeline toneRose
class node_psm toneNeutral
```

## Components

### Management ingress

- [TR-181 DML](https://github.com/mothishree/onewifi/blob/develop/source/dml/tr_181/ml/cosa_wifi_dml.c): RBus/CCSP handler · Exposes Device.WiFi management callbacks. · `source/dml/tr_181/ml/cosa_wifi_dml.c`
- [WebConfig decoder](https://github.com/mothishree/onewifi/blob/develop/source/webconfig/wifi_decoder.c): JSON ingress · Validates subdocuments and translates bulk updates. · `source/webconfig/wifi_decoder.c`
- [Management schemas](https://github.com/mothishree/onewifi/blob/develop/config/TR181-WiFi-USGv2.XML): interface contracts · `config/TR181-WiFi-USGv2.XML`

### Core control

- [Service process](https://github.com/mothishree/onewifi/blob/develop/source/dml/wifi_ssp/ssp_main.c): RDK-B service entry · Owns lifecycle and startup sequencing. · `source/dml/wifi_ssp/ssp_main.c`
- [WiFi manager](https://github.com/mothishree/onewifi/blob/develop/source/core/wifi_mgr.c): global state manager · Owns discovered capabilities and subsystem handles. · `source/core/wifi_mgr.c`
- [WiFi control](https://github.com/mothishree/onewifi/blob/develop/source/core/wifi_ctrl.c): async controller · Queues and executes hardware-facing apply flows. · `source/core/wifi_ctrl.c`
- [WiFi database](https://github.com/mothishree/onewifi/blob/develop/source/db/wifi_db.c): persistence API · Persists configuration and operational state. · `source/db/wifi_db.c`
- [OVSDB cache](https://github.com/mothishree/onewifi/blob/develop/lib/ovsdb/ovsdb_cache.c): OVSDB support · Provides cache and table update support. · `lib/ovsdb/ovsdb_cache.c`

### WiFi runtime

- [WiFi data plane](https://github.com/mothishree/onewifi/blob/develop/source/core/wifi_data_plane.c): HAL adapter · Converts normalized state to WiFi HAL actions and events. · `source/core/wifi_data_plane.c`
- [VAP services](https://github.com/mothishree/onewifi/blob/develop/source/core/services/vap_svc.c): service policies · Encapsulates private, public, and mesh VAP behavior. · `source/core/services/vap_svc.c`
- [Platform adapters](https://github.com/mothishree/onewifi/blob/develop/source/services/wifi_services_mgr.c): runtime adapters · Isolates RDK-B, Linux, OpenWrt, DBus, and bus differences. · `source/services/wifi_services_mgr.c`
- **WiFi HAL**: external hardware API
- **hostapd / Linux networking**: external network runtime

### Apps and telemetry

- [Application manager](https://github.com/mothishree/onewifi/blob/develop/source/apps/wifi_apps_mgr.c): feature module host · Loads enabled modules and routes relevant events. · `source/apps/wifi_apps_mgr.c`
- [EasyMesh module](https://github.com/mothishree/onewifi/blob/develop/source/apps/em/wifi_em.c): feature application · `source/apps/em/wifi_em.c`
- [Statistics monitor](https://github.com/mothishree/onewifi/blob/develop/source/stats/wifi_monitor.c): periodic measurement · Collects measurements for telemetry serialization. · `source/stats/wifi_monitor.c`
- [Data pipeline](https://github.com/mothishree/onewifi/blob/develop/lib/datapipeline/dppline.c): telemetry integration · `lib/datapipeline/dppline.c`

### Other components

- **PSM**: external persistence · RDK-B persistence dependency.

## Connections

- Service process → WiFi manager: initializes
- Service process → WiFi database: initializes
- Service process → WiFi control: starts
- Service process → Application manager: loads enabled apps
- TR-181 DML → WiFi manager: management updates
- TR-181 DML → WiFi database: reads and writes state
- WebConfig decoder → WiFi control: translated updates
- Management schemas → TR-181 DML: defines model
- Management schemas → WebConfig decoder: defines subdocuments
- WiFi manager → WiFi database: configuration and state
- WiFi database → OVSDB cache: cache and table operations
- WiFi database → PSM: persistent settings
- WiFi manager → WiFi control: normalized state and events
- WiFi control → WiFi data plane: apply operations
- WiFi control → VAP services: VAP policy apply
- WiFi data plane → WiFi HAL: HAL calls and events
- VAP services → Platform adapters: platform-specific services
- WiFi HAL → hostapd / Linux networking: configures radios and VAPs
- WiFi HAL → WiFi control: hardware events
- WiFi control → WiFi database: operational state update
- WiFi control → Application manager: runtime events
- Application manager → EasyMesh module: routes feature events
- Statistics monitor → Data pipeline: measurements
- WiFi control → Statistics monitor: state and event inputs
- WiFi database → TR-181 DML: state notifications
