Browse code

lib/kcore: cleaned up unused code

- local route and errinfo related code were not used for long time
- also moved some bits of code to more appropriate location

Daniel-Constantin Mierla authored on 10/02/2012 12:42:59
Showing 67 changed files
... ...
@@ -294,6 +294,34 @@ int crc32file (char *name)
294 294
 	fclose(fin); return OK;
295 295
 }
296 296
 
297
+/*!
298
+ * \brief CRC32 value from source string
299
+ * \param source_string source string
300
+ * \param hash_ret calulated CRC32
301
+ */
302
+void crc32_uint (str *source_string, unsigned int *hash_ret) 
303
+{	
304
+	unsigned int hash;	
305
+	unsigned int len;
306
+	const char *data;
307
+	
308
+	hash = 0xffffffff;
309
+	data = source_string->s;
310
+	
311
+	for (len = source_string->len / 4; len--; data += 4) {
312
+		hash = crc_32_tab[((unsigned char)hash) ^ data[0]] ^ (hash >> 8);
313
+		hash = crc_32_tab[((unsigned char)hash) ^ data[1]] ^ (hash >> 8);
314
+		hash = crc_32_tab[((unsigned char)hash) ^ data[2]] ^ (hash >> 8);
315
+		hash = crc_32_tab[((unsigned char)hash) ^ data[3]] ^ (hash >> 8);
316
+	}
317
+	
318
+	for (len = source_string->len % 4; len--; data++) {
319
+		hash = crc_32_tab[((unsigned char)hash) ^ *data] ^ (hash >> 8);
320
+	}
321
+	
322
+	*hash_ret = ~hash;
323
+}
324
+
297 325
 /*
298 326
 
299 327
 int main(int argc, char **argv)
... ...
@@ -16,5 +16,7 @@ unsigned short crcitt_string_ex( char *s, int len, register unsigned short ccitt
16 16
 unsigned short crcitt_string( char *s, int len );
17 17
 void crcitt_string_array( char *dst, str src[], int size );
18 18
 
19
+void crc32_uint (str *source_string, unsigned int *hash_ret);
20
+
19 21
 #endif /* _CRC_H_ */
20 22
 
... ...
@@ -251,5 +251,94 @@ inline static unsigned int get_hash2_case_raw2(const str* key1,
251 251
 }
252 252
 
253 253
 
254
+/*
255
+ * generic hashing - from the intial origins of ser
256
+ */
257
+#define ch_h_inc h+=v^(v>>3)
258
+#define ch_icase(_c) (((_c)>='A'&&(_c)<='Z')?((_c)|0x20):(_c))
259
+
260
+/*
261
+ * case sensitive hashing
262
+ * - s1 - str to hash
263
+ * - s2 - optional - continue hashing over s2
264
+ * - size - optional - size of hash table (must be power of 1); if set (!=0),
265
+ *   instead of hash id, returned value is slot index
266
+ * return computed hash id or hash table slot index
267
+ */
268
+static inline unsigned int core_hash(const str *s1, const str *s2,
269
+		const unsigned int size)
270
+{
271
+	char *p, *end;
272
+	register unsigned v;
273
+	register unsigned h;
274
+
275
+	h=0;
276
+
277
+	end=s1->s+s1->len;
278
+	for ( p=s1->s ; p<=(end-4) ; p+=4 ){
279
+		v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
280
+		ch_h_inc;
281
+	}
282
+	v=0;
283
+	for (; p<end ; p++){ v<<=8; v+=*p;}
284
+	ch_h_inc;
285
+
286
+	if (s2) {
287
+		end=s2->s+s2->len;
288
+		for (p=s2->s; p<=(end-4); p+=4){
289
+			v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
290
+			ch_h_inc;
291
+		}
292
+		v=0;
293
+		for (; p<end ; p++){ v<<=8; v+=*p;}
294
+		ch_h_inc;
295
+	}
296
+	h=((h)+(h>>11))+((h>>13)+(h>>23));
297
+	return size?((h)&(size-1)):h;
298
+}
299
+
300
+
301
+/*
302
+ * case insensitive hashing
303
+ * - s1 - str to hash
304
+ * - s2 - optional - continue hashing over s2
305
+ * - size - optional - size of hash table (must be power of 1); if set (!=0),
306
+ *   instead of hash id, returned value is slot index
307
+ * return computed hash id or hash table slot index
308
+ */
309
+static inline unsigned int core_case_hash( str *s1, str *s2,
310
+		unsigned int size)
311
+{
312
+	char *p, *end;
313
+	register unsigned v;
314
+	register unsigned h;
315
+
316
+	h=0;
317
+
318
+	end=s1->s+s1->len;
319
+	for ( p=s1->s ; p<=(end-4) ; p+=4 ){
320
+		v=(ch_icase(*p)<<24)+(ch_icase(p[1])<<16)+(ch_icase(p[2])<<8)
321
+			+ ch_icase(p[3]);
322
+		ch_h_inc;
323
+	}
324
+	v=0;
325
+	for (; p<end ; p++){ v<<=8; v+=ch_icase(*p);}
326
+	ch_h_inc;
327
+
328
+	if (s2) {
329
+		end=s2->s+s2->len;
330
+		for (p=s2->s; p<=(end-4); p+=4){
331
+			v=(ch_icase(*p)<<24)+(ch_icase(p[1])<<16)+(ch_icase(p[2])<<8)
332
+				+ ch_icase(p[3]);
333
+			ch_h_inc;
334
+		}
335
+		v=0;
336
+		for (; p<end ; p++){ v<<=8; v+=ch_icase(*p);}
337
+		ch_h_inc;
338
+	}
339
+	h=((h)+(h>>11))+((h>>13)+(h>>23));
340
+	return size?((h)&(size-1)):h;
341
+}
342
+
254 343
 
255 344
 #endif
