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,119 +0,0 @@
1
-/*
2
- * Copyright (C) 2005 iptelorg GmbH
3
- *
4
- * This file is part of Kamailio, a free SIP server.
5
- *
6
- * Kamailio is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version
10
- *
11
- * Kamailio is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
- */
20
-/*!
21
- * \file
22
- * \brief Kamailio core :: IP address handling
23
- * \author andrei
24
- * \ingroup core
25
- * Module: \ref core
26
- */
27
-
28
-#ifndef onsend_h
29
-#define onsend_h
30
-
31
-
32
-#include "ip_addr.h"
33
-#include "action.h"
34
-#include "route.h"
35
-#include "script_cb.h"
36
-#include "sr_compat.h"
37
-#include "kemi.h"
38
-
39
-struct onsend_info{
40
-	union sockaddr_union* to;       /* dest info */
41
-	struct socket_info* send_sock;  /* local send socket */
42
-	char* buf;                      /* outgoing buffer */
43
-	int len;                        /* outgoing buffer len */
44
-	sip_msg_t *msg;                 /* original sip msg struct */
45
-};
46
-
47
-extern struct onsend_info* p_onsend;
48
-
49
-
50
-#define get_onsend_info()	(p_onsend)
51
-
52
-/*
53
- * returns: 0 drop the message, >= ok, <0 error (but forward the message)
54
- * it also migh change dst->send_flags!
55
- * WARNING: buf must be 0 terminated (to allow regex matches on it) */
56
-static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
57
-								char* buf, int len)
58
-{
59
-	struct onsend_info onsnd_info = {0};
60
-	int ret;
61
-	struct run_act_ctx ra_ctx;
62
-	struct run_act_ctx *bctx;
63
-	int backup_route_type;
64
-	snd_flags_t fwd_snd_flags_bak;
65
-	snd_flags_t rpl_snd_flags_bak;
66
-	sr_kemi_eng_t *keng = NULL;
67
-
68
-	if(orig_msg==NULL || dst==NULL || buf==NULL) {
69
-		LM_DBG("required parameters are not available - ignoring\n");
70
-		return 1;
71
-	}
72
-	ret=1;
73
-	if (onsend_rt.rlist[DEFAULT_RT]){
74
-		onsnd_info.to=&dst->to;
75
-		onsnd_info.send_sock=dst->send_sock;
76
-		onsnd_info.buf=buf;
77
-		onsnd_info.len=len;
78
-		onsnd_info.msg=orig_msg;
79
-		p_onsend=&onsnd_info;
80
-		backup_route_type=get_route_type();
81
-		set_route_type(ONSEND_ROUTE);
82
-		if (exec_pre_script_cb(orig_msg, ONSEND_CB_TYPE)>0) {
83
-			/* backup orig_msg send flags */
84
-			fwd_snd_flags_bak=orig_msg->fwd_send_flags;
85
-			rpl_snd_flags_bak=orig_msg->rpl_send_flags;
86
-			orig_msg->fwd_send_flags=dst->send_flags; /* intial value */
87
-			init_run_actions_ctx(&ra_ctx);
88
-
89
-			keng = sr_kemi_eng_get();
90
-			if(unlikely(keng!=NULL)) {
91
-				bctx = sr_kemi_act_ctx_get();
92
-				sr_kemi_act_ctx_set(&ra_ctx);
93
-				ret=keng->froute(orig_msg, ONSEND_ROUTE, NULL, NULL);
94
-				sr_kemi_act_ctx_set(bctx);
95
-			} else {
96
-				ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
97
-			}
98
-
99
-			/* update dst send_flags */
100
-			dst->send_flags=orig_msg->fwd_send_flags;
101
-			/* restore orig_msg flags */
102
-			orig_msg->fwd_send_flags=fwd_snd_flags_bak;
103
-			orig_msg->rpl_send_flags=rpl_snd_flags_bak;
104
-			exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
105
-			if((ret==0) && !(ra_ctx.run_flags&DROP_R_F)){
106
-				ret = 1;
107
-			}
108
-		} else {
109
-			ret=0; /* drop the message */
110
-		}
111
-		set_route_type(backup_route_type);
112
-		p_onsend=0; /* reset it */
113
-	}
114
-	return ret;
115
-}
116
-
117
-#define onsend_route_enabled(rtype) (onsend_rt.rlist[DEFAULT_RT]?((rtype==SIP_REPLY)?onsend_route_reply:1):0)
118
-
119
-#endif
Browse code

