drouting: redirect calls, from direction

dpinedo
2012-07-16
2013-05-09
  • dpinedo
    dpinedo
    2012-07-16

    Hello,

    I'd like to redirect incoming calls in function of the caller direction.
    I invoque a route as:
    route{
    if (!do_routing()) {
    xlog("no routing\n");
    }
    }
    That shoul look for a matching in dr_groups based in the callers user URI, isn't it?

    In my dr_groups table I have:
    | id | username | domain | groupid | description |
    |  1 | 4001     | .*     |       0 | Everyone |

    Can I use regular expressions and non numerical characters in username? In case I can use regular expresions: Which kind of regular expressions?

    In my dr_rules I have:
    | ruleid | groupid | prefix | timerec | priority | routeid | gwlist | attrs | description  |
    |      1 | 0       |        |         |        0 | NULL    | 1      | NULL  | International Calls |
    I have read that I can only use number in the "prefix" field, is that true? Can I use regular expressions?

    And in my dr_gateways I have:
    | id | gwid | type | address         | strip | pri_prefix | attrs | probe_mode | description        |
    |  1 | 1    |    1 | usera@89.1.44.2 |     0 | NULL       | NULL  |          0 | Prism Server #1 |

    But when I call from a SIP phone (4001@10.0.0.22)  to another user I get the following error logs, and the call is not redirected:

    Jul 16 13:33:11 localhost /usr/sbin/opensips: calling route3
    Jul 16 13:33:11 localhost /usr/sbin/opensips: ERROR:drouting:get_group_id: no group for user "4001"@"89.1.23.212"
    Jul 16 13:33:11 localhost /usr/sbin/opensips: ERROR:drouting:do_routing: failed to get group id
    Jul 16 13:33:11 localhost /usr/sbin/opensips: no routing

    I don't know what I'm doing wrong. Any idea?

     
  • dpinedo
    dpinedo
    2012-07-16

    I have seen that I can only use numerical prefixes in dr_rules.

    I have seen also that I don't need to define a new row in the dr_groups to invoke a new redirection. I can invoke
    do_route("my_group_id");
    "my_group_id" is what I have in the field "groupid" in dr_rules table.

    But what I need to know is: How to define "dr_groups" fields to use "do_routing()" (instead of do_routing("route_id")) and so OpenSIPS can choose the rule in function of the user who calls?

     
  • As per documentation, if you do not provide a group parameter do do_routing(), it will query the dr_group table for the caller (user + domain) - note that the key to search in that table is user and domain of caller - if you want to have only the username part, set the "use_domain" to 0 (see http://www.opensips.org/html/docs/modules/1.8.x/drouting.html#id293395)

    Regards,
    Bogdan

     
  • dpinedo
    dpinedo
    2012-09-03

    OK, thanks for your help,

    Now when I do the redirect I can observe in the redirected machine (the redirection is OK) that there is no info about the redirected direction in the SIP headers. I can add it using
    add_rr_param(";redirection=usera@89.1.44.2");
    but I don't know how to obtain this information dinamically (as a result of the do_routing())

    1) There is any way to send the redirected information without usint add_rr_param ?
    2) If it's not possible how can I obtain the redirection URI dinamically?

    Regards