[asterisk-commits] branch oej/jitterbuffer r15250 - in /team/oej/jitterbuffer: ./ channels/ chan...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Mar 27 09:26:00 MST 2006


Author: oej
Date: Mon Mar 27 10:25:58 2006
New Revision: 15250

URL: http://svn.digium.com/view/asterisk?rev=15250&view=rev
Log:
Resolve, reset, go!

Modified:
    team/oej/jitterbuffer/   (props changed)
    team/oej/jitterbuffer/channels/chan_misdn.c
    team/oej/jitterbuffer/channels/chan_sip.c
    team/oej/jitterbuffer/channels/misdn/isdn_lib.c

Propchange: team/oej/jitterbuffer/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Propchange: team/oej/jitterbuffer/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Mar 27 10:25:58 2006
@@ -1,1 +1,1 @@
-/trunk:1-15184
+/trunk:1-15249

Modified: team/oej/jitterbuffer/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer/channels/chan_misdn.c?rev=15250&r1=15249&r2=15250&view=diff
==============================================================================
--- team/oej/jitterbuffer/channels/chan_misdn.c (original)
+++ team/oej/jitterbuffer/channels/chan_misdn.c Mon Mar 27 10:25:58 2006
@@ -3324,6 +3324,16 @@
 			
 		}
 
+		/* check if we should jump into s when we have no dad */
+		{
+			int im;
+			misdn_cfg_get( bc->port, MISDN_CFG_IMMEDIATE, &im, sizeof(im));
+			if ( im && ast_strlen_zero(bc->dad) ) {
+				do_immediate_setup(bc, ch , chan);
+				break;
+			}
+		}
+
 		
 			chan_misdn_log(5,bc->port,"CONTEXT:%s\n",ch->context);
 			if(!ast_canmatch_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {

Modified: team/oej/jitterbuffer/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/jitterbuffer/channels/chan_sip.c?rev=15250&r1=15249&r2=15250&view=diff
==============================================================================
--- team/oej/jitterbuffer/channels/chan_sip.c (original)
+++ team/oej/jitterbuffer/channels/chan_sip.c Mon Mar 27 10:25:58 2006
@@ -444,8 +444,7 @@
 static int apeerobjs = 0;		/*!< Autocreated peer objects */
 static int regobjs = 0;			/*!< Registry objects */
 
-static struct ast_flags global_flags = {0};		/*!< global SIP_ flags */
-static struct ast_flags global_flags_page2 = {0};	/*!< more global SIP_ flags */
+static struct ast_flags global_flags[2] = {{0}};	/*!< global SIP_ flags */
 
 AST_MUTEX_DEFINE_STATIC(usecnt_lock);
 
@@ -635,9 +634,9 @@
 #define SIP_PKT_DEBUG		(1 << 0)	/*!< Debug this packet */
 #define SIP_PKT_WITH_TOTAG	(1 << 1)	/*!< This packet has a to-tag */
 
-#define sipdebug		ast_test_flag(&global_flags_page2, SIP_PAGE2_DEBUG)
-#define sipdebug_config		ast_test_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONFIG)
-#define sipdebug_console	ast_test_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONSOLE)
+#define sipdebug		ast_test_flag(&global_flags[1], SIP_PAGE2_DEBUG)
+#define sipdebug_config		ast_test_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONFIG)
+#define sipdebug_console	ast_test_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONSOLE)
 
 /*! \brief sip_pvt: PVT structures are used for each SIP dialog, ie. a call, a registration, a subscribe  */
 static struct sip_pvt {
@@ -689,8 +688,7 @@
 	ast_group_t callgroup;			/*!< Call group */
 	ast_group_t pickupgroup;		/*!< Pickup group */
 	int lastinvite;				/*!< Last Cseq of invite */
-	unsigned int flags;			/*!< SIP_ flags */	
-	struct ast_flags flags_page2;		/*!< SIP PAGE2 flags */
+	struct ast_flags flags[2];		/*!< SIP_ flags */
 	int timer_t1;				/*!< SIP timer T1, ms rtt */
 	unsigned int sipoptions;		/*!< Supported SIP sipoptions on the other end */
 	int capability;				/*!< Special capability (codec) */
@@ -792,9 +790,8 @@
 	struct ast_codec_pref prefs;	/*!< codec prefs */
 	ast_group_t callgroup;		/*!< Call group */
 	ast_group_t pickupgroup;	/*!< Pickup Group */
-	unsigned int flags;		/*!< SIP flags */	
 	unsigned int sipoptions;	/*!< Supported SIP options */
-	struct ast_flags flags_page2;	/*!< SIP_PAGE2 flags */
+	struct ast_flags flags[2];	/*!< SIP_ flags */
 	int amaflags;			/*!< AMA flags for billing */
 	int callingpres;		/*!< Calling id presentation */
 	int capability;			/*!< Codec capability */
@@ -835,9 +832,8 @@
 	struct ast_codec_pref prefs;	/*!<  codec prefs */
 	int lastmsgssent;
 	time_t	lastmsgcheck;		/*!<  Last time we checked for MWI */
-	unsigned int flags;		/*!<  SIP flags */	
 	unsigned int sipoptions;	/*!<  Supported SIP options */
-	struct ast_flags flags_page2;	/*!<  SIP_PAGE2 flags */
+	struct ast_flags flags[2];	/*!<  SIP_ flags */
 	int expire;			/*!<  When to expire this peer registration */
 	int capability;			/*!<  Codec capability */
 	int rtptimeout;			/*!<  RTP timeout */
@@ -1151,7 +1147,7 @@
 {
 	if (!sipdebug)
 		return 0;
-	return sip_debug_test_addr(((ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE) ? &p->recv : &p->sa));
+	return sip_debug_test_addr(ast_test_flag(&p->flags[0], SIP_NAT_ROUTE) ? &p->recv : &p->sa);
 }
 
 
@@ -1161,7 +1157,7 @@
 	int res;
 	char iabuf[INET_ADDRSTRLEN];
 
-	if (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE)
+	if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE))
 		res=sendto(sipsock, data, len, 0, (struct sockaddr *)&p->recv, sizeof(struct sockaddr_in));
 	else
 		res=sendto(sipsock, data, len, 0, (struct sockaddr *)&p->sa, sizeof(struct sockaddr_in));
@@ -1178,7 +1174,7 @@
 {
 	char iabuf[INET_ADDRSTRLEN];
 	/* Work around buggy UNIDEN UIP200 firmware */
-	const char *rport = ast_test_flag(p, SIP_NAT) & SIP_NAT_RFC3581 ? ";rport" : "";
+	const char *rport = ast_test_flag(&p->flags[0], SIP_NAT) & SIP_NAT_RFC3581 ? ";rport" : "";
 
 	/* z9hG4bK is a magic cookie.  See RFC 3261 section 8.1.1.7 */
 	ast_string_field_build(p, via, "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x%s",
@@ -1302,7 +1298,7 @@
  		} 
 
 		if (pkt->owner && sip_debug_test_pvt(pkt->owner)) {
-			if (ast_test_flag(pkt->owner, SIP_NAT) & SIP_NAT_ROUTE)
+			if (ast_test_flag(&pkt->owner->flags[0], SIP_NAT_ROUTE))
 				ast_verbose("Retransmitting #%d (NAT) to %s:%d:\n%s\n---\n", pkt->retrans, ast_inet_ntoa(iabuf, sizeof(iabuf), pkt->owner->recv.sin_addr), ntohs(pkt->owner->recv.sin_port), pkt->data);
 			else
 				ast_verbose("Retransmitting #%d (no NAT) to %s:%d:\n%s\n---\n", pkt->retrans, ast_inet_ntoa(iabuf, sizeof(iabuf), pkt->owner->sa.sin_addr), ntohs(pkt->owner->sa.sin_port), pkt->data);
@@ -1332,13 +1328,13 @@
 			ast_mutex_lock(&pkt->owner->lock);
 		}
 		if (pkt->owner->owner) {
-			ast_set_flag(pkt->owner, SIP_ALREADYGONE);
+			ast_set_flag(&pkt->owner->flags[0], SIP_ALREADYGONE);
 			ast_log(LOG_WARNING, "Hanging up call %s - no reply to our critical packet.\n", pkt->owner->callid);
 			ast_queue_hangup(pkt->owner->owner);
 			ast_mutex_unlock(&pkt->owner->owner->lock);
 		} else {
 			/* If no channel owner, destroy now */
-			ast_set_flag(pkt->owner, SIP_NEEDDESTROY);	
+			ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY);	
 		}
 	}
 	/* In any case, go ahead and remove the packet */
