[svn-commits] rizzo: branch rizzo/astobj2 r48411 - /team/rizzo/astobj2/channels/chan_sip.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Dec 12 08:52:34 MST 2006


Author: rizzo
Date: Tue Dec 12 09:52:33 2006
New Revision: 48411

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48411
Log:
reduce diffs with trunk


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=48411&r1=48410&r2=48411
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Tue Dec 12 09:52:33 2006
@@ -245,14 +245,14 @@
 */
 enum invitestates {
 	INV_NONE = 0,		/*!< No state at all, maybe not an INVITE dialog */
-	INV_CALLING,		/*!< Invite sent, no answer */
-	INV_PROCEEDING,		/*!< We got/sent 1xx message */
-	INV_EARLY_MEDIA,	/*!< We got 18x message with to-tag back */
-	INV_COMPLETED,		/*!< Got final response with error. Wait for ACK, then CONFIRMED */
-	INV_CONFIRMED,		/*!< Confirmed response - we've got an ack (Incoming calls only) */
-	INV_TERMINATED,		/*!< Transaction done - either successful (AST_STATE_UP) or failed, but done 
+	INV_CALLING = 1,	/*!< Invite sent, no answer */
+	INV_PROCEEDING = 2,	/*!< We got/sent 1xx message */
+	INV_EARLY_MEDIA = 3,	/*!< We got 18x message with to-tag back */
+	INV_COMPLETED = 4,	/*!< Got final response with error. Wait for ACK, then CONFIRMED */
+	INV_CONFIRMED = 5,	/*!< Confirmed response - we've got an ack (Incoming calls only) */
+	INV_TERMINATED = 6,	/*!< Transaction done - either successful (AST_STATE_UP) or failed, but done 
 					The only way out of this is a BYE from one side */
-	INV_CANCELLED		/*!< Transaction cancelled by client or server in non-terminated state */
+	INV_CANCELLED = 7,	/*!< Transaction cancelled by client or server in non-terminated state */
 };
 
 /* Do _NOT_ make any changes to this enum, or the array following it;
@@ -880,7 +880,7 @@
 	char replaces_callid[BUFSIZ];			/*!< Replace info: callid */
 	char replaces_callid_totag[BUFSIZ/2];		/*!< Replace info: to-tag */
 	char replaces_callid_fromtag[BUFSIZ/2];		/*!< Replace info: from-tag */
-	struct sip_pvt *refer_pvt;			/*!< Call we are referring. This is just a reference to a
+	struct sip_pvt *refer_call;			/*!< Call we are referring. This is just a reference to a
 							 * dialog owned by someone else, so we should not destroy
 							 * it when the sip_refer object goes.
 							 */
@@ -1184,13 +1184,13 @@
 	struct sockaddr_in addr;	/*!<  IP address of peer */
 	
 	/* Qualification */
-	struct sip_pvt *peer_pvt;		/*!<  Call pointer */
+	struct sip_pvt *call;		/*!<  Call pointer */
 	int pokeexpire;			/*!<  When to expire poke (qualify= checking) */
 	int lastms;			/*!<  How long last response took (in ms), or -1 for no response */
 	int maxms;			/*!<  Max ms we will accept for the host to be up, 0 to not monitor */
 	struct timeval ps;		/*!<  Time for sending SIP OPTION in sip_pke_peer() */
 	struct sockaddr_in defaddr;	/*!<  Default IP address, used until registration */
-	struct sip_pvt *mwi_pvt;		/*!<  Subscription for MWI */
+	struct sip_pvt *mwipvt;		/*!<  Subscription for MWI */
 	int lastmsg;
 };
 
@@ -1300,7 +1300,7 @@
 /* --- Sockets and networking --------------*/
 
 /*!
- * __sipsock is shared between the manager thread (which handles reload
+ * sipsock is shared between the manager thread (which handles reload
  * requests), the io handler (sipsock_read()) and the user routines that
  * issue writes (using __sip_xmit()).
  * The socket is -1 only when opening fails (this is a permanent condition),
@@ -1313,7 +1313,7 @@
  * the protocol handle this above us.
  */
 
