Mon Oct 8 12:39:15 2012

Asterisk developer's documentation


chan_misdn_config.h File Reference

Interface to mISDN - Config. More...

Go to the source code of this file.

Defines

#define BUFFERSIZE   512

Enumerations

enum  misdn_cfg_elements {
  MISDN_CFG_FIRST = 0, MISDN_CFG_GROUPNAME, MISDN_CFG_ALLOWED_BEARERS, MISDN_CFG_FAR_ALERTING,
  MISDN_CFG_RXGAIN, MISDN_CFG_TXGAIN, MISDN_CFG_TE_CHOOSE_CHANNEL, MISDN_CFG_PMP_L1_CHECK,
  MISDN_CFG_REJECT_CAUSE, MISDN_CFG_ALARM_BLOCK, MISDN_CFG_HDLC, MISDN_CFG_CONTEXT,
  MISDN_CFG_LANGUAGE, MISDN_CFG_MUSICCLASS, MISDN_CFG_CALLERID, MISDN_CFG_INCOMING_CALLERID_TAG,
  MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, MISDN_CFG_METHOD, MISDN_CFG_DIALPLAN, MISDN_CFG_LOCALDIALPLAN,
  MISDN_CFG_CPNDIALPLAN, MISDN_CFG_TON_PREFIX_UNKNOWN, MISDN_CFG_TON_PREFIX_INTERNATIONAL, MISDN_CFG_TON_PREFIX_NATIONAL,
  MISDN_CFG_TON_PREFIX_NETWORK_SPECIFIC, MISDN_CFG_TON_PREFIX_SUBSCRIBER, MISDN_CFG_TON_PREFIX_ABBREVIATED, MISDN_CFG_PRES,
  MISDN_CFG_SCREEN, MISDN_CFG_DISPLAY_CONNECTED, MISDN_CFG_DISPLAY_SETUP, MISDN_CFG_ALWAYS_IMMEDIATE,
  MISDN_CFG_NODIALTONE, MISDN_CFG_IMMEDIATE, MISDN_CFG_SENDDTMF, MISDN_CFG_ASTDTMF,
  MISDN_CFG_HOLD_ALLOWED, MISDN_CFG_EARLY_BCONNECT, MISDN_CFG_INCOMING_EARLY_AUDIO, MISDN_CFG_ECHOCANCEL,
  MISDN_CFG_CC_REQUEST_RETENTION, MISDN_CFG_OUTGOING_COLP, MISDN_CFG_NEED_MORE_INFOS, MISDN_CFG_NOAUTORESPOND_ON_SETUP,
  MISDN_CFG_NTTIMEOUT, MISDN_CFG_BRIDGING, MISDN_CFG_JITTERBUFFER, MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD,
  MISDN_CFG_CALLGROUP, MISDN_CFG_PICKUPGROUP, MISDN_CFG_MAX_IN, MISDN_CFG_MAX_OUT,
  MISDN_CFG_L1_TIMEOUT, MISDN_CFG_OVERLAP_DIAL, MISDN_CFG_MSNS, MISDN_CFG_FAXDETECT,
  MISDN_CFG_FAXDETECT_CONTEXT, MISDN_CFG_FAXDETECT_TIMEOUT, MISDN_CFG_PTP, MISDN_CFG_LAST,
  MISDN_GEN_FIRST, MISDN_GEN_MISDN_INIT, MISDN_GEN_DEBUG, MISDN_GEN_TRACEFILE,
  MISDN_GEN_BRIDGING, MISDN_GEN_STOP_TONE, MISDN_GEN_APPEND_DIGITS2EXTEN, MISDN_GEN_DYNAMIC_CRYPT,
  MISDN_GEN_CRYPT_PREFIX, MISDN_GEN_CRYPT_KEYS, MISDN_GEN_NTKEEPCALLS, MISDN_GEN_NTDEBUGFLAGS,
  MISDN_GEN_NTDEBUGFILE, MISDN_GEN_LAST
}
enum  misdn_cfg_method { METHOD_STANDARD = 0, METHOD_ROUND_ROBIN, METHOD_STANDARD_DEC }

Functions

void misdn_cfg_destroy (void)
void misdn_cfg_get (int port, enum misdn_cfg_elements elem, void *buf, int bufsize)
void misdn_cfg_get_config_string (int port, enum misdn_cfg_elements elem, char *buf, int bufsize)
void misdn_cfg_get_desc (enum misdn_cfg_elements elem, void *buf, int bufsize, void *buf_default, int bufsize_default)
enum misdn_cfg_elements misdn_cfg_get_elem (const char *name)
void misdn_cfg_get_name (enum misdn_cfg_elements elem, void *buf, int bufsize)
int misdn_cfg_get_next_port (int port)
int misdn_cfg_get_next_port_spin (int port)
void misdn_cfg_get_ports_string (char *ports)
 Generate a comma separated list of all active ports.
