[asterisk-commits] branch oej/siptransfer r16708 - /team/oej/siptransfer/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Mar 31 09:50:38 MST 2006


Author: oej
Date: Fri Mar 31 10:50:37 2006
New Revision: 16708

URL: http://svn.digium.com/view/asterisk?rev=16708&view=rev
Log:
Look Ma, it compiles :-)

Modified:
    team/oej/siptransfer/channels/chan_sip.c

Modified: team/oej/siptransfer/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/siptransfer/channels/chan_sip.c?rev=16708&r1=16707&r2=16708&view=diff
==============================================================================
--- team/oej/siptransfer/channels/chan_sip.c (original)
+++ team/oej/siptransfer/channels/chan_sip.c Fri Mar 31 10:50:37 2006
@@ -621,14 +621,10 @@
 #define SIP_SENDRPID		(1 << 30)	/*!< Remote Party-ID Support */
 #define SIP_INC_COUNT		(1 << 31)	/*!< Did this connection increment the counter of in-use calls? */
 
-/* RTP NAT Support */
-/* #define RTP_FORCE_NAT	(1 << 31) */
-#define RTP_FORCE_NAT	(1 << 14)
-
 #define SIP_FLAGS_TO_COPY \
 	(SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \
-	 SIP_PROG_INBAND | SIP_OSPAUTH | SIP_USECLIENTCODE | SIP_NAT | \
-	 SIP_USEREQPHONE  SIP_INSECURE_PORT | SIP_INSECURE_INVITE | RTP_FORCE_NAT)
+	SIP_PROG_INBAND | SIP_OSPAUTH | SIP_USECLIENTCODE | SIP_NAT | \
+	SIP_USEREQPHONE | SIP_INSECURE_PORT | SIP_INSECURE_INVITE )
 
 /* a new page of flags for peers */
 #define SIP_PAGE2_RTCACHEFRIENDS	(1 << 0)
@@ -745,6 +741,7 @@
 		AST_STRING_FIELD(our_contact);	/*!< Our contact header */
 		AST_STRING_FIELD(rpid);		/*!< Our RPID header */
 		AST_STRING_FIELD(rpid_from);	/*!< Our RPID From header */
+		AST_STRING_FIELD(subscribeuri);	/*!< Subscription URI */
 	);
 	struct ast_codec_pref prefs;		/*!< codec prefs */
 	unsigned int ocseq;			/*!< Current outgoing seqno */
@@ -3571,9 +3568,9 @@
 		/* Setup NAT structure according to global settings if we have an address */
 		memcpy(&p->recv, sin, sizeof(p->recv));
 		if (p->rtp)
-			ast_rtp_setnat(p->rtp, ast_test_flag(&p->flags[0], SIP_NAT_ROUTE) || ast_test_flag(p, RTP_FORCE_NAT));
+			ast_rtp_setnat(p->rtp, ast_test_flag(&p->flags[0], SIP_NAT_ROUTE));
 		if (p->vrtp)
-			ast_rtp_setnat(p->vrtp, ast_test_flag(&p->flags[0], SIP_NAT_ROUTE) || ast_test_flag(p, RTP_FORCE_NAT));
+			ast_rtp_setnat(p->vrtp, ast_test_flag(&p->flags[0], SIP_NAT_ROUTE));
 	}
 
 	if (p->method != SIP_REGISTER)
@@ -4582,14 +4579,6 @@
 
 	ot = get_header(orig, "To");
 	of = get_header(orig, "From");
-
-	/* OEJ test */
-	if (p->owner && sipmethod == SIP_INVITE) {   /* SIP RE-invite */
-		if (ast_test_flag(p, SIP_OUTGOING))
-			of = "ASTERISK re-INVITE ha ha ha ha ha  OUTGOING <test>";
-		else
-			ot = "ASTERISK re-INVITE ha ha ha ha ha INCOMING <test>";
-	}
 
 	/* Add tag *unless* this is a CANCEL, in which case we need to send it exactly
 	   as our original request, including tag (or presumably lack thereof) */
@@ -6069,7 +6058,7 @@
 		ast_log(LOG_DEBUG, "SIP transfer of %s to %s\n", p->callid, dest);
 
 	/* Are we transfering an inbound or outbound call ? */