256 345
deleted file mode 100644
... ...
@@ -1,75 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * Copyright (C) 2006 Voice Sistem SRL
5
- *
6
- * This file is part of Kamailio, a free SIP server.
7
- *
8
- * Kamailio is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
12
- *
13
- * Kamailio is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License 
19
- * along with this program; if not, write to the Free Software 
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
- */
22
-
23
-/*!
24
- * \file errinfo.c
25
- * \brief Kamailio Error info functions
26
- */
27
-
28
-
29
-#include <stdlib.h>
30
-#include <string.h>
31
-
32
-#include "../../dprint.h"
33
-#include "errinfo.h"
34
-
35
-/*! global error info */
36
-err_info_t _oser_err_info;
37
-
38
-/*! \brief Get global error state
39
- */
40
-err_info_t* get_err_info(void) { return &_oser_err_info; }
41
-
42
-/*! \brief Initialize global error state
43
- */
44
-void init_err_info(void)
45
-{
46
-	memset(&_oser_err_info, 0, sizeof(err_info_t));
47
-}
48
-
49
-/*! \brief Set suggested error info message
50
- */
51
-void set_err_info(int ec, int el, char *info)
52
-{
53
-	LM_DBG("ec: %d, el: %d, ei: '%s'\n", ec, el,
54
-			(info)?info:"");
55
-	_oser_err_info.eclass = ec;
56
-	_oser_err_info.level = el;
57
-	if(info)
58
-	{
59
-		_oser_err_info.info.s   = info;
60
-		_oser_err_info.info.len = strlen(info);
61
-	}
62
-}
63
-
64
-/*! \brief Set suggested error reply
65
- */
66
-void set_err_reply(int rc, char *rr)
67
-{
68
-	_oser_err_info.rcode = rc;
69
-	if(rr)
70
-	{
71
-		_oser_err_info.rreason.s   = rr;
72
-		_oser_err_info.rreason.len = strlen(rr);
73
-	}
74
-}
75
-
76 1
deleted file mode 100644
... ...
@@ -1,59 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * Copyright (C) 2006 Voice Sistem SRL
5
- *
6
- * This file is part of Kamailio, a free SIP server.
7
- *
8
- * Kamailio is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
12
- *
13
- * Kamailio is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License 
19
- * along with this program; if not, write to the Free Software 
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
- */
22
-
23
-/*!
24
- * \file errinfo.h
25
- * \brief Error handling
26
- */
27
-
28
-
29
-#ifndef _errinfo_h_
30
-#define _errinfo_h_
31
-
32
-#include "../../str.h"
33
-
34
-/*! \name ErrorClasses  error clases */
35
-#define OSER_EC_PARSER	1 /*!< parse error */
36
-#define OSER_EC_PMEMORY	2 /*!< private memory error */
37
-#define OSER_EC_SMEMORY	3 /*!< share memory error */
38
-
39
-#define OSER_EL_CRITIC	1
40
-#define OSER_EL_HIGH	2
41
-#define OSER_EL_MEDIUM	3 /*!< severity level normal - used by parsing errors */
42
-#define OSER_EL_NORMAL	4
43
-#define OSER_EL_LOW	5
44
-
45
-typedef struct err_info_
46
-{
47
-	int eclass;		/*!< error class */
48
-	int level;		/*!< severity level (lower is higher) */
49
-	str info;		/*!< error details */
50
-	int rcode;		/*!< recommended reply code */
51
-	str rreason;	/*!< recommended reply reason phrase */
52
-} err_info_t;
53
-
54
-void init_err_info(void);
55
-void set_err_info(int ec, int el, char *info);
56
-void set_err_reply(int rc, char *rr);
57
-err_info_t* get_err_info(void);
58
-
59
-#endif
60 1
deleted file mode 100644
... ...
@@ -1,112 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * Copyright (C) 2001-2003 FhG Fokus
5
- *
6
- * This file is part of Kamailio, a free SIP server.
7
- *
8
- * Kamailio is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version
12
- *
13
- * Kamailio is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License 
19
- * along with this program; if not, write to the Free Software 
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
- *
22
- * History:
23
- *---------
24
- *
25
- * 2006-01-20 - new_hash1() added; support for configurable hash size
26
- *              added (bogdan)
27
- * 2006-03-13 - new_hash1() and new_hash2() merged into core_hash();
28
- *              added core_case_hash() for case insensitive hashes;
29
- *              all TM dependet stuff moved to TM config file (bogdan)
30
- */
31
-
32
-/*!
33
- * \file
34
- * \brief Hash functions
35
- */
36
-
37
-
38
-#ifndef _HASH_FUNC_H_
39
-#define _HASH_FUNC_H_
40
-
41
-#include "../../str.h"
42
-
43
-
44
-#define ch_h_inc h+=v^(v>>3)
45
-#define ch_icase(_c) (((_c)>='A'&&(_c)<='Z')?((_c)|0x20):(_c))
46
-static inline unsigned int core_hash(const str *s1, const str *s2, const unsigned int size)
47
-{
48
-	char *p, *end;
49
-	register unsigned v;
50
-	register unsigned h;
51
-
52
-	h=0;
53
-
54
-	end=s1->s+s1->len;
55
-	for ( p=s1->s ; p<=(end-4) ; p+=4 ){
56
-		v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
57
-		ch_h_inc;
58
-	}
59
-	v=0;
60
-	for (; p<end ; p++){ v<<=8; v+=*p;}
61
-	ch_h_inc;
62
-
63
-	if (s2) {
64
-		end=s2->s+s2->len;
65
-		for (p=s2->s; p<=(end-4); p+=4){
66
-			v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
67
-			ch_h_inc;
68
-		}
69
-		v=0;
70
-		for (; p<end ; p++){ v<<=8; v+=*p;}
71
-		ch_h_inc;
72
-	}
73
-	h=((h)+(h>>11))+((h>>13)+(h>>23));
74
-	return size?((h)&(size-1)):h;
75
-}
76
-
77
-
78
-static inline unsigned int core_case_hash( str *s1, str *s2, unsigned int size)
79
-{
80
-	char *p, *end;
81
-	register unsigned v;
82
-	register unsigned h;
83
-
84
-	h=0;
85
-
86
-	end=s1->s+s1->len;
87
-	for ( p=s1->s ; p<=(end-4) ; p+=4 ){
88
-		v=(ch_icase(*p)<<24)+(ch_icase(p[1])<<16)+(ch_icase(p[2])<<8)
89
-			+ ch_icase(p[3]);
90
-		ch_h_inc;
91
-	}
92
-	v=0;
93
-	for (; p<end ; p++){ v<<=8; v+=ch_icase(*p);}
94
-	ch_h_inc;
95
-
96
-	if (s2) {
97
-		end=s2->s+s2->len;
98
-		for (p=s2->s; p<=(end-4); p+=4){
99
-			v=(ch_icase(*p)<<24)+(ch_icase(p[1])<<16)+(ch_icase(p[2])<<8)
100
-				+ ch_icase(p[3]);
101
-			ch_h_inc;
102
-		}
103
-		v=0;
104
-		for (; p<end ; p++){ v<<=8; v+=ch_icase(*p);}
105
-		ch_h_inc;
106
-	}
107
-	h=((h)+(h>>11))+((h>>13)+(h>>23));
108
-	return size?((h)&(size-1)):h;
109
-}
110
-
111
-
112
-#endif
113 1
deleted file mode 100644
... ...
@@ -1,30 +0,0 @@
1
-#include "km_crc.h"
2
-
3
-/*!
4
- * \brief CRC32 value from source string
5
- * \param source_string source string
6
- * \param hash_ret calulated CRC32
7
- */
8
-void crc32_uint (str *source_string, unsigned int *hash_ret) 
9
-{	
10
-	unsigned int hash;	
11
-	unsigned int len;
12
-	const char *data;
13
-	
14
-	hash = 0xffffffff;
15
-	data = source_string->s;
16
-	
17
-	for (len = source_string->len / 4; len--; data += 4) {
18
-		hash = crc_32_tab[((unsigned char)hash) ^ data[0]] ^ (hash >> 8);
19
-		hash = crc_32_tab[((unsigned char)hash) ^ data[1]] ^ (hash >> 8);
20
-		hash = crc_32_tab[((unsigned char)hash) ^ data[2]] ^ (hash >> 8);
21
-		hash = crc_32_tab[((unsigned char)hash) ^ data[3]] ^ (hash >> 8);
22
-	}
23
-	
24
-	for (len = source_string->len % 4; len--; data++) {
25
-		hash = crc_32_tab[((unsigned char)hash) ^ *data] ^ (hash >> 8);
26
-	}
27
-	
28
-	*hash_ret = ~hash;
29
-}
30
-
31 1
deleted file mode 100644
... ...
@@ -1,9 +0,0 @@
1
-#ifndef _KM_CRC_H
2
-#define _KM_CRC_H
3
-
4
-#include "../../crc.h"
5
-#include "../../str.h"
6
-
7
-void crc32_uint (str *source_string, unsigned int *hash_ret);
8
-
9
-#endif /* _KM_CRC_H */
10 1
deleted file mode 100644
... ...
@@ -1,112 +0,0 @@
1
-/*
2
- *$Id$
3
- *
4
- * - various general purpose functions
5
- *
6
- * Copyright (C) 2001-2003 FhG Fokus
7
- *
8
- * This file is part of Kamailio, a free SIP server.
9
- *
10
- * Kamailio is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version
14
- *
15
- * Kamailio is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
- *
24
- */
25
-
26
-/*!
27
- * \file
28
- * \brief Various utility functions, mostly related to string handling
29
- */
30
-
31
-#ifndef _KM_UT_H
32
-#define _KM_UT_H
33
-
34
-#include "../../ut.h"
35
-
36
-#ifndef MIN
37
-#define MIN(a, b) (a<b?a:b)
38
-#endif
39
-#ifndef MAX
40
-#define MAX(a, b) (a>b?a:b)
41
-#endif
42
-
43
-
44
-/* INTeger-TO-Buffer-STRing : convers an unsigned long to a string 
45
- * IMPORTANT: the provided buffer must be at least INT2STR_MAX_LEN size !! */
46
-static inline char* int2bstr(unsigned long l, char *s, int* len)
47
-{
48
-	int i;
49
-	i=INT2STR_MAX_LEN-2;
50
-	s[INT2STR_MAX_LEN-1]=0;
51
-	/* null terminate */
52
-	do{
53
-		s[i]=l%10+'0';
54
-		i--;
55
-		l/=10;
56
-	}while(l && (i>=0));
57
-	if (l && (i<0)){
58
-		LM_CRIT("overflow error\n");
59
-	}
60
-	if (len) *len=(INT2STR_MAX_LEN-2)-i;
61
-	return &s[i+1];
62
-}
63
-
64
-
65
-inline static int hexstr2int(char *c, int len, unsigned int *val)
66
-{
67
-	char *pc;
68
-	int r;
69
-	char mychar;
70
-
71
-	r=0;
72
-	for (pc=c; pc<c+len; pc++) {
73
-		r <<= 4 ;
74
-		mychar=*pc;
75
-		if ( mychar >='0' && mychar <='9') r+=mychar -'0';
76
-		else if (mychar >='a' && mychar <='f') r+=mychar -'a'+10;
77
-		else if (mychar  >='A' && mychar <='F') r+=mychar -'A'+10;
78
-		else return -1;
79
-	}
80
-	*val = r;
81
-	return 0;
82
-}
83
-
84
-
85
-
86
-/*
87
- * Convert a str (base 10 or 16) into integer
88
- */
89
-static inline int strno2int( str *val, unsigned int *mask )
90
-{
91
-	/* hexa or decimal*/
92
-	if (val->len>2 && val->s[0]=='0' && val->s[1]=='x') {
93
-		return hexstr2int( val->s+2, val->len-2, mask);
94
-	} else {
95
-		return str2int( val, mask);
96
-	}
97
-}
98
-
99
-
100
-
101
-/*! right and left space trimming */
102
-#define trim_spaces_lr(_s_)												\
103
-	do{																	\
104
-		for(;(_s_).s[(_s_).len-1]==' ';(_s_).s[--(_s_).len]=0);			\
105
-		for(;(_s_).s[0]==' ';(_s_).s=(_s_).s+1,(_s_).len--);			\
106
-																		\
107
-	}																	\
108
-	while(0);															\
109
-	
110
-
111
-
112
-#endif /* _KM_UT_H */
... ...
@@ -34,7 +34,6 @@
34 34
 #include "../../dprint.h"
