Browse Source

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

Bogdan-Andrei Iancu 21 năm trước cách đây
mục cha
commit
717bc5dab3
2 tập tin đã thay đổi với 174 bổ sung0 xóa
  1. 106 0
      usr_avp.c
  2. 68 0
      usr_avp.h

+ 106 - 0
usr_avp.c

@@ -0,0 +1,106 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2001-2003 Fhg Fokus
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * For a license to use the ser software under conditions
+ * other than those described here, or to purchase support for this
+ * software, please contact iptel.org by e-mail at the following addresses:
+ *    [email protected]
+ *
+ * ser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * History:
+ * ---------
+ *  2004-02-06  created (bogdan)
+ */
+
+
+#include "sr_module.h"
+#include "dprint.h"
+#include "mem/mem.h"
+#include "db/db.h"
+#include "usr_avp.h"
+
+
+
+static db_con_t  *avp_db_con = 0;
+struct usr_avp   *users_avps = 0;
+char             *avp_db_url = 0;
+
+
+static char* usr_type[] = {"ruri","from","to",0};
+
+
+int init_avp_child( int rank )
+{
+	if ( rank>PROC_MAIN ) {
+		if (avp_db_con==0) {
+			LOG(L_NOTICE,"NOTICE:init_avp_child: no avp_db_url specified "
+				"-> feature disabled\n");
+			return 0;
+		}
+		/* init db connection */
+		if ( bind_dbmod(avp_db_url) < 0 ) {
+			LOG(L_ERR,"ERROR:init_avp_child: unable to find any db module\n");
+			return -1;
+		}
+		if ( (avp_db_con=db_init( avp_db_url ))==0) {
+			/* connection failed */
+			LOG(L_ERR,"ERROR:init_avp_child: unable to connect to database\n");
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+
+
+void destroy_avps( )
+{
+	struct usr_avp *avp;
+
+	while (users_avps) {
+		avp = users_avps;
+		users_avps = users_avps->next;
+		pkg_free( avp );
+	}
+}
+
+
+
+int get_user_type( char *id )
+{
+	int i;
+
+	for(i=0;usr_type[i];i++) {
+		if (!strcasecmp( id, usr_type[i]) )
+			return i;
+	}
+
+	LOG(L_ERR,"ERROR:avp:get_user_type: unknown user type <%s>\n",id);
+	return -1;
+}
+
+
+int load_avp( struct sip_msg *msg, int type, char *attr, int use_dom)
+{
+	DBG("----load_avp:%d,%s,%d\n",type,attr?attr:"NULL",use_dom);
+	return 1;
+}
+

+ 68 - 0
usr_avp.h

@@ -0,0 +1,68 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2001-2003 Fhg Fokus
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version
+ *
+ * For a license to use the ser software under conditions
+ * other than those described here, or to purchase support for this
+ * software, please contact iptel.org by e-mail at the following addresses:
+ *    [email protected]
+ *
+ * ser is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License 
+ * along with this program; if not, write to the Free Software 
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * History:
+ * ---------
+ *  2004-02-06  created (bogdan)
+ */
+
+#ifndef _SER_URS_AVP_H_
+#define _SER_URS_AVP_H_
+
+
+#include "parser/msg_parser.h"
+
+
+struct usr_avp {
+	unsigned int id;
+	str attr;
+	union {
+		str  str_val;
+		unsigned int int_val;
+	}val;
+	struct usr_avp *next;
+};
+
+extern struct usr_avp   *users_avps;
+
+
+#define AVP_USER_RURI    1
+#define AVP_USER_FROM    2
+#define AVP_USER_TO      3
+
+#define AVP_ALL_ATTR     ((char*)0xffffffff)
+
+
+/* init function */
+int init_avp_child( int rank );
+int get_user_type( char *id );
+
+/* load/free/seach functions */
+void destroy_avps( );
+int load_avp( struct sip_msg *msg, int type, char *attr, int use_dom);
+
+#endif
+