int misdn_cfg_init (int max_ports, int reload)
int misdn_cfg_is_group_method (char *group, enum misdn_cfg_method meth)
int misdn_cfg_is_msn_valid (int port, char *msn)
int misdn_cfg_is_port_valid (int port)
void misdn_cfg_reload (void)
void misdn_cfg_update_ptp (void)
ast_jb_confmisdn_get_global_jbconf (void)


Detailed Description

Interface to mISDN - Config.

Author:
Christian Richter <crich@beronet.com>

Definition in file chan_misdn_config.h.


Define Documentation

#define BUFFERSIZE   512

Definition at line 25 of file chan_misdn_config.h.

Referenced by _build_port_config(), complete_show_config(), handle_cli_misdn_show_config(), load_module(), misdn_cfg_get_config_string(), misdn_cfg_update_ptp(), misdn_check_l2l1(), misdn_request(), process_ast_dsp(), read_config(), and show_config_description().


Enumeration Type Documentation

enum misdn_cfg_elements

Enumerator:
MISDN_CFG_FIRST 
MISDN_CFG_GROUPNAME 
MISDN_CFG_ALLOWED_BEARERS 
MISDN_CFG_FAR_ALERTING 
MISDN_CFG_RXGAIN 
MISDN_CFG_TXGAIN 
MISDN_CFG_TE_CHOOSE_CHANNEL 
MISDN_CFG_PMP_L1_CHECK 
MISDN_CFG_REJECT_CAUSE 
MISDN_CFG_ALARM_BLOCK 
MISDN_CFG_HDLC 
MISDN_CFG_CONTEXT 
MISDN_CFG_LANGUAGE 
MISDN_CFG_MUSICCLASS 
MISDN_CFG_CALLERID 
MISDN_CFG_INCOMING_CALLERID_TAG 
MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG 
MISDN_CFG_METHOD 
MISDN_CFG_DIALPLAN 
MISDN_CFG_LOCALDIALPLAN 
MISDN_CFG_CPNDIALPLAN 
MISDN_CFG_TON_PREFIX_UNKNOWN 
MISDN_CFG_TON_PREFIX_INTERNATIONAL 
MISDN_CFG_TON_PREFIX_NATIONAL 
MISDN_CFG_TON_PREFIX_NETWORK_SPECIFIC 
MISDN_CFG_TON_PREFIX_SUBSCRIBER 
MISDN_CFG_TON_PREFIX_ABBREVIATED 
MISDN_CFG_PRES 
MISDN_CFG_SCREEN 
MISDN_CFG_DISPLAY_CONNECTED 
MISDN_CFG_DISPLAY_SETUP 
MISDN_CFG_ALWAYS_IMMEDIATE 
MISDN_CFG_NODIALTONE 
MISDN_CFG_IMMEDIATE 
MISDN_CFG_SENDDTMF 
MISDN_CFG_ASTDTMF 
MISDN_CFG_HOLD_ALLOWED 
MISDN_CFG_EARLY_BCONNECT 
MISDN_CFG_INCOMING_EARLY_AUDIO 
MISDN_CFG_ECHOCANCEL 
MISDN_CFG_CC_REQUEST_RETENTION 
MISDN_CFG_OUTGOING_COLP 
MISDN_CFG_NEED_MORE_INFOS 
MISDN_CFG_NOAUTORESPOND_ON_SETUP 
MISDN_CFG_NTTIMEOUT 
MISDN_CFG_BRIDGING 
MISDN_CFG_JITTERBUFFER 
MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD 
MISDN_CFG_CALLGROUP 
MISDN_CFG_PICKUPGROUP 
MISDN_CFG_MAX_IN 
MISDN_CFG_MAX_OUT 
MISDN_CFG_L1_TIMEOUT 
MISDN_CFG_OVERLAP_DIAL 
MISDN_CFG_MSNS 
MISDN_CFG_FAXDETECT 
MISDN_CFG_FAXDETECT_CONTEXT 
MISDN_CFG_FAXDETECT_TIMEOUT 
MISDN_CFG_PTP 
MISDN_CFG_LAST 
MISDN_GEN_FIRST 
MISDN_GEN_MISDN_INIT 
MISDN_GEN_DEBUG 
MISDN_GEN_TRACEFILE 
MISDN_GEN_BRIDGING 
MISDN_GEN_STOP_TONE 
MISDN_GEN_APPEND_DIGITS2EXTEN 
MISDN_GEN_DYNAMIC_CRYPT 
MISDN_GEN_CRYPT_PREFIX 
MISDN_GEN_CRYPT_KEYS 
MISDN_GEN_NTKEEPCALLS 
MISDN_GEN_NTDEBUGFLAGS 
MISDN_GEN_NTDEBUGFILE 
MISDN_GEN_LAST 

Definition at line 27 of file chan_misdn_config.h.

