summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-11-04 17:30:06 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2010-07-12 09:56:42 +0200
commitf3be28cb1158e38f2f96fd334419a029277624d5 (patch)
treed2a888c1613ef98580a0db2aa13f28243a675d6f
parent050585311ac7e6f17a0d4e33650ea3a5a4ee182b (diff)
downloadeurephia-f3be28cb1158e38f2f96fd334419a029277624d5.tar.gz
eurephia-f3be28cb1158e38f2f96fd334419a029277624d5.tar.xz
eurephia-f3be28cb1158e38f2f96fd334419a029277624d5.zip
Cleaned up the driver/interface API for database and firewall
-rw-r--r--common/eurephia_driverapi.h43
-rw-r--r--database/eurephiadb_driver.h85
-rw-r--r--plugin/firewall/eurephiafw_intf.h8
3 files changed, 93 insertions, 43 deletions
diff --git a/common/eurephia_driverapi.h b/common/eurephia_driverapi.h
new file mode 100644
index 0000000..14083d9
--- /dev/null
+++ b/common/eurephia_driverapi.h
@@ -0,0 +1,43 @@
+/* eurephia_driver.h
+ *
+ * GPLv2 only - Copyright (C) 2008
+ * David Sommerseth <dazo@users.sourceforge.net>
+ *
+ * This program 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; version 2
+ * of the License.
+ *
+ * This program 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/**
+ * @file eurephia_driverapi.h
+ * @author David Sommerseth <davids@redhat.com>
+ * @date Wed Nov 4 15:23:47 2009
+ *
+ * @brief Generic definitions used to provide a driver API
+ *
+ */
+
+#ifndef _EUREPHIA_DRIVER_H
+#define _EUREPHIA_DRIVER_H
+
+#ifndef DRIVER_MODE
+
+#define EUREPHIA_DRIVERAPI_FUNC(funcname) (*funcname)
+
+#else // ifdef DRIVER_MODE
+
+#define EUREPHIA_DRIVERAPI_FUNC(funcname) funcname
+
+#endif // ifdef DRIVER_MODE
+#endif // ifndef _EUREPHIA_DRIVER_H
diff --git a/database/eurephiadb_driver.h b/database/eurephiadb_driver.h
index d042173..c02d167 100644
--- a/database/eurephiadb_driver.h
+++ b/database/eurephiadb_driver.h
@@ -28,6 +28,7 @@
*
*/
+#include <eurephia_driverapi.h>
#include <eurephia_context.h>
#include <eurephiadb_session_struct.h>
#include <eurephia_values_struct.h>
@@ -52,14 +53,12 @@
#define USERINFO_attempts 0x08 /**< flag for extracting information from attempts log */
#define USERINFO_blacklist 0x10 /**< flag for extracting information from blacklist log */
-#ifndef DRIVER_MODE
-
/**
* Mandatory function. Retrieves driver version information
*
* @return Returns string (const char *) containing driver version information.
*/
-const char *(*eDB_DriverVersion) (void);
+const char * EUREPHIA_DRIVERAPI_FUNC(eDB_DriverVersion)(void);
/**
@@ -67,7 +66,7 @@ const char *(*eDB_DriverVersion) (void);
*
* @return Returns integer value with API level supported by driver.
*/
-int (*eDB_DriverAPIVersion) (void);
+int EUREPHIA_DRIVERAPI_FUNC(eDB_DriverAPIVersion)(void);
/*
* functions which needs to exists in the API level 1
@@ -84,7 +83,7 @@ int (*eDB_DriverAPIVersion) (void);
*
* @return Returns 1 on success, otherwise 0.
*/
-int (*eDBconnect) (eurephiaCTX *ctx, const int argc, const char **argv);
+int EUREPHIA_DRIVERAPI_FUNC(eDBconnect)(eurephiaCTX *ctx, const int argc, const char **argv);
/**
* Disconnects from a database
@@ -93,7 +92,7 @@ int (*eDBconnect) (eurephiaCTX *ctx, const int argc, const char **argv);
* @param ctx eurephiaCTX - context with the database connection to disconnect from.
*
*/
-void (*eDBdisconnect) (eurephiaCTX *ctx);
+void EUREPHIA_DRIVERAPI_FUNC(eDBdisconnect) (eurephiaCTX *ctx);
/**
* Authenticates a certificate against the database.
@@ -110,8 +109,9 @@ void (*eDBdisconnect) (eurephiaCTX *ctx);
* @return Returns certid (certificate ID) on success. 0 is returned if certificate is not found,
* or -1 if the certificate is blacklisted.
*/
-int (*eDBauth_TLS) (eurephiaCTX *ctx, const char *org, const char *cname, const char *email,
- const char *digest, const unsigned int depth);
+int EUREPHIA_DRIVERAPI_FUNC(eDBauth_TLS)(eurephiaCTX *ctx, const char *org, const char *cname,
+ const char *email,
+ const char *digest, const unsigned int depth);
/**
* Authenticates a client against the database, with users certificate ID, username and password.
@@ -125,7 +125,8 @@ int (*eDBauth_TLS) (eurephiaCTX *ctx, const char *org, const char *cname, const
* @return Returns uicid (user-certs ID) to the user on success. 0 if user account is not
* found and -1 on authentication failure.
*/
-int (*eDBauth_user) (eurephiaCTX *ctx, const int certid, const char *username, const char *passwd);
+int EUREPHIA_DRIVERAPI_FUNC(eDBauth_user)(eurephiaCTX *ctx, const int certid,
+ const char *username, const char *passwd);
/**
@@ -138,7 +139,7 @@ int (*eDBauth_user) (eurephiaCTX *ctx, const int certid, const char *username, c
*
* @return Returns uid of user on success, 0 if user account is not found, otherwise -1 on errors.
*/
-int (*eDBget_uid) (eurephiaCTX *ctx, const int certid, const char *username);
+int EUREPHIA_DRIVERAPI_FUNC(eDBget_uid)(eurephiaCTX *ctx, const int certid, const char *username);
/**
@@ -154,7 +155,7 @@ int (*eDBget_uid) (eurephiaCTX *ctx, const int certid, const char *username);
*
* @see attempt_IPADDR, attempt_CERTIFICATE, attempt_USERNAME
*/
-int (*eDBblacklist_check) (eurephiaCTX *ctx, const int type, const char *val);
+int EUREPHIA_DRIVERAPI_FUNC(eDBblacklist_check)(eurephiaCTX *ctx, const int type, const char *val);
/**
@@ -170,7 +171,7 @@ int (*eDBblacklist_check) (eurephiaCTX *ctx, const int type, const char *val);
*
* @see ATTEMPT_REGISTER, ATTEMPT_RESET, attempt_IPADDR, attempt_CERTIFICATE, attempt_USERNAME
*/
-void (*eDBregister_attempt) (eurephiaCTX *ctx, int type, int mode, const char *value);
+void EUREPHIA_DRIVERAPI_FUNC(eDBregister_attempt)(eurephiaCTX *ctx, int type, int mode, const char *value);
/**
@@ -190,9 +191,10 @@ void (*eDBregister_attempt) (eurephiaCTX *ctx, int type, int mode, const char *v
*
* @return Returns 1 on success, otherwise 0.
*/
-int (*eDBregister_login) (eurephiaCTX *ctx, eurephiaSESSION *skey, const int certid, const int uid,
- const char *proto, const char *remipaddr, const char *remport,
- const char *vpnipaddr, const char *vpnipmask);
+int EUREPHIA_DRIVERAPI_FUNC(eDBregister_login)(eurephiaCTX *ctx, eurephiaSESSION *skey,
+ const int certid, const int uid,
+ const char *proto, const char *remipaddr, const char *remport,
+ const char *vpnipaddr, const char *vpnipmask);
/**
@@ -206,7 +208,8 @@ int (*eDBregister_login) (eurephiaCTX *ctx, eurephiaSESSION *skey, const int cer
*
* @return Returns 1 on success, otherwise 0.
*/
-int (*eDBregister_vpnmacaddr) (eurephiaCTX *ctx, eurephiaSESSION *session, const char *macaddr);
+int EUREPHIA_DRIVERAPI_FUNC(eDBregister_vpnmacaddr)(eurephiaCTX *ctx, eurephiaSESSION *session,
+ const char *macaddr);
/**
@@ -222,8 +225,9 @@ int (*eDBregister_vpnmacaddr) (eurephiaCTX *ctx, eurephiaSESSION *session, const
*
* @return Returns 1 on success, otherwise 0.
*/
-int (*eDBregister_logout) (eurephiaCTX *ctx, eurephiaSESSION *skey,
- const char *bytes_sent, const char *bytes_received, const char *duration);
+int EUREPHIA_DRIVERAPI_FUNC(eDBregister_logout)(eurephiaCTX *ctx, eurephiaSESSION *skey,
+ const char *bytes_sent, const char *bytes_received,
+ const char *duration);
/* firewall functions */
@@ -238,7 +242,7 @@ int (*eDBregister_logout) (eurephiaCTX *ctx, eurephiaSESSION *skey,
* @return Returns a char pointer to a buffer with the name of the firewall profile. This buffer
* must be freed when no longer needed.
*/
-char *(*eDBget_firewall_profile) (eurephiaCTX *ctx, eurephiaSESSION *session);
+char * EUREPHIA_DRIVERAPI_FUNC(eDBget_firewall_profile) (eurephiaCTX *ctx, eurephiaSESSION *session);
/**
* Retrieve a list of IP addresses found in the IP address blacklist table.
@@ -249,7 +253,7 @@ char *(*eDBget_firewall_profile) (eurephiaCTX *ctx, eurephiaSESSION *session);
* @return Returns an eurephiaVALUES chain with all blacklisted IP addresses on success, otherwise
* NULL is returned
*/
-eurephiaVALUES *(*eDBget_blacklisted_ip) (eurephiaCTX *ctx);
+eurephiaVALUES * EUREPHIA_DRIVERAPI_FUNC(eDBget_blacklisted_ip)(eurephiaCTX *ctx);
/* The following functions is also declared in eurephia_session_values.c - for local internal usage. */
/**
@@ -264,7 +268,8 @@ eurephiaVALUES *(*eDBget_blacklisted_ip) (eurephiaCTX *ctx);
* @return Returns the unique session key string (char *) on success, otherwise NULL. The session key
* string must be freed when no longer needed.
*/
-char *(*eDBget_sessionkey_seed) (eurephiaCTX *ctx, sessionType type, const char *sessionseed);
+char * EUREPHIA_DRIVERAPI_FUNC(eDBget_sessionkey_seed)(eurephiaCTX *ctx, sessionType type,
+ const char *sessionseed);
/**
@@ -278,7 +283,7 @@ char *(*eDBget_sessionkey_seed) (eurephiaCTX *ctx, sessionType type, const char
* @return Returns the unique session key string (char *) on success, otherwise NULL. The session key
* string must be freed when no longer needed.
*/
-char *(*eDBget_sessionkey_macaddr) (eurephiaCTX *ctx, const char *macaddr);
+char * EUREPHIA_DRIVERAPI_FUNC(eDBget_sessionkey_macaddr)(eurephiaCTX *ctx, const char *macaddr);
/**
@@ -291,7 +296,7 @@ char *(*eDBget_sessionkey_macaddr) (eurephiaCTX *ctx, const char *macaddr);
*
* @return Returns 1 if the session key is unique and not been used earlier.
*/
-int (*eDBcheck_sessionkey_uniqueness) (eurephiaCTX *ctx, const char *seskey);
+int EUREPHIA_DRIVERAPI_FUNC(eDBcheck_sessionkey_uniqueness)(eurephiaCTX *ctx, const char *seskey);
/**
@@ -304,7 +309,7 @@ int (*eDBcheck_sessionkey_uniqueness) (eurephiaCTX *ctx, const char *seskey);
*
* @return Returns 1 on success, otherwise 0
*/
-int (*eDBregister_sessionkey) (eurephiaCTX *ctx, const char *seed, const char *seskey);
+int EUREPHIA_DRIVERAPI_FUNC(eDBregister_sessionkey)(eurephiaCTX *ctx, const char *seed, const char *seskey);
/**
@@ -318,7 +323,7 @@ int (*eDBregister_sessionkey) (eurephiaCTX *ctx, const char *seed, const char *s
* @return Returns a pointer to an eurephiaVALUES pointer chain with all the variables available
* for the given session. On errors, it will return an empty eurephiaVALUES chain.
*/
-eurephiaVALUES *(*eDBload_sessiondata) (eurephiaCTX *ctx, const char *sesskey);
+eurephiaVALUES * EUREPHIA_DRIVERAPI_FUNC(eDBload_sessiondata)(eurephiaCTX *ctx, const char *sesskey);
/**
@@ -331,7 +336,7 @@ eurephiaVALUES *(*eDBload_sessiondata) (eurephiaCTX *ctx, const char *sesskey);
*
* @return Returns 1 on success, otherwise 0.
*/
-int (*eDBdestroy_session) (eurephiaCTX *ctx, eurephiaSESSION *session);
+int EUREPHIA_DRIVERAPI_FUNC(eDBdestroy_session)(eurephiaCTX *ctx, eurephiaSESSION *session);
/**
@@ -348,8 +353,9 @@ int (*eDBdestroy_session) (eurephiaCTX *ctx, eurephiaSESSION *session);
* @return Returns 1 on success, otherwise 0
* @see SESSVAL_NEW, SESSVAL_UPDATE, SESSVAL_DELETE
*/
-int (*eDBstore_session_value)(eurephiaCTX *ctx, eurephiaSESSION *session, int mode,
- const char *key, const char *val);
+int EUREPHIA_DRIVERAPI_FUNC(eDBstore_session_value)(eurephiaCTX *ctx, eurephiaSESSION *session, int mode,
+ const char *key, const char *val);
+
/*
* functions which needs to exists in the API level 2
@@ -403,7 +409,7 @@ int (*eDBstore_session_value)(eurephiaCTX *ctx, eurephiaSESSION *session, int mo
* user will be returned in the details part of the ResultMsg.
*
*/
-xmlDoc *(*eDBadminAuthenticate) (eurephiaCTX *ctx, xmlDoc *qryxml);
+xmlDoc * EUREPHIA_DRIVERAPI_FUNC(eDBadminAuthenticate)(eurephiaCTX *ctx, xmlDoc *qryxml);
/**
@@ -427,7 +433,7 @@ xmlDoc *(*eDBadminAuthenticate) (eurephiaCTX *ctx, xmlDoc *qryxml);
* @return Returns a valid XML document with information about the operation, or NULL on fatal errors.
* @see eurephiaXML_CreateDoc()
*/
-xmlDoc *(*eDBadminConfiguration)(eurephiaCTX *ctx, xmlDoc *cfgxml);
+xmlDoc * EUREPHIA_DRIVERAPI_FUNC(eDBadminConfiguration)(eurephiaCTX *ctx, xmlDoc *cfgxml);
/**
@@ -471,7 +477,7 @@ xmlDoc *(*eDBadminConfiguration)(eurephiaCTX *ctx, xmlDoc *cfgxml);
*
* @see eurephiaXML_CreateDoc(), eurephiaXML_ParseResultMsg(), eurephiaXML_getRoot()
*/
-xmlDoc *(*eDBadminUserAccount) (eurephiaCTX *ctx, xmlDoc *qryxml);
+xmlDoc * EUREPHIA_DRIVERAPI_FUNC(eDBadminUserAccount)(eurephiaCTX *ctx, xmlDoc *qryxml);
/**
@@ -521,7 +527,7 @@ xmlDoc *(*eDBadminUserAccount) (eurephiaCTX *ctx, xmlDoc *qryxml);
*
* @see eurephiaXML_CreateDoc(), eurephiaXML_ParseResultMsg(), eurephiaXML_getRoot()
*/
-xmlDoc *(*eDBadminCertificate) (eurephiaCTX *ctx, xmlDoc *qryxml);
+xmlDoc * EUREPHIA_DRIVERAPI_FUNC(eDBadminCertificate)(eurephiaCTX *ctx, xmlDoc *qryxml);
/**
@@ -550,7 +556,7 @@ xmlDoc *(*eDBadminCertificate) (eurephiaCTX *ctx, xmlDoc *qryxml);
* with an error message will be returned or NULL.
* @see eurephiaXML_CreateDoc(), eurephiaXML_getRoot()
*/
-xmlDoc *(*eDBadminUserCertsLink) (eurephiaCTX *ctx, xmlDoc *usrcrt_xml);
+xmlDoc * EUREPHIA_DRIVERAPI_FUNC(eDBadminUserCertsLink)(eurephiaCTX *ctx, xmlDoc *usrcrt_xml);
/**
@@ -597,7 +603,7 @@ xmlDoc *(*eDBadminUserCertsLink) (eurephiaCTX *ctx, xmlDoc *usrcrt_xml);
* On fatal errors NULL is returned.
* @see eurephiaXML_CreateDoc(), eurephiaXML_getRoot()
*/
-xmlDoc *(*eDBadminAccessLevel) (eurephiaCTX *ctx, xmlDoc *qryxml);
+xmlDoc * EUREPHIA_DRIVERAPI_FUNC(eDBadminAccessLevel)(eurephiaCTX *ctx, xmlDoc *qryxml);
/**
@@ -624,7 +630,7 @@ xmlDoc *(*eDBadminAccessLevel) (eurephiaCTX *ctx, xmlDoc *qryxml);
* NULL or an XML error document is returned.
* @see eurephiaXML_CreateDoc(), eurephiaXML_getRoot()
*/
-xmlDoc *(*eDBadminFirewallProfiles) (eurephiaCTX *ctx, xmlDoc *xmlqry);
+xmlDoc * EUREPHIA_DRIVERAPI_FUNC(eDBadminFirewallProfiles)(eurephiaCTX *ctx, xmlDoc *xmlqry);
/**
@@ -650,7 +656,8 @@ xmlDoc *(*eDBadminFirewallProfiles) (eurephiaCTX *ctx, xmlDoc *xmlqry);
* @return Returns a valid XML document on success, otherwise NULL
* @see eurephiaXML_CreateDoc(), eurephiaXML_getRoot()
*/
-xmlDoc *(*eDBadminGetLastlog) (eurephiaCTX *ctx, xmlDoc *srch_xml, const char *sortkeys);
+xmlDoc * EUREPHIA_DRIVERAPI_FUNC(eDBadminGetLastlog)(eurephiaCTX *ctx, xmlDoc *srch_xml,
+ const char *sortkeys);
/**
@@ -676,7 +683,7 @@ xmlDoc *(*eDBadminGetLastlog) (eurephiaCTX *ctx, xmlDoc *srch_xml, const char *s
* with an error message.
* @see eurephiaXML_CreateDoc(), eurephiaXML_getRoot()
*/
-xmlDoc *(*eDBadminAttemptsLog) (eurephiaCTX *ctx, xmlDoc *qryxml);
+xmlDoc * EUREPHIA_DRIVERAPI_FUNC(eDBadminAttemptsLog)(eurephiaCTX *ctx, xmlDoc *qryxml);
/**
@@ -703,9 +710,7 @@ xmlDoc *(*eDBadminAttemptsLog) (eurephiaCTX *ctx, xmlDoc *qryxml);
* with an error message.
* @see eurephiaXML_CreateDoc(), eurephiaXML_getRoot()
*/
-xmlDoc *(*eDBadminBlacklist) (eurephiaCTX *ctx, xmlDoc *qryxml);
+xmlDoc * EUREPHIA_DRIVERAPI_FUNC(eDBadminBlacklist)(eurephiaCTX *ctx, xmlDoc *qryxml);
#endif /* HAVE_LIBXML2 */
-#endif /* !DRIVER_MODE */
-
#endif /* !EUREPHIADB_DRIVER_H_ */
diff --git a/plugin/firewall/eurephiafw_intf.h b/plugin/firewall/eurephiafw_intf.h
index d9f1bd5..b65a1cd 100644
--- a/plugin/firewall/eurephiafw_intf.h
+++ b/plugin/firewall/eurephiafw_intf.h
@@ -32,19 +32,21 @@
#ifndef EUREPHIAFW_INTF_H_
#define EUREPHIAFW_INTF_H_
+#include <eurephia_driverapi.h>
+
/**
* Mandatory function, contains driver information.
*
* @return Should retun a static string, containing the version information.
*/
-const char *(*eFWinterfaceVersion) ();
+const char * EUREPHIA_DRIVERAPI_FUNC(eFWinterfaceVersion)(void);
/**
* Mandatory function, contains driver information.
*
* @return Should retun an integer which correponds to the API level the interface driver uses.
*/
-int (*eFWinterfaceAPIversion) ();
+int EUREPHIA_DRIVERAPI_FUNC(eFWinterfaceAPIversion)(void);
/**
* The main routine of the firewall interface. This function should not return before
@@ -52,6 +54,6 @@ int (*eFWinterfaceAPIversion) ();
*
* @param fwargs efw_threaddata pointer, with needed information to communicate with the openvpn process.
*/
-void (*eFW_RunFirewall) (void *fwargs);
+void EUREPHIA_DRIVERAPI_FUNC(eFW_RunFirewall)(void *fwargs);
#endif /* !EUREPHIAFW_INTF_H_ */