@@ -115,7 +115,7 @@ alice@example presence bob@example watcher@example
115115```
116116
117117
118- - The watcher subscribes the "Event: dialog" of Bob .
118+ - The watcher subscribes to Bob's "call-info" event .
119119- Alice calls Bob.
120120- The publisher is publishing the "alerting" state for Bob.
121121- PUBLISH is received and handled by presence module.
@@ -157,10 +157,10 @@ To trigger the internal publishing (from the dialog module) for a
157157certain call, use the "sca_engage()" function from the script when
158158handling the initial INVITE. It creates the dialog and publishes the
159159state of the caller's line, of the callee's line, or of both. For
160- outbound calls, "sca_validate_invite_out()" checks that the caller
161- has seized its line first . Per branch, "sca_set_called_line()" changes
162- the callee's line and "sca_mute_branch()" stops publishing it - see
163- the below documentation.
160+ outbound calls, "sca_validate_invite_out()" checks for a recorded seizure
161+ on the caller's requested appearance index . Per branch,
162+ "sca_set_called_line()" changes the callee's line and "sca_mute_branch()"
163+ stops publishing it - see the below documentation.
164164
165165
166166LIMITATIONS : in this mode, the module does not really check if the
@@ -171,6 +171,57 @@ a line becomes known with the first "line-seize" SUBSCRIBE for it,
171171and no "call-info" is published for a line that is not known.
172172
173173
174+ #### Internal publishing example
175+
176+
177+ The following routing fragment handles initial INVITEs to a shared line. Call
178+ ` route(sca_inbound) ` after authentication and access control, before resolving
179+ the called line to its registered contacts. It assumes that the line is already
180+ known from a previous line-seize subscription, and that the configuration loads
181+ the registrar/usrloc, rr, sl, and signaling modules in addition to the dependencies
182+ below. Handle SUBSCRIBE requests with ` handle_subscribe() ` and route in-dialog
183+ requests with ` loose_route() ` in the main request route.
184+
185+
186+ ``` opensips title="Inbound SCA with per-branch publishing"
187+ route[sca_inbound] {
188+ # Save the shared line before lookup rewrites the R-URI to a contact.
189+ $var(sca_line) = $ru;
190+ if (!sca_engage("B")) {
191+ send_reply(500, "Cannot Enable SCA");
192+ exit;
193+ }
194+ record_route();
195+ t_on_branch("sca_publish");
196+
197+ if (!lookup("location")) {
198+ send_reply(404, "No Registered Contact");
199+ exit;
200+ }
201+ if (!t_relay()) {
202+ sl_reply_error();
203+ }
204+ exit;
205+ }
206+
207+ branch_route[sca_publish] {
208+ # Example policy: do not publish the callee on a voicemail branch.
209+ if ($rU == "voicemail") {
210+ sca_mute_branch("B");
211+ } else {
212+ sca_set_called_line($var(sca_line));
213+ }
214+ }
215+ ```
216+
217+
218+ Only the callee's line is published here. For an outbound call from a shared
219+ line, use ` sca_engage("A") ` ; use ` sca_engage("AB") ` when both parties are shared
220+ lines. Both forms include caller-side validation, so handle a negative return
221+ value before relaying the INVITE. A separate ` sca_validate_invite_out() ` call is
222+ only needed if the script needs to check the caller before engaging publishing.
223+
224+
174225### Dependencies
175226
176227
@@ -181,7 +232,9 @@ The following modules must be loaded before this module:
181232
182233
183234- * presence* .
184- - * dialog* .
235+ - * tm* .
236+ - * dialog* - required only for internal publishing
237+ (` disable_dialog_support_for_sca=0 ` ).
185238
186239
187240#### External Libraries or Applications
@@ -271,9 +324,10 @@ modparam("presence_callinfo", "line_hash_size", 128)
271324#### caller_spec_param (string)
272325
273326
274- A variable holding the caller's line, as a SIP URI. When the variable
275- is set, "sca_engage()" and "sca_validate_invite_out()" use it instead of
276- the From URI of the INVITE.
327+ A variable holding the caller's line, as a SIP URI. When the variable has a
328+ string value, "sca_engage()" and "sca_validate_invite_out()" use it instead of
329+ the From URI of the INVITE. An unset or non-string value falls back to the From
330+ URI; an empty or malformed string is not a valid override and causes an error.
277331
278332
279333* Default value is "NULL"* (the From URI is used).
@@ -290,8 +344,12 @@ modparam("presence_callinfo", "caller_spec_param", "$var(sca_caller)")
290344#### callee_spec_param (string)
291345
292346
293- A variable holding the callee's line, as a SIP URI. When the variable
294- is set, "sca_engage()" uses it instead of the R-URI of the INVITE.
347+ A variable holding the callee's line, as a SIP URI. When the variable has a
348+ string value, "sca_engage()" uses it instead of the R-URI of the INVITE. An
349+ unset or non-string value falls back to the R-URI; an empty or malformed string
350+ is not a valid override and causes an error. The value is captured when
351+ "sca_engage()" first registers the publishing callbacks; use
352+ "sca_set_called_line()" for subsequent per-branch changes.
295353
296354
297355* Default value is "NULL"* (the R-URI is used).
@@ -312,7 +370,13 @@ The log level of the module's SCA trace messages. It can be changed at
312370runtime with the * presence_callinfo: set_log_level * MI command.
313371
314372
315- * Default value is "-3"* (L_ALERT - always printed).
373+ * Default value is "-3"* (L_ALERT).
374+
375+
376+ These messages are subject to the core log level. For example, setting this
377+ parameter to 4 (L_DBG) only prints SCA trace messages when the core log level
378+ also permits debug messages. Other module errors and debug messages keep
379+ their own log levels.
316380
317381
318382``` opensips title="Set log_level parameter"
@@ -331,20 +395,31 @@ modparam("presence_callinfo", "log_level", 4)
331395
332396The function (to be used only in internal publishing mode) checks an
333397outbound call from a shared line: the INVITE must carry a Call-Info
334- header with an "appearance-index", and the caller's line (the From URI,
335- or "caller_spec_param") must be seized for that index.
398+ header with a nonzero "appearance-index", and the caller's line (the From URI,
399+ or "caller_spec_param") must have a recorded seizure for that index.
400+
401+
402+ This checks recorded seizure information, not whether its expiry is still in
403+ the future or whether the INVITE sender owns the line-seize subscription. It
404+ does not replace authentication or access control in the routing script.
336405
337406
338- It returns 1 if the call is valid, otherwise:
407+ It returns 1 when the check succeeds, or for a non-INVITE request without
408+ performing the check. Negative return codes are:
339409
340410
411+ - * -1* - internal publishing is disabled, the caller override cannot be parsed,
412+ or an internal error occurs;
341413- * -2* - the line is not known to the module;
342- - * -3* - the line is not seized;
343- - * -4* - the line is seized for a different index;
414+ - * -3* - no seizure is recorded for the requested appearance index;
344415- * -5* - missing or bogus Call-Info header;
345416- * -6* - no index in the Call-Info header.
346417
347418
419+ Return code -4 (a seizure on a different index) is no longer used: seizures on
420+ other indexes are independent and do not satisfy the check for this index.
421+
422+
348423This function can be used from REQUEST_ROUTE.
349424
350425
@@ -374,9 +449,19 @@ the call on the lines given by *parties*:
374449line set for the branch by "sca_set_called_line()".
375450
376451
377- If the parameter is missing, both lines are published. With * A* , the
378- call is first checked as by "sca_validate_invite_out()", and its error
379- code is returned if the check fails.
452+ The flags are uppercase and may be combined as * AB* . If the parameter is
453+ missing or empty, both lines are selected. Unsupported characters are logged
454+ and ignored; if no recognized flag remains, both lines are selected.
455+
456+
457+ Whenever * A* is selected, including by default, the caller is checked as by
458+ "sca_validate_invite_out()". Use * B* for an inbound call whose caller does not
459+ have a shared line and a recorded seizure.
460+
461+
462+ The function returns 1 on success, or for a non-INVITE request without enabling
463+ publishing. It returns -1 if internal publishing is disabled or setup fails,
464+ and propagates the caller-validation error codes when * A* is selected.
380465
381466
382467This function can be used from REQUEST_ROUTE.
@@ -396,14 +481,22 @@ This function can be used from REQUEST_ROUTE.
396481
397482
398483The function (to be used only in internal publishing mode) sets the
399- callee's line for the current branch, overriding the R-URI. The value
400- must be a SIP URI ! Variables are accepted. An empty string drops a
401- line set before for the branch.
484+ callee's line for the current branch, overriding the callee identity captured
485+ by "sca_engage()". The value must be a SIP URI; variables are accepted. An empty
486+ string removes a previous branch override and restores the captured identity:
487+ "callee_spec_param", if it had a string value, otherwise the R-URI at the time
488+ the publishing callbacks were registered. It does not re-read the branch's
489+ current R-URI.
402490
403491
404492The dialog must already exist, so call "sca_engage()" first.
405493
406494
495+ The function returns 1 on success, or for a non-INVITE request without changing
496+ the line. It returns -1 if internal publishing is disabled, no dialog exists,
497+ the line cannot be parsed, or an internal error occurs.
498+
499+
407500This function can be used from REQUEST_ROUTE and BRANCH_ROUTE.
408501
409502
@@ -424,12 +517,22 @@ publishing for the callee's line on the current branch. Only *B* has
424517an effect; * A* is accepted, but the caller's line is still published.
425518
426519
520+ The flags use the same uppercase * A* , * B* , and * AB* syntax as "sca_engage()".
521+ An empty string, or a string with no recognized flags, selects both parties;
522+ currently this still only mutes the callee. To disable caller publishing,
523+ select only * B* when calling "sca_engage()".
524+
525+
427526The dialog must already exist, so call "sca_engage()" first.
428527
429528
430529This function can be used from BRANCH_ROUTE.
431530
432531
532+ It returns 1 when the branch mute settings are stored, or -1 if no dialog
533+ exists or the settings cannot be stored.
534+
535+
433536``` opensips title="sca_mute_branch() usage"
434537...
435538branch_route[sca] {
0 commit comments