[asterisk-commits] dhubbard: branch group/issue3450 r122765 - /team/group/issue3450/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 13 17:28:47 CDT 2008


Author: dhubbard
Date: Fri Jun 13 17:28:47 2008
New Revision: 122765

URL: http://svn.digium.com/view/asterisk?view=rev&rev=122765
Log:
merged revisions to move this branch into the world of DAHDI

Modified:
    team/group/issue3450/channels/chan_dahdi.c

Modified: team/group/issue3450/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/group/issue3450/channels/chan_dahdi.c?view=diff&rev=122765&r1=122764&r2=122765
==============================================================================
--- team/group/issue3450/channels/chan_dahdi.c (original)
+++ team/group/issue3450/channels/chan_dahdi.c Fri Jun 13 17:28:47 2008
@@ -584,6 +584,7 @@
 	unsigned int progress:1;
 	unsigned int resetting:1;
 	unsigned int setup_ack:1;
+	unsigned int changestatus;	/* for NFAS MAINTenance SERVice message handling */
 #endif
 	unsigned int use_smdi:1;		/* Whether to use SMDI on this channel */
 	struct ast_smdi_interface *smdi_iface;	/* The serial port to listen for SMDI data on */
@@ -8628,7 +8629,11 @@
 
 	if (p->locallyblocked || p->remotelyblocked)
 		return 0;
-		
+
+	/* If channel is not in service, definitely not */
+	if (p->changestatus > 0)
+		return 0;
+
 	/* If no owner definitely available */
 	if (!p->owner) {
 #ifdef HAVE_PRI
@@ -9772,6 +9777,32 @@
 						ast_log(LOG_NOTICE, "Received FAA and we haven't sent FAR.  Ignoring.\n");
 					}
 					ast_mutex_unlock(&p->lock);
+				}
+				break;
+			case PRI_EVENT_SERVICE:
+				chanpos = pri_find_principle(pri, e->service.channel);
+				if (chanpos < 0) {
+					ast_log(LOG_WARNING, "Received SERVice change status %d on unconfigured channel %d/%d span %d\n",
+						e->service_ack.changestatus, PRI_SPAN(e->service_ack.channel), PRI_CHANNEL(e->service_ack.channel), pri->span);
+				} else {
+					ast_mutex_lock(&pri->pvts[chanpos]->lock);
+					pri->pvts[chanpos]->changestatus = e->service.changestatus;
+					ast_mutex_unlock(&pri->pvts[chanpos]->lock);
+					ast_log(LOG_WARNING, "Received SERVice change status %d on channel %d/%d span %d\n",
+						e->service.changestatus, PRI_SPAN(e->service.channel), PRI_CHANNEL(e->service.channel), pri->span);
+				}
+				break;
+			case PRI_EVENT_SERVICE_ACK:
+				chanpos = pri_find_principle(pri, e->service_ack.channel);
+				if (chanpos < 0) {
+					ast_log(LOG_WARNING, "Received SERVice ACKnowledge change status %d on unconfigured channel %d/%d span %d\n",
+						e->service_ack.changestatus, PRI_SPAN(e->service_ack.channel), PRI_CHANNEL(e->service_ack.channel), pri->span);
+				} else {
+					ast_mutex_lock(&pri->pvts[chanpos]->lock);
+					pri->pvts[chanpos]->changestatus = e->service_ack.changestatus;
+					ast_mutex_unlock(&pri->pvts[chanpos]->lock);
+					ast_log(LOG_WARNING, "Received SERVice ACKnowledge change status %d on channel %d/%d span %d\n",
+						e->service_ack.changestatus, PRI_SPAN(e->service_ack.channel), PRI_CHANNEL(e->service_ack.channel), pri->span);
 				}
 				break;
 			default:
@@ -11459,6 +11490,163 @@
 	return CLI_SUCCESS;
 }
 
