k/auth_db/api.h

00001 /*
00002  * $Id$
00003  *
00004  * Digest Authentication - Database support
00005  *
00006  * Copyright (C) 2001-2003 FhG Fokus
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  */
00024 
00025 
00026 #ifndef _AUTH_DB_API_H_
00027 #define _AUTH_DB_API_H_
00028 
00029 #include "../../sr_module.h"
00030 #include "../../parser/msg_parser.h"
00031 
00032 typedef int (*digest_authenticate_f)(struct sip_msg* msg, str *realm,
00033                                 str *table, hdr_types_t hftype);
00037 typedef struct auth_db_api {
00038         digest_authenticate_f digest_authenticate;
00039 } auth_db_api_t;
00040 
00041 typedef int (*bind_auth_db_f)(auth_db_api_t* api);
00042 
00046 static inline int auth_db_load_api(auth_db_api_t *api)
00047 {
00048         bind_auth_db_f bindauthdb;
00049 
00050         bindauthdb = (bind_auth_db_f)find_export("bind_auth_db", 0, 0);
00051         if(bindauthdb == 0) {
00052                 LM_ERR("cannot find bind_auth_db\n");
00053                 return -1;
00054         }
00055         if (bindauthdb(api)==-1)
00056         {
00057                 LM_ERR("cannot bind authdb api\n");
00058                 return -1;
00059         }
00060         return 0;
00061 }
00062 
00063 #endif /* _AUTH_DB_API_H_ */