[asterisk-commits] branch oej/t38passthrough r12677 - /team/oej/t38passthrough/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Mar 12 13:04:18 MST 2006


Author: oej
Date: Sun Mar 12 14:04:14 2006
New Revision: 12677

URL: http://svn.digium.com/view/asterisk?rev=12677&view=rev
Log:
Update to trunk

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

Modified: team/oej/t38passthrough/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/t38passthrough/channels/chan_sip.c?rev=12677&r1=12676&r2=12677&view=diff
==============================================================================
--- team/oej/t38passthrough/channels/chan_sip.c (original)
+++ team/oej/t38passthrough/channels/chan_sip.c Sun Mar 12 14:04:14 2006
@@ -71,9 +71,7 @@
 #include "asterisk/sched.h"
 #include "asterisk/io.h"
 #include "asterisk/rtp.h"
-#if defined(T38_SUPPORT)
 #include "asterisk/udptl.h"
-#endif
 #include "asterisk/acl.h"
 #include "asterisk/manager.h"
 #include "asterisk/callerid.h"
@@ -454,7 +452,6 @@
 static int sip_reloading = FALSE;			/*!< Flag for avoiding multiple reloads at the same time */
 static enum channelreloadreason sip_reloadreason;	/*!< Reason for last reload/load of configuration */
 
-#if defined(T38_SUPPORT)
 /* T.38 set of flags */
 #define T38FAX_FILL_BIT_REMOVAL			(1 << 0) 	/*!< Default: 0 (unset)*/
 #define T38FAX_TRANSCODING_MMR			(1 << 1)	/*!< Default: 0 (unset)*/
@@ -479,7 +476,6 @@
 #define T38FAX_RATE_14400			(1 << 13)	/*!< 14400 bps t38FaxRate */
 
 static int global_t38_capability = T38FAX_VERSION_0 | T38FAX_RATE_2400 | T38FAX_RATE_4800 | T38FAX_RATE_7200 | T38FAX_RATE_9600; /*!< This is default: NO MMR and JBIG trancoding, NO fill bit removal, transfered TCF, UDP FEC, Version 0 and 9600 max fax rate */
-#endif
 
 /*! \brief Codecs that we support by default: */
 static struct sched_context *sched;	/*!< The scheduling context */
@@ -531,7 +527,7 @@
 	char hop[0];
 };
 
-#ifdef T38_SUPPORT
+/*! \brief T38 Sates for a call */
 enum t38state {
 	T38_DISABLED	= 0,		/*! Not enabled */
 	T38_LOCAL_DIRECT,		/*! Offered from local */
@@ -541,6 +537,7 @@
 	T38_ENABLED			/*! Negotiated (enabled) */
 };
 
+/*! \brief T.38 channel settings (at some point we need to make this alloc'ed */
 struct t38properties {
 	struct ast_flags t38support;	/*!< Flag for udptl, rtp or tcp support for this session */
 	int capability;			/*!< Our T38 capability */
@@ -548,7 +545,6 @@
 	int jointcapability;		/*!< Supported T38 capability at both ends */
 	enum t38state state;		/*!< T.38 state */
 };
-#endif
 
 /*! \brief Modes for SIP domain handling in the PBX */
 enum domain_mode {
@@ -731,11 +727,9 @@
 	int peercapability;			/*!< Supported peer capability */
 	int prefcodec;				/*!< Preferred codec (outbound only) */
 	int noncodeccapability;
-#if defined(T38_SUPPORT)
 	struct t38properties t38;		/*!< T38 settings */
 	struct sockaddr_in udptlredirip;	/*!< Where our T.38 UDPTL should be going if not to us */
 	struct ast_udptl *udptl;		/*!< T.38 UDPTL session */
-#endif
 	int callingpres;			/*!< Calling presentation */
 	int authtries;				/*!< Times we've tried to authenticate */
 	int expiry;				/*!< How long we take to expire */
@@ -1040,14 +1034,12 @@
 static struct sip_peer *temp_peer(const char *name);
 
 /*------ T38 Support --------- */
-#if defined(T38_SUPPORT)
 static int sip_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo,struct ast_channel **rc, int timeoutms);	/*!< Function to bridge to SIP channels if NOT T.38 enabled */
 static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_pvt *pvt, int reinvite); /*!< T38 negotiation helper function */
 static int transmit_response_with_t38_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans);
 static int transmit_reinvite_with_t38_sdp(struct sip_pvt *p);
 static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan);
 static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl);
-#endif
 
 /*----- RTP interface functions */
 static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active);
@@ -1073,11 +1065,7 @@
 	.transfer = sip_transfer,
 	.fixup = sip_fixup,
 	.send_digit = sip_senddigit,
-#if defined(T38_SUPPORT)
 	.bridge = sip_bridge,