-static volatile int __sipsock  = -1;			/*!< Main socket for SIP network communication */
+static volatile int sipsock  = -1;			/*!< Main socket for SIP network communication */
 static struct sockaddr_in bindaddr = { 0, };	/*!< The address we bind to */
 static struct sockaddr_in externip;		/*!< External IP address if we are behind NAT */
 static char externhost[MAXHOSTNAMELEN];		/*!< External host name (possibly with dynamic DNS and DHCP */
@@ -1946,7 +1946,7 @@
 	 * There is a short window during a reload when this might fail.
 	 * Just live with it.
 	 */
-	res = sendto(__sipsock, data, len, 0, (const struct sockaddr *)dst, sizeof(struct sockaddr_in));
+	res = sendto(sipsock, data, len, 0, (const struct sockaddr *)dst, sizeof(struct sockaddr_in));
 
 	if (res != len)
 		ast_log(LOG_WARNING, "sip_xmit of %p (len %d) to %s:%d returned %d: %s\n", data, len, ast_inet_ntoa(dst->sin_addr), ntohs(dst->sin_port), res, strerror(errno));
@@ -2664,11 +2664,11 @@
 		ast_log(LOG_DEBUG, "Destroying SIP peer %s\n", peer->name);
 
 	/* Delete it, it needs to disappear */
-	if (peer->peer_pvt)
-		peer->peer_pvt = sip_destroy(peer->peer_pvt);
-
-	if (peer->mwi_pvt) 	/* We have an active subscription, delete it */
-		peer->mwi_pvt = sip_destroy(peer->mwi_pvt);
+	if (peer->call)
+		peer->call = sip_destroy(peer->call);
+
+	if (peer->mwipvt) 	/* We have an active subscription, delete it */
+		peer->mwipvt = sip_destroy(peer->mwipvt);
 
 	if (peer->chanvars) {
 		ast_variables_destroy(peer->chanvars);
@@ -2676,6 +2676,7 @@
 	}
 	if (peer->expire > -1)
 		ast_sched_del(sched, peer->expire);
+
 	if (peer->pokeexpire > -1)
 		ast_sched_del(sched, peer->pokeexpire);
 	register_peer_exten(peer, FALSE);
@@ -2747,6 +2748,7 @@
 		ast_variables_destroy(var);
 		return NULL;
 	}
+
 
 	/* Peer found in realtime, now build it in memory */
 	peer = build_peer(newpeername, var, NULL, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
@@ -3194,8 +3196,8 @@
 		ast_verbose("Really destroying SIP dialog '%s' Method: %s\n", p->callid, sip_methods[p->method].text);
 
 	/* Remove link from peer to subscription of MWI */
-	if (p->relatedpeer && p->relatedpeer->mwi_pvt) /* XXX sip_destroy ? */
-		p->relatedpeer->mwi_pvt = pvt_unref(p->relatedpeer->mwi_pvt);
+	if (p->relatedpeer && p->relatedpeer->mwipvt) /* XXX sip_destroy ? */
+		p->relatedpeer->mwipvt = pvt_unref(p->relatedpeer->mwipvt);
 
 	if (dumphistory)
 		sip_dump_history(p);
@@ -5067,6 +5069,7 @@
 		    !strcasecmp(req->line[x + 1], "Content-Type: application/sdp")) {
 			x += 2;
 			req->sdp_start = x;
+
 			/* search for the end of the body part */
 			for ( ; x < req->lines; x++) {
 				if (!strncasecmp(req->line[x], boundary, strlen(boundary)))
@@ -5276,6 +5279,7 @@
 				ast_log(LOG_DEBUG, "Peer doesn't provide T.38 UDPTL\n");
 		}
 	}