35 35
 #include "../../parser/msg_parser.h"
36 36
 #include "../../ut.h"
37
-#include "errinfo.h"
38 37
 #include "../../mem/mem.h"
39 38
 
40 39
 
... ...
@@ -113,8 +112,6 @@ struct sip_uri *parse_ppi_uri(struct sip_msg *msg)
113 113
 	{
114 114
 		LM_ERR("failed to parse P-P-I URI\n");
115 115
 		memset(&tb->parsed_uri, 0, sizeof(struct sip_uri));
116
-		set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM, "error parsing P-P-I URI");
117
-		set_err_reply(400, "bad P-Preferred-Identity uri");
118 116
 		return NULL;
119 117
 	}
120 118
 
... ...
@@ -41,7 +41,6 @@
41 41
 #include "../../ut.h"
42 42
 #include "../../dprint.h"
43 43
 #include "../../socket_info.h"
44
-#include "km_ut.h"
45 44
 #include "statistics.h"
46 45
 
47 46
 #ifdef STATISTICS
... ...
@@ -35,7 +35,6 @@
35 35
 #include "../../dprint.h"
36 36
 #include "../../usr_avp.h"
37 37
 #include "../../mem/mem.h"
38
-#include "../../lib/kcore/km_ut.h"
39 38
 #include "avpops_parse.h"
