ld_session.h

00001 /*
00002 * $Id$
00003 *
00004 * Kamailio LDAP Module
00005 *
00006 * Copyright (C) 2007 University of North Carolina
00007 *
00008 * Original author: Christian Schlatter, cs@unc.edu
00009 *
00010 *
00011 * This file is part of Kamailio, a free SIP server.
00012 *
00013 * Kamailio is free software; you can redistribute it and/or modify
00014 * it under the terms of the GNU General Public License as published by
00015 * the Free Software Foundation; either version 2 of the License, or
00016 * (at your option) any later version
00017 *
00018 * Kamailio is distributed in the hope that it will be useful,
00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 * GNU General Public License for more details.
00022 *
00023 * You should have received a copy of the GNU General Public License
00024 * along with this program; if not, write to the Free Software
00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 *
00027 * History:
00028 * --------
00029 * 2007-02-18: Initial version
00030 */
00031 
00032 
00033 #ifndef LD_SESSION_H
00034 #define LD_SESSION_H
00035 
00036 #include <ldap.h>
00037 
00038 #include "iniparser.h"
00039 
00040 
00041 struct ld_session {
00042         char                    name[256];
00043         LDAP*                   handle;
00044         char*                   host_name;
00045         int                     version;
00046         int                     server_search_timeout;
00047         struct timeval          client_search_timeout;
00048         struct timeval          client_bind_timeout;
00049         struct timeval          network_timeout;
00050         char*                   bind_dn;
00051         char*                   bind_pwd;
00052         int                     calculate_ha1;
00053         struct ld_session*      next;
00054 };
00055 
00056 #define CFG_N_LDAP_HOST "ldap_server_url"
00057 #define CFG_N_LDAP_VERSION "ldap_version"
00058 #define CFG_N_LDAP_SERVER_SEARCH_TIMEOUT "ldap_server_search_timeout"
00059 #define CFG_N_LDAP_CLIENT_SEARCH_TIMEOUT "ldap_client_search_timeout"
00060 #define CFG_N_LDAP_CLIENT_BIND_TIMEOUT "ldap_client_bind_timeout"
00061 #define CFG_N_LDAP_NETWORK_TIMEOUT "ldap_network_timeout"
00062 #define CFG_N_LDAP_BIND_DN "ldap_bind_dn"
00063 #define CFG_N_LDAP_BIND_PWD "ldap_bind_password"
00064 #define CFG_N_CALCULATE_HA1 "calculate_ha1"
00065 
00066 
00067 #define CFG_DEF_HOST_NAME ""
00068 #define CFG_DEF_LDAP_SERVER_URL NULL
00069 #define CFG_DEF_LDAP_VERSION 3
00070 #define CFG_DEF_LDAP_CLIENT_BIND_TIMEOUT 1000
00071 #define CFG_DEF_LDAP_CLIENT_SEARCH_TIMEOUT 5000
00072 #define CFG_DEF_LDAP_NETWORK_TIMEOUT 1000
00073 #define CFG_DEF_LDAP_BIND_DN ""
00074 #define CFG_DEF_LDAP_BIND_PWD ""
00075 #define CFG_DEF_CALCULATE_HA1 1
00076 
00077 #define CFG_LDAP_CLIENT_SEARCH_TIMEOUT_MIN 2000
00078 
00079 extern int add_ld_session(char* _name, LDAP* _ldh, dictionary* _d);
00080 extern struct ld_session* get_ld_session(char* _name);
00081 extern int free_ld_sessions(void);
00082 
00083 extern char* get_ini_key_name(char* _section, char* _key);
00084 
00085 #endif /* LD_SESSION_H */
00086