Browse code

adding interoperability with TurboSIP

Jiri Kuthan authored on 12/01/2002 02:33:31
Showing 5 changed files
... ...
@@ -53,8 +53,9 @@ ARCH = $(shell uname -s)
53 53
 
54 54
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
55 55
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
56
-	-DEXTRA_DEBUG \
57
-	-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
56
+	-DVQ_MALLOC -DBRUT_HACK
57
+	#-DEXTRA_DEBUG -DBRUT_HACK \
58
+	#-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
58 59
 	  #-DDBG_QM_MALLOC #-DVQ_MALLOC #-DNO_DEBUG
59 60
 	  #-DNO_DEBUG #-DDBG_QM_MALLOC
60 61
 #-DEXTRA_DEBUG
... ...
@@ -64,9 +65,9 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
64 65
 #-DNO_DEBUG#-DSTATS -DNO_DEBUG 
65 66
 #-DNO_LOG
66 67
 
67
-PROFILE=  -pg #set this if you want profiling
68
-mode = debug
69
-#mode = release
68
+#PROFILE=  -pg #set this if you want profiling
69
+#mode = debug
70
+mode = release
70 71
 
71 72
 # platform dependent settings
72 73
 
... ...
@@ -39,4 +39,11 @@
39 39
 */
40 40
 #define REPLY_OVERBUFFER_LEN 160
41 41
 
42
+/* character which separates individual parts of MPLS-ized branch */
43
+#ifdef BRUT_HACK
44
+#	define BRANCH_SEPARATOR 'X'
45
+#else
46
+#	define BRANCH_SEPARATOR '.'
47
+#endif
48
+
42 49
 #endif
... ...
@@ -3,13 +3,14 @@
3 3
  *
4 4
  */
5 5
 
6
-#include "hash_func.h"
7
-#include "t_funcs.h"
8 6
 #include "../../dprint.h"
9 7
 #include "../../config.h"
10 8
 #include "../../parser_f.h"
11 9
 #include "../../ut.h"
12 10
 #include "../../timer.h"
11
+#include "hash_func.h"
12
+#include "t_funcs.h"
13
+#include "config.h"
13 14
 
14 15
 static int reverse_hex2int( char *c, int len )
15 16
 {
... ...
@@ -221,25 +222,25 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch )
221 222
    scan_space=p_msg->via1->branch->value.len;
222 223
 
223 224
    /* loop detection ... ignore */
224
-   n=eat_token2_end( p, p+scan_space, '.');
225
+   n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR );
225 226
    scan_space-=n-p;
226
-   if (n==p || scan_space<2 || *n!='.') goto nomatch2;
227
+   if (n==p || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
227 228
    p=n+1; scan_space--;
228 229
 
229 230
    /* hash_id */
230
-   n=eat_token2_end( p, p+scan_space, '.');
231
+   n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR);
231 232
    hashl=n-p;
232 233
    scan_space-=hashl;
233
-   if (!hashl || scan_space<2 || *n!='.') goto nomatch2;
234
+   if (!hashl || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
234 235
    hashi=p;
235 236
    p=n+1;scan_space--;
236 237
 
237 238
 
238 239
    /* sequence id */
239
-   n=eat_token2_end( p, p+scan_space, '.');
240
+   n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR);
240 241
    synl=n-p;
241 242
    scan_space-=synl;
