[asterisk-commits] dhubbard: branch group/issue3450 r115075 - /team/group/issue3450/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 1 17:28:25 CDT 2008
Author: dhubbard
Date: Thu May 1 17:28:25 2008
New Revision: 115075
URL: http://svn.digium.com/view/asterisk?view=rev&rev=115075
Log:
merge lastest Asterisk patch from mantis issue 3450
Modified:
team/group/issue3450/channels/chan_zap.c
Modified: team/group/issue3450/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/group/issue3450/channels/chan_zap.c?view=diff&rev=115075&r1=115074&r2=115075
==============================================================================
--- team/group/issue3450/channels/chan_zap.c (original)
+++ team/group/issue3450/channels/chan_zap.c Thu May 1 17:28:25 2008
@@ -585,6 +585,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 */
@@ -8654,7 +8655,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
@@ -9788,6 +9793,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:
@@ -11477,6 +11508,164 @@
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 zt_pvt *tmp = NULL;
+ int x;
+ int y;
+ ast_mutex_t *lock;
+ struct zt_pvt *start;
+ char *c;
+ int trunkgroup;
+ struct zt_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(%d)\n", PRI_SPAN(PVT_TO_CHANNEL(tmp)));
+ //pri_maintenance_service(tmp->pri->pri, PRI_SPAN(PVT_TO_CHANNEL(tmp)), PVT_TO_CHANNEL(tmp), changestatus);
+ pri_maintenance_service(tmp->pri->pri, 2, 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)
@@ -11700,6 +11889,11 @@
AST_CLI_DEFINE(handle_pri_show_debug, "Displays current PRI debug settings"),
AST_CLI_DEFINE(handle_pri_set_debug_file, "Sends PRI debug output to the specified file"),
AST_CLI_DEFINE(handle_pri_unset_debug_file, "Ends PRI debug output to file"),
+ 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"),
};
#endif /* HAVE_PRI */
@@ -12042,6 +12236,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 ");
@@ -14318,13 +14513,15 @@
#ifdef HAVE_PRI
ast_string_field_init(&inuse, 16);
ast_string_field_set(&inuse, name, "GR-303InUse");
- ast_cli_register_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(struct ast_cli_entry));
+ //ast_cli_register_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(struct ast_cli_entry));
+ ast_cli_register_multiple(zap_pri_cli, ARRAY_LEN(zap_pri_cli));
#endif
#ifdef HAVE_SS7
- ast_cli_register_multiple(zap_ss7_cli, sizeof(zap_ss7_cli) / sizeof(zap_ss7_cli[0]));
-#endif
-
- ast_cli_register_multiple(zap_cli, sizeof(zap_cli) / sizeof(struct ast_cli_entry));
+ //ast_cli_register_multiple(zap_ss7_cli, sizeof(zap_ss7_cli) / sizeof(zap_ss7_cli[0]));
+ ast_cli_register_multiple(zap_ss7_cli, ARRAY_LEN(zap_ss7_cli));
+#endif
+
+ ast_cli_register_multiple(zap_cli, ARRAY_LEN(zap_cli));
memset(round_robin, 0, sizeof(round_robin));
ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );
More information about the asterisk-commits
mailing list