Tue Nov 4 13:20:40 2008

Asterisk developer's documentation


misdn_config.c File Reference

chan_misdn configuration management More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "chan_misdn_config.h"
#include "asterisk/config.h"
#include "asterisk/channel.h"
#include "asterisk/logger.h"
#include "asterisk/lock.h"
#include "asterisk/pbx.h"
#include "asterisk/strings.h"
#include "asterisk/utils.h"

Go to the source code of this file.

Data Structures

union  misdn_cfg_pt
struct  misdn_cfg_spec
struct  msn_list

Defines

#define AST_DESTROY_CFG   ast_config_destroy
#define AST_LOAD_CFG   ast_config_load
#define CLI_ERROR(name, value, section)
#define GEN_CFG   1
#define NO_DEFAULT   "<>"
#define NONE   0
#define NUM_GEN_ELEMENTS   (sizeof(gen_spec) / sizeof(struct misdn_cfg_spec))
#define NUM_PORT_ELEMENTS   (sizeof(port_spec) / sizeof(struct misdn_cfg_spec))
#define PORT_CFG   2

Enumerations

enum  misdn_cfg_type {
  MISDN_CTYPE_STR, MISDN_CTYPE_INT, MISDN_CTYPE_BOOL, MISDN_CTYPE_BOOLINT,
  MISDN_CTYPE_MSNLIST, MISDN_CTYPE_ASTGROUP
}

Functions

static void _build_general_config (struct ast_variable *v)
static void _build_port_config (struct ast_variable *v, char *cat)
static int _enum_array_map (void)
static void _fill_defaults (void)
static void _free_general_cfg (void)
static void _free_msn_list (struct msn_list *iter)
static void _free_port_cfg (void)
static int _parse (union misdn_cfg_pt *dest, char *value, enum misdn_cfg_type type, int boolint_def)
static int get_cfg_position (char *name, int type)
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 this_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)
static void misdn_cfg_lock (void)
void misdn_cfg_reload (void)
static void misdn_cfg_unlock (void)
void misdn_cfg_update_ptp (void)
ast_jb_confmisdn_get_global_jbconf ()

Variables

static ast_mutex_t config_mutex
static struct ast_jb_conf default_jbconf
static struct misdn_cfg_spec gen_spec []
static union misdn_cfg_ptgeneral_cfg
static struct ast_jb_conf global_jbconf
static int * map
static int max_ports
static union misdn_cfg_pt ** port_cfg
static struct misdn_cfg_spec port_spec []
static const char ports_description []
static int * ptp


Detailed Description

chan_misdn configuration management

Author:
Christian Richter <crich@beronet.com>

Definition in file misdn_config.c.


Define Documentation

#define AST_DESTROY_CFG   ast_config_destroy

Definition at line 49 of file misdn_config.c.

Referenced by misdn_cfg_init().

#define AST_LOAD_CFG   ast_config_load

Definition at line 48 of file misdn_config.c.

Referenced by misdn_cfg_init().

#define CLI_ERROR ( name,
value,
section   ) 

Value:

({ \
   ast_log(LOG_WARNING, "misdn.conf: \"%s=%s\" (section: %s) invalid or out of range. " \
      "Please edit your misdn.conf and then do a \"misdn reload\".\n", name, value, section); \
})

Definition at line 396 of file misdn_config.c.

Referenced by _build_general_config(), and _build_port_config().

#define GEN_CFG   1

Definition at line 54 of file misdn_config.c.

Referenced by _build_general_config(), get_cfg_position(), and misdn_cfg_get_elem().

#define NO_DEFAULT   "<>"

Definition at line 51 of file misdn_config.c.

Referenced by _fill_defaults(), and misdn_cfg_get_desc().

#define NONE   0

Definition at line 52 of file misdn_config.c.

#define NUM_GEN_ELEMENTS   (sizeof(gen_spec) / sizeof(struct misdn_cfg_spec))

Definition at line 56 of file misdn_config.c.

Referenced by _enum_array_map(), _fill_defaults(), _free_general_cfg(), get_cfg_position(), and misdn_cfg_init().

#define NUM_PORT_ELEMENTS   (sizeof(port_spec) / sizeof(struct misdn_cfg_spec))

Definition at line 57 of file misdn_config.c.

Referenced by _build_port_config(), _enum_array_map(), _fill_defaults(), _free_port_cfg(), get_cfg_position(), and misdn_cfg_init().

#define PORT_CFG   2

Definition at line 55 of file misdn_config.c.

Referenced by _build_port_config(), get_cfg_position(), and misdn_cfg_get_elem().


Enumeration Type Documentation

enum misdn_cfg_type

Enumerator:
MISDN_CTYPE_STR 
MISDN_CTYPE_INT 
MISDN_CTYPE_BOOL 
MISDN_CTYPE_BOOLINT 
MISDN_CTYPE_MSNLIST 
MISDN_CTYPE_ASTGROUP 

Definition at line 70 of file misdn_config.c.


Function Documentation

static void _build_general_config ( struct ast_variable v  )  [static]

Definition at line 934 of file misdn_config.c.

References _parse(), ast_jb_read_conf(), misdn_cfg_spec::boolint_def, CLI_ERROR, GEN_CFG, gen_spec, general_cfg, get_cfg_position(), global_jbconf, ast_variable::name, ast_variable::next, misdn_cfg_spec::type, and ast_variable::value.

Referenced by misdn_cfg_init().

00935 {
00936    int pos;
00937 
00938    for (; v; v = v->next) {
00939       if (!ast_jb_read_conf(&global_jbconf, v->name, v->value))
00940          continue;
00941       if (((pos = get_cfg_position(v->name, GEN_CFG)) < 0) || 
00942          (_parse(&general_cfg[pos], v->value, gen_spec[pos].type, gen_spec[pos].boolint_def) < 0))
00943          CLI_ERROR(v->name, v->value, "general");
00944    }
00945 }

static void _build_port_config ( struct ast_variable v,
char *  cat 
) [static]

Definition at line 947 of file misdn_config.c.

References _parse(), BUFFERSIZE, CLI_ERROR, get_cfg_position(), max_ports, ast_variable::name, ast_variable::next, NUM_PORT_ELEMENTS, PORT_CFG, port_spec, ptp, strsep(), type, and ast_variable::value.

Referenced by misdn_cfg_init().

00948 {
00949    int pos, i;
00950    union misdn_cfg_pt cfg_tmp[NUM_PORT_ELEMENTS];
00951    int cfg_for_ports[max_ports + 1];
00952 
00953    if (!v || !cat)
00954       return;
00955 
00956    memset(cfg_tmp, 0, sizeof(cfg_tmp));
00957    memset(cfg_for_ports, 0, sizeof(cfg_for_ports));
00958 
00959    if (!strcasecmp(cat, "default")) {
00960       cfg_for_ports[0] = 1;
00961    }
00962 
00963    if (((pos = get_cfg_position("name", PORT_CFG)) < 0) || 
00964       (_parse(&cfg_tmp[pos], cat, port_spec[pos].type, port_spec[pos].boolint_def) < 0)) {
00965       CLI_ERROR(v->name, v->value, cat);
00966       return;
00967    }
00968 
00969    for (; v; v = v->next) {
00970       if (!strcasecmp(v->name, "ports")) {
00971          char *token;
00972          char ptpbuf[BUFFERSIZE] = "";
00973          int start, end;
00974          for (token = strsep(&v->value, ","); token; token = strsep(&v->value, ","), *ptpbuf = 0) { 
00975             if (!*token)
00976                continue;
00977             if (sscanf(token, "%d-%d%s", &start, &end, ptpbuf) >= 2) {
00978                for (; start <= end; start++) {
00979                   if (start <= max_ports && start > 0) {
00980                      cfg_for_ports[start] = 1;
00981                      ptp[start] = (strstr(ptpbuf, "ptp")) ? 1 : 0;
00982                   } else
00983                      CLI_ERROR(v->name, v->value, cat);
00984                }
00985             } else {
00986                if (sscanf(token, "%d%s", &start, ptpbuf)) {
00987                   if (start <= max_ports && start > 0) {
00988                      cfg_for_ports[start] = 1;
00989                      ptp[start] = (strstr(ptpbuf, "ptp")) ? 1 : 0;
00990                   } else
00991                      CLI_ERROR(v->name, v->value, cat);
00992                } else
00993                   CLI_ERROR(v->name, v->value, cat);
00994             }
00995          }
00996       } else {
00997          if (((pos = get_cfg_position(v->name, PORT_CFG)) < 0) || 
00998             (_parse(&cfg_tmp[pos], v->value, port_spec[pos].type, port_spec[pos].boolint_def) < 0))
00999             CLI_ERROR(v->name, v->value, cat);
01000       }
01001    }
01002 
01003    for (i = 0; i < (max_ports + 1); ++i) {
01004       if (cfg_for_ports[i]) {
01005          memcpy(port_cfg[i], cfg_tmp, sizeof(cfg_tmp));
01006       }
01007    }
01008 }

