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