Wed, 10 Feb 2010 21:21:24 +0100
Introduce authentication credential logic into the LCR module.
This logic is meant to complement that of changeset 18, adding
additional authentication flexibility to the UAC module.
1 /*
2 * $Id: enum_mod.c 5976 2009-08-18 13:35:23Z bogdan_iancu $
3 *
4 * Enum module
5 *
6 * Copyright (C) 2002-2008 Juha Heinanen
7 *
8 * This file is part of opensips, a free SIP server.
9 *
10 * opensips is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version
14 *
15 * opensips is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * History:
25 * -------
26 * 2003-03-11: New module interface (janakj)
27 * 2003-03-16: flags export parameter added (janakj)
28 * 2003-12-15: added suffix parameter to enum_query (jh)
29 */
32 #include "enum_mod.h"
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include "../../sr_module.h"
36 #include "../../error.h"
37 #include "../../mod_fix.h"
38 #include "enum.h"
42 /*
43 * Module initialization function prototype
44 */
45 static int mod_init(void);
48 /*
49 * Module parameter variables
50 */
51 char* domain_suffix = "e164.arpa.";
52 char* tel_uri_params = "";
54 char* branchlabel = "i";
55 char* i_enum_suffix = "e164.arpa.";
56 char* bl_algorithm = "cc";
58 char* isn_suffix = "freenum.org.";
61 /*
62 * Internal module variables
63 */
64 str suffix;
65 str param;
66 str service;
68 str i_suffix;
69 str i_branchlabel;
70 str i_bl_alg;
72 str isnsuffix;
75 /*
76 * Exported functions
77 */
78 static cmd_export_t cmds[] = {
79 {"enum_query", (cmd_function)enum_query_0, 0, 0, 0, REQUEST_ROUTE},
80 {"enum_query", (cmd_function)enum_query_1, 1, fixup_str_null,
81 fixup_free_str_null, REQUEST_ROUTE},
82 {"enum_query", (cmd_function)enum_query_2, 2, fixup_str_str,
83 fixup_free_str_str, REQUEST_ROUTE},
84 {"enum_pv_query", (cmd_function)enum_pv_query_1, 1, fixup_pvar_null,
85 fixup_free_pvar_null, REQUEST_ROUTE},
86 {"enum_pv_query", (cmd_function)enum_pv_query_2, 2, fixup_pvar_str,
87 fixup_free_pvar_str, REQUEST_ROUTE},
88 {"enum_pv_query", (cmd_function)enum_pv_query_3, 3,
89 fixup_pvar_str_str, fixup_free_pvar_str_str, REQUEST_ROUTE},
90 {"is_from_user_enum", (cmd_function)is_from_user_enum_0, 0, 0, 0,
91 REQUEST_ROUTE},
92 {"is_from_user_enum", (cmd_function)is_from_user_enum_1, 1,
93 fixup_str_null, fixup_free_str_null, REQUEST_ROUTE},
94 {"is_from_user_enum", (cmd_function)is_from_user_enum_2, 2,
95 fixup_str_str, fixup_free_str_str, REQUEST_ROUTE},
96 {"i_enum_query", (cmd_function)i_enum_query_0, 0, 0, 0, REQUEST_ROUTE},
97 {"i_enum_query", (cmd_function)i_enum_query_1, 1, fixup_str_null, 0,
98 REQUEST_ROUTE},
99 {"i_enum_query", (cmd_function)i_enum_query_2, 2, fixup_str_str, 0,
100 REQUEST_ROUTE},
101 {"isn_query", (cmd_function)isn_query_0, 0, 0, 0, REQUEST_ROUTE},
102 {"isn_query", (cmd_function)isn_query_1, 1, fixup_str_null,
103 fixup_free_str_null, REQUEST_ROUTE},
104 {"isn_query", (cmd_function)isn_query_2, 2, fixup_str_str,
105 fixup_free_str_str, REQUEST_ROUTE},
106 {0, 0, 0, 0, 0, 0}
107 };
110 /*
111 * Exported parameters
112 */
113 static param_export_t params[] = {
114 {"domain_suffix", STR_PARAM, &domain_suffix},
115 {"tel_uri_params", STR_PARAM, &tel_uri_params},
116 {"branchlabel", STR_PARAM, &branchlabel},
117 {"i_enum_suffix", STR_PARAM, &i_enum_suffix},
118 {"bl_algorithm", STR_PARAM, &bl_algorithm},
119 {"isn_suffix", STR_PARAM, &isn_suffix},
120 {0, 0, 0}
121 };
124 /*
125 * Module parameter variables
126 */
127 struct module_exports exports = {
128 "enum",
129 MODULE_VERSION,
130 DEFAULT_DLFLAGS, /* dlopen flags */
131 cmds, /* Exported functions */
132 params, /* Exported parameters */
133 0, /* exported statistics */
134 0, /* exported MI functions */
135 0, /* exported pseudo-variables */
136 0, /* extra processes */
137 mod_init, /* module initialization function */
138 0, /* response function*/
139 0, /* destroy function */
140 0 /* per-child init function */
141 };
144 static int mod_init(void)
145 {
146 LM_DBG("Initializing\n");
148 suffix.s = domain_suffix;
149 suffix.len = strlen(suffix.s);
151 param.s = tel_uri_params;
152 param.len = strlen(param.s);
154 service.len = 0;
156 i_suffix.s = i_enum_suffix;
157 i_suffix.len = strlen(i_enum_suffix);
159 i_branchlabel.s = branchlabel;
160 i_branchlabel.len = strlen(branchlabel);
162 i_bl_alg.s = bl_algorithm;
163 i_bl_alg.len = strlen(bl_algorithm);
165 isnsuffix.s = isn_suffix;
166 isnsuffix.len = strlen(isnsuffix.s);
168 return 0;
169 }