static int _enum_array_map ( void   )  [static]

Definition at line 401 of file misdn_config.c.

References ast_log(), gen_spec, LOG_WARNING, MISDN_CFG_FIRST, MISDN_CFG_LAST, MISDN_CFG_PTP, MISDN_GEN_FIRST, MISDN_GEN_LAST, NUM_GEN_ELEMENTS, NUM_PORT_ELEMENTS, and port_spec.

Referenced by misdn_cfg_init().

00402 {
00403    int i, j, ok;
00404 
00405    for (i = MISDN_CFG_FIRST + 1; i < MISDN_CFG_LAST; ++i) {
00406       if (i == MISDN_CFG_PTP)
00407          continue;
00408       ok = 0;
00409       for (j = 0; j < NUM_PORT_ELEMENTS; ++j) {
00410          if (port_spec[j].elem == i) {
00411             map[i] = j;
00412             ok = 1;
00413             break;
00414          }
00415       }
00416       if (!ok) {
00417          ast_log(LOG_WARNING, "Enum element %d in misdn_cfg_elements (port section) has no corresponding element in the config struct!\n", i);
00418          return -1;
00419       }
00420    }
00421    for (i = MISDN_GEN_FIRST + 1; i < MISDN_GEN_LAST; ++i) {
00422       ok = 0;
00423       for (j = 0; j < NUM_GEN_ELEMENTS; ++j) {
00424          if (gen_spec[j].elem == i) {
00425             map[i] = j;
00426             ok = 1;
00427             break;
00428          }
00429       }
00430       if (!ok) {
00431          ast_log(LOG_WARNING, "Enum element %d in misdn_cfg_elements (general section) has no corresponding element in the config struct!\n", i);
00432          return -1;
00433       }
00434    }
00435    return 0;
00436 }

static void _fill_defaults ( void   )  [static]

Definition at line 1065 of file misdn_config.c.

References _parse(), misdn_cfg_pt::any, gen_spec, general_cfg, NO_DEFAULT, NUM_GEN_ELEMENTS, NUM_PORT_ELEMENTS, port_cfg, port_spec, and type.

Referenced by misdn_cfg_init().

01066 {
01067    int i;
01068 
01069    for (i = 0; i < NUM_PORT_ELEMENTS; ++i) {
01070       if (!port_cfg[0][i].any && strcasecmp(port_spec[i].def, NO_DEFAULT))
01071          _parse(&(port_cfg[0][i]), (char *)port_spec[i].def, port_spec[i].type, port_spec[i].boolint_def);
01072    }
01073    for (i = 0; i < NUM_GEN_ELEMENTS; ++i) {
01074       if (!general_cfg[i].any && strcasecmp(gen_spec[i].def, NO_DEFAULT))
01075          _parse(&(general_cfg[i]), (char *)gen_spec[i].def, gen_spec[i].type, gen_spec[i].boolint_def);
01076    }
01077 }

static void _free_general_cfg ( void   )  [static]

Definition at line 511 of file misdn_config.c.

References misdn_cfg_pt::any, free, general_cfg, and NUM_GEN_ELEMENTS.

Referenced by misdn_cfg_destroy(), and misdn_cfg_init().

00512 {
00513    int i;
00514 
00515    for (i = 0; i < NUM_GEN_ELEMENTS; i++) 
00516       if (general_cfg[i].any)
00517          free(general_cfg[i].any);
00518 }

