Browse code

various small fixes

Jiri Kuthan authored on 10/06/2002 19:00:19
Showing 7 changed files
... ...
@@ -10,9 +10,9 @@ auto_gen=lex.yy.c cfg.tab.c   #lexx, yacc etc
10 10
 #include  source related defs
11 11
 include Makefile.sources
12 12
 
13
-exclude_modules=CVS mysql 
13
+exclude_modules=CVS 
14 14
 #mysql auth rr
15
-static_modules=
15
+static_modules=tm
16 16
 static_modules_path=$(addprefix modules/, $(static_modules))
17 17
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
18 18
 extra_objs=$(extra_sources:.c=.o)
... ...
@@ -1,4 +1,8 @@
1
+<<<<<<< Makefile.defs
1 2
 # $Id$
3
+=======
4
+# $Id$
5
+>>>>>>> 1.99
2 6
 #
3 7
 # makefile defs (CC, LD,a.s.o)
4 8
 #
... ...
@@ -7,7 +11,7 @@
7 7
 #version number
8 8
 VERSION = 0
9 9
 PATCHLEVEL = 8
10
-SUBLEVEL = 8
10
+SUBLEVEL = 7
11 11
 EXTRAVERSION = -3-ipv6
12 12
 
13 13
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
... ...
@@ -74,22 +78,21 @@ ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
74 74
 # -DNEW_HNAME
75 75
 #		32-bit header name parsing; turn off for lower speed ;-) or debugging;
76 76
 #		to become non-optional if fast and stable
77
-# -DSILENT_FR
77
+# -SILENT_FR
78 78
 #		if defined, when FR timer hits (in tm) cancel is sent only if forking
79 79
 #		if used; otherwise, just delete the transaction without doing anything
80
-# -DUSE_IPV6
81
-#		compiles ipv6 support
82 80
 
83 81
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
84 82
 	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
85
-	 -DDNS_IP_HACK  -DPKG_MALLOC \
83
+	 -DPKG_MALLOC \
86 84
 	 -DF_MALLOC \
87 85
 	 -DSHM_MEM  -DSHM_MMAP \
88 86
 	 -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
89 87
 	 -DWAIT -DNEW_HNAME \
88
+	 -DSILENT_FR \
90 89
 	 -DUSE_IPV6 \
91
-	 -DVERY_NOISY_REPLIES\
92
-	 #-DSILENT_FR \
90
+	 -DNOISY_REPLIES -DVERY_NOISY_REPLIES\
91
+ 	 #-DUSE_SYNONIM\
93 92
 	 #-DNO_DEBUG \
94 93
 	 #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
95 94
 	 #-DNOSMP \
... ...
@@ -230,7 +233,7 @@ ifeq	($(ARCH), sparc64)
230 230
 ifeq		($(CC_NAME), gcc)
231 231
 				#common stuff
232 232
 				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
233
-					-Wall #-Wmissing-prototypes \
233
+					#-Wmissing-prototypes \
234 234
 				#if gcc 3.0
235 235
 ifeq			($(CC_SHORTVER), 3.0)
236 236
 					#use 32bit for now
... ...
@@ -318,7 +321,7 @@ endif
318 318
 	# -andrei
319 319
 else	#mode,release
320 320
 ifeq	($(CC_NAME), gcc)
321
-		CFLAGS=-g -Wcast-align -Winline $(PROFILE) -Wall
321
+		CFLAGS=-g -Wcast-align -Winline $(PROFILE)
322 322
 		LDFLAGS+=-g -Wl,-E $(PROFILE)
323 323
 endif
324 324
 ifeq	($(CC_NAME), icc)
... ...
@@ -375,8 +378,7 @@ ifeq  ($(OS), SunOS)
375 375
 ifeq ($(CC_NAME), suncc)
376 376
 	LIBS=-lfast
377 377
 endif
378
-	LIBS+=-ldl -L/usr/local/lib -L/usr/lib/mysql -lfl -lresolv -lnsl \
379
-		-lsocket -lrt
378
+	LIBS+=-ldl -L/usr/local/lib -L/usr/lib/mysql -lfl -lxnet -lrt
380 379
 	# -lrt needed for sched_yield
381 380
 endif
382 381
 
... ...
@@ -123,8 +123,8 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
123 123
 
124 124
 	/*computing the length of entire sip_msg structure*/
125 125
 	len = ROUND4(sizeof( struct sip_msg ));
126
-	/*we will keep only the original msg*/
127
-	len += ROUND4(org_msg->len);
126
+	/*we will keep only the original msg +ZT */
127
+	len += ROUND4(org_msg->len + 1);
128 128
 	/*the new uri (if any)*/
129 129
 	if (org_msg->new_uri.s && org_msg->new_uri.len)
130 130
 		len+= ROUND4(org_msg->new_uri.len);
... ...
@@ -206,8 +206,10 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
206 206
 	}
207 207
 	/* message buffers(org and scratch pad) */
