Interface to mISDN - Config. More...
Go to the source code of this file.
Interface to mISDN - Config.
Definition in file chan_misdn_config.h.
#define BUFFERSIZE 512 |
Definition at line 25 of file chan_misdn_config.h.
Referenced by _build_port_config(), complete_show_config(), handle_cli_misdn_show_config(), load_module(), misdn_cfg_get_config_string(), misdn_cfg_update_ptp(), misdn_check_l2l1(), misdn_request(), process_ast_dsp(), read_config(), and show_config_description().
enum misdn_cfg_elements |
Definition at line 27 of file chan_misdn_config.h.
{ /* port config items */ MISDN_CFG_FIRST = 0, MISDN_CFG_GROUPNAME, /* char[] */ MISDN_CFG_ALLOWED_BEARERS, /* char[] */ MISDN_CFG_FAR_ALERTING, /* int (bool) */ MISDN_CFG_RXGAIN, /* int */ MISDN_CFG_TXGAIN, /* int */ MISDN_CFG_TE_CHOOSE_CHANNEL, /* int (bool) */ MISDN_CFG_PMP_L1_CHECK, /* int (bool) */ MISDN_CFG_REJECT_CAUSE, /* int */ MISDN_CFG_ALARM_BLOCK, /* int (bool) */ MISDN_CFG_HDLC, /* int (bool) */ MISDN_CFG_CONTEXT, /* char[] */ MISDN_CFG_LANGUAGE, /* char[] */ MISDN_CFG_MUSICCLASS, /* char[] */ MISDN_CFG_CALLERID, /* char[] */ MISDN_CFG_METHOD, /* char[] */ MISDN_CFG_DIALPLAN, /* int */ MISDN_CFG_LOCALDIALPLAN, /* int */ MISDN_CFG_CPNDIALPLAN, /* int */ MISDN_CFG_NATPREFIX, /* char[] */ MISDN_CFG_INTERNATPREFIX, /* char[] */ MISDN_CFG_PRES, /* int */ MISDN_CFG_SCREEN, /* int */ MISDN_CFG_ALWAYS_IMMEDIATE, /* int (bool) */ MISDN_CFG_NODIALTONE, /* int (bool) */ MISDN_CFG_IMMEDIATE, /* int (bool) */ MISDN_CFG_SENDDTMF, /* int (bool) */ MISDN_CFG_ASTDTMF, /* int (bool) */ MISDN_CFG_HOLD_ALLOWED, /* int (bool) */ MISDN_CFG_EARLY_BCONNECT, /* int (bool) */ MISDN_CFG_INCOMING_EARLY_AUDIO, /* int (bool) */ MISDN_CFG_ECHOCANCEL, /* int */ #ifdef MISDN_1_2 MISDN_CFG_PIPELINE, /* char[] */ #endif #ifdef WITH_BEROEC MISDN_CFG_BNECHOCANCEL, MISDN_CFG_BNEC_ANTIHOWL, MISDN_CFG_BNEC_NLP, MISDN_CFG_BNEC_ZEROCOEFF, MISDN_CFG_BNEC_TD, MISDN_CFG_BNEC_ADAPT, #endif MISDN_CFG_NEED_MORE_INFOS, /* bool */ MISDN_CFG_NOAUTORESPOND_ON_SETUP, /* bool */ MISDN_CFG_NTTIMEOUT, /* bool */ MISDN_CFG_BRIDGING, /* bool */ MISDN_CFG_JITTERBUFFER, /* int */ MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, /* int */ MISDN_CFG_CALLGROUP, /* ast_group_t */ MISDN_CFG_PICKUPGROUP, /* ast_group_t */ MISDN_CFG_MAX_IN, /* int */ MISDN_CFG_MAX_OUT, /* int */ MISDN_CFG_L1_TIMEOUT, /* int */ MISDN_CFG_OVERLAP_DIAL, /* int (bool)*/ MISDN_CFG_MSNS, /* char[] */ MISDN_CFG_FAXDETECT, /* char[] */ MISDN_CFG_FAXDETECT_CONTEXT, /* char[] */ MISDN_CFG_FAXDETECT_TIMEOUT, /* int */ MISDN_CFG_PTP, /* int (bool) */ MISDN_CFG_LAST, /* general config items */ MISDN_GEN_FIRST, #ifndef MISDN_1_2 MISDN_GEN_MISDN_INIT, /* char[] */ #endif MISDN_GEN_DEBUG, /* int */ MISDN_GEN_TRACEFILE, /* char[] */ MISDN_GEN_BRIDGING, /* int (bool) */ MISDN_GEN_STOP_TONE, /* int (bool) */ MISDN_GEN_APPEND_DIGITS2EXTEN, /* int (bool) */ MISDN_GEN_DYNAMIC_CRYPT, /* int (bool) */ MISDN_GEN_CRYPT_PREFIX, /* char[] */ MISDN_GEN_CRYPT_KEYS, /* char[] */ MISDN_GEN_NTKEEPCALLS, /* int (bool) */ MISDN_GEN_NTDEBUGFLAGS, /* int */ MISDN_GEN_NTDEBUGFILE, /* char[] */ MISDN_GEN_LAST };
enum misdn_cfg_method |
Definition at line 112 of file chan_misdn_config.h.
{ METHOD_STANDARD = 0, METHOD_ROUND_ROBIN, METHOD_STANDARD_DEC };
void misdn_cfg_destroy | ( | void | ) |
Definition at line 1102 of file misdn_config.c.
References _free_general_cfg(), _free_port_cfg(), ast_free, ast_mutex_destroy(), misdn_cfg_lock(), and misdn_cfg_unlock().
Referenced by unload_module().
{ misdn_cfg_lock(); _free_port_cfg(); _free_general_cfg(); ast_free(port_cfg); ast_free(general_cfg); ast_free(ptp); ast_free(map); misdn_cfg_unlock(); ast_mutex_destroy(&config_mutex); }
void misdn_cfg_get | ( | int | port, |
enum misdn_cfg_elements | elem, | ||
void * | buf, | ||
int | bufsize | ||
) |
Definition at line 517 of file misdn_config.c.
References misdn_cfg_pt::any, ast_copy_string(), ast_log(), LOG_WARNING, misdn_cfg_is_port_valid(), MISDN_CFG_LAST, misdn_cfg_lock(), MISDN_CFG_PTP, misdn_cfg_unlock(), MISDN_CTYPE_STR, S_OR, 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().
{ int place; if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { memset(buf, 0, bufsize); ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Port number %d is not valid.\n", port); return; } misdn_cfg_lock(); if (elem == MISDN_CFG_PTP) { if (!memcpy(buf, &ptp[port], (bufsize > ptp[port]) ? sizeof(ptp[port]) : bufsize)) memset(buf, 0, bufsize); } else { if ((place = map[elem]) < 0) { memset(buf, 0, bufsize); ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Invalid element (%d) requested.\n", elem); } else { if (elem < MISDN_CFG_LAST) { switch (port_spec[place].type) { case MISDN_CTYPE_STR: if (port_cfg[port][place].str) { ast_copy_string(buf, port_cfg[port][place].str, bufsize); } else if (port_cfg[0][place].str) { ast_copy_string(buf, port_cfg[0][place].str, bufsize); } else memset(buf, 0, bufsize); break; default: if (port_cfg[port][place].any) memcpy(buf, port_cfg[port][place].any, bufsize); else if (port_cfg[0][place].any) memcpy(buf, port_cfg[0][place].any, bufsize); else memset(buf, 0, bufsize); } } else { switch (gen_spec[place].type) { case MISDN_CTYPE_STR: ast_copy_string(buf, S_OR(general_cfg[place].str, ""), bufsize); break; default: if (general_cfg[place].any) memcpy(buf, general_cfg[place].any, bufsize); else memset(buf, 0, bufsize); } } } } misdn_cfg_unlock(); }
void misdn_cfg_get_config_string | ( | int | port, |
enum misdn_cfg_elements | elem, | ||
char * | buf, | ||
int | bufsize | ||
) |
Definition at line 742 of file misdn_config.c.
References ast_log(), ast_print_group(), BUFFERSIZE, LOG_WARNING, MISDN_CFG_FIRST, misdn_cfg_is_port_valid(), MISDN_CFG_LAST, misdn_cfg_lock(), MISDN_CFG_PTP, misdn_cfg_unlock(), MISDN_CTYPE_ASTGROUP, MISDN_CTYPE_BOOL, MISDN_CTYPE_BOOLINT, MISDN_CTYPE_INT, MISDN_CTYPE_MSNLIST, MISDN_CTYPE_STR, MISDN_GEN_FIRST, MISDN_GEN_LAST, misdn_cfg_pt::ml, msn_list::msn, name, msn_list::next, num, str, and type.
Referenced by handle_cli_misdn_show_config().
{ int place; char tempbuf[BUFFERSIZE] = ""; struct msn_list *iter; if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { *buf = 0; ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Port number %d is not valid.\n", port); return; } place = map[elem]; misdn_cfg_lock(); if (elem == MISDN_CFG_PTP) { snprintf(buf, bufsize, " -> ptp: %s", ptp[port] ? "yes" : "no"); } else if (elem > MISDN_CFG_FIRST && elem < MISDN_CFG_LAST) { switch (port_spec[place].type) { case MISDN_CTYPE_INT: case MISDN_CTYPE_BOOLINT: if (port_cfg[port][place].num) snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[port][place].num); else if (port_cfg[0][place].num) snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[0][place].num); else snprintf(buf, bufsize, " -> %s:", port_spec[place].name); break; case MISDN_CTYPE_BOOL: if (port_cfg[port][place].num) snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[port][place].num ? "yes" : "no"); else if (port_cfg[0][place].num) snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[0][place].num ? "yes" : "no"); else snprintf(buf, bufsize, " -> %s:", port_spec[place].name); break; case MISDN_CTYPE_ASTGROUP: if (port_cfg[port][place].grp) snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp)); else if (port_cfg[0][place].grp) snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp)); else snprintf(buf, bufsize, " -> %s:", port_spec[place].name); break; case MISDN_CTYPE_MSNLIST: if (port_cfg[port][place].ml) iter = port_cfg[port][place].ml; else iter = port_cfg[0][place].ml; if (iter) { for (; iter; iter = iter->next) { strncat(tempbuf, iter->msn, sizeof(tempbuf) - strlen(tempbuf) - 1); } if (strlen(tempbuf) > 1) { tempbuf[strlen(tempbuf)-2] = 0; } } snprintf(buf, bufsize, " -> msns: %s", *tempbuf ? tempbuf : "none"); break; case MISDN_CTYPE_STR: if ( port_cfg[port][place].str) { snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[port][place].str); } else if (port_cfg[0][place].str) { snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[0][place].str); } else { snprintf(buf, bufsize, " -> %s:", port_spec[place].name); } break; } } else if (elem > MISDN_GEN_FIRST && elem < MISDN_GEN_LAST) { switch (gen_spec[place].type) { case MISDN_CTYPE_INT: case MISDN_CTYPE_BOOLINT: if (general_cfg[place].num) snprintf(buf, bufsize, " -> %s: %d", gen_spec[place].name, *general_cfg[place].num); else snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); break; case MISDN_CTYPE_BOOL: if (general_cfg[place].num) snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, *general_cfg[place].num ? "yes" : "no"); else snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); break; case MISDN_CTYPE_STR: if ( general_cfg[place].str) { snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, general_cfg[place].str); } else { snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); } break; default: snprintf(buf, bufsize, " -> type of %s not handled yet", gen_spec[place].name); break; } } else { *buf = 0; ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Invalid config element (%d) requested.\n", elem); } misdn_cfg_unlock(); }
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 ast_copy_string(), misdn_cfg_spec::def, desc, misdn_cfg_spec::elem, MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, MISDN_CFG_LAST, MISDN_GEN_FIRST, MISDN_GEN_LAST, and NO_DEFAULT.
Referenced by show_config_description().
{ int place = map[elem]; struct misdn_cfg_spec *spec = NULL; /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ if (elem == MISDN_CFG_GROUPNAME) { ast_copy_string(buf, ports_description, bufsize); if (buf_default && bufsize_default) memset(buf_default, 0, 1); return; } if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) spec = (struct misdn_cfg_spec *)port_spec; else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) spec = (struct misdn_cfg_spec *)gen_spec; if (!spec || !spec[place].desc) memset(buf, 0, 1); else { ast_copy_string(buf, spec[place].desc, bufsize); if (buf_default && bufsize) { if (!strcmp(spec[place].def, NO_DEFAULT)) memset(buf_default, 0, 1); else ast_copy_string(buf_default, spec[place].def, bufsize_default); } } }
enum misdn_cfg_elements misdn_cfg_get_elem | ( | char * | name | ) |
Definition at line 571 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().
{ int pos; /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ if (!strcmp(name, "ports")) return MISDN_CFG_GROUPNAME; if (!strcmp(name, "name")) return MISDN_CFG_FIRST; pos = get_cfg_position(name, PORT_CFG); if (pos >= 0) return port_spec[pos].elem; pos = get_cfg_position(name, GEN_CFG); if (pos >= 0) return gen_spec[pos].elem; return MISDN_CFG_FIRST; }
void misdn_cfg_get_name | ( | enum misdn_cfg_elements | elem, |
void * | buf, | ||
int | bufsize | ||
) |
Definition at line 592 of file misdn_config.c.
References ast_copy_string(), misdn_cfg_spec::elem, MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, MISDN_CFG_LAST, MISDN_CFG_PTP, MISDN_GEN_FIRST, MISDN_GEN_LAST, and name.
Referenced by complete_show_config(), and show_config_description().
{ struct misdn_cfg_spec *spec = NULL; int place = map[elem]; /* the ptp hack */ if (elem == MISDN_CFG_PTP) { memset(buf, 0, 1); return; } /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ if (elem == MISDN_CFG_GROUPNAME) { if (!snprintf(buf, bufsize, "ports")) memset(buf, 0, 1); return; } if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) spec = (struct misdn_cfg_spec *)port_spec; else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) spec = (struct misdn_cfg_spec *)gen_spec; ast_copy_string(buf, spec ? spec[place].name : "", bufsize); }
int misdn_cfg_get_next_port | ( | int | port | ) |
Definition at line 847 of file misdn_config.c.
References 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().
{ int p = -1; int gn = map[MISDN_CFG_GROUPNAME]; misdn_cfg_lock(); for (port++; port <= max_ports; port++) { if (port_cfg[port][gn].str) { p = port; break; } } misdn_cfg_unlock(); return p; }
int misdn_cfg_get_next_port_spin | ( | int | port | ) |
Definition at line 864 of file misdn_config.c.
References misdn_cfg_get_next_port().
Referenced by misdn_request().
{ int p = misdn_cfg_get_next_port(port); return (p > 0) ? p : misdn_cfg_get_next_port(0); }
void misdn_cfg_get_ports_string | ( | char * | ports | ) |
Generate a comma separated list of all active ports.
Definition at line 716 of file misdn_config.c.
References max_ports, MISDN_CFG_GROUPNAME, misdn_cfg_lock(), misdn_cfg_unlock(), and str.
Referenced by load_module().
{ char tmp[16]; int l, i; int gn = map[MISDN_CFG_GROUPNAME]; *ports = 0; misdn_cfg_lock(); for (i = 1; i <= max_ports; i++) { if (port_cfg[i][gn].str) { if (ptp[i]) sprintf(tmp, "%dptp,", i); else sprintf(tmp, "%d,", i); strcat(ports, tmp); } } misdn_cfg_unlock(); if ((l = strlen(ports))) { /* Strip trailing ',' */ ports[l-1] = 0; } }
int misdn_cfg_init | ( | int | max_ports, |
int | reload | ||
) |
Definition at line 1118 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, max_ports, misdn_cfg_lock(), misdn_cfg_unlock(), MISDN_GEN_LAST, NUM_GEN_ELEMENTS, and NUM_PORT_ELEMENTS.
Referenced by load_module(), and misdn_cfg_reload().
{ char config[] = "misdn.conf"; char *cat, *p; int i; struct ast_config *cfg; struct ast_variable *v; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) { ast_log(LOG_WARNING, "missing or invalid file: misdn.conf\n"); return -1; } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) return 0; ast_mutex_init(&config_mutex); /* Copy the default jb config over global_jbconf */ memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); misdn_cfg_lock(); if (this_max_ports) { /* this is the first run */ max_ports = this_max_ports; map = ast_calloc(MISDN_GEN_LAST + 1, sizeof(int)); if (_enum_array_map()) return -1; p = ast_calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *) + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt)); port_cfg = (union misdn_cfg_pt **)p; p += (max_ports + 1) * sizeof(union misdn_cfg_pt *); for (i = 0; i <= max_ports; ++i) { port_cfg[i] = (union misdn_cfg_pt *)p; p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt); } general_cfg = ast_calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); ptp = ast_calloc(max_ports + 1, sizeof(int)); } else { /* misdn reload */ _free_port_cfg(); _free_general_cfg(); memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1)); memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); memset(ptp, 0, sizeof(int) * (max_ports + 1)); } cat = ast_category_browse(cfg, NULL); while(cat) { v = ast_variable_browse(cfg, cat); if (!strcasecmp(cat, "general")) { _build_general_config(v); } else { _build_port_config(v, cat); } cat = ast_category_browse(cfg, cat); } _fill_defaults(); misdn_cfg_unlock(); ast_config_destroy(cfg); return 0; }
int misdn_cfg_is_group_method | ( | char * | group, |
enum misdn_cfg_method | meth | ||
) |
Definition at line 681 of file misdn_config.c.
References max_ports, METHOD_ROUND_ROBIN, METHOD_STANDARD, METHOD_STANDARD_DEC, MISDN_CFG_GROUPNAME, misdn_cfg_lock(), MISDN_CFG_METHOD, misdn_cfg_unlock(), str, and misdn_cfg_pt::str.
Referenced by misdn_request().
{ int i, re = 0; char *method ; misdn_cfg_lock(); method = port_cfg[0][map[MISDN_CFG_METHOD]].str; for (i = 1; i <= max_ports; i++) { if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) { if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group)) method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ? port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str); } } if (method) { switch (meth) { case METHOD_STANDARD: re = !strcasecmp(method, "standard"); break; case METHOD_ROUND_ROBIN: re = !strcasecmp(method, "round_robin"); break; case METHOD_STANDARD_DEC: re = !strcasecmp(method, "standard_dec"); break; } } misdn_cfg_unlock(); return re; }
int misdn_cfg_is_msn_valid | ( | int | port, |
char * | msn | ||
) |
Definition at line 649 of file misdn_config.c.
References ast_extension_match(), ast_log(), LOG_WARNING, misdn_cfg_is_port_valid(), misdn_cfg_lock(), MISDN_CFG_MSNS, misdn_cfg_unlock(), misdn_cfg_pt::ml, msn_list::msn, and msn_list::next.
Referenced by cb_events().
{ int re = 0; struct msn_list *iter; if (!misdn_cfg_is_port_valid(port)) { ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port); return 0; } misdn_cfg_lock(); if (port_cfg[port][map[MISDN_CFG_MSNS]].ml) iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml; else iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml; for (; iter; iter = iter->next) if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) { re = 1; break; } misdn_cfg_unlock(); return re; }
int misdn_cfg_is_port_valid | ( | int | port | ) |
Definition at line 674 of file misdn_config.c.
References MISDN_CFG_GROUPNAME, and str.
Referenced by handle_cli_misdn_show_config(), misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_is_msn_valid(), and misdn_cfg_update_ptp().
{ int gn = map[MISDN_CFG_GROUPNAME]; return (port >= 1 && port <= max_ports && port_cfg[port][gn].str); }
void misdn_cfg_reload | ( | void | ) |
Definition at line 1097 of file misdn_config.c.
References misdn_cfg_init().
Referenced by reload_config().
{ misdn_cfg_init(0, 1); }
void misdn_cfg_update_ptp | ( | void | ) |
Definition at line 1028 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(), and MISDN_GEN_MISDN_INIT.
Referenced by load_module(), and reload_config().
{ #ifndef MISDN_1_2 char misdn_init[BUFFERSIZE]; char line[BUFFERSIZE]; FILE *fp; char *tok, *p, *end; int port; misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init)); if (!ast_strlen_zero(misdn_init)) { fp = fopen(misdn_init, "r"); if (fp) { while(fgets(line, sizeof(line), fp)) { if (!strncmp(line, "nt_ptp", 6)) { for (tok = strtok_r(line,",=", &p); tok; tok = strtok_r(NULL,",=", &p)) { port = strtol(tok, &end, 10); if (end != tok && misdn_cfg_is_port_valid(port)) { misdn_cfg_lock(); ptp[port] = 1; misdn_cfg_unlock(); } } } } fclose(fp); } else { ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno)); } } #else int i; int proto; char filename[128]; FILE *fp; for (i = 1; i <= max_ports; ++i) { snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8); fp = fopen(filename, "r"); if (!fp) { ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno)); continue; } if (fscanf(fp, "0x%08x", &proto) != 1) ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename); else ptp[i] = proto & 1<<5 ? 1 : 0; fclose(fp); } #endif }
struct ast_jb_conf* misdn_get_global_jbconf | ( | void | ) | [read] |
Definition at line 1186 of file misdn_config.c.
References global_jbconf.
Referenced by misdn_new().
{ return &global_jbconf; }