+static char *handle_pri_service_generic(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a, int changestatus)
+{
+	int channel;
+	int interfaceid = 0;
+	struct dahdi_pvt *tmp = NULL;
+	int x;
+	int y;
+	ast_mutex_t *lock;
+	struct dahdi_pvt *start;
+	char *c;
+	int trunkgroup;
+	struct dahdi_pri *pri=NULL;
+	int fd = a->fd;
+	
+	lock = &iflock;
+	start = iflist;
+
+	if (a->argc < 5 || a->argc > 6)
+		return CLI_SHOWUSAGE;
+	if ((c = strchr(a->argv[4], ':'))) {
+		if (sscanf(a->argv[4], "%d:%d", &trunkgroup, &channel) != 2)
+			return CLI_SHOWUSAGE;
+		if ((trunkgroup < 1) || (channel < 1))
+			return CLI_SHOWUSAGE;
+		for (x=0;x<NUM_SPANS;x++) {
+			if (pris[x].trunkgroup == trunkgroup) {
+				pri = pris + x;
+				break;
+			}
+		}
+		if (pri) {
+			start = pri->crvs;
+			lock = &pri->lock;
+		} else {
+			ast_cli(fd, "No such trunk group %d\n", trunkgroup);
+			return CLI_FAILURE;
+		}
+	} else
+		channel = atoi(a->argv[4]);
+	
+	if (a->argc == 6)
+		interfaceid = atoi(a->argv[5]);
+
+	/* either servicing a D-Channel */
+	for (x=0;x<NUM_SPANS;x++) {
+		for (y=0;y<NUM_DCHANS;y++) {
+			if (pris[x].dchannels[y] == channel) {
+				pri = pris + x;
+				pri_maintenance_service(pri->pri, interfaceid, -1, changestatus);
+				return CLI_SUCCESS;
+			}
+		}
+	}
+
+	/* or servicing a B-Channel */
+	ast_mutex_lock(lock);
+	tmp = start;
+	while (tmp) {
+		if (tmp->pri && tmp->channel == channel) {
+			ast_log(LOG_NOTICE, "about to call pri_maintenance_service(span: %d, channel: %d)\n", PRI_SPAN(PVT_TO_CHANNEL(tmp)), PVT_TO_CHANNEL(tmp));
+			pri_maintenance_service(tmp->pri->pri, PRI_SPAN(PVT_TO_CHANNEL(tmp)), PVT_TO_CHANNEL(tmp), changestatus);
+			ast_mutex_unlock(lock);
+			return CLI_SUCCESS;
+		}
+		tmp = tmp->next;
+	}
+	ast_mutex_unlock(lock);
+
+	ast_cli(fd, "Unable to find given channel %d, possibly not a PRI\n", channel);
+	return CLI_FAILURE;
+}
+
+static char *handle_pri_service_enable_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:	
+		e->command = "pri service enable channel";
+		e->usage = 
+			"Usage: pri service enable channel <channel> [<interface id>]\n"
+			"       Send an AT&T / NFAS / CCS ANSI T1.607 maintenance message\n"
+			"	to restore a channel to service, with optional interface id\n"
+			"	as agreed upon with remote switch operator\n";
+		return NULL;
+	case CLI_GENERATE:	
+		return NULL;
+	}
+	return handle_pri_service_generic(e, cmd, a, 0);
+}
+
+static char *handle_pri_service_loop_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:	
+		e->command = "pri service loop channel";
+		e->usage = 
+			"Usage: pri service loop channel <chan num> [<interface id>]\n"
+			"	Send an AT&T / NFAS / CCS ANSI T1.607 maintenance message\n"
+			"	to put a channel into a maintenance loop, with optional interface id\n"
+			"	as agreed upon with remote switch operator\n";
+		return NULL;
+	case CLI_GENERATE:	
+		return NULL;
+	}
+	return handle_pri_service_generic(e, cmd, a, 1);
+}
+
+static char *handle_pri_service_disable_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:	
+		e->command = "pri service disable channel";
+		e->usage = 
+			"Usage: pri service disable channel <chan num> [<interface id>]\n"
+			"	Send an AT&T / NFAS / CCS ANSI T1.607 maintenance message\n"
+			"	to remove a channel from service, with optional interface id\n"
+			"	as agreed upon with remote switch operator\n";
+		return NULL;
+	case CLI_GENERATE:	
+		return NULL;
+	}
+	return handle_pri_service_generic(e, cmd, a, 2);
+}
+
+static char *handle_pri_service_continuity_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:	
+		e->command = "pri service continuity channel";
+		e->usage = 
+			"Usage: pri service continuity channel <chan num> [<interface id>]\n"
+			"	Send an AT&T / NFAS / CCS ANSI T1.607 maintenance message\n"
+			"	to test channel continuity, with optional interface id\n"
+			"	as agreed upon with remote switch operator\n";
+		return NULL;
+	case CLI_GENERATE:	
+		return NULL;
+	}
+	return handle_pri_service_generic(e, cmd, a, 3);
+}
+
+static char *handle_pri_service_shutdown_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:	
+		e->command = "pri service shutdown channel";
+		e->usage = 
+			"Usage: pri service shutdown channel <chan num> [<interface id>]\n"
+			"	Send an AT&T / NFAS / CCS ANSI T1.607 maintenance message\n"
+			"	to shutdown a channel, with optional interface id\n"
+			"	as agreed upon with remote switch operator\n";
+		return NULL;
+	case CLI_GENERATE:	
+		return NULL;
+	}
+	return handle_pri_service_generic(e, cmd, a, 4);
+}
+
 
 
 static char *handle_pri_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -11692,6 +11880,11 @@
 	AST_CLI_DEFINE(handle_pri_debug, "Enables PRI debugging on a span"),
 	AST_CLI_DEFINE(handle_pri_no_debug, "Disables PRI debugging on a span"),
 	AST_CLI_DEFINE(handle_pri_really_debug, "Enables REALLY INTENSE PRI debugging"),
