77 lines
2.6 KiB
Markdown
77 lines
2.6 KiB
Markdown
# Runtime Flow
|
|
|
|
The flow is generated alongside the call graph. Function names are validated
|
|
against the current C sources so renamed or removed stages fail documentation
|
|
checks.
|
|
|
|
## Daemon scheduler
|
|
|
|
```mermaid
|
|
flowchart TD
|
|
start([main]) --> config[config_load]
|
|
config --> state[state_load]
|
|
state --> model[ufmodel_find]
|
|
model --> identity[Read LAN MAC, IP, and default gateway]
|
|
identity --> persist[state_save]
|
|
persist --> announceInit[announce_init when enabled]
|
|
announceInit --> loop{One-second main loop}
|
|
loop -->|announce due| announce[announce_send]
|
|
announce --> loop
|
|
loop -->|LLDP due| ports{For every model port}
|
|
ports --> lldp[lldp_send_frame]
|
|
lldp --> loop
|
|
loop -->|inform due| refresh[Refresh controller URL and device IP]
|
|
refresh --> inform[inform_send]
|
|
inform --> loop
|
|
loop -->|nothing due| sleep[sleep 1 second]
|
|
sleep --> loop
|
|
```
|
|
|
|
## Inform exchange
|
|
|
|
```mermaid
|
|
flowchart TD
|
|
send([inform_send]) --> url{inform URL available?}
|
|
url -->|no| error[Return an error]
|
|
url -->|yes| key{Device adopted?}
|
|
key -->|no| defaultKey[Use DEFAULT_AUTH_KEY]
|
|
key -->|yes| stateKey[Use persisted device key]
|
|
defaultKey --> payload[inform_build_payload]
|
|
stateKey --> payload
|
|
payload --> packet[inform_packet_build]
|
|
packet --> post[http_post]
|
|
post --> status{HTTP 200?}
|
|
status -->|no, first attempt| retry[Retry with alternate CBC or GCM cipher]
|
|
retry --> packet
|
|
status -->|no, final attempt| error
|
|
status -->|yes| decode[inform_packet_parse]
|
|
decode --> json[Parse controller JSON]
|
|
json --> handle[inform_handle_response]
|
|
```
|
|
|
|
## Controller response and provisioning
|
|
|
|
```mermaid
|
|
flowchart TD
|
|
response([inform_handle_response]) --> type{_type}
|
|
type -->|noop| done[No state change]
|
|
type -->|upgrade| version[Persist requested firmware version]
|
|
type -->|reboot or reset| reboot[reboot_openwrt]
|
|
type -->|cmd adopt| adopt[Persist key, URL, and adopted state]
|
|
type -->|setparam| params[Parse management parameters]
|
|
params --> legacy{system_cfg present?}
|
|
legacy -->|yes| legacyApply[wlan_apply_system_cfg]
|
|
legacyApply --> normalize[Build radio_table and vap_table JSON]
|
|
normalize --> apply[wlan_apply_config]
|
|
type -->|setstate| apply
|
|
apply --> ids[wlan_ensure_vap_ids]
|
|
ids --> clear[wlan_clear managed openuf_ VAPs]
|
|
clear --> radios[wlan_apply_radio for each band]
|
|
radios --> vaps[Create controller VAP sections]
|
|
vaps --> commit[Commit UCI and configure usteer]
|
|
commit --> start[Start and verify radios sequentially]
|
|
start --> result{Apply succeeded?}
|
|
result -->|yes| saved[Save cfgversion and config schema]
|
|
result -->|no| retryConfig[Reset cfgversion to 0]
|
|
```
|