00027                         {
00028 
00029    /* port config items */
00030    MISDN_CFG_FIRST = 0,
00031    MISDN_CFG_GROUPNAME,           /* char[] */
00032    MISDN_CFG_ALLOWED_BEARERS,           /* char[] */
00033    MISDN_CFG_FAR_ALERTING,        /* int (bool) */
00034    MISDN_CFG_RXGAIN,              /* int */
00035    MISDN_CFG_TXGAIN,              /* int */
00036    MISDN_CFG_TE_CHOOSE_CHANNEL,   /* int (bool) */
00037    MISDN_CFG_PMP_L1_CHECK,        /* int (bool) */
00038    MISDN_CFG_REJECT_CAUSE,    /* int */
00039    MISDN_CFG_ALARM_BLOCK,        /* int (bool) */
00040    MISDN_CFG_HDLC,                /* int (bool) */
00041    MISDN_CFG_CONTEXT,             /* char[] */
00042    MISDN_CFG_LANGUAGE,            /* char[] */
00043    MISDN_CFG_MUSICCLASS,            /* char[] */
00044    MISDN_CFG_CALLERID,            /* char[] */
00045    MISDN_CFG_INCOMING_CALLERID_TAG, /* char[] */
00046    MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, /* int (bool) */
00047    MISDN_CFG_METHOD,              /* char[] */
00048    MISDN_CFG_DIALPLAN,            /* int */
00049    MISDN_CFG_LOCALDIALPLAN,       /* int */
00050    MISDN_CFG_CPNDIALPLAN,       /* int */
00051    MISDN_CFG_TON_PREFIX_UNKNOWN,         /* char[] */
00052    MISDN_CFG_TON_PREFIX_INTERNATIONAL,   /* char[] */
00053    MISDN_CFG_TON_PREFIX_NATIONAL,        /* char[] */
00054    MISDN_CFG_TON_PREFIX_NETWORK_SPECIFIC,/* char[] */
00055    MISDN_CFG_TON_PREFIX_SUBSCRIBER,      /* char[] */
00056    MISDN_CFG_TON_PREFIX_ABBREVIATED,     /* char[] */
00057    MISDN_CFG_PRES,                /* int */
00058    MISDN_CFG_SCREEN,              /* int */
00059    MISDN_CFG_DISPLAY_CONNECTED,   /* int */
00060    MISDN_CFG_DISPLAY_SETUP,       /* int */
00061    MISDN_CFG_ALWAYS_IMMEDIATE,    /* int (bool) */
00062    MISDN_CFG_NODIALTONE,    /* int (bool) */
00063    MISDN_CFG_IMMEDIATE,           /* int (bool) */
00064    MISDN_CFG_SENDDTMF,           /* int (bool) */
00065    MISDN_CFG_ASTDTMF,            /* int (bool) */
00066    MISDN_CFG_HOLD_ALLOWED,        /* int (bool) */
00067    MISDN_CFG_EARLY_BCONNECT,      /* int (bool) */
00068    MISDN_CFG_INCOMING_EARLY_AUDIO,      /* int (bool) */
00069    MISDN_CFG_ECHOCANCEL,          /* int */
00070    MISDN_CFG_CC_REQUEST_RETENTION,/* bool */
00071    MISDN_CFG_OUTGOING_COLP,       /* int */
00072 #ifdef MISDN_1_2
00073    MISDN_CFG_PIPELINE,      /* char[] */
00074 #endif
00075 
00076 #ifdef WITH_BEROEC
00077    MISDN_CFG_BNECHOCANCEL,
00078    MISDN_CFG_BNEC_ANTIHOWL,
00079    MISDN_CFG_BNEC_NLP,
00080    MISDN_CFG_BNEC_ZEROCOEFF,
00081    MISDN_CFG_BNEC_TD,
00082    MISDN_CFG_BNEC_ADAPT,
00083 #endif
00084    MISDN_CFG_NEED_MORE_INFOS,     /* bool */
00085    MISDN_CFG_NOAUTORESPOND_ON_SETUP,     /* bool */
00086    MISDN_CFG_NTTIMEOUT,       /* bool */
00087    MISDN_CFG_BRIDGING,              /* bool */
00088    MISDN_CFG_JITTERBUFFER,             /* int */
00089    MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD,              /* int */
00090    MISDN_CFG_CALLGROUP,           /* ast_group_t */
00091    MISDN_CFG_PICKUPGROUP,         /* ast_group_t */
00092    MISDN_CFG_MAX_IN,              /* int */
00093    MISDN_CFG_MAX_OUT,              /* int */
00094    MISDN_CFG_L1_TIMEOUT,          /* int */
00095    MISDN_CFG_OVERLAP_DIAL,    /* int (bool)*/
00096    MISDN_CFG_MSNS,                /* char[] */
00097    MISDN_CFG_FAXDETECT,           /* char[] */
00098    MISDN_CFG_FAXDETECT_CONTEXT,   /* char[] */
00099    MISDN_CFG_FAXDETECT_TIMEOUT,   /* int */
00100    MISDN_CFG_PTP,                 /* int (bool) */
00101    MISDN_CFG_LAST,
00102 
00103    /* general config items */
00104    MISDN_GEN_FIRST,
00105 #ifndef MISDN_1_2
00106    MISDN_GEN_MISDN_INIT,           /* char[] */
00107 #endif
00108    MISDN_GEN_DEBUG,               /* int */
00109    MISDN_GEN_TRACEFILE,           /* char[] */
00110    MISDN_GEN_BRIDGING,            /* int (bool) */
00111    MISDN_GEN_STOP_TONE,           /* int (bool) */
00112    MISDN_GEN_APPEND_DIGITS2EXTEN, /* int (bool) */
00113    MISDN_GEN_DYNAMIC_CRYPT,       /* int (bool) */
00114    MISDN_GEN_CRYPT_PREFIX,        /* char[] */
00115    MISDN_GEN_CRYPT_KEYS,          /* char[] */
00116    MISDN_GEN_NTKEEPCALLS,          /* int (bool) */
00117    MISDN_GEN_NTDEBUGFLAGS,          /* int */
00118    MISDN_GEN_NTDEBUGFILE,          /* char[] */
00119    MISDN_GEN_LAST
00120 };

