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,569 +0,0 @@
1
-/*
2
- * route structures helping functions
3
- *
4
- * Copyright (C) 2001-2003 FhG Fokus
5
- *
6
- * This file is part of Kamailio, a free SIP server.
7
- *
8
- * Kamailio is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
- */
22
-
23
-/*!
24
- * \file
25
- * \brief Kamailio core :: route structures helping functions
26
- * \ingroup core
27
- * Module: \ref core
28
- */
29
-
30
-
31
-
32
-#include  "route_struct.h"
33
-
34
-#include <stdio.h>
35
-#include <stdlib.h>
36
-#include <string.h>
37
-#include <stdarg.h>
38
-
39
-#include "dprint.h"
40
-#include "ip_addr.h"
41
-#include "mem/mem.h"
42
-#include "usr_avp.h"
43
-#include "ut.h" /* ZSW() */
44
-
45
-
46
-
47
-/** joins to cfg file positions into a new one. */
48
-void cfg_pos_join(struct cfg_pos* res,
49
-							struct cfg_pos* pos1, struct cfg_pos* pos2)
50
-{
51
-	struct cfg_pos ret;
52
-	ret=*pos1;
53
-	if ((ret.s_line == 0) || (ret.s_line > pos2->s_line)){
54
-		ret.s_line=pos2->s_line;
55
-		ret.s_col=pos2->s_col;
56
-	}else if ((ret.s_line == pos2->s_line) && (ret.s_col > pos2->s_col)){
57
-		ret.s_col=pos2->s_col;
58
-	}
59
-	if ((ret.e_line == 0) || (ret.e_line < pos2->e_line)){
60
-		ret.e_line=pos2->e_line;
61
-		ret.e_col=pos2->e_col;
62
-	}else if ((ret.e_line == pos2->e_line) && (ret.e_col < pos2->e_col)){
63
-		ret.e_col=pos2->e_col;
64
-	}
65
-	*res=ret;
66
-}
67
-
68
-
69
-
70
-struct expr* mk_exp(int op, struct expr* left, struct expr* right)
71
-{
72
-	struct expr * e;
73
-	e=(struct expr*)pkg_malloc(sizeof (struct expr));
74
-	if (e==0) goto error;
75
-	e->type=EXP_T;
76
-	e->op=op;
77
-	e->l.expr=left;
78
-	e->r.expr=right;
79
-	return e;
80
-error:
81
-	LM_CRIT("memory allocation failure\n");
82
-	return 0;
83
-}
84
-
85
-
86
-struct expr* mk_elem(int op, expr_l_type ltype, void* lparam,
87
-							 expr_r_type rtype, void* rparam)
88
-{
89
-	struct expr * e;
90
-	e=(struct expr*)pkg_malloc(sizeof (struct expr));
91
-	if (e==0) goto error;
92
-	e->type=ELEM_T;
93
-	e->op=op;
94
-	e->l_type=ltype;
95
-	e->l.param=lparam;
96
-	e->r_type = rtype;
97
-	e->r.param=rparam;
98
-	return e;
99
-error:
100
-	LM_CRIT("memory allocation failure\n");
101
-	return 0;
102
-}
103
-
104
-
105
-/** create an action structure (parser use).
106
- * @param type - type of the action
107
- * @param count - count of couples {param_type,val}
108
- * @param ... -   count {param_type, val} pairs, where param_type is
109
- *                action_param_type.
110
- * @return  new action structure on success (pkg_malloc'ed) or 0 on error.
111
- */
112
-struct action* mk_action(enum action_type type, int count, ...)
113
-{
114
-	va_list args;
115
-	int i;
116
-	struct action* a;
117
-
118
-	a = (struct action*)pkg_malloc(sizeof(struct action));
119
-	if (a==0) goto  error;
120
-	memset(a, 0, sizeof(struct action));
121
-	a->type=type;
122
-	a->count = (count > MAX_ACTIONS)?MAX_ACTIONS:count;
123
-
124
-	va_start(args, count);
125
-	for (i=0; i<a->count; i++) {
126
-		a->val[i].type = va_arg(args, int);
127
-		a->val[i].u.data = va_arg(args, void *);
128
-
129
-		DBG("ACTION_#%d #%d/%d: %d(%x)/ %p\n", a->type, i, a->count, a->val[i].type, a->val[i].type, a->val[i].u.data);
130
-	}
131
-	va_end(args);
132
-
133
-	a->next=0;
134
-	return a;
135
-
136
-error:
137
-	LM_CRIT("memory allocation failure\n");
138
-	return 0;
139
-}
140
-
141
-
142
-struct action* append_action(struct action* a, struct action* b)
143
-{
144
-	struct action *t;
145
-	if (b==0) return a;
146
-	if (a==0) return b;
147
-
148
-	for(t=a; t->next; t=t->next);
149
-	t->next=b;
150
-	return a;
151
-}
152
-
153
-
154
-
155
-void print_expr(struct expr* exp)
156
-{
157
-	if (exp==0){
158
-		LM_CRIT("null expression!\n");
159
-		return;
160
-	}
161
-	if (exp->type==ELEM_T){
162
-		switch(exp->l_type){
163
-			case METHOD_O:
164
-				DBG("method");
165
-				break;
166
-			case URI_O:
167
-				DBG("uri");
168
-				break;
169
-			case FROM_URI_O:
170
-				DBG("from_uri");
171
-				break;
172
-			case TO_URI_O:
173
-				DBG("to_uri");
174
-				break;
175
-			case SRCIP_O:
176
-				DBG("srcip");
177
-				break;
178
-			case SRCPORT_O:
179
-				DBG("srcport");
180
-				break;
181
-			case DSTIP_O:
182
-				DBG("dstip");
183
-				break;
184
-			case DSTPORT_O:
185
-				DBG("dstport");
186
-				break;
187
-			case PROTO_O:
188
-				DBG("proto");
189
-				break;
190
-			case AF_O:
191
-				DBG("af");
192
-				break;
193
-			case MSGLEN_O:
194
-				DBG("msglen");
195
-				break;
196
-			case ACTION_O:
197
-				break;
198
-			case NUMBER_O:
199
-				break;
200
-			case AVP_O:
201
-				DBG("avp");
202
-				break;
203
-			case SNDIP_O:
204
-				DBG("sndip");
205
-				break;
206
-			case SNDPORT_O:
207
-				DBG("sndport");
208
-				break;
209
-			case TOIP_O:
210
-				DBG("toip");
211
-				break;
212
-			case TOPORT_O:
213
-				DBG("toport");
214
-				break;
215
-			case SNDPROTO_O:
216
-				DBG("sndproto");
217
-				break;
218
-			case SNDAF_O:
219
-				DBG("sndaf");
220
-				break;
221
-			case RETCODE_O:
222
-				DBG("retcode");
223
-				break;
224
-			case SELECT_O:
225
-				DBG("select");
226
-				break;
227
-			case RVEXP_O:
228
-				DBG("rval");
229
-				break;
230
-
231
-			default:
232
-				DBG("UNKNOWN");
233
-		}
234
-		switch(exp->op){
235
-			case EQUAL_OP:
236
-				DBG("==");
237
-				break;
238
-			case MATCH_OP:
239
-				DBG("=~");
240
-				break;
241
-			case NO_OP:
242
-				break;
243
-			case GT_OP:
244
-				DBG(">");
245
-				break;
246
-			case GTE_OP:
247
-				DBG(">=");
248
-				break;
249
-			case LT_OP:
250
-				DBG("<");
251
-				break;
252
-			case LTE_OP:
253
-				DBG("<=");
254
-				break;
255
-			case DIFF_OP:
256
-				DBG("!=");
257
-				break;
258
-			default:
259
-				DBG("<UNKNOWN>");
260
-		}
261
-		switch(exp->r_type){
262
-			case NOSUBTYPE:
263
-					DBG("N/A");
264
-					break;
265
-			case STRING_ST:
266
-					DBG("\"%s\"", ZSW((char*)exp->r.param));
267
-					break;
268
-			case NET_ST:
269
-					print_net((struct net*)exp->r.param);
270
-					break;
271
-			case IP_ST:
272
-					print_ip("", (struct ip_addr*)exp->r.param, "");
273
-					break;
274
-			case ACTIONS_ST:
275
-					print_actions((struct action*)exp->r.param);
276
-					break;
277
-			case NUMBER_ST:
278
-					DBG("%ld",exp->r.numval);
279
-					break;
280
-			case MYSELF_ST:
281
-					DBG("_myself_");
282
-					break;
283
-		        case AVP_ST:
284
-				        DBG("attr");
285
-			 	        break;
286
-		        case SELECT_ST:
287
-				        DBG("select");
288
-				        break;
289
-			default:
290
-					DBG("type<%d>", exp->r_type);
291
-		}
292
-	}else if (exp->type==EXP_T){
293
-		switch(exp->op){
294
-			case LOGAND_OP:
295
-					DBG("AND( ");
296
-					print_expr(exp->l.expr);
297
-					DBG(", ");
298
-					print_expr(exp->r.expr);
299
-					DBG(" )");
300
-					break;
301
-			case LOGOR_OP:
302
-					DBG("OR( ");
303
-					print_expr(exp->l.expr);
304
-					DBG(", ");
305
-					print_expr(exp->r.expr);
306
-					DBG(" )");
307
-					break;
308
-			case NOT_OP:
309
-					DBG("NOT( ");
310
-					print_expr(exp->l.expr);
311
-					DBG(" )");
312
-					break;
313
-			default:
314
-					DBG("UNKNOWN_EXP ");
315
-		}
316
-
317
-	}else{
318
-		DBG("ERROR:print_expr: unknown type\n");
319
-	}
320
-}
321
-
322
-
323
-
324
-
325
-void print_action(struct action* t)
326
-{
327
-	switch(t->type){
328
-		case FORWARD_T:
329
-			DBG("forward(");
330
-			break;
331
-		case FORWARD_TCP_T:
332
-			DBG("forward_tcp(");
333
-			break;
334
-		case FORWARD_UDP_T:
335
-			DBG("forward_udp(");
336
-			break;
337
-		case DROP_T:
338
-			DBG("drop(");
339
-			break;
340
-		case LOG_T:
341
-			DBG("log(");
342
-			break;
343
-		case ERROR_T:
344
-			DBG("error(");
345
-			break;
346
-		case ROUTE_T:
347
-			DBG("route(");
348
-			break;
349
-		case EXEC_T:
350
-			DBG("exec(");
351
-			break;
352
-		case REVERT_URI_T:
353
-			DBG("revert_uri(");
354
-			break;
355
-		case STRIP_T:
356
-			DBG("strip(");
357
-			break;
358
-		case APPEND_BRANCH_T:
359
-			DBG("append_branch(");
360
-			break;
361
-		case PREFIX_T:
362
-			DBG("prefix(");
363
-			break;
364
-		case LEN_GT_T:
365
-			DBG("len_gt(");
366
-			break;
367
-		case SETFLAG_T:
368
-			DBG("setflag(");
369
-			break;
370
-		case RESETFLAG_T:
371
-			DBG("resetflag(");
372
-			break;
373
-		case ISFLAGSET_T:
374
-			DBG("isflagset(");
375
-			break;
376
-		case AVPFLAG_OPER_T:
377
-			DBG("avpflagoper(");
378
-			break;
379
-		case SET_HOST_T:
380
-			DBG("sethost(");
381
-			break;
382
-		case SET_HOSTPORT_T:
383
-			DBG("sethostport(");
384
-			break;
385
-		case SET_HOSTPORTTRANS_T:
386
-			DBG("sethostporttrans(");
387
-			break;
388
-		case SET_USER_T:
389
-			DBG("setuser(");
390
-			break;
391
-		case SET_USERPASS_T:
392
-			DBG("setuserpass(");
393
-			break;
394
-		case SET_PORT_T:
395
-			DBG("setport(");
396
-			break;
397
-		case SET_URI_T:
398
-			DBG("seturi(");
399
-			break;
400
-		case IF_T:
401
-			DBG("if (");
402
-			break;
403
-		case MODULE0_T:
404
-		case MODULE1_T:
405
-		case MODULE2_T:
406
-		case MODULE3_T:
407
-		case MODULE4_T:
408
-		case MODULE5_T:
409
-		case MODULE6_T:
410
-		case MODULEX_T:
411
-		case MODULE1_RVE_T:
412
-		case MODULE2_RVE_T:
413
-		case MODULE3_RVE_T:
414
-		case MODULE4_RVE_T:
415
-		case MODULE5_RVE_T:
416
-		case MODULE6_RVE_T:
417
-		case MODULEX_RVE_T:
418
-			DBG(" external_module_call(");
419
-			break;
420
-		case FORCE_RPORT_T:
421
-			DBG("force_rport(");
422
-			break;
423
-		case SET_ADV_ADDR_T:
424
-			DBG("set_advertised_address(");
425
-			break;
426
-		case SET_ADV_PORT_T:
427
-			DBG("set_advertised_port(");
428
-			break;
429
-		case FORCE_TCP_ALIAS_T:
430
-			DBG("force_tcp_alias(");
431
-			break;
432
-		case LOAD_AVP_T:
433
-			DBG("load_avp(");
434
-			break;
435
-		case AVP_TO_URI_T:
436
-			DBG("avp_to_attr");
437
-			break;
438
-		case FORCE_SEND_SOCKET_T:
439
-			DBG("force_send_socket");
440
-			break;
441
-		case ASSIGN_T
442
-	:		DBG("assign(");
443
-			break;
444
-		case ADD_T:
445
-			DBG("assign_add(");
446
-			break;
447
-		default:
448
-			DBG("UNKNOWN(");
449
-	}
450
-	switch(t->val[0].type){
451
-		case STRING_ST:
452
-			DBG("\"%s\"", ZSW(t->val[0].u.string));
453
-			break;
454
-		case NUMBER_ST:
455
-			DBG("%lu",t->val[0].u.number);
456
-			break;
457
-		case IP_ST:
458
-			print_ip("", (struct ip_addr*)t->val[0].u.data, "");
459
-			break;
460
-		case EXPR_ST:
461
-			print_expr((struct expr*)t->val[0].u.data);
462
-			break;
463
-		case ACTIONS_ST:
464
-			print_actions((struct action*)t->val[0].u.data);
465
-			break;
466
-		case MODEXP_ST:
467
-			DBG("f_ptr<%p>",t->val[0].u.data);
468
-			break;
469
-		case SOCKID_ST:
470
-			DBG("%d:%s:%d",
471
-			((struct socket_id*)t->val[0].u.data)->proto,
472
-			ZSW(((struct socket_id*)t->val[0].u.data)->addr_lst->name),
473
-			((struct socket_id*)t->val[0].u.data)->port
474
-			);
475
-			break;
476
-		case AVP_ST:
477
-			DBG("avp(%u,%.*s)", t->val[0].u.attr->type, t->val[0].u.attr->name.s.len, ZSW(t->val[0].u.attr->name.s.s));
478
-			break;
479
-		case SELECT_ST:
480
-			DBG("select");
481
-			break;
482
-		default:
483
-			DBG("type<%d>", t->val[0].type);
484
-	}
485
-	if (t->type==IF_T) DBG(") {");
486
-	switch(t->val[1].type){
487
-		case NOSUBTYPE:
488
-			break;
489
-		case STRING_ST:
490
-			DBG(", \"%s\"", ZSW(t->val[1].u.string));
491
-			break;
492
-		case NUMBER_ST:
493
-			DBG(", %lu",t->val[1].u.number);
494
-			break;
495
-		case EXPR_ST:
496
-			print_expr((struct expr*)t->val[1].u.data);
497
-			break;
498
-		case ACTION_ST:
499
-		case ACTIONS_ST:
500
-			print_actions((struct action*)t->val[1].u.data);
501
-			break;
502
-
503
-		case SOCKID_ST:
504
-			DBG("%d:%s:%d",
505
-			((struct socket_id*)t->val[0].u.data)->proto,
506
-			ZSW(((struct socket_id*)t->val[0].u.data)->addr_lst->name),
507
-			((struct socket_id*)t->val[0].u.data)->port
508
-			);
509
-			break;
510
-		case AVP_ST:
511
-			DBG(", avp(%u,%.*s)", t->val[1].u.attr->type, t->val[1].u.attr->name.s.len, ZSW(t->val[1].u.attr->name.s.s));
512
-			break;
513
-		case SELECT_ST:
514
-			DBG("select");
515
-			break;
516
-		default:
517
-			DBG(", type<%d>", t->val[1].type);
518
-	}
519
-	if (t->type==IF_T) DBG("} else {");
520
-	switch(t->val[2].type){
521
-		case NOSUBTYPE:
522
-			break;
523
-		case STRING_ST:
524
-			DBG(", \"%s\"", ZSW(t->val[2].u.string));
525
-			break;
526
-		case NUMBER_ST:
527
-			DBG(", %lu",t->val[2].u.number);
528
-			break;
529
-		case EXPR_ST:
530
-			print_expr((struct expr*)t->val[2].u.data);
531
-			break;
532
-		case ACTIONS_ST:
533
-			print_actions((struct action*)t->val[2].u.data);
534
-			break;
535
-		case SOCKID_ST:
536
-			DBG("%d:%s:%d",
537
-			((struct socket_id*)t->val[0].u.data)->proto,
538
-			ZSW(((struct socket_id*)t->val[0].u.data)->addr_lst->name),
539
-			((struct socket_id*)t->val[0].u.data)->port
540
-			);
541
-			break;
542
-		default:
543
-			DBG(", type<%d>", t->val[2].type);
544
-	}
545
-	if (t->type==IF_T) DBG("}; ");
546
-		else	DBG("); ");
547
-}
548
-
549
-void print_actions(struct action* a)
550
-{
551
-	while(a) {
552
-		print_action(a);
553
-		a = a->next;
554
-	}
555
-}
556
-
557
-/**
558
- * get the pointer to action structure from parameter
559
- */
560
-struct action *get_action_from_param(void **param, int param_no)
561
-{
562
-	struct action *ac, ac2;
563
-	action_u_t *au, au2;
564
-	/* param points to au->u.string, get pointer to au */
565
-	au = (void*) ((char *)param - ((char *)&au2.u.string-(char *)&au2));
566
-	au = au - 1 - param_no;
567
-	ac = (void*) ((char *)au - ((char *)&ac2.val-(char *)&ac2));
568
-	return ac;
569
-}
Browse code

