[asterisk-commits] mmichelson: branch group/issue8824 r157855 - /team/group/issue8824/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Nov 19 14:44:18 CST 2008
Author: mmichelson
Date: Wed Nov 19 14:44:17 2008
New Revision: 157855
URL: http://svn.digium.com/view/asterisk?view=rev&rev=157855
Log:
Add proper support for parsing redirecting information in an INVITE.
This was not working properly since the channel had not yet been created
at the time that the INVITE was being parsed
Modified:
team/group/issue8824/channels/chan_sip.c
Modified: team/group/issue8824/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_sip.c?view=diff&rev=157855&r1=157854&r2=157855
==============================================================================
--- team/group/issue8824/channels/chan_sip.c (original)
+++ team/group/issue8824/channels/chan_sip.c Wed Nov 19 14:44:17 2008
@@ -2480,7 +2480,7 @@
static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout);
static void update_connectedline(struct sip_pvt *p, const void *data, size_t datalen);
static void update_redirecting(struct sip_pvt *p, const void *data, size_t datalen);
-static void change_redirecting_information(struct sip_pvt *p, struct sip_request *req);
+static void change_redirecting_information(struct sip_pvt *p, struct sip_request *req, struct ast_party_redirecting *redirecting);
/*-- TCP connection handling ---*/
static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_session_instance *ser);
@@ -16244,7 +16244,7 @@
/*! \brief update redirecting information for a channel based on headers
*
*/
-static void change_redirecting_information(struct sip_pvt *p, struct sip_request *req)
+static void change_redirecting_information(struct sip_pvt *p, struct sip_request *req, struct ast_party_redirecting *redirecting)
{
char *redirecting_from_name = NULL;
char *redirecting_from_number = NULL;
@@ -16273,42 +16273,35 @@
read_to_parts(p, req, &redirecting_to_name, &redirecting_to_number);
}
- /* This check could probably moved up higher so we don't do any unnecessary
- * parsing
- */
- if (!p->owner) {
- return;
- }
-
if (!ast_strlen_zero(redirecting_from_number)) {
- if (p->owner->redirecting.from.number) {
- ast_free(p->owner->redirecting.from.number);
+ if (redirecting->from.number) {
+ ast_free(redirecting->from.number);
}
ast_debug(3, "Got redirecting from number %s\n", redirecting_from_number);
- p->owner->redirecting.from.number = redirecting_from_number;
+ redirecting->from.number = redirecting_from_number;
}
if (!ast_strlen_zero(redirecting_from_name)) {
- if (p->owner->redirecting.from.name) {
- ast_free(p->owner->redirecting.from.name);
+ if (redirecting->from.name) {
+ ast_free(redirecting->from.name);
}
ast_debug(3, "Got redirecting from name %s\n", redirecting_from_name);
- p->owner->redirecting.from.name = redirecting_from_name;
+ redirecting->from.name = redirecting_from_name;
}
if (!ast_strlen_zero(redirecting_to_number)) {
- if (p->owner->redirecting.to.number) {
- ast_free(p->owner->redirecting.to.number);
+ if (redirecting->to.number) {
+ ast_free(redirecting->to.number);
}
ast_debug(3, "Got redirecting to number %s\n", redirecting_to_number);
- p->owner->redirecting.to.number = redirecting_to_number;
+ redirecting->to.number = redirecting_to_number;
}
if (!ast_strlen_zero(redirecting_to_name)) {
- if (p->owner->redirecting.to.name) {
- ast_free(p->owner->redirecting.to.name);
+ if (redirecting->to.name) {
+ ast_free(redirecting->to.name);
}
ast_debug(3, "Got redirecting to name %s\n", redirecting_from_number);
- p->owner->redirecting.to.name = redirecting_to_name;
- }
- p->owner->redirecting.reason = reason;
+ redirecting->to.name = redirecting_to_name;
+ }
+ redirecting->reason = reason;
}
/*! \brief Parse 302 Moved temporalily response
@@ -16564,7 +16557,7 @@
if (!req->ignore && (p->invitestate != INV_CANCELLED) && sip_cancel_destroy(p))
ast_log(LOG_WARNING, "Unable to cancel SIP destruction. Expect bad things.\n");
if (!req->ignore && p->owner) {
- change_redirecting_information(p, req);
+ change_redirecting_information(p, req, &p->owner->redirecting);
ast_queue_redirecting_update(p->owner, &p->owner->redirecting);
}
check_pendings(p);
@@ -17463,7 +17456,7 @@
case 301: /* Moved permanently */
case 302: /* Moved temporarily */
case 305: /* Use Proxy */
- change_redirecting_information(p, req);
+ change_redirecting_information(p, req, &p->owner->redirecting);
/* Fall through */
case 486: /* Busy here */
case 600: /* Busy everywhere */
@@ -18857,6 +18850,7 @@
if (!p->lastinvite && !req->ignore && !p->owner) {
/* This is a new invite */
/* Handle authentication if this is our first invite */
+ struct ast_party_redirecting redirecting = {{0,},};
res = check_user(p, req, SIP_INVITE, e, XMIT_RELIABLE, sin);
if (res == AUTH_CHALLENGE_SENT) {
p->invitestate = INV_COMPLETED; /* Needs to restart in another INVITE transaction */
@@ -18914,7 +18908,7 @@
return 0;
}
gotdest = get_destination(p, NULL); /* Get destination right away */
- change_redirecting_information(p, req); /*Will return immediately if no Diversion header is present */
+ change_redirecting_information(p, req, &redirecting); /*Will return immediately if no Diversion header is present */
extract_uri(p, req); /* Get the Contact URI */
build_contact(p); /* Build our contact header */
@@ -18958,6 +18952,7 @@
if (c) {
/* Pre-lock the call */
ast_channel_lock(c);
+ ast_party_redirecting_copy(&c->redirecting, &redirecting);
}
}
} else {
More information about the asterisk-commits
mailing list