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_HOLD_ALLOWED, /* int (bool) */ 00052 MISDN_CFG_EARLY_BCONNECT, /* int (bool) */ 00053 MISDN_CFG_INCOMING_EARLY_AUDIO, /* int (bool) */ 00054 MISDN_CFG_ECHOCANCEL, /* int */ 00055 #ifdef MISDN_1_2 00056 MISDN_CFG_PIPELINE, /* char[] */ 00057 #endif 00058 00059 #ifdef WITH_BEROEC 00060 MISDN_CFG_BNECHOCANCEL, 00061 MISDN_CFG_BNEC_ANTIHOWL, 00062 MISDN_CFG_BNEC_NLP, 00063 MISDN_CFG_BNEC_ZEROCOEFF, 00064 MISDN_CFG_BNEC_TD, 00065 MISDN_CFG_BNEC_ADAPT, 00066 #endif 00067 MISDN_CFG_NEED_MORE_INFOS, /* bool */ 00068 MISDN_CFG_NOAUTORESPOND_ON_SETUP, /* bool */ 00069 MISDN_CFG_NTTIMEOUT, /* bool */ 00070 MISDN_CFG_JITTERBUFFER, /* int */ 00071 MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, /* int */ 00072 MISDN_CFG_CALLGROUP, /* ast_group_t */ 00073 MISDN_CFG_PICKUPGROUP, /* ast_group_t */ 00074 MISDN_CFG_MAX_IN, /* int */ 00075 MISDN_CFG_MAX_OUT, /* int */ 00076 MISDN_CFG_L1_TIMEOUT, /* int */ 00077 MISDN_CFG_OVERLAP_DIAL, /* int (bool)*/ 00078 MISDN_CFG_MSNS, /* char[] */ 00079 MISDN_CFG_FAXDETECT, /* char[] */ 00080 MISDN_CFG_FAXDETECT_CONTEXT, /* char[] */ 00081 MISDN_CFG_FAXDETECT_TIMEOUT, /* int */ 00082 MISDN_CFG_PTP, /* int (bool) */ 00083 MISDN_CFG_LAST, 00084 00085 /* general config items */ 00086 MISDN_GEN_FIRST, 00087 #ifndef MISDN_1_2 00088 MISDN_GEN_MISDN_INIT, /* char[] */ 00089 #endif 00090 MISDN_GEN_DEBUG, /* int */ 00091 MISDN_GEN_TRACEFILE, /* char[] */ 00092 MISDN_GEN_BRIDGING, /* int (bool) */ 00093 MISDN_GEN_STOP_TONE, /* int (bool) */ 00094 MISDN_GEN_APPEND_DIGITS2EXTEN, /* int (bool) */ 00095 MISDN_GEN_DYNAMIC_CRYPT, /* int (bool) */ 00096 MISDN_GEN_CRYPT_PREFIX, /* char[] */ 00097 MISDN_GEN_CRYPT_KEYS, /* char[] */ 00098 MISDN_GEN_NTDEBUGFLAGS, /* int */ 00099 MISDN_GEN_NTDEBUGFILE, /* char[] */ 00100 MISDN_GEN_LAST 00101 };
enum misdn_cfg_method |
Definition at line 103 of file chan_misdn_config.h.
00103 { 00104 METHOD_STANDARD = 0, 00105 METHOD_ROUND_ROBIN, 00106 METHOD_STANDARD_DEC 00107 };
void misdn_cfg_destroy | ( | void | ) |
Definition at line 1055 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().
01056 { 01057 misdn_cfg_lock(); 01058 01059 _free_port_cfg(); 01060 _free_general_cfg(); 01061 01062 free(port_cfg); 01063 free(general_cfg); 01064 free(ptp); 01065 free(map); 01066 01067 misdn_cfg_unlock(); 01068 ast_mutex_destroy(&config_mutex); 01069 }
void misdn_cfg_get | ( | int | port, | |
enum misdn_cfg_elements | elem, | |||
void * | buf, | |||
int | bufsize | |||
) |
Definition at line 494 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().
00495 { 00496 int place; 00497 00498 if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { 00499 memset(buf, 0, bufsize); 00500 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Port number %d is not valid.\n", port); 00501 return; 00502 } 00503 00504 misdn_cfg_lock(); 00505 if (elem == MISDN_CFG_PTP) { 00506 if (!memcpy(buf, &ptp[port], (bufsize > ptp[port]) ? sizeof(ptp[port]) : bufsize)) 00507 memset(buf, 0, bufsize); 00508 } else { 00509 if ((place = map[elem]) < 0) { 00510 memset (buf, 0, bufsize); 00511 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get! Invalid element (%d) requested.\n", elem); 00512 } else { 00513 if (elem < MISDN_CFG_LAST) { 00514 switch (port_spec[place].type) { 00515 case MISDN_CTYPE_STR: 00516 if (port_cfg[port][place].str) { 00517 if (!memccpy(buf, port_cfg[port][place].str, 0, bufsize)) 00518 memset(buf, 0, 1); 00519 } else if (port_cfg[0][place].str) { 00520 if (!memccpy(buf, port_cfg[0][place].str, 0, bufsize)) 00521 memset(buf, 0, 1); 00522 } 00523 break; 00524 default: 00525 if (port_cfg[port][place].any) 00526 memcpy(buf, port_cfg[port][place].any, bufsize); 00527 else if (port_cfg[0][place].any) 00528 memcpy(buf, port_cfg[0][place].any, bufsize); 00529 else 00530 memset(buf, 0, bufsize); 00531 } 00532 } else { 00533 switch (gen_spec[place].type) { 00534 case MISDN_CTYPE_STR: 00535 if (!general_cfg[place].str || !memccpy(buf, general_cfg[place].str, 0, bufsize)) 00536 memset(buf, 0, 1); 00537 break; 00538 default: 00539 if (general_cfg[place].any) 00540 memcpy(buf, general_cfg[place].any, bufsize); 00541 else 00542 memset(buf, 0, bufsize); 00543 } 00544 } 00545 } 00546 } 00547 misdn_cfg_unlock(); 00548 }
void misdn_cfg_get_config_string | ( | int | port, | |
enum misdn_cfg_elements | elem, | |||
char * | buf, | |||
int | bufsize | |||
) |
Definition at line 719 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().
00720 { 00721 int place; 00722 char tempbuf[BUFFERSIZE] = ""; 00723 struct msn_list *iter; 00724 00725 if ((elem < MISDN_CFG_LAST) && !misdn_cfg_is_port_valid(port)) { 00726 *buf = 0; 00727 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Port number %d is not valid.\n", port); 00728 return; 00729 } 00730 00731 place = map[elem]; 00732 00733 misdn_cfg_lock(); 00734 if (elem == MISDN_CFG_PTP) { 00735 snprintf(buf, bufsize, " -> ptp: %s", ptp[port] ? "yes" : "no"); 00736 } 00737 else if (elem > MISDN_CFG_FIRST && elem < MISDN_CFG_LAST) { 00738 switch (port_spec[place].type) { 00739 case MISDN_CTYPE_INT: 00740 case MISDN_CTYPE_BOOLINT: 00741 if (port_cfg[port][place].num) 00742 snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[port][place].num); 00743 else if (port_cfg[0][place].num) 00744 snprintf(buf, bufsize, " -> %s: %d", port_spec[place].name, *port_cfg[0][place].num); 00745 else 00746 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00747 break; 00748 case MISDN_CTYPE_BOOL: 00749 if (port_cfg[port][place].num) 00750 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[port][place].num ? "yes" : "no"); 00751 else if (port_cfg[0][place].num) 00752 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, *port_cfg[0][place].num ? "yes" : "no"); 00753 else 00754 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00755 break; 00756 case MISDN_CTYPE_ASTGROUP: 00757 if (port_cfg[port][place].grp) 00758 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 00759 ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[port][place].grp)); 00760 else if (port_cfg[0][place].grp) 00761 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, 00762 ast_print_group(tempbuf, sizeof(tempbuf), *port_cfg[0][place].grp)); 00763 else 00764 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00765 break; 00766 case MISDN_CTYPE_MSNLIST: 00767 if (port_cfg[port][place].ml) 00768 iter = port_cfg[port][place].ml; 00769 else 00770 iter = port_cfg[0][place].ml; 00771 if (iter) { 00772 for (; iter; iter = iter->next) 00773 sprintf(tempbuf, "%s%s, ", tempbuf, iter->msn); 00774 tempbuf[strlen(tempbuf)-2] = 0; 00775 } 00776 snprintf(buf, bufsize, " -> msns: %s", *tempbuf ? tempbuf : "none"); 00777 break; 00778 case MISDN_CTYPE_STR: 00779 if ( port_cfg[port][place].str) { 00780 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[port][place].str); 00781 } else if (port_cfg[0][place].str) { 00782 snprintf(buf, bufsize, " -> %s: %s", port_spec[place].name, port_cfg[0][place].str); 00783 } else { 00784 snprintf(buf, bufsize, " -> %s:", port_spec[place].name); 00785 } 00786 break; 00787 } 00788 } else if (elem > MISDN_GEN_FIRST && elem < MISDN_GEN_LAST) { 00789 switch (gen_spec[place].type) { 00790 case MISDN_CTYPE_INT: 00791 case MISDN_CTYPE_BOOLINT: 00792 if (general_cfg[place].num) 00793 snprintf(buf, bufsize, " -> %s: %d", gen_spec[place].name, *general_cfg[place].num); 00794 else 00795 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00796 break; 00797 case MISDN_CTYPE_BOOL: 00798 if (general_cfg[place].num) 00799 snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, *general_cfg[place].num ? "yes" : "no"); 00800 else 00801 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00802 break; 00803 case MISDN_CTYPE_STR: 00804 if ( general_cfg[place].str) { 00805 snprintf(buf, bufsize, " -> %s: %s", gen_spec[place].name, general_cfg[place].str); 00806 } else { 00807 snprintf(buf, bufsize, " -> %s:", gen_spec[place].name); 00808 } 00809 break; 00810 default: 00811 snprintf(buf, bufsize, " -> type of %s not handled yet", gen_spec[place].name); 00812 break; 00813 } 00814 } else { 00815 *buf = 0; 00816 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_get_config_string! Invalid config element (%d) requested.\n", elem); 00817 } 00818 misdn_cfg_unlock(); 00819 }
void misdn_cfg_get_desc | ( | enum misdn_cfg_elements | elem, | |
void * | buf, | |||
int | bufsize, | |||
void * | buf_default, | |||
int | bufsize_default | |||
) |
Definition at line 598 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().
00599 { 00600 int place = map[elem]; 00601 struct misdn_cfg_spec *spec = NULL; 00602 00603 /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */ 00604 if (elem == MISDN_CFG_GROUPNAME) { 00605 if (!memccpy(buf, ports_description, 0, bufsize)) 00606 memset(buf, 0, 1); 00607 if (buf_default && bufsize_default) 00608 memset(buf_default, 0, 1); 00609 return; 00610 } 00611 00612 if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) 00613 spec = (struct misdn_cfg_spec *)port_spec; 00614 else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) 00615 spec = (struct misdn_cfg_spec *)gen_spec; 00616 00617 if (!spec || !spec[place].desc) 00618 memset(buf, 0, 1); 00619 else { 00620 if (!memccpy(buf, spec[place].desc, 0, bufsize)) 00621 memset(buf, 0, 1); 00622 if (buf_default && bufsize) { 00623 if (!strcmp(spec[place].def, NO_DEFAULT)) 00624 memset(buf_default, 0, 1); 00625 else if (!memccpy(buf_default, spec[place].def, 0, bufsize_default)) 00626 memset(buf_default, 0, 1); 00627 } 00628 } 00629 }
enum misdn_cfg_elements misdn_cfg_get_elem | ( | char * | name | ) |
Definition at line 550 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().
00551 { 00552 int pos; 00553 00554 /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */ 00555 if (!strcmp(name, "ports")) 00556 return MISDN_CFG_GROUPNAME; 00557 if (!strcmp(name, "name")) 00558 return MISDN_CFG_FIRST; 00559 00560 pos = get_cfg_position (name, PORT_CFG); 00561 if (pos >= 0) 00562 return port_spec[pos].elem; 00563 00564 pos = get_cfg_position (name, GEN_CFG); 00565 if (pos >= 0) 00566 return gen_spec[pos].elem; 00567 00568 return MISDN_CFG_FIRST; 00569 }
void misdn_cfg_get_name | ( | enum misdn_cfg_elements | elem, | |
void * | buf, | |||
int | bufsize | |||
) |
Definition at line 571 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().
00572 { 00573 struct misdn_cfg_spec *spec = NULL; 00574 int place = map[elem]; 00575 00576 /* the ptp hack */ 00577 if (elem == MISDN_CFG_PTP) { 00578 memset(buf, 0, 1); 00579 return; 00580 } 00581 00582 /* here comes a hack to replace the (not existing) "name" elemet with the "ports" element */ 00583 if (elem == MISDN_CFG_GROUPNAME) { 00584 if (!snprintf(buf, bufsize, "ports")) 00585 memset(buf, 0, 1); 00586 return; 00587 } 00588 00589 if ((elem > MISDN_CFG_FIRST) && (elem < MISDN_CFG_LAST)) 00590 spec = (struct misdn_cfg_spec *)port_spec; 00591 else if ((elem > MISDN_GEN_FIRST) && (elem < MISDN_GEN_LAST)) 00592 spec = (struct misdn_cfg_spec *)gen_spec; 00593 00594 if (!spec || !memccpy(buf, spec[place].name, 0, bufsize)) 00595 memset(buf, 0, 1); 00596 }
int misdn_cfg_get_next_port | ( | int | port | ) |
Definition at line 821 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().
00822 { 00823 int p = -1; 00824 int gn = map[MISDN_CFG_GROUPNAME]; 00825 00826 misdn_cfg_lock(); 00827 for (port++; port <= max_ports; port++) { 00828 if (port_cfg[port][gn].str) { 00829 p = port; 00830 break; 00831 } 00832 } 00833 misdn_cfg_unlock(); 00834 00835 return p; 00836 }
int misdn_cfg_get_next_port_spin | ( | int | port | ) |
Definition at line 838 of file misdn_config.c.
References misdn_cfg_get_next_port().
Referenced by misdn_request().
00839 { 00840 int p = misdn_cfg_get_next_port(port); 00841 return (p > 0) ? p : misdn_cfg_get_next_port(0); 00842 }
void misdn_cfg_get_ports_string | ( | char * | ports | ) |
Definition at line 695 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().
00696 { 00697 char tmp[16]; 00698 int l, i; 00699 int gn = map[MISDN_CFG_GROUPNAME]; 00700 00701 *ports = 0; 00702 00703 misdn_cfg_lock(); 00704 for (i = 1; i <= max_ports; i++) { 00705 if (port_cfg[i][gn].str) { 00706 if (ptp[i]) 00707 sprintf(tmp, "%dptp,", i); 00708 else 00709 sprintf(tmp, "%d,", i); 00710 strcat(ports, tmp); 00711 } 00712 } 00713 misdn_cfg_unlock(); 00714 00715 if ((l = strlen(ports))) 00716 ports[l-1] = 0; 00717 }
int misdn_cfg_init | ( | int | max_ports | ) |
Definition at line 1071 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().
01072 { 01073 char config[] = "misdn.conf"; 01074 char *cat, *p; 01075 int i; 01076 struct ast_config *cfg; 01077 struct ast_variable *v; 01078 01079 if (!(cfg = AST_LOAD_CFG(config))) { 01080 ast_log(LOG_WARNING, "missing file: misdn.conf\n"); 01081 return -1; 01082 } 01083 01084 ast_mutex_init(&config_mutex); 01085 01086 misdn_cfg_lock(); 01087 01088 if (this_max_ports) { 01089 /* this is the first run */ 01090 max_ports = this_max_ports; 01091 map = (int *)calloc(MISDN_GEN_LAST + 1, sizeof(int)); 01092 if (_enum_array_map()) 01093 return -1; 01094 p = (char *)calloc(1, (max_ports + 1) * sizeof(union misdn_cfg_pt *) 01095 + (max_ports + 1) * NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt)); 01096 port_cfg = (union misdn_cfg_pt **)p; 01097 p += (max_ports + 1) * sizeof(union misdn_cfg_pt *); 01098 for (i = 0; i <= max_ports; ++i) { 01099 port_cfg[i] = (union misdn_cfg_pt *)p; 01100 p += NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt); 01101 } 01102 general_cfg = (union misdn_cfg_pt *)calloc(1, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); 01103 ptp = (int *)calloc(max_ports + 1, sizeof(int)); 01104 } 01105 else { 01106 /* misdn reload */ 01107 _free_port_cfg(); 01108 _free_general_cfg(); 01109 memset(port_cfg[0], 0, NUM_PORT_ELEMENTS * sizeof(union misdn_cfg_pt) * (max_ports + 1)); 01110 memset(general_cfg, 0, sizeof(union misdn_cfg_pt *) * NUM_GEN_ELEMENTS); 01111 memset(ptp, 0, sizeof(int) * (max_ports + 1)); 01112 } 01113 01114 cat = ast_category_browse(cfg, NULL); 01115 01116 while(cat) { 01117 v = ast_variable_browse(cfg, cat); 01118 if (!strcasecmp(cat, "general")) { 01119 _build_general_config(v); 01120 } else { 01121 _build_port_config(v, cat); 01122 } 01123 cat = ast_category_browse(cfg, cat); 01124 } 01125 01126 _fill_defaults(); 01127 01128 misdn_cfg_unlock(); 01129 AST_DESTROY_CFG(cfg); 01130 01131 return 0; 01132 }
int misdn_cfg_is_group_method | ( | char * | group, | |
enum misdn_cfg_method | meth | |||
) |
Definition at line 663 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().
00664 { 00665 int i, re = 0; 00666 char *method ; 00667 00668 misdn_cfg_lock(); 00669 00670 method = port_cfg[0][map[MISDN_CFG_METHOD]].str; 00671 00672 for (i = 1; i <= max_ports; i++) { 00673 if (port_cfg[i] && port_cfg[i][map[MISDN_CFG_GROUPNAME]].str) { 00674 if (!strcasecmp(port_cfg[i][map[MISDN_CFG_GROUPNAME]].str, group)) 00675 method = (port_cfg[i][map[MISDN_CFG_METHOD]].str ? 00676 port_cfg[i][map[MISDN_CFG_METHOD]].str : port_cfg[0][map[MISDN_CFG_METHOD]].str); 00677 } 00678 } 00679 00680 if (method) { 00681 switch (meth) { 00682 case METHOD_STANDARD: re = !strcasecmp(method, "standard"); 00683 break; 00684 case METHOD_ROUND_ROBIN: re = !strcasecmp(method, "round_robin"); 00685 break; 00686 case METHOD_STANDARD_DEC: re = !strcasecmp(method, "standard_dec"); 00687 break; 00688 } 00689 } 00690 misdn_cfg_unlock(); 00691 00692 return re; 00693 }
int misdn_cfg_is_msn_valid | ( | int | port, | |
char * | msn | |||
) |
Definition at line 631 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().
00632 { 00633 int re = 0; 00634 struct msn_list *iter; 00635 00636 if (!misdn_cfg_is_port_valid(port)) { 00637 ast_log(LOG_WARNING, "Invalid call to misdn_cfg_is_msn_valid! Port number %d is not valid.\n", port); 00638 return 0; 00639 } 00640 00641 misdn_cfg_lock(); 00642 if (port_cfg[port][map[MISDN_CFG_MSNS]].ml) 00643 iter = port_cfg[port][map[MISDN_CFG_MSNS]].ml; 00644 else 00645 iter = port_cfg[0][map[MISDN_CFG_MSNS]].ml; 00646 for (; iter; iter = iter->next) 00647 if (*(iter->msn) == '*' || ast_extension_match(iter->msn, msn)) { 00648 re = 1; 00649 break; 00650 } 00651 misdn_cfg_unlock(); 00652 00653 return re; 00654 }
int misdn_cfg_is_port_valid | ( | int | port | ) |
Definition at line 656 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().
00657 { 00658 int gn = map[MISDN_CFG_GROUPNAME]; 00659 00660 return (port >= 1 && port <= max_ports && port_cfg[port][gn].str); 00661 }
void misdn_cfg_reload | ( | void | ) |
Definition at line 1050 of file misdn_config.c.
References misdn_cfg_init().
Referenced by reload_config().
01051 { 01052 misdn_cfg_init (0); 01053 }
void misdn_cfg_update_ptp | ( | void | ) |
Definition at line 981 of file misdn_config.c.
References ast_log(), BUFFERSIZE, 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().
00982 { 00983 #ifndef MISDN_1_2 00984 char misdn_init[BUFFERSIZE]; 00985 char line[BUFFERSIZE]; 00986 FILE *fp; 00987 char *tok, *p, *end; 00988 int port; 00989 00990 misdn_cfg_get(0, MISDN_GEN_MISDN_INIT, &misdn_init, sizeof(misdn_init)); 00991 00992 if (misdn_init) { 00993 fp = fopen(misdn_init, "r"); 00994 if (fp) { 00995 while(fgets(line, sizeof(line), fp)) { 00996 if (!strncmp(line, "nt_ptp", 6)) { 00997 for (tok = strtok_r(line,",=", &p); 00998 tok; 00999 tok = strtok_r(NULL,",=", &p)) { 01000 port = strtol(tok, &end, 10); 01001 if (end != tok && misdn_cfg_is_port_valid(port)) { 01002 misdn_cfg_lock(); 01003 ptp[port] = 1; 01004 misdn_cfg_unlock(); 01005 } 01006 } 01007 } 01008 } 01009 fclose(fp); 01010 } else { 01011 ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno)); 01012 } 01013 } 01014 #else 01015 int i; 01016 int proto; 01017 char filename[128]; 01018 FILE *fp; 01019 01020 for (i = 1; i <= max_ports; ++i) { 01021 snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8); 01022 fp = fopen(filename, "r"); 01023 if (!fp) { 01024 ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno)); 01025 continue; 01026 } 01027 if (fscanf(fp, "0x%08x", &proto) != 1) 01028 ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename); 01029 else 01030 ptp[i] = proto & 1<<5 ? 1 : 0; 01031 fclose(fp); 01032 } 01033 #endif 01034 }