[asterisk-commits] rmudgett: branch 12 r404354 - in /branches/12: addons/ channels/ include/aste...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 19 11:03:58 CST 2013


Author: rmudgett
Date: Thu Dec 19 11:03:55 2013
New Revision: 404354

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404354
Log:
udptl: Dead code elimination. ast_udptl_bridge was not used.

Removing dead code starting with ast_udptl_bridge() eliminated the code in
this change.

Note: This code has actually been dead since Asterisk v1.4 when it was
first put in.

Review: https://reviewboard.asterisk.org/r/3079/

Modified:
    branches/12/addons/chan_ooh323.c
    branches/12/channels/chan_sip.c
    branches/12/include/asterisk/udptl.h
    branches/12/main/udptl.c

Modified: branches/12/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/addons/chan_ooh323.c?view=diff&rev=404354&r1=404353&r2=404354
==============================================================================
--- branches/12/addons/chan_ooh323.c (original)
+++ branches/12/addons/chan_ooh323.c Thu Dec 19 11:03:55 2013
@@ -91,9 +91,6 @@
           struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *codecs, int nat_active);
 static void ooh323_get_codec(struct ast_channel *chan, struct ast_format_cap *result);
 void setup_rtp_remote(ooCallData *call, const char *remoteIp, int remotePort);
-
-static struct ast_udptl *ooh323_get_udptl_peer(struct ast_channel *chan);
-static int ooh323_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl);
 
 static void print_codec_to_cli(int fd, struct ast_codec_pref *pref);
 
@@ -129,13 +126,6 @@
 	.update_peer = ooh323_set_rtp_peer,
 	.get_codec = ooh323_get_codec,
 };
-
-static struct ast_udptl_protocol ooh323_udptl = {
-	.type = "H323",
-	.get_udptl_info = ooh323_get_udptl_peer,
-	.set_udptl_peer = ooh323_set_udptl_peer,
-};
-
 
 
 struct ooh323_user;
@@ -3780,7 +3770,6 @@
 			return 0;
 		}
 		ast_rtp_glue_register(&ooh323_rtp);
-		ast_udptl_proto_register(&ooh323_udptl);
 		ast_cli_register_multiple(cli_ooh323, sizeof(cli_ooh323) / sizeof(struct ast_cli_entry));
 
 		 /* fire up the H.323 Endpoint */		 
@@ -4201,7 +4190,6 @@
 	/* First, take us out of the channel loop */
 	ast_cli_unregister_multiple(cli_ooh323, sizeof(cli_ooh323) / sizeof(struct ast_cli_entry));
 	ast_rtp_glue_unregister(&ooh323_rtp);
-	ast_udptl_proto_unregister(&ooh323_udptl);
 	ast_channel_unregister(&ooh323_tech);
 #if 0
 	ast_unregister_atexit(&ast_ooh323c_exit);
@@ -4752,41 +4740,6 @@
 /*
  udptl handling functions
  */
-
-static struct ast_udptl *ooh323_get_udptl_peer(struct ast_channel *chan)
-{
-	struct ooh323_pvt *p;
-	struct ast_udptl *udptl = NULL;
-
-	p = ast_channel_tech_pvt(chan);
-	if (!p)
-		return NULL;
-
-	ast_mutex_lock(&p->lock);
-	if (p->udptl)
-		udptl = p->udptl;
-	ast_mutex_unlock(&p->lock);
-	return udptl;
-}
-
-static int ooh323_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
-{
-	struct ooh323_pvt *p;
-
-	p = ast_channel_tech_pvt(chan);
-	if (!p)
-		return -1;
-	ast_mutex_lock(&p->lock);
-
-	if (udptl) {
-		ast_udptl_get_peer(udptl, &p->udptlredirip);
-	} else
-		memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
-
-	ast_mutex_unlock(&p->lock);
-	/* free(callToken); */
-	return 0;
-}
 
 void setup_udptl_connection(ooCallData *call, const char *remoteIp, 
 								  int remotePort)

