Hi All I am receiving a Preferred-Identity from a customer which I need to modify (strip the first character a 0) and then send it as Remote Party ID Sending the RPID is no problem, my issue is stripping the character. I have tried a few things to do this. subst('/^P-Preferred-Identity:(.*)<sip:(0)(.*)@.*>(.*)$/P-Preferred-Identity:\1<sip:\3@domain
\4/ig')
This substitution works fine but when I read $pU it still has the leading 0 I also looked at using re.subst on $pU but can't get it to work. What is the best way to achieve what I'm trying to do? Sorry for hassling you! Thanks, Brian
On 09/21/2010 04:47 PM, dotnetdub wrote:
I also looked at using re.subst on $pU but can't get it to work.
What is the best way to achieve what I'm trying to do?
I would extract a substring based on length. Intermediate (first) variable 'pu_len' is required because transformations cannot be nested: $var(pu_len) = $(pU{s.len}) - 1; $var(new_pi) = $(pU{s.substr,1,$var(pu_len)}); append_hf("Remote-Party_ID: ...$var(new_pi)..."); -- Alex Balashov - Principal Evariste Systems LLC 1170 Peachtree Street 12th Floor, Suite 1200 Atlanta, GA 30309 Tel: +1-678-954-0670 Fax: +1-404-961-1892 Web: http://www.evaristesys.com/
On 9/22/10 12:49 AM, Alex Balashov wrote:
On 09/21/2010 04:47 PM, dotnetdub wrote:
I also looked at using re.subst on $pU but can't get it to work.
What is the best way to achieve what I'm trying to do?
I would extract a substring based on length. Intermediate (first) variable 'pu_len' is required because transformations cannot be nested:
$var(pu_len) = $(pU{s.len}) - 1; $var(new_pi) = $(pU{s.substr,1,$var(pu_len)}); while this is correct, you can do it without computing the length: $var(new_pi) = $(pU{s.substr,1,0});
- meaning is that when len param for transformation is 0, get substring from position param till the end of pv value. Cheers, Daniel
append_hf("Remote-Party_ID: ...$var(new_pi)...");
-- Daniel-Constantin Mierla http://www.asipto.com
On 21 September 2010 23:53, Daniel-Constantin Mierla <miconda@gmail.com>wrote:
On 9/22/10 12:49 AM, Alex Balashov wrote:
On 09/21/2010 04:47 PM, dotnetdub wrote:
I also looked at using re.subst on $pU but can't get it to work.
What is the best way to achieve what I'm trying to do?
I would extract a substring based on length. Intermediate (first) variable 'pu_len' is required because transformations cannot be nested:
$var(pu_len) = $(pU{s.len}) - 1; $var(new_pi) = $(pU{s.substr,1,$var(pu_len)});
while this is correct, you can do it without computing the length: $var(new_pi) = $(pU{s.substr,1,0});
- meaning is that when len param for transformation is 0, get substring from position param till the end of pv value.
Cheers, Daniel
<http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users>
Thank you very much. Both ways work as expected. Regards Brian
2010/9/21 dotnetdub <dotnetdub@gmail.com>:
This substitution works fine but when I read $pU it still has the leading 0
Yes, the change is just applied when the message leaves the proxy.
What is the best way to achieve what I'm trying to do?
I recommedn you to first delete the PPI header with hf_remove("P-Preferred-Identity") and later generate your own PPI header (hf_append) by reading the content of $pu (which still has the original value arrived to the proxy). -- Iñaki Baz Castillo <ibc@aliax.net>
On 9/22/10 12:55 AM, Iñaki Baz Castillo wrote:
2010/9/21 dotnetdub<dotnetdub@gmail.com>:
This substitution works fine but when I read $pU it still has the leading 0 Yes, the change is just applied when the message leaves the proxy. ... and if one needs the change to be visible in the config before sending to network, then use (carefully, not extensively) msg_apply_changes() -- function in textops module from version 3.0+
Cheers, Daniel
What is the best way to achieve what I'm trying to do? I recommedn you to first delete the PPI header with hf_remove("P-Preferred-Identity") and later generate your own PPI header (hf_append) by reading the content of $pu (which still has the original value arrived to the proxy).
participants (5)
-
Alex Balashov -
Daniel-Constantin Mierla -
Daniel-Constantin Mierla -
dotnetdub -
Iñaki Baz Castillo