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
deleted file mode 100644
... ...
@@ -1,364 +0,0 @@
1
-/**
2
- * Copyright (C) 2009 SIP-Router.org
3
- *
4
- * This file is part of Kamailio, a free SIP server.
5
- *
6
- * Permission to use, copy, modify, and distribute this software for any
7
- * purpose with or without fee is hereby granted, provided that the above
8
- * copyright notice and this permission notice appear in all copies.
9
- *
10
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
- */
18
-
19
-/*!
20
- * \file
21
- * \brief Kamailio core :: event handling
22
- * \ingroup core
23
- * Module: \ref core
24
- */
25
-
26
-#include "dprint.h"
27
-#include "mem/mem.h"
28
-#include "route.h"
29
-#include "events.h"
30
-
31
-static sr_event_cb_t _sr_events_list;
32
-static int _sr_events_inited = 0;
33
-
34
-typedef struct _sr_core_ert {
35
-	int init_parse_error;
36
-} sr_core_ert_t;
37
-
38
-static sr_core_ert_t _sr_core_ert_list;
39
-
40
-/**
41
- *
42
- */
43
-void sr_core_ert_init(void)
44
-{
45
-	memset(&_sr_core_ert_list, 0, sizeof(sr_core_ert_t));
46
-	/* 0 - is not a valid index in event_route blocks list */
47
-	_sr_core_ert_list.init_parse_error = route_get(&event_rt,
48
-											"core:receive-parse-error");
49
-	if(_sr_core_ert_list.init_parse_error<=0
50
-				|| event_rt.rlist[_sr_core_ert_list.init_parse_error]==NULL) {
51
-		_sr_core_ert_list.init_parse_error = -1;
52
-	} else {
53
-		LM_DBG("event_route[core:receive-parse-error] is defined\n");
54
-	}
55
-}
56
-
57
-/**
58
- *
59
- */
60
-void sr_core_ert_run(sip_msg_t *msg, int e)
61
-{
62
-	struct run_act_ctx ctx;
63
-	int rtb;
64
-
65
-	switch(e) {
66
-		case SR_CORE_ERT_RECEIVE_PARSE_ERROR:
67
-			if(likely(_sr_core_ert_list.init_parse_error<=0))
68
-				return;
69
-			rtb = get_route_type();
70
-			set_route_type(REQUEST_ROUTE);
71
-			init_run_actions_ctx(&ctx);
72
-			run_top_route(event_rt.rlist[_sr_core_ert_list.init_parse_error],
73
-					msg, &ctx);
74
-			set_route_type(rtb);
75
-		break;
76
-	}
77
-}
78
-
79
-/**
80
- *
81
- */
82
-void sr_event_cb_init(void)
83
-{
84
-	if(_sr_events_inited == 0)
85
-	{
86
-		memset(&_sr_events_list, 0, sizeof(sr_event_cb_t));
87
-		_sr_events_inited = 1;
88
-	}
89
-}
90
-
91
-/**
92
- *
93
- */
94
-int sr_event_register_cb(int type, sr_event_cb_f f)
95
-{
96
-	int i;
97
-
98
-	sr_event_cb_init();
99
-	switch(type) {
100
-		case SREV_NET_DATA_IN:
101
-				for(i=0; i<SREV_CB_LIST_SIZE; i++) {
102
-					if(_sr_events_list.net_data_in[i]==0) {
103
-						_sr_events_list.net_data_in[i] = f;
104
-						break;
105
-					}
106
-				}
107
-				if(i==SREV_CB_LIST_SIZE) return -1;
108
-			break;
109
-		case SREV_NET_DATA_OUT:
110
-				for(i=SREV_CB_LIST_SIZE-1; i>=0; i--) {
111
-					if(_sr_events_list.net_data_out[i]==0) {
112
-						_sr_events_list.net_data_out[i] = f;
113
-						break;
114
-					}
115
-				}
116
-				if(i<0) return -1;
117
-			break;
118
-		case SREV_CORE_STATS:
119
-				if(_sr_events_list.core_stats==0)
120
-					_sr_events_list.core_stats = f;
121
-				else return -1;
122
-			break;
123
-		case SREV_CFG_RUN_ACTION:
124
-				if(_sr_events_list.run_action==0)
125
-					_sr_events_list.run_action = f;
126
-				else return -1;
127
-			break;
128
-		case SREV_PKG_UPDATE_STATS:
129
-				if(_sr_events_list.pkg_update_stats==0)
130
-					_sr_events_list.pkg_update_stats = f;
131
-				else return -1;
132
-			break;
133
-		case SREV_NET_DGRAM_IN:
134
-				if(_sr_events_list.net_dgram_in==0)
135
-					_sr_events_list.net_dgram_in = f;
136
-				else return -1;
137
-			break;
138
-		case SREV_TCP_HTTP_100C:
139
-				if(_sr_events_list.tcp_http_100c==0)
140
-					_sr_events_list.tcp_http_100c = f;
141
-				else return -1;
142
-			break;
143
-		case SREV_TCP_MSRP_FRAME:
144
-				if(_sr_events_list.tcp_msrp_frame==0)
145
-					_sr_events_list.tcp_msrp_frame = f;
146
-				else return -1;
147
-			break;
148
-		case SREV_TCP_WS_FRAME_IN:
149
-				if(_sr_events_list.tcp_ws_frame_in==0)
150
-					_sr_events_list.tcp_ws_frame_in = f;
151
-				else return -1;
152
-			break;
153
-		case SREV_TCP_WS_FRAME_OUT:
154
-				if(_sr_events_list.tcp_ws_frame_out==0)
155
-					_sr_events_list.tcp_ws_frame_out = f;
156
-				else return -1;
157
-			break;
158
-		case SREV_STUN_IN:
159
-				if(_sr_events_list.stun_in==0)
160
-					_sr_events_list.stun_in = f;
161
-				else return -1;
162
-			break;
163
-		case SREV_RCV_NOSIP:
164
-				if(_sr_events_list.rcv_nosip==0)
165
-					_sr_events_list.rcv_nosip = f;
166
-				else return -1;
167
-			break;
168
-		case SREV_TCP_CLOSED:
169
-				if(_sr_events_list.tcp_closed==0)
170
-					_sr_events_list.tcp_closed = f;
171
-				else return -1;
172
-			break;
173
-		case SREV_NET_DATA_RECV:
174
-				if(_sr_events_list.net_data_recv==0)
175
-					_sr_events_list.net_data_recv = f;
176
-				else return -1;
177
-			break;
178
-		case SREV_NET_DATA_SEND:
179
-				if(_sr_events_list.net_data_send==0)
180
-					_sr_events_list.net_data_send = f;
181
-				else return -1;
182
-			break;
183
-		default:
184
-			return -1;
185
-	}
186
-	return 0;
187
-}
188
-
189
-/**
190
- *
191
- */
192
-int sr_event_exec(int type, void *data)
193
-{
194
-	int ret;
195
-	int i;
196
-#ifdef EXTRA_DEBUG
197
-	str *p;
198
-#endif /* EXTRA_DEBUG */
199
-	switch(type) {
200
-		case SREV_NET_DATA_IN:
201
-				if(unlikely(_sr_events_list.net_data_in[0]!=0))
202
-				{
203
-#ifdef EXTRA_DEBUG
204
-					p = (str*)data;
205
-					LM_DBG("PRE-IN ++++++++++++++++++++++++++++++++\n"
206
-							"%.*s\n+++++\n", p->len, p->s);
207
-#endif /* EXTRA_DEBUG */
208
-					ret = 0;
209
-					for(i=0; i<SREV_CB_LIST_SIZE
210
-							&& _sr_events_list.net_data_in[i]; i++) {
211
-						ret |= _sr_events_list.net_data_in[i](data);
212
-					}
213
-#ifdef EXTRA_DEBUG
214
-					LM_DBG("POST-IN ++++++++++++++++++++++++++++++++\n"
215
-							"%.*s\n+++++\n", p->len, p->s);
216
-#endif /* EXTRA_DEBUG */
217
-					return ret;
218
-				} else return 1;
219
-			break;
220
-		case SREV_NET_DATA_OUT:
221
-				if(unlikely(_sr_events_list.net_data_out[SREV_CB_LIST_SIZE-1]!=0))
222
-				{
223
-#ifdef EXTRA_DEBUG
224
-					p = (str*)data;
225
-					LM_DBG("PRE-OUT ++++++++++++++++++++\n"
226
-							"%.*s\n+++++++++++++++++++\n", p->len, p->s);
227
-#endif /* EXTRA_DEBUG */
228
-					ret = 0;
229
-					for(i=0; i<SREV_CB_LIST_SIZE; i++) {
230
-						if(_sr_events_list.net_data_out[i]) {
231
-							ret |= _sr_events_list.net_data_out[i](data);
232
-						}
233
-					}
234
-#ifdef EXTRA_DEBUG
235
-					LM_DBG("POST-OUT ++++++++++++++++++++\n"
236
-							"%.*s\n+++++++++++++++++++\n", p->len, p->s);
237
-#endif /* EXTRA_DEBUG */
238
-					return ret;
239
-				} else return 1;
240
-			break;
241
-		case SREV_CORE_STATS:
242
-				if(unlikely(_sr_events_list.core_stats!=0))
243
-				{
244
-					ret = _sr_events_list.core_stats(data);
245
-					return ret;
246
-				} else return 1;
247
-			break;
248
-		case SREV_CFG_RUN_ACTION:
249
-				if(unlikely(_sr_events_list.run_action!=0))
250
-				{
251
-					ret = _sr_events_list.run_action(data);
252
-					return ret;
253
-				} else return 1;
254
-		case SREV_PKG_UPDATE_STATS:
255
-				if(unlikely(_sr_events_list.pkg_update_stats!=0))
256
-				{
257
-					ret = _sr_events_list.pkg_update_stats(data);
258
-					return ret;
259
-				} else return 1;
260
-		case SREV_NET_DGRAM_IN:
261
-				if(unlikely(_sr_events_list.net_dgram_in!=0))
262
-				{
263
-					ret = _sr_events_list.net_dgram_in(data);
264
-					return ret;
265
-				} else return 1;
266
-		case SREV_TCP_HTTP_100C:
267
-				if(unlikely(_sr_events_list.tcp_http_100c!=0))
268
-				{
269
-					ret = _sr_events_list.tcp_http_100c(data);
270
-					return ret;
271
-				} else return 1;
272
-		case SREV_TCP_MSRP_FRAME:
273
-				if(unlikely(_sr_events_list.tcp_msrp_frame!=0))
274
-				{
275
-					ret = _sr_events_list.tcp_msrp_frame(data);
276
-					return ret;
277
-				} else return 1;
278
-		case SREV_TCP_WS_FRAME_IN:
279
-				if(unlikely(_sr_events_list.tcp_ws_frame_in!=0))
280
-				{
281
-					ret = _sr_events_list.tcp_ws_frame_in(data);
282
-					return ret;
283
-				} else return 1;
284
-		case SREV_TCP_WS_FRAME_OUT:
285
-				if(unlikely(_sr_events_list.tcp_ws_frame_out!=0))
286
-				{
287
-					ret = _sr_events_list.tcp_ws_frame_out(data);
288
-					return ret;
289
-				} else return 1;
290
-		case SREV_STUN_IN:
291
-				if(unlikely(_sr_events_list.stun_in!=0))
292
-				{
293
-					ret = _sr_events_list.stun_in(data);
294
-					return ret;
295
-				} else return 1;
296
-		case SREV_RCV_NOSIP:
297
-				if(unlikely(_sr_events_list.rcv_nosip!=0))
298
-				{
299
-					ret = _sr_events_list.rcv_nosip(data);
300
-					return ret;
301
-				} else return 1;
302
-		case SREV_TCP_CLOSED:
303
-				if(unlikely(_sr_events_list.tcp_closed!=0))
304
-				{
305
-					ret = _sr_events_list.tcp_closed(data);
306
-					return ret;
307
-				} else return 1;
308
-		case SREV_NET_DATA_RECV:
309
-				if(unlikely(_sr_events_list.net_data_recv!=0))
310
-				{
311
-					ret = _sr_events_list.net_data_recv(data);
312
-					return ret;
313
-				} else return 1;
314
-		case SREV_NET_DATA_SEND:
315
-				if(unlikely(_sr_events_list.net_data_send!=0))
316
-				{
317
-					ret = _sr_events_list.net_data_send(data);
318
-					return ret;
319
-				} else return 1;
320
-		default:
321
-			return -1;
322
-	}
323
-}
324
-
325
-/**
326
- *
327
- */
328
-int sr_event_enabled(int type)
329
-{
330
-	switch(type) {
331
-		case SREV_NET_DATA_IN:
332
-				return (_sr_events_list.net_data_in[0]!=0)?1:0;
333
-		case SREV_NET_DATA_OUT:
334
-				return (_sr_events_list.net_data_out[SREV_CB_LIST_SIZE-1]!=0)?1:0;
335
-		case SREV_CORE_STATS:
336
-				return (_sr_events_list.core_stats!=0)?1:0;
337
-		case SREV_CFG_RUN_ACTION:
338
-				return (_sr_events_list.run_action!=0)?1:0;
339
-		case SREV_PKG_UPDATE_STATS:
340
-				return (_sr_events_list.pkg_update_stats!=0)?1:0;
341
-		case SREV_NET_DGRAM_IN:
342
-				return (_sr_events_list.net_dgram_in!=0)?1:0;
343
-		case SREV_TCP_HTTP_100C:
344
-				return (_sr_events_list.tcp_http_100c!=0)?1:0;
345
-		case SREV_TCP_MSRP_FRAME:
346
-				return (_sr_events_list.tcp_msrp_frame!=0)?1:0;
347
-		case SREV_TCP_WS_FRAME_IN:
348
-				return (_sr_events_list.tcp_ws_frame_in!=0)?1:0;
349
-		case SREV_TCP_WS_FRAME_OUT:
350
-				return (_sr_events_list.tcp_ws_frame_out!=0)?1:0;
351
-		case SREV_STUN_IN:
352
-				return (_sr_events_list.stun_in!=0)?1:0;
353
-		case SREV_RCV_NOSIP:
354
-				return (_sr_events_list.rcv_nosip!=0)?1:0;
355
-		case SREV_TCP_CLOSED:
356
-				return (_sr_events_list.tcp_closed!=0)?1:0;
357
-		case SREV_NET_DATA_RECV:
358
-				return (_sr_events_list.net_data_recv!=0)?1:0;
359
-		case SREV_NET_DATA_SEND:
360
-				return (_sr_events_list.net_data_send!=0)?1:0;
361
-	}
362
-	return 0;
363
-}
364
-
Browse code

