Asterisk - The Open Source Telephony Project  18.5.0
Macros | Enumerations | Functions
chan_misdn_config.h File Reference

Interface to mISDN - Config. More...

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

Go to the source code of this file.

Macros

#define BUFFERSIZE   512
 

Enumerations

enum  misdn_cfg_elements {
  MISDN_CFG_FIRST = 0, MISDN_CFG_GROUPNAME, MISDN_CFG_ALLOWED_BEARERS, MISDN_CFG_FAR_ALERTING,
  MISDN_CFG_RXGAIN, MISDN_CFG_TXGAIN, MISDN_CFG_TE_CHOOSE_CHANNEL, MISDN_CFG_PMP_L1_CHECK,
  MISDN_CFG_REJECT_CAUSE, MISDN_CFG_ALARM_BLOCK, MISDN_CFG_HDLC, MISDN_CFG_CONTEXT,
  MISDN_CFG_LANGUAGE, MISDN_CFG_MUSICCLASS, MISDN_CFG_CALLERID, MISDN_CFG_INCOMING_CALLERID_TAG,
  MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, MISDN_CFG_METHOD, MISDN_CFG_DIALPLAN, MISDN_CFG_LOCALDIALPLAN,
  MISDN_CFG_CPNDIALPLAN, MISDN_CFG_TON_PREFIX_UNKNOWN, MISDN_CFG_TON_PREFIX_INTERNATIONAL, MISDN_CFG_TON_PREFIX_NATIONAL,
  MISDN_CFG_TON_PREFIX_NETWORK_SPECIFIC, MISDN_CFG_TON_PREFIX_SUBSCRIBER, MISDN_CFG_TON_PREFIX_ABBREVIATED, MISDN_CFG_PRES,
  MISDN_CFG_SCREEN, MISDN_CFG_DISPLAY_CONNECTED, MISDN_CFG_DISPLAY_SETUP, MISDN_CFG_ALWAYS_IMMEDIATE,
  MISDN_CFG_NODIALTONE, MISDN_CFG_IMMEDIATE, MISDN_CFG_SENDDTMF, MISDN_CFG_ASTDTMF,
  MISDN_CFG_HOLD_ALLOWED, MISDN_CFG_EARLY_BCONNECT, MISDN_CFG_INCOMING_EARLY_AUDIO, MISDN_CFG_ECHOCANCEL,
  MISDN_CFG_CC_REQUEST_RETENTION, MISDN_CFG_OUTGOING_COLP, MISDN_CFG_NEED_MORE_INFOS, MISDN_CFG_NOAUTORESPOND_ON_SETUP,
  MISDN_CFG_NTTIMEOUT, MISDN_CFG_BRIDGING, MISDN_CFG_JITTERBUFFER, MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD,
  MISDN_CFG_CALLGROUP, MISDN_CFG_PICKUPGROUP, MISDN_CFG_NAMEDCALLGROUP, MISDN_CFG_NAMEDPICKUPGROUP,
  MISDN_CFG_MAX_IN, MISDN_CFG_MAX_OUT, MISDN_CFG_L1_TIMEOUT, MISDN_CFG_OVERLAP_DIAL,
  MISDN_CFG_MSNS, MISDN_CFG_FAXDETECT, MISDN_CFG_FAXDETECT_CONTEXT, MISDN_CFG_FAXDETECT_TIMEOUT,
  MISDN_CFG_PTP, MISDN_CFG_LAST, MISDN_GEN_FIRST, MISDN_GEN_MISDN_INIT,
  MISDN_GEN_DEBUG, MISDN_GEN_TRACEFILE, MISDN_GEN_BRIDGING, MISDN_GEN_STOP_TONE,
  MISDN_GEN_APPEND_DIGITS2EXTEN, MISDN_GEN_DYNAMIC_CRYPT, MISDN_GEN_CRYPT_PREFIX, MISDN_GEN_CRYPT_KEYS,
  MISDN_GEN_NTKEEPCALLS, MISDN_GEN_NTDEBUGFLAGS, MISDN_GEN_NTDEBUGFILE, MISDN_GEN_LAST
}
 
enum  misdn_cfg_method { METHOD_STANDARD = 0, METHOD_ROUND_ROBIN, METHOD_STANDARD_DEC }
 

Functions

void misdn_cfg_destroy (void)
 
void misdn_cfg_get (int port, enum misdn_cfg_elements elem, void *buf, int bufsize)
 
void misdn_cfg_get_config_string (int port, enum misdn_cfg_elements elem, char *buf, int bufsize)
 
void misdn_cfg_get_desc (enum misdn_cfg_elements elem, void *buf, int bufsize, void *buf_default, int bufsize_default)
 
enum misdn_cfg_elements misdn_cfg_get_elem (const char *name)
 
void misdn_cfg_get_name (enum misdn_cfg_elements elem, void *buf, int bufsize)
 
int misdn_cfg_get_next_port (int port)
 
int misdn_cfg_get_next_port_spin (int port)
 
void misdn_cfg_get_ports_string (char *ports)
 Generate a comma separated list of all active ports. More...
 
int misdn_cfg_init (int max_ports, int reload)
 
int misdn_cfg_is_group_method (char *group, enum misdn_cfg_method meth)
 
int misdn_cfg_is_msn_valid (int port, char *msn)
 
int misdn_cfg_is_port_valid (int port)
 
void misdn_cfg_reload (void)
 
void misdn_cfg_update_ptp (void)
 
struct ast_jb_confmisdn_get_global_jbconf (void)
 

Detailed Description

Interface to mISDN - Config.

Author
Christian Richter crich.nosp@m.@ber.nosp@m.onet..nosp@m.com

