Index: channels/chan_zap.c =================================================================== RCS file: /asterisk/asterisk/channels/chan_zap.c,v retrieving revision 1.356 diff -u -r1.356 chan_zap.c --- channels/chan_zap.c 6 Oct 2004 23:45:26 -0000 1.356 +++ channels/chan_zap.c 13 Oct 2004 15:36:40 -0000 @@ -279,6 +279,9 @@ static int zt_sendtext(struct ast_channel *c, char *text); +/* Prototype our reload function to make the cli stuff happy */ +static int zap_reload(int fd, int argc, char **argv); + static inline int zt_get_event(int fd) { /* Avoid the silly zt_getevent which ignores a bunch of events */ @@ -8673,6 +8676,10 @@ static char show_channel_usage[] = "Usage: zap show channel \n" " Detailed information about a given channel\n"; +static char reload_usage[] = + "Usage: zap reload\n" + " Reloads information in zapata.conf and sets active\n" + " *** DOES NOT CHANGE SIGNALLING OR OTHER DRIVER RELATED SETTINGS ***\n"; static char destroy_channel_usage[] = "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"; @@ -8683,6 +8690,9 @@ static struct ast_cli_entry cli_show_channel = { {"zap", "show", "channel", NULL}, zap_show_channel, "Show information on a channel", show_channel_usage, NULL }; +static struct ast_cli_entry cli_reload = { + {"zap", "reload", NULL}, zap_reload, "Reload information from zapata.conf", reload_usage, NULL}; + static struct ast_cli_entry cli_destroy_channel = { {"zap", "destroy", "channel", NULL}, zap_destroy_channel, "Destroy a channel", destroy_channel_usage, NULL }; @@ -8901,6 +8911,7 @@ ast_cli_unregister(&cli_show_channels); ast_cli_unregister(&cli_show_channel); ast_cli_unregister(&cli_destroy_channel); + ast_cli_unregister(&cli_reload); ast_cli_unregister(&zap_show_cadences_cli); ast_manager_unregister( "ZapDialOffhook" ); ast_manager_unregister( "ZapHangup" ); @@ -9724,6 +9735,7 @@ #endif ast_cli_register(&cli_show_channels); ast_cli_register(&cli_show_channel); + ast_cli_register(&cli_reload); ast_cli_register(&cli_destroy_channel); ast_cli_register(&zap_show_cadences_cli); @@ -9739,7 +9751,7 @@ return res; } -#if 0 + static int reload_zt(void) { @@ -9751,6 +9763,8 @@ char *ringc; int start, finish,x; char *stringp=NULL; + int cur_radio; + int a; /* Some crap that needs to be reinitialized on the reload */ strncpy(context, "default", sizeof(context) - 1); @@ -9760,6 +9774,7 @@ cid_signalling = CID_SIG_BELL; cid_start = CID_START_RING; cur_signalling = -1; + cur_radio = 0; cur_group = 0; cur_callergroup = 0; cur_pickupgroup = 0; @@ -9781,7 +9796,6 @@ gendigittimeout = 8000; amaflags = 0; adsi = 0; - memset(drings,0,sizeof(drings)); strncpy(accountcode, "", sizeof(accountcode)-1); #ifdef ZAPATA_PRI strncpy(idleext, "", sizeof(idleext) - 1); @@ -9790,7 +9804,7 @@ minidle = 0; #endif // usecnt = 0; - + #if 0 #ifdef ZAPATA_PRI int y; @@ -9838,12 +9852,14 @@ while(v) { /* Create the interface list */ if (!strcasecmp(v->name, "channel")) { +#ifdef RELOAD_SIG if (cur_signalling < 0) { ast_log(LOG_ERROR, "Signalling must be specified before any channels are.\n"); ast_destroy(cfg); ast_mutex_unlock(&iflock); return -1; } +#endif stringp=v->value; chan = strsep(&stringp, ","); while(chan) { @@ -9865,12 +9881,24 @@ start = x; } for (x = start; x <= finish; x++) { - tmp = mkintf(x, cur_signalling); +#ifndef RELOAD_SIG + tmp = iflist; + while (tmp) { + if (tmp->channel == x) { + cur_signalling = tmp->sig; + cur_radio = tmp->radio; + break; + } else + tmp = tmp->next; + } +#endif + tmp = mkintf(x, cur_signalling , cur_radio, NULL); + if (tmp) { if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Registered channel %d, %s signalling\n", x, sig2str(tmp->sig)); + ast_verbose(VERBOSE_PREFIX_3 "Reconfigured channel %d.\n", x); } else { - ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value); + ast_log(LOG_ERROR, "Unable to reconfigure channel '%s'\n", v->value); ast_destroy(cfg); ast_mutex_unlock(&iflock); return -1; @@ -9916,6 +9944,17 @@ cid_start = CID_START_RING; } else if (!strcasecmp(v->name, "threewaycalling")) { threewaycalling = ast_true(v->value); + } else if (!strcasecmp(v->name, "cancallforward")) { + cancallforward = ast_true(v->value); + } else if (!strcasecmp(v->name, "relaxdtmf")) { + if (ast_true(v->value)) + relaxdtmf = DSP_DIGITMODE_RELAXDTMF; + else + relaxdtmf = 0; + } else if (!strcasecmp(v->name, "adsi")) { + adsi = ast_true(v->value); + } else if (!strcasecmp(v->name, "echocancelwhenbridged")) { + echocanbridged = ast_true(v->value); } else if (!strcasecmp(v->name, "transfer")) { transfer = ast_true(v->value); } else if (!strcasecmp(v->name, "busydetect")) { @@ -9923,9 +9962,48 @@ } else if (!strcasecmp(v->name, "busycount")) { busycount = atoi(v->value); } else if (!strcasecmp(v->name, "callprogress")) { - callprogress = ast_true(v->value); + if (ast_true(v->value)) + callprogress |= 1; + else + callprogress &= ~1; + } else if (!strcasecmp(v->name, "faxdetect")) { + if (!strcasecmp(v->value, "incoming")) { + callprogress |= 4; + callprogress &= ~2; + } else if (!strcasecmp(v->value, "outgoing")) { + callprogress &= ~4; + callprogress |= 2; + } else if (!strcasecmp(v->value, "both") || ast_true(v->value)) + callprogress |= 6; + else + callprogress &= ~6; + } else if (!strcasecmp(v->name, "echocancel")) { + if (v->value && !ast_strlen_zero(v->value)) { + a = atoi(v->value); + } else + a = 0; + if ((a == 32) || (a == 64) || (a == 128) || (a == 256)) + echocancel = a; + else { + echocancel = ast_true(v->value); + if (echocancel) + echocancel=128; + } + } else if (!strcasecmp(v->name, "echotraining")) { + if (sscanf(v->value, "%i", &a) == 1) { + if ((a < 10) || (a > 4000)) { + ast_log(LOG_WARNING, "Echo training time must be within the range of 10 to 2000 ms at line %d\n", v->lineno); + } else { + echotraining = a; + } + } else if (ast_true(v->value)) { + echotraining = 400; + } else + echotraining = 0; } else if (!strcasecmp(v->name, "hidecallerid")) { hidecallerid = ast_true(v->value); + } else if (!strcasecmp(v->name, "pulsedial")) { + pulse = ast_true(v->value); } else if (!strcasecmp(v->name, "callreturn")) { callreturn = ast_true(v->value); } else if (!strcasecmp(v->name, "callwaiting")) { @@ -9943,11 +10021,11 @@ } else if (!strcasecmp(v->name, "stripmsd")) { stripmsd = atoi(v->value); } else if (!strcasecmp(v->name, "group")) { - cur_group = get_group(v->value); + cur_group = ast_get_group(v->value); } else if (!strcasecmp(v->name, "callgroup")) { - cur_callergroup = get_group(v->value); + cur_callergroup = ast_get_group(v->value); } else if (!strcasecmp(v->name, "pickupgroup")) { - cur_pickupgroup = get_group(v->value); + cur_pickupgroup = ast_get_group(v->value); } else if (!strcasecmp(v->name, "immediate")) { immediate = ast_true(v->value); } else if (!strcasecmp(v->name, "mailbox")) { @@ -9965,10 +10043,27 @@ ast_log(LOG_WARNING, "Invalid tonezone: %s\n", v->value); } } else if (!strcasecmp(v->name, "callerid")) { - if (!strcasecmp(v->value, "asreceived")) - callerid[0] = '\0'; + if (!strcasecmp(v->value, "asreceived")) { + cid_num[0] = '\0'; + cid_name[0] = '\0'; + } else { + ast_callerid_split(v->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num)); + } + } else if (!strcasecmp(v->name, "useincomingcalleridonzaptransfer")) { + zaptrcallerid = ast_true(v->value); + } else if (!strcasecmp(v->name, "restrictcid")) { + restrictcid = ast_true(v->value); + } else if (!strcasecmp(v->name, "usecallingpres")) { + use_callingpres = ast_true(v->value); + } else if (!strcasecmp(v->name, "accountcode")) { + strncpy(accountcode, v->value, sizeof(accountcode)-1); + } else if (!strcasecmp(v->name, "amaflags")) { + a = ast_cdr_amaflags2int(v->value); + if (a < 0) + ast_log(LOG_WARNING, "Invalid AMA flags: %s at line %d\n", v->value, v->lineno); else - strncpy(callerid, v->value, sizeof(callerid)-1); + amaflags = a; +#ifdef RELOAD_SIG } else if (!strcasecmp(v->name, "signalling")) { if (!strcasecmp(v->value, "em")) { cur_signalling = SIG_EM; @@ -10005,6 +10100,7 @@ } else { ast_log(LOG_ERROR, "Unknown signalling method '%s'\n", v->value); } + #ifdef ZAPATA_PRI } else if (!strcasecmp(v->name, "switchtype")) { if (!strcasecmp(v->value, "national")) @@ -10043,7 +10139,8 @@ } else if (!strcasecmp(v->name, "idledial")) { strncpy(idledial, v->value, sizeof(idledial) - 1); #endif - } else +#endif + } else if (option_verbose > 5) ast_log(LOG_WARNING, "Ignoring %s\n", v->name); v = v->next; } @@ -10073,7 +10170,7 @@ restart_monitor(); return 0; } -#endif + static int zt_sendtext(struct ast_channel *c, char *text) { @@ -10174,18 +10271,26 @@ return(0); } -#if 0 + /* XXX Very broken on PRI XXX */ -int reload(void) +static int zap_reload(int fd, int argc, char **argv) { - if (reload_zt()) { - ast_log(LOG_WARNING, "Reload of chan_zap is unsuccessful\n"); + int res = 0; + + res = usecount(); + if (res) { + ast_log(LOG_ERROR, "Cannot reload chan_zap, as there are channels in use."); return -1; + } else { + res = reload_zt(); + if (res) { + ast_log(LOG_WARNING, "Reload of chan_zap is unsuccessful!\n"); + return -1; + } } - return 0; } -#endif + int usecount() { int res;