Browse code

- added myself==src_ip/dst_ip/uri condition - created parse_sip_msg_uri which puts the result in msg->parsed_uri & updates msg->parsed_rui_ok - changed default value of syn_branch to 1

Andrei Pelinescu-Onciul authored on 19/08/2002 11:51:31
Showing 16 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 VERSION = 0
9 9
 PATCHLEVEL = 8
10 10
 SUBLEVEL = 7
11
-EXTRAVERSION = -8-srv
11
+EXTRAVERSION = -9-self
12 12
 
13 13
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
14 14
 OS = $(shell uname -s)
... ...
@@ -99,7 +99,8 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
99 99
 	 -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
100 100
 	 -DUSE_IPV6 \
101 101
 	 -DEXTRA_DEBUG \
102
-	 -DVQ_MALLOC  -DDBG_QM_MALLOC \
102
+	 -DDBG_QM_MALLOC \
103
+	 #-DVQ_MALLOC  
103 104
 	 #-DCONTACT_BUG
104 105
 	 #-DF_MALLOC \
105 106
 	 #-DDBG_LOCK
... ...
@@ -13,6 +13,7 @@
13 13
 #include "udp_server.h"
14 14
 #include "route.h"
15 15
 #include "parser/msg_parser.h"
16
+#include "parser/parse_uri.h"
16 17
 #include "ut.h"
17 18
 #include "sr_module.h"
18 19
 #include "mem/mem.h"
... ...
@@ -48,6 +49,7 @@ int do_action(struct action* a, struct sip_msg* msg)
48 48
 	int user;
49 49
 	int err;
50 50
 	struct sip_uri uri;
51
+	struct sip_uri* u;
51 52
 	unsigned short port;
52 53
 
53 54
 	/* reset the value of error to E_UNSPEC so avoid unknowledgable
... ...
@@ -65,30 +67,24 @@ int do_action(struct action* a, struct sip_msg* msg)
65 65
 		case FORWARD_T:
66 66
 			if (a->p1_type==URIHOST_ST){
67 67
 				/*parse uri*/
68
-				if (msg->new_uri.s){
69
-						tmp=msg->new_uri.s;
70
-						len=msg->new_uri.len;
71
-				}else{
72
-						tmp=msg->first_line.u.request.uri.s;
73
-						len=msg->first_line.u.request.uri.len;
74
-				}
75
-				ret=parse_uri(tmp, len, &uri );
68
+				ret=parse_sip_msg_uri(msg);
76 69
 				if (ret<0) {
77
-					LOG(L_ERR, "ERROR: do_action: forward: bad_uri <%s>,"
78
-								" dropping packet\n",tmp);
70
+					LOG(L_ERR, "ERROR: do_action: forward: bad_uri "
71
+								" dropping packet\n");
79 72
 					break;
80 73
 				}
