path_mod.c

Go to the documentation of this file.
00001 /*
00002  * $Id$ 
00003  *
00004  * Path handling for intermediate proxies
00005  *
00006  * Copyright (C) 2006 Inode GmbH (Andreas Granig <andreas.granig@inode.info>)
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  */
00025 
00048 #include <stdio.h>
00049 #include <stdlib.h>
00050 #include <string.h>
00051 
00052 #include "../../sr_module.h"
00053 #include "../../mem/mem.h"
00054 #include "../../mod_fix.h"
00055 #include "../rr/api.h"
00056 
00057 #include "path.h"
00058 #include "path_mod.h"
00059 
00060 MODULE_VERSION
00061 
00062 
00065 int use_received = 0;
00066 
00070 static int mod_init(void);
00071 
00075 struct rr_binds path_rrb;
00076 
00077 
00081 static cmd_export_t cmds[] = {
00082         { "add_path",          (cmd_function)add_path,              0,
00083                         0,              0,  REQUEST_ROUTE },
00084         { "add_path",          (cmd_function)add_path_usr,          1,
00085                         fixup_str_null, 0, REQUEST_ROUTE },
00086         { "add_path_received", (cmd_function)add_path_received,     0,
00087                         0,              0, REQUEST_ROUTE },
00088         { "add_path_received", (cmd_function)add_path_received_usr, 1,
00089                         fixup_str_null, 0, REQUEST_ROUTE },
00090         { 0, 0, 0, 0, 0, 0 }
00091 };
00092 
00093 
00097 static param_export_t params[] = {
00098         {"use_received", INT_PARAM, &use_received },
00099         { 0, 0, 0 }
00100 };
00101 
00102 
00106 struct module_exports exports = {
00107         "path", 
00108         DEFAULT_DLFLAGS, /* dlopen flags */
00109         cmds,       /* Exported functions */
00110         params,     /* Exported parameters */
00111         0,          /* exported statistics */
00112         0,          /* exported MI functions */
00113         0,          /* exported pseudo-variables */
00114         0,          /* extra processes */
00115         mod_init,   /* module initialization function */
00116         0,          /* response function */
00117         0,    /* destroy function */
00118         0           /* child initialization function */
00119 };
00120 
00121 
00122 static int mod_init(void)
00123 {
00124         if (use_received) {
00125                 if (load_rr_api(&path_rrb) != 0) {
00126                         LM_ERR("failed to load rr-API\n");
00127                         return -1;
00128                 }
00129                 if (path_rrb.register_rrcb(path_rr_callback, 0) != 0) {
00130                         LM_ERR("failed to register rr callback\n");
00131                         return -1;
00132                 }
00133         }
00134         
00135         return 0;
00136 }