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.
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 1085 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().
01086 { 01087 misdn_cfg_lock(); 01088 01089 _free_port_cfg(); 01090 _free_general_cfg(); 01091 01092 ast_free(port_cfg); 01093 ast_free(general_cfg); 01094 ast_free(ptp); 01095 ast_free(map); 01096 01097 misdn_cfg_unlock(); 01098 ast_mutex_destroy(&config_mutex); 01099 }
| void misdn_cfg_get | ( | int | port, | |
| enum misdn_cfg_elements | elem, | |||
| void * | buf, | |||
| int | bufsize | |||
| ) |
Definition at line 516 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().
00517 { 00518 int place; 00519 00520 if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { 00521 memset(buf, 0, bufsize); 00522 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Port number %d is not valid.\n", port); 00523 return; 00524 } 00525 00526 misdn_cfg_lock(); 00527 if (elem == MISDN_CFG_PTP) { 00528 if (!memcpy(buf, &ptp[port], (bufsize > ptp[port]) ? sizeof(ptp[port]) : bufsize)) 00529 memset(buf, 0, bufsize); 00530 } else { 00531 if ((place = map[elem]) < 0) { 00532 memset(buf, 0, bufsize); 00533 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Invalid element (%d) requested.\n", elem); 00534 } else { 00535 if (elem < MISDN_CFG_LAST) { 00536 switch (port_spec[place].type) { 00537 case MISDN_CTYPE_STR: 00538 if (port_cfg[port][place].str) { 00539 ast_copy_string(buf, port_cfg[port][place].str, bufsize); 00540 } else if (port_cfg[0][place].str) { 00541 ast_copy_string(buf, port_cfg[0][place].str, bufsize); 00542 } else 00543 memset(buf, 0, bufsize); 00544 break; 00545 default: 00546 if (port_cfg[port][place].any) 00547 memcpy(buf, port_cfg[port][place].any, bufsize); 00548 else if (port_cfg[0][place].any) 00549 memcpy(buf, port_cfg[0][place].any, bufsize); 00550 else 00551 memset(buf, 0, bufsize); 00552 } 00553 } else { 00554 switch (gen_spec[place].type) { 00555 case MISDN_CTYPE_STR: 00556 ast_copy_string(buf, S_OR(general_cfg[place].str, ""), bufsize); 00557 break; 00558 default: 00559 if (general_cfg[place].any) 00560 memcpy(buf, general_cfg[place].any, bufsize); 00561 else 00562 memset(buf, 0, bufsize); 00563 } 00564 } 00565 } 00566 } 00567 misdn_cfg_unlock(); 00568 }
| void misdn_cfg_get_config_string | ( | int | port, | |
| enum misdn_cfg_elements | elem, | |||
| char * | buf, | |||
| int | bufsize | |||
| ) |
Definition at line 741 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().
00742 { 00743 int place; 00744 char tempbuf[BUFFERSIZE] = ""; 00745 struct msn_list *iter; 00746 00747 if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { 00748 *buf = 0; 00749 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Port number %d is not valid.\n", port); 00750 return; 00751 } 00752 00753 place = map[elem]; 00754 00755 misdn_cfg_lock(); 00756 if (elem == MISDN_CFG_PTP) { 00757 snprintf(buf, bufsize, " -> ptp: %s", ptp[port] ? "yes" : "no"); 00758 } 00759 else if (elem > MISDN_CFG_FIRST && elem < MISDN_CFG_LAST) { 00760 switch (port_spec[place].type) { 00761 case MISDN_CTYPE_INT: 00762 case MISDN_CTYPE_BOOLINT: 00763 if (port_cfg[port][place].num) 00764 snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[port][place].num); 00765 else if (port_cfg[0][place].num) 00766 snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[0][place].num); 00767 else 00768 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00769 break; 00770 case MISDN_CTYPE_BOOL: 00771 if (port_cfg[port][place].num) 00772 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[port][place].num ? "yes" : "no"); 00773 else if (port_cfg[0][place].num) 00774 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[0][place].num ? "yes" : "no"); 00775 else 00776 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00777 break; 00778 case MISDN_CTYPE_ASTGROUP: 00779 if (port_cfg[port][place].grp) 00780 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 00781 ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp)); 00782 else if (port_cfg[0][place].grp) 00783 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 00784 ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp)); 00785 else 00786 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00787 break; 00788 case MISDN_CTYPE_MSNLIST: 00789 if (port_cfg[port][place].ml) 00790 iter = port_cfg[port][place].ml; 00791 else 00792 iter = port_cfg[0][place].ml; 00793 if (iter) { 00794 for (; iter; iter = iter->next) { 00795 strncat(tempbuf, iter->msn, sizeof(tempbuf) - strlen(tempbuf) - 1); 00796 } 00797 if (strlen(tempbuf) > 1) { 00798 tempbuf[strlen(tempbuf)-2] = 0; 00799 } 00800 } 00801 snprintf(buf, bufsize, " -> msns: %s", *tempbuf ? tempbuf : "none"); 00802 break; 00803 case MISDN_CTYPE_STR: 00804 if ( port_cfg[port][place].str) { 00805 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[port][place].str); 00806 } else if (port_cfg[0][place].str) { 00807 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[0][place].str); 00808 } else { 00809 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00810 } 00811 break; 00812 } 00813 } else if (elem > MISDN_GEN_FIRST && elem < MISDN_GEN_LAST) { 00814 switch (gen_spec[place].type) { 00815 case MISDN_CTYPE_INT: 00816 case MISDN_CTYPE_BOOLINT: 00817 if (general_cfg[place].num) 00818 snprintf(buf, bufsize, " -> %s: %d", gen_spec[place].name, *general_cfg[place].num); 00819 else 00820 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00821 break; 00822 case MISDN_CTYPE_BOOL: 00823 if (general_cfg[place].num) 00824 snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, *general_cfg[place].num ? "yes" : "no"); 00825 else 00826 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00827 break; 00828 case MISDN_CTYPE_STR: 00829 if ( general_cfg[place].str) { 00830 snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, general_cfg[place].str); 00831 } else { 00832 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00833 } 00834 break; 00835 default: 00836 snprintf(buf, bufsize, " -> type of %s not handled yet", gen_spec[place].name); 00837 break; 00838 } 00839 } else { 00840 *buf = 0; 00841 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Invalid config element (%d) requested.\n", elem); 00842 } 00843 misdn_cfg_unlock(); 00844 }
| void misdn_cfg_get_desc | ( | enum misdn_cfg_elements | elem, | |
| void * | buf, | |||
| int | bufsize, | |||
| void * | buf_default, | |||
| int | bufsize_default | |||
| ) |
Definition at line 617 of file misdn_config.c.
References ast_copy_string(), misdn_cfg_spec::def, desc, MISDN_CFG_FIRST, MISDN_CFG_GROUPNAME, MISDN_CFG_LAST, MISDN_GEN_FIRST, MISDN_GEN_LAST, and NO_DEFAULT.
Referenced by show_config_description().
00618 { 00619 int place = map[elem]; 00620 struct misdn_cfg_spec *spec = NULL; 00621 00622 /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ 00623 if (elem == MISDN_CFG_GROUPNAME) { 00624 ast_copy_string(buf, ports_description, bufsize); 00625 if (buf_default && bufsize_default) 00626 memset(buf_default, 0, 1); 00627 return; 00628 } 00629 00630 if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) 00631 spec = (struct misdn_cfg_spec *)port_spec; 00632 else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) 00633 spec = (struct misdn_cfg_spec *)gen_spec; 00634 00635 if (!spec || !spec[place].desc) 00636 memset(buf, 0, 1); 00637 else { 00638 ast_copy_string(buf, spec[place].desc, bufsize); 00639 if (buf_default && bufsize) { 00640 if (!strcmp(spec[place].def, NO_DEFAULT)) 00641 memset(buf_default, 0, 1); 00642 else 00643 ast_copy_string(buf_default, spec[place].def, bufsize_default); 00644 } 00645 } 00646 }
| enum misdn_cfg_elements misdn_cfg_get_elem | ( | char * | name | ) |
Definition at line 570 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().
00571 { 00572 int pos; 00573 00574 /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ 00575 if (!strcmp(name, "ports")) 00576 return MISDN_CFG_GROUPNAME; 00577 if (!strcmp(name, "name")) 00578 return MISDN_CFG_FIRST; 00579 00580 pos = get_cfg_position(name, PORT_CFG); 00581 if (pos >= 0) 00582 return port_spec[pos].elem; 00583 00584 pos = get_cfg_position(name, GEN_CFG); 00585 if (pos >= 0) 00586 return gen_spec[pos].elem; 00587 00588 return MISDN_CFG_FIRST; 00589 }
| void misdn_cfg_get_name | ( | enum misdn_cfg_elements | elem, | |
| void * | buf, | |||
| int | bufsize | |||
| ) |
Definition at line 591 of file misdn_config.c.
References ast_copy_string(), 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().
00592 { 00593 struct misdn_cfg_spec *spec = NULL; 00594 int place = map[elem]; 00595 00596 /* the ptp hack */ 00597 if (elem == MISDN_CFG_PTP) { 00598 memset(buf, 0, 1); 00599 return; 00600 } 00601 00602 /* here comes a hack to replace the (not existing) "name" element with the "ports" element */ 00603 if (elem == MISDN_CFG_GROUPNAME) { 00604 if (!snprintf(buf, bufsize, "ports")) 00605 memset(buf, 0, 1); 00606 return; 00607 } 00608 00609 if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) 00610 spec = (struct misdn_cfg_spec *)port_spec; 00611 else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) 00612 spec = (struct misdn_cfg_spec *)gen_spec; 00613 00614 ast_copy_string(buf, spec ? spec[place].name : "", bufsize); 00615 }
| int misdn_cfg_get_next_port | ( | int | port | ) |
Definition at line 846 of file misdn_config.c.
References 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().
00847 { 00848 int p = -1; 00849 int gn = map[MISDN_CFG_GROUPNAME]; 00850 00851 misdn_cfg_lock(); 00852 for (port++; port <= max_ports; port++) { 00853 if (port_cfg[port][gn].str) { 00854 p = port; 00855 break; 00856 } 00857 } 00858 misdn_cfg_unlock(); 00859 00860 return p; 00861 }
| int misdn_cfg_get_next_port_spin | ( | int | port | ) |
Definition at line 863 of file misdn_config.c.
References misdn_cfg_get_next_port().
Referenced by misdn_request().
00864 { 00865 int p = misdn_cfg_get_next_port(port); 00866 return (p > 0) ? p : misdn_cfg_get_next_port(0); 00867 }
| void misdn_cfg_get_ports_string | ( | char * | ports | ) |
Generate a comma separated list of all active ports.
Definition at line 715 of file misdn_config.c.
References MISDN_CFG_GROUPNAME, misdn_cfg_lock(), misdn_cfg_unlock(), and str.
Referenced by load_module().
00716 { 00717 char tmp[16]; 00718 int l, i; 00719 int gn = map[MISDN_CFG_GROUPNAME]; 00720 00721 *ports = 0; 00722 00723 misdn_cfg_lock(); 00724 for (i = 1; i <= max_ports; i++) { 00725 if (port_cfg[i][gn].str) { 00726 if (ptp[i]) 00727 sprintf(tmp, "%dptp,", i); 00728 else 00729 sprintf(tmp, "%d,", i); 00730 strcat(ports, tmp); 00731 } 00732 } 00733 misdn_cfg_unlock(); 00734 00735 if ((l = strlen(ports))) { 00736 /* Strip trailing ',' */ 00737 ports[l-1] = 0; 00738 } 00739 }
| int misdn_cfg_init | ( | int | max_ports, | |
| int | reload | |||
| ) |
Definition at line 1101 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_FILEUNCHANGED, global_jbconf, LOG_WARNING, misdn_cfg_lock(), misdn_cfg_unlock(), MISDN_GEN_LAST, NUM_GEN_ELEMENTS, and NUM_PORT_ELEMENTS.
Referenced by load_module(), and misdn_cfg_reload().
01102 { 01103 char config[] = "misdn.conf"; 01104 char *cat, *p; 01105 int i; 01106 struct ast_config *cfg; 01107 struct ast_variable *v; 01108 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 01109 01110 if (!(cfg = ast_config_load2(config, "chan_misdn", config_flags))) { 01111 ast_log(LOG_WARNING, "missing file: misdn.conf\n"); 01112 return -1; 01113 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) 01114 return 0; 01115 01116 ast_mutex_init(&config_mutex); 01117 01118 /* Copy the default jb config over global_jbconf */ 01119 memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); 01120 01121 misdn_cfg_lock(); 01122 01123 if (this_max_ports) { 01124 /* this is the first run */ 01125 max_ports = this_max_ports; 01126 map = ast_calloc(MISDN_GEN_LAST + 1, sizeof(int)); 01127 if (_enum_array_map()) 01128 return -1; 01129 p = ast_calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *) 01130 + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt)); 01131 port_cfg = (union misdn_cfg_pt **)p; 01132 p += (max_ports + 1) * sizeof(union misdn_cfg_pt *); 01133 for (i = 0; i <= max_ports; ++i) { 01134 port_cfg[i] = (union misdn_cfg_pt *)p; 01135 p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt); 01136 } 01137 general_cfg = ast_calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); 01138 ptp = ast_calloc(max_ports + 1, sizeof(int)); 01139 } 01140 else { 01141 /* misdn reload */ 01142 _free_port_cfg(); 01143 _free_general_cfg(); 01144 memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1)); 01145 memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); 01146 memset(ptp, 0, sizeof(int) * (max_ports + 1)); 01147 } 01148 01149 cat = ast_category_browse(cfg, NULL); 01150 01151 while(cat) { 01152 v = ast_variable_browse(cfg, cat); 01153 if (!strcasecmp(cat, "general")) { 01154 _build_general_config(v); 01155 } else { 01156 _build_port_config(v, cat); 01157 } 01158 cat = ast_category_browse(cfg, cat); 01159 } 01160 01161 _fill_defaults(); 01162 01163 misdn_cfg_unlock(); 01164 ast_config_destroy(cfg); 01165 01166 return 0; 01167 }
| int misdn_cfg_is_group_method | ( | char * | group, | |
| enum misdn_cfg_method | meth | |||
| ) |
Definition at line 680 of file misdn_config.c.
References 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().
00681 { 00682 int i, re = 0; 00683 char *method ; 00684 00685 misdn_cfg_lock(); 00686 00687 method = port_cfg[0][map[MISDN_CFG_METHOD]].str; 00688 00689 for (i = 1; i <= max_ports; i++) { 00690 if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) { 00691 if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group)) 00692 method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ? 00693 port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str); 00694 } 00695 } 00696 00697 if (method) { 00698 switch (meth) { 00699 case METHOD_STANDARD: re = !strcasecmp(method, "standard"); 00700 break; 00701 case METHOD_ROUND_ROBIN: re = !strcasecmp(method, "round_robin"); 00702 break; 00703 case METHOD_STANDARD_DEC: re = !strcasecmp(method, "standard_dec"); 00704 break; 00705 } 00706 } 00707 misdn_cfg_unlock(); 00708 00709 return re; 00710 }
| int misdn_cfg_is_msn_valid | ( | int | port, | |
| char * | msn | |||
| ) |
Definition at line 648 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().
00649 { 00650 int re = 0; 00651 struct msn_list *iter; 00652 00653 if (!misdn_cfg_is_port_valid(port)) { 00654 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port); 00655 return 0; 00656 } 00657 00658 misdn_cfg_lock(); 00659 if (port_cfg[port][map[MISDN_CFG_MSNS]].ml) 00660 iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml; 00661 else 00662 iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml; 00663 for (; iter; iter = iter->next) 00664 if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) { 00665 re = 1; 00666 break; 00667 } 00668 misdn_cfg_unlock(); 00669 00670 return re; 00671 }
| int misdn_cfg_is_port_valid | ( | int | port | ) |
Definition at line 673 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().
00674 { 00675 int gn = map[MISDN_CFG_GROUPNAME]; 00676 00677 return (port >= 1 && port <= max_ports && port_cfg[port][gn].str); 00678 }
| void misdn_cfg_reload | ( | void | ) |
Definition at line 1080 of file misdn_config.c.
References misdn_cfg_init().
Referenced by reload_config().
01081 { 01082 misdn_cfg_init(0, 1); 01083 }
| void misdn_cfg_update_ptp | ( | void | ) |
Definition at line 1011 of file misdn_config.c.
References ast_log(), ast_strlen_zero(), BUFFERSIZE, errno, LOG_WARNING, 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().
01012 { 01013 #ifndef MISDN_1_2 01014 char misdn_init[BUFFERSIZE]; 01015 char line[BUFFERSIZE]; 01016 FILE *fp; 01017 char *tok, *p, *end; 01018 int port; 01019 01020 misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init)); 01021 01022 if (!ast_strlen_zero(misdn_init)) { 01023 fp = fopen(misdn_init, "r"); 01024 if (fp) { 01025 while(fgets(line, sizeof(line), fp)) { 01026 if (!strncmp(line, "nt_ptp", 6)) { 01027 for (tok = strtok_r(line,",=", &p); 01028 tok; 01029 tok = strtok_r(NULL,",=", &p)) { 01030 port = strtol(tok, &end, 10); 01031 if (end != tok && misdn_cfg_is_port_valid(port)) { 01032 misdn_cfg_lock(); 01033 ptp[port] = 1; 01034 misdn_cfg_unlock(); 01035 } 01036 } 01037 } 01038 } 01039 fclose(fp); 01040 } else { 01041 ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno)); 01042 } 01043 } 01044 #else 01045 int i; 01046 int proto; 01047 char filename[128]; 01048 FILE *fp; 01049 01050 for (i = 1; i <= max_ports; ++i) { 01051 snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8); 01052 fp = fopen(filename, "r"); 01053 if (!fp) { 01054 ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno)); 01055 continue; 01056 } 01057 if (fscanf(fp, "0x%08x", &proto) != 1) 01058 ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename); 01059 else 01060 ptp[i] = proto & 1<<5 ? 1 : 0; 01061 fclose(fp); 01062 } 01063 #endif 01064 }
| struct ast_jb_conf* misdn_get_global_jbconf | ( | void | ) | [read] |
Definition at line 1169 of file misdn_config.c.
References global_jbconf.
Referenced by misdn_new().
01169 { 01170 return &global_jbconf; 01171 }
1.6.1