Fri Sep 25 19:28:26 2009

Asterisk developer's documentation


chan_misdn_config.h File Reference

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_METHOD,
  MISDN_CFG_DIALPLAN, MISDN_CFG_LOCALDIALPLAN, MISDN_CFG_CPNDIALPLAN, MISDN_CFG_NATPREFIX,
  MISDN_CFG_INTERNATPREFIX, MISDN_CFG_PRES, MISDN_CFG_SCREEN, 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_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 (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)
int misdn_cfg_init (int max_ports)
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)


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_METHOD 
MISDN_CFG_DIALPLAN 
MISDN_CFG_LOCALDIALPLAN 
MISDN_CFG_CPNDIALPLAN 
MISDN_CFG_NATPREFIX 
MISDN_CFG_INTERNATPREFIX 
MISDN_CFG_PRES 
MISDN_CFG_SCREEN 
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_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 21 of file chan_misdn_config.h.

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

Enumerator:
METHOD_STANDARD 
METHOD_ROUND_ROBIN 
METHOD_STANDARD_DEC 

Definition at line 106 of file chan_misdn_config.h.

00106                       {
00107    METHOD_STANDARD = 0,
00108    METHOD_ROUND_ROBIN,
00109    METHOD_STANDARD_DEC
00110 };


Function Documentation

void misdn_cfg_destroy ( void   ) 

Definition at line 1070 of file misdn_config.c.

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

Referenced by unload_module().

01071 {
01072    misdn_cfg_lock();
01073 
01074    _free_port_cfg();
01075    _free_general_cfg();
01076 
01077    free(port_cfg);
01078    free(general_cfg);
01079    free(ptp);
01080    free(map);
01081 
01082    misdn_cfg_unlock();
01083    ast_mutex_destroy(&config_mutex);
01084 }

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

Definition at line 509 of file misdn_config.c.

References misdn_cfg_pt::any, ast_log(), LOG_WARNING, misdn_cfg_is_port_valid(), MISDN_CFG_LAST, misdn_cfg_lock(), MISDN_CFG_PTP, misdn_cfg_unlock(), MISDN_CTYPE_STR, misdn_cfg_pt::str, and type.

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

00510 {
00511    int place;
00512 
00513    if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) {
00514       memset(buf, 0, bufsize);
00515       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Port number %d is not valid.\n", port);
00516       return;
00517    }
00518 
00519    misdn_cfg_lock();
00520    if (elem == MISDN_CFG_PTP) {
00521       if (!memcpy(buf, &ptp[port], (bufsize > ptp[port]) ? sizeof(ptp[port]) : bufsize))
00522          memset(buf, 0, bufsize);
00523    } else {
00524       if ((place = map[elem]) < 0) {
00525          memset (buf, 0, bufsize);
00526          ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Invalid element (%d) requested.\n", elem);
00527       } else {
00528          if (elem < MISDN_CFG_LAST) {
00529             switch (port_spec[place].type) {
00530             case MISDN_CTYPE_STR:
00531                if (port_cfg[port][place].str) {
00532                   if (!memccpy(buf, port_cfg[port][place].str, 0, bufsize))
00533                      memset(buf, 0, 1);
00534                } else if (port_cfg[0][place].str) {
00535                   if (!memccpy(buf, port_cfg[0][place].str, 0, bufsize))
00536                      memset(buf, 0, 1);
00537                }
00538                break;
00539             default:
00540                if (port_cfg[port][place].any)
00541                   memcpy(buf, port_cfg[port][place].any, bufsize);
00542                else if (port_cfg[0][place].any)
00543                   memcpy(buf, port_cfg[0][place].any, bufsize);
00544                else
00545                   memset(buf, 0, bufsize);
00546             }
00547          } else {
00548             switch (gen_spec[place].type) {
00549             case MISDN_CTYPE_STR:
00550                if (!general_cfg[place].str || !memccpy(buf, general_cfg[place].str, 0, bufsize))
00551                   memset(buf, 0, 1);
00552                break;
00553             default:
00554                if (general_cfg[place].any)
00555                   memcpy(buf, general_cfg[place].any, bufsize);
00556                else
00557                   memset(buf, 0, bufsize);
00558             }
00559          }
00560       }
00561    }
00562    misdn_cfg_unlock();
00563 }

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

