chan_misdn_config.h File Reference

Interface to mISDN - Config. More...

This graph shows which files directly or indirectly include this file:

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_NAMEDCALLGROUP, MISDN_CFG_NAMEDPICKUPGROUP,
  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)
struct 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


Enumeration Type Documentation

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_NAMEDCALLGROUP 
MISDN_CFG_NAMEDPICKUPGROUP 
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_NAMEDCALLGROUP,      /* ast_namedgroups * */
00093    MISDN_CFG_NAMEDPICKUPGROUP,    /* ast_namedgroups * */
00094    MISDN_CFG_MAX_IN,              /* int */
00095    MISDN_CFG_MAX_OUT,              /* int */
00096    MISDN_CFG_L1_TIMEOUT,          /* int */
00097    MISDN_CFG_OVERLAP_DIAL,    /* int (bool)*/
00098    MISDN_CFG_MSNS,                /* char[] */
00099    MISDN_CFG_FAXDETECT,           /* char[] */
00100    MISDN_CFG_FAXDETECT_CONTEXT,   /* char[] */
00101    MISDN_CFG_FAXDETECT_TIMEOUT,   /* int */
00102    MISDN_CFG_PTP,                 /* int (bool) */
00103    MISDN_CFG_LAST,
00104 
00105    /* general config items */
00106    MISDN_GEN_FIRST,
00107 #ifndef MISDN_1_2
00108    MISDN_GEN_MISDN_INIT,           /* char[] */
00109 #endif
00110    MISDN_GEN_DEBUG,               /* int */
00111    MISDN_GEN_TRACEFILE,           /* char[] */
00112    MISDN_GEN_BRIDGING,            /* int (bool) */
00113    MISDN_GEN_STOP_TONE,           /* int (bool) */
00114    MISDN_GEN_APPEND_DIGITS2EXTEN, /* int (bool) */
00115    MISDN_GEN_DYNAMIC_CRYPT,       /* int (bool) */
00116    MISDN_GEN_CRYPT_PREFIX,        /* char[] */
00117    MISDN_GEN_CRYPT_KEYS,          /* char[] */
00118    MISDN_GEN_NTKEEPCALLS,          /* int (bool) */
00119    MISDN_GEN_NTDEBUGFLAGS,          /* int */
00120    MISDN_GEN_NTDEBUGFILE,          /* char[] */
00121    MISDN_GEN_LAST
00122 };

Enumerator:
METHOD_STANDARD 
METHOD_ROUND_ROBIN 
METHOD_STANDARD_DEC 

Definition at line 124 of file chan_misdn_config.h.

00124                       {
00125    METHOD_STANDARD = 0,
00126    METHOD_ROUND_ROBIN,
00127    METHOD_STANDARD_DEC
00128 };


Function Documentation

void misdn_cfg_destroy ( void   ) 

Definition at line 1189 of file misdn_config.c.

References _free_general_cfg(), _free_port_cfg(), ast_free, ast_mutex_destroy, misdn_cfg_lock(), and misdn_cfg_unlock().

Referenced by unload_module().

01190 {
01191    misdn_cfg_lock();
01192 
01193    _free_port_cfg();
01194    _free_general_cfg();
01195 
01196    ast_free(port_cfg);
01197    ast_free(general_cfg);
01198    ast_free(ptp);
01199    ast_free(map);
01200 
01201    misdn_cfg_unlock();
01202    ast_mutex_destroy(&config_mutex);
01203 }

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

Definition at line 571 of file misdn_config.c.

References ast_copy_string(), ast_log, LOG_WARNING, misdn_cfg_is_port_valid(), MISDN_CFG_LAST, misdn_cfg_lock(), MISDN_CFG_PTP, misdn_cfg_unlock(), MISDN_CTYPE_ASTNAMEDGROUP, MISDN_CTYPE_STR, misdn_cfg_pt::namgrp, NULL, S_OR, str, and type.

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