-#else
- 	.bridge = ast_rtp_bridge,
-#endif
 	.send_text = sip_sendtext,
 };
 
@@ -1090,14 +1078,12 @@
 	get_codec: sip_get_codec,
 };
 
-#if defined(T38_SUPPORT)
 /*! \brief Interface structure with callbacks used to connect to UDPTL module*/
 static struct ast_udptl_protocol sip_udptl = {
 	type: "SIP",
 	get_udptl_info: sip_get_udptl_peer,
 	set_udptl_peer: sip_set_udptl_peer,
 };
-#endif
 
 
 /*!
@@ -2004,7 +1990,6 @@
 	ast_copy_flags(r, peer, SIP_FLAGS_TO_COPY);
 	r->capability = peer->capability;
 	r->prefs = peer->prefs;
-#if defined(T38_SUPPORT)
 	if (ast_test_flag(&peer->flags_page2, SIP_PAGE2_T38SUPPORT)) {
 		ast_copy_flags(&r->t38.t38support, &peer->flags_page2, SIP_PAGE2_T38SUPPORT);
 		r->t38.capability = global_t38_capability;
@@ -2025,7 +2010,6 @@
 		if (r->udptl)
 			ast_udptl_destroy(r->udptl);
 	}
-#endif
 	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));
@@ -2036,13 +2020,11 @@
 			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));
 	}
-#if defined(T38_SUPPORT)
 	if (r->udptl) {
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %d\n", (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE));
 		ast_udptl_setnat(r->udptl, (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE));
 	}
-#endif
 	ast_string_field_set(r, peername, peer->username);
 	ast_string_field_set(r, authname, peer->username);
 	ast_string_field_set(r, username, peer->username);
@@ -2213,13 +2195,11 @@
 		} else if (!p->options->addsipheaders && !strncasecmp(ast_var_name(current), "SIPADDHEADER", strlen("SIPADDHEADER"))) {
 			/* Check whether there is a variable with a name starting with SIPADDHEADER */
 			p->options->addsipheaders = 1;
-#if defined(T38_SUPPORT)
 		} else if (!strncasecmp(ast_var_name(current), "T38CALL", strlen("T38CALL"))) {
 			/* Check whether there is a variable with a name starting with T38CALL */
 			p->t38.state = T38_LOCAL_DIRECT;
 			if (option_debug)
 				ast_log(LOG_DEBUG,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
-#endif
 		}
 
 		
@@ -2249,11 +2229,9 @@
 	if ( res != -1 ) {
 		p->callingpres = ast->cid.cid_pres;
 		p->jointcapability = p->capability;
-#if defined(T38_SUPPORT)
 		p->t38.jointcapability = p->t38.capability;
 		if (option_debug)
 			ast_log(LOG_DEBUG,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
-#endif
 		transmit_invite(p, SIP_INVITE, 1, 2);
 		if (p->maxtime) {
 			/* Initialize auto-congest time */
@@ -2317,11 +2295,9 @@
 	if (p->vrtp) {
 		ast_rtp_destroy(p->vrtp);
 	}
-#if defined(T38_SUPPORT)
 	if (p->udptl) {
 		ast_udptl_destroy(p->udptl);
 	}
-#endif
 	if (p->route) {
 		free_old_route(p->route);
 		p->route = NULL;
@@ -2787,15 +2763,13 @@
 		ast_setstate(ast, AST_STATE_UP);
 		if (option_debug)
 			ast_log(LOG_DEBUG, "SIP answering channel: %s\n", ast->name);
-#if defined(T38_SUPPORT)
 		if (p->t38.state == T38_PEER_DIRECT) {
 			p->t38.state = T38_ENABLED;
 			if (option_debug > 1)
 				ast_log(LOG_DEBUG,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
 			res = transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, 1);
 		} else
-#endif
-		res = transmit_response_with_sdp(p, "200 OK", &p->initreq, XMIT_RELIABLE);
+			res = transmit_response_with_sdp(p, "200 OK", &p->initreq, XMIT_RELIABLE);
 	}
 	ast_mutex_unlock(&p->lock);
 	return res;
@@ -2846,7 +2820,6 @@
 	case AST_FRAME_IMAGE:
 		return 0;
 		break;
-#if defined(T38_SUPPORT)
 	case AST_FRAME_MODEM:
 		if (p) {
 			ast_mutex_lock(&p->lock);
@@ -2860,7 +2833,6 @@
 			ast_mutex_unlock(&p->lock);
 		}
 		break;
-#endif
 	default: 
 		ast_log(LOG_WARNING, "Can't send %d type frames with SIP write\n", frame->frametype);
 		return 0;
@@ -3013,7 +2985,6 @@
 	return res;
 }
 
-#ifdef T38_SUPPORT
 /*! \brief SIP bridge
 \note	Because attempt to do a native RTP bridge between peers happens before T38 re-invites
         and that one time only, and at that moment neither peers have T38 enabled, this will
@@ -3035,7 +3006,6 @@
 	/* We can't do T38 passthrough, so go ahead with RTP bridge and possibly reinvites */
 	return ast_rtp_bridge(c0, c1, flags, fo, rc, timeoutms);
 }
-#endif
 
 /*! \brief Initiate a call in the SIP channel
 	called from sip_request_call (calls from the pbx ) */
@@ -3079,11 +3049,10 @@
 
 	if (ast_test_flag(i, SIP_DTMF) ==  SIP_DTMF_INBAND) {
 		i->vad = ast_dsp_new();
-#if defined(T38_SUPPORT)
-		ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT | DSP_FEATURE_FAX_DETECT);
-#else
- 		ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
-#endif
+		if (ast_test_flag(&i->t38.t38support, SIP_PAGE2_T38SUPPORT))
+			ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT | DSP_FEATURE_FAX_DETECT);
+		else
+ 			ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
 		if (global_relaxdtmf)
 			ast_dsp_digitmode(i->vad, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF);
 	}