core: new event SREV_NET_DATA_RECV

- to be executed if a sip message has been received

Daniel-Constantin Mierla authored on 11/01/2016 21:21:37
Showing 1 changed files
... ...
@@ -170,6 +170,11 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
170 170
 					_sr_events_list.tcp_closed = f;
171 171
 				else return -1;
172 172
 			break;
173
+		case SREV_NET_DATA_RECV:
174
+				if(_sr_events_list.net_data_recv==0)
175
+					_sr_events_list.net_data_recv = f;
176
+				else return -1;
177
+			break;
173 178
 		case SREV_NET_DATA_SEND:
174 179
 				if(_sr_events_list.net_data_send==0)
175 180
 					_sr_events_list.net_data_send = f;
... ...
@@ -300,6 +305,12 @@ int sr_event_exec(int type, void *data)
300 305
 					ret = _sr_events_list.tcp_closed(data);
301 306
 					return ret;
302 307
 				} else return 1;
308
+		case SREV_NET_DATA_RECV:
309
+				if(unlikely(_sr_events_list.net_data_recv!=0))
310
+				{
311
+					ret = _sr_events_list.net_data_recv(data);
312
+					return ret;
313
+				} else return 1;
303 314
 		case SREV_NET_DATA_SEND:
304 315
 				if(unlikely(_sr_events_list.net_data_send!=0))
305 316
 				{
... ...
@@ -343,6 +354,8 @@ int sr_event_enabled(int type)
343 354
 				return (_sr_events_list.rcv_nosip!=0)?1:0;
344 355
 		case SREV_TCP_CLOSED:
345 356
 				return (_sr_events_list.tcp_closed!=0)?1:0;
357
+		case SREV_NET_DATA_RECV:
358
+				return (_sr_events_list.net_data_recv!=0)?1:0;
346 359
 		case SREV_NET_DATA_SEND:
347 360
 				return (_sr_events_list.net_data_send!=0)?1:0;
348 361
 	}
Browse code

core: new event SREV_NET_DATA_SEND

- to be executed if message was sent to the network

Daniel-Constantin Mierla authored on 11/01/2016 11:39:59
Showing 1 changed files
... ...
@@ -170,6 +170,11 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
170 170
 					_sr_events_list.tcp_closed = f;
171 171
 				else return -1;
172 172
 			break;
173
+		case SREV_NET_DATA_SEND:
174
+				if(_sr_events_list.net_data_send==0)
175
+					_sr_events_list.net_data_send = f;
176
+				else return -1;
177
+			break;
173 178
 		default:
174 179
 			return -1;
175 180
 	}
... ...
@@ -295,6 +300,12 @@ int sr_event_exec(int type, void *data)
295 300
 					ret = _sr_events_list.tcp_closed(data);