Modified: branches/12/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/channels/chan_sip.c?view=diff&rev=404354&r1=404353&r2=404354
==============================================================================
--- branches/12/channels/chan_sip.c (original)
+++ branches/12/channels/chan_sip.c Thu Dec 19 11:03:55 2013
@@ -1535,8 +1535,6 @@
 
 /*------ T38 Support --------- */
 static int transmit_response_with_t38_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans);
-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);
 static void change_t38_state(struct sip_pvt *p, int state);
 
 /*------ Session-Timers functions --------- */
@@ -3570,13 +3568,6 @@
 	ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount + 1);
 	return ASTOBJ_REF(reg);	/* Add pointer to registry in packet */
 }
-
-/*! \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,
-};
 
 static void append_history_full(struct sip_pvt *p, const char *fmt, ...)
 	__attribute__((format(printf, 2, 3)));
@@ -32457,67 +32448,6 @@
 	return 0;
 }
 
-static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan)
-{
-	struct sip_pvt *p;
-	struct ast_udptl *udptl = NULL;
-
-	p = ast_channel_tech_pvt(chan);
-	if (!p) {
-		return NULL;
-	}
-
-	sip_pvt_lock(p);
-	if (p->udptl && ast_test_flag(&p->flags[0], SIP_DIRECT_MEDIA)) {
-		udptl = p->udptl;
-	}
-	sip_pvt_unlock(p);
-	return udptl;
-}
-
-static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
-{
-	struct sip_pvt *p;
-
-	/* Lock the channel and the private safely. */
-	ast_channel_lock(chan);
-	p = ast_channel_tech_pvt(chan);
-	if (!p) {
-		ast_channel_unlock(chan);
-		return -1;
-	}
-	sip_pvt_lock(p);
-	if (p->owner != chan) {
-		/* I suppose it could be argued that if this happens it is a bug. */
-		ast_debug(1, "The private is not owned by channel %s anymore.\n", ast_channel_name(chan));
-		sip_pvt_unlock(p);
-		ast_channel_unlock(chan);
-		return 0;
-	}
-
-	if (udptl) {
-		ast_udptl_get_peer(udptl, &p->udptlredirip);
-	} else {
-		memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
-	}
-	if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
-		if (!p->pendinginvite) {
-			ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s\n",
-					p->callid, ast_sockaddr_stringify(udptl ? &p->udptlredirip : &p->ourip));
-			transmit_reinvite_with_sdp(p, TRUE, FALSE);
-		} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
-			ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s\n",
-					p->callid, ast_sockaddr_stringify(udptl ? &p->udptlredirip : &p->ourip));
-			ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
-		}
-	}
-	/* Reset lastrtprx timer */
-	p->lastrtprx = p->lastrtptx = time(NULL);
-	sip_pvt_unlock(p);
-	ast_channel_unlock(chan);
-	return 0;
-}
-
 static int sip_allow_anyrtp_remote(struct ast_channel *chan1, struct ast_rtp_instance *instance, const char *rtptype)
 {
 	struct sip_pvt *p;
@@ -34511,9 +34441,6 @@
 	/* Register all CLI functions for SIP */
 	ast_cli_register_multiple(cli_sip, ARRAY_LEN(cli_sip));
 
-	/* Tell the UDPTL subdriver that we're here */
-	ast_udptl_proto_register(&sip_udptl);
-
 	/* Tell the RTP engine about our RTP glue */
 	ast_rtp_glue_register(&sip_rtp_glue);
 
@@ -34644,9 +34571,6 @@
 	/* Unregister CLI commands */
 	ast_cli_unregister_multiple(cli_sip, ARRAY_LEN(cli_sip));
 
-	/* Disconnect from UDPTL */
-	ast_udptl_proto_unregister(&sip_udptl);
-
 	/* Disconnect from RTP engine */
 	ast_rtp_glue_unregister(&sip_rtp_glue);
 

Modified: branches/12/include/asterisk/udptl.h
URL: http://svnview.digium.com/svn/asterisk/branches/12/include/asterisk/udptl.h?view=diff&rev=404354&r1=404353&r2=404354
==============================================================================
--- branches/12/include/asterisk/udptl.h (original)
+++ branches/12/include/asterisk/udptl.h Thu Dec 19 11:03:55 2013
@@ -43,15 +43,6 @@
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
-
-struct ast_udptl_protocol {
-	/*! \brief Get UDPTL struct, or NULL if unwilling to transfer */
-	struct ast_udptl *(*get_udptl_info)(struct ast_channel *chan);
-	/*! \brief Set UDPTL peer */
-	int (* const set_udptl_peer)(struct ast_channel *chan, struct ast_udptl *peer);
-	const char * const type;
-	AST_RWLIST_ENTRY(ast_udptl_protocol) list;
-};
 
 struct ast_udptl;
 
@@ -133,13 +124,6 @@
 
 void ast_udptl_setnat(struct ast_udptl *udptl, int nat);
 
-int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
-		     struct ast_frame **fo, struct ast_channel **rc);
-
-int ast_udptl_proto_register(struct ast_udptl_protocol *proto);
-
-void ast_udptl_proto_unregister(struct ast_udptl_protocol *proto);
-
 void ast_udptl_stop(struct ast_udptl *udptl);
 
 void ast_udptl_init(void);