Definition in file chan_misdn_config.h.

Macro Definition Documentation

◆ BUFFERSIZE

#define BUFFERSIZE   512

Enumeration Type Documentation

◆ misdn_cfg_elements

Enumerator
MISDN_CFG_FIRST 
MISDN_CFG_GROUPNAME 
MISDN_CFG_ALLOWED_BEARERS 
MISDN_CFG_FAR_ALERTING 
MISDN_CFG_RXGAIN 
MISDN_CFG_TXGAIN 
MISDN_CFG_TE_CHOOSE_CHANNEL 
MISDN_CFG_PMP_L1_CHECK 
MISDN_CFG_REJECT_CAUSE 
MISDN_CFG_ALARM_BLOCK 
MISDN_CFG_HDLC 
MISDN_CFG_CONTEXT 
MISDN_CFG_LANGUAGE 
MISDN_CFG_MUSICCLASS 
MISDN_CFG_CALLERID 
MISDN_CFG_INCOMING_CALLERID_TAG 
MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG 
MISDN_CFG_METHOD 
MISDN_CFG_DIALPLAN 
MISDN_CFG_LOCALDIALPLAN 
MISDN_CFG_CPNDIALPLAN 
MISDN_CFG_TON_PREFIX_UNKNOWN 
MISDN_CFG_TON_PREFIX_INTERNATIONAL 
MISDN_CFG_TON_PREFIX_NATIONAL 
MISDN_CFG_TON_PREFIX_NETWORK_SPECIFIC 
MISDN_CFG_TON_PREFIX_SUBSCRIBER 
MISDN_CFG_TON_PREFIX_ABBREVIATED 
MISDN_CFG_PRES 
MISDN_CFG_SCREEN 
MISDN_CFG_DISPLAY_CONNECTED 
MISDN_CFG_DISPLAY_SETUP 
MISDN_CFG_ALWAYS_IMMEDIATE 
MISDN_CFG_NODIALTONE 
MISDN_CFG_IMMEDIATE 
MISDN_CFG_SENDDTMF 
MISDN_CFG_ASTDTMF 
MISDN_CFG_HOLD_ALLOWED 
MISDN_CFG_EARLY_BCONNECT 
MISDN_CFG_INCOMING_EARLY_AUDIO 
MISDN_CFG_ECHOCANCEL 
MISDN_CFG_CC_REQUEST_RETENTION 
MISDN_CFG_OUTGOING_COLP 
MISDN_CFG_NEED_MORE_INFOS 
MISDN_CFG_NOAUTORESPOND_ON_SETUP 
MISDN_CFG_NTTIMEOUT 
MISDN_CFG_BRIDGING 
MISDN_CFG_JITTERBUFFER 
MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD 
MISDN_CFG_CALLGROUP 
MISDN_CFG_PICKUPGROUP 
MISDN_CFG_NAMEDCALLGROUP 
MISDN_CFG_NAMEDPICKUPGROUP 
MISDN_CFG_MAX_IN 
MISDN_CFG_MAX_OUT 
MISDN_CFG_L1_TIMEOUT 
MISDN_CFG_OVERLAP_DIAL 
MISDN_CFG_MSNS 
MISDN_CFG_FAXDETECT 
MISDN_CFG_FAXDETECT_CONTEXT 
MISDN_CFG_FAXDETECT_TIMEOUT 
MISDN_CFG_PTP 
MISDN_CFG_LAST 
MISDN_GEN_FIRST 
MISDN_GEN_MISDN_INIT 
MISDN_GEN_DEBUG 
MISDN_GEN_TRACEFILE 
MISDN_GEN_BRIDGING 
MISDN_GEN_STOP_TONE 
MISDN_GEN_APPEND_DIGITS2EXTEN 
MISDN_GEN_DYNAMIC_CRYPT 
MISDN_GEN_CRYPT_PREFIX 
MISDN_GEN_CRYPT_KEYS 
MISDN_GEN_NTKEEPCALLS 
MISDN_GEN_NTDEBUGFLAGS 
MISDN_GEN_NTDEBUGFILE 
MISDN_GEN_LAST 

Definition at line 27 of file chan_misdn_config.h.

27  {
28 
29  /* port config items */
30  MISDN_CFG_FIRST = 0,
31  MISDN_CFG_GROUPNAME, /* char[] */
32  MISDN_CFG_ALLOWED_BEARERS, /* char[] */
33  MISDN_CFG_FAR_ALERTING, /* int (bool) */
34  MISDN_CFG_RXGAIN, /* int */
35  MISDN_CFG_TXGAIN, /* int */
36  MISDN_CFG_TE_CHOOSE_CHANNEL, /* int (bool) */
37  MISDN_CFG_PMP_L1_CHECK, /* int (bool) */
38  MISDN_CFG_REJECT_CAUSE, /* int */
39  MISDN_CFG_ALARM_BLOCK, /* int (bool) */
40  MISDN_CFG_HDLC, /* int (bool) */
41  MISDN_CFG_CONTEXT, /* char[] */
42  MISDN_CFG_LANGUAGE, /* char[] */
43  MISDN_CFG_MUSICCLASS, /* char[] */
44  MISDN_CFG_CALLERID, /* char[] */
46  MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, /* int (bool) */
47  MISDN_CFG_METHOD, /* char[] */
48  MISDN_CFG_DIALPLAN, /* int */
49  MISDN_CFG_LOCALDIALPLAN, /* int */
50  MISDN_CFG_CPNDIALPLAN, /* int */
51  MISDN_CFG_TON_PREFIX_UNKNOWN, /* char[] */
53  MISDN_CFG_TON_PREFIX_NATIONAL, /* char[] */
57  MISDN_CFG_PRES, /* int */
58  MISDN_CFG_SCREEN, /* int */
60  MISDN_CFG_DISPLAY_SETUP, /* int */
61  MISDN_CFG_ALWAYS_IMMEDIATE, /* int (bool) */
62  MISDN_CFG_NODIALTONE, /* int (bool) */
63  MISDN_CFG_IMMEDIATE, /* int (bool) */
64  MISDN_CFG_SENDDTMF, /* int (bool) */
65  MISDN_CFG_ASTDTMF, /* int (bool) */
66  MISDN_CFG_HOLD_ALLOWED, /* int (bool) */
67  MISDN_CFG_EARLY_BCONNECT, /* int (bool) */
68  MISDN_CFG_INCOMING_EARLY_AUDIO, /* int (bool) */
69  MISDN_CFG_ECHOCANCEL, /* int */
71  MISDN_CFG_OUTGOING_COLP, /* int */
72 #ifdef MISDN_1_2
73  MISDN_CFG_PIPELINE, /* char[] */
74 #endif
75 
76 #ifdef WITH_BEROEC
77  MISDN_CFG_BNECHOCANCEL,
78  MISDN_CFG_BNEC_ANTIHOWL,
79  MISDN_CFG_BNEC_NLP,
80  MISDN_CFG_BNEC_ZEROCOEFF,
81  MISDN_CFG_BNEC_TD,
82  MISDN_CFG_BNEC_ADAPT,
83 #endif
84  MISDN_CFG_NEED_MORE_INFOS, /* bool */
86  MISDN_CFG_NTTIMEOUT, /* bool */
87  MISDN_CFG_BRIDGING, /* bool */
88  MISDN_CFG_JITTERBUFFER, /* int */
90  MISDN_CFG_CALLGROUP, /* ast_group_t */
91  MISDN_CFG_PICKUPGROUP, /* ast_group_t */
92  MISDN_CFG_NAMEDCALLGROUP, /* ast_namedgroups * */
93  MISDN_CFG_NAMEDPICKUPGROUP, /* ast_namedgroups * */
94  MISDN_CFG_MAX_IN, /* int */
95  MISDN_CFG_MAX_OUT, /* int */
96  MISDN_CFG_L1_TIMEOUT, /* int */
97  MISDN_CFG_OVERLAP_DIAL, /* int (bool)*/
98  MISDN_CFG_MSNS, /* char[] */
99  MISDN_CFG_FAXDETECT, /* char[] */
100  MISDN_CFG_FAXDETECT_CONTEXT, /* char[] */
101  MISDN_CFG_FAXDETECT_TIMEOUT, /* int */
102  MISDN_CFG_PTP, /* int (bool) */
104 
105  /* general config items */
107 #ifndef MISDN_1_2
108  MISDN_GEN_MISDN_INIT, /* char[] */
109 #endif
110  MISDN_GEN_DEBUG, /* int */
111  MISDN_GEN_TRACEFILE, /* char[] */
112  MISDN_GEN_BRIDGING, /* int (bool) */
113  MISDN_GEN_STOP_TONE, /* int (bool) */
114  MISDN_GEN_APPEND_DIGITS2EXTEN, /* int (bool) */
115  MISDN_GEN_DYNAMIC_CRYPT, /* int (bool) */
116  MISDN_GEN_CRYPT_PREFIX, /* char[] */
117  MISDN_GEN_CRYPT_KEYS, /* char[] */
118  MISDN_GEN_NTKEEPCALLS, /* int (bool) */
119  MISDN_GEN_NTDEBUGFLAGS, /* int */
120  MISDN_GEN_NTDEBUGFILE, /* char[] */
122 };

◆ misdn_cfg_method

Enumerator
METHOD_STANDARD 
METHOD_ROUND_ROBIN 
METHOD_STANDARD_DEC 

Definition at line 124 of file chan_misdn_config.h.

Function Documentation

◆ misdn_cfg_destroy()

void misdn_cfg_destroy ( void  )

Definition at line 1187 of file misdn_config.c.

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

Referenced by unload_module().

1188 {
1189  misdn_cfg_lock();
1190 
1191  _free_port_cfg();
1193 
1194  ast_free(port_cfg);
1196  ast_free(ptp);
1197  ast_free(map);
1198 
1199  misdn_cfg_unlock();
1201 }
static union misdn_cfg_pt ** port_cfg
Definition: misdn_config.c:430
static int * map
Definition: misdn_config.c:438
static void _free_port_cfg(void)
Definition: misdn_config.c:524
static union misdn_cfg_pt * general_cfg
Definition: misdn_config.c:434
#define ast_free(a)
Definition: astmm.h:182
static void misdn_cfg_unlock(void)
Definition: misdn_config.c:510
static void _free_general_cfg(void)
Definition: misdn_config.c:560
static int * ptp
Definition: misdn_config.c:436
static void misdn_cfg_lock(void)
Definition: misdn_config.c:505
#define ast_mutex_destroy(a)
Definition: lock.h:186
static ast_mutex_t config_mutex
Definition: misdn_config.c:440

◆ misdn_cfg_get()

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

Definition at line 569 of file misdn_config.c.

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

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

