drouting: redirect calls, from direction

  • dpinedo

    dpinedo - 2012-07-16


    I'd like to redirect incoming calls in function of the caller direction.
    I invoque a route as:
    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@ |     0 | NULL       | NULL  |          0 | Prism Server #1 |

    But when I call from a SIP phone (4001@  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"@""
    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
    "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?

  • Bogdan-Andrei Iancu

    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)


  • 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
    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?