– Kamailio SIP Server –

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
examples:caller-callee-same-group [2011/08/19 09:01]
92.112.119.221
examples:caller-callee-same-group [2012/03/22 13:33] (current)
80.250.1.245 removed spam
Line 1: Line 1:
 +====== Determine if both the caller and the callee are in the same group ======
 +
 +
 +How to use Attribute Value Pairs (AVP'​s) to determine if both the caller and the callee are in the same group?
 +
 +A real world example would be to limit friends to only calling friends that are in the same group of friends.
 +
 +1) Create two entries in the usr_preferences table.
 +
 +One entry is associated with the caller and the other is associated with the callee.
 +Both entries use "​friend"​ as the attribute and "​groupa"​ as the value.
 +
 +2) Add the following AVP alias definition:
 +
 +<​code>​
 +modparam("​avpops","​avp_aliases",​ "​temp=i:​59;​......)
 +</​code>​
 +
 +3) Add the following code to the INVITE section of your configuration:​
 +
 +<​code>​
 +avp_db_load("​$from/​username",​ "​s:​friend"​);​
 +avp_copy("​s:​friend",​ "​$temp"​);​\\
 +avp_db_load("​$ruri/​username",​ "​s:​friend"​);​
 +
 +# xlog("​L_NOTICE",​ "​friend avp: ($avp(s:​friend))\n"​);​
 +# xlog("​L_NOTICE",​ "temp avp: ($avp(i:​59))\n"​);​
 +
 +if (avp_check("​s:​friend",​ "​eq/​$temp"​) ) {
 +  xlog("​L_NOTICE",​ "​friend avp: ($avp(s:​friend))\n"​);​
 +  xlog("​L_NOTICE",​ "temp avp: ($avp(i:​59))\n"​);​
 +};
 +</​code>​