enum misdn_cfg_method

Enumerator:
METHOD_STANDARD 
METHOD_ROUND_ROBIN 
METHOD_STANDARD_DEC 

Definition at line 122 of file chan_misdn_config.h.

00122                       {
00123    METHOD_STANDARD = 0,
00124    METHOD_ROUND_ROBIN,
00125    METHOD_STANDARD_DEC
00126 };


Function Documentation

void misdn_cfg_destroy ( void   ) 

Definition at line 1147 of file misdn_config.c.

References _free_general_cfg(), _free_port_cfg(), ast_free, ast_mutex_destroy, config_mutex, general_cfg, map, misdn_cfg_lock(), misdn_cfg_unlock(), port_cfg, and ptp.

Referenced by unload_module().

01148 {
01149    misdn_cfg_lock();
01150 
01151    _free_port_cfg();
01152    _free_general_cfg();
01153 
01154    ast_free(port_cfg);
01155    ast_free(general_cfg);
01156    ast_free(ptp);
01157    ast_free(map);
01158 
01159    misdn_cfg_unlock();
01160    ast_mutex_destroy(&config_mutex);
01161 }

void misdn_cfg_get ( int  port,
enum misdn_cfg_elements  elem,
void *  buf,
int  bufsize 
)

Definition at line 562 of file misdn_config.c.

References misdn_cfg_pt::any, ast_copy_string(), ast_log(), gen_spec, general_cfg, LOG_WARNING, misdn_cfg_is_port_valid(), MISDN_CFG_LAST, misdn_cfg_lock(), MISDN_CFG_PTP, misdn_cfg_unlock(), MISDN_CTYPE_STR, port_cfg, port_spec, S_OR, str, and type.

Referenced by add_in_calls(), add_out_calls(), cb_events(), dialtone_indicate(), load_module(), misdn_add_number_prefix(), misdn_bridge(), misdn_call(), misdn_cfg_update_ptp(), misdn_check_l2l1(), misdn_get_connected_line(), misdn_new(), misdn_request(), misdn_set_opt_exec(), process_ast_dsp(), read_config(), reload_config(), update_config(), and update_ec_config().

00563 {
00564    int place;
00565 
00566    if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) {
00567       memset(buf, 0, bufsize);
00568       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Port number %d is not valid.\n", port);
00569       return;
00570    }
00571 
00572    misdn_cfg_lock();
00573    if (elem == MISDN_CFG_PTP) {
00574       if (!memcpy(buf, &ptp[port], (bufsize > ptp[port]) ? sizeof(ptp[port]) : bufsize))
00575          memset(buf, 0, bufsize);
00576    } else {
00577       if ((place = map[elem]) < 0) {
00578          memset(buf, 0, bufsize);
00579          ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Invalid element (%d) requested.\n", elem);
00580       } else {
00581          if (elem < MISDN_CFG_LAST) {
00582             switch (port_spec[place].type) {
00583             case MISDN_CTYPE_STR:
00584                if (port_cfg[port][place].str) {
00585                   ast_copy_string(buf, port_cfg[port][place].str, bufsize);
00586                } else if (port_cfg[0][place].str) {
00587                   ast_copy_string(buf, port_cfg[0][place].str, bufsize);
00588                } else
00589                   memset(buf, 0, bufsize);
00590                break;
00591             default:
00592                if (port_cfg[port][place].any)
00593                   memcpy(buf, port_cfg[port][place].any, bufsize);
00594                else if (port_cfg[0][place].any)
00595                   memcpy(buf, port_cfg[0][place].any, bufsize);
00596                else
00597                   memset(buf, 0, bufsize);
00598             }
00599          } else {
00600             switch (gen_spec[place].type) {
00601             case MISDN_CTYPE_STR:
00602                ast_copy_string(buf, S_OR(general_cfg[place].str, ""), bufsize);
00603                break;
00604             default:
00605                if (general_cfg[place].any)
00606                   memcpy(buf, general_cfg[place].any, bufsize);
00607                else
00608                   memset(buf, 0, bufsize);
00609             }
00610          }
00611       }
00612    }
00613    misdn_cfg_unlock();
00614 }