@@ -1576,7 +1572,7 @@
 
 	if (sip_debug_test_pvt(p)) {
 		char iabuf[INET_ADDRSTRLEN];
-		if (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE)
+		if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE))
 			ast_verbose("%sTransmitting (NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port), req->data);
 		else
 			ast_verbose("%sTransmitting (no NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port), req->data);
@@ -1601,7 +1597,7 @@
 
 	if (sip_debug_test_pvt(p)) {
 		char iabuf[INET_ADDRSTRLEN];
-		if (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE)
+		if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE))
 			ast_verbose("%sTransmitting (NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port), req->data);
 		else
 			ast_verbose("%sTransmitting (no NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port), req->data);
@@ -1736,9 +1732,9 @@
 		ast_sched_del(sched, peer->pokeexpire);
 	register_peer_exten(peer, FALSE);
 	ast_free_ha(peer->ha);
-	if (ast_test_flag((&peer->flags_page2), SIP_PAGE2_SELFDESTRUCT))
+	if (ast_test_flag(&peer->flags[1], SIP_PAGE2_SELFDESTRUCT))
 		apeerobjs--;
-	else if (ast_test_flag(peer, SIP_REALTIME))
+	else if (ast_test_flag(&peer->flags[0], SIP_REALTIME))
 		rpeerobjs--;
 	else
 		speerobjs--;
@@ -1752,9 +1748,9 @@
 /*! \brief Update peer data in database (if used) */
 static void update_peer(struct sip_peer *p, int expiry)
 {
-	int rtcachefriends = ast_test_flag(&(p->flags_page2), SIP_PAGE2_RTCACHEFRIENDS);
-	if (ast_test_flag((&global_flags_page2), SIP_PAGE2_RTUPDATE) &&
-		(ast_test_flag(p, SIP_REALTIME) || rtcachefriends)) {
+	int rtcachefriends = ast_test_flag(&p->flags[1], SIP_PAGE2_RTCACHEFRIENDS);
+	if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTUPDATE) &&
+	    (ast_test_flag(&p->flags[0], SIP_REALTIME) || rtcachefriends)) {
 		realtime_update_peer(p->name, &p->addr, p->username, rtcachefriends ? p->fullcontact : NULL, expiry);
 	}
 }
@@ -1806,16 +1802,16 @@
 	}
 
 	/* Peer found in realtime, now build it in memory */
-	peer = build_peer(newpeername, var, !ast_test_flag((&global_flags_page2), SIP_PAGE2_RTCACHEFRIENDS));
+	peer = build_peer(newpeername, var, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
 	if (!peer) {
 		ast_variables_destroy(var);
 		return (struct sip_peer *) NULL;
 	}
 
-	if (ast_test_flag((&global_flags_page2), SIP_PAGE2_RTCACHEFRIENDS)) {
+	if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
 		/* Cache peer */
-		ast_copy_flags((&peer->flags_page2),(&global_flags_page2), SIP_PAGE2_RTAUTOCLEAR|SIP_PAGE2_RTCACHEFRIENDS);
-		if (ast_test_flag((&global_flags_page2), SIP_PAGE2_RTAUTOCLEAR)) {
+		ast_copy_flags(&peer->flags[1],&global_flags[1], SIP_PAGE2_RTAUTOCLEAR|SIP_PAGE2_RTCACHEFRIENDS);
+		if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
 			if (peer->expire > -1) {
 				ast_sched_del(sched, peer->expire);
 			}
@@ -1823,7 +1819,7 @@
 		}
 		ASTOBJ_CONTAINER_LINK(&peerl,peer);
 	} else {
-		ast_set_flag(peer, SIP_REALTIME);
+		ast_set_flag(&peer->flags[0], SIP_REALTIME);
 	}
 	ast_variables_destroy(var);
 
@@ -1836,7 +1832,7 @@
 	/* We know name is the first field, so we can cast */
 	struct sip_peer *p = (struct sip_peer *) name;
 	return 	!(!inaddrcmp(&p->addr, sin) || 
-					(ast_test_flag(p, SIP_INSECURE_PORT) &&
+					(ast_test_flag(&p->flags[0], SIP_INSECURE_PORT) &&
 					(p->addr.sin_addr.s_addr == sin->sin_addr.s_addr)));
 }
 
@@ -1868,7 +1864,7 @@
 		ast_variables_destroy(user->chanvars);
 		user->chanvars = NULL;
 	}
-	if (ast_test_flag(user, SIP_REALTIME))
+	if (ast_test_flag(&user->flags[0], SIP_REALTIME))
 		ruserobjs--;
 	else
 		suserobjs--;
@@ -1897,22 +1893,22 @@
 		}
 	}
 
-	user = build_user(username, var, !ast_test_flag((&global_flags_page2), SIP_PAGE2_RTCACHEFRIENDS));
+	user = build_user(username, var, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
 	
 	if (!user) {	/* No user found */
 		ast_variables_destroy(var);
 		return NULL;
 	}
 
-	if (ast_test_flag((&global_flags_page2), SIP_PAGE2_RTCACHEFRIENDS)) {
-		ast_set_flag((&user->flags_page2), SIP_PAGE2_RTCACHEFRIENDS);
+	if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
+		ast_set_flag(&user->flags[1], SIP_PAGE2_RTCACHEFRIENDS);
 		suserobjs++;
 		ASTOBJ_CONTAINER_LINK(&userl,user);
 	} else {
 		/* Move counter from s to r... */
 		suserobjs--;
 		ruserobjs++;
-		ast_set_flag(user, SIP_REALTIME);
+		ast_set_flag(&user->flags[0], SIP_REALTIME);
 	}
 	ast_variables_destroy(var);
 	return user;
@@ -1951,23 +1947,23 @@
 		return -1;
 	}
 
-	ast_copy_flags(r, peer, SIP_FLAGS_TO_COPY);
-	ast_copy_flags((&r->flags_page2),(&peer->flags_page2), SIP_PAGE2_FLAGS_TO_COPY);
+	ast_copy_flags(&r->flags[0], &peer->flags[0], SIP_FLAGS_TO_COPY);
+	ast_copy_flags(&r->flags[1], &peer->flags[1], SIP_PAGE2_FLAGS_TO_COPY);
 	r->capability = peer->capability;
-	if (!ast_test_flag((&r->flags_page2), SIP_PAGE2_VIDEOSUPPORT) && r->vrtp) {
+	if (!ast_test_flag(&r->flags[0], SIP_PAGE2_VIDEOSUPPORT) && r->vrtp) {
 		ast_rtp_destroy(r->vrtp);
 		r->vrtp = NULL;
 	}
 	r->prefs = peer->prefs;
 	if (r->rtp) {
 		if (option_debug)
-			ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE));
-		ast_rtp_setnat(r->rtp, (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE));
+			ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", (ast_test_flag(&r->flags[0], SIP_NAT) & SIP_NAT_ROUTE));
+		ast_rtp_setnat(r->rtp, (ast_test_flag(&r->flags[0], SIP_NAT) & SIP_NAT_ROUTE));
 	}
 	if (r->vrtp) {
 		if (option_debug)
-			ast_log(LOG_DEBUG, "Setting NAT on VRTP to %d\n", (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE));
-		ast_rtp_setnat(r->vrtp, (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE));
+			ast_log(LOG_DEBUG, "Setting NAT on VRTP to %d\n", (ast_test_flag(&r->flags[0], SIP_NAT) & SIP_NAT_ROUTE));
+		ast_rtp_setnat(r->vrtp, (ast_test_flag(&r->flags[0], SIP_NAT) & SIP_NAT_ROUTE));
 	}
 	ast_string_field_set(r, peername, peer->username);
 	ast_string_field_set(r, authname, peer->username);
@@ -2006,7 +2002,8 @@
 	/* Minimum is settable or default to 100 ms */
 	if (peer->maxms && peer->lastms)
 		r->timer_t1 = peer->lastms < global_t1min ? global_t1min : peer->lastms;
-	if ((ast_test_flag(r, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(r, SIP_DTMF) == SIP_DTMF_AUTO))
+	if ((ast_test_flag(&r->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833) ||
+	    (ast_test_flag(&r->flags[0], SIP_DTMF) == SIP_DTMF_AUTO))
 		r->noncodeccapability |= AST_RTP_DTMF;
 	else
 		r->noncodeccapability &= ~AST_RTP_DTMF;
@@ -2015,7 +2012,7 @@
 	r->rtpholdtimeout = peer->rtpholdtimeout;
 	r->rtpkeepalive = peer->rtpkeepalive;
 	if (peer->call_limit)
-		ast_set_flag(r, SIP_CALL_LIMIT);
+		ast_set_flag(&r->flags[0], SIP_CALL_LIMIT);
 	r->maxcallbitrate = peer->maxcallbitrate;
 	
 	return 0;
@@ -2153,7 +2150,7 @@
 	}
 	
 	res = 0;
-	ast_set_flag(p, SIP_OUTGOING);
+	ast_set_flag(&p->flags[0], SIP_OUTGOING);
 #ifdef OSP_SUPPORT
 	if (!p->options->osptoken || !osphandle || (sscanf(osphandle, "%d", &p->osphandle) != 1)) {
 		/* Force Disable OSP support */
@@ -2319,7 +2316,7 @@
 {
 	char name[256];
 	int *inuse, *call_limit;
-	int outgoing = ast_test_flag(fup, SIP_OUTGOING);
+	int outgoing = ast_test_flag(&fup->flags[0], SIP_OUTGOING);
 	struct sip_user *u = NULL;
 	struct sip_peer *p = NULL;
 
@@ -2327,7 +2324,7 @@
 		ast_log(LOG_DEBUG, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
 	/* Test if we need to check call limits, in order to avoid 
 	   realtime lookups if we do not need it */
-	if (!ast_test_flag(fup, SIP_CALL_LIMIT))
+	if (!ast_test_flag(&fup->flags[0], SIP_CALL_LIMIT))
 		return 0;
 
 	ast_copy_string(name, fup->username, sizeof(name));
@@ -2358,7 +2355,7 @@
 		/* incoming and outgoing affects the inUse counter */
 		case DEC_CALL_LIMIT:
 			if ( *inuse > 0 ) {
-				if (ast_test_flag(fup, SIP_INC_COUNT))
+				if (ast_test_flag(&fup->flags[0], SIP_INC_COUNT))
 					(*inuse)--;
 			} else {
 				*inuse = 0;
@@ -2379,7 +2376,7 @@
 				}
 			}
 			(*inuse)++;
-			ast_set_flag(fup, SIP_INC_COUNT);
+			ast_set_flag(&fup->flags[0], SIP_INC_COUNT);
 			if (option_debug > 1 || sipdebug) {
 				ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
 			}
@@ -2615,9 +2612,9 @@
 	ast_set_flag(&locflags, SIP_NEEDDESTROY);	
 
 	/* Start the process if it's not already started */
-	if (!ast_test_flag(p, SIP_ALREADYGONE) && !ast_strlen_zero(p->initreq.data)) {
+	if (!ast_test_flag(&p->flags[0], SIP_ALREADYGONE) && !ast_strlen_zero(p->initreq.data)) {
 		if (needcancel) {	/* Outgoing call, not up */
-			if (ast_test_flag(p, SIP_OUTGOING)) {
+			if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
 				/* stop retransmitting an INVITE that has not received a response */
 				__sip_pretend_ack(p);
 
@@ -2647,12 +2644,12 @@
 			} else {
 				/* Note we will need a BYE when this all settles out
 				   but we can't send one while we have "INVITE" outstanding. */
-				ast_set_flag(p, SIP_PENDINGBYE);	
-				ast_clear_flag(p, SIP_NEEDREINVITE);	
+				ast_set_flag(&p->flags[0], SIP_PENDINGBYE);	
+				ast_clear_flag(&p->flags[0], SIP_NEEDREINVITE);	
 			}
 		}
 	}
-	ast_copy_flags(p, (&locflags), SIP_NEEDDESTROY);	
+	ast_copy_flags(&p->flags[0], &locflags, SIP_NEEDDESTROY);	
 	ast_mutex_unlock(&p->lock);
 	return 0;
 }
@@ -2720,9 +2717,11 @@
 			ast_mutex_lock(&p->lock);
 			if (p->rtp) {
 				/* If channel is not up, activate early media session */
-				if ((ast->_state != AST_STATE_UP) && !ast_test_flag(p, SIP_PROGRESS_SENT) && !ast_test_flag(p, SIP_OUTGOING)) {
+				if ((ast->_state != AST_STATE_UP) &&
+				    !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
+				    !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
 					transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, XMIT_UNRELIABLE);
-					ast_set_flag(p, SIP_PROGRESS_SENT);	
+					ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);	
 				}
 				time(&p->lastrtptx);
 				res =  ast_rtp_write(p->rtp, frame);
@@ -2735,9 +2734,11 @@
 			ast_mutex_lock(&p->lock);
 			if (p->vrtp) {
 				/* Activate video early media */
-				if ((ast->_state != AST_STATE_UP) && !ast_test_flag(p, SIP_PROGRESS_SENT) && !ast_test_flag(p, SIP_OUTGOING)) {
+				if ((ast->_state != AST_STATE_UP) &&
+				    !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
+				    !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
 					transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, XMIT_UNRELIABLE);
-					ast_set_flag(p, SIP_PROGRESS_SENT);	
+					ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);	
 				}
 				time(&p->lastrtptx);
 				res =  ast_rtp_write(p->vrtp, frame);
@@ -2780,7 +2781,7 @@
 	int res = 0;
 
 	ast_mutex_lock(&p->lock);
-	switch (ast_test_flag(p, SIP_DTMF)) {
+	switch (ast_test_flag(&p->flags[0], SIP_DTMF)) {
 	case SIP_DTMF_INFO:
 		transmit_info_with_digit(p, digit);
 		break;
@@ -2825,12 +2826,12 @@
 	switch(condition) {
 	case AST_CONTROL_RINGING:
 		if (ast->_state == AST_STATE_RING) {
-			if (!ast_test_flag(p, SIP_PROGRESS_SENT) ||
-			    (ast_test_flag(p, SIP_PROG_INBAND) == SIP_PROG_INBAND_NEVER)) {				
+			if (!ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) ||
+			    (ast_test_flag(&p->flags[0], SIP_PROG_INBAND) == SIP_PROG_INBAND_NEVER)) {				
 				/* Send 180 ringing if out-of-band seems reasonable */
 				transmit_response(p, "180 Ringing", &p->initreq);
-				ast_set_flag(p, SIP_RINGING);
-				if (ast_test_flag(p, SIP_PROG_INBAND) != SIP_PROG_INBAND_YES)
+				ast_set_flag(&p->flags[0], SIP_RINGING);
+				if (ast_test_flag(&p->flags[0], SIP_PROG_INBAND) != SIP_PROG_INBAND_YES)
 					break;
 			} else {
 				/* Well, if it's not reasonable, just send in-band */
@@ -2841,7 +2842,7 @@
 	case AST_CONTROL_BUSY:
 		if (ast->_state != AST_STATE_UP) {
 			transmit_response(p, "486 Busy Here", &p->initreq);
-			ast_set_flag(p, SIP_ALREADYGONE);	
+			ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
 			ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
 			break;
 		}
@@ -2850,23 +2851,27 @@
 	case AST_CONTROL_CONGESTION:
 		if (ast->_state != AST_STATE_UP) {
 			transmit_response(p, "503 Service Unavailable", &p->initreq);
-			ast_set_flag(p, SIP_ALREADYGONE);	
+			ast_set_flag(&p->flags[0], SIP_ALREADYGONE);	
 			ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
 			break;
 		}
 		res = -1;
 		break;
 	case AST_CONTROL_PROCEEDING:
-		if ((ast->_state != AST_STATE_UP) && !ast_test_flag(p, SIP_PROGRESS_SENT) && !ast_test_flag(p, SIP_OUTGOING)) {
+		if ((ast->_state != AST_STATE_UP) &&
+		    !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
+		    !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
 			transmit_response(p, "100 Trying", &p->initreq);
 			break;
 		}
 		res = -1;
 		break;
 	case AST_CONTROL_PROGRESS:
-		if ((ast->_state != AST_STATE_UP) && !ast_test_flag(p, SIP_PROGRESS_SENT) && !ast_test_flag(p, SIP_OUTGOING)) {
+		if ((ast->_state != AST_STATE_UP) &&
+		    !ast_test_flag(&p->flags[0], SIP_PROGRESS_SENT) &&
+		    !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
 			transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, XMIT_UNRELIABLE);
-			ast_set_flag(p, SIP_PROGRESS_SENT);	
+			ast_set_flag(&p->flags[0], SIP_PROGRESS_SENT);	
 			break;
 		}
 		res = -1;
@@ -2882,7 +2887,7 @@
 		res = -1;
 		break;
 	case AST_CONTROL_VIDUPDATE:	/* Request a video frame update */
-		if (p->vrtp && !ast_test_flag(p, SIP_NOVIDEO)) {
+		if (p->vrtp && !ast_test_flag(&p->flags[0], SIP_NOVIDEO)) {
 			transmit_info_with_vidupdate(p);
 			/* ast_rtcp_send_h261fur(p->vrtp); */
 			res = 0;
@@ -2943,7 +2948,7 @@
 	else
 		ast_string_field_build(tmp, name, "SIP/%s-%08x", i->fromdomain, (int)(long)(i));
 
-	if (ast_test_flag(i, SIP_DTMF) ==  SIP_DTMF_INBAND) {
+	if (ast_test_flag(&i->flags[0], SIP_DTMF) ==  SIP_DTMF_INBAND) {
 		i->vad = ast_dsp_new();
 		ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
 		if (global_relaxdtmf)
@@ -3156,7 +3161,8 @@
 		f = &ast_null_frame;
 	}
 	/* Don't forward RFC2833 if we're not supposed to */
-	if (f && (f->frametype == AST_FRAME_DTMF) && (ast_test_flag(p, SIP_DTMF) != SIP_DTMF_RFC2833))
+	if (f && (f->frametype == AST_FRAME_DTMF) &&
+	    (ast_test_flag(&p->flags[0], SIP_DTMF) != SIP_DTMF_RFC2833))
 		return &ast_null_frame;
 
 	if (p->owner) {
@@ -3169,7 +3175,7 @@
 				ast_set_read_format(p->owner, p->owner->readformat);
 				ast_set_write_format(p->owner, p->owner->writeformat);
 			}
-			if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
+			if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
 				f = ast_dsp_process(p->owner, p->vad, f);
 				if (option_debug && f && (f->frametype == AST_FRAME_DTMF)) 
 					ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
@@ -3272,8 +3278,8 @@
 		memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
 	}
 	
-	ast_copy_flags(p, &global_flags, SIP_FLAGS_TO_COPY);
-	ast_copy_flags((&p->flags_page2),(&global_flags_page2), SIP_PAGE2_FLAGS_TO_COPY);
+	ast_copy_flags(&p->flags[0], &global_flags[0], SIP_FLAGS_TO_COPY);
+	ast_copy_flags(&p->flags[1], &global_flags[1], SIP_PAGE2_FLAGS_TO_COPY);
 
 	p->branch = thread_safe_rand();	
 	make_our_tag(p->tag, sizeof(p->tag));
@@ -3282,10 +3288,11 @@
 
 	if (sip_methods[intended_method].need_rtp) {
 		p->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
-		if (ast_test_flag((&p->flags_page2), SIP_PAGE2_VIDEOSUPPORT))
+		if (ast_test_flag(&p->flags[1], SIP_PAGE2_VIDEOSUPPORT))
 			p->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
-		if (!p->rtp || (ast_test_flag((&p->flags_page2), SIP_PAGE2_VIDEOSUPPORT) && !p->vrtp)) {
-			ast_log(LOG_WARNING, "Unable to create RTP audio %s session: %s\n", ast_test_flag((&p->flags_page2), SIP_PAGE2_VIDEOSUPPORT) ? "and video" : "", strerror(errno));
+		if (!p->rtp || (ast_test_flag(&p->flags[1], SIP_PAGE2_VIDEOSUPPORT) && !p->vrtp)) {
+			ast_log(LOG_WARNING, "Unable to create RTP audio %s session: %s\n",
+				ast_test_flag(&p->flags[1], SIP_PAGE2_VIDEOSUPPORT) ? "and video" : "", strerror(errno));
 			ast_mutex_destroy(&p->lock);
 			if (p->chanvars) {
 				ast_variables_destroy(p->chanvars);
@@ -3305,12 +3312,12 @@
 
 	if (useglobal_nat && sin) {
 		/* Setup NAT structure according to global settings if we have an address */
-		ast_copy_flags(p, &global_flags, SIP_NAT);
+		ast_copy_flags(&p->flags[0], &global_flags[0], SIP_NAT);
 		memcpy(&p->recv, sin, sizeof(p->recv));
 		if (p->rtp)
-			ast_rtp_setnat(p->rtp, (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
+			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, SIP_NAT) & SIP_NAT_ROUTE));
+			ast_rtp_setnat(p->vrtp, ast_test_flag(&p->flags[0], SIP_NAT_ROUTE));
 	}
 
 	if (p->method != SIP_REGISTER)
@@ -3323,7 +3330,8 @@
 	/* Assign default music on hold class */
 	ast_string_field_set(p, musicclass, default_musicclass);
 	p->capability = global_capability;
-	if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO))
+	if ((ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833) ||
+	    (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_AUTO))
 		p->noncodeccapability |= AST_RTP_DTMF;
 	ast_string_field_set(p, context, default_context);
 
@@ -3670,7 +3678,7 @@
 		return -1;
 	}
 	sdpLineNum_iterator_init(&iterator);
-	ast_set_flag(p, SIP_NOVIDEO);	
+	ast_set_flag(&p->flags[0], SIP_NOVIDEO);	
 	while ((m = get_sdp_iterate(&iterator, req, "m"))[0] != '\0') {
 		int found = 0;
 		if ((sscanf(m, "audio %d/%d RTP/AVP %n", &x, &y, &len) == 2) ||
@@ -3696,7 +3704,7 @@
 
 		if (p->vrtp && (sscanf(m, "video %d RTP/AVP %n", &x, &len) == 1)) {
 			found = 1;
-			ast_clear_flag(p, SIP_NOVIDEO);	
+			ast_clear_flag(&p->flags[0], SIP_NOVIDEO);	
 			vportno = x;
 			/* Scan through the RTP payload types specified in a "m=" line: */
 			codecs = m + len;
@@ -3801,13 +3809,13 @@
 	p->peercapability = (peercapability | vpeercapability);
 	p->noncodeccapability = noncodeccapability & peernoncodeccapability;
 	
-	if (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO) {
-		ast_clear_flag(p, SIP_DTMF);
+	if (ast_test_flag(&p->flags[0], SIP_DTMF) == SIP_DTMF_AUTO) {
+		ast_clear_flag(&p->flags[0], SIP_DTMF);
 		if (p->noncodeccapability & AST_RTP_DTMF) {
 			/* XXX Would it be reasonable to drop the DSP at this point? XXX */
-			ast_set_flag(p, SIP_DTMF_RFC2833);
+			ast_set_flag(&p->flags[0], SIP_DTMF_RFC2833);
 		} else {
-			ast_set_flag(p, SIP_DTMF_INBAND);
+			ast_set_flag(&p->flags[0], SIP_DTMF_INBAND);
 		}
 	}
 	
@@ -3868,7 +3876,7 @@
 	if (sin.sin_addr.s_addr && !sendonly) {
 		append_history(p, "Unhold", "%s", req->data);
 
-		if (global_callevents && ast_test_flag(p, SIP_CALL_ONHOLD)) {
+		if (global_callevents && ast_test_flag(&p->flags[0], SIP_CALL_ONHOLD)) {
 			manager_event(EVENT_FLAG_CALL, "Unhold",
 				"Channel: %s\r\n"
 				"Uniqueid: %s\r\n",
@@ -3876,19 +3884,19 @@
 				p->owner->uniqueid);
 
 		}
-		ast_clear_flag(p, SIP_CALL_ONHOLD);
+		ast_clear_flag(&p->flags[0], SIP_CALL_ONHOLD);
 	} else {
 		/* No address for RTP, we're on hold */
 		append_history(p, "Hold", "%s", req->data);
 
-		if (global_callevents && !ast_test_flag(p, SIP_CALL_ONHOLD)) {
+		if (global_callevents && !ast_test_flag(&p->flags[0], SIP_CALL_ONHOLD)) {
 			manager_event(EVENT_FLAG_CALL, "Hold",
 				"Channel: %s\r\n"
 				"Uniqueid: %s\r\n",
 				p->owner->name, 
 				p->owner->uniqueid);
 		}
-		ast_set_flag(p, SIP_CALL_ONHOLD);
+		ast_set_flag(&p->flags[0], SIP_CALL_ONHOLD);
 	}
 
 	return 0;
@@ -4039,7 +4047,7 @@
 				if (rport && *(rport+6) == '=') 
 					rport = NULL;		/* We already have a parameter to rport */
 
-				if (rport && (ast_test_flag(p, SIP_NAT) == SIP_NAT_ALWAYS)) {
+				if (rport && (ast_test_flag(&p->flags[0], SIP_NAT) == SIP_NAT_ALWAYS)) {
 					/* We need to add received port - rport */
 					ast_copy_string(tmp, oh, sizeof(tmp));
 
@@ -4215,9 +4223,9 @@
 	if (!strcasestr(ot, "tag=") && strncmp(msg, "100", 3)) {
 		/* Add the proper tag if we don't have it already.  If they have specified
 		   their tag, use it.  Otherwise, use our own tag */
-		if (!ast_strlen_zero(p->theirtag) && ast_test_flag(p, SIP_OUTGOING))
+		if (!ast_strlen_zero(p->theirtag) && ast_test_flag(&p->flags[0], SIP_OUTGOING))
 			snprintf(newto, sizeof(newto), "%s;tag=%s", ot, p->theirtag);
-		else if (p->tag && !ast_test_flag(p, SIP_OUTGOING))
+		else if (p->tag && !ast_test_flag(&p->flags[0], SIP_OUTGOING))
 			snprintf(newto, sizeof(newto), "%s;tag=%s", ot, p->tag);
 		else {
 			ast_copy_string(newto, ot, sizeof(newto));
@@ -4296,7 +4304,7 @@
 		c = p->uri;
 	} else {
 		/* We have no URI, use To: or From:  header as URI (depending on direction) */
-		ast_copy_string(stripped, get_header(orig, (ast_test_flag(p, SIP_OUTGOING)) ? "To" : "From"),
+		ast_copy_string(stripped, get_header(orig, (ast_test_flag(&p->flags[0], SIP_OUTGOING)) ? "To" : "From"),
 				sizeof(stripped));
 		c = get_in_brackets(stripped);
 		n = strchr(c, ';');
@@ -4324,16 +4332,16 @@
 	if (!strcasestr(ot, "tag=") && sipmethod != SIP_CANCEL) {
 		/* Add the proper tag if we don't have it already.  If they have specified
 		   their tag, use it.  Otherwise, use our own tag */
-		if (ast_test_flag(p, SIP_OUTGOING) && !ast_strlen_zero(p->theirtag))
+		if (ast_test_flag(&p->flags[0], SIP_OUTGOING) && !ast_strlen_zero(p->theirtag))
 			snprintf(newto, sizeof(newto), "%s;tag=%s", ot, p->theirtag);
-		else if (!ast_test_flag(p, SIP_OUTGOING))
+		else if (!ast_test_flag(&p->flags[0], SIP_OUTGOING))
 			snprintf(newto, sizeof(newto), "%s;tag=%s", ot, p->tag);
 		else
 			snprintf(newto, sizeof(newto), "%s", ot);
 		ot = newto;
 	}
 
-	if (ast_test_flag(p, SIP_OUTGOING)) {
+	if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
 		add_header(req, "From", of);
 		add_header(req, "To", ot);
 	} else {
@@ -4621,7 +4629,9 @@
 	snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
 	snprintf(s, sizeof(s), "s=session\r\n");
 	snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
-	if ((p->vrtp) && (!ast_test_flag(p, SIP_NOVIDEO)) && (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */
+	if ((p->vrtp) &&
+	    (!ast_test_flag(&p->flags[0], SIP_NOVIDEO)) &&
+	    (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */
 		snprintf(b, sizeof(b), "b=CT:%d\r\n", p->maxcallbitrate);	
 	snprintf(t, sizeof(t), "t=0 0\r\n");
 
@@ -4668,7 +4678,9 @@
 	}
 
 	/* Now send any other common codecs, and non-codec formats: */
-	for (x = 1; x <= ((ast_test_flag((&p->flags_page2), SIP_PAGE2_VIDEOSUPPORT) && p->vrtp) ? AST_FORMAT_MAX_VIDEO : AST_FORMAT_MAX_AUDIO); x <<= 1) {
+	for (x = 1;
+	     x <= ((ast_test_flag(&p->flags[1], SIP_PAGE2_VIDEOSUPPORT) && p->vrtp) ? AST_FORMAT_MAX_VIDEO : AST_FORMAT_MAX_AUDIO);
+	     x <<= 1) {
 		if (!(capability & x))
 			continue;
 
@@ -4706,7 +4718,9 @@
 	ast_build_string(&m_video_next, &m_video_left, "\r\n");
 
 	len = strlen(v) + strlen(s) + strlen(o) + strlen(c) + strlen(t) + strlen(m_audio) + strlen(a_audio);
-	if ((p->vrtp) && (!ast_test_flag(p, SIP_NOVIDEO)) && (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */
+	if ((p->vrtp) &&
+	    (!ast_test_flag(&p->flags[0], SIP_NOVIDEO)) &&
+	    (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */
 		len += strlen(m_video) + strlen(a_video) + strlen(b);
 
 	add_header(resp, "Content-Type", "application/sdp");
@@ -4715,12 +4729,16 @@
 	add_line(resp, o);
 	add_line(resp, s);
 	add_line(resp, c);
-	if ((p->vrtp) && (!ast_test_flag(p, SIP_NOVIDEO)) && (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */
+	if ((p->vrtp) &&
+	    (!ast_test_flag(&p->flags[0], SIP_NOVIDEO)) &&
+	    (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */
 		add_line(resp, b);
 	add_line(resp, t);
 	add_line(resp, m_audio);
 	add_line(resp, a_audio);
-	if ((p->vrtp) && (!ast_test_flag(p, SIP_NOVIDEO)) && (capability & VIDEO_CODEC_MASK)) { /* only if video response is appropriate */
+	if ((p->vrtp) &&
+	    (!ast_test_flag(&p->flags[0], SIP_NOVIDEO)) &&
+	    (capability & VIDEO_CODEC_MASK)) { /* only if video response is appropriate */
 		add_line(resp, m_video);
 		add_line(resp, a_video);
 	}
@@ -4824,7 +4842,7 @@
 static int transmit_reinvite_with_sdp(struct sip_pvt *p)
 {
 	struct sip_request req;
-	if (ast_test_flag(p, SIP_REINVITE_UPDATE))
+	if (ast_test_flag(&p->flags[0], SIP_REINVITE_UPDATE))
 		reqprep(&req, p, SIP_UPDATE, 0, 1);
 	else 
 		reqprep(&req, p, SIP_INVITE, 0, 1);
@@ -4839,7 +4857,7 @@
 	if (sip_debug_test_pvt(p))
 		ast_verbose("%d headers, %d lines\n", p->initreq.headers, p->initreq.lines);
 	p->lastinvite = p->ocseq;
-	ast_set_flag(p, SIP_OUTGOING);
+	ast_set_flag(&p->flags[0], SIP_OUTGOING);
 	return send_request(p, &req, 1, p->ocseq);
 }
 
@@ -4965,7 +4983,7 @@
 	int x;
 	char urioptions[256]="";
 
-	if (ast_test_flag(p, SIP_USEREQPHONE)) {
+	if (ast_test_flag(&p->flags[0], SIP_USEREQPHONE)) {
 	 	char onlydigits = TRUE;
 		x=0;
 
@@ -4997,7 +5015,8 @@
 		n = p->owner->cid.cid_name;
 	}
 	/* if we are not sending RPID and user wants his callerid restricted */
-	if (!ast_test_flag(p, SIP_SENDRPID) && ((p->callingpres & AST_PRES_RESTRICTION) != AST_PRES_ALLOWED)) {
+	if (!ast_test_flag(&p->flags[0], SIP_SENDRPID) &&
+	    ((p->callingpres & AST_PRES_RESTRICTION) != AST_PRES_ALLOWED)) {
 		l = CALLERID_UNKNOWN;
 		n = l;
 	}
@@ -5070,7 +5089,7 @@
 	/* SLD: FIXME?: do Route: here too?  I think not cos this is the first request.
 	 * OTOH, then we won't have anything in p->route anyway */
 	/* Build Remote Party-ID and From */
-	if (ast_test_flag(p, SIP_SENDRPID) && (sipmethod == SIP_INVITE)) {
+	if (ast_test_flag(&p->flags[0], SIP_SENDRPID) && (sipmethod == SIP_INVITE)) {
 		build_rpid(p);
 		add_header(req, "From", p->rpid_from);
 	} else {
@@ -5515,7 +5534,7 @@
 		if (p->registry)
 			ASTOBJ_UNREF(p->registry, sip_registry_destroy);
 		r->call = NULL;
-		ast_set_flag(p, SIP_NEEDDESTROY);	
+		ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
 		/* Pretend to ACK anything just in case */
 		__sip_pretend_ack(p);
 	}
@@ -5595,7 +5614,7 @@
 		ast_string_field_set(r, callid, p->callid);
 		if (r->portno)
 			p->sa.sin_port = htons(r->portno);
-		ast_set_flag(p, SIP_OUTGOING);	/* Registration is outgoing call */
+		ast_set_flag(&p->flags[0], SIP_OUTGOING);	/* Registration is outgoing call */
 		r->call=p;			/* Save pointer to SIP packet */
 		p->registry = ASTOBJ_REF(r);	/* Add pointer to registry in packet */
 		if (!ast_strlen_zero(r->secret))	/* Secret (password) */
@@ -5740,7 +5759,7 @@
 	char *of, *c;
 	char referto[256];
 
-	if (ast_test_flag(p, SIP_OUTGOING)) 
+	if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) 
 		of = get_header(&p->initreq, "To");
 	else
 		of = get_header(&p->initreq, "From");
@@ -5840,8 +5859,8 @@
 /*! \brief Remove registration data from realtime database and AST/DB when registration expires */
 static void destroy_association(struct sip_peer *peer)
 {
-	if (!ast_test_flag((&global_flags_page2), SIP_PAGE2_IGNOREREGEXPIRE)) {
-		if (ast_test_flag(&(peer->flags_page2), SIP_PAGE2_RT_FROMCONTACT)) {
+	if (!ast_test_flag(&global_flags[1], SIP_PAGE2_IGNOREREGEXPIRE)) {
+		if (ast_test_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT)) {
 			ast_update_realtime("sippeers", "name", peer->name, "fullcontact", "", "ipaddr", "", "port", "", "regseconds", "0", "username", "", NULL);
 		} else {
 			ast_db_del("SIP/Registry", peer->name);
@@ -5862,7 +5881,8 @@
 	register_peer_exten(peer, FALSE);
 	peer->expire = -1;
 	ast_device_state_changed("SIP/%s", peer->name);
-	if (ast_test_flag((&peer->flags_page2), SIP_PAGE2_SELFDESTRUCT) || ast_test_flag((&peer->flags_page2), SIP_PAGE2_RTAUTOCLEAR)) {
+	if (ast_test_flag(&peer->flags[1], SIP_PAGE2_SELFDESTRUCT) ||
+	    ast_test_flag(&peer->flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
 		peer = ASTOBJ_CONTAINER_UNLINK(&peerl, peer);
 		ASTOBJ_UNREF(peer, sip_destroy_peer);
 	}
@@ -5890,7 +5910,7 @@
 	int port;
 	char *scan, *addr, *port_str, *expiry_str, *username, *contact;
 
-	if (ast_test_flag(&(peer->flags_page2), SIP_PAGE2_RT_FROMCONTACT)) 
+	if (ast_test_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT)) 
 		return;
 	if (ast_db_get("SIP/Registry", peer->name, data, sizeof(data)))
 		return;
@@ -5991,7 +6011,7 @@
 
 	memcpy(&oldsin, &pvt->sa, sizeof(oldsin));
 
-	if (!(ast_test_flag(pvt, SIP_NAT) & SIP_NAT_ROUTE)) {
+	if (!ast_test_flag(&pvt->flags[0], SIP_NAT_ROUTE)) {
 		/* XXX This could block for a long time XXX */
 		/* We should only do this if it's a name, not an IP */
 		hp = ast_gethostbyname(n, &ahp);
@@ -6114,7 +6134,7 @@
 	} else
 		port = DEFAULT_SIP_PORT;
 	memcpy(&oldsin, &p->addr, sizeof(oldsin));
-	if (!(ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE)) {
+	if (!ast_test_flag(&p->flags[0], SIP_NAT_ROUTE)) {
 		/* XXX This could block for a long time XXX */
 		hp = ast_gethostbyname(n, &ahp);
 		if (!hp)  {
@@ -6141,13 +6161,13 @@
 		expiry = max_expiry;
 	if (expiry < min_expiry)
 		expiry = min_expiry;
-	if (!ast_test_flag(p, SIP_REALTIME))
+	if (!ast_test_flag(&p->flags[0], SIP_REALTIME))
 		p->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, p);
 	else
 		p->expire = -1;
 	pvt->expiry = expiry;
 	snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username, p->fullcontact);
-	if (!ast_test_flag((&p->flags_page2), SIP_PAGE2_RT_FROMCONTACT)) 
+	if (!ast_test_flag(&p->flags[1], SIP_PAGE2_RT_FROMCONTACT)) 
 		ast_db_put("SIP/Registry", p->name, data);
 	manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Registered\r\n", p->name);
 	if (inaddrcmp(&p->addr, &oldsin)) {
@@ -6331,7 +6351,7 @@
 	/* Always OK if no secret */
 	if (ast_strlen_zero(secret) && ast_strlen_zero(md5secret)
 #ifdef OSP_SUPPORT
-	    && !ast_test_flag(p, SIP_OSPAUTH)
+	    && !ast_test_flag(&p->flags[0], SIP_OSPAUTH)
 	    && global_allowguest != 2
 #endif
 		)
@@ -6350,7 +6370,7 @@
 		if (option_debug)
 			ast_log (LOG_DEBUG, "Checking OSP Authentication!\n");
 		osptoken = get_header (req, "P-OSP-Auth-Token");
-		switch (ast_test_flag (p, SIP_OSPAUTH)) {
+		switch (ast_test_flag(&p->flags[0], SIP_OSPAUTH)) {
 			case SIP_OSPAUTH_NO:
 				break;
 			case SIP_OSPAUTH_GATEWAY:
@@ -6594,10 +6614,10 @@
 			ASTOBJ_UNREF(peer, sip_destroy_peer);
 	}
 	if (peer) {
-		if (!ast_test_flag((&peer->flags_page2), SIP_PAGE2_DYNAMIC)) {
+		if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC)) {
 			ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name);
 		} else {
-			ast_copy_flags(p, peer, SIP_NAT);
+			ast_copy_flags(&p->flags[0], &peer->flags[0], SIP_NAT);
 			transmit_response(p, "100 Trying", req);
 			if (!(res = check_auth(p, req, peer->name, peer->secret, peer->md5secret, SIP_REGISTER, uri, XMIT_UNRELIABLE, ignore))) {
 				sip_cancel_destroy(p);
@@ -7029,7 +7049,7 @@
 	/* Check for rport */
 	c = strstr(via, ";rport");
 	if (c && (c[6] != '='))	/* rport query, not answer */
-		ast_set_flag(p, SIP_NAT_ROUTE);
+		ast_set_flag(&p->flags[0], SIP_NAT_ROUTE);
 
 	c = strchr(via, ';');
 	if (c) 
@@ -7057,7 +7077,7 @@
 		p->sa.sin_port = htons(pt ? atoi(pt) : DEFAULT_SIP_PORT);
 
 		if (sip_debug_test_pvt(p)) {
-			c = (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE) ? "NAT" : "non-NAT";
+			c = (ast_test_flag(&p->flags[0], SIP_NAT) & SIP_NAT_ROUTE) ? "NAT" : "non-NAT";
 			ast_verbose("Sending to %s : %d (%s)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port), c);
 		}
 	}
@@ -7155,6 +7175,7 @@
 	char calleridname[50];
 	int debug=sip_debug_test_addr(sin);
 	struct ast_variable *tmpvar = NULL, *v = NULL;
+	int usenatroute;
 
 	/* Terminate URI */
 	t = uri;
@@ -7217,8 +7238,8 @@
 
 	/* Find user based on user name in the from header */
 	if (user && ast_apply_ha(user->ha, sin)) {
-		ast_copy_flags(p, user, SIP_FLAGS_TO_COPY);
-		ast_copy_flags(p, &user->flags_page2, SIP_PAGE2_FLAGS_TO_COPY);
+		ast_copy_flags(&p->flags[0], &user->flags[0], SIP_FLAGS_TO_COPY);
+		ast_copy_flags(&p->flags[1], &user->flags[1], SIP_PAGE2_FLAGS_TO_COPY);
 		/* copy channel vars */
 		for (v = user->chanvars ; v ; v = v->next) {
 			if ((tmpvar = ast_variable_new(v->name, v->value))) {
@@ -7228,7 +7249,7 @@
 		}
 		p->prefs = user->prefs;
 		/* replace callerid if rpid found, and not restricted */
-		if (!ast_strlen_zero(rpid_num) && ast_test_flag(p, SIP_TRUSTRPID)) {
+		if (!ast_strlen_zero(rpid_num) && ast_test_flag(&p->flags[0], SIP_TRUSTRPID)) {
 			char *tmp;
 			if (*calleridname)
 				ast_string_field_set(p, cid_name, calleridname);

[... 1820 lines stripped ...]


More information about the asterisk-commits mailing list