michael@12: /* michael@12: * $Id: enum_mod.c 5976 2009-08-18 13:35:23Z bogdan_iancu $ michael@12: * michael@12: * Enum module michael@12: * michael@12: * Copyright (C) 2002-2008 Juha Heinanen michael@12: * michael@12: * This file is part of opensips, a free SIP server. michael@12: * michael@12: * opensips is free software; you can redistribute it and/or modify michael@12: * it under the terms of the GNU General Public License as published by michael@12: * the Free Software Foundation; either version 2 of the License, or michael@12: * (at your option) any later version michael@12: * michael@12: * opensips is distributed in the hope that it will be useful, michael@12: * but WITHOUT ANY WARRANTY; without even the implied warranty of michael@12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the michael@12: * GNU General Public License for more details. michael@12: * michael@12: * You should have received a copy of the GNU General Public License michael@12: * along with this program; if not, write to the Free Software michael@12: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA michael@12: * michael@12: * History: michael@12: * ------- michael@12: * 2003-03-11: New module interface (janakj) michael@12: * 2003-03-16: flags export parameter added (janakj) michael@12: * 2003-12-15: added suffix parameter to enum_query (jh) michael@12: */ michael@12: michael@12: michael@12: #include "enum_mod.h" michael@12: #include michael@12: #include michael@12: #include "../../sr_module.h" michael@12: #include "../../error.h" michael@12: #include "../../mod_fix.h" michael@12: #include "enum.h" michael@12: michael@12: michael@12: michael@12: /* michael@12: * Module initialization function prototype michael@12: */ michael@12: static int mod_init(void); michael@12: michael@12: michael@12: /* michael@12: * Module parameter variables michael@12: */ michael@12: char* domain_suffix = "e164.arpa."; michael@12: char* tel_uri_params = ""; michael@12: michael@12: char* branchlabel = "i"; michael@12: char* i_enum_suffix = "e164.arpa."; michael@12: char* bl_algorithm = "cc"; michael@12: michael@13: char* isn_suffix = "freenum.org."; michael@13: michael@12: michael@12: /* michael@12: * Internal module variables michael@12: */ michael@12: str suffix; michael@12: str param; michael@12: str service; michael@12: michael@12: str i_suffix; michael@12: str i_branchlabel; michael@12: str i_bl_alg; michael@12: michael@13: str isnsuffix; michael@13: michael@12: michael@12: /* michael@12: * Exported functions michael@12: */ michael@12: static cmd_export_t cmds[] = { michael@12: {"enum_query", (cmd_function)enum_query_0, 0, 0, 0, REQUEST_ROUTE}, michael@12: {"enum_query", (cmd_function)enum_query_1, 1, fixup_str_null, michael@12: fixup_free_str_null, REQUEST_ROUTE}, michael@12: {"enum_query", (cmd_function)enum_query_2, 2, fixup_str_str, michael@12: fixup_free_str_str, REQUEST_ROUTE}, michael@12: {"enum_pv_query", (cmd_function)enum_pv_query_1, 1, fixup_pvar_null, michael@12: fixup_free_pvar_null, REQUEST_ROUTE}, michael@12: {"enum_pv_query", (cmd_function)enum_pv_query_2, 2, fixup_pvar_str, michael@12: fixup_free_pvar_str, REQUEST_ROUTE}, michael@12: {"enum_pv_query", (cmd_function)enum_pv_query_3, 3, michael@12: fixup_pvar_str_str, fixup_free_pvar_str_str, REQUEST_ROUTE}, michael@12: {"is_from_user_enum", (cmd_function)is_from_user_enum_0, 0, 0, 0, michael@12: REQUEST_ROUTE}, michael@12: {"is_from_user_enum", (cmd_function)is_from_user_enum_1, 1, michael@12: fixup_str_null, fixup_free_str_null, REQUEST_ROUTE}, michael@12: {"is_from_user_enum", (cmd_function)is_from_user_enum_2, 2, michael@12: fixup_str_str, fixup_free_str_str, REQUEST_ROUTE}, michael@12: {"i_enum_query", (cmd_function)i_enum_query_0, 0, 0, 0, REQUEST_ROUTE}, michael@12: {"i_enum_query", (cmd_function)i_enum_query_1, 1, fixup_str_null, 0, michael@12: REQUEST_ROUTE}, michael@12: {"i_enum_query", (cmd_function)i_enum_query_2, 2, fixup_str_str, 0, michael@12: REQUEST_ROUTE}, michael@13: {"isn_query", (cmd_function)isn_query_0, 0, 0, 0, REQUEST_ROUTE}, michael@13: {"isn_query", (cmd_function)isn_query_1, 1, fixup_str_null, michael@13: fixup_free_str_null, REQUEST_ROUTE}, michael@13: {"isn_query", (cmd_function)isn_query_2, 2, fixup_str_str, michael@13: fixup_free_str_str, REQUEST_ROUTE}, michael@12: {0, 0, 0, 0, 0, 0} michael@12: }; michael@12: michael@12: michael@12: /* michael@12: * Exported parameters michael@12: */ michael@12: static param_export_t params[] = { michael@12: {"domain_suffix", STR_PARAM, &domain_suffix}, michael@12: {"tel_uri_params", STR_PARAM, &tel_uri_params}, michael@12: {"branchlabel", STR_PARAM, &branchlabel}, michael@12: {"i_enum_suffix", STR_PARAM, &i_enum_suffix}, michael@12: {"bl_algorithm", STR_PARAM, &bl_algorithm}, michael@13: {"isn_suffix", STR_PARAM, &isn_suffix}, michael@12: {0, 0, 0} michael@12: }; michael@12: michael@12: michael@12: /* michael@12: * Module parameter variables michael@12: */ michael@12: struct module_exports exports = { michael@12: "enum", michael@12: MODULE_VERSION, michael@12: DEFAULT_DLFLAGS, /* dlopen flags */ michael@12: cmds, /* Exported functions */ michael@12: params, /* Exported parameters */ michael@12: 0, /* exported statistics */ michael@12: 0, /* exported MI functions */ michael@12: 0, /* exported pseudo-variables */ michael@12: 0, /* extra processes */ michael@12: mod_init, /* module initialization function */ michael@12: 0, /* response function*/ michael@12: 0, /* destroy function */ michael@12: 0 /* per-child init function */ michael@12: }; michael@12: michael@12: michael@12: static int mod_init(void) michael@12: { michael@12: LM_DBG("Initializing\n"); michael@12: michael@12: suffix.s = domain_suffix; michael@12: suffix.len = strlen(suffix.s); michael@12: michael@12: param.s = tel_uri_params; michael@12: param.len = strlen(param.s); michael@12: michael@12: service.len = 0; michael@12: michael@12: i_suffix.s = i_enum_suffix; michael@12: i_suffix.len = strlen(i_enum_suffix); michael@12: michael@12: i_branchlabel.s = branchlabel; michael@12: i_branchlabel.len = strlen(branchlabel); michael@12: michael@12: i_bl_alg.s = bl_algorithm; michael@12: i_bl_alg.len = strlen(bl_algorithm); michael@12: michael@13: isnsuffix.s = isn_suffix; michael@13: isnsuffix.len = strlen(isnsuffix.s); michael@13: michael@12: return 0; michael@12: } michael@12: