Browse code

path: option to set received param name

Daniel-Constantin Mierla authored on 29/03/2021 13:25:21
Showing 1 changed files
... ...
@@ -67,6 +67,7 @@ int path_use_received = 0;
67 67
 int path_received_format = 0;
68 68
 int path_enable_r2 = 0;
69 69
 int path_sockname_mode = 0;
70
+str path_received_name = str_init("received");
70 71
 
71 72
 /*! \brief
72 73
  * Module initialization function prototype
... ...
@@ -111,6 +112,7 @@ static param_export_t params[] = {
111 112
 	{"received_format", INT_PARAM, &path_received_format },
112 113
 	{"enable_r2",       INT_PARAM, &path_enable_r2 },
113 114
 	{"sockname_mode",   INT_PARAM, &path_sockname_mode },
115
+	{"received_name",   PARAM_STR, &path_received_name },
114 116
 	{ 0, 0, 0 }
115 117
 };
116 118
 
Browse code

path: removed svn id header

Daniel-Constantin Mierla authored on 29/03/2021 13:04:38
Showing 1 changed files
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id$ 
3
- *
4 2
  * Path handling for intermediate proxies
5 3
  *
6 4
  * Copyright (C) 2006 Inode GmbH (Andreas Granig <andreas.granig@inode.info>)
... ...
@@ -17,8 +15,8 @@
17 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 16
  * GNU General Public License for more details.
19 17
  *
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 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
22 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 21
  *
24 22
  */
Browse code

path: new param sockname_mode

- if set to 1, socket name is added to Path URI in 'sn' param

Daniel-Constantin Mierla authored on 02/04/2020 12:17:36
Showing 1 changed files
... ...
@@ -68,6 +68,7 @@ int path_use_received = 0;
68 68
 
69 69
 int path_received_format = 0;
70 70
 int path_enable_r2 = 0;
71
+int path_sockname_mode = 0;
71 72
 
72 73
 /*! \brief
73 74
  * Module initialization function prototype
... ...
@@ -111,6 +112,7 @@ static param_export_t params[] = {
111 112
 	{"use_received",    INT_PARAM, &path_use_received },
112 113
 	{"received_format", INT_PARAM, &path_received_format },
113 114
 	{"enable_r2",       INT_PARAM, &path_enable_r2 },
115
+	{"sockname_mode",   INT_PARAM, &path_sockname_mode },
114 116
 	{ 0, 0, 0 }
115 117
 };
116 118
 
Browse code

path: converted to the new module interface

Mikko Lehto authored on 27/09/2018 14:51:49 • Victor Seva committed on 28/09/2018 11:03:26
Showing 1 changed files
... ...
@@ -119,18 +119,16 @@ static param_export_t params[] = {
119 119
  * Module interface
120 120
  */
121 121
 struct module_exports exports = {
122
-	"path",
122
+	"path",          /* module name */
123 123
 	DEFAULT_DLFLAGS, /* dlopen flags */
124
-	cmds,       /* Exported functions */
125
-	params,     /* Exported parameters */
126
-	0,          /* exported statistics */
127
-	0,          /* exported MI functions */
128
-	0,          /* exported pseudo-variables */
129
-	0,          /* extra processes */
130
-	mod_init,   /* module initialization function */
131
-	0,          /* response function */
132
-	0,    /* destroy function */
133
-	0           /* child initialization function */
124
+	cmds,            /* Exported functions */
125
+	params,          /* Exported parameters */
126
+	0,               /* RPC method exports */
127
+	0,               /* exported pseudo-variables */
128
+	0,               /* response function */
129
+	mod_init,        /* module initialization function */
130
+	0,               /* child initialization function */
131
+	0                /* destroy function */
134 132
 };
135 133
 
136 134
 
Browse code

path: updating the exported expected parameters to match the functions

- Mismatch between export and function declaration with regards to the quantity of parameters