00572 {
00573    int place;
00574 
00575    if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) {
00576       memset(buf, 0, bufsize);
00577       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Port number %d is not valid.\n", port);
00578       return;
00579    }
00580 
00581    misdn_cfg_lock();
00582    if (elem == MISDN_CFG_PTP) {
00583       if (!memcpy(buf, &ptp[port], (bufsize > ptp[port]) ? sizeof(ptp[port]) : bufsize))
00584          memset(buf, 0, bufsize);
00585    } else {
00586       if ((place = map[elem]) < 0) {
00587          memset(buf, 0, bufsize);
00588          ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Invalid element (%d) requested.\n", elem);
00589       } else {
00590          if (elem < MISDN_CFG_LAST) {
00591             switch (port_spec[place].type) {
00592             case MISDN_CTYPE_STR:
00593                if (port_cfg[port][place].str) {
00594                   ast_copy_string(buf, port_cfg[port][place].str, bufsize);
00595                } else if (port_cfg[0][place].str) {
00596                   ast_copy_string(buf, port_cfg[0][place].str, bufsize);
00597                } else
00598                   memset(buf, 0, bufsize);
00599                break;
00600             case MISDN_CTYPE_ASTNAMEDGROUP:
00601                if (bufsize >= sizeof(struct ast_namedgroups *)) {
00602                   if (port_cfg[port][place].namgrp) {
00603                      *(struct ast_namedgroups **)buf = port_cfg[port][place].namgrp;
00604                   } else if (port_cfg[0][place].namgrp) {
00605                      *(struct ast_namedgroups **)buf = port_cfg[0][place].namgrp;
00606                   } else {
00607                      *(struct ast_namedgroups **)buf = NULL;
00608                   }
00609                }
00610                break;
00611             default:
00612                if (port_cfg[port][place].any)
00613                   memcpy(buf, port_cfg[port][place].any, bufsize);
00614                else if (port_cfg[0][place].any)
00615                   memcpy(buf, port_cfg[0][place].any, bufsize);
00616                else
00617                   memset(buf, 0, bufsize);
00618             }
00619          } else {
00620             switch (gen_spec[place].type) {
00621             case MISDN_CTYPE_STR:
00622                ast_copy_string(buf, S_OR(general_cfg[place].str, ""), bufsize);
00623                break;
00624             default:
00625                if (general_cfg[place].any)
00626                   memcpy(buf, general_cfg[place].any, bufsize);
00627                else
00628                   memset(buf, 0, bufsize);
00629             }
00630          }
00631       }
00632    }
00633    misdn_cfg_unlock();
00634 }

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

Definition at line 807 of file misdn_config.c.

References ast_free, ast_log, ast_print_group(), ast_print_namedgroups(), ast_str_create(), BUFFERSIZE, LOG_WARNING, 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_ASTNAMEDGROUP, 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, str, and type.

Referenced by handle_cli_misdn_show_config().