570 {
571  int place;
572 
573  if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) {
574  memset(buf, 0, bufsize);
575  ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Port number %d is not valid.\n", port);
576  return;
577  }
578 
579  misdn_cfg_lock();
580  if (elem == MISDN_CFG_PTP) {
581  if (!memcpy(buf, &ptp[port], (bufsize > ptp[port]) ? sizeof(ptp[port]) : bufsize))
582  memset(buf, 0, bufsize);
583  } else {
584  if ((place = map[elem]) < 0) {
585  memset(buf, 0, bufsize);
586  ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Invalid element (%d) requested.\n", elem);
587  } else {
588  if (elem < MISDN_CFG_LAST) {
589  switch (port_spec[place].type) {
590  case MISDN_CTYPE_STR:
591  if (port_cfg[port][place].str) {
592  ast_copy_string(buf, port_cfg[port][place].str, bufsize);
593  } else if (port_cfg[0][place].str) {
594  ast_copy_string(buf, port_cfg[0][place].str, bufsize);
595  } else
596  memset(buf, 0, bufsize);
597  break;
599  if (bufsize >= sizeof(struct ast_namedgroups *)) {
600  if (port_cfg[port][place].namgrp) {
601  *(struct ast_namedgroups **)buf = port_cfg[port][place].namgrp;
602  } else if (port_cfg[0][place].namgrp) {
603  *(struct ast_namedgroups **)buf = port_cfg[0][place].namgrp;
604  } else {
605  *(struct ast_namedgroups **)buf = NULL;
606  }
607  }
608  break;
609  default:
610  if (port_cfg[port][place].any)
611  memcpy(buf, port_cfg[port][place].any, bufsize);
612  else if (port_cfg[0][place].any)
613  memcpy(buf, port_cfg[0][place].any, bufsize);
614  else
615  memset(buf, 0, bufsize);
616  }
617  } else {
618  switch (gen_spec[place].type) {
619  case MISDN_CTYPE_STR:
620  ast_copy_string(buf, S_OR(general_cfg[place].str, ""), bufsize);
621  break;
622  default:
623  if (general_cfg[place].any)
624  memcpy(buf, general_cfg[place].any, bufsize);
625  else
626  memset(buf, 0, bufsize);
627  }
628  }
629  }
630  }
632 }
static const char type[]
Definition: chan_ooh323.c:109
static union misdn_cfg_pt ** port_cfg
Definition: misdn_config.c:430
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int * map
Definition: misdn_config.c:438
#define LOG_WARNING
Definition: logger.h:274
const char * str
Definition: app_jack.c:147
static const struct misdn_cfg_spec gen_spec[]
Definition: misdn_config.c:391
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
static union misdn_cfg_pt * general_cfg
Definition: misdn_config.c:434
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
static void misdn_cfg_unlock(void)
Definition: misdn_config.c:510
static const struct misdn_cfg_spec port_spec[]
Definition: misdn_config.c:102
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
static int * ptp
Definition: misdn_config.c:436
static void misdn_cfg_lock(void)
Definition: misdn_config.c:505
int misdn_cfg_is_port_valid(int port)
Definition: misdn_config.c:737

◆ misdn_cfg_get_config_string()

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

Definition at line 805 of file misdn_config.c.

References ast_free, ast_log, ast_print_group(), ast_print_namedgroups(), ast_str_create, BUFFERSIZE, 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_ASTNAMEDGROUP, MISDN_CTYPE_BOOL, MISDN_CTYPE_BOOLINT, MISDN_CTYPE_INT, MISDN_CTYPE_MSNLIST, MISDN_CTYPE_STR, MISDN_GEN_FIRST, MISDN_GEN_LAST, misdn_cfg_pt::ml, msn_list::msn, name, msn_list::next, ptp, str, and type.

Referenced by handle_cli_misdn_show_config().

