Go to the source code of this file.
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.
00027 { 00028 00029 /* port config items */ 00030 MISDN_CFG_FIRST = 0, 00031 MISDN_CFG_GROUPNAME, /* char[] */ 00032 MISDN_CFG_ALLOWED_BEARERS, /* char[] */ 00033 MISDN_CFG_FAR_ALERTING, /* int (bool) */ 00034 MISDN_CFG_RXGAIN, /* int */ 00035 MISDN_CFG_TXGAIN, /* int */ 00036 MISDN_CFG_TE_CHOOSE_CHANNEL, /* int (bool) */ 00037 MISDN_CFG_PMP_L1_CHECK, /* int (bool) */ 00038 MISDN_CFG_REJECT_CAUSE, /* int */ 00039 MISDN_CFG_ALARM_BLOCK, /* int (bool) */ 00040 MISDN_CFG_HDLC, /* int (bool) */ 00041 MISDN_CFG_CONTEXT, /* char[] */ 00042 MISDN_CFG_LANGUAGE, /* char[] */ 00043 MISDN_CFG_MUSICCLASS, /* char[] */ 00044 MISDN_CFG_CALLERID, /* char[] */ 00045 MISDN_CFG_METHOD, /* char[] */ 00046 MISDN_CFG_DIALPLAN, /* int */ 00047 MISDN_CFG_LOCALDIALPLAN, /* int */ 00048 MISDN_CFG_CPNDIALPLAN, /* int */ 00049 MISDN_CFG_NATPREFIX, /* char[] */ 00050 MISDN_CFG_INTERNATPREFIX, /* char[] */ 00051 MISDN_CFG_PRES, /* int */ 00052 MISDN_CFG_SCREEN, /* int */ 00053 MISDN_CFG_ALWAYS_IMMEDIATE, /* int (bool) */ 00054 MISDN_CFG_NODIALTONE, /* int (bool) */ 00055 MISDN_CFG_IMMEDIATE, /* int (bool) */ 00056 MISDN_CFG_SENDDTMF, /* int (bool) */ 00057 MISDN_CFG_ASTDTMF, /* int (bool) */ 00058 MISDN_CFG_HOLD_ALLOWED, /* int (bool) */ 00059 MISDN_CFG_EARLY_BCONNECT, /* int (bool) */ 00060 MISDN_CFG_INCOMING_EARLY_AUDIO, /* int (bool) */ 00061 MISDN_CFG_ECHOCANCEL, /* int */ 00062 #ifdef MISDN_1_2 00063 MISDN_CFG_PIPELINE, /* char[] */ 00064 #endif 00065 00066 #ifdef WITH_BEROEC 00067 MISDN_CFG_BNECHOCANCEL, 00068 MISDN_CFG_BNEC_ANTIHOWL, 00069 MISDN_CFG_BNEC_NLP, 00070 MISDN_CFG_BNEC_ZEROCOEFF, 00071 MISDN_CFG_BNEC_TD, 00072 MISDN_CFG_BNEC_ADAPT, 00073 #endif 00074 MISDN_CFG_NEED_MORE_INFOS, /* bool */ 00075 MISDN_CFG_NOAUTORESPOND_ON_SETUP, /* bool */ 00076 MISDN_CFG_NTTIMEOUT, /* bool */ 00077 MISDN_CFG_BRIDGING, /* bool */ 00078 MISDN_CFG_JITTERBUFFER, /* int */ 00079 MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, /* int */ 00080 MISDN_CFG_CALLGROUP, /* ast_group_t */ 00081 MISDN_CFG_PICKUPGROUP, /* ast_group_t */ 00082 MISDN_CFG_MAX_IN, /* int */ 00083 MISDN_CFG_MAX_OUT, /* int */ 00084 MISDN_CFG_L1_TIMEOUT, /* int */ 00085 MISDN_CFG_OVERLAP_DIAL, /* int (bool)*/ 00086 MISDN_CFG_MSNS, /* char[] */ 00087 MISDN_CFG_FAXDETECT, /* char[] */ 00088 MISDN_CFG_FAXDETECT_CONTEXT, /* char[] */ 00089 MISDN_CFG_FAXDETECT_TIMEOUT, /* int */ 00090 MISDN_CFG_PTP, /* int (bool) */ 00091 MISDN_CFG_LAST, 00092 00093 /* general config items */ 00094 MISDN_GEN_FIRST, 00095 #ifndef MISDN_1_2 00096 MISDN_GEN_MISDN_INIT, /* char[] */ 00097 #endif 00098 MISDN_GEN_DEBUG, /* int */ 00099 MISDN_GEN_TRACEFILE, /* char[] */ 00100 MISDN_GEN_BRIDGING, /* int (bool) */ 00101 MISDN_GEN_STOP_TONE, /* int (bool) */ 00102 MISDN_GEN_APPEND_DIGITS2EXTEN, /* int (bool) */ 00103 MISDN_GEN_DYNAMIC_CRYPT, /* int (bool) */ 00104 MISDN_GEN_CRYPT_PREFIX, /* char[] */ 00105 MISDN_GEN_CRYPT_KEYS, /* char[] */ 00106 MISDN_GEN_NTKEEPCALLS, /* int (bool) */ 00107 MISDN_GEN_NTDEBUGFLAGS, /* int */ 00108 MISDN_GEN_NTDEBUGFILE, /* char[] */ 00109 MISDN_GEN_LAST 00110 };
enum misdn_cfg_method |
Definition at line 112 of file chan_misdn_config.h.
00112 { 00113 METHOD_STANDARD = 0, 00114 METHOD_ROUND_ROBIN, 00115 METHOD_STANDARD_DEC 00116 };
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(), config_mutex, general_cfg, map, misdn_cfg_lock(), misdn_cfg_unlock(), port_cfg, and ptp.
Referenced by unload_module().
01103 { 01104 misdn_cfg_lock(); 01105 01106 _free_port_cfg(); 01107 _free_general_cfg(); 01108 01109 ast_free(port_cfg); 01110 ast_free(general_cfg); 01111 ast_free(ptp); 01112 ast_free(map); 01113 01114 misdn_cfg_unlock(); 01115 ast_mutex_destroy(&config_mutex); 01116 }
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(), 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, 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().
00518 { 00519 int place; 00520 00521 if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { 00522 memset(buf, 0, bufsize); 00523 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Port number %d is not valid.\n", port); 00524 return; 00525 } 00526 00527 misdn_cfg_lock(); 00528 if (elem == MISDN_CFG_PTP) { 00529 if (!memcpy(buf, &ptp[port], (bufsize > ptp[port]) ? sizeof(ptp[port]) : bufsize)) 00530 memset(buf, 0, bufsize); 00531 } else { 00532 if ((place = map[elem]) < 0) { 00533 memset(buf, 0, bufsize); 00534 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Invalid element (%d) requested.\n", elem); 00535 } else { 00536 if (elem < MISDN_CFG_LAST) { 00537 switch (port_spec[place].type) { 00538 case MISDN_CTYPE_STR: 00539 if (port_cfg[port][place].str) { 00540 ast_copy_string(buf, port_cfg[port][place].str, bufsize); 00541 } else if (port_cfg[0][place].str) { 00542 ast_copy_string(buf, port_cfg[0][place].str, bufsize); 00543 } else 00544 memset(buf, 0, bufsize); 00545 break; 00546 default: 00547 if (port_cfg[port][place].any) 00548 memcpy(buf, port_cfg[port][place].any, bufsize); 00549 else if (port_cfg[0][place].any) 00550 memcpy(buf, port_cfg[0][place].any, bufsize); 00551 else 00552 memset(buf, 0, bufsize); 00553 } 00554 } else { 00555 switch (gen_spec[place].type) { 00556 case MISDN_CTYPE_STR: 00557 ast_copy_string(buf, S_OR(general_cfg[place].str, ""), bufsize); 00558 break; 00559 default: 00560 if (general_cfg[place].any) 00561 memcpy(buf, general_cfg[place].any, bufsize); 00562 else 00563 memset(buf, 0, bufsize); 00564 } 00565 } 00566 } 00567 } 00568 misdn_cfg_unlock(); 00569 }
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, 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, num, port_cfg, port_spec, ptp, str, and type.
00743 { 00744 int place; 00745 char tempbuf[BUFFERSIZE] = ""; 00746 struct msn_list *iter; 00747 00748 if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { 00749 *buf = 0; 00750 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Port number %d is not valid.\n", port); 00751 return; 00752 } 00753 00754 place = map[elem]; 00755 00756 misdn_cfg_lock(); 00757 if (elem == MISDN_CFG_PTP) { 00758 snprintf(buf, bufsize, " -> ptp: %s", ptp[port] ? "yes" : "no"); 00759 } 00760 else if (elem > MISDN_CFG_FIRST && elem < MISDN_CFG_LAST) { 00761 switch (port_spec[place].type) { 00762 case MISDN_CTYPE_INT: 00763 case MISDN_CTYPE_BOOLINT: 00764 if (port_cfg[port][place].num) 00765 snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[port][place].num); 00766 else if (port_cfg[0][place].num) 00767 snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[0][place].num); 00768 else 00769 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00770 break; 00771 case MISDN_CTYPE_BOOL: 00772 if (port_cfg[port][place].num) 00773 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[port][place].num ? "yes" : "no"); 00774 else if (port_cfg[0][place].num) 00775 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[0][place].num ? "yes" : "no"); 00776 else 00777 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00778 break; 00779 case MISDN_CTYPE_ASTGROUP: 00780 if (port_cfg[port][place].grp) 00781 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 00782 ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp)); 00783 else if (port_cfg[0][place].grp) 00784 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 00785 ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp)); 00786 else 00787 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00788 break; 00789 case MISDN_CTYPE_MSNLIST: 00790 if (port_cfg[port][place].ml) 00791 iter = port_cfg[port][place].ml; 00792 else 00793 iter = port_cfg[0][place].ml; 00794 if (iter) { 00795 for (; iter; iter = iter->next) { 00796 strncat(tempbuf, iter->msn, sizeof(tempbuf) - strlen(tempbuf) - 1); 00797 } 00798 if (strlen(tempbuf) > 1) { 00799 tempbuf[strlen(tempbuf)-2] = 0; 00800 } 00801 } 00802 snprintf(buf, bufsize, " -> msns: %s", *tempbuf ? tempbuf : "none"); 00803 break; 00804 case MISDN_CTYPE_STR: 00805 if ( port_cfg[port][place].str) { 00806 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[port][place].str); 00807 } else if (port_cfg[0][place].str) { 00808 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[0][place].str); 00809 } else { 00810 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00811 } 00812 break; 00813 } 00814 } else if (elem > MISDN_GEN_FIRST && elem < MISDN_GEN_LAST) { 00815 switch (gen_spec[place].type) { 00816 case MISDN_CTYPE_INT: 00817 case MISDN_CTYPE_BOOLINT: 00818 if (general_cfg[place].num) 00819 snprintf(buf, bufsize, " -> %s: %d", gen_spec[place].name, *general_cfg[place].num); 00820 else 00821 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00822 break; 00823 case MISDN_CTYPE_BOOL: 00824 if (general_cfg[place].num) 00825 snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, *general_cfg[place].num ? "yes" : "no"); 00826 else 00827 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00828 break; 00829 case MISDN_CTYPE_STR: 00830 if ( general_cfg[place].str) { 00831 snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, general_cfg[place].str); 00832 } else { 00833 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00834 } 00835 break; 00836 default: 00837 snprintf(buf, bufsize, " -> type of %s not handled yet", gen_spec[place].name); 00838 break; 00839 } 00840 } else { 00841 *buf = 0; 00842 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Invalid config element (%d) requested.\n", elem); 00843 } 00844 misdn_cfg_unlock(); 00845 }
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, gen_spec, MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, MISDN_CFG_LAST, MISDN_GEN_FIRST, MISDN_GEN_LAST, NO_DEFAULT, and port_spec.
Referenced by show_config_description().
00619 { 00620 int place = map[elem]; 00621 struct misdn_cfg_spec *spec = NULL; 00622 00623 /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ 00624 if (elem == MISDN_CFG_GROUPNAME) { 00625 ast_copy_string(buf, ports_description, bufsize); 00626 if (buf_default && bufsize_default) 00627 memset(buf_default, 0, 1); 00628 return; 00629 } 00630 00631 if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) 00632 spec = (struct misdn_cfg_spec *)port_spec; 00633 else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) 00634 spec = (struct misdn_cfg_spec *)gen_spec; 00635 00636 if (!spec || !spec[place].desc) 00637 memset(buf, 0, 1); 00638 else { 00639 ast_copy_string(buf, spec[place].desc, bufsize); 00640 if (buf_default && bufsize) { 00641 if (!strcmp(spec[place].def, NO_DEFAULT)) 00642 memset(buf_default, 0, 1); 00643 else 00644 ast_copy_string(buf_default, spec[place].def, bufsize_default); 00645 } 00646 } 00647 }
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, gen_spec, get_cfg_position(), MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, PORT_CFG, and port_spec.
Referenced by handle_cli_misdn_show_config().
00572 { 00573 int pos; 00574 00575 /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ 00576 if (!strcmp(name, "ports")) 00577 return MISDN_CFG_GROUPNAME; 00578 if (!strcmp(name, "name")) 00579 return MISDN_CFG_FIRST; 00580 00581 pos = get_cfg_position(name, PORT_CFG); 00582 if (pos >= 0) 00583 return port_spec[pos].elem; 00584 00585 pos = get_cfg_position(name, GEN_CFG); 00586 if (pos >= 0) 00587 return gen_spec[pos].elem; 00588 00589 return MISDN_CFG_FIRST; 00590 }
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(), 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().
00593 { 00594 struct misdn_cfg_spec *spec = NULL; 00595 int place = map[elem]; 00596 00597 /* the ptp hack */ 00598 if (elem == MISDN_CFG_PTP) { 00599 memset(buf, 0, 1); 00600 return; 00601 } 00602 00603 /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ 00604 if (elem == MISDN_CFG_GROUPNAME) { 00605 if (!snprintf(buf, bufsize, "ports")) 00606 memset(buf, 0, 1); 00607 return; 00608 } 00609 00610 if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) 00611 spec = (struct misdn_cfg_spec *)port_spec; 00612 else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) 00613 spec = (struct misdn_cfg_spec *)gen_spec; 00614 00615 ast_copy_string(buf, spec ? spec[place].name : "", bufsize); 00616 }
int misdn_cfg_get_next_port | ( | int | port | ) |
Definition at line 847 of file misdn_config.c.
References map, max_ports, MISDN_CFG_GROUPNAME, misdn_cfg_lock(), misdn_cfg_unlock(), port_cfg, and str.
Referenced by complete_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().
00848 { 00849 int p = -1; 00850 int gn = map[MISDN_CFG_GROUPNAME]; 00851 00852 misdn_cfg_lock(); 00853 for (port++; port <= max_ports; port++) { 00854 if (port_cfg[port][gn].str) { 00855 p = port; 00856 break; 00857 } 00858 } 00859 misdn_cfg_unlock(); 00860 00861 return p; 00862 }
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().
00865 { 00866 int p = misdn_cfg_get_next_port(port); 00867 return (p > 0) ? p : misdn_cfg_get_next_port(0); 00868 }
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 map, max_ports, MISDN_CFG_GROUPNAME, misdn_cfg_lock(), misdn_cfg_unlock(), port_cfg, ptp, and str.
Referenced by load_module().
00717 { 00718 char tmp[16]; 00719 int l, i; 00720 int gn = map[MISDN_CFG_GROUPNAME]; 00721 00722 *ports = 0; 00723 00724 misdn_cfg_lock(); 00725 for (i = 1; i <= max_ports; i++) { 00726 if (port_cfg[i][gn].str) { 00727 if (ptp[i]) 00728 sprintf(tmp, "%dptp,", i); 00729 else 00730 sprintf(tmp, "%d,", i); 00731 strcat(ports, tmp); 00732 } 00733 } 00734 misdn_cfg_unlock(); 00735 00736 if ((l = strlen(ports))) { 00737 /* Strip trailing ',' */ 00738 ports[l-1] = 0; 00739 } 00740 }
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_flags, config_mutex, CONFIG_STATUS_FILEUNCHANGED, 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().
01119 { 01120 char config[] = "misdn.conf"; 01121 char *cat, *p; 01122 int i; 01123 struct ast_config *cfg; 01124 struct ast_variable *v; 01125 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 01126 01127 if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags))) { 01128 ast_log(LOG_WARNING, "missing file: misdn.conf\n"); 01129 return -1; 01130 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) 01131 return 0; 01132 01133 ast_mutex_init(&config_mutex); 01134 01135 /* Copy the default jb config over global_jbconf */ 01136 memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); 01137 01138 misdn_cfg_lock(); 01139 01140 if (this_max_ports) { 01141 /* this is the first run */ 01142 max_ports = this_max_ports; 01143 map = ast_calloc(MISDN_GEN_LAST + 1, sizeof(int)); 01144 if (_enum_array_map()) 01145 return -1; 01146 p = ast_calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *) 01147 + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt)); 01148 port_cfg = (union misdn_cfg_pt **)p; 01149 p += (max_ports + 1) * sizeof(union misdn_cfg_pt *); 01150 for (i = 0; i <= max_ports; ++i) { 01151 port_cfg[i] = (union misdn_cfg_pt *)p; 01152 p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt); 01153 } 01154 general_cfg = ast_calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); 01155 ptp = ast_calloc(max_ports + 1, sizeof(int)); 01156 } 01157 else { 01158 /* misdn reload */ 01159 _free_port_cfg(); 01160 _free_general_cfg(); 01161 memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1)); 01162 memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); 01163 memset(ptp, 0, sizeof(int) * (max_ports + 1)); 01164 } 01165 01166 cat = ast_category_browse(cfg, NULL); 01167 01168 while(cat) { 01169 v = ast_variable_browse(cfg, cat); 01170 if (!strcasecmp(cat, "general")) { 01171 _build_general_config(v); 01172 } else { 01173 _build_port_config(v, cat); 01174 } 01175 cat = ast_category_browse(cfg, cat); 01176 } 01177 01178 _fill_defaults(); 01179 01180 misdn_cfg_unlock(); 01181 ast_config_destroy(cfg); 01182 01183 return 0; 01184 }
int misdn_cfg_is_group_method | ( | char * | group, | |
enum misdn_cfg_method | meth | |||
) |
Definition at line 681 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, str, and misdn_cfg_pt::str.
Referenced by misdn_request().
00682 { 00683 int i, re = 0; 00684 char *method ; 00685 00686 misdn_cfg_lock(); 00687 00688 method = port_cfg[0][map[MISDN_CFG_METHOD]].str; 00689 00690 for (i = 1; i <= max_ports; i++) { 00691 if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) { 00692 if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group)) 00693 method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ? 00694 port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str); 00695 } 00696 } 00697 00698 if (method) { 00699 switch (meth) { 00700 case METHOD_STANDARD: re = !strcasecmp(method, "standard"); 00701 break; 00702 case METHOD_ROUND_ROBIN: re = !strcasecmp(method, "round_robin"); 00703 break; 00704 case METHOD_STANDARD_DEC: re = !strcasecmp(method, "standard_dec"); 00705 break; 00706 } 00707 } 00708 misdn_cfg_unlock(); 00709 00710 return re; 00711 }
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_pt::ml, msn_list::msn, msn_list::next, and port_cfg.
Referenced by cb_events().
00650 { 00651 int re = 0; 00652 struct msn_list *iter; 00653 00654 if (!misdn_cfg_is_port_valid(port)) { 00655 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port); 00656 return 0; 00657 } 00658 00659 misdn_cfg_lock(); 00660 if (port_cfg[port][map[MISDN_CFG_MSNS]].ml) 00661 iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml; 00662 else 00663 iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml; 00664 for (; iter; iter = iter->next) 00665 if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) { 00666 re = 1; 00667 break; 00668 } 00669 misdn_cfg_unlock(); 00670 00671 return re; 00672 }
int misdn_cfg_is_port_valid | ( | int | port | ) |
Definition at line 674 of file misdn_config.c.
References map, max_ports, MISDN_CFG_GROUPNAME, port_cfg, and str.
Referenced by misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_is_msn_valid(), and misdn_cfg_update_ptp().
00675 { 00676 int gn = map[MISDN_CFG_GROUPNAME]; 00677 00678 return (port >= 1 && port <= max_ports && port_cfg[port][gn].str); 00679 }
void misdn_cfg_reload | ( | void | ) |
Definition at line 1097 of file misdn_config.c.
References misdn_cfg_init().
Referenced by reload_config().
01098 { 01099 misdn_cfg_init(0, 1); 01100 }
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(), MISDN_GEN_MISDN_INIT, and ptp.
Referenced by load_module(), and reload_config().
01029 { 01030 #ifndef MISDN_1_2 01031 char misdn_init[BUFFERSIZE]; 01032 char line[BUFFERSIZE]; 01033 FILE *fp; 01034 char *tok, *p, *end; 01035 int port; 01036 01037 misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init)); 01038 01039 if (!ast_strlen_zero(misdn_init)) { 01040 fp = fopen(misdn_init, "r"); 01041 if (fp) { 01042 while(fgets(line, sizeof(line), fp)) { 01043 if (!strncmp(line, "nt_ptp", 6)) { 01044 for (tok = strtok_r(line,",=", &p); 01045 tok; 01046 tok = strtok_r(NULL,",=", &p)) { 01047 port = strtol(tok, &end, 10); 01048 if (end != tok && misdn_cfg_is_port_valid(port)) { 01049 misdn_cfg_lock(); 01050 ptp[port] = 1; 01051 misdn_cfg_unlock(); 01052 } 01053 } 01054 } 01055 } 01056 fclose(fp); 01057 } else { 01058 ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno)); 01059 } 01060 } 01061 #else 01062 int i; 01063 int proto; 01064 char filename[128]; 01065 FILE *fp; 01066 01067 for (i = 1; i <= max_ports; ++i) { 01068 snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8); 01069 fp = fopen(filename, "r"); 01070 if (!fp) { 01071 ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno)); 01072 continue; 01073 } 01074 if (fscanf(fp, "0x%08x", &proto) != 1) 01075 ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename); 01076 else 01077 ptp[i] = proto & 1<<5 ? 1 : 0; 01078 fclose(fp); 01079 } 01080 #endif 01081 }
struct ast_jb_conf* misdn_get_global_jbconf | ( | void | ) |
Definition at line 1186 of file misdn_config.c.
References global_jbconf.
Referenced by misdn_new().
01186 { 01187 return &global_jbconf; 01188 }