Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 11/02/2002 12:00:21
Showing 6 changed files
... ...
@@ -33,6 +33,9 @@
33 33
 #define MY_VIA "Via: SIP/2.0/UDP "
34 34
 #define MY_VIA_LEN 17
35 35
 
36
+#define CONTENT_LEN "Content-Length: 0"
37
+#define CONTENT_LEN_LEN 17
38
+
36 39
 #define MY_BRANCH ";branch=0"
37 40
 #define MY_BRANCH_LEN 9
38 41
 
... ...
@@ -150,10 +150,10 @@ struct cell*  build_cell( struct sip_msg* p_msg )
150 150
    /* filling with 0 */
151 151
    memset( new_cell, 0, sizeof( struct cell ) );
152 152
 
153
-	new_cell->outbound_response.retr_timer.tg=TG_RT;
154
-	new_cell->outbound_response.fr_timer.tg=TG_FR;
155
-	new_cell->wait_tl.tg=TG_WT;
156
-	new_cell->dele_tl.tg=TG_DEL;
153
+   new_cell->outbound_response.retr_timer.tg=TG_RT;
154
+   new_cell->outbound_response.fr_timer.tg=TG_FR;
155
+   new_cell->wait_tl.tg=TG_WT;
156
+   new_cell->dele_tl.tg=TG_DEL;
157 157
 
158 158
    /* hash index of the entry */
159 159
    /* new_cell->hash_index = hash( p_msg->callid->body , get_cseq(p_msg)->number ); */
... ...
@@ -67,26 +67,22 @@ static inline void reset_retr_timers( struct s_table *h_table,
67 67
 	/* lock the first timer list of the FR group -- all other
68 68
 	   lists share the same lock
69 69
 	*/
70
-	lock(  hash_table->timers[FR_TIMER_LIST].mutex );
71
-	/* reset_timer( h_table, &(p_cell->outbound_response.retr_timer)); */
70
+	lock(  hash_table->timers[RT_T1_TO_1].mutex );
72 71
 	remove_timer_unsafe( & p_cell->outbound_response.retr_timer );
73
-	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  { 
72
+	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  {
74 73
 			if ( rb = p_cell->outbound_request[ijk] ) {
75
-				/* reset_timer(h_table, &(rb->retr_timer)); */
76 74
 				remove_timer_unsafe( & rb->retr_timer );
77 75
 			}
78
-		} 
79
-	unlock(  hash_table->timers[FR_TIMER_LIST].mutex );
80
-	lock(  hash_table->timers[RT_T1_TO_1].mutex );
81
-	/* reset_timer( h_table, &(p_cell->outbound_response.fr_timer)); */
76
+		}
77
+	unlock(  hash_table->timers[RT_T1_TO_1].mutex );
78
+	lock(  hash_table->timers[FR_TIMER_LIST].mutex );
82 79
 	remove_timer_unsafe( & p_cell->outbound_response.fr_timer );
83
-	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  { 
80
+	for( ijk=0 ; ijk<(p_cell)->nr_of_outgoings ; ijk++ )  {
84 81
 			if ( rb = p_cell->outbound_request[ijk] ) {
85
-				/* reset_timer(h_table, &(rb->fr_timer)); */
86 82
 				remove_timer_unsafe( & rb->fr_timer );
87 83
 			}
88
-		} 
89
-	unlock(  hash_table->timers[RT_T1_TO_1].mutex );
84
+		}
85
+	unlock(  hash_table->timers[FR_TIMER_LIST].mutex );
90 86
 	DBG("DEBUG:stop_RETR_and_FR_timers : stop\n");
91 87
 }
92 88
 
... ...
@@ -80,94 +80,105 @@ inline static int int2reverse_hex( char **c, int *size, int nr )
80 80
  */
81 81
 int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