Samuel authored on 26/11/2017 19:55:19 • Daniel-Constantin Mierla committed on 27/11/2017 07:29:08
Showing 1 changed files
... ...
@@ -164,7 +164,7 @@ static int mod_init(void)
164 164
 static sr_kemi_t sr_kemi_path_exports[] = {
165 165
 	{ str_init("path"), str_init("add_path"),
166 166
 		SR_KEMIP_INT, ki_add_path,
167
-		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
167
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
168 168
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
169 169
 	},
170 170
 	{ str_init("path"), str_init("add_path_user"),
... ...
@@ -179,7 +179,7 @@ static sr_kemi_t sr_kemi_path_exports[] = {
179 179
 	},
180 180
 	{ str_init("path"), str_init("add_path_received"),
181 181
 		SR_KEMIP_INT, ki_add_path_received,
182
-		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
182
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
183 183
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
184 184
 	},
185 185
 	{ str_init("path"), str_init("add_path_received_user"),
Browse code

path: option to add two path headers and use alias like received value

- enable_r2 - add two path headers, one for incoming socket and one for
outgoing socket
- received_format - parameter to control if received value should be
in sip uri (as so far) or in contact-alias param format

Daniel-Constantin Mierla authored on 27/06/2017 13:04:31
Showing 1 changed files
... ...
@@ -64,7 +64,10 @@ MODULE_VERSION
64 64
 
65 65
 /*! \brief If received-param of current Route uri should be used
66 66
  * as dst-uri. */
67
-int use_received = 0;
67
+int path_use_received = 0;
68
+
69
+int path_received_format = 0;
70
+int path_enable_r2 = 0;
68 71
 
69 72
 /*! \brief
70 73
  * Module initialization function prototype
... ...
@@ -105,7 +108,9 @@ static cmd_export_t cmds[] = {
105 108
  * Exported parameters
106 109
  */
107 110
 static param_export_t params[] = {
108
-	{"use_received", INT_PARAM, &use_received },
111
+	{"use_received",    INT_PARAM, &path_use_received },
112
+	{"received_format", INT_PARAM, &path_received_format },
113
+	{"enable_r2",       INT_PARAM, &path_enable_r2 },
109 114
 	{ 0, 0, 0 }
110 115
 };
111 116
 
... ...
@@ -114,7 +119,7 @@ static param_export_t params[] = {
114 119
  * Module interface
115 120
  */
116 121
 struct module_exports exports = {
117
-	"path", 
122
+	"path",
118 123
 	DEFAULT_DLFLAGS, /* dlopen flags */
119 124
 	cmds,       /* Exported functions */
120 125
 	params,     /* Exported parameters */
... ...
@@ -131,7 +136,7 @@ struct module_exports exports = {
131 136
 
132 137
 static int mod_init(void)
133 138
 {
134
-	if (use_received) {
139
+	if (path_use_received) {
135 140
 		if (load_rr_api(&path_rrb) != 0) {
136 141
 			LM_ERR("failed to load rr-API\n");
137 142
 			return -1;
... ...
@@ -148,7 +153,7 @@ static int mod_init(void)
148 153
 		LM_INFO("outbound module not available\n");
149 154
 		memset(&path_obb, 0, sizeof(ob_api_t));
150 155
 	}
151
-	
156
+
152 157
 	return 0;
153 158
 }
154 159
 
... ...
@@ -198,4 +203,4 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2)
198 203
 {
199 204
 	sr_kemi_modules_add(sr_kemi_path_exports);
200 205
 	return 0;
201
-}
202 206
\ No newline at end of file
207
+}
Browse code

path: exported functions to kemi interface

Daniel-Constantin Mierla authored on 07/05/2017 06:22:57
Showing 1 changed files
... ...
@@ -52,6 +52,7 @@
52 52
 #include "../../core/sr_module.h"
53 53
 #include "../../core/mem/mem.h"
54 54
 #include "../../core/mod_fix.h"
55
+#include "../../core/kemi.h"
55 56
 #include "../outbound/api.h"
56 57
 #include "../rr/api.h"
57 58
 
... ...
@@ -150,3 +151,51 @@ static int mod_init(void)
150 151
 	
151 152
 	return 0;
152 153
 }
154
+
155
+/**
156
+ *
157
+ */
158
+/* clang-format off */
159
+static sr_kemi_t sr_kemi_path_exports[] = {
160
+	{ str_init("path"), str_init("add_path"),
161
+		SR_KEMIP_INT, ki_add_path,
162
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
163
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
164
+	},
165
+	{ str_init("path"), str_init("add_path_user"),
166
+		SR_KEMIP_INT, ki_add_path_user,
167
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
168
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
169
+	},
170
+	{ str_init("path"), str_init("add_path_user_params"),
171
+		SR_KEMIP_INT, ki_add_path_user_params,
172
+		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
173
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
174
+	},
175
+	{ str_init("path"), str_init("add_path_received"),
176
+		SR_KEMIP_INT, ki_add_path_received,
177
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
178
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
179
+	},
180
+	{ str_init("path"), str_init("add_path_received_user"),
181
+		SR_KEMIP_INT, ki_add_path_received_user,
182
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
183
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
184
+	},
185
+	{ str_init("path"), str_init("add_path_received_user_params"),
186
+		SR_KEMIP_INT, ki_add_path_received_user_params,
187
+		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
188
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
189
+	},
190
+	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
191
+};
192
+/* clang-format on */
193
+
194
+/**
195
+ *
196
+ */
197
+int mod_register(char *path, int *dlflags, void *p1, void *p2)
198
+{
199
+	sr_kemi_modules_add(sr_kemi_path_exports);
200
+	return 0;
201
+}
153 202
\ No newline at end of file
Browse code

core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
... ...
@@ -49,9 +49,9 @@
49 49
 #include <stdlib.h>
50 50
 #include <string.h>
51 51
 
52
-#include "../../sr_module.h"
53
-#include "../../mem/mem.h"
54
-#include "../../mod_fix.h"
52
+#include "../../core/sr_module.h"
53
+#include "../../core/mem/mem.h"
54
+#include "../../core/mod_fix.h"
55 55
 #include "../outbound/api.h"
56 56
 #include "../rr/api.h"
57 57
 
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,152 @@
1
+/*
2
+ * $Id$ 
3
+ *
4
+ * Path handling for intermediate proxies
5
+ *
6
+ * Copyright (C) 2006 Inode GmbH (Andreas Granig <andreas.granig@inode.info>)
7
+ *
8
+ * This file is part of Kamailio, a free SIP server.
9
+ *
10
+ * Kamailio 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
+ * Kamailio 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
+ *
24
+ */
25
+
26
+/*! \file
27
+ * \brief Path :: Core
28
+ *
29
+ * \ingroup path
30
+ * - Module: path
31
+ */
32
+
33
+/*! \defgroup path Path:: Handling of "path" header for intermediate proxies
34
+ * This module is designed to be used at intermediate sip proxies
35
+ * like loadbalancers in front of registrars and proxies. It
36
+ * provides functions for inserting a Path header including a
37
+ * parameter for passing forward the received-URI of a
38
+ * registration to the next hop. It also provides a mechanism for
39
+ * evaluating this parameter in subsequent requests and to set the
40
+ * destination URI according to it.
41
+ *
42
+ * - No developer API
43
+ * - No MI functions
44
+ */
45
+
46
+
47
+
48
+#include <stdio.h>
49
+#include <stdlib.h>
50
+#include <string.h>
51
+
52
+#include "../../sr_module.h"
53
+#include "../../mem/mem.h"
54
+#include "../../mod_fix.h"
55
+#include "../outbound/api.h"
56
+#include "../rr/api.h"
57
+
58
+#include "path.h"
59
+#include "path_mod.h"
60
+
61
+MODULE_VERSION
62
+
63
+
64
+/*! \brief If received-param of current Route uri should be used
65
+ * as dst-uri. */
66
+int use_received = 0;
67
+
68
+/*! \brief
69
+ * Module initialization function prototype
70
+ */
71
+static int mod_init(void);
72
+
73
+/*! \brief
74
+ * rr callback API
75
+ */
76
+struct rr_binds path_rrb;
77
+
78
+/*! \brief
79
+ * outbound API
80
+ */
81
+ob_api_t path_obb;
82
+
83
+/*! \brief
84
+ * Exported functions
85
+ */
86
+static cmd_export_t cmds[] = {
87
+	{ "add_path",          (cmd_function)add_path,              0,
88
+			0,              0,  REQUEST_ROUTE },
89
+	{ "add_path",          (cmd_function)add_path_usr,          1,
90
+			fixup_spve_null, 0, REQUEST_ROUTE },
91
+	{ "add_path",          (cmd_function)add_path_usr,          2,
92
+			fixup_spve_spve, 0, REQUEST_ROUTE },
93
+	{ "add_path_received", (cmd_function)add_path_received,     0,
94
+			0,              0, REQUEST_ROUTE },
95
+	{ "add_path_received", (cmd_function)add_path_received_usr, 1,
96
+			fixup_spve_null, 0, REQUEST_ROUTE },
97
+	{ "add_path_received", (cmd_function)add_path_received_usr, 2,
98
+			fixup_spve_spve, 0, REQUEST_ROUTE },
99
+	{ 0, 0, 0, 0, 0, 0 }
100
+};
101
+
102
+
103
+/*! \brief
104
+ * Exported parameters
105
+ */
106
+static param_export_t params[] = {
107
+	{"use_received", INT_PARAM, &use_received },
108
+	{ 0, 0, 0 }
109
+};
110
+
111
+
112
+/*! \brief
113
+ * Module interface
114
+ */
115
+struct module_exports exports = {
116
+	"path", 
117
+	DEFAULT_DLFLAGS, /* dlopen flags */
118
+	cmds,       /* Exported functions */
119
+	params,     /* Exported parameters */
120
+	0,          /* exported statistics */
121
+	0,          /* exported MI functions */
122
+	0,          /* exported pseudo-variables */
123
+	0,          /* extra processes */
124
+	mod_init,   /* module initialization function */
125
+	0,          /* response function */
126
+	0,    /* destroy function */
127
+	0           /* child initialization function */
128
+};
129
+
130
+
131
+static int mod_init(void)
132
+{
133
+	if (use_received) {
134
+		if (load_rr_api(&path_rrb) != 0) {
135
+			LM_ERR("failed to load rr-API\n");
136
+			return -1;
137
+		}
138
+		if (path_rrb.register_rrcb(path_rr_callback, 0) != 0) {
139
+			LM_ERR("failed to register rr callback\n");
140
+			return -1;
141
+		}
142
+	}
143
+
144
+	if (ob_load_api(&path_obb) == 0)
145
+		LM_DBG("Bound path module to outbound module\n");
146
+	else {
147
+		LM_INFO("outbound module not available\n");
148
+		memset(&path_obb, 0, sizeof(ob_api_t));
149
+	}
150
+	
151
+	return 0;
152
+}