core: Modify doxygen, remove history, remove SVN IDs, change "ser" and "sip-router" to "KAMAILIO"

Olle E. Johansson authored on 16/01/2015 16:38:46
Showing 1 changed files
... ...
@@ -22,7 +22,7 @@
22 22
 
23 23
 /*!
24 24
  * \file
25
- * \brief SIP-router core :: route structures helping functions
25
+ * \brief Kamailio core :: route structures helping functions
26 26
  * \ingroup core
27 27
  * Module: \ref core
28 28
  */
Browse code

core: removed unused code

- removes also some clang compile warnings

Daniel-Constantin Mierla authored on 11/01/2015 15:51:36
Showing 1 changed files
... ...
@@ -83,27 +83,6 @@ error:
83 83
 }
84 84
 
85 85
 
86
-struct expr* mk_exp_rve(int op, void* left, void* right)
87
-{
88
-	struct expr * e;
89
-	e=(struct expr*)pkg_malloc(sizeof (struct expr));
90
-	if (e==0) goto error;
91
-	e->type=EXP_T;
92
-	e->op=op;
93
-	e->l.param=mk_elem(RVEXP_O, RVE_ST, left, 0, 0);
94
-	e->r.param=mk_elem(RVEXP_O, RVE_ST, right, 0, 0);
95
-	if (e->l.param==0 || e->r.param==0){
96
-		if (e->l.param) pkg_free(e->l.param);
97
-		if (e->r.param) pkg_free(e->r.param);
98
-		pkg_free(e);
99
-		goto error;
100
-	}
101
-	return e;
102
-error:
103
-	LM_CRIT("memory allocation failure\n");
104
-	return 0;
105
-}
106
-
107 86
 struct expr* mk_elem(int op, expr_l_type ltype, void* lparam,
108 87
 							 expr_r_type rtype, void* rparam)