806 {
807  int place;
808  char tempbuf[BUFFERSIZE] = "";
809  struct msn_list *iter;
810 
811  if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) {
812  *buf = 0;
813  ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Port number %d is not valid.\n", port);
814  return;
815  }
816 
817  place = map[elem];
818 
819  misdn_cfg_lock();
820  if (elem == MISDN_CFG_PTP) {
821  snprintf(buf, bufsize, " -> ptp: %s", ptp[port] ? "yes" : "no");
822  }
823  else if (elem > MISDN_CFG_FIRST && elem < MISDN_CFG_LAST) {
824  switch (port_spec[place].type) {
825  case MISDN_CTYPE_INT:
826  case MISDN_CTYPE_BOOLINT:
827  if (port_cfg[port][place].num)
828  snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[port][place].num);
829  else if (port_cfg[0][place].num)
830  snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[0][place].num);
831  else
832  snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
833  break;
834  case MISDN_CTYPE_BOOL:
835  if (port_cfg[port][place].num)
836  snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[port][place].num ? "yes" : "no");
837  else if (port_cfg[0][place].num)
838  snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[0][place].num ? "yes" : "no");
839  else
840  snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
841  break;
843  if (port_cfg[port][place].grp)
844  snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name,
845  ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp));
846  else if (port_cfg[0][place].grp)
847  snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name,
848  ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp));
849  else
850  snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
851  break;
853  if (port_cfg[port][place].namgrp) {
854  struct ast_str *tmp_str = ast_str_create(1024);
855  if (tmp_str) {
856  snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name,
857  ast_print_namedgroups(&tmp_str, port_cfg[port][place].namgrp));
858  ast_free(tmp_str);
859  }
860  } else if (port_cfg[0][place].namgrp) {
861  struct ast_str *tmp_str = ast_str_create(1024);
862  if (tmp_str) {
863  snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name,
864  ast_print_namedgroups(&tmp_str, port_cfg[0][place].namgrp));
865  ast_free(tmp_str);
866  }
867  } else {
868  snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
869  }
870  break;
871  case MISDN_CTYPE_MSNLIST:
872  if (port_cfg[port][place].ml)
873  iter = port_cfg[port][place].ml;
874  else
875  iter = port_cfg[0][place].ml;
876  if (iter) {
877  for (; iter; iter = iter->next) {
878  strncat(tempbuf, iter->msn, sizeof(tempbuf) - strlen(tempbuf) - 1);
879  }
880  if (strlen(tempbuf) > 1) {
881  tempbuf[strlen(tempbuf)-2] = 0;
882  }
883  }
884  snprintf(buf, bufsize, " -> msns: %s", *tempbuf ? tempbuf : "none");
885  break;
886  case MISDN_CTYPE_STR:
887  if ( port_cfg[port][place].str) {
888  snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[port][place].str);
889  } else if (port_cfg[0][place].str) {
890  snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[0][place].str);
891  } else {
892  snprintf(buf, bufsize, " -> %s:", port_spec[place].name);
893  }
894  break;
895  }
896  } else if (elem > MISDN_GEN_FIRST && elem < MISDN_GEN_LAST) {
897  switch (gen_spec[place].type) {
898  case MISDN_CTYPE_INT:
899  case MISDN_CTYPE_BOOLINT:
900  if (general_cfg[place].num)
901  snprintf(buf, bufsize, " -> %s: %d", gen_spec[place].name, *general_cfg[place].num);
902  else
903  snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
904  break;
905  case MISDN_CTYPE_BOOL:
906  if (general_cfg[place].num)
907  snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, *general_cfg[place].num ? "yes" : "no");
908  else
909  snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
910  break;
911  case MISDN_CTYPE_STR:
912  if ( general_cfg[place].str) {
913  snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, general_cfg[place].str);
914  } else {
915  snprintf(buf, bufsize, " -> %s:", gen_spec[place].name);
916  }
917  break;
918  default:
919  snprintf(buf, bufsize, " -> type of %s not handled yet", gen_spec[place].name);
920  break;
921  }
922  } else {
923  *buf = 0;
924  ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Invalid config element (%d) requested.\n", elem);
925  }
927 }
static const char type[]
Definition: chan_ooh323.c:109
static union misdn_cfg_pt ** port_cfg
Definition: misdn_config.c:430
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int * map
Definition: misdn_config.c:438
#define LOG_WARNING
Definition: logger.h:274
const char * str
Definition: app_jack.c:147
static const struct misdn_cfg_spec gen_spec[]
Definition: misdn_config.c:391
struct msn_list * next
Definition: misdn_config.c:77
char * ast_print_group(char *buf, int buflen, ast_group_t group)
Print call and pickup groups into buffer.
Definition: channel.c:8133
#define BUFFERSIZE
#define ast_log
Definition: astobj2.c:42
char * msn
Definition: misdn_config.c:76
static union misdn_cfg_pt * general_cfg
Definition: misdn_config.c:434
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
static const char name[]
Definition: cdr_mysql.c:74
#define ast_free(a)
Definition: astmm.h:182
static void misdn_cfg_unlock(void)
Definition: misdn_config.c:510
static const struct misdn_cfg_spec port_spec[]
Definition: misdn_config.c:102
struct msn_list * ml
Definition: misdn_config.c:83
static int * ptp
Definition: misdn_config.c:436
static void misdn_cfg_lock(void)
Definition: misdn_config.c:505
int misdn_cfg_is_port_valid(int port)
Definition: misdn_config.c:737
char * ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups)
Print named call groups and named pickup groups.
Definition: channel.c:8158
#define ast_str_create(init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:620

◆ misdn_cfg_get_desc()

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

Definition at line 681 of file misdn_config.c.

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

Referenced by show_config_description().

682 {
683  int place = map[elem];
684  struct misdn_cfg_spec *spec = NULL;
685 
686  /* here comes a hack to replace the (not existing) "name" element with the "ports" element */
687  if (elem == MISDN_CFG_GROUPNAME) {
689  if (buf_default && bufsize_default)
690  memset(buf_default, 0, 1);
691  return;
692  }
693 
694  if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST))
695  spec = (struct misdn_cfg_spec *)port_spec;
696  else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST))
697  spec = (struct misdn_cfg_spec *)gen_spec;
698 
699  if (!spec)
700  memset(buf, 0, 1);
701  else {
702  ast_copy_string(buf, spec[place].desc, bufsize);
703  if (buf_default && bufsize) {
704  if (!strcmp(spec[place].def, NO_DEFAULT))
705  memset(buf_default, 0, 1);
706  else
707  ast_copy_string(buf_default, spec[place].def, bufsize_default);
708  }
709  }
710 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int * map
Definition: misdn_config.c:438
static const char desc[]
Definition: cdr_mysql.c:73
static const struct misdn_cfg_spec gen_spec[]
Definition: misdn_config.c:391
#define NULL
Definition: resample.c:96
enum misdn_cfg_elements elem
Definition: misdn_config.c:91
char def[BUFFERSIZE]
Definition: misdn_config.c:93
static const char ports_description[]
Definition: misdn_config.c:99
static const struct misdn_cfg_spec port_spec[]
Definition: misdn_config.c:102
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define NO_DEFAULT
Definition: misdn_config.c:44

◆ misdn_cfg_get_elem()

enum misdn_cfg_elements misdn_cfg_get_elem ( const char *  name)

Definition at line 634 of file misdn_config.c.

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

Referenced by handle_cli_misdn_show_config().

