aboutsummaryrefslogtreecommitdiffstats
path: root/main/channel.c
diff options
context:
space:
mode:
authorjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-12 19:08:20 +0000
committerjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-12 19:08:20 +0000
commitf84b02a71d0968338c22758b24cc14e15e3864a4 (patch)
tree464a2032e05934a867493f45e5a2605929fceb8a /main/channel.c
parentac54a25ad7440165f775131b2859ab56aa3c5a92 (diff)
Adds DAHDI support alongside Zaptel. DAHDI usage favored, but all Zap stuff should continue working. Release announcement to follow.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@122314 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/main/channel.c b/main/channel.c
index 4947e7621..49b097f35 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -37,9 +37,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <unistd.h>
#include <math.h>
-#ifdef HAVE_ZAPTEL
+#if defined(HAVE_ZAPTEL) || defined (HAVE_DAHDI)
#include <sys/ioctl.h>
-#include <zaptel/zaptel.h>
+#include "asterisk/dahdi_compat.h"
#endif
#include "asterisk/pbx.h"
@@ -742,13 +742,19 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_
for (x = 0; x < AST_MAX_FDS - 2; x++)
tmp->fds[x] = -1;
+#ifdef HAVE_DAHDI
+
#ifdef HAVE_ZAPTEL
tmp->timingfd = open("/dev/zap/timer", O_RDWR);
+#else
+ tmp->timingfd = open("/dev/dahdi/timer", O_RDWR);
+#endif
+
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
@@ -759,7 +765,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
@@ -937,9 +943,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);
@@ -1805,7 +1811,7 @@ 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;
@@ -1813,7 +1819,7 @@ int ast_settimeout(struct ast_channel *c, int samples, int (*func)(const void *d
}
if (option_debug)
ast_log(LOG_DEBUG, "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;
}
@@ -2020,26 +2026,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;
@@ -2048,7 +2054,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);
}
@@ -2405,7 +2411,7 @@ int ast_indicate_data(struct ast_channel *chan, int condition, const void *data,
if (condition < 0)
ast_playtones_stop(chan);
else {
- const struct tone_zone_sound *ts = NULL;
+ const struct ind_tone_zone_sound *ts = NULL;
switch (condition) {
case AST_CONTROL_RINGING:
ts = ast_get_indication_tone(chan->zone, "ring");
@@ -3024,6 +3030,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;