Browse code

- oops - I forgot about adding the new files :-(

Bogdan-Andrei Iancu authored on 07/02/2004 09:16:22
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,106 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Copyright (C) 2001-2003 Fhg Fokus
4
+ *
5
+ * This file is part of ser, a free SIP server.
6
+ *
7
+ * ser is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version
11
+ *
12
+ * For a license to use the ser software under conditions
13
+ * other than those described here, or to purchase support for this
14
+ * software, please contact iptel.org by e-mail at the following addresses:
15
+ *    info@iptel.org
16
+ *
17
+ * ser is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+ * GNU General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU General Public License 
23
+ * along with this program; if not, write to the Free Software 
24
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ *
26
+ * History:
27
+ * ---------
28
+ *  2004-02-06  created (bogdan)
29
+ */
30
+
31
+
32
+#include "sr_module.h"
33
+#include "dprint.h"
34
+#include "mem/mem.h"
35
+#include "db/db.h"
36
+#include "usr_avp.h"
37
+
38
+
39
+
40
+static db_con_t  *avp_db_con = 0;
41
+struct usr_avp   *users_avps = 0;
42
+char             *avp_db_url = 0;
43
+
44
+
45
+static char* usr_type[] = {"ruri","from","to",0};
46
+
47
+
48
+int init_avp_child( int rank )
49
+{
50
+	if ( rank>PROC_MAIN ) {
51
+		if (avp_db_con==0) {
52
+			LOG(L_NOTICE,"NOTICE:init_avp_child: no avp_db_url specified "
53
+				"-> feature disabled\n");
54
+			return 0;
55
+		}
56
+		/* init db connection */
57
+		if ( bind_dbmod(avp_db_url) < 0 ) {
58
+			LOG(L_ERR,"ERROR:init_avp_child: unable to find any db module\n");
59
+			return -1;
60
+		}
61
+		if ( (avp_db_con=db_init( avp_db_url ))==0) {
62
+			/* connection failed */
63
+			LOG(L_ERR,"ERROR:init_avp_child: unable to connect to database\n");
64
+			return -1;
65
+		}
66
+	}
67
+
68
+	return 0;
69
+}
70
+
71
+
72
+
73
+void destroy_avps( )
74
+{
75
+	struct usr_avp *avp;
76
+
77
+	while (users_avps) {
78
+		avp = users_avps;
79
+		users_avps = users_avps->next;
80
+		pkg_free( avp );
81
+	}
82
+}
83
+
84
+
85
+
86
+int get_user_type( char *id )
87
+{
88
+	int i;
89
+
90
+	for(i=0;usr_type[i];i++) {
91
+		if (!strcasecmp( id, usr_type[i]) )
92
+			return i;
93
+	}
94
+
95
+	LOG(L_ERR,"ERROR:avp:get_user_type: unknown user type <%s>\n",id);
96
+	return -1;
97
+}
98
+
99
+
100
+int load_avp( struct sip_msg *msg, int type, char *attr, int use_dom)
101
+{
102
+	DBG("----load_avp:%d,%s,%d\n",type,attr?attr:"NULL",use_dom);
103
+	return 1;
104
+}
105
+
0 106
new file mode 100644
... ...
@@ -0,0 +1,68 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * Copyright (C) 2001-2003 Fhg Fokus
4
+ *
5
+ * This file is part of ser, a free SIP server.
6
+ *
7
+ * ser is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version
11
+ *
12
+ * For a license to use the ser software under conditions
13
+ * other than those described here, or to purchase support for this
14
+ * software, please contact iptel.org by e-mail at the following addresses:
15
+ *    info@iptel.org
16
+ *
17
+ * ser is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+ * GNU General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU General Public License 
23
+ * along with this program; if not, write to the Free Software 
24
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ *
26
+ * History:
27
+ * ---------
28
+ *  2004-02-06  created (bogdan)
29
+ */
30
+
31
+#ifndef _SER_URS_AVP_H_
32
+#define _SER_URS_AVP_H_
33
+
34
+
35
+#include "parser/msg_parser.h"
36
+
37
+
38
+struct usr_avp {
39
+	unsigned int id;
40
+	str attr;
41
+	union {
42
+		str  str_val;
43
+		unsigned int int_val;
44
+	}val;
45
+	struct usr_avp *next;
46
+};
47
+
48
+extern struct usr_avp   *users_avps;
49
+
50
+
51
+#define AVP_USER_RURI    1
52
+#define AVP_USER_FROM    2
53
+#define AVP_USER_TO      3
54
+
55
+#define AVP_ALL_ATTR     ((char*)0xffffffff)
56
+
57
+
58
+/* init function */
59
+int init_avp_child( int rank );
60
+int get_user_type( char *id );
61
+
62
+/* load/free/seach functions */
63
+void destroy_avps( );
64
+int load_avp( struct sip_msg *msg, int type, char *attr, int use_dom);
65
+
66
+#endif
67
+