Definition at line 734 of file misdn_config.c.

References ast_log(), ast_print_group(), 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_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, and type.

Referenced by misdn_show_config().

00735 {
00736    int place;
00737    char tempbuf[BUFFERSIZE] = "";
00738    struct msn_list *iter;
00739 
00740    if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) {
00741       *buf = 0;
00742       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Port number %d is not valid.\n", port);
00743       return;
00744    }
00745 
00746    place = map[elem];
00747 
00748    misdn_cfg_lock();
00749    if (elem == MISDN_CFG_PTP) {
00750       snprintf(buf, bufsize, " -> ptp: %s", ptp[port] ? "yes" : "no");
00751    }
00752    else if (elem > MISDN_CFG_FIRST && elem < MISDN_CFG_LAST) {
00753       switch (port_spec[place].type) {
00754       case MISDN_CTYPE_INT:
00755       case MISDN_CTYPE_BOOLINT:
00756          if (port_cfg[port][place].num)
00757             snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[port][place].num);
00758          else if (port_cfg[0][place].num)
00759             snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[0][place].num);
00760          else
00761             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00762          break;
00763       case MISDN_CTYPE_BOOL:
00764          if (port_cfg[port][place].num)
00765             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[port][place].num ? "yes" : "no");
00766          else if (port_cfg[0][place].num)
00767             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[0][place].num ? "yes" : "no");
00768          else
00769             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00770          break;
00771       case MISDN_CTYPE_ASTGROUP:
00772          if (port_cfg[port][place].grp)
00773             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 
00774                    ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp));
00775          else if (port_cfg[0][place].grp)
00776             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 
00777                    ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp));
00778          else
00779             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00780          break;
00781       case MISDN_CTYPE_MSNLIST:
00782          if (port_cfg[port][place].ml)
00783             iter = port_cfg[port][place].ml;
00784          else
00785             iter = port_cfg[0][place].ml;
00786          if (iter) {
00787             for (; iter; iter = iter->next)
00788                sprintf(tempbuf, "%s%s, ", tempbuf, iter->msn);
00789             tempbuf[strlen(tempbuf)-2] = 0;
00790          }
00791          snprintf(buf, bufsize, " -> msns: %s", *tempbuf ? tempbuf : "none");
00792          break;
00793       case MISDN_CTYPE_STR:
00794          if ( port_cfg[port][place].str) {
00795             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[port][place].str);
00796          } else if (port_cfg[0][place].str) {
00797             snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[0][place].str);
00798          } else {
00799             snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
00800          }
00801          break;
00802       }
00803    } else if (elem > MISDN_GEN_FIRST && elem < MISDN_GEN_LAST) {
00804       switch (gen_spec[place].type) {
00805       case MISDN_CTYPE_INT:
00806       case MISDN_CTYPE_BOOLINT:
00807          if (general_cfg[place].num)
00808             snprintf(buf, bufsize, " -> %s: %d", gen_spec[place].name, *general_cfg[place].num);
00809          else
00810             snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
00811          break;
00812       case MISDN_CTYPE_BOOL:
00813          if (general_cfg[place].num)
00814             snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, *general_cfg[place].num ? "yes" : "no");
00815          else
00816             snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
00817          break;
00818       case MISDN_CTYPE_STR:
00819          if ( general_cfg[place].str) {
00820             snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, general_cfg[place].str);
00821          } else {
00822             snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
00823          }
00824          break;
00825       default:
00826          snprintf(buf, bufsize, " -> type of %s not handled yet", gen_spec[place].name);
00827          break;
00828       }
00829    } else {
00830       *buf = 0;
00831       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Invalid config element (%d) requested.\n", elem);
00832    }
00833    misdn_cfg_unlock();
00834 }

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

Definition at line 613 of file misdn_config.c.