void misdn_cfg_get_config_string ( int  port,
enum misdn_cfg_elements  elem,
char *  buf,
int  bufsize 
)

Definition at line 787 of file misdn_config.c.

References ast_log(), ast_print_group(), BUFFERSIZE, gen_spec, general_cfg, LOG_WARNING, map, MISDN_CFG_FIRST, misdn_cfg_is_port_valid(), MISDN_CFG_LAST, misdn_cfg_lock(), MISDN_CFG_PTP, misdn_cfg_unlock(), MISDN_CTYPE_ASTGROUP, MISDN_CTYPE_BOOL, MISDN_CTYPE_BOOLINT, MISDN_CTYPE_INT, MISDN_CTYPE_MSNLIST, MISDN_CTYPE_STR, MISDN_GEN_FIRST, MISDN_GEN_LAST, misdn_cfg_pt::ml, msn_list::msn, name, msn_list::next, port_cfg, port_spec, ptp, str, and type.

00788 {
00789    int place;
00790    char tempbuf[BUFFERSIZE] = "";
00791    struct msn_list *iter;
00792 
00793    if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) {
00794       *buf = 0;
00795       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Port number %d is not valid.\n", port);
00796       return;
00797    }
00798 
00799    place = map[elem];
00800 
00801    misdn_cfg_lock();
00802    if (elem == MISDN_CFG_PTP) {
00803       snprintf(buf, bufsize, " -> ptp: %s", ptp[port] ? "yes" : "no");
00804    }
00805    else if (elem > MISDN_CFG_FIRST && elem < MISDN_CFG_LAST) {
00806       switch (port_spec[place].type) {
00807       case MISDN_CTYPE_INT:
00808       case MISDN_CTYPE_BOOLINT:
00809          if (port_cfg[port][place].num)
00810             snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[port][place].num);
00811          else if (port_cfg[0][place].num)
00812             snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[0][place].num);
00813          else
00814             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00815          break;
00816       case MISDN_CTYPE_BOOL:
00817          if (port_cfg[port][place].num)
00818             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[port][place].num ? "yes" : "no");
00819          else if (port_cfg[0][place].num)
00820             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[0][place].num ? "yes" : "no");
00821          else
00822             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00823          break;
00824       case MISDN_CTYPE_ASTGROUP:
00825          if (port_cfg[port][place].grp)
00826             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name,
00827                    ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp));
00828          else if (port_cfg[0][place].grp)
00829             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name,
00830                    ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp));
00831          else
00832             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00833          break;
00834       case MISDN_CTYPE_MSNLIST:
00835          if (port_cfg[port][place].ml)
00836             iter = port_cfg[port][place].ml;
00837          else
00838             iter = port_cfg[0][place].ml;
00839          if (iter) {
00840             for (; iter; iter = iter->next) {
00841                strncat(tempbuf, iter->msn, sizeof(tempbuf) - strlen(tempbuf) - 1);
00842             }
00843             if (strlen(tempbuf) > 1) {
00844                tempbuf[strlen(tempbuf)-2] = 0;
00845             }
00846          }
00847          snprintf(buf, bufsize, " -> msns: %s", *tempbuf ? tempbuf : "none");
00848          break;
00849       case MISDN_CTYPE_STR:
00850          if ( port_cfg[port][place].str) {
00851             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[port][place].str);
00852          } else if (port_cfg[0][place].str) {
00853             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[0][place].str);
00854          } else {
00855             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00856          }
00857          break;
00858       }
00859    } else if (elem > MISDN_GEN_FIRST && elem < MISDN_GEN_LAST) {
00860       switch (gen_spec[place].type) {
00861       case MISDN_CTYPE_INT:
00862       case MISDN_CTYPE_BOOLINT:
00863          if (general_cfg[place].num)
00864             snprintf(buf, bufsize, " -> %s: %d", gen_spec[place].name, *general_cfg[place].num);
00865          else
00866             snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
00867          break;
00868       case MISDN_CTYPE_BOOL:
00869          if (general_cfg[place].num)
00870             snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, *general_cfg[place].num ? "yes" : "no");
00871          else
00872             snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
00873          break;
00874       case MISDN_CTYPE_STR:
00875          if ( general_cfg[place].str) {
00876             snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, general_cfg[place].str);
00877          } else {
00878             snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
00879          }
00880          break;
00881       default:
00882          snprintf(buf, bufsize, " -> type of %s not handled yet", gen_spec[place].name);
00883          break;
00884       }
00885    } else {
00886       *buf = 0;
00887       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Invalid config element (%d) requested.\n", elem);
00888    }
00889    misdn_cfg_unlock();
00890 }