static void _free_msn_list ( struct msn_list iter  )  [static]

Definition at line 469 of file misdn_config.c.

References free, msn_list::msn, and msn_list::next.

Referenced by _free_port_cfg().

00470 {
00471    if (iter->next)
00472       _free_msn_list(iter->next);
00473    if (iter->msn)
00474       free(iter->msn);
00475    free(iter);
00476 }

static void _free_port_cfg ( void   )  [static]

Definition at line 478 of file misdn_config.c.

References _free_msn_list(), misdn_cfg_pt::any, free, MISDN_CFG_GROUPNAME, MISDN_CTYPE_MSNLIST, misdn_cfg_pt::ml, NUM_PORT_ELEMENTS, port_cfg, port_spec, misdn_cfg_pt::str, and type.

Referenced by misdn_cfg_destroy(), and misdn_cfg_init().

00479 {
00480    int i, j;
00481    int gn = map[MISDN_CFG_GROUPNAME];
00482    union misdn_cfg_pt* free_list[max_ports + 2];
00483    
00484    memset(free_list, 0, sizeof(free_list));
00485    free_list[0] = port_cfg[0];
00486    for (i = 1; i <= max_ports; ++i) {
00487       if (port_cfg[i][gn].str) {
00488          /* we always have a groupname in the non-default case, so this is fine */
00489          for (j = 1; j <= max_ports; ++j) {
00490             if (free_list[j] && free_list[j][gn].str == port_cfg[i][gn].str)
00491                break;
00492             else if (!free_list[j]) {
00493                free_list[j] = port_cfg[i];
00494                break;
00495             }
00496          }
00497       }
00498    }
00499    for (j = 0; free_list[j]; ++j) {
00500       for (i = 0; i < NUM_PORT_ELEMENTS; ++i) {
00501          if (free_list[j][i].any) {
00502             if (port_spec[i].type == MISDN_CTYPE_MSNLIST)
00503                _free_msn_list(free_list[j][i].ml);
00504             else
00505                free(free_list[j][i].any);
00506          }
00507       }
00508    }
00509 }

static int _parse ( union misdn_cfg_pt dest,
char *  value,
enum misdn_cfg_type  type,
int  boolint_def 
) [static]

Definition at line 871 of file misdn_config.c.

References ast_get_group(), ast_true(), calloc, misdn_cfg_pt::grp, len, malloc, MISDN_CTYPE_ASTGROUP, MISDN_CTYPE_BOOL, MISDN_CTYPE_BOOLINT, MISDN_CTYPE_INT, MISDN_CTYPE_MSNLIST, MISDN_CTYPE_STR, misdn_cfg_pt::ml, msn_list::msn, msn_list::next, misdn_cfg_pt::num, misdn_cfg_pt::str, and strsep().

Referenced by _build_general_config(), _build_port_config(), and _fill_defaults().

00872 {
00873    int re = 0;
00874    int len, tmp;
00875    char *valtmp;
00876 
00877    switch (type) {
00878    case MISDN_CTYPE_STR:
00879       if ((len = strlen(value))) {
00880          dest->str = (char *)malloc((len + 1) * sizeof(char));
00881          strncpy(dest->str, value, len);
00882          dest->str[len] = 0;
00883       } else {
00884          dest->str = (char *)malloc( sizeof(char));
00885          dest->str[0] = 0;
00886       }
00887       break;
00888    case MISDN_CTYPE_INT:
00889    {
00890       char *pat;
00891       if (strchr(value,'x')) 
00892          pat="%x";
00893       else
00894          pat="%d";
00895       if (sscanf(value, pat, &tmp)) {
00896          dest->num = (int *)malloc(sizeof(int));
00897          memcpy(dest->num, &tmp, sizeof(int));
00898       } else
00899          re = -1;
00900    }
00901       break;
00902    case MISDN_CTYPE_BOOL:
00903       dest->num = (int *)malloc(sizeof(int));
00904       *(dest->num) = (ast_true(value) ? 1 : 0);
00905       break;
00906    case MISDN_CTYPE_BOOLINT:
00907       dest->num = (int *)malloc(sizeof(int));
00908       if (sscanf(value, "%d", &tmp)) {
00909          memcpy(dest->num, &tmp, sizeof(int));
00910       } else {
00911          *(dest->num) = (ast_true(value) ? boolint_def : 0);
00912       }
00913       break;
00914    case MISDN_CTYPE_MSNLIST:
00915       for (valtmp = strsep(&value, ","); valtmp; valtmp = strsep(&value, ",")) {
00916          if ((len = strlen(valtmp))) {
00917             struct msn_list *ml = (struct msn_list *)malloc(sizeof(struct msn_list));
00918             ml->msn = (char *)calloc(len+1, sizeof(char));
00919             strncpy(ml->msn, valtmp, len);
00920             ml->next = dest->ml;
00921             dest->ml = ml;
00922          }
00923       }
00924       break;
00925    case MISDN_CTYPE_ASTGROUP:
00926       dest->grp = (ast_group_t *)malloc(sizeof(ast_group_t));
00927       *(dest->grp) = ast_get_group(value);
00928       break;
00929    }
00930 
00931    return re;
00932 }