40 39
 
41 40
 
... ...
@@ -31,7 +31,7 @@
31 31
 #include "../../parser/parse_uri.h"
32 32
 #include "../../parser/parse_to.h"
33 33
 #include "../../parser/parse_from.h"
34
-#include "../../lib/kcore/km_crc.h"
34
+#include "../../crc.h"
35 35
 
36 36
 #include <ctype.h>
37 37
 #include <stdio.h> /* for snprintf */
... ...
@@ -35,7 +35,7 @@
35 35
 #include "../../mem/shm_mem.h"
36 36
 #include "../../mem/mem.h"
37 37
 #include "../../dprint.h"
38
-#include "../../lib/kcore/hash_func.h"
38
+#include "../../hashes.h"
39 39
 #include "../../lock_ops.h"
40 40
 
41 41
 #include "dbcassa_table.h"
... ...
@@ -28,7 +28,7 @@
28 28
  */
29 29
 
30 30
 #include "../../mem/shm_mem.h"
31
-#include "../../lib/kcore/hash_func.h"
31
+#include "../../hashes.h"
32 32
 #include "lcr_mod.h"
33 33
 
34 34
 #define rule_hash(_s) core_hash(_s, 0, lcr_rule_hash_size_param)
... ...
@@ -68,7 +68,6 @@
68 68
 #include "../../mem/mem.h"
69 69
 #include "../../mem/shm_mem.h"
70 70
 #include "../../lib/srdb1/db.h"
71
-#include "../../lib/kcore/km_ut.h"
72 71
 #include "../../usr_avp.h"
73 72
 #include "../../parser/parse_from.h"
74 73
 #include "../../parser/msg_parser.h"
... ...
@@ -49,7 +49,6 @@
49 49
 #include "../../data_lump_rpl.h"
50 50
 #include "../../lib/kcore/statistics.h"
51 51
 #include "../../modules/sl/sl.h"
52
-#include "../../lib/kcore/km_ut.h"
53 52
 #include "../../lib/kmi/mi.h"
54 53
 
55 54
 #include "pl_ht.h"
... ...
@@ -39,7 +39,6 @@
39 39
 #include "../../hashes.h"
40 40
 #include "../../mem/shm_mem.h"
41 41
 #include "../../lib/kmi/mi.h"
42
-#include "../../lib/kcore/km_ut.h"
43 42
 
44 43
 #include "pl_ht.h"
45 44
 
... ...
@@ -49,7 +49,6 @@
49 49
 #include "../../data_lump.h"
50 50
 #include "../../data_lump_rpl.h"
51 51
 #include "../../lib/kcore/statistics.h"
52
-#include "../../lib/kcore/km_ut.h"
53 52
 #include "../../rpc_lookup.h"
54 53
 
55 54
 
... ...
@@ -210,7 +210,6 @@
210 210
 #include "../../pt.h"
211 211
 #include "../../timer_proc.h"
212 212
 #include "../../lib/kmi/mi.h"
213
-#include "../../lib/kcore/km_ut.h"
214 213
 #include "../../pvar.h"
215 214
 #include "../../lvalue.h"
216 215
 #include "../../msg_translator.h"
... ...
@@ -51,7 +51,6 @@
51 51
 #include "../../mem/mem.h"
52 52
 #include "../../usr_avp.h"
53 53
 #include "../../lib/srdb1/db.h"
54
-#include "../../lib/kcore/km_ut.h"
55 54
 #include "../../parser/hf.h"
56 55
 #include "../../parser/msg_parser.h"
57 56
 #include "../../parser/parse_from.h"
... ...
@@ -48,7 +48,6 @@
48 48
 #include "../../ut.h"
49 49
 #include "../../usr_avp.h"