void misdn_cfg_get_desc ( enum misdn_cfg_elements  elem,
void *  buf,
int  bufsize,
void *  buf_default,
int  bufsize_default 
)

Definition at line 663 of file misdn_config.c.

References ast_copy_string(), misdn_cfg_spec::def, desc, gen_spec, MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, MISDN_CFG_LAST, MISDN_GEN_FIRST, MISDN_GEN_LAST, NO_DEFAULT, and port_spec.

Referenced by show_config_description().

00664 {
00665    int place = map[elem];
00666    struct misdn_cfg_spec *spec = NULL;
00667 
00668    /* here comes a hack to replace the (not existing) "name" element with the "ports" element */
00669    if (elem == MISDN_CFG_GROUPNAME) {
00670       ast_copy_string(buf, ports_description, bufsize);
00671       if (buf_default && bufsize_default)
00672          memset(buf_default, 0, 1);
00673       return;
00674    }
00675 
00676    if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST))
00677       spec = (struct misdn_cfg_spec *)port_spec;
00678    else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST))
00679       spec = (struct misdn_cfg_spec *)gen_spec;
00680 
00681    if (!spec || !spec[place].desc)
00682       memset(buf, 0, 1);
00683    else {
00684       ast_copy_string(buf, spec[place].desc, bufsize);
00685       if (buf_default && bufsize) {
00686          if (!strcmp(spec[place].def, NO_DEFAULT))
00687             memset(buf_default, 0, 1);
00688          else
00689             ast_copy_string(buf_default, spec[place].def, bufsize_default);
00690       }
00691    }
00692 }

enum misdn_cfg_elements misdn_cfg_get_elem ( const char *  name  ) 

Definition at line 616 of file misdn_config.c.

References misdn_cfg_spec::elem, GEN_CFG, gen_spec, get_cfg_position(), MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, PORT_CFG, and port_spec.

Referenced by handle_cli_misdn_show_config().

00617 {
00618    int pos;
00619 
00620    /* here comes a hack to replace the (not existing) "name" element with the "ports" element */
00621    if (!strcmp(name, "ports"))
00622       return MISDN_CFG_GROUPNAME;
00623    if (!strcmp(name, "name"))
00624       return MISDN_CFG_FIRST;
00625 
00626    pos = get_cfg_position(name, PORT_CFG);
00627    if (pos >= 0)
00628       return port_spec[pos].elem;
00629 
00630    pos = get_cfg_position(name, GEN_CFG);
00631    if (pos >= 0)
00632       return gen_spec[pos].elem;
00633 
00634    return MISDN_CFG_FIRST;
00635 }

void misdn_cfg_get_name ( enum misdn_cfg_elements  elem,
void *  buf,
int  bufsize 
)

Definition at line 637 of file misdn_config.c.

References ast_copy_string(), gen_spec, MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, MISDN_CFG_LAST, MISDN_CFG_PTP, MISDN_GEN_FIRST, MISDN_GEN_LAST, name, and port_spec.

Referenced by complete_show_config(), and show_config_description().

00638 {
00639    struct misdn_cfg_spec *spec = NULL;
00640    int place = map[elem];
00641 
00642    /* the ptp hack */
00643    if (elem == MISDN_CFG_PTP) {
00644       memset(buf, 0, 1);
00645       return;
00646    }
00647 
00648    /* here comes a hack to replace the (not existing) "name" element with the "ports" element */
00649    if (elem == MISDN_CFG_GROUPNAME) {
00650       if (!snprintf(buf, bufsize, "ports"))
00651          memset(buf, 0, 1);
00652       return;
00653    }
00654 
00655    if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST))
00656       spec = (struct misdn_cfg_spec *)port_spec;
00657    else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST))
00658       spec = (struct misdn_cfg_spec *)gen_spec;
00659 
00660    ast_copy_string(buf, spec ? spec[place].name : "", bufsize);
00661 }

int misdn_cfg_get_next_port ( int  port  ) 

Definition at line 892 of file misdn_config.c.

References map, max_ports, MISDN_CFG_GROUPNAME, misdn_cfg_lock(), misdn_cfg_unlock(), port_cfg, and str.

Referenced by complete_show_config(), handle_cli_misdn_show_ports_stats(), handle_cli_misdn_show_stacks(), load_module(), misdn_cfg_get_next_port_spin(), misdn_check_l2l1(), misdn_new(), misdn_request(), and update_name().

00893 {
00894    int p = -1;
00895    int gn = map[MISDN_CFG_GROUPNAME];
00896 
00897    misdn_cfg_lock();
00898    for (port++; port <= max_ports; port++) {
00899       if (port_cfg[port][gn].str) {
00900          p = port;
00901          break;
00902       }
00903    }
00904    misdn_cfg_unlock();
00905 
00906    return p;
00907 }

