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