[asterisk-commits] kpfleming: branch 1.4 r130298 - in /branches/1.4: ./ apps/ cdr/ channels/ con...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 11 17:12:27 CDT 2008


Author: kpfleming
Date: Fri Jul 11 17:12:26 2008
New Revision: 130298

URL: http://svn.digium.com/view/asterisk?view=rev&rev=130298
Log:
a whole pile of Zaptel/DAHDI compatibility work, with lots more to come... this tree is not yet ready for users to be easily upgrading or switching, but it needs to be :-)

Modified:
    branches/1.4/Makefile
    branches/1.4/apps/app_dahdibarge.c
    branches/1.4/apps/app_dahdiras.c
    branches/1.4/apps/app_flash.c
    branches/1.4/cdr/cdr_csv.c
    branches/1.4/channels/chan_dahdi.c
    branches/1.4/channels/chan_iax2.c
    branches/1.4/contrib/utils/zones2indications.c
    branches/1.4/doc/hardware.txt
    branches/1.4/include/asterisk/channel.h
    branches/1.4/include/asterisk/options.h
    branches/1.4/main/asterisk.c
    branches/1.4/main/channel.c
    branches/1.4/main/file.c

Modified: branches/1.4/Makefile
URL: http://svn.digium.com/view/asterisk/branches/1.4/Makefile?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/Makefile (original)
+++ branches/1.4/Makefile Fri Jul 11 17:12:26 2008
@@ -607,6 +607,7 @@
 		echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
 		echo ";runuser = asterisk ; The user to run as" ; \
 		echo ";rungroup = asterisk ; The group to run as" ; \
+		echo ";dahdichanname = yes ; Channels created by chan_dahdi will be called 'DAHDI', otherwise 'Zap'" ; \
 		echo "" ; \
 		echo "; Changing the following lines may compromise your security." ; \
 		echo ";[files]" ; \

Modified: branches/1.4/apps/app_dahdibarge.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_dahdibarge.c?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/apps/app_dahdibarge.c (original)
+++ branches/1.4/apps/app_dahdibarge.c Fri Jul 11 17:12:26 2008
@@ -61,17 +61,23 @@
 
 #include "asterisk/dahdi_compat.h"
 
-static char *app = "DAHDIBarge";
-static char *deprecated_app = "ZapBarge";
-
-static char *synopsis = "Barge in (monitor) Zap channel";
-
-static char *descrip = 
-"  ZapBarge([channel]): Barges in on a specified zap\n"
+static char *dahdi_app = "DAHDIBarge";
+static char *zap_app = "ZapBarge";
+
+static char *dahdi_synopsis = "Barge in (monitor) DAHDI channel";
+static char *zap_synopsis = "Barge in (monitor) Zap channel";
+
+static char *dahdi_descrip = 
+"  DAHDIBarge([channel]): Barges in on a specified DAHDI\n"
 "channel or prompts if one is not specified.  Returns\n"
 "-1 when caller user hangs up and is independent of the\n"
 "state of the channel being monitored.";
 
+static char *zap_descrip = 
+"  ZapBarge([channel]): Barges in on a specified Zaptel\n"
+"channel or prompts if one is not specified.  Returns\n"
+"-1 when caller user hangs up and is independent of the\n"
+"state of the channel being monitored.";
 
 #define CONF_SIZE 160
 
@@ -125,11 +131,15 @@
 		goto outrun;
 	}
 	ast_indicate(chan, -1);
