[svn-commits] trunk r36865 - in /trunk/channels: ./ misdn/
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Mon Jul 3 09:41:44 MST 2006
Author: crichter
Date: Mon Jul 3 11:41:43 2006
New Revision: 36865
URL: http://svn.digium.com/view/asterisk?rev=36865&view=rev
Log:
added misdn show config description[s] to show all the possible misdn.conf settings with a description in the CLI
Modified:
trunk/channels/chan_misdn.c
trunk/channels/misdn/chan_misdn_config.h
trunk/channels/misdn_config.c
Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=36865&r1=36864&r2=36865&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Mon Jul 3 11:41:43 2006
@@ -62,6 +62,7 @@
#include "asterisk/indications.h"
#include "asterisk/app.h"
#include "asterisk/features.h"
+#include "asterisk/term.h"
#include "asterisk/stringfields.h"
#include "chan_misdn_config.h"
@@ -578,15 +579,66 @@
return 0;
}
+static inline void show_config_description (int fd, enum misdn_cfg_elements elem)
+{
+ char section[BUFFERSIZE];
+ char name[BUFFERSIZE];
+ char desc[BUFFERSIZE];
+ char def[BUFFERSIZE];
+ char tmp[BUFFERSIZE];
+
+ misdn_cfg_get_name(elem, tmp, sizeof(tmp));
+ term_color(name, tmp, COLOR_BRWHITE, 0, sizeof(tmp));
+ misdn_cfg_get_desc(elem, desc, sizeof(desc), def, sizeof(def));
+
+ if (elem < MISDN_CFG_LAST)
+ term_color(section, "PORTS SECTION", COLOR_YELLOW, 0, sizeof(section));
+ else
+ term_color(section, "GENERAL SECTION", COLOR_YELLOW, 0, sizeof(section));
+
+ if (*def)
+ ast_cli(fd, "[%s] %s (Default: %s)\n\t%s\n", section, name, def, desc);
+ else
+ ast_cli(fd, "[%s] %s\n\t%s\n", section, name, desc);
+}
static int misdn_show_config (int fd, int argc, char *argv[])
{
char buffer[BUFFERSIZE];
enum misdn_cfg_elements elem;
int linebreak;
-
int onlyport = -1;
+ int ok = 0;
+
if (argc >= 4) {
+ if (!strcmp(argv[3], "description")) {
+ if (argc == 5) {
+ enum misdn_cfg_elements elem = misdn_cfg_get_elem (argv[4]);
+ if (elem == MISDN_CFG_FIRST)
+ ast_cli(fd, "Unknown element: %s\n", argv[4]);
+ else
+ show_config_description(fd, elem);
+ return 0;
+ }
+ return RESULT_SHOWUSAGE;
+ }
+ if (!strcmp(argv[3], "descriptions")) {
+ if ((argc == 4) || ((argc == 5) && !strcmp(argv[4], "general"))) {
+ for (elem = MISDN_GEN_FIRST + 1; elem < MISDN_GEN_LAST; ++elem) {
+ show_config_description(fd, elem);
+ ast_cli(fd, "\n");
+ }
+ ok = 1;
+ }
+ if ((argc == 4) || ((argc == 5) && !strcmp(argv[4], "ports"))) {
+ for (elem = MISDN_CFG_FIRST + 1; elem < MISDN_CFG_LAST; ++elem) {
+ show_config_description(fd, elem);
+ ast_cli(fd, "\n");
+ }
+ ok = 1;
+ }
+ return ok ? 0 : RESULT_SHOWUSAGE;
+ }
if (!sscanf(argv[3], "%d", &onlyport) || onlyport < 0) {
ast_cli(fd, "Unknown option: %s\n", argv[3]);
return RESULT_SHOWUSAGE;
@@ -619,7 +671,7 @@
if (misdn_cfg_is_port_valid(onlyport)) {
ast_cli(fd, "[PORT %d]\n", onlyport);
for (elem = MISDN_CFG_FIRST + 1, linebreak = 1; elem < MISDN_CFG_LAST; elem++, linebreak++) {
- misdn_cfg_get_config_string( onlyport, elem, buffer, BUFFERSIZE);
+ misdn_cfg_get_config_string(onlyport, elem, buffer, BUFFERSIZE);
ast_cli(fd, "%-36s%s", buffer, !(linebreak % 2) ? "\n" : "");
}
ast_cli(fd, "\n");
@@ -1043,6 +1095,50 @@
return NULL;
}
+static char *complete_show_config (const char *line, const char *word, int pos, int state)
+{
+ char buffer[BUFFERSIZE];
+ enum misdn_cfg_elements elem;
+ int wordlen = strlen(word);
+ int which = 0;
+ int port = 0;
+
+ switch (pos) {
+ case 3: if ((!strncmp(word, "description", wordlen)) && (++which > state))
+ return strdup("description");
+ if ((!strncmp(word, "descriptions", wordlen)) && (++which > state))
+ return strdup("descriptions");
+ if ((!strncmp(word, "0", wordlen)) && (++which > state))
+ return strdup("0");
+ while ((port = misdn_cfg_get_next_port(port)) != -1) {
+ snprintf(buffer, sizeof(buffer), "%d", port);
+ if ((!strncmp(word, buffer, wordlen)) && (++which > state)) {
+ return strdup(buffer);
+ }
+ }
+ break;
+ case 4:
+ if (strstr(line, "description ")) {
+ for (elem = MISDN_CFG_FIRST + 1; elem < MISDN_GEN_LAST; ++elem) {
+ if ((elem == MISDN_CFG_LAST) || (elem == MISDN_GEN_FIRST))
+ continue;
+ misdn_cfg_get_name(elem, buffer, BUFFERSIZE);
+ if (!wordlen || !strncmp(word, buffer, wordlen)) {
+ if (++which > state)
+ return strdup(buffer);
+ }
+ }
+ } else if (strstr(line, "descriptions ")) {
+ if ((!wordlen || !strncmp(word, "general", wordlen)) && (++which > state))
+ return strdup("general");
+ if ((!wordlen || !strncmp(word, "ports", wordlen)) && (++which > state))
+ return strdup("ports");
+ }
+ break;
+ }
+ return NULL;
+}
+
static struct ast_cli_entry cli_send_cd =
{ {"misdn","send","calldeflect", NULL},
misdn_send_cd,
@@ -1083,7 +1179,9 @@
{ {"misdn","show","config", NULL},
misdn_show_config,
"Shows internal mISDN config, read from cfg-file",
- "Usage: misdn show config [port | 0]\n use 0 to only print the general config.\n"
+ "Usage: misdn show config [<port> | description <config element> | descriptions [general|ports]]\n"
+ " Use 0 for <port> to only print the general config.\n",
+ complete_show_config
};
static struct ast_cli_entry cli_reload =
@@ -3127,7 +3225,7 @@
void import_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
{
- char *tmp;
+ const char *tmp;
tmp=pbx_builtin_getvar_helper(chan,"MISDN_PID");
if (tmp) {
ch->other_pid=atoi(tmp);
Modified: trunk/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/chan_misdn_config.h?rev=36865&r1=36864&r2=36865&view=diff
==============================================================================
--- trunk/channels/misdn/chan_misdn_config.h (original)
+++ trunk/channels/misdn/chan_misdn_config.h Mon Jul 3 11:41:43 2006
@@ -60,6 +60,7 @@
MISDN_CFG_MAX_OUT, /* int */
MISDN_CFG_MSNS, /* char[] */
MISDN_CFG_PTP, /* int (bool) */
+ MISDN_CFG_FAXDETECT, /* char[] */
MISDN_CFG_LAST,
/* general config items */
@@ -96,6 +97,15 @@
* case of a char* only its first byte will be nulled). */
void misdn_cfg_get(int port, enum misdn_cfg_elements elem, void* buf, int bufsize);
+/* returns the enum element for the given name, returns MISDN_CFG_FIRST if none was found */
+enum misdn_cfg_elements misdn_cfg_get_elem (char *name);
+
+/* fills the buffer with the name of the given config element */
+void misdn_cfg_get_name (enum misdn_cfg_elements elem, void *buf, int bufsize);
+
+/* fills the buffer with the description of the given config element */
+void misdn_cfg_get_desc (enum misdn_cfg_elements elem, void *buf, int bufsize, void *buf_default, int bufsize_default);
+
/* fills the buffer with a ',' separated list of all active ports */
void misdn_cfg_get_ports_string(char *ports);
Modified: trunk/channels/misdn_config.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn_config.c?rev=36865&r1=36864&r2=36865&view=diff
==============================================================================
--- trunk/channels/misdn_config.c (original)
+++ trunk/channels/misdn_config.c Mon Jul 3 11:41:43 2006
@@ -84,62 +84,225 @@
enum misdn_cfg_type type;
char def[BUFFERSIZE];
int boolint_def;
+ char desc[BUFFERSIZE];
};
+
+static const char ports_description[] =
+ "Define your ports, e.g. 1,2 (depends on mISDN-driver loading order).";
+
static const struct misdn_cfg_spec port_spec[] = {
- { "name", MISDN_CFG_GROUPNAME, MISDN_CTYPE_STR, "default", NONE },
- { "allowed_bearers", MISDN_CFG_ALLOWED_BEARERS, MISDN_CTYPE_STR, "all", NONE },
- { "rxgain", MISDN_CFG_RXGAIN, MISDN_CTYPE_INT, "0", NONE },
- { "txgain", MISDN_CFG_TXGAIN, MISDN_CTYPE_INT, "0", NONE },
- { "te_choose_channel", MISDN_CFG_TE_CHOOSE_CHANNEL, MISDN_CTYPE_BOOL, "no", NONE },
- { "far_alerting", MISDN_CFG_FAR_ALERTING, MISDN_CTYPE_BOOL, "no", NONE },
- { "pmp_l1_check", MISDN_CFG_PMP_L1_CHECK, MISDN_CTYPE_BOOL, "yes", NONE },
- { "hdlc", MISDN_CFG_HDLC, MISDN_CTYPE_BOOL, "no", NONE },
- { "context", MISDN_CFG_CONTEXT, MISDN_CTYPE_STR, "default", NONE },
- { "language", MISDN_CFG_LANGUAGE, MISDN_CTYPE_STR, "en", NONE },
- { "musicclass", MISDN_CFG_MUSICCLASS, MISDN_CTYPE_STR, "default", NONE },
- { "callerid", MISDN_CFG_CALLERID, MISDN_CTYPE_STR, "", NONE },
- { "method", MISDN_CFG_METHOD, MISDN_CTYPE_STR, "standard", NONE },
- { "dialplan", MISDN_CFG_DIALPLAN, MISDN_CTYPE_INT, "0", NONE },
- { "localdialplan", MISDN_CFG_LOCALDIALPLAN, MISDN_CTYPE_INT, "0", NONE },
- { "cpndialplan", MISDN_CFG_CPNDIALPLAN, MISDN_CTYPE_INT, "0", NONE },
- { "nationalprefix", MISDN_CFG_NATPREFIX, MISDN_CTYPE_STR, "0", NONE },
- { "internationalprefix", MISDN_CFG_INTERNATPREFIX, MISDN_CTYPE_STR, "00", NONE },
- { "presentation", MISDN_CFG_PRES, MISDN_CTYPE_INT, "-1", NONE },
- { "screen", MISDN_CFG_SCREEN, MISDN_CTYPE_INT, "-1", NONE },
- { "always_immediate", MISDN_CFG_ALWAYS_IMMEDIATE, MISDN_CTYPE_BOOL, "no", NONE },
- { "immediate", MISDN_CFG_IMMEDIATE, MISDN_CTYPE_BOOL, "no", NONE },
- { "senddtmf", MISDN_CFG_SENDDTMF, MISDN_CTYPE_BOOL, "no", NONE },
- { "hold_allowed", MISDN_CFG_HOLD_ALLOWED, MISDN_CTYPE_BOOL, "no", NONE },
- { "early_bconnect", MISDN_CFG_EARLY_BCONNECT, MISDN_CTYPE_BOOL, "yes", NONE },
- { "incoming_early_audio", MISDN_CFG_INCOMING_EARLY_AUDIO, MISDN_CTYPE_BOOL, "no", NONE },
- { "echocancel", MISDN_CFG_ECHOCANCEL, MISDN_CTYPE_BOOLINT, "0", 128 },
- { "echocancelwhenbridged", MISDN_CFG_ECHOCANCELWHENBRIDGED, MISDN_CTYPE_BOOL, "no", NONE },
- { "echotraining", MISDN_CFG_ECHOTRAINING, MISDN_CTYPE_BOOLINT, "0", 2000 },
- { "need_more_infos", MISDN_CFG_NEED_MORE_INFOS, MISDN_CTYPE_BOOL, "0", NONE },
- { "jitterbuffer", MISDN_CFG_JITTERBUFFER, MISDN_CTYPE_INT, "4000", NONE },
- { "jitterbuffer_upper_threshold", MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, MISDN_CTYPE_INT, "0", NONE },
- { "callgroup", MISDN_CFG_CALLGROUP, MISDN_CTYPE_ASTGROUP, NO_DEFAULT, NONE },
- { "pickupgroup", MISDN_CFG_PICKUPGROUP, MISDN_CTYPE_ASTGROUP, NO_DEFAULT, NONE },
- { "max_incoming", MISDN_CFG_MAX_IN, MISDN_CTYPE_INT, "-1", NONE },
- { "max_outgoing", MISDN_CFG_MAX_OUT, MISDN_CTYPE_INT, "-1", NONE },
- { "msns", MISDN_CFG_MSNS, MISDN_CTYPE_MSNLIST, NO_DEFAULT, NONE }
+ { "name", MISDN_CFG_GROUPNAME, MISDN_CTYPE_STR, "default", NONE,
+ "Name of the portgroup." },
+ { "allowed_bearers", MISDN_CFG_ALLOWED_BEARERS, MISDN_CTYPE_STR, "all", NONE,
+ "Here you can define which bearers should be allowed." },
+ { "rxgain", MISDN_CFG_RXGAIN, MISDN_CTYPE_INT, "0", NONE,
+ "Set this between -8 and 8 to change the RX Gain." },
+ { "txgain", MISDN_CFG_TXGAIN, MISDN_CTYPE_INT, "0", NONE,
+ "Set this between -8 and 8 to change the TX Gain." },
+ { "te_choose_channel", MISDN_CFG_TE_CHOOSE_CHANNEL, MISDN_CTYPE_BOOL, "no", NONE,
+ "Some telcos espacially in NL seem to need this set to yes,\n"
+ "\talso in switzerland this seems to be important." },
+ { "far_alerting", MISDN_CFG_FAR_ALERTING, MISDN_CTYPE_BOOL, "no", NONE,
+ "If we should generate ringing for chan_sip and others." },
+ { "pmp_l1_check", MISDN_CFG_PMP_L1_CHECK, MISDN_CTYPE_BOOL, "yes", NONE,
+ "This option defines, if chan_misdn should check the L1 on a PMP\n"
+ "\tbefore makeing a group call on it. The L1 may go down for PMP Ports\n"
+ "\tso we might need this.\n"
+ "\tBut be aware! a broken or plugged off cable might be used for a group call\n"
+ "\tas well, since chan_misdn has no chance to distinguish if the L1 is down\n"
+ "\tbecause of a lost Link or because the Provider shut it down..." },
+ { "hdlc", MISDN_CFG_HDLC, MISDN_CTYPE_BOOL, "no", NONE,
+ "Set this to yes, if you want to bridge a mISDN data channel to\n"
+ "\tanother channel type or to an application." },
+ { "context", MISDN_CFG_CONTEXT, MISDN_CTYPE_STR, "default", NONE,
+ "Context to use for incoming calls." },
+ { "language", MISDN_CFG_LANGUAGE, MISDN_CTYPE_STR, "en", NONE,
+ "Language." },
+ { "musicclass", MISDN_CFG_MUSICCLASS, MISDN_CTYPE_STR, "default", NONE,
+ "Sets the musiconhold class." },
+ { "callerid", MISDN_CFG_CALLERID, MISDN_CTYPE_STR, "", NONE,
+ "Sets the caller ID." },
+ { "method", MISDN_CFG_METHOD, MISDN_CTYPE_STR, "standard", NONE,
+ "Sets the method to use for channel selection:\n"
+ "\t standard - always choose the first free channel with the lowest number\n"
+ "\t round_robin - use the round robin algorithm to select a channel. use this\n"
+ "\t if you want to balance your load." },
+ { "dialplan", MISDN_CFG_DIALPLAN, MISDN_CTYPE_INT, "0", NONE,
+ "Dialplan means Type Of Number in ISDN Terms (for outgoing calls)\n"
+ "\n"
+ "\tThere are different types of the dialplan:\n"
+ "\n"
+ "\tdialplan -> outgoing Number\n"
+ "\tlocaldialplan -> callerid\n"
+ "\tcpndialplan -> connected party number\n"
+ "\n"
+ "\tdialplan options:\n"
+ "\n"
+ "\t0 - unknown\n"
+ "\t1 - International\n"
+ "\t2 - National\n"
+ "\t4 - Subscriber\n"
+ "\n"
+ "\tThis setting is used for outgoing calls." },
+ { "localdialplan", MISDN_CFG_LOCALDIALPLAN, MISDN_CTYPE_INT, "0", NONE,
+ "Dialplan means Type Of Number in ISDN Terms (for outgoing calls)\n"
+ "\n"
+ "\tThere are different types of the dialplan:\n"
+ "\n"
+ "\tdialplan -> outgoing Number\n"
+ "\tlocaldialplan -> callerid\n"
+ "\tcpndialplan -> connected party number\n"
+ "\n"
+ "\tdialplan options:\n"
+ "\n"
+ "\t0 - unknown\n"
+ "\t1 - International\n"
+ "\t2 - National\n"
+ "\t4 - Subscriber\n"
+ "\n"
+ "\tThis setting is used for outgoing calls" },
+ { "cpndialplan", MISDN_CFG_CPNDIALPLAN, MISDN_CTYPE_INT, "0", NONE,
+ "Dialplan means Type Of Number in ISDN Terms (for outgoing calls)\n"
+ "\n"
+ "\tThere are different types of the dialplan:\n"
+ "\n"
+ "\tdialplan -> outgoing Number\n"
+ "\tlocaldialplan -> callerid\n"
+ "\tcpndialplan -> connected party number\n"
+ "\n"
+ "\tdialplan options:\n"
+ "\n"
+ "\t0 - unknown\n"
+ "\t1 - International\n"
+ "\t2 - National\n"
+ "\t4 - Subscriber\n"
+ "\n"
+ "\tThis setting is used for outgoing calls." },
+ { "nationalprefix", MISDN_CFG_NATPREFIX, MISDN_CTYPE_STR, "0", NONE,
+ "Prefix for national, this is put before the\n"
+ "\toad if an according dialplan is set by the other end." },
+ { "internationalprefix", MISDN_CFG_INTERNATPREFIX, MISDN_CTYPE_STR, "00", NONE,
+ "Prefix for international, this is put before the\n"
+ "\toad if an according dialplan is set by the other end." },
+ { "presentation", MISDN_CFG_PRES, MISDN_CTYPE_INT, "-1", NONE,
+ "These (presentation and screen) are the exact isdn screening and presentation\n"
+ "\tindicators.\n"
+ "\tIf -1 is given for both values, the presentation indicators are used from\n"
+ "\tAsterisks SetCallerPres application.\n"
+ "\n"
+ "\tscreen=0, presentation=0 -> callerid presented not screened\n"
+ "\tscreen=1, presentation=1 -> callerid presented but screened (the remote end doesn't see it!)" },
+ { "screen", MISDN_CFG_SCREEN, MISDN_CTYPE_INT, "-1", NONE,
+ "These (presentation and screen) are the exact isdn screening and presentation\n"
+ "\tindicators.\n"
+ "\tIf -1 is given for both values, the presentation indicators are used from\n"
+ "\tAsterisks SetCallerPres application.\n"
+ "\n"
+ "\tscreen=0, presentation=0 -> callerid presented not screened\n"
+ "\tscreen=1, presentation=1 -> callerid presented but screened (the remote end doesn't see it!)" },
+ { "always_immediate", MISDN_CFG_ALWAYS_IMMEDIATE, MISDN_CTYPE_BOOL, "no", NONE,
+ "Enable this to get into the s dialplan-extension.\n"
+ "\tThere you can use DigitTimeout if you can't or don't want to use\n"
+ "\tisdn overlap dial.\n"
+ "\tNOTE: This will jump into the s extension for every exten!" },
+ { "immediate", MISDN_CFG_IMMEDIATE, MISDN_CTYPE_BOOL, "no", NONE,
+ "Enable this if you want callers which called exactly the base\n"
+ "\tnumber (so no extension is set) to jump into the s extension.\n"
+ "\tIf the user dials something more, it jumps to the correct extension\n"
+ "\tinstead." },
+ { "senddtmf", MISDN_CFG_SENDDTMF, MISDN_CTYPE_BOOL, "no", NONE,
+ "Enable this if we should produce DTMF Tones ourselves." },
+ { "hold_allowed", MISDN_CFG_HOLD_ALLOWED, MISDN_CTYPE_BOOL, "no", NONE,
+ "Enable this to have support for hold and retrieve.\n" },
+ { "early_bconnect", MISDN_CFG_EARLY_BCONNECT, MISDN_CTYPE_BOOL, "yes", NONE,
+ "Disable this if you don't mind correct handling of Progress Indicators." },
+ { "incoming_early_audio", MISDN_CFG_INCOMING_EARLY_AUDIO, MISDN_CTYPE_BOOL, "no", NONE,
+ "Turn this on if you like to send Tone Indications to a Incoming\n"
+ "\tisdn channel on a TE Port. Rarely used, only if the Telco allows\n"
+ "\tyou to send indications by yourself, normally the Telco sends the\n"
+ "\tindications to the remote party." },
+ { "echocancel", MISDN_CFG_ECHOCANCEL, MISDN_CTYPE_BOOLINT, "0", 128,
+ "This enables echocancellation, with the given number of taps.\n"
+ "\tBe aware, move this setting only to outgoing portgroups!\n"
+ "\tA value of zero turns echocancellation off.\n"
+ "\n"
+ "\tPossible values are: 0,32,64,128,256,yes(=128),no(=0)" },
+ { "echocancelwhenbridged", MISDN_CFG_ECHOCANCELWHENBRIDGED, MISDN_CTYPE_BOOL, "no", NONE,
+ "This disables echocancellation when the call is bridged between\n"
+ "\tmISDN channels" },
+ { "echotraining", MISDN_CFG_ECHOTRAINING, MISDN_CTYPE_BOOLINT, "0", 2000,
+ "Set this to no to disable echotraining. You can enter a number > 10.\n"
+ "\tThe value is a multiple of 0.125 ms.\n"
+ "\n"
+ "\tyes = 2000\n"
+ "\tno = 0" },
+ { "need_more_infos", MISDN_CFG_NEED_MORE_INFOS, MISDN_CTYPE_BOOL, "0", NONE,
+ "Send Setup_Acknowledge on incoming calls anyway (instead of PROCEEDING),\n"
+ "\tthis requests additional Infos, so we can waitfordigits without much\n"
+ "\tissues. This works only for PTP Ports" },
+ { "jitterbuffer", MISDN_CFG_JITTERBUFFER, MISDN_CTYPE_INT, "4000", NONE,
+ "The jitterbuffer." },
+ { "jitterbuffer_upper_threshold", MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, MISDN_CTYPE_INT, "0", NONE,
+ "Change this threshold to enable dejitter functionality." },
+ { "callgroup", MISDN_CFG_CALLGROUP, MISDN_CTYPE_ASTGROUP, NO_DEFAULT, NONE,
+ "Callgroup." },
+ { "pickupgroup", MISDN_CFG_PICKUPGROUP, MISDN_CTYPE_ASTGROUP, NO_DEFAULT, NONE,
+ "Pickupgroup." },
+ { "max_incoming", MISDN_CFG_MAX_IN, MISDN_CTYPE_INT, "-1", NONE,
+ "Defines the maximum amount of incoming calls per port for this group.\n"
+ "\tCalls which exceed the maximum will be marked with the channel varible\n"
+ "\tMAX_OVERFLOW. It will contain the amount of overflowed calls" },
+ { "max_outgoing", MISDN_CFG_MAX_OUT, MISDN_CTYPE_INT, "-1", NONE,
+ "Defines the maximum amount of outgoing calls per port for this group\n"
+ "\texceeding calls will be rejected" },
+ { "faxdetect", MISDN_CFG_FAXDETECT, MISDN_CTYPE_STR, "no", NONE,
+ "Context to jump into if we detect an incoming fax." },
+ { "msns", MISDN_CFG_MSNS, MISDN_CTYPE_MSNLIST, NO_DEFAULT, NONE,
+ "MSN's for TE ports, listen on those numbers on the above ports, and\n"
+ "\tindicate the incoming calls to Asterisk.\n"
+ "\tHere you can give a comma seperated list, or simply an '*' for any msn." },
};
static const struct misdn_cfg_spec gen_spec[] = {
- { "debug", MISDN_GEN_DEBUG, MISDN_CTYPE_INT, "0", NONE },
- { "misdn_init", MISDN_GEN_MISDN_INIT, MISDN_CTYPE_STR, "/etc/misdn-init.conf", NONE },
- { "tracefile", MISDN_GEN_TRACEFILE, MISDN_CTYPE_STR, "/var/log/asterisk/misdn.log", NONE },
- { "bridging", MISDN_GEN_BRIDGING, MISDN_CTYPE_BOOL, "yes", NONE },
- { "stop_tone_after_first_digit", MISDN_GEN_STOP_TONE, MISDN_CTYPE_BOOL, "yes", NONE },
- { "append_digits2exten", MISDN_GEN_APPEND_DIGITS2EXTEN, MISDN_CTYPE_BOOL, "yes", NONE },
- { "dynamic_crypt", MISDN_GEN_DYNAMIC_CRYPT, MISDN_CTYPE_BOOL, "no", NONE },
- { "crypt_prefix", MISDN_GEN_CRYPT_PREFIX, MISDN_CTYPE_STR, NO_DEFAULT, NONE },
- { "crypt_keys", MISDN_GEN_CRYPT_KEYS, MISDN_CTYPE_STR, NO_DEFAULT, NONE },
- { "l1watcher_timeout", MISDN_GEN_L1_TIMEOUT, MISDN_CTYPE_INT, "0", NONE },
- { "ntdebugflags", MISDN_GEN_NTDEBUGFLAGS, MISDN_CTYPE_INT, "0", NONE },
- { "ntdebugfile", MISDN_GEN_NTDEBUGFILE, MISDN_CTYPE_STR, "/var/log/misdn-nt.log", NONE }
+ { "debug", MISDN_GEN_DEBUG, MISDN_CTYPE_INT, "0", NONE,
+ "Sets the debugging flag:\n"
+ "\t0 - No Debug\n"
+ "\t1 - mISDN Messages and * - Messages, and * - State changes\n"
+ "\t2 - Messages + Message specific Informations (e.g. bearer capability)\n"
+ "\t3 - very Verbose, the above + lots of Driver specific infos\n"
+ "\t4 - even more Verbose than 3" },
+ { "misdn_init", MISDN_GEN_MISDN_INIT, MISDN_CTYPE_STR, "/etc/misdn-init.conf", NONE,
+ "Set the path to the misdn-init.conf (for nt_ptp mode checking)." },
+ { "tracefile", MISDN_GEN_TRACEFILE, MISDN_CTYPE_STR, "/var/log/asterisk/misdn.log", NONE,
+ "Set the path to the massively growing trace file, if you want that." },
+ { "bridging", MISDN_GEN_BRIDGING, MISDN_CTYPE_BOOL, "yes", NONE,
+ "Set this to yes if you want mISDN_dsp to bridge the calls in HW." },
+ { "stop_tone_after_first_digit", MISDN_GEN_STOP_TONE, MISDN_CTYPE_BOOL, "yes", NONE,
+ "Stops dialtone after getting first digit on NT Port." },
+ { "append_digits2exten", MISDN_GEN_APPEND_DIGITS2EXTEN, MISDN_CTYPE_BOOL, "yes", NONE,
+ "Wether to append overlapdialed Digits to Extension or not." },
+ { "dynamic_crypt", MISDN_GEN_DYNAMIC_CRYPT, MISDN_CTYPE_BOOL, "no", NONE,
+ "Wether to look out for dynamic crypting attempts." },
+ { "crypt_prefix", MISDN_GEN_CRYPT_PREFIX, MISDN_CTYPE_STR, NO_DEFAULT, NONE,
+ "What is used for crypting Protocol." },
+ { "crypt_keys", MISDN_GEN_CRYPT_KEYS, MISDN_CTYPE_STR, NO_DEFAULT, NONE,
+ "Keys for cryption, you reference them in the dialplan\n"
+ "\tLater also in dynamic encr." },
+ { "l1watcher_timeout", MISDN_GEN_L1_TIMEOUT, MISDN_CTYPE_INT, "0", NONE,
+ "Watches the L1s of every port. If one l1 is down it tries to\n"
+ "\tget it up. The timeout is given in seconds. with 0 as value it\n"
+ "\tdoes not watch the l1 at all\n"
+ "\n"
+ "\tThis option is only read at loading time of chan_misdn, which\n"
+ "\tmeans you need to unload and load chan_misdn to change the value,\n"
+ "\tan Asterisk restart should do the trick." },
+ { "ntdebugflags", MISDN_GEN_NTDEBUGFLAGS, MISDN_CTYPE_INT, "0", NONE,
+ "no description yet"},
+ { "ntdebugfile", MISDN_GEN_NTDEBUGFILE, MISDN_CTYPE_STR, "/var/log/misdn-nt.log", NONE,
+ "no description yet" }
};
+
/* array of port configs, default is at position 0. */
static union misdn_cfg_pt **port_cfg;
@@ -321,6 +484,87 @@
misdn_cfg_unlock();
}
+enum misdn_cfg_elements misdn_cfg_get_elem (char *name)
+{
+ int pos;
+
+ /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */
+ if (!strcmp(name, "ports"))
+ return MISDN_CFG_GROUPNAME;
+ if (!strcmp(name, "name"))
+ return MISDN_CFG_FIRST;
+
+ pos = get_cfg_position (name, PORT_CFG);
+ if (pos >= 0)
+ return port_spec[pos].elem;
+
+ pos = get_cfg_position (name, GEN_CFG);
+ if (pos >= 0)
+ return gen_spec[pos].elem;
+
+ return MISDN_CFG_FIRST;
+}
+
+void misdn_cfg_get_name (enum misdn_cfg_elements elem, void *buf, int bufsize)
+{
+ struct misdn_cfg_spec *spec = NULL;
+ int place = map[elem];
+
+ /* the ptp hack */
+ if (elem == MISDN_CFG_PTP) {
+ memset(buf, 0, 1);
+ return;
+ }
+
+ /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */
+ if (elem == MISDN_CFG_GROUPNAME) {
+ if (!snprintf(buf, bufsize, "ports"))
+ memset(buf, 0, 1);
+ return;
+ }
+
+ if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST))
+ spec = (struct misdn_cfg_spec *)port_spec;
+ else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST))
+ spec = (struct misdn_cfg_spec *)gen_spec;
+
+ if (!spec || !memccpy(buf, spec[place].name, 0, bufsize))
+ memset(buf, 0, 1);
+}
+
+void misdn_cfg_get_desc (enum misdn_cfg_elements elem, void *buf, int bufsize, void *buf_default, int bufsize_default)
+{
+ int place = map[elem];
+ struct misdn_cfg_spec *spec = NULL;
+
+ /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */
+ if (elem == MISDN_CFG_GROUPNAME) {
+ if (!memccpy(buf, ports_description, 0, bufsize))
+ memset(buf, 0, 1);
+ if (buf_default && bufsize_default)
+ memset(buf_default, 0, 1);
+ return;
+ }
+
+ if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST))
+ spec = (struct misdn_cfg_spec *)port_spec;
+ else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST))
+ spec = (struct misdn_cfg_spec *)gen_spec;
+
+ if (!spec || !spec[place].desc)
+ memset(buf, 0, 1);
+ else {
+ if (!memccpy(buf, spec[place].desc, 0, bufsize))
+ memset(buf, 0, 1);
+ if (buf_default && bufsize) {
+ if (!strcmp(spec[place].def, NO_DEFAULT))
+ memset(buf_default, 0, 1);
+ else if (!memccpy(buf_default, spec[place].def, 0, bufsize_default))
+ memset(buf_default, 0, 1);
+ }
+ }
+}
+
int misdn_cfg_is_msn_valid (int port, char* msn)
{
int re = 0;
@@ -348,7 +592,9 @@
int misdn_cfg_is_port_valid (int port)
{
- return (port >= 1 && port <= max_ports);
+ int gn = map[MISDN_CFG_GROUPNAME];
+
+ return (port >= 1 && port <= max_ports && port_cfg[port][gn].str);
}
int misdn_cfg_is_group_method (char *group, enum misdn_cfg_method meth)
More information about the svn-commits
mailing list