Modified: branches/12/main/udptl.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/udptl.c?view=diff&rev=404354&r1=404353&r2=404354
==============================================================================
--- branches/12/main/udptl.c (original)
+++ branches/12/main/udptl.c Thu Dec 19 11:03:55 2013
@@ -217,8 +217,6 @@
 	udptl_fec_tx_buffer_t tx[UDPTL_BUF_MASK + 1];
 	udptl_fec_rx_buffer_t rx[UDPTL_BUF_MASK + 1];
 };
-
-static AST_RWLIST_HEAD_STATIC(protos, ast_udptl_protocol);
 
 struct udptl_global_options {
 	unsigned int start; /*< The UDPTL start port */
@@ -1186,164 +1184,6 @@
 	return 0;
 }
 
-void ast_udptl_proto_unregister(struct ast_udptl_protocol *proto)
-{
-	AST_RWLIST_WRLOCK(&protos);
-	AST_RWLIST_REMOVE(&protos, proto, list);
-	AST_RWLIST_UNLOCK(&protos);
-}
-
-int ast_udptl_proto_register(struct ast_udptl_protocol *proto)
-{
-	struct ast_udptl_protocol *cur;
-
-	AST_RWLIST_WRLOCK(&protos);
-	AST_RWLIST_TRAVERSE(&protos, cur, list) {
-		if (cur->type == proto->type) {
-			ast_log(LOG_WARNING, "Tried to register same protocol '%s' twice\n", cur->type);
-			AST_RWLIST_UNLOCK(&protos);
-			return -1;
-		}
-	}
-	AST_RWLIST_INSERT_TAIL(&protos, proto, list);
-	AST_RWLIST_UNLOCK(&protos);
-	return 0;
-}
-
-static struct ast_udptl_protocol *get_proto(struct ast_channel *chan)
-{
-	struct ast_udptl_protocol *cur = NULL;
-
-	AST_RWLIST_RDLOCK(&protos);
-	AST_RWLIST_TRAVERSE(&protos, cur, list) {
-		if (cur->type == ast_channel_tech(chan)->type)
-			break;
-	}
-	AST_RWLIST_UNLOCK(&protos);
-
-	return cur;
-}
-
-int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc)
-{
-	struct ast_frame *f;
-	struct ast_channel *who;
-	struct ast_channel *cs[3];
-	struct ast_udptl *p0;
-	struct ast_udptl *p1;
-	struct ast_udptl_protocol *pr0;
-	struct ast_udptl_protocol *pr1;
-	struct ast_sockaddr ac0;
-	struct ast_sockaddr ac1;
-	struct ast_sockaddr t0;
-	struct ast_sockaddr t1;
-	void *pvt0;
-	void *pvt1;
-	int to;
-
-	ast_channel_lock_both(c0, c1);
-	pr0 = get_proto(c0);
-	pr1 = get_proto(c1);
-	if (!pr0) {
-		ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", ast_channel_name(c0));
-		ast_channel_unlock(c0);
-		ast_channel_unlock(c1);
-		return -1;
-	}
-	if (!pr1) {
-		ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", ast_channel_name(c1));
-		ast_channel_unlock(c0);
-		ast_channel_unlock(c1);
-		return -1;
-	}
-	pvt0 = ast_channel_tech_pvt(c0);
-	pvt1 = ast_channel_tech_pvt(c1);
-	p0 = pr0->get_udptl_info(c0);
-	p1 = pr1->get_udptl_info(c1);
-	if (!p0 || !p1) {
-		/* Somebody doesn't want to play... */
-		ast_channel_unlock(c0);
-		ast_channel_unlock(c1);
-		return -2;
-	}
-	if (pr0->set_udptl_peer(c0, p1)) {
-		ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", ast_channel_name(c0), ast_channel_name(c1));
-		memset(&ac1, 0, sizeof(ac1));
-	} else {
-		/* Store UDPTL peer */
-		ast_udptl_get_peer(p1, &ac1);
-	}
-	if (pr1->set_udptl_peer(c1, p0)) {
-		ast_log(LOG_WARNING, "Channel '%s' failed to talk back to '%s'\n", ast_channel_name(c1), ast_channel_name(c0));
-		memset(&ac0, 0, sizeof(ac0));
-	} else {
-		/* Store UDPTL peer */
-		ast_udptl_get_peer(p0, &ac0);
-	}
-	ast_channel_unlock(c0);
-	ast_channel_unlock(c1);
-	cs[0] = c0;
-	cs[1] = c1;
-	cs[2] = NULL;
-	for (;;) {
-		if ((ast_channel_tech_pvt(c0) != pvt0) ||
-			(ast_channel_tech_pvt(c1) != pvt1) ||
-			(ast_channel_masq(c0) || ast_channel_masqr(c0) || ast_channel_masq(c1) || ast_channel_masqr(c1))) {
-				ast_debug(1, "Oooh, something is weird, backing out\n");
-				/* Tell it to try again later */
-				return -3;
-		}
-		to = -1;
-		ast_udptl_get_peer(p1, &t1);
-		ast_udptl_get_peer(p0, &t0);
-		if (ast_sockaddr_cmp(&t1, &ac1)) {
-			ast_debug(1, "Oooh, '%s' changed end address to %s\n",
-				ast_channel_name(c1), ast_sockaddr_stringify(&t1));
-			ast_debug(1, "Oooh, '%s' was %s\n",
-				ast_channel_name(c1), ast_sockaddr_stringify(&ac1));
-			ast_sockaddr_copy(&ac1, &t1);
-		}
-		if (ast_sockaddr_cmp(&t0, &ac0)) {
-			ast_debug(1, "Oooh, '%s' changed end address to %s\n",
-				ast_channel_name(c0), ast_sockaddr_stringify(&t0));
-			ast_debug(1, "Oooh, '%s' was %s\n",
-				ast_channel_name(c0), ast_sockaddr_stringify(&ac0));
-			ast_sockaddr_copy(&ac0, &t0);
-		}
-		who = ast_waitfor_n(cs, 2, &to);
-		if (!who) {
-			ast_debug(1, "Ooh, empty read...\n");
-			/* check for hangup / whentohangup */
-			if (ast_check_hangup(c0) || ast_check_hangup(c1))
-				break;
-			continue;
-		}
-		f = ast_read(who);
-		if (!f) {
-			*fo = f;
-			*rc = who;
-			ast_debug(1, "Oooh, got a %s\n", f ? "digit" : "hangup");
-			/* That's all we needed */
-			return 0;
-		} else {
-			if (f->frametype == AST_FRAME_MODEM) {
-				/* Forward T.38 frames if they happen upon us */
-				if (who == c0) {
-					ast_write(c1, f);
-				} else if (who == c1) {
-					ast_write(c0, f);
-				}
-			}
-			ast_frfree(f);
-		}
-		/* Swap priority. Not that it's a big deal at this point */
-		cs[2] = cs[0];
-		cs[0] = cs[1];
-		cs[1] = cs[2];
-	}
-	return -1;
-}
-
 static char *handle_cli_udptl_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	switch (cmd) {




More information about the asterisk-commits mailing list