aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-22 22:11:01 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-22 22:11:01 +0000
commit21ecfefe647461701504aeeccc9f795078094436 (patch)
tree7d7dc3b190e0c231e06caf43a57202700f8c7456
parent2d0c70e4ebb0f6d7e826065d6bb75e3e2513089e (diff)
fix up namespace pollution for dahdi_chan_mode enum
correct registration of AMI actions in chan_dahdi; in zap-only mode, only register the Zap flavors of the actions (and use Zap prefixes for headers and acks), but in dahdi+zap mode, register both Zap and DAHDI flavors of actions git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@132787 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_dahdibarge.c4
-rw-r--r--apps/app_dahdiras.c4
-rw-r--r--apps/app_flash.c2
-rw-r--r--channels/chan_dahdi.c193
-rw-r--r--include/asterisk/options.h4
-rw-r--r--main/asterisk.c8
6 files changed, 140 insertions, 75 deletions
diff --git a/apps/app_dahdibarge.c b/apps/app_dahdibarge.c
index 48bc0c62f..88610cc36 100644
--- a/apps/app_dahdibarge.c
+++ b/apps/app_dahdibarge.c
@@ -336,7 +336,7 @@ static int unload_module(void)
{
int res = 0;
- if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+ if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
res |= ast_unregister_application(dahdi_app);
}
@@ -351,7 +351,7 @@ static int load_module(void)
{
int res = 0;
- if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+ if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
res |= ast_register_application(dahdi_app, exec_dahdi, dahdi_synopsis, dahdi_descrip);
}
diff --git a/apps/app_dahdiras.c b/apps/app_dahdiras.c
index 2a9875ed3..1012a5fbe 100644
--- a/apps/app_dahdiras.c
+++ b/apps/app_dahdiras.c
@@ -260,7 +260,7 @@ static int unload_module(void)
{
int res = 0;
- if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+ if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
res |= ast_unregister_application(dahdi_app);
}
@@ -275,7 +275,7 @@ static int load_module(void)
{
int res = 0;
- if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+ if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
res |= ast_register_application(dahdi_app, exec, dahdi_synopsis, dahdi_descrip);
}
diff --git a/apps/app_flash.c b/apps/app_flash.c
index 98ea17d03..e6b2db49a 100644
--- a/apps/app_flash.c
+++ b/apps/app_flash.c
@@ -126,7 +126,7 @@ static int unload_module(void)
static int load_module(void)
{
- if (dahdi_chan_mode == ZAP_ONLY_MODE) {
+ if (dahdi_chan_mode == CHAN_ZAP_MODE) {
return ast_register_application(app, flash_exec, zap_synopsis, zap_descrip);
} else {
return ast_register_application(app, flash_exec, dahdi_synopsis, dahdi_descrip);
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index e6c137fa1..ddba8016e 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -9906,13 +9906,6 @@ static struct ast_cli_entry dahdi_pri_cli[] = {
#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;
@@ -9956,16 +9949,6 @@ static int dahdi_restart_cmd(int fd, int argc, char **argv)
return RESULT_SUCCESS;
}
-static int action_dahdirestart(struct mansession *s, const struct message *m)
-{
- if (dahdi_restart() != 0) {
- astman_send_error(s, m, "Failed to restart chan_dahdi");
- return 1;
- }
- local_astman_ack(s, m, "Restart: Success");
- return 0;
-}
-
static int dahdi_show_channels(int fd, int argc, char **argv)
{
#define FORMAT "%7s %-10.10s %-15.15s %-10.10s %-20.20s\n"
@@ -10366,86 +10349,109 @@ static struct dahdi_pvt *find_channel(int channel)
return p;
}
-static int action_dahdidndon(struct mansession *s, const struct message *m)
+#define local_astman_ack(s, m, msg, zap) do { if (!zap) astman_send_ack(s, m, "DAHDI" msg); else astman_send_ack(s, m, "Zap" msg); } while (0)
+#define local_astman_header(m, hdr, zap) astman_get_header(m, (!zap) ? "DAHDI" hdr : "Zap" hdr)
+
+static int __action_dnd(struct mansession *s, const struct message *m, int zap_mode, int dnd)
{
struct dahdi_pvt *p = NULL;
- const char *channel = local_astman_header(m, "Channel");
+ const char *channel = local_astman_header(m, "Channel", zap_mode);
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
return 0;
}
- p = find_channel(atoi(channel));
- if (!p) {
+ if (!(p = find_channel(atoi(channel)))) {
astman_send_error(s, m, "No such channel");
return 0;
}
- p->dnd = 1;
- astman_send_ack(s, m, "DND Enabled");
+ p->dnd = dnd;
+ local_astman_ack(s, m, "DND", zap_mode);
+
return 0;
}
-static int action_dahdidndoff(struct mansession *s, const struct message *m)
+static int zap_action_dndon(struct mansession *s, const struct message *m)
{
- struct dahdi_pvt *p = NULL;
- const char *channel = local_astman_header(m, "Channel");
+ return __action_dnd(s, m, 1, 1);
+}
- if (ast_strlen_zero(channel)) {
- astman_send_error(s, m, "No channel specified");
- return 0;
- }
- p = find_channel(atoi(channel));
- if (!p) {
- astman_send_error(s, m, "No such channel");
- return 0;
- }
- p->dnd = 0;
- astman_send_ack(s, m, "DND Disabled");
- return 0;
+static int dahdi_action_dndon(struct mansession *s, const struct message *m)
+{
+ return __action_dnd(s, m, 0, 1);
+}
+
+static int zap_action_dndoff(struct mansession *s, const struct message *m)
+{
+ return __action_dnd(s, m, 1, 0);
+}
+
+static int dahdi_action_dndoff(struct mansession *s, const struct message *m)
+{
+ return __action_dnd(s, m, 0, 0);
}
-static int action_transfer(struct mansession *s, const struct message *m)
+static int __action_transfer(struct mansession *s, const struct message *m, int zap_mode)
{
struct dahdi_pvt *p = NULL;
- const char *channel = local_astman_header(m, "Channel");
+ const char *channel = local_astman_header(m, "Channel", zap_mode);
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
return 0;
}
- p = find_channel(atoi(channel));
- if (!p) {
+ if (!(p = find_channel(atoi(channel)))) {
astman_send_error(s, m, "No such channel");
return 0;
}
dahdi_fake_event(p,TRANSFER);
- local_astman_ack(s, m, "Transfer");
+ local_astman_ack(s, m, "Transfer", zap_mode);
+
return 0;
}
-static int action_transferhangup(struct mansession *s, const struct message *m)
+static int zap_action_transfer(struct mansession *s, const struct message *m)
+{
+ return __action_transfer(s, m, 1);
+}
+
+static int dahdi_action_transfer(struct mansession *s, const struct message *m)
+{
+ return __action_transfer(s, m, 0);
+}
+
+static int __action_transferhangup(struct mansession *s, const struct message *m, int zap_mode)
{
struct dahdi_pvt *p = NULL;
- const char *channel = local_astman_header(m, "Channel");
+ const char *channel = local_astman_header(m, "Channel", zap_mode);
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
return 0;
}
- p = find_channel(atoi(channel));
- if (!p) {
+ if (!(p = find_channel(atoi(channel)))) {
astman_send_error(s, m, "No such channel");
return 0;
}
- dahdi_fake_event(p,HANGUP);
- local_astman_ack(s, m, "Hangup");
+ dahdi_fake_event(p, HANGUP);
+ local_astman_ack(s, m, "Hangup", zap_mode);
return 0;
}
-static int action_dahdidialoffhook(struct mansession *s, const struct message *m)
+static int zap_action_transferhangup(struct mansession *s, const struct message *m)
+{
+ return __action_transferhangup(s, m, 1);
+}
+
+static int dahdi_action_transferhangup(struct mansession *s, const struct message *m)
+{
+ return __action_transferhangup(s, m, 0);
+}
+
+static int __action_dialoffhook(struct mansession *s, const struct message *m, int zap_mode)
{
struct dahdi_pvt *p = NULL;
- const char *channel = local_astman_header(m, "Channel");
+ const char *channel = local_astman_header(m, "Channel", zap_mode);
const char *number = astman_get_header(m, "Number");
int i;
@@ -10457,30 +10463,41 @@ static int action_dahdidialoffhook(struct mansession *s, const struct message *m
astman_send_error(s, m, "No number specified");
return 0;
}
- p = find_channel(atoi(channel));
- if (!p) {
+ if (!(p = find_channel(atoi(channel)))) {
astman_send_error(s, m, "No such channel");
return 0;
}
if (!p->owner) {
- astman_send_error(s, m, "Channel does not have it's owner");
+ astman_send_error(s, m, "Channel does not have an owner");
return 0;
}
for (i = 0; i < strlen(number); i++) {
struct ast_frame f = { AST_FRAME_DTMF, number[i] };
+
dahdi_queue_frame(p, &f, NULL);
}
- local_astman_ack(s, m, "DialOffhook");
+ local_astman_ack(s, m, "DialOffHook", zap_mode);
+
return 0;
}
-static int action_dahdishowchannels(struct mansession *s, const struct message *m)
+static int zap_action_dialoffhook(struct mansession *s, const struct message *m)
+{
+ return __action_dialoffhook(s, m, 1);
+}
+
+static int dahdi_action_dialoffhook(struct mansession *s, const struct message *m)
+{
+ return __action_dialoffhook(s, m, 0);
+}
+
+static int __action_showchannels(struct mansession *s, const struct message *m, int zap_mode)
{
struct dahdi_pvt *tmp = NULL;
const char *id = astman_get_header(m, "ActionID");
char idText[256] = "";
- local_astman_ack(s, m, " channel status will follow");
+ local_astman_ack(s, m, " channel status will follow", zap_mode);
if (!ast_strlen_zero(id))
snprintf(idText, sizeof(idText) - 1, "ActionID: %s\r\n", id);
@@ -10519,6 +10536,47 @@ static int action_dahdishowchannels(struct mansession *s, const struct message *
return 0;
}
+static int zap_action_showchannels(struct mansession *s, const struct message *m)
+{
+ return __action_showchannels(s, m, 1);
+}
+
+static int dahdi_action_showchannels(struct mansession *s, const struct message *m)
+{
+ return __action_showchannels(s, m, 0);
+}
+
+static int __action_restart(struct mansession *s, const struct message *m, int zap_mode)
+{
+ if (dahdi_restart() != 0) {
+ if (zap_mode) {
+ astman_send_error(s, m, "Failed to restart Zap");
+ } else {
+ astman_send_error(s, m, "Failed to restart DAHDI");
+ }
+ return 1;
+ }
+ local_astman_ack(s, m, "Restart: Success", zap_mode);
+ return 0;
+}
+
+static int zap_action_restart(struct mansession *s, const struct message *m)
+{
+ return __action_restart(s, m, 1);
+}
+
+static int dahdi_action_restart(struct mansession *s, const struct message *m)
+{
+ return __action_restart(s, m, 0);
+}
+
+#define local_astman_unregister(a) do { \
+ if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) { \
+ ast_manager_unregister("DAHDI" a); \
+ } \
+ ast_manager_unregister("Zap" a); \
+ } while (0)
+
static int __unload_module(void)
{
int x;
@@ -10534,7 +10592,7 @@ static int __unload_module(void)
ast_unregister_application(dahdi_send_keypad_facility_app);
#endif
ast_cli_unregister_multiple(dahdi_cli, sizeof(dahdi_cli) / sizeof(struct ast_cli_entry));
- local_astman_unregister("DialOffhook");
+ local_astman_unregister("DialOffHook");
local_astman_unregister("Hangup");
local_astman_unregister("Transfer");
local_astman_unregister("DNDoff");
@@ -11511,6 +11569,13 @@ static int setup_dahdi(int reload)
return 0;
}
+#define local_astman_register(a, b, c, d) do { \
+ if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) { \
+ ast_manager_register("DAHDI" a, b, dahdi_ ## c, d); \
+ } \
+ ast_manager_register("Zap" a, b, zap_ ## c, d); \
+ } while (0)
+
static int load_module(void)
{
int res;
@@ -11533,7 +11598,7 @@ static int load_module(void)
if ((res = setup_dahdi(0))) {
return AST_MODULE_LOAD_DECLINE;
}
- if (!strcmp(dahdi_chan_name, "DAHDI")) {
+ if (dahdi_chan_mode == CHAN_DAHDI_PLUS_ZAP_MODE) {
chan_tech = &dahdi_tech;
} else {
chan_tech = &zap_tech;
@@ -11553,11 +11618,11 @@ static int load_module(void)
memset(round_robin, 0, sizeof(round_robin));
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)");
+ local_astman_register("DialOffHook", 0, action_dialoffhook, "Dial over channel while offhook");
+ local_astman_register("DNDon", 0, action_dndon, "Toggle channel Do Not Disturb status ON");
+ local_astman_register("DNDoff", 0, action_dndoff, "Toggle channel Do Not Disturb status OFF");
+ local_astman_register("ShowChannels", 0, action_showchannels, "Show status channels");
+ local_astman_register("Restart", 0, action_restart, "Fully Restart channels (terminates calls)");
return res;
}
diff --git a/include/asterisk/options.h b/include/asterisk/options.h
index 57e1374fe..10c2126c2 100644
--- a/include/asterisk/options.h
+++ b/include/asterisk/options.h
@@ -124,8 +124,8 @@ extern char record_cache_dir[AST_CACHE_DIR_LEN];
extern char debug_filename[AST_FILENAME_MAX];
extern const char *dahdi_chan_name;
extern enum dahdi_chan_modes {
- ZAP_ONLY_MODE,
- DAHDI_PLUS_ZAP,
+ CHAN_ZAP_MODE,
+ CHAN_DAHDI_PLUS_ZAP_MODE,
} dahdi_chan_mode;
extern int ast_language_is_prefix;
diff --git a/main/asterisk.c b/main/asterisk.c
index 36a65c91a..4bfa45036 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -174,10 +174,10 @@ char record_cache_dir[AST_CACHE_DIR_LEN] = AST_TMP_DIR;
char debug_filename[AST_FILENAME_MAX] = "";
#ifdef HAVE_ZAPTEL
char _dahdi_chan_name[AST_CHANNEL_NAME] = "Zap";
-enum dahdi_chan_modes dahdi_chan_mode = ZAP_ONLY_MODE;
+enum dahdi_chan_modes dahdi_chan_mode = CHAN_ZAP_MODE;
#else
char _dahdi_chan_name[AST_CHANNEL_NAME] = "DAHDI";
-enum dahdi_chan_modes dahdi_chan_mode = DAHDI_PLUS_ZAP;
+enum dahdi_chan_modes dahdi_chan_mode = CHAN_DAHDI_PLUS_ZAP_MODE;
#endif
const char *dahdi_chan_name;
@@ -2593,12 +2593,12 @@ static void ast_readconfig(void)
#ifdef HAVE_ZAPTEL
if (ast_true(v->value)) {
strcpy(_dahdi_chan_name, "DAHDI");
- dahdi_chan_mode = DAHDI_PLUS_ZAP;
+ dahdi_chan_mode = CHAN_DAHDI_PLUS_ZAP_MODE;
}
#else
if (ast_false(v->value)) {
strcpy(_dahdi_chan_name, "Zap");
- dahdi_chan_mode = ZAP_ONLY_MODE;
+ dahdi_chan_mode = CHAN_ZAP_MODE;
}
#endif
}