enum_mod.c

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Enum module
00005  *
00006  * Copyright (C) 2002-2008 Juha Heinanen
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  * History:
00025  * -------
00026  * 2003-03-11: New module interface (janakj)
00027  * 2003-03-16: flags export parameter added (janakj)
00028  * 2003-12-15: added suffix parameter to enum_query (jh)
00029  */
00030 
00039 #include "enum_mod.h"
00040 #include <stdio.h>
00041 #include <stdlib.h>
00042 #include "../../sr_module.h"
00043 #include "../../error.h"
00044 #include "../../mod_fix.h"
00045 #include "enum.h"
00046 
00047 MODULE_VERSION
00048 
00049 /*
00050  * Module initialization function prototype
00051  */
00052 static int mod_init(void);
00053 
00054 
00055 /*
00056  * Module parameter variables
00057  */
00058 char* domain_suffix = "e164.arpa.";
00059 char* tel_uri_params = "";
00060 
00061 char* branchlabel = "i";
00062 char* i_enum_suffix = "e164.arpa.";
00063 char* bl_algorithm = "cc";
00064 
00065 
00066 /*
00067  * Internal module variables
00068  */
00069 str suffix;
00070 str param;
00071 str service;
00072 
00073 str i_suffix;
00074 str i_branchlabel;
00075 str i_bl_alg;
00076 
00077 
00078 /*
00079  * Exported functions
00080  */
00081 static cmd_export_t cmds[] = {
00082         {"enum_query", (cmd_function)enum_query_0, 0, 0, 0, REQUEST_ROUTE},
00083         {"enum_query", (cmd_function)enum_query_1, 1, fixup_spve_null, 0,
00084          REQUEST_ROUTE},
00085         {"enum_query", (cmd_function)enum_query_2, 2, fixup_spve_str, 0,
00086          REQUEST_ROUTE},
00087         {"enum_pv_query", (cmd_function)enum_pv_query_1, 1, fixup_pvar_null,
00088          fixup_free_pvar_null, REQUEST_ROUTE},
00089         {"enum_pv_query", (cmd_function)enum_pv_query_2, 2, fixup_pvar_str,
00090          fixup_free_pvar_str, REQUEST_ROUTE},
00091         {"enum_pv_query", (cmd_function)enum_pv_query_3, 3,
00092          fixup_pvar_str_str, fixup_free_pvar_str_str, REQUEST_ROUTE},
00093         {"is_from_user_enum", (cmd_function)is_from_user_enum_0, 0, 0, 0,
00094          REQUEST_ROUTE},
00095         {"is_from_user_enum", (cmd_function)is_from_user_enum_1, 1,
00096          fixup_str_null, fixup_free_str_null, REQUEST_ROUTE},
00097         {"is_from_user_enum", (cmd_function)is_from_user_enum_2, 2,
00098          fixup_str_str, fixup_free_str_str, REQUEST_ROUTE},
00099         {"i_enum_query", (cmd_function)i_enum_query_0, 0, 0, 0, REQUEST_ROUTE},
00100         {"i_enum_query", (cmd_function)i_enum_query_1, 1, fixup_str_null, 0,
00101          REQUEST_ROUTE},
00102         {"i_enum_query", (cmd_function)i_enum_query_2, 2, fixup_str_str, 0,
00103          REQUEST_ROUTE},
00104         {0, 0, 0, 0, 0, 0}
00105 };
00106 
00107 
00108 /*
00109  * Exported parameters
00110  */
00111 static param_export_t params[] = {
00112         {"domain_suffix", STR_PARAM, &domain_suffix},
00113         {"tel_uri_params", STR_PARAM, &tel_uri_params},
00114         {"branchlabel", STR_PARAM, &branchlabel},
00115         {"i_enum_suffix", STR_PARAM, &i_enum_suffix},
00116         {"bl_algorithm", STR_PARAM, &bl_algorithm},
00117         {0, 0, 0}
00118 };
00119 
00120 
00121 /*
00122  * Module parameter variables
00123  */
00124 struct module_exports exports = {
00125         "enum", 
00126         DEFAULT_DLFLAGS, /* dlopen flags */
00127         cmds,     /* Exported functions */
00128         params,   /* Exported parameters */
00129         0,        /* exported statistics */
00130         0,        /* exported MI functions */
00131         0,        /* exported pseudo-variables */
00132         0,        /* extra processes */
00133         mod_init, /* module initialization function */
00134         0,        /* response function*/
00135         0,        /* destroy function */
00136         0         /* per-child init function */
00137 };
00138 
00139 
00140 static int mod_init(void)
00141 {
00142         suffix.s = domain_suffix;
00143         suffix.len = strlen(suffix.s);
00144 
00145         param.s = tel_uri_params;
00146         param.len = strlen(param.s);
00147 
00148         service.len = 0;
00149 
00150         i_suffix.s = i_enum_suffix;
00151         i_suffix.len = strlen(i_enum_suffix);
00152 
00153         i_branchlabel.s = branchlabel;
00154         i_branchlabel.len = strlen(branchlabel);
00155 
00156         i_bl_alg.s = bl_algorithm;
00157         i_bl_alg.len = strlen(bl_algorithm);
00158 
00159         return 0;
00160 }
00161