50 50
 #include "../../mem/mem.h"
51
-#include "../../lib/kcore/km_ut.h"
52 51
 #include "acc_api.h"
53 52
 #include "acc_extra.h"
54 53
 
... ...
@@ -43,7 +43,6 @@
43 43
 #include "../../parser/parse_content.h"
44 44
 #include "../../modules/tm/tm_load.h"
45 45
 #include "../rr/api.h"
46
-#include "../../lib/kcore/km_ut.h"
47 46
 #include "../../flags.h"
48 47
 #include "acc.h"
49 48
 #include "acc_api.h"
... ...
@@ -68,8 +68,7 @@
68 68
 #include "../../md5.h"
69 69
 #include "../../md5utils.h"
70 70
 #include "../../globals.h"
71
-#include "../../lib/kcore/hash_func.h"
72
-#include "../../lib/kcore/km_ut.h"
71
+#include "../../hashes.h"
73 72
 #include "../../locking.h"
74 73
 #include <stdio.h>
75 74
 #include <stdlib.h>
... ...
@@ -32,7 +32,7 @@
32 32
 #include <libxml/parser.h>
33 33
 
34 34
 #include "../../parser/parse_uri.h"
35
-#include "../../lib/kcore/km_ut.h"
35
+#include "../../trim.h"
36 36
 #include "../../dprint.h"
37 37
 #include "../../str.h"
38 38
 #include "../../ut.h"
... ...
@@ -36,7 +36,7 @@
36 36
 #include "../../mem/shm_mem.h"
37 37
 #include "../../mem/mem.h"
38 38
 #include "../../dprint.h"
39
-#include "../../lib/kcore/hash_func.h"
39
+#include "../../hashes.h"
40 40
 
41 41
 #include "dbt_util.h"
42 42
 #include "dbt_lib.h"
... ...
@@ -66,7 +66,7 @@
66 66
 #include "../../mod_fix.h"
67 67
 #include "../../script_cb.h"
68 68
 #include "../../lib/kcore/faked_msg.h"
69
-#include "../../lib/kcore/hash_func.h"
69
+#include "../../hashes.h"
70 70
 #include "../../lib/kcore/kstats_wrapper.h"
71 71
 #include "../../mem/mem.h"
72 72
 #include "../../lib/kmi/mi.h"
... ...
@@ -54,7 +54,7 @@
54 54
 
55 55
 #include "../../dprint.h"
56 56
 #include "../../ut.h"
57
-#include "../../lib/kcore/hash_func.h"
57
+#include "../../hashes.h"
58 58
 #include "../../lib/kmi/mi.h"
59 59
 #include "dlg_timer.h"
60 60
 #include "dlg_var.h"
... ...
@@ -33,8 +33,8 @@
33 33
 
34 34
 
35 35
 #include "../../mem/shm_mem.h"
36
-#include "../../lib/kcore/hash_func.h"
37
-#include "../../lib/kcore/km_ut.h"
36
+#include "../../hashes.h"
37
+#include "../../trim.h"
38 38
 #include "../../dprint.h"
39 39
 #include "../../ut.h"
40 40
 #include "../../route.h"
... ...
@@ -37,7 +37,6 @@
37 37
 #include "../../modules/tm/dlg.h"
38 38
 #include "../../modules/tm/tm_load.h"
39 39
 #include "../../lib/kmi/tree.h"
40
-#include "../../lib/kcore/km_ut.h"
41 40
 #include "../../lib/kcore/kstats_wrapper.h"
42 41
 #include "dlg_timer.h"
43 42
 #include "dlg_hash.h"
... ...
@@ -26,7 +26,7 @@
26 26
 #include "../../mem/shm_mem.h"
27 27
 #include "../../mem/mem.h"
28 28
 #include "../../dprint.h"
29
-#include "../../lib/kcore/hash_func.h"
29
+#include "../../hashes.h"
30 30
 #include "../../ut.h"
31 31
 
32 32
 #include "ds_ht.h"
... ...
@@ -46,7 +46,7 @@
46 46
 #include "../../modules/sl/sl.h"
47 47
 #include "../../pt.h"
48 48
 #include "../../lib/kmi/mi.h"
49
-#include "../../lib/kcore/hash_func.h"
49
+#include "../../hashes.h"
50 50
 #include "dmq.h"
51 51
 #include "dmq_funcs.h"
52 52
 #include "peer.h"
... ...
@@ -25,7 +25,7 @@
25 25
 
26 26
 #include "../../dprint.h"
27 27
 #include "../../ut.h"
28
-#include "../../lib/kcore/hash_func.h"
28
+#include "../../hashes.h"
29 29
 #include "../../mem/shm_mem.h"
30 30
 #include "../../lib/kmi/mi.h"
31 31
 #include "domain_mod.h"
... ...
@@ -28,7 +28,7 @@
28 28
 #include "../../shm_init.h"
29 29
 #include "../../dprint.h"
30 30
 #include "../../parser/parse_param.h"
31
-#include "../../lib/kcore/hash_func.h"
31
+#include "../../hashes.h"
32 32
 #include "../../ut.h"
33 33
 #include "../../re.h"
34 34
 
... ...
@@ -47,7 +47,7 @@
47 47
 #include "../../parser/parse_content.h"
48 48
 #include "../../parser/contact/parse_contact.h"
49 49
 #include "../../resolve.h"
50
-#include "../../lib/kcore/hash_func.h"
50
+#include "../../hashes.h"
51 51
 #include "../../lib/kmi/mi.h"
52 52
 
53 53
 #include "../../modules/tm/tm_load.h"
... ...
@@ -34,7 +34,7 @@
34 34
 #include "../../mem/mem.h"
35 35
 #include "../../mem/shm_mem.h"
36 36
 #include "../../dprint.h"
37
-#include "../../lib/kcore/hash_func.h"
37
+#include "../../hashes.h"
38 38
 
39 39
 #include "imc_mng.h"
40 40
 /* imc hash table */
... ...
@@ -212,7 +212,6 @@
212 212
 #include "../../timer_proc.h"
213 213
 #include "../../lib/kmi/attr.h"
214 214
 #include "../../lib/kmi/mi.h"
215
-#include "../../lib/kcore/km_ut.h"
216 215
 #include "../../pvar.h"
217 216
 #include "../../lvalue.h"
218 217
 #include "../../msg_translator.h"
... ...
@@ -43,7 +43,7 @@
43 43
 #include "../../lib/srdb1/db.h"
44 44
 #include "../../socket_info.h"
45 45
 #include "../../ut.h"
46
-#include "../../lib/kcore/hash_func.h"
46
+#include "../../hashes.h"
47 47
 #include "p_usrloc_mod.h"            /* usrloc module parameters */
48 48
 #include "utime.h"
49 49
 #include "ul_db_layer.h"
... ...
@@ -23,7 +23,7 @@
23 23
 #include "p_usrloc_mod.h"
24 24
 #include "ul_db.h"
25 25
 #include "ul_db_watch.h"
26
-#include "../../lib/kcore/km_crc.h"
26
+#include "../../crc.h"
27 27
 
28 28
 static ul_db_handle_list_t * db_handles = NULL;
29 29
 
... ...
@@ -39,7 +39,7 @@
39 39
 #include "../../mem/shm_mem.h"
40 40
 #include "../../dprint.h"
41 41
 #include "../../ut.h"
42
-#include "../../lib/kcore/hash_func.h"
42
+#include "../../hashes.h"
43 43
 #include "p_usrloc_mod.h"
44 44
 #include "utime.h"
45 45
 #include "../usrloc/ul_callback.h"
... ...
@@ -25,7 +25,7 @@
25 25
 #include "../../mem/shm_mem.h"
26 26
 #include "../../parser/parse_from.h"
27 27
 #include "../../ut.h"
28
-#include "../../lib/kcore/hash_func.h"
28
+#include "../../hashes.h"
29 29
 #include "../../usr_avp.h"
30 30
 #include "../../ip_addr.h"
31 31
 #include "../../pvar.h"
... ...
@@ -34,7 +34,7 @@
34 34
 #include <stdio.h>
35 35
 #include <stdlib.h>
36 36
 #include "../../mem/shm_mem.h"
37
-#include "../../lib/kcore/hash_func.h"
37
+#include "../../hashes.h"
38 38
 #include "../../dprint.h"
39 39
 #include "../../str.h"
40 40
 #include "../pua/hash.h"
... ...
@@ -43,7 +43,7 @@
43 43
 #include "../../str.h"
44 44
 #include "../../lib/srdb1/db.h"
45 45
 #include "../../lib/srdb1/db_val.h"
46
-#include "../../lib/kcore/hash_func.h"
46
+#include "../../hashes.h"
47 47
 #include "../../socket_info.h"
48 48
 #include "../../modules/tm/tm_load.h"
49 49
 #include "../pua/hash.h"
... ...
@@ -63,7 +63,7 @@
63 63
 #include "../../modules/sl/sl.h"
64 64
 #include "../../pt.h"
65 65
 #include "../../lib/kmi/mi.h"
66
-#include "../../lib/kcore/hash_func.h"
66
+#include "../../hashes.h"
67 67
 #include "../pua/hash.h"
68 68
 #include "presence.h"
69 69
 #include "publish.h"
... ...
@@ -35,7 +35,7 @@
35 35
 #include <time.h>
36 36
 
37 37
 #include "../../lib/srdb1/db.h"
38
-#include "../../lib/kcore/hash_func.h"
38
+#include "../../hashes.h"
39 39
 #include "../../dprint.h"
40 40
 #include "../../mem/shm_mem.h"
41 41
 #include "../../str.h"
... ...
@@ -39,7 +39,7 @@
39 39
 #include "../../parser/parse_event.h" 
40 40
 #include "../../parser/parse_content.h" 
41 41
 #include "../../lock_ops.h"
42
-#include "../../lib/kcore/hash_func.h"
42
+#include "../../hashes.h"
43 43
 #include "../../lib/kcore/cmpapi.h"
44 44
 #include "../../lib/srdb1/db.h"
45 45
 #include "presence.h"
... ...
@@ -38,7 +38,7 @@
38 38
 #include "../../parser/parse_expires.h"
39 39
 #include "../../parser/parse_event.h"
40 40
 #include "../../parser/contact/parse_contact.h"
41
-#include "../../lib/kcore/hash_func.h"
41
+#include "../../hashes.h"
42 42
 #include "presence.h"
43 43
 #include "subscribe.h"
44 44
 #include "utils_func.h"
... ...
@@ -30,7 +30,7 @@
30 30
 #include "../../mem/mem.h"
31 31
 #include "../../mem/shm_mem.h"
32 32
 #include "../../dprint.h"
33
-#include "../../lib/kcore/hash_func.h"
33
+#include "../../hashes.h"
34 34
 #include "../../parser/msg_parser.h"
35 35
 #include "../../parser/parse_from.h"
36 36
 #include "hash.h" 
... ...
@@ -40,7 +40,7 @@
40 40
 #include "../../mem/shm_mem.h"
41 41
 #include "../../parser/msg_parser.h"
42 42
 #include "../../lib/kcore/cmpapi.h"
43
-#include "../../lib/kcore/hash_func.h"
43
+#include "../../hashes.h"
44 44
 #include "../../modules/tm/tm_load.h"
45 45
 #include "pua.h"
46 46
 #include "hash.h"
... ...
@@ -39,7 +39,7 @@
39 39
 #include "../../parser/parse_from.h"
40 40
 #include "../../parser/parse_expires.h"
41 41
 #include "../presence/hash.h"
42
-#include "../../lib/kcore/hash_func.h"
42
+#include "../../hashes.h"
43 43
 #include "hash.h"