int misdn_cfg_get_next_port_spin ( int  port  ) 

Definition at line 909 of file misdn_config.c.

References misdn_cfg_get_next_port().

Referenced by misdn_request().

00910 {
00911    int p = misdn_cfg_get_next_port(port);
00912    return (p > 0) ? p : misdn_cfg_get_next_port(0);
00913 }

void misdn_cfg_get_ports_string ( char *  ports  ) 

Generate a comma separated list of all active ports.

Definition at line 761 of file misdn_config.c.

References map, max_ports, MISDN_CFG_GROUPNAME, misdn_cfg_lock(), misdn_cfg_unlock(), port_cfg, ptp, and str.

Referenced by load_module().

00762 {
00763    char tmp[16];
00764    int l, i;
00765    int gn = map[MISDN_CFG_GROUPNAME];
00766 
00767    *ports = 0;
00768 
00769    misdn_cfg_lock();
00770    for (i = 1; i <= max_ports; i++) {
00771       if (port_cfg[i][gn].str) {
00772          if (ptp[i])
00773             sprintf(tmp, "%dptp,", i);
00774          else
00775             sprintf(tmp, "%d,", i);
00776          strcat(ports, tmp);
00777       }
00778    }
00779    misdn_cfg_unlock();
00780 
00781    if ((l = strlen(ports))) {
00782       /* Strip trailing ',' */
00783       ports[l-1] = 0;
00784    }
00785 }

int misdn_cfg_init ( int  max_ports,
int  reload 
)

Definition at line 1163 of file misdn_config.c.

References _build_general_config(), _build_port_config(), _enum_array_map(), _fill_defaults(), _free_general_cfg(), _free_port_cfg(), ast_calloc, ast_category_browse(), ast_config_destroy(), ast_config_load2(), ast_log(), ast_mutex_init, ast_variable_browse(), config, CONFIG_FLAG_FILEUNCHANGED, config_mutex, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, default_jbconf, general_cfg, global_jbconf, LOG_WARNING, map, max_ports, misdn_cfg_lock(), misdn_cfg_unlock(), MISDN_GEN_LAST, NUM_GEN_ELEMENTS, NUM_PORT_ELEMENTS, port_cfg, and ptp.

Referenced by load_module(), and misdn_cfg_reload().

01164 {
01165    char config[] = "misdn.conf";
01166    char *cat, *p;
01167    int i;
01168    struct ast_config *cfg;
01169    struct ast_variable *v;
01170    struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
01171 
01172    if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
01173       ast_log(LOG_WARNING, "missing or invalid file: misdn.conf\n");
01174       return -1;
01175    } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
01176       return 0;
01177 
01178    ast_mutex_init(&config_mutex);
01179 
01180    /* Copy the default jb config over global_jbconf */
01181    memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
01182 
01183    misdn_cfg_lock();
01184 
01185    if (this_max_ports) {
01186       /* this is the first run */
01187       max_ports = this_max_ports;
01188       map = ast_calloc(MISDN_GEN_LAST + 1, sizeof(int));
01189       if (_enum_array_map())
01190          return -1;
01191       p = ast_calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *)
01192                      + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt));
01193       port_cfg = (union misdn_cfg_pt **)p;
01194       p += (max_ports + 1) * sizeof(union misdn_cfg_pt *);
01195       for (i = 0; i <= max_ports; ++i) {
01196          port_cfg[i] = (union misdn_cfg_pt *)p;
01197          p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt);
01198       }
01199       general_cfg = ast_calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
01200       ptp = ast_calloc(max_ports + 1, sizeof(int));
01201    }
01202    else {
01203       /* misdn reload */
01204       _free_port_cfg();
01205       _free_general_cfg();
01206       memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1));
01207       memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
01208       memset(ptp, 0, sizeof(int) * (max_ports + 1));
01209    }
01210 
01211    cat = ast_category_browse(cfg, NULL);
01212 
01213    while(cat) {
01214       v = ast_variable_browse(cfg, cat);
01215       if (!strcasecmp(cat, "general")) {
01216          _build_general_config(v);
01217       } else {
01218          _build_port_config(v, cat);
01219       }
01220       cat = ast_category_browse(cfg, cat);
01221    }
01222 
01223    _fill_defaults();
01224 
01225    misdn_cfg_unlock();
01226    ast_config_destroy(cfg);
01227 
01228    return 0;
01229 }

int misdn_cfg_is_group_method ( char *  group,
enum misdn_cfg_method  meth 
)

Definition at line 726 of file misdn_config.c.

References map, max_ports, METHOD_ROUND_ROBIN, METHOD_STANDARD, METHOD_STANDARD_DEC, MISDN_CFG_GROUPNAME, misdn_cfg_lock(), MISDN_CFG_METHOD, misdn_cfg_unlock(), port_cfg, str, and misdn_cfg_pt::str.

Referenced by misdn_request().