+
 
 	if (p->rtp) {
 		if (portno > 0) {
@@ -7467,7 +7471,7 @@
 	case REG_STATE_TIMEOUT:
 		return "Timeout";
 	case REG_STATE_NOAUTH:
-		return "Invalid Credentials";
+		return "No Authentication";
 	default:
 		return "Unknown";
 	}
@@ -7690,12 +7694,9 @@
 	add_header(&req, "User-Agent", global_useragent);
 
 	
-	if (auth) {	/* Add auth header */
+	if (auth) 	/* Add auth header */
 		add_header(&req, authheader, auth);
-		if (option_debug > 3)
-			ast_verbose("REGISTER attempt %d to %s@%s, %s: %s\n",
-				r->regattempts, r->username, r->hostname, authheader, auth);
-	} else if (!ast_strlen_zero(r->nonce)) {
+	else if (!ast_strlen_zero(r->nonce)) {
 		char digest[1024];
 
 		/* We have auth data to reuse, build a digest header!
@@ -7762,8 +7763,8 @@
 {
 	if (!p->refer)
 		return;
-	if (p->refer->refer_pvt)
-		p->refer->refer_pvt = pvt_unref(p->refer->refer_pvt);
+	if (p->refer->refer_call)
+		p->refer->refer_call = pvt_unref(p->refer->refer_call);
 	free(p->refer);
 	p->refer = NULL;
 }
@@ -8023,7 +8024,7 @@
 	peer->addr.sin_family = AF_INET;
 	peer->addr.sin_addr = in;
 	peer->addr.sin_port = htons(port);
-	if (__sipsock < 0) {
+	if (sipsock < 0) {
 		/* SIP isn't up yet, so schedule a poke only, pretty soon */
 		if (peer->pokeexpire > -1)
 			ast_sched_del(sched, peer->pokeexpire);
@@ -8198,8 +8199,10 @@
 	else
 		peer->username[0] = '\0';
 
-	if (peer->expire > -1)
+	if (peer->expire > -1) {
 		ast_sched_del(sched, peer->expire);
+		peer->expire = -1;
+	}
 	if (expiry > max_expiry)
 		expiry = max_expiry;
 	if (expiry < min_expiry)
@@ -8512,6 +8515,7 @@
 			transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, FALSE);
 		}
 
+		/* Schedule auto destroy in 32 seconds */
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 		return AUTH_CHALLENGE_SENT;
 	} 
@@ -8524,6 +8528,7 @@
 	/* Challenge again, and again, and again */
 	transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 0);
 	sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+
 	return AUTH_CHALLENGE_SENT;
 }
 
@@ -8557,6 +8562,8 @@
 	switch(state) {
 	case AST_EXTENSION_DEACTIVATED:	/* Retry after a while */
 	case AST_EXTENSION_REMOVED:	/* Extension is gone */
+		if (p->autokillid > -1)
+			sip_cancel_destroy(p);	/* Remove subscription expiry for renewals */
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);	/* Delete subscription in 32 secs, possibly remove old sched. */
 		ast_verbose(VERBOSE_PREFIX_2 "Extension state: Watcher for hint %s %s. Notify User %s\n", exten, state == AST_EXTENSION_DEACTIVATED ? "deactivated" : "removed", p->username);
 		p->stateid = -1;
@@ -9257,8 +9264,8 @@
 		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));
-		if (referdata->refer_pvt)
-			referdata->refer_pvt = pvt_unref(referdata->refer_pvt);
+		if (referdata->refer_call)
+			referdata->refer_call = pvt_unref(referdata->refer_call);
 		/* Set new context */
 		ast_string_field_set(p, context, transfer_context);
 		return 0;
@@ -12021,6 +12028,7 @@
 		ast_channel_unlock(chan);
 		return -1;
 	}
+
 	if (!strcasecmp(data, "peerip")) {
 		ast_copy_string(buf, p->sa.sin_addr.s_addr ? ast_inet_ntoa(p->sa.sin_addr) : "", len);
 	} else  if (!strcasecmp(data, "recvip")) {
@@ -12355,14 +12363,13 @@
 		break;
 
 	case 481: /* Call leg does not exist */
-		/* Could be REFER or INVITE with replaces */
+		/* Could be REFER caused INVITE with replaces */
 		ast_log(LOG_WARNING, "Re-invite to non-existing call leg on other UA. SIP dialog '%s'. Giving up.\n", p->callid);
 		transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE);
 		if (p->owner)
 			ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 		break;