@@ -3095,11 +3064,9 @@
 		tmp->fds[2] = ast_rtp_fd(i->vrtp);
 		tmp->fds[3] = ast_rtcp_fd(i->vrtp);
 	}
-#if defined(T38_SUPPORT)
 	if (i->udptl) {
     		tmp->fds[4] = ast_udptl_fd(i->udptl);
 	}
-#endif
 	if (state == AST_STATE_RING)
 		tmp->rings = 1;
 	tmp->adsicpe = AST_ADSI_UNAVAILABLE;
@@ -3263,11 +3230,7 @@
 }
 
 /*! \brief Read RTP from network */
-#if defined(T38_SUPPORT)
 static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p, int *faxdetect)
-#else
-static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p)
-#endif
 {
 	/* Retrieve audio/etc from channel.  Assumes p->lock is already held. */
 	struct ast_frame *f;
@@ -3290,11 +3253,9 @@
 	case 3:
 		f = ast_rtcp_read(p->vrtp);	/* RTCP Control Channel for video */
 		break;
-#if defined(T38_SUPPORT)
 	case 4:
 		f = ast_udptl_read(p->udptl);	/* UDPTL for T.38 */
 		break;
-#endif
 	default:
 		f = &ast_null_frame;
 	}
@@ -3315,7 +3276,6 @@
 			if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
 				f = ast_dsp_process(p->owner, p->vad, f);
 				if (f && (f->frametype == AST_FRAME_DTMF)) { 
-#if defined(T38_SUPPORT)
 					if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
 						/* Fax tone */
 						if (option_debug)
@@ -3323,7 +3283,6 @@
 
 						*faxdetect = 1;
 					}
-#endif
 					if (option_debug)
 						ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
 				}
@@ -3338,18 +3297,13 @@
 {
 	struct ast_frame *fr;
 	struct sip_pvt *p = ast->tech_pvt;
-#if defined(T38_SUPPORT)
 	int faxdetected = FALSE;
-#endif
+
 	ast_mutex_lock(&p->lock);
-#if defined(T38_SUPPORT)
 	fr = sip_rtp_read(ast, p, &faxdetected);
-#else
-	fr = sip_rtp_read(ast, p);
-#endif
 	time(&p->lastrtprx);
 	ast_mutex_unlock(&p->lock);
-#if defined(T38_SUPPORT)
+
 	/* If we are NOT bridged to another channel, and we have detected fax tone we issue T38 re-invite to a peer */
 	/* If we are bridged then it is responsibility of the SIP device to issue T38 re-invite if it detects CNG or fax preabmle */
 	if (faxdetected  && ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && (p->t38.state == T38_DISABLED) && !(ast_bridged_channel(ast))) {
@@ -3368,7 +3322,7 @@
 				ast_set_flag(p, SIP_NEEDREINVITE);
 			}	
 	}
-#endif
+
 	return fr;
 }
 
@@ -3461,11 +3415,10 @@
 		p->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
 		if (global_videosupport)
 			p->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
-#if defined(T38_SUPPORT)
 		if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) )
 			p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, bindaddr.sin_addr);
 			/* TODO: Need to check for error - or ?? */