core: check required parameters for execution of onsend_route

- alternative to GH #861

Daniel-Constantin Mierla authored on 16/11/2016 15:31:20
Showing 1 changed files
... ...
@@ -65,6 +65,10 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
65 65
 	snd_flags_t rpl_snd_flags_bak;
66 66
 	sr_kemi_eng_t *keng = NULL;
67 67
 
68
+	if(orig_msg==NULL || dst==NULL || buf==NULL) {
69
+		LM_DBG("required parameters are not available - ignoring\n");
70
+		return 1;
71
+	}
68 72
 	ret=1;
69 73
 	if (onsend_rt.rlist[DEFAULT_RT]){
70 74
 		onsnd_info.to=&dst->to;
Browse code

core: updates to kemi callbacks for core routing blocks

Daniel-Constantin Mierla authored on 14/11/2016 09:30:41
Showing 1 changed files
... ...
@@ -86,7 +86,7 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
86 86
 			if(unlikely(keng!=NULL)) {
87 87
 				bctx = sr_kemi_act_ctx_get();
88 88
 				sr_kemi_act_ctx_set(&ra_ctx);
89
-				ret=keng->froute(orig_msg, ONSEND_ROUTE, NULL);
89
+				ret=keng->froute(orig_msg, ONSEND_ROUTE, NULL, NULL);
90 90
 				sr_kemi_act_ctx_set(bctx);
91 91
 			} else {
92 92
 				ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
Browse code

core: execute onsend_route callback via kemi

Daniel-Constantin Mierla authored on 15/04/2016 07:00:53
Showing 1 changed files
... ...
@@ -13,8 +13,8 @@
13 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
  * GNU General Public License for more details.
15 15
  *
16
- * You should have received a copy of the GNU General Public License 
17
- * along with this program; if not, write to the Free Software 
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 19
  */
20 20
 /*!
... ...
@@ -34,6 +34,7 @@
34 34
 #include "route.h"
35 35
 #include "script_cb.h"
36 36
 #include "sr_compat.h"
37
+#include "kemi.h"
37 38
 
38 39
 struct onsend_info{
39 40
 	union sockaddr_union* to;       /* dest info */
... ...
@@ -58,10 +59,12 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
58 59
 	struct onsend_info onsnd_info = {0};
59 60
 	int ret;
60 61
 	struct run_act_ctx ra_ctx;
62
+	struct run_act_ctx *bctx;
61 63
 	int backup_route_type;
62 64
 	snd_flags_t fwd_snd_flags_bak;
63 65
 	snd_flags_t rpl_snd_flags_bak;
64
-	
66
+	sr_kemi_eng_t *keng = NULL;
67
+
65 68
 	ret=1;
66 69
 	if (onsend_rt.rlist[DEFAULT_RT]){
67 70
 		onsnd_info.to=&dst->to;
... ...
@@ -78,7 +81,17 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
78 81
 			rpl_snd_flags_bak=orig_msg->rpl_send_flags;
79 82
 			orig_msg->fwd_send_flags=dst->send_flags; /* intial value */
80 83
 			init_run_actions_ctx(&ra_ctx);
81
-			ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
84
+
85
+			keng = sr_kemi_eng_get();
86
+			if(unlikely(keng!=NULL)) {
87
+				bctx = sr_kemi_act_ctx_get();
88
+				sr_kemi_act_ctx_set(&ra_ctx);
89
+				ret=keng->froute(orig_msg, ONSEND_ROUTE, NULL);
90
+				sr_kemi_act_ctx_set(bctx);
91
+			} else {
92
+				ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
93
+			}
94
+
82 95
 			/* update dst send_flags */
83 96
 			dst->send_flags=orig_msg->fwd_send_flags;
84 97
 			/* restore orig_msg flags */
Browse code

Core Update of doxygen, removal of history, changing "ser" to "kamailio"

Olle E. Johansson authored on 03/01/2015 14:03:24
Showing 1 changed files
... ...
@@ -1,21 +1,14 @@
1 1
 /*
2
- *  $Id$
3
- *
4 2
  * Copyright (C) 2005 iptelorg GmbH
5 3
  *
6
- * This file is part of ser, a free SIP server.
4
+ * This file is part of Kamailio, a free SIP server.
7 5
  *
8
- * ser is free software; you can redistribute it and/or modify
6
+ * Kamailio is free software; you can redistribute it and/or modify
9 7
  * it under the terms of the GNU General Public License as published by
10 8
  * the Free Software Foundation; either version 2 of the License, or
11 9
  * (at your option) any later version
12 10
  *
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
- * ser is distributed in the hope that it will be useful,
11
+ * Kamailio is distributed in the hope that it will be useful,
19 12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 14
  * GNU General Public License for more details.
... ...
@@ -24,14 +17,14 @@
24 17
  * along with this program; if not, write to the Free Software 
25 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26 19
  */
27
-/*
28
- * History:
29
- * -------
30
- *  2005-12-11 created by andrei
31
- *  2009-06-01 Pre- and post-script callbacks of onsend route are executed (Miklos)
20
+/*!
21
+ * \file
22
+ * \brief Kamailio core :: IP address handling
23
+ * \author andrei
24
+ * \ingroup core
25
+ * Module: \ref core
32 26
  */
33 27
 
34
-
35 28
 #ifndef onsend_h
36 29
 #define onsend_h
37 30
 
Browse code

core: execute onsend_route for replies before sending out

- control execution of onsend_route block for replies via parameter
onsend_route_reply

Lucian Balaceanu authored on 12/10/2014 08:28:29 • Daniel-Constantin Mierla committed on 12/10/2014 08:28:29
Showing 1 changed files
... ...
@@ -104,5 +104,6 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
104 104
 	return ret;
105 105
 }
106 106
 
107
+#define onsend_route_enabled(rtype) (onsend_rt.rlist[DEFAULT_RT]?((rtype==SIP_REPLY)?onsend_route_reply:1):0)
107 108
 
108 109
 #endif
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
... ...
@@ -22,7 +22,7 @@
22 22
  *
23 23
  * You should have received a copy of the GNU General Public License 
24 24
  * along with this program; if not, write to the Free Software 
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26 26
  */
27 27
 /*
28 28
  * History:
Browse code

core: added field to link sip msg in onsend structure

- to be used when opening an ongoing stream (tcp/tls) connection

Daniel-Constantin Mierla authored on 26/05/2014 12:13:30
Showing 1 changed files
... ...
@@ -43,10 +43,11 @@
43 43
 #include "sr_compat.h"
44 44
 
45 45
 struct onsend_info{
46
-	union sockaddr_union* to;
47
-	struct socket_info* send_sock;
48
-	char* buf;
49
-	int len;
46
+	union sockaddr_union* to;       /* dest info */
47
+	struct socket_info* send_sock;  /* local send socket */
48
+	char* buf;                      /* outgoing buffer */
49
+	int len;                        /* outgoing buffer len */
50
+	sip_msg_t *msg;                 /* original sip msg struct */
50 51
 };
51 52
 
52 53
 extern struct onsend_info* p_onsend;
... ...
@@ -61,7 +62,7 @@ extern struct onsend_info* p_onsend;
61 62
 static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
62 63
 								char* buf, int len)
