Mon Mar 19 11:30:41 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 1143 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().

01144 {
01145    misdn_cfg_lock();
01146 
01147    _free_port_cfg();
01148    _free_general_cfg();
01149 
01150    ast_free(port_cfg);
01151    ast_free(general_cfg);
01152    ast_free(ptp);
01153    ast_free(map);
01154 
01155    misdn_cfg_unlock();
01156    ast_mutex_destroy(&config_mutex);
01157 }

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

Definition at line 558 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().

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

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

Definition at line 783 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.

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

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

Definition at line 659 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().

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

enum misdn_cfg_elements misdn_cfg_get_elem ( const char *  name  ) 

Definition at line 612 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().

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

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

Definition at line 633 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().

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

int misdn_cfg_get_next_port ( int  port  ) 

Definition at line 888 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().

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

int misdn_cfg_get_next_port_spin ( int  port  ) 

Definition at line 905 of file misdn_config.c.

References misdn_cfg_get_next_port().

Referenced by misdn_request().

00906 {
00907    int p = misdn_cfg_get_next_port(port);
00908    return (p > 0) ? p : misdn_cfg_get_next_port(0);
00909 }

void misdn_cfg_get_ports_string ( char *  ports  ) 

Generate a comma separated list of all active ports.

Definition at line 757 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().

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

int misdn_cfg_init ( int  max_ports,
int  reload 
)

Definition at line 1159 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_flags, 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().

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

int misdn_cfg_is_group_method ( char *  group,
enum misdn_cfg_method  meth 
)

Definition at line 722 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().

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

int misdn_cfg_is_msn_valid ( int  port,
char *  msn 
)

Definition at line 690 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().

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

int misdn_cfg_is_port_valid ( int  port  ) 

Definition at line 715 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().

00716 {
00717    int gn = map[MISDN_CFG_GROUPNAME];
00718 
00719    return (port >= 1 && port <= max_ports && port_cfg[port][gn].str);
00720 }

void misdn_cfg_reload ( void   ) 

Definition at line 1138 of file misdn_config.c.

References misdn_cfg_init().

Referenced by reload_config().

01139 {
01140    misdn_cfg_init(0, 1);
01141 }

void misdn_cfg_update_ptp ( void   ) 

Definition at line 1069 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().

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

struct ast_jb_conf* misdn_get_global_jbconf ( void   ) 

Definition at line 1227 of file misdn_config.c.

References global_jbconf.

Referenced by misdn_new().

01227                                               {
01228    return &global_jbconf;
01229 }


Generated on Mon Mar 19 11:30:41 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7