109 88
 {
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
... ...
@@ -10,11 +10,6 @@
10 10
  * the Free Software Foundation; either version 2 of the License, or
11 11
  * (at your option) any later version
12 12
  *
13
- * For a license to use the ser software under conditions
14
- * other than those described here, or to purchase support for this
15
- * software, please contact iptel.org by e-mail at the following addresses:
16
- *    info@iptel.org
17
- *
18 13
  * Kamailio is distributed in the hope that it will be useful,
19 14
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
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,13 +1,11 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * route structures helping functions
5 3
  *
6 4
  * Copyright (C) 2001-2003 FhG Fokus
7 5
  *
8
- * This file is part of ser, a free SIP server.
6
+ * This file is part of Kamailio, a free SIP server.
9 7
  *
10
- * ser is free software; you can redistribute it and/or modify
8
+ * Kamailio is free software; you can redistribute it and/or modify
11 9
  * it under the terms of the GNU General Public License as published by
12 10
  * the Free Software Foundation; either version 2 of the License, or
13 11
  * (at your option) any later version
... ...
@@ -17,7 +15,7 @@
17 15
  * software, please contact iptel.org by e-mail at the following addresses:
18 16
  *    info@iptel.org
19 17
  *
20
- * ser is distributed in the hope that it will be useful,
18
+ * Kamailio is distributed in the hope that it will be useful,
21 19
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 20
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 21
  * GNU General Public License for more details.
... ...
@@ -26,19 +24,10 @@
26 24
  * along with this program; if not, write to the Free Software
27 25
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28 26
  */
29
-/* History:
30
- * --------
31
- *  2003-01-29  src_port introduced (jiri)
32
- *  2003-03-19  replaced all mallocs/frees w/ pkg_malloc/pkg_free (andrei)
33
- *  2003-04-12  FORCE_RPORT_T added (andrei)
34
- *  2003-10-02  added SET_ADV_ADDRESS & SET_ADV_PORT (andrei)
35
- *  2004-02-24  added LOAD_AVP_T and AVP_TO_URI_T (bogdan)
36
- *  2005-12-19  select framework added SELECT_O and SELECT_ST (mma)
37
- */
38 27
 
39 28
 /*!
40 29
  * \file
41
- * \brief SIP-router core :: 
30
+ * \brief SIP-router core :: route structures helping functions
42 31
  * \ingroup core
43 32
  * Module: \ref core
44 33
  */
Browse code

route_struct.c: logging: convert LOG to LM_*

Ovidiu Sas authored on 03/10/2014 21:26:34
Showing 1 changed files
... ...
@@ -94,7 +94,7 @@ struct expr* mk_exp(int op, struct expr* left, struct expr* right)
94 94
 	e->r.expr=right;
95 95
 	return e;
96 96
 error:
97
-	LOG(L_CRIT, "ERROR: mk_exp: memory allocation failure\n");
97
+	LM_CRIT("memory allocation failure\n");
98 98
 	return 0;
99 99
 }