44 44
 #include "pua.h"
45 45
 #include "send_subscribe.h"
... ...
@@ -24,7 +24,6 @@
24 24
 
25 25
 
26 26
 #include "../../qvalue.h"
27
-#include "../../lib/kcore/errinfo.h"
28 27
 #include "../../ut.h" 
29 28
 #include "../../route_struct.h"
30 29
 #include "../../dset.h"
... ...
@@ -322,32 +321,10 @@ int pv_get_ouri_attr(struct sip_msg *msg, pv_param_t *param,
322 322
 	return pv_get_xuri_attr(msg, &(msg->parsed_orig_ruri), param, res);
323 323
 }
324 324
 
325
-extern err_info_t _oser_err_info;
326 325
 int pv_get_errinfo_attr(struct sip_msg *msg, pv_param_t *param,
327 326
 		pv_value_t *res)
328 327
 {
329
-	if(msg==NULL)
330
-		return -1;
331
-
332
-	if(param->pvn.u.isname.name.n==0) /* class */ {
333
-		return pv_get_sintval(msg, param, res, _oser_err_info.eclass);
334
-	} else if(param->pvn.u.isname.name.n==1) /* level */ {
335
-		return pv_get_sintval(msg, param, res, _oser_err_info.level);
336
-	} else if(param->pvn.u.isname.name.n==2) /* info */ {
337
-		if(_oser_err_info.info.s==NULL)
338
-			pv_get_null(msg, param, res);
339
-		return pv_get_strval(msg, param, res, &_oser_err_info.info);
340
-	} else if(param->pvn.u.isname.name.n==3) /* rcode */ {
341
-		return pv_get_sintval(msg, param, res, _oser_err_info.rcode);
342
-	} else if(param->pvn.u.isname.name.n==4) /* rreason */ {
343
-		if(_oser_err_info.rreason.s==NULL)
344
-			pv_get_null(msg, param, res);
345
-		return pv_get_strval(msg, param, res, &_oser_err_info.rreason);
346
-	} else {
347
-		LM_DBG("invalid attribute!\n");
348
-		return pv_get_null(msg, param, res);
349
-	}
350
-	return 0;
328
+	return pv_get_null(msg, param, res);
351 329
 }
352 330
 
353 331
 int pv_get_contact(struct sip_msg *msg, pv_param_t *param,
... ...
@@ -39,7 +39,6 @@
39 39
 #include "../../trim.h" 
40 40
 #include "../../pvapi.h"
41 41
 #include "../../dset.h"
42
-#include "../../lib/kcore/errinfo.h"
43 42
 
44 43
 #include "../../parser/parse_param.h"
45 44
 #include "../../parser/parse_uri.h"
... ...
@@ -66,7 +66,6 @@
66 66
 #include "../../error.h"
67 67
 #include "../../socket_info.h"
68 68
 #include "../../pvar.h"
69
-#include "../../lib/kcore/km_ut.h"
70 69
 #include "../../modules_k/usrloc/usrloc.h"
71 70
 #include "../../lib/kcore/statistics.h"
72 71
 #include "../../modules/sl/sl.h"
... ...
@@ -45,7 +45,7 @@
45 45
 #include "../../modules/tm/dlg.h"
46 46
 #include "../presence/utils_func.h"
47 47
 #include "../presence/hash.h"
48
-#include "../../lib/kcore/hash_func.h"
48
+#include "../../hashes.h"
49 49
 #include "rls.h"
50 50
 #include "notify.h"
51 51
 #include <libxml/xpath.h>
... ...
@@ -32,7 +32,7 @@
32 32
 #include "../../parser/parse_content.h"
33 33
 #include "../../parser/parse_from.h"
34 34
 #include "../../lib/kcore/cmpapi.h"
35
-#include "../../lib/kcore/hash_func.h"
35
+#include "../../hashes.h"
36 36
 #include "../../trim.h"
37 37
 #include "../pua/hash.h"
38 38
 #include "rls.h"
... ...
@@ -41,7 +41,7 @@
41 41
 #include "../../dprint.h"
42 42
 #include "../../error.h"
43 43
 #include "../../ut.h"
44
-#include "../../lib/kcore/hash_func.h"
44
+#include "../../hashes.h"
45 45
 #include "../../mem/mem.h"
46 46
 #include "../../mem/shm_mem.h"
47 47
 #include "../../modules/tm/tm_load.h"
... ...
@@ -34,7 +34,7 @@
34 34
 #include "../../dprint.h"
35 35
 #include "../../data_lump_rpl.h"
36 36
 #include "../../lib/kcore/cmpapi.h"
37
-#include "../../lib/kcore/hash_func.h"
37
+#include "../../hashes.h"
38 38
 #include "../../lib/kcore/parse_supported.h"
39 39
 #include "../../parser/msg_parser.h"
40 40
 #include "../../parser/parse_event.h"
... ...
@@ -33,7 +33,7 @@
33 33
 #include <sys/wait.h>/*waitpid*/
34 34
 
35 35
 #include "../../ip_addr.h" /*sockaddr_union, ip_addr*/
36
-#include "../../lib/kcore/hash_func.h" /*T_TABLE_POWER*/
36
+#include "../../hashes.h" /*T_TABLE_POWER*/
37 37
 #include "../../mem/mem.h" /*pkg_malloc*/
38 38
 #include "../../mem/shm_mem.h" /*shm_malloc*/
39 39
 #include "../../dprint.h" /*LM_**/
... ...
@@ -21,7 +21,7 @@
21 21
 
22 22
 #include <sys/time.h>
23 23
 #include <time.h>
24
-#include "../../lib/kcore/hash_func.h"/* for TABLE_ENTRIES define*/
24
+#include "../../hashes.h"/* for TABLE_ENTRIES define*/
25 25
 #include "../../locking.h"/* for TABLE_ENTRIES define*/
26 26
 #include "../../modules/tm/h_table.h"/* for struct cell*/
27 27
 #define STATS_CELLS 50
... ...
@@ -43,7 +43,6 @@
43 43
 #include "../../dprint.h"
44 44
 #include "../../error.h"
45 45
 #include "../../ut.h"
46
-#include "../../lib/kcore/km_ut.h"
47 46
 #include "../../mem/mem.h"
48 47
 #include "../../mem/shm_mem.h"
49 48
 #include "../../timer.h"
... ...
@@ -30,7 +30,7 @@
30 30
 
31 31
 #include "../../mem/mem.h"
32 32
 #include "../../dprint.h"
33
-#include "../../lib/kcore/hash_func.h"
33
+#include "../../hashes.h"
34 34
 #include "../../ut.h"
35 35
 #include "../../lib/srdb1/db_ut.h"
36 36
 #ifdef WITH_XAVP
... ...
@@ -56,7 +56,6 @@
56 56
 #include "../../pvar.h"
57 57
 #include "../../lib/kcore/parse_sst.h"
58 58
 #include "../../lib/kcore/parse_supported.h"
59
-#include "../../lib/kcore/km_ut.h"
60 59
 #include "../../mem/mem.h"
61 60
 #include "../../mem/shm_mem.h"
62 61
 #include "../../data_lump.h"
... ...
@@ -43,7 +43,7 @@
43 43
 #include "../../lib/srdb1/db.h"
44 44
 #include "../../socket_info.h"
45 45
 #include "../../ut.h"
46
-#include "../../lib/kcore/hash_func.h"
46
+#include "../../hashes.h"
47 47
 #include "ul_mod.h"            /* usrloc module parameters */
48 48
 #include "usrloc.h"
49 49
 #include "utime.h"
... ...
@@ -39,7 +39,7 @@
39 39
 #include "../../mem/shm_mem.h"
40 40
 #include "../../dprint.h"
41 41
 #include "../../ut.h"
42
-#include "../../lib/kcore/hash_func.h"
42
+#include "../../hashes.h"
43 43
 #include "ul_mod.h"
44 44
 #include "usrloc.h"
45 45
 #include "utime.h"
... ...
@@ -50,7 +50,6 @@
50 50
 #include "reg_avps.h"
51 51
 #include "reg_avps_db.h"
52 52
 
53
-#define	MIN(x, y)	((x) < (y) ? (x) : (y))
54 53
 
55 54
 /*
56 55
  * Create a new contact structure
... ...
@@ -100,4 +100,18 @@ static inline void trim(str* _s)
100 100
 }
101 101
 
102 102
 
103
+/*
104
+ * right and left space trimming
105
+ *
106
+ * WARNING: String structure will be modified !
107
+ *          Make a copy otherwise you might be
108
+ *          unable to free _s_->s for example !
109
+ */
110
+#define trim_spaces_lr(_s_)												\
111
+	do{																	\
112
+		for(;(_s_).s[(_s_).len-1]==' ';(_s_).s[--(_s_).len]=0);			\
113
+		for(;(_s_).s[0]==' ';(_s_).s=(_s_).s+1,(_s_).len--);			\
114
+																		\
115
+	} while(0);
116
+	
103 117
 #endif /* TRIM_H */
... ...
@@ -772,6 +772,69 @@ static inline int str_strcasecmp(const str *str1, const str *str2)
772 772
 		return strncasecmp(str1->s, str2->s, str1->len);
773 773
 }
