[asterisk-commits] mmichelson: branch 1.8 r355732 - /branches/1.8/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Feb 17 12:57:34 CST 2012
Author: mmichelson
Date: Fri Feb 17 12:57:28 2012
New Revision: 355732
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=355732
Log:
Fix regressions with regards to route-set creation on early dialogs.
This fixes two main issues:
1. Asterisk would send a CANCEL to the route created by the provisional response
instead of using the same destination it did in the initial INVITE.
2. If a new route set arrives in a 200 OK than was in the 1XX response (perfectly
possible if our outbound INVITE gets forked), then the route set in the 200 OK
needs to overwrite the route set in the 1XX response.
(closes issue ASTERISK-19358)
Reported by: Karsten Wemheuer
Tested by: Karsten Wemheuer
patches:
ASTERISK-19358.patch uploaded by Mark Michelson (license 5049)
ASTERISK-19358.patch uploaded by Stefan Schmidt (license 6034)
Review: https://reviewboard.asterisk.org/r/1749
Modified:
branches/1.8/channels/chan_sip.c
Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=355732&r1=355731&r2=355732
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Fri Feb 17 12:57:28 2012
@@ -1280,7 +1280,7 @@
static struct sip_pvt *find_call(struct sip_request *req, struct ast_sockaddr *addr, const int intended_method);
static void free_old_route(struct sip_route *route);
static void list_route(struct sip_route *route);
-static void build_route(struct sip_pvt *p, struct sip_request *req, int backwards);
+static void build_route(struct sip_pvt *p, struct sip_request *req, int backwards, int resp);
static enum check_auth_result register_verify(struct sip_pvt *p, struct ast_sockaddr *addr,
struct sip_request *req, const char *uri);
static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *totag, const char *fromtag);
@@ -10353,7 +10353,11 @@
snprintf(tmp, sizeof(tmp), "%u %s", seqno, sip_methods[sipmethod].text);
add_header(req, "Via", p->via);
- if (p->route) {
+ /*
+ * Use the learned route set unless this is a CANCEL. For a CANCEL
+ * we have to send to the same destination as the original INVITE.
+ */
+ if (p->route && sipmethod != SIP_CANCEL) {
set_destination(p, p->route->hop);
add_route(req, is_strict ? p->route->next : p->route);
}
@@ -14151,8 +14155,9 @@
}
}
-/*! \brief Build route list from Record-Route header */
-static void build_route(struct sip_pvt *p, struct sip_request *req, int backwards)
+/*! \brief Build route list from Record-Route header
+ \param resp the SIP response code or 0 for a request */
+static void build_route(struct sip_pvt *p, struct sip_request *req, int backwards, int resp)
{
struct sip_route *thishop, *head, *tail;
int start = 0;
@@ -14170,9 +14175,12 @@
p->route = NULL;
}
- /* We only want to create the route set the first time this is called */
- p->route_persistent = 1;
-
+ /* We only want to create the route set the first time this is called except
+ it is called from a provisional response.*/
+ if ((resp < 100) || (resp > 199)) {
+ p->route_persistent = 1;
+ }
+
/* Build a tailq, then assign it to p->route when done.
* If backwards, we add entries from the head so they end up
* in reverse order. However, we do need to maintain a correct
@@ -19969,7 +19977,7 @@
* */
parse_ok_contact(p, req);
if (!reinvite) {
- build_route(p, req, 1);
+ build_route(p, req, 1, resp);
}
if (!req->ignore && p->owner) {
if (get_rpid(p, req)) {
@@ -20019,7 +20027,7 @@
* */
parse_ok_contact(p, req);
if (!reinvite) {
- build_route(p, req, 1);
+ build_route(p, req, 1, resp);
}
if (!req->ignore && p->owner) {
struct ast_party_redirecting redirecting;
@@ -20045,7 +20053,7 @@
* */
parse_ok_contact(p, req);
if (!reinvite) {
- build_route(p, req, 1);
+ build_route(p, req, 1, resp);
}
if (!req->ignore && p->owner) {
if (get_rpid(p, req)) {
@@ -20145,7 +20153,7 @@
parse_ok_contact(p, req);
/* Save Record-Route for any later requests we make on this dialogue */
if (!reinvite)
- build_route(p, req, 1);
+ build_route(p, req, 1, resp);
if(set_address_from_contact(p)) {
/* Bad contact - we don't know how to reach this device */
@@ -22649,7 +22657,7 @@
*recount = 1;
/* Save Record-Route for any later requests we make on this dialogue */
- build_route(p, req, 0);
+ build_route(p, req, 0, 0);
if (c) {
ast_party_redirecting_init(&redirecting);
@@ -24531,7 +24539,7 @@
if (sipdebug)
ast_debug(4, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
check_via(p, req);
- build_route(p, req, 0);
+ build_route(p, req, 0, 0);
} else if (req->debug && req->ignore)
ast_verbose("Ignoring this SUBSCRIBE request\n");
More information about the asterisk-commits
mailing list