Browse code

added MD5 support from RFC 1321

Jiri Kuthan authored on 29/11/2001 14:28:03
Showing 6 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,351 @@
0
+/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
1
+ */
2
+
3
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
4
+rights reserved.
5
+
6
+License to copy and use this software is granted provided that it
7
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
8
+Algorithm" in all material mentioning or referencing this software
9
+or this function.
10
+
11
+License is also granted to make and use derivative works provided
12
+that such works are identified as "derived from the RSA Data
13
+Security, Inc. MD5 Message-Digest Algorithm" in all material
14
+mentioning or referencing the derived work.
15
+
16
+RSA Data Security, Inc. makes no representations concerning either
17
+the merchantability of this software or the suitability of this
18
+software for any particular purpose. It is provided "as is"
19
+without express or implied warranty of any kind.
20
+
21
+These notices must be retained in any copies of any part of this
22
+documentation and/or software.
23
+ */
24
+
25
+#include "md5global.h"
26
+#include "md5.h"
27
+
28
+#define USE_MEM
29
+
30
+/* Constants for MD5Transform routine.
31
+ */
32
+
33
+
34
+
35
+
36
+#define S11 7
37
+#define S12 12
38
+#define S13 17
39
+#define S14 22
40
+#define S21 5
41
+#define S22 9
42
+#define S23 14
43
+#define S24 20
44
+#define S31 4
45
+#define S32 11
46
+#define S33 16
47
+#define S34 23
48
+#define S41 6
49
+#define S42 10
50
+#define S43 15
51
+#define S44 21
52
+
53
+static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
54
+static void Encode PROTO_LIST
55
+  ((unsigned char *, UINT4 *, unsigned int));
56
+static void Decode PROTO_LIST
57
+  ((UINT4 *, unsigned char *, unsigned int));
58
+static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int));
59
+static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
60
+
61
+static unsigned char PADDING[64] = {
62
+  0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
63
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
64
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
65
+};
66
+
67
+/* F, G, H and I are basic MD5 functions.
68
+ */
69
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
70
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
71
+#define H(x, y, z) ((x) ^ (y) ^ (z))
72
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
73
+
74
+/* ROTATE_LEFT rotates x left n bits.
75
+ */
76
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
77
+
78
+/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
79
+Rotation is separate from addition to prevent recomputation.
80
+ */
81
+#define FF(a, b, c, d, x, s, ac) { \
82
+ (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
83
+ (a) = ROTATE_LEFT ((a), (s)); \
84
+ (a) += (b); \
85
+  }
86
+#define GG(a, b, c, d, x, s, ac) { \
87
+ (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
88
+ (a) = ROTATE_LEFT ((a), (s)); \
89
+ (a) += (b); \
90
+  }
91
+#define HH(a, b, c, d, x, s, ac) { \
92
+ (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
93
+ (a) = ROTATE_LEFT ((a), (s)); \
94
+ (a) += (b); \
95
+  }
96
+#define II(a, b, c, d, x, s, ac) { \
97
+ (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
98
+ (a) = ROTATE_LEFT ((a), (s)); \
99
+ (a) += (b); \
100
+  }
101
+
102
+/* MD5 initialization. Begins an MD5 operation, writing a new context.
103
+ */
104
+void MD5Init (context)
105
+MD5_CTX *context;                                        /* context */
106
+{
107
+  context->count[0] = context->count[1] = 0;
108
+  /* Load magic initialization constants.
109
+*/
110
+  context->state[0] = 0x67452301;
111
+  context->state[1] = 0xefcdab89;
112
+  context->state[2] = 0x98badcfe;
113
+  context->state[3] = 0x10325476;
114
+}
115
+
116
+/* MD5 block update operation. Continues an MD5 message-digest
117
+  operation, processing another message block, and updating the
118
+  context.
119
+ */
120
+void MD5Update (context, input, inputLen)
121
+MD5_CTX *context;                                        /* context */
122
+unsigned char *input;                                /* input block */
123
+unsigned int inputLen;                     /* length of input block */
124
+{
125
+  unsigned int i, index, partLen;
126
+
127
+  /* Compute number of bytes mod 64 */
128
+  index = (unsigned int)((context->count[0] >> 3) & 0x3F);
129
+
130
+  /* Update number of bits */
131
+  if ((context->count[0] += ((UINT4)inputLen << 3))
132
+
133
+   < ((UINT4)inputLen << 3))
134
+ context->count[1]++;
135
+  context->count[1] += ((UINT4)inputLen >> 29);
136
+
137
+  partLen = 64 - index;
138
+
139
+  /* Transform as many times as possible.
140
+*/
141
+  if (inputLen >= partLen) {
142
+ MD5_memcpy
143
+   ((POINTER)&context->buffer[index], (POINTER)input, partLen);
144
+ MD5Transform (context->state, context->buffer);
145
+
146
+ for (i = partLen; i + 63 < inputLen; i += 64)
147
+   MD5Transform (context->state, &input[i]);
148
+
149
+ index = 0;
150
+  }
151
+  else
152
+ i = 0;
153
+
154
+  /* Buffer remaining input */
155
+  MD5_memcpy
156
+ ((POINTER)&context->buffer[index], (POINTER)&input[i],
157
+  inputLen-i);
158
+}
159
+
160
+/* MD5 finalization. Ends an MD5 message-digest operation, writing the
161
+  the message digest and zeroizing the context.
162
+ */
163
+void MD5Final (digest, context)
164
+unsigned char digest[16];                         /* message digest */
165
+MD5_CTX *context;                                       /* context */
166
+{
167
+  unsigned char bits[8];
168
+  unsigned int index, padLen;
169
+
170
+  /* Save number of bits */
171
+  Encode (bits, context->count, 8);
172
+
173
+  /* Pad out to 56 mod 64.
174
+*/
175
+  index = (unsigned int)((context->count[0] >> 3) & 0x3f);
176
+  padLen = (index < 56) ? (56 - index) : (120 - index);
177
+  MD5Update (context, PADDING, padLen);
178
+
179
+  /* Append length (before padding) */
180
+  MD5Update (context, bits, 8);
181
+
182
+  /* Store state in digest */
183
+  Encode (digest, context->state, 16);
184
+
185
+  /* Zeroize sensitive information.
186
+*/
187
+  MD5_memset ((POINTER)context, 0, sizeof (*context));
188
+}
189
+
190
+/* MD5 basic transformation. Transforms state based on block.
191
+ */
192
+static void MD5Transform (state, block)
193
+UINT4 state[4];
194
+unsigned char block[64];
195
+{
196
+  UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
197
+
198
+  Decode (x, block, 64);
199
+
200
+  /* Round 1 */
201
+  FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
202
+  FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
203
+  FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
204
+  FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
205
+  FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
206
+  FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
207
+  FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
208
+  FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
209
+  FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
210
+  FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
211
+  FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
212
+  FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
213
+  FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
214
+  FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
215
+  FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
216
+  FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
217
+
218
+ /* Round 2 */
219
+  GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
220
+  GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
221
+  GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
222
+  GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
223
+  GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
224
+  GG (d, a, b, c, x[10], S22,  0x2441453); /* 22 */
225
+  GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
226
+  GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
227
+  GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
228
+  GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
229
+  GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
230
+  GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
231
+  GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
232
+  GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
233
+  GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
234
+  GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
235
+
236
+  /* Round 3 */
237
+  HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
238
+  HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
239
+  HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
240
+  HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
241
+  HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
242
+  HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
243
+  HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
244
+  HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
245
+  HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
246
+  HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
247
+  HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
248
+  HH (b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
249
+  HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
250
+  HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
251
+  HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
252
+  HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
253
+
254
+  /* Round 4 */
255
+  II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
256
+  II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
257
+  II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
258
+  II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
259
+  II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
260
+  II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
261
+  II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
262
+  II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
263
+  II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
264
+  II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
265
+  II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
266
+  II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
267
+  II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
268
+  II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
269
+  II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
270
+  II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
271
+
272
+  state[0] += a;
273
+  state[1] += b;
274
+  state[2] += c;
275
+  state[3] += d;
276
+
277
+  /* Zeroize sensitive information.
278
+*/
279
+  MD5_memset ((POINTER)x, 0, sizeof (x));
280
+}
281
+
282
+/* Encodes input (UINT4) into output (unsigned char). Assumes len is
283
+  a multiple of 4.
284
+ */
285
+static void Encode (output, input, len)
286
+unsigned char *output;
287
+UINT4 *input;
288
+unsigned int len;
289
+{
290
+  unsigned int i, j;
291
+
292
+  for (i = 0, j = 0; j < len; i++, j += 4) {
293
+ output[j] = (unsigned char)(input[i] & 0xff);
294
+ output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
295
+ output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
296
+ output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
297
+  }
298
+}
299
+
300
+/* Decodes input (unsigned char) into output (UINT4). Assumes len is
301
+  a multiple of 4.
302
+ */
303
+static void Decode (output, input, len)
304
+UINT4 *output;
305
+unsigned char *input;
306
+unsigned int len;
307
+{
308
+  unsigned int i, j;
309
+
310
+  for (i = 0, j = 0; j < len; i++, j += 4)
311
+ output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
312
+   (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
313
+}
314
+
315
+/* Note: Replace "for loop" with standard memcpy if possible.
316
+ */
317
+
318
+static void MD5_memcpy (output, input, len)
319
+POINTER output;
320
+POINTER input;
321
+unsigned int len;
322
+{
323
+
324
+#ifndef USE_MEM
325
+  unsigned int i;
326
+
327
+  for (i = 0; i < len; i++)
328
+ output[i] = input[i];
329
+#else
330
+  memcpy( output, input, len );
331
+#endif
332
+}
333
+
334
+/* Note: Replace "for loop" with standard memset if possible.
335
+ */
336
+static void MD5_memset (output, value, len)
337
+POINTER output;
338
+int value;
339
+unsigned int len;
340
+{
341
+
342
+#ifndef USE_MEM
343
+  unsigned int i;
344
+  for (i = 0; i < len; i++)
345
+ ((char *)output)[i] = (char)value;
346
+#else
347
+  memset( output, value, len );
348
+#endif
349
+}
350
+
0 351
new file mode 100644
... ...
@@ -0,0 +1,37 @@
0
+/* MD5.H - header file for MD5C.C
1
+ */
2
+
3
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
4
+rights reserved.
5
+
6
+License to copy and use this software is granted provided that it
7
+is identified as the "RSA Data Security, Inc. MD5 Message-Digest
8
+Algorithm" in all material mentioning or referencing this software
9
+or this function.
10
+
11
+License is also granted to make and use derivative works provided
12
+that such works are identified as "derived from the RSA Data
13
+Security, Inc. MD5 Message-Digest Algorithm" in all material
14
+mentioning or referencing the derived work.
15
+
16
+RSA Data Security, Inc. makes no representations concerning either
17
+the merchantability of this software or the suitability of this
18
+software for any particular purpose. It is provided "as is"
19
+without express or implied warranty of any kind.
20
+
21
+These notices must be retained in any copies of any part of this
22
+documentation and/or software.
23
+ */
24
+
25
+/* MD5 context. */
26
+typedef struct {
27
+  UINT4 state[4];                                   /* state (ABCD) */
28
+  UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
29
+  unsigned char buffer[64];                         /* input buffer */
30
+} MD5_CTX;
31
+
32
+void MD5Init PROTO_LIST ((MD5_CTX *));
33
+void MD5Update PROTO_LIST
34
+  ((MD5_CTX *, unsigned char *, unsigned int));
35
+void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));
36
+
0 37
new file mode 100644
... ...
@@ -0,0 +1,31 @@
0
+/* GLOBAL.H - RSAREF types and constants
1
+ */
2
+
3
+/* PROTOTYPES should be set to one if and only if the compiler supports
4
+  function argument prototyping.
5
+The following makes PROTOTYPES default to 0 if it has not already
6
+  been defined with C compiler flags.
7
+ */
8
+#ifndef PROTOTYPES
9
+#define PROTOTYPES 0
10
+#endif
11
+
12
+/* POINTER defines a generic pointer type */
13
+typedef unsigned char *POINTER;
14
+
15
+/* UINT2 defines a two byte word */
16
+typedef unsigned short int UINT2;
17
+
18
+/* UINT4 defines a four byte word */
19
+typedef unsigned long int UINT4;
20
+
21
+/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
22
+If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
23
+  returns an empty list.
24
+ */
25
+#if PROTOTYPES
26
+#define PROTO_LIST(list) list
27
+#else
28
+#define PROTO_LIST(list) ()
29
+#endif
30
+
0 31
new file mode 100644
... ...
@@ -0,0 +1,62 @@
0
+/* MDDRIVER.C - test driver for MD2, MD4 and MD5
1
+ */
2
+
3
+
4
+/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
5
+rights reserved.
6
+
7
+RSA Data Security, Inc. makes no representations concerning either
8
+the merchantability of this software or the suitability of this
9
+software for any particular purpose. It is provided "as is"
10
+without express or implied warranty of any kind.
11
+
12
+These notices must be retained in any copies of any part of this
13
+documentation and/or software.
14
+ */
15
+
16
+/*
17
+
18
+jku: added support to deal with vectors
19
+
20
+*/
21
+
22
+#define MD 5
23
+
24
+#include <stdio.h>
25
+#include <time.h>
26
+#include <string.h>
27
+#include "md5global.h"
28
+#include "md5.h"
29
+#include "md5utils.h"
30
+
31
+#include "dprint.h"
32
+
33
+
34
+static void MDString PROTO_LIST ((char *));
35
+
36
+#define MD_CTX MD5_CTX
37
+#define MDInit MD5Init
38
+#define MDUpdate MD5Update
39
+#define MDFinal MD5Final
40
+
41
+
42
+/* Digests a string array and store the result in dst; assumes
43
+  32 bytes in dst
44
+ */
45
+void MDStringArray (char *dst, str src[], int size)
46
+{
47
+  MD_CTX context;
48
+  unsigned char digest[16];
49
+  int i;
50
+
51
+  MDInit (&context);
52
+  for (i=0; i<size; i++) {
53
+  	MDUpdate (&context, src[i].s, src[i].len);
54
+  }
55
+  MDFinal (digest, &context);
56
+
57
+  for (i=0; i<16; i++)
58
+    sprintf(dst+i*2, "%02x", digest[i] );
59
+
60
+  DBG("DEBUG: MD5 calculated: %32s\n", dst );
61
+}
0 62
new file mode 100644
... ...
@@ -0,0 +1,10 @@
0
+#ifndef _MD5UTILS_H
1
+#define _MD5UTILS_H
2
+
3
+#include "str.h"
4
+
5
+#define MD5_LEN	32
6
+
7
+void MDStringArray (char *dst, str src[], int size);
8
+
9
+#endif
... ...
@@ -4,30 +4,7 @@
4 4
 struct cell         *T;