82 82
 {
83
-   struct cell      *p_cell;
84
-   struct cell      *tmp_cell;
85
-   /* unsigned int  hash_index=0; */
86
-   unsigned int  isACK;
87
-   struct sip_msg	*t_msg;
83
+	struct cell         *p_cell;
84
+	struct cell         *tmp_cell;
85
+	unsigned int       isACK;
86
+	struct sip_msg  *t_msg;
88 87
 
89
-   /* parse all*/
90
-   if (check_transaction_quadruple(p_msg)==0)
91
-   {
92
-      LOG(L_ERR, "ERROR: TM module: t_lookup_request: too few headers\n");
93
-      T=0;
94
-      /* stop processing */
95
-      return 0;
96
-   }
97
-   /* start searching into the table */
98
-   p_msg->hash_index = hash( p_msg->callid->body , get_cseq(p_msg)->number ) ;
99
-   isACK = p_msg->REQ_METHOD==METHOD_ACK;
100
-   DBG("t_lookup_request: start searching:  hash=%d, isACK=%d\n",p_msg->hash_index,isACK);
88
+	/* parse all*/
89
+	if (check_transaction_quadruple(p_msg)==0)
90
+	{
91
+		LOG(L_ERR, "ERROR: TM module: t_lookup_request: too few headers\n");
92
+		T=0;
93
+		/* stop processing */
94
+		return 0;
95
+	}
101 96
 
102
-   /* lock the hole entry*/
103
-   lock( hash_table->entrys[p_msg->hash_index].mutex );
97
+	/* start searching into the table */
98
+	p_msg->hash_index=hash( p_msg->callid->body , get_cseq(p_msg)->number ) ;
99
+	isACK = p_msg->REQ_METHOD==METHOD_ACK;
100
+	DBG("t_lookup_request: start searching: hash=%d, isACK=%d\n",
101
+		p_msg->hash_index,isACK);
104 102
 
105
-   /* all the transactions from the entry are compared */
106
-   p_cell     = hash_table->entrys[p_msg->hash_index].first_cell;
107
-   tmp_cell = 0;
108
-   while( p_cell )
109
-   {
110
-     t_msg = p_cell->inbound_request;
103
+	/* lock the hole entry*/
104
+	lock( hash_table->entrys[p_msg->hash_index].mutex );
111 105
 
112
-      /* is it the wanted transaction ? */
113
-      if ( !isACK )
114
-      { /* is not an ACK request */
115
-         /* first only the length are checked */
116
-         if ( EQ_LEN(callid) && EQ_LEN(cseq) )
117
-            if ( EQ_REQ_URI_LEN )
118
-                if ( EQ_VIA_LEN(via1) )
119
-                   if ( EQ_LEN(from) && EQ_LEN(to)  )
120
-                     /* so far the lengths are the same
121
-                     -> let's check the contents */
122
-                     if ( EQ_STR(callid) && EQ_STR(cseq) )
123
-                        if ( EQ_REQ_URI_STR )
124
-                           if ( EQ_VIA_STR(via1) )
125
-                              if ( EQ_STR(from) && EQ_STR(to) )
126
-                               { /* WE FOUND THE GOLDEN EGG !!!! */
127
-                                  goto found;
128
-                               }
129
-      }
130
-      else
131
-      { /* it's a ACK request*/
132
-         /* first only the length are checked */
133
-         if ( t_msg->first_line.u.request.method_value==METHOD_INVITE)
134
-            if ( /*callid length*/ EQ_LEN(callid) )
135
-               if ( get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len )
136
-                  if ( EQ_REQ_URI_LEN )
137
-                     if (/*VIA1 len*/ EQ_VIA_LEN(via1) )
138
-                       if ( /*from length*/ EQ_LEN(from) )
139
-                         if (get_to(t_msg)->body.len==get_to(p_msg)->body.len)
140
-                            if (p_cell->tag->len==get_to(p_msg)->tag_value.len )
141
-                            /* so far the lengths are the same -> let's check the contents */
142
-                                if ( /*callid*/ !memcmp( t_msg->callid->body.s , p_msg->callid->body.s , p_msg->callid->body.len ) )
143
-                                   if ( /*cseq_nr*/ !memcmp( get_cseq(t_msg)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len ) )
144
-                                      if (/*URI len*/ EQ_REQ_URI_STR )
145
-                                         if (/*VIA1*/ EQ_VIA_STR(via1) )
146
-                                            if ( /*from*/ EQ_STR(from) )
147
-                                               if (!memcmp(get_to(t_msg)->body.s,get_to(p_msg)->body.s,get_to(t_msg)->body.len))
148
-                                                 if (!memcmp(p_cell->tag->s,get_to(p_msg)->tag_value.s , p_cell->tag->len))
149
-                                              { /* WE FOUND THE GOLDEN EGG !!!! */
150
-                                                 goto found;
151
-                                              }
152
-      }
153
-      /* next transaction */
154
-      tmp_cell = p_cell;
155
-      p_cell = p_cell->next_cell;
156
-   } /* synonym loop */
106
+	/* all the transactions from the entry are compared */
107
+	p_cell     = hash_table->entrys[p_msg->hash_index].first_cell;
108
+	tmp_cell = 0;
109
+	while( p_cell )
110
+	{
111
+		t_msg = p_cell->inbound_request;
112
+
113
+		/* is it the wanted transaction ? */
114
+		if ( !isACK )
115
+		{ /* is not an ACK request */
116
+			/* first only the length are checked */
117
+			if ( /*callied*/EQ_LEN(callid) && /*cseq*/EQ_LEN(cseq)
118
+			&& /*req URI*/EQ_REQ_URI_LEN && /*VIA*/EQ_VIA_LEN(via1)
119
+			&& /*from*/EQ_LEN(from) && /*to*/EQ_LEN(to)  )
120
+				/* so far the lengths are the same
121
+				-> let's check the contents */
122
+				if ( /*callid*/EQ_STR(callid) && /*cseq*/EQ_STR(cseq)
123
+				&& /*req URI*/EQ_REQ_URI_STR && /*VIA*/EQ_VIA_STR(via1)
124
+				&& /*from*/EQ_STR(from) && /*to*/EQ_STR(to) )
125
+					{ /* WE FOUND THE GOLDEN EGG !!!! */
126
+						goto found;
127
+					}
128
+		}
129
+		else
130
+		{ /* it's a ACK request*/
131
+			/* first only the length are checked */
132
+			if ( t_msg->first_line.u.request.method_value==METHOD_INVITE
133
+			&& /*callid length*/ EQ_LEN(callid)
134
+			&& get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len
135
+			&& /*from length*/ EQ_LEN(from)
136
+			&& /*to body*/get_to(t_msg)->body.len==get_to(p_msg)->body.len
137
+			&& printf("------>0.4   %d (%d,%d)\n",p_cell->status,p_cell->tag->len,get_to(p_msg)->tag_value.len)
138
+			&& /*to tag*/p_cell->tag->len==get_to(p_msg)->tag_value.len
139
+			&& printf("------>0.5   %d\n",p_cell->status)
140
+			&& /*req URI*/(p_cell->status==200 || EQ_REQ_URI_LEN )
141
+			&& printf("------>0.6   %d\n",p_cell->status)
142
+			&& /*VIA*/(p_cell->status==200 || EQ_VIA_LEN(via1))
143
+			&& printf("------>2   %d\n",p_cell->status)  )
144
+				/* so far the lengths are the same
145
+				-> let's check the contents */
146
+				if (/*callid*/!memcmp( t_msg->callid->body.s,
147
+					p_msg->callid->body.s,p_msg->callid->body.len)
148
+				&& /*cseq nr*/!memcmp(get_cseq(t_msg)->number.s,
149
+					get_cseq(p_msg)->number.s,get_cseq(p_msg)->number.len)
150
+				&& /*from*/EQ_STR(from)
151
+				&& /*to body*/!memcmp(get_to(t_msg)->body.s,
152
+					get_to(p_msg)->body.s,get_to(t_msg)->body.len)
153
+				&& /*to tag*/!memcmp(p_cell->tag->s,
154
+					get_to(p_msg)->tag_value.s,p_cell->tag->len)
155
+				&& /*req URI*/(p_cell->status==200 || EQ_REQ_URI_STR||
156
+					printf("------>1   %d\n",p_cell->status) )
157
+				&& /*VAI*/(p_cell->status==200 ||EQ_VIA_STR(via1) ||
158
+						printf("------>2   %d\n",p_cell->status) ) )
159
+					{ /* WE FOUND THE GOLDEN EGG !!!! */
160
+						goto found;
161
+					}
162
+		}
163
+		/* next transaction */
164
+		tmp_cell = p_cell;
165
+		p_cell = p_cell->next_cell;
166
+	} /* synonym loop */
157 167
 
158
-   /* no transaction found */
159
-   T = 0;
160
-   if (!leave_new_locked) unlock( hash_table->entrys[p_msg->hash_index].mutex );
161
-   DBG("DEBUG: t_lookup_request: no transaction found\n");
162
-   return -1;
168
+	/* no transaction found */
169
+	T = 0;
170
+	if (!leave_new_locked)
171
+		unlock( hash_table->entrys[p_msg->hash_index].mutex );
172
+	DBG("DEBUG: t_lookup_request: no transaction found\n");
173
+	return -1;
163 174
 
164 175
 found:
165
-   T=p_cell;
166
-   T_REF( T );
167
-   DBG("DEBUG:XXXXXXXXXXXXXXXXXXXXX t_lookup_request: "
168
-                   "transaction found ( T=%p , ref=%x)\n",T,T->ref_bitmap);
169
-   unlock( hash_table->entrys[p_msg->hash_index].mutex );
170
-   return 1;
176
+	T=p_cell;
177
+	T_REF( T );
178
+	DBG("DEBUG:XXXXXXXXXXXXXXXXXXXXX t_lookup_request: "
179
+		"transaction found ( T=%p , ref=%x)\n",T,T->ref_bitmap);
180
+	unlock( hash_table->entrys[p_msg->hash_index].mutex );
181
+	return 1;
171 182
 }
