[SR-Users] [Kamailio-Users] PCRE Regex / Transformations Bug?

Daniel-Constantin Mierla miconda at gmail.com
Fri Apr 30 21:14:01 CEST 2010


Hi Brandon,

you are missing the multi-line matching flag, try:
xlog("L_INFO", "[$ci] $(rb{re.subst,/^(.*)m=audio ([0-9]+)(.*)$/\2/s})")

Note the 's' after the last '/' in subst expression.

Cheers,
Daniel


On 4/29/10 10:21 PM, Brandon Armstead wrote:
> Daniel,
>
> Here is the XLOG output, the top log is the unmodified version and the 
> bottom is the modified version.
>
> xlog("L_INFO", "[$ci] $rb") OUTPUTS:
>
> Apr 29 20:17:23 sip-core02 /sbin/kamailio[23550]: 
> [6db72a2f-7e263847 at 192.168.1.75 
> <mailto:6db72a2f-7e263847 at 192.168.1.75>] v=0#015#012o=- 24986155 
> 24986155 IN IP4 99.21.137.236#015#012s=-#015#012c=IN IP4 
> 174.37.45.134#015#012t=0 0#015#012m=audio 55630 RTP/AVP 0 2 4 8 18 96 
> 97 98 101#015#012a=rtpmap:0 PCMU/8000#015#012a=rtpmap:2 
> G726-32/8000#015#012a=rtpmap:4 G723/8000#015#012a=rtpmap:8 
> PCMA/8000#015#012a=rtpmap:18 G729a/8000#015#012a=rtpmap:96 
> G726-40/8000#015#012a=rtpmap:97 G726-24/8000#015#012a=rtpmap:98 
> G726-16/8000#015#012a=rtpmap:101 
> telephone-event/8000#015#012a=fmtp:101 
> 0-15#015#012a=ptime:30#015#012a=sendrecv#015#012a=nortpproxy:yes#015
>
> xlog("L_INFO", "[$ci] $(rb{re.subst,/^(.*)m=audio 
> ([0-9]+)(.*)$/\2/})") OUTPUTS:
>
> Apr 29 20:17:23 sip-core02 /sbin/kamailio[23550]: 
> [6db72a2f-7e263847 at 192.168.1.75 
> <mailto:6db72a2f-7e263847 at 192.168.1.75>] v=0#015#012o=- 24986155 
> 24986155 IN IP4 99.21.137.236#015#012s=-#015#012c=IN IP4 
> 174.37.45.134#015#012t=0 0#015#01255630#012a=rtpmap:0 
> PCMU/8000#015#012a=rtpmap:2 G726-32/8000#015#012a=rtpmap:4 
> G723/8000#015#012a=rtpmap:8 PCMA/8000#015#012a=rtpmap:18 
> G729a/8000#015#012a=rtpmap:96 G726-40/8000#015#012a=rtpmap:97 
> G726-24/8000#015#012a=rtpmap:98 G726-16/8000#015#012a=rtpmap:101 
> telephone-event/8000#015#012a=fmtp:101 
> 0-15#015#012a=ptime:30#015#012a=sendrecv#015#012a=nortpproxy:yes#015
>
> As for the actual INVITE / SDP BODY:
>
> v=0.
> o=- 24986155 24986155 IN IP4 99.21.XXX.XXX.
> s=-.
> c=IN IP4 174.37.XX.XXX.
> t=0 0.
> m=audio 55630 RTP/AVP 0 2 4 8 18 96 97 98 101.
> a=rtpmap:0 PCMU/8000.
> a=rtpmap:2 G726-32/8000.
> a=rtpmap:4 G723/8000.
> a=rtpmap:8 PCMA/8000.
> a=rtpmap:18 G729a/8000.
> a=rtpmap:96 G726-40/8000.
> a=rtpmap:97 G726-24/8000.
> a=rtpmap:98 G726-16/8000.
> a=rtpmap:101 telephone-event/8000.
> a=fmtp:101 0-15.
> a=ptime:30.
> a=sendrecv.
> a=nortpproxy:yes.
>
> Let me know if this is sufficient or if there is anything else I can 
> provide.  Thanks!
>
> Sincerely,
> Brandon Armstead
>
> On Wed, Apr 28, 2010 at 3:54 PM, Daniel-Constantin Mierla 
> <miconda at gmail.com <mailto:miconda at gmail.com>> wrote:
>
>     Hello,
>
>     can you paste here the sip message and the result of the
>     substitution? It will help to troubleshoot if is something wrong
>     there.
>
>     Cheers,
>     Daniel
>
>
>
>     On 4/27/10 2:35 AM, Brandon Armstead wrote:
>>     Hello All,
>>
>>       Correction, it seems both the last supplied regex and
>>     xlog("L_INFO", "[$ci] m=audio $(rb{re.subst,/(.*)m=audio ([0-9]+)
>>     (.*)/\2/})"); return the same invalid results.
>>
>>     Thanks again!
>>
>>     Sincerely,
>>     Brandon Armstead
>>
>>     On Mon, Apr 26, 2010 at 7:33 PM, Brandon Armstead
>>     <brandon at cryy.com <mailto:brandon at cryy.com>> wrote:
>>
>>         Hello All,
>>
>>            I hate to dig-up this older mailing list entry.  However I
>>         am some additional trouble with what I believe is a
>>         completely posix-only regex.
>>
>>         xlog("L_INFO", "[$ci] m=audio
>>         $(rb{re.subst,/(.*)m=audio(.*)/\2/})");
>>
>>         I would expect to give me the port from the m=audio line,
>>         however it does not -- it simply removes m=audio.
>>
>>         Any thoughts / ideas / suggestions?
>>
>>         Sincerely,
>>         Brandon Armstead
>>
>>
>>         On Wed, Dec 23, 2009 at 9:31 PM, Iñaki Baz Castillo
>>         <ibc at aliax.net <mailto:ibc at aliax.net>> wrote:
>>
>>             El Miércoles, 23 de Diciembre de 2009, Daniel-Constantin
>>             Mierla escribió:
>>             > the re.subst transformation uses Posix regexp for
>>             matching, only the
>>             > format of the command is perl-like. I implemented this
>>             because textops
>>             > has no dependency of extra libraries than core and I
>>             wanted to keep it so.
>>             >
>>             > Maybe is good to add a pcre.subst transformation in
>>             regex module to be
>>             > able to use extended regexp formats given by libpcre.
>>
>>             I¡ll try to implement it when I get some spare time :)
>>
>>
>>             --
>>             Iñaki Baz Castillo <ibc at aliax.net <mailto:ibc at aliax.net>>
>>
>>             _______________________________________________
>>             Kamailio (OpenSER) - Users mailing list
>>             Users at lists.kamailio.org <mailto:Users at lists.kamailio.org>
>>             http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
>>             http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
>>
>>
>>
>>
>>     _______________________________________________
>>     SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>>     sr-users at lists.sip-router.org  <mailto:sr-users at lists.sip-router.org>
>>     http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>        
>
>     -- Daniel-Constantin Mierla * http://www.asipto.com/
>
>     *http://twitter.com/miconda
>     *http://www.linkedin.com/in/danielconstantinmierla
>          
>
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>    

-- 
Daniel-Constantin Mierla
* http://www.asipto.com/
* http://twitter.com/miconda
* http://www.linkedin.com/in/danielconstantinmierla

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20100430/3e9d5182/attachment.htm>


More information about the sr-users mailing list