-	if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) 
+	if (ast_test_flag(&p->flags[0], SIP_OUTGOING))  {
 		of = get_header(&p->initreq, "To");
 		ttag = theirtag;
 		ftag = p->tag;
@@ -7186,59 +7175,61 @@
 	/* Search interfaces and find the match */
 	ast_mutex_lock(&iflock);
 	sip_pvt_ptr = iflist;
-   if (option_debug > 3)       ast_log(LOG_DEBUG, "Looking for callid %s (fromtag %s totag %s)\n", callid, fromtag ? fromtag : "<no fromtag>", totag ? totag : "<no totag>");
+
+	if (option_debug > 3)
+		ast_log(LOG_DEBUG, "Looking for callid %s (fromtag %s totag %s)\n", callid, fromtag ? fromtag : "<no fromtag>", totag ? totag : "<no totag>");
 
 	while(sip_pvt_ptr) {
-      if (!strcmp(sip_pvt_ptr->callid, callid)) {
-         int match = 1;
-         char ourtag[12];
-
-         sprintf(ourtag, "%s", sip_pvt_ptr->tag);
-
-
-         /* Go ahead and lock it (and its owner) before returning */
-         ast_mutex_lock(&sip_pvt_ptr->lock);
-
-         if (option_debug > 3)             
-				ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n", ast_test_flag(sip_pvt_ptr, SIP_OUTGOING) ? "OUTGOING": "INCOMING", sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
-         /* Their tag is fromtag, our tag is to-tag */
-
-         if (pedanticsipchecking) {
-            /* Check if tags match. If not, this is not the call we want
-                  (With a forking SIP proxy, several call legs share the
-                  call id, but have different tags)
-             */
-            if (strcmp(fromtag, sip_pvt_ptr->theirtag) || strcmp(totag, ourtag))
-               match = 0;
-         }
-
-         if (!match) {
-            ast_mutex_unlock(&sip_pvt_ptr->lock);
-            break;
-         }
-
-         if (option_debug > 3 && match)
-            ast_log(LOG_DEBUG, "Found match for callid %s\n", callid);
-
-         if (sip_pvt_ptr->owner) {
-            while(ast_channel_trylock(sip_pvt_ptr->owner, "getsippvt...")) {
-               if (option_debug > 3)
-                  ast_log(LOG_DEBUG, "Locked channel %s\n", sip_pvt_ptr->owner->name);
-               ast_mutex_unlock(&sip_pvt_ptr->lock);
-               usleep(1);
-               ast_mutex_lock(&sip_pvt_ptr->lock);
-               if (!sip_pvt_ptr->owner)
-                  break;
-            }
-         }
-         break;
-      }
-      sip_pvt_ptr = sip_pvt_ptr->next;
-   }
-   ast_mutex_unlock(&iflock);
-   if (option_debug > 3 && !sip_pvt_ptr)
-      ast_log(LOG_DEBUG, "Found no match for callid %s to-tag %s from-tag %s\n", callid, totag, fromtag);
-   return sip_pvt_ptr;
+		if (!strcmp(sip_pvt_ptr->callid, callid)) {
+			int match = 1;
+			char ourtag[12];
+
+			sprintf(ourtag, "%s", sip_pvt_ptr->tag);
+
+
+			/* Go ahead and lock it (and its owner) before returning */
+			ast_mutex_lock(&sip_pvt_ptr->lock);
+
+			if (option_debug > 3)				 
+		ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n", ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING", sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
+			/* Their tag is fromtag, our tag is to-tag */
+
+			if (pedanticsipchecking) {
+				/* Check if tags match. If not, this is not the call we want
+				(With a forking SIP proxy, several call legs share the
+				call id, but have different tags)
+			*/
+			if (strcmp(fromtag, sip_pvt_ptr->theirtag) || strcmp(totag, ourtag))
+					match = 0;
+			}
+
+			if (!match) {
+				ast_mutex_unlock(&sip_pvt_ptr->lock);
+				break;
+			}
+
+			if (option_debug > 3 && match)
+				ast_log(LOG_DEBUG, "Found match for callid %s\n", callid);
+
+			if (sip_pvt_ptr->owner) {
+				while(ast_channel_trylock(sip_pvt_ptr->owner, "getsippvt...")) {
+					if (option_debug > 3)
+						ast_log(LOG_DEBUG, "Locked channel %s\n", sip_pvt_ptr->owner->name);
+					ast_mutex_unlock(&sip_pvt_ptr->lock);
+					usleep(1);
+					ast_mutex_lock(&sip_pvt_ptr->lock);
+					if (!sip_pvt_ptr->owner)
+						break;
+				}
+			}
+			break;
+		}
+		sip_pvt_ptr = sip_pvt_ptr->next;
+	}
+	ast_mutex_unlock(&iflock);
+	if (option_debug > 3 && !sip_pvt_ptr)
+		ast_log(LOG_DEBUG, "Found no match for callid %s to-tag %s from-tag %s\n", callid, totag, fromtag);
+	return sip_pvt_ptr;
 }
 
 /*! \brief Call transfer support (the REFER method) 
@@ -7403,57 +7394,66 @@
 	return -1;
 }
 
-
-/*! \brief  Call transfer support (old way, deprecated in the IETF) */
+/*! \brief Call transfer support (old way, depreciated by the IETF)--*/
 static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
 {
-	char tmp[256], *c, *a;
+	char tmp[256] = "", *c, *a;
 	struct sip_request *req;
-	const char *transfer_context = NULL;
+	struct sip_refer *referdata;
+	char *transfer_context = NULL;
 	
-	req = oreq;
-	if (!req)
+	referdata = p->refer;
+	
+	if (!oreq)
 		req = &p->initreq;
+	else
+		req = oreq;
 	ast_copy_string(tmp, get_header(req, "Also"), sizeof(tmp));
 	
 	c = get_in_brackets(tmp);
 
 	if (pedanticsipchecking)
 		ast_uri_decode(c);
-		
+	
 	if (strncmp(c, "sip:", 4)) {
-		ast_log(LOG_WARNING, "Huh?  Not a SIP header (%s)?\n", c);
+		ast_log(LOG_WARNING, "Huh?  Not a SIP header in Also: transfer (%s)?\n", c);
 		return -1;
 	}
 	c += 4;
-	if ((a = strchr(c, '@')))
+	if ((a = strchr(c, '@'))) {	/* Separate Domain */
 		*a = '\0';
-	if ((a = strchr(c, ';'))) 
+		a++;
+		ast_copy_string(referdata->refer_to_domain, a, sizeof(referdata->refer_to_domain));
+	}
+	
+	if ((a = strchr(c, ';'))) 	/* Remove arguments */
 		*a = '\0';
 	
 	if (sip_debug_test_pvt(p)) {
 		ast_verbose("Looking for %s in %s\n", c, p->context);
 	}
-	if (p->owner)  /* Mimic behaviour in res_features.c */
+	if (p->owner)	/* Mimic behaviour in res_features.c */
 		transfer_context = pbx_builtin_getvar_helper(p->owner, "TRANSFER_CONTEXT");
 
 	/* By default, use the context in the channel sending the REFER */
 	if (!transfer_context || ast_strlen_zero(transfer_context)) {
 		if (!ast_strlen_zero(p->owner->macrocontext))
-			transfer_context=p->owner->macrocontext;
+			transfer_context = p->owner->macrocontext;
 		else if (ast_strlen_zero(p->context))
 			transfer_context = default_context;
 		else
 			transfer_context = p->context;
 	}
-	if (ast_exists_extension(NULL, p->context, c, 1, NULL)) {
-		/* This is an unsupervised transfer */
+	if (ast_exists_extension(NULL, transfer_context, c, 1, NULL)) {
+		/* This is a blind transfer */
 		if (option_debug)
-			ast_log(LOG_DEBUG,"Assigning Extension %s to REFER-TO\n", c);
-		ast_string_field_set(p, refer_to, c);
-		ast_string_field_free(p, referred_by);
-		ast_string_field_free(p, refer_contact);
-		p->refer_call = NULL;
+			ast_log(LOG_DEBUG,"SIP Bye-also transfer to Extension %s@%s \n", c, transfer_context);
+		ast_copy_string(referdata->refer_to, c, sizeof(referdata->refer_to));
+		ast_copy_string(referdata->referred_by, "", sizeof(referdata->referred_by));
+		ast_copy_string(referdata->refer_contact, "", sizeof(referdata->refer_contact));
+		referdata->refer_call = NULL;
+		/* Set new context */
+		ast_string_field_set(p, context, transfer_context);
 		return 0;
 	} else if (ast_canmatch_extension(NULL, p->context, c, 1, NULL)) {
 		return 1;
@@ -7808,7 +7808,7 @@
 					ast_string_field_set(p, cid_num, rpid_num);
 				}
 			}
-			usenatroute = ast_test_flag(&p->flags[0], SIP_NAT_ROUTE || ast_test_flag(p, RTP_FORCE_NAT));
+			usenatroute = ast_test_flag(&p->flags[0], SIP_NAT_ROUTE);;
 			if (p->rtp) {
 				ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", usenatroute);
 				ast_rtp_setnat(p->rtp, usenatroute);
@@ -8037,7 +8037,7 @@
 {
 	if (mode == TRANSFER_OPENFORALL)
 		return "open";
-	else if (mode == closed)
+	else if (mode == TRANSFER_CLOSED)
 		return "closed";
 	return "strict";
 }
@@ -9059,7 +9059,7 @@
 				S_OR(cur->username, S_OR(cur->cid_num, "(None)")), 
 			   	cur->callid,
 				/* the 'complete' exten/context is hidden in the refer_to field for subscriptions */
-				cur->subscribed == MWI_NOTIFICATION ? "--" : cur->refer_to,
+				cur->subscribed == MWI_NOTIFICATION ? "--" : cur->subscribeuri,
 				cur->subscribed == MWI_NOTIFICATION ? "<none>" : ast_extension_state2str(cur->laststate), 
 				subscription_type2str(cur->subscribed),
 				cur->subscribed == MWI_NOTIFICATION ? (cur->relatedpeer ? cur->relatedpeer->mailbox : "<none>") : "<none>"
@@ -10352,7 +10352,7 @@
 		if (ast_strlen_zero(p->authname)) {
 			ast_log(LOG_WARNING, "Asked to authenticate REFER to %s:%d but we have no matching peer or realm auth!\n",
 			ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
-			ast_set_flag(p, SIP_NEEDDESTROY);
+			ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
 		}
 		if (resp == 401) {
 			auth = "WWW-Authenticate";
@@ -10361,7 +10361,7 @@
 		if ((p->authtries > 1) || do_proxy_auth(p, req, auth, auth2, SIP_REFER, 0)) {
 			ast_log(LOG_NOTICE, "Failed to authenticate on REFER to '%s'\n", get_header(&p->initreq, "From"));
 			p->refer->status = REFER_NOAUTH;
-			ast_set_flag(p, SIP_NEEDDESTROY);
+			ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
 		}
 		break;
 
@@ -10376,7 +10376,7 @@
 	case 603:   /* Transfer declined */
 		p->refer->status = REFER_FAILED;
 		ast_log(LOG_NOTICE, "SIP transfer to %s declined, call fails. \n", p->refer->refer_to);
-		ast_set_flag(p, SIP_NEEDDESTROY);
+		ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
 		break;
 	}
 }
@@ -10696,14 +10696,14 @@
 					ast_log(LOG_WARNING, "INVITE with REPLACEs failed to '%s'\n", get_header(&p->initreq, "From"));
 				if (owner)
 					ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
-				ast_set_flag(p, SIP_NEEDDESTROY);
+				ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
 			} else if (sipmethod == SIP_REFER) {
 				transmit_request(p, SIP_ACK, seqno, 0, 0);
 				/* A transfer with Replaces did not work */
 				/* OEJ: Set flag, cancel the REFER, go back
 				to original call */
 				ast_log(LOG_WARNING, "Remote host can't match request %s to call '%s'. Giving up.\n", sip_methods[sipmethod].text, p->callid);
-				ast_set_flag(p, SIP_NEEDDESTROY);
+				ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
 			} else if (sipmethod == SIP_BYE) {
 				/* The other side has no transaction to bye,
 				just assume it's all right then */
@@ -11227,7 +11227,7 @@
 		if (!p->refer && !sip_refer_allocate(p)) {
 			transmit_response(p, "500 Server Internal Error", req);
 			append_history(p, "Xfer", "INVITE/Replace Failed. Out of memory.");
-			ast_set_flag(p, SIP_NEEDDESTROY);	
+			ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
 			return -1;
 		}
 
@@ -11311,7 +11311,7 @@
 
 		if (error) {	/* Give up this dialog */
 			append_history(p, "Xfer", "INVITE/Replace Failed.");
-			ast_set_flag(p, SIP_NEEDDESTROY);	
+			ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
 			ast_mutex_unlock(&p->lock);
 			if (p->refer->refer_call) {
 				ast_mutex_unlock(&p->refer->refer_call->lock);
@@ -11615,7 +11615,7 @@
 		ast_log(LOG_DEBUG, "Unable to create new channel.  Invite/replace failed.\n");
 		transmit_response_with_sdp(p, "503 Service Unavailable", req, 1);
 		append_history(p, "Xfer", "INVITE/Replace Failed. No new channel.");
-		ast_set_flag(p, SIP_NEEDDESTROY);	
+		ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
 		ast_mutex_unlock(&p->refer->refer_call->lock);
 		return 1;
 	}
@@ -11744,7 +11744,7 @@
 		   	to follow the standard */
 			transmit_notify_with_sipfrag(transferer, seqno, "481 Call leg/transaction does not exist");
 			append_history(transferer, "Xfer", "Refer failed");
-			ast_clear_flag(transferer, SIP_GOTREFER);	
+			ast_clear_flag(&transferer->flags[0], SIP_GOTREFER);	
 			transferer->refer->status = REFER_FAILED;
 			return -1;
 		}
@@ -11785,7 +11785,7 @@
 	if (error) {	/* Cancel transfer */
 		transmit_notify_with_sipfrag(transferer, seqno, "503 Service Unavailable");
 		append_history(transferer, "Xfer", "Refer failed");
-		ast_clear_flag(transferer, SIP_GOTREFER);	
+		ast_clear_flag(&transferer->flags[0], SIP_GOTREFER);	
 		transferer->refer->status = REFER_FAILED;
 		ast_mutex_unlock(&targetcall_pvt->lock);
 		ast_channel_unlock(current->chan1);
@@ -11801,7 +11801,7 @@
 			ast_log(LOG_DEBUG, "SIP attended transfer: trying to make %s take over (masq) %s\n", target.chan1->name, current->chan1->name);
 	}
 
-	ast_set_flag(transferer, SIP_PAGE2_DEFER_BYE_ON_TRANSFER);	/* Delay hangup */
+	ast_set_flag(&transferer->flags[0], SIP_PAGE2_DEFER_BYE_ON_TRANSFER);	/* Delay hangup */
 	if (transferer->owner)
 		ast_set_flag(transferer->owner, AST_FLAG_KEEP_PVT_AT_HANGUP);	/* Delay hangup */
 
@@ -11903,9 +11903,9 @@
 	int res = 0;
 
 	if (req->debug)
-		ast_verbose("Call %s got a SIP call transfer from %s: (REFER)!\n", p->callid, ast_test_flag(p, SIP_OUTGOING) ? "callee" : "caller");
-
-	if (p->allowtransfer == closed ) {
+		ast_verbose("Call %s got a SIP call transfer from %s: (REFER)!\n", p->callid, ast_test_flag(&p->flags[0], SIP_OUTGOING) ? "callee" : "caller");
+
+	if (p->allowtransfer == TRANSFER_CLOSED ) {
 		/* Transfer not allowed, decline */
 		transmit_response(p, "603 Declined (policy)", req);
 		append_history(p, "Xfer", "Refer failed. Allowtransfer == closed.");
@@ -11974,7 +11974,6 @@
 	}
 	if (ast_strlen_zero(p->context))
 		ast_string_field_set(p, context, default_context);
-<<<<<<< .working
 
 	/* If we do not support SIP domains, all transfers are local */
 	if (allow_external_domains && check_sip_domain(p->refer->refer_to_domain, NULL, 0)) {
@@ -12047,7 +12046,7 @@
 	if (current.chan2)
 		ast_moh_stop(current.chan2);
 
-	ast_set_flag(p, SIP_GOTREFER);	
+	ast_set_flag(&p->flags[0], SIP_GOTREFER);	
 
 	/* Attended transfer: Find all call legs and bridge transferee with target*/
 	if (p->refer->attendedtransfer) {
@@ -12140,12 +12139,11 @@
 		transmit_response(p, "202 Accepted", req);
 		p->refer->status = REFER_FAILED;
 		transmit_notify_with_sipfrag(p, seqno, "503 Service Unavailable (can't handle one-legged xfers)");
-		ast_clear_flag(p, SIP_GOTREFER);	
+		ast_clear_flag(&p->flags[0], SIP_GOTREFER);	
 		append_history(p, "Xfer", "Refer failed (only bridged calls).");
-		//res = -1;
 		return -1;
 	}
-	ast_set_flag(p, SIP_PAGE2_DEFER_BYE_ON_TRANSFER);	/* Delay hangup */
+	ast_set_flag(&p->flags[1], SIP_PAGE2_DEFER_BYE_ON_TRANSFER);	/* Delay hangup */
 	if (p->owner)
 		ast_set_flag(p->owner, AST_FLAG_KEEP_PVT_AT_HANGUP);	/* Delay hangup */
 
@@ -12155,25 +12153,27 @@
 
 	if (!res) {
 		/* Success  - we have a new channel */
-		ast_log(LOG_DEBUG, "%s transfer succeeded. Telling transferer.\n", p->refer->attendedtransfer? "Attended" : "Blind");
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "%s transfer succeeded. Telling transferer.\n", p->refer->attendedtransfer? "Attended" : "Blind");
 		transmit_notify_with_sipfrag(p, seqno, "200 Ok");
 		if (p->refer->localtransfer)
 			p->refer->status = REFER_200OK;
 		if (p->owner)
 			p->owner->hangupcause = AST_CAUSE_NORMAL_CLEARING;
 		append_history(p, "Xfer", "Refer succeeded.");
-		ast_clear_flag(p, SIP_GOTREFER);	
+		ast_clear_flag(&p->flags[0], SIP_GOTREFER);	
 		/* Do not hangup call, the other side do that when we say 200 OK */
 		/* OEJ: We could possibly implement a timer here, auto congestion */
 		res = 0;
 	} else {
-		ast_clear_flag(p, SIP_PAGE2_DEFER_BYE_ON_TRANSFER);	/* Delay hangup */
-		ast_log(LOG_DEBUG, "%s transfer failed. Resuming original call.\n", p->refer->attendedtransfer? "Attended" : "Blind");
+		ast_clear_flag(&p->flags[1], SIP_PAGE2_DEFER_BYE_ON_TRANSFER);	/* Delay hangup */
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "%s transfer failed. Resuming original call.\n", p->refer->attendedtransfer? "Attended" : "Blind");
 		append_history(p, "Xfer", "Refer failed.");
 		/* Failure of some kind */
 		p->refer->status = REFER_FAILED;
 		transmit_notify_with_sipfrag(p, seqno, "503 Service Unavailable");
-		ast_clear_flag(p, SIP_GOTREFER);	
+		ast_clear_flag(&p->flags[0], SIP_GOTREFER);	
 		res = -1;
 	}
 	return res;
@@ -12243,7 +12243,7 @@
 				if (bridged_to) {
 					/* Don't actually hangup here... */
 					ast_moh_stop(bridged_to);
-					ast_async_goto(bridged_to, p->context, p->refer_to,1);
+					ast_async_goto(bridged_to, p->context, p->refer->refer_to, 1);
 				} else
 					ast_queue_hangup(p->owner);
 			}
@@ -12453,7 +12453,7 @@
 				transmit_state_notify(p, firststate, 1);	/* Send first notification */
 				append_history(p, "Subscribestatus", "%s", ast_extension_state2str(firststate));
 				/* hide the 'complete' exten/context in the refer_to field for later display */
-				ast_string_field_build(p, refer_to, "%s@%s", p->exten, p->context);
+				ast_string_field_build(p, subscribeuri, "%s@%s", p->exten, p->context);
 
 				/* remove any old subscription from this peer for the same exten/context,
 			   	as the peer has obviously forgotten about it and it's wasteful to wait
@@ -13304,8 +13304,6 @@
 			ast_set_flag(&flags[0], SIP_NAT_ALWAYS);
 		else
 			ast_set_flag(&flags[0], SIP_NAT_RFC3581);
-	} else if (!strcasecmp(v->name, "rtpforcenat")) {
-		ast_set2_flag(&flags[0], ast_true(v->value), RTP_FORCE_NAT);
 	} else if (!strcasecmp(v->name, "canreinvite")) {
 		ast_set_flag(&mask[0], SIP_REINVITE);
 		ast_clear_flag(&flags[0], SIP_REINVITE);
@@ -13574,7 +13572,7 @@
 	strcpy(user->context, default_context);
 	strcpy(user->language, default_language);
 	strcpy(user->musicclass, default_musicclass);
-	peer->allowtransfer = global_allowtransfer;
+	user->allowtransfer = global_allowtransfer;
 	for (; v; v = v->next) {
 		if (handle_common_options(&userflags[0], &mask[0], v))
 			continue;



More information about the asterisk-commits mailing list