Browse code

Merge remote branch 'origin/sr_3.0'

* origin/sr_3.0:
tm: fix setting the pre-T callbacks
drouting: register MI commands
drouting(k): Makefile updated to link libs
registrar(k): preserve old bflags upon lookup
pv: fixed author name
tm: set request and reply for TMCB_RESPONSE_SENT
tm: run release function for tmcb parameters
tm: t_on_xyz("0") fixup updates
core: usage of drop in onsend_route for Kamailio compatibility
core: exit() is now equivalent to exit 1
core: drop reply ser compatibility
core: drop reply in K compatible style
sanity: fix include file due to previous re-location
sanity: moved module from modules_s to modules

Andrei Pelinescu-Onciul authored on 01/02/2010 11:44:30
Showing 31 changed files
... ...
@@ -3239,7 +3239,8 @@ ret_cmd:
3239 3239
 						(void*)(DROP_R_F|EXIT_R_F)); set_cfg_pos($$);
3240 3240
 	}
3241 3241
 	| EXIT LPAREN RPAREN		{
3242
-		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F);
3242
+		$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST,
3243
+						(void*)EXIT_R_F);
3243 3244
 		set_cfg_pos($$);
3244 3245
 	}
3245 3246
 	| EXIT rval_expr	{
... ...
@@ -3247,7 +3248,8 @@ ret_cmd:
3247 3248
 		set_cfg_pos($$);
3248 3249
 	}
3249 3250
 	| EXIT				{
3250
-		$$=mk_action(DROP_T, 2, NUMBER_ST, 0, NUMBER_ST, (void*)EXIT_R_F);
3251
+		$$=mk_action(DROP_T, 2, NUMBER_ST, (void*)1, NUMBER_ST,
3252
+						(void*)EXIT_R_F);
3251 3253
 		set_cfg_pos($$);
3252 3254
 	}
