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_INCOMING_CALLERID_TAG, /* char[] */ 00046 MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, /* int (bool) */ 00047 MISDN_CFG_METHOD, /* char[] */ 00048 MISDN_CFG_DIALPLAN, /* int */ 00049 MISDN_CFG_LOCALDIALPLAN, /* int */ 00050 MISDN_CFG_CPNDIALPLAN, /* int */ 00051 MISDN_CFG_TON_PREFIX_UNKNOWN, /* char[] */ 00052 MISDN_CFG_TON_PREFIX_INTERNATIONAL, /* char[] */ 00053 MISDN_CFG_TON_PREFIX_NATIONAL, /* char[] */ 00054 MISDN_CFG_TON_PREFIX_NETWORK_SPECIFIC,/* char[] */ 00055 MISDN_CFG_TON_PREFIX_SUBSCRIBER, /* char[] */ 00056 MISDN_CFG_TON_PREFIX_ABBREVIATED, /* char[] */ 00057 MISDN_CFG_PRES, /* int */ 00058 MISDN_CFG_SCREEN, /* int */ 00059 MISDN_CFG_DISPLAY_CONNECTED, /* int */ 00060 MISDN_CFG_DISPLAY_SETUP, /* int */ 00061 MISDN_CFG_ALWAYS_IMMEDIATE, /* int (bool) */ 00062 MISDN_CFG_NODIALTONE, /* int (bool) */ 00063 MISDN_CFG_IMMEDIATE, /* int (bool) */ 00064 MISDN_CFG_SENDDTMF, /* int (bool) */ 00065 MISDN_CFG_ASTDTMF, /* int (bool) */ 00066 MISDN_CFG_HOLD_ALLOWED, /* int (bool) */ 00067 MISDN_CFG_EARLY_BCONNECT, /* int (bool) */ 00068 MISDN_CFG_INCOMING_EARLY_AUDIO, /* int (bool) */ 00069 MISDN_CFG_ECHOCANCEL, /* int */ 00070 MISDN_CFG_CC_REQUEST_RETENTION,/* bool */ 00071 MISDN_CFG_OUTGOING_COLP, /* int */ 00072 #ifdef MISDN_1_2 00073 MISDN_CFG_PIPELINE, /* char[] */ 00074 #endif 00075 00076 #ifdef WITH_BEROEC 00077 MISDN_CFG_BNECHOCANCEL, 00078 MISDN_CFG_BNEC_ANTIHOWL, 00079 MISDN_CFG_BNEC_NLP, 00080 MISDN_CFG_BNEC_ZEROCOEFF, 00081 MISDN_CFG_BNEC_TD, 00082 MISDN_CFG_BNEC_ADAPT, 00083 #endif 00084 MISDN_CFG_NEED_MORE_INFOS, /* bool */ 00085 MISDN_CFG_NOAUTORESPOND_ON_SETUP, /* bool */ 00086 MISDN_CFG_NTTIMEOUT, /* bool */ 00087 MISDN_CFG_BRIDGING, /* bool */ 00088 MISDN_CFG_JITTERBUFFER, /* int */ 00089 MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, /* int */ 00090 MISDN_CFG_CALLGROUP, /* ast_group_t */ 00091 MISDN_CFG_PICKUPGROUP, /* ast_group_t */ 00092 MISDN_CFG_MAX_IN, /* int */ 00093 MISDN_CFG_MAX_OUT, /* int */ 00094 MISDN_CFG_L1_TIMEOUT, /* int */ 00095 MISDN_CFG_OVERLAP_DIAL, /* int (bool)*/ 00096 MISDN_CFG_MSNS, /* char[] */ 00097 MISDN_CFG_FAXDETECT, /* char[] */ 00098 MISDN_CFG_FAXDETECT_CONTEXT, /* char[] */ 00099 MISDN_CFG_FAXDETECT_TIMEOUT, /* int */ 00100 MISDN_CFG_PTP, /* int (bool) */ 00101 MISDN_CFG_LAST, 00102 00103 /* general config items */ 00104 MISDN_GEN_FIRST, 00105 #ifndef MISDN_1_2 00106 MISDN_GEN_MISDN_INIT, /* char[] */ 00107 #endif 00108 MISDN_GEN_DEBUG, /* int */ 00109 MISDN_GEN_TRACEFILE, /* char[] */ 00110 MISDN_GEN_BRIDGING, /* int (bool) */ 00111 MISDN_GEN_STOP_TONE, /* int (bool) */ 00112 MISDN_GEN_APPEND_DIGITS2EXTEN, /* int (bool) */ 00113 MISDN_GEN_DYNAMIC_CRYPT, /* int (bool) */ 00114 MISDN_GEN_CRYPT_PREFIX, /* char[] */ 00115 MISDN_GEN_CRYPT_KEYS, /* char[] */ 00116 MISDN_GEN_NTKEEPCALLS, /* int (bool) */ 00117 MISDN_GEN_NTDEBUGFLAGS, /* int */ 00118 MISDN_GEN_NTDEBUGFILE, /* char[] */ 00119 MISDN_GEN_LAST 00120 };
enum misdn_cfg_method |
Definition at line 122 of file chan_misdn_config.h.
00122 { 00123 METHOD_STANDARD = 0, 00124 METHOD_ROUND_ROBIN, 00125 METHOD_STANDARD_DEC 00126 };
void misdn_cfg_destroy | ( | void | ) |
Definition at line 1142 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().
01143 { 01144 misdn_cfg_lock(); 01145 01146 _free_port_cfg(); 01147 _free_general_cfg(); 01148 01149 ast_free(port_cfg); 01150 ast_free(general_cfg); 01151 ast_free(ptp); 01152 ast_free(map); 01153 01154 misdn_cfg_unlock(); 01155 ast_mutex_destroy(&config_mutex); 01156 }
void misdn_cfg_get | ( | int | port, | |
enum misdn_cfg_elements | elem, | |||
void * | buf, | |||
int | bufsize | |||
) |
Definition at line 557 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_add_number_prefix(), misdn_bridge(), misdn_call(), misdn_cfg_update_ptp(), misdn_check_l2l1(), misdn_get_connected_line(), misdn_new(), misdn_request(), misdn_set_opt_exec(), process_ast_dsp(), read_config(), reload_config(), update_config(), and update_ec_config().
00558 { 00559 int place; 00560 00561 if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { 00562 memset(buf, 0, bufsize); 00563 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Port number %d is not valid.\n", port); 00564 return; 00565 } 00566 00567 misdn_cfg_lock(); 00568 if (elem == MISDN_CFG_PTP) { 00569 if (!memcpy(buf, &ptp[port], (bufsize > ptp[port]) ? sizeof(ptp[port]) : bufsize)) 00570 memset(buf, 0, bufsize); 00571 } else { 00572 if ((place = map[elem]) < 0) { 00573 memset(buf, 0, bufsize); 00574 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Invalid element (%d) requested.\n", elem); 00575 } else { 00576 if (elem < MISDN_CFG_LAST) { 00577 switch (port_spec[place].type) { 00578 case MISDN_CTYPE_STR: 00579 if (port_cfg[port][place].str) { 00580 ast_copy_string(buf, port_cfg[port][place].str, bufsize); 00581 } else if (port_cfg[0][place].str) { 00582 ast_copy_string(buf, port_cfg[0][place].str, bufsize); 00583 } else 00584 memset(buf, 0, bufsize); 00585 break; 00586 default: 00587 if (port_cfg[port][place].any) 00588 memcpy(buf, port_cfg[port][place].any, bufsize); 00589 else if (port_cfg[0][place].any) 00590 memcpy(buf, port_cfg[0][place].any, bufsize); 00591 else 00592 memset(buf, 0, bufsize); 00593 } 00594 } else { 00595 switch (gen_spec[place].type) { 00596 case MISDN_CTYPE_STR: 00597 ast_copy_string(buf, S_OR(general_cfg[place].str, ""), bufsize); 00598 break; 00599 default: 00600 if (general_cfg[place].any) 00601 memcpy(buf, general_cfg[place].any, bufsize); 00602 else 00603 memset(buf, 0, bufsize); 00604 } 00605 } 00606 } 00607 } 00608 misdn_cfg_unlock(); 00609 }
void misdn_cfg_get_config_string | ( | int | port, | |
enum misdn_cfg_elements | elem, | |||
char * | buf, | |||
int | bufsize | |||
) |
Definition at line 782 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, str, and type.
00783 { 00784 int place; 00785 char tempbuf[BUFFERSIZE] = ""; 00786 struct msn_list *iter; 00787 00788 if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { 00789 *buf = 0; 00790 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Port number %d is not valid.\n", port); 00791 return; 00792 } 00793 00794 place = map[elem]; 00795 00796 misdn_cfg_lock(); 00797 if (elem == MISDN_CFG_PTP) { 00798 snprintf(buf, bufsize, " -> ptp: %s", ptp[port] ? "yes" : "no"); 00799 } 00800 else if (elem > MISDN_CFG_FIRST && elem < MISDN_CFG_LAST) { 00801 switch (port_spec[place].type) { 00802 case MISDN_CTYPE_INT: 00803 case MISDN_CTYPE_BOOLINT: 00804 if (port_cfg[port][place].num) 00805 snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[port][place].num); 00806 else if (port_cfg[0][place].num) 00807 snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[0][place].num); 00808 else 00809 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00810 break; 00811 case MISDN_CTYPE_BOOL: 00812 if (port_cfg[port][place].num) 00813 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[port][place].num ? "yes" : "no"); 00814 else if (port_cfg[0][place].num) 00815 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[0][place].num ? "yes" : "no"); 00816 else 00817 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00818 break; 00819 case MISDN_CTYPE_ASTGROUP: 00820 if (port_cfg[port][place].grp) 00821 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 00822 ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp)); 00823 else if (port_cfg[0][place].grp) 00824 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 00825 ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp)); 00826 else 00827 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00828 break; 00829 case MISDN_CTYPE_MSNLIST: 00830 if (port_cfg[port][place].ml) 00831 iter = port_cfg[port][place].ml; 00832 else 00833 iter = port_cfg[0][place].ml; 00834 if (iter) { 00835 for (; iter; iter = iter->next) { 00836 strncat(tempbuf, iter->msn, sizeof(tempbuf) - strlen(tempbuf) - 1); 00837 } 00838 if (strlen(tempbuf) > 1) { 00839 tempbuf[strlen(tempbuf)-2] = 0; 00840 } 00841 } 00842 snprintf(buf, bufsize, " -> msns: %s", *tempbuf ? tempbuf : "none"); 00843 break; 00844 case MISDN_CTYPE_STR: 00845 if ( port_cfg[port][place].str) { 00846 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[port][place].str); 00847 } else if (port_cfg[0][place].str) { 00848 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[0][place].str); 00849 } else { 00850 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00851 } 00852 break; 00853 } 00854 } else if (elem > MISDN_GEN_FIRST && elem < MISDN_GEN_LAST) { 00855 switch (gen_spec[place].type) { 00856 case MISDN_CTYPE_INT: 00857 case MISDN_CTYPE_BOOLINT: 00858 if (general_cfg[place].num) 00859 snprintf(buf, bufsize, " -> %s: %d", gen_spec[place].name, *general_cfg[place].num); 00860 else 00861 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00862 break; 00863 case MISDN_CTYPE_BOOL: 00864 if (general_cfg[place].num) 00865 snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, *general_cfg[place].num ? "yes" : "no"); 00866 else 00867 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00868 break; 00869 case MISDN_CTYPE_STR: 00870 if ( general_cfg[place].str) { 00871 snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, general_cfg[place].str); 00872 } else { 00873 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00874 } 00875 break; 00876 default: 00877 snprintf(buf, bufsize, " -> type of %s not handled yet", gen_spec[place].name); 00878 break; 00879 } 00880 } else { 00881 *buf = 0; 00882 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Invalid config element (%d) requested.\n", elem); 00883 } 00884 misdn_cfg_unlock(); 00885 }
void misdn_cfg_get_desc | ( | enum misdn_cfg_elements | elem, | |
void * | buf, | |||
int | bufsize, | |||
void * | buf_default, | |||
int | bufsize_default | |||
) |
Definition at line 658 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().
00659 { 00660 int place = map[elem]; 00661 struct misdn_cfg_spec *spec = NULL; 00662 00663 /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ 00664 if (elem == MISDN_CFG_GROUPNAME) { 00665 ast_copy_string(buf, ports_description, bufsize); 00666 if (buf_default && bufsize_default) 00667 memset(buf_default, 0, 1); 00668 return; 00669 } 00670 00671 if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) 00672 spec = (struct misdn_cfg_spec *)port_spec; 00673 else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) 00674 spec = (struct misdn_cfg_spec *)gen_spec; 00675 00676 if (!spec || !spec[place].desc) 00677 memset(buf, 0, 1); 00678 else { 00679 ast_copy_string(buf, spec[place].desc, bufsize); 00680 if (buf_default && bufsize) { 00681 if (!strcmp(spec[place].def, NO_DEFAULT)) 00682 memset(buf_default, 0, 1); 00683 else 00684 ast_copy_string(buf_default, spec[place].def, bufsize_default); 00685 } 00686 } 00687 }
enum misdn_cfg_elements misdn_cfg_get_elem | ( | const char * | name | ) |
Definition at line 611 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().
00612 { 00613 int pos; 00614 00615 /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ 00616 if (!strcmp(name, "ports")) 00617 return MISDN_CFG_GROUPNAME; 00618 if (!strcmp(name, "name")) 00619 return MISDN_CFG_FIRST; 00620 00621 pos = get_cfg_position(name, PORT_CFG); 00622 if (pos >= 0) 00623 return port_spec[pos].elem; 00624 00625 pos = get_cfg_position(name, GEN_CFG); 00626 if (pos >= 0) 00627 return gen_spec[pos].elem; 00628 00629 return MISDN_CFG_FIRST; 00630 }
void misdn_cfg_get_name | ( | enum misdn_cfg_elements | elem, | |
void * | buf, | |||
int | bufsize | |||
) |
Definition at line 632 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().
00633 { 00634 struct misdn_cfg_spec *spec = NULL; 00635 int place = map[elem]; 00636 00637 /* the ptp hack */ 00638 if (elem == MISDN_CFG_PTP) { 00639 memset(buf, 0, 1); 00640 return; 00641 } 00642 00643 /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ 00644 if (elem == MISDN_CFG_GROUPNAME) { 00645 if (!snprintf(buf, bufsize, "ports")) 00646 memset(buf, 0, 1); 00647 return; 00648 } 00649 00650 if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) 00651 spec = (struct misdn_cfg_spec *)port_spec; 00652 else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) 00653 spec = (struct misdn_cfg_spec *)gen_spec; 00654 00655 ast_copy_string(buf, spec ? spec[place].name : "", bufsize); 00656 }
int misdn_cfg_get_next_port | ( | int | port | ) |
Definition at line 887 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().
00888 { 00889 int p = -1; 00890 int gn = map[MISDN_CFG_GROUPNAME]; 00891 00892 misdn_cfg_lock(); 00893 for (port++; port <= max_ports; port++) { 00894 if (port_cfg[port][gn].str) { 00895 p = port; 00896 break; 00897 } 00898 } 00899 misdn_cfg_unlock(); 00900 00901 return p; 00902 }
int misdn_cfg_get_next_port_spin | ( | int | port | ) |
Definition at line 904 of file misdn_config.c.
References misdn_cfg_get_next_port().
Referenced by misdn_request().
00905 { 00906 int p = misdn_cfg_get_next_port(port); 00907 return (p > 0) ? p : misdn_cfg_get_next_port(0); 00908 }
void misdn_cfg_get_ports_string | ( | char * | ports | ) |
Generate a comma separated list of all active ports.
Definition at line 756 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().
00757 { 00758 char tmp[16]; 00759 int l, i; 00760 int gn = map[MISDN_CFG_GROUPNAME]; 00761 00762 *ports = 0; 00763 00764 misdn_cfg_lock(); 00765 for (i = 1; i <= max_ports; i++) { 00766 if (port_cfg[i][gn].str) { 00767 if (ptp[i]) 00768 sprintf(tmp, "%dptp,", i); 00769 else 00770 sprintf(tmp, "%d,", i); 00771 strcat(ports, tmp); 00772 } 00773 } 00774 misdn_cfg_unlock(); 00775 00776 if ((l = strlen(ports))) { 00777 /* Strip trailing ',' */ 00778 ports[l-1] = 0; 00779 } 00780 }
int misdn_cfg_init | ( | int | max_ports, | |
int | reload | |||
) |
Definition at line 1158 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_FILEINVALID, 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().
01159 { 01160 char config[] = "misdn.conf"; 01161 char *cat, *p; 01162 int i; 01163 struct ast_config *cfg; 01164 struct ast_variable *v; 01165 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 01166 01167 if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) { 01168 ast_log(LOG_WARNING, "missing or invalid file: misdn.conf\n"); 01169 return -1; 01170 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) 01171 return 0; 01172 01173 ast_mutex_init(&config_mutex); 01174 01175 /* Copy the default jb config over global_jbconf */ 01176 memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); 01177 01178 misdn_cfg_lock(); 01179 01180 if (this_max_ports) { 01181 /* this is the first run */ 01182 max_ports = this_max_ports; 01183 map = ast_calloc(MISDN_GEN_LAST + 1, sizeof(int)); 01184 if (_enum_array_map()) 01185 return -1; 01186 p = ast_calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *) 01187 + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt)); 01188 port_cfg = (union misdn_cfg_pt **)p; 01189 p += (max_ports + 1) * sizeof(union misdn_cfg_pt *); 01190 for (i = 0; i <= max_ports; ++i) { 01191 port_cfg[i] = (union misdn_cfg_pt *)p; 01192 p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt); 01193 } 01194 general_cfg = ast_calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); 01195 ptp = ast_calloc(max_ports + 1, sizeof(int)); 01196 } 01197 else { 01198 /* misdn reload */ 01199 _free_port_cfg(); 01200 _free_general_cfg(); 01201 memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1)); 01202 memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); 01203 memset(ptp, 0, sizeof(int) * (max_ports + 1)); 01204 } 01205 01206 cat = ast_category_browse(cfg, NULL); 01207 01208 while(cat) { 01209 v = ast_variable_browse(cfg, cat); 01210 if (!strcasecmp(cat, "general")) { 01211 _build_general_config(v); 01212 } else { 01213 _build_port_config(v, cat); 01214 } 01215 cat = ast_category_browse(cfg, cat); 01216 } 01217 01218 _fill_defaults(); 01219 01220 misdn_cfg_unlock(); 01221 ast_config_destroy(cfg); 01222 01223 return 0; 01224 }
int misdn_cfg_is_group_method | ( | char * | group, | |
enum misdn_cfg_method | meth | |||
) |
Definition at line 721 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().
00722 { 00723 int i, re = 0; 00724 char *method ; 00725 00726 misdn_cfg_lock(); 00727 00728 method = port_cfg[0][map[MISDN_CFG_METHOD]].str; 00729 00730 for (i = 1; i <= max_ports; i++) { 00731 if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) { 00732 if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group)) 00733 method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ? 00734 port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str); 00735 } 00736 } 00737 00738 if (method) { 00739 switch (meth) { 00740 case METHOD_STANDARD: re = !strcasecmp(method, "standard"); 00741 break; 00742 case METHOD_ROUND_ROBIN: re = !strcasecmp(method, "round_robin"); 00743 break; 00744 case METHOD_STANDARD_DEC: re = !strcasecmp(method, "standard_dec"); 00745 break; 00746 } 00747 } 00748 misdn_cfg_unlock(); 00749 00750 return re; 00751 }
int misdn_cfg_is_msn_valid | ( | int | port, | |
char * | msn | |||
) |
Definition at line 689 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 misdn_is_msn_valid().
00690 { 00691 int re = 0; 00692 struct msn_list *iter; 00693 00694 if (!misdn_cfg_is_port_valid(port)) { 00695 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port); 00696 return 0; 00697 } 00698 00699 misdn_cfg_lock(); 00700 if (port_cfg[port][map[MISDN_CFG_MSNS]].ml) 00701 iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml; 00702 else 00703 iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml; 00704 for (; iter; iter = iter->next) 00705 if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) { 00706 re = 1; 00707 break; 00708 } 00709 misdn_cfg_unlock(); 00710 00711 return re; 00712 }
int misdn_cfg_is_port_valid | ( | int | port | ) |
Definition at line 714 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().
00715 { 00716 int gn = map[MISDN_CFG_GROUPNAME]; 00717 00718 return (port >= 1 && port <= max_ports && port_cfg[port][gn].str); 00719 }
void misdn_cfg_reload | ( | void | ) |
Definition at line 1137 of file misdn_config.c.
References misdn_cfg_init().
Referenced by reload_config().
01138 { 01139 misdn_cfg_init(0, 1); 01140 }
void misdn_cfg_update_ptp | ( | void | ) |
Definition at line 1068 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().
01069 { 01070 #ifndef MISDN_1_2 01071 char misdn_init[BUFFERSIZE]; 01072 char line[BUFFERSIZE]; 01073 FILE *fp; 01074 char *tok, *p, *end; 01075 int port; 01076 01077 misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init)); 01078 01079 if (!ast_strlen_zero(misdn_init)) { 01080 fp = fopen(misdn_init, "r"); 01081 if (fp) { 01082 while(fgets(line, sizeof(line), fp)) { 01083 if (!strncmp(line, "nt_ptp", 6)) { 01084 for (tok = strtok_r(line,",=", &p); 01085 tok; 01086 tok = strtok_r(NULL,",=", &p)) { 01087 port = strtol(tok, &end, 10); 01088 if (end != tok && misdn_cfg_is_port_valid(port)) { 01089 misdn_cfg_lock(); 01090 ptp[port] = 1; 01091 misdn_cfg_unlock(); 01092 } 01093 } 01094 } 01095 } 01096 fclose(fp); 01097 } else { 01098 ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno)); 01099 } 01100 } 01101 #else 01102 int i; 01103 int proto; 01104 char filename[128]; 01105 FILE *fp; 01106 01107 for (i = 1; i <= max_ports; ++i) { 01108 snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8); 01109 fp = fopen(filename, "r"); 01110 if (!fp) { 01111 ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno)); 01112 continue; 01113 } 01114 if (fscanf(fp, "0x%08x", &proto) != 1) 01115 ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename); 01116 else 01117 ptp[i] = proto & 1<<5 ? 1 : 0; 01118 fclose(fp); 01119 } 01120 #endif 01121 }
struct ast_jb_conf* misdn_get_global_jbconf | ( | void | ) |
Definition at line 1226 of file misdn_config.c.
References global_jbconf.
Referenced by misdn_new().
01226 { 01227 return &global_jbconf; 01228 }