diff options
author | jpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-12 17:27:55 +0000 |
---|---|---|
committer | jpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-06-12 17:27:55 +0000 |
commit | 490730a6b3bd90a5389cac88847e6977bf234f66 (patch) | |
tree | 4732aea57767a39cd0efe083ba0119911ee976a3 /main | |
parent | b97df61759759251c094187317c450b97088eeaf (diff) |
Goodbye Zaptel, hello DAHDI. Removes Zaptel driver support with DAHDI. Configuration file and dialplan backwards compatability has been put in place where appropiate. Release announcement to follow.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@122234 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/asterisk.c | 31 | ||||
-rw-r--r-- | main/channel.c | 39 | ||||
-rw-r--r-- | main/features.c | 2 | ||||
-rw-r--r-- | main/file.c | 8 | ||||
-rw-r--r-- | main/loader.c | 33 |
5 files changed, 75 insertions, 38 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 14fbbf98e..5651bbd68 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -86,7 +86,7 @@ int daemon(int, int); /* defined in libresolv of all places */ #include <sys/loadavg.h> #endif -#include "asterisk/zapata.h" +#include "asterisk/dahdi.h" #ifdef linux #include <sys/prctl.h> @@ -166,6 +166,7 @@ int option_maxfiles; /*!< Max number of open file handles (files, sockets) */ #if defined(HAVE_SYSINFO) long option_minmemfree; /*!< Minimum amount of free system memory - stop accepting calls if free memory falls below this watermark */ #endif +char dahdi_chan_name[AST_CHANNEL_NAME] = "ZAP"; /*! @} */ @@ -2560,7 +2561,7 @@ static int show_cli_help(void) { printf(" -g Dump core in case of a crash\n"); printf(" -h This help screen\n"); printf(" -i Initialize crypto keys at startup\n"); - printf(" -I Enable internal timing if Zaptel timer is available\n"); + printf(" -I Enable internal timing if DAHDI timer is available\n"); printf(" -L <load> Limit the maximum load average before rejecting new calls\n"); printf(" -M <value> Limit the maximum number of calls to the specified value\n"); printf(" -m Mute debugging and console output on the console\n"); @@ -2781,6 +2782,10 @@ static void ast_readconfig(void) option_minmemfree = 0; } #endif + } else if (!strcasecmp(v->name, "dahdichanname")) { + if (!strcasecmp(v->value, "yes")) { + ast_copy_string(dahdi_chan_name, "DAHDI", sizeof(dahdi_chan_name)); + } } else if (!strcasecmp(v->name, "entityid")) { struct ast_eid tmp_eid; if (!ast_str_to_eid(&tmp_eid, v->value)) { @@ -3294,28 +3299,28 @@ int main(int argc, char *argv[]) printf("%s", term_quit()); exit(1); } -#ifdef HAVE_ZAPTEL +#ifdef HAVE_DAHDI { int fd; int x = 160; - fd = open("/dev/zap/timer", O_RDWR); + fd = open("/dev/dahdi/timer", O_RDWR); if (fd >= 0) { - if (ioctl(fd, ZT_TIMERCONFIG, &x)) { - ast_log(LOG_ERROR, "You have Zaptel built and drivers loaded, but the Zaptel timer test failed to set ZT_TIMERCONFIG to %d.\n", x); + if (ioctl(fd, DAHDI_TIMERCONFIG, &x)) { + ast_log(LOG_ERROR, "You have DAHDI built and drivers loaded, but the DAHDI timer test failed to set DAHDI_TIMERCONFIG to %d.\n", x); exit(1); } if ((x = ast_wait_for_input(fd, 300)) < 0) { - ast_log(LOG_ERROR, "You have Zaptel built and drivers loaded, but the Zaptel timer could not be polled during the Zaptel timer test.\n"); + ast_log(LOG_ERROR, "You have DAHDI built and drivers loaded, but the DAHDI timer could not be polled during the DAHDI timer test.\n"); exit(1); } if (!x) { - const char zaptel_timer_error[] = { - "Asterisk has detected a problem with your Zaptel configuration and will shutdown for your protection. You have options:" - "\n\t1. You only have to compile Zaptel support into Asterisk if you need it. One option is to recompile without Zaptel support." - "\n\t2. You only have to load Zaptel drivers if you want to take advantage of Zaptel services. One option is to unload zaptel modules if you don't need them." - "\n\t3. If you need Zaptel services, you must correctly configure Zaptel." + const char dahdi_timer_error[] = { + "Asterisk has detected a problem with your DAHDI configuration and will shutdown for your protection. You have options:" + "\n\t1. You only have to compile DAHDI support into Asterisk if you need it. One option is to recompile without DAHDI support." + "\n\t2. You only have to load DAHDI drivers if you want to take advantage of DAHDI services. One option is to unload DAHDI modules if you don't need them." + "\n\t3. If you need DAHDI services, you must correctly configure DAHDI." }; - ast_log(LOG_ERROR, "%s\n", zaptel_timer_error); + ast_log(LOG_ERROR, "%s\n", dahdi_timer_error); usleep(100); exit(1); } diff --git a/main/channel.c b/main/channel.c index 287fcdda8..4f97c1008 100644 --- a/main/channel.c +++ b/main/channel.c @@ -34,7 +34,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include <math.h> #include "asterisk/paths.h" /* use ast_config_AST_SYSTEM_NAME */ -#include "asterisk/zapata.h" +#include "asterisk/dahdi.h" #include "asterisk/pbx.h" #include "asterisk/frame.h" @@ -808,13 +808,13 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_ #endif } -#ifdef HAVE_ZAPTEL - tmp->timingfd = open("/dev/zap/timer", O_RDWR); +#ifdef HAVE_DAHDI + tmp->timingfd = open("/dev/dahdi/timer", O_RDWR); if (tmp->timingfd > -1) { /* Check if timing interface supports new ping/pong scheme */ flags = 1; - if (!ioctl(tmp->timingfd, ZT_TIMERPONG, &flags)) + if (!ioctl(tmp->timingfd, DAHDI_TIMERPONG, &flags)) needqueue = 0; } #else @@ -825,7 +825,7 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_ if (pipe(tmp->alertpipe)) { ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe!\n"); alertpipe_failed: -#ifdef HAVE_ZAPTEL +#ifdef HAVE_DAHDI if (tmp->timingfd > -1) close(tmp->timingfd); #endif @@ -1007,9 +1007,9 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin) if (write(chan->alertpipe[1], &blah, sizeof(blah)) != sizeof(blah)) ast_log(LOG_WARNING, "Unable to write to alert pipe on %s, frametype/subclass %d/%d (qlen = %d): %s!\n", chan->name, f->frametype, f->subclass, qlen, strerror(errno)); -#ifdef HAVE_ZAPTEL +#ifdef HAVE_DAHDI } else if (chan->timingfd > -1) { - ioctl(chan->timingfd, ZT_TIMERPING, &blah); + ioctl(chan->timingfd, DAHDI_TIMERPING, &blah); #endif } else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) { pthread_kill(chan->blocker, SIGURG); @@ -2184,14 +2184,14 @@ int ast_waitfordigit(struct ast_channel *c, int ms) int ast_settimeout(struct ast_channel *c, int samples, int (*func)(const void *data), void *data) { int res = -1; -#ifdef HAVE_ZAPTEL +#ifdef HAVE_DAHDI if (c->timingfd > -1) { if (!func) { samples = 0; data = 0; } ast_debug(1, "Scheduling timer at %d sample intervals\n", samples); - res = ioctl(c->timingfd, ZT_TIMERCONFIG, &samples); + res = ioctl(c->timingfd, DAHDI_TIMERCONFIG, &samples); c->timingfunc = func; c->timingdata = data; } @@ -2411,26 +2411,26 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) read(chan->alertpipe[0], &blah, sizeof(blah)); } -#ifdef HAVE_ZAPTEL +#ifdef HAVE_DAHDI if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD && ast_test_flag(chan, AST_FLAG_EXCEPTION)) { int res; ast_clear_flag(chan, AST_FLAG_EXCEPTION); blah = -1; /* IF we can't get event, assume it's an expired as-per the old interface */ - res = ioctl(chan->timingfd, ZT_GETEVENT, &blah); + res = ioctl(chan->timingfd, DAHDI_GETEVENT, &blah); if (res) - blah = ZT_EVENT_TIMER_EXPIRED; + blah = DAHDI_EVENT_TIMER_EXPIRED; - if (blah == ZT_EVENT_TIMER_PING) { + if (blah == DAHDI_EVENT_TIMER_PING) { if (AST_LIST_EMPTY(&chan->readq) || !AST_LIST_NEXT(AST_LIST_FIRST(&chan->readq), frame_list)) { /* Acknowledge PONG unless we need it again */ - if (ioctl(chan->timingfd, ZT_TIMERPONG, &blah)) { + if (ioctl(chan->timingfd, DAHDI_TIMERPONG, &blah)) { ast_log(LOG_WARNING, "Failed to pong timer on '%s': %s\n", chan->name, strerror(errno)); } } - } else if (blah == ZT_EVENT_TIMER_EXPIRED) { - ioctl(chan->timingfd, ZT_TIMERACK, &blah); + } else if (blah == DAHDI_EVENT_TIMER_EXPIRED) { + ioctl(chan->timingfd, DAHDI_TIMERACK, &blah); if (chan->timingfunc) { /* save a copy of func/data before unlocking the channel */ int (*func)(const void *) = chan->timingfunc; @@ -2439,7 +2439,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) func(data); } else { blah = 0; - ioctl(chan->timingfd, ZT_TIMERCONFIG, &blah); + ioctl(chan->timingfd, DAHDI_TIMERCONFIG, &blah); chan->timingdata = NULL; ast_channel_unlock(chan); } @@ -3433,6 +3433,11 @@ struct ast_channel *ast_request(const char *type, int format, void *data, int *c return NULL; } + if (!strcasecmp(type, "Zap")) { + type = "DAHDI"; + ast_log(LOG_NOTICE, "Zap interface translated to DAHDI.\n"); + } + AST_LIST_TRAVERSE(&backends, chan, list) { if (strcasecmp(type, chan->tech->type)) continue; diff --git a/main/features.c b/main/features.c index 3c66769e6..1855ca47b 100644 --- a/main/features.c +++ b/main/features.c @@ -2390,7 +2390,7 @@ int manage_parkinglot(struct ast_parkinglot *curlot, fd_set *rfds, fd_set *efds, if (pu->peername[0]) { char *peername = ast_strdupa(pu->peername); char *cp = strrchr(peername, '-'); - char peername_flat[AST_MAX_EXTENSION]; /* using something like Zap/52 for an extension name is NOT a good idea */ + char peername_flat[AST_MAX_EXTENSION]; /* using something like DAHDI/52 for an extension name is NOT a good idea */ int i; if (cp) diff --git a/main/file.c b/main/file.c index 86efb6000..15b6a5d88 100644 --- a/main/file.c +++ b/main/file.c @@ -659,11 +659,11 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s) } } if (whennext != s->lasttimeout) { -#ifdef HAVE_ZAPTEL +#ifdef HAVE_DAHDI if (s->owner->timingfd > -1) { int zap_timer_samples = whennext; int rate; - /* whennext is in samples, but zaptel timers operate in 8 kHz samples. */ + /* whennext is in samples, but DAHDI timers operate in 8 kHz samples. */ if ((rate = ast_format_rate(s->fmt->format)) != 8000) { float factor; factor = ((float) rate) / ((float) 8000.0); @@ -681,7 +681,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s) return_failure: s->owner->streamid = -1; -#ifdef HAVE_ZAPTEL +#ifdef HAVE_DAHDI ast_settimeout(s->owner, 0, NULL, NULL); #endif return FSREAD_FAILURE; @@ -792,7 +792,7 @@ int ast_closestream(struct ast_filestream *f) if (f->fmt->format & AST_FORMAT_AUDIO_MASK) { f->owner->stream = NULL; AST_SCHED_DEL(f->owner->sched, f->owner->streamid); -#ifdef HAVE_ZAPTEL +#ifdef HAVE_DAHDI ast_settimeout(f->owner, 0, NULL, NULL); #endif } else { diff --git a/main/loader.c b/main/loader.c index b5a451617..990d2fb85 100644 --- a/main/loader.c +++ b/main/loader.c @@ -758,6 +758,23 @@ static struct load_order_entry *add_to_load_order(const char *resource, struct l return order; } + +static int translate_module_name(const char *oldname, char *newname) +{ + if (!strcasecmp(oldname, "app_zapbarge.so")) + ast_copy_string(newname, "app_dahdibarge.so", 18); + else if(!strcasecmp(oldname, "app_zapras.so")) + ast_copy_string(newname, "app_dahdiras.so", 16); + else if(!strcasecmp(oldname, "app_zapscan.so")) + ast_copy_string(newname, "app_dahdiscan.so", 17); + else if(!strcasecmp(oldname, "codec_zap.so")) + ast_copy_string(newname, "codec_dahdi.so", 16); + else + return -1; /* no use for newname, oldname is fine */ + + return 0; +} + int load_modules(unsigned int preload_only) { struct ast_config *cfg; @@ -769,6 +786,9 @@ int load_modules(unsigned int preload_only) int res = 0; struct ast_flags config_flags = { 0 }; int modulecount = 0; + + int translate_status; + char newname[18]; /* although this would normally be 80, max length in translate_module_name is 18 */ #ifdef LOADABLE_MODULES struct dirent *dirent; DIR *dir; @@ -796,8 +816,12 @@ int load_modules(unsigned int preload_only) /* first, find all the modules we have been explicitly requested to load */ for (v = ast_variable_browse(cfg, "modules"); v; v = v->next) { - if (!strcasecmp(v->name, preload_only ? "preload" : "load")) - add_to_load_order(v->value, &load_order); + if (!strcasecmp(v->name, preload_only ? "preload" : "load")) { + translate_status = translate_module_name(v->value, newname); + if (!translate_status) + ast_log(LOG_WARNING, "Use of old module name %s is deprecated, please use %s instead.\n", v->value, newname); + add_to_load_order(translate_status ? v->value : newname, &load_order); + } } /* check if 'autoload' is on */ @@ -853,7 +877,10 @@ int load_modules(unsigned int preload_only) continue; AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) { - if (!resource_name_match(order->resource, v->value)) { + translate_status = translate_module_name(v->value, newname); + if (!resource_name_match(order->resource, translate_status ? v->value : newname)) { + if (!translate_status) + ast_log(LOG_WARNING, "Use of old module name %s is deprecated, please use %s instead.\n", v->value, newname); AST_LIST_REMOVE_CURRENT(entry); ast_free(order->resource); ast_free(order); |