Browse code

MD5 matching for reply

Bogdan-Andrei Iancu authored on 31/01/2002 19:16:36
Showing 7 changed files
... ...
@@ -15,27 +15,27 @@ RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
15 15
 ARCH = $(shell uname -s)
16 16
 
17 17
 # compile-time options
18
-# 
19
-# -DSTATS	
20
-#		allows to print out number of packets processed on CTRL-C; 
18
+#
19
+# -DSTATS
20
+#		allows to print out number of packets processed on CTRL-C;
21 21
 # 		implementation still nasty and reports per-process
22
-# -DNO_DEBUG 	
22
+# -DNO_DEBUG
23 23
 #		turns off some of the debug messages (DBG(...)).
24
-# -DNO_LOG 	
24
+# -DNO_LOG
25 25
 #		completely turns of all the logging (and DBG(...))
26
-# -DEXTRA_DEBUG	
26
+# -DEXTRA_DEBUG
27 27
 #		compiles in some extra debugging code
28
-# -DDNS_IP_HACK	
28
+# -DDNS_IP_HACK
29 29
 #		faster ip address resolver for ip strings (e.g "127.0.0.1")
30
-# -DSHM_MEM	
30
+# -DSHM_MEM
31 31
 #		compiles in shared mem. support, needed by some modules and
32 32
 #		by USE_SHM_MEM
33 33
 # -DSHM_MMAP
34 34
 #		use mmap instead of SYSV shared memory
35
-# -DPKG_MALLOC	
35
+# -DPKG_MALLOC
36 36
 #		uses a faster malloc (exclusive w/ USE_SHM_MEM)
37
-# -DUSE_SHM_MEM	
38
-#		all pkg_malloc => shm_malloc (most mallocs use a common sh. 
37
+# -DUSE_SHM_MEM
38
+#		all pkg_malloc => shm_malloc (most mallocs use a common sh.
39 39
 #		mem. segment); don't define PKG_MALLOC if you want this!
40 40
 # -DDBG_QM_MALLOC
41 41
 #		qm_malloc debug code, will cause pkg_malloc and shm_malloc
... ...
@@ -60,13 +60,13 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
60 60
 	  #-DNO_DEBUG #-DDBG_QM_MALLOC
61 61
 #-DEXTRA_DEBUG
62 62
 # -DUSE_SHM_MEM
63
-#-DNO_DEBUG 
63
+#-DNO_DEBUG
64 64
 #-DPKG_MALLOC
65
-#-DNO_DEBUG#-DSTATS -DNO_DEBUG 
65
+#-DNO_DEBUG#-DSTATS -DNO_DEBUG
66 66
 #-DNO_LOG
67 67
 
68 68
 #PROFILE=  -pg #set this if you want profiling
69
-mode = release
69
+mode = debug
70 70
 #mode = release
71 71
 
72 72
 # platform dependent settings
... ...
@@ -82,7 +82,7 @@ ifeq ($(mode), release)
82 82
 	CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
83 83
 			-malign-double -malign-loops=4 -minline-all-stringops \
84 84
 			-march=athlon -mcpu=athlon
85
-	#-Wmissing-prototypes 
85
+	#-Wmissing-prototypes
86 86
 	LDFLAGS=-Wl,-O2 -Wl,-E $(PROFILE)\
87 87
 			 -march=athlon
88 88
 	# we need -fPIC -DPIC only for shared objects, we don't need them for
... ...
@@ -6,6 +6,7 @@
6 6
 #include "h_table.h"
7 7
 #include "../../dprint.h"
8 8
 #include "sh_malloc.h"
9
+ #include "../../md5utils.h"
9 10
 
10 11
 /*   Frees the all the containes of a cell and the cell's body itself
11 12
   */
... ...
@@ -132,6 +133,7 @@ error:
132 133
 struct cell*  build_cell( struct sip_msg* p_msg )