-
 	case 487: /* Cancelled transaction */
 		 /* We have sent CANCEL on an outbound INVITE
 			 This transaction is already scheduled to be killed by sip_hangup().
@@ -12373,7 +12380,6 @@
 		 else if (!ast_test_flag(req, SIP_PKT_IGNORE))
 			 update_call_counter(p, DEC_CALL_LIMIT);
 		 break;
-
 	case 491: /* Pending */
 		/* we really should have to wait a while, then retransmit */
 		/* We should support the retry-after at some point */
@@ -12426,6 +12432,7 @@
 		}
 		break;
 	case 481: /* Call leg does not exist */
+
 		/* A transfer with Replaces did not work */
 		/* OEJ: We should Set flag, cancel the REFER, go back
 			to original call - but right now we can't */
@@ -12443,7 +12450,6 @@
 		set_destroy(p);
 		p->refer->status = REFER_FAILED;
 		break;
-
 	case 603:   /* Transfer declined */
 		ast_log(LOG_NOTICE, "SIP transfer to %s declined, call miserably fails. \n", p->refer->refer_to);
 		p->refer->status = REFER_FAILED;
@@ -12663,8 +12669,8 @@
 
 	peer->lastms = pingtime;
 	/* XXX do we need to unlink too ? */
-	if (peer->peer_pvt)
-		peer->peer_pvt = pvt_unref(peer->peer_pvt);
+	if (peer->call)
+		peer->call = pvt_unref(peer->call);
 	if (statechanged) {
 		const char *s = is_reachable ? "Reachable" : "Lagged";
 
@@ -12840,6 +12846,7 @@
 				if (ast_strlen_zero(p->authname)) {
 					ast_log(LOG_WARNING, "Asked to authenticate %s, to %s:%d but we have no matching peer!\n",
 							msg, ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
+					/* XXX is this in or out of the block ? */
 					set_destroy(p);
 				}
 				if (p->authtries == MAX_AUTHTRIES || do_proxy_auth(p, req, 407, sipmethod, 0)) {
@@ -12872,12 +12879,10 @@
 				/* Guessing that this is not an important request */
 			}
 			break;
-
 		case 487:
 			if (sipmethod == SIP_INVITE)
 				handle_response_invite(p, resp, rest, req, seqno);
 			break;
-
 		case 491: /* Pending */
 			if (sipmethod == SIP_INVITE)
 				handle_response_invite(p, resp, rest, req, seqno);
@@ -13524,7 +13529,7 @@
 	int earlyreplace = 0;
 	int oneleggedreplace = 0;		/* Call with no bridge, propably IVR or voice message */
 	struct ast_channel *c = p->owner;	/* Our incoming call */
-	struct ast_channel *replacecall = p->refer->refer_pvt->owner;	/* The channel we're about to take over */
+	struct ast_channel *replacecall = p->refer->refer_call->owner;	/* The channel we're about to take over */
 	struct ast_channel *targetcall;		/* The bridge to the take-over target */
 
 	/* Check if we're in ring state */
@@ -13558,7 +13563,7 @@
 		transmit_response_with_sdp(p, "200 OK", req, XMIT_RELIABLE);
 		/* Do something more clever here */
 		ast_channel_unlock(c);
-		sip_pvt_unlock(p->refer->refer_pvt);
+		sip_pvt_unlock(p->refer->refer_call);
 		return 1;
 	} 
 	/* XXX this block is wrong here, we already assumed c != NULL above */
@@ -13568,7 +13573,7 @@
 		transmit_response_reliable(p, "503 Service Unavailable", req);
 		append_history(p, "Xfer", "INVITE/Replace Failed. No new channel.");
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
-		sip_pvt_unlock(p->refer->refer_pvt);
+		sip_pvt_unlock(p->refer->refer_call);
 		return 1;
 	}
 	append_history(p, "Xfer", "INVITE/Replace received");