References misdn_cfg_spec::def, desc, MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, MISDN_CFG_LAST, MISDN_GEN_FIRST, MISDN_GEN_LAST, and NO_DEFAULT.

Referenced by show_config_description().

00614 {
00615    int place = map[elem];
00616    struct misdn_cfg_spec *spec = NULL;
00617 
00618    /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */
00619    if (elem == MISDN_CFG_GROUPNAME) {
00620       if (!memccpy(buf, ports_description, 0, bufsize))
00621          memset(buf, 0, 1);
00622       if (buf_default && bufsize_default)
00623          memset(buf_default, 0, 1);
00624       return;
00625    }
00626 
00627    if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST))
00628       spec = (struct misdn_cfg_spec *)port_spec;
00629    else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST))
00630       spec = (struct misdn_cfg_spec *)gen_spec;
00631       
00632    if (!spec || !spec[place].desc)
00633       memset(buf, 0, 1);
00634    else {
00635       if (!memccpy(buf, spec[place].desc, 0, bufsize))
00636          memset(buf, 0, 1);
00637       if (buf_default && bufsize) {
00638          if (!strcmp(spec[place].def, NO_DEFAULT))
00639             memset(buf_default, 0, 1);
00640          else if (!memccpy(buf_default, spec[place].def, 0, bufsize_default))
00641             memset(buf_default, 0, 1);
00642       }
00643    }
00644 }

enum misdn_cfg_elements misdn_cfg_get_elem ( char *  name  ) 

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

00566 {
00567    int pos;
00568 
00569    /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */
00570    if (!strcmp(name, "ports"))
00571       return MISDN_CFG_GROUPNAME;
00572    if (!strcmp(name, "name"))
00573       return MISDN_CFG_FIRST;
00574 
00575    pos = get_cfg_position (name, PORT_CFG);
00576    if (pos >= 0)
00577       return port_spec[pos].elem;
00578    
00579    pos = get_cfg_position (name, GEN_CFG);
00580    if (pos >= 0)
00581       return gen_spec[pos].elem;
00582    
00583    return MISDN_CFG_FIRST;
00584 }

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

Definition at line 586 of file misdn_config.c.

References MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, MISDN_CFG_LAST, MISDN_CFG_PTP, MISDN_GEN_FIRST, MISDN_GEN_LAST, and name.

Referenced by complete_show_config(), and show_config_description().

00587 {
00588    struct misdn_cfg_spec *spec = NULL;
00589    int place = map[elem];
00590 
00591    /* the ptp hack */
00592    if (elem == MISDN_CFG_PTP) {
00593       memset(buf, 0, 1);
00594       return;
00595    }
00596    
00597    /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */
00598    if (elem == MISDN_CFG_GROUPNAME) {
00599       if (!snprintf(buf, bufsize, "ports"))
00600          memset(buf, 0, 1);
00601       return;
00602    }
00603    
00604    if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST))
00605       spec = (struct misdn_cfg_spec *)port_spec;
00606    else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST))
00607       spec = (struct misdn_cfg_spec *)gen_spec;
00608 
00609    if (!spec || !memccpy(buf, spec[place].name, 0, bufsize))
00610       memset(buf, 0, 1);
00611 }

int misdn_cfg_get_next_port ( int  port  ) 

Definition at line 836 of file misdn_config.c.

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

Referenced by complete_show_config(), load_module(), misdn_cfg_get_next_port_spin(), misdn_check_l2l1(), misdn_new(), misdn_request(), misdn_show_config(), misdn_show_ports_stats(), misdn_show_stacks(), and update_name().

00837 {
00838    int p = -1;
00839    int gn = map[MISDN_CFG_GROUPNAME];
00840    
00841    misdn_cfg_lock();
00842    for (port++; port <= max_ports; port++) {
00843       if (port_cfg[port][gn].str) {
00844          p = port;
00845          break;
00846       }
00847    }
00848    misdn_cfg_unlock();
00849 
00850    return p;
00851 }

int misdn_cfg_get_next_port_spin ( int  port  ) 

