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,173 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * Copyright (C) 2004-2006 Voice Sistem SRL
5
- *
6
- * This file is part of Kamailio.
7
- *
8
- * Kamailio is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License
10
- * as published by the Free Software Foundation; either version 2
11
- * of the License, or (at your option) any later version.
12
- *
13
- * Kamailio is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
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
20
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
- *
22
- * History:
23
- * ---------
24
- * 
25
- */
26
-
27
-
28
-#include <stdio.h>
29
-#include <string.h>
30
-#include "../../sr_module.h"
31
-#include "../../lib/srdb1/db.h"
32
-#include "../../dprint.h"
33
-#include "../../error.h"
34
-#include "../../mem/mem.h"
35
-#include "../../mod_fix.h"
36
-
37
-#include "sdlookup.h"
38
-
39
-MODULE_VERSION
40
-
41
-
42
-/* Module destroy function prototype */
43
-static void destroy(void);
44
-
45
-
46
-/* Module child-init function prototype */
47
-static int child_init(int rank);
48
-
49
-
50
-/* Module initialization function prototype */
51
-static int mod_init(void);
52
-
53
-/* Module parameter variables */
54
-static str db_url    = str_init(DEFAULT_RODB_URL);
55
-str user_column      = str_init("username");
56
-str domain_column    = str_init("domain");
57
-str sd_user_column   = str_init("sd_username");
58
-str sd_domain_column = str_init("sd_domain");
59
-str new_uri_column   = str_init("new_uri");
60
-int use_domain       = 0;
61
-static str domain_prefix    = {NULL, 0};
62
-
63
-str dstrip_s = {NULL, 0};
64
-
65
-
66
-db_func_t db_funcs;      /* Database functions */
67
-db1_con_t* db_handle=0;   /* Database connection handle */
68
-
69
-
70
-/* Exported functions */
71
-static cmd_export_t cmds[] = {
72
-	{"sd_lookup", (cmd_function)sd_lookup, 1, fixup_spve_null, 0,
73
-		REQUEST_ROUTE},
74
-	{"sd_lookup", (cmd_function)sd_lookup, 2, fixup_spve_spve, 0,
75
-		REQUEST_ROUTE},
76
-	{0, 0, 0, 0, 0, 0}
77
-};
78
-
79
-
80
-/* Exported parameters */
81
-static param_export_t params[] = {
82
-	{"db_url",           STR_PARAM, &db_url.s             },
83
-	{"user_column",      STR_PARAM, &user_column.s        },
84
-	{"domain_column",    STR_PARAM, &domain_column.s      },
85
-	{"sd_user_column",   STR_PARAM, &sd_user_column.s     },
86
-	{"sd_domain_column", STR_PARAM, &sd_domain_column.s   },
87
-	{"new_uri_column",   STR_PARAM, &new_uri_column.s     },
88
-	{"use_domain",       INT_PARAM, &use_domain           },
89
-	{"domain_prefix",    STR_PARAM, &domain_prefix.s      },
90
-	{0, 0, 0}
91
-};
92
-
93
-
94
-/* Module interface */
95
-struct module_exports exports = {
96
-	"speeddial", 
97
-	DEFAULT_DLFLAGS, /* dlopen flags */
98
-	cmds,       /* Exported functions */
99
-	params,     /* Exported parameters */
100
-	0,          /* exported statistics */
101
-	0,          /* exported MI functions */
102
-	0,          /* exported pseudo-variables */
103
-	0,          /* extra processes */
104
-	mod_init,   /* module initialization function */
105
-	0,          /* response function */
106
-	destroy,    /* destroy function */
107
-	child_init  /* child initialization function */
108
-};
109
-
110
-
111
-/**
112
- *
113
- */
114
-static int child_init(int rank)
115
-{
116
-	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
117
-		return 0; /* do nothing for the main process */
118
-
119
-	db_handle = db_funcs.init(&db_url);
120
-	if (!db_handle)
121
-	{
122
-		LM_ERR("failed to connect database\n");
123
-		return -1;
124
-	}
125
-	return 0;
126
-
127
-}
128
-
129
-
130
-/**
131
- *
132
- */
133
-static int mod_init(void)
134
-{
135
-	db_url.len = strlen(db_url.s);
136
-	user_column.len = strlen(user_column.s);
137
-	domain_column.len = strlen(domain_column.s);
138
-	sd_user_column.len = strlen(sd_user_column.s);
139
-	sd_domain_column.len  = strlen(sd_domain_column.s);
140
-	new_uri_column.len = strlen(new_uri_column.s);
141
-	if (domain_prefix.s)
142
-		domain_prefix.len = strlen(domain_prefix.s);
143
-
144
-    /* Find a database module */
145
-	if (db_bind_mod(&db_url, &db_funcs))
146
-	{
147
-		LM_ERR("failed to bind database module\n");
148
-		return -1;
149
-	}
150
-	if (!DB_CAPABILITY(db_funcs, DB_CAP_QUERY))
151
-	{
152
-		LM_ERR("Database modules does not "
153
-			"provide all functions needed by SPEEDDIAL module\n");
154
-		return -1;
155
-	}
156
-	if (domain_prefix.s && domain_prefix.len > 0) {
157
-		dstrip_s.s = domain_prefix.s;
158
-		dstrip_s.len = domain_prefix.len;
159
-	}
160
-
161
-	return 0;
162
-}
163
-
164
-
165
-/**
166
- *
167
- */
168
-static void destroy(void)
169
-{
170
-	if (db_handle)
171
-		db_funcs.close(db_handle);
172
-}
173
-
Browse code