static int get_cfg_position ( char *  name,
int  type 
) [static]

Definition at line 438 of file misdn_config.c.

References GEN_CFG, gen_spec, NUM_GEN_ELEMENTS, NUM_PORT_ELEMENTS, PORT_CFG, and port_spec.

Referenced by _build_general_config(), _build_port_config(), and misdn_cfg_get_elem().

00439 {
00440    int i;
00441 
00442    switch (type) {
00443    case PORT_CFG:
00444       for (i = 0; i < NUM_PORT_ELEMENTS; ++i) {
00445          if (!strcasecmp(name, port_spec[i].name))
00446             return i;
00447       }
00448       break;
00449    case GEN_CFG:
00450       for (i = 0; i < NUM_GEN_ELEMENTS; ++i) {
00451          if (!strcasecmp(name, gen_spec[i].name))
00452             return i;
00453       }
00454    }
00455 
00456    return -1;
00457 }

void misdn_cfg_destroy ( void   ) 

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

01085 {
01086    misdn_cfg_lock();
01087 
01088    _free_port_cfg();
01089    _free_general_cfg();
01090 
01091    free(port_cfg);
01092    free(general_cfg);
01093    free(ptp);
01094    free(map);
01095 
01096    misdn_cfg_unlock();
01097    ast_mutex_destroy(&config_mutex);
01098 }

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

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

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

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

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

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

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

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

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

enum misdn_cfg_elements misdn_cfg_get_elem ( char *  name  ) 

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

00578 {
00579    int pos;
00580 
00581    /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */
00582    if (!strcmp(name, "ports"))
00583       return MISDN_CFG_GROUPNAME;
00584    if (!strcmp(name, "name"))
00585       return MISDN_CFG_FIRST;
00586 
00587    pos = get_cfg_position (name, PORT_CFG);
00588    if (pos >= 0)
00589       return port_spec[pos].elem;
00590    
00591    pos = get_cfg_position (name, GEN_CFG);
00592    if (pos >= 0)
00593       return gen_spec[pos].elem;
00594    
00595    return MISDN_CFG_FIRST;
00596 }

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

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

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

int misdn_cfg_get_next_port ( int  port  ) 

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

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

int misdn_cfg_get_next_port_spin ( int  port  ) 

Definition at line 865 of file misdn_config.c.

References misdn_cfg_get_next_port().

Referenced by misdn_request().

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

void misdn_cfg_get_ports_string ( char *  ports  ) 

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

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

int misdn_cfg_init ( int  this_max_ports  ) 

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

