Browse code

cdp_avp: converted to the new module interface

Federico Cabiddu authored on 27/09/2018 16:11:15 • Victor Seva committed on 28/09/2018 11:03:26
Showing 1 changed files
... ...
@@ -55,9 +55,9 @@ void 	cdp_avp_destroy();
55 55
 cdp_avp_bind_t*	cdp_avp_get_bind();
56 56
 	
57 57
 static cmd_export_t cdp_avp_cmds[] = {
58
-	{"cdp_avp_get_bind",			(cmd_function)cdp_avp_get_bind, 	NO_SCRIPT, 0, 0},
58
+	{"cdp_avp_get_bind",			(cmd_function)cdp_avp_get_bind, 	NO_SCRIPT, 0, 0, 0},
59 59
 	
60
-	{ 0, 0, 0, 0, 0 }
60
+	{ 0, 0, 0, 0, 0, 0 }
61 61
 };
62 62
 	
63 63
 /**
... ...
@@ -65,14 +65,15 @@ static cmd_export_t cdp_avp_cmds[] = {
65 65
  */
66 66
 struct module_exports exports = {
67 67
 	"cdp_avp",
68
-	cdp_avp_cmds,                   /**< Exported functions */
68
+	DEFAULT_DLFLAGS, 	/* dlopen flags */
69
+	cdp_avp_cmds,    	/**< Exported functions */
70
+	0,               	/**< Exported parameters */
71
+	0,               	/* RPC method exports */
72
+        0,       		/* pseudo-variables exports */
69 73
 	0,
70
-	0,                     			/**< Exported parameters */
71
-	cdp_avp_init,                   /**< Module initialization function */
72
-	(response_function) 0,
73
-	(destroy_function) cdp_avp_destroy,
74
-	0,
75
-	(child_init_function) cdp_avp_child_init /**< per-child init function */
74
+	cdp_avp_init,    	/**< Module initialization function */
75
+	cdp_avp_child_init, 	/**< per-child init function */
76
+	cdp_avp_destroy
76 77
 };
77 78
 
78 79
 
Browse code

cdp_avp: Rename module interface file #82

Victor Seva authored on 05/01/2017 12:03:55
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,240 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * The initial version of this code was written by Dragos Vingarzan
5
+ * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
6
+ * Fruanhofer Institute. It was and still is maintained in a separate
7
+ * branch of the original SER. We are therefore migrating it to
8
+ * Kamailio/SR and look forward to maintaining it from here on out.
9
+ * 2011/2012 Smile Communications, Pty. Ltd.
10
+ * ported/maintained/improved by 
11
+ * Jason Penton (jason(dot)penton(at)smilecoms.com and
12
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
13
+ * effort to add full IMS support to Kamailio/SR using a new and
14
+ * improved architecture
15
+ * 
16
+ * NB: Alot of this code was originally part of OpenIMSCore,
17
+ * FhG Focus. Thanks for great work! This is an effort to 
18
+ * break apart the various CSCF functions into logically separate
19
+ * components. We hope this will drive wider use. We also feel
20
+ * that in this way the architecture is more complete and thereby easier
21
+ * to manage in the Kamailio/SR environment
22
+ *
23
+ * This file is part of Kamailio, a free SIP server.
24
+ *
25
+ * Kamailio is free software; you can redistribute it and/or modify
26
+ * it under the terms of the GNU General Public License as published by
27
+ * the Free Software Foundation; either version 2 of the License, or
28
+ * (at your option) any later version
29
+ *
30
+ * Kamailio is distributed in the hope that it will be useful,
31
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
32
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
+ * GNU General Public License for more details.
34
+ *
35
+ * You should have received a copy of the GNU General Public License 
36
+ * along with this program; if not, write to the Free Software 
37
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
38
+ * 
39
+ */
40
+
41
+#include <time.h>
42
+
43
+#include "../../core/sr_module.h"
44
+MODULE_VERSION
45
+
46
+#include "cdp_avp_mod.h"
47
+
48
+#include "../cdp/cdp_load.h"
49
+
50
+struct cdp_binds *cdp;
51
+	
52
+int 	cdp_avp_init();
53
+int 	cdp_avp_child_init(int rank);
54
+void 	cdp_avp_destroy();
55
+cdp_avp_bind_t*	cdp_avp_get_bind();
56
+	
57
+static cmd_export_t cdp_avp_cmds[] = {
58
+	{"cdp_avp_get_bind",			(cmd_function)cdp_avp_get_bind, 	NO_SCRIPT, 0, 0},
59
+	
60
+	{ 0, 0, 0, 0, 0 }
61
+};
62
+	
63
+/**
64
+ * Exported SER module interface
65
+ */
66
+struct module_exports exports = {
67
+	"cdp_avp",
68
+	cdp_avp_cmds,                   /**< Exported functions */
69
+	0,
70
+	0,                     			/**< Exported parameters */
71
+	cdp_avp_init,                   /**< Module initialization function */
72
+	(response_function) 0,
73
+	(destroy_function) cdp_avp_destroy,
74
+	0,
75
+	(child_init_function) cdp_avp_child_init /**< per-child init function */
76
+};
77
+
78
+
79
+/** Sample binding */
80
+cdp_avp_bind_t cdp_avp_bind={
81
+		0,	/* cdp 		*/
82
+		
83
+		{	/* basic 	*/
84
+				cdp_avp_new,
85
+				
86
+				cdp_avp_add_new_to_list,
87
+				cdp_avp_add_new_to_msg,
88
+				cdp_avp_add_to_list,
89
+				cdp_avp_add_to_msg,
90
+				
91
+				cdp_avp_get_next_from_list,
92
+				cdp_avp_get_next_from_msg,
93
+				cdp_avp_get_from_list,
94
+				cdp_avp_get_from_msg,
95
+		},
96
+		
97
+		{	/* base_data	*/
98
+				cdp_avp_new_OctetString,
99
+				cdp_avp_new_Integer32,
100
+				cdp_avp_new_Integer64,
101
+				cdp_avp_new_Unsigned32,
102
+				cdp_avp_new_Unsigned64,
103
+				cdp_avp_new_Float32,
104
+				cdp_avp_new_Float64,
105
+				cdp_avp_new_Grouped,
106
+				
107
+				cdp_avp_new_Address,
108
+				cdp_avp_new_Time,
109
+				cdp_avp_new_UTF8String,
110
+				cdp_avp_new_DiameterIdentity,
111
+				cdp_avp_new_DiameterURI,
112
+				cdp_avp_new_Enumerated,
113
+				cdp_avp_new_IPFilterRule,
114
+				cdp_avp_new_QoSFilterRule,
115
+				
116
+				
117
+				cdp_avp_get_OctetString,
118
+				cdp_avp_get_Integer32,
119
+				cdp_avp_get_Integer64,
120
+				cdp_avp_get_Unsigned32,
121
+				cdp_avp_get_Unsigned64,
122
+				cdp_avp_get_Float32,
123
+				cdp_avp_get_Float64,
124
+				cdp_avp_get_Grouped,
125
+				cdp_avp_free_Grouped,
126
+
127
+				cdp_avp_get_Address,
128
+				cdp_avp_get_Time,
129
+				cdp_avp_get_UTF8String,
130
+				cdp_avp_get_DiameterIdentity,
131
+				cdp_avp_get_DiameterURI,
132
+				cdp_avp_get_Enumerated,
133
+				cdp_avp_get_IPFilterRule,
134
+				cdp_avp_get_QoSFilterRule,
135
+		},
136
+		
137
+		{	/*	base 	*/
138
+				
139
+				#define CDP_AVP_INIT					
140
+					#include "base.h"				
141
+				#undef	CDP_AVP_INIT												
142
+		},
143
+		
144
+		{	/*	ccapp 	*/
145
+				#define CDP_AVP_INIT			
146
+					#include "ccapp.h"		
147
+				#undef	CDP_AVP_INIT
148
+		},
149
+
150
+		{	/*  nasapp  */
151
+				#define CDP_AVP_INIT					
152
+					#include "nasapp.h"				
153
+				#undef	CDP_AVP_INIT
154
+		},
155
+		
156
+		{	/*  imsapp  */
157
+				#define CDP_AVP_INIT					
158
+					#include "imsapp.h"				
159
+				#undef	CDP_AVP_INIT
160
+		},	
161
+		
162
+		{	/*  epcapp  */				
163
+				#define CDP_AVP_INIT					
164
+					#include "epcapp.h"				
165
+				#undef	CDP_AVP_INIT				
166
+		}
167
+};
168
+
169
+
170
+/**
171
+ * Module initialization function - called once at startup.
172
+ * \note Other modules might not be loaded at this moment.
173
+ * If this returns failure, wharf will exit
174
+ * 
175
+ * @param config - abstract configuration string
176
+ * @return 1 on success or 0 on failure
177
+ */
178
+int cdp_avp_init()
179
+{
180
+	LOG(L_DBG," Initializing module cdp_avp\n");
181
+	load_cdp_f load_cdp;
182
+	/* bind to the cdp module */
183
+	if (!(load_cdp = (load_cdp_f)find_export("load_cdp",NO_SCRIPT,0))) {
184
+		LOG(L_ERR, "ERR"M_NAME":mod_init: Can not import load_cdp. This module requires cdp module\n");
185
+		goto error;
186
+	}
187
+	cdp = pkg_malloc(sizeof(struct cdp_binds));
188
+	if (!cdp) return 0;
189
+	/* Load CDP module bindings*/
190
+	if (load_cdp(cdp) == -1)
191
+		goto error;
192
+	
193
+	cdp_avp_bind.cdp = cdp;
194
+	
195
+	return 0;
196
+error:
197
+	return -1;
198
+}
199
+
200
+/**
201
+ * Module initialization function - called once for every process.
202
+ * \note All modules have by now executed the mod_init.
203
+ * If this returns failure, wharf will exit
204
+ * 
205
+ * @param rank - rank of the process calling this
206
+ * @return 1 on success or 0 on failure
207
+ */
208
+int cdp_avp_child_init(int rank)
209
+{
210
+	LOG(L_DBG,"Initializing child in module cdp_avp for rank [%d]\n",
211
+			rank);
212
+	return 1;
213
+}
214
+
215
+
216
+
217
+/**
218
+ * Module destroy function. 
219
+ * Spould clean-up and do nice shut-down.
220
+ * \note Will be called multiple times, once from each process, although crashed processes might not.
221
+ */
222
+void cdp_avp_destroy(void)
223
+{
224
+	LOG(L_DBG,"Destroying module cdp_avp\n");
225
+	pkg_free(cdp);
226
+}
227
+
228
+
229
+/**
230
+ * Returns the module's binding. This will give the structure containing the 
231
+ * functions and data to be used from other processes.
232
+ * @return the pointer to the binding.
233
+ */
234
+cdp_avp_bind_t* cdp_avp_get_bind()
235
+{
236
+	return &cdp_avp_bind;
237
+}
238
+
239
+
240
+