Index: chan_zap.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_zap.c,v retrieving revision 1.406 diff -u -r1.406 chan_zap.c --- chan_zap.c 4 Feb 2005 06:12:32 -0000 1.406 +++ chan_zap.c 4 Feb 2005 19:32:00 -0000 @@ -595,6 +595,7 @@ int proceeding; int setup_ack; /* whether we received SETUP_ACKNOWLEDGE or not */ int dsp_features; + int changestatus; /* for special maintenance service */ #endif #ifdef ZAPATA_R2 int r2prot; @@ -6768,7 +6769,9 @@ /* If guard time, definitely not */ if (p->guardtime && (time(NULL) < p->guardtime)) return 0; - + /* If channel is not in service, definitely not */ + if (p->changestatus > 0) + return 0; /* If no owner definitely available */ if (!p->owner) { /* Trust PRI */ @@ -8334,6 +8337,32 @@ ast_mutex_unlock(&pri->pvts[chanpos]->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.changestatus, PRI_SPAN(e->service.channel), PRI_CHANNEL(e->service.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: ast_log(LOG_DEBUG, "Event: %d\n", e->e); } @@ -8857,6 +8886,7 @@ ast_cli(fd, "Confno: %d\n", tmp->confno); ast_cli(fd, "Propagated Conference: %d\n", tmp->propconfno); ast_cli(fd, "Real in conference: %d\n", tmp->inconference); + ast_cli(fd, "Do Not Disturb: %s\n", tmp->dnd ? "yes" : "no"); ast_cli(fd, "DSP: %s\n", tmp->dsp ? "yes" : "no"); ast_cli(fd, "Relax DTMF: %s\n", tmp->dtmfrelax ? "yes" : "no"); ast_cli(fd, "Dialing/CallwaitCAS: %d/%d\n", tmp->dialing, tmp->callwaitcas); @@ -8872,6 +8902,7 @@ } #ifdef ZAPATA_PRI if (tmp->pri) { + ast_cli(fd, "Change Status: %d\n", tmp->changestatus); ast_cli(fd, "PRI Flags: "); if (tmp->resetting) ast_cli(fd, "Resetting "); @@ -8925,6 +8956,87 @@ return RESULT_FAILURE; } +#ifdef ZAPATA_PRI +static int zap_service_generic(int fd, int argc, char **argv, int changestatus) +{ + int channel; + struct zt_pvt *tmp = NULL; + int x; + ast_mutex_t *lock; + struct zt_pvt *start; + char *c; + int trunkgroup; + struct zt_pri *pri=NULL; + + lock = &iflock; + start = iflist; + + if (argc != 5) + return RESULT_SHOWUSAGE; + if ((c = strchr(argv[4], ':'))) { + if (sscanf(argv[4], "%d:%d", &trunkgroup, &channel) != 2) + return RESULT_SHOWUSAGE; + if ((trunkgroup < 1) || (channel < 1)) + return RESULT_SHOWUSAGE; + for (x=0;xcrvs; + lock = &pri->lock; + } else { + ast_cli(fd, "No such trunk group %d\n", trunkgroup); + return RESULT_FAILURE; + } + } else + channel = atoi(argv[4]); + + ast_mutex_lock(lock); + tmp = start; + while (tmp) { + if (tmp->channel == channel) { + pri_maintenance_service(tmp->pri->pri, PVT_TO_CHANNEL(tmp), changestatus); + ast_mutex_unlock(lock); + return RESULT_SUCCESS; + } + tmp = tmp->next; + } + ast_cli(fd, "Unable to find given channel %d\n", channel); + ast_mutex_unlock(lock); + return RESULT_FAILURE; +} + +static int zap_service_enable_channel(int fd, int argc, char **argv) +{ + return zap_service_generic(fd, argc, argv, 0); +} + +static int zap_service_loop_channel(int fd, int argc, char **argv) +{ + return zap_service_generic(fd, argc, argv, 1); +} + +static int zap_service_disable_channel(int fd, int argc, char **argv) +{ + return zap_service_generic(fd, argc, argv, 2); +} + +/* +static int zap_service_continuity_channel(int fd, int argc, char **argv) +{ + return zap_service_generic(fd, argc, argv, 3); +} + +static int zap_service_shutdown_channel(int fd, int argc, char **argv) +{ + return zap_service_generic(fd, argc, argv, 4); +} +*/ +#endif + static char zap_show_cadences_help[] = "Usage: zap show cadences\n" " Shows all cadences currently defined\n"; @@ -8972,6 +9084,20 @@ "Usage: zap destroy channel \n" " DON'T USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING. Immediately removes a given channel, whether it is in use or not\n"; +#ifdef ZAPATA_PRI +static char service_enable_channel_usage[] = + "Usage: zap service enable channel \n" + " Send an NFAS/CCS ANSI T1.607 maintenance message to restore a channel to service\n"; + +static char service_disable_channel_usage[] = + "Usage: zap service disable channel \n" + " Send an NFAS/CCS ANSI T1.607 maintenance message to remove a channel from service\n"; + +static char service_loop_channel_usage[] = + "Usage: zap service loop channel \n" + " Send an NFAS/CCS ANSI T1.607 maintenance message to put a channel into a maintenance loop\n"; +#endif + static struct ast_cli_entry cli_show_channels = { {"zap", "show", "channels", NULL}, zap_show_channels, "Show active zapata channels", show_channels_usage, NULL }; @@ -8981,6 +9107,17 @@ static struct ast_cli_entry cli_destroy_channel = { {"zap", "destroy", "channel", NULL}, zap_destroy_channel, "Destroy a channel", destroy_channel_usage, NULL }; +#ifdef ZAPATA_PRI +static struct ast_cli_entry cli_service_enable_channel = { + {"zap", "service", "enable", "channel", NULL}, zap_service_enable_channel, "Return a channel to service", service_enable_channel_usage, NULL }; + +static struct ast_cli_entry cli_service_disable_channel = { + {"zap", "service", "disable", "channel", NULL}, zap_service_disable_channel, "Remove a channel from service", service_disable_channel_usage, NULL }; + +static struct ast_cli_entry cli_service_loop_channel = { + {"zap", "service", "loop", "channel", NULL}, zap_service_loop_channel, "Put a channel into maintenance loop", service_loop_channel_usage, NULL }; +#endif + static char *synopsis_callingpres = "Change the presentation for the callerid"; static char *descrip_callingpres = "Callingpres(number): Changes the presentation for the callerid. Should be called before placing an outgoing call\n"; static char *app_callingpres = "CallingPres"; @@ -9188,6 +9325,10 @@ ast_cli_unregister(&pri_no_debug); ast_cli_unregister(&pri_really_debug); ast_cli_unregister(&pri_show_span); + ast_cli_unregister(&cli_destroy_channel); + ast_cli_unregister(&cli_service_enable_channel); + ast_cli_unregister(&cli_service_disable_channel); + ast_cli_unregister(&cli_service_loop_channel); #endif #ifdef ZAPATA_R2 ast_cli_unregister(&r2_debug); @@ -9195,7 +9336,6 @@ #endif ast_cli_unregister(&cli_show_channels); ast_cli_unregister(&cli_show_channel); - ast_cli_unregister(&cli_destroy_channel); ast_cli_unregister(&zap_show_cadences_cli); ast_manager_unregister( "ZapDialOffhook" ); ast_manager_unregister( "ZapHangup" ); @@ -10051,6 +10191,9 @@ ast_cli_register(&pri_no_debug); ast_cli_register(&pri_really_debug); ast_cli_register(&pri_show_span); + ast_cli_register(&cli_service_enable_channel); + ast_cli_register(&cli_service_disable_channel); + ast_cli_register(&cli_service_loop_channel); #endif #ifdef ZAPATA_R2 ast_cli_register(&r2_debug);