-#endif
+
 		if (!p->rtp || (global_videosupport && !p->vrtp)) {
 			ast_log(LOG_WARNING, "Unable to create RTP audio %s session: %s\n", global_videosupport ? "and video" : "", strerror(errno));
 			ast_mutex_destroy(&p->lock);
@@ -3479,10 +3432,8 @@
 		ast_rtp_settos(p->rtp, global_tos);
 		if (p->vrtp)
 			ast_rtp_settos(p->vrtp, global_tos);
-#if defined(T38_SUPPORT)
 		if (p->udptl)
 			ast_udptl_settos(p->udptl, global_tos);
-#endif
 		p->rtptimeout = global_rtptimeout;
 		p->rtpholdtimeout = global_rtpholdtimeout;
 		p->rtpkeepalive = global_rtpkeepalive;
@@ -3496,10 +3447,8 @@
 			ast_rtp_setnat(p->rtp, (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
 		if (p->vrtp)
 			ast_rtp_setnat(p->vrtp, (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
-#if defined(T38_SUPPORT)
 		if (p->udptl)
 			ast_udptl_setnat(p->udptl, (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
-#endif
 	}
 
 	if (p->method != SIP_REGISTER)
@@ -3515,7 +3464,6 @@
 	p->capability = global_capability;
 	if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO))
 		p->noncodeccapability |= AST_RTP_DTMF;
-#if defined(T38_SUPPORT)
 	if (p->udptl) {
 		p->t38.capability = global_t38_capability;
 		if (ast_udptl_get_error_correction_scheme(p->udptl) == UDPTL_ERROR_CORRECTION_REDUNDANCY)
@@ -3527,7 +3475,6 @@
 		p->t38.capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
 		p->t38.jointcapability = p->t38.capability;
 	}	
-#endif
 	ast_string_field_set(p, context, default_context);
 
 	/* Add to active dialog list */
@@ -3822,12 +3769,10 @@
 	int len = -1;
 	int portno = -1;
 	int vportno = -1;
-#if defined(T38_SUPPORT)
 	int udptlportno = -1;
 	int peert38capability = 0;
 	char s[256];
 	int old = 0;
-#endif        
 	int peercapability, peernoncodeccapability;
 	int vpeercapability=0, vpeernoncodeccapability=0;
 	struct sockaddr_in sin;
@@ -3895,7 +3840,7 @@
 				codecs = ast_skip_blanks(codecs + len);
 			}
 		}
-#if defined(T38_SUPPORT)
+
 		if (p->udptl && (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL)) && (sscanf(m, "image %d udptl t38 %n", &x, &len) == 1)) {
 			if (debug)
 				ast_verbose("Got T.38 offer in SDP\n");
@@ -3912,7 +3857,7 @@
 					ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
 			}				
 		}
-#endif
+
 		if (p->vrtp)
 			ast_rtp_pt_clear(p->vrtp);  /* Must be cleared in case no m=video line exists */
 
@@ -3936,11 +3881,7 @@
 		if (!found )
 			ast_log(LOG_WARNING, "Unknown SDP media type in offer: %s\n", m);
 	}
-#if defined(T38_SUPPORT)
 	if (portno == -1 && vportno == -1 && udptlportno == -1) {
-#else
-	if (portno == -1 && vportno == -1) {
-#endif
 		/* No acceptable offer found in SDP */
 		return -2;
 	}
@@ -4008,7 +3949,6 @@
 			}
 		}
 	}
-#if defined(T38_SUPPORT)
 	/* Setup UDPTL port number */
 	if (p->udptl && (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL))) {
 		if (udptlportno > 0) {
@@ -4023,7 +3963,6 @@
 				ast_log(LOG_DEBUG, "Peer doesn't provide T.38 UDPTL\n");
 		}
 	}
-#endif
 
 	/* Next, scan through each "a=rtpmap:" line, noting each
 	 * specified RTP payload type (with corresponding MIME subtype):
@@ -4046,7 +3985,7 @@
 		if (p->vrtp)
 			ast_rtp_set_rtpmap_type(p->vrtp, codec, "video", mimeSubtype);
 	}
-#if defined(T38_SUPPORT)
+
 	if (udptlportno != -1) {
 		int found = 0;
 
@@ -4167,7 +4106,6 @@
 		if (option_debug > 1)
 			ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
 	}
-#endif
 
 	/* Now gather all of the codecs that were asked for: */
 	ast_rtp_get_current_formats(p->rtp,
@@ -4914,7 +4852,7 @@
 		/* Indicate we support DTMF and FLASH... */
 		ast_build_string(a_buf, a_size, "a=fmtp:%d 0-16\r\n", rtp_code);
 }
-#if defined(T38_SUPPORT)
+
 /*! \brief Get Max T.38 Transmision rate from T38 capabilities */
 int t38_get_rate(int t38cap)
 {
@@ -5050,7 +4988,6 @@
 
 	return 0;
 }
-#endif
 
 /*! \brief Add Session Description Protocol message */
 static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
@@ -5154,12 +5091,11 @@
 					 debug);
 		alreadysent |= p->prefcodec;
 	}
