[svn-commits] rmudgett: branch rmudgett/dahdi_deflection r221703 - in /team/rmudgett/dahdi_...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Oct 1 14:54:14 CDT 2009


Author: rmudgett
Date: Thu Oct  1 14:54:10 2009
New Revision: 221703

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=221703
Log:
Merged revisions 221697,221701 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r221697 | dvossel | 2009-10-01 14:33:33 -0500 (Thu, 01 Oct 2009) | 9 lines
  
  outbound tls connections were not defaulting to port 5061
  
  (closes issue #15854)
  Reported by: dvossel
  Patches:
        sip_port_config_trunk.diff uploaded by dvossel (license 671)
  Tested by: dvossel
........
  r221701 | rmudgett | 2009-10-01 14:48:58 -0500 (Thu, 01 Oct 2009) | 10 lines
  
  Prevent deadlock if chan_dahdi attempts to change PRI channel names.
  
  The PRI channels can no longer change the channel name if a different B
  channel is selected during call negotiation.  To prevent using the channel
  name to infer what B channel a call is using and to avoid name collisions,
  the channel name format is changed.
  
  The new channel naming for PRI channels is:
  DAHDI/ISDN-<span>-<sequence-number>
........

Modified:
    team/rmudgett/dahdi_deflection/   (props changed)
    team/rmudgett/dahdi_deflection/CHANGES
    team/rmudgett/dahdi_deflection/channels/chan_dahdi.c
    team/rmudgett/dahdi_deflection/channels/chan_sip.c
    team/rmudgett/dahdi_deflection/channels/sig_pri.h

Propchange: team/rmudgett/dahdi_deflection/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Oct  1 14:54:10 2009
@@ -1,1 +1,1 @@
-/trunk:1-221639
+/trunk:1-221701

Modified: team/rmudgett/dahdi_deflection/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/dahdi_deflection/CHANGES?view=diff&rev=221703&r1=221702&r2=221703
==============================================================================
--- team/rmudgett/dahdi_deflection/CHANGES (original)
+++ team/rmudgett/dahdi_deflection/CHANGES Thu Oct  1 14:54:10 2009
@@ -216,6 +216,12 @@
    LibPRI).
  * Added the ability to ignore calls that are not in a Multiple Subscriber
    Number (MSN) list for PTMP CPE interfaces.
+ * The PRI channels can no longer change the channel name if a different B
+   channel is selected during call negotiation.  To prevent using the channel
+   name to infer what B channel a call is using and to avoid name collisions,
+   the channel name format is changed.
+   The new channel naming for PRI channels is:
+   DAHDI/ISDN-<span>-<sequence-number>
 
 Asterisk Manager Interface
 --------------------------