296 301
 					return ret;
297 302
 				} else return 1;
303
+		case SREV_NET_DATA_SEND:
304
+				if(unlikely(_sr_events_list.net_data_send!=0))
305
+				{
306
+					ret = _sr_events_list.net_data_send(data);
307
+					return ret;
308
+				} else return 1;
298 309
 		default:
299 310
 			return -1;
300 311
 	}
... ...
@@ -332,6 +343,8 @@ int sr_event_enabled(int type)
332 343
 				return (_sr_events_list.rcv_nosip!=0)?1:0;
333 344
 		case SREV_TCP_CLOSED:
334 345
 				return (_sr_events_list.tcp_closed!=0)?1:0;
346
+		case SREV_NET_DATA_SEND:
347
+				return (_sr_events_list.net_data_send!=0)?1:0;
335 348
 	}
336 349
 	return 0;
337 350
 }
Browse code

core: added event callback field for tcp closed connection

Armen Babikyan authored on 04/01/2016 22:04:37 • Daniel-Constantin Mierla committed on 04/01/2016 22:04:37
Showing 1 changed files
... ...
@@ -165,6 +165,11 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
165 165
 					_sr_events_list.rcv_nosip = f;
166 166
 				else return -1;
167 167
 			break;
168
+		case SREV_TCP_CLOSED:
169
+				if(_sr_events_list.tcp_closed==0)
170
+					_sr_events_list.tcp_closed = f;
171
+				else return -1;
172
+			break;
168 173
 		default:
169 174
 			return -1;
170 175
 	}
... ...
@@ -284,6 +289,12 @@ int sr_event_exec(int type, void *data)
284 289
 					ret = _sr_events_list.rcv_nosip(data);
285 290
 					return ret;
286 291
 				} else return 1;
292
+		case SREV_TCP_CLOSED:
293
+				if(unlikely(_sr_events_list.tcp_closed!=0))
294
+				{
295
+					ret = _sr_events_list.tcp_closed(data);
296
+					return ret;
297
+				} else return 1;
287 298
 		default:
288 299
 			return -1;
289 300
 	}
... ...
@@ -319,6 +330,8 @@ int sr_event_enabled(int type)
319 330
 				return (_sr_events_list.stun_in!=0)?1:0;
320 331
 		case SREV_RCV_NOSIP:
321 332
 				return (_sr_events_list.rcv_nosip!=0)?1:0;
333
+		case SREV_TCP_CLOSED:
334
+				return (_sr_events_list.tcp_closed!=0)?1:0;
322 335
 	}
323 336
 	return 0;
324 337
 }
Browse code

kex: removed unused callbacks

Removed the two SREV_MODULE_PKG_STATS and SREV_MODULE_SHM_STATS callbacks
that were never used.

Stefan Mititelu authored on 02/11/2015 15:30:30
Showing 1 changed files
... ...
@@ -165,15 +165,6 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
165 165
 					_sr_events_list.rcv_nosip = f;
166 166
 				else return -1;
167 167
 			break;
168
-		case SREV_MODULE_PKG_STATS:
169
-				if(_sr_events_list.mod_update_pkg_stats==0)
170
-					_sr_events_list.mod_update_pkg_stats = f;
171
-				else return -1;
172
-		case SREV_MODULE_SHM_STATS:
173
-				if(_sr_events_list.mod_update_shm_stats==0)
174
-					_sr_events_list.mod_update_shm_stats = f;
175
-				else return -1;
176
-			break;
177 168
 		default:
178 169
 			return -1;
179 170
 	}
... ...
@@ -293,18 +284,6 @@ int sr_event_exec(int type, void *data)
293 284
 					ret = _sr_events_list.rcv_nosip(data);
294 285
 					return ret;
295 286
 				} else return 1;
296
-		case SREV_MODULE_PKG_STATS:
297
-				if(unlikely(_sr_events_list.mod_update_pkg_stats!=0))
298
-				{
299
-					ret = _sr_events_list.mod_update_pkg_stats(data);
300
-					return ret;
301
-				} else return 1;
302
-		case SREV_MODULE_SHM_STATS:
303
-				if(unlikely(_sr_events_list.mod_update_shm_stats!=0))
304
-				{
305
-					ret = _sr_events_list.mod_update_shm_stats(data);
306
-					return ret;
307
-				} else return 1;
308 287
 		default:
309 288
 			return -1;
310 289
 	}
... ...
@@ -340,10 +319,6 @@ int sr_event_enabled(int type)
340 319
 				return (_sr_events_list.stun_in!=0)?1:0;
341 320
 		case SREV_RCV_NOSIP:
342 321
 				return (_sr_events_list.rcv_nosip!=0)?1:0;
343
-		case SREV_MODULE_PKG_STATS:
344
-				return (_sr_events_list.mod_update_pkg_stats!=0)?1:0;
345
-		case SREV_MODULE_SHM_STATS:
346
-				return (_sr_events_list.mod_update_shm_stats!=0)?1:0;
347 322
 	}
348 323
 	return 0;
349 324
 }
Browse code

core: added events for per module pkg/shm summary

- used by kex for per module memory stats

Stefan Mititelu authored on 02/11/2015 12:38:40 • Daniel-Constantin Mierla committed on 02/11/2015 12:38:40
Showing 1 changed files
... ...
@@ -165,6 +165,15 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
165 165
 					_sr_events_list.rcv_nosip = f;
166 166
 				else return -1;
167 167
 			break;
168
+		case SREV_MODULE_PKG_STATS:
169
+				if(_sr_events_list.mod_update_pkg_stats==0)
170
+					_sr_events_list.mod_update_pkg_stats = f;
171
+				else return -1;
172
+		case SREV_MODULE_SHM_STATS:
173
+				if(_sr_events_list.mod_update_shm_stats==0)
174
+					_sr_events_list.mod_update_shm_stats = f;
175
+				else return -1;
176
+			break;
168 177
 		default:
169 178
 			return -1;
170 179
 	}
... ...
@@ -284,6 +293,18 @@ int sr_event_exec(int type, void *data)
284 293
 					ret = _sr_events_list.rcv_nosip(data);
285 294
 					return ret;
286 295
 				} else return 1;
296
+		case SREV_MODULE_PKG_STATS:
297
+				if(unlikely(_sr_events_list.mod_update_pkg_stats!=0))
298
+				{
299
+					ret = _sr_events_list.mod_update_pkg_stats(data);
300
+					return ret;
301
+				} else return 1;
302
+		case SREV_MODULE_SHM_STATS:
303
+				if(unlikely(_sr_events_list.mod_update_shm_stats!=0))
304
+				{
305
+					ret = _sr_events_list.mod_update_shm_stats(data);
306
+					return ret;
307
+				} else return 1;
287 308
 		default:
288 309
 			return -1;
289 310
 	}
... ...
@@ -319,6 +340,10 @@ int sr_event_enabled(int type)
319 340
 				return (_sr_events_list.stun_in!=0)?1:0;
320 341
 		case SREV_RCV_NOSIP:
321 342
 				return (_sr_events_list.rcv_nosip!=0)?1:0;
343
+		case SREV_MODULE_PKG_STATS:
344
+				return (_sr_events_list.mod_update_pkg_stats!=0)?1:0;
345
+		case SREV_MODULE_SHM_STATS:
346
+				return (_sr_events_list.mod_update_shm_stats!=0)?1:0;
322 347
 	}
323 348
 	return 0;
324 349
 }
Browse code

core Update headers, change "SIP-router" to "Kamailio", update doxygen file headers

Olle E. Johansson authored on 03/01/2015 14:15:58
Showing 1 changed files
... ...
@@ -18,7 +18,7 @@
18 18
 
19 19
 /*!
20 20
  * \file
21
- * \brief SIP-router core :: event handling
21
+ * \brief Kamailio core :: event handling
22 22
  * \ingroup core
23 23
  * Module: \ref core
24 24
  */
Browse code

Core Removed history, svn $id$ and doxygen udpates on the .c files

Olle E. Johansson authored on 03/01/2015 09:53:17
Showing 1 changed files
... ...
@@ -1,9 +1,7 @@
1 1
 /**
2
- * $Id$
3
- *
4 2
  * Copyright (C) 2009 SIP-Router.org
5 3
  *
6
- * This file is part of Extensible SIP Router, a free SIP server.
4
+ * This file is part of Kamailio, a free SIP server.
7 5
  *
8 6
  * Permission to use, copy, modify, and distribute this software for any
9 7
  * purpose with or without fee is hereby granted, provided that the above
... ...
@@ -20,7 +18,7 @@
20 18
 
21 19
 /*!
22 20
  * \file
23
- * \brief SIP-router core :: 
21
+ * \brief SIP-router core :: event handling
24 22
  * \ingroup core
25 23
  * Module: \ref core
26 24
  */
Browse code

core: fix execution of callbacks list for net_data_in

Daniel-Constantin Mierla authored on 10/09/2014 18:11:14
Showing 1 changed files
... ...
@@ -194,7 +194,7 @@ int sr_event_exec(int type, void *data)
194 194
 #endif /* EXTRA_DEBUG */
195 195
 					ret = 0;
196 196
 					for(i=0; i<SREV_CB_LIST_SIZE
197
-							&& _sr_events_list.net_data_out[i]; i++) {
197
+							&& _sr_events_list.net_data_in[i]; i++) {
198 198
 						ret |= _sr_events_list.net_data_in[i](data);
199 199
 					}
200 200
 #ifdef EXTRA_DEBUG
Browse code

core: proper reverse order execution for net_data_out event callbacks

