[Users] AVP subst callerid example

Norman Brandinger norm at goes.com
Thu Jun 30 16:26:29 CEST 2005


At the risk of being flamed by the developers that argue messing with 
SIP headers can break interoperability, cause parse problems, is a bad 
programming practice, etc, etc. I'm posting a little example of using an 
AVP to set the callerid of a user. 

Disclaimer: I'm not suggesting this is what anyone should or should not 
do, I'm just showing an interesting example.

In the usr_preferences table, there is the following row:

Username: user1
Attribute: callerid
Value: "My Name" <sip:19995551212 at example.com

Note that the ending > after .com in the value column is missing on 
purpose.  I haven't spent the time tweaking the regular expression below 
to enable the trailing > to be included.

  
#-------------------------------------------------------------------------------------------
  # Set the callerid for the user from an AVP
  
#-------------------------------------------------------------------------------------------
    if (avp_db_load("$from/username", "s:callerid")) {
        subst('/^From: (.*)>(.*)$/From: $avp(callerid)>\2/ig');
    };

Some things to consider would be to use one subst to change the "name" 
and another subst to change the "number".  Obviously, two AVPs would be 
needed to implement this.

Regards,
Norman Brandinger
norm at goes dot com







More information about the sr-users mailing list