774 774
 
775
+#ifndef MIN
776
+#define	MIN(x, y)	((x) < (y) ? (x) : (y))
777
+#endif
778
+#ifndef MAX
779
+#define	MAX(x, y)	((x) > (y) ? (x) : (y))
780
+#endif
781
+
782
+
783
+/* INTeger-TO-Buffer-STRing : convers an unsigned long to a string 
784
+ * IMPORTANT: the provided buffer must be at least INT2STR_MAX_LEN size !! */
785
+static inline char* int2bstr(unsigned long l, char *s, int* len)
786
+{
787
+	int i;
788
+	i=INT2STR_MAX_LEN-2;
789
+	s[INT2STR_MAX_LEN-1]=0;
790
+	/* null terminate */
791
+	do{
792
+		s[i]=l%10+'0';
793
+		i--;
794
+		l/=10;
795
+	}while(l && (i>=0));
796
+	if (l && (i<0)){
797
+		LM_CRIT("overflow error\n");
798
+	}
799
+	if (len) *len=(INT2STR_MAX_LEN-2)-i;
800
+	return &s[i+1];
801
+}
802
+
803
+
804
+inline static int hexstr2int(char *c, int len, unsigned int *val)
805
+{
806
+	char *pc;
807
+	int r;
808
+	char mychar;
809
+
810
+	r=0;
811
+	for (pc=c; pc<c+len; pc++) {
812
+		r <<= 4 ;
813
+		mychar=*pc;
814
+		if ( mychar >='0' && mychar <='9') r+=mychar -'0';
815
+		else if (mychar >='a' && mychar <='f') r+=mychar -'a'+10;
816
+		else if (mychar  >='A' && mychar <='F') r+=mychar -'A'+10;
817
+		else return -1;
818
+	}
819
+	*val = r;
820
+	return 0;
821
+}
822
+
823
+
824
+
825
+/*
826
+ * Convert a str (base 10 or 16) into integer
827
+ */
828
+static inline int strno2int( str *val, unsigned int *mask )
829
+{
830
+	/* hexa or decimal*/
831
+	if (val->len>2 && val->s[0]=='0' && val->s[1]=='x') {
832
+		return hexstr2int( val->s+2, val->len-2, mask);
833
+	} else {
834
+		return str2int( val, mask);
835
+	}
836
+}
837
+
775 838
 /* converts a username into uid:gid,
776 839
  * returns -1 on error & 0 on success */
777 840
 int user2uid(int* uid, int* gid, char* user);