-#if defined(T38_SUPPORT)
+
 	if ((ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_RTP))) {
 		ast_build_string(&m_audio_next, &m_audio_left, " %d", 191);
 		ast_build_string(&a_audio_next, &a_audio_left, "a=rtpmap:%d %s/%d\r\n", 191, "t38", 8000);
 	}
-#endif
 
 	/* Start by sending our preferred codecs */
 	for (x = 0; x < 32; x++) {
@@ -5282,7 +5218,6 @@
 	return send_response(p, &resp, reliable, seqno);
 }
 
-#if defined(T38_SUPPORT)
 /*--- transmit_response_with_t38_sdp: Used for 200 OK and 183 early media ---*/
 static int transmit_response_with_t38_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans)
 {
@@ -5302,7 +5237,6 @@
 	}
 	return send_response(p, &resp, retrans, seqno);
 }
-#endif
 
 /*! \brief Parse first line of incoming SIP request */
 static int determine_firstline_parts( struct sip_request *req ) 
@@ -5381,7 +5315,6 @@
 	return send_request(p, &req, 1, p->ocseq);
 }
 
-#if defined(T38_SUPPORT)
 /*--- transmit_reinvite_with_t38_sdp: Transmit reinvite with T38 SDP ---*/
 /* 	A re-invite is basically a new INVITE with the same CALL-ID and TAG as the
 	INVITE that opened the SIP dialogue 
@@ -5410,7 +5343,6 @@
 	ast_set_flag(p, SIP_OUTGOING);
 	return send_request(p, &req, 1, p->ocseq);
 }
-#endif
 
 /*! \brief Check Contact: URI of SIP message */
 static void extract_uri(struct sip_pvt *p, struct sip_request *req)
@@ -5736,16 +5668,13 @@
 			}
 		}
 	}