635 {
636  int pos;
637 
638  /* here comes a hack to replace the (not existing) "name" element with the "ports" element */
639  if (!strcmp(name, "ports"))
640  return MISDN_CFG_GROUPNAME;
641  if (!strcmp(name, "name"))
642  return MISDN_CFG_FIRST;
643 
645  if (pos >= 0)
646  return port_spec[pos].elem;
647 
648  pos = get_cfg_position(name, GEN_CFG);
649  if (pos >= 0)
650  return gen_spec[pos].elem;
651 
652  return MISDN_CFG_FIRST;
653 }
#define PORT_CFG
Definition: misdn_config.c:48
static const struct misdn_cfg_spec gen_spec[]
Definition: misdn_config.c:391
static int get_cfg_position(const char *name, int type)
Definition: misdn_config.c:484
enum misdn_cfg_elements elem
Definition: misdn_config.c:91
static const char name[]
Definition: cdr_mysql.c:74
static const struct misdn_cfg_spec port_spec[]
Definition: misdn_config.c:102
#define GEN_CFG
Definition: misdn_config.c:47

◆ misdn_cfg_get_name()

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

Definition at line 655 of file misdn_config.c.

References ast_copy_string(), misdn_cfg_spec::elem, map, MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, MISDN_CFG_LAST, MISDN_CFG_PTP, MISDN_GEN_FIRST, MISDN_GEN_LAST, name, and NULL.

Referenced by complete_show_config(), and show_config_description().

656 {
657  struct misdn_cfg_spec *spec = NULL;
658  int place = map[elem];
659 
660  /* the ptp hack */
661  if (elem == MISDN_CFG_PTP) {
662  memset(buf, 0, 1);
663  return;
664  }
665 
666  /* here comes a hack to replace the (not existing) "name" element with the "ports" element */
667  if (elem == MISDN_CFG_GROUPNAME) {
668  if (!snprintf(buf, bufsize, "ports"))
669  memset(buf, 0, 1);
670  return;
671  }
672 
673  if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST))
674  spec = (struct misdn_cfg_spec *)port_spec;
675  else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST))
676  spec = (struct misdn_cfg_spec *)gen_spec;
677 
678  ast_copy_string(buf, spec ? spec[place].name : "", bufsize);
679 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int * map
Definition: misdn_config.c:438
static const struct misdn_cfg_spec gen_spec[]
Definition: misdn_config.c:391
#define NULL
Definition: resample.c:96
enum misdn_cfg_elements elem
Definition: misdn_config.c:91
static const char name[]
Definition: cdr_mysql.c:74
static const struct misdn_cfg_spec port_spec[]
Definition: misdn_config.c:102
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ misdn_cfg_get_next_port()

int misdn_cfg_get_next_port ( int  port)

Definition at line 929 of file misdn_config.c.

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

Referenced by complete_show_config(), handle_cli_misdn_show_config(), handle_cli_misdn_show_ports_stats(), handle_cli_misdn_show_stacks(), load_module(), misdn_cfg_get_next_port_spin(), misdn_check_l2l1(), misdn_new(), misdn_request(), and update_name().

930 {
931  int p = -1;
932  int gn = map[MISDN_CFG_GROUPNAME];
933 
934  misdn_cfg_lock();
935  for (port++; port <= max_ports; port++) {
936  if (port_cfg[port][gn].str) {
937  p = port;
938  break;
939  }
940  }
942 
943  return p;
944 }
static union misdn_cfg_pt ** port_cfg
Definition: misdn_config.c:430
static int * map
Definition: misdn_config.c:438
static int max_ports
Definition: misdn_config.c:432
const char * str
Definition: app_jack.c:147
static void misdn_cfg_unlock(void)
Definition: misdn_config.c:510
static void misdn_cfg_lock(void)
Definition: misdn_config.c:505

◆ misdn_cfg_get_next_port_spin()

int misdn_cfg_get_next_port_spin ( int  port)

Definition at line 946 of file misdn_config.c.

References misdn_cfg_get_next_port().

Referenced by misdn_request().

947 {
948  int p = misdn_cfg_get_next_port(port);
949  return (p > 0) ? p : misdn_cfg_get_next_port(0);
950 }
int misdn_cfg_get_next_port(int port)
Definition: misdn_config.c:929

◆ misdn_cfg_get_ports_string()

void misdn_cfg_get_ports_string ( char *  ports)

Generate a comma separated list of all active ports.

Definition at line 779 of file misdn_config.c.

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

Referenced by load_module().

780 {
781  char tmp[16];
782  int l, i;
783  int gn = map[MISDN_CFG_GROUPNAME];
784 
785  *ports = 0;
786 
787  misdn_cfg_lock();
788  for (i = 1; i <= max_ports; i++) {
789  if (port_cfg[i][gn].str) {
790  if (ptp[i])
791  sprintf(tmp, "%dptp,", i);
792  else
793  sprintf(tmp, "%d,", i);
794  strcat(ports, tmp);
795  }
796  }
798 
799  if ((l = strlen(ports))) {
800  /* Strip trailing ',' */
801  ports[l-1] = 0;
802  }
803 }
static union misdn_cfg_pt ** port_cfg
Definition: misdn_config.c:430
static int * map
Definition: misdn_config.c:438
static int tmp()
Definition: bt_open.c:389
static int max_ports
Definition: misdn_config.c:432
const char * str
Definition: app_jack.c:147
static void misdn_cfg_unlock(void)
Definition: misdn_config.c:510
static int * ptp
Definition: misdn_config.c:436
static void misdn_cfg_lock(void)
Definition: misdn_config.c:505

◆ misdn_cfg_init()

int misdn_cfg_init ( int  max_ports,
int  reload 
)

Definition at line 1203 of file misdn_config.c.

References _build_general_config(), _build_port_config(), _enum_array_map(), _fill_defaults(), _free_general_cfg(), _free_port_cfg(), ast_calloc, ast_category_browse(), ast_config_destroy(), ast_config_load2(), ast_log, ast_mutex_init, ast_variable_browse(), config, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, global_jbconf, LOG_WARNING, map, max_ports, misdn_cfg_lock(), misdn_cfg_unlock(), MISDN_GEN_LAST, NULL, NUM_GEN_ELEMENTS, NUM_PORT_ELEMENTS, and ptp.

