Skip to main content

rodecaster_protocol/names/
sip.rs

1//! SIP subsystem parameter families: [`SipCallingParam`],
2//! [`SipRegistrationParam`], [`SipCallSlotsParam`], [`SipAdvancedParam`].
3//!
4//! Empirically measured on Duo fw 1.7.3 (2026-07-01) via CLI raw-write fuzzing:
5//! every SIPADVANCED property accepts writes and persists them across
6//! `refresh`. Registration-relevant writes trigger a
7//! `sipRegistrationIsRegistered` echo as a device-side re-check. Statistical
8//! properties on SIPCALLSLOTS (`sipSlotCallQuality`, `sipSlotCallJitter`,
9//! `sipSlotCallBitrate`, `sipSlotCallPacketLoss`) are device-managed
10//! read-back only.
11
12// SIPCALLING node (fourteen properties, plus SIPREGISTRATION sub-nodes).
13// Singleton at root; the device presents itself via `sipRodeCode`, tracks
14// remaining calltime, and hosts + accepts + emits call setup metadata here.
15wire_param_enum! {
16    /// A SIP calling-level parameter: one of the fourteen flat properties the
17    /// device carries on the singleton `SIPCALLING` node. Combines settings
18    /// (`HostingEnabled` / `HostingToggleEnabled` / `LicenceMode` /
19    /// `LicenceCheck`), device-managed read-back (`RodeCode`: the invite
20    /// code; rotates on hosting toggle), incoming/outgoing call setup
21    /// channels (JSON-ish strings), the pending-slot selector, subscription
22    /// remaining-time meters, and the post-call rating write channel.
23    SipCallingParam {
24    HostingEnabled => "sipCallHostingEnabled",
25    HostingToggleEnabled => "sipCallHostingToggleEnabled",
26    LicenceMode => "sipLicenceMode",
27    LicenceCheck => "sipLicenceCheck",
28    RodeCode => "sipRodeCode",
29    IncomingCallAccept => "sipIncomingCallAccept",
30    IncomingCallDetails => "sipIncomingCallDetails",
31    OutgoingCallDetails => "sipOutgoingCallDetails",
32    SlotPendingCallSetup => "sipSlotPendingCallSetup",
33    RemainingCalltime => "sipRemainingCalltime",
34    RemainingWebCalltime => "sipRemainingWebCalltime",
35    RenewalDate => "sipRenewalDate",
36    LicenceRenewal => "sipLicenceRenewal",
37    CallRating => "sipCallRating",
38    }
39}
40
41// SIPREGISTRATION node (three properties per registration). Per-instance under
42// SIPCALLING: the Duo has two registration slots preconfigured. `Details`
43// carries the account registration payload; `IsRegistered` is a device-side
44// read-back that echoes on every registration re-check.
45wire_param_enum! {
46    /// A per-registration SIP parameter: one of the three flat properties the
47    /// device carries on each `SIPREGISTRATION` child under `SIPCALLING`.
48    /// `Index` selects which registration slot; `Details` is the account
49    /// registration payload; `IsRegistered` is the device-side registered
50    /// flag (read-back: echoes whenever the SIP subsystem re-checks
51    /// registration, including as a side effect of writes to SIPADVANCED
52    /// account fields).
53    SipRegistrationParam {
54    Index => "sipRegistrationIndex",
55    Details => "sipRegistrationDetails",
56    IsRegistered => "sipRegistrationIsRegistered",
57    }
58}
59
60// SIPCALLSLOTS nodes (twelve properties per slot). Per-slot at root; the Duo
61// has three consecutive call slots. Read-back statistics (`Quality`, `Jitter`,
62// `Bitrate`, `PacketLoss`) are device-managed; command channels
63// (`Disconnect`, `Extend`) accept writes; identity fields (`SlotId`,
64// `State`, `UUID`, `Address`, `IsHost`, `Mode`) mostly read-back.
65wire_param_enum! {
66    /// A per-slot SIP call parameter: one of the twelve flat properties the
67    /// device carries on each `SIPCALLSLOTS` node (three consecutive slots
68    /// at root). Statistics (`Quality`, `Jitter`, `Bitrate`, `PacketLoss`)
69    /// are device-managed. `Disconnect` is a `Binary` command channel
70    /// (same request-pulse pattern as `mixLinkRequest`); `Extend` is a
71    /// bool command. Identity/state fields (`SlotId`, `State`, `UUID`,
72    /// `Address`, `IsHost`, `Mode`) reflect the call's current status.
73    SipCallSlotsParam {
74    SlotId => "sipCallSlotId",
75    State => "sipSlotCallState",
76    Uuid => "sipSlotCallUUID",
77    Address => "sipSlotCallAddress",
78    Quality => "sipSlotCallQuality",
79    Jitter => "sipSlotCallJitter",
80    Bitrate => "sipSlotCallBitrate",
81    PacketLoss => "sipSlotCallPacketLoss",
82    Disconnect => "sipSlotCallDisconnect",
83    Extend => "sipSlotCallExtend",
84    IsHost => "sipSlotCallIsHost",
85    Mode => "sipSlotCallMode",
86    }
87}
88
89// SIPADVANCED node (twenty-five properties). Singleton at root: every one of
90// these was proven writable + persistent in the 2026-07-01 fuzz session.
91// Notably the device stores arbitrary property names verbatim on this node
92// (no schema enforcement); the typed set here is the observed-25.
93wire_param_enum! {
94    /// A SIP advanced-settings parameter: one of the twenty-five flat
95    /// properties the device carries on the singleton `SIPADVANCED` node.
96    /// Every property in this family is empirically writable + persistent
97    /// on Duo fw 1.7.3 (measured 2026-07-01). Groups: codec / feature
98    /// flags (`ForceCodecChoice`, `EnableVideoStream`, `EnableRFCDuplication`,
99    /// `IncomingNameFilter`, `UsbNumberPad`, `NonHTTPSInterface`,
100    /// `AutoReconnect`); audio routing + DTMF (`IncomingAudioRouting`,
101    /// `DtmfMode`); receive jitter buffer bounds; the sipAccount* config
102    /// (username / password / domain / proxy / transport / auth), a NAT
103    /// traversal block (`sipNATTraversal*`), the unit name, and the
104    /// device's rodeCallQuality read-back.
105    ///
106    /// Writes to registration-relevant fields (account credentials, NAT,
107    /// domain) trigger a `sipRegistrationIsRegistered` echo as the device
108    /// re-checks its registration state.
109    SipAdvancedParam {
110    ForceCodecChoice => "forceCodecChoice",
111    EnableVideoStream => "enableVideoStream",
112    EnableRFCDuplication => "enableRFCDuplication",
113    IncomingNameFilter => "incomingNameFilter",
114    UsbNumberPad => "usbNumberPad",
115    NonHTTPSInterface => "nonHTTPSInterface",
116    AutoReconnect => "autoReconnect",
117    IncomingAudioRouting => "incomingAudioRouting",
118    DtmfMode => "dtmfMode",
119    ReceiveJitterBufferMin => "receiveJitterBufferMin",
120    ReceiveJitterBufferMax => "receiveJitterBufferMax",
121    SipWebPassword => "sipWebPassword",
122    SipAccountRegister => "sipAccountRegister",
123    SipAccountUsername => "sipAccountUsername",
124    SipAccountPassword => "sipAccountPassword",
125    SipAccountDomain => "sipAccountDomain",
126    SipAccountProxyAddress => "sipAccountProxyAddress",
127    SipAccountTransport => "sipAccountTransport",
128    SipNatTraversalMode => "sipNATTraversalMode",
129    SipNatTraversalServer => "sipNATTraversalServer",
130    SipNatTraversalUsername => "sipNATTraversalUsername",
131    SipNatTraversalPassword => "sipNATTraversalPassword",
132    SipUnitName => "sipUnitName",
133    SipAccountAuthUsername => "sipAccountAuthUsername",
134    RodeCallQuality => "rodeCallQuality",
135    }
136}
137
138#[cfg(test)]
139mod tests {
140    use super::*;
141
142    #[test]
143    fn sip_calling_param_round_trips() {
144        let params = [
145            SipCallingParam::HostingEnabled,
146            SipCallingParam::HostingToggleEnabled,
147            SipCallingParam::LicenceMode,
148            SipCallingParam::LicenceCheck,
149            SipCallingParam::RodeCode,
150            SipCallingParam::IncomingCallAccept,
151            SipCallingParam::IncomingCallDetails,
152            SipCallingParam::OutgoingCallDetails,
153            SipCallingParam::SlotPendingCallSetup,
154            SipCallingParam::RemainingCalltime,
155            SipCallingParam::RemainingWebCalltime,
156            SipCallingParam::RenewalDate,
157            SipCallingParam::LicenceRenewal,
158            SipCallingParam::CallRating,
159        ];
160        for p in params {
161            assert_eq!(SipCallingParam::from_name(p.as_str()), p);
162            assert!(p.is_known());
163        }
164    }
165
166    #[test]
167    fn sip_registration_param_round_trips() {
168        for p in [
169            SipRegistrationParam::Index,
170            SipRegistrationParam::Details,
171            SipRegistrationParam::IsRegistered,
172        ] {
173            assert_eq!(SipRegistrationParam::from_name(p.as_str()), p);
174            assert!(p.is_known());
175        }
176    }
177
178    #[test]
179    fn sip_call_slots_param_round_trips_all_twelve() {
180        let params = [
181            SipCallSlotsParam::SlotId,
182            SipCallSlotsParam::State,
183            SipCallSlotsParam::Uuid,
184            SipCallSlotsParam::Address,
185            SipCallSlotsParam::Quality,
186            SipCallSlotsParam::Jitter,
187            SipCallSlotsParam::Bitrate,
188            SipCallSlotsParam::PacketLoss,
189            SipCallSlotsParam::Disconnect,
190            SipCallSlotsParam::Extend,
191            SipCallSlotsParam::IsHost,
192            SipCallSlotsParam::Mode,
193        ];
194        for p in params {
195            assert_eq!(SipCallSlotsParam::from_name(p.as_str()), p);
196            assert!(p.is_known());
197        }
198    }
199
200    #[test]
201    fn sip_advanced_param_round_trips_all_twenty_five() {
202        let params = [
203            SipAdvancedParam::ForceCodecChoice,
204            SipAdvancedParam::EnableVideoStream,
205            SipAdvancedParam::EnableRFCDuplication,
206            SipAdvancedParam::IncomingNameFilter,
207            SipAdvancedParam::UsbNumberPad,
208            SipAdvancedParam::NonHTTPSInterface,
209            SipAdvancedParam::AutoReconnect,
210            SipAdvancedParam::IncomingAudioRouting,
211            SipAdvancedParam::DtmfMode,
212            SipAdvancedParam::ReceiveJitterBufferMin,
213            SipAdvancedParam::ReceiveJitterBufferMax,
214            SipAdvancedParam::SipWebPassword,
215            SipAdvancedParam::SipAccountRegister,
216            SipAdvancedParam::SipAccountUsername,
217            SipAdvancedParam::SipAccountPassword,
218            SipAdvancedParam::SipAccountDomain,
219            SipAdvancedParam::SipAccountProxyAddress,
220            SipAdvancedParam::SipAccountTransport,
221            SipAdvancedParam::SipNatTraversalMode,
222            SipAdvancedParam::SipNatTraversalServer,
223            SipAdvancedParam::SipNatTraversalUsername,
224            SipAdvancedParam::SipNatTraversalPassword,
225            SipAdvancedParam::SipUnitName,
226            SipAdvancedParam::SipAccountAuthUsername,
227            SipAdvancedParam::RodeCallQuality,
228        ];
229        for p in params {
230            assert_eq!(SipAdvancedParam::from_name(p.as_str()), p);
231            assert!(p.is_known());
232        }
233    }
234
235    #[test]
236    fn sip_advanced_param_preserves_firmware_casing() {
237        // Firmware uses HTTPS / RFC / NAT / HTTPS in wire names; preserved verbatim.
238        assert_eq!(
239            SipAdvancedParam::EnableRFCDuplication.as_str(),
240            "enableRFCDuplication"
241        );
242        assert_eq!(
243            SipAdvancedParam::NonHTTPSInterface.as_str(),
244            "nonHTTPSInterface"
245        );
246        assert_eq!(
247            SipAdvancedParam::SipNatTraversalMode.as_str(),
248            "sipNATTraversalMode"
249        );
250    }
251}