A few examples on how to use the UAC module are listed below.
In providing SIP services, allowing Anonymous User ID (intra-domain or inter-domain) may be a useful feature.
Based on different criteria - like groups as shown in this example - the identity of some users can be hidden when placing calls.
The script will look like:
Example 8. Anonymous ID example
... modparam("uac","from_restore_mode", 1) #auto ... route { ... # is it a call? if (method=="INVITE"||method=="ACK"||method=="CANCEL"||method=="BYE") { # is the user in anonymous group? if (is_user_in("from","anonymous")) { uac_replace_from("Anonymous","sip:[email protected]"); } } ... } ...
Many SIP platforms relay calls to SIP-to-PSTN third party gateways which require SIP authentication.
The example show how calls from all local users are forwarded and authenticated against the PSTN gateway. The PSTN terminator provides with one username and password for authentication.
The script will look like:
Example 9. Restricting access example
... #define the credential modparam("uac","credential","gw_user:gw_realm:gw_passwd") ..... route { ..... # set failure route for authentication t_on_failure("3") # reset flag to mark no authentication yet performed resetflag(7); # forward to PSTN t_relay_to_udp("GW_IP","GW_PORT"); .... } failure_route[3] { # authentication reply received? if ( t_check_status("401|407") ) { # have we already tried to authenticate? if (isflagset(7)) { t_reply("503","Authentication failed"); break; } if (uac_auth()) { # mark that auth was performed setflag(7); # trigger again the failure route t_on_failure("3"); # repeat the request with auth response this time append_branch(); t_relay(); } } } ...