[Home]

Summary:ASTERISK-12358: SIPPEER isn't working inside REGEX and IF
Reporter:pj (pj)Labels:
Date Opened:2008-07-10 09:45:59Date Closed:2008-07-30 17:04:39
Priority:MinorRegression?No
Status:Closed/CompleteComponents:PBX/pbx_ael
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:I'm checking if peer is registered OK, before issue Dial() to avoid warning messages, I'm using expression below and it working as expected in trunk, but it's not working in 1.4.21.1, this expression is always false:
if (${REGEX("^OK" ${SIPPEER(998,status)})})
as workaround for 1.4, I must first store result of REGEX in variable and then check this variable using if()
issue is probably with SIPPEER function, because if I tried replace SIPPEER with string value, that SIPPEER returns, ie:
if (${REGEX("^OK" OK (57 ms))})
then it returns TRUE.



****** ADDITIONAL INFORMATION ******

 998 => {
       Set(registered=${REGEX("^OK" ${SIPPEER(998,status)})});
       NoOP(STATUS: ${registered});
       if (${REGEX("^OK" ${SIPPEER(998,status)})})
         NoOP(registered);
       else
         NoOP(NOT registered);
       Congestion;
 }


console output shows, that even regex expression returns '1' it's working incorrectly if all is placed inside if()

   -- Set("SIP/688-0819c1c8", "registered=1") in new stack
   -- NoOp("SIP/688-0819c1c8", "STATUS: 1") in new stack
   -- GotoIf("SIP/688-0819c1c8", "0?4:6") in new stack
   --
   -- NoOp("SIP/688-0819c1c8", "NOT registered") in new stack
   -- Congestion("SIP/688-0819c1c8", "") in new stack
Comments:By: Tilghman Lesher (tilghman) 2008-07-10 10:08:16

What is the output of 'dialplan show' ?

By: pj (pj) 2008-07-10 10:11:16

SIPPER delimiter inside Set() is shown as '|' and inside if() as ',' weird :-\

'998' =>          1. Set(registered=${REGEX("^OK" ${SIPPEER(998|status)})}) [pbx_ael]
                   2. NoOP(STATUS: ${registered})                [pbx_ael]
                   3. GotoIf($[${REGEX("^OK" ${SIPPEER(998,status)})}]?4:6) [pbx_ael]
                   4. NoOP(registered)                           [pbx_ael]
                   5. Goto(7)                                    [pbx_ael]
                   6. NoOP(NOT registered)                       [pbx_ael]
                   7. NoOp(Finish if-zamestnanci-100)            [pbx_ael]
                   8. Congestion()                               [pbx_ael]



By: pj (pj) 2008-07-30 06:36:07

probably related to new discovered issue 0013197

By: pj (pj) 2008-07-30 10:52:22

same workaround, that I wrote in 0013197, replace 'comma' separator with 'pipe' in ael dialplan, works for this issue, ie:

does NOT work:
       if (${REGEX("^OK" ${SIPPEER(998,status)})})
WORKS
       if (${REGEX("^OK" ${SIPPEER(998|status)})})

By: Digium Subversion (svnbot) 2008-07-30 16:54:01

Repository: asterisk
Revision: 134652

U   branches/1.4/pbx/pbx_ael.c

------------------------------------------------------------------------
r134652 | murf | 2008-07-30 16:53:58 -0500 (Wed, 30 Jul 2008) | 19 lines

(closes issue ASTERISK-12485)
Reported by: pj

(closes issue ASTERISK-12358)
Reported by: pj

This patch substitutes commas in the expr
supplied to the if () statement, as in
if ( expr ) ...

This solves both the bugs above, and makes
the source symmetric with switch statements,
which were earlier reported to need this sort
of treatment.

I tested this using the examples, both for
the compiler and at run time. Looks good.


------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=134652