drouting a 302 response

Anonymous
2012-03-19
2013-05-09

  • Anonymous
    2012-03-19

    Using dynamic routing to process initial INVITE, calls are sent to a gateway based on dr_rules.  In cases when the gateway responds with a 302, we would like to re-query the dr_rules and select a gateway (list) based on the contact header in the 302.

    For example an incoming call to opensips (8.19.33.2):

    PSTN_GW1  ->  Opensips  ->  TERM_GW1

    1.  INVITE sip:12125551212@8.19.33.2;user=phone SIP/2.0

    ruleid     groupid     prefix                 timerec        priority     routeid     gwlist     attrs     description   
    ------  -------       ------               -------       -------    -------   ------  -----  ---------
    1            0                12125551212                        0                                1                                  

    2.  Contact: sip:2006#13106507070@8.19.33.2

    ruleid     groupid     prefix                 timerec        priority     routeid     gwlist     attrs     description   
    ------  -------       ------               -------       -------    -------   ------  -----  --------- 
    2            1                2006#12125551212            0                                2      

    Effectively, the initial invite is processed by as group 1, with the 302 being processed as group 2.  The goal, is the ability to add additional dr_rules pointing to additional dr_gateways without having to edit the opensips.cfg file and restart the service. 

    There are a few pieces to this that still have to be worked out:

    1).  Assign dr_groupid based on originating IP.  Right now, I am trying to get my arms around avp_db_query to handle this since that seems to be the best way to map IP address to Group ID in the db.

    2).  The failure route for the first drouting attempt would be to handle the 302, whereas the failure route for the second drouting attempt would actually terminate the call.  Otherwise, a failure would continuously loop through the script.

    3).  sethostport of the target gw using the IP contained in the drouting response.

    For now, is it possible to invoke the do_routing process on the 302 response?

    Thanks.