[asterisk-bugs] [Asterisk 0007403]: [patch] allow SIP Spiral to work instead of causing a '482 Loop Detected' condition
noreply at bugs.digium.com
noreply at bugs.digium.com
Tue Jul 1 09:15:09 CDT 2008
A NOTE has been added to this issue.
======================================================================
http://bugs.digium.com/view.php?id=7403
======================================================================
Reported By: stephen_dredge
Assigned To: putnopvut
======================================================================
Project: Asterisk
Issue ID: 7403
Category: Channels/chan_sip/General
Reproducibility: N/A
Severity: tweak
Priority: normal
Status: ready for testing
Asterisk Version: SVN
SVN Branch (only for SVN checkouts, not tarball releases): trunk
SVN Revision (number only!): 47646
Disclaimer on File?: No
Request Review:
======================================================================
Date Submitted: 06-21-2006 00:13 CDT
Last Modified: 07-01-2008 09:13 CDT
======================================================================
Summary: [patch] allow SIP Spiral to work instead of causing
a '482 Loop Detected' condition
Description:
A sip call originating from asterisk causes a '482 Loop Detected' response
when forwarded back to asterisk from a external proxy. This should be
allowed when the request URI has been changed by the proxy and the call is
now targeted at a different user.
======================================================================
Relationships ID Summary
----------------------------------------------------------------------
has duplicate 0012215 Asterisk returns 482 Loop Detected upon...
======================================================================
----------------------------------------------------------------------
ibc - 07-01-08 09:13
----------------------------------------------------------------------
Hi, I'm trying to patch chan_sip.c (rev 123742) but I get this error:
/usr/src/asterisk-trunk$ patch -p0 < working_spiral.patch
patching file channels/chan_sip.c
Hunk http://bugs.digium.com/view.php?id=1 FAILED at 4641.
Hunk http://bugs.digium.com/view.php?id=2 succeeded at 17406 (offset 3642
lines).
Hunk http://bugs.digium.com/view.php?id=3 succeeded at 17734 with fuzz 1 (offset
3658 lines).
1 out of 3 hunks FAILED -- saving rejects to file channels/chan_sip.c.rej
It's seems that the path is done for this 123742 revision, isn't?
The content of channels/chan_sip.c.rej is:
-------------
***************
*** 4641,4648 ****
if (!found && option_debug > 4)
ast_log(LOG_DEBUG, "= Being pedantic: This
is not our match on request: Call ID: %s Ourtag <null> Totag %s Method
%s\n", p->callid, totag, sip_methods[req->method].text);
}
-
-
if (found) {
/* Found the call */
ast_mutex_lock(&p->lock);
--- 4641,4646 ----
if (!found && option_debug > 4)
ast_log(LOG_DEBUG, "= Being pedantic: This
is not our match on request: Call ID: %s Ourtag <null> Totag %s Method
%s\n", p->callid, totag, sip_methods[req->method].text);
}
if (found) {
/* Found the call */
ast_mutex_lock(&p->lock);
***************
*** 17985,17994 ****
being able to call yourself */
/* If pedantic is on, we need to check the tags. If
they're different, this is
in fact a forked call through a SIP proxy somewhere. */
- transmit_response(p, "482 Loop Detected", req);
- p->invitestate = INV_COMPLETED;
- sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- return 0;
}
if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->pendinginvite) {
--- 18248,18289 ----
being able to call yourself */
/* If pedantic is on, we need to check the tags. If
they're different, this is
in fact a forked call through a SIP proxy somewhere. */
+ int different;
+ if (pedanticsipchecking)
+ different = sip_uri_cmp(p->initreq.rlPart2,
req->rlPart2);
+ else
+ different = strcmp(p->initreq.rlPart2,
req->rlPart2);
+ if (!different) {
+ transmit_response(p, "482 Loop Detected", req);
+ p->invitestate = INV_COMPLETED;
+ sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+ return 0;
+ } else {
+ /* This is a spiral. What we need to do is to just
change the outgoing INVITE
+ * so that it now routes to the new Request URI.
Since we created the INVITE ourselves
+ * that should be all we need to do.
+ */
+ char *uri = ast_strdupa(req->rlPart2);
+ char *at = strchr(uri, '@');
+ char *peerorhost;
+ struct sip_pkt *pkt = NULL;
+ ast_log(LOG_NOTICE, "Spiral detected\n");
+ if (at) {
+ *at = '\0';
+ }
+ /* Parse out "sip:" */
+ if ((peerorhost = strchr(uri, ':'))) {
+ *peerorhost++ = '\0';
+ }
+ create_addr(p, peerorhost);
+ ast_string_field_free(p, theirtag);
+ for (pkt = p->packets; pkt; pkt = pkt->next) {
+ if (pkt->seqno == p->icseq && pkt->method
== SIP_INVITE) {
+ AST_SCHED_DEL(sched,
pkt->retransid);
+ }
+ }
+ return transmit_invite(p, SIP_INVITE, 1, 2);
+ }
}
if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->pendinginvite) {
-------------
Issue History
Date Modified Username Field Change
======================================================================
07-01-08 09:13 ibc Note Added: 0089500
======================================================================
More information about the asterisk-bugs
mailing list