-	retryzap = strcasecmp(chan->tech->type, "Zap");
+	retryzap = strcasecmp(chan->tech->type, dahdi_chan_name);
 zapretry:
 	origfd = chan->fds[0];
 	if (retryzap) {
+#ifdef HAVE_ZAPTEL
 		fd = open("/dev/zap/pseudo", O_RDWR);
+#else
+		fd = open("/dev/dahdi/pseudo", O_RDWR);
+#endif
 		if (fd < 0) {
 			ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
 			goto outrun;
@@ -174,7 +184,7 @@
 	if (ztc.confmode) {
 		/* Whoa, already in a conference...  Retry... */
 		if (!retryzap) {
-			ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+			ast_log(LOG_DEBUG, "Channel is in a conference already, retrying with pseudo\n");
 			retryzap = 1;
 			goto zapretry;
 		}
@@ -190,7 +200,7 @@
 		close(fd);
 		goto outrun;
 	}
-	ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+	ast_log(LOG_DEBUG, "Placed channel %s in channel %d monitor\n", chan->name, confno);
 
 	for(;;) {
 		outfd = -1;
@@ -259,7 +269,7 @@
 	return ret;
 }
 
-static int conf_exec(struct ast_channel *chan, void *data)
+static int exec(struct ast_channel *chan, void *data, int dahdimode)
 {
 	int res=-1;
 	struct ast_module_user *u;
@@ -271,11 +281,20 @@
 	u = ast_module_user_add(chan);
 	
 	if (!ast_strlen_zero(data)) {
-		if ((sscanf(data, "Zap/%d", &confno) != 1) &&
-		    (sscanf(data, "%d", &confno) != 1)) {
-			ast_log(LOG_WARNING, "ZapBarge Argument (if specified) must be a channel number, not '%s'\n", (char *)data);
-			ast_module_user_remove(u);
-			return 0;
+		if (dahdimode) {
+			if ((sscanf(data, "DAHDI/%d", &confno) != 1) &&
+			    (sscanf(data, "%d", &confno) != 1)) {
+				ast_log(LOG_WARNING, "Argument (if specified) must be a channel number, not '%s'\n", (char *) data);
+				ast_module_user_remove(u);
+				return 0;
+			}
+		} else {
+			if ((sscanf(data, "Zap/%d", &confno) != 1) &&
+			    (sscanf(data, "%d", &confno) != 1)) {
+				ast_log(LOG_WARNING, "Argument (if specified) must be a channel number, not '%s'\n", (char *) data);
+				ast_module_user_remove(u);
+				return 0;
+			}
 		}
 	}
 	
@@ -301,28 +320,44 @@
 	return res;
 }
 
-static int conf_exec_warn(struct ast_channel *chan, void *data)
-{
-    ast_log(LOG_WARNING, "Use of the command %s is deprecated, please use %s instead.\n", deprecated_app, app);
-    return conf_exec(chan, data);
-}
-
-
-static int unload_module(void)
-{
-	int res;
+static int exec_zap(struct ast_channel *chan, void *data)
+{
+	ast_log(LOG_WARNING, "Use of the command %s is deprecated, please use %s instead.\n", zap_app, dahdi_app);
 	
-	res = ast_unregister_application(app);
+	return exec(chan, data, 0);
+}
+
+static int exec_dahdi(struct ast_channel *chan, void *data)
+{
+	return exec(chan, data, 1);
+}
+
+static int unload_module(void) 
+{
+	int res = 0;
+
+	if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+		res |= ast_unregister_application(dahdi_app);
+	}
+
+	res |= ast_unregister_application(zap_app);
 	
 	ast_module_user_hangup_all();
 
-	return res;	
+	return res;
 }
 
 static int load_module(void)
 {
-	ast_register_application(deprecated_app, conf_exec_warn, synopsis, descrip);
-	return ast_register_application(app, conf_exec, synopsis, descrip);
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Barge in on Zap channel application");
+	int res = 0;
+
+	if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+		res |= ast_register_application(dahdi_app, exec_dahdi, dahdi_synopsis, dahdi_descrip);
+	}
+
+	res |= ast_register_application(zap_app, exec_zap, zap_synopsis, zap_descrip);
+
+	return res;
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Barge in on channel application");

Modified: branches/1.4/apps/app_dahdiras.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_dahdiras.c?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/apps/app_dahdiras.c (original)
+++ branches/1.4/apps/app_dahdiras.c Fri Jul 11 17:12:26 2008
@@ -59,18 +59,25 @@
 
 #include "asterisk/dahdi_compat.h"
 
-static char *app = "DAHDIRAS";
-static char *deprecated_app = "ZapRAS";
-
-static char *synopsis = "Executes Zaptel ISDN RAS application";
-
-static char *descrip =
+static char *dahdi_app = "DAHDIRAS";
+static char *zap_app = "ZapRAS";
+
+static char *dahdi_synopsis = "Executes DAHDI ISDN RAS application";
+static char *zap_synopsis = "Executes Zaptel ISDN RAS application";
+
+static char *dahdi_descrip =
+"  DAHDIRAS(args): Executes a RAS server using pppd on the given channel.\n"
+"The channel must be a clear channel (i.e. PRI source) and a DAHDI\n"
+"channel to be able to use this function (no modem emulation is included).\n"
+"Your pppd must have the DAHDI plugin available. Arguments should be\n"
+"separated by | characters.\n";
+
+static char *zap_descrip =
 "  ZapRAS(args): Executes a RAS server using pppd on the given channel.\n"
 "The channel must be a clear channel (i.e. PRI source) and a Zaptel\n"
-"channel to be able to use this function (No modem emulation is included).\n"
-"Your pppd must be patched to be zaptel aware. Arguments should be\n"
+"channel to be able to use this function (no modem emulation is included).\n"
+"Your pppd must have the Zaptel plugin available. Arguments should be\n"
 "separated by | characters.\n";
-
 
 #define PPP_MAX_ARGS	32
 #define PPP_EXEC	"/usr/sbin/pppd"
@@ -117,7 +124,7 @@
 	memset(argv, 0, sizeof(argv));
 
 	/* First argument is executable, followed by standard
-	   arguments for zaptel PPP */
+	   arguments for DAHDI PPP */
 	argv[argc++] = PPP_EXEC;
 	argv[argc++] = "nodetach";
 
@@ -130,7 +137,11 @@
 	}
 
 	argv[argc++] = "plugin";
+#ifdef HAVE_ZAPTEL
 	argv[argc++] = "zaptel.so";
+#else
+	argv[argc++] = "dahdi.so";
+#endif
 	argv[argc++] = "stdin";
 
 	/* Finally launch PPP */
@@ -198,7 +209,7 @@
 	}
 }
 