208 208
 	memcpy( p , org_msg->orig , org_msg->len);
209
+	/* ZT to be safer */
210
+	*(p+org_msg->len)=0;
209 211
 	new_msg->orig = new_msg->buf = p;
210
-	p += ROUND4(new_msg->len);
212
+	p += ROUND4(new_msg->len+1);
211 213
 	/* unparsed and eoh pointer */
212 214
 	new_msg->unparsed = translate_pointer(new_msg->buf ,org_msg->buf,
213 215
 		org_msg->unparsed );
... ...
@@ -48,13 +48,15 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
48 48
 	via = 0;
49 49
 	p_msg = Trans->uas.request;
50 50
 
51
-	len = 0;
52
-	/*first line's len - CANCEL and INVITE has the same lenght */
53
-	len += ( REQ_LINE(p_msg).version.s+REQ_LINE(p_msg).version.len)-
54
-		REQ_LINE(p_msg).method.s+CRLF_LEN;
55
-	/*check if the REQ URI was override */
51
+	/* method, separators, version */
52
+	len=SIP_VERSION_LEN + CANCEL_LEN + 2 /* spaces */ + CRLF_LEN;
53
+	/* if URL was overridden .... */
56 54
 	if (Trans->uac[branch].uri.s)
57
-		len += Trans->uac[branch].uri.len - REQ_LINE(p_msg).uri.len;
55
+		len+=Trans->uac[branch].uri.len;
56
+	else
57
+	/* ... otherwise use the inbound URL */
58
+		len+=REQ_LINE(p_msg).uri.len;
59
+
58 60
 	/*via*/
59 61
 	if ( add_branch_label(Trans,p_msg,branch)==-1 )
60 62
 		goto error;
... ...
@@ -67,16 +69,18 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
67 67
 	}
68 68
 	len+= via_len;
69 69
 	/*headers*/
70
-	for ( hdr=p_msg->headers ; hdr ; hdr=hdr->next )
71
-		if (hdr->type==HDR_FROM || hdr->type==HDR_CALLID || 
72
-			hdr->type==HDR_CSEQ || hdr->type==HDR_TO )
70
+	for ( hdr=p_msg->headers ; hdr ; hdr=hdr->next ) {
71
+		if (hdr->type==HDR_FROM || hdr->type==HDR_CALLID 
72
+			|| hdr->type==HDR_TO )
73 73
 			len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN ;
74
-	/* User Agent header*/
75
-	len += USER_AGENT_LEN + CRLF_LEN;
76
-	/* Content Lenght heder*/
77
-	len += CONTENT_LEN_LEN + CRLF_LEN;
78
-	/* end of message */
79
-	len += CRLF_LEN;
74
+		else if (hdr->type==HDR_CSEQ)
75
+			len += hdr->name.len + 2 + ((struct cseq_body*)hdr->parsed)->number.len +
76
+				1+CANCEL_LEN+CRLF_LEN;
77
+	}
78
+	/* User Agent, Conteny Length, EoM */
79
+	len += USER_AGENT_LEN + CRLF_LEN +
80
+		CONTENT_LEN_LEN + CRLF_LEN +
81
+		CRLF_LEN;
80 82
 
81 83
 	cancel_buf=sh_malloc( len+1 );
82 84
 	if (!cancel_buf)
... ...
@@ -86,24 +90,16 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
86 86
 	}
87 87
 	p = cancel_buf;
88 88
 
89
-	/* first line -> do we have a new URI? */
90
-	if (Trans->uac[branch].uri.s)
91
-	{
92
-		append_mem_block(p,REQ_LINE(p_msg).method.s,
93
-			REQ_LINE(p_msg).uri.s-REQ_LINE(p_msg).method.s);
94
-		append_mem_block(p,Trans->uac[branch].uri.s,
89
+	append_mem_block( p, CANCEL " ", CANCEL_LEN +1 );
90
+	if (Trans->uac[branch].uri.s) {
91
+		append_mem_block( p, Trans->uac[branch].uri.s, 
95 92
 			Trans->uac[branch].uri.len);
96
-		append_mem_block(p,REQ_LINE(p_msg).uri.s+REQ_LINE(p_msg).uri.len,
97
-			REQ_LINE(p_msg).version.s+REQ_LINE(p_msg).version.len-
98
-			(REQ_LINE(p_msg).uri.s+REQ_LINE(p_msg).uri.len))
99
-	}else{
100
-		append_mem_block(p,REQ_LINE(p_msg).method.s,
101
-			REQ_LINE(p_msg).version.s+REQ_LINE(p_msg).version.len-
102
-			REQ_LINE(p_msg).method.s);
93
+	} else {
94
+		append_mem_block(p,REQ_LINE(p_msg).uri.s,
95
+			REQ_LINE(p_msg).uri.len );
103 96
 	}
104
-	/* changhing method name*/
105
-	memcpy(cancel_buf, CANCEL , CANCEL_LEN );
106
-	append_mem_block(p,CRLF,CRLF_LEN);
97
+	append_mem_block( p, " " SIP_VERSION CRLF, 1+SIP_VERSION_LEN+CRLF_LEN );
98
+
107 99
 	/* insert our via */
108 100
 	append_mem_block(p,via,via_len);
109 101
 
... ...
@@ -115,22 +111,19 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
115 115
 			append_mem_block(p,hdr->name.s,
116 116
 				((hdr->body.s+hdr->body.len)-hdr->name.s) );
117 117
 			append_mem_block(p, CRLF, CRLF_LEN );
118
-		}else if ( hdr->type==HDR_CSEQ )
118
+		} else if ( hdr->type==HDR_CSEQ )
119 119
 		{
120
-			append_mem_block(p,hdr->name.s,
121
-				((((struct cseq_body*)hdr->parsed)->method.s)-hdr->name.s));
122
-			append_mem_block(p, CANCEL CRLF, CANCEL_LEN +CRLF_LEN );
120
+			append_mem_block(p,hdr->name.s, hdr->name.len );
121
+			append_mem_block(p,": ", 2 );
122
+			append_mem_block(p, ((struct cseq_body*)hdr->parsed)->number.s,
123
+				((struct cseq_body*)hdr->parsed)->number.len );
124
+			append_mem_block(p, " " CANCEL CRLF, 1+CANCEL_LEN+CRLF_LEN);
123 125
 		}