00727 {
00728    int i, re = 0;
00729    char *method ;
00730 
00731    misdn_cfg_lock();
00732 
00733    method = port_cfg[0][map[MISDN_CFG_METHOD]].str;
00734 
00735    for (i = 1; i <= max_ports; i++) {
00736       if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) {
00737          if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group))
00738             method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ?
00739                     port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str);
00740       }
00741    }
00742 
00743    if (method) {
00744       switch (meth) {
00745       case METHOD_STANDARD:      re = !strcasecmp(method, "standard");
00746                            break;
00747       case METHOD_ROUND_ROBIN:   re = !strcasecmp(method, "round_robin");
00748                            break;
00749       case METHOD_STANDARD_DEC:  re = !strcasecmp(method, "standard_dec");
00750                            break;
00751       }
00752    }
00753    misdn_cfg_unlock();
00754 
00755    return re;
00756 }

int misdn_cfg_is_msn_valid ( int  port,
char *  msn 
)

Definition at line 694 of file misdn_config.c.

References ast_extension_match(), ast_log(), LOG_WARNING, misdn_cfg_is_port_valid(), misdn_cfg_lock(), MISDN_CFG_MSNS, misdn_cfg_pt::ml, msn_list::msn, msn_list::next, and port_cfg.

Referenced by misdn_is_msn_valid().

00695 {
00696    int re = 0;
00697    struct msn_list *iter;
00698 
00699    if (!misdn_cfg_is_port_valid(port)) {
00700       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port);
00701       return 0;
00702    }
00703 
00704    misdn_cfg_lock();
00705    if (port_cfg[port][map[MISDN_CFG_MSNS]].ml)
00706       iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml;
00707    else
00708       iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml;
00709    for (; iter; iter = iter->next)
00710       if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) {
00711          re = 1;
00712          break;
00713       }
00714    misdn_cfg_unlock();
00715 
00716    return re;
00717 }

int misdn_cfg_is_port_valid ( int  port  ) 

Definition at line 719 of file misdn_config.c.

References map, max_ports, MISDN_CFG_GROUPNAME, port_cfg, and str.

Referenced by misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_is_msn_valid(), and misdn_cfg_update_ptp().

00720 {
00721    int gn = map[MISDN_CFG_GROUPNAME];
00722 
00723    return (port >= 1 && port <= max_ports && port_cfg[port][gn].str);
00724 }

void misdn_cfg_reload ( void   ) 

Definition at line 1142 of file misdn_config.c.

References misdn_cfg_init().

Referenced by reload_config().

01143 {
01144    misdn_cfg_init(0, 1);
01145 }

void misdn_cfg_update_ptp ( void   ) 

Definition at line 1073 of file misdn_config.c.

References ast_log(), ast_strlen_zero(), BUFFERSIZE, errno, LOG_WARNING, max_ports, misdn_cfg_get(), misdn_cfg_is_port_valid(), misdn_cfg_lock(), misdn_cfg_unlock(), MISDN_GEN_MISDN_INIT, and ptp.

Referenced by load_module(), and reload_config().

01074 {
01075 #ifndef MISDN_1_2
01076    char misdn_init[BUFFERSIZE];
01077    char line[BUFFERSIZE];
01078    FILE *fp;
01079    char *tok, *p, *end;
01080    int port;
01081 
01082    misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init));
01083 
01084    if (!ast_strlen_zero(misdn_init)) {
01085       fp = fopen(misdn_init, "r");
01086       if (fp) {
01087          while(fgets(line, sizeof(line), fp)) {
01088             if (!strncmp(line, "nt_ptp", 6)) {
01089                for (tok = strtok_r(line,",=", &p);
01090                    tok;
01091                    tok = strtok_r(NULL,",=", &p)) {
01092                   port = strtol(tok, &end, 10);
01093                   if (end != tok && misdn_cfg_is_port_valid(port)) {
01094                      misdn_cfg_lock();
01095                      ptp[port] = 1;
01096                      misdn_cfg_unlock();
01097                   }
01098                }
01099             }
01100          }
01101          fclose(fp);
01102       } else {
01103          ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno));
01104       }
01105    }
01106 #else
01107    int i;
01108    int proto;
01109    char filename[128];
01110    FILE *fp;
01111 
01112    for (i = 1; i <= max_ports; ++i) {
01113       snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8);
01114       fp = fopen(filename, "r");
01115       if (!fp) {
01116          ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno));
01117          continue;
01118       }
01119       if (fscanf(fp, "0x%08x", &proto) != 1)
01120          ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename);
01121       else
01122          ptp[i] = proto & 1<<5 ? 1 : 0;
01123       fclose(fp);
01124    }
01125 #endif
01126 }

struct ast_jb_conf* misdn_get_global_jbconf ( void   ) 

Definition at line 1231 of file misdn_config.c.

References global_jbconf.

Referenced by misdn_new().

01231                                               {
01232    return &global_jbconf;
01233 }


Generated on Mon Oct 8 12:39:15 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7