[asterisk-dev] SIPPEER() mistake getting IPAddress in peer

keiichiro kawasaki yassanet at gmail.com
Mon Mar 11 20:06:17 CDT 2013


Hey all,

I tried processing text messages on asterisk. I have used version of
asterisk is SVN-trunk-r382764M.

extensions.conf is:
exten = 161616,1,NoOp(recv messages)
exten = 161616,n,NoOp(${EXTEN}: ${MESSAGE(body)})
exten = 161616,n,MessageSend(sip:${EXTEN}@$[SIPPEER(${EXTEN},ip)]:$[SIPPEER(${EXTEN},port)],
${MESSAGE(from)})

SIPPEER function should get registered ip address and port of peer.
But I sent MESSAGE from 171717 to 161616, SIPPEER func got "192.168"
and "43967". Its correct ip address is "192.168.1.195".

this is full log then.
[Mar 11 20:28:30] VERBOSE[7630][C-00000000] pbx.c:     -- Executing
[161616 at messages:1] NoOp("Message/ast_msg_queue", "recv messages
161616:aaa") in new stack
[Mar 11 20:28:30] VERBOSE[7679] chan_sip.c: Scheduling destruction of
SIP dialog 'btLtuPlbap44Vrc3D5oAGZrXrSj9uXZn' in 32000 ms (Method:
MESSAGE)
[Mar 11 20:28:30] DEBUG[7630][C-00000000] pbx.c: Result of 'EXTEN' is '161616'
[Mar 11 20:28:30] DEBUG[7630][C-00000000] pbx.c: Result of 'EXTEN' is '161616'
[Mar 11 20:28:30] NOTICE[7630][C-00000000] ast_expr2.y: argbuf
allocated 10 bytes;
[Mar 11 20:28:30] NOTICE[7630][C-00000000] ast_expr2.y: argbuf uses 9 bytes;
[Mar 11 20:28:30] DEBUG[7630][C-00000000] pbx.c: Expression result is '192.168'
[Mar 11 20:28:30] DEBUG[7630][C-00000000] pbx.c: Result of 'EXTEN' is '161616'
[Mar 11 20:28:30] NOTICE[7630][C-00000000] ast_expr2.y: argbuf
allocated 12 bytes;
[Mar 11 20:28:30] NOTICE[7630][C-00000000] ast_expr2.y: argbuf uses 11 bytes;
[Mar 11 20:28:30] DEBUG[7630][C-00000000] pbx.c: Expression result is '43967'
[Mar 11 20:28:30] DEBUG[7630][C-00000000] pbx.c: Function result is
'<sip:171717 at 192.168.1.242>'
[Mar 11 20:28:30] DEBUG[7630][C-00000000] pbx.c: Launching 'MessageSend'
[Mar 11 20:28:30] VERBOSE[7630][C-00000000] pbx.c:     -- Executing
[161616 at messages:2] MessageSend("Message/ast_msg_queue",
"sip:161616 at 192.168:43967, <sip:171717 at 192.168.1.242>") in new stack

I found issue in main/ast_expr2.c. the gotten value is checked in the
number or the string in line about 3066 of op_func(). If is_really_num() has
one or more periods, the func will assess that long double format even
if IP address format.

I fixed:
Index: main/ast_expr2.c
===================================================================
--- main/ast_expr2.c    (revision 382782)
+++ main/ast_expr2.c    (working copy)
@@ -2792,7 +2792,7 @@

 static int is_really_num(char *str)
 {
-       if ( strspn(str,"-0123456789.   ") == strlen(str))
+       if ((strspn(str,"-0123456789.   ") == strlen(str)) &&
((strchr(str, '.') == strrchr(str, '.'))) )
                return 1;
        else
                return 0;

It's fine this situation.
Is this known Issues? If I have worng, please tell me fixed points.

I thank you for reading it through.
--
Keiichiro Kawasaki



More information about the asterisk-dev mailing list