3253 3255
 	| RETURN			{
3254 3256
similarity index 100%
3255 3257
rename from modules_s/sanity/Makefile
3256 3258
rename to modules/sanity/Makefile
3257 3259
similarity index 100%
3258 3260
rename from modules_s/sanity/README
3259 3261
rename to modules/sanity/README
3260 3262
similarity index 100%
3261 3263
rename from modules_s/sanity/doc/Makefile
3262 3264
rename to modules/sanity/doc/Makefile
3263 3265
similarity index 100%
3264 3266
rename from modules_s/sanity/doc/functions.xml
3265 3267
rename to modules/sanity/doc/functions.xml
3266 3268
similarity index 100%
3267 3269
rename from modules_s/sanity/doc/params.xml
3268 3270
rename to modules/sanity/doc/params.xml
3269 3271
similarity index 100%
3270 3272
rename from modules_s/sanity/doc/sanity.xml
3271 3273
rename to modules/sanity/doc/sanity.xml
3272 3274
similarity index 100%
3273 3275
rename from modules_s/sanity/mod_sanity.c
3274 3276
rename to modules/sanity/mod_sanity.c
3275 3277
similarity index 98%
3276 3278
rename from modules_s/sanity/mod_sanity.h
3277 3279
rename to modules/sanity/mod_sanity.h
... ...
@@ -32,7 +32,7 @@
32 32
 #define MOD_SANITY_CHK_H
33 33
 
34 34
 #include "../../str.h"
35
-#include "../sl/sl.h"
35
+#include "../../modules_s/sl/sl.h"
36 36
 #include "../../parser/msg_parser.h"
37 37
 
38 38
 #define SANITY_RURI_SIP_VERSION        (1<<0)
39 39
similarity index 100%
40 40
rename from modules_s/sanity/sanity.c
41 41
rename to modules/sanity/sanity.c
42 42
similarity index 100%
43 43
rename from modules_s/sanity/sanity.h
44 44
rename to modules/sanity/sanity.h
... ...
@@ -325,8 +325,11 @@ struct cell*  build_cell( struct sip_msg* p_msg )
325 325
 
326 326
 	/* enter callback, which may potentially want to parse some stuff,
327 327
 	 * before the request is shmem-ized */
328
-	if (p_msg && has_reqin_tmcbs())
328
+	if (p_msg) {
329
+		set_early_tmcb_list(p_msg, new_cell);
330
+		if(has_reqin_tmcbs())
329 331
 			run_reqin_callbacks( new_cell, p_msg, p_msg->REQ_METHOD);
332
+	}
330 333
 
331 334
 	if (p_msg) {
332 335
 #ifndef POSTPONE_MSG_CLONING
... ...
@@ -57,7 +57,36 @@
57 57
 struct tmcb_head_list* req_in_tmcb_hl = 0;
58 58
 struct tmcb_head_list* local_req_in_tmcb_hl = 0;
59 59
 
60
+struct tm_early_cb {
61
+	unsigned int msgid;
62
+	struct tmcb_head_list cb_list;
63
+} tmcb_early_hl = { 0, {0, 0} };
60 64
 
65
+struct tmcb_head_list* get_early_tmcb_list(struct sip_msg *msg)
66
+{
67
+	struct tm_callback *cbp, *cbp_tmp;
68
+	if (msg->id!=tmcb_early_hl.msgid) {
69
+		for( cbp=(struct tm_callback*)tmcb_early_hl.cb_list.first; cbp ; ) {
70
+			cbp_tmp = cbp;
71
+			cbp = cbp->next;
72
+			if (cbp_tmp->param && cbp_tmp->release)
73
+					cbp_tmp->release( cbp_tmp->param );
74
+			shm_free( cbp_tmp );
75
+		}
76
+		memset(&tmcb_early_hl.cb_list, 0, sizeof(struct tmcb_head_list));
77
+		tmcb_early_hl.msgid = msg->id;
78
+	}
79
+	return &tmcb_early_hl.cb_list;
80
+}
81
+
82
+void set_early_tmcb_list(struct sip_msg *msg, struct cell *t)
83
+{
84
+	if (msg->id==tmcb_early_hl.msgid) {
85
+		t->tmcb_hl = tmcb_early_hl.cb_list;
86
+		memset(&tmcb_early_hl.cb_list, 0, sizeof(struct tmcb_head_list));
87
+		tmcb_early_hl.msgid = 0;
88
+	}
89
+}
61 90
 
62 91
 int init_tmcb_lists()
63 92
 {
... ...
@@ -95,7 +124,8 @@ void destroy_tmcb_lists()
95 124
 		for( cbp=(struct tm_callback*)req_in_tmcb_hl->first; cbp ; ) {
96 125
 			cbp_tmp = cbp;
97 126
 			cbp = cbp->next;
98
-			if (cbp_tmp->param) shm_free( cbp_tmp->param );
127
+			if (cbp_tmp->param && cbp_tmp->release)
128
+					cbp_tmp->release( cbp_tmp->param );
99 129
 			shm_free( cbp_tmp );
100 130
 		}
101 131
 		shm_free(req_in_tmcb_hl);
... ...
@@ -105,7 +135,8 @@ void destroy_tmcb_lists()
105 135
 		for( cbp=(struct tm_callback*)local_req_in_tmcb_hl->first; cbp ; ) {
106 136
 			cbp_tmp = cbp;
107 137
 			cbp = cbp->next;
108
-			if (cbp_tmp->param) shm_free( cbp_tmp->param );
138
+			if (cbp_tmp->param && cbp_tmp->release)
139
+					cbp_tmp->release( cbp_tmp->param );
109 140
 			shm_free( cbp_tmp );
110 141
 		}
111 142
 		shm_free(local_req_in_tmcb_hl);
... ...
@@ -207,17 +238,15 @@ int register_tmcb( struct sip_msg* p_msg, struct cell *t, int types,
207 238
 				return E_BUG;
208 239
 			}
209 240
 			/* look for the transaction */
210
-			if ( t_check(p_msg,0)!=1 ){
211
-				LOG(L_CRIT,"BUG:tm:register_tmcb: no transaction found\n");
212
-				return E_BUG;
213
-			}
214
-			if ( (t=get_t())==0 ) {
215
-				LOG(L_CRIT,"BUG:tm:register_tmcb: transaction found "
216
-					"is NULL\n");
217
-				return E_BUG;
241
+			t=get_t();
242
+			if ( t!=0 && t!=T_UNDEFINED) {
243
+				cb_list = &(t->tmcb_hl);
244
+			} else {
245
+				cb_list = get_early_tmcb_list(p_msg);
218 246
 			}
247
+		} else {
248
+			cb_list = &(t->tmcb_hl);
219 249
 		}
220
-		cb_list = &(t->tmcb_hl);
221 250
 	}
222 251
 
223 252
 	return insert_tmcb( cb_list, types, f, param, rel_func );
... ...
@@ -418,6 +418,8 @@ struct tmcb_head_list {
418 418
 extern struct tmcb_head_list*  req_in_tmcb_hl;
419 419
 extern struct tmcb_head_list*  local_req_in_tmcb_hl;
420 420
 
421
+void set_early_tmcb_list(struct sip_msg *msg,
422
+		struct cell *t);
421 423
 
422 424
 #define has_tran_tmcbs(_T_, _types_) \
423 425
 	( ((_T_)->tmcb_hl.reg_types)&(_types_) )
... ...
@@ -602,7 +602,8 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
602 602
 									trans->uas.request, FAKED_REPLY, code);
603 603
 #ifdef TMCB_ONSEND
604 604
 			if (unlikely(has_tran_tmcbs(trans, TMCB_RESPONSE_SENT))){
605
-				INIT_TMCB_ONSEND_PARAMS(onsend_params, 0, 0, rb, &rb->dst, 
605
+				INIT_TMCB_ONSEND_PARAMS(onsend_params, trans->uas.request,
606
+								FAKED_REPLY, rb, &rb->dst, 
606 607
 								buf, len, TMCB_LOCAL_F, rb->branch, code);
607 608
 				run_onsend_callbacks2(TMCB_RESPONSE_SENT, trans,
608 609
 										&onsend_params);
... ...
@@ -589,6 +589,11 @@ static int fixup_t_reply(void** param, int param_no)
589 589
 static int fixup_on_failure(void** param, int param_no)
590 590
 {
591 591
 	if (param_no==1){
592
+		if(strlen((char*)*param)<=1
593
+				&& (*(char*)(*param)==0 || *(char*)(*param)=='0')) {
594
+			*param = (void*)0;
595
+			return 0;
596
+		}
592 597
 		return fixup_routes("t_on_failure", &failure_rt, param);
593 598
 	}
594 599
 	return 0;
... ...
@@ -599,6 +604,11 @@ static int fixup_on_failure(void** param, int param_no)
599 604
 static int fixup_on_reply(void** param, int param_no)
600 605
 {
601 606
 	if (param_no==1){
607
+		if(strlen((char*)*param)<=1
608
+				&& (*(char*)(*param)==0 || *(char*)(*param)=='0')) {
609
+			*param = (void*)0;
610
+			return 0;
611
+		}
602 612
 		return fixup_routes("t_on_reply", &onreply_rt, param);
603 613
 	}
604 614
 	return 0;
... ...
@@ -609,6 +619,11 @@ static int fixup_on_reply(void** param, int param_no)
609 619
 static int fixup_on_branch(void** param, int param_no)
610 620
 {
611 621
 	if (param_no==1){
622
+		if(strlen((char*)*param)<=1
623
+				&& (*(char*)(*param)==0 || *(char*)(*param)=='0')) {
624
+			*param = (void*)0;
625
+			return 0;
626
+		}
612 627
 		return fixup_routes("t_on_branch", &branch_rt, param);
613 628
 	}
614 629
 	return 0;
... ...
@@ -8,4 +8,9 @@ NAME=drouting.so
8 8
 LIBS= 
9 9
 DEFS+=-DOPENSER_MOD_INTERFACE
10 10
 
11
+SERLIBPATH=../../lib
12
+SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1
13
+SER_LIBS+=$(SERLIBPATH)/kcore/kcore
14
+SER_LIBS+=$(SERLIBPATH)/kmi/kmi
15
+
11 16
 include ../../Makefile.modules
... ...
@@ -1,6 +1,6 @@
1 1
 Pseudo-Variables Module
2 2
 
3
-Daniel-Constantin Modroiu
3
+Daniel-Constantin Mierla
4 4
 
5 5
    asipto.com
6 6
    <daniel@asipto.com>
... ...
@@ -15,7 +15,7 @@
15 15
 	<authorgroup>
16 16
 	    <author>
17 17
 		<firstname>Daniel-Constantin</firstname>
18
-		<surname>Modroiu</surname>
18
+		<surname>Mierla</surname>
19 19
 		<affiliation><orgname>asipto.com</orgname></affiliation>
20 20
 		<email>daniel@asipto.com</email>
21 21
 		<address>
... ...
@@ -65,6 +65,8 @@ int lookup(struct sip_msg* _m, char* _t, char* _s)
65 65
 	int res;
66 66
 	int ret;
67 67
 	str path_dst;
68
+	flag_t old_bflags;
69
+
68 70
 
69 71
 	if (_m->new_uri.s) uri = _m->new_uri;
70 72
 	else uri = _m->first_line.u.request.uri;
... ...
@@ -131,7 +133,9 @@ int lookup(struct sip_msg* _m, char* _t, char* _s)
131 133
 
132 134
 		set_ruri_q(ptr->q);
133 135
 
134
-		setbflagsval( 0, ptr->cflags);
136
+		old_bflags = 0;
137
+		getbflagsval(0, &old_bflags);
138
+		setbflagsval(0, old_bflags|ptr->cflags);
135 139
 
136 140
 		if (ptr->sock)
137 141
 			set_force_socket(_m, ptr->sock);
138 142
deleted file mode 100755
... ...
@@ -1,16 +0,0 @@
1
-# $Id$
2
-#
3
-# sanity check module makefile
4
-#
5
-#
6
-# WARNING: do not run this directly, it should be run by the master Makefile
7
-
8
-include ../../Makefile.defs
9
-
10
-auto_gen=
11
-NAME=sanity.so
12
-LIBS=
13
-
14
-DEFS+=-DOPENSER_MOD_INTERFACE
15
-
16
-include ../../Makefile.modules
17 0
deleted file mode 100644
... ...
@@ -1,196 +0,0 @@
1
-Sanity Module
2
-
3
-Nils Ohlmeier
4
-
5
-   iptelorg GmbH
6
-   <nils@iptel.org>
7
-
8
-Edited by
9
-
10
-Nils Ohlmeier
11
-
12
-   <nils@iptel.org>
13
-
14
-   Copyright � 2006 iptelorg GmbH
15
-     __________________________________________________________
16
-
17
-   Table of Contents
18
-
19
-   1. Admin Guide
20
-
21
-        1.1. Overview
22
-        1.2. Dependencies
23
-
24
-              1.2.1. Kamailio Modules
25
-              1.2.2. External Libraries or Applications
26
-
27
-        1.3. Exported Parameters
28
-
29
-              1.3.1. default_checks (integer)
30
-              1.3.2. uri_checks (integer)
31
-              1.3.3. proxy_require (string)
32
-
33
-        1.4. Exported Functions
34
-
35
-              1.4.1. sanity_check([checks, [uri_checks]])
36
-
37
-   List of Examples
38
-
39
-   1.1. Set default_checks parameter
40
-   1.2. Set proxy_require parameter
41
-   1.3. sanity_check usage
42
-   1.4. sanity_check usage with parameter
43
-   1.5. sanity_check usage with two parameters
44
-
45
-Chapter 1. Admin Guide
46
-
47
-1.1. Overview
48
-
49
-   This module aims to implement several sanity checks on incoming
50
-   requests which are suggested or even required by a RFC.
51
-
52
-   This checks are not required by Kamailio itself for its
53
-   functionality. But on the other side it makes not much sence if
54
-   a broken request traverses through a SIP network if it is
55
-   rejected sooner or later by a SIP device any way. As every
56
-   sanity cost extra performance because of additional parsing and
57
-   evaluation it is now with this module up to the Kamailio
58
-   adminstrator which checks should be done on which request.
59
-
60
-   The following checks are available:
61
-     * ruri sip version - (1) - checks if the SIP version in the
62
-       request URI is supported, currently only 2.0.
63
-     * ruri scheme - (2) - checks if the URI scheme of the request
64
-       URI is supported (sip[s]|tel[s]) by Kamailio.
65
-     * required headers - (4) -checks if the minimum set of
66
-       required headers to, from, cseq, callid and via is present
67
-       in the request.
68
-     * via sip version - (8) - not working because parser fails
69
-       already when another version then 2.0 is present.
70
-     * via protocol - (16) - not working because parser fails
71
-       already if an unsupported transport is present.
72
-     * cseq method - (32) - checks if the method from the cseq
73
-       header is equal to the request method.
74
-     * cseq value - (64) - checks if the number in the cseq header
75
-       is a valid unsigend integer.
76
-     * content length - (128) - checks if the size of the body
77
-       matches with the value from the content length header.
78
-     * expires value - (256) - checks if the value of the expires
79
-       header is a valid unsigned integer.
80
-     * proxy require - (512) - checks if all items of the proxy
81
-       require header are present in the list of the extensions
82
-       from the module parameter proxy_require.
83
-     * parse uri's - (1024) - checks if the specified URIs are
84
-       present and parseable by the Kamailio parsers
85
-     * digest credentials (2048) Check all instances of digest
86
-       credentials in a message. The test checks whether there are
87
-       all required digest parameters and have meaningful values.
88
-
89
-1.2. Dependencies
90
-
91
-1.2.1. Kamailio Modules
92
-
93
-   The following modules must be loaded before this module:
94
-     * sl - send reply.
95
-
96
-1.2.2. External Libraries or Applications
97
-
98
-   The following libraries or applications must be installed
99
-   before running Kamailio with this module loaded:
100
-     * None.
101
-
102
-1.3. Exported Parameters
103
-
104
-1.3.1. default_checks (integer)
105
-
106
-   This parameter determines which of the checks from the sanity
107
-   module are executed if no parameter was given to the
108
-   sanity_check function call. By default all implemented checks
109
-   are included in the execution of the sanity_check function. The
110
-   integer value is the sum of the check numbers which should be
111
-   executed by default.
112
-
113
-   Default value is 999. This resolves to the following list of
114
-   checks: ruri_sip_version (1), ruri_scheme (2), required_headers
115
-   (4), cseq_method (32), cseq_value (64), content_length (128),
116
-   expires_value (256), proxy_require (512).
117
-
118
-   Example 1.1. Set default_checks parameter
119
-...
120
-modparam("sanity", "default_checks", 1)
121
-...
122
-
123
-1.3.2. uri_checks (integer)
124
-
125
-   This parameter determines which URIs are going to be checked if
126
-   the 'parse uri' will be executed.
127
-
128
-   Default value is 7. This resolves to the following list of
129
-   parsed URIs: Request RUI (1), From URI (2) and To URI (4).
130
-
131
-1.3.3. proxy_require (string)
132
-
133
-   This parameter set the list of supported extensions for this
134
-   Kamailio. The value is expected as comma seperated list of the
135
-   extensions. This list is seperated into single tokens. Each
136
-   token from a proxy require header will be compare to the tokens
137
-   from this list.
138
-
139
-   Example 1.2. Set proxy_require parameter
140
-...
141
-modparam("sanity", "proxy_require", "foo, bar")
142
-...
143
-
144
-1.4. Exported Functions
145
-
146
-1.4.1.  sanity_check([checks, [uri_checks]])
147
-
148
-   This function makes a row of sanity checks on the given
149
-   request. The function returns true if one of the checks failed.
150
-   If one of the checks fails the module sends a precise error
151
-   reply via sl_send_reply. Thus their is no need to reply with a
152
-   generic error message.
153
-
154
-   Example 1.3. sanity_check usage
155
-
156
-...
157
-if (sanity_check()) {
158
-        xlog("malformed message from $si:$sp\n");
159
-        exit;
160
-}
161
-...
162
-
163
-
164
-   Optionally the function takes an integer argument which
165
-   overwrites the global module parameter default_checks. This
166
-   allows to make certain test from script regions. The integer
167
-   value is again the sum of the checks (like for the module
168
-   parameter) which should be executed at this function call.
169
-
170
-   Example 1.4. sanity_check usage with parameter
171
-
172
-...
173
-if (method=="REGISTER" && sanity_check("256")) {
174
-        /* the register contains an invalid expires value and is replied
175
- with a 400 */
176
-        xlog("malformed message from $si:$sp\n");
177
-        exit;
178
-}
179
-...
180
-
181
-
182
-   Optionally the function takes a second integer argument which
183
-   overwrites the global module parameter uri_checks and thus
184
-   determines which URIs will be checked if the parse uri test
185
-   will be executed.
186
-
187
-   Example 1.5. sanity_check usage with two parameters
188
-
189
-...
190
-if (method=="INVITE" && sanity_check("1024", "6")) {
191
-        /* the INVITE contains an invalid From or To header and is repli
192
-ed with a 400 */
193
-        xlog("malformed message from $si:$sp\n");
194
-        exit;
195
-}
196
-...
197 0
deleted file mode 100644
... ...
@@ -1,4 +0,0 @@
1
-docs = sanity.xml
2
-
3
-docbook_dir = ../../../docbook
4
-include $(docbook_dir)/Makefile.module
5 0
deleted file mode 100644
... ...
@@ -1,41 +0,0 @@
1
-<?xml version="1.0" encoding='ISO-8859-1'?>
2
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3
-"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4
-
5
-<!-- Include general documentation entities -->
6
-<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
7
-%docentities;
8
-
9
-]>
10
-
11
-<book xmlns:xi="http://www.w3.org/2001/XInclude">
12
-    <bookinfo>
13
-	<title>Sanity Module</title>
14
-	<productname class="trade">&kamailioname;</productname>
15
-	<authorgroup>
16
-	    <author>
17
-		<firstname>Nils</firstname>
18
-		<surname>Ohlmeier</surname>
19
-		<affiliation><orgname>iptelorg GmbH</orgname></affiliation>
20
-		<email>nils@iptel.org</email>
21
-		<address>
22
-		</address>
23
-	    </author>
24
-	    <editor>
25
-		<firstname>Nils</firstname>
26
-		<surname>Ohlmeier</surname>
27
-		<email>nils@iptel.org</email>
28
-	    </editor>
29
-	</authorgroup>
30
-	<copyright>
31
-	    <year>2006</year>
32
-	    <holder>iptelorg GmbH</holder>
33
-	</copyright>
34
-    </bookinfo>
35
-    <toc></toc>
36
-    
37
-    <xi:include href="sanity_admin.xml"/>
38
-    
39
-    
40
-</book>
41
-
42 0
deleted file mode 100644
... ...
@@ -1,271 +0,0 @@
1
-<?xml version="1.0" encoding='ISO-8859-1'?>
2
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
3
-"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
4
-
5
-<!-- Include general documentation entities -->
6
-<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
7
-%docentities;
8
-
9
-]>
10
-<!-- Module User's Guide -->
11
-
12
-<chapter>
13
-	
14
-	<title>&adminguide;</title>
15
-	
16
-	<section>
17
-	<title>Overview</title>
18
-	<para>
19
-		This module aims to implement several sanity checks on incoming
20
-		requests which are suggested or even required by a RFC.
21
-	</para>
22
-	<para>
23
-		This checks are not required by &kamailio; itself for its functionality.
24
-		But on the other side it makes not much sence if a broken
25
-		request traverses through a SIP network if it is rejected sooner
26
-		or later by a SIP device any way. As every sanity cost extra
27
-		performance because of additional parsing and evaluation it
28
-		is now with this module up to the &kamailio; adminstrator which checks
29
-		should be done on which request.
30
-	</para>
31
-	<para>
32
-		The following checks are available:
33
-		<itemizedlist>
34
-		<listitem>
35
-			<para>
36
-			ruri sip version - (1) - checks if the SIP version in the request
37
-			URI is supported, currently only 2.0.
38
-			</para>
39
-		</listitem>
40
-		<listitem>
41
-			<para>
42
-			ruri scheme - (2) - checks if the URI scheme of the request URI is
43
-			supported (sip[s]|tel[s]) by &kamailio;.
44
-			</para>
45
-		</listitem>
46
-		<listitem>
47
-			<para>
48
-			required headers - (4) -checks if the minimum set of required headers
49
-			to, from, cseq, callid and via is present in the request.
50
-			</para>
51
-		</listitem>
52
-		<listitem>
53
-			<para>
54
-			via sip version - (8) - not working because parser fails already 
55
-			when another version then 2.0 is present.
56
-			</para>
57
-		</listitem>
58
-		<listitem>
59
-			<para>
60
-			via protocol - (16) - not working because parser fails already if an
61
-			unsupported transport is present.
62
-			</para>
63
-		</listitem>
64
-		<listitem>
65
-			<para>
66
-			cseq method - (32) - checks if the method from the cseq header is equal
67
-			to the request method.
68
-			</para>
69
-		</listitem>
70
-		<listitem>
71
-			<para>
72
-			cseq value - (64) - checks if the number in the cseq header is a valid
73
-			unsigend integer.
74
-			</para>
75
-		</listitem>
76
-		<listitem>
77
-			<para>
78
-			content length - (128) - checks if the size of the body matches with the
79
-			value from the content length header.
80
-			</para>
81
-		</listitem>
82
-		<listitem>
83
-			<para>
84
-			expires value - (256) - checks if the value of the expires header is a
85
-			valid unsigned integer.
86
-			</para>
87
-		</listitem>
88
-		<listitem>
89
-			<para>
90
-			proxy require - (512) - checks if all items of the proxy require header
91
-			are present in the list of the extensions from the module 
92
-			parameter proxy_require.
93
-			</para>
94
-		</listitem>
95
-		<listitem>
96
-			<para>
97
-			parse uri's - (1024) - checks if the specified URIs are present and
98
-			parseable by the &kamailio; parsers
99
-			</para>
100
-		</listitem>
101
-		<listitem>
102
-		    <para>
103
-			digest credentials (2048) Check all instances of digest credentials in a
104
-			message. The test checks whether there are all required
105
-			digest parameters and have meaningful values.
106
-			</para>
107
-		</listitem>
108
-		</itemizedlist>
109
-	</para>
110
-
111
-	</section>
112
-	<section>
113
-	<title>Dependencies</title>
114
-	<section>
115
-		<title>&kamailio; Modules</title>
116
-		<para>
117
-		The following modules must be loaded before this module:
118
-			<itemizedlist>
119
-			<listitem>
120
-			<para>
121
-				<emphasis>sl</emphasis> - send reply.
122
-			</para>
123
-			</listitem>
124
-			</itemizedlist>
125
-		</para>
126
-	</section>
127
-	<section>
128
-		<title>External Libraries or Applications</title>
129
-		<para>
130
-		The following libraries or applications must be installed before running
131
-		&kamailio; with this module loaded:
132
-			<itemizedlist>
133
-			<listitem>
134
-			<para>
135
-				<emphasis>None</emphasis>.
136
-			</para>
137
-			</listitem>
138
-			</itemizedlist>
139
-		</para>
140
-	</section>
141
-
142
-	</section>
143
-	<section>
144
-	<title>Exported Parameters</title>
145
-   <section>
146
-	<title><varname>default_checks</varname> (integer)</title>
147
-	<para>
148
-		This parameter determines which of the checks from the sanity
149
-		module are executed if no parameter was given to the sanity_check
150
-		function call. By default all implemented checks are included
151
-		in the execution of the sanity_check function. The integer value
152
-		is the sum of the check numbers which should be executed by default.
153
-	</para>
154
-	<para>
155
-	    Default value is 999. This resolves to the following list of
156
-		checks: ruri_sip_version (1), ruri_scheme (2), required_headers (4),
157
-		cseq_method (32), cseq_value (64), content_length (128), 
158
-		expires_value (256), proxy_require (512).
159
-	</para>
160
-	<example>
161
-	    <title>Set <varname>default_checks</varname> parameter</title>
162
-	    <programlisting>
163
-...
164
-modparam("sanity", "default_checks", 1)
165
-...
166
-	    </programlisting>
167
-	</example>
168
-    </section>
169
-
170
-	<section>
171
-	<title><varname>uri_checks</varname> (integer)</title>
172
-	<para>
173
-		This parameter determines which URIs are going to be checked
174
-		if the 'parse uri' will be executed.
175
-	</para>
176
-	<para>
177
-		Default value is 7. This resolves to the following list of
178
-		parsed URIs: Request RUI (1), From URI (2) and To URI (4).
179
-	</para>
180
-	</section>
181
-
182
-	<section>
183
-	<title><varname>proxy_require</varname> (string)</title>
184
-	<para>
185
-		This parameter set the list of supported extensions for this &kamailio;.
186
-		The value is expected as comma seperated list of the extensions.
187
-		This list is seperated into single tokens. Each token from
188
-		a proxy require header will be compare to the tokens from this
189
-		list.
190
-	</para>
191
-	<example>
192
-	    <title>Set <varname>proxy_require</varname> parameter</title>
193
-	    <programlisting>
194
-...
195
-modparam("sanity", "proxy_require", "foo, bar")
196
-...
197
-	    </programlisting>
198
-	</example>
199
-	</section>
200
-	</section>
201
-	<section>
202
-	<title>Exported Functions</title>
203
-    <section id="sanity_check">
204
-	    <title>
205
-		<function>sanity_check([checks, [uri_checks]])</function>
206
-	    </title>
207
-	<para>
208
-		This function makes a row of sanity checks on the given request.
209
-		The function returns true if one of the checks failed. If one
210
-		of the checks fails the module sends a precise error reply via 
211
-		sl_send_reply. Thus their is no need to reply with a generic 
212
-		error message.
213
-	</para>
214
-	<example>
215
-	    <title><function>sanity_check</function> usage</title>
216
-	    <programlisting>
217
-<![CDATA[
218
-...
219
-if (sanity_check()) {
220
-	xlog("malformed message from $si:$sp\n");
221
-	exit;
222
-}
223
-...
224
-]]>
225
-	    </programlisting>
226
-	</example>
227
-	<para>
228
-		Optionally the function takes an integer argument which overwrites
229
-		the global module parameter default_checks. This allows to make
230
-		certain test from script regions. The integer value is again the sum
231
-		of the checks (like for the module parameter) which should be executed
232
-		at this function call.
233
-	</para>
234
-	<example>
235
-	    <title><function>sanity_check</function> usage with parameter</title>
236
-	    <programlisting>
237
-<![CDATA[
238
-...
239
-if (method=="REGISTER" && sanity_check("256")) {
240
-	/* the register contains an invalid expires value and is replied with a 400 */
241
-	xlog("malformed message from $si:$sp\n");
242
-	exit;
243
-}
244
-...
245
-]]>
246
-	    </programlisting>
247
-	</example>
248
-	<para>
249
-		Optionally the function takes a second integer argument which
250
-		overwrites the global module parameter uri_checks and thus determines
251
-		which URIs will be checked if the parse uri test will be executed.
252
-	</para>
253
-	<example>
254
-		<title><function>sanity_check</function> usage with two parameters</title>
255
-		<programlisting>
256
-<![CDATA[
257
-...
258
-if (method=="INVITE" && sanity_check("1024", "6")) {
259
-	/* the INVITE contains an invalid From or To header and is replied with a 400 */
260
-	xlog("malformed message from $si:$sp\n");
261
-	exit;
262
-}
263
-...
264
-]]>
265
-		</programlisting>
266
-	</example>
267
-    </section>
268
-    </section>
269
-
270
-</chapter>
271
-
272 0
deleted file mode 100644
... ...
@@ -1,221 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * Sanity Checks Module
5
- * 
6
- * Copyright (C) 2006 iptelorg GbmH
7
- *
8
- * This file is part of Kamailio, a free SIP server.
9
- *
10
- * Kamailio is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
14
- *
15
- * Kamailio is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
- */
24
-
25
-
26
-#include "mod_sanity.h"
27
-#include "sanity.h"
28
-#include "../../sr_module.h"
29
-#include "../../ut.h"
30
-#include "../../error.h"
31
-
32
-MODULE_VERSION
33
-
34
-#define PROXY_REQUIRE_DEF 	""
35
-
36
-str pr_str 	= {PROXY_REQUIRE_DEF, sizeof(PROXY_REQUIRE_DEF)-1 };
37
-
38
-int default_checks = SANITY_DEFAULT_CHECKS;
39
-int uri_checks = SANITY_DEFAULT_URI_CHECKS;
40
-strl* proxyrequire_list = NULL;
41
-
42
-struct sl_binds sl;
43
-
44
-static int mod_init(void);
45
-static int sanity_fixup(void** param, int param_no);
46
-static int sanity_check(struct sip_msg* _msg, char* _foo, char* _bar);
47
-
48
-/*
49
- * Exported functions
50
- */
51
-static cmd_export_t cmds[] = {
52
-	{"sanity_check", (cmd_function)sanity_check, 0, 0, 0, REQUEST_ROUTE},
53
-	{"sanity_check", (cmd_function)sanity_check, 1, sanity_fixup, 0,
54
-		REQUEST_ROUTE},
55
-	{"sanity_check", (cmd_function)sanity_check, 2, sanity_fixup, 0,
56
-		REQUEST_ROUTE},
57
-	{0, 0, 0, 0, 0, 0}
58
-};
59
-
60
-/*
61
- * Exported parameters
62
- */
63
-static param_export_t params[] = {
64
-	{"default_checks", 	INT_PARAM, 	&default_checks},
65
-	{"uri_checks",		INT_PARAM,  &uri_checks	},
66
-	{"proxy_require", 	STR_PARAM, 	&pr_str 	},
67
-	{0, 0, 0}
68
-};
69
-
70
-/*
71
- * Module description
72
- */
73
-struct module_exports exports = {
74
-	"sanity",        /* Module name */
75
-	DEFAULT_DLFLAGS, /* dlopen flags */
76
-	cmds,            /* Exported functions */
77
-	params,          /* Exported parameters */
78
-	0,          /* exported statistics */
79
-	0,          /* exported MI functions */
80
-	0,          /* exported pseudo-variables */
81
-	0,          /* extra processes */
82
-	mod_init,        /* Initialization function */
83
-	0,               /* Response function */
84
-	0,               /* Destroy function */
85
-	0                /* Child init function */
86
-};
87
-
88
-/*
89
- * initialize module
90
- */
91
-static int mod_init(void) {
92
-	strl* ptr;
93
-
94
-	/*
95
-	 * We will need sl_send_reply from stateless
96
-	 * module for sending replies
97
-	 */
98
-	if (load_sl_api(&sl)!=0) {
99
-		LM_ERR("can't load SL API\n");
100
-		return -1;
101
-	}
102
-
103
-	LM_DBG("parsing proxy requires string:\n");
104
-	ptr = parse_str_list(&pr_str);
105
-
106
-	proxyrequire_list = ptr;
107
-
108
-	while (ptr != NULL) {
109
-		LM_DBG("string: '%.*s', next: %p\n", ptr->string.len,
110
-				ptr->string.s, ptr->next);
111
-		ptr = ptr->next;
112
-	}
113
-
114
-	return 0;
115
-}
116
-
117
-static int sanity_fixup(void** param, int param_no) {
118
-	int checks;
119
-	str in;
120
-
121
-	if (param_no == 1) {
122
-		in.s = (char*)*param;
123
-		in.len = strlen(in.s);
124
-		if (str2int(&in, (unsigned int*)&checks) < 0) {
125
-			LM_ERR("failed to convert input integer\n");
126
-			return E_UNSPEC;
127
-		}
128
-		if ((checks < 1) || (checks >= (SANITY_MAX_CHECKS))) {
129
-			LM_ERR("input parameter (%i) outside of valid range <1-%i)\n",
130
-					checks, SANITY_MAX_CHECKS);
131
-			return E_UNSPEC;
132
-		}
133
-		*param = (void*)(long)checks;
134
-	}
135
-	if (param_no == 2) {
136
-		in.s = (char*)*param;
137
-		in.len = strlen(in.s);
138
-		if (str2int(&in, (unsigned int*)&checks) < 0) {
139
-			LM_ERR("failed to convert second integer argument\n");
140
-			return E_UNSPEC;
141
-		}
142
-		if ((checks < 1) || (checks > (SANITY_DEFAULT_URI_CHECKS))) {
143
-			LM_ERR("second input parameter (%i) outside of valid range 1-%i\n",
144
-					checks, SANITY_DEFAULT_URI_CHECKS);
145
-			return E_UNSPEC;
146
-		}
147
-		*param = (void*)(long)checks;
148
-	}
149
-	return 0;
150
-}
151
-
152
-static int sanity_check(struct sip_msg* _msg, char* _number, char* _arg) {
153
-	int ret, check, arg;
154
-
155
-	if (_number == NULL) {
156
-		check = default_checks;
157
-	}
158
-	else {
159
-		check = (int)(long)_number;
160
-	}
161
-	if (_arg == NULL) {
162
-		arg = uri_checks;
163
-	}
164
-	else {
165
-		arg = (int)(long)_arg;
166
-	}
167
-
168
-	if (SANITY_RURI_SIP_VERSION & check &&
169
-		(ret = check_ruri_sip_version(_msg)) != SANITY_CHECK_PASSED) {
170
-		return ret;
171
-	}
172
-	if (SANITY_RURI_SCHEME & check &&
173
-		(ret = check_ruri_scheme(_msg)) != SANITY_CHECK_PASSED) {
174
-		return ret;
175
-	}
176
-	if (SANITY_REQUIRED_HEADERS & check &&
177
-		(ret = check_required_headers(_msg)) != SANITY_CHECK_PASSED) {
178
-		return ret;
179
-	}
180
-	if (SANITY_VIA_SIP_VERSION & check &&
181
-		(ret = check_via_sip_version(_msg)) != SANITY_CHECK_PASSED) {
182
-		return ret;
183
-	}
184
-	if (SANITY_VIA_PROTOCOL & check &&
185
-		(ret = check_via_protocol(_msg)) != SANITY_CHECK_PASSED) {
186
-		return ret;
187
-	}
188
-	if (SANITY_CSEQ_METHOD & check &&
189
-		(ret = check_cseq_method(_msg)) != SANITY_CHECK_PASSED) {
190
-		return ret;
191
-	}
192
-	if (SANITY_CSEQ_VALUE & check &&
193
-		(ret = check_cseq_value(_msg)) != SANITY_CHECK_PASSED) {
194
-		return ret;
195
-	}
196
-	if (SANITY_CL & check &&
197
-		(ret = check_cl(_msg)) != SANITY_CHECK_PASSED) {
198
-		return ret;
199
-	}
200
-	if (SANITY_EXPIRES_VALUE & check &&
201
-		(ret = check_expires_value(_msg)) != SANITY_CHECK_PASSED) {
202
-		return ret;
203
-	}
204
-	if (SANITY_PROXY_REQUIRE & check &&
205
-		(ret = check_proxy_require(_msg)) != SANITY_CHECK_PASSED) {
206
-		return ret;
207
-	}
208
-	if (SANITY_PARSE_URIS & check &&
209
-		(ret = check_parse_uris(_msg, arg)) != SANITY_CHECK_PASSED) {
210
-		return ret;
211
-	}
212
-
213
-	if (SANITY_CHECK_DIGEST & check &&
214
-	        (ret = check_digest(_msg, arg)) != SANITY_CHECK_PASSED) {
215
-	        return ret;
216
-	}
217
-
218
-	LM_DBG("all sanity checks passed\n");
219
-	/* nobody complained so everything is fine */
220
-	return 1;
221
-}
222 0
deleted file mode 100644
... ...
@@ -1,85 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * Sanity Checks Module
5
- * 
6
- * Copyright (C) 2006 iptelorg GbmH
7
- *
8
- * This file is part of Kamailio, a free SIP server.
9
- *
10
- * Kamailio is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
14
- *
15
- * Kamailio is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
- */
24
-
25
-
26
-#ifndef MOD_SANITY_CHK_H
27
-#define MOD_SANITY_CHK_H
28
-
29
-#include "../../str.h"
30
-#include "../sl/sl_api.h"
31
-#include "../../parser/msg_parser.h"
32
-
33
-#define SANITY_RURI_SIP_VERSION        (1<<0)
34
-#define SANITY_RURI_SCHEME             (1<<1)
35
-#define SANITY_REQUIRED_HEADERS        (1<<2)
36
-#define SANITY_VIA_SIP_VERSION         (1<<3)
37
-#define SANITY_VIA_PROTOCOL            (1<<4)
38
-#define SANITY_CSEQ_METHOD             (1<<5)
39
-#define SANITY_CSEQ_VALUE              (1<<6)
40
-#define SANITY_CL                      (1<<7)
41
-#define SANITY_EXPIRES_VALUE           (1<<8)
42
-#define SANITY_PROXY_REQUIRE           (1<<9)
43
-#define SANITY_PARSE_URIS              (1<<10)
44
-#define SANITY_CHECK_DIGEST            (1<<11)
45
-#define SANITY_MAX_CHECKS              (1<<12)  /* Make sure this is the highest value */
46
-
47
-/* VIA_SIP_VERSION and VIA_PROTOCOL do not work yet
48
- * and PARSE_URIS is very expensive */
49
-#define SANITY_DEFAULT_CHECKS 	SANITY_RURI_SIP_VERSION | \
50
-								SANITY_RURI_SCHEME | \
51
-								SANITY_REQUIRED_HEADERS | \
52
-								SANITY_CSEQ_METHOD | \
53
-								SANITY_CSEQ_VALUE | \
54
-								SANITY_CL | \
55
-								SANITY_EXPIRES_VALUE | \
56
-								SANITY_PROXY_REQUIRE | \
57
-                                                                SANITY_CHECK_DIGEST
58
-
59
-
60
-#define SANITY_URI_CHECK_RURI    (1<<0)
61
-#define SANITY_URI_CHECK_FROM    (1<<1)
62
-#define SANITY_URI_CHECK_TO      (1<<2)
63
-#define SANITY_URI_CHECK_CONTACT (1<<3)
64
-
65
-#define SANITY_DEFAULT_URI_CHECKS	SANITY_URI_CHECK_RURI | \
66
-									SANITY_URI_CHECK_FROM | \
67
-									SANITY_URI_CHECK_TO
68
-
69
-#define SANITY_CHECK_PASSED 1
70
-#define SANITY_CHECK_FAILED 0
71
-#define SANITY_CHECK_ERROR -1
72
-
73
-struct _strlist {
74
-	str string;            /* the string */
75
-	struct _strlist* next; /* the next strlist element */
76
-};
77
-
78
-typedef struct _strlist strl;
79
-
80
-extern int default_checks;
81
-extern strl* proxyrequire_list;
82
-
83
-extern struct sl_binds sl;
84
-
85
-#endif /* MOD_SANITY_CHK_H */
86 0
deleted file mode 100644
... ...
@@ -1,749 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * Sanity Checks Module
5
- * 
6
- * Copyright (C) 2006 iptelorg GbmH
7
- *
8
- * This file is part of Kamailio, a free SIP server.
9
- *
10
- * Kamailio is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
14
- *
15
- * Kamailio is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
- */
24
-
25
-
26
-#include "mod_sanity.h"
27
-#include "sanity.h"
28
-#include "../../ut.h"
29
-#include "../../trim.h"
30
-#include "../../data_lump_rpl.h"
31
-#include "../../mem/mem.h"
32
-#include "../../parser/parse_uri.h"
33
-#include "../../parser/parse_to.h"
34
-#include "../../parser/parse_expires.h"
35
-#include "../../parser/parse_content.h"
36
-#include "../../parser/digest/digest.h"
37
-#include "../../parser/contact/parse_contact.h"
38
-
39
-#define UNSUPPORTED_HEADER "Unsupported: "
40
-#define UNSUPPORTED_HEADER_LEN (sizeof(UNSUPPORTED_HEADER)-1)
41
-
42
-int sanity_reply(struct sip_msg* _msg, int _code, char *_reason)
43
-{
44
-	str s;
45
-	s.s = _reason;
46
-	s.len = strlen(s.s);
47
-	return sl.send_reply(_msg, _code, &s);
48
-}
49
-
50
-
51
-/* check if the given string is a valid unsigned int value */
52
-int str2valid_uint(str* _number, unsigned int* _result) {
53
-	int i;
54
-	int result= 0;
55
-	int equal = 1;
56
-	char mui[10] = "4294967296";
57
-
58
-	*_result = 0;
59
-	if (_number->len > 10) {
60
-		return -1;
61
-	}
62
-	if (_number->len < 10) {
63
-		equal = 0;
64
-	}
65
-	for (i=0; i < _number->len; i++) {
66
-		if (_number->s[i] < '0' || _number->s[i] > '9') {
67
-			return -1;
68
-		}
69
-		if (equal == 1) {
70
-			if (_number->s[i] < mui[i]) {
71
-				equal = 0;
72
-			}
73
-			else if (_number->s[i] > mui[i]) {
74
-				return -1;
75
-			}
76
-		}
77
-		result *= 10;
78
-		result += _number->s[i] - '0';
79
-	}
80
-	*_result = result;
81
-	return 0;
82
-}
83
-
84
-/* parses the given comma seperated string into a string list */
85
-strl* parse_str_list(str* _string) {
86
-	str input;
87
-	strl *parsed_list, *pl;
88
-	char *comma;
89
-
90
-	/* make a copy because we trim it */
91
-	input.s = _string->s;
92
-	input.len = _string->len;
93
-
94
-	trim(&input);
95
-
96
-	if (input.len == 0) {
97
-		return NULL;
98
-	}
99
-	parsed_list = pkg_malloc(sizeof(strl));
100
-	if (parsed_list == NULL) {
101
-		LM_ERR("OUT OF MEMORY for initial list element\n");
102
-		return NULL;
103
-	}
104
-	memset(parsed_list, 0, sizeof(strl));
105
-	parsed_list->string.s = input.s;
106
-	parsed_list->string.len = input.len;
107
-
108
-	comma = q_memchr(input.s, ',', input.len);
109
-	pl = parsed_list;
110
-	while (comma != NULL) {
111
-		pl->next = pkg_malloc(sizeof(strl));
112
-		if (pl->next == NULL) {
113
-			LM_ERR("parse_str_list: OUT OF MEMORY for further list element\n");
114
-			return parsed_list;
115
-		}
116
-		memset(pl->next, 0, sizeof(strl));
117
-		pl->next->string.s = comma + 1;
118
-		pl->next->string.len = pl->string.len - (pl->next->string.s - pl->string.s);
119
-		pl->string.len = comma - pl->string.s;
120
-		trim_trailing(&(pl->string));
121
-		pl = pl->next;
122
-		trim_leading(&(pl->string));
123
-		comma = q_memchr(pl->string.s, ',', pl->string.len);
124
-	}
125
-
126
-	return parsed_list;
127
-}
128
-
129
-/* free the elements of the linked str list */
130
-void free_str_list(strl *_list) {
131
-	strl *cur, *next;
132
-
133
-	if (_list != NULL) {
134
-		cur = _list;
135
-		while (cur != NULL) {
136
-			next = cur->next;
137
-			pkg_free(cur);
138
-			cur = next;
139
-		}
140
-	}
141
-}
142
-
143
-int parse_proxyrequire(struct hdr_field* _h) {
144
-	strl *pr_l;
145
-
146
-	if (_h->parsed) {
147
-		return 0; /* Already parsed */
148
-	}
149
-
150
-	if ((pr_l = parse_str_list(&(_h->body))) == NULL) {
151
-		LM_ERR("Error while parsing\n");
152
-		return -1;
153
-	}
154
-
155
-	_h->parsed = pr_l;
156
-	return 0;
157
-}
158
-
159
-/* check the SIP version in the request URI */
160
-int check_ruri_sip_version(struct sip_msg* _msg) {
161
-	char *sep;
162
-	str version;
163
-
164
-	if (_msg->first_line.u.request.version.len != 0) {
165
-		sep = q_memchr(_msg->first_line.u.request.version.s, '/',
166
-						_msg->first_line.u.request.version.len);
167
-		if (sep == NULL) {
168
-			LM_WARN("check_ruri_sip_version(): failed to find / in ruri version\n");
169
-			return SANITY_CHECK_FAILED;
170
-		}
171
-		version.s = sep + 1;
172
-		version.len = _msg->first_line.u.request.version.len - (version.s - _msg->first_line.u.request.version.s);
173
-
174
-		if (version.len != SIP_VERSION_TWO_POINT_ZERO_LENGTH ||
175
-			(memcmp(version.s, SIP_VERSION_TWO_POINT_ZERO, 
176
-				SIP_VERSION_TWO_POINT_ZERO_LENGTH) != 0)) {
177
-			if (_msg->REQ_METHOD != METHOD_ACK) {
178
-				if (sanity_reply(_msg, 505, "Version Not Supported (R-URI)") == -1) {
179
-					LM_WARN("check_ruri_sip_version(): failed to send 505 via send_reply\n");
180
-				}
181
-			}
182
-			return SANITY_CHECK_FAILED;
183
-		}
184
-	}
185
-	return SANITY_CHECK_PASSED;
186
-}
187
-
188
-/* check if the r-uri scheme */
189
-int check_ruri_scheme(struct sip_msg* _msg) {
190
-
191
-	if (_msg->parsed_uri_ok == 0 &&
192
-			parse_sip_msg_uri(_msg) != 1) {
193
-		/* unsupported schemes end up here already */
194
-		LM_WARN("failed to parse request uri\n");
195
-	}
196
-	if (_msg->parsed_uri.type == ERROR_URI_T) {
197
-		if (_msg->REQ_METHOD != METHOD_ACK) {
198
-			if (sanity_reply(_msg, 416, "Unsupported URI Scheme in Request URI") == -1) {
199
-				LM_WARN("failed to send 416 via send_reply\n");
200
-			}
201
-		}
202
-		LM_DBG("check_ruri_scheme failed\n");
203
-		return SANITY_CHECK_FAILED;
204
-	}
205
-
206
-	return SANITY_CHECK_PASSED;
207
-}
208
-
209
-/* check for the presence of the minimal required headers */
210
-int check_required_headers(struct sip_msg* _msg) {
211
-
212
-	if (!check_transaction_quadruple(_msg)) {
213
-		if (_msg->REQ_METHOD != METHOD_ACK) {
214
-			if (sanity_reply(_msg, 400, "Missing Required Header in Request") == -1) {
215
-				LM_WARN("failed to send 400 via send_reply\n");
216
-			}
217
-		}
218
-		LM_DBG("check_required_headers failed\n");
219
-		return SANITY_CHECK_FAILED;
220
-	}
221
-
222
-	return SANITY_CHECK_PASSED;
223
-}
224
-
225
-/* check if the SIP version in the Via header is 2.0 */
226
-int check_via_sip_version(struct sip_msg* _msg) {
227
-
228
-	LM_DBG("this is a useless check for now; check the source code comments for details\n");
229
-	return SANITY_CHECK_PASSED;
230
-
231
-	/* FIMXE the Via parser fails already on non-2.0 versions
232
-	 * thus this check makes no sence yet
233
-	DBG("check_via_sip_version entered\n");
234
-
235
-	// FIXME via parser fails on non 2.0 number
236
-	if (parse_headers(_msg, HDR_VIA1_F, 0) != 0) {
237
-		LOG(L_WARN, "sanity_check(): check_via_sip_version(): failed to parse the first Via header\n");
238
-		return SANITY_CHECK_FAILED;
239
-	}
240
-
241
-	if (_msg->via1->version.len != 3 ||
242
-			memcmp(_msg->via1->version.s, SIP_VERSION_TWO_POINT_ZERO, 
243
-					SIP_VERSION_TWO_POINT_ZERO_LENGTH ) != 0) {
244
-		if (_msg->REQ_METHOD != METHOD_ACK) {
245
-			if (sl.reply(_msg, 505, "Version Not Supported (Via)") == -1) {
246
-				LOG(L_WARN, "sanity_check(): check_via_sip_version(): failed to send 505 via send_reply\n");
247
-			}
248
-		}
249
-		DBG("check_via_sip_version failed\n");
250
-		return SANITY_CHECK_FAILED;
251
-	}
252
-#ifdef EXTRA_DEBUG
253
-	DBG("check_via_sip_version passed\n");
254
-#endif
255
-
256
-	return SANITY_CHECK_PASSED;
257
-	*/
258
-}
259
-
260
-/* compare the protocol string in the Via header with the transport */
261
-int check_via_protocol(struct sip_msg* _msg) {
262
-
263
-	LM_DBG("this is a useless check for now; check the source code comment for details\n");
264
-	return SANITY_CHECK_PASSED;
265
-
266
-	/* FIXME as the Via parser fails already on unknown transports
267
-	 * this function makes no sence yet
268
-	DBG("check_via_protocol entered\n");
269
-
270
-	// FIXME via parser fails on unknown transport
271
-	if (parse_headers(_msg, HDR_VIA1_F, 0) != 0) {
272
-		LOG(L_WARN, "sanity_check(): check_via_protocol(): failed to parse the first Via header\n");
273
-		return SANITY_CHECK_FAILED;
274
-	}
275
-	if (_msg->via1->transport.len != 3 &&
276
-			_msg->via1->transport.len != 4) {
277
-		if (_msg->REQ_METHOD != METHOD_ACK) {
278
-			if (sl.reply(_msg, 400, "Unsupported Transport in Topmost Via") == -1) {
279
-				LOG(L_WARN, "sanity_check(): check_via_protocol(): failed to send 400 via send_reply\n");
280
-			}
281
-		}
282
-		DBG("check_via_protocol failed\n");
283
-		return SANITY_CHECK_FAILED;
284
-	}
285
-	switch (_msg->rcv.proto) {
286
-		case PROTO_UDP:
287
-			if (memcmp(_msg->via1->transport.s, "UDP", 3) != 0) {
288
-				if (_msg->REQ_METHOD != METHOD_ACK) {
289
-					if (sl.reply(_msg, 400, "Transport Missmatch in Topmost Via") == -1) {
290
-						LOG(L_WARN, "sanity_check(): check_via_protocol(): failed to send 505 via send_reply\n");
291