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 214
 
214 215
 
215 216
 
217
+#ifdef VERY_NOISY_REPLIES
218
+char * warning_builder( struct sip_msg *msg, unsigned int *returned_len)
219
+{
220
+	static char buf[MAX_WARNING_LEN];
221
+	static unsigned int fix_len=0;
222
+	str *foo;
223
+	char *p;
216 224
 
225
+	if (!fix_len)
226
+	{
227
+		memcpy(buf+fix_len,"Warning: 392 ",13);
228
+		fix_len +=13;
229
+		memcpy(buf+fix_len,names[0],names_len[0]);
230
+		fix_len += names_len[0];
231
+		//*(buf+fix_len++) = ':';
232
+		memcpy(buf+fix_len,port_no_str,port_no_str_len);
233
+		fix_len += port_no_str_len;
234
+		memcpy(buf+fix_len, " \"Noisy feedback tells: ",24);
235
+		fix_len += 24;
236
+	}
217 237
 
238
+	p = buf+fix_len;
239
+	/* adding pid */
240
+	if (p-buf+10+2>=MAX_WARNING_LEN)
241
+		goto done;
242
+	p += sprintf(p, "pid=%d", pids?pids[process_no]:0 );
243
+	*(p++)=' ';
244
+
245
+	/*adding src_ip*/
246
+	if (p-buf+26+2>=MAX_WARNING_LEN)
247
+		goto done;
248
+	p += sprintf(p,"req_src_ip=%s",q_inet_itoa(msg->src_ip));
249
+	*(p++)=' ';
250
+
251
+	/*adding in_uri*/
252
+	if(p-buf+7+msg->first_line.u.request.uri.len+2>=MAX_WARNING_LEN)
253
+		goto done;
254
+	p += sprintf( p, "in_uri=%.*s",msg->first_line.u.request.uri.len,
255
+		msg->first_line.u.request.uri.s);
256
+	*(p++) = ' ';
257
+
258
+	/*adding out_uri*/
259
+	if (msg->new_uri.s)
260
+		foo=&(msg->new_uri);
261
+	else
262
+		foo=&(msg->first_line.u.request.uri);
263
+	if(p-buf+8+foo->len+2>=MAX_WARNING_LEN)
264
+		goto done;
265
+	p += sprintf( p, "out_uri=%.*s", foo->len, foo->s);
266
+
267
+done:
268
+	*(p++) = '\"';
269
+	*(p) = 0;
270
+	*returned_len = p-buf;
271
+	return buf;
272
+}
273
+#endif
218 274
 
219 275
 
220 276
 
221 277
 
222
-
223
-char * build_req_buf_from_sip_req(	struct sip_msg* msg,
224
-				unsigned int *returned_len)
278
+char * build_req_buf_from_sip_req( struct sip_msg* msg,
279
+								unsigned int *returned_len)
225 280
 {
226 281
 	unsigned int len, new_len, received_len, uri_len, via_len;
227 282
 	char* line_buf;
... ...
@@ -548,16 +603,20 @@ error:
548 603
 
549 604
 
550 605
 
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)
606
+char * build_res_buf_from_sip_req( unsigned int code, char *text,
607
+					char *new_tag, unsigned int new_tag_len,
608
+					struct sip_msg* msg, unsigned int *returned_len)
554 609
 {
555
-	char                    *buf, *p;
556
-	unsigned int       len,foo;
610
+	char              *buf, *p;
611
+	unsigned int      len,foo;
557 612
 	struct hdr_field  *hdr;
558
-	struct lump_rpl  *lump;
559
-	int                       i;
560
-	str                        *tag_str;
613
+	struct lump_rpl   *lump;
614
+	int               i;
615
+	str               *tag_str;
616
+#ifdef VERY_NOISY_REPLIES
617
+	char              *warning;
618
+	unsigned int      warning_len;
619
+#endif
561 620
 
562 621
 	/* force parsing all headers -- we want to return all
563 622
 	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 627
 	/*computes the lenght of the new response buffer*/
569 628
 	len = 0;
570 629
 	/* first line */
571
-	len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ + strlen(text) + CRLF_LEN/*new line*/;
630
+	len += SIP_VERSION_LEN + 1/*space*/ + 3/*code*/ + 1/*space*/ +
631
+		strlen(text) + CRLF_LEN/*new line*/;
572 632
 	/*headers that will be copied (TO, FROM, CSEQ,CALLID,VIA)*/
573 633
 	for ( hdr=msg->headers ; hdr ; hdr=hdr->next )
574 634
 		switch (hdr->type)
... ...
@@ -591,10 +651,14 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
591 651
 	for(lump=msg->reply_lump;lump;lump=lump->next)
592 652
 		len += lump->text.len;
593 653
 #ifdef NOISY_REPLIES
594
-	/*user agent header*/
595
-	len += USER_AGENT_LEN + CRLF_LEN;
654
+	/*server header*/
655
+	len += SERVER_HDR_LEN + CRLF_LEN;
596 656
 	/*content length header*/
597 657
 	len +=CONTENT_LEN_LEN + CRLF_LEN;
658
+#endif
659
+#ifdef VERY_NOISY_REPLIES
660
+	warning = warning_builder(msg,&warning_len);
661
+	len += warning_len + CRLF_LEN;
598 662
 #endif
599 663
 	/* end of message */
600 664
 	len += CRLF_LEN; /*new line*/
... ...
@@ -662,10 +726,10 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
662 726
 		memcpy(p,lump->text.s,lump->text.len);
663 727
 		p += lump->text.len;
664 728
 	}
665
-	/*user agent header*/
666 729
 #ifdef NOISY_REPLIES
667
-	memcpy( p, USER_AGENT , USER_AGENT_LEN );
668
-	p+=USER_AGENT_LEN;
730
+	/*server header*/
731
+	memcpy( p, SERVER_HDR , SERVER_HDR_LEN );
732
+	p+=SERVER_HDR_LEN;
669 733
 	memcpy( p, CRLF, CRLF_LEN );
670 734
 	p+=CRLF_LEN;
671 735
 	/* content length header*/
... ...
@@ -673,6 +737,12 @@ char * build_res_buf_from_sip_req(	unsigned int code ,
673 737
 	p+=CONTENT_LEN_LEN;
674 738
 	memcpy( p, CRLF, CRLF_LEN );
675 739
 	p+=CRLF_LEN;
740
+#endif
741
+#ifdef VERY_NOISY_REPLIES
742
+	memcpy( p, warning, warning_len);
743
+	p+=warning_len;
744
+	memcpy( p, CRLF, CRLF_LEN);
745
+	p+=CRLF_LEN;
676 746
 #endif
677 747
 	/*end of message*/
678 748
 	memcpy( p, CRLF, 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 62
                 };
65 63
              }; */
66 64
 
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 65
 
81 66
              t_relay();
82 67
 }