100 100
 
... ...
@@ -116,7 +116,7 @@ struct expr* mk_exp_rve(int op, void* left, void* right)
116 116
 	}
117 117
 	return e;
118 118
 error:
119
-	LOG(L_CRIT, "ERROR: mk_exp_rve: memory allocation failure\n");
119
+	LM_CRIT("memory allocation failure\n");
120 120
 	return 0;
121 121
 }
122 122
 
... ...
@@ -134,7 +134,7 @@ struct expr* mk_elem(int op, expr_l_type ltype, void* lparam,
134 134
 	e->r.param=rparam;
135 135
 	return e;
136 136
 error:
137
-	LOG(L_CRIT, "ERROR: mk_elem: memory allocation failure\n");
137
+	LM_CRIT("memory allocation failure\n");
138 138
 	return 0;
139 139
 }
140 140
 
... ...
@@ -171,7 +171,7 @@ struct action* mk_action(enum action_type type, int count, ...)
171 171
 	return a;
172 172
 
173 173
 error:
174
-	LOG(L_CRIT, "ERROR: mk_action: memory allocation failure\n");
174
+	LM_CRIT("memory allocation failure\n");
175 175
 	return 0;
176 176
 }
177 177
 
... ...
@@ -192,7 +192,7 @@ struct action* append_action(struct action* a, struct action* b)
192 192
 void print_expr(struct expr* exp)