5 5
 unsigned int     global_msg_id;
6 6
 struct s_table*  hash_table;
7
-
8
-
9
-struct cell* t_lookupOriginalT(  struct s_table* hash_table , struct sip_msg* p_msg );
10
-int t_reply_matching( struct s_table* , struct sip_msg* , struct cell** , unsigned int*  );
11
-int t_store_incoming_reply( struct cell* , unsigned int , struct sip_msg* );
12
-int t_relay_reply( struct cell* , unsigned int , struct sip_msg* );
13
-int t_check( struct s_table* , struct sip_msg*  );
14
-int t_all_final( struct cell * );
15
-int t_build_and_send_ACK( struct cell *Trans , unsigned int brach );
16
-int relay_lowest_reply_upstream( struct cell *Trans , struct sip_msg *p_msg );
17
-int push_reply_from_uac_to_uas( struct sip_msg * , unsigned int );
18
-int t_cancel_branch(unsigned int branch); //TO DO
19
-
20
-int send_udp_to( char *buf, unsigned buflen, struct sockaddr_in*  to, unsigned tolen );
21
-
22
-void retransmission_handler( void *);
23
-void final_response_handler( void *);
24
-void wait_handler( void *);
25
-void delete_handler( void *);
26
-
27
-int add_branch_label( struct cell *Trans, struct sip_msg *p_msg , int branch );
28
-
29
-
30
-
7
+int                      sock_fd;
31 8
 
