[Users] lcr gw strip and prefix

Steve Blair blairs at isc.upenn.edu
Tue Sep 19 01:01:31 CEST 2006


Alan:

  Would it be possible in your config file to use regular expressions to 
classify the number as a specific area code or range of area codes (such 
as 212) or as an international call then strip the appropriate number of 
digits based on the classification? If so then the next step would 
probably be to add the correct prefix to the lcr gateway table.

-Steve

Alan Crosswell wrote:

>Does anybody have samples of using LCR strip and prefix?  I've tried
>configuring it for an ITSP that wants US numbers to be 10-digits and
>international calls to be prefixed with 011.  I keep these numbers in
>E.164 format, so, for example:
>
>+12128543754 should have the ruri rewritten to: 2128543754
>and +44123456789 should become 01144123456789
>
>Here are relevant portions of my lcr tables:
>
>lcr routes
>+--------------+----------+--------+----------+
>| prefix       | from_uri | grp_id | priority |
>+--------------+----------+--------+----------+
>| +1__________ | %        |      5 |       10 |
>| +1__________ | %        |      7 |       20 |
>| +__          | %        |      8 |       20 |
>| +__          | %        |      6 |       10 |
>
>lcr gateways (edited to fit and hide details:-)
>+-----------+---------+------+-----+-----+--------+-------+--------+
>| gw_name   | ip      | port | uri_| tran| grp_id | strip | prefix |
>+-----------+---------+------------+-----+--------+-------+--------+
>| prov1-us  | x.x.x.x | 5060 |   1 |   1 |      5 |     2 |        |
>| prov1-int | x.x.x.x | 5060 |   1 |   1 |      6 |     1 | 011    |
>| voip1-int | y.y.y.y | 5060 |   1 |   1 |      7 |     1 | 011    |
>| voip1-us  | y.y.y.y | 5060 |   1 |   1 |      8 |     2 |        |
>
>openser.cfg snippet (our internal dialplan has 93 for outside line):
>
>    xlog("L_INFO","route[4]: SIP-to-PSTN call from <$fu> to <$tu>
>routed\n");
>    if (uri=~"^sip:931") {
>        subst_user('/^931/+1/');                  # rewrite to E.164
>        subst('/^(To:[^0-9]*)931(.*)$/\1+1\2/');  # rewrite to E.164
>    }
>    if (uri=~"^sip:93011") {
>        subst_user('/^93011/+/');                 # rewrite to E.164
>        subst('/^(To:[^0-9]*)93011(.*)$/\1+\2/'); # rewrite to E.164
>    }
>    xlog("L_INFO","route[4]: SIP-to-PSTN r-uri is now <$ru>\n");
>    # rewrite callee's 5-digit extensions to  +121285.....
>    if !((isflagset(6) && !isflagset(4)) || isflagset(5)) {
>        subst('/^(From:.*<sip:)([134][0-9]{4}@)/\1+121285\2/');
>        subst('/^(Remote-Party-ID:.*<sip:)([134][0-9]{4}@)/\1+121285\2/');
>    }
>    t_on_failure("4");          # if gateway unavail go to 4
>    if (!next_gw()) {
>        sl_send_reply("503", "Service not available - No gateways");
>        return;
>    };
>    xlog("L_INFO","route[4]: SIP-to-PSTN after next_gw() r-uri is now
><$ru>\n");
>    # Cookbook does a forward.  I think we do a stateful t_relay which
>will handle
>    # e.g. TCP/UDP or v6->v4 conversion as needed.
>    if (isflagset(18))
>    {  #call fwd enabled
>            append_branch();
>    }
>    if (!t_relay()) {
>        sl_reply_error();
>    };
>    xlog("L_INFO","Fell through route[4]: $si: $rm From <$fu> To <$tu>\n");
>} # end of route[4]
>
>The observed behavior is that the host part gets rewritten correctly (to
>x.x.x.x) but the user part does not get stripped and/or prefixed.
>
>Any help would be appreciated.
>
>/a
>
>_______________________________________________
>Users mailing list
>Users at openser.org
>http://openser.org/cgi-bin/mailman/listinfo/users
>
>  
>




More information about the sr-users mailing list