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