Sat Nov 1 06:28:55 2008

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)
 Generate a comma separated list of all active 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

Definition at line 19 of file chan_misdn_config.h.

Referenced by _build_port_config(), complete_show_config(), load_module(), misdn_cfg_get_config_string(), misdn_cfg_update_ptp(), misdn_check_l2l1(), misdn_request(), misdn_show_config(), process_ast_dsp(), read_config(), reload_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_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 };

enum misdn_cfg_method

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 1080 of file misdn_config.c.

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

Referenced by unload_module().

01081 {
01082    misdn_cfg_lock();
01083 
01084    _free_port_cfg();
01085    _free_general_cfg();
01086 
01087    free(port_cfg);
01088    free(general_cfg);
01089    free(ptp);
01090    free(map);
01091 
01092    misdn_cfg_unlock();
01093    ast_mutex_destroy(&config_mutex);
01094 }

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

Definition at line 513 of file misdn_config.c.

References misdn_cfg_pt::any, 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, 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().

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

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

Definition at line 744 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, and type.

Referenced by misdn_show_config().

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

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

Definition at line 618 of file misdn_config.c.

References 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().

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

enum misdn_cfg_elements misdn_cfg_get_elem ( char *  name  ) 

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

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

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

Definition at line 591 of file misdn_config.c.

References 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().

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

int misdn_cfg_get_next_port ( int  port  ) 

Definition at line 846 of file misdn_config.c.

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

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().

00847 {
00848    int p = -1;
00849    int gn = map[MISDN_CFG_GROUPNAME];
00850    
00851    misdn_cfg_lock();
00852    for (port++; port <= max_ports; port++) {
00853       if (port_cfg[port][gn].str) {
00854          p = port;
00855          break;
00856       }
00857    }
00858    misdn_cfg_unlock();
00859 
00860    return p;
00861 }

int misdn_cfg_get_next_port_spin ( int  port  ) 

Definition at line 863 of file misdn_config.c.

References misdn_cfg_get_next_port().

Referenced by misdn_request().

00864 {
00865    int p = misdn_cfg_get_next_port(port);
00866    return (p > 0) ? p : misdn_cfg_get_next_port(0);
00867 }

void misdn_cfg_get_ports_string ( char *  ports  ) 

Generate a comma separated list of all active ports.

Definition at line 718 of file misdn_config.c.

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

Referenced by load_module().

00719 {
00720    char tmp[16];
00721    int l, i;
00722    int gn = map[MISDN_CFG_GROUPNAME];
00723 
00724    *ports = 0;
00725 
00726    misdn_cfg_lock();
00727    for (i = 1; i <= max_ports; i++) {
00728       if (port_cfg[i][gn].str) {
00729          if (ptp[i])
00730             sprintf(tmp, "%dptp,", i);
00731          else
00732             sprintf(tmp, "%d,", i);
00733          strcat(ports, tmp);
00734       }
00735    }
00736    misdn_cfg_unlock();
00737 
00738    if ((l = strlen(ports))) {
00739       /* Strip trailing ',' */
00740       ports[l-1] = 0;
00741    }
00742 }

int misdn_cfg_init ( int  max_ports  ) 

Definition at line 1096 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, config_mutex, general_cfg, 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().

01097 {
01098    char config[] = "misdn.conf";
01099    char *cat, *p;
01100    int i;
01101    struct ast_config *cfg;
01102    struct ast_variable *v;
01103 
01104    if (!(cfg = AST_LOAD_CFG(config))) {
01105       ast_log(LOG_WARNING, "missing file: misdn.conf\n");
01106       return -1;
01107    }
01108 
01109    ast_mutex_init(&config_mutex);
01110 
01111    misdn_cfg_lock();
01112 
01113    if (this_max_ports) {
01114       /* this is the first run */
01115       max_ports = this_max_ports;
01116       map = (int *)calloc(MISDN_GEN_LAST + 1, sizeof(int));
01117       if (_enum_array_map())
01118          return -1;
01119       p = (char *)calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *)
01120                      + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt));
01121       port_cfg = (union misdn_cfg_pt **)p;
01122       p += (max_ports + 1) * sizeof(union misdn_cfg_pt *);
01123       for (i = 0; i <= max_ports; ++i) {
01124          port_cfg[i] = (union misdn_cfg_pt *)p;
01125          p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt);
01126       }
01127       general_cfg = (union misdn_cfg_pt *)calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
01128       ptp = (int *)calloc(max_ports + 1, sizeof(int));
01129    }
01130    else {
01131       /* misdn reload */
01132       _free_port_cfg();
01133       _free_general_cfg();
01134       memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1));
01135       memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
01136       memset(ptp, 0, sizeof<