– Kamailio SIP Server –

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

examples:set-blind-call-forwarding [2006/10/20 02:00] (current)
Line 1: Line 1:
 +====== Manage blind call forwarding from a SIP device ======
  
 +
 +The following example shows how to "​setup"​ and "​stop"​ blind call forwarding from a SIP device.
 +
 +This example assumes that only authorized users are allowed to turn on or turn off blind call forwarding. ​ The example also checks for and rejects recursive blinc call forwarding (attempts to blindly call forward to the same number the caller is using).
 +
 +This example DOES NOT implement the call forwarding function. ​ It just dynamically sets an AVP called fwd_blind. ​ There must be additional logic placed in the configuration file to actually implement the call forwarding function when an INVITE to the caller'​s number takes place.
 +
 +The "​xlog"​ statements are just reminders that you will probably want to send an audio clip to the caller letting him/her know the status of the blind call forwarding operation.
 +
 +As an exercise, this example can be expanded to offer the end user the ability to just enter *21 and then be presented with a voice prompt to enter the number that calls will be forwarded to.
 +
 +Another exercise would be to offer the caller the ability to change the "call forward on no answer"​ and "call forward on busy" settings.
 +
 +Regards,
 +Norm
 +
 +<​code>​
 +  #​---------------------------------------------------------------------------
 +  # Setup BLIND CALL FORWARD BLIND (ACL=fwd_blind) (AVP=fwd_blind)
 +  # *21 + NPA + NXX + NNNN
 +  #​---------------------------------------------------------------------------
 +  if (uri=~"​^sip:​\*21[2-9][0-9]{9}@"​) {
 +    if (is_user_in("​From",​ "​fwd_blind"​)) {
 +      strip(3);
 +      avp_write("​$ruri",​ "​s:​fwd_blind"​);​
 +      # Check for (and reject) attempts to perform recursive blind call forwarding
 +      if (!avp_check("​s:​fwd_blind",​ "​eq/​$from/​i"​)) {
 +        avp_db_delete("​$from/​username","​s:​fwd_blind"​);​
 +        avp_db_store("​$from/​username","​s:​fwd_blind"​);​
 +        xlog("​L_NOTICE",​ "blind call forwarding setup audio clip"​);​
 +      } else {
 +        xlog("​L_NOTICE",​ "​recursive blind call forwarding not allowed audio clip"​);​
 +      };
 +    } else {
 +      xlog("​L_NOTICE",​ "blind call forwarding not authorized audio clip"​);​
 +    };
 +    exit;
 +  };
 +
 +
 +  #​---------------------------------------------------------------------------
 +  # Stop BLIND CALL FORWARD(ACL=fwd_blind) (AVP=fwd_blind)
 +  # *22
 +  #​---------------------------------------------------------------------------
 +  if (uri=~"​^sip:​\*22@"​) {
 +    if (is_user_in("​From",​ "​fwd_blind"​)) {
 +      avp_db_delete("​$from/​username","​s:​fwd_blind"​);​
 +      xlog("​L_NOTICE",​ "blind call forwarding stopped audio clip"​);​
 +    } else {
 +      xlog("​L_NOTICE",​ "blind call forwarding stop not authorized audio clip"​);​
 +    };
 +    exit;
 +  };
 +</​code>​