32 9
 
33 10
 
... ...
@@ -278,7 +255,7 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
278 278
       T->outbound_request[branch]->to.sin_addr.s_addr = ntohl( dest_ip ) ;
279 279
 
280 280
       if (add_branch_label( T, p_msg , branch )==-1) return -1;
281
-      buf = build_req_buf_from_sip_req( p_msg, &len);
281
+      buf = build_buf_from_sip_request  ( p_msg, &len);
282 282
       if (!buf)
283 283
          return -1;
284 284
       T->outbound_request[branch]->bufflen = len ;
... ...
@@ -287,6 +264,7 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
287 287
       free( buf ) ;
288 288
    }/* end for the first time */
289 289
 
290
+
290 291
    /* sets and starts the RETRANS timer */
291 292
    T->outbound_request[branch]->nr_retrans    = 0;
292 293
    T->outbound_request[branch]->max_retrans = 
... ...
@@ -295,7 +273,7 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
295 295
    T->outbound_request[branch]->timeout         = RETR_T1;
296 296
    /* send the request */
297 297
    udp_send( T->outbound_request[branch]->buffer , T->outbound_request[branch]->bufflen , 
298
-		(struct sockaddr*)&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );
298
+		&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );
299 299
 }
300 300
 
301 301
 
... ...
@@ -529,19 +507,19 @@ int t_reply_matching( struct s_table *hash_table , struct sip_msg *p_msg , struc
529 529
    /* getting the hash_index from the brach param , via header*/
530 530
    begin = p_msg->via1->branch->value.s;
531 531
    for(  ; *begin!='.' ; begin++ );
532
-   hash_index = strtol( ++begin , &end , 16 );
532
+   hash_index = strtol( ++begin , &end , 10 );
533 533
    /*if the hash index is corect */
534 534
    if  ( *end=='.' && hash_index>=0 && hash_index<TABLE_ENTRIES-1 )
535 535
    {
536 536
       /* getting the entry label value */
537 537
       begin=end++ ;
538
-      entry_label = strtol( ++begin , &end , 16 );
538
+      entry_label = strtol( ++begin , &end , 10 );
539 539
       /* if the entry label also is corect */
540 540
       if  ( *end=='.' && entry_label>=0 )
541 541
       {
542 542
          /* getting the branch_id value */
543 543
          begin=end++ ;
544
-         branch_id = strtol( ++begin , &end , 16 );
544
+         branch_id = strtol( ++begin , &end , 10 );
545 545
          /* if the entry label also is corect */
546 546
           if  ( branch_id>=0 )
547 547
           {
... ...
@@ -896,8 +874,28 @@ void delete_handler( void *attr)
896 896
    to outgoing requests
897 897
 */
898 898
 int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
899
-{	trans->label;
899
+{
900
+	char *c;
901
+
902
+
903
+	/* check size now */
904
+/*
905
+	if (p_msg->add_to_branch.len+ .... > MAX_BRANCH_PARAM_LEN ) {
906
+		LOG(L_ERR, "ERROR: add_branch_label: too small branch buffer\n");
907
+		return -1;
908
+	}	
909
+*/
910
+
911
+	/* check if there already was something else -- if not, allocate */
912
+
913
+/*
914
+ = (char*)sh_malloc( MAX_BRANCH_PARAM_LEN );
915
+
916
+
917
+
918
+	trans->label;
900 919
 	trans->hash_index;
901 920
 	p_msg->add_to_branch;
902 921
 	branch;
922
+*/
903 923
 }