[Users] Re: lcr gw strip and prefix

Alan Crosswell alan at columbia.edu
Wed Sep 20 02:37:17 CEST 2006


(sheepishly) never mind.

I was editing the r-uri *after* calling load_gws() so the prefix match 
had already been done.  Strip/prefix working just fine!

Further explanation:

Dial plan for an international call here for example is:
93,011ccxxxx... which I canonicalize as +ccxxxx... (E.164).  My carrier 
wants to see 011ccxxxx... so in my gw entry I have strip 1 (to remove 
the +) and prefix 011 to insert the 011.

I was calling load_gws() *before* canonicalizing to E.164 format.  So 
the prefix match was hitting some other random row!
/a

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




More information about the sr-users mailing list