Definition at line 853 of file misdn_config.c.

References misdn_cfg_get_next_port().

Referenced by misdn_request().

00854 {
00855    int p = misdn_cfg_get_next_port(port);
00856    return (p > 0) ? p : misdn_cfg_get_next_port(0);
00857 }

void misdn_cfg_get_ports_string ( char *  ports  ) 

Definition at line 710 of file misdn_config.c.

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

Referenced by load_module().

00711 {
00712    char tmp[16];
00713    int l, i;
00714    int gn = map[MISDN_CFG_GROUPNAME];
00715 
00716    *ports = 0;
00717 
00718    misdn_cfg_lock();
00719    for (i = 1; i <= max_ports; i++) {
00720       if (port_cfg[i][gn].str) {
00721          if (ptp[i])
00722             sprintf(tmp, "%dptp,", i);
00723          else
00724             sprintf(tmp, "%d,", i);
00725          strcat(ports, tmp);
00726       }
00727    }
00728    misdn_cfg_unlock();
00729 
00730    if ((l = strlen(ports)))
00731       ports[l-1] = 0;
00732 }

int misdn_cfg_init ( int  max_ports  ) 

Definition at line 1086 of file misdn_config.c.

References _build_general_config(), _build_port_config(), _enum_array_map(), _fill_defaults(), _free_general_cfg(), _free_port_cfg(), ast_category_browse(), AST_DESTROY_CFG, AST_LOAD_CFG, ast_log(), ast_mutex_init(), ast_variable_browse(), calloc, config, LOG_WARNING, misdn_cfg_lock(), misdn_cfg_unlock(), MISDN_GEN_LAST, NUM_GEN_ELEMENTS, and NUM_PORT_ELEMENTS.

Referenced by load_module(), and misdn_cfg_reload().

01087 {
01088    char config[] = "misdn.conf";
01089    char *cat, *p;
01090    int i;
01091    struct ast_config *cfg;
01092    struct ast_variable *v;
01093 
01094    if (!(cfg = AST_LOAD_CFG(config))) {
01095       ast_log(LOG_WARNING, "missing file: misdn.conf\n");
01096       return -1;
01097    }
01098 
01099    ast_mutex_init(&config_mutex);
01100 
01101    misdn_cfg_lock();
01102 
01103    if (this_max_ports) {
01104       /* this is the first run */
01105       max_ports = this_max_ports;
01106       map = (int *)calloc(MISDN_GEN_LAST + 1, sizeof(int));
01107       if (_enum_array_map())
01108          return -1;
01109       p = (char *)calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *)
01110                      + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt));
01111       port_cfg = (union misdn_cfg_pt **)p;
01112       p += (max_ports + 1) * sizeof(union misdn_cfg_pt *);
01113       for (i = 0; i <= max_ports; ++i) {
01114          port_cfg[i] = (union misdn_cfg_pt *)p;
01115          p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt);
01116       }
01117       general_cfg = (union misdn_cfg_pt *)calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
01118       ptp = (int *)calloc(max_ports + 1, sizeof(int));
01119    }
01120    else {
01121       /* misdn reload */
01122       _free_port_cfg();
01123       _free_general_cfg();
01124       memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1));
01125       memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
01126       memset(ptp, 0, sizeof(int) * (max_ports + 1));
01127    }
01128 
01129    cat = ast_category_browse(cfg, NULL);
01130 
01131    while(cat) {
01132       v = ast_variable_browse(cfg, cat);
01133       if (!strcasecmp(cat, "general")) {
01134          _build_general_config(v);
01135       } else {
01136          _build_port_config(v, cat);
01137       }
01138       cat = ast_category_browse(cfg, cat);
01139    }
01140 
01141    _fill_defaults();
01142 
01143    misdn_cfg_unlock();
01144    AST_DESTROY_CFG(cfg);
01145 
01146    return 0;
01147 }

int misdn_cfg_is_group_method ( char *  group,
enum misdn_cfg_method  meth 
)

Definition at line 678 of file misdn_config.c.

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