124
-}
126
+	}
125 127
 
126
-	/* User Agent header */
127
-	append_mem_block(p,USER_AGENT,USER_AGENT_LEN);
128
-	append_mem_block(p,CRLF,CRLF_LEN);
129
-	/* Content Lenght header*/
130
-	append_mem_block(p,CONTENT_LEN,CONTENT_LEN_LEN);
131
-	append_mem_block(p,CRLF,CRLF_LEN);
132
-	/* end of message */
133
-	append_mem_block(p,CRLF,CRLF_LEN);
128
+	/* User Agent header, Content Length, EoM */
129
+	append_mem_block(p,USER_AGENT CRLF CONTENT_LEN CRLF CRLF ,
130
+		USER_AGENT_LEN + CRLF_LEN + CONTENT_LEN_LEN + CRLF_LEN + CRLF_LEN);
134 131
 	*p=0;
135 132
 
136 133
 	if (Trans->uac[branch].request.cancel) {
... ...
@@ -93,7 +93,12 @@ inline void final_response_handler( void *attr)
93 93
 	{
94 94
 		DBG("DEBUG: FR_handler:stop retr. and send CANCEL (%p)\n",r_buf->my_T);
95 95
 		reset_timer( hash_table, &(r_buf->retr_timer) );
96
-		t_build_and_send_CANCEL( r_buf->my_T ,r_buf->branch);
96
+		/* BUG -- we want CANCELs actually ONLY for INVITE; BTW, the
97
+		   CANCEL construction method results for non-INVITEs in
98
+		   bizzar messages such as "CANCELS" for OPTIONS; -Jiri
99
+		*/
100
+		if (r_buf->my_T->uas.request->first_line.u.request.method_value==METHOD_INVITE)
101
+			t_build_and_send_CANCEL( r_buf->my_T ,r_buf->branch);
97 102
 		/* dirty hack:t_send_reply would increase ref_count which would indeed
98 103
 		result in refcount++ which would not -- until timer processe's
99 104
 		T changes again; currently only on next call to t_send_reply from
... ...
@@ -42,6 +42,9 @@ int receive_msg(char* buf, unsigned int len, union sockaddr_union* src_su)
42 42
 	/* fill in msg */
43 43
 	msg->buf=buf;
44 44
 	msg->len=len;
45
+	/* zero termination (termination of orig message bellow not that
46
+	   useful as most of the work is done with scrath-pad; -jiri  */
47
+	buf[len]=0;
45 48
 	su2ip_addr(&msg->src_ip, src_su);
46 49
 	msg->dst_ip=bind_address->address; /* won't work if listening on 0.0.0.0 */
47 50
 	msg->id=msg_no;
... ...
@@ -1,6 +1,6 @@
1 1
 BYE sip:jiri@bat.iptel.org SIP/2.0
2 2
 Max-Forwards: 0
3
-Via: SIP/2.0/UDP 195.37.77.101;branch=df6250bb14ccda4a69dc0502173d02b2.e0e.0
3
+Via: SIP/2.0/UDP 195.37.77.100;branch=df6250bb14ccda4a69dc0502173d02b2.e0e.0
4 4
 Via: SIP/2.0/UDP 213.20.228.21:13671
5 5
 From: "jiri" <sip:jiri@iptel.org>;tag=9c77afe9-71ec-4c52-a009-f2869fba848b
6 6
 To: <sip:jiri@bat.iptel.org>;tag=9c77afe9-71ec-4c52-a009-f2869fba848b