Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 15/03/2002 21:47:17
Showing 4 changed files
... ...
@@ -87,6 +87,7 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
87 87
 	 -DWAIT -DNEW_HNAME \
88 88
 	 -DSILENT_FR \
89 89
 	 -DNO_DEBUG \
90
+	 -DVERY_NOISY_REPLIES\
90 91
 	 #-DNOISY_REPLIES \
91 92
 	 #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
92 93
 	 #-DNOSMP \
... ...
@@ -37,9 +37,15 @@
37 37
 #define CONTENT_LEN_LEN 17
38 38
 
39 39
 #define USER_AGENT "User-Agent: Sip EXpress router"\
40
-                                     "(" VERSION " (" ARCH "/" OS"))"
41
- #define USER_AGENT_LEN (sizeof(USER_AGENT)-1)
40
+		"(" VERSION " (" ARCH "/" OS"))"
41
+#define USER_AGENT_LEN (sizeof(USER_AGENT)-1)
42 42
 
43
+#define SERVER_HDR "Server: Sip EXpress router"\
44
+		"(" VERSION " (" ARCH "/" OS"))"
45
+#define SERVER_HDR_LEN (sizeof(SERVER_HDR)-1)
46
+
47
+#define MAX_WARNING_LEN  256
48
+		
43 49
 #define MY_BRANCH ";branch=0"
44 50
 #define MY_BRANCH_LEN 9
45 51
 
... ...
@@ -6,6 +6,7 @@
6 6
 #include <sys/socket.h>
7 7
 #include <netdb.h>
8 8
 #include <string.h>
9
+#include <stdio.h>
9 10
 
10 11
 #include "msg_translator.h"
11 12
 #include "mem/mem.h"
... ...
@@ -213,15 +214,69 @@ error:
213 213
 
214 214
 
215 215
 
216
+#ifdef VERY_NOISY_REPLIES
217
+char * warning_builder( struct sip_msg *msg, unsigned int *returned_len)
218
+{
219
+	static char buf[MAX_WARNING_LEN];
220
+	static unsigned int fix_len=0;
221
+	str *foo;
222
+	char *p;
216 223
 
224
+	if (!fix_len)
225
+	{
226
+		memcpy(buf+fix_len,"Warning: 392 ",13);
227
+		fix_len +=13;
228
+		memcpy(buf+fix_len,names[0],names_len[0]);
229
+		fix_len += names_len[0];
230
+		//*(buf+fix_len++) = ':';
231
+		memcpy(buf+fix_len,port_no_str,port_no_str_len);
232
+		fix_len += port_no_str_len;
233
+		memcpy(buf+fix_len, " \"Noisy feedback tells: ",24);
234
+		fix_len += 24;
235
+	}
217 236
 
237
+	p = buf+fix_len;
238
+	/* adding pid */
239
+	if (p-buf+10+2>=MAX_WARNING_LEN)
240
+		goto done;
241
+	p += sprintf(p, "pid=%d", pids?pids[process_no]:0 );
242
+	*(p++)=' ';
243
+
244
+	/*adding src_ip*/
245
+	if (p-buf+26+2>=MAX_WARNING_LEN)
246
+		goto done;
247
+	p += sprintf(p,"req_src_ip=%s",q_inet_itoa(msg->src_ip));
248
+	*(p++)=' ';
249
+
250
+	/*adding in_uri*/
251
+	if(p-buf+7+msg->first_line.u.request.uri.len+2>=MAX_WARNING_LEN)
252
+		goto done;
253
+	p += sprintf( p, "in_uri=%.*s",msg->first_line.u.request.uri.len,
254
+		msg->first_line.u.request.uri.s);
255
+	*(p++) = ' ';
256
+
257
+	/*adding out_uri*/
258
+	if (msg->new_uri.s)
259
+		foo=&(msg->new_uri);
260
+	else
261
+		foo=&(msg->first_line.u.request.uri);
262
+	if(p-buf+8+foo->len+2>=MAX_WARNING_LEN)
263
+		goto done;
264
+	p += sprintf( p, "out_uri=%.*s", foo->len, foo->s);
265
+
266
+done:
267
+	*(p++) = '\"';
268
+	*(p) = 0;
269
+	*returned_len = p-buf;
270
+	return buf;
271
+}
272
+#endif
218 273
 
219 274
 
220 275
 
221 276
 