74
+				u=&msg->parsed_uri;
81 75
 				switch (a->p2_type){
82 76
 					case URIPORT_ST:
83
-									if (uri.port.s){
77
+									if (u->port.s){
84 78
 									 /*port=strtol(uri.port.s,&end,10);*/
85
-										port=str2s((unsigned char*)uri.port.s, 
86
-													uri.port.len, &err);
79
+										port=str2s((unsigned char*)u->port.s,
80
+													u->port.len, &err);
87 81
 										/*if ((end)&&(*end)){*/
88 82
 										if (err){
89 83
 											LOG(L_ERR, "ERROR: do_action: "
90 84
 												"forward: bad port in "
91
-												"uri: <%s>\n", uri.port.s);
85
+												"uri: <%s>\n", u->port.s);
92 86
 											ret=E_BAD_URI;
93 87
 											goto error_fwd_uri;
94 88
 										}
... ...
@@ -104,7 +100,7 @@ int do_action(struct action* a, struct sip_msg* msg)
104 104
 							goto error_fwd_uri;
105 105
 				}
106 106
 				/* create a temporary proxy*/
107
-				p=mk_proxy(uri.host.s, port);
107
+				p=mk_proxy(u->host.s, port);
108 108
 				if (p==0){
109 109
 					LOG(L_ERR, "ERROR:  bad host name in uri,"
110 110
 							" dropping packet\n");
... ...
@@ -112,7 +108,7 @@ int do_action(struct action* a, struct sip_msg* msg)
112 112
 					goto error_fwd_uri;
113 113
 				}
114 114
 				ret=forward_request(msg, p);
115
-				free_uri(&uri);
115
+				/*free_uri(&uri); -- no longer needed, in sip_msg*/
116 116
 				free_proxy(p); /* frees only p content, not p itself */
117 117
 				free(p);
118 118
 				if (ret>=0) ret=1;
... ...
@@ -299,6 +295,10 @@ int do_action(struct action* a, struct sip_msg* msg)
299 299
 				pkg_free(msg->new_uri.s);
300 300
 				msg->new_uri.len=0;
301 301
 				msg->new_uri.s=0;
302
+				if (msg->parsed_uri_ok){
303
+					msg->parsed_uri_ok=0; /* invalidate current parsed uri*/
304
+					free_uri(&msg->parsed_uri);
305
+				}
302 306
 			};
303 307
 			ret=1;
304 308
 			break;
... ...
@@ -327,6 +327,10 @@ int do_action(struct action* a, struct sip_msg* msg)
327 327
 					if (msg->new_uri.s) {
328 328
 							pkg_free(msg->new_uri.s);
329 329
 							msg->new_uri.len=0;
330
+							if (msg->parsed_uri_ok){
331
+								msg->parsed_uri_ok=0;
332
+								free_uri(&msg->parsed_uri);
333
+							}
330 334
 					}
331 335
 					len=strlen(a->p1.string);
332 336
 					msg->new_uri.s=pkg_malloc(len+1);
... ...
@@ -460,6 +464,10 @@ int do_action(struct action* a, struct sip_msg* msg)
460 460
 				if (msg->new_uri.s) pkg_free(msg->new_uri.s);
461 461
 				msg->new_uri.s=new_uri;
462 462
 				msg->new_uri.len=crt-new_uri;
463
+				if (msg->parsed_uri_ok){
464
+					msg->parsed_uri_ok=0;
465
+					free_uri(&msg->parsed_uri);
466
+				}
463 467
 				free_uri(&uri);
464 468
 				ret=1;
465 469
 				break;
... ...
@@ -508,7 +516,7 @@ error_uri:
508 508
 	if (new_uri) free(new_uri);
509 509
 	return E_UNSPEC;
510 510
 error_fwd_uri:
511
-	free_uri(&uri);
511
+	/*free_uri(&uri); -- not needed anymore, using msg->parsed_uri*/
512 512
 	return ret;
513 513
 }
514 514
 
... ...
@@ -77,6 +77,7 @@ METHOD	method
77 77
 URI		uri
78 78
 SRCIP	src_ip
79 79
 DSTIP	dst_ip
80
+MYSELF	myself
80 81
 /* operators */
81 82
 EQUAL	=
82 83
 EQUAL_T	==
... ...
@@ -180,6 +181,7 @@ EAT_ABLE	[\ \t\b\r]
180 180
 <INITIAL>{URI}	{ count(); yylval.strval=yytext; return URI; }
181 181
 <INITIAL>{SRCIP}	{ count(); yylval.strval=yytext; return SRCIP; }
182 182
 <INITIAL>{DSTIP}	{ count(); yylval.strval=yytext; return DSTIP; }
183
+<INITIAL>{MYSELF}	{ count(); yylval.strval=yytext; return MYSELF; }
183 184
 
184 185
 <INITIAL>{DEBUG}	{ count(); yylval.strval=yytext; return DEBUG; }
185 186
 <INITIAL>{FORK}		{ count(); yylval.strval=yytext; return FORK; }
... ...
@@ -81,6 +81,7 @@ void* f_tmp;
81 81
 %token URI
82 82
 %token SRCIP
83 83
 %token DSTIP
84
+%token MYSELF
84 85
 
85 86
 /* config vars. */
86 87
 %token DEBUG
... ...
@@ -427,6 +428,9 @@ exp_elem:	METHOD EQUAL_T STRING	{$$= mk_elem(	EQUAL_OP, STRING_ST,
427 427
 		| URI EQUAL_T ID 	{$$ = mk_elem(	EQUAL_OP, STRING_ST,
428 428
 											URI_O, $3); 
429 429
 				 			}
430
+		| URI EQUAL_T MYSELF    { $$=mk_elem(	EQUAL_OP, MYSELF_ST,
431
+												URI_O, 0);
432
+								}
430 433
 		| URI EQUAL_T error { $$=0; yyerror("string expected"); }
431 434
 		| URI MATCH STRING	{ $$=mk_elem(	MATCH_OP, STRING_ST,
432 435
 											URI_O, $3);
... ...
@@ -447,6 +451,9 @@ exp_elem:	METHOD EQUAL_T STRING	{$$= mk_elem(	EQUAL_OP, STRING_ST,
447 447
 		| SRCIP EQUAL_T host	{ $$=mk_elem(	EQUAL_OP, STRING_ST,
448 448
 												SRCIP_O, $3);
449 449
 								}
450
+		| SRCIP EQUAL_T MYSELF  { $$=mk_elem(	EQUAL_OP, MYSELF_ST,
451
+												SRCIP_O, 0);
452
+								}
450 453
 		| SRCIP EQUAL_T error { $$=0; yyerror( "ip address or hostname"
451 454
 						 "expected" ); }
452 455
 		| SRCIP MATCH STRING	{ $$=mk_elem(	MATCH_OP, STRING_ST,
... ...
@@ -467,6 +474,9 @@ exp_elem:	METHOD EQUAL_T STRING	{$$= mk_elem(	EQUAL_OP, STRING_ST,
467 467
 		| DSTIP EQUAL_T host	{ $$=mk_elem(	EQUAL_OP, STRING_ST,
468 468
 												DSTIP_O, $3);
469 469
 								}
470
+		| DSTIP EQUAL_T MYSELF  { $$=mk_elem(	EQUAL_OP, MYSELF_ST,
471
+												DSTIP_O, 0);
472
+								}
470 473
 		| DSTIP EQUAL_T error { $$=0; yyerror( "ip address or hostname"
471 474
 						 			"expected" ); }
472 475
 		| DSTIP MATCH STRING	{ $$=mk_elem(	MATCH_OP, STRING_ST,
... ...
@@ -478,6 +488,18 @@ exp_elem:	METHOD EQUAL_T STRING	{$$= mk_elem(	EQUAL_OP, STRING_ST,
478 478
 		| DSTIP MATCH error  { $$=0; yyerror ( "hostname  expected" ); }
479 479
 		| DSTIP error { $$=0; 
480 480
 						yyerror("invalid operator, == or =~ expected");}
481
+		| MYSELF EQUAL_T URI    { $$=mk_elem(	EQUAL_OP, MYSELF_ST,
482
+												URI_O, 0);
483
+								}
484
+		| MYSELF EQUAL_T SRCIP  { $$=mk_elem(	EQUAL_OP, MYSELF_ST,
485
+												SRCIP_O, 0);
486
+								}
487
+		| MYSELF EQUAL_T DSTIP  { $$=mk_elem(	EQUAL_OP, MYSELF_ST,
488
+												DSTIP_O, 0);
489
+								}
490
+		| MYSELF EQUAL_T error {	$$=0; 
491
+									yyerror(" URI, SRCIP or DSTIP expected"); }
492
+		| MYSELF error	{ $$=0; yyerror ("invalid operator, == expected"); }
481 493
 		| stm				{ $$=mk_elem( NO_OP, ACTIONS_ST, ACTION_O, $1 ); }
482 494
 		| NUMBER		{$$=mk_elem( NO_OP, NUMBER_ST, NUMBER_O, (void*)$1 ); }
483 495
 	;
... ...
@@ -62,6 +62,52 @@ struct socket_info* get_send_socket(union sockaddr_union* to)
62 62
 
63 63
 
64 64
 
65
+/* checks if the host is one of the address we listen on
66
+* returns 1 if true, 0 if false, -1 on error
67
+*/
68
+int check_self(str* host)
69
+{
70
+	int r;
71
+	
72
+	for (r=0; r<sock_no; r++){
73
+		DBG("check_self - checking if host==us: %d==%d && "
74
+				" [%.*s] == [%.*s]\n", 
75
+					host->len,
76
+					sock_info[r].name.len,
77
+					host->len, host->s,
78
+					sock_info[r].name.len, sock_info[r].name.s
79
+			);
80
+		if ( (host->len==sock_info[r].name.len) && 
81
+	#ifdef USE_IPV6
82
+			(strncasecmp(host->s, sock_info[r].name.s,
83
+								 sock_info[r].name.len)==0) /*slower*/
84
+	#else
85
+			(memcmp(host->s, sock_info[r].name.s, 
86
+								sock_info[r].name.len)==0)
87
+	#endif
88
+			)
89
+			break;
90
+	/* check if host == ip address */
91
+		if ( 	(!sock_info[r].is_ip) &&
92
+				(host->len==sock_info[r].address_str.len) && 
93
+	#ifdef USE_IPV6
94
+			(strncasecmp(host->s, sock_info[r].address_str.s,
95
+								 sock_info[r].address_str.len)==0) /*slower*/
96
+	#else
97
+			(memcmp(host->s, sock_info[r].address_str.s, 
98
+								sock_info[r].address_str.len)==0)
99
+	#endif
100
+			)
101
+			break;
102
+	}
103
+	if (r==sock_no){
104
+		DBG("check_self: host != me\n");
105
+		return 0;
106
+	}
107
+	return 1;
108
+}
109
+
110
+
65 111
 int forward_request( struct sip_msg* msg, struct proxy_l * p)
66 112
 {
67 113
 	unsigned int len;
... ...
@@ -247,7 +293,6 @@ int update_sock_struct_from_via( union sockaddr_union* to,
247 247
 /* removes first via & sends msg to the second */
248 248
 int forward_reply(struct sip_msg* msg)
249 249
 {
250
-	int  r;
251 250
 	char* new_buf;
252 251
 	union sockaddr_union* to;
253 252
 	struct socket_info* send_sock;
... ...
@@ -258,27 +303,7 @@ int forward_reply(struct sip_msg* msg)
258 258
 	new_buf=0;
259 259
 	/*check if first via host = us */
260 260
 	if (check_via){
261
-		for (r=0; r<sock_no; r++)
262
-		{
263
-			DBG("forward_reply - checking if via==us: %d==%d && "
264
-					" [%.*s] == [%.*s]\n", 
265
-					msg->via1->host.len,
266
-					sock_info[r].name.len,
267
-					msg->via1->host.len, msg->via1->host.s,
268
-					sock_info[r].name.len, sock_info[r].name.s
269
-				);
270
-			if ( (msg->via1->host.len==sock_info[r].name.len) && 
271
-	#ifdef USE_IPV6
272
-					(strncasecmp(msg->via1->host.s, sock_info[r].name.s,
273
-								 sock_info[r].name.len)==0) /*slower*/
274
-	#else
275
-					(memcmp(msg->via1->host.s, sock_info[r].name.s, 
276
-										sock_info[r].name.len)==0)
277
-	#endif
278
-					)
279
-				break;
280
-		}
281
-		if (r==sock_no){
261
+		if (check_self(&(msg->via1->host))!=1){
282 262
 			LOG(L_NOTICE, "ERROR: forward_reply: host in first via!=me :"
283 263
 					" %.*s\n", msg->via1->host.len, msg->via1->host.s);
284 264
 			/* send error msg back? */
... ...
@@ -13,6 +13,7 @@
13 13
 
14 14
 
15 15
 struct socket_info* get_send_socket(union sockaddr_union* su);
16
+int check_self(str* host);
16 17
 int forward_request( struct sip_msg* msg,  struct proxy_l* p);
17 18
 int update_sock_struct_from_via( union sockaddr_union* to,
18 19
 								struct via_body* via );
... ...
@@ -53,6 +53,7 @@ struct socket_info{
53 53
 	str address_str;        /* ip address converted to string -- optimization*/
54 54
 	unsigned short port_no;  /* port number */
55 55
 	str port_no_str; /* port number converted to string -- optimization*/
56
+	int is_ip; /* 1 if name is an ip address, 0 if not  -- optimization*/
56 57
 };
57 58
 
58 59
 
... ...
@@ -197,7 +197,7 @@ int log_stderr = 0;
197 197
 /* check if reply first via host==us */
198 198
 int check_via =  0;        
199 199
 /* shall use stateful synonym branches? faster but not reboot-safe */
200
-int syn_branch = 0;
200
+int syn_branch = 1;
201 201
 /* should replies include extensive warnings? by default yes,
202 202
    good for trouble-shooting
203 203
 */
... ...
@@ -956,8 +956,14 @@ int main(int argc, char** argv)
956 956
 			goto error;
957 957
 		}
958 958
 		strncpy(sock_info[r].address_str.s, tmp, strlen(tmp)+1);
959
+		/* set is_ip (1 if name is an ip address, 0 otherwise) */
959 960
 		sock_info[r].address_str.len=strlen(tmp);
960
-		
961
+		if 	(	(sock_info[r].address_str.len==sock_info[r].name.len)&&
962
+				(strncasecmp(sock_info[r].address_str.s, sock_info[r].name.s,
963
+						 sock_info[r].address_str.len)==0)
964
+			)	sock_info[r].is_ip=1;
965
+		else sock_info[r].is_ip=0;
966
+			
961 967
 		if (sock_info[r].port_no==0) sock_info[r].port_no=port_no;
962 968
 		port_no_str_len=snprintf(port_no_str, MAX_PORT_LEN, ":%d", 
963 969
 									(unsigned short) sock_info[r].port_no);
... ...
@@ -18,6 +18,7 @@
18 18
 #include "../error.h"
19 19
 #include "../globals.h"
20 20
 #include "parse_hname2.h"
21
+#include "parse_uri.h"
21 22
 
22 23
 #ifdef DEBUG_DMALLOC
23 24
 #include <mem/dmalloc.h>
... ...
@@ -463,6 +464,7 @@ void free_sip_msg(struct sip_msg* msg)
463 463
 	if (msg->add_rm)      free_lump_list(msg->add_rm);
464 464
 	if (msg->repl_add_rm) free_lump_list(msg->repl_add_rm);
465 465
 	if (msg->reply_lump)   free_reply_lump(msg->reply_lump);
466
+	if (msg->parsed_uri_ok) free_uri(&msg->parsed_uri);
466 467
 	pkg_free(msg->orig);
467 468
 	/* don't free anymore -- now a pointer to a static buffer */
468 469
 #	ifdef DYN_BUF
... ...
@@ -14,7 +14,6 @@
14 14
 #include "parse_cseq.h"
15 15
 #include "parse_to.h"
16 16
 #include "parse_via.h"
17
-#include "parse_uri.h"
18 17
 #include "parse_fline.h"
19 18
 #include "hf.h"
20 19
 
... ...
@@ -46,6 +45,18 @@ if (  (*tmp==(firstchar) || *tmp==((firstchar) | 32)) &&                  \
46 46
 }
47 47
 
48 48
 
49
+
50
+struct sip_uri {
51
+	str user;     /* Username */
52
+	str passwd;   /* Password */
53
+	str host;     /* Host name */
54
+	str port;     /* Port number */
55
+	str params;   /* Parameters */
56
+	str headers;  
57
+};
58
+
59
+
60
+
49 61
 struct sip_msg {
50 62
 	unsigned int id;               /* message id, unique/process*/
51 63
 	struct msg_start first_line;   /* Message first line */
... ...
@@ -96,6 +107,8 @@ struct sip_msg {
96 96
 	     /* modifications */
97 97
 	
98 98
 	str new_uri; /* changed first line uri*/
99
+	int parsed_uri_ok; /* 1 if parsed_uri is valid, 0 if not */
100
+	struct sip_uri parsed_uri; /* speed-up > keep here the parsed uri*/
99 101
 	
100 102
 	struct lump* add_rm;         /* used for all the forwarded requests */
101 103
 	struct lump* repl_add_rm;    /* used for all the forwarded replies */
... ...
@@ -192,6 +192,33 @@ error:
192 192
 }
193 193
 
194 194
 
195
+
196
+int parse_sip_msg_uri(struct sip_msg* msg)
197
+{
198
+	char* tmp;
199
+	int tmp_len;
200
+	if (msg->parsed_uri_ok) return 1;
201
+	else{
202
+		if (msg->new_uri.s){
203
+			tmp=msg->new_uri.s;
204
+			tmp_len=msg->new_uri.len;
205
+		}else{
206
+			tmp=msg->first_line.u.request.uri.s;
207
+			tmp_len=msg->first_line.u.request.uri.len;
208
+		}
209
+		if (parse_uri(tmp, tmp_len, &msg->parsed_uri)<0){
210
+			LOG(L_ERR, "ERROR: parse_sip_msg_uri: bad uri <%*s>\n",
211
+						tmp_len, tmp);
212
+			msg->parsed_uri_ok=0;
213
+			return -1;
214
+		}
215
+		msg->parsed_uri_ok=1;
216
+		return 1;
217
+	}
218
+}
219
+
220
+
221
+
195 222
 void free_uri(struct sip_uri* u)
196 223
 {
197 224
 	if (u) {
... ...
@@ -11,15 +11,8 @@
11 11
 
12 12
 
13 13
 #include "../str.h"
14
+#include "../parser/msg_parser.h"
14 15
 
15
-struct sip_uri {
16
-	str user;     /* Username */
17
-	str passwd;   /* Password */
18
-	str host;     /* Host name */
19
-	str port;     /* Port number */
20
-	str params;   /* Parameters */
21
-	str headers;  
22
-};
23 16
 
24 17
 
25 18
 /* buf= pointer to begining of uri (sip:x@foo.bar:5060;a=b?h=i)
... ...
@@ -27,6 +20,7 @@ struct sip_uri {
27 27
  * returns: fills uri & returns <0 on error or 0 if ok 
28 28
  */
29 29
 int parse_uri(char *buf, int len, struct sip_uri* uri);
30
+int parse_sip_msg_uri(struct sip_msg* msg);
30 31
 
31 32
 void free_uri(struct sip_uri* u);
32 33
 
... ...
@@ -16,12 +16,14 @@
16 16
 #include <netdb.h>
17 17
 
18 18
 #include "route.h"
19
+#include "forward.h"
19 20
 #include "dprint.h"
20 21
 #include "proxy.h"
21 22
 #include "action.h"
22 23
 #include "sr_module.h"
23 24
 #include "ip_addr.h"
24 25
 #include "resolve.h"
26
+#include "parser/parse_uri.h"
25 27
 
26 28
 #ifdef DEBUG_DMALLOC
27 29
 #include <dmalloc.h>
... ...
@@ -242,6 +244,7 @@ static int comp_ip(struct ip_addr* ip, void* param, int op, int subtype)
242 242
 	struct hostent* he;
243 243
 	char ** h;
244 244
 	int ret;
245
+	str tmp;
245 246
 
246 247
 	ret=-1;
247 248
 	switch(subtype){
... ...
@@ -275,6 +278,11 @@ static int comp_ip(struct ip_addr* ip, void* param, int op, int subtype)
275 275
 				}
276 276
 			}
277 277
 			break;
278
+		case MYSELF_ST: /* check if it's one of our addresses*/
279
+			tmp.s=ip_addr2a(ip);
280
+			tmp.len=strlen(tmp.s);
281
+			ret=check_self(&tmp);
282
+			break;
278 283
 		default:
279 284
 			LOG(L_CRIT, "BUG: comp_ip: invalid type for "
280 285
 						" src_ip or dst_ip (%d)\n", subtype);
... ...
@@ -304,11 +312,21 @@ static int eval_elem(struct expr* e, struct sip_msg* msg)
304 304
 				break;
305 305
 		case URI_O:
306 306
 				if(msg->new_uri.s){
307
-					ret=comp_str(msg->new_uri.s, e->r.param,
308
-									e->op, e->subtype);
307
+					if (e->subtype==MYSELF_ST){
308
+						if (parse_sip_msg_uri(msg)<0) ret=-1;
309
+						else	ret=check_self(&msg->parsed_uri.host);
310
+					}else{
311
+						ret=comp_str(msg->new_uri.s, e->r.param,
312
+										e->op, e->subtype);
313
+					}
309 314
 				}else{
310
-					ret=comp_str(msg->first_line.u.request.uri.s, e->r.param,
311
-									e->op, e->subtype);
315
+					if (e->subtype==MYSELF_ST){
316
+						if (parse_sip_msg_uri(msg)<0) ret=-1;
317
+						else	ret=check_self(&msg->parsed_uri.host);
318
+					}else{
319
+						ret=comp_str(msg->first_line.u.request.uri.s,
320
+										 e->r.param, e->op, e->subtype);
321
+					}
312 322
 				}
313 323
 				break;
314 324
 		case SRCIP_O:
... ...
@@ -160,6 +160,9 @@ void print_expr(struct expr* exp)
160 160
 			case NUMBER_ST:
161 161
 					DBG("%d",exp->r.intval);
162 162
 					break;
163
+			case MYSELF_ST:
164
+					DBG("_myself_");
165
+					break;
163 166
 			default:
164 167
 					DBG("type<%d>", exp->subtype);
165 168
 		}
... ...
@@ -32,7 +32,8 @@ enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
32 32
 		APPEND_BRANCH_T,
33 33
 		REVERT_URI_T };
34 34
 enum { NOSUBTYPE=0, STRING_ST, NET_ST, NUMBER_ST, IP_ST, RE_ST, PROXY_ST,
35
-		EXPR_ST, ACTIONS_ST, CMDF_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST };
35
+		EXPR_ST, ACTIONS_ST, CMDF_ST, MODFIXUP_ST, URIHOST_ST, URIPORT_ST,
36
+		MYSELF_ST };
36 37
 
37 38
 	
38 39
 struct expr{
... ...
@@ -22,12 +22,16 @@ rev_dns=off      # (cmd. line: -R)
22 22
 #listen=127.0.0.1
23 23
 #listen=192.168.57.33
24 24
 #listen=192.168.57.72
25
-loop_checks=0
25
+#loop_checks=0
26 26
 # for more info: sip_router -h
27 27
 
28 28
 #modules
29 29
 
30 30
 
31 31
 route{
32
+	if (myself==uri){
33
+		log("\n\nfrom myself\n\n"); drop;
34
+	};
35
+	log("\n\n continue \n\n");
32 36
 	forward(uri:host, uri:port);
33 37
 }