-#if defined(T38_SUPPORT)
+
 	if (sdp && (p->udptl) && (p->t38.state == T38_LOCAL_DIRECT)) {
 		ast_udptl_offered_from_local(p->udptl, 1);
 		if (option_debug)
 			ast_log(LOG_DEBUG, "T38 is in state %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
 		add_t38_sdp(&req, p);
 	} else if (sdp && p->rtp) {
-#else
-	if (sdp && p->rtp) {
-#endif
 		add_sdp(&req, p);
 	} else {
 		add_header_contentLength(&req, 0);
@@ -7829,13 +7758,11 @@
 				ast_log(LOG_DEBUG, "Setting NAT on VRTP to %d\n", (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
 			ast_rtp_setnat(p->vrtp, (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
 		}
-#if defined(T38_SUPPORT)
 		if (p->udptl) {
 			if (option_debug)
 				ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %d\n", (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
 			ast_udptl_setnat(p->udptl, (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
 		}
-#endif
 		if (!(res = check_auth(p, req, user->name, user->secret, user->md5secret, sipmethod, uri, reliable, ignore))) {
 			sip_cancel_destroy(p);
 			ast_copy_flags(p, user, SIP_FLAGS_TO_COPY);
@@ -7878,10 +7805,8 @@
 				p->noncodeccapability |= AST_RTP_DTMF;
 			else
 				p->noncodeccapability &= ~AST_RTP_DTMF;
-#if defined(T38_SUPPORT)
 			if (p->t38.peercapability)
 				p->t38.jointcapability &= p->t38.peercapability;
-#endif
 		}
 		if (user && debug)
 			ast_verbose("Found user '%s'\n", user->name);
@@ -7938,13 +7863,11 @@
 					ast_log(LOG_DEBUG, "Setting NAT on VRTP to %d\n", (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
 				ast_rtp_setnat(p->vrtp, (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
 			}
-#if defined(T38_SUPPORT)
 			if (p->udptl) {
 				if (option_debug)
 					ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %d\n", (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
 				ast_udptl_setnat(p->udptl, (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
 			}
-#endif
 			ast_string_field_set(p, peersecret, peer->secret);
 			ast_string_field_set(p, peermd5secret, peer->md5secret);
 			ast_string_field_set(p, subscribecontext, peer->subscribecontext);
@@ -8008,10 +7931,8 @@
 					p->noncodeccapability |= AST_RTP_DTMF;
 				else
 					p->noncodeccapability &= ~AST_RTP_DTMF;
-#if defined(T38_SUPPORT)
 				if (p->t38.peercapability)
 					p->t38.jointcapability &= p->t38.peercapability;
-#endif
 			}
 			ASTOBJ_UNREF(peer, sip_destroy_peer);
 		} else { 
@@ -8322,17 +8243,12 @@
 		ast_cli(fd, FORMAT2, "Name/username", "Host", "Dyn", "Nat", "ACL", "Port", "Status");
 	} 
 	
-#ifdef T38_SUPPORT
 #define T38FMT	"T38pt_support_udptl: %s\r\n" \
 				"T38pt_support_rtp: %s\r\n" \
 				"T38pt_support_tcp: %s\r\n"
 #define T38ARGS	ast_test_flag((&iterator->flags_page2), SIP_PAGE2_T38SUPPORT_UDPTL) ? "yes" : "no", 	/* Dynamic or not? */ \
 				ast_test_flag((&iterator->flags_page2), SIP_PAGE2_T38SUPPORT_RTP) ? "yes" : "no", 	/* Dynamic or not? */ \
 				ast_test_flag((&iterator->flags_page2), SIP_PAGE2_T38SUPPORT_TCP) ? "yes" : "no", 	/* Dynamic or not? */
-#else
-#define T38FMT		""
-#define T38ARGS
-#endif
 
 	ASTOBJ_CONTAINER_TRAVERSE(&peerl, 1, do {
 		char status[20] = "";
@@ -8787,11 +8703,9 @@
 		ast_cli(fd, "  User=Phone   : %s\n", (ast_test_flag(peer, SIP_USEREQPHONE)?"Yes":"No"));
 		ast_cli(fd, "  Trust RPID   : %s\n", (ast_test_flag(peer, SIP_TRUSTRPID) ? "Yes" : "No"));
 		ast_cli(fd, "  Send RPID    : %s\n", (ast_test_flag(peer, SIP_SENDRPID) ? "Yes" : "No"));
-#ifdef T38_SUPPORT
 		ast_cli(fd, "  T38 pt UDPTL: %s\n", (ast_test_flag((&peer->flags_page2), SIP_PAGE2_T38SUPPORT_UDPTL)?"Yes":"No"));
 		ast_cli(fd, "  T38 pt RTP  : %s\n", (ast_test_flag((&peer->flags_page2), SIP_PAGE2_T38SUPPORT_RTP)?"Yes":"No"));
 		ast_cli(fd, "  T38 pt TCP  : %s\n", (ast_test_flag((&peer->flags_page2), SIP_PAGE2_T38SUPPORT_TCP)?"Yes":"No"));
-#endif
 
 		/* - is enumerated */
 		ast_cli(fd, "  DTMFmode     : %s\n", dtmfmode2str(ast_test_flag(peer, SIP_DTMF)));
@@ -8866,11 +8780,9 @@
 		ast_cli(fd, "SIP-CanReinvite: %s\r\n", (ast_test_flag(peer, SIP_CAN_REINVITE)?"Y":"N"));
 		ast_cli(fd, "SIP-PromiscRedir: %s\r\n", (ast_test_flag(peer, SIP_PROMISCREDIR)?"Y":"N"));
 		ast_cli(fd, "SIP-UserPhone: %s\r\n", (ast_test_flag(peer, SIP_USEREQPHONE)?"Y":"N"));
-#ifdef T38_SUPPORT
 		ast_cli(fd, "SIP-T38pt-support-udptl: %s\r\n", (ast_test_flag((&peer->flags_page2), SIP_PAGE2_T38SUPPORT_UDPTL)?"Y":"N"));
 		ast_cli(fd, "SIP-T38pt-support-rtp: %s\r\n", (ast_test_flag((&peer->flags_page2), SIP_PAGE2_T38SUPPORT_RTP)?"Y":"N"));
 		ast_cli(fd, "SIP-T38pt-support-tcp: %s\r\n", (ast_test_flag((&peer->flags_page2), SIP_PAGE2_T38SUPPORT_TCP)?"Y":"N"));
-#endif
 
 		/* - is enumerated */
 		ast_cli(fd, "SIP-DTMFmode %s\r\n", dtmfmode2str(ast_test_flag(peer, SIP_DTMF)));
@@ -9034,13 +8946,9 @@
 	ast_cli(fd, "  Record SIP history:     %s\n", recordhistory ? "On" : "Off");
 	ast_cli(fd, "  Call Events:            %s\n", global_callevents ? "On" : "Off");
 	ast_cli(fd, "  IP ToS:                 0x%x\n", global_tos);
-#ifdef T38_SUPPORT
 	ast_cli(fd, "  T38 fax pt UDPTL:       %s\n", ast_test_flag(&global_flags_page2, SIP_PAGE2_T38SUPPORT_UDPTL) ? "Yes" : "No");
 	ast_cli(fd, "  T38 fax pt RTP:         %s\n", ast_test_flag(&global_flags_page2, SIP_PAGE2_T38SUPPORT_RTP) ? "Yes" : "No");
 	ast_cli(fd, "  T38 fax pt TCP:         %s\n", ast_test_flag(&global_flags_page2, SIP_PAGE2_T38SUPPORT_TCP) ? "Yes" : "No");
-#else
-	ast_cli(fd, "  T38 passthrough supp.:  %s\n", "Disabled");
-#endif
 #ifdef OSP_SUPPORT
 	ast_cli(fd, "  OSP Support:            Yes\n");
 #else
@@ -10199,13 +10107,11 @@
 		ast_copy_string(buf, p->useragent, len);
 	} else  if (!strcasecmp(data, "peername")) {
 		ast_copy_string(buf, p->peername, len);
-#ifdef T38_SUPPORT
 	} else  if (!strcasecmp(data, "t38passthrough")) {
 		if (p->t38.state == T38_DISABLED)
 			ast_copy_string(buf, "0", sizeof("0"));
 		else	/* T38 is offered or enabled in this call */
 			ast_copy_string(buf, "1", sizeof("1"));
-#endif
 	} else {
 		ast_mutex_unlock(&chan->lock);
 		return -1;
@@ -10228,9 +10134,7 @@
 	"- uri                   The URI from the Contact: header.\n"
 	"- useragent             The useragent.\n"
 	"- peername              The name of the peer.\n"
-#ifdef T38_SUPPORT
 	"- t38passthrough        1 if T38 is offered or enabled in this channel, otherwise 0\n"
-#endif
 };
 
 /*! \brief  parse_moved_contact: Parse 302 Moved temporalily response */
@@ -10359,7 +10263,6 @@
 			build_route(p, req, 1);
 		}
 		
-#if defined(T38_SUPPORT)
 		if (p->owner && (p->owner->_state == AST_STATE_UP)) { /* if this is a re-invite */ 
 			struct ast_channel *bridgepeer = NULL;
 			struct sip_pvt *bridgepvt = NULL;
@@ -10406,7 +10309,6 @@
 			if (option_debug)
 				ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
 		}
-#endif
 		if (!ignore && p->owner) {
 			if (p->owner->_state != AST_STATE_UP) {
 #ifdef OSP_SUPPORT	
@@ -10802,12 +10704,10 @@
 					/* Immediately stop VRTP */
 					ast_rtp_stop(p->vrtp);
 				}
-#if defined(T38_SUPPORT)
 				if (p->udptl) {
 					/* Immediately stop T.38 UDPTL */
 					ast_udptl_stop(p->udptl);
 				}
-#endif
 				/* XXX Locking issues?? XXX */
 				switch(resp) {
 				case 300: /* Multiple Choices */
@@ -11379,7 +11279,6 @@
 			transmit_response(p, "180 Ringing", req);
 			break;
 		case AST_STATE_UP:
-#if defined(T38_SUPPORT)
 			if (p->t38.state == T38_PEER_REINVITE) {
 	    			struct ast_channel *bridgepeer = NULL;
 				struct sip_pvt *bridgepvt = NULL;
@@ -11401,18 +11300,18 @@
 								if (option_debug > 1)
 							    		ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->name);
 	    						 	if (ignore)
-									transmit_response(p, "415 Unsupported Media Type", req);
+									transmit_response(p, "488 Not acceptable here", req);
 								else
-									transmit_response_reliable(p, "415 Unsupported Media Type", req, 1);
+									transmit_response_reliable(p, "488 Not acceptable here", req);
 								ast_set_flag(p, SIP_NEEDDESTROY);
 							} 
 						}
 					} else {
 						/* Other side is not a SIP channel */
 						if (ignore)
-							transmit_response(p, "415 Unsupported Media Type", req);
+							transmit_response(p, "488 Not acceptable here", req);
 						else 
-	    						transmit_response_reliable(p, "415 Unsupported Media Type", req, 1);
+							transmit_response_reliable(p, "488 Not acceptable here", req);
 						p->t38.state = T38_DISABLED;
 						if (option_debug > 1)
 							ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
@@ -11439,7 +11338,7 @@
 							if (ignore)
 								transmit_response(p, "488 Not Acceptable Here (unsupported)", req);
 							else
-								transmit_response_reliable(p, "488 Not Acceptable Here (unsupported)", req, 1);
+								transmit_response_reliable(p, "488 Not Acceptable Here (unsupported)", req);
 							ast_set_flag(p, SIP_NEEDDESTROY);
 						} else {
 							/* No bridged peer with T38 enabled*/
@@ -11448,9 +11347,6 @@
 					}
 				}
 			} 
-#else
-			transmit_response_with_sdp(p, "200 OK", req, 1);
-#endif
 			break;
 		default:
 			ast_log(LOG_WARNING, "Don't know how to handle INVITE in state %d\n", c->_state);
@@ -11558,12 +11454,10 @@
 		/* Immediately stop VRTP */
 		ast_rtp_stop(p->vrtp);
 	}
-#if defined(T38_SUPPORT)
 	if (p->udptl) {
 		/* Immediately stop T.38 UDPTL */
 		ast_udptl_stop(p->udptl);
 	}
-#endif
 	if (p->owner)
 		ast_queue_hangup(p->owner);
 	else
@@ -11601,12 +11495,10 @@
 		/* Immediately stop VRTP */
 		ast_rtp_stop(p->vrtp);
 	}
-#if defined(T38_SUPPORT)
 	if (p->udptl) {
 		/* Immediately stop T.38 UDPTL */
 		ast_udptl_stop(p->udptl);
 	}
-#endif
 	if (!ast_strlen_zero(get_header(req, "Also"))) {
 		ast_log(LOG_NOTICE, "Client '%s' using deprecated BYE/Also transfer method.  Ask vendor to support REFER instead\n",
 			ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr));
@@ -12918,7 +12810,6 @@
 			user->callingpres = ast_parse_caller_presentation(v->value);
 			if (user->callingpres == -1)
 				user->callingpres = atoi(v->value);
-#if defined(T38_SUPPORT)
 		} else if (!strcasecmp(v->name, "t38pt_udptl")) {
 			if (ast_true(v->value)) {
 				ast_set_flag(&user->flags_page2, SIP_PAGE2_T38SUPPORT_UDPTL);
@@ -12934,7 +12825,6 @@
 				ast_set_flag(&user->flags_page2, SIP_PAGE2_T38SUPPORT_TCP);
 			} else
 				ast_clear_flag(&user->flags_page2, SIP_PAGE2_T38SUPPORT_TCP);
-#endif
 		}
 	}
 	ast_copy_flags(user, &userflags, mask.flags);
@@ -13186,7 +13076,6 @@
 				ast_log(LOG_WARNING, "'%s' is not a valid RTP keepalive time at line %d.  Using default.\n", v->value, v->lineno);
 				peer->rtpkeepalive = global_rtpkeepalive;
 			}
-#if defined(T38_SUPPORT)
 		} else if (!strcasecmp(v->name, "t38pt_udptl")) {
 			if (ast_true(v->value)) {
 				ast_set_flag(&peer->flags_page2, SIP_PAGE2_T38SUPPORT_UDPTL);
@@ -13202,7 +13091,6 @@
 				ast_set_flag(&peer->flags_page2, SIP_PAGE2_T38SUPPORT_TCP);
 			} else
 				ast_clear_flag(&peer->flags_page2, SIP_PAGE2_T38SUPPORT_TCP);
-#endif
 		} else if (!strcasecmp(v->name, "setvar")) {
 			/* Set peer channel variable */
 			varname = ast_strdupa(v->value);
@@ -13397,7 +13285,6 @@
 			}
 		} else if (!strcasecmp(v->name, "videosupport")) {
 			global_videosupport = ast_true(v->value);
-#if defined(T38_SUPPORT)
 		} else if (!strcasecmp(v->name, "t38pt_udptl")) {
 			if (ast_true(v->value)) {
 				ast_set_flag(&global_flags_page2, SIP_PAGE2_T38SUPPORT_UDPTL);
@@ -13410,7 +13297,6 @@
 			if (ast_true(v->value)) {
 				ast_set_flag(&global_flags_page2, SIP_PAGE2_T38SUPPORT_TCP);
 			}
-#endif
 		} else if (!strcasecmp(v->name, "compactheaders")) {
 			compactheaders = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "notifymimetype")) {
@@ -13764,7 +13650,6 @@
 	return 0;
 }
 
-#if defined(T38_SUPPORT)
 static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan)
 {
 	struct sip_pvt *p;
@@ -13893,7 +13778,6 @@
 		return 0;
 	}
 }