-static int zapras_exec(struct ast_channel *chan, void *data)
+static int exec(struct ast_channel *chan, void *data)
 {
 	int res=-1;
 	char *args;
@@ -215,16 +226,14 @@
 	/* Answer the channel if it's not up */
 	if (chan->_state != AST_STATE_UP)
 		ast_answer(chan);
-	if (strcasecmp(chan->tech->type, "Zap")) {
-		/* If it's not a zap channel, we're done.  Wait a couple of
-		   seconds and then hangup... */
+	if (strcasecmp(chan->tech->type, dahdi_chan_name)) {
 		if (option_verbose > 1)
-			ast_verbose(VERBOSE_PREFIX_2 "Channel %s is not a Zap channel\n", chan->name);
+			ast_verbose(VERBOSE_PREFIX_2 "Channel %s is not a %s channel\n", chan->name, dahdi_chan_name);
 		sleep(2);
 	} else {
 		memset(&ztp, 0, sizeof(ztp));
 		if (ioctl(chan->fds[0], DAHDI_GET_PARAMS, &ztp)) {
-			ast_log(LOG_WARNING, "Unable to get zaptel parameters\n");
+			ast_log(LOG_WARNING, "Unable to get parameters\n");
 		} else if (ztp.sigtype != DAHDI_SIG_CLEAR) {
 			if (option_verbose > 1)
 				ast_verbose(VERBOSE_PREFIX_2 "Channel %s is not a clear channel\n", chan->name);
@@ -240,18 +249,22 @@
 	return res;
 }
 
-static int zapras_exec_warn(struct ast_channel *chan, void *data)
-{
-    ast_log(LOG_WARNING, "Use of the command %s is deprecated, please use %s instead.\n", deprecated_app, app);
-    return zapras_exec(chan, data);
-}
-
+static int exec_warn(struct ast_channel *chan, void *data)
+{
+	ast_log(LOG_WARNING, "Use of the command %s is deprecated, please use %s instead.\n", zap_app, dahdi_app);
+
+	return exec(chan, data);
+}
 
 static int unload_module(void) 
 {
-	int res;
-
-	res = ast_unregister_application(app);
+	int res = 0;
+
+	if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+		res |= ast_unregister_application(dahdi_app);
+	}
+
+	res |= ast_unregister_application(zap_app);
 	
 	ast_module_user_hangup_all();
 
@@ -260,9 +273,16 @@
 
 static int load_module(void)
 {
-	ast_register_application(deprecated_app, zapras_exec_warn, synopsis, descrip);
-	return ast_register_application(app, zapras_exec, synopsis, descrip);
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Zap RAS Application");
-
+	int res = 0;
+
+	if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+		res |= ast_register_application(dahdi_app, exec, dahdi_synopsis, dahdi_descrip);
+	}
+
+	res |= ast_register_application(zap_app, exec_warn, zap_synopsis, zap_descrip);
+
+	return res;
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "DAHDI RAS Application");
+

Modified: branches/1.4/apps/app_flash.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_flash.c?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/apps/app_flash.c (original)
+++ branches/1.4/apps/app_flash.c Fri Jul 11 17:12:26 2008
@@ -18,7 +18,7 @@
 
 /*! \file
  *
- * \brief App to flash a zap trunk
+ * \brief App to flash a DAHDI trunk
  *
  * \author Mark Spencer <markster at digium.com>
  * 
@@ -53,14 +53,21 @@
 
 static char *app = "Flash";
 
-static char *synopsis = "Flashes a Zap Trunk";
+static char *dahdi_synopsis = "Flashes a DAHDI trunk";
 
-static char *descrip = 
-"Performs a flash on a zap trunk.  This can be used\n"
+static char *dahdi_descrip = 
+"Performs a flash on a DAHDI trunk.  This can be used\n"
 "to access features provided on an incoming analogue circuit\n"
 "such as conference and call waiting. Use with SendDTMF() to\n"
 "perform external transfers\n";
 
+static char *zap_synopsis = "Flashes a Zap trunk";
+
+static char *zap_descrip = 
+"Performs a flash on a Zap trunk.  This can be used\n"
+"to access features provided on an incoming analogue circuit\n"
+"such as conference and call waiting. Use with SendDTMF() to\n"
+"perform external transfers\n";
 
 static inline int zt_wait_event(int fd)
 {
@@ -79,7 +86,7 @@
 	struct ast_module_user *u;
 	DAHDI_PARAMS ztp;
 	u = ast_module_user_add(chan);
-	if (!strcasecmp(chan->tech->type, "Zap")) {
+	if (!strcasecmp(chan->tech->type, dahdi_chan_name)) {
 		memset(&ztp, 0, sizeof(ztp));
 		res = ioctl(chan->fds[0], DAHDI_GET_PARAMS, &ztp);
 		if (!res) {
@@ -101,7 +108,7 @@
 		} else
 			ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));
 	} else
-		ast_log(LOG_WARNING, "%s is not a Zap channel\n", chan->name);
+		ast_log(LOG_WARNING, "%s is not a DAHDI channel\n", chan->name);
 	ast_module_user_remove(u);
 	return res;
 }
@@ -119,8 +126,11 @@
 
 static int load_module(void)
 {
-	return ast_register_application(app, flash_exec, synopsis, descrip);
+	if (dahdi_chan_mode == ZAP_ONLY_MODE) {
+		return ast_register_application(app, flash_exec, zap_synopsis, zap_descrip);
+	} else {
+		return ast_register_application(app, flash_exec, dahdi_synopsis, dahdi_descrip);
+	}
 }
 
 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Flash channel application");
-

Modified: branches/1.4/cdr/cdr_csv.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/cdr/cdr_csv.c?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/cdr/cdr_csv.c (original)
+++ branches/1.4/cdr/cdr_csv.c Fri Jul 11 17:12:26 2008
@@ -69,7 +69,7 @@
 
   "accountcode", 	accountcode is the account name of detail records, Master.csv contains all records *
   			Detail records are configured on a channel basis, IAX and SIP are determined by user *
-			Zap is determined by channel in zaptel.conf 
+			DAHDI is determined by channel in chan_dahdi.conf 
   "source",
   "destination",
   "destination context", 

Modified: branches/1.4/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_dahdi.c?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/channels/chan_dahdi.c (original)
+++ branches/1.4/channels/chan_dahdi.c Fri Jul 11 17:12:26 2008
@@ -115,10 +115,6 @@
 	.impl = ""
 };
 static struct ast_jb_conf global_jbconf;
-
-#if !defined(DAHDI_SIG_EM_E1) || (defined(HAVE_PRI) && !defined(DAHDI_SIG_HARDHDLC))
-#error "Your DAHDI is too old.  Please update"
-#endif
 
 #ifndef DAHDI_TONEDETECT
 /* Work around older code with no tone detect */
@@ -707,6 +703,29 @@
 	.func_channel_read = dahdi_func_read,
 };
 
+static const struct ast_channel_tech zap_tech = {
+	.type = "Zap",
+	.description = tdesc,
+	.capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ALAW,
+	.requester = dahdi_request,
+	.send_digit_begin = dahdi_digit_begin,
+	.send_digit_end = dahdi_digit_end,
+	.send_text = dahdi_sendtext,
+	.call = dahdi_call,
+	.hangup = dahdi_hangup,
+	.answer = dahdi_answer,
+	.read = dahdi_read,
+	.write = dahdi_write,
+	.bridge = dahdi_bridge,
+	.exception = dahdi_exception,
+	.indicate = dahdi_indicate,
+	.fixup = dahdi_fixup,
+	.setoption = dahdi_setoption,
+	.func_channel_read = dahdi_func_read,
+};
+
+static const struct ast_channel_tech *chan_tech;
+
 #ifdef HAVE_PRI
 #define GET_CHANNEL(p) ((p)->bearer ? (p)->bearer->channel : p->channel)
 #else
@@ -3813,7 +3832,7 @@
 			do {
 				const char *alarm_str = alarm2str(res);
 
-				/* hack alert!  DAHDI 1.4 now exposes FXO battery as an alarm, but asterisk 1.4
+				/* hack alert! Zaptel 1.4 and DAHDI expose FXO battery as an alarm, but Asterisk 1.4
 				 * doesn't know what to do with it.  Don't confuse users with log messages. */
 				if (!strcasecmp(alarm_str, "No Alarm") || !strcasecmp(alarm_str, "Unknown Alarm")) {
 					p->unknown_alarm = 1;
@@ -5212,6 +5231,8 @@
 	int features;
 	char *b2 = NULL;
 	DAHDI_PARAMS ps;
+	char chanprefix[strlen(dahdi_chan_name) + 4];
+
 	if (i->subs[index].owner) {
 		ast_log(LOG_WARNING, "Channel %d already has a %s call\n", i->channel,subnames[index]);
 		return NULL;
@@ -5235,12 +5256,14 @@
 		}
 		y++;
 	} while (x < 3);
-	tmp = ast_channel_alloc(0, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "DAHDI/%s", b2);
+	strcpy(chanprefix, dahdi_chan_name);
+	strcat(chanprefix, "/%s");
+	tmp = ast_channel_alloc(0, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, chanprefix, b2);
 	if (b2) /*!> b2 can be freed now, it's been copied into the channel structure */
 		free(b2);
 	if (!tmp)
 		return NULL;
-	tmp->tech = &dahdi_tech;
+	tmp->tech = chan_tech;
 	ps.channo = i->channel;
 	res = ioctl(i->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &ps);
 	if (res) {
@@ -5950,8 +5973,8 @@
 				if (option_verbose > 2)
 					ast_verbose(VERBOSE_PREFIX_3 "Enabled DND on channel %d\n", p->channel);
 				manager_event(EVENT_FLAG_SYSTEM, "DNDState",
-							"Channel: DAHDI/%d\r\n"
-							"Status: enabled\r\n", p->channel);
+					      "Channel: %s/%d\r\n"
+					      "Status: enabled\r\n", dahdi_chan_name, p->channel);
 				res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL);
 				p->dnd = 1;
 				getforward = 0;
@@ -5962,8 +5985,8 @@
 				if (option_verbose > 2)
 					ast_verbose(VERBOSE_PREFIX_3 "Disabled DND on channel %d\n", p->channel);
 				manager_event(EVENT_FLAG_SYSTEM, "DNDState",
-							"Channel: DAHDI/%d\r\n"
-							"Status: disabled\r\n", p->channel);
+					      "Channel: %s/%d\r\n"
+					      "Status: disabled\r\n", dahdi_chan_name, p->channel);
 				res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL);
 				p->dnd = 0;
 				getforward = 0;