63 64
 {
64
-	struct onsend_info onsnd_info;
65
+	struct onsend_info onsnd_info = {0};
65 66
 	int ret;
66 67
 	struct run_act_ctx ra_ctx;
67 68
 	int backup_route_type;
... ...
@@ -74,6 +75,7 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
74 75
 		onsnd_info.send_sock=dst->send_sock;
75 76
 		onsnd_info.buf=buf;
76 77
 		onsnd_info.len=len;
78
+		onsnd_info.msg=orig_msg;
77 79
 		p_onsend=&onsnd_info;
78 80
 		backup_route_type=get_route_type();
79 81
 		set_route_type(ONSEND_ROUTE);
Browse code

core: removed K compat mode for onsend route

- no conditions around drop flag
- part of work to remove config compat modes, as per irc devel meeting
discussions

Daniel-Constantin Mierla authored on 17/04/2010 09:56:01
Showing 1 changed files
... ...
@@ -90,8 +90,7 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
90 90
 			orig_msg->fwd_send_flags=fwd_snd_flags_bak;
91 91
 			orig_msg->rpl_send_flags=rpl_snd_flags_bak;
92 92
 			exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
93
-			if((sr_cfg_compat==SR_COMPAT_KAMAILIO)
94
-					&& (ret==0) && !(ra_ctx.run_flags&DROP_R_F)){
93
+			if((ret==0) && !(ra_ctx.run_flags&DROP_R_F)){
95 94
 				ret = 1;
96 95
 			}
97 96
 		} else {
Browse code

core: usage of drop in onsend_route for Kamailio compatibility

- in K exit and drop have different behavior in some cases
- fr onsend_route exit means stop executing the actions and drop does in
addition discard sending the message
(cherry picked from commit 8a43c6fcb21ff7aeb097b1d8791bfc3d8f020bcb)

Daniel-Constantin Mierla authored on 24/12/2009 16:11:58 • Andrei Pelinescu-Onciul committed on 01/02/2010 11:20:44
Showing 1 changed files
... ...
@@ -40,6 +40,7 @@
40 40
 #include "action.h"
41 41
 #include "route.h"
42 42
 #include "script_cb.h"
43
+#include "sr_compat.h"
43 44
 
44 45
 struct onsend_info{
45 46
 	union sockaddr_union* to;
... ...
@@ -89,6 +90,10 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
89 90
 			orig_msg->fwd_send_flags=fwd_snd_flags_bak;
90 91
 			orig_msg->rpl_send_flags=rpl_snd_flags_bak;
91 92
 			exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
93
+			if((sr_cfg_compat==SR_COMPAT_KAMAILIO)
94
+					&& (ret==0) && !(ra_ctx.run_flags&DROP_R_F)){
95
+				ret = 1;
96
+			}
92 97
 		} else {
93 98
 			ret=0; /* drop the message */
94 99
 		}
Browse code

core: send_flags support in the onsend_route

send_flags can now be set also in the onsend_route
(via set_forward_no_connect() or set_forward_close()).

E.g.:
onsend_route{
if (dsp_ip!=10.0.0.0/8)
set_forward_no_connect(); # don't open new connection,
# only reuse
}

Andrei Pelinescu-Onciul authored on 18/09/2009 18:58:20
Showing 1 changed files
... ...
@@ -55,6 +55,7 @@ extern struct onsend_info* p_onsend;
55 55
 
56 56
 /*
57 57
  * returns: 0 drop the message, >= ok, <0 error (but forward the message)
58
+ * it also migh change dst->send_flags!
58 59
  * WARNING: buf must be 0 terminated (to allow regex matches on it) */
59 60
 static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
60 61
 								char* buf, int len)
... ...
@@ -63,6 +64,8 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
63 64
 	int ret;
64 65
 	struct run_act_ctx ra_ctx;
65 66
 	int backup_route_type;
67
+	snd_flags_t fwd_snd_flags_bak;
68
+	snd_flags_t rpl_snd_flags_bak;
66 69
 	
67 70
 	ret=1;
68 71
 	if (onsend_rt.rlist[DEFAULT_RT]){
... ...
@@ -74,8 +77,17 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
74 77
 		backup_route_type=get_route_type();
75 78
 		set_route_type(ONSEND_ROUTE);
76 79
 		if (exec_pre_script_cb(orig_msg, ONSEND_CB_TYPE)>0) {
80
+			/* backup orig_msg send flags */
81
+			fwd_snd_flags_bak=orig_msg->fwd_send_flags;
82
+			rpl_snd_flags_bak=orig_msg->rpl_send_flags;
83
+			orig_msg->fwd_send_flags=dst->send_flags; /* intial value */
77 84
 			init_run_actions_ctx(&ra_ctx);
78 85
 			ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
86
+			/* update dst send_flags */
87
+			dst->send_flags=orig_msg->fwd_send_flags;
88
+			/* restore orig_msg flags */
89
+			orig_msg->fwd_send_flags=fwd_snd_flags_bak;
90
+			orig_msg->rpl_send_flags=rpl_snd_flags_bak;
79 91
 			exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
80 92
 		} else {
81 93
 			ret=0; /* drop the message */
Browse code

Merge branch 'master' into script_callbacks

* master:
route_type: branch and onsend route bugs corrected
* Commented out warning about deprecated avp name syntax. I suggest to
sl(k) - use load_tm_api()
* modules_k/textops
core: added km_parse_avp_spec()
pv: parse K-style AVP aliases
docbook: Generate TOC for root-level section elements
make: required version is now 3.81
test: gcc version test scripts
tm: doc - added note about tmx module
pua: use load_tm_api() instead of find_export()/load_tm()
kex: added K pv_printf() function
kex: added K dst uri related functions
makefile: fix last commit
* modules_k/acc: included Makefile.radius
makefile: gcc version detection fix

Conflicts:

onsend.h

Miklos Tirpak authored on 04/06/2009 07:35:00
Showing 0 changed files
Browse code

route_type: branch and onsend route bugs corrected

- Branch and onsend routes did not restore the original
route_type after they have finished the execution,
so subsequent functions that need the route_type failed.
(For example t_relay() in the second branch did not work
if branch or onsend routes of the first branch were executed.)
- get_route_type() macro added.

Miklos Tirpak authored on 03/06/2009 08:38:42
Showing 1 changed files
... ...
@@ -60,6 +60,7 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
60 60
 	struct onsend_info onsnd_info;
61 61
 	int ret;
62 62
 	struct run_act_ctx ra_ctx;
63
+	int backup_route_type;
63 64
 	
64 65
 	ret=1;
65 66
 	if (onsend_rt.rlist[DEFAULT_RT]){
... ...
@@ -68,9 +69,11 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
68 69
 		onsnd_info.buf=buf;
69 70
 		onsnd_info.len=len;
70 71
 		p_onsend=&onsnd_info;
72
+		backup_route_type=get_route_type();
71 73
 		set_route_type(ONSEND_ROUTE);
72 74
 		init_run_actions_ctx(&ra_ctx);
73 75
 		ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
76
+		set_route_type(backup_route_type);
74 77
 		p_onsend=0; /* reset it */
75 78
 	}
76 79
 	return ret;
Browse code

script callbacks: onsend_route correction

- The pre-script callbacks are executed only
if the onsend_route is defined.
- The callbacks can access the socket info.

Miklos Tirpak authored on 01/06/2009 14:33:59
Showing 1 changed files
... ...
@@ -63,22 +63,22 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
63 63
 	int ret;
64 64
 	struct run_act_ctx ra_ctx;
65 65
 
66
-	if (exec_pre_script_cb(orig_msg, ONSEND_CB_TYPE)>0) {
67
-		ret=1;
68
-		if (onsend_rt.rlist[DEFAULT_RT]){
69
-			onsnd_info.to=&dst->to;
70
-			onsnd_info.send_sock=dst->send_sock;
71
-			onsnd_info.buf=buf;
72
-			onsnd_info.len=len;
73
-			p_onsend=&onsnd_info;
74
-			set_route_type(ONSEND_ROUTE);
66
+	ret=1;
67
+	if (onsend_rt.rlist[DEFAULT_RT]){
68
+		onsnd_info.to=&dst->to;
69
+		onsnd_info.send_sock=dst->send_sock;
70
+		onsnd_info.buf=buf;
71
+		onsnd_info.len=len;
72
+		p_onsend=&onsnd_info;
73
+		set_route_type(ONSEND_ROUTE);
74
+		if (exec_pre_script_cb(orig_msg, ONSEND_CB_TYPE)>0) {
75 75
 			init_run_actions_ctx(&ra_ctx);
76 76
 			ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
77
-			p_onsend=0; /* reset it */
77
+			exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
78
+		} else {
79
+			ret=0; /* drop the message */
78 80
 		}
79
-		exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
80
-	} else {
81
-		ret = 0;
81
+		p_onsend=0; /* reset it */
82 82
 	}
83 83
 	return ret;
84 84
 }
Browse code

script callbacks: onsend route

- pre- and post-script callbacks are executed also
for onsend route

Miklos Tirpak authored on 01/06/2009 13:50:37
Showing 1 changed files
... ...
@@ -28,6 +28,7 @@
28 28
  * History:
29 29
  * -------
30 30
  *  2005-12-11 created by andrei
31
+ *  2009-06-01 Pre- and post-script callbacks of onsend route are executed (Miklos)
31 32
  */
32 33
 
33 34
 
... ...
@@ -38,6 +39,7 @@
38 39
 #include "ip_addr.h"
39 40
 #include "action.h"
40 41
 #include "route.h"
42
+#include "script_cb.h"
41 43
 
42 44
 struct onsend_info{
43 45
 	union sockaddr_union* to;
... ...
@@ -60,18 +62,23 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
60 62
 	struct onsend_info onsnd_info;
61 63
 	int ret;
62 64
 	struct run_act_ctx ra_ctx;
63
-	
64
-	ret=1;
65
-	if (onsend_rt.rlist[DEFAULT_RT]){
66
-		onsnd_info.to=&dst->to;
67
-		onsnd_info.send_sock=dst->send_sock;
68
-		onsnd_info.buf=buf;
69
-		onsnd_info.len=len;
70
-		p_onsend=&onsnd_info;
71
-		set_route_type(ONSEND_ROUTE);
72
-		init_run_actions_ctx(&ra_ctx);
73
-		ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
74
-		p_onsend=0; /* reset it */
65
+
66
+	if (exec_pre_script_cb(orig_msg, ONSEND_CB_TYPE)>0) {
67
+		ret=1;
68
+		if (onsend_rt.rlist[DEFAULT_RT]){
69
+			onsnd_info.to=&dst->to;
70
+			onsnd_info.send_sock=dst->send_sock;
71
+			onsnd_info.buf=buf;
72
+			onsnd_info.len=len;
73
+			p_onsend=&onsnd_info;
74
+			set_route_type(ONSEND_ROUTE);
75
+			init_run_actions_ctx(&ra_ctx);
76
+			ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
77
+			p_onsend=0; /* reset it */
78
+		}
79
+		exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
80
+	} else {
81
+		ret = 0;
75 82
 	}
76 83
 	return ret;
77 84
 }
Browse code

Update tm module to use and set the global route_type variable.

This patch removes the rmode variable from tm module and replaces it
with the global variable route_type defined in route.h. In addition to
that we replaced MODE_* constants with *_ROUTE (also defined in
route.h).

A variable that was once defined in the tm module is now better moved
to the core, because just the core itself without the tm module loaded
can execute two types of routes, the request route and the global
onreply route (if used).

Jan Janak authored on 07/03/2009 00:51:19
Showing 1 changed files
... ...
@@ -68,6 +68,7 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
68 68
 		onsnd_info.buf=buf;
69 69
 		onsnd_info.len=len;
70 70
 		p_onsend=&onsnd_info;
71
+		set_route_type(ONSEND_ROUTE);
71 72
 		init_run_actions_ctx(&ra_ctx);
72 73
 		ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
73 74
 		p_onsend=0; /* reset it */
Browse code

- fix: run_actions() & friends used some static variables to save some internal state (run_flags, last_ret a.s.o). Problems would appear when different routes (e.g. main route and an onsend route) would execute in the same process (e.g. an onsend route return would exit also the main route). Now run_actions(), do_action() and eval_expr() take an extra "context" parameter (which must be initialized before use).

Andrei Pelinescu-Onciul authored on 14/06/2007 23:12:26
Showing 1 changed files
... ...
@@ -59,6 +59,7 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
59 59
 {
60 60
 	struct onsend_info onsnd_info;
61 61
 	int ret;
62
+	struct run_act_ctx ra_ctx;
62 63
 	
63 64
 	ret=1;
64 65
 	if (onsend_rt.rlist[DEFAULT_RT]){
... ...
@@ -67,7 +68,8 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
67 68
 		onsnd_info.buf=buf;
68 69
 		onsnd_info.len=len;
69 70
 		p_onsend=&onsnd_info;
70
-		ret=run_actions(onsend_rt.rlist[DEFAULT_RT], orig_msg);
71
+		init_run_actions_ctx(&ra_ctx);
72
+		ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
71 73
 		p_onsend=0; /* reset it */
72 74
 	}
73 75
 	return ret;
Browse code

- msg_send(), udp_send() and tcp_send() parameter list changed (now they use a struct dest_info to pack several of the old params)

Andrei Pelinescu-Onciul authored on 12/04/2006 18:04:23
Showing 1 changed files
... ...
@@ -54,17 +54,16 @@ extern struct onsend_info* p_onsend;
54 54
 /*
55 55
  * returns: 0 drop the message, >= ok, <0 error (but forward the message)
56 56
  * WARNING: buf must be 0 terminated (to allow regex matches on it) */
57
-static inline int run_onsend(struct sip_msg* orig_msg,
58
-							struct socket_info* send_sock, int proto,
59
-							union sockaddr_union* to, char* buf, int len)
57
+static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
58
+								char* buf, int len)
60 59
 {
61 60
 	struct onsend_info onsnd_info;
62 61
 	int ret;
63 62
 	
64 63
 	ret=1;
65 64
 	if (onsend_rt.rlist[DEFAULT_RT]){
66
-		onsnd_info.to=to;
67
-		onsnd_info.send_sock=send_sock;
65
+		onsnd_info.to=&dst->to;
66
+		onsnd_info.send_sock=dst->send_sock;
68 67
 		onsnd_info.buf=buf;
69 68
 		onsnd_info.len=len;
70 69
 		p_onsend=&onsnd_info;
Browse code

- named routes support in core and tm (t_on_*). e.g.: route{ route(bar); t_on_reply("reply_route"); route(1); # == route("1") ... } route[foo]{ ... } route["bar"]{ ... } route[1]{ ... } onreply_route[reply_route]{ ... }

route(bar);

Andrei Pelinescu-Onciul authored on 07/02/2006 01:14:57
Showing 1 changed files
... ...
@@ -62,13 +62,13 @@ static inline int run_onsend(struct sip_msg* orig_msg,
62 62
 	int ret;
63 63
 	
64 64
 	ret=1;
65
-	if (onsend_rlist[DEFAULT_RT]){
65
+	if (onsend_rt.rlist[DEFAULT_RT]){
66 66
 		onsnd_info.to=to;
67 67
 		onsnd_info.send_sock=send_sock;
68 68
 		onsnd_info.buf=buf;
69 69
 		onsnd_info.len=len;
70 70
 		p_onsend=&onsnd_info;
71
-		ret=run_actions(onsend_rlist[DEFAULT_RT], orig_msg);
71
+		ret=run_actions(onsend_rt.rlist[DEFAULT_RT], orig_msg);
72 72
 		p_onsend=0; /* reset it */
73 73
 	}
74 74
 	return ret;
Browse code

- added missing onsend.h

Andrei Pelinescu-Onciul authored on 12/12/2005 12:26:53
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,78 @@
1
+/*
2
+ *  $Id$
3
+ *
4
+ * Copyright (C) 2005 iptelorg GmbH
5
+ *
6
+ * This file is part of ser, a free SIP server.
7
+ *
8
+ * ser 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
+ * 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
+ * ser is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License 
24
+ * along with this program; if not, write to the Free Software 
25
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
+ */
27
+/*
28
+ * History:
29
+ * -------
30
+ *  2005-12-11 created by andrei
31
+ */
32
+
33
+
34
+#ifndef onsend_h
35
+#define onsend_h
36
+
37
+
38
+#include "ip_addr.h"
39
+#include "action.h"
40
+#include "route.h"
41
+
42
+struct onsend_info{
43
+	union sockaddr_union* to;
44
+	struct socket_info* send_sock;
45
+	char* buf;
46
+	int len;
47
+};
48
+
49
+extern struct onsend_info* p_onsend;
50
+
51
+
52
+#define get_onsend_info()	(p_onsend)
53
+
54
+/*
55
+ * returns: 0 drop the message, >= ok, <0 error (but forward the message)
56
+ * WARNING: buf must be 0 terminated (to allow regex matches on it) */
57
+static inline int run_onsend(struct sip_msg* orig_msg,
58
+							struct socket_info* send_sock, int proto,
59
+							union sockaddr_union* to, char* buf, int len)
60
+{
61
+	struct onsend_info onsnd_info;
62
+	int ret;
63
+	
64
+	ret=1;
65
+	if (onsend_rlist[DEFAULT_RT]){
66
+		onsnd_info.to=to;
67
+		onsnd_info.send_sock=send_sock;
68
+		onsnd_info.buf=buf;
69
+		onsnd_info.len=len;
70
+		p_onsend=&onsnd_info;
71
+		ret=run_actions(onsend_rlist[DEFAULT_RT], orig_msg);
72
+		p_onsend=0; /* reset it */
73
+	}
74
+	return ret;
75
+}
76
+
77
+
78
+#endif