Modified: team/rmudgett/dahdi_deflection/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/dahdi_deflection/channels/chan_dahdi.c?view=diff&rev=221703&r1=221702&r2=221703
==============================================================================
--- team/rmudgett/dahdi_deflection/channels/chan_dahdi.c (original)
+++ team/rmudgett/dahdi_deflection/channels/chan_dahdi.c Thu Oct  1 14:54:10 2009
@@ -2600,18 +2600,10 @@
 {
 	struct dahdi_pvt *old_chan = chan_old;
 	struct dahdi_pvt *new_chan = chan_new;
-	struct sig_pri_chan *pchan = new_chan->sig_pvt;
-	struct sig_pri_pri *pri = pchan->pri;
 
 	new_chan->owner = old_chan->owner;
 	old_chan->owner = NULL;
 	if (new_chan->owner) {
-		char newname[AST_CHANNEL_NAME];
-
-		snprintf(newname, sizeof(newname), "DAHDI/%d:%d-%s", pri->trunkgroup,
-			new_chan->channel, pchan->no_b_channel ? "NO-MEDIA" : "1");
-		ast_change_name(new_chan->owner, newname);
-
 		new_chan->owner->tech_pvt = new_chan;
 		new_chan->owner->fds[0] = new_chan->subs[SUB_REAL].dfd;
 		new_chan->subs[SUB_REAL].owner = old_chan->subs[SUB_REAL].owner;
@@ -8371,23 +8363,36 @@
 	struct ast_str *chan_name;
 	struct ast_variable *v;
 	struct dahdi_params ps;
+
 	if (i->subs[idx].owner) {
 		ast_log(LOG_WARNING, "Channel %d already has a %s call\n", i->channel,subnames[idx]);
 		return NULL;
 	}
-	y = 1;
+
+	/* Create the new channel name tail. */
 	chan_name = ast_str_alloca(32);
-	do {
-		if (i->channel == CHAN_PSEUDO)
-			ast_str_set(&chan_name, 0, "pseudo-%ld", ast_random());
-		else
+	if (i->channel == CHAN_PSEUDO) {
+		ast_str_set(&chan_name, 0, "pseudo-%ld", ast_random());
+#if defined(HAVE_PRI)
+	} else if (i->pri) {
+		ast_mutex_lock(&i->pri->lock);
+		ast_str_set(&chan_name, 0, "ISDN-%d-%d", i->pri->span, ++i->pri->new_chan_seq);
+		ast_mutex_unlock(&i->pri->lock);
+#endif	/* defined(HAVE_PRI) */
+	} else {
+		y = 1;
+		do {
 			ast_str_set(&chan_name, 0, "%d-%d", i->channel, y);
-		for (x = 0; x < 3; x++) {
-			if ((idx != x) && i->subs[x].owner && !strcasecmp(ast_str_buffer(chan_name), i->subs[x].owner->name + 6))
-				break;
-		}
-		y++;
-	} while (x < 3);
+			for (x = 0; x < 3; ++x) {
+				if (i->subs[x].owner && !strcasecmp(ast_str_buffer(chan_name),
+					i->subs[x].owner->name + 6)) {
+					break;
+				}
+			}
+			++y;
+		} while (x < 3);
+	}
+
 	tmp = ast_channel_alloc(0, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, linkedid, i->amaflags, "DAHDI/%s", ast_str_buffer(chan_name));
 	if (!tmp)
 		return NULL;

Modified: team/rmudgett/dahdi_deflection/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/dahdi_deflection/channels/chan_sip.c?view=diff&rev=221703&r1=221702&r2=221703
==============================================================================
--- team/rmudgett/dahdi_deflection/channels/chan_sip.c (original)
+++ team/rmudgett/dahdi_deflection/channels/chan_sip.c Thu Oct  1 14:54:10 2009
@@ -7606,29 +7606,32 @@
 	AST_NONSTANDARD_RAW_ARGS(user2, user1.userpart, '@');
 
 	if (host3.port) {
-		if (sscanf(host3.port, "%5u", &portnum) != 1 || portnum > 65535) {
+		if (!(portnum = port_str2int(host3.port, 0))) {
 			ast_log(LOG_NOTICE, "'%s' is not a valid port number on line %d of sip.conf. using default.\n", host3.port, lineno);
-			portnum = -1;
-		}
-	}
-
+		}
+	}
+
+	/* set transport type */
 	if (!pre2.transport) {
 		transport = SIP_TRANSPORT_UDP;
 	} else if (!strncasecmp(pre2.transport, "tcp", 3)) {
 		transport = SIP_TRANSPORT_TCP;
 	} else if (!strncasecmp(pre2.transport, "tls", 3)) {
 		transport = SIP_TRANSPORT_TLS;
-		if (portnum < 0) {
-			portnum = STANDARD_TLS_PORT;
-		}
 	} else if (!strncasecmp(pre2.transport, "udp", 3)) {
 		transport = SIP_TRANSPORT_UDP;
 	} else {
+		transport = SIP_TRANSPORT_UDP;
 		ast_log(LOG_NOTICE, "'%.3s' is not a valid transport type on line %d of sip.conf. defaulting to udp.\n", pre2.transport, lineno);
 	}
 
-	if (portnum < 0) {
-		portnum = STANDARD_SIP_PORT;
+	/* if no portnum specified, set default for transport */
+	if (!portnum) {
+		if (transport == SIP_TRANSPORT_TLS) {
+			portnum = STANDARD_TLS_PORT;
+		} else {
+			portnum = STANDARD_SIP_PORT;
+		}
 	}
 
 	if (!(reg = ast_calloc(1, sizeof(*reg)))) {
@@ -24166,6 +24169,7 @@
 	struct ast_ha *oldha = NULL;
 	int found = 0;
 	int firstpass = 1;
+	uint16_t port = 0;
 	int format = 0;		/* Ama flags */
 	time_t regseconds = 0;
 	struct ast_flags peerflags[2] = {{(0)}};
@@ -24341,17 +24345,15 @@
 						/* Initialize stuff if this is a new peer, or if it used to
 						 * not be dynamic before the reload. */
 						memset(&peer->addr.sin_addr, 0, 4);
-						if (peer->addr.sin_port) {
-							/* If we've already got a port, make it the default rather than absolute */
-							peer->defaddr.sin_port = peer->addr.sin_port;
-							peer->addr.sin_port = 0;
-						}
+						peer->addr.sin_port = 0;
 					}
 					peer->host_dynamic = TRUE;
 				} else {
 					/* Non-dynamic.  Make sure we become that way if we're not */
 					AST_SCHED_DEL_UNREF(sched, peer->expire,
 							unref_peer(peer, "removing register expire ref"));
+					/* the port will either be set to a default value or a config specified value once all option parsing is complete */
+					peer->addr.sin_port = 0;
 					peer->host_dynamic = FALSE;
 					srvlookup = v->value;
 					if (global_dynamic_exclude_static) {
@@ -24381,10 +24383,8 @@
 				}
 			} else if (!strcasecmp(v->name, "port")) {
 				peer->portinuri = 1;
-				if (!realtime && peer->host_dynamic) {
-					peer->defaddr.sin_port = htons(atoi(v->value));
-				} else {
-					peer->addr.sin_port = htons(atoi(v->value));
+				if (!(port = port_str2int(v->value, 0))) {
+					ast_log(LOG_WARNING, "Invalid peer port configuration at line %d : %s\n", v->lineno, v->value);
 				}
 			} else if (!strcasecmp(v->name, "callingpres")) {
 				peer->callingpres = ast_parse_caller_presentation(v->value);
@@ -24608,6 +24608,12 @@
 			set_socket_transport(&peer->socket, peer->default_outbound_transport);
 		}
 
+		if (port && !realtime && peer->host_dynamic) {
+			peer->defaddr.sin_port = htons(port);
+		} else if (port) {
+			peer->addr.sin_port = htons(port);
+		}
+
 		if (ast_str_strlen(fullcontact)) {
 			ast_string_field_set(peer, fullcontact, ast_str_buffer(fullcontact));
 			peer->rt_fromcontact = TRUE;
@@ -24648,7 +24654,9 @@
 		if (!peer->addr.sin_port) {
 			peer->addr.sin_port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
 		}
-
+		if (!peer->defaddr.sin_port) {
+			peer->defaddr.sin_port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
+		}
 		if (!peer->socket.port) {
 			peer->socket.port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
 		}

Modified: team/rmudgett/dahdi_deflection/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/dahdi_deflection/channels/sig_pri.h?view=diff&rev=221703&r1=221702&r2=221703
==============================================================================
--- team/rmudgett/dahdi_deflection/channels/sig_pri.h (original)
+++ team/rmudgett/dahdi_deflection/channels/sig_pri.h Thu Oct  1 14:54:10 2009
@@ -219,6 +219,7 @@
 	int resetting;							/*!< true if span is being reset/restarted */
 	int resetpos;							/*!< current position during a reset (-1 if not started) */
 	int sig;								/*!< ISDN signalling type (SIG_PRI, SIG_BRI, SIG_BRI_PTMP, etc...) */
+	int new_chan_seq;						/*!< New struct ast_channel sequence number */
 
 	/* Everything after here is internally set */
 	struct pri *dchans[NUM_DCHANS];				/*!< Actual d-channels */




More information about the svn-commits mailing list