01101 {
01102    char config[] = "misdn.conf";
01103    char *cat, *p;
01104    int i;
01105    struct ast_config *cfg;
01106    struct ast_variable *v;
01107 
01108    if (!(cfg = AST_LOAD_CFG(config))) {
01109       ast_log(LOG_WARNING, "missing file: misdn.conf\n");
01110       return -1;
01111    }
01112 
01113    ast_mutex_init(&config_mutex);
01114 
01115    /* Copy the default jb config over global_jbconf */
01116    memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
01117 
01118    misdn_cfg_lock();
01119 
01120    if (this_max_ports) {
01121       /* this is the first run */
01122       max_ports = this_max_ports;
01123       map = (int *)calloc(MISDN_GEN_LAST + 1, sizeof(int));
01124       if (_enum_array_map())
01125          return -1;
01126       p = (char *)calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *)
01127                      + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt));
01128       port_cfg = (union misdn_cfg_pt **)p;
01129       p += (max_ports + 1) * sizeof(union misdn_cfg_pt *);
01130       for (i = 0; i <= max_ports; ++i) {
01131          port_cfg[i] = (union misdn_cfg_pt *)p;
01132          p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt);
01133       }
01134       general_cfg = (union misdn_cfg_pt *)calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
01135       ptp = (int *)calloc(max_ports + 1, sizeof(int));
01136    }
01137    else {
01138       /* misdn reload */
01139       _free_port_cfg();
01140       _free_general_cfg();
01141       memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1));
01142       memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
01143       memset(ptp, 0, sizeof(int) * (max_ports + 1));
01144    }
01145 
01146    cat = ast_category_browse(cfg, NULL);
01147 
01148    while(cat) {
01149       v = ast_variable_browse(cfg, cat);
01150       if (!strcasecmp(cat, "general")) {
01151          _build_general_config(v);
01152       } else {
01153          _build_port_config(v, cat);
01154       }
01155       cat = ast_category_browse(cfg, cat);
01156    }
01157 
01158    _fill_defaults();
01159 
01160    misdn_cfg_unlock();
01161    AST_DESTROY_CFG(cfg);
01162 
01163    return 0;
01164 }

int misdn_cfg_is_group_method ( char *  group,
enum misdn_cfg_method  meth 
)

Definition at line 690 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, and misdn_cfg_pt::str.

Referenced by misdn_request().

00691 {
00692    int i, re = 0;
00693    char *method ;
00694 
00695    misdn_cfg_lock();
00696 
00697    method = port_cfg[0][map[MISDN_CFG_METHOD]].str;
00698 
00699    for (i = 1; i <= max_ports; i++) {
00700       if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) {
00701          if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group))
00702             method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ? 
00703                     port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str);
00704       }
00705    }
00706 
00707    if (method) {
00708       switch (meth) {
00709       case METHOD_STANDARD:      re = !strcasecmp(method, "standard");
00710                            break;
00711       case METHOD_ROUND_ROBIN:   re = !strcasecmp(method, "round_robin");
00712                            break;
00713       case METHOD_STANDARD_DEC:  re = !strcasecmp(method, "standard_dec");
00714                            break;
00715       }
00716    }
00717    misdn_cfg_unlock();
00718 
00719    return re;
00720 }

int misdn_cfg_is_msn_valid ( int  port,
char *  msn 
)

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

00659 {
00660    int re = 0;
00661    struct msn_list *iter;
00662 
00663    if (!misdn_cfg_is_port_valid(port)) {
00664       ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port);
00665       return 0;
00666    }
00667 
00668    misdn_cfg_lock();
00669    if (port_cfg[port][map[MISDN_CFG_MSNS]].ml)
00670       iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml;
00671    else
00672       iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml;
00673    for (; iter; iter = iter->next) 
00674       if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) {
00675          re = 1;
00676          break;
00677       }
00678    misdn_cfg_unlock();
00679 
00680    return re;
00681 }

int misdn_cfg_is_port_valid ( int  port  ) 

Definition at line 683 of file misdn_config.c.

References map, max_ports, MISDN_CFG_GROUPNAME, and port_cfg.

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

00684 {
00685    int gn = map[MISDN_CFG_GROUPNAME];
00686 
00687    return (port >= 1 && port <= max_ports && port_cfg[port][gn].str);
00688 }

static void misdn_cfg_lock ( void   )  [inline, static]

Definition at line 459 of file misdn_config.c.

References ast_mutex_lock().

Referenced by misdn_cfg_destroy(), misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_get_next_port(), misdn_cfg_get_ports_string(), misdn_cfg_init(), misdn_cfg_is_group_method(), misdn_cfg_is_msn_valid(), and misdn_cfg_update_ptp().

00460 {
00461    ast_mutex_lock(&config_mutex);
00462 }

void misdn_cfg_reload ( void   ) 

Definition at line 1079 of file misdn_config.c.

References misdn_cfg_init().

Referenced by reload_config().

01080 {
01081    misdn_cfg_init (0);
01082 }

static void misdn_cfg_unlock ( void   )  [inline, static]

Definition at line 464 of file misdn_config.c.

References ast_mutex_unlock().

Referenced by misdn_cfg_destroy(), misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_get_next_port(), misdn_cfg_get_ports_string(), misdn_cfg_init(), misdn_cfg_is_group_method(), and misdn_cfg_update_ptp().

00465 {
00466    ast_mutex_unlock(&config_mutex);
00467 }

void misdn_cfg_update_ptp ( void   ) 

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

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

struct ast_jb_conf* misdn_get_global_jbconf ( void   ) 

Definition at line 1166 of file misdn_config.c.

References global_jbconf.

Referenced by misdn_new().

01166                                               {
01167    return &global_jbconf;
01168 }


Variable Documentation

ast_mutex_t config_mutex [static]

Definition at line 394 of file misdn_config.c.

Referenced by misdn_cfg_destroy(), and misdn_cfg_init().

struct ast_jb_conf default_jbconf [static]

Global jitterbuffer configuration - by default, jb is disabled

Definition at line 60 of file misdn_config.c.

struct misdn_cfg_spec gen_spec[] [static]

Definition at line 345 of file misdn_config.c.

Referenced by _build_general_config(), _enum_array_map(), _fill_defaults(), get_cfg_position(), misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_get_desc(), misdn_cfg_get_elem(), and misdn_cfg_get_name().

union misdn_cfg_pt* general_cfg [static]

Definition at line 388 of file misdn_config.c.

Referenced by _build_general_config(), _fill_defaults(), _free_general_cfg(), misdn_cfg_destroy(), misdn_cfg_get(), misdn_cfg_get_config_string(), and misdn_cfg_init().

struct ast_jb_conf global_jbconf [static]

Definition at line 68 of file misdn_config.c.

int* map [static]

Definition at line 392 of file misdn_config.c.

Referenced by append_mapping(), build_mapping(), build_translators(), clear_config_maps(), config_command(), destroy_map(), dundi_lookup_local(), dundi_show_mappings(), find_engine(), find_transcoders(), mark_mappings(), misdn_cfg_destroy(), misdn_cfg_get_config_string(), misdn_cfg_get_next_port(), misdn_cfg_get_ports_string(), misdn_cfg_init(), misdn_cfg_is_group_method(), misdn_cfg_is_port_valid(), and prune_mappings().

int max_ports [static]

Definition at line 386 of file misdn_config.c.

union misdn_cfg_pt** port_cfg [static]

Definition at line 384 of file misdn_config.c.

Referenced by _fill_defaults(), _free_port_cfg(), misdn_cfg_destroy(), misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_get_next_port(), misdn_cfg_get_ports_string(), misdn_cfg_init(), misdn_cfg_is_group_method(), misdn_cfg_is_msn_valid(), and misdn_cfg_is_port_valid().

struct misdn_cfg_spec port_spec[] [static]

Definition at line 105 of file misdn_config.c.

Referenced by _build_port_config(), _enum_array_map(), _fill_defaults(), _free_port_cfg(), get_cfg_position(), misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_get_desc(), misdn_cfg_get_elem(), and misdn_cfg_get_name().

const char ports_description[] [static]

Initial value:

   "Define your ports, e.g. 1,2 (depends on mISDN-driver loading order)."

Definition at line 102 of file misdn_config.c.

int* ptp [static]

Definition at line 390 of file misdn_config.c.

Referenced by _build_port_config(), misdn_cfg_destroy(), misdn_cfg_get_config_string(), misdn_cfg_get_ports_string(), misdn_cfg_init(), misdn_cfg_update_ptp(), and misdn_lib_init().


Generated on Tue Nov 4 13:20:40 2008 for Asterisk - the Open Source PBX by  doxygen 1.4.7