[Serusers] Blocking the caller ID

SIP sip at arcdiv.com
Thu Jul 19 12:20:44 CEST 2007


We do this using two different tables and two different kinds of checks 
in the SER.cfg

Keep in mind, this code is all SER 0.9.6 specific. There may be easier 
ways to do this in SER 2.0

For the sake of making things less messy (the idea of storing EVERY 
check in one usr_preferences table for ALL functions in SER is an ugly 
use of the database), we have a callblock table that stores per-user 
blocked numbers via the web interface or a phone keypad entry scheme. It 
has the same format as the usr_preferences table:

+-----------+--------------+------+-----+-------------------+-------+
| Field     | Type         | Null | Key | Default           | Extra |
+-----------+--------------+------+-----+-------------------+-------+
| uuid      | varchar(64)  | NO   |     |                   |       |
| username  | varchar(100) | NO   |     | 0                 |       |
| domain    | varchar(128) | NO   |     |                   |       |
| attribute | varchar(32)  | NO   |     |                   |       |
| value     | varchar(128) | NO   |     |                   |       |
| type      | int(11)      | NO   |     | 0                 |       |
| modified  | timestamp    | NO   |     | CURRENT_TIMESTAMP |       |
+-----------+--------------+------+-----+-------------------+-------+

Into the attribute column goes the attribute 'callblock' and into the 
value goes the URI you wish to block.

Then, in the code, some sort of check like:
if(avp_db_load("$ruri/username","s:callblock/callblock")
)
                        {
                                if(avp_check("s:callblock","eq/$from/gi"))
                                {
                                        log(1, "CallblkVM\n");
                                        sl_send_reply("603", "Call denied");
                                        break;
                                };
                        };



For blocking ALL numbers instead of a per-user numbering scheme, we 
another separate table that looks like usr_preferences; however, an 
entry for that table might look like:

insert into blocked_numbers(username,domain,attribute,value,modified) 
values('6667778888','local.domain','block','Blocked',now());

This stores the number to block as the username instead of as a URI int 
he value column. This makes the check in the SER.cfg code a little easier:

if(avp_db_load("$to/username", "s:block/blocked_numbers"))
                {
                        sl_send_reply("603", "Number is blocked");
                        break;
                };

Place that near the top of your invite block and all calls to 666 777 
8888 from ANY user will be blocked.


N.



Jai Rangi wrote:
> Hello All,
>
> Does any one know what module can be used to block calls from some 
> particular phone numbers. I want to store those numbers in the 
> database. I am looking for these possibilities,
>
> 1. We want to block all the calls from some phone number 666 777 8888
>
> 2. One of the user agent wants to block the call from some phone 
> number 444 444 4444.
>
>
> Thank you,
> -Jai
> ------------------------------------------------------------------------
>
> _______________________________________________
> Serusers mailing list
> Serusers at lists.iptel.org
> http://lists.iptel.org/mailman/listinfo/serusers
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20070719/e25e67dd/attachment.htm>


More information about the sr-users mailing list