193 193
 {
194 194
 	if (exp==0){
195
-		LOG(L_CRIT, "ERROR: print_expr: null expression!\n");
195
+		LM_CRIT("null expression!\n");
196 196
 		return;
197 197
 	}
198 198
 	if (exp->type==ELEM_T){
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -24,7 +24,7 @@
24 24
  *
25 25
  * You should have received a copy of the GNU General Public License
26 26
  * along with this program; if not, write to the Free Software
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28 28
  */
29 29
 /* History:
30 30
  * --------
Browse code

core/corex: move send()/send_tcp() to corex module

As suggested by miconda on sr-dev, move send() and send_tcp() out of core
and into the new corex module in order to make them support pseudo variables.
This changes:

- drops SEND and SEND_TCP tokens from config parser
- remove related config parser code relying on SEND_T and SEND_TCP_T
- augment corex module to provide the functions removed from core
- update corex docs

Richard Fuchs authored on 30/11/2012 19:00:09
Showing 1 changed files
... ...
@@ -371,12 +371,6 @@ void print_action(struct action* t)
371 371
 		case FORWARD_UDP_T:
372 372
 			DBG("forward_udp(");
373 373
 			break;
374
-		case SEND_T:
375
-			DBG("send(");
376
-			break;
377
-		case SEND_TCP_T:
378
-			DBG("send_tcp(");
379
-			break;
380 374
 		case DROP_T:
381 375
 			DBG("drop(");
382 376
 			break;
Browse code

core: function to return action struct from param

- moved the function from xlog module to core to be used by other
modules
- get_action_from_param(param, param_no) can return the pointer to
action structure when the pointer to pointer param and param no is
provided (like in the fixup of module functions)

Daniel-Constantin Mierla authored on 25/06/2011 19:07:31
Showing 1 changed files
... ...
@@ -596,3 +596,17 @@ void print_actions(struct action* a)
596 596
 		a = a->next;
597 597
 	}
598 598
 }
599
+
600
+/**
601
+ * get the pointer to action structure from parameter
602
+ */
603
+struct action *get_action_from_param(void **param, int param_no)
604
+{
605
+	struct action *ac, ac2;
606
+	action_u_t *au, au2;
607
+	/* param points to au->u.string, get pointer to au */
608
+	au = (void*) ((char *)param - ((char *)&au2.u.string-(char *)&au2));
609
+	au = au - 1 - param_no;
610
+	ac = (void*) ((char *)au - ((char *)&ac2.val-(char *)&ac2));
611
+	return ac;
612
+}
Browse code

core: support for expressions/variables in function parameters

- all module functions that do not have fixups can now be called
with variables, avps or expressions. They will be converted to
string, either on startup (if the expression is constant, e.g.
"a"+"b") or at runtime (if the expression is not constant, .e.g.
$a, $b+$var(foo)+"test").
E.g.: f("1+1=" + 1 + 1, "v=" + $v).
- slightly faster module function calls (eliminated some
never-triggered sanity tests).

Andrei Pelinescu-Onciul authored on 15/03/2010 19:05:49
Showing 1 changed files
... ...
@@ -443,12 +443,21 @@ void print_action(struct action* t)
443 443
 		case IF_T:
444 444
 			DBG("if (");
445 445
 			break;
446
-		case MODULE_T:
446
+		case MODULE0_T:
447
+		case MODULE1_T:
448
+		case MODULE2_T:
447 449
 		case MODULE3_T:
448 450
 		case MODULE4_T:
449 451
 		case MODULE5_T:
450 452
 		case MODULE6_T:
451 453
 		case MODULEX_T:
454
+		case MODULE1_RVE_T:
455
+		case MODULE2_RVE_T:
456
+		case MODULE3_RVE_T:
457
+		case MODULE4_RVE_T:
458
+		case MODULE5_RVE_T:
459
+		case MODULE6_RVE_T:
460
+		case MODULEX_RVE_T:
452 461
 			DBG(" external_module_call(");
453 462
 			break;
454 463
 		case FORCE_RPORT_T:
Browse code

Adding doxygen template to all core .c files

Please fill in after the :: to explain the function of this file.

oej authored on 10/10/2009 13:54:13
Showing 1 changed files
... ...
@@ -36,6 +36,13 @@
36 36
  *  2005-12-19  select framework added SELECT_O and SELECT_ST (mma)
37 37
  */
38 38
 
39
+/*!
40
+ * \file
41
+ * \brief SIP-router core :: 
42
+ * \ingroup core
43
+ * Module: \ref core
44
+ */
45
+
39 46
 
40 47
 
41 48
 #include  "route_struct.h"
Browse code

core: script engine cleanups

Use named enums for action types, expression types, expressions
left operands, expression right operands and action parameter
types. This should avoid future type mismatching bugs (like trying
to compare a left expr. operand type with a type that can exist
only on the right part) by triggering compile time warnings.
For extra protection the expression left operands and right
operands possible value do not overlap anymore.

Andrei Pelinescu-Onciul authored on 18/07/2009 09:05:05
Showing 1 changed files
... ...
@@ -113,7 +113,8 @@ error:
113 113
 	return 0;
114 114
 }
115 115
 
116
-struct expr* mk_elem(int op, int ltype, void* lparam, int rtype, void* rparam)
116
+struct expr* mk_elem(int op, expr_l_type ltype, void* lparam,
117
+							 expr_r_type rtype, void* rparam)
117 118
 {
118 119
 	struct expr * e;
119 120
 	e=(struct expr*)pkg_malloc(sizeof (struct expr));
... ...
@@ -131,7 +132,15 @@ error:
131 132
 }
132 133
 
133 134
 
134
-struct action* mk_action(int type, int count/* of couples {type,val} */, .../* int type1, void *val1 [, int type2, void *val2, ...] */) {
135
+/** create an action structure (parser use).
136
+ * @param type - type of the action
137
+ * @param count - count of couples {param_type,val}
138
+ * @param ... -   count {param_type, val} pairs, where param_type is
139
+ *                action_param_type.
140
+ * @return  new action structure on success (pkg_malloc'ed) or 0 on error.
141
+ */
142
+struct action* mk_action(enum action_type type, int count, ...)
143
+{
135 144
 	va_list args;
136 145
 	int i;
137 146
 	struct action* a;
Browse code

script parsing: helper function updated & moved

- helper function for computing the file position of an expression

Andrei Pelinescu-Onciul authored on 19/12/2008 13:20:41
Showing 1 changed files
... ...
@@ -52,6 +52,30 @@
52 52
 #include "ut.h" /* ZSW() */
53 53
 
54 54
 
55
+
56
+/** joins to cfg file positions into a new one. */
57
+void cfg_pos_join(struct cfg_pos* res,
58
+							struct cfg_pos* pos1, struct cfg_pos* pos2)
59
+{
60
+	struct cfg_pos ret;
61
+	ret=*pos1;
62
+	if ((ret.s_line == 0) || (ret.s_line > pos2->s_line)){
63
+		ret.s_line=pos2->s_line;
64
+		ret.s_col=pos2->s_col;
65
+	}else if ((ret.s_line == pos2->s_line) && (ret.s_col > pos2->s_col)){
66
+		ret.s_col=pos2->s_col;
67
+	}
68
+	if ((ret.e_line == 0) || (ret.e_line < pos2->e_line)){
69
+		ret.e_line=pos2->e_line;
70
+		ret.e_col=pos2->e_col;
71
+	}else if ((ret.e_line == pos2->e_line) && (ret.e_col < pos2->e_col)){
72
+		ret.e_col=pos2->e_col;
73
+	}
74
+	*res=ret;
75
+}
76
+
77
+
78
+
55 79
 struct expr* mk_exp(int op, struct expr* left, struct expr* right)
56 80
 {
57 81
 	struct expr * e;
Browse code

script engine: rvalue support in logical expr.

- hard coded expressions elements (e.g. method==xxx) support now
rvalues as operands (e.g. uri=="sip:"+$a)
- small cleanups

Andrei Pelinescu-Onciul authored on 09/12/2008 15:15:21
Showing 1 changed files
... ...
@@ -68,6 +68,27 @@ error:
68 68
 }
69 69
 
70 70
 
71
+struct expr* mk_exp_rve(int op, void* left, void* right)
72
+{
73
+	struct expr * e;
74
+	e=(struct expr*)pkg_malloc(sizeof (struct expr));
75
+	if (e==0) goto error;
76
+	e->type=EXP_T;
77
+	e->op=op;
78
+	e->l.param=mk_elem(RVEXP_O, RVE_ST, left, 0, 0);
79
+	e->r.param=mk_elem(RVEXP_O, RVE_ST, right, 0, 0);
80
+	if (e->l.param==0 || e->r.param==0){
81
+		if (e->l.param) pkg_free(e->l.param);
82
+		if (e->r.param) pkg_free(e->r.param);
83
+		pkg_free(e);
84
+		goto error;
85
+	}
86
+	return e;
87
+error:
88
+	LOG(L_CRIT, "ERROR: mk_exp_rve: memory allocation failure\n");
89
+	return 0;
90
+}
91
+
71 92
 struct expr* mk_elem(int op, int ltype, void* lparam, int rtype, void* rparam)
72 93
 {
73 94
 	struct expr * e;
... ...
@@ -160,15 +181,48 @@ void print_expr(struct expr* exp)
160 181
 			case DSTPORT_O:
161 182
 				DBG("dstport");
162 183
 				break;
163
-			case NUMBER_O:
184
+			case PROTO_O:
185
+				DBG("proto");
186
+				break;
187
+			case AF_O:
188
+				DBG("af");
189
+				break;
190
+			case MSGLEN_O:
191
+				DBG("msglen");
164 192
 				break;
165 193
 			case ACTION_O:
166 194
 				break;
167
-		        case AVP_ST:
168
-				DBG("attr");
195
+			case NUMBER_O:
169 196
 				break;
170
-		        case SELECT_ST:
171
-			        DBG("select");
197
+			case AVP_O:
198
+				DBG("avp");