opensips/modules/enum/enum_mod.c

Wed, 10 Feb 2010 21:21:24 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 10 Feb 2010 21:21:24 +0100
changeset 17
733187d496d0
parent 12
a3ac912f2857
permissions
-rw-r--r--

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.

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

mercurial