Daniel-Constantin Mierla authored on 05/09/2014 14:18:38
Showing 1 changed files
... ...
@@ -213,9 +213,10 @@ int sr_event_exec(int type, void *data)
213 213
 							"%.*s\n+++++++++++++++++++\n", p->len, p->s);
214 214
 #endif /* EXTRA_DEBUG */
215 215
 					ret = 0;
216
-					for(i=SREV_CB_LIST_SIZE-1;
217
-							i>=0 && _sr_events_list.net_data_out[i]; i--) {
218
-						ret |= _sr_events_list.net_data_out[i](data);
216
+					for(i=0; i<SREV_CB_LIST_SIZE; i++) {
217
+						if(_sr_events_list.net_data_out[i]) {
218
+							ret |= _sr_events_list.net_data_out[i](data);
219
+						}
219 220
 					}
220 221
 #ifdef EXTRA_DEBUG
221 222
 					LM_DBG("POST-OUT ++++++++++++++++++++\n"
Browse code

core: allow up to three callback functions for net_data_in and net_data_out

- they are added normal for net_data_in and reverse for net_data_out,
allowing nested execution (e.g., first module registering the two
callbacks with have the first net_data_in and the last net_data_out)
- allow topoh module can be used with other functionalities needed the same
callbacks

Daniel-Constantin Mierla authored on 05/09/2014 14:11:51
Showing 1 changed files
... ...
@@ -95,17 +95,27 @@ void sr_event_cb_init(void)
95 95
  */
96 96
 int sr_event_register_cb(int type, sr_event_cb_f f)
97 97
 {
98
+	int i;
99
+
98 100
 	sr_event_cb_init();
99 101
 	switch(type) {
100 102
 		case SREV_NET_DATA_IN:
101
-				if(_sr_events_list.net_data_in==0)
102
-					_sr_events_list.net_data_in = f;
103
-				else return -1;
103
+				for(i=0; i<SREV_CB_LIST_SIZE; i++) {
104
+					if(_sr_events_list.net_data_in[i]==0) {
105
+						_sr_events_list.net_data_in[i] = f;
106
+						break;
107
+					}
108
+				}
109
+				if(i==SREV_CB_LIST_SIZE) return -1;
104 110
 			break;
105 111
 		case SREV_NET_DATA_OUT:
106
-				if(_sr_events_list.net_data_out==0)
107
-					_sr_events_list.net_data_out = f;
108
-				else return -1;
112
+				for(i=SREV_CB_LIST_SIZE-1; i>=0; i--) {
113
+					if(_sr_events_list.net_data_out[i]==0) {
114
+						_sr_events_list.net_data_out[i] = f;
115
+						break;
116
+					}
117
+				}
118
+				if(i<0) return -1;
109 119
 			break;
110 120
 		case SREV_CORE_STATS:
111 121
 				if(_sr_events_list.core_stats==0)
... ...
@@ -169,19 +179,24 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
169 179
 int sr_event_exec(int type, void *data)
170 180
 {
171 181
 	int ret;
182
+	int i;
172 183
 #ifdef EXTRA_DEBUG
173 184
 	str *p;
174 185
 #endif /* EXTRA_DEBUG */
175 186
 	switch(type) {
176 187
 		case SREV_NET_DATA_IN:
177
-				if(unlikely(_sr_events_list.net_data_in!=0))
188
+				if(unlikely(_sr_events_list.net_data_in[0]!=0))
178 189
 				{
179 190
 #ifdef EXTRA_DEBUG
180 191
 					p = (str*)data;
181 192
 					LM_DBG("PRE-IN ++++++++++++++++++++++++++++++++\n"
182 193
 							"%.*s\n+++++\n", p->len, p->s);
183 194
 #endif /* EXTRA_DEBUG */
184
-					ret = _sr_events_list.net_data_in(data);
195
+					ret = 0;
196
+					for(i=0; i<SREV_CB_LIST_SIZE
197
+							&& _sr_events_list.net_data_out[i]; i++) {
198
+						ret |= _sr_events_list.net_data_in[i](data);
199
+					}
185 200
 #ifdef EXTRA_DEBUG
186 201
 					LM_DBG("POST-IN ++++++++++++++++++++++++++++++++\n"
187 202
 							"%.*s\n+++++\n", p->len, p->s);
... ...
@@ -190,14 +205,18 @@ int sr_event_exec(int type, void *data)
190 205
 				} else return 1;
191 206
 			break;
192 207
 		case SREV_NET_DATA_OUT:
193
-				if(unlikely(_sr_events_list.net_data_out!=0))
208
+				if(unlikely(_sr_events_list.net_data_out[SREV_CB_LIST_SIZE-1]!=0))
194 209
 				{
195 210
 #ifdef EXTRA_DEBUG
196 211
 					p = (str*)data;
197 212
 					LM_DBG("PRE-OUT ++++++++++++++++++++\n"
198 213
 							"%.*s\n+++++++++++++++++++\n", p->len, p->s);
199 214
 #endif /* EXTRA_DEBUG */
200
-					ret = _sr_events_list.net_data_out(data);
215
+					ret = 0;
216
+					for(i=SREV_CB_LIST_SIZE-1;
217
+							i>=0 && _sr_events_list.net_data_out[i]; i--) {
218
+						ret |= _sr_events_list.net_data_out[i](data);
219
+					}
201 220
 #ifdef EXTRA_DEBUG
202 221
 					LM_DBG("POST-OUT ++++++++++++++++++++\n"
203 222
 							"%.*s\n+++++++++++++++++++\n", p->len, p->s);
... ...
@@ -278,9 +297,9 @@ int sr_event_enabled(int type)
278 297
 {
279 298
 	switch(type) {
280 299
 		case SREV_NET_DATA_IN:
281
-				return (_sr_events_list.net_data_in!=0)?1:0;
300
+				return (_sr_events_list.net_data_in[0]!=0)?1:0;
282 301
 		case SREV_NET_DATA_OUT:
283
-				return (_sr_events_list.net_data_out!=0)?1:0;
302
+				return (_sr_events_list.net_data_out[SREV_CB_LIST_SIZE-1]!=0)?1:0;
284 303
 		case SREV_CORE_STATS:
285 304
 				return (_sr_events_list.core_stats!=0)?1:0;
286 305
 		case SREV_CFG_RUN_ACTION:
Browse code

core: new core event executed when a non sip packet is received

- event type SREV_RCV_NOSIP

Daniel-Constantin Mierla authored on 18/07/2014 14:01:29
Showing 1 changed files
... ...
@@ -152,6 +152,11 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
152 152
 					_sr_events_list.stun_in = f;
153 153
 				else return -1;
154 154
 			break;
155
+		case SREV_RCV_NOSIP:
156
+				if(_sr_events_list.rcv_nosip==0)
157
+					_sr_events_list.rcv_nosip = f;
158
+				else return -1;
159
+			break;
155 160
 		default:
156 161
 			return -1;
157 162
 	}
... ...
@@ -255,6 +260,12 @@ int sr_event_exec(int type, void *data)
255 260
 					ret = _sr_events_list.stun_in(data);
256 261
 					return ret;
257 262
 				} else return 1;
263
+		case SREV_RCV_NOSIP:
264
+				if(unlikely(_sr_events_list.rcv_nosip!=0))
265
+				{
266
+					ret = _sr_events_list.rcv_nosip(data);
267
+					return ret;
268
+				} else return 1;
258 269
 		default:
259 270
 			return -1;
260 271
 	}
... ...
@@ -288,6 +299,8 @@ int sr_event_enabled(int type)
288 299
 				return (_sr_events_list.tcp_ws_frame_out!=0)?1:0;
289 300
 		case SREV_STUN_IN:
290 301
 				return (_sr_events_list.stun_in!=0)?1:0;
302
+		case SREV_RCV_NOSIP:
303
+				return (_sr_events_list.rcv_nosip!=0)?1:0;
291 304
 	}
292 305
 	return 0;
293 306
 }
Browse code

core: repaced the two pkg update event callbacks with one

- simplified usage as can be executed at the end of memory operations
(malloc, free, realloc)

Daniel-Constantin Mierla authored on 03/05/2014 18:02:47
Showing 1 changed files
... ...
@@ -117,14 +117,9 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
117 117
 					_sr_events_list.run_action = f;
118 118
 				else return -1;
119 119
 			break;
120
-		case SREV_PKG_SET_USED:
121
-				if(_sr_events_list.pkg_set_used==0)
122
-					_sr_events_list.pkg_set_used = f;
123
-				else return -1;
124
-			break;
125
-		case SREV_PKG_SET_REAL_USED:
126
-				if(_sr_events_list.pkg_set_real_used==0)
127
-					_sr_events_list.pkg_set_real_used = f;
120
+		case SREV_PKG_UPDATE_STATS:
121
+				if(_sr_events_list.pkg_update_stats==0)
122
+					_sr_events_list.pkg_update_stats = f;
128 123
 				else return -1;
129 124
 			break;
130 125
 		case SREV_NET_DGRAM_IN:
... ...
@@ -218,16 +213,10 @@ int sr_event_exec(int type, void *data)
218 213
 					ret = _sr_events_list.run_action(data);
219 214
 					return ret;
220 215
 				} else return 1;
221
-		case SREV_PKG_SET_USED:
222
-				if(unlikely(_sr_events_list.pkg_set_used!=0))
223
-				{
224
-					ret = _sr_events_list.pkg_set_used(data);
225
-					return ret;
226
-				} else return 1;
227
-		case SREV_PKG_SET_REAL_USED:
228
-				if(unlikely(_sr_events_list.pkg_set_real_used!=0))
216
+		case SREV_PKG_UPDATE_STATS:
217
+				if(unlikely(_sr_events_list.pkg_update_stats!=0))
229 218
 				{
230
-					ret = _sr_events_list.pkg_set_real_used(data);
219
+					ret = _sr_events_list.pkg_update_stats(data);
231 220
 					return ret;
232 221
 				} else return 1;
233 222
 		case SREV_NET_DGRAM_IN:
... ...
@@ -285,10 +274,8 @@ int sr_event_enabled(int type)
285 274
 				return (_sr_events_list.core_stats!=0)?1:0;
286 275
 		case SREV_CFG_RUN_ACTION:
287 276
 				return (_sr_events_list.run_action!=0)?1:0;
288
-		case SREV_PKG_SET_USED:
289
-				return (_sr_events_list.pkg_set_used!=0)?1:0;
290
-		case SREV_PKG_SET_REAL_USED:
291
-				return (_sr_events_list.pkg_set_real_used!=0)?1:0;
277
+		case SREV_PKG_UPDATE_STATS:
278
+				return (_sr_events_list.pkg_update_stats!=0)?1:0;
292 279
 		case SREV_NET_DGRAM_IN:
293 280
 				return (_sr_events_list.net_dgram_in!=0)?1:0;
294 281
 		case SREV_TCP_HTTP_100C:
Browse code

core: efectively run the event_route[core:receive-parse-error]

- reported by Juha Heinanen

Daniel-Constantin Mierla authored on 22/08/2013 15:51:49
Showing 1 changed files
... ...
@@ -61,10 +61,19 @@ void sr_core_ert_init(void)
61 61
  */
62 62
 void sr_core_ert_run(sip_msg_t *msg, int e)
63 63
 {
64
+	struct run_act_ctx ctx;
65
+	int rtb;
66
+
64 67
 	switch(e) {
65 68
 		case SR_CORE_ERT_RECEIVE_PARSE_ERROR:
66 69
 			if(likely(_sr_core_ert_list.init_parse_error<=0))
67 70
 				return;
71
+			rtb = get_route_type();
72
+			set_route_type(REQUEST_ROUTE);
73
+			init_run_actions_ctx(&ctx);
74
+			run_top_route(event_rt.rlist[_sr_core_ert_list.init_parse_error],
75
+					msg, &ctx);
76
+			set_route_type(rtb);
68 77
 		break;
69 78
 	}
70 79
 }
Browse code

core: fix condition to lookup envet_route[core:receive-parse-error]

- reported by Juha Heinanen

Daniel-Constantin Mierla authored on 22/08/2013 13:44:05
Showing 1 changed files
... ...
@@ -48,9 +48,11 @@ void sr_core_ert_init(void)
48 48
 	/* 0 - is not a valid index in event_route blocks list */
49 49
 	_sr_core_ert_list.init_parse_error = route_get(&event_rt,
50 50
 											"core:receive-parse-error");
51
-	if(_sr_core_ert_list.init_parse_error>=0
52
-			&& event_rt.rlist[_sr_core_ert_list.init_parse_error]!=NULL) {
51
+	if(_sr_core_ert_list.init_parse_error<=0
52
+				|| event_rt.rlist[_sr_core_ert_list.init_parse_error]==NULL) {
53 53
 		_sr_core_ert_list.init_parse_error = -1;
54
+	} else {
55
+		LM_DBG("event_route[core:receive-parse-error] is defined\n");
54 56
 	}
55 57
 }
56 58
 
Browse code

core: execute event_route[core:receive-parse-error] block on error of initial sip message parsing

- note that the SIP message is broken in this case, but it gets access
to source and local socket addresses (ip, port, proto, af) as well as
the whole message buffer and its size

Daniel-Constantin Mierla authored on 22/08/2013 11:01:55
Showing 1 changed files
... ...
@@ -27,11 +27,46 @@
27 27
 
28 28
 #include "dprint.h"
29 29
 #include "mem/mem.h"
30
+#include "route.h"
30 31
 #include "events.h"
31 32
 
32 33
 static sr_event_cb_t _sr_events_list;
33 34
 static int _sr_events_inited = 0;
34 35
 
36
+typedef struct _sr_core_ert {
37
+	int init_parse_error;
38
+} sr_core_ert_t;
39
+
40
+static sr_core_ert_t _sr_core_ert_list;
41
+
42
+/**
43
+ *
44
+ */
45
+void sr_core_ert_init(void)
46
+{
47
+	memset(&_sr_core_ert_list, 0, sizeof(sr_core_ert_t));
48
+	/* 0 - is not a valid index in event_route blocks list */
49
+	_sr_core_ert_list.init_parse_error = route_get(&event_rt,
50
+											"core:receive-parse-error");
51
+	if(_sr_core_ert_list.init_parse_error>=0
52
+			&& event_rt.rlist[_sr_core_ert_list.init_parse_error]!=NULL) {
53
+		_sr_core_ert_list.init_parse_error = -1;
54
+	}
55
+}
56
+
57
+/**
58
+ *
59
+ */
60
+void sr_core_ert_run(sip_msg_t *msg, int e)
61
+{
62
+	switch(e) {
63
+		case SR_CORE_ERT_RECEIVE_PARSE_ERROR:
64
+			if(likely(_sr_core_ert_list.init_parse_error<=0))
65
+				return;
66
+		break;
67
+	}
68
+}
69
+
35 70
 /**
36 71
  *
37 72
  */
Browse code

core: removed STUN from core

- Added hooks so that STUN messages can be passed to a module
- Removed STUN configuration file parameters

Peter Dunkley authored on 29/03/2013 21:47:57
Showing 1 changed files
... ...
@@ -106,6 +106,11 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
106 106
 					_sr_events_list.tcp_ws_frame_out = f;
107 107
 				else return -1;
108 108
 			break;
109
+		case SREV_STUN_IN:
110
+				if(_sr_events_list.stun_in==0)
111
+					_sr_events_list.stun_in = f;
112
+				else return -1;
113
+			break;
109 114
 		default:
110 115
 			return -1;
111 116
 	}
... ...
@@ -209,6 +214,12 @@ int sr_event_exec(int type, void *data)
209 214
 					ret = _sr_events_list.tcp_ws_frame_out(data);
210 215
 					return ret;
211 216
 				} else return 1;
217
+		case SREV_STUN_IN:
218
+				if(unlikely(_sr_events_list.stun_in!=0))
219
+				{
220
+					ret = _sr_events_list.stun_in(data);
221
+					return ret;
222
+				} else return 1;
212 223
 		default:
213 224
 			return -1;
214 225
 	}
... ...
@@ -242,6 +253,8 @@ int sr_event_enabled(int type)
242 253
 				return (_sr_events_list.tcp_ws_frame_in!=0)?1:0;