00808 {
00809    int place;
00810    char tempbuf[BUFFERSIZE] = "";
00811    struct msn_list *iter;
00812 
00813    if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) {
00814       *buf = 0;
00815       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Port number %d is not valid.\n", port);
00816       return;
00817    }
00818 
00819    place = map[elem];
00820 
00821    misdn_cfg_lock();
00822    if (elem == MISDN_CFG_PTP) {
00823       snprintf(buf, bufsize, " -> ptp: %s", ptp[port] ? "yes" : "no");
00824    }
00825    else if (elem > MISDN_CFG_FIRST && elem < MISDN_CFG_LAST) {
00826       switch (port_spec[place].type) {
00827       case MISDN_CTYPE_INT:
00828       case MISDN_CTYPE_BOOLINT:
00829          if (port_cfg[port][place].num)
00830             snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[port][place].num);
00831          else if (port_cfg[0][place].num)
00832             snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[0][place].num);
00833          else
00834             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00835          break;
00836       case MISDN_CTYPE_BOOL:
00837          if (port_cfg[port][place].num)
00838             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[port][place].num ? "yes" : "no");
00839          else if (port_cfg[0][place].num)
00840             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[0][place].num ? "yes" : "no");
00841          else
00842             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00843          break;
00844       case MISDN_CTYPE_ASTGROUP:
00845          if (port_cfg[port][place].grp)
00846             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name,
00847                    ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp));
00848          else if (port_cfg[0][place].grp)
00849             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name,
00850                    ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp));
00851          else
00852             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00853          break;
00854       case MISDN_CTYPE_ASTNAMEDGROUP:
00855          if (port_cfg[port][place].namgrp) {
00856             struct ast_str *tmp_str = ast_str_create(1024);
00857             if (tmp_str) {
00858                snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name,
00859                      ast_print_namedgroups(&tmp_str, port_cfg[port][place].namgrp));
00860                ast_free(tmp_str);
00861             }
00862          } else if (port_cfg[0][place].namgrp) {
00863             struct ast_str *tmp_str = ast_str_create(1024);
00864             if (tmp_str) {
00865                snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name,
00866                      ast_print_namedgroups(&tmp_str, port_cfg[0][place].namgrp));
00867                ast_free(tmp_str);
00868             }
00869          } else {
00870             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00871          }
00872          break;
00873       case MISDN_CTYPE_MSNLIST:
00874          if (port_cfg[port][place].ml)
00875             iter = port_cfg[port][place].ml;
00876          else
00877             iter = port_cfg[0][place].ml;
00878          if (iter) {
00879             for (; iter; iter = iter->next) {
00880                strncat(tempbuf, iter->msn, sizeof(tempbuf) - strlen(tempbuf) - 1);
00881             }
00882             if (strlen(tempbuf) > 1) {
00883                tempbuf[strlen(tempbuf)-2] = 0;
00884             }
00885          }
00886          snprintf(buf, bufsize, " -> msns: %s", *tempbuf ? tempbuf : "none");
00887          break;
00888       case MISDN_CTYPE_STR:
00889          if ( port_cfg[port][place].str) {
00890             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[port][place].str);
00891          } else if (port_cfg[0][place].str) {
00892             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[0][place].str);
00893          } else {
00894             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00895          }
00896          break;
00897       }
00898    } else if (elem > MISDN_GEN_FIRST && elem < MISDN_GEN_LAST) {
00899       switch (gen_spec[place].type) {
00900       case MISDN_CTYPE_INT:
00901       case MISDN_CTYPE_BOOLINT:
00902          if (general_cfg[place].num)
00903             snprintf(buf, bufsize, " -> %s: %d", gen_spec[place].name, *general_cfg[place].num);
00904          else
00905             snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
00906          break;
00907       case MISDN_CTYPE_BOOL:
00908          if (general_cfg[place].num)
00909             snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, *general_cfg[place].num ? "yes" : "no");
00910          else
00911             snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
00912          break;
00913       case MISDN_CTYPE_STR:
00914          if ( general_cfg[place].str) {
00915             snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, general_cfg[place].str);
00916          } else {
00917             snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
00918          }
00919          break;
00920       default:
00921          snprintf(buf, bufsize, " -> type of %s not handled yet", gen_spec[place].name);
00922          break;
00923       }
00924    } else {
00925       *buf = 0;
00926       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Invalid config element (%d) requested.\n", elem);
00927    }
00928    misdn_cfg_unlock();
00929 }

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

Definition at line 683 of file misdn_config.c.

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

Referenced by show_config_description().

00684 {
00685    int place = map[elem];
00686    struct misdn_cfg_spec *spec = NULL;
00687 
00688    /* here comes a hack to replace the (not existing) "name" element with the "ports" element */
00689    if (elem == MISDN_CFG_GROUPNAME) {
00690       ast_copy_string(buf, ports_description, bufsize);
00691       if (buf_default && bufsize_default)
00692          memset(buf_default, 0, 1);
00693       return;
00694    }
00695 
00696    if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST))
00697       spec = (struct misdn_cfg_spec *)port_spec;
00698    else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST))
00699       spec = (struct misdn_cfg_spec *)gen_spec;
00700 
00701    if (!spec || !spec[place].desc)
00702       memset(buf, 0, 1);
00703    else {
00704       ast_copy_string(buf, spec[place].desc, bufsize);
00705       if (buf_default && bufsize) {
00706          if (!strcmp(spec[place].def, NO_DEFAULT))
00707             memset(buf_default, 0, 1);
00708          else
00709             ast_copy_string(buf_default, spec[place].def, bufsize_default);
00710       }
00711    }
00712 }

enum misdn_cfg_elements misdn_cfg_get_elem ( const char *  name  ) 

Definition at line 636 of file misdn_config.c.

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

Referenced by handle_cli_misdn_show_config().

00637 {
00638    int pos;
00639 
00640    /* here comes a hack to replace the (not existing) "name" element with the "ports" element */
00641    if (!strcmp(name, "ports"))
00642       return MISDN_CFG_GROUPNAME;
00643    if (!strcmp(name, "name"))
00644       return MISDN_CFG_FIRST;
00645 
00646    pos = get_cfg_position(name, PORT_CFG);
00647    if (pos >= 0)
00648       return port_spec[pos].elem;
00649 
00650    pos = get_cfg_position(name, GEN_CFG);
00651    if (pos >= 0)
00652       return gen_spec[pos].elem;
00653 
00654    return MISDN_CFG_FIRST;
00655 }

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

Definition at line 657 of file misdn_config.c.

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

Referenced by complete_show_config(), and show_config_description().

00658 {
00659    struct misdn_cfg_spec *spec = NULL;
00660    int place = map[elem];
00661 
00662    /* the ptp hack */
00663    if (elem == MISDN_CFG_PTP) {
00664       memset(buf, 0, 1);
00665       return;
00666    }
00667 
00668    /* here comes a hack to replace the (not existing) "name" element with the "ports" element */
00669    if (elem == MISDN_CFG_GROUPNAME) {
00670       if (!snprintf(buf, bufsize, "ports"))
00671          memset(buf, 0, 1);
00672       return;
00673    }
00674 
00675    if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST))
00676       spec = (struct misdn_cfg_spec *)port_spec;
00677    else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST))
00678       spec = (struct misdn_cfg_spec *)gen_spec;
00679 
00680    ast_copy_string(buf, spec ? spec[place].name : "", bufsize);
00681 }

int misdn_cfg_get_next_port ( int  port  ) 

Definition at line 931 of file misdn_config.c.

References MISDN_CFG_GROUPNAME, misdn_cfg_lock(), misdn_cfg_unlock(), and str.

Referenced by complete_show_config(), handle_cli_misdn_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().

00932 {
00933    int p = -1;
00934    int gn = map[MISDN_CFG_GROUPNAME];
00935 
00936    misdn_cfg_lock();
00937    for (port++; port <= max_ports; port++) {
00938       if (port_cfg[port][gn].str) {
00939          p = port;
00940          break;
00941       }
00942    }
00943    misdn_cfg_unlock();
00944 
00945    return p;
00946 }

int misdn_cfg_get_next_port_spin ( int  port  ) 

Definition at line 948 of file misdn_config.c.

References misdn_cfg_get_next_port().

Referenced by misdn_request().

00949 {
00950    int p = misdn_cfg_get_next_port(port);
00951    return (p > 0) ? p : misdn_cfg_get_next_port(0);
00952 }

void misdn_cfg_get_ports_string ( char *  ports  ) 

Generate a comma separated list of all active ports.

Definition at line 781 of file misdn_config.c.

References MISDN_CFG_GROUPNAME, misdn_cfg_lock(), misdn_cfg_unlock(), str, and tmp().

Referenced by load_module().