@@ -6028,8 +6051,8 @@
 				if (nbridge && ast_bridged_channel(nbridge)) 
 					pbridge = ast_bridged_channel(nbridge)->tech_pvt;
 				if (nbridge && pbridge && 
-				    (nbridge->tech == &dahdi_tech) && 
-				    (ast_bridged_channel(nbridge)->tech == &dahdi_tech) &&
+				    (nbridge->tech == chan_tech) && 
+				    (ast_bridged_channel(nbridge)->tech == chan_tech) &&
 				    ISTRUNK(pbridge)) {
 					int func = DAHDI_FLASH;
 					/* Clear out the dial buffer */
@@ -6704,7 +6727,7 @@
 		if (!i->unknown_alarm) {
 			ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", i->channel);
 			manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
-				"Channel: %d\r\n", i->channel);
+				      "Channel: %d\r\n", i->channel);
 		} else {
 			i->unknown_alarm = 0;
 		}
@@ -8105,15 +8128,13 @@
 				new->owner = old->owner;
 				old->owner = NULL;
 				if (new->owner) {
-					ast_string_field_build(new->owner, name, 
-							       "DAHDI/%d:%d-%d", pri->trunkgroup,
-							       new->channel, 1);
+					ast_string_field_build(new->owner, name, "%s/%d:%d-%d", dahdi_chan_name, pri->trunkgroup, new->channel, 1);
 					new->owner->tech_pvt = new;
 					new->owner->fds[0] = new->subs[SUB_REAL].dfd;
 					new->subs[SUB_REAL].owner = old->subs[SUB_REAL].owner;
 					old->subs[SUB_REAL].owner = NULL;
 				} else