242
-   if (!synl || scan_space<2 || *n!='.') goto nomatch2;
243
+   if (!synl || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
243 244
    syni=p;
244 245
    p=n+1;scan_space--;
245 246
 
... ...
@@ -377,11 +378,11 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
377 378
 	begin=p_msg->add_to_branch_s+p_msg->add_to_branch_len;
378 379
 	orig_size = size=MAX_BRANCH_PARAM_LEN - p_msg->add_to_branch_len;
379 380
 
380
-	if (size) { *begin='.'; begin++; size--; } else return -1;
381
+	if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
381 382
 	if (int2reverse_hex( &begin, &size, trans->hash_index)==-1) return -1;
382
-	if (size) { *begin='.'; begin++; size--; } else return -1;
383
+	if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
383 384
 	if (int2reverse_hex( &begin, &size, trans->label)==-1) return -1;
384
-	if (size) { *begin='.'; begin++; size--; } else return -1;
385
+	if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
385 386
 	if (int2reverse_hex( &begin, &size, branch)==-1) return -1;
386 387
 
387 388
 	p_msg->add_to_branch_len+=(orig_size-size);
... ...
@@ -540,6 +540,9 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
540 540
 	unsigned int       len,foo;
541 541
 	struct hdr_field  *hdr;
542 542
 	int                       i;
543
+#ifdef BRUT_HACK
544
+	struct hdr_field  *to, *from, *callid, *cseq, *via;
545
+#endif
543 546
 
544 547
 	/* force parsing all headers -- we want to return all
545 548
 	Via's in the reply and they may be scattered down to the
... ...
@@ -553,10 +556,22 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
553 556
 	len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ + strlen(text) + CRLF_LEN/*new line*/;
554 557
 	/*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/
555 558
 	for ( hdr=msg->headers ; hdr ; hdr=hdr->next )
559
+#ifdef BRUT_HACK
560
+	{
561
+		len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN;
562
+		if ( hdr->type==HDR_VIA ) via = hdr;
563
+		else if ( hdr->type==HDR_FROM) from = hdr;
564
+		else if (hdr->type==HDR_CALLID) callid = hdr;
565
+		else if ( hdr->type==HDR_TO) to = hdr;
566
+		else if ( hdr->type==HDR_CSEQ) cseq = hdr;
567
+		else len-=((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN;
568
+	}
569
+#else
556 570
 		if ( hdr->type==HDR_VIA || hdr->type==HDR_FROM ||
557 571
 				hdr->type==HDR_CALLID || hdr->type==HDR_TO ||
558 572
 				hdr->type==HDR_CSEQ )
559 573
 			len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN;
574
+#endif
560 575
 	/* end of message */
561 576
 	len += CRLF_LEN; /*new line*/
562 577
 
... ...
@@ -585,6 +600,20 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
585 600
 	memcpy( p, CRLF, CRLF_LEN );
586 601
 	p+=CRLF_LEN;
587 602
 	/* headers*/
603
+#ifdef BRUT_HACK
604
+#define	COPY_HF(_hf) memcpy(p, msg->orig+(_hf->name.s-msg->buf), \
605
+			((_hf->body.s+_hf->body.len ) - \
606
+			_hf->name.s )); \
607
+			p+=((_hf->body.s+_hf->body.len)-_hf->name.s ) ; \
608
+			memcpy( p, CRLF, CRLF_LEN ); \
609
+			p+=CRLF_LEN;
610
+
611
+	COPY_HF(via);
612
+	COPY_HF(from);
613
+	COPY_HF(to);
614
+	COPY_HF(callid);
615
+	COPY_HF(cseq);
616
+#else
588 617
 	for ( hdr=msg->headers ; hdr ; hdr=hdr->next )
589 618
 		if ( hdr->type==HDR_VIA || hdr->type==HDR_FROM ||
590 619
 		hdr->type==HDR_CALLID || hdr->type==HDR_TO || hdr->type==HDR_CSEQ )
... ...
@@ -596,6 +625,7 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
596 625
 			memcpy( p, CRLF, CRLF_LEN );
597 626
 			p+=CRLF_LEN;
598 627
 		}
628
+#endif
599 629
 
600 630
 	memcpy( p, CRLF, CRLF_LEN );
601 631
 	p+=CRLF_LEN;
... ...
@@ -4,21 +4,21 @@
4 4
 # $ID: $
5 5
 #
6 6
 
7
-debug=4          # debug level (cmd line: -dddddddddd)
7
+debug=1          # debug level (cmd line: -dddddddddd)
8 8
 fork=yes          # (cmd. line: -D)
9 9
 #fork=no
10
-log_stderror=yes # (cmd line: -E)
11
-#log_stderror=no	# (cmd line: -E)
10
+#log_stderror=yes # (cmd line: -E)
11
+log_stderror=no	# (cmd line: -E)
12 12
 
13 13
 
14
-children=2
14
+children=8
15 15
 check_via=yes     # (cmd. line: -v)
16 16
 dns=on           # (cmd. line: -r)
17 17
 rev_dns=yes      # (cmd. line: -R)
18 18
 port=5080
19 19
 #listen=127.0.0.1
20 20
 listen=195.37.77.101
21
-loop_checks=1
21
+loop_checks=0
22 22
 # for more info: sip_router -h
23 23
 
24 24
 #modules
... ...
@@ -74,7 +74,7 @@ route[0]{
74 74
 				};
75 75
 			} else {
76 76
 				log("SER: replying\n");
77
-				if (! t_send_reply("100", "trying -- your call is important to us")
77
+				if (! t_send_reply("100", "Trying")
78 78
 					){
79 79
 					log("SER: ERROR: t_send_reply (100)\n");
80 80
 				} else log("SER: t_send_reply ok\n");
... ...
@@ -84,7 +84,7 @@ route[0]{
84 84
 					log("SER:ERROR: t_forward (..., 5555)\n");
85 85
 				} else log("SER: t_forward ok\n");
86 86
 			} else if (method=="BYE") {
87
-				if (! t_forward("bat.iptel.org", "5090")){
87
+				if (! t_forward("bat.iptel.org", "5000")){
88 88
 					log("SER:ERROR: t_forward (..., 5555)\n");
89 89
 				} else log("SER: t_forward ok\n");
90 90
 			} else log("SER: ERROR unknwon request\n");