133 134
 {
134 135
    struct cell*  new_cell;
136
+   str                src[5];
135 137
    int                i;
136 138
 
137 139
     DBG("DEBUG: build_cell : start\n");
... ...
@@ -168,8 +170,17 @@ struct cell*  build_cell( struct sip_msg* p_msg )
168 170
 	goto error;
169 171
    new_cell->relaied_reply_branch   = -1;
170 172
    new_cell->T_canceled = T_UNDEFINED;
173
+#ifndef USE_SYNONIM
174
+   src[0]= p_msg->from->body;
175
+   src[1]= p_msg->to->body;
176
+   src[2]= p_msg->callid->body;
177
+   src[3]= p_msg->first_line.u.request.uri;
178
+   src[4]= get_cseq( p_msg )->number;
179
+   MDStringArray ( new_cell->md5, src, 5 );
171 180
 
172
-    init_cell_lock(  new_cell ); 
181
+#endif
182
+
183
+    init_cell_lock(  new_cell );
173 184
 
174 185
    DBG("DEBUG: build_cell : done\n");
175 186
    return new_cell;
... ...
@@ -100,6 +100,10 @@ typedef struct cell
100 100
 	   good if a need to forward ACK later on
101 101
 	*/
102 102
 	struct sockaddr_in ack_to;
103
+#ifndef	USE_SYNONIM
104
+	/* MD5checksum */
105
+	char md5[32];
106
+#endif
103 107
 
104 108
 #ifdef	EXTRA_DEBUG
105 109
 	/* scheduled for deletion ? */
... ...
@@ -252,6 +252,7 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch )
252 252
 	p=p_msg->via1->branch->value.s;
253 253
 	scan_space=p_msg->via1->branch->value.len;
254 254
 
255
+#ifndef USE_SYNONIM
255 256
 	/* loop detection ... ignore */
256 257
 	n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR );
257 258
 	loopl = n-p;
... ...
@@ -259,6 +260,7 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch )
259 260
 	if (n==p || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2;
260 261
 	loopi=p;
261 262
 	p=n+1; scan_space--;
263
+#endif
262 264
 
263 265
 	/* hash_id */
264 266
 	n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR);
... ...
@@ -414,7 +416,10 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
414 416
 	begin=p_msg->add_to_branch_s+p_msg->add_to_branch_len;
415 417
 	orig_size = size=MAX_BRANCH_PARAM_LEN - p_msg->add_to_branch_len;
416 418
 
419
+#ifndef USE_SYNONIM
420
+	if (memcpy(begin,trans->md5,32)) {begin+=32;size-=32;} else return -1;
417 421
 	if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
422
+#endif
418 423
 	if (int2reverse_hex( &begin, &size, trans->hash_index)==-1) return -1;
419 424
 #ifdef USE_SYNONIM
420 425
 	if (size) { *begin=BRANCH_SEPARATOR; begin++; size--; } else return -1;
... ...
@@ -31,8 +31,11 @@
31 31
 #define HDR_OTHER       65536 /*unknown header type*/
32 32
 
33 33
 /* maximum length of values appended to Via-branch parameter */
34
-#define	MAX_BRANCH_PARAM_LEN	32
35
-
34
+#ifdef USE_SYNONIM
35
+#define MAX_BRANCH_PARAM_LEN  22
36
+#else
37
+#define MAX_BRANCH_PARAM_LEN  48
38
+#endif
36 39
 /* via param types
37 40
  * WARNING: keep in sync w/ FIN_*, GEN_PARAM and PARAM_ERROR from via_parse.c*/
38 41
 enum{
... ...
@@ -149,7 +149,7 @@ char* via_builder( struct sip_msg *msg , unsigned int *len )
149 149
 		/* jku: branch parameter */
150 150
 		memcpy(line_buf+via_len, MY_BRANCH, MY_BRANCH_LEN );
151 151
 		via_len+=MY_BRANCH_LEN;
152
-		/* loop checks ? */
152
+		/* loop checks ?
153 153
 		if (loop_checks) {
154 154
 
155 155
 			if (check_transaction_quadruple( msg )) {
... ...
@@ -166,10 +166,10 @@ char* via_builder( struct sip_msg *msg , unsigned int *len )
166 166
 
167 167
 			} else DBG("DEBUG: via_builder: required HFs for "
168 168
 					"loop checking missing\n");
169
-		}
169
+		}  */
170 170
 		//DBG("DEBUG: XXX will add branch now: %s (%d)\n", msg->add_to_branch_s, msg->add_to_branch_len );
171 171
 		/* someone wants me to add something to branch here ? */
172
-		memcpy(line_buf+via_len, msg->add_to_branch_s,
172
+		memcpy(line_buf+via_len-1, msg->add_to_branch_s,
173 173
 				msg->add_to_branch_len );
174 174
 		via_len+=msg->add_to_branch_len;
175 175
 
... ...
@@ -5,7 +5,7 @@
5 5
 #
6 6
 
7 7
 
8
-debug=1          # debug level (cmd line: -dddddddddd)
8
+debug=9          # debug level (cmd line: -dddddddddd)
9 9
 #fork=yes          # (cmd. line: -D)
10 10
 fork=no
11 11
 log_stderror=yes # (cmd line: -E)