[OpenSIPS-Users] Regex module limitations ?

Odin Gremaud odin.gremaud at nexcom.fr
Mon Oct 1 14:09:04 CEST 2012


Hi,

 From my understanding (correct me if I'm wrong), you want to match a  
particular header value and return this value to use it afterwards in your  
script. You could of course use an external script (using exec or perl  
module), but may I suggest you having a look at the dialplan module ? It  
can not only be used for a dial plan (thus the name), but you can match  
almost anything with it : IP addresses, SIP headers, ...

For instance, you would populate the database table, and then, you could  
do this :

if !dp_translate("<dialplan_id>","$ua/$avp(ua)") {
     xlog("L_INFO", "No match found for User-Agent");
}

If your rule is done correctly (you can apply transformations or not, it's  
up to you), you could get in $avp(ua) the matched (transformed or not)  
value, or anything else you want. You could even declare, in your rules,  
some attributes that could be fetched at the same time, using the  
"attrs_pvar" module parameter.

Hope this helps.

Odin



On Mon, 01 Oct 2012 12:25:02 +0200, <denis.barbaron at orange.com> wrote:

> Hi,
>
> I would like to use the "regex" module to perform pattern matching  
> against strings or SIP headers in order to get back results in the same  
> way I can do it with PCRE API, as follow :  
> preg_match_all('#<([ib])>(.*?)</\1>#', $txt, $out). The problem is that  
> "regex" module seems to not be able to provide such feature but only a  
> comparison function returning a boolean value (TRUE or FALSE), as follow  
> :
> ...
> if (pcre_match("$ua", "(?i)^twinkle")) {
>     xlog("L_INFO", "User-Agent matches\n");
> }
> ...
>
> The only way I found to solve this problem would be to use the "exec"  
> module to run an external script doing the job or to develop a new  
> module, so is there a more simple solution please ?
> Thanks.
> Denis.
>
>
>
> [cid:image001.gif at 01CD85FD.DD28EF80]
>
> Denis Barbaron
> R&D engineer
> FT/OLPS/OLNC/IVA/VMI/INTL
> tél. +33 2 96 05 03 57
> denis.barbaron at orange.com<mailto:thierry.moreau at orange-ftgroup.com>
>
>
> _________________________________________________________________________________________________________________________
>
> Ce message et ses pieces jointes peuvent contenir des informations  
> confidentielles ou privilegiees et ne doivent donc
> pas etre diffuses, exploites ou copies sans autorisation. Si vous avez  
> recu ce message par erreur, veuillez le signaler
> a l'expediteur et le detruire ainsi que les pieces jointes. Les messages  
> electroniques etant susceptibles d'alteration,
> France Telecom - Orange decline toute responsabilite si ce message a ete  
> altere, deforme ou falsifie. Merci.
>
> This message and its attachments may contain confidential or privileged  
> information that may be protected by law;
> they should not be distributed, used or copied without authorisation.
> If you have received this email in error, please notify the sender and  
> delete this message and its attachments.
> As emails may be altered, France Telecom - Orange is not liable for  
> messages that have been modified, changed or falsified.
> Thank you.



More information about the Users mailing list