-					ast_log(LOG_WARNING, "Whoa, there's no  owner, and we're having to fix up channel %d to channel %d\n", old->channel, new->channel);
+					ast_log(LOG_WARNING, "Whoa, there's no owner, and we're having to fix up channel %d to channel %d\n", old->channel, new->channel);
 				new->call = old->call;
 				old->call = NULL;
 
@@ -8471,7 +8492,7 @@
 				if (ast_tvdiff_ms(ast_tvnow(), lastidle) > 1000) {
 					/* Don't create a new idle call more than once per second */
 					snprintf(idlen, sizeof(idlen), "%d/%s", pri->pvts[nextidle]->channel, pri->idledial);
-					idle = dahdi_request("DAHDI", AST_FORMAT_ULAW, idlen, &cause);
+					idle = dahdi_request(dahdi_chan_name, AST_FORMAT_ULAW, idlen, &cause);
 					if (idle) {
 						pri->pvts[nextidle]->isidlecall = 1;
 						if (ast_pthread_create_background(&p, NULL, do_idle_thread, idle)) {
@@ -9894,6 +9915,13 @@
 
 #endif /* HAVE_PRI */
 
+/* Wrappers for astman operations to use proper channel name prefix */
+
+#define local_astman_ack(s, m, msg) do { if (chan_tech == &dahdi_tech) astman_send_ack(s, m, "DAHDI" msg); else astman_send_ack(s, m, "Zap" msg); } while (0)
+#define local_astman_header(m, hdr) astman_get_header(m, (chan_tech == &dahdi_tech) ? "DAHDI" hdr : "Zap" hdr)
+#define local_astman_register(a, b, c, d) do { if (chan_tech == &dahdi_tech) ast_manager_register("DAHDI" a, b, c, d); else ast_manager_register("Zap" a, b, c, d); } while (0)
+#define local_astman_unregister(a) do { if (chan_tech == &dahdi_tech) ast_manager_unregister("DAHDI" a); else ast_manager_unregister("Zap" a); } while (0)
+
 static int dahdi_destroy_channel(int fd, int argc, char **argv)
 {
 	int channel;
@@ -9910,17 +9938,17 @@
 static int dahdi_restart(void)
 {
 	if (option_verbose > 0)
-		ast_verbose(VERBOSE_PREFIX_1 "Destroying channels and reloading DAHDI configuration.\n");
+		ast_verbose(VERBOSE_PREFIX_1 "Destroying channels and reloading %s configuration.\n", dahdi_chan_name);
 	while (iflist) {
 		if (option_debug)
-			ast_log(LOG_DEBUG, "Destroying DAHDI channel no. %d\n", iflist->channel);
+			ast_log(LOG_DEBUG, "Destroying %s channel no. %d\n", dahdi_chan_name, iflist->channel);
 		/* Also updates iflist: */
 		destroy_channel(NULL, iflist, 1);
 	}
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Channels destroyed. Now re-reading config.\n");
 	if (setup_dahdi(0) != 0) {
-		ast_log(LOG_WARNING, "Reload channels from dahdi config failed!\n");
+		ast_log(LOG_WARNING, "Reload channels from %s config failed!\n", dahdi_chan_name);
 		return 1;
 	}
 	return 0;
@@ -9940,10 +9968,10 @@
 static int action_dahdirestart(struct mansession *s, const struct message *m)
 {
 	if (dahdi_restart() != 0) {
-		astman_send_error(s, m, "Failed rereading DAHDI configuration");
+		astman_send_error(s, m, "Failed to restart chan_dahdi");
 		return 1;
 	}
-	astman_send_ack(s, m, "DAHDIRestart: Success");
+	local_astman_ack(s, m, "Restart: Success");
 	return 0;
 }
 
@@ -10181,15 +10209,18 @@
 	DAHDI_SPANINFO s;
 
 #ifdef HAVE_ZAPTEL
-	ctl = open("/dev/zap/ctl", O_RDWR);
+	if ((ctl = open("/dev/zap/ctl", O_RDWR)) < 0) {
+		ast_log(LOG_WARNING, "Unable to open /dev/zap/ctl: %s\n", strerror(errno));
+		ast_cli(fd, "No Zaptel interface found.\n");
+		return RESULT_FAILURE;
+	}
 #else
-	ctl = open("/dev/dahdi/ctl", O_RDWR);
-#endif
-	if (ctl < 0) {
+	if ((ctl = open("/dev/dahdi/ctl", O_RDWR)) < 0) {
 		ast_log(LOG_WARNING, "Unable to open /dev/dahdi/ctl: %s\n", strerror(errno));
 		ast_cli(fd, "No DAHDI interface found.\n");
 		return RESULT_FAILURE;
 	}
+#endif
 	ast_cli(fd, FORMAT2, "Description", "Alarms", "IRQ", "bpviol", "CRC4");
 
 	for (span = 1; span < DAHDI_MAX_SPANS; ++span) {
@@ -10347,7 +10378,7 @@
 static int action_dahdidndon(struct mansession *s, const struct message *m)
 {
 	struct dahdi_pvt *p = NULL;
-	const char *channel = astman_get_header(m, "DAHDIChannel");
+	const char *channel = local_astman_header(m, "Channel");
 
 	if (ast_strlen_zero(channel)) {
 		astman_send_error(s, m, "No channel specified");
@@ -10366,7 +10397,7 @@
 static int action_dahdidndoff(struct mansession *s, const struct message *m)
 {
 	struct dahdi_pvt *p = NULL;
-	const char *channel = astman_get_header(m, "DAHDIChannel");
+	const char *channel = local_astman_header(m, "Channel");
 
 	if (ast_strlen_zero(channel)) {
 		astman_send_error(s, m, "No channel specified");
@@ -10385,7 +10416,7 @@
 static int action_transfer(struct mansession *s, const struct message *m)
 {
 	struct dahdi_pvt *p = NULL;
-	const char *channel = astman_get_header(m, "DAHDIChannel");
+	const char *channel = local_astman_header(m, "Channel");
 
 	if (ast_strlen_zero(channel)) {
 		astman_send_error(s, m, "No channel specified");
@@ -10397,14 +10428,14 @@
 		return 0;
 	}
 	dahdi_fake_event(p,TRANSFER);
-	astman_send_ack(s, m, "DAHDITransfer");
+	local_astman_ack(s, m, "Transfer");
 	return 0;
 }
 
 static int action_transferhangup(struct mansession *s, const struct message *m)
 {
 	struct dahdi_pvt *p = NULL;
-	const char *channel = astman_get_header(m, "DAHDIChannel");
+	const char *channel = local_astman_header(m, "Channel");
 
 	if (ast_strlen_zero(channel)) {
 		astman_send_error(s, m, "No channel specified");
@@ -10416,14 +10447,14 @@
 		return 0;
 	}
 	dahdi_fake_event(p,HANGUP);
-	astman_send_ack(s, m, "DAHDIHangup");
+	local_astman_ack(s, m, "Hangup");
 	return 0;
 }
 
 static int action_dahdidialoffhook(struct mansession *s, const struct message *m)
 {
 	struct dahdi_pvt *p = NULL;
-	const char *channel = astman_get_header(m, "DAHDIChannel");
+	const char *channel = local_astman_header(m, "Channel");
 	const char *number = astman_get_header(m, "Number");
 	int i;
 
@@ -10448,7 +10479,7 @@
 		struct ast_frame f = { AST_FRAME_DTMF, number[i] };
 		dahdi_queue_frame(p, &f, NULL); 
 	}
-	astman_send_ack(s, m, "DAHDIDialOffhook");
+	local_astman_ack(s, m, "DialOffhook");
 	return 0;
 }
 
@@ -10458,7 +10489,7 @@
 	const char *id = astman_get_header(m, "ActionID");
 	char idText[256] = "";
 
-	astman_send_ack(s, m, "DAHDI channel status will follow");
+	local_astman_ack(s, m, " channel status will follow");
 	if (!ast_strlen_zero(id))
 		snprintf(idText, sizeof(idText) - 1, "ActionID: %s\r\n", id);
 
@@ -10469,17 +10500,18 @@
 		if (tmp->channel > 0) {
 			int alarm = get_alarms(tmp);
 			astman_append(s,
-				"Event: DAHDIShowChannels\r\n"
-				"Channel: %d\r\n"
-				"Signalling: %s\r\n"
-				"Context: %s\r\n"
-				"DND: %s\r\n"
-				"Alarm: %s\r\n"
-				"%s"
-				"\r\n",
-				tmp->channel, sig2str(tmp->sig), tmp->context, 
-				tmp->dnd ? "Enabled" : "Disabled",
-				alarm2str(alarm), idText);
+				      "Event: %sShowChannels\r\n"
+				      "Channel: %d\r\n"
+				      "Signalling: %s\r\n"
+				      "Context: %s\r\n"
+				      "DND: %s\r\n"
+				      "Alarm: %s\r\n"
+				      "%s"
+				      "\r\n",
+				      dahdi_chan_name,
+				      tmp->channel, sig2str(tmp->sig), tmp->context, 
+				      tmp->dnd ? "Enabled" : "Disabled",
+				      alarm2str(alarm), idText);
 		} 
 
 		tmp = tmp->next;
@@ -10488,10 +10520,11 @@
 	ast_mutex_unlock(&iflock);
 	
 	astman_append(s, 
-		"Event: DAHDIShowChannelsComplete\r\n"
-		"%s"
-		"\r\n", 
-		idText);
+		      "Event: %sShowChannelsComplete\r\n"
+		      "%s"
+		      "\r\n",
+		      dahdi_chan_name,
+		      idText);
 	return 0;
 }
 
@@ -10510,14 +10543,14 @@
 	ast_unregister_application(dahdi_send_keypad_facility_app);
 #endif
 	ast_cli_unregister_multiple(dahdi_cli, sizeof(dahdi_cli) / sizeof(struct ast_cli_entry));
-	ast_manager_unregister( "DAHDIDialOffhook" );
-	ast_manager_unregister( "DAHDIHangup" );
-	ast_manager_unregister( "DAHDITransfer" );
-	ast_manager_unregister( "DAHDIDNDoff" );
-	ast_manager_unregister( "DAHDIDNDon" );
-	ast_manager_unregister("DAHDIShowChannels");
-	ast_manager_unregister("DAHDIRestart");
-	ast_channel_unregister(&dahdi_tech);
+	local_astman_unregister("DialOffhook");
+	local_astman_unregister("Hangup");
+	local_astman_unregister("Transfer");
+	local_astman_unregister("DNDoff");
+	local_astman_unregister("DNDon");
+	local_astman_unregister("ShowChannels");
+	local_astman_unregister("Restart");
+	ast_channel_unregister(chan_tech);
 	ast_mutex_lock(&iflock);
 	/* Hangup all interfaces if they have an owner */
 	p = iflist;
@@ -11506,12 +11539,16 @@
 	ast_register_application(dahdi_send_keypad_facility_app, dahdi_send_keypad_facility_exec,
 			dahdi_send_keypad_facility_synopsis, dahdi_send_keypad_facility_descrip);
 #endif
-	res = setup_dahdi(0);
-	/* Make sure we can register our DAHDI channel type */
-	if (res)
+	if ((res = setup_dahdi(0))) {
 		return AST_MODULE_LOAD_DECLINE;
-	if (ast_channel_register(&dahdi_tech)) {
-		ast_log(LOG_ERROR, "Unable to register channel class 'DAHDI'\n");
+	}
+	if (!strcmp(dahdi_chan_name, "DAHDI")) {
+		chan_tech = &dahdi_tech;
+	} else {
+		chan_tech = &zap_tech;
+	}
+	if (ast_channel_register(chan_tech)) {
+		ast_log(LOG_ERROR, "Unable to register channel class '%s'\n", chan_tech->type);
 		__unload_module();
 		return -1;
 	}
@@ -11523,13 +11560,13 @@
 	ast_cli_register_multiple(dahdi_cli, sizeof(dahdi_cli) / sizeof(struct ast_cli_entry));
 	
 	memset(round_robin, 0, sizeof(round_robin));
-	ast_manager_register("DAHDITransfer", 0, action_transfer, "Transfer DAHDI Channel" );
-	ast_manager_register("DAHDIHangup", 0, action_transferhangup, "Hangup DAHDI Channel" );
-	ast_manager_register("DAHDIDialOffhook", 0, action_dahdidialoffhook, "Dial over DAHDI channel while offhook" );
-	ast_manager_register("DAHDIDNDon", 0, action_dahdidndon, "Toggle DAHDI channel Do Not Disturb status ON" );
-	ast_manager_register("DAHDIDNDoff", 0, action_dahdidndoff, "Toggle DAHDI channel Do Not Disturb status OFF" );
-	ast_manager_register("DAHDIShowChannels", 0, action_dahdishowchannels, "Show status DAHDI channels");
-	ast_manager_register("DAHDIRestart", 0, action_dahdirestart, "Fully Restart DAHDI channels (terminates calls)");
+	local_astman_register("Transfer", 0, action_transfer, "Transfer Channel");
+	local_astman_register("Hangup", 0, action_transferhangup, "Hangup Channel");
+	local_astman_register("DialOffhook", 0, action_dahdidialoffhook, "Dial over channel while offhook");
+	local_astman_register("DNDon", 0, action_dahdidndon, "Toggle channel Do Not Disturb status ON");
+	local_astman_register("DNDoff", 0, action_dahdidndoff, "Toggle channel Do Not Disturb status OFF");
+	local_astman_register("ShowChannels", 0, action_dahdishowchannels, "Show status channels");
+	local_astman_register("Restart", 0, action_dahdirestart, "Fully Restart channels (terminates calls)");
 
 	return res;
 }

Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Fri Jul 11 17:12:26 2008
@@ -6580,7 +6580,7 @@
 #ifdef DAHDI_TIMERACK
 		/* Great, this is a timing interface, just call the ioctl */
 		if (ioctl(fd, DAHDI_TIMERACK, &x)) {
-			ast_log(LOG_WARNING, "Unable to acknowledge zap timer. IAX trunking will fail!\n");
+			ast_log(LOG_WARNING, "Unable to acknowledge timer. IAX trunking will fail!\n");
 			usleep(1);
 			return -1;
 		}
@@ -9408,7 +9408,7 @@
 			} else if (!strcasecmp(v->name, "trunk")) {
 				ast_set2_flag(peer, ast_true(v->value), IAX_TRUNK);	
 				if (ast_test_flag(peer, IAX_TRUNK) && (timingfd < 0)) {
-					ast_log(LOG_WARNING, "Unable to support trunking on peer '%s' without zaptel timing\n", peer->name);
+					ast_log(LOG_WARNING, "Unable to support trunking on peer '%s' without timing\n", peer->name);
 					ast_clear_flag(peer, IAX_TRUNK);
 				}
 			} else if (!strcasecmp(v->name, "auth")) {
@@ -9666,7 +9666,7 @@
 			} else if (!strcasecmp(v->name, "trunk")) {
 				ast_set2_flag(user, ast_true(v->value), IAX_TRUNK);	
 				if (ast_test_flag(user, IAX_TRUNK) && (timingfd < 0)) {
-					ast_log(LOG_WARNING, "Unable to support trunking on user '%s' without zaptel timing\n", user->name);
+					ast_log(LOG_WARNING, "Unable to support trunking on user '%s' without timing\n", user->name);
 					ast_clear_flag(user, IAX_TRUNK);
 				}
 			} else if (!strcasecmp(v->name, "auth")) {

Modified: branches/1.4/contrib/utils/zones2indications.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/contrib/utils/zones2indications.c?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/contrib/utils/zones2indications.c (original)
+++ branches/1.4/contrib/utils/zones2indications.c Fri Jul 11 17:12:26 2008
@@ -22,7 +22,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <zaptel/tonezone.h>
+#include <dahdi/tonezone.h>
 #include <unistd.h>
 
 #define PROGRAM "zones2indication"

Modified: branches/1.4/doc/hardware.txt
URL: http://svn.digium.com/view/asterisk/branches/1.4/doc/hardware.txt?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/doc/hardware.txt (original)
+++ branches/1.4/doc/hardware.txt Fri Jul 11 17:12:26 2008
@@ -2,12 +2,12 @@
 can use Asterisk with VoIP calls (SIP, H.323, IAX), but you can also talk
 to the real PSTN through various cards.
 
-Supported Hardware is divided into two general groups:  Zaptel devices and 
-non-zaptel devices.  The Zaptel compatible hardware supports pseudo-TDM 
-conferencing and all call features through chan_zap, whereas non-zaptel 
+Supported Hardware is divided into two general groups:  DAHDI devices and 
+non-DAHDI devices.  The DAHDI compatible hardware supports pseudo-TDM 
+conferencing and all call features through chan_dahdi, whereas non-DAHDI 
 compatible hardware may have different features.
 
-Zaptel compatible hardware
+DAHDI compatible hardware
 ==========================
 
 -- Digium (Primary author of Asterisk)
@@ -31,7 +31,7 @@
    * Wildcard TE410P - Quad T1/E1 switchable interface.  Supports PRI and 
      RBS signalling, as well as PPP, FR, and HDLC data modes.
 
-Non-zaptel compatible hardware
+Non-DAHDI compatible hardware
 ==============================
 
 -- QuickNet, Inc. 

Modified: branches/1.4/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/channel.h?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/include/asterisk/channel.h (original)
+++ branches/1.4/include/asterisk/channel.h Fri Jul 11 17:12:26 2008
@@ -1168,7 +1168,7 @@
  */
 int ast_autoservice_stop(struct ast_channel *chan);
 
-/* If built with zaptel optimizations, force a scheduled expiration on the
+/* If built with DAHDI optimizations, force a scheduled expiration on the
    timer fd, at which point we call the callback function / data */
 int ast_settimeout(struct ast_channel *c, int samples, int (*func)(const void *data), void *data);
 

Modified: branches/1.4/include/asterisk/options.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/options.h?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/include/asterisk/options.h (original)
+++ branches/1.4/include/asterisk/options.h Fri Jul 11 17:12:26 2008
@@ -122,8 +122,12 @@
 
 extern char record_cache_dir[AST_CACHE_DIR_LEN];
 extern char debug_filename[AST_FILENAME_MAX];
-extern char dahdi_chan_name[AST_CHANNEL_NAME];
-
+extern const char *dahdi_chan_name;
+extern enum dahdi_chan_modes {
+	ZAP_ONLY_MODE,
+	DAHDI_PLUS_ZAP,
+} dahdi_chan_mode;
+	
 extern int ast_language_is_prefix;
 
 #if defined(__cplusplus) || defined(c_plusplus)

Modified: branches/1.4/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/asterisk.c?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/main/asterisk.c (original)
+++ branches/1.4/main/asterisk.c Fri Jul 11 17:12:26 2008
@@ -172,7 +172,14 @@
 
 char record_cache_dir[AST_CACHE_DIR_LEN] = AST_TMP_DIR;
 char debug_filename[AST_FILENAME_MAX] = "";
-char dahdi_chan_name[AST_CHANNEL_NAME] = "ZAP";
+#ifdef HAVE_ZAPTEL
+char _dahdi_chan_name[AST_CHANNEL_NAME] = "Zap";
+enum dahdi_chan_modes dahdi_chan_mode = ZAP_ONLY_MODE;
+#else
+char _dahdi_chan_name[AST_CHANNEL_NAME] = "DAHDI";
+enum dahdi_chan_modes dahdi_chan_mode = DAHDI_PLUS_ZAP;
+#endif
+const char *dahdi_chan_name;
 
 static int ast_socket = -1;		/*!< UNIX Socket for allowing remote control */
 static int ast_consock = -1;		/*!< UNIX Socket for controlling another asterisk */
@@ -2409,7 +2416,7 @@
 	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 %s timer is available\n", dahdi_chan_name);
 	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");
@@ -2583,9 +2590,17 @@
 		} else if (!strcasecmp(v->name, "languageprefix")) {
 			ast_language_is_prefix = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "dahdichanname")) {
-			if (!strcasecmp(v->value, "yes")) {
-				ast_copy_string(dahdi_chan_name, "DAHDI", sizeof(dahdi_chan_name));
-			}
+#ifdef HAVE_ZAPTEL
+			if (ast_true(v->value)) {
+				strcpy(_dahdi_chan_name, "DAHDI");
+				dahdi_chan_mode = DAHDI_PLUS_ZAP;
+			}
+#else
+			if (ast_false(v->value)) {
+				strcpy(_dahdi_chan_name, "Zap");
+				dahdi_chan_mode = ZAP_ONLY_MODE;
+			}
+#endif
 		}
 	}
 	ast_config_destroy(cfg);
@@ -2966,6 +2981,9 @@
 		printf(term_quit());
 		exit(1);
 	}
+
+	dahdi_chan_name = _dahdi_chan_name;
+
 #ifdef HAVE_ZAPTEL
 	{
 		int fd;

Modified: branches/1.4/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/channel.c?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/main/channel.c (original)
+++ branches/1.4/main/channel.c Fri Jul 11 17:12:26 2008
@@ -3009,11 +3009,6 @@
 		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;

Modified: branches/1.4/main/file.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/file.c?view=diff&rev=130298&r1=130297&r2=130298
==============================================================================
--- branches/1.4/main/file.c (original)
+++ branches/1.4/main/file.c Fri Jul 11 17:12:26 2008
@@ -683,7 +683,7 @@
 		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); 




More information about the asterisk-commits mailing list