00782 {
00783    char tmp[16];
00784    int l, i;
00785    int gn = map[MISDN_CFG_GROUPNAME];
00786 
00787    *ports = 0;
00788 
00789    misdn_cfg_lock();
00790    for (i = 1; i <= max_ports; i++) {
00791       if (port_cfg[i][gn].str) {
00792          if (ptp[i])
00793             sprintf(tmp, "%dptp,", i);
00794          else
00795             sprintf(tmp, "%d,", i);
00796          strcat(ports, tmp);
00797       }
00798    }
00799    misdn_cfg_unlock();
00800 
00801    if ((l = strlen(ports))) {
00802       /* Strip trailing ',' */
00803       ports[l-1] = 0;
00804    }
00805 }

int misdn_cfg_init ( int  max_ports,
int  reload 
)

Definition at line 1205 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_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, global_jbconf, LOG_WARNING, misdn_cfg_lock(), misdn_cfg_unlock(), MISDN_GEN_LAST, NULL, NUM_GEN_ELEMENTS, and NUM_PORT_ELEMENTS.

Referenced by load_module(), and misdn_cfg_reload().

01206 {
01207    char config[] = "misdn.conf";
01208    char *cat, *p;
01209    int i;
01210    struct ast_config *cfg;
01211    struct ast_variable *v;
01212    struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
01213 
01214    if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
01215       ast_log(LOG_WARNING, "missing or invalid file: misdn.conf\n");
01216       return -1;
01217    } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
01218       return 0;
01219 
01220    ast_mutex_init(&config_mutex);
01221 
01222    /* Copy the default jb config over global_jbconf */
01223    memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
01224 
01225    misdn_cfg_lock();
01226 
01227    if (this_max_ports) {
01228       /* this is the first run */
01229       max_ports = this_max_ports;
01230       map = ast_calloc(MISDN_GEN_LAST + 1, sizeof(int));
01231       if (_enum_array_map())
01232          return -1;
01233       p = ast_calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *)
01234                      + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt));
01235       port_cfg = (union misdn_cfg_pt **)p;
01236       p += (max_ports + 1) * sizeof(union misdn_cfg_pt *);
01237       for (i = 0; i <= max_ports; ++i) {
01238          port_cfg[i] = (union misdn_cfg_pt *)p;
01239          p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt);
01240       }
01241       general_cfg = ast_calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
01242       ptp = ast_calloc(max_ports + 1, sizeof(int));
01243    }
01244    else {
01245       /* misdn reload */
01246       _free_port_cfg();
01247       _free_general_cfg();
01248       memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1));
01249       memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
01250       memset(ptp, 0, sizeof(int) * (max_ports + 1));
01251    }
01252 
01253    cat = ast_category_browse(cfg, NULL);
01254 
01255    while(cat) {
01256       v = ast_variable_browse(cfg, cat);
01257       if (!strcasecmp(cat, "general")) {
01258          _build_general_config(v);
01259       } else {
01260          _build_port_config(v, cat);
01261       }
01262       cat = ast_category_browse(cfg, cat);
01263    }
01264 
01265    _fill_defaults();
01266 
01267    misdn_cfg_unlock();
01268    ast_config_destroy(cfg);
01269 
01270    return 0;
01271 }

int misdn_cfg_is_group_method ( char *  group,
enum misdn_cfg_method  meth 
)

Definition at line 746 of file misdn_config.c.

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

Referenced by misdn_request().

00747 {
00748    int i, re = 0;
00749    char *method ;
00750 
00751    misdn_cfg_lock();
00752 
00753    method = port_cfg[0][map[MISDN_CFG_METHOD]].str;
00754 
00755    for (i = 1; i <= max_ports; i++) {
00756       if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) {
00757          if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group))
00758             method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ?
00759                     port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str);
00760       }
00761    }
00762 
00763    if (method) {
00764       switch (meth) {
00765       case METHOD_STANDARD:      re = !strcasecmp(method, "standard");
00766                            break;
00767       case METHOD_ROUND_ROBIN:   re = !strcasecmp(method, "round_robin");
00768                            break;
00769       case METHOD_STANDARD_DEC:  re = !strcasecmp(method, "standard_dec");
00770                            break;
00771       }
00772    }
00773    misdn_cfg_unlock();
00774 
00775    return re;
00776 }

