[Sipsak] Missing last URI's port digit
Ricardo Barroetaveña
rbarroetavena at anura.com.ar
Wed Mar 17 20:48:44 CET 2010
Hi,
I'm using sipsak against a proxy in a non-default port (> 9999) and it
seems it's not correctly adding port information, last digit is
missing:
$ ./sipsak -vvv -s sip:10.10.10.2:55060
fqdnhostname: 127.0.0.1
warning: need raw socket (root privileges) to receive all ICMP errors
our Via-Line: Via: SIP/2.0/UDP
127.0.0.1:42507;branch=z9hG4bK.41b16f59;rport;alias
New message with Via-Line:
OPTIONS sip:10.10.10.2:5506 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:42507;branch=z9hG4bK.41b16f59;rport;alias
From: sip:sipsak at 127.0.0.1:42507;tag=e181e12
To: sip:10.10.10.2:5506
Call-ID: 236461586 at 127.0.0.1
CSeq: 1 OPTIONS
Contact: sip:sipsak at 127.0.0.1:42507
Content-Length: 0
Max-Forwards: 70
User-Agent: sipsak 0.9.7pre
Accept: text/plain
request:
OPTIONS sip:10.10.10.2:5506 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:42507;branch=z9hG4bK.41b16f59;rport;alias
From: sip:sipsak at 127.0.0.1:42507;tag=e181e12
To: sip:10.10.10.2:5506
Call-ID: 236461586 at 127.0.0.1
CSeq: 1 OPTIONS
Contact: sip:sipsak at 127.0.0.1:42507
Content-Length: 0
Max-Forwards: 70
User-Agent: sipsak 0.9.7pre
Accept: text/plain
send to: UDP:10.10.10.2:55060
** timeout after 500 ms**
If you look at the request, last '0' is missing from the port number
at the request line and from the 'To' header.
I took a quick look at the code from svn and the size arg in the
snprintf call seems to be missing a '+1'.
But I'm not sure if this is the only thing that needs to be changed.
$ diff -u sipsak.c.orig sipsak.c
--- sipsak.c.orig 2010-03-17 10:45:34.468901284 -0300
+++ sipsak.c 2010-03-17 10:45:52.950775707 -0300
@@ -733,7 +733,7 @@
}
if (port != 0) {
backup =
str_alloc(strlen(domainname)+1+6);
- snprintf(backup,
strlen(domainname)+6, "%s:%i", domainname, port);
+ snprintf(backup,
strlen(domainname)+1+6, "%s:%i", domainname, port);
domainname = backup;
}
uri_b=1;
$
Here's the same example with the patch applied:
$ ./sipsak -vvv -s sip:10.10.10.2:55060
fqdnhostname: 127.0.0.1
warning: need raw socket (root privileges) to receive all ICMP errors
our Via-Line: Via: SIP/2.0/UDP
127.0.0.1:46181;branch=z9hG4bK.31a76cc2;rport;alias
New message with Via-Line:
OPTIONS sip:10.10.10.2:55060 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:46181;branch=z9hG4bK.31a76cc2;rport;alias
From: sip:sipsak at 127.0.0.1:46181;tag=78e7ac0e
To: sip:10.10.10.2:55060
Call-ID: 2028448782 at 127.0.0.1
CSeq: 1 OPTIONS
Contact: sip:sipsak at 127.0.0.1:46181
Content-Length: 0
Max-Forwards: 70
User-Agent: sipsak 0.9.7pre
Accept: text/plain
request:
OPTIONS sip:10.10.10.2:55060 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:46181;branch=z9hG4bK.31a76cc2;rport;alias
From: sip:sipsak at 127.0.0.1:46181;tag=78e7ac0e
To: sip:10.10.10.2:55060
Call-ID: 2028448782 at 127.0.0.1
CSeq: 1 OPTIONS
Contact: sip:sipsak at 127.0.0.1:46181
Content-Length: 0
Max-Forwards: 70
User-Agent: sipsak 0.9.7pre
Accept: text/plain
send to: UDP:10.10.10.2:55060
message received
received from: UDP:10.10.10.2:55060
SIP/2.0 200 OK
Via: SIP/2.0/UDP
127.0.0.1:46181;branch=z9hG4bK.31a76cc2;rport=55544;alias;received=10.10.10.2
From: sip:sipsak at 127.0.0.1:46181;tag=78e7ac0e
To: sip:10.10.10.2:55060;tag=4db2d3f59131950335889d6ae61a0478.d95b
Call-ID: 2028448782 at 127.0.0.1
CSeq: 1 OPTIONS
Accept: */*
Accept-Encoding:
Accept-Language: en
Supported:
Server: OpenSIPS (1.6.1-tls (x86_64/linux))
Content-Length: 0
** reply received after 0.176 ms **
SIP/2.0 200 OK
final received
$
Thanks for the tool.
Regards,
Ricardo.
More information about the Sipsak
mailing list