db: Fixing problem with incorrect initialization of db connections

The sip-router core is based on the ser core and thus has a slightly
different initialization sequence of the main sr process. Namely we
also call the child_init function of all modules in the main process
with rank PROC_INIT. This is a kind of delayed initialization (called
after all mod_init functions have finished but before the main
process started forking children).

There should be no database connections opened in child_init called
with PROC_INIT parameter. This would result in database connections
opened in the main process and inherited by all children. Such
connections could then be used from multiple processes simultaneously
and that can cause race conditions.

This change checks for the value of the rank parameter in child_init
functions and skips database initialization if the value is PROC_INIT,
PROC_MAIN, or PROC_TCP_MAIN.

The problem was reported by Juha and he deserves the credit for helping to
investigate the issue.

Jan Janak authored on 10/06/2009 20:41:27
Showing 1 changed files
... ...
@@ -113,6 +113,9 @@ struct module_exports exports = {
113 113
  */
114 114
 static int child_init(int rank)
115 115
 {
116
+	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
117
+		return 0; /* do nothing for the main process */
118
+
116 119
 	db_handle = db_funcs.init(&db_url);
117 120
 	if (!db_handle)
118 121
 	{
Browse code

Various db api changes needed after migration to libsrdb1

This patch makes the module compatible with the changes done in the
database library of kamailio/ser when it was converted to shared library
libsrdb1. These changes are mostly needed to avoid conflicts with the
symbols defined in the newer version of the library libsrdb2.

List of changes:
* Rename db_con_t to db1_con_t
* Rename db_res_t to db1_res_t
* Rename db field type names from DB_* to DB1_*
* Updated header paths to files in ../../lib/srdb1
* Link with libsrdb1

Jan Janak authored on 03/03/2009 14:41:41
Showing 1 changed files
... ...
@@ -28,7 +28,7 @@
28 28
 #include <stdio.h>
29 29
 #include <string.h>
30 30
 #include "../../sr_module.h"
31
-#include "../../db/db.h"
31
+#include "../../lib/srdb1/db.h"
32 32
 #include "../../dprint.h"
33 33
 #include "../../error.h"
34 34
 #include "../../mem/mem.h"
... ...
@@ -64,7 +64,7 @@ str dstrip_s = {NULL, 0};
64 64
 
65 65
 
66 66
 db_func_t db_funcs;      /* Database functions */
67
-db_con_t* db_handle=0;   /* Database connection handle */
67
+db1_con_t* db_handle=0;   /* Database connection handle */
68 68
 
69 69
 
70 70
 /* Exported functions */
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
... ...
@@ -129,8 +129,6 @@ static int child_init(int rank)
129 129
  */
130 130
 static int mod_init(void)
131 131
 {
132
-	LM_DBG("initializing\n");
133
-
134 132
 	db_url.len = strlen(db_url.s);
135 133
 	user_column.len = strlen(user_column.s);
136 134
 	domain_column.len = strlen(domain_column.s);
Browse code

- renaming: openser -> kamailio

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

Klaus Darilion authored on 06/08/2008 08:20:30
Showing 1 changed files
... ...
@@ -3,9 +3,9 @@
3 3
  *
4 4
  * Copyright (C) 2004-2006 Voice Sistem SRL
5 5
  *
6
- * This file is part of Open SIP Express Router (openser).
6
+ * This file is part of Kamailio.
7 7
  *
8
- * openser is free software; you can redistribute it and/or
8
+ * Kamailio is free software; you can redistribute it and/or
9 9
  * modify it under the terms of the GNU General Public License
10 10
  * as published by the Free Software Foundation; either version 2
11 11
  * of the License, or (at your option) any later version.
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
... ...
@@ -10,7 +10,7 @@
10 10
  * as published by the Free Software Foundation; either version 2
11 11
  * of the License, or (at your option) any later version.
12 12
  *
13
- * openser is distributed in the hope that it will be useful,
13
+ * Kamailio is distributed in the hope that it will be useful,
14 14
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 16
  * GNU General Public License for more details.
Browse code

- added fixup function for PV-formatted string - speeddial updated to use it

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

Daniel-Constantin Mierla authored on 04/03/2008 12:13:23
Showing 1 changed files
... ...
@@ -32,7 +32,7 @@
32 32
 #include "../../dprint.h"
33 33
 #include "../../error.h"
34 34
 #include "../../mem/mem.h"
35
-#include "../../pvar.h"
35
+#include "../../mod_fix.h"
36 36
 
37 37
 #include "sdlookup.h"
38 38
 
... ...
@@ -50,8 +50,6 @@ static int child_init(int rank);
50 50
 /* Module initialization function prototype */
51 51
 static int mod_init(void);
52 52
 
53
-static int fixup_sd(void** param, int param_no);
54
-
55 53
 /* Module parameter variables */
56 54
 static str db_url    = str_init(DEFAULT_RODB_URL);
57 55
 str user_column      = str_init("username");
... ...
@@ -71,8 +69,10 @@ db_con_t* db_handle=0;   /* Database connection handle */
71 69
 
72 70
 /* Exported functions */
73 71
 static cmd_export_t cmds[] = {
74
-	{"sd_lookup", (cmd_function)sd_lookup, 1, 0, 0, REQUEST_ROUTE},
75
-	{"sd_lookup", (cmd_function)sd_lookup, 2, fixup_sd, 0, REQUEST_ROUTE},
72
+	{"sd_lookup", (cmd_function)sd_lookup, 1, fixup_spve_null, 0,
73
+		REQUEST_ROUTE},
74
+	{"sd_lookup", (cmd_function)sd_lookup, 2, fixup_spve_spve, 0,
75
+		REQUEST_ROUTE},
76 76
 	{0, 0, 0, 0, 0, 0}
77 77
 };
78 78
 
... ...
@@ -170,27 +170,3 @@ static void destroy(void)
170 170
 		db_funcs.close(db_handle);
171 171
 }
172 172
 
173
-static int fixup_sd(void** param, int param_no)
174
-{
175
-	pv_elem_t *model;
176
-	str s;
177
-
178
-	if(param_no==1)
179
-		return 0;
180
-
181
-	if(*param)
182
-	{
183
-		s.s = (char*)(*param); s.len = strlen(s.s);
184
-		if(pv_parse_format(&s, &model)<0)
185
-		{
186
-			LM_ERR("wrong format[%s]\n",(char*)(*param));
187
-			return E_UNSPEC;
188
-		}
189
-			
190
-		*param = (void*)model;
191
-		return 0;
192
-	}
193
-	LM_ERR("null format\n");
194
-	return E_UNSPEC;
195
-}
196
-
Browse code

- port database interface (almost) complete from 'const char*' to 'str' for more safety (e.g. not null terminated strings) and performance (save strlen calls in core and library code) - adapt existing modules to use the new interface - change bind_dbmod and use_table function to the naming scheme of the other functions of the API - port existing module to use 'str' values for database related parameters - if modules uses already 'str' functions internally, remove the unnecessary temporary variables - make functions and parameter that needs only locally be used static - introduce new column variables needed for the keys for modules that don't have them already, this could be used to make them configurable later on - add 'const' to more db related functions - fix postgres driver, async queries must be finished, otherwise the next one will not complete - smaller whitespace and formatting changes and cleanups all over the place - reviewed and tested with testcases, but probably not error free because of the change size

- basic DB operations should work, but no extensive load testing has yet be done,
as some work still remains:
- remove dead code and superflous comments in postgres driver
- clean up memory management, at the moment there exists two flavors: don't
copy that much (mysql, unixodbc), don't trust the driver, copy everything
(postgres, db_berkeley)
- after this is unified, then only one implementation for the memory
management of the db API could be used for all modules

- Foundations of this change have been created from Frederick Bullik,
Frederick.Bullik at 1und1 dot de

- Please review and test.


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

Henning Westerholt authored on 22/01/2008 13:55:43
Showing 1 changed files
... ...
@@ -53,16 +53,16 @@ static int mod_init(void);
53 53
 static int fixup_sd(void** param, int param_no);
54 54
 
55 55
 /* Module parameter variables */
56
-char* db_url           = DEFAULT_RODB_URL;
57
-char* user_column      = "username";
58
-char* domain_column    = "domain";
59
-char* sd_user_column   = "sd_username";
60
-char* sd_domain_column = "sd_domain";
61
-char* new_uri_column   = "new_uri";
62
-int   use_domain       = 0;
63
-char* domain_prefix    = NULL;
56
+static str db_url    = str_init(DEFAULT_RODB_URL);
57
+str user_column      = str_init("username");
58
+str domain_column    = str_init("domain");
59
+str sd_user_column   = str_init("sd_username");
60
+str sd_domain_column = str_init("sd_domain");
61
+str new_uri_column   = str_init("new_uri");
62
+int use_domain       = 0;
63
+static str domain_prefix    = {NULL, 0};
64 64
 
65
-str   dstrip_s;
65
+str dstrip_s = {NULL, 0};
66 66
 
67 67
 
68 68
 db_func_t db_funcs;      /* Database functions */
... ...
@@ -79,14 +79,14 @@ static cmd_export_t cmds[] = {
79 79
 
80 80
 /* Exported parameters */
81 81
 static param_export_t params[] = {
82
-	{"db_url",           STR_PARAM, &db_url          },
83
-	{"user_column",      STR_PARAM, &user_column     },
84
-	{"domain_column",    STR_PARAM, &domain_column   },
85
-	{"sd_user_column",   STR_PARAM, &sd_user_column     },
86
-	{"sd_domain_column", STR_PARAM, &sd_domain_column   },
87
-	{"new_uri_column",   STR_PARAM, &new_uri_column     },
88
-	{"use_domain",       INT_PARAM, &use_domain      },
89
-	{"domain_prefix",    STR_PARAM, &domain_prefix   },
82
+	{"db_url",           STR_PARAM, &db_url.s             },
83
+	{"user_column",      STR_PARAM, &user_column.s        },
84
+	{"domain_column",    STR_PARAM, &domain_column.s      },
85
+	{"sd_user_column",   STR_PARAM, &sd_user_column.s     },
86
+	{"sd_domain_column", STR_PARAM, &sd_domain_column.s   },
87
+	{"new_uri_column",   STR_PARAM, &new_uri_column.s     },
88
+	{"use_domain",       INT_PARAM, &use_domain           },
89
+	{"domain_prefix",    STR_PARAM, &domain_prefix.s      },
90 90
 	{0, 0, 0}
91 91
 };
92 92
 
... ...
@@ -113,7 +113,7 @@ struct module_exports exports = {
113 113
  */
114 114
 static int child_init(int rank)
115 115
 {
116
-	db_handle = db_funcs.init(db_url);
116
+	db_handle = db_funcs.init(&db_url);
117 117
 	if (!db_handle)
118 118
 	{
119 119
 		LM_ERR("failed to connect database\n");
... ...
@@ -131,8 +131,17 @@ static int mod_init(void)
131 131
 {
132 132
 	LM_DBG("initializing\n");
133 133
 
134
+	db_url.len = strlen(db_url.s);
135
+	user_column.len = strlen(user_column.s);
136
+	domain_column.len = strlen(domain_column.s);
137
+	sd_user_column.len = strlen(sd_user_column.s);
138
+	sd_domain_column.len  = strlen(sd_domain_column.s);
139
+	new_uri_column.len = strlen(new_uri_column.s);
140
+	if (domain_prefix.s)
141
+		domain_prefix.len = strlen(domain_prefix.s);
142
+
134 143
     /* Find a database module */
135
-	if (bind_dbmod(db_url, &db_funcs))
144
+	if (db_bind_mod(&db_url, &db_funcs))
136 145
 	{
137 146
 		LM_ERR("failed to bind database module\n");
138 147
 		return -1;
... ...
@@ -143,16 +152,9 @@ static int mod_init(void)
143 152
 			"provide all functions needed by SPEEDDIAL module\n");
144 153
 		return -1;
145 154
 	}
146
-	
147
-	if(domain_prefix==NULL || strlen(domain_prefix)==0)
148
-	{
149
-		dstrip_s.s   = 0;
150
-		dstrip_s.len = 0;
151
-	}
152
-	else
153
-	{
154
-		dstrip_s.s   = domain_prefix;
155
-		dstrip_s.len = strlen(domain_prefix);
155
+	if (domain_prefix.s && domain_prefix.len > 0) {
156
+		dstrip_s.s = domain_prefix.s;
157
+		dstrip_s.len = domain_prefix.len;
156 158
 	}
157 159
 
158 160
 	return 0;
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
... ...
@@ -71,8 +71,8 @@ db_con_t* db_handle=0;   /* Database connection handle */
71 71
 
72 72
 /* Exported functions */
73 73
 static cmd_export_t cmds[] = {
74
-	{"sd_lookup", sd_lookup, 1, 0, 0, REQUEST_ROUTE},
75
-	{"sd_lookup", sd_lookup, 2, fixup_sd, 0, REQUEST_ROUTE},
74
+	{"sd_lookup", (cmd_function)sd_lookup, 1, 0, 0, REQUEST_ROUTE},
75
+	{"sd_lookup", (cmd_function)sd_lookup, 2, fixup_sd, 0, REQUEST_ROUTE},
76 76
 	{0, 0, 0, 0, 0, 0}
77 77
 };
78 78
 
Browse code

- changed LOG with LM_*

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

Anca Vamanu authored on 19/10/2007 15:15:01
Showing 1 changed files
... ...
@@ -116,7 +116,7 @@ static int child_init(int rank)
116 116
 	db_handle = db_funcs.init(db_url);
117 117
 	if (!db_handle)
118 118
 	{
119
-		LOG(L_ERR, "speeddial:init_child: Unable to connect database\n");
119
+		LM_ERR("failed to connect database\n");
120 120
 		return -1;
121 121
 	}
122 122
 	return 0;
... ...
@@ -129,17 +129,17 @@ static int child_init(int rank)
129 129
  */
130 130
 static int mod_init(void)
131 131
 {
132
-	DBG("speeddial module - initializing\n");
132
+	LM_DBG("initializing\n");
133 133
 
134 134
     /* Find a database module */
135 135
 	if (bind_dbmod(db_url, &db_funcs))
136 136
 	{
137
-		LOG(L_ERR, "speeddial:mod_init: Unable to bind database module\n");
137
+		LM_ERR("failed to bind database module\n");
138 138
 		return -1;
139 139
 	}
140 140
 	if (!DB_CAPABILITY(db_funcs, DB_CAP_QUERY))
141 141
 	{
142
-		LOG(L_ERR, "speeddial:mod_init: Database modules does not "
142
+		LM_ERR("Database modules does not "
143 143
 			"provide all functions needed by SPEEDDIAL module\n");
144 144
 		return -1;
145 145
 	}
... ...
@@ -181,15 +181,14 @@ static int fixup_sd(void** param, int param_no)
181 181
 		s.s = (char*)(*param); s.len = strlen(s.s);
182 182
 		if(pv_parse_format(&s, &model)<0)
183 183
 		{
184
-			LOG(L_ERR, "ERROR:speeddial:fixup_sd: wrong format[%s]\n",
185
-				(char*)(*param));
184
+			LM_ERR("wrong format[%s]\n",(char*)(*param));
186 185
 			return E_UNSPEC;
187 186
 		}
188 187
 			
189 188
 		*param = (void*)model;
190 189
 		return 0;
191 190
 	}
192
-	LOG(L_ERR, "ERROR:speeddial:fixup_sd: null format\n");
191
+	LM_ERR("null format\n");
193 192
 	return E_UNSPEC;
194 193
 }
195 194
 
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
... ...
@@ -71,9 +71,9 @@ db_con_t* db_handle=0;   /* Database connection handle */
71 71
 
72 72
 /* Exported functions */
73 73
 static cmd_export_t cmds[] = {
74
-	{"sd_lookup", sd_lookup, 1, 0, REQUEST_ROUTE},
75
-	{"sd_lookup", sd_lookup, 2, fixup_sd, REQUEST_ROUTE},
76
-	{0, 0, 0, 0, 0}
74
+	{"sd_lookup", sd_lookup, 1, 0, 0, REQUEST_ROUTE},
75
+	{"sd_lookup", sd_lookup, 2, fixup_sd, 0, REQUEST_ROUTE},
76
+	{0, 0, 0, 0, 0, 0}
77 77
 };
78 78
 
79 79
 
Browse code

- internal redesign of pseudo-variable (PV) model - more compact and clear format for name and index - naming format of structures and functions are prefixed with pv_ instead of xl_ - types of PV are prefixed with PVT_ instead of XL_ - PV spec formats: - $class_name - $class_name(inner_name) - $(class_name[index]) - $(class_name(inner_name)[index]) - $(class_name{transformation}) - $(class_name(inner_name){transformation}) - $(class_name[index]{transformation}) - $(class_name(inner_name)[index]{transformation}) - NOTE: the index for avp and hdr has to be specified after the pharantesis enclosing the name ( $avp(name[index]) => $(avp(name)[index]) ) - there are three classes that accept inner name: avp, hdr and var - there are two classes that accept index: avp and hdr - NOTE: color printing PV not yet migrated -- they will be introduced as a new PV class exported by xlog module - modules migrated to new PV model - NOTE: avpsops need special attention -- it was prety much affected - PV exporting by modules is done via a new simpler structure that allows to add PV with inner name and index - NEW FEATURE: inner_name and index for avp and hdr can be PV ( example: $(avp($var(avp_name))[$var(index)]) - name of avp is taken from $var(avp_name) and the index from $var(index)) - dev version increased

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

Daniel-Constantin Mierla authored on 09/09/2007 20:55:56
Showing 1 changed files
... ...
@@ -32,7 +32,7 @@
32 32
 #include "../../dprint.h"
33 33
 #include "../../error.h"
34 34
 #include "../../mem/mem.h"
35
-#include "../../items.h"
35
+#include "../../pvar.h"
36 36
 
37 37
 #include "sdlookup.h"
38 38
 
... ...
@@ -170,14 +170,16 @@ static void destroy(void)
170 170
 
171 171
 static int fixup_sd(void** param, int param_no)
172 172
 {
173
-	xl_elem_t *model;
173
+	pv_elem_t *model;
174
+	str s;
174 175
 
175 176
 	if(param_no==1)
176 177
 		return 0;
177 178
 
178 179
 	if(*param)
179 180
 	{
180
-		if(xl_parse_format((char*)(*param), &model, XL_DISABLE_COLORS)<0)
181
+		s.s = (char*)(*param); s.len = strlen(s.s);
182
+		if(pv_parse_format(&s, &model)<0)
181 183
 		{
182 184
 			LOG(L_ERR, "ERROR:speeddial:fixup_sd: wrong format[%s]\n",
183 185
 				(char*)(*param));
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
... ...
@@ -100,6 +100,7 @@ struct module_exports exports = {
100 100
 	0,          /* exported statistics */
101 101
 	0,          /* exported MI functions */
102 102
 	0,          /* exported pseudo-variables */
103
+	0,          /* extra processes */
103 104
 	mod_init,   /* module initialization function */
104 105
 	0,          /* response function */
105 106
 	destroy,    /* destroy function */
Browse code

- parameter of m_store() redesined to be more meaningful. Instead of using integer values, the parameter can be given via pseudo-variables - same parameter can be used for m_dump() and in speedial module to have coherence

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

Daniel-Constantin Mierla authored on 19/02/2007 13:31:48
Showing 1 changed files
... ...
@@ -32,6 +32,7 @@
32 32
 #include "../../dprint.h"
33 33
 #include "../../error.h"
34 34
 #include "../../mem/mem.h"
35
+#include "../../items.h"
35 36
 
36 37
 #include "sdlookup.h"
37 38
 
... ...
@@ -49,6 +50,7 @@ static int child_init(int rank);
49 50
 /* Module initialization function prototype */
50 51
 static int mod_init(void);
51 52
 
53
+static int fixup_sd(void** param, int param_no);
52 54
 
53 55
 /* Module parameter variables */
54 56
 char* db_url           = DEFAULT_RODB_URL;
... ...
@@ -70,6 +72,7 @@ db_con_t* db_handle=0;   /* Database connection handle */
70 72
 /* Exported functions */
71 73
 static cmd_export_t cmds[] = {
72 74
 	{"sd_lookup", sd_lookup, 1, 0, REQUEST_ROUTE},
75
+	{"sd_lookup", sd_lookup, 2, fixup_sd, REQUEST_ROUTE},
73 76
 	{0, 0, 0, 0, 0}
74 77
 };
75 78
 
... ...
@@ -112,7 +115,7 @@ static int child_init(int rank)
112 115
 	db_handle = db_funcs.init(db_url);
113 116
 	if (!db_handle)
114 117
 	{
115
-		LOG(L_ERR, "sd:init_child: Unable to connect database\n");
118
+		LOG(L_ERR, "speeddial:init_child: Unable to connect database\n");
116 119
 		return -1;
117 120
 	}
118 121
 	return 0;
... ...
@@ -130,12 +133,12 @@ static int mod_init(void)
130 133
     /* Find a database module */
131 134
 	if (bind_dbmod(db_url, &db_funcs))
132 135
 	{
133
-		LOG(L_ERR, "sd:mod_init: Unable to bind database module\n");
136
+		LOG(L_ERR, "speeddial:mod_init: Unable to bind database module\n");
134 137
 		return -1;
135 138
 	}
136 139
 	if (!DB_CAPABILITY(db_funcs, DB_CAP_QUERY))
137 140
 	{
138
-		LOG(L_ERR, "sd:mod_init: Database modules does not "
141
+		LOG(L_ERR, "speeddial:mod_init: Database modules does not "
139 142
 			"provide all functions needed by SPEEDDIAL module\n");
140 143
 		return -1;
141 144
 	}
... ...
@@ -164,3 +167,26 @@ static void destroy(void)
164 167
 		db_funcs.close(db_handle);
165 168
 }
166 169
 
170
+static int fixup_sd(void** param, int param_no)
171
+{
172
+	xl_elem_t *model;
173
+
174
+	if(param_no==1)
175
+		return 0;
176
+
177
+	if(*param)
178
+	{
179
+		if(xl_parse_format((char*)(*param), &model, XL_DISABLE_COLORS)<0)
180
+		{
181
+			LOG(L_ERR, "ERROR:speeddial:fixup_sd: wrong format[%s]\n",
182
+				(char*)(*param));
183
+			return E_UNSPEC;
184
+		}
185
+			
186
+		*param = (void*)model;
187
+		return 0;
188
+	}
189
+	LOG(L_ERR, "ERROR:speeddial:fixup_sd: null format\n");
190
+	return E_UNSPEC;
191
+}
192
+
Browse code

- new route type: error_route - to be automatically executed when an error occured while sip request processing - now it is triggered by parsing errors of r-uri, header structure, From, To, CSeq, Call-ID, Content-Length - new pseudo variables available in error_route - $err.class - the class of error - $err.level - the severity level - $err.info - text describing the error - $err.rcode - recommended reply code - $err.rreason - recommended reply reason - you have to call exit in error_route to stop the execution - sl_reply(code,reason) is similar to sl_send_reply(), but can take pseudo-variables in parameters (sl_send_reply() is kept by now because it is used internally by other modules) - both sl_reply() and sl_send_reply() can be used in error_route - append_to_reply() can be used in error_route

- struct to_body has a new field, parsed_uri to cache the URI in From and To headers (suggeste by Juha Heinanen)
- parse_from_uri() and parse_to_uri() were introduced to parse and return From/To uri
- psuedo-varaibles and several modules were updated to use the cached structure of From and To URI -- lot of re-parsing is avoided now
- cloning of sip uri in tm is done for all members


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

Daniel-Constantin Mierla authored on 09/01/2007 15:30:28
Showing 1 changed files
... ...
@@ -66,11 +66,6 @@ str   dstrip_s;
66 66
 db_func_t db_funcs;      /* Database functions */
67 67
 db_con_t* db_handle=0;   /* Database connection handle */
68 68
 
69
-/*
70
- * sl_send_reply function pointer
71
- */
72
-int (*sl_reply)(struct sip_msg* _m, char* _s1, char* _s2);
73
-
74 69
 
75 70
 /* Exported functions */
76 71
 static cmd_export_t cmds[] = {
... ...
@@ -145,18 +140,6 @@ static int mod_init(void)
145 140
 		return -1;
146 141
 	}
147 142
 	
148
-	/**
149
-	 * We will need sl_send_reply from stateless
150
-	 * module for sending replies
151
-	 */
152
-	
153
-	sl_reply = find_export("sl_send_reply", 2, 0);
154
-	if (!sl_reply)
155
-	{
156
-		LOG(L_ERR, "sd: This module requires sl module\n");
157
-		return -1;
158
-	}
159
-
160 143
 	if(domain_prefix==NULL || strlen(domain_prefix)==0)
161 144
 	{
162 145
 		dstrip_s.s   = 0;
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
... ...
@@ -96,6 +96,7 @@ static param_export_t params[] = {
96 96
 /* Module interface */
97 97
 struct module_exports exports = {
98 98
 	"speeddial", 
99
+	DEFAULT_DLFLAGS, /* dlopen flags */
99 100
 	cmds,       /* Exported functions */
100 101
 	params,     /* Exported parameters */
101 102
 	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
... ...
@@ -100,6 +100,7 @@ struct module_exports exports = {
100 100
 	params,     /* Exported parameters */
101 101
 	0,          /* exported statistics */
102 102
 	0,          /* exported MI functions */
103
+	0,          /* exported pseudo-variables */
103 104
 	mod_init,   /* module initialization function */
104 105
 	0,          /* response function */
105 106
 	destroy,    /* destroy function */
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
... ...
@@ -99,6 +99,7 @@ struct module_exports exports = {
99 99
 	cmds,       /* Exported functions */
100 100
 	params,     /* Exported parameters */
101 101
 	0,          /* exported statistics */
102
+	0,          /* exported MI functions */
102 103
 	mod_init,   /* module initialization function */
103 104
 	0,          /* response function */
104 105
 	destroy,    /* destroy function */
Browse code

- syncronize the copyright text with the rest of openser. - remove from indication of "office@voice-system.ro" from copyright text

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

Bogdan-Andrei Iancu authored on 06/09/2006 11:05:17
Showing 1 changed files
... ...
@@ -1,16 +1,16 @@
1 1
 /*
2 2
  * $Id$
3 3
  *
4
- * Copyright (C) 2004 Voice Sistem SRL
4
+ * Copyright (C) 2004-2006 Voice Sistem SRL
5 5
  *
6
- * This file is part of Open SIP Express Router.
6
+ * This file is part of Open SIP Express Router (openser).
7 7
  *
8
- * SPEEDDIAL OpenSER-module is free software; you can redistribute it and/or
8
+ * openser is free software; you can redistribute it and/or
9 9
  * modify it under the terms of the GNU General Public License
10 10
  * as published by the Free Software Foundation; either version 2
11 11
  * of the License, or (at your option) any later version.
12 12
  *
13
- * SPEEDDIAL OpenSER-module is distributed in the hope that it will be useful,
13
+ * openser is distributed in the hope that it will be useful,
14 14
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 16
  * GNU General Public License for more details.
... ...
@@ -19,11 +19,6 @@
19 19
  * along with this program; if not, write to the Free Software
20 20
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 21
  *
22
- * For any questions about this software and its license, please contact
23
- * Voice Sistem at following e-mail address:
24
- *         office@voice-sistem.ro
25
- *  
26
- *
27 22
  * History:
28 23
  * ---------
29 24
  * 
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
... ...
@@ -107,7 +107,6 @@ struct module_exports exports = {
107 107
 	mod_init,   /* module initialization function */
108 108
 	0,          /* response function */
109 109
 	destroy,    /* destroy function */
110
-	0,          /* oncancel function */
111 110
 	child_init  /* child initialization function */
112 111
 };
113 112
 
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
... ...
@@ -103,6 +103,7 @@ struct module_exports exports = {
103 103
 	"speeddial", 
104 104
 	cmds,       /* Exported functions */
105 105
 	params,     /* Exported parameters */
106
+	0,          /* exported statistics */
106 107
 	mod_init,   /* module initialization function */
107 108
 	0,          /* response function */
108 109
 	destroy,    /* destroy function */
Browse code

Initial revision

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

Bogdan-Andrei Iancu authored on 13/06/2005 16:47:24
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,185 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2004 Voice Sistem SRL
5
+ *
6
+ * This file is part of Open SIP Express Router.
7
+ *
8
+ * SPEEDDIAL OpenSER-module is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU General Public License
10
+ * as published by the Free Software Foundation; either version 2
11
+ * of the License, or (at your option) any later version.
12
+ *
13
+ * SPEEDDIAL OpenSER-module is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
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
20
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
+ *
22
+ * For any questions about this software and its license, please contact
23
+ * Voice Sistem at following e-mail address:
24
+ *         office@voice-sistem.ro
25
+ *  
26
+ *
27
+ * History:
28
+ * ---------
29
+ * 
30
+ */
31
+
32
+
33
+#include <stdio.h>
34
+#include <string.h>
35
+#include "../../sr_module.h"
36
+#include "../../db/db.h"
37
+#include "../../dprint.h"
38
+#include "../../error.h"
39
+#include "../../mem/mem.h"
40
+
41
+#include "sdlookup.h"
42
+
43
+MODULE_VERSION
44
+
45
+
46
+/* Module destroy function prototype */
47
+static void destroy(void);
48
+
49
+
50
+/* Module child-init function prototype */
51
+static int child_init(int rank);
52
+
53
+
54
+/* Module initialization function prototype */
55
+static int mod_init(void);
56
+
57
+
58
+/* Module parameter variables */
59
+char* db_url           = DEFAULT_RODB_URL;
60
+char* user_column      = "username";
61
+char* domain_column    = "domain";
62
+char* sd_user_column   = "sd_username";
63
+char* sd_domain_column = "sd_domain";
64
+char* new_uri_column   = "new_uri";
65
+int   use_domain       = 0;
66
+char* domain_prefix    = NULL;
67
+
68
+str   dstrip_s;
69
+
70
+
71
+db_func_t db_funcs;      /* Database functions */
72
+db_con_t* db_handle=0;   /* Database connection handle */
73
+
74
+/*
75
+ * sl_send_reply function pointer
76
+ */
77
+int (*sl_reply)(struct sip_msg* _m, char* _s1, char* _s2);
78
+
79
+
80
+/* Exported functions */
81
+static cmd_export_t cmds[] = {
82
+	{"sd_lookup", sd_lookup, 1, 0, REQUEST_ROUTE},
83
+	{0, 0, 0, 0, 0}
84
+};
85
+
86
+
87
+/* Exported parameters */
88
+static param_export_t params[] = {
89
+	{"db_url",           STR_PARAM, &db_url          },
90
+	{"user_column",      STR_PARAM, &user_column     },
91
+	{"domain_column",    STR_PARAM, &domain_column   },
92
+	{"sd_user_column",   STR_PARAM, &sd_user_column     },
93
+	{"sd_domain_column", STR_PARAM, &sd_domain_column   },
94
+	{"new_uri_column",   STR_PARAM, &new_uri_column     },
95
+	{"use_domain",       INT_PARAM, &use_domain      },
96
+	{"domain_prefix",    STR_PARAM, &domain_prefix   },
97
+	{0, 0, 0}
98
+};
99
+
100
+
101
+/* Module interface */
102
+struct module_exports exports = {
103
+	"speeddial", 
104
+	cmds,       /* Exported functions */
105
+	params,     /* Exported parameters */
106
+	mod_init,   /* module initialization function */
107
+	0,          /* response function */
108
+	destroy,    /* destroy function */
109
+	0,          /* oncancel function */
110
+	child_init  /* child initialization function */
111
+};
112
+
113
+
114
+/**
115
+ *
116
+ */
117
+static int child_init(int rank)
118
+{
119
+	db_handle = db_funcs.init(db_url);
120
+	if (!db_handle)
121
+	{
122
+		LOG(L_ERR, "sd:init_child: Unable to connect database\n");
123
+		return -1;
124
+	}
125
+	return 0;
126
+
127
+}
128
+
129
+
130
+/**
131
+ *
132
+ */
133
+static int mod_init(void)
134
+{
135
+	DBG("speeddial module - initializing\n");
136
+
137
+    /* Find a database module */
138
+	if (bind_dbmod(db_url, &db_funcs))
139
+	{
140
+		LOG(L_ERR, "sd:mod_init: Unable to bind database module\n");
141
+		return -1;
142
+	}
143
+	if (!DB_CAPABILITY(db_funcs, DB_CAP_QUERY))
144
+	{
145
+		LOG(L_ERR, "sd:mod_init: Database modules does not "
146
+			"provide all functions needed by SPEEDDIAL module\n");
147
+		return -1;
148
+	}
149
+	
150
+	/**
151
+	 * We will need sl_send_reply from stateless
152
+	 * module for sending replies
153
+	 */
154
+	
155
+	sl_reply = find_export("sl_send_reply", 2, 0);
156
+	if (!sl_reply)
157
+	{
158
+		LOG(L_ERR, "sd: This module requires sl module\n");
159
+		return -1;
160
+	}
161
+
162
+	if(domain_prefix==NULL || strlen(domain_prefix)==0)
163
+	{
164
+		dstrip_s.s   = 0;
165
+		dstrip_s.len = 0;
166
+	}
167
+	else
168
+	{
169
+		dstrip_s.s   = domain_prefix;
170
+		dstrip_s.len = strlen(domain_prefix);
171
+	}
172
+
173
+	return 0;
174
+}
175
+
176
+
177
+/**
178
+ *
179
+ */
180
+static void destroy(void)
181
+{
182
+	if (db_handle)
183
+		db_funcs.close(db_handle);
184
+}
185
+