int misdn_cfg_is_msn_valid ( int  port,
char *  msn 
)

Definition at line 714 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_unlock(), misdn_cfg_pt::ml, msn_list::msn, and msn_list::next.

Referenced by misdn_is_msn_valid().

00715 {
00716    int re = 0;
00717    struct msn_list *iter;
00718 
00719    if (!misdn_cfg_is_port_valid(port)) {
00720       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port);
00721       return 0;
00722    }
00723 
00724    misdn_cfg_lock();
00725    if (port_cfg[port][map[MISDN_CFG_MSNS]].ml)
00726       iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml;
00727    else
00728       iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml;
00729    for (; iter; iter = iter->next)
00730       if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) {
00731          re = 1;
00732          break;
00733       }
00734    misdn_cfg_unlock();
00735 
00736    return re;
00737 }

int misdn_cfg_is_port_valid ( int  port  ) 

Definition at line 739 of file misdn_config.c.

References MISDN_CFG_GROUPNAME, and str.

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

00740 {
00741    int gn = map[MISDN_CFG_GROUPNAME];
00742 
00743    return (port >= 1 && port <= max_ports && port_cfg[port][gn].str);
00744 }

void misdn_cfg_reload ( void   ) 

Definition at line 1184 of file misdn_config.c.

References misdn_cfg_init().

Referenced by reload_config().

01185 {
01186    misdn_cfg_init(0, 1);
01187 }

void misdn_cfg_update_ptp ( void   ) 

Definition at line 1115 of file misdn_config.c.

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

Referenced by load_module(), and reload_config().

01116 {
01117 #ifndef MISDN_1_2
01118    char misdn_init[BUFFERSIZE];
01119    char line[BUFFERSIZE];
01120    FILE *fp;
01121    char *tok, *p, *end;
01122    int port;
01123 
01124    misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init));
01125 
01126    if (!ast_strlen_zero(misdn_init)) {
01127       fp = fopen(misdn_init, "r");
01128       if (fp) {
01129          while(fgets(line, sizeof(line), fp)) {
01130             if (!strncmp(line, "nt_ptp", 6)) {
01131                for (tok = strtok_r(line,",=", &p);
01132                    tok;
01133                    tok = strtok_r(NULL,",=", &p)) {
01134                   port = strtol(tok, &end, 10);
01135                   if (end != tok && misdn_cfg_is_port_valid(port)) {
01136                      misdn_cfg_lock();
01137                      ptp[port] = 1;
01138                      misdn_cfg_unlock();
01139                   }
01140                }
01141             }
01142          }
01143          fclose(fp);
01144       } else {
01145          ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno));
01146       }
01147    }
01148 #else
01149    int i;
01150    int proto;
01151    char filename[128];
01152    FILE *fp;
01153 
01154    for (i = 1; i <= max_ports; ++i) {
01155       snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8);
01156       fp = fopen(filename, "r");
01157       if (!fp) {
01158          ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno));
01159          continue;
01160       }
01161       if (fscanf(fp, "0x%08x", &proto) != 1)
01162          ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename);
01163       else
01164          ptp[i] = proto & 1<<5 ? 1 : 0;
01165       fclose(fp);
01166    }
01167 #endif
01168 }

struct ast_jb_conf* misdn_get_global_jbconf ( void   )  [read]

Definition at line 1273 of file misdn_config.c.

References global_jbconf.

Referenced by misdn_new().

01273                                               {
01274    return &global_jbconf;
01275 }


Generated on Thu Apr 16 06:29:43 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6