Referenced by misdn_request().

00679 {
00680    int i, re = 0;
00681    char *method ;
00682 
00683    misdn_cfg_lock();
00684 
00685    method = port_cfg[0][map[MISDN_CFG_METHOD]].str;
00686 
00687    for (i = 1; i <= max_ports; i++) {
00688       if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) {
00689          if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group))
00690             method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ? 
00691                     port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str);
00692       }
00693    }
00694 
00695    if (method) {
00696       switch (meth) {
00697       case METHOD_STANDARD:      re = !strcasecmp(method, "standard");
00698                            break;
00699       case METHOD_ROUND_ROBIN:   re = !strcasecmp(method, "round_robin");
00700                            break;
00701       case METHOD_STANDARD_DEC:  re = !strcasecmp(method, "standard_dec");
00702                            break;
00703       }
00704    }
00705    misdn_cfg_unlock();
00706 
00707    return re;
00708 }

int misdn_cfg_is_msn_valid ( int  port,
char *  msn 
)

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

00647 {
00648    int re = 0;
00649    struct msn_list *iter;
00650 
00651    if (!misdn_cfg_is_port_valid(port)) {
00652       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port);
00653       return 0;
00654    }
00655 
00656    misdn_cfg_lock();
00657    if (port_cfg[port][map[MISDN_CFG_MSNS]].ml)
00658       iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml;
00659    else
00660       iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml;
00661    for (; iter; iter = iter->next) 
00662       if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) {
00663          re = 1;
00664          break;
00665       }
00666    misdn_cfg_unlock();
00667 
00668    return re;
00669 }

int misdn_cfg_is_port_valid ( int  port  ) 

Definition at line 671 of file misdn_config.c.

References MISDN_CFG_GROUPNAME.

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

00672 {
00673    int gn = map[MISDN_CFG_GROUPNAME];
00674 
00675    return (port >= 1 && port <= max_ports && port_cfg[port][gn].str);
00676 }

void misdn_cfg_reload ( void   ) 

Definition at line 1065 of file misdn_config.c.

References misdn_cfg_init().

Referenced by reload_config().

01066 {
01067    misdn_cfg_init (0);
01068 }

void misdn_cfg_update_ptp ( void   ) 

Definition at line 996 of file misdn_config.c.

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

Referenced by load_module(), and reload_config().

00997 {
00998 #ifndef MISDN_1_2
00999    char misdn_init[BUFFERSIZE];
01000    char line[BUFFERSIZE];
01001    FILE *fp;
01002    char *tok, *p, *end;
01003    int port;
01004 
01005    misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init));
01006 
01007    if (!ast_strlen_zero(misdn_init)) {
01008       fp = fopen(misdn_init, "r");
01009       if (fp) {
01010          while(fgets(line, sizeof(line), fp)) {
01011             if (!strncmp(line, "nt_ptp", 6)) {
01012                for (tok = strtok_r(line,",=", &p);
01013                    tok;
01014                    tok = strtok_r(NULL,",=", &p)) {
01015                   port = strtol(tok, &end, 10);
01016                   if (end != tok && misdn_cfg_is_port_valid(port)) {
01017                      misdn_cfg_lock();
01018                      ptp[port] = 1;
01019                      misdn_cfg_unlock();
01020                   }
01021                }
01022             }
01023          }
01024          fclose(fp);
01025       } else {
01026          ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno));
01027       }
01028    }
01029 #else
01030    int i;
01031    int proto;
01032    char filename[128];
01033    FILE *fp;
01034 
01035    for (i = 1; i <= max_ports; ++i) {
01036       snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8);
01037       fp = fopen(filename, "r");
01038       if (!fp) {
01039          ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno));
01040          continue;
01041       }
01042       if (fscanf(fp, "0x%08x", &proto) != 1)
01043          ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename);
01044       else
01045          ptp[i] = proto & 1<<5 ? 1 : 0;
01046       fclose(fp);
01047    }
01048 #endif
01049 }


Generated on Fri Sep 25 19:28:26 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.5