We need to make 2 transformations in URI and To field 
1. Convert telephone number to to format E.164
2. To correct a domain part of the address if it is set incorrectly by
stupid UA

All this is done through set of if operators because every of
transformations can be absent or can be done on own algorithm. Let's
consider a special case. We have on an input [EMAIL PROTECTED] and on
an output should receive [EMAIL PROTECTED] 
URI will be transformed by these commands
subst_uri("/^sip:([0-9]+)@(.*)/sip:[EMAIL PROTECTED]/i");
subst_uri("/^sip:([0-9]+)@(.*)/sip:[EMAIL PROTECTED]/i");
To field will be transformed by these commands
subst("/^To:(.*)sip:([0-9]+)@(.*)/To:\1sip:[EMAIL PROTECTED]/i");
subst("/^To:(.*)sip:([0-9]+)@([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)(.*)/
To:\1sip:[EMAIL PROTECTED]/i");

We test and get dump of messages using tcpdump
We receive from UA
INVITE sip:[EMAIL PROTECTED] SIP/2.0
Via: SIP/2.0/UDP 192.168.13.15
From: ......._1 <sip:[EMAIL PROTECTED]>;tag=22683200-29298-10909
To: <sip:[EMAIL PROTECTED]>
............

We make transformation and sent following:
INVITE sip:[EMAIL PROTECTED] SIP/2.0
Max-Forwards: 10
Record-Route: <sip:62.33.22.14;ftag=22683200-29298-10909;lr>
Via: SIP/2.0/UDP voapp.ru:5060;branch=z9hG4bKa4db.e5fa9a02.0
Via: SIP/2.0/UDP 192.168.13.15;rport=53809;received=217.107.59.194
From: ......._1 <sip:[EMAIL PROTECTED]>;tag=22683200-29298-10909
To: <sip:[EMAIL PROTECTED]>
To: <sip:[EMAIL PROTECTED]>
...............

As you can see URI was transformed correctly
And instead of To field we have 2 To fields everyone corresponding to
one of transformations.
It is a bug? Or it is feature OpenSER? Whether it is possible to bypass
this restriction?

I understand that it is possible to make one subst call instead of two
calls.
subst("/^To:(.*)sip:([0-9]+)@([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)(.*)/
To:\1sip:[EMAIL PROTECTED]/i");
But in a reality the algorithm is much more complex. And that instead of
several consecutive transformations to leave one it is required to use a
many of if operators. It is very inconvenient, conducts to mistakes and
reduces readability of a code.

Dmitry




_______________________________________________
Users mailing list
[email protected]
http://openser.org/cgi-bin/mailman/listinfo/users

Reply via email to