-#endif
 
 static char *synopsis_dtmfmode = "Change the dtmfmode for a SIP call";
 static char *descrip_dtmfmode = "SIPDtmfMode(inband|info|rfc2833): Changes the dtmfmode for a SIP call\n";
@@ -14232,10 +14116,10 @@
 
 	/* Tell the RTP subdriver that we're here */
 	ast_rtp_proto_register(&sip_rtp);
-#if defined(T38_SUPPORT)
+
 	/* Tell the UDPTL subdriver that we're here */
 	ast_udptl_proto_register(&sip_udptl);
-#endif
+
 	/* Register dialplan applications */
 	ast_register_application(app_dtmfmode, sip_dtmfmode, synopsis_dtmfmode, descrip_dtmfmode);
 	ast_register_application(app_sipaddheader, sip_addheader, synopsis_sipaddheader, descrip_sipaddheader);
@@ -14276,10 +14160,8 @@
 	ast_unregister_application(app_dtmfmode);
 	ast_unregister_application(app_sipaddheader);
 
-#if defined(T38_SUPPORT)
 	/* Tell the UDPTL subdriver that we're gone */
 	ast_udptl_proto_unregister(&sip_udptl);
-#endif
 
 	ast_cli_unregister_multiple(my_clis, sizeof(my_clis) / sizeof(my_clis[0]));
 



More information about the asterisk-commits mailing list