@@ -13602,10 +13607,10 @@
 	ast_channel_unlock(c);
 
 	/* Unlock PVT */
-	sip_pvt_unlock(p->refer->refer_pvt);
+	sip_pvt_unlock(p->refer->refer_call);
 
 	/* Make sure that the masq does not free our PVT for the old call */
-	ast_set_flag(&p->refer->refer_pvt->flags[0], SIP_DEFER_BYE_ON_TRANSFER);	/* Delay hangup */
+	ast_set_flag(&p->refer->refer_call->flags[0], SIP_DEFER_BYE_ON_TRANSFER);	/* Delay hangup */
 		
 	/* Prepare the masquerade - if this does not happen, we will be gone */
 	if(ast_channel_masquerade(replacecall, c))
@@ -13643,7 +13648,7 @@
 		}
 		ast_channel_unlock(replacecall);
 	}
-	sip_pvt_unlock(p->refer->refer_pvt);
+	sip_pvt_unlock(p->refer->refer_call);
 
 	ast_setstate(c, AST_STATE_DOWN);
 	if (option_debug > 3) {
@@ -13733,6 +13738,7 @@
 		transmit_response(p, "491 Request Pending", req);
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Got INVITE on call where we already have pending INVITE, deferring that - %s\n", p->callid);
+		/* Don't destroy dialog here */
 		return 0;
 	}
 
@@ -13795,13 +13801,13 @@
 		/* Try to find call that we are replacing 
 			If we have a Replaces  header, we need to cancel that call if we succeed with this call 
 		*/