222
-
223
-char * build_req_buf_from_sip_req(	struct sip_msg* msg,
224
-				unsigned int *returned_len)
277
+char * build_req_buf_from_sip_req( struct sip_msg* msg,
278
+								unsigned int *returned_len)
225 279
 {
226 280
 	unsigned int len, new_len, received_len, uri_len, via_len;
227 281
 	char* line_buf;
... ...
@@ -548,16 +603,20 @@ error:
548 548
 
549 549
 
550 550
 
551
-char * build_res_buf_from_sip_req(	unsigned int code ,
552
-	char *text, char *new_tag, unsigned int new_tag_len,
553
-	struct sip_msg* msg, unsigned int *returned_len)
551
+char * build_res_buf_from_sip_req( unsigned int code, char *text,
552
+					char *new_tag, unsigned int new_tag_len,
553
+					struct sip_msg* msg, unsigned int *returned_len)
554 554
 {
555
-	char                    *buf, *p;
556
-	unsigned int       len,foo;
555
+	char              *buf, *p;
556
+	unsigned int      len,foo;
557 557
 	struct hdr_field  *hdr;
558
-	struct lump_rpl  *lump;
559
-	int                       i;
560
-	str                        *tag_str;
558
+	struct lump_rpl   *lump;
559
+	int               i;
560
+	str               *tag_str;
561
+#ifdef VERY_NOISY_REPLIES
562
+	char              *warning;
563
+	unsigned int      warning_len;
564
+#endif
561 565
 
562 566
 	/* force parsing all headers -- we want to return all
563 567
 	Via's in the reply and they may be scattered down to the
... ...
@@ -568,7 +627,8 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
568 568
 	/*computes the lenght of the new response buffer*/
569 569
 	len = 0;
570 570
 	/* first line */
571
-	len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ + strlen(text) + CRLF_LEN/*new line*/;
571
+	len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ +
572
+		strlen(text) + CRLF_LEN/*new line*/;
572 573
 	/*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/
573 574
 	for ( hdr=msg->headers ; hdr ; hdr=hdr->next )
574 575
 		switch (hdr->type)
... ...
@@ -591,11 +651,15 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
591 591
 	for(lump=msg->reply_lump;lump;lump=lump->next)
592 592
 		len += lump->text.len;
593 593
 #ifdef NOISY_REPLIES
594
-	/*user agent header*/
595
-	len += USER_AGENT_LEN + CRLF_LEN;
594
+	/*server header*/
595
+	len += SERVER_HDR_LEN + CRLF_LEN;
596 596
 	/*content length header*/
597 597
 	len +=CONTENT_LEN_LEN + CRLF_LEN;
598 598
 #endif
599
+#ifdef VERY_NOISY_REPLIES
600
+	warning = warning_builder(msg,&warning_len);
601
+	len += warning_len + CRLF_LEN;
602
+#endif
599 603
 	/* end of message */
600 604
 	len += CRLF_LEN; /*new line*/
601 605
 	/*allocating mem*/
... ...
@@ -662,10 +726,10 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
662 662
 		memcpy(p,lump->text.s,lump->text.len);
663 663
 		p += lump->text.len;
664 664
 	}
665
-	/*user agent header*/
666 665
 #ifdef NOISY_REPLIES
667
-	memcpy( p, USER_AGENT , USER_AGENT_LEN );
668
-	p+=USER_AGENT_LEN;
666
+	/*server header*/
667
+	memcpy( p, SERVER_HDR , SERVER_HDR_LEN );
668
+	p+=SERVER_HDR_LEN;
669 669
 	memcpy( p, CRLF, CRLF_LEN );
670 670
 	p+=CRLF_LEN;
671 671
 	/* content length header*/
... ...
@@ -674,6 +738,12 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
674 674
 	memcpy( p, CRLF, CRLF_LEN );
675 675
 	p+=CRLF_LEN;
676 676
 #endif
677
+#ifdef VERY_NOISY_REPLIES
678
+	memcpy( p, warning, warning_len);
679
+	p+=warning_len;
680
+	memcpy( p, CRLF, CRLF_LEN);
681
+	p+=CRLF_LEN;
682
+#endif
677 683
 	/*end of message*/
678 684
 	memcpy( p, CRLF, CRLF_LEN );
679 685
 	p+=CRLF_LEN;
... ...
@@ -35,8 +35,6 @@ loadmodule "modules/sl/sl.so"
35 35
 route{
36 36
              sl_filter_ACK();
37 37
 
38
-             #rewritehostport("195.37.77.110:5060");
39
-
40 38
              if ( !mf_process_maxfwd_header("10") )
41 39
              {
42 40
                      sl_send_reply("483","To Many Hops");
... ...
@@ -64,19 +62,6 @@ route{
64 64
                 };
65 65
              }; */
66 66
 
67
-           #  if ( !rewriteFromRoute() )
68
-            # {
69
-                #log( " SER : no route found!\n");
70
-                #if ( method=="INVITE" )
71
-                #{
72
-                  # log ("SER : INVITE found - > adding RecordRoute!\n");
73
-                   #addRecordRoute();
74
-                #};
75
-             #}
76
-             #else
77
-             #{
78
-                #log( "SER : ROUTE found! \n");
79
-             #};
80 67
 
81 68
              t_relay();
82 69
 }