Skip to content

UAC REDIRECT module

UAC REDIRECT - User Agent Client redirection - module enhance OpenSIPS with the functionality of being able to handle (interpret, filter, log and follow) redirect responses ( 3xx replies class).

UAC REDIRECT module offer stateful processing, gathering the contacts from all 3xx branches of a call.

The module provide a powerful mechanism for selecting and filtering the contacts to be used for the new redirect:

  • number based - limits like the number of total contacts to be used or the maximum number of contacts per branch to be selected.
  • Regular Expression based - combinations of deny and accept filters allow a strict control of the contacts to be used for redirection.

When selecting from a 3xx branch the contacts to be used, the contacts will be ordered and prioritized based on the “q” value.

The following modules must be loaded before this module:

  • TM - Transaction Module, for accessing replies.
  • ACC - Accounting Module, but only if the logging feature is used.

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • None

The default behavior in filtering contacts. It may be “accept” or “deny”.

The default value is “accept”.

Set default_filter module parameter
...
modparam("uac_redirect","default_filter","deny")
...

The regular expression for default deny filtering. It make sens to be defined on only if the default_filter parameter is set to “accept”. All contacts matching the deny_filter will be rejected; the rest of them will be accepted for redirection.

The parameter may be defined only one - multiple definition will overwrite the previous definitions. If more regular expression need to be defined, use the set_deny_filter() scripting function.

This parameter is optional, it’s default value being NULL.

Set deny_filter module parameter
...
modparam("uac_redirect","deny_filter",".*@siphub\.net")
...

The regular expression for default accept filtering. It make sens to be defined on only if the default_filter parameter is set to “deny”. All contacts matching the accept_filter will be accepted; the rest of them will be rejected for redirection.

The parameter may be defined only one - multiple definition will overwrite the previous definitions. If more regular expression need to be defined, use the set_accept_filter() scripting function.

This parameter is optional, it’s default value being NULL.

Set accept_filter module parameter
...
modparam("uac_redirect","accept_filter",".*@siphub\.net")
...

Sets additional deny filters. Maximum 6 may be combined. This additional filter will apply only to the current message - it will not have a global effect.

Parameters:

  • filter (string) - regular expression

  • flags (string) Default or previous added deny filter may be reset depending of the parameter value:

    • reset_all - reset both default and previous added deny filters;
    • reset_default - reset only the default deny filter;
    • reset_added - reset only the previous added deny filters;
    • empty - no reset, just add the filter.

This function can be used from FAILURE_ROUTE.

set_deny_filter usage
...
set_deny_filter(".*@domain2.net","reset_all");
set_deny_filter(".*@domain1.net","");
...

Sets additional accept filters. Maximum 6 may be combined. This additional filter will apply only to the current message - it will not have a global effect.

Parameters:

  • filter (string) - regular expression

  • flags (string) Default or previous added deny filter may be reset depending of the parameter value:

    • reset_all - reset both default and previous added accept filters;
    • reset_default - reset only the default accept filter;
    • reset_added - reset only the previous added accept filters;
    • empty - no reset, just add the filter.

This function can be used from FAILURE_ROUTE.

set_accept_filter usage
...
set_accept_filter(".*@domain2.net","reset_added");
set_accept_filter(".*@domain1.net","");
...

The function may be called only from failure routes. It will extract the contacts from all 3xx branches and append them as new branches. Note that the function will not forward the new branches, this must be done explicitly from script.

How many contacts (in total and per branch) are selected depends on the max_total and max_branch parameters:

  • max_total (int, optional) - max overall number of contacts to be selected
  • max_branch (int, optional) - max number of contacts per branch to be selected

Both “max_total” and “max_branch” default to 0 (unlimited).

This function can be used from FAILURE_ROUTE.

get_redirects usage
...
# no restrictions
get_redirects();
...
# no limits per branch, but not more than 6 overall contacts
get_redirects(6);
...
# max 2 contacts per branch, but no overall limit
get_redirects(, 2);
...
Redirection script example
loadmodule "modules/sl/sl.so"
loadmodule "modules/usrloc/usrloc.so"
loadmodule "modules/registrar/registrar.so"
loadmodule "modules/tm/tm.so"
loadmodule "modules/acc/acc.so"
loadmodule "modules/uac_redirect/uac_redirect.so"
modparam("usrloc", "working_mode_preset", "single-instance-no-db")
route{
if (is_myself("$rd")) {
if ($rm=="REGISTER") {
save("location");
exit;
};
if (!lookup("location")) {
sl_send_reply(404, "Not Found");
exit;
};
}
t_on_failure("do_redirect");
if (!t_relay()) {
sl_reply_error();
};
}
failure_route[do_redirect] {
if (get_redirects(3, 1))
t_relay();
}

Top contributors by DevScore(1), authored commits(2) and lines added/removed(3)

#NameDevScoreCommitsLines++Lines—
1.Bogdan-Andrei Iancu (@bogdan-iancu)51321765191
2.Liviu Chircu (@liviuchircu)1810116382
3.Daniel-Constantin Mierla (@miconda)12102420
4.Razvan Crainea (@razvancrainea)1081413
5.Stefan Darius (@dariusstefan)10437463
6.Rob Gagnon (@rgagnon24)865553
7.Henning Westerholt (@henningw)751211
8.Vlad Patrascu (@rvlad-patrascu)536950
9.Maksym Sobolyev (@sobomax)4234
10.Anca Vamanu313055

All remaining contributors: Konstantin Bokarius, Peter Lemenkov (@lemenkov), Walter Doekes (@wdoekes), Andreas Granig, Edson Gellert Schubert, Elena-Ramona Modroiu.

(1) DevScore = author_commits + author_lines_added / (project_lines_added / project_commits) + author_lines_deleted / (project_lines_deleted / project_commits)

(2) including any documentation-related commits, excluding merge commits

(3) ignoring whitespace edits, renamed files and auto-generated files

#NameCommit Activity
1.Bogdan-Andrei Iancu (@bogdan-iancu)Jun 2005 - Jul 2026
2.Stefan Darius (@dariusstefan)Jun 2026 - Jul 2026
3.Razvan Crainea (@razvancrainea)Feb 2012 - Jun 2026
4.Maksym Sobolyev (@sobomax)Feb 2023 - Feb 2023
5.Vlad Patrascu (@rvlad-patrascu)May 2017 - Apr 2019
6.Liviu Chircu (@liviuchircu)Mar 2014 - Apr 2019
7.Peter Lemenkov (@lemenkov)Jun 2018 - Jun 2018
8.Rob Gagnon (@rgagnon24)Mar 2015 - Mar 2015
9.Walter Doekes (@wdoekes)May 2014 - May 2014
10.Daniel-Constantin Mierla (@miconda)Nov 2006 - Mar 2008

All remaining contributors: Konstantin Bokarius, Edson Gellert Schubert, Henning Westerholt (@henningw), Anca Vamanu, Andreas Granig, Elena-Ramona Modroiu.

(1) including any documentation-related commits, excluding merge commits

Last edited by: Razvan Crainea (@razvancrainea), Bogdan-Andrei Iancu (@bogdan-iancu), Vlad Patrascu (@rvlad-patrascu), Liviu Chircu (@liviuchircu), Peter Lemenkov (@lemenkov), Rob Gagnon (@rgagnon24), Daniel-Constantin Mierla (@miconda), Konstantin Bokarius, Edson Gellert Schubert, Henning Westerholt (@henningw).

All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0