Referenced by load_module(), and misdn_cfg_reload().

1204 {
1205  char config[] = "misdn.conf";
1206  char *cat, *p;
1207  int i;
1208  struct ast_config *cfg;
1209  struct ast_variable *v;
1210  struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
1211 
1212  if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
1213  ast_log(LOG_WARNING, "missing or invalid file: misdn.conf\n");
1214  return -1;
1215  } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
1216  return 0;
1217 
1219 
1220  /* Copy the default jb config over global_jbconf */
1221  memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
1222 
1223  misdn_cfg_lock();
1224 
1225  if (this_max_ports) {
1226  /* this is the first run */
1227  max_ports = this_max_ports;
1228  map = ast_calloc(MISDN_GEN_LAST + 1, sizeof(int));
1229  if (_enum_array_map())
1230  return -1;
1231  p = ast_calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *)
1232  + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt));
1233  port_cfg = (union misdn_cfg_pt **)p;
1234  p += (max_ports + 1) * sizeof(union misdn_cfg_pt *);
1235  for (i = 0; i <= max_ports; ++i) {
1236  port_cfg[i] = (union misdn_cfg_pt *)p;
1237  p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt);
1238  }
1239  general_cfg = ast_calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
1240  ptp = ast_calloc(max_ports + 1, sizeof(int));
1241  }
1242  else {
1243  /* misdn reload */
1244  _free_port_cfg();
1246  memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1));
1247  memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS);
1248  memset(ptp, 0, sizeof(int) * (max_ports + 1));
1249  }
1250 
1251  cat = ast_category_browse(cfg, NULL);
1252 
1253  while(cat) {
1254  v = ast_variable_browse(cfg, cat);
1255  if (!strcasecmp(cat, "general")) {
1257  } else {
1258  _build_port_config(v, cat);
1259  }
1260  cat = ast_category_browse(cfg, cat);
1261  }
1262 
1263  _fill_defaults();
1264 
1265  misdn_cfg_unlock();
1266  ast_config_destroy(cfg);
1267 
1268  return 0;
1269 }
static union misdn_cfg_pt ** port_cfg
Definition: misdn_config.c:430
static void _fill_defaults(void)
char * config
Definition: conf2ael.c:66
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Definition: extconf.c:1216
#define NUM_PORT_ELEMENTS
Definition: misdn_config.c:50
static int * map
Definition: misdn_config.c:438
#define NUM_GEN_ELEMENTS
Definition: misdn_config.c:49
#define LOG_WARNING
Definition: logger.h:274
static struct ast_jb_conf default_jbconf
Definition: misdn_config.c:54
#define CONFIG_STATUS_FILEINVALID
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Definition: main/config.c:3154
Structure for variables, used for configurations and for channel variables.
static int max_ports
Definition: misdn_config.c:432
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
Definition: extconf.c:3328
#define NULL
Definition: resample.c:96
static struct ast_jb_conf global_jbconf
Definition: misdn_config.c:63
static void _build_port_config(struct ast_variable *v, char *cat)
static void _free_port_cfg(void)
Definition: misdn_config.c:524
#define ast_log
Definition: astobj2.c:42
static int _enum_array_map(void)
Definition: misdn_config.c:447
static union misdn_cfg_pt * general_cfg
Definition: misdn_config.c:434
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: extconf.c:1290
#define CONFIG_STATUS_FILEUNCHANGED
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
static int reload(void)
Definition: cdr_mysql.c:741
static void misdn_cfg_unlock(void)
Definition: misdn_config.c:510
Structure used to handle boolean flags.
Definition: utils.h:199
static void _free_general_cfg(void)
Definition: misdn_config.c:560
static void _build_general_config(struct ast_variable *v)
static int * ptp
Definition: misdn_config.c:436
static void misdn_cfg_lock(void)
Definition: misdn_config.c:505
#define ast_mutex_init(pmutex)
Definition: lock.h:184
static ast_mutex_t config_mutex
Definition: misdn_config.c:440
General jitterbuffer configuration.
Definition: abstract_jb.h:69

◆ misdn_cfg_is_group_method()

int misdn_cfg_is_group_method ( char *  group,
enum misdn_cfg_method  meth 
)

Definition at line 744 of file misdn_config.c.

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

Referenced by misdn_request().

745 {
746  int i, re = 0;
747  char *method ;
748 
749  misdn_cfg_lock();
750 
751  method = port_cfg[0][map[MISDN_CFG_METHOD]].str;
752 
753  for (i = 1; i <= max_ports; i++) {
754  if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) {
755  if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group))
756  method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ?
758  }
759  }
760 
761  if (method) {
762  switch (meth) {
763  case METHOD_STANDARD: re = !strcasecmp(method, "standard");
764  break;
765  case METHOD_ROUND_ROBIN: re = !strcasecmp(method, "round_robin");
766  break;
767  case METHOD_STANDARD_DEC: re = !strcasecmp(method, "standard_dec");
768  break;
769  }
770  }
772 
773  return re;
774 }
static union misdn_cfg_pt ** port_cfg
Definition: misdn_config.c:430
static int * map
Definition: misdn_config.c:438
static int max_ports
Definition: misdn_config.c:432
const char * str
Definition: app_jack.c:147
const char * method
Definition: res_pjsip.c:4335
static void misdn_cfg_unlock(void)
Definition: misdn_config.c:510
static void misdn_cfg_lock(void)
Definition: misdn_config.c:505

