Thank you Daniel,

I tried different combination but still have problem:
kamctl dialplan addrule \\ 10 100 1 ^123+ 0 '^(123)(.+)' \2
ERROR: dialplan - unexpected 100 for operating matching. Use 'equal' or 'regexp'!

I proceed with PHPMyAdmin and was able to insert values directly to db:

 kamctl dialplan show
dialplan tables
+----+------+-----+----------+-----------+-----------+------------+----------+-------+
| id | dpid | pr  | match_op | match_exp | match_len | subst_exp  | repl_exp | attrs |
+----+------+-----+----------+-----------+-----------+------------+----------+-------+
|  1 |   10 | 100 |        1 | ^123+     |         0 | ^(123)(.+) | \2       |       |
+----+------+-----+----------+-----------+-----------+------------+----------+-------+

Db translation is working:

kamctl fifo dp_translate 10 12315555555555
Output:: 15555555555

But when I try to place call Kamailio send out all string with prefix:

U 2011/10/24 15:41:40.535040 XX.XX.205.100:5060 -> XX.XX.XX.38:5060
INVITE sip:1231973XXXXXXX@XX.XX.XX.38 SIP/2.0.
Record-Route: <sip:XX.XX.205.100;lr=on;did=a5e.1b3b5752>.
Via: SIP/2.0/UDP XX.XX.231.158;branch=z9hG4bK4d0e.c320ccf.0.
Via: SIP/2.0/UDP XX.XX.63.186:54574;branch=z9hG4bK-d8754z-e5356a5e91117c0c-1---d8754z-;rport=54574.
Max-Forwards: 69.
Contact: <sip:1718XXXXXXX@XX.XX.63.186:54574>.
To: "1231973XXXXXXX"<sip:1231973XXXXXXX@XX.XX.231.158>.
From: "1718XXXXXXX"<sip:1718XXXXXXX@XX.XX.231.158>;tag=9c266709.
CSeq: 2 INVITE.
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO.
Content-Type: application/sdp.
User-Agent: X-Lite release 1104o stamp 56125.
Content-Length:344.

What I doing wrong?

Arthur Alkhasyan


2011/10/21 Daniel-Constantin Mierla <miconda@gmail.com>
Hello,


On 10/21/11 3:36 PM, Arthur Alkhasyan wrote:
Hi all,

I'm new to the list and new to the Kamailio. We are using Kamailio with Mysql to route calls between clients asterisks and SIP PSTN gateways. We have two inbound gateways and one outbound. I need to add outbound gateway and a few new features:
1. Call routing between carriers based at prefixes added by asterisks. I would like to route all calls with prefix 99101 to gateway 1 and prefix 99102 to gateway 2. Prefix have to be striped out before sending call to carrier.
2. Remote Call Forwarding. I have to setup RCF at Kamailio. All calls to the particular DID number have to be forward to another number. 
I found description for dialplan module and believe the module can work for me. I recompiled Kamailio with dialplan module support and added to config 

# ----- dialplan params -----
modparam("dialplan", "db_url", "mysql://openser:openserrw@localhost/openser")
I did search and found this thread related to my problem:
http://lists.sip-router.org/pipermail/sr-users/2009-November/025416.html 
I try to use kamctl to add rule to the MySQL and can't find proper syntax
kamctl dialplan addrule 10 100 1 ^123+ 0 ^(123.+) 0030\1
-bash: syntax error near unexpected token `('

try to enclose the parameters that have special characters between double or single quotes. Also, you may need to double the char '\', in case the shell expands the parameters (usually happens with double quoted parameters).

Cheers,
Daniel
-- 
Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Dec 5-8, Berlin: http://asipto.com/u/kat
http://linkedin.com/in/miconda -- http://twitter.com/miconda