172 183
 
173 184
 
... ...
@@ -36,7 +36,7 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
36 36
 	/* int l; */
37 37
 	char* end;
38 38
 	char s1,s2,s3;
39
-	
39
+
40 40
 	/* grammar:
41 41
 		request  =  method SP uri SP version CRLF
42 42
 		response =  version SP status  SP reason  CRLF
... ...
@@ -262,8 +262,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
262 262
 			}
263 263
 			hdr->parsed=to_b;
264 264
 			hdr->body.len=tmp-hdr->body.s;
265
-			DBG("get_hdr_field: to <%s>: <%s> %c [%d]\n",
266
-				hdr->name.s, to_b->body.s,*tmp,hdr->body.len);
265
+			DBG("get_hdr_field: to <%s>: <%s>=[%d] %c [%d]\n",
266
+				hdr->name.s, to_b->body.s,to_b->body.len,*tmp,hdr->body.len);
267 267
 			break;
268 268
 		case HDR_FROM:
269 269
 		case HDR_CALLID:
... ...
@@ -570,6 +570,8 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
570 570
 				hdr->type==HDR_CSEQ )
571 571
 			len += ((hdr->body.s+hdr->body.len ) - hdr->name.s ) + CRLF_LEN;
572 572
 #endif
573
+	/*content length header*/
574
+	len +=CONTENT_LEN_LEN + CRLF_LEN;
573 575
 	/* end of message */
574 576
 	len += CRLF_LEN; /*new line*/
575 577
 
... ...
@@ -625,6 +627,12 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
625 625
 		}
626 626
 #endif
627 627
 
628
+	/* content length header*/
629
+	memcpy( p, CONTENT_LEN , CONTENT_LEN_LEN );
630
+	p+=CONTENT_LEN_LEN;
631
+	memcpy( p, CRLF, CRLF_LEN );
632
+	p+=CRLF_LEN;
633
+	/*end of message*/
628 634
 	memcpy( p, CRLF, CRLF_LEN );
629 635
 	p+=CRLF_LEN;
630 636
 	*(p++) = 0;