This graph shows which files directly or indirectly include this file:
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 1071 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().
01072 { 01073 misdn_cfg_lock(); 01074 01075 _free_port_cfg(); 01076 _free_general_cfg(); 01077 01078 free(port_cfg); 01079 free(general_cfg); 01080 free(ptp); 01081 free(map); 01082 01083 misdn_cfg_unlock(); 01084 ast_mutex_destroy(&config_mutex); 01085 }
void misdn_cfg_get | ( | int | port, | |
enum misdn_cfg_elements | elem, | |||
void * | buf, | |||
int | bufsize | |||
) |
Definition at line 509 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().
00510 { 00511 int place; 00512 00513 if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { 00514 memset(buf, 0, bufsize); 00515 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Port number %d is not valid.\n", port); 00516 return; 00517 } 00518 00519 misdn_cfg_lock(); 00520 if (elem == MISDN_CFG_PTP) { 00521 if (!memcpy(buf, &ptp[port], (bufsize > ptp[port]) ? sizeof(ptp[port]) : bufsize)) 00522 memset(buf, 0, bufsize); 00523 } else { 00524 if ((place = map[elem]) < 0) { 00525 memset (buf, 0, bufsize); 00526 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Invalid element (%d) requested.\n", elem); 00527 } else { 00528 if (elem < MISDN_CFG_LAST) { 00529 switch (port_spec[place].type) { 00530 case MISDN_CTYPE_STR: 00531 if (port_cfg[port][place].str) { 00532 if (!memccpy(buf, port_cfg[port][place].str, 0, bufsize)) 00533 memset(buf, 0, 1); 00534 } else if (port_cfg[0][place].str) { 00535 if (!memccpy(buf, port_cfg[0][place].str, 0, bufsize)) 00536 memset(buf, 0, 1); 00537 } else 00538 memset(buf, 0, bufsize); 00539 break; 00540 default: 00541 if (port_cfg[port][place].any) 00542 memcpy(buf, port_cfg[port][place].any, bufsize); 00543 else if (port_cfg[0][place].any) 00544 memcpy(buf, port_cfg[0][place].any, bufsize); 00545 else 00546 memset(buf, 0, bufsize); 00547 } 00548 } else { 00549 switch (gen_spec[place].type) { 00550 case MISDN_CTYPE_STR: 00551 if (!general_cfg[place].str || !memccpy(buf, general_cfg[place].str, 0, bufsize)) 00552 memset(buf, 0, 1); 00553 break; 00554 default: 00555 if (general_cfg[place].any) 00556 memcpy(buf, general_cfg[place].any, bufsize); 00557 else 00558 memset(buf, 0, bufsize); 00559 } 00560 } 00561 } 00562 } 00563 misdn_cfg_unlock(); 00564 }
void misdn_cfg_get_config_string | ( | int | port, | |
enum misdn_cfg_elements | elem, | |||
char * | buf, | |||
int | bufsize | |||
) |
Definition at line 735 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().
00736 { 00737 int place; 00738 char tempbuf[BUFFERSIZE] = ""; 00739 struct msn_list *iter; 00740 00741 if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { 00742 *buf = 0; 00743 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Port number %d is not valid.\n", port); 00744 return; 00745 } 00746 00747 place = map[elem]; 00748 00749 misdn_cfg_lock(); 00750 if (elem == MISDN_CFG_PTP) { 00751 snprintf(buf, bufsize, " -> ptp: %s", ptp[port] ? "yes" : "no"); 00752 } 00753 else if (elem > MISDN_CFG_FIRST && elem < MISDN_CFG_LAST) { 00754 switch (port_spec[place].type) { 00755 case MISDN_CTYPE_INT: 00756 case MISDN_CTYPE_BOOLINT: 00757 if (port_cfg[port][place].num) 00758 snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[port][place].num); 00759 else if (port_cfg[0][place].num) 00760 snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[0][place].num); 00761 else 00762 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00763 break; 00764 case MISDN_CTYPE_BOOL: 00765 if (port_cfg[port][place].num) 00766 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[port][place].num ? "yes" : "no"); 00767 else if (port_cfg[0][place].num) 00768 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[0][place].num ? "yes" : "no"); 00769 else 00770 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00771 break; 00772 case MISDN_CTYPE_ASTGROUP: 00773 if (port_cfg[port][place].grp) 00774 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 00775 ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp)); 00776 else if (port_cfg[0][place].grp) 00777 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 00778 ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp)); 00779 else 00780 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00781 break; 00782 case MISDN_CTYPE_MSNLIST: 00783 if (port_cfg[port][place].ml) 00784 iter = port_cfg[port][place].ml; 00785 else 00786 iter = port_cfg[0][place].ml; 00787 if (iter) { 00788 for (; iter; iter = iter->next) 00789 sprintf(tempbuf, "%s%s, ", tempbuf, iter->msn); 00790 tempbuf[strlen(tempbuf)-2] = 0; 00791 } 00792 snprintf(buf, bufsize, " -> msns: %s", *tempbuf ? tempbuf : "none"); 00793 break; 00794 case MISDN_CTYPE_STR: 00795 if ( port_cfg[port][place].str) { 00796 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[port][place].str); 00797 } else if (port_cfg[0][place].str) { 00798 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[0][place].str); 00799 } else { 00800 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00801 } 00802 break; 00803 } 00804 } else if (elem > MISDN_GEN_FIRST && elem < MISDN_GEN_LAST) { 00805 switch (gen_spec[place].type) { 00806 case MISDN_CTYPE_INT: 00807 case MISDN_CTYPE_BOOLINT: 00808 if (general_cfg[place].num) 00809 snprintf(buf, bufsize, " -> %s: %d", gen_spec[place].name, *general_cfg[place].num); 00810 else 00811 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00812 break; 00813 case MISDN_CTYPE_BOOL: 00814 if (general_cfg[place].num) 00815 snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, *general_cfg[place].num ? "yes" : "no"); 00816 else 00817 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00818 break; 00819 case MISDN_CTYPE_STR: 00820 if ( general_cfg[place].str) { 00821 snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, general_cfg[place].str); 00822 } else { 00823 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00824 } 00825 break; 00826 default: 00827 snprintf(buf, bufsize, " -> type of %s not handled yet", gen_spec[place].name); 00828 break; 00829 } 00830 } else { 00831 *buf = 0; 00832 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Invalid config element (%d) requested.\n", elem); 00833 } 00834 misdn_cfg_unlock(); 00835 }
void misdn_cfg_get_desc | ( | enum misdn_cfg_elements | elem, | |
void * | buf, | |||
int | bufsize, | |||
void * | buf_default, | |||
int | bufsize_default | |||
) |
Definition at line 614 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().
00615 { 00616 int place = map[elem]; 00617 struct misdn_cfg_spec *spec = NULL; 00618 00619 /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */ 00620 if (elem == MISDN_CFG_GROUPNAME) { 00621 if (!memccpy(buf, ports_description, 0, bufsize)) 00622 memset(buf, 0, 1); 00623 if (buf_default && bufsize_default) 00624 memset(buf_default, 0, 1); 00625 return; 00626 } 00627 00628 if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) 00629 spec = (struct misdn_cfg_spec *)port_spec; 00630 else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) 00631 spec = (struct misdn_cfg_spec *)gen_spec; 00632 00633 if (!spec || !spec[place].desc) 00634 memset(buf, 0, 1); 00635 else { 00636 if (!memccpy(buf, spec[place].desc, 0, bufsize)) 00637 memset(buf, 0, 1); 00638 if (buf_default && bufsize) { 00639 if (!strcmp(spec[place].def, NO_DEFAULT)) 00640 memset(buf_default, 0, 1); 00641 else if (!memccpy(buf_default, spec[place].def, 0, bufsize_default)) 00642 memset(buf_default, 0, 1); 00643 } 00644 } 00645 }
enum misdn_cfg_elements misdn_cfg_get_elem | ( | char * | name | ) |
Definition at line 566 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().
00567 { 00568 int pos; 00569 00570 /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */ 00571 if (!strcmp(name, "ports")) 00572 return MISDN_CFG_GROUPNAME; 00573 if (!strcmp(name, "name")) 00574 return MISDN_CFG_FIRST; 00575 00576 pos = get_cfg_position (name, PORT_CFG); 00577 if (pos >= 0) 00578 return port_spec[pos].elem; 00579 00580 pos = get_cfg_position (name, GEN_CFG); 00581 if (pos >= 0) 00582 return gen_spec[pos].elem; 00583 00584 return MISDN_CFG_FIRST; 00585 }
void misdn_cfg_get_name | ( | enum misdn_cfg_elements | elem, | |
void * | buf, | |||
int | bufsize | |||
) |
Definition at line 587 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().
00588 { 00589 struct misdn_cfg_spec *spec = NULL; 00590 int place = map[elem]; 00591 00592 /* the ptp hack */ 00593 if (elem == MISDN_CFG_PTP) { 00594 memset(buf, 0, 1); 00595 return; 00596 } 00597 00598 /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */ 00599 if (elem == MISDN_CFG_GROUPNAME) { 00600 if (!snprintf(buf, bufsize, "ports")) 00601 memset(buf, 0, 1); 00602 return; 00603 } 00604 00605 if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) 00606 spec = (struct misdn_cfg_spec *)port_spec; 00607 else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) 00608 spec = (struct misdn_cfg_spec *)gen_spec; 00609 00610 if (!spec || !memccpy(buf, spec[place].name, 0, bufsize)) 00611 memset(buf, 0, 1); 00612 }
int misdn_cfg_get_next_port | ( | int | port | ) |
Definition at line 837 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().
00838 { 00839 int p = -1; 00840 int gn = map[MISDN_CFG_GROUPNAME]; 00841 00842 misdn_cfg_lock(); 00843 for (port++; port <= max_ports; port++) { 00844 if (port_cfg[port][gn].str) { 00845 p = port; 00846 break; 00847 } 00848 } 00849 misdn_cfg_unlock(); 00850 00851 return p; 00852 }
int misdn_cfg_get_next_port_spin | ( | int | port | ) |
Definition at line 854 of file misdn_config.c.
References misdn_cfg_get_next_port().
Referenced by misdn_request().
00855 { 00856 int p = misdn_cfg_get_next_port(port); 00857 return (p > 0) ? p : misdn_cfg_get_next_port(0); 00858 }
void misdn_cfg_get_ports_string | ( | char * | ports | ) |
Definition at line 711 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().
00712 { 00713 char tmp[16]; 00714 int l, i; 00715 int gn = map[MISDN_CFG_GROUPNAME]; 00716 00717 *ports = 0; 00718 00719 misdn_cfg_lock(); 00720 for (i = 1; i <= max_ports; i++) { 00721 if (port_cfg[i][gn].str) { 00722 if (ptp[i]) 00723 sprintf(tmp, "%dptp,", i); 00724 else 00725 sprintf(tmp, "%d,", i); 00726 strcat(ports, tmp); 00727 } 00728 } 00729 misdn_cfg_unlock(); 00730 00731 if ((l = strlen(ports))) 00732 ports[l-1] = 0; 00733 }
int misdn_cfg_init | ( | int | max_ports | ) |
Definition at line 1087 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, general_cfg, 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().
01088 { 01089 char config[] = "misdn.conf"; 01090 char *cat, *p; 01091 int i; 01092 struct ast_config *cfg; 01093 struct ast_variable *v; 01094 01095 if (!(cfg = AST_LOAD_CFG(config))) { 01096 ast_log(LOG_WARNING, "missing file: misdn.conf\n"); 01097 return -1; 01098 } 01099 01100 ast_mutex_init(&config_mutex); 01101 01102 misdn_cfg_lock(); 01103 01104 if (this_max_ports) { 01105 /* this is the first run */ 01106 max_ports = this_max_ports; 01107 map = (int *)calloc(MISDN_GEN_LAST + 1, sizeof(int)); 01108 if (_enum_array_map()) 01109 return -1; 01110 p = (char *)calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *) 01111 + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt)); 01112 port_cfg = (union misdn_cfg_pt **)p; 01113 p += (max_ports + 1) * sizeof(union misdn_cfg_pt *); 01114 for (i = 0; i <= max_ports; ++i) { 01115 port_cfg[i] = (union misdn_cfg_pt *)p; 01116 p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt); 01117 } 01118 general_cfg = (union misdn_cfg_pt *)calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); 01119 ptp = (int *)calloc(max_ports + 1, sizeof(int)); 01120 } 01121 else { 01122 /* misdn reload */ 01123 _free_port_cfg(); 01124 _free_general_cfg(); 01125 memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1)); 01126 memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); 01127 memset(ptp, 0, sizeof(int) * (max_ports + 1)); 01128 } 01129 01130 cat = ast_category_browse(cfg, NULL); 01131 01132 while(cat) { 01133 v = ast_variable_browse(cfg, cat); 01134 if (!strcasecmp(cat, "general")) { 01135 _build_general_config(v); 01136 } else { 01137 _build_port_config(v, cat); 01138 } 01139 cat = ast_category_browse(cfg, cat); 01140 } 01141 01142 _fill_defaults(); 01143 01144 misdn_cfg_unlock(); 01145 AST_DESTROY_CFG(cfg); 01146 01147 return 0; 01148 }
int misdn_cfg_is_group_method | ( | char * | group, | |
enum misdn_cfg_method | meth | |||
) |
Definition at line 679 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().
00680 { 00681 int i, re = 0; 00682 char *method ; 00683 00684 misdn_cfg_lock(); 00685 00686 method = port_cfg[0][map[MISDN_CFG_METHOD]].str; 00687 00688 for (i = 1; i <= max_ports; i++) { 00689 if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) { 00690 if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group)) 00691 method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ? 00692 port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str); 00693 } 00694 } 00695 00696 if (method) { 00697 switch (meth) { 00698 case METHOD_STANDARD: re = !strcasecmp(method, "standard"); 00699 break; 00700 case METHOD_ROUND_ROBIN: re = !strcasecmp(method, "round_robin"); 00701 break; 00702 case METHOD_STANDARD_DEC: re = !strcasecmp(method, "standard_dec"); 00703 break; 00704 } 00705 } 00706 misdn_cfg_unlock(); 00707 00708 return re; 00709 }
int misdn_cfg_is_msn_valid | ( | int | port, | |
char * | msn | |||
) |
Definition at line 647 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().
00648 { 00649 int re = 0; 00650 struct msn_list *iter; 00651 00652 if (!misdn_cfg_is_port_valid(port)) { 00653 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port); 00654 return 0; 00655 } 00656 00657 misdn_cfg_lock(); 00658 if (port_cfg[port][map[MISDN_CFG_MSNS]].ml) 00659 iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml; 00660 else 00661 iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml; 00662 for (; iter; iter = iter->next) 00663 if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) { 00664 re = 1; 00665 break; 00666 } 00667 misdn_cfg_unlock(); 00668 00669 return re; 00670 }
int misdn_cfg_is_port_valid | ( | int | port | ) |
Definition at line 672 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().
00673 { 00674 int gn = map[MISDN_CFG_GROUPNAME]; 00675 00676 return (port >= 1 && port <= max_ports && port_cfg[port][gn].str); 00677 }
void misdn_cfg_reload | ( | void | ) |
Definition at line 1066 of file misdn_config.c.
References misdn_cfg_init().
Referenced by reload_config().
01067 { 01068 misdn_cfg_init (0); 01069 }
void misdn_cfg_update_ptp | ( | void | ) |
Definition at line 997 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().
00998 { 00999 #ifndef MISDN_1_2 01000 char misdn_init[BUFFERSIZE]; 01001 char line[BUFFERSIZE]; 01002 FILE *fp; 01003 char *tok, *p, *end; 01004 int port; 01005 01006 misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init)); 01007 01008 if (!ast_strlen_zero(misdn_init)) { 01009 fp = fopen(misdn_init, "r"); 01010 if (fp) { 01011 while(fgets(line, sizeof(line), fp)) { 01012 if (!strncmp(line, "nt_ptp", 6)) { 01013 for (tok = strtok_r(line,",=", &p); 01014 tok; 01015 tok = strtok_r(NULL,",=", &p)) { 01016 port = strtol(tok, &end, 10); 01017 if (end != tok && misdn_cfg_is_port_valid(port)) { 01018 misdn_cfg_lock(); 01019 ptp[port] = 1; 01020 misdn_cfg_unlock(); 01021 } 01022 } 01023 } 01024 } 01025 fclose(fp); 01026 } else { 01027 ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno)); 01028 } 01029 } 01030 #else 01031 int i; 01032 int proto; 01033 char filename[128]; 01034 FILE *fp; 01035 01036 for (i = 1; i <= max_ports; ++i) { 01037 snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8); 01038 fp = fopen(filename, "r"); 01039 if (!fp) { 01040 ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno)); 01041 continue; 01042 } 01043 if (fscanf(fp, "0x%08x", &proto) != 1) 01044 ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename); 01045 else 01046 ptp[i] = proto & 1<<5 ? 1 : 0; 01047 fclose(fp); 01048 } 01049 #endif 01050 }