nuclient.h

Go to the documentation of this file.
00001 /*
00002  ** Copyright 2004-2008 - INL
00003  ** Written by Eric Leblond <regit@inl.fr>
00004  **            Vincent Deffontaines <vincent@inl.fr>
00005  ** INL http://www.inl.fr/
00006  **
00007  ** $Id: nuclient.h 5226 2008-11-19 14:39:26Z pollux $
00008  **
00009  ** This program is free software; you can redistribute it and/or modify
00010  ** it under the terms of the GNU General Public License as published by
00011  ** the Free Software Foundation, version 3 of the License.
00012  **
00013  ** This program is distributed in the hope that it will be useful,
00014  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  ** GNU General Public License for more details.
00017  **
00018  ** You should have received a copy of the GNU General Public License
00019  ** along with this program; if not, write to the Free Software
00020  ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00021  */
00022 
00023 #ifndef NUCLIENT_H
00024 #define NUCLIENT_H
00025 
00026 #include <netinet/in.h>
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #if 0
00031         /* dummy code to make vim indentation works */
00032 }
00033 #endif
00034 #endif
00035 
00036 #define NUCLIENT_VERSION "2.1.1-3"
00037 #define DEBUG 0
00038 
00040 #define NUAUTH_IP "192.168.1.1"
00041 
00043 #define DEFAULT_KRB5_REALM "nuauth"
00044 
00046 #define UDP_TIMEOUT 30
00047 
00048 enum {
00049         ERROR_OK = 0,
00050         ERROR_LOGIN = 1,
00051         ERROR_NETWORK = 2
00052 };
00053 
00055 typedef enum {
00056         INTERNAL_ERROR = 0,
00057         NUSSL_ERR = 1,
00058         SASL_ERROR = 2
00059 } nuclient_error_family_t;
00060 
00061 /* INTERNAL ERROR CODES */
00062 enum {
00063         NO_ERR = 0,          
00064         SESSION_NOT_CONNECTED_ERR = 1,
00066         UNKNOWN_ERR = 2,     
00067         TIMEOUT_ERR = 3,     
00068         DNS_RESOLUTION_ERR = 4,
00070         NO_ADDR_ERR = 5,     
00071         FILE_ACCESS_ERR = 6, 
00072         CANT_CONNECT_ERR = 7,
00073         MEMORY_ERR = 8,      
00074         TCPTABLE_ERR = 9,    
00075         SEND_ERR = 10,       
00076         BAD_CREDENTIALS_ERR, 
00077         BINDING_ERR,         
00078         NUSSL_INIT_ERR,      
00079 };
00080 
00081 /* Define for backward compatibility */
00082 #define nuclient_error nuclient_error_t
00083 
00084 typedef struct nuauth_session nuauth_session_t;
00085 
00086 /* libnuclient return code structure */
00087 typedef struct {
00088         nuclient_error_family_t family;
00089         int error;
00090 } nuclient_error_t;
00091 
00092 /* Exported functions */
00093 int nu_client_check(nuauth_session_t *session, nuclient_error_t *err);
00094 
00095 int nu_client_error_init(nuclient_error_t **err);
00096 void nu_client_error_destroy(nuclient_error_t *err);
00097 
00098 const char *nu_client_strerror(nuauth_session_t *session, nuclient_error_t *err);
00099 
00100 int nu_client_global_init(nuclient_error_t *err);
00101 void nu_client_global_deinit();
00102 
00103 nuauth_session_t *nu_client_new(const char *username,
00104                 const char *password,
00105                 unsigned char diffie_hellman,
00106                 nuclient_error_t *err);
00107 
00108 nuauth_session_t *nu_client_new_callback(void *username_callback,
00109                 void *passwd_callback,
00110                 unsigned char diffie_hellman,
00111                 nuclient_error_t * err);
00112 
00113 void nu_client_set_username(nuauth_session_t *session,
00114                 const char *username);
00115 
00116 void nu_client_set_password(nuauth_session_t *session,
00117                 const char *password);
00118 
00119 const char* nu_client_default_hostname();
00120 
00121 const char* nu_client_default_port();
00122 
00123 const char* nu_client_default_tls_ca();
00124 const char* nu_client_default_tls_cert();
00125 const char* nu_client_default_tls_key();
00126 const char* nu_client_default_tls_crl();
00127 
00128 int nu_client_default_suppress_fqdn_verif();
00129 
00130 void nu_client_set_debug(nuauth_session_t * session, unsigned char enabled);
00131 void nu_client_set_verbose(nuauth_session_t * session,
00132                 unsigned char enabled);
00133 void nu_client_set_source(nuauth_session_t *session, struct sockaddr_storage *addr);
00134 
00135 int nu_client_set_key(nuauth_session_t * session,
00136                 char *keyfile, char *certfile,
00137                 nuclient_error_t *err);
00138 
00139 int nu_client_set_pkcs12(nuauth_session_t * session,
00140                 char *pkcs12file, char *pkcs12password,
00141                 nuclient_error_t *err);
00142 
00143 int nu_client_set_ca(nuauth_session_t * session,
00144                 char *cafile, nuclient_error_t *err);
00145 
00146 int nu_client_set_nuauth_cert_dn(nuauth_session_t * session,
00147                 char *nuauth_cert_dn,
00148                 nuclient_error_t *err);
00149 
00150 int nu_client_set_crlfile(nuauth_session_t * session,
00151                                 char *crlfile,
00152                                 nuclient_error_t *err);
00153 
00154 char* nu_client_get_cert_infos(nuauth_session_t * session);
00155 char* nu_client_get_server_cert_infos(nuauth_session_t * session);
00156 
00157 int nu_client_set_crlfile(nuauth_session_t * session,
00158                 char *crlfile,
00159                 nuclient_error_t *err);
00160 
00161 int nu_client_set_krb5_service(nuauth_session_t * session,
00162                 char *service);
00163 
00164 int nu_client_set_ca_suppress_warning(nuauth_session_t * session,
00165                 int suppress_ca_warning);
00166 
00167 int nu_client_set_fqdn_suppress_verif(nuauth_session_t * session,
00168                 int suppress_fqdn_verif);
00169 
00170 int nu_client_connect(nuauth_session_t * session,
00171                 const char *hostname,
00172                 const char *service,
00173                 nuclient_error_t *err);
00174 
00175 void nu_client_reset(nuauth_session_t * session);
00176 
00177 void nu_client_delete(nuauth_session_t * session);
00178 
00179 char *nu_client_to_utf8(const char *inbuf, char *from_charset);
00180 
00181 const char *nu_get_version();
00182 int nu_check_version(const char *version);
00183 
00184 void nu_client_set_min_delay(nuauth_session_t * session, unsigned int delay);
00185 void nu_client_set_max_delay(nuauth_session_t * session, unsigned int delay);
00186 
00187 char *nu_get_home_dir();
00188 char *nu_get_user_name();
00189 
00190 
00191 #ifdef __cplusplus
00192 }
00193 #endif
00194 #endif   /* #ifndef NUCLIENT_H */
00195 

Generated on Sat Nov 22 04:00:37 2008 for NuFW by  doxygen 1.4.7