Browse code

modules_k/*: moved k modules in directory modules/

Daniel-Constantin Mierla authored on 20/01/2013 11:57:52
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,233 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * MAXFWD module
5
- *
6
- * Copyright (C) 2001-2003 FhG Fokus
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
- *
24
- * History:
25
- * --------
26
- *  2003-03-11  updated to the new module interface (andrei)
27
- *  2003-03-16  flags export parameter added (janakj)
28
- *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
29
- *  2004-08-15  max value of max-fwd header is configurable via max_limit
30
- *              module param (bogdan)
31
- *  2005-09-15  max_limit param cannot be disabled anymore (according to RFC)
32
- *              (bogdan)
33
- *  2005-11-03  is_maxfwd_lt() function added; MF value saved in 
34
- *              msg->maxforwards->parsed (bogdan)
35
- */
36
-
37
-
38
-#include <stdio.h>
39
-#include <string.h>
40
-#include <stdlib.h>
41
-
42
-#include "../../sr_module.h"
43
-#include "../../dprint.h"
44
-#include "../../error.h"
45
-#include "../../ut.h"
46
-#include "../../mem/mem.h"
47
-#include "../../cfg/cfg.h"
48
-#include "mf_funcs.h"
49
-#include "api.h"
50
-
51
-MODULE_VERSION
52
-
53
-struct cfg_group_maxfwd {
54
-	int max_limit;
55
-};
56
-
57
-static struct cfg_group_maxfwd default_maxfwd_cfg = {
58
-	max_limit:16
59
-};
60
-
61
-static void *maxfwd_cfg = &default_maxfwd_cfg;
62
-
63
-static cfg_def_t maxfwd_cfg_def[] = {
64
-        {"max_limit", CFG_VAR_INT, 0, 255, 0, 0, "Max. maxfwd limit"},
65
-        {0, 0, 0, 0, 0, 0}
66
-};
67
-
68
-static int w_process_maxfwd_header(struct sip_msg* msg,char* str,char* str2);
69
-static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo);
70
-static int mod_init(void);
71
-
72
-int bind_maxfwd(maxfwd_api_t *api);
73
-
74
-static cmd_export_t cmds[]={
75
-	{"maxfwd_process", (cmd_function)w_process_maxfwd_header, 1,
76
-		fixup_var_int_1, 0, REQUEST_ROUTE},
77
-	{"mf_process_maxfwd_header", (cmd_function)w_process_maxfwd_header, 1,
78
-		fixup_var_int_1, 0, REQUEST_ROUTE},
79
-	{"process_maxfwd", (cmd_function)w_process_maxfwd_header, 1,
80
-		fixup_var_int_1, 0, REQUEST_ROUTE},
81
-
82
-	{"is_maxfwd_lt", (cmd_function)is_maxfwd_lt, 1,
83
-		fixup_var_int_1, 0, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
84
-	{"maxfwd_at_least", (cmd_function)is_maxfwd_lt, 1,
85
-		fixup_var_int_1, 0, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
86
-	{"mf_lowlimit", (cmd_function)is_maxfwd_lt, 1,
87
-		fixup_var_int_1, 0, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
88
-
89
-	{"bind_maxfwd",  (cmd_function)bind_maxfwd,  0,
90
-		0, 0, 0},
91
-	{0,0,0,0,0,0}
92
-};
93
-
94
-static param_export_t params[]={
95
-	{"max_limit",    INT_PARAM,  &default_maxfwd_cfg.max_limit},
96
-	{0,0,0}
97
-};
98
-
99
-
100
-
101
-struct module_exports exports= {
102
-	"maxfwd",
103
-	DEFAULT_DLFLAGS, /* dlopen flags */
104
-	cmds,
105
-	params,
106
-	0,          /* exported statistics */
107
-	0,          /* exported MI functions */
108
-	0,          /* exported pseudo-variables */
109
-	0,          /* extra processes */
110
-	mod_init,
111
-	0,
112
-	0,
113
-	0           /* per-child init function */
114
-};
115
-
116
-
117
-
118
-static int mod_init(void)
119
-{
120
-	if (cfg_declare("maxfwd", maxfwd_cfg_def, &default_maxfwd_cfg,
121
-				cfg_sizeof(maxfwd), &maxfwd_cfg)) {
122
-		LM_ERR("failed to declare the configuration\n");
123
-		return E_CFG;
124
-	}
125
-	return 0;
126
-}
127
-
128
-
129
-
130
-
131
-/**
132
- * process max forward header
133
- */
134
-int process_maxfwd_header(struct sip_msg *msg, int limit)
135
-{
136
-	int val;
137
-	str mf_value = {0};
138
-	int max_limit;
139
-
140
-	if(limit<0 || limit>255) {
141
-		LM_ERR("invalid param value: %d\n", limit);
142
-		return -1;
143
-	}
144
-	max_limit = cfg_get(maxfwd, maxfwd_cfg, max_limit);
145
-
146
-	val=is_maxfwd_present(msg, &mf_value);
147
-	switch (val) {
148
-		/* header not found */
149
-		case -1:
150
-			if (add_maxfwd_header(msg, (unsigned int)limit)!=0)
151
-				goto error;
152
-			return 2;
153
-		/* error */
154
-		case -2:
155
-			goto error;
156
-		/* found */
157
-		case 0:
158
-			return -1;
159
-		default:
160
-			if (val>max_limit){
161
-				LM_DBG("value %d decreased to %d\n", val, max_limit);
162
-				val = max_limit+1;
163
-			}
164
-			if ( decrement_maxfwd(msg, val, &mf_value)!=0 ) {
165
-				LM_ERR("decrement failed!\n");
166
-				goto error;
167
-			}
168
-	}
169
-
170
-	return 1;
171
-error:
172
-	return -2;
173
-}
174
-
175
-/**
176
- *
177
- */
178
-static int w_process_maxfwd_header(struct sip_msg* msg, char* str1, char* str2)
179
-{
180
-	int mfval;
181
-	if (get_int_fparam(&mfval, msg, (fparam_t*) str1) < 0) {
182
-		LM_ERR("could not get param value\n");
183
-		return -1;
184
-	}
185
-	return process_maxfwd_header(msg, mfval);
186
-}
187
-
188
-
189
-/**
190
- *
191
- */
192
-static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo)
193
-{
194
-	str mf_value;
195
-	int limit;
196
-	int val;
197
-
198
-	limit = (int)(long)slimit;
199
-	if (get_int_fparam(&limit, msg, (fparam_t*) slimit) < 0) {
200
-		LM_ERR("could not get param value\n");
201
-		return -1;
202
-	}
203
-	if(limit<0 || limit>255) {
204
-		LM_ERR("invalid param value: %d\n", limit);
205
-		return -1;
206
-	}
207
-	val = is_maxfwd_present( msg, &mf_value);
208
-	LM_DBG("value = %d \n",val);
209
-
210
-	if ( val<0 ) {
211
-		/* error or not found */
212
-		return val-1;
213
-	} else if ( val>=limit ) {
214
-		/* greater or equal than/to limit */
215
-		return -1;
216
-	}
217
-
218
-	return 1;
219
-}
220
-
221
-/**
222
- * @brief bind functions to MAXFWD API structure
223
- */
224
-int bind_maxfwd(maxfwd_api_t *api)
225
-{
226
-	if (!api) {
227
-		ERR("Invalid parameter value\n");
228
-		return -1;
229
-	}
230
-	api->process_maxfwd = process_maxfwd_header;
231
-
232
-	return 0;
233
-}
Browse code

maxfwd(k): max_limit module param can be changed at runtime

- changed to use cfg param reload framework
- added aliases to existing functions to make them compatible with ser
flavour
- config functions can take variables as parameters

Daniel-Constantin Mierla authored on 21/12/2012 21:43:54
Showing 1 changed files
... ...
@@ -44,16 +44,27 @@
44 44
 #include "../../error.h"
45 45
 #include "../../ut.h"
46 46
 #include "../../mem/mem.h"
47
+#include "../../cfg/cfg.h"
47 48
 #include "mf_funcs.h"
48 49
 #include "api.h"
49 50
 
50 51
 MODULE_VERSION
51 52
 
52
-#define MAXFWD_UPPER_LIMIT 256
53
+struct cfg_group_maxfwd {
54
+	int max_limit;
55
+};
56
+
57
+static struct cfg_group_maxfwd default_maxfwd_cfg = {
58
+	max_limit:16
59
+};
53 60
 
54
-static int max_limit = MAXFWD_UPPER_LIMIT;
61
+static void *maxfwd_cfg = &default_maxfwd_cfg;
62
+
63
+static cfg_def_t maxfwd_cfg_def[] = {
64
+        {"max_limit", CFG_VAR_INT, 0, 255, 0, 0, "Max. maxfwd limit"},
65
+        {0, 0, 0, 0, 0, 0}
66
+};
55 67
 
56
-static int fixup_maxfwd_header(void** param, int param_no);
57 68
 static int w_process_maxfwd_header(struct sip_msg* msg,char* str,char* str2);
58 69
 static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo);
59 70
 static int mod_init(void);
... ...
@@ -61,17 +72,27 @@ static int mod_init(void);
61 72
 int bind_maxfwd(maxfwd_api_t *api);
62 73
 
63 74
 static cmd_export_t cmds[]={
75
+	{"maxfwd_process", (cmd_function)w_process_maxfwd_header, 1,
76
+		fixup_var_int_1, 0, REQUEST_ROUTE},
64 77
 	{"mf_process_maxfwd_header", (cmd_function)w_process_maxfwd_header, 1,
65
-		fixup_maxfwd_header, 0, REQUEST_ROUTE},
78
+		fixup_var_int_1, 0, REQUEST_ROUTE},
79
+	{"process_maxfwd", (cmd_function)w_process_maxfwd_header, 1,
80
+		fixup_var_int_1, 0, REQUEST_ROUTE},
81
+
66 82
 	{"is_maxfwd_lt", (cmd_function)is_maxfwd_lt, 1,
67
-		fixup_maxfwd_header, 0, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
83
+		fixup_var_int_1, 0, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
84
+	{"maxfwd_at_least", (cmd_function)is_maxfwd_lt, 1,
85
+		fixup_var_int_1, 0, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
86
+	{"mf_lowlimit", (cmd_function)is_maxfwd_lt, 1,
87
+		fixup_var_int_1, 0, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
88
+
68 89
 	{"bind_maxfwd",  (cmd_function)bind_maxfwd,  0,
69 90
 		0, 0, 0},
70 91
 	{0,0,0,0,0,0}
71 92
 };
72 93
 
73 94
 static param_export_t params[]={
74
-	{"max_limit",    INT_PARAM,  &max_limit},
95
+	{"max_limit",    INT_PARAM,  &default_maxfwd_cfg.max_limit},
75 96
 	{0,0,0}
76 97
 };
77 98
 
... ...
@@ -96,9 +117,9 @@ struct module_exports exports= {
96 117
 
97 118
 static int mod_init(void)
98 119
 {
99
-	if ( max_limit<1 || max_limit>MAXFWD_UPPER_LIMIT ) {
100
-		LM_ERR("invalid max limit (%d) [1,%d]\n",
101
-			max_limit,MAXFWD_UPPER_LIMIT);
120
+	if (cfg_declare("maxfwd", maxfwd_cfg_def, &default_maxfwd_cfg,
121
+				cfg_sizeof(maxfwd), &maxfwd_cfg)) {
122
+		LM_ERR("failed to declare the configuration\n");
102 123
 		return E_CFG;
103 124
 	}
104 125
 	return 0;
... ...
@@ -106,35 +127,6 @@ static int mod_init(void)
106 127
 
107 128
 
108 129
 
109
-static int fixup_maxfwd_header(void** param, int param_no)
110
-{
111
-	unsigned long code;
112
-	int err;
113
-
114
-	if (param_no==1){
115
-		code=str2s(*param, strlen(*param), &err);
116
-		if (err==0){
117
-			if (code<1 || code>MAXFWD_UPPER_LIMIT){
118
-				LM_ERR("invalid MAXFWD number <%ld> [1,%d]\n",
119
-					code,MAXFWD_UPPER_LIMIT);
120
-				return E_UNSPEC;
121
-			}
122
-			if (code>max_limit) {
123
-				LM_ERR("default value <%ld> bigger than max limit(%d)\n",
124
-					code, max_limit);
125
-				return E_UNSPEC;
126
-			}
127
-			pkg_free(*param);
128
-			*param=(void*)code;
129
-			return 0;
130
-		}else{
131
-			LM_ERR("bad  number <%s>\n",(char*)(*param));
132
-			return E_UNSPEC;
133
-		}
134
-	}
135
-	return 0;
136
-}
137
-
138 130
 
139 131
 /**
140 132
  * process max forward header
... ...
@@ -142,7 +134,14 @@ static int fixup_maxfwd_header(void** param, int param_no)
142 134
 int process_maxfwd_header(struct sip_msg *msg, int limit)
143 135
 {
144 136
 	int val;
145
-	str mf_value;
137
+	str mf_value = {0};
138
+	int max_limit;
139
+
140
+	if(limit<0 || limit>255) {
141
+		LM_ERR("invalid param value: %d\n", limit);
142
+		return -1;
143
+	}
144
+	max_limit = cfg_get(maxfwd, maxfwd_cfg, max_limit);
146 145
 
147 146
 	val=is_maxfwd_present(msg, &mf_value);
148 147
 	switch (val) {
... ...
@@ -178,7 +177,12 @@ error:
178 177
  */
179 178
 static int w_process_maxfwd_header(struct sip_msg* msg, char* str1, char* str2)
180 179
 {
181
-	return process_maxfwd_header(msg, (int)(unsigned long)str1);
180
+	int mfval;
181
+	if (get_int_fparam(&mfval, msg, (fparam_t*) str1) < 0) {
182
+		LM_ERR("could not get param value\n");
183
+		return -1;
184
+	}
185
+	return process_maxfwd_header(msg, mfval);
182 186
 }
183 187
 
184 188
 
... ...
@@ -192,6 +196,14 @@ static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo)
192 196
 	int val;
193 197
 
194 198
 	limit = (int)(long)slimit;
199
+	if (get_int_fparam(&limit, msg, (fparam_t*) slimit) < 0) {
200
+		LM_ERR("could not get param value\n");
201
+		return -1;
202
+	}
203
+	if(limit<0 || limit>255) {
204
+		LM_ERR("invalid param value: %d\n", limit);
205
+		return -1;
206
+	}
195 207
 	val = is_maxfwd_present( msg, &mf_value);
196 208
 	LM_DBG("value = %d \n",val);
197 209
 
Browse code

maxfwd(k): return -2 (false) if MF header cannot be processed

- reported by Ladislav Jurak, FS#214

Daniel-Constantin Mierla authored on 17/04/2012 20:40:06
Showing 1 changed files
... ...
@@ -153,7 +153,7 @@ int process_maxfwd_header(struct sip_msg *msg, int limit)
153 153
 			return 2;
154 154
 		/* error */
155 155
 		case -2:
156
-			break;
156
+			goto error;
157 157
 		/* found */
158 158
 		case 0:
159 159
 			return -1;
Browse code

maxfwd(k): added inter-module API structure

Daniel-Constantin Mierla authored on 16/11/2010 17:37:37
Showing 1 changed files
... ...
@@ -45,6 +45,7 @@
45 45
 #include "../../ut.h"
46 46
 #include "../../mem/mem.h"
47 47
 #include "mf_funcs.h"
48
+#include "api.h"
48 49
 
49 50
 MODULE_VERSION
50 51
 
... ...
@@ -57,11 +58,15 @@ static int w_process_maxfwd_header(struct sip_msg* msg,char* str,char* str2);
57 58
 static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo);
58 59
 static int mod_init(void);
59 60
 
61
+int bind_maxfwd(maxfwd_api_t *api);
62
+
60 63
 static cmd_export_t cmds[]={
61 64
 	{"mf_process_maxfwd_header", (cmd_function)w_process_maxfwd_header, 1,
62 65
 		fixup_maxfwd_header, 0, REQUEST_ROUTE},
63 66
 	{"is_maxfwd_lt", (cmd_function)is_maxfwd_lt, 1,
64 67
 		fixup_maxfwd_header, 0, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
68
+	{"bind_maxfwd",  (cmd_function)bind_maxfwd,  0,
69
+		0, 0, 0},
65 70
 	{0,0,0,0,0,0}
66 71
 };
67 72
 
... ...
@@ -131,8 +136,10 @@ static int fixup_maxfwd_header(void** param, int param_no)
131 136
 }
132 137
 
133 138
 
134
-
135
-static int w_process_maxfwd_header(struct sip_msg* msg, char* str1,char* str2)
139
+/**
140
+ * process max forward header
141
+ */
142
+int process_maxfwd_header(struct sip_msg *msg, int limit)
136 143
 {
137 144
 	int val;
138 145
 	str mf_value;
... ...
@@ -141,7 +148,7 @@ static int w_process_maxfwd_header(struct sip_msg* msg, char* str1,char* str2)
141 148
 	switch (val) {
142 149
 		/* header not found */
143 150
 		case -1:
144
-			if (add_maxfwd_header( msg, (unsigned int)(unsigned long)str1)!=0)
151
+			if (add_maxfwd_header(msg, (unsigned int)limit)!=0)
145 152
 				goto error;
146 153
 			return 2;
147 154
 		/* error */
... ...
@@ -166,8 +173,18 @@ error:
166 173
 	return -2;
167 174
 }
168 175
 
176
+/**
177
+ *
178
+ */
179
+static int w_process_maxfwd_header(struct sip_msg* msg, char* str1, char* str2)
180
+{
181
+	return process_maxfwd_header(msg, (int)(unsigned long)str1);
182
+}
169 183
 
170 184
 
185
+/**
186
+ *
187
+ */
171 188
 static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo)
172 189
 {
173 190
 	str mf_value;
... ...
@@ -189,3 +206,16 @@ static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo)
189 206
 	return 1;
190 207
 }
191 208
 
209
+/**
210
+ * @brief bind functions to MAXFWD API structure
211
+ */
212
+int bind_maxfwd(maxfwd_api_t *api)
213
+{
214
+	if (!api) {
215
+		ERR("Invalid parameter value\n");
216
+		return -1;
217
+	}
218
+	api->process_maxfwd = process_maxfwd_header;
219
+
220
+	return 0;
221
+}
Browse code

- further logging output cleanup in mod_init, mod_destroy: dispatcher, mi_xmlrpc, presence_dialoginfo, presence_mwi, pua, pua_bla, pua_dialoginfo, pua_mi, pua_usrloc - remove now empty mod_init, mod_destroy functions in: presence_dialoginfo, presence_mwi, pua_bla, pua_dialoginfo, pua_mi, pua_usrloc - smaller whitespace and alignment changes in module exports, remove response_function cast from NULL pointer, we don't do this for all other function exports, so it make no sense to handle this one special

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4949 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 18/09/2008 12:02:39
Showing 1 changed files
... ...
@@ -82,9 +82,9 @@ struct module_exports exports= {
82 82
 	0,          /* exported pseudo-variables */
83 83
 	0,          /* extra processes */
84 84
 	mod_init,
85
-	(response_function) 0,
86
-	(destroy_function) 0,
87
-	0  /* per-child init function */
85
+	0,
86
+	0,
87
+	0           /* per-child init function */
88 88
 };
89 89
 
90 90
 
Browse code

- remove serval STATIC_$MODNAME module #ifdefs from core and modules - this not even compile/ link in 0.9, let alone in the trunk so this is probably not needed anymore

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4778 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 29/08/2008 17:21:02
Showing 1 changed files
... ...
@@ -72,11 +72,7 @@ static param_export_t params[]={
72 72
 
73 73
 
74 74
 
75
-#ifdef STATIC_MAXFWD
76
-struct module_exports maxfwd_exports = {
77
-#else
78 75
 struct module_exports exports= {
79
-#endif
80 76
 	"maxfwd",
81 77
 	DEFAULT_DLFLAGS, /* dlopen flags */
82 78
 	cmds,
Browse code

- cleanup in modules, instead of logging module initialization in each mod_init (with different messages, levels..) do this in the core

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4657 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 10/08/2008 22:51:44
Showing 1 changed files
... ...
@@ -95,7 +95,6 @@ struct module_exports exports= {
95 95
 
96 96
 static int mod_init(void)
97 97
 {
98
-	LM_INFO("initializing...\n");
99 98
 	if ( max_limit<1 || max_limit>MAXFWD_UPPER_LIMIT ) {
100 99
 		LM_ERR("invalid max limit (%d) [1,%d]\n",
101 100
 			max_limit,MAXFWD_UPPER_LIMIT);
Browse code

- change name in copyright headers

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4518 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 28/07/2008 15:39:28
Showing 1 changed files
... ...
@@ -5,14 +5,14 @@
5 5
  *
6 6
  * Copyright (C) 2001-2003 FhG Fokus
7 7
  *
8
- * This file is part of openser, a free SIP server.
8
+ * This file is part of Kamailio, a free SIP server.
9 9
  *
10
- * openser is free software; you can redistribute it and/or modify
10
+ * Kamailio is free software; you can redistribute it and/or modify
11 11
  * it under the terms of the GNU General Public License as published by
12 12
  * the Free Software Foundation; either version 2 of the License, or
13 13
  * (at your option) any later version
14 14
  *
15
- * openser is distributed in the hope that it will be useful,
15
+ * Kamailio is distributed in the hope that it will be useful,
16 16
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 17
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 18
  * GNU General Public License for more details.
Browse code

- add missing cast for cmd_function after module interface extension

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3441 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 19/12/2007 12:23:10
Showing 1 changed files
... ...
@@ -58,9 +58,9 @@ static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo);
58 58
 static int mod_init(void);
59 59
 
60 60
 static cmd_export_t cmds[]={
61
-	{"mf_process_maxfwd_header", w_process_maxfwd_header, 1,
61
+	{"mf_process_maxfwd_header", (cmd_function)w_process_maxfwd_header, 1,
62 62
 		fixup_maxfwd_header, 0, REQUEST_ROUTE},
63
-	{"is_maxfwd_lt", is_maxfwd_lt, 1,
63
+	{"is_maxfwd_lt", (cmd_function)is_maxfwd_lt, 1,
64 64
 		fixup_maxfwd_header, 0, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
65 65
 	{0,0,0,0,0,0}
66 66
 };
Browse code

- decrease log level of maxfwd and pdt module initialization messages

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3223 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 28/11/2007 13:06:31
Showing 1 changed files
... ...
@@ -95,7 +95,7 @@ struct module_exports exports= {
95 95
 
96 96
 static int mod_init(void)
97 97
 {
98
-	LM_NOTICE("initializing...\n");
98
+	LM_INFO("initializing...\n");
99 99
 	if ( max_limit<1 || max_limit>MAXFWD_UPPER_LIMIT ) {
100 100
 		LM_ERR("invalid max limit (%d) [1,%d]\n",
101 101
 			max_limit,MAXFWD_UPPER_LIMIT);
Browse code

- apply patch #1807792, migrate more code to LM_* format Patch provided by Andreas Heise

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2865 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 05/10/2007 11:51:58
Showing 1 changed files
... ...
@@ -95,7 +95,7 @@ struct module_exports exports= {
95 95
 
96 96
 static int mod_init(void)
97 97
 {
98
-	LM_NOTICE("initializing\n");
98
+	LM_NOTICE("initializing...\n");
99 99
 	if ( max_limit<1 || max_limit>MAXFWD_UPPER_LIMIT ) {
100 100
 		LM_ERR("invalid max limit (%d) [1,%d]\n",
101 101
 			max_limit,MAXFWD_UPPER_LIMIT);
Browse code

- cmd_export_t has a new field: free_fixup - it is the function to be called if you want to free the structure resulted after calling the fixup function - to be used in dynamic environments, like perl scripts, where you have to call fixup function every time you call a function exported by modules - for future, a better cleanup of used memory can be achived by freeing fixed strucutred in config file - fixup functions in core got the free_fixup pair if is the case - textops has some free_fixup functions set - dev version increased

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2845 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 04/10/2007 11:21:22
Showing 1 changed files
... ...
@@ -59,10 +59,10 @@ static int mod_init(void);
59 59
 
60 60
 static cmd_export_t cmds[]={
61 61
 	{"mf_process_maxfwd_header", w_process_maxfwd_header, 1,
62
-		fixup_maxfwd_header, REQUEST_ROUTE},
62
+		fixup_maxfwd_header, 0, REQUEST_ROUTE},
63 63
 	{"is_maxfwd_lt", is_maxfwd_lt, 1,
64
-		fixup_maxfwd_header, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
65
-	{0,0,0,0,0}
64
+		fixup_maxfwd_header, 0, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
65
+	{0,0,0,0,0,0}
66 66
 };
67 67
 
68 68
 static param_export_t params[]={
Browse code

- added new field in the module interface - list of the additional processes to be created (work on progress)

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2554 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 31/07/2007 13:01:04
Showing 1 changed files
... ...
@@ -84,6 +84,7 @@ struct module_exports exports= {
84 84
 	0,          /* exported statistics */
85 85
 	0,          /* exported MI functions */
86 86
 	0,          /* exported pseudo-variables */
87
+	0,          /* extra processes */
87 88
 	mod_init,
88 89
 	(response_function) 0,
89 90
 	(destroy_function) 0,
Browse code

- removed the function name from the log message (it will by automatically added by the new logging system)

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2483 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 19/07/2007 13:01:03
Showing 1 changed files
... ...
@@ -96,7 +96,7 @@ static int mod_init(void)
96 96
 {
97 97
 	LM_NOTICE("initializing\n");
98 98
 	if ( max_limit<1 || max_limit>MAXFWD_UPPER_LIMIT ) {
99
-		LM_ERR("init: invalid max limit (%d) [1,%d]\n",
99
+		LM_ERR("invalid max limit (%d) [1,%d]\n",
100 100
 			max_limit,MAXFWD_UPPER_LIMIT);
101 101
 		return E_CFG;
102 102
 	}
... ...
@@ -114,20 +114,20 @@ static int fixup_maxfwd_header(void** param, int param_no)
114 114
 		code=str2s(*param, strlen(*param), &err);
115 115
 		if (err==0){
116 116
 			if (code<1 || code>MAXFWD_UPPER_LIMIT){
117
-				LM_ERR("fixup_maxfwd_header: invalid MAXFWD number "
118
-					"<%ld> [1,%d]\n",code,MAXFWD_UPPER_LIMIT);
117
+				LM_ERR("invalid MAXFWD number <%ld> [1,%d]\n",
118
+					code,MAXFWD_UPPER_LIMIT);
119 119
 				return E_UNSPEC;
120 120
 			}
121 121
 			if (code>max_limit) {
122
-				LM_ERR("fixup_maxfwd_header: default value <%ld> bigger "
123
-					"than max limit(%d)\n", code, max_limit);
122
+				LM_ERR("default value <%ld> bigger than max limit(%d)\n",
123
+					code, max_limit);
124 124
 				return E_UNSPEC;
125 125
 			}
126 126
 			pkg_free(*param);
127 127
 			*param=(void*)code;
128 128
 			return 0;
129 129
 		}else{
130
-			LM_ERR("fixup_maxfwd_header: bad  number <%s>\n",(char*)(*param));
130
+			LM_ERR("bad  number <%s>\n",(char*)(*param));
131 131
 			return E_UNSPEC;
132 132
 		}
133 133
 	}
... ...
@@ -156,12 +156,11 @@ static int w_process_maxfwd_header(struct sip_msg* msg, char* str1,char* str2)
156 156
 			return -1;
157 157
 		default:
158 158
 			if (val>max_limit){
159
-				LM_DBG("process_maxfwd_header: value %d decreased to %d\n",
160
-					val, max_limit);
159
+				LM_DBG("value %d decreased to %d\n", val, max_limit);
161 160
 				val = max_limit+1;
162 161
 			}
163 162
 			if ( decrement_maxfwd(msg, val, &mf_value)!=0 ) {
164
-				LM_ERR("process_maxfwd_header: decrement failed!\n");
163
+				LM_ERR("decrement failed!\n");
165 164
 				goto error;
166 165
 			}
167 166
 	}
... ...
@@ -181,7 +180,7 @@ static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo)
181 180
 
182 181
 	limit = (int)(long)slimit;
183 182
 	val = is_maxfwd_present( msg, &mf_value);
184
-	LM_DBG("is_maxfwd_lt: value = %d \n",val);
183
+	LM_DBG("value = %d \n",val);
185 184
 
186 185
 	if ( val<0 ) {
187 186
 		/* error or not found */
Browse code

- all log messages ported to the new set of macros

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2461 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 16/07/2007 20:06:19
Showing 1 changed files
... ...
@@ -94,9 +94,9 @@ struct module_exports exports= {
94 94
 
95 95
 static int mod_init(void)
96 96
 {
97
-	LOG(L_NOTICE, "Maxfwd module- initializing\n");
97
+	LM_NOTICE("initializing\n");
98 98
 	if ( max_limit<1 || max_limit>MAXFWD_UPPER_LIMIT ) {
99
-		LOG(L_ERR,"ERROR:maxfwd:init: invalid max limit (%d) [1,%d]\n",
99
+		LM_ERR("init: invalid max limit (%d) [1,%d]\n",
100 100
 			max_limit,MAXFWD_UPPER_LIMIT);
101 101
 		return E_CFG;
102 102
 	}
... ...
@@ -114,23 +114,20 @@ static int fixup_maxfwd_header(void** param, int param_no)
114 114
 		code=str2s(*param, strlen(*param), &err);
115 115
 		if (err==0){
116 116
 			if (code<1 || code>MAXFWD_UPPER_LIMIT){
117
-				LOG(L_ERR, "ERROR:maxfwd:fixup_maxfwd_header: "
118
-					"invalid MAXFWD number <%ld> [1,%d]\n",
119
-					code,MAXFWD_UPPER_LIMIT);
117
+				LM_ERR("fixup_maxfwd_header: invalid MAXFWD number "
118
+					"<%ld> [1,%d]\n",code,MAXFWD_UPPER_LIMIT);
120 119
 				return E_UNSPEC;
121 120
 			}
122 121
 			if (code>max_limit) {
123
-				LOG(L_ERR, "ERROR:maxfwd:fixup_maxfwd_header: "
124
-					"default value <%ld> bigger than max limit(%d)\n",
125
-					code, max_limit);
122
+				LM_ERR("fixup_maxfwd_header: default value <%ld> bigger "
123
+					"than max limit(%d)\n", code, max_limit);
126 124
 				return E_UNSPEC;
127 125
 			}
128 126
 			pkg_free(*param);
129 127
 			*param=(void*)code;
130 128
 			return 0;
131 129
 		}else{
132
-			LOG(L_ERR, "ERROR:maxfwd:fixup_maxfwd_header: bad  number <%s>\n",
133
-					(char*)(*param));
130
+			LM_ERR("fixup_maxfwd_header: bad  number <%s>\n",(char*)(*param));
134 131
 			return E_UNSPEC;
135 132
 		}
136 133
 	}
... ...
@@ -159,13 +156,12 @@ static int w_process_maxfwd_header(struct sip_msg* msg, char* str1,char* str2)
159 156
 			return -1;
160 157
 		default:
161 158
 			if (val>max_limit){
162
-				DBG("DBG:maxfwd:process_maxfwd_header: "
163
-					"value %d decreased to %d\n", val, max_limit);
159
+				LM_DBG("process_maxfwd_header: value %d decreased to %d\n",
160
+					val, max_limit);
164 161
 				val = max_limit+1;
165 162
 			}
166 163
 			if ( decrement_maxfwd(msg, val, &mf_value)!=0 ) {
167
-				LOG( L_ERR,"ERROR:maxfwd:process_maxfwd_header: "
168
-					"decrement failed!\n");
164
+				LM_ERR("process_maxfwd_header: decrement failed!\n");
169 165
 				goto error;
170 166
 			}
171 167
 	}
... ...
@@ -185,7 +181,7 @@ static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo)
185 181
 
186 182
 	limit = (int)(long)slimit;
187 183
 	val = is_maxfwd_present( msg, &mf_value);
188
-	DBG("DEBUG:maxfwd:is_maxfwd_lt: value = %d \n",val);
184
+	LM_DBG("is_maxfwd_lt: value = %d \n",val);
189 185
 
190 186
 	if ( val<0 ) {
191 187
 		/* error or not found */
Browse code

- dynamic library loading flags can be specific per module - new modules under development requires such features - by default RTLD_NOW is used, see 'man dlopen' for more options - thanks to Bastian Friedrich <bastian.friedrich@collax.com>

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1282 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 28/11/2006 15:49:10
Showing 1 changed files
... ...
@@ -78,6 +78,7 @@ struct module_exports maxfwd_exports = {
78 78
 struct module_exports exports= {
79 79
 #endif
80 80
 	"maxfwd",
81
+	DEFAULT_DLFLAGS, /* dlopen flags */
81 82
 	cmds,
82 83
 	params,
83 84
 	0,          /* exported statistics */
Browse code

- modules can register pseudo-variables via export structure - a null terminated list with PVs is now part of module's exports { pv-name, pv-function, pv-type, pv-parameter } - the old function to register PV can be still used - small tlsops updates: module name in exports aligned with external name and old TLS pseudo-variables moved to new structure (some by Klaus Darilion)

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1266 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 23/11/2006 21:57:20
Showing 1 changed files
... ...
@@ -82,6 +82,7 @@ struct module_exports exports= {
82 82
 	params,
83 83
 	0,          /* exported statistics */
84 84
 	0,          /* exported MI functions */
85
+	0,          /* exported pseudo-variables */
85 86
 	mod_init,
86 87
 	(response_function) 0,
87 88
 	(destroy_function) 0,
Browse code

- MI interface extended: - each MI function may register an init function to be called from the MI processes - module may register MI functions in a more simpler way, via module's export interface instead of using register_mi_cmd()

- all module migrated to the changes in the module_export

- some syncronizations fixes in the MI functions in imc module

- new module ported to the new MI - flatstore and pdt


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1165 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 10/10/2006 18:46:07
Showing 1 changed files
... ...
@@ -81,6 +81,7 @@ struct module_exports exports= {
81 81
 	cmds,
82 82
 	params,
83 83
 	0,          /* exported statistics */
84
+	0,          /* exported MI functions */
84 85
 	mod_init,
85 86
 	(response_function) 0,
86 87
 	(destroy_function) 0,
Browse code

- log mesage fixed

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@922 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 21/06/2006 18:39:26
Showing 1 changed files
... ...
@@ -112,7 +112,7 @@ static int fixup_maxfwd_header(void** param, int param_no)
112 112
 		if (err==0){
113 113
 			if (code<1 || code>MAXFWD_UPPER_LIMIT){
114 114
 				LOG(L_ERR, "ERROR:maxfwd:fixup_maxfwd_header: "
115
-					"invalid MAXFWD number <%ld> [1,%d\\n",
115
+					"invalid MAXFWD number <%ld> [1,%d]\n",
116 116
 					code,MAXFWD_UPPER_LIMIT);
117 117
 				return E_UNSPEC;
118 118
 			}
Browse code

- onbreak module function removed from module interface : not used anymore, it;s functionality took-ver by post-script callbacks

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@552 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 24/01/2006 20:56:29
Showing 1 changed files
... ...
@@ -84,7 +84,6 @@ struct module_exports exports= {
84 84
 	mod_init,
85 85
 	(response_function) 0,
86 86
 	(destroy_function) 0,
87
-	0,
88 87
 	0  /* per-child init function */
89 88
 };
90 89
 
Browse code

-first version of a global Statistics Manager (core and modules exports statistics variables to the Manager which is centralized collector and access point for fetching statististics. -module interfaces updated to export statistics (none so far) -some basic statistics exported by core - how many replies/request were received, how many were dropped by script/callbacks and how many were bogus. -new compilation define STATISTICS - if the statistics manaer and collection should be compiled or not (default no) WARNING - this is still under developement, so it may not be so stable ;)

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@551 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 24/01/2006 19:15:09
Showing 1 changed files
... ...
@@ -80,6 +80,7 @@ struct module_exports exports= {
80 80
 	"maxfwd",
81 81
 	cmds,
82 82
 	params,
83
+	0,          /* exported statistics */
83 84
 	mod_init,
84 85
 	(response_function) 0,
85 86
 	(destroy_function) 0,
Browse code

- better error reporting for mf_process_maxfwd_header() - improvement: store MF value in parsed structure for later usage - new function is_maxfwd_lt() added

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@362 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 03/11/2005 16:27:21
Showing 1 changed files
... ...
@@ -30,6 +30,8 @@
30 30
  *              module param (bogdan)
31 31
  *  2005-09-15  max_limit param cannot be disabled anymore (according to RFC)
32 32
  *              (bogdan)
33
+ *  2005-11-03  is_maxfwd_lt() function added; MF value saved in 
34
+ *              msg->maxforwards->parsed (bogdan)
33 35
  */
34 36
 
35 37
 
... ...
@@ -52,11 +54,14 @@ static int max_limit = MAXFWD_UPPER_LIMIT;
52 54
 
53 55
 static int fixup_maxfwd_header(void** param, int param_no);
54 56
 static int w_process_maxfwd_header(struct sip_msg* msg,char* str,char* str2);
57
+static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo);
55 58
 static int mod_init(void);
56 59
 
57 60
 static cmd_export_t cmds[]={
58
-	{"mf_process_maxfwd_header", w_process_maxfwd_header, 1, 
61
+	{"mf_process_maxfwd_header", w_process_maxfwd_header, 1,
59 62
 		fixup_maxfwd_header, REQUEST_ROUTE},
63
+	{"is_maxfwd_lt", is_maxfwd_lt, 1,
64
+		fixup_maxfwd_header, REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
60 65
 	{0,0,0,0,0}
61 66
 };
62 67
 
... ...
@@ -90,7 +95,7 @@ static int mod_init(void)
90 95
 	if ( max_limit<1 || max_limit>MAXFWD_UPPER_LIMIT ) {
91 96
 		LOG(L_ERR,"ERROR:maxfwd:init: invalid max limit (%d) [1,%d]\n",
92 97
 			max_limit,MAXFWD_UPPER_LIMIT);
93
-		return -1;
98
+		return E_CFG;
94 99
 	}
95 100
 	return 0;
96 101
 }
... ...
@@ -138,11 +143,15 @@ static int w_process_maxfwd_header(struct sip_msg* msg, char* str1,char* str2)
138 143
 
139 144
 	val=is_maxfwd_present(msg, &mf_value);
140 145
 	switch (val) {
146
+		/* header not found */
141 147
 		case -1:
142
-			add_maxfwd_header( msg, (unsigned int)(unsigned long)str1 );
143
-			break;
148
+			if (add_maxfwd_header( msg, (unsigned int)(unsigned long)str1)!=0)
149
+				goto error;
150
+			return 2;
151
+		/* error */
144 152
 		case -2:
145 153
 			break;
154
+		/* found */
146 155
 		case 0:
147 156
 			return -1;
148 157
 		default:
... ...
@@ -151,13 +160,38 @@ static int w_process_maxfwd_header(struct sip_msg* msg, char* str1,char* str2)
151 160
 					"value %d decreased to %d\n", val, max_limit);
152 161
 				val = max_limit+1;
153 162
 			}
154
-			if ( decrement_maxfwd(msg, val, &mf_value)!=1 )
163
+			if ( decrement_maxfwd(msg, val, &mf_value)!=0 ) {
155 164
 				LOG( L_ERR,"ERROR:maxfwd:process_maxfwd_header: "
156 165
 					"decrement failed!\n");
166
+				goto error;
167
+			}
157 168
 	}
169
+
158 170
 	return 1;
171
+error:
172
+	return -2;
159 173
 }
160 174
 
161 175
 
162 176
 
177
+static int is_maxfwd_lt(struct sip_msg *msg, char *slimit, char *foo)
178
+{
179
+	str mf_value;
180
+	int limit;
181
+	int val;
182
+
183
+	limit = (int)(long)slimit;
184
+	val = is_maxfwd_present( msg, &mf_value);
185
+	DBG("DEBUG:maxfwd:is_maxfwd_lt: value = %d \n",val);
186
+
187
+	if ( val<0 ) {
188
+		/* error or not found */
189
+		return val-1;
190
+	} else if ( val>=limit ) {
191
+		/* greater or equal than/to limit */
192
+		return -1;
193
+	}
194
+
195
+	return 1;
196
+}
163 197
 
Browse code

fixups and cleanup: - max_limit of MAX-FORWARDS cannot exceed 256 (as per RFC) - proper checks (as range) for the module and function params - useless checks removed

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@268 689a6050-402a-0410-94f2-e92a70836424

Bogdan-Andrei Iancu authored on 15/09/2005 10:32:49
Showing 1 changed files
... ...
@@ -28,6 +28,8 @@
28 28
  *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
29 29
  *  2004-08-15  max value of max-fwd header is configurable via max_limit
30 30
  *              module param (bogdan)
31
+ *  2005-09-15  max_limit param cannot be disabled anymore (according to RFC)
32
+ *              (bogdan)
31 33
  */
32 34
 
33 35
 
... ...
@@ -44,7 +46,9 @@
44 46
 
45 47
 MODULE_VERSION
46 48
 
47
-static int max_limit = 16;
49
+#define MAXFWD_UPPER_LIMIT 256
50
+
51
+static int max_limit = MAXFWD_UPPER_LIMIT;
48 52
 
49 53
 static int fixup_maxfwd_header(void** param, int param_no);
50 54
 static int w_process_maxfwd_header(struct sip_msg* msg,char* str,char* str2);
... ...
@@ -83,9 +87,9 @@ struct module_exports exports= {
83 87
 static int mod_init(void)
84 88
 {
85 89
 	LOG(L_NOTICE, "Maxfwd module- initializing\n");
86
-	if ( max_limit>255 ) {
87
-		LOG(L_ERR,"ERROR:maxfwd:init: max limit (%d) to high (<255)\n",
88
-			max_limit);
90
+	if ( max_limit<1 || max_limit>MAXFWD_UPPER_LIMIT ) {
91
+		LOG(L_ERR,"ERROR:maxfwd:init: invalid max limit (%d) [1,%d]\n",
92
+			max_limit,MAXFWD_UPPER_LIMIT);
89 93
 		return -1;
90 94
 	}
91 95
 	return 0;
... ...
@@ -101,12 +105,13 @@ static int fixup_maxfwd_header(void** param, int param_no)
101 105
 	if (param_no==1){
102 106
 		code=str2s(*param, strlen(*param), &err);
103 107
 		if (err==0){
104