◆ misdn_cfg_is_msn_valid()

int misdn_cfg_is_msn_valid ( int  port,
char *  msn 
)

Definition at line 712 of file misdn_config.c.

References ast_extension_match(), ast_log, LOG_WARNING, map, misdn_cfg_is_port_valid(), misdn_cfg_lock(), MISDN_CFG_MSNS, misdn_cfg_unlock(), misdn_cfg_pt::ml, msn_list::msn, and msn_list::next.

Referenced by misdn_is_msn_valid().

713 {
714  int re = 0;
715  struct msn_list *iter;
716 
717  if (!misdn_cfg_is_port_valid(port)) {
718  ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port);
719  return 0;
720  }
721 
722  misdn_cfg_lock();
723  if (port_cfg[port][map[MISDN_CFG_MSNS]].ml)
724  iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml;
725  else
726  iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml;
727  for (; iter; iter = iter->next)
728  if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) {
729  re = 1;
730  break;
731  }
733 
734  return re;
735 }
static union misdn_cfg_pt ** port_cfg
Definition: misdn_config.c:430
static int * map
Definition: misdn_config.c:438
#define LOG_WARNING
Definition: logger.h:274
struct msn_list * next
Definition: misdn_config.c:77
#define ast_log
Definition: astobj2.c:42
char * msn
Definition: misdn_config.c:76
int ast_extension_match(const char *pattern, const char *extension)
Determine if a given extension matches a given pattern (in NXX format)
Definition: extconf.c:4297
static void misdn_cfg_unlock(void)
Definition: misdn_config.c:510
struct msn_list * ml
Definition: misdn_config.c:83
static void misdn_cfg_lock(void)
Definition: misdn_config.c:505
int misdn_cfg_is_port_valid(int port)
Definition: misdn_config.c:737

◆ misdn_cfg_is_port_valid()

int misdn_cfg_is_port_valid ( int  port)

Definition at line 737 of file misdn_config.c.

References map, max_ports, MISDN_CFG_GROUPNAME, and str.

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

738 {
739  int gn = map[MISDN_CFG_GROUPNAME];
740 
741  return (port >= 1 && port <= max_ports && port_cfg[port][gn].str);
742 }
static union misdn_cfg_pt ** port_cfg
Definition: misdn_config.c:430
static int * map
Definition: misdn_config.c:438
static int max_ports
Definition: misdn_config.c:432
const char * str
Definition: app_jack.c:147

◆ misdn_cfg_reload()

void misdn_cfg_reload ( void  )

Definition at line 1182 of file misdn_config.c.

References misdn_cfg_init().

Referenced by reload_config().

1183 {
1184  misdn_cfg_init(0, 1);
1185 }
int misdn_cfg_init(int this_max_ports, int reload)

◆ misdn_cfg_update_ptp()

void misdn_cfg_update_ptp ( void  )

Definition at line 1113 of file misdn_config.c.

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

Referenced by load_module(), and reload_config().

1114 {
1115 #ifndef MISDN_1_2
1116  char misdn_init[BUFFERSIZE];
1117  char line[BUFFERSIZE];
1118  FILE *fp;
1119  char *tok, *p, *end;
1120  int port;
1121 
1122  misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init));
1123 
1124  if (!ast_strlen_zero(misdn_init)) {
1125  fp = fopen(misdn_init, "r");
1126  if (fp) {
1127  while(fgets(line, sizeof(line), fp)) {
1128  if (!strncmp(line, "nt_ptp", 6)) {
1129  for (tok = strtok_r(line,",=", &p);
1130  tok;
1131  tok = strtok_r(NULL,",=", &p)) {
1132  port = strtol(tok, &end, 10);
1133  if (end != tok && misdn_cfg_is_port_valid(port)) {
1134  misdn_cfg_lock();
1135  ptp[port] = 1;
1136  misdn_cfg_unlock();
1137  }
1138  }
1139  }
1140  }
1141  fclose(fp);
1142  } else {
1143  ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno));
1144  }
1145  }
1146 #else
1147  int i;
1148  int proto;
1149  char filename[128];
1150  FILE *fp;
1151 
1152  for (i = 1; i <= max_ports; ++i) {
1153  snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8);
1154  fp = fopen(filename, "r");
1155  if (!fp) {
1156  ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno));
1157  continue;
1158  }
1159  if (fscanf(fp, "0x%08x", &proto) != 1)
1160  ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename);
1161  else
1162  ptp[i] = proto & 1<<5 ? 1 : 0;
1163  fclose(fp);
1164  }
1165 #endif
1166 }
#define LOG_WARNING
Definition: logger.h:274
static int max_ports
Definition: misdn_config.c:432
#define NULL
Definition: resample.c:96
char * end
Definition: eagi_proxy.c:73
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define BUFFERSIZE
#define ast_log
Definition: astobj2.c:42
int errno
static void misdn_cfg_unlock(void)
Definition: misdn_config.c:510
void misdn_cfg_get(int port, enum misdn_cfg_elements elem, void *buf, int bufsize)
Definition: misdn_config.c:569
static int * ptp
Definition: misdn_config.c:436
static void misdn_cfg_lock(void)
Definition: misdn_config.c:505
int misdn_cfg_is_port_valid(int port)
Definition: misdn_config.c:737

◆ misdn_get_global_jbconf()

struct ast_jb_conf* misdn_get_global_jbconf ( void  )

Definition at line 1271 of file misdn_config.c.

References global_jbconf.

Referenced by misdn_new().

1271  {
1272  return &global_jbconf;
1273 }
static struct ast_jb_conf global_jbconf
Definition: misdn_config.c:63