-		/* XXX do we have a previous refer_pvt ? */
-		if (p->refer->refer_pvt) {
-			ast_log(LOG_DEBUG, "-- note, refer_pvt %p for %p is going to be replaced\n",
-				p->refer->refer_pvt, p);
-			p->refer->refer_pvt = pvt_unref(p->refer->refer_pvt);
-		}
-		if ((p->refer->refer_pvt = get_sip_pvt_byid_locked(replace_id, totag, fromtag)) == NULL) {
+		/* XXX do we have a previous refer_call ? */
+		if (p->refer->refer_call) {
+			ast_log(LOG_DEBUG, "-- note, refer_call %p for %p is going to be replaced\n",
+				p->refer->refer_call, p);
+			p->refer->refer_call = pvt_unref(p->refer->refer_call);
+		}
+		if ((p->refer->refer_call = get_sip_pvt_byid_locked(replace_id, totag, fromtag)) == NULL) {
 			ast_log(LOG_NOTICE, "Supervised transfer attempted to replace non-existent call id (%s)!\n", replace_id);
 			transmit_response(p, "481 Call Leg Does Not Exist (Replaces)", req);
 			error = 1;
@@ -13813,14 +13819,14 @@
 			We want to bridge the bridged part of the call to the 
 			incoming invite, thus taking over the refered call */
 
-		if (p->refer->refer_pvt == p) {
+		if (p->refer->refer_call == p) {
 			ast_log(LOG_NOTICE, "INVITE with replaces into it's own call id (%s == %s)!\n", replace_id, p->callid);
-			p->refer->refer_pvt = pvt_unref(p->refer->refer_pvt);
+			p->refer->refer_call = pvt_unref(p->refer->refer_call);
 			transmit_response(p, "400 Bad request", req);	/* The best way to not not accept the transfer */
 			error = 1;
 		}
 
-		if (!error && !p->refer->refer_pvt->owner) {
+		if (!error && !p->refer->refer_call->owner) {
 			/* Oops, someting wrong anyway, no owner, no call */
 			ast_log(LOG_NOTICE, "Supervised transfer attempted to replace non-existing call id (%s)!\n", replace_id);
 			/* Check for better return code */
@@ -13828,7 +13834,7 @@
 			error = 1;
 		}
 
-		if (!error && p->refer->refer_pvt->owner->_state != AST_STATE_RING && p->refer->refer_pvt->owner->_state != AST_STATE_UP ) {
+		if (!error && p->refer->refer_call->owner->_state != AST_STATE_RING && p->refer->refer_call->owner->_state != AST_STATE_UP ) {
 			ast_log(LOG_NOTICE, "Supervised transfer attempted to replace non-ringing or active call id (%s)!\n", replace_id);
 			transmit_response(p, "603 Declined (Replaces)", req);
 			error = 1;
@@ -13838,9 +13844,9 @@
 			append_history(p, "Xfer", "INVITE/Replace Failed.");
 			sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 			sip_pvt_unlock(p);
-			if (p->refer->refer_pvt) {	/* XXX what's the right order here ? */
-				sip_pvt_unlock(p->refer->refer_pvt);
-				ast_channel_unlock(p->refer->refer_pvt->owner);
+			if (p->refer->refer_call) {	/* XXX what's the right order here ? */
+				sip_pvt_unlock(p->refer->refer_call);
+				ast_channel_unlock(p->refer->refer_call->owner);
 			}
 			return -1;
 		}
@@ -14109,6 +14115,7 @@
 									transmit_response(p, "488 Not acceptable here", req);
 								else
 									transmit_response_reliable(p, "488 Not acceptable here", req);
+
 							}
 						} else {
 							/* The other side is already setup for T.38 most likely so we need to acknowledge this too */
@@ -14682,7 +14689,6 @@
 	p->invitestate = INV_TERMINATED;
 
 	copy_request(&p->initreq, req);
-
 	if (sipdebug && option_debug)
 		ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
 	check_via(p, req);
@@ -14923,14 +14929,14 @@
 		}
 
 		p->subscribed = MWI_NOTIFICATION;
-		if (authpeer->mwi_pvt) {
+		if (authpeer->mwipvt) {
 			/* We only allow one subscription per peer */
-			if (authpeer->mwi_pvt != p)	/* Destroy old PVT if this is a new one */
-				sip_destroy(authpeer->mwi_pvt);
+			if (authpeer->mwipvt != p)	/* Destroy old PVT if this is a new one */
+				sip_destroy(authpeer->mwipvt);
 			else
-				pvt_unref(authpeer->mwi_pvt);
-		}
-		authpeer->mwi_pvt = pvt_ref(p);		/* Link from peer to pvt */
+				pvt_unref(authpeer->mwipvt);
+		}
+		authpeer->mwipvt = pvt_ref(p);		/* Link from peer to pvt */
 		p->relatedpeer = authpeer;	/* Link from pvt to peer */
 		/* Do not release authpeer here */
 	} else { /* At this point, Asterisk does not understand the specified event */
@@ -15328,12 +15334,12 @@
 	ast_mark(prof_memset, 0);
 	/*
 	 * There is a short window during a reload when recvfrom
-	 * might fail because __sipsock is being closed and reopened.
+	 * might fail because sipsock is being closed and reopened.
 	 * Just live with it, it is not fatal, the network could have
 	 * dropped the packet anyways.
 	 */
 	ast_mark(prof_recv, 1);
-	res = recvfrom(__sipsock, req.data, buflen, 0, (struct sockaddr *)&sin, &len);
+	res = recvfrom(sipsock, req.data, buflen, 0, (struct sockaddr *)&sin, &len);
 	ast_mark(prof_recv, 0);
 	if (res < 0) {
 #if !defined(__FreeBSD__)
@@ -15471,9 +15477,9 @@
 	
 	peer->lastmsgssent = ((newmsgs > 0x7fff ? 0x7fff0000 : (newmsgs << 16)) | (oldmsgs > 0xffff ? 0xffff : oldmsgs));
 
-	if (peer->mwi_pvt) {
+	if (peer->mwipvt) {
 		/* Base message on subscription */
-		p = pvt_ref(peer->mwi_pvt);
+		p = pvt_ref(peer->mwipvt);
 	} else {
 		/* Build temporary dialog for this message */
 		if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY))) 
@@ -15504,7 +15510,7 @@
 	time_t t = time(NULL);
 
 	if (ast_test_flag(&peer->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY) &&
-	    !peer->mwi_pvt) {	/* We don't have a subscription */
+	    !peer->mwipvt) {	/* We don't have a subscription */
 		peer->lastmsgcheck = t;	/* Reset timer */
 		return FALSE;
 	}
@@ -15749,8 +15755,8 @@
 		ast_log(LOG_NOTICE, "Peer '%s' is now UNREACHABLE!  Last qualify: %d\n", peer->name, peer->lastms);
 		manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Unreachable\r\nTime: %d\r\n", peer->name, -1);
 	}
-	if (peer->peer_pvt)
-		peer->peer_pvt = sip_destroy(peer->peer_pvt);
+	if (peer->call)
+		peer->call = sip_destroy(peer->call);
 	peer->lastms = -1;
 	ast_device_state_changed("SIP/%s", peer->name);
 	/* Try again quickly */
@@ -15772,16 +15778,16 @@
 			ast_sched_del(sched, peer->pokeexpire);
 		peer->lastms = 0;
 		peer->pokeexpire = -1;
-		if (peer->peer_pvt)	/* XXX or sip_destroy() ? */
-			peer->peer_pvt = sip_destroy(peer->peer_pvt);
+		if (peer->call)	/* XXX or sip_destroy() ? */
+			peer->call = sip_destroy(peer->call);
 		return 0;
 	}
-	if (peer->peer_pvt) {
+	if (peer->call) {
 		if (sipdebug)
 			ast_log(LOG_NOTICE, "Still have a QUALIFY dialog active, deleting\n");
-		peer->peer_pvt = sip_destroy(peer->peer_pvt);
-	}
-	if (!(p = peer->peer_pvt = sip_alloc(NULL, NULL, 0, SIP_OPTIONS)))
+		peer->call = sip_destroy(peer->call);
+	}
+	if (!(p = peer->call = sip_alloc(NULL, NULL, 0, SIP_OPTIONS)))
 		return -1;
 	
 	p->sa = peer->addr;
@@ -17111,11 +17117,11 @@
 	 * At the beginning, sipsock = -1 and old_bindaddr = 0:0 so
 	 * we detect a change easily.
 	 */
-	if (__sipsock == -1 || memcmp(&old_bindaddr, &bindaddr, sizeof(struct sockaddr_in))) {
+	if (sipsock == -1 || memcmp(&old_bindaddr, &bindaddr, sizeof(struct sockaddr_in))) {
 		/* address changed, or previous open failed */
-		int my_socket = __sipsock;
-
-		__sipsock = -1;	/* it is changing... */
+		int my_socket = sipsock;
+
+		sipsock = -1;	/* it is changing... */
 		if (my_socket > -1) {
 			ast_io_remove(io, sipsock_read_id);
 			close(my_socket);
@@ -17146,8 +17152,8 @@
 					ast_log(LOG_WARNING, "Unable to set SIP TOS to %s\n", ast_tos2str(global_tos_sip));
 				else if (option_verbose > 1)
 					ast_verbose(VERBOSE_PREFIX_2 "Using SIP TOS: %s\n", ast_tos2str(global_tos_sip));
-				__sipsock = my_socket;
-				sipsock_read_id = ast_io_add(io, __sipsock, sipsock_read, AST_IO_IN, NULL);
+				sipsock = my_socket;
+				sipsock_read_id = ast_io_add(io, sipsock, sipsock_read, AST_IO_IN, NULL);
 			}
 		}
 	}
@@ -17932,7 +17938,7 @@
 
 	clear_realm_authentication(authl);
 	clear_sip_domains();
-	close(__sipsock);
+	close(sipsock);
 	sched_context_destroy(sched);
 		
 	return 0;



More information about the svn-commits mailing list