+ 	AST_CLI_DEFINE(handle_pri_service_enable_channel, "Return a channel to service"),
+ 	AST_CLI_DEFINE(handle_pri_service_disable_channel, "Remove a channel from service"),
+ 	AST_CLI_DEFINE(handle_pri_service_loop_channel, "Put a channel into maintenance loop"),
+ 	AST_CLI_DEFINE(handle_pri_service_continuity_channel, "Test channel continuity"),
+ 	AST_CLI_DEFINE(handle_pri_service_shutdown_channel, "Shutdown a channel"), 
 	AST_CLI_DEFINE(handle_pri_show_spans, "Displays PRI Information"),
 	AST_CLI_DEFINE(handle_pri_show_span, "Displays PRI Information"),
 	AST_CLI_DEFINE(handle_pri_show_debug, "Displays current PRI debug settings"),
@@ -12090,6 +12283,7 @@
 #endif
 #ifdef HAVE_PRI
 			if (tmp->pri) {
+ 				ast_cli(a->fd, "Change Status: %d\n", tmp->changestatus);
 				ast_cli(a->fd, "PRI Flags: ");
 				if (tmp->resetting)
 					ast_cli(a->fd, "Resetting ");
@@ -14518,13 +14712,13 @@
 #ifdef HAVE_PRI
 	ast_string_field_init(&inuse, 16);
 	ast_string_field_set(&inuse, name, "GR-303InUse");
-	ast_cli_register_multiple(dahdi_pri_cli, sizeof(dahdi_pri_cli) / sizeof(struct ast_cli_entry));
+	ast_cli_register_multiple(dahdi_pri_cli, ARRAY_LEN(dahdi_pri_cli));
 #endif	
 #ifdef HAVE_SS7
-	ast_cli_register_multiple(dahdi_ss7_cli, sizeof(dahdi_ss7_cli) / sizeof(dahdi_ss7_cli[0]));
+	ast_cli_register_multiple(dahdi_ss7_cli, ARRAY_LEN(dahdi_ss7_cli));
 #endif
 
-	ast_cli_register_multiple(dahdi_cli, sizeof(dahdi_cli) / sizeof(struct ast_cli_entry));
+	ast_cli_register_multiple(dahdi_cli, ARRAY_LEN(dahdi_cli));
 	
 	memset(round_robin, 0, sizeof(round_robin));
 	ast_manager_register( "DAHDITransfer", 0, action_transfer, "Transfer DAHDI Channel" );




More information about the asterisk-commits mailing list