[Asterisk-Dev] chan_sip.c - fix for Asterisk not on port 5060, other bugs
Stephen Davies
steve at daviesfam.org
Fri Mar 28 05:53:01 MST 2003
Hi Mark,
There's problems with the SIP channel if Asterisk is running on other than
port 5060 - Asterisk was not including its port number in From and Contact
headers.
Attached is a fix.
I've also been hunting down *s problems with being a client to Free World
Dialup - which boils down to lack of proper handling of
Contact: and Record-Route: in the 200 OK reply.
But in the process I did notice another minor thing: RFC3261 says that
the ACK to a 200 OK should have a new branch in the Via header. See the
example in section 24.2 and also 8.1.1.7. This should probably be fixed
(or, perhaps, the branch= should be left off entirely?)
Regards,
Steve
-------------- next part --------------
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.15
diff -u -r1.15 chan_sip.c
--- channels/chan_sip.c 28 Mar 2003 06:59:34 -0000 1.15
+++ channels/chan_sip.c 28 Mar 2003 12:46:00 -0000
@@ -1727,10 +1727,10 @@
char contact[256];
char *c;
if ((c=getsipuri(ot))) {
- snprintf(contact, sizeof(contact), "<%s@%s>", c, inet_ntoa(p->ourip));
+ snprintf(contact, sizeof(contact), "<%s@%s:%d>", c, inet_ntoa(p->ourip), ourport);
free(c);
} else {
- snprintf(contact, sizeof(contact), "<%s>", inet_ntoa(p->ourip));
+ snprintf(contact, sizeof(contact), "<%s:%d>", inet_ntoa(p->ourip), ourport);
}
snprintf(tmp, sizeof(tmp), "%d", p->expirey);
add_header(resp, "Expires", tmp);
@@ -1741,10 +1741,10 @@
very stupidly *sigh* XXX */
char *c;
if ((c=getsipuri(ot))) {
- snprintf(contact, sizeof(contact), "<%s@%s>", c, inet_ntoa(p->ourip));
+ snprintf(contact, sizeof(contact), "<%s@%s:%d>", c, inet_ntoa(p->ourip), ourport);
free(c);
} else {
- snprintf(contact, sizeof(contact), "<%s>", inet_ntoa(p->ourip));
+ snprintf(contact, sizeof(contact), "<%s:%d>", inet_ntoa(p->ourip), ourport);
}
add_header(resp, "Contact", contact);
}
@@ -2035,7 +2035,7 @@
}
if (!n)
n = callerid;
- snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=%08x", n, l, inet_ntoa(p->ourip), p->tag);
+ snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s:%d>;tag=%08x", n, l, inet_ntoa(p->ourip), ourport, p->tag);
if (strlen(p->username)) {
if (ntohs(p->sa.sin_port) != DEFAULT_SIP_PORT) {
snprintf(invite, sizeof(invite), "sip:%s@%s:%d",p->username, inet_ntoa(p->sa.sin_addr), ntohs(p->sa.sin_port));
More information about the asterisk-dev
mailing list