[Freeswitch-svn] [commit] r11713 - freeswitch/trunk/src/mod/endpoints/mod_sofia

FreeSWITCH SVN mikej at freeswitch.org
Mon Feb 9 09:56:38 PST 2009


Author: mikej
Date: Mon Feb  9 11:56:38 2009
New Revision: 11713

Log:
use sofia specific flag macros

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Mon Feb  9 11:56:38 2009
@@ -85,15 +85,15 @@
 		sofia_glue_tech_absorb_sdp(tech_pvt);
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 		const char *var;
 
 		if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && !switch_strlen_zero(var)) {
 			if (switch_true(var) || !strcasecmp(var, SWITCH_RTP_CRYPTO_KEY_32)) {
-				switch_set_flag_locked(tech_pvt, TFLAG_SECURE);
+				sofia_set_flag_locked(tech_pvt, TFLAG_SECURE);
 				sofia_glue_build_crypto(tech_pvt, 1, AES_CM_128_HMAC_SHA1_32, SWITCH_RTP_CRYPTO_SEND);
 			} else if (!strcasecmp(var, SWITCH_RTP_CRYPTO_KEY_80)) {
-				switch_set_flag_locked(tech_pvt, TFLAG_SECURE);
+				sofia_set_flag_locked(tech_pvt, TFLAG_SECURE);
 				sofia_glue_build_crypto(tech_pvt, 1, AES_CM_128_HMAC_SHA1_80, SWITCH_RTP_CRYPTO_SEND);
 			}
 		}
@@ -123,8 +123,8 @@
 	private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	switch_assert(tech_pvt != NULL);
 
-	if (!switch_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
-		switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+	if (!sofia_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
+		sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA ROUTING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
@@ -138,8 +138,8 @@
 	private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	switch_assert(tech_pvt != NULL);
 
-	if (!switch_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
-		switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+	if (!sofia_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
+		sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA RESET\n", switch_channel_get_name(switch_core_session_get_channel(session)));
@@ -153,8 +153,8 @@
 	private_object_t *tech_pvt = switch_core_session_get_private(session);
 	switch_assert(tech_pvt != NULL);
 
-	if (!switch_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
-		switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+	if (!sofia_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
+		sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 	}
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA HIBERNATE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
@@ -167,8 +167,8 @@
 	private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
 	switch_assert(tech_pvt != NULL);
 
-	if (!switch_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
-		switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+	if (!sofia_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
+		sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 	}
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s SOFIA EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
 
@@ -256,7 +256,7 @@
 		}
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) && cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
+	if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD) && cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
 		const char *buuid;
 		switch_core_session_t *bsession;
 		switch_channel_t *bchannel;
@@ -279,7 +279,7 @@
 				switch_core_session_rwunlock(bsession);
 			}
 		}
-		switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+		sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 	}
 
 	sofia_glue_deactivate_rtp(tech_pvt);
@@ -305,7 +305,7 @@
 
 
 
-	if (tech_pvt->nh && !switch_test_flag(tech_pvt, TFLAG_BYE)) {
+	if (tech_pvt->nh && !sofia_test_flag(tech_pvt, TFLAG_BYE)) {
 		char reason[128] = "";
 		switch_stream_handle_t stream = { 0 };
 		switch_event_header_t *hi;
@@ -337,7 +337,7 @@
 			switch_snprintf(reason, sizeof(reason), "FreeSWITCH;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
 		}
 		
-		if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
+		if (sofia_test_flag(tech_pvt, TFLAG_ANS)) {
 			if (!tech_pvt->got_bye) {
 				switch_channel_set_variable(channel, "sip_hangup_disposition", "send_bye");
 			}
@@ -347,7 +347,7 @@
 					TAG_IF(!switch_strlen_zero(bye_headers), SIPTAG_HEADER_STR(bye_headers)),
 					TAG_END());
 		} else {
-			if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+			if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n", switch_channel_get_name(channel));
 				if (!tech_pvt->got_bye) {
 					switch_channel_set_variable(channel, "sip_hangup_disposition", "send_cancel");
@@ -369,7 +369,7 @@
 			}
 		}
 
-		switch_set_flag(tech_pvt, TFLAG_BYE);
+		sofia_set_flag(tech_pvt, TFLAG_BYE);
 		switch_safe_free(stream.data);
 	}
 
@@ -422,7 +422,7 @@
 	int is_proxy = 0;
 	char *sticky = NULL;
 
-	if (switch_test_flag(tech_pvt, TFLAG_ANS) || switch_channel_test_flag(channel, CF_OUTBOUND)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_ANS) || switch_channel_test_flag(channel, CF_OUTBOUND)) {
 		return SWITCH_STATUS_SUCCESS;
 	}
 
@@ -441,7 +441,7 @@
 		}
 	} else {
 		/* This if statement check and handles the 3pcc proxy mode */
-		if ((tech_pvt->profile->pflags & PFLAG_3PCC_PROXY) && switch_test_flag(tech_pvt, TFLAG_3PCC)) {
+		if ((tech_pvt->profile->pflags & PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
 			/* Send the 200 OK */
 			nua_respond(tech_pvt->nh, SIP_200_OK,
 				SIPTAG_CONTACT_STR(tech_pvt->profile->url),
@@ -454,7 +454,7 @@
 			// Maybe we should timeout?
 			switch_mutex_unlock(tech_pvt->sofia_mutex);
 			
-			while(switch_channel_ready(channel) && !switch_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
+			while(switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
 				switch_cond_next();
 			}
 			
@@ -464,8 +464,8 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n");
 		}
 
-		if ((is_proxy && !b_sdp) || switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) || !tech_pvt->iananame) {
-			switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
+		if ((is_proxy && !b_sdp) || sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) || !tech_pvt->iananame) {
+			sofia_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
 
 			if (is_proxy) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Disabling proxy mode due to call answer with no bridge\n");
@@ -512,7 +512,7 @@
 		}
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_NAT) ||
+	if (sofia_test_flag(tech_pvt, TFLAG_NAT) ||
 		(val = switch_channel_get_variable(channel, "sip-force-contact")) ||
 		((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val))) {
 		sticky = tech_pvt->record_route;
@@ -528,7 +528,7 @@
 				SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
 				SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 				SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
-	switch_set_flag_locked(tech_pvt, TFLAG_ANS);
+	sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -541,7 +541,7 @@
 
 	switch_assert(tech_pvt != NULL);
 
-	if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_HUP)) {
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -555,17 +555,17 @@
 
 	tech_pvt->video_read_frame.datalen = 0;
 
-	if (switch_test_flag(tech_pvt, TFLAG_IO)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_IO)) {
 		switch_status_t status;
 
-		if (!switch_test_flag(tech_pvt, TFLAG_RTP)) {
+		if (!sofia_test_flag(tech_pvt, TFLAG_RTP)) {
 			return SWITCH_STATUS_GENERR;
 		}
 
 		switch_assert(tech_pvt->rtp_session != NULL);
 		tech_pvt->video_read_frame.datalen = 0;
 
-		while (switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->video_read_frame.datalen == 0) {
+		while (sofia_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->video_read_frame.datalen == 0) {
 			tech_pvt->video_read_frame.flags = SFF_NONE;
 
 			status = switch_rtp_zerocopy_read_frame(tech_pvt->video_rtp_session, &tech_pvt->video_read_frame, flags);
@@ -610,19 +610,19 @@
 		}
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_HUP)) {
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if (!switch_test_flag(tech_pvt, TFLAG_RTP)) {
+	if (!sofia_test_flag(tech_pvt, TFLAG_RTP)) {
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
+	if (!sofia_test_flag(tech_pvt, TFLAG_IO)) {
 		return SWITCH_STATUS_SUCCESS;
 	}
 
-	if (!switch_test_flag(frame, SFF_CNG)) {
+	if (!sofia_test_flag(frame, SFF_CNG)) {
 		switch_rtp_write_frame(tech_pvt->video_rtp_session, frame);
 	}
 
@@ -637,12 +637,12 @@
 
 	switch_assert(tech_pvt != NULL);
 
-	if (!(tech_pvt->profile->pflags & PFLAG_RUNNING)) {
+	if (!sofia_test_pflag(tech_pvt->profile, PFLAG_RUNNING)) {
 		switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_NORMAL_CLEARING);
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_HUP)) {
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -655,23 +655,23 @@
 	}
 
 	tech_pvt->read_frame.datalen = 0;
-	switch_set_flag_locked(tech_pvt, TFLAG_READING);
+	sofia_set_flag_locked(tech_pvt, TFLAG_READING);
 
-	if (switch_test_flag(tech_pvt, TFLAG_HUP) || switch_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation) {
+	if (sofia_test_flag(tech_pvt, TFLAG_HUP) || sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation) {
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_IO)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_IO)) {
 		switch_status_t status;
 
-		if (!switch_test_flag(tech_pvt, TFLAG_RTP)) {
+		if (!sofia_test_flag(tech_pvt, TFLAG_RTP)) {
 			return SWITCH_STATUS_GENERR;
 		}
 
 		switch_assert(tech_pvt->rtp_session != NULL);
 		tech_pvt->read_frame.datalen = 0;
 		
-		while (switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
+		while (sofia_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
 			tech_pvt->read_frame.flags = SFF_NONE;
 
 			status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags);
@@ -684,8 +684,8 @@
 			}
 
 			/* Fast PASS! */
-			if (switch_test_flag((&tech_pvt->read_frame), SFF_PROXY_PACKET)) {
-				switch_clear_flag_locked(tech_pvt, TFLAG_READING);
+			if (sofia_test_flag((&tech_pvt->read_frame), SFF_PROXY_PACKET)) {
+				sofia_clear_flag_locked(tech_pvt, TFLAG_READING);
 				*frame = &tech_pvt->read_frame;
 				return SWITCH_STATUS_SUCCESS;
 			}
@@ -702,7 +702,7 @@
 				size_t bytes = 0;
 				int frames = 1;
 				
-				if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
+				if (!sofia_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
 					if (!tech_pvt->read_codec.implementation) {
 						*frame = NULL;
 						return SWITCH_STATUS_GENERR;
@@ -820,7 +820,7 @@
 		}
 	}
 
-	switch_clear_flag_locked(tech_pvt, TFLAG_READING);
+	sofia_clear_flag_locked(tech_pvt, TFLAG_READING);
 
 	if (tech_pvt->read_frame.datalen == 0) {
 		*frame = NULL;
@@ -853,25 +853,25 @@
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_HUP)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_HUP)) {
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if (!switch_test_flag(tech_pvt, TFLAG_RTP)) {
+	if (!sofia_test_flag(tech_pvt, TFLAG_RTP)) {
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
+	if (!sofia_test_flag(tech_pvt, TFLAG_IO)) {
 		return SWITCH_STATUS_SUCCESS;
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation) {
+	if (sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation) {
 		return SWITCH_STATUS_FALSE;
 	}
 
-	switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
+	sofia_set_flag_locked(tech_pvt, TFLAG_WRITING);
 
-	if (!switch_test_flag(frame, SFF_CNG) && !switch_test_flag(frame, SFF_PROXY_PACKET)) {
+	if (!sofia_test_flag(frame, SFF_CNG) && !sofia_test_flag(frame, SFF_PROXY_PACKET)) {
 		if (tech_pvt->read_impl.encoded_bytes_per_packet) {
 			bytes = tech_pvt->read_impl.encoded_bytes_per_packet;
 			frames = ((int) frame->datalen / bytes);
@@ -884,7 +884,7 @@
 	tech_pvt->timestamp_send += samples;
 	switch_rtp_write_frame(tech_pvt->rtp_session, frame);
 
-	switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
+	sofia_clear_flag_locked(tech_pvt, TFLAG_WRITING);
 	return status;
 }
 
@@ -907,8 +907,8 @@
 		break;
 	case SWITCH_SIG_KILL:
 	default:
-		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
-		switch_set_flag_locked(tech_pvt, TFLAG_HUP);
+		sofia_clear_flag_locked(tech_pvt, TFLAG_IO);
+		sofia_set_flag_locked(tech_pvt, TFLAG_HUP);
 
 		if (switch_rtp_ready(tech_pvt->rtp_session)) {
 			switch_rtp_kill_socket(tech_pvt->rtp_session);
@@ -979,7 +979,7 @@
 		{
 			const char *var;
 			if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && switch_true(var)) {
-				switch_set_flag_locked(tech_pvt, TFLAG_SECURE);
+				sofia_set_flag_locked(tech_pvt, TFLAG_SECURE);
 			}
 		}
 		break;
@@ -1062,7 +1062,7 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Sending media re-direct:\n%s\n", 
 							  switch_channel_get_name(channel), msg->string_arg);
 			tech_pvt->local_sdp_str = switch_core_session_strdup(session, msg->string_arg);
-			switch_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
+			sofia_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
 			sofia_glue_do_invite(session);
 		}
 		break;
@@ -1078,7 +1078,7 @@
 							  switch_channel_get_name(channel), tech_pvt->local_sdp_str);
 							  
 			
-			switch_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
+			sofia_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
 			sofia_glue_do_invite(session);
 		}
 		break;
@@ -1133,7 +1133,7 @@
 
 	case SWITCH_MESSAGE_INDICATE_HOLD:
 		{
-			switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+			sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 			sofia_glue_do_invite(session);
 			if (!switch_strlen_zero(msg->string_arg)) {
 				char message[256] = "";
@@ -1145,7 +1145,7 @@
 
 	case SWITCH_MESSAGE_INDICATE_UNHOLD:
 		{
-			switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+			sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 			sofia_glue_do_invite(session);
 		}
 		break;
@@ -1154,7 +1154,7 @@
 			if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Redirecting to %s\n", msg->string_arg);
 				nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(msg->string_arg), TAG_END());
-				switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+				sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
 			} else {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Too late for redirecting to %s, already answered\n", msg->string_arg);
 			}
@@ -1241,7 +1241,7 @@
 							SIPTAG_SUPPORTED_STR(NULL), SIPTAG_ACCEPT_STR(NULL),
 							TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END());
 				if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
-					switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+					sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
 				}
 			} else if (code == 302 && !switch_strlen_zero(msg->string_arg)) {
 				char * p = strchr(msg->string_arg, ' ');
@@ -1267,7 +1267,7 @@
 					nua_respond(tech_pvt->nh, code, su_strdup(tech_pvt->nh->nh_home, reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact), TAG_END());
 				}
 				if (!switch_channel_test_flag(channel, CF_ANSWERED) && code >= 300) {
-					switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+					sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
 				}
 			}
 
@@ -1288,9 +1288,9 @@
 			char *sticky = NULL;
 			const char *val = NULL;
 
-			if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
+			if (!sofia_test_flag(tech_pvt, TFLAG_ANS) && !sofia_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
 
-				switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
+				sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Asked to send early media by %s\n", msg->from);
 
 				/* Transmit 183 Progress with SDP */
@@ -1307,8 +1307,8 @@
 						}
 					}
 				} else {
-					if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) || !tech_pvt->iananame) {
-						switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
+					if (sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) || !tech_pvt->iananame) {
+						sofia_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
 						if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
 							const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
 
@@ -1338,7 +1338,7 @@
 				switch_channel_mark_pre_answered(channel);
 
 
-				if (switch_test_flag(tech_pvt, TFLAG_NAT) ||
+				if (sofia_test_flag(tech_pvt, TFLAG_NAT) ||
 					(val = switch_channel_get_variable(channel, "sip-force-contact")) ||
 					((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val))) {
 					sticky = tech_pvt->record_route;
@@ -1574,9 +1574,9 @@
 					stream->write_function(stream, "CNG              \t%d\n", profile->cng_pt);
 					stream->write_function(stream, "SESSION-TO       \t%d\n", profile->session_timeout);
 					stream->write_function(stream, "MAX-DIALOG       \t%d\n", profile->max_proceeding);
-					stream->write_function(stream, "NOMEDIA          \t%s\n", switch_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
-					stream->write_function(stream, "LATE-NEG         \t%s\n", switch_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
-					stream->write_function(stream, "PROXY-MEDIA      \t%s\n", switch_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
+					stream->write_function(stream, "NOMEDIA          \t%s\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
+					stream->write_function(stream, "LATE-NEG         \t%s\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
+					stream->write_function(stream, "PROXY-MEDIA      \t%s\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
 					stream->write_function(stream, "AGGRESSIVENAT    \t%s\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
 					stream->write_function(stream, "STUN_ENABLED     \t%s\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
 					stream->write_function(stream, "STUN_AUTO_DISABLE\t%s\n", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
@@ -1765,9 +1765,9 @@
 					stream->write_function(stream, "<CNG>%d</CNG>\n", profile->cng_pt);
 					stream->write_function(stream, "<SESSION-TO>%d</SESSION-TO>\n", profile->session_timeout);
 					stream->write_function(stream, "<MAX-DIALOG>%d</MAX-DIALOG>\n", profile->max_proceeding);
-					stream->write_function(stream, "<NOMEDIA>%s</NOMEDIA>\n", switch_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
-					stream->write_function(stream, "<LATE-NEG>%s</LATE-NEG>\n", switch_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
-					stream->write_function(stream, "<PROXY-MEDIA>%s</PROXY-MEDIA>\n", switch_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
+					stream->write_function(stream, "<NOMEDIA>%s</NOMEDIA>\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
+					stream->write_function(stream, "<LATE-NEG>%s</LATE-NEG>\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
+					stream->write_function(stream, "<PROXY-MEDIA>%s</PROXY-MEDIA>\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
 					stream->write_function(stream, "<AGGRESSIVENAT>%s</AGGRESSIVENAT>\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
 					stream->write_function(stream, "<STUN_ENABLED>%s</STUN_ENABLED>\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
 					stream->write_function(stream, "<STUN_AUTO_DISABLE>%s</STUN_AUTO_DISABLE>\n", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
@@ -1920,9 +1920,9 @@
 		if (argv[2]) {
 			int is_true = switch_true(argv[2]);
 			if (is_true) {
-				profile->pflags |= PFLAG_STUN_AUTO_DISABLE;
+				sofia_set_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
 			} else {
-				profile->pflags &= ~PFLAG_STUN_AUTO_DISABLE;
+				sofia_clear_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
 			}
 		}
 
@@ -1935,9 +1935,9 @@
 		if (argv[2]) {
 			int is_true = switch_true(argv[2]);
 			if (is_true) {
-				profile->pflags |= PFLAG_STUN_ENABLED;
+				sofia_set_pflag(profile, PFLAG_STUN_ENABLED);
 			} else {
-				profile->pflags &= ~PFLAG_STUN_ENABLED;
+				sofia_clear_pflag(profile, PFLAG_STUN_ENABLED);
 			}
 		}
 
@@ -2417,7 +2417,7 @@
 		tech_pvt->gateway_name = switch_core_session_strdup(nsession, gateway_ptr->name);
 		switch_channel_set_variable(nchannel, "sip_gateway_name", gateway_ptr->name);
 
-		if (!switch_test_flag(gateway_ptr, REG_FLAG_CALLERID)) {
+		if (!sofia_test_flag(gateway_ptr, REG_FLAG_CALLERID)) {
 			tech_pvt->gateway_from_str = switch_core_session_strdup(nsession, gateway_ptr->register_from);
 		}
 
@@ -2522,8 +2522,8 @@
 	caller_profile->destination_number = switch_core_strdup(caller_profile->pool, dest);
 	switch_channel_set_caller_profile(nchannel, caller_profile);
 	switch_channel_set_flag(nchannel, CF_OUTBOUND);
-	switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
-	switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
+	sofia_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
+	sofia_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
 	if (switch_channel_get_state(nchannel) == CS_NEW) {
 		switch_channel_set_state(nchannel, CS_INIT);
 	}
@@ -2572,7 +2572,7 @@
 				tech_pvt->video_rm_rate = 90000;
 				tech_pvt->video_codec_ms = 0;
 				switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
-				switch_set_flag(tech_pvt, TFLAG_VIDEO);
+				sofia_set_flag(tech_pvt, TFLAG_VIDEO);
 			}
 		}
 	}

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	Mon Feb  9 11:56:38 2009
@@ -595,6 +595,11 @@
 #define sofia_clear_pflag(obj, flag) (obj)->pflags &= ~(flag)
 #define sofia_copy_pflags(dest, src, flags) (dest)->pflags &= ~(flags);	(dest)->pflags |= ((src)->pflags & (flags))
 
+#define sofia_set_flag_locked(obj, flag) switch_set_flag_locked(obj, flag)
+#define sofia_set_flag(obj, flag) switch_set_flag(obj, flag)
+#define sofia_clear_flag_locked(obj, flag) switch_clear_flag_locked(obj, flag)
+#define sofia_test_flag(obj, flag) switch_test_flag(obj, flag)
+
 /* Function Prototypes */
 /*************************************************************************************************************************************************************/
 
@@ -785,4 +790,3 @@
 void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]);
 void sofia_sla_handle_sip_r_subscribe(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]);
 void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]);
-

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Mon Feb  9 11:56:38 2009
@@ -377,7 +377,7 @@
 		sofia_private->destroy_me = 22;
 	}
 
-	if ((profile->pflags & PFLAG_AUTH_ALL) && tech_pvt && tech_pvt->key && sip) {
+	if (sofia_test_pflag(profile, PFLAG_AUTH_ALL) && tech_pvt && tech_pvt->key && sip) {
 		sip_authorization_t const *authorization = NULL;
 
 		if (sip->sip_authorization) {
@@ -709,7 +709,7 @@
 		goto end;
 	}
 
-	if (switch_test_flag(profile, TFLAG_TPORT_LOG)) {
+	if (sofia_test_flag(profile, TFLAG_TPORT_LOG)) {
 		tportlog = 1;
 	}
 
@@ -1226,7 +1226,7 @@
 			gateway->auth_username = switch_core_strdup(gateway->pool, auth_username);
 			gateway->register_password = switch_core_strdup(gateway->pool, password);
 			if (switch_true(caller_id_in_from)) {
-				switch_set_flag(gateway, REG_FLAG_CALLERID);
+				sofia_set_flag(gateway, REG_FLAG_CALLERID);
 			}
 			register_transport = (char *) sofia_glue_transport2str(gateway->register_transport);
 			if (contact_params) {
@@ -1365,7 +1365,7 @@
 			/* you could change profile->foo here if it was a minor change like context or dialplan ... */
 			profile->rport_level = 1; /* default setting */
 			profile->acl_count = 0;
-			profile->pflags |= PFLAG_STUN_ENABLED;
+			sofia_set_pflag(profile, PFLAG_STUN_ENABLED);
 
 			if (xprofiledomain) {
 				profile->domain_name = switch_core_strdup(profile->pool, xprofiledomain);
@@ -1399,7 +1399,7 @@
 						profile->record_template = switch_core_strdup(profile->pool, val);;
 					} else if ((!strcasecmp(var, "inbound-no-media") || !strcasecmp(var, "inbound-bypass-media"))) {
 						if (switch_true(val)) {
-							switch_set_flag(profile, TFLAG_INB_NOMEDIA);
+							sofia_set_flag(profile, TFLAG_INB_NOMEDIA);
 						} else {
 							switch_clear_flag(profile, TFLAG_INB_NOMEDIA);
 						}
@@ -1410,69 +1410,69 @@
 						}
 					} else if (!strcasecmp(var, "inbound-late-negotiation")) {
 						if (switch_true(val)) {
-							switch_set_flag(profile, TFLAG_LATE_NEGOTIATION);
+							sofia_set_flag(profile, TFLAG_LATE_NEGOTIATION);
 						} else {
 							switch_clear_flag(profile, TFLAG_LATE_NEGOTIATION);
 						}
 					} else if (!strcasecmp(var, "inbound-proxy-media")) {
 						if (switch_true(val)) { 
-							switch_set_flag(profile, TFLAG_PROXY_MEDIA);
+							sofia_set_flag(profile, TFLAG_PROXY_MEDIA);
 						} else {
 							switch_clear_flag(profile, TFLAG_PROXY_MEDIA);
 						}
 					} else if (!strcasecmp(var, "inbound-use-callid-as-uuid")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_CALLID_AS_UUID;
+							sofia_set_pflag(profile, PFLAG_CALLID_AS_UUID);
 						} else {
-							profile->pflags &= ~PFLAG_CALLID_AS_UUID;
+							sofia_clear_pflag(profile, PFLAG_CALLID_AS_UUID);
 						}
 					} else if (!strcasecmp(var, "outbound-use-uuid-as-callid")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_UUID_AS_CALLID;
+							sofia_set_pflag(profile, PFLAG_UUID_AS_CALLID);
 						} else {
-							profile->pflags &= ~PFLAG_UUID_AS_CALLID;
+							sofia_clear_pflag(profile, PFLAG_UUID_AS_CALLID);
 						}
 					} else if (!strcasecmp(var, "NDLB-received-in-nat-reg-contact")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_RECIEVED_IN_NAT_REG_CONTACT;
+							sofia_set_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT);
 						} else {
-							profile->pflags &= ~PFLAG_RECIEVED_IN_NAT_REG_CONTACT;
+							sofia_clear_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT);
 						}
 					} else if (!strcasecmp(var, "aggressive-nat-detection")) {
 						if (switch_true(val)) { 
-							profile->pflags |= PFLAG_AGGRESSIVE_NAT_DETECTION;
+							sofia_set_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION);
 						} else {
-							profile->pflags &= ~PFLAG_AGGRESSIVE_NAT_DETECTION;
+							sofia_clear_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION);
 						}
 					} else if (!strcasecmp(var, "disable-rtp-auto-adjust")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_DISABLE_RTP_AUTOADJ;
+							sofia_set_pflag(profile, PFLAG_DISABLE_RTP_AUTOADJ);
 						} else {
-							profile->pflags &= ~PFLAG_DISABLE_RTP_AUTOADJ;
+							sofia_clear_pflag(profile, PFLAG_DISABLE_RTP_AUTOADJ);
 						}
 					} else if (!strcasecmp(var, "NDLB-support-asterisk-missing-srtp-auth")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_DISABLE_SRTP_AUTH; 
+							sofia_set_pflag(profile, PFLAG_DISABLE_SRTP_AUTH); 
 						} else {
-							profile->pflags &= ~PFLAG_DISABLE_SRTP_AUTH; 
+							sofia_clear_pflag(profile, PFLAG_DISABLE_SRTP_AUTH); 
 						}
 					} else if (!strcasecmp(var, "NDLB-funny-stun")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_FUNNY_STUN; 
+							sofia_set_pflag(profile, PFLAG_FUNNY_STUN); 
 						} else {
-							profile->pflags &= ~PFLAG_FUNNY_STUN; 
+							sofia_clear_pflag(profile, PFLAG_FUNNY_STUN); 
 						}
 					} else if (!strcasecmp(var, "stun-enabled")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_STUN_ENABLED;
+							sofia_set_pflag(profile, PFLAG_STUN_ENABLED);
 						} else {
-							profile->pflags &= ~PFLAG_STUN_ENABLED; 
+							sofia_clear_pflag(profile, PFLAG_STUN_ENABLED);
 						}
 					} else if (!strcasecmp(var, "stun-auto-disable")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_STUN_AUTO_DISABLE;
+							sofia_set_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
 						} else {
-							profile->pflags &= ~PFLAG_STUN_AUTO_DISABLE; 
+							sofia_clear_pflag(profile, PFLAG_STUN_AUTO_DISABLE); 
 						}
 					} else if (!strcasecmp(var, "apply-nat-acl")) {
 						if (profile->acl_count < SOFIA_MAX_ACL) {
@@ -1498,47 +1498,47 @@
 						}
 					} else if (!strcasecmp(var, "rfc2833-pt")) {
 						profile->te = (switch_payload_t) atoi(val);
-					} else if (!strcasecmp(var, "cng-pt") && !(profile->pflags & PFLAG_SUPPRESS_CNG)) {
+					} else if (!strcasecmp(var, "cng-pt") && !(sofia_test_pflag(profile, PFLAG_SUPPRESS_CNG))) {
 						profile->cng_pt = (switch_payload_t) atoi(val);
 					} else if (!strcasecmp(var, "vad")) {
 						if (!strcasecmp(val, "in")) {
-							switch_set_flag(profile, TFLAG_VAD_IN);
+							sofia_set_flag(profile, TFLAG_VAD_IN);
 						} else if (!strcasecmp(val, "out")) {
-							switch_set_flag(profile, TFLAG_VAD_OUT);
+							sofia_set_flag(profile, TFLAG_VAD_OUT);
 						} else if (!strcasecmp(val, "both")) {
-							switch_set_flag(profile, TFLAG_VAD_IN);
-							switch_set_flag(profile, TFLAG_VAD_OUT);
+							sofia_set_flag(profile, TFLAG_VAD_IN);
+							sofia_set_flag(profile, TFLAG_VAD_OUT);
 						} else if (strcasecmp(val, "none")) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid option %s for VAD\n", val);
 						}
 					} else if (!strcasecmp(var, "unregister-on-options-fail")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_UNREG_OPTIONS_FAIL;
+							sofia_set_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL);
 						} else {
-							profile->pflags &= ~PFLAG_UNREG_OPTIONS_FAIL;
+							sofia_clear_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL);
 						}
 					} else if (!strcasecmp(var, "require-secure-rtp")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_SECURE;
+							sofia_set_pflag(profile, PFLAG_SECURE);
 						} else {
-							profile->pflags &= ~PFLAG_SECURE;
+							sofia_clear_pflag(profile, PFLAG_SECURE);
 						}
 					} else if (!strcasecmp(var, "multiple-registrations")) {
 						if (!strcasecmp(val, "call-id")) {
-							profile->pflags |= PFLAG_MULTIREG;
+							sofia_set_pflag(profile, PFLAG_MULTIREG);
 						} else if (!strcasecmp(val, "contact") || switch_true(val)) {
-							profile->pflags |= PFLAG_MULTIREG;
-							profile->pflags |= PFLAG_MULTIREG_CONTACT;
+							sofia_set_pflag(profile, PFLAG_MULTIREG);
+							sofia_set_pflag(profile, PFLAG_MULTIREG_CONTACT);
 						} else if (switch_true(val)) {
-							profile->pflags &= ~PFLAG_MULTIREG;
-							//profile->pflags &= ~PFLAG_MULTIREG_CONTACT;
+							sofia_clear_pflag(profile, PFLAG_MULTIREG);
+							//sofia_clear_pflag(profile, PFLAG_MULTIREG_CONTACT);
 						}
 					} else if (!strcasecmp(var, "supress-cng") || !strcasecmp(var, "suppress-cng")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_SUPPRESS_CNG;
+							sofia_set_pflag(profile, PFLAG_SUPPRESS_CNG);
 							profile->cng_pt = 0;
 						} else {
-							profile->pflags &= ~PFLAG_SUPPRESS_CNG;
+							sofia_clear_pflag(profile, PFLAG_SUPPRESS_CNG);
 						}
 					} else if (!strcasecmp(var, "NDLB-to-in-200-contact")) {
 						if (switch_true(val)) {
@@ -1554,33 +1554,33 @@
 						}
 					} else if (!strcasecmp(var, "pass-rfc2833")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_PASS_RFC2833;
+							sofia_set_pflag(profile, PFLAG_PASS_RFC2833);
 						} else {
-							profile->pflags &= ~PFLAG_PASS_RFC2833;
+							sofia_clear_pflag(profile, PFLAG_PASS_RFC2833);
 						}
 					} else if (!strcasecmp(var, "inbound-codec-negotiation")) {
 						if (!strcasecmp(val, "greedy")) {
-							profile->pflags |= PFLAG_GREEDY;
+							sofia_set_pflag(profile, PFLAG_GREEDY);
 						} else {
-							profile->pflags &= ~PFLAG_GREEDY;
+							sofia_clear_pflag(profile, PFLAG_GREEDY);
 						}
 					} else if (!strcasecmp(var, "disable-transcoding")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_DISABLE_TRANSCODING;
+							sofia_set_pflag(profile, PFLAG_DISABLE_TRANSCODING);
 						} else {
-							profile->pflags &= ~PFLAG_DISABLE_TRANSCODING;
+							sofia_clear_pflag(profile, PFLAG_DISABLE_TRANSCODING);
 						}
 					} else if (!strcasecmp(var, "rtp-rewrite-timestamps")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_REWRITE_TIMESTAMPS;
+							sofia_set_pflag(profile, PFLAG_REWRITE_TIMESTAMPS);
 						} else {
-							profile->pflags &= ~PFLAG_REWRITE_TIMESTAMPS;
+							sofia_clear_pflag(profile, PFLAG_REWRITE_TIMESTAMPS);
 						}
 					} else if (!strcasecmp(var, "auth-calls")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_AUTH_CALLS;
+							sofia_set_pflag(profile, PFLAG_AUTH_CALLS);
 						} else {
-							profile->pflags &= ~PFLAG_AUTH_CALLS;
+							sofia_clear_pflag(profile, PFLAG_AUTH_CALLS);
 						}
 					} else if (!strcasecmp(var, "force-register-domain")) {
 						profile->reg_domain = switch_core_strdup(profile->pool, val);
@@ -1800,8 +1800,8 @@
 				profile->tls_version = 0;
 				profile->mflags = MFLAG_REFER | MFLAG_REGISTER;
 				profile->rport_level = 1;
-				profile->pflags |= PFLAG_STUN_ENABLED;
-				profile->pflags |= PFLAG_DISABLE_100REL;
+				sofia_set_pflag(profile, PFLAG_STUN_ENABLED);
+				sofia_set_pflag(profile, PFLAG_DISABLE_100REL);
 				profile->auto_restart = 1;
 				profile->manage_shared_appearance = 0; /* Initialize default */
 				profile->disable_srv = 0;
@@ -1814,7 +1814,7 @@
 					if (!strcasecmp(var, "debug")) {
 						profile->debug = atoi(val);
 					} else if (!strcasecmp(var, "sip-trace") && switch_true(val)) {
-						switch_set_flag(profile, TFLAG_TPORT_LOG);
+						sofia_set_flag(profile, TFLAG_TPORT_LOG);
 					} else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
 #ifdef SWITCH_HAVE_ODBC
 						profile->odbc_dsn = switch_core_strdup(profile->pool, val);
@@ -1852,11 +1852,11 @@
 					} else if (!strcasecmp(var, "record-template")) {
 						profile->record_template = switch_core_strdup(profile->pool, val);
 					} else if ((!strcasecmp(var, "inbound-no-media") || !strcasecmp(var, "inbound-bypass-media")) && switch_true(val)) {
-						switch_set_flag(profile, TFLAG_INB_NOMEDIA);
+						sofia_set_flag(profile, TFLAG_INB_NOMEDIA);
 					} else if (!strcasecmp(var, "inbound-late-negotiation") && switch_true(val)) {
-						switch_set_flag(profile, TFLAG_LATE_NEGOTIATION);
+						sofia_set_flag(profile, TFLAG_LATE_NEGOTIATION);
 					} else if (!strcasecmp(var, "inbound-proxy-media") && switch_true(val)) {
-						switch_set_flag(profile, TFLAG_PROXY_MEDIA);
+						sofia_set_flag(profile, TFLAG_PROXY_MEDIA);
 					} else if (!strcasecmp(var, "force-subscription-expires")) {
 						int tmp = atoi(val);
 						if (tmp > 0) {
@@ -1864,56 +1864,56 @@
 						}
 					} else if (!strcasecmp(var, "inbound-use-callid-as-uuid")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_CALLID_AS_UUID;
+							sofia_set_pflag(profile, PFLAG_CALLID_AS_UUID);
 						} else {
-							profile->pflags &= ~PFLAG_CALLID_AS_UUID;
+							sofia_clear_pflag(profile, PFLAG_CALLID_AS_UUID);
 						}
 					} else if (!strcasecmp(var, "outbound-use-uuid-as-callid")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_UUID_AS_CALLID;
+							sofia_set_pflag(profile, PFLAG_UUID_AS_CALLID);
 						} else {
-							profile->pflags &= ~PFLAG_UUID_AS_CALLID;
+							sofia_clear_pflag(profile, PFLAG_UUID_AS_CALLID);
 						}
 					} else if (!strcasecmp(var, "NDLB-received-in-nat-reg-contact") && switch_true(val)) {
-						profile->pflags |= PFLAG_RECIEVED_IN_NAT_REG_CONTACT;
+						sofia_set_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT);
 					} else if (!strcasecmp(var, "aggressive-nat-detection") && switch_true(val)) {
-						profile->pflags |= PFLAG_AGGRESSIVE_NAT_DETECTION;
+						sofia_set_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION);
 					} else if (!strcasecmp(var, "disable-rtp-auto-adjust") && switch_true(val)) {
-						profile->pflags |= PFLAG_DISABLE_RTP_AUTOADJ;
+						sofia_set_pflag(profile, PFLAG_DISABLE_RTP_AUTOADJ);
 					} else if (!strcasecmp(var, "NDLB-support-asterisk-missing-srtp-auth") && switch_true(val)) {
-						profile->pflags |= PFLAG_DISABLE_SRTP_AUTH;
+						sofia_set_pflag(profile, PFLAG_DISABLE_SRTP_AUTH);
 					} else if (!strcasecmp(var, "NDLB-funny-stun")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_FUNNY_STUN; 
+							sofia_set_pflag(profile, PFLAG_FUNNY_STUN); 
 						} else {
-							profile->pflags &= ~PFLAG_FUNNY_STUN; 
+							sofia_clear_pflag(profile, PFLAG_FUNNY_STUN); 
 						}
 					} else if (!strcasecmp(var, "stun-enabled")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_STUN_ENABLED;
+							sofia_set_pflag(profile, PFLAG_STUN_ENABLED);
 						} else {
-							profile->pflags &= ~PFLAG_STUN_ENABLED; 
+							sofia_clear_pflag(profile, PFLAG_STUN_ENABLED); 
 						}
 					} else if (!strcasecmp(var, "stun-auto-disable")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_STUN_AUTO_DISABLE;
+							sofia_set_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
 						} else {
-							profile->pflags &= ~PFLAG_STUN_AUTO_DISABLE; 
+							sofia_clear_pflag(profile, PFLAG_STUN_AUTO_DISABLE); 
 						}
 					} else if (!strcasecmp(var, "rfc2833-pt")) {
 						profile->te = (switch_payload_t) atoi(val);
-					} else if (!strcasecmp(var, "cng-pt") && !(profile->pflags & PFLAG_SUPPRESS_CNG)) {
+					} else if (!strcasecmp(var, "cng-pt") && !sofia_test_pflag(profile, PFLAG_SUPPRESS_CNG)) {
 						profile->cng_pt = (switch_payload_t) atoi(val);
 					} else if (!strcasecmp(var, "sip-port")) {
 						profile->sip_port = atoi(val);
 					} else if (!strcasecmp(var, "vad")) {
 						if (!strcasecmp(val, "in")) {
-							switch_set_flag(profile, TFLAG_VAD_IN);
+							sofia_set_flag(profile, TFLAG_VAD_IN);
 						} else if (!strcasecmp(val, "out")) {
-							switch_set_flag(profile, TFLAG_VAD_OUT);
+							sofia_set_flag(profile, TFLAG_VAD_OUT);
 						} else if (!strcasecmp(val, "both")) {
-							switch_set_flag(profile, TFLAG_VAD_IN);
-							switch_set_flag(profile, TFLAG_VAD_OUT);
+							sofia_set_flag(profile, TFLAG_VAD_IN);
+							sofia_set_flag(profile, TFLAG_VAD_OUT);
 						} else if (strcasecmp(val, "none")) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid option %s for VAD\n", val);
 						}
@@ -2036,25 +2036,25 @@
 						}
 					} else if (!strcasecmp(var, "unregister-on-options-fail")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_UNREG_OPTIONS_FAIL;
+							sofia_set_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL);
 						}
 					} else if (!strcasecmp(var, "require-secure-rtp")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_SECURE;
+							sofia_set_pflag(profile, PFLAG_SECURE);
 						}
 					} else if (!strcasecmp(var, "multiple-registrations")) {
 						if (!strcasecmp(val, "call-id")) {
-							profile->pflags |= PFLAG_MULTIREG;
+							sofia_set_pflag(profile, PFLAG_MULTIREG);
 						} else if (!strcasecmp(val, "contact") || switch_true(val)) {
-							profile->pflags |= PFLAG_MULTIREG;
-							profile->pflags |= PFLAG_MULTIREG_CONTACT;
+							sofia_set_pflag(profile, PFLAG_MULTIREG);
+							sofia_set_pflag(profile, PFLAG_MULTIREG_CONTACT);
 						} else if (switch_true(val)) {
-							profile->pflags &= ~PFLAG_MULTIREG;
-							//profile->pflags &= ~PFLAG_MULTIREG_CONTACT;
+							sofia_clear_pflag(profile, PFLAG_MULTIREG);
+							//sofia_clear_pflag(profile, PFLAG_MULTIREG_CONTACT);
 						}
 					} else if (!strcasecmp(var, "supress-cng") || !strcasecmp(var, "suppress-cng")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_SUPPRESS_CNG;
+							sofia_set_pflag(profile, PFLAG_SUPPRESS_CNG);
 							profile->cng_pt = 0;
 						}
 					} else if (!strcasecmp(var, "NDLB-to-in-200-contact")) {
@@ -2067,56 +2067,56 @@
 						}
 					} else if (!strcasecmp(var, "pass-rfc2833")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_PASS_RFC2833;
+							sofia_set_pflag(profile, PFLAG_PASS_RFC2833);
 						}
 					} else if (!strcasecmp(var, "inbound-codec-negotiation")) {
 						if (!strcasecmp(val, "greedy")) {
-							profile->pflags |= PFLAG_GREEDY;
+							sofia_set_pflag(profile, PFLAG_GREEDY);
 						}
 					} else if (!strcasecmp(var, "disable-transcoding")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_DISABLE_TRANSCODING;
+							sofia_set_pflag(profile, PFLAG_DISABLE_TRANSCODING);
 						}
 					} else if (!strcasecmp(var, "rtp-rewrite-timestamps")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_REWRITE_TIMESTAMPS;
+							sofia_set_pflag(profile, PFLAG_REWRITE_TIMESTAMPS);
 						}
 					} else if (!strcasecmp(var, "auth-calls")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_AUTH_CALLS;
+							sofia_set_pflag(profile, PFLAG_AUTH_CALLS);
 						}
 					} else if (!strcasecmp(var, "nonce-ttl")) {
 						profile->nonce_ttl = atoi(val);
 					} else if (!strcasecmp(var, "accept-blind-reg")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_BLIND_REG;
+							sofia_set_pflag(profile, PFLAG_BLIND_REG);
 						}
 					} else if (!strcasecmp(var, "enable-3pcc")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_3PCC;
+							sofia_set_pflag(profile, PFLAG_3PCC);
 						}
 						else if(!strcasecmp(val, "proxy")){
-							profile->pflags |= PFLAG_3PCC_PROXY;
+							sofia_set_pflag(profile, PFLAG_3PCC_PROXY);
 						}
 					} else if (!strcasecmp(var, "accept-blind-auth")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_BLIND_AUTH;
+							sofia_set_pflag(profile, PFLAG_BLIND_AUTH);
 						}
 					} else if (!strcasecmp(var, "auth-all-packets")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_AUTH_ALL;
+							sofia_set_pflag(profile, PFLAG_AUTH_ALL);
 						}
 					} else if (!strcasecmp(var, "full-id-in-dialplan")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_FULL_ID;
+							sofia_set_pflag(profile, PFLAG_FULL_ID);
 						}
 					} else if (!strcasecmp(var, "inbound-reg-force-matching-username")) {
 						if (switch_true(val)) {
-							profile->pflags |= PFLAG_CHECKUSER;
+							sofia_set_pflag(profile, PFLAG_CHECKUSER);
 						}
 					} else if (!strcasecmp(var, "enable-timer")) {
 						if (!switch_true(val)) {
-							profile->pflags |= PFLAG_DISABLE_TIMER;
+							sofia_set_pflag(profile, PFLAG_DISABLE_TIMER);
 						}
 					} else if (!strcasecmp(var, "minimum-session-expires")) {
 						profile->minimum_session_expires = atoi(val);
@@ -2126,7 +2126,7 @@
 						}
 					} else if (!strcasecmp(var, "enable-100rel")) {
 						if (switch_true(val)) {
-							profile->pflags &= ~PFLAG_DISABLE_100REL;
+							sofia_clear_pflag(profile, PFLAG_DISABLE_100REL);
 						}
 					} else if (!strcasecmp(var, "bitpacking")) {
 						if (!strcasecmp(val, "aal2")) {
@@ -2441,7 +2441,7 @@
 		gateway->ping = switch_epoch_time_now(NULL) + gateway->ping_freq;
 		sofia_reg_release_gateway(gateway);
 		gateway->pinging = 0;
-	} else if ((profile->pflags & PFLAG_UNREG_OPTIONS_FAIL) && status != 200 && sip && sip->sip_to) {
+	} else if (sofia_test_pflag(profile, PFLAG_UNREG_OPTIONS_FAIL) && status != 200 && sip && sip->sip_to) {
 		char *sql;
 		time_t now = switch_epoch_time_now(NULL);
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Expire registration '%s@%s' due to options failure\n",
@@ -2495,11 +2495,11 @@
 
 		if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
 
-			if (!switch_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) {
+			if (!sofia_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) {
 				return;
 			}
 
-			switch_clear_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
+			sofia_clear_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
 
 			if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
 				const char *r_sdp = NULL;
@@ -2645,7 +2645,7 @@
 		
 		if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
 			if (switch_core_session_compare(session, other_session)) {
-				switch_set_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
+				sofia_set_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
 				switch_ivr_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE);
 			
 				if (tech_pvt->rtp_session) {
@@ -2787,9 +2787,9 @@
 			
 		if (r_sdp) {
 			if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
-				switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
+				sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
 				switch_channel_mark_pre_answered(channel);
-				switch_set_flag(tech_pvt, TFLAG_SDP);
+				sofia_set_flag(tech_pvt, TFLAG_SDP);
 				if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
 					if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
 						goto done;
@@ -2809,7 +2809,7 @@
 			} else {
 				if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) && !switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
 					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "PROXY MEDIA");
-				} else if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) && !switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
+				} else if (sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION) && !switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
 					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "DELAYED NEGOTIATION");
 				} else {
 					if (sofia_glue_tech_media(tech_pvt, (char *) r_sdp) != SWITCH_STATUS_SUCCESS) {
@@ -2826,25 +2826,25 @@
 		nua_ack(nh, TAG_END());
 		break;
 	case nua_callstate_received:
-		if (!switch_test_flag(tech_pvt, TFLAG_SDP)) {
-			if (r_sdp && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
+		if (!sofia_test_flag(tech_pvt, TFLAG_SDP)) {
+			if (r_sdp && !sofia_test_flag(tech_pvt, TFLAG_SDP)) {
 				if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
 					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOMEDIA");
-					switch_set_flag_locked(tech_pvt, TFLAG_READY);
+					sofia_set_flag_locked(tech_pvt, TFLAG_READY);
 					if (switch_channel_get_state(channel) == CS_NEW) {
 						switch_channel_set_state(channel, CS_INIT);
 					}
-					switch_set_flag(tech_pvt, TFLAG_SDP);
+					sofia_set_flag(tech_pvt, TFLAG_SDP);
 					goto done;
 				} else if (switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
 					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "PROXY MEDIA");
-					switch_set_flag_locked(tech_pvt, TFLAG_READY);
+					sofia_set_flag_locked(tech_pvt, TFLAG_READY);
 					if (switch_channel_get_state(channel) == CS_NEW) {
 						switch_channel_set_state(channel, CS_INIT);
 					}
-				} else if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
+				} else if (sofia_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
 					switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "DELAYED NEGOTIATION");
-					switch_set_flag_locked(tech_pvt, TFLAG_READY);
+					sofia_set_flag_locked(tech_pvt, TFLAG_READY);
 					if (switch_channel_get_state(channel) == CS_NEW) {
 						switch_channel_set_state(channel, CS_INIT);
 					}
@@ -2867,11 +2867,11 @@
 						sip_replaces_t *replaces;
 						su_home_t *home = NULL;
 						switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED");
-						switch_set_flag_locked(tech_pvt, TFLAG_READY);
+						sofia_set_flag_locked(tech_pvt, TFLAG_READY);
 						if (switch_channel_get_state(channel) == CS_NEW) {
 							switch_channel_set_state(channel, CS_INIT);
 						}
-						switch_set_flag(tech_pvt, TFLAG_SDP);
+						sofia_set_flag(tech_pvt, TFLAG_SDP);
 						if (replaces_str) {
 							home = su_home_new(sizeof(*home));
 							switch_assert(home != NULL);
@@ -2891,8 +2891,8 @@
 									if (br_b) {
 										switch_ivr_uuid_bridge(br_a, br_b);
 										switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
-										switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-										switch_clear_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
+										sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+										sofia_clear_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
 										switch_channel_hangup(channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
 									} else {
 										switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER_ERROR");
@@ -2918,22 +2918,22 @@
 				if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
 					goto done;
 				} else {
-					if (profile->pflags & PFLAG_3PCC) {
+					if (sofia_test_pflag(profile, PFLAG_3PCC)) {
 						switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP");
 						sofia_glue_tech_choose_port(tech_pvt, 0);
 						sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
-						switch_set_flag_locked(tech_pvt, TFLAG_3PCC);
+						sofia_set_flag_locked(tech_pvt, TFLAG_3PCC);
 						switch_channel_set_state(channel, CS_HIBERNATE);
 						nua_respond(tech_pvt->nh, SIP_200_OK,
 									SIPTAG_CONTACT_STR(tech_pvt->profile->url),
 									SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 									SOATAG_REUSE_REJECTED(1),
 									SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), 
-									TAG_IF((profile->pflags & PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
-					} else if(profile->pflags & PFLAG_3PCC_PROXY){
+									TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
+					} else if (sofia_test_pflag(profile, PFLAG_3PCC_PROXY)) {
 						//3PCC proxy mode delays the 200 OK until the call is answered
 						switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOSDP");
-						switch_set_flag_locked(tech_pvt, TFLAG_3PCC);
+						sofia_set_flag_locked(tech_pvt, TFLAG_3PCC);
 						sofia_glue_tech_choose_port(tech_pvt, 0);
 						sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
 						switch_channel_set_flag(channel, TFLAG_LATE_NEGOTIATION);
@@ -2947,9 +2947,9 @@
 				}
 			}
 
-		} else if (tech_pvt && switch_test_flag(tech_pvt, TFLAG_SDP) && !r_sdp) {
+		} else if (tech_pvt && sofia_test_flag(tech_pvt, TFLAG_SDP) && !r_sdp) {
 			nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
-			switch_set_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
+			sofia_set_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
 			goto done;
 		} else {
 			ss_state = nua_callstate_completed;
@@ -3015,7 +3015,7 @@
 										SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 										SOATAG_REUSE_REJECTED(1),
 										SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), 
-										TAG_IF((profile->pflags & PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
+										TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
 							launch_media_on_hold(session);
 
 							switch_core_session_rwunlock(other_session);
@@ -3027,13 +3027,13 @@
 						msg.string_arg = (char *) r_sdp;
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Passing SDP to other leg.\n%s\n", r_sdp);
 						
-						if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
+						if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
 							if (!switch_stristr("sendonly", r_sdp)) {
-								switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+								sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 								switch_channel_presence(tech_pvt->channel, "unknown", "unhold", NULL);
 							}
 						} else if (switch_stristr("sendonly", r_sdp)) {
-							switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+							sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 							switch_channel_presence(tech_pvt->channel, "unknown", "hold", NULL);
 						}
 					
@@ -3063,7 +3063,7 @@
 							goto done;
 						}
 						sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
-						switch_set_flag_locked(tech_pvt, TFLAG_REINVITE);
+						sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
 						if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
 							switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Reinvite RTP Error!\n");
 							is_ok = 0;
@@ -3082,7 +3082,7 @@
 								SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 								SOATAG_REUSE_REJECTED(1),
 								SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), 
-								TAG_IF((profile->pflags & PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
+								TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
 				} else {
 					nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
 				}
@@ -3091,13 +3091,13 @@
 		break;
 	case nua_callstate_ready:
 
-		if (r_sdp && switch_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
+		if (r_sdp && sofia_test_flag(tech_pvt, TFLAG_NOSDP_REINVITE)) {
 			sdp_parser_t *parser;
 			sdp_session_t *sdp;
 			uint8_t match = 0;
 			int is_ok = 1;
 			
-			switch_clear_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
+			sofia_clear_flag_locked(tech_pvt, TFLAG_NOSDP_REINVITE);
 
 			if (tech_pvt->num_codecs) {
 				if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
@@ -3109,13 +3109,13 @@
 			}
 
 			if (match) {
-				switch_set_flag_locked(tech_pvt, TFLAG_REINVITE);
+				sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
 				if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP Error!\n");
 					switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RTP ERROR");
 					is_ok = 0;
 				}
-				switch_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
+				sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
 			} else {
 				switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
 				is_ok = 0;
@@ -3134,7 +3134,7 @@
 		}
 		if (tech_pvt && nh == tech_pvt->nh2) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cheater Reinvite!\n");
-			switch_set_flag_locked(tech_pvt, TFLAG_REINVITE);
+			sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
 			tech_pvt->nh = tech_pvt->nh2;
 			tech_pvt->nh2 = NULL;
 			if (sofia_glue_tech_choose_port(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) {
@@ -3147,9 +3147,9 @@
 		}
 		
 		if (channel) {
-            if (switch_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
-                switch_set_flag_locked(tech_pvt, TFLAG_ANS);
-                switch_set_flag(tech_pvt, TFLAG_SDP);
+            if (sofia_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
+                sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
+                sofia_set_flag(tech_pvt, TFLAG_SDP);
                 switch_channel_mark_answered(channel);
 				if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
 					if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
@@ -3162,14 +3162,14 @@
                 goto done;
             }
 			
-			if (!r_sdp && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
+			if (!r_sdp && !sofia_test_flag(tech_pvt, TFLAG_SDP)) {
 				r_sdp = (const char *) switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
 			}
 
-			if (r_sdp && !switch_test_flag(tech_pvt, TFLAG_SDP)) {
+			if (r_sdp && !sofia_test_flag(tech_pvt, TFLAG_SDP)) {
 				if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
-					switch_set_flag_locked(tech_pvt, TFLAG_ANS);
-					switch_set_flag_locked(tech_pvt, TFLAG_SDP);
+					sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
+					sofia_set_flag_locked(tech_pvt, TFLAG_SDP);
 					switch_channel_mark_answered(channel);
 					if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
 						if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
@@ -3202,7 +3202,7 @@
 					}
 
 					if (match) {
-						switch_set_flag_locked(tech_pvt, TFLAG_ANS);
+						sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
 						if (sofia_glue_tech_choose_port(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) {
 							if (sofia_glue_activate_rtp(tech_pvt, 0) == SWITCH_STATUS_SUCCESS) {
 								switch_channel_mark_answered(channel);
@@ -3211,15 +3211,15 @@
 								switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 							}
 
-							if (switch_test_flag(tech_pvt, TFLAG_3PCC)) {
+							if (sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
 								/* Check if we are in 3PCC proxy mode, if so then set the flag to indicate we received the ack */
-								if (profile->pflags & PFLAG_3PCC_PROXY ) {
+								if (sofia_test_pflag(profile, PFLAG_3PCC_PROXY )) {
 									switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "3PCC-PROXY, Got my ACK\n");
-									switch_set_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
+									sofia_set_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
 								} else if (switch_channel_get_state(channel) == CS_HIBERNATE) {
-									switch_set_flag_locked(tech_pvt, TFLAG_READY);
+									sofia_set_flag_locked(tech_pvt, TFLAG_READY);
 									switch_channel_set_state(channel, CS_INIT);
-									switch_set_flag(tech_pvt, TFLAG_SDP);
+									sofia_set_flag(tech_pvt, TFLAG_SDP);
 								}
 							}
 							goto done;
@@ -3236,15 +3236,15 @@
 	case nua_callstate_terminating:
 		if (status == 488 || switch_channel_get_state(channel) == CS_HIBERNATE) {
 			tech_pvt->q850_cause = SWITCH_CAUSE_MANDATORY_IE_MISSING;
-		} else if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
-			switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+		} else if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
+			sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
 		}
 		break;
 	case nua_callstate_terminated:
-		if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
-			switch_set_flag_locked(tech_pvt, TFLAG_BYE);
-			if (switch_test_flag(tech_pvt, TFLAG_NOHUP)) {
-				switch_clear_flag_locked(tech_pvt, TFLAG_NOHUP);
+		if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
+			sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
+			if (sofia_test_flag(tech_pvt, TFLAG_NOHUP)) {
+				sofia_clear_flag_locked(tech_pvt, TFLAG_NOHUP);
 			} else {
 				int cause;
 				if (tech_pvt->q850_cause) {
@@ -3325,7 +3325,7 @@
 					tuuid_str = switch_core_session_get_uuid(tsession);
 					switch_ivr_uuid_bridge(nhelper->bridge_to_uuid, tuuid_str);
 					switch_channel_set_variable(channel_a, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
-					switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+					sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
 					nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
 							   NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(nhelper->event), TAG_END());
 					switch_core_session_rwunlock(tsession);
@@ -3397,7 +3397,7 @@
 		char *rep;
 		full_ref_to = sip_header_as_string(home, (void *) sip->sip_refer_to);
 
-		if (profile->pflags & PFLAG_FULL_ID) {
+		if (sofia_test_pflag(profile, PFLAG_FULL_ID)) {
 			exten = switch_core_session_sprintf(session, "%s@%s", (char *) refer_to->r_url->url_user, (char *) refer_to->r_url->url_host);
 		} else {
 			exten = (char *) refer_to->r_url->url_user;
@@ -3472,8 +3472,8 @@
 							nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
 									   NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(etmp), TAG_END());
 
-							switch_clear_flag_locked(b_tech_pvt, TFLAG_SIP_HOLD);
-							switch_clear_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
+							sofia_clear_flag_locked(b_tech_pvt, TFLAG_SIP_HOLD);
+							sofia_clear_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
 							switch_channel_set_variable(switch_core_session_get_channel(b_session), "park_timeout", "2");
 							switch_channel_set_state(switch_core_session_get_channel(b_session), CS_PARK);
 
@@ -3506,8 +3506,8 @@
 									private_object_t *h_tech_pvt = (private_object_t *) switch_core_session_get_private(b_session);
 									t_session = switch_core_session_locate(br_b);
 									hup_channel = channel_a;
-									switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
-									switch_clear_flag_locked(h_tech_pvt, TFLAG_SIP_HOLD);
+									sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+									sofia_clear_flag_locked(h_tech_pvt, TFLAG_SIP_HOLD);
 									switch_channel_hangup(channel_b, SWITCH_CAUSE_ATTENDED_TRANSFER);
 								}
 
@@ -3894,7 +3894,7 @@
 	char *is_nat = NULL;
 	char *acl_token = NULL;
 
-	if (sess_count >= sess_max || !(profile->pflags & PFLAG_RUNNING)) {
+	if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING)) {
 		nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
 		return;
 	}
@@ -3914,7 +3914,7 @@
 	get_addr(network_ip, sizeof(network_ip), my_addrinfo->ai_addr, my_addrinfo->ai_addrlen);
 	network_port = ntohs(((struct sockaddr_in *) msg_addrinfo(nua_current_request(nua))->ai_addr)->sin_port);
 
-	if ((profile->pflags & PFLAG_AGGRESSIVE_NAT_DETECTION)) {
+	if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION)) {
 		if (sip && sip->sip_via) {
 			const char *port = sip->sip_via->v_port;
 			const char *host = sip->sip_via->v_host;
@@ -3970,13 +3970,13 @@
 			if (token) {
 				acl_token = strdup(token);
 			}
-			if ((profile->pflags & PFLAG_AUTH_CALLS)) {
+			if (sofia_test_pflag(profile, PFLAG_AUTH_CALLS)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IP %s Approved by acl \"%s[%s]\". Access Granted.\n",
 								  network_ip, switch_str_nil(last_acl), switch_str_nil(acl_token));
 				is_auth = 1;
 			}
 		} else {
-			if (!(profile->pflags & PFLAG_AUTH_CALLS)) {
+			if (!sofia_test_pflag(profile, PFLAG_AUTH_CALLS)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "IP %s Rejected by acl \"%s\"\n", network_ip, switch_str_nil(last_acl));
 				nua_respond(nh, SIP_403_FORBIDDEN, TAG_END());
 				return;
@@ -3988,7 +3988,7 @@
 	}
 
 	if (!is_auth &&
-		((profile->pflags & PFLAG_AUTH_CALLS) || (!(profile->pflags & PFLAG_BLIND_AUTH) && (sip->sip_proxy_authorization || sip->sip_authorization)))) {
+		(sofia_test_pflag(profile, PFLAG_AUTH_CALLS) || (!sofia_test_pflag(profile, PFLAG_BLIND_AUTH) && (sip->sip_proxy_authorization || sip->sip_authorization)))) {
 		if (!strcmp(network_ip, profile->sipip) && network_port == profile->sip_port) {
 			calling_myself++;
 		} else {
@@ -4003,7 +4003,7 @@
 	}
 
 	if (sofia_endpoint_interface) {
-		if (profile->pflags & PFLAG_CALLID_AS_UUID) {
+		if (sofia_test_pflag(profile, PFLAG_CALLID_AS_UUID)) {
 			session = switch_core_session_request_uuid(sofia_endpoint_interface, NULL, sip->sip_call_id->i_id);
 		} else {
 			session = switch_core_session_request(sofia_endpoint_interface, NULL);
@@ -4152,7 +4152,7 @@
 
 	if (sip->sip_request->rq_url) {
 		const char *req_uri = url_set_chanvars(session, sip->sip_request->rq_url, sip_req);
-		if (profile->pflags & PFLAG_FULL_ID) {
+		if (sofia_test_pflag(profile, PFLAG_FULL_ID)) {
 			destination_number = req_uri;
 		} else {
 			destination_number = sip->sip_request->rq_url->url_user;
@@ -4280,11 +4280,11 @@
 
 	switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "INBOUND CALL");
 
-	if (switch_test_flag(tech_pvt, TFLAG_INB_NOMEDIA)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_INB_NOMEDIA)) {
 		switch_channel_set_flag(channel, CF_PROXY_MODE);
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_PROXY_MEDIA)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_PROXY_MEDIA)) {
 		switch_channel_set_flag(channel, CF_PROXY_MEDIA);
 	}
 
@@ -4422,8 +4422,8 @@
 								
 
 								if (!one_leg && 
-									(!b_tech_pvt || !switch_test_flag(b_tech_pvt, TFLAG_SIP_HOLD)) && 
-									(!c_tech_pvt || !switch_test_flag(c_tech_pvt, TFLAG_SIP_HOLD))) {
+									(!b_tech_pvt || !sofia_test_flag(b_tech_pvt, TFLAG_SIP_HOLD)) && 
+									(!c_tech_pvt || !sofia_test_flag(c_tech_pvt, TFLAG_SIP_HOLD))) {
 									char *ext = switch_core_session_sprintf(b_session, "conference:%s at sla+flags{mintwo}", uuid);
 								
 									switch_channel_set_flag(c_channel, CF_REDIRECT);
@@ -4462,13 +4462,13 @@
 		if (rpid) {
 			if (rpid->rpid_privacy) {
 				if (!strcasecmp(rpid->rpid_privacy, "yes")) {
-					switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
+					sofia_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
 				} else if (!strcasecmp(rpid->rpid_privacy, "full")) {
-					switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
+					sofia_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
 				} else if (!strcasecmp(rpid->rpid_privacy, "name")) {
-					switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME);
+					sofia_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME);
 				} else if (!strcasecmp(rpid->rpid_privacy, "number")) {
-					switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NUMBER);
+					sofia_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NUMBER);
 				} else {
 					switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME);
 					switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NUMBER);
@@ -4482,7 +4482,7 @@
 
 		if ((privacy = sip_privacy(sip))) {
 			if(msg_params_find(privacy->priv_values, "id")) {
-				switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
+				sofia_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
 			}
 		}
 
@@ -4595,7 +4595,7 @@
 		}
 
 		if (is_nat) {
-			switch_set_flag(tech_pvt, TFLAG_NAT);
+			sofia_set_flag(tech_pvt, TFLAG_NAT);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting NAT mode based on %s\n", is_nat);
 			switch_channel_set_variable(channel, "sip_nat_detected", "true");
 		}

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Mon Feb  9 11:56:38 2009
@@ -163,7 +163,7 @@
 					"m=audio %d RTP/%sAVP", 
 					tech_pvt->owner_id, tech_pvt->session_id, family, ip, family, ip, port,
 					(!switch_strlen_zero(tech_pvt->local_crypto_key) 
-					&& switch_test_flag(tech_pvt,TFLAG_SECURE)) ? "S" : "");
+					&& sofia_test_flag(tech_pvt,TFLAG_SECURE)) ? "S" : "");
 
 	if (tech_pvt->rm_encoding) {
 		switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->pt);
@@ -196,7 +196,7 @@
 		switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->te);
 	}
 
-	if (!(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG) && tech_pvt->cng_pt && use_cng) {
+	if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) && tech_pvt->cng_pt && use_cng) {
 		switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->cng_pt);
 	}
 
@@ -243,7 +243,7 @@
 	if (tech_pvt->dtmf_type == DTMF_2833 && tech_pvt->te > 95) {
 		switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n", tech_pvt->te, tech_pvt->te);
 	}
-	if (!(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG) && tech_pvt->cng_pt && use_cng) {
+	if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) && tech_pvt->cng_pt && use_cng) {
 		switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d CN/8000\n", tech_pvt->cng_pt);
 		if (!tech_pvt->rm_encoding) {
 			tech_pvt->cng_pt = 0;
@@ -260,7 +260,7 @@
 		switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=%s\n", sr);
 	} 
 
-	if (!switch_strlen_zero(tech_pvt->local_crypto_key) && switch_test_flag(tech_pvt, TFLAG_SECURE)) {
+	if (!switch_strlen_zero(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE)) {
 		switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=crypto:%s\n", tech_pvt->local_crypto_key);
 		//switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=encryption:optional\n");
 #if 0
@@ -294,7 +294,7 @@
 #endif
 	}
 
-	if (switch_test_flag(tech_pvt, TFLAG_VIDEO)) {
+	if (sofia_test_flag(tech_pvt, TFLAG_VIDEO)) {
 		if (!switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED) && !switch_channel_test_flag(tech_pvt->channel, CF_EARLY_MEDIA) &&
 			!tech_pvt->local_sdp_video_port) {
 			sofia_glue_tech_choose_video_port(tech_pvt, 0);
@@ -419,7 +419,7 @@
 		}
 
 		if ((ocodec = switch_channel_get_variable(tech_pvt->channel, SWITCH_ORIGINATOR_CODEC_VARIABLE))) {
-			if (!codec_string || (tech_pvt->profile->pflags & PFLAG_DISABLE_TRANSCODING)) {
+			if (!codec_string || sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_TRANSCODING)) {
 				codec_string = ocodec;
 			} else {
 				if (!(codec_string = switch_core_session_sprintf(tech_pvt->session, "%s,%s", ocodec, codec_string))) {
@@ -445,7 +445,7 @@
 
 void sofia_glue_check_video_codecs(private_object_t *tech_pvt)
 {
-	if (tech_pvt->num_codecs && !switch_test_flag(tech_pvt, TFLAG_VIDEO)) {
+	if (tech_pvt->num_codecs && !sofia_test_flag(tech_pvt, TFLAG_VIDEO)) {
 		int i;
 		tech_pvt->video_count = 0;
 		for (i = 0; i < tech_pvt->num_codecs; i++) {
@@ -454,7 +454,7 @@
 			}
 		}
 		if (tech_pvt->video_count) {
-			switch_set_flag_locked(tech_pvt, TFLAG_VIDEO);
+			sofia_set_flag_locked(tech_pvt, TFLAG_VIDEO);
 		}
 	}
 }
@@ -486,7 +486,7 @@
 
 	tech_pvt->dtmf_type = profile->dtmf_type;
 
-	if (!(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG)) {
+	if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG)) {
 		if (tech_pvt->bcng_pt) {
 			tech_pvt->cng_pt = tech_pvt->bcng_pt;
 		} else if (!tech_pvt->cng_pt) {
@@ -522,7 +522,7 @@
 	} else if (!strncasecmp(sourceip, "stun:", 5)) {
 		char *p;
 
-		if (!(profile->pflags & PFLAG_STUN_ENABLED)) {
+		if (!sofia_test_pflag(profile, PFLAG_STUN_ENABLED)) {
 			*ip = switch_core_strdup(pool, tech_pvt->profile->rtpip);
 			return SWITCH_STATUS_SUCCESS;
 		}
@@ -544,7 +544,7 @@
 		}
 
 		for (x = 0; x < 5; x++) {
-			if ((profile->pflags & PFLAG_FUNNY_STUN) || 
+			if (sofia_test_pflag(profile, PFLAG_FUNNY_STUN) || 
 				(tech_pvt && (var = switch_channel_get_variable(tech_pvt->channel, "funny_stun")) && switch_true(var))) {
 				error = "funny";
 				funny++;
@@ -568,8 +568,8 @@
 		if (tech_pvt) {
 			if (myport == *port && !strcmp(*ip, tech_pvt->profile->rtpip)) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "STUN Not Required ip and port match. [%s]:[%d]\n", *ip, *port);
-				if (profile->pflags & PFLAG_STUN_AUTO_DISABLE) {
-					profile->pflags &= ~PFLAG_STUN_ENABLED;
+				if (sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE)) {
+					sofia_clear_pflag(profile, PFLAG_STUN_ENABLED);
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "STUN completely disabled.\n");
 				}
 			} else {
@@ -927,7 +927,7 @@
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Remote video address:port [%s:%d] has not changed.\n",
 							  tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
 		} else {
-			switch_set_flag_locked(tech_pvt, TFLAG_VIDEO);
+			sofia_set_flag_locked(tech_pvt, TFLAG_VIDEO);
 			switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
 			if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
 				if (switch_rtp_set_remote_address(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip, 
@@ -1108,7 +1108,7 @@
 
 	switch_assert(tech_pvt != NULL);
 
-	switch_clear_flag_locked(tech_pvt, TFLAG_SDP);
+	sofia_clear_flag_locked(tech_pvt, TFLAG_SDP);
 
 	caller_profile = switch_channel_get_caller_profile(channel);
 
@@ -1149,7 +1149,7 @@
 
 	sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
 
-	switch_set_flag_locked(tech_pvt, TFLAG_READY);
+	sofia_set_flag_locked(tech_pvt, TFLAG_READY);
 
 	if (!tech_pvt->nh) {
 		char *d_url = NULL, *url = NULL;
@@ -1264,7 +1264,7 @@
 		}
 		
 		if (!(call_id = switch_channel_get_variable(channel, "sip_outgoing_call_id"))) {
-			if (tech_pvt->profile->pflags & PFLAG_UUID_AS_CALLID) {
+			if (sofia_test_pflag(tech_pvt->profile, PFLAG_UUID_AS_CALLID)) {
 				call_id = switch_core_session_get_uuid(session);
 			}
 		}
@@ -1280,7 +1280,7 @@
 
 		if (tech_pvt->dest && (strstr(tech_pvt->dest, ";fs_nat") || strstr(tech_pvt->dest, ";received") 
 							   || ((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val)))) {
-			switch_set_flag(tech_pvt, TFLAG_NAT);
+			sofia_set_flag(tech_pvt, TFLAG_NAT);
 			tech_pvt->record_route = switch_core_session_strdup(tech_pvt->session, url_str);
 			route_uri = tech_pvt->record_route;
 			session_timeout = SOFIA_NAT_SESSION_TIMEOUT;
@@ -1288,16 +1288,16 @@
 		}
 
 		/* TODO: We should use the new tags for making an rpid and add profile options to turn this on/off */
-		if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) {
+		if (sofia_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) {
 			priv = "name";
-			if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
+			if (sofia_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
 				priv = "full";
 			}
-		} else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
+		} else if (sofia_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
 			priv = "full";
 		}
 
-		if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
+		if (sofia_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
 			screen = "yes";
 		}
 
@@ -1343,7 +1343,7 @@
 		free(e_dest);
 	}
 
-	holdstr = switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) ? "*" : "";
+	holdstr = sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD) ? "*" : "";
 
 	if (!switch_channel_get_variable(channel, "sofia_profile_name")) {
 		switch_channel_set_variable(channel, "sofia_profile_name", tech_pvt->profile->name);
@@ -1513,7 +1513,7 @@
 {
 	int loops = 0;
 	if (switch_rtp_ready(tech_pvt->rtp_session)) {
-		while (loops < 10 && (switch_test_flag(tech_pvt, TFLAG_READING) || switch_test_flag(tech_pvt, TFLAG_WRITING))) {
+		while (loops < 10 && (sofia_test_flag(tech_pvt, TFLAG_READING) || sofia_test_flag(tech_pvt, TFLAG_WRITING))) {
 			switch_yield(10000);
 			loops++;
 		}
@@ -1825,7 +1825,7 @@
 	}
 
 	if ((var = switch_channel_get_variable(tech_pvt->channel, SOFIA_SECURE_MEDIA_VARIABLE)) && switch_true(var)) {
-		switch_set_flag_locked(tech_pvt, TFLAG_SECURE);
+		sofia_set_flag_locked(tech_pvt, TFLAG_SECURE);
 	}
 
 
@@ -1834,7 +1834,7 @@
 		goto end;
 	}
 
-	if (switch_rtp_ready(tech_pvt->rtp_session) && !switch_test_flag(tech_pvt, TFLAG_REINVITE)) {
+	if (switch_rtp_ready(tech_pvt->rtp_session) && !sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
 		status = SWITCH_STATUS_SUCCESS;
 		goto end;
 	}
@@ -1865,23 +1865,23 @@
 		}
 	}
 
-	if ((tech_pvt->profile->pflags & PFLAG_PASS_RFC2833)
+	if (sofia_test_pflag(tech_pvt->profile, PFLAG_PASS_RFC2833)
 		|| ((val = switch_channel_get_variable(tech_pvt->channel, "pass_rfc2833")) && switch_true(val))) {
 		flags |= SWITCH_RTP_FLAG_PASS_RFC2833;
 	}
 
-	if (!((tech_pvt->profile->pflags & PFLAG_REWRITE_TIMESTAMPS) ||
+	if (!(sofia_test_pflag(tech_pvt->profile, PFLAG_REWRITE_TIMESTAMPS) ||
 		  ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_rewrite_timestamps")) && !switch_true(val)))) {
 		flags |= SWITCH_RTP_FLAG_RAW_WRITE;
 	}
 
-	if (tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG) {
+	if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG)) {
 		tech_pvt->cng_pt = 0;
 	} else if (tech_pvt->cng_pt) {
 		flags |= SWITCH_RTP_FLAG_AUTO_CNG;
 	}
 
-	if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_REINVITE)) {
+	if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
 		//const char *ip = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
 		//const char *port = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
 		char *remote_host = switch_rtp_get_remote_host(tech_pvt->rtp_session);
@@ -1910,8 +1910,8 @@
 	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
 	switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
 
-	if (tech_pvt->rtp_session && switch_test_flag(tech_pvt, TFLAG_REINVITE)) {
-		switch_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
+	if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
+		sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
 		
 		if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port, SWITCH_TRUE, &err) !=
 			SWITCH_STATUS_SUCCESS) {
@@ -1965,9 +1965,9 @@
 										   (switch_rtp_flag_t) flags, timer_name, &err, switch_core_session_get_pool(tech_pvt->session));
 
 	if (switch_rtp_ready(tech_pvt->rtp_session)) {
-		uint8_t vad_in = switch_test_flag(tech_pvt, TFLAG_VAD_IN) ? 1 : 0;
-		uint8_t vad_out = switch_test_flag(tech_pvt, TFLAG_VAD_OUT) ? 1 : 0;
-		uint8_t inb = switch_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
+		uint8_t vad_in = sofia_test_flag(tech_pvt, TFLAG_VAD_IN) ? 1 : 0;
+		uint8_t vad_out = sofia_test_flag(tech_pvt, TFLAG_VAD_OUT) ? 1 : 0;
+		uint8_t inb = sofia_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
 		uint32_t stun_ping = 0;
 		
 		if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_enable_vad_in")) && switch_true(val)) {
@@ -1997,14 +1997,14 @@
 		}
 
 		tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
-		switch_set_flag(tech_pvt, TFLAG_RTP);
-		switch_set_flag(tech_pvt, TFLAG_IO);
+		sofia_set_flag(tech_pvt, TFLAG_RTP);
+		sofia_set_flag(tech_pvt, TFLAG_IO);
 		
 		switch_rtp_intentional_bugs(tech_pvt->rtp_session, tech_pvt->rtp_bugs);
 		
 		if ((vad_in && inb) || (vad_out && !inb)) {
 			switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING);
-			switch_set_flag(tech_pvt, TFLAG_VAD);
+			sofia_set_flag(tech_pvt, TFLAG_VAD);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "AUDIO RTP Engage VAD for %s ( %s %s )\n",
 							  switch_channel_get_name(switch_core_session_get_channel(tech_pvt->session)), vad_in ? "in" : "", vad_out ? "out" : "");
 		}
@@ -2069,12 +2069,12 @@
 			tech_pvt->cng_pt = 0;
 		}
 
-		if (tech_pvt->cng_pt && !(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG)) {
+		if (tech_pvt->cng_pt && !sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG)) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", tech_pvt->cng_pt);
 			switch_rtp_set_cng_pt(tech_pvt->rtp_session, tech_pvt->cng_pt);
 		}
 
-		if (tech_pvt->remote_crypto_key && switch_test_flag(tech_pvt, TFLAG_SECURE)) {
+		if (tech_pvt->remote_crypto_key && sofia_test_flag(tech_pvt, TFLAG_SECURE)) {
 			sofia_glue_add_crypto(tech_pvt, tech_pvt->remote_crypto_key, SWITCH_RTP_CRYPTO_RECV);
 			switch_rtp_add_crypto_key(tech_pvt->rtp_session, SWITCH_RTP_CRYPTO_SEND, 1, tech_pvt->crypto_type, tech_pvt->local_raw_key,
 									  SWITCH_RTP_KEY_LEN);
@@ -2087,7 +2087,7 @@
 
 		sofia_glue_check_video_codecs(tech_pvt);
 
-		if (switch_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding && tech_pvt->remote_sdp_video_port) {
+		if (sofia_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding && tech_pvt->remote_sdp_video_port) {
 			if (!tech_pvt->local_sdp_video_port) {
 				sofia_glue_tech_choose_video_port(tech_pvt, 1);
 			}
@@ -2133,12 +2133,12 @@
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", switch_str_nil(err));
 		switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-		switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+		sofia_clear_flag_locked(tech_pvt, TFLAG_IO);
 		status = SWITCH_STATUS_FALSE;
 		goto end;
 	}
 
-	switch_set_flag(tech_pvt, TFLAG_IO);
+	sofia_set_flag(tech_pvt, TFLAG_IO);
 	status = SWITCH_STATUS_SUCCESS;
 
   end:
@@ -2182,7 +2182,7 @@
 			return SWITCH_STATUS_FALSE;
 		}
 		switch_channel_set_variable(tech_pvt->channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "EARLY MEDIA");
-		switch_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
+		sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
 		switch_channel_mark_pre_answered(tech_pvt->channel);
 		return SWITCH_STATUS_SUCCESS;
 	}
@@ -2193,10 +2193,10 @@
 void sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly)
 {
 	if (sendonly && switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED)) {
-		if (!switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
+		if (!sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
 			const char *stream;
 
-			switch_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+			sofia_set_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 			switch_channel_presence(tech_pvt->channel, "unknown", "hold", NULL);
 
 			if (tech_pvt->max_missed_hold_packets) {
@@ -2219,13 +2219,13 @@
 			}
 		}
 	} else {
-		if (switch_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
-			switch_set_flag(tech_pvt, TFLAG_SIP_HOLD);
+		if (sofia_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
+			sofia_set_flag(tech_pvt, TFLAG_SIP_HOLD);
 		}
 
-		switch_clear_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
+		sofia_clear_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
 		
-		if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
+		if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
 			const char *uuid;
 			switch_core_session_t *b_session;
 
@@ -2249,7 +2249,7 @@
 				switch_core_session_rwunlock(b_session);
 			}
 
-			switch_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
+			sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
 			switch_channel_presence(tech_pvt->channel, "unknown", "unhold", NULL);
 		}
 	}
@@ -2273,7 +2273,7 @@
 
 	switch_assert(tech_pvt != NULL);
 
-	greedy = !!(tech_pvt->profile->pflags & PFLAG_GREEDY);
+	greedy = !!sofia_test_pflag(tech_pvt->profile, PFLAG_GREEDY);
 
 	if (!greedy) {
 		if ((val = switch_channel_get_variable(channel, "sip_codec_negotiation")) && !strcasecmp(val, "greedy")) {
@@ -2406,7 +2406,7 @@
 								tech_pvt->remote_crypto_key = switch_core_session_strdup(tech_pvt->session, crypto);
 								tech_pvt->crypto_tag = crypto_tag;
 
-								if (switch_rtp_ready(tech_pvt->rtp_session) && switch_test_flag(tech_pvt, TFLAG_SECURE)) {
+								if (switch_rtp_ready(tech_pvt->rtp_session) && sofia_test_flag(tech_pvt, TFLAG_SECURE)) {
 									sofia_glue_add_crypto(tech_pvt, tech_pvt->remote_crypto_key, SWITCH_RTP_CRYPTO_RECV);
 									switch_rtp_add_crypto_key(tech_pvt->rtp_session, SWITCH_RTP_CRYPTO_RECV, tech_pvt->crypto_tag,
 															  tech_pvt->crypto_type, tech_pvt->remote_raw_key, SWITCH_RTP_KEY_LEN);
@@ -2498,7 +2498,7 @@
 					}
 				}
 
-				if (!(tech_pvt->profile->pflags & PFLAG_SUPPRESS_CNG) && !cng_pt && !strcasecmp(rm_encoding, "CN")) {
+				if (!sofia_test_pflag(tech_pvt->profile, PFLAG_SUPPRESS_CNG) && !cng_pt && !strcasecmp(rm_encoding, "CN")) {
 					cng_pt = (switch_payload_t) map->rm_pt;
 					if (tech_pvt->rtp_session) {
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", cng_pt);
@@ -2700,7 +2700,7 @@
 	
  done:
 	tech_pvt->cng_pt = cng_pt;
-	switch_set_flag_locked(tech_pvt, TFLAG_SDP);
+	sofia_set_flag_locked(tech_pvt, TFLAG_SDP);
 
 	return match;
 }
@@ -2779,11 +2779,11 @@
 		other_channel = switch_core_session_get_channel(other_session);
 		switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
 
-		if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
+		if (!sofia_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
 																switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND) &&
 																switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE))) {
 			switch_ivr_nomedia(val, SMF_FORCE);
-			switch_set_flag_locked(tech_pvt, TFLAG_CHANGE_MEDIA);
+			sofia_set_flag_locked(tech_pvt, TFLAG_CHANGE_MEDIA);
 		}
 		switch_core_session_rwunlock(other_session);
 	}
@@ -2817,7 +2817,7 @@
 
 	switch_mutex_lock(mod_sofia_globals.hash_mutex);
 	if ((profile = (sofia_profile_t *) switch_core_hash_find(mod_sofia_globals.profile_hash, key))) {
-		if (!(profile->pflags & PFLAG_RUNNING)) {
+		if (!sofia_test_pflag(profile, PFLAG_RUNNING)) {
 #ifdef SOFIA_DEBUG_RWLOCKS
 			switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "Profile %s is not running\n", profile->name);
 #endif

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c	Mon Feb  9 11:56:38 2009
@@ -1447,7 +1447,7 @@
 			display = "\"user\"";
 		}
 
-		if ((profile->pflags & PFLAG_AGGRESSIVE_NAT_DETECTION)) {
+		if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION)) {
 			if (sip && sip->sip_via) {
 				const char *v_port = sip->sip_via->v_port;
 				const char *v_host = sip->sip_via->v_host;

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	Mon Feb  9 11:56:38 2009
@@ -765,7 +765,7 @@
 			switch_snprintf(new_port, sizeof(new_port), ":%s", port);
 		}
 
-		if (is_nat && (profile->pflags & PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {
+		if (is_nat && sofia_test_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {
 			switch_snprintf(received_data, sizeof(received_data), ";received=%s:%d", url_ip, network_port);
 		}
 
@@ -793,7 +793,7 @@
 		authorization = sip->sip_proxy_authorization;
 	}
 
-	if (regtype == REG_AUTO_REGISTER || (regtype == REG_REGISTER && (profile->pflags & PFLAG_BLIND_REG))) {
+	if (regtype == REG_AUTO_REGISTER || (regtype == REG_REGISTER && sofia_test_pflag(profile, PFLAG_BLIND_REG))) {
 		regtype = REG_REGISTER;
 		goto reg;
 	}
@@ -826,7 +826,7 @@
 
 			if ((v_contact_str = switch_event_get_header(*v_event, "sip-force-contact"))) {
 
-				if (*received_data && (profile->pflags & PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {
+				if (*received_data && sofia_test_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {
 					switch_snprintf(received_data, sizeof(received_data), ";received=%s:%d", url_ip, network_port);
 				}
 
@@ -1141,7 +1141,7 @@
 		goto end;
 	}
 
-	if ((profile->pflags & PFLAG_AGGRESSIVE_NAT_DETECTION)) {
+	if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION)) {
 		if (sip && sip->sip_via) {
 			const char *port = sip->sip_via->v_port;
 			const char *host = sip->sip_via->v_host;
@@ -1192,7 +1192,7 @@
 			}
 		}
 
-		if (ok && !(profile->pflags & PFLAG_BLIND_REG)) {
+		if (ok && !sofia_test_pflag(profile, PFLAG_BLIND_REG)) {
 			type = REG_AUTO_REGISTER;
 		} else if (!ok) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "IP %s Rejected by acl \"%s\"\n", network_ip, profile->reg_acl[x]);
@@ -1292,7 +1292,7 @@
 		private_object_t *tech_pvt;
 		switch_channel_t *channel = switch_core_session_get_channel(session);
 
-		if ((tech_pvt = switch_core_session_get_private(session)) && switch_test_flag(tech_pvt, TFLAG_REFER)) {
+		if ((tech_pvt = switch_core_session_get_private(session)) && sofia_test_flag(tech_pvt, TFLAG_REFER)) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Received reply from REFER\n");
 			goto end;
 		}
@@ -1462,7 +1462,7 @@
 	}
 
 	/* Optional check that auth name == SIP username */
-	if ((regtype == REG_REGISTER) && (profile->pflags & PFLAG_CHECKUSER)) {
+	if ((regtype == REG_REGISTER) && sofia_test_pflag(profile, PFLAG_CHECKUSER)) {
 		if (switch_strlen_zero(username) || switch_strlen_zero(to_user) || strcasecmp(to_user, username)) {
 			/* Names don't match, so fail */
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SIP username %s does not match auth username\n", switch_str_nil(to_user));
@@ -1837,7 +1837,7 @@
 
 	switch_mutex_lock(mod_sofia_globals.hash_mutex);
 	if ((gateway = (sofia_gateway_t *) switch_core_hash_find(mod_sofia_globals.gateway_hash, key))) {
-		if (!(gateway->profile->pflags & PFLAG_RUNNING) || gateway->deleted) {
+		if (!sofia_test_pflag(gateway->profile, PFLAG_RUNNING) || gateway->deleted) {
 			gateway = NULL;
 			goto done;
 		}



More information about the Freeswitch-svn mailing list