diff options
Diffstat (limited to 'database/eurephiadb.c')
-rw-r--r-- | database/eurephiadb.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/database/eurephiadb.c b/database/eurephiadb.c index d4618d3..e53d67f 100644 --- a/database/eurephiadb.c +++ b/database/eurephiadb.c @@ -1,6 +1,6 @@ /* eurephiadb.c -- Loads and initialises the database driver * - * GPLv2 only - Copyright (C) 2008 - 2010 + * GPLv2 only - Copyright (C) 2008 - 2012 * David Sommerseth <dazo@users.sourceforge.net> * * This program is free software; you can redistribute it and/or @@ -70,6 +70,7 @@ int eDBlink_close(eurephiaCTX *ctx) */ int eDBlink_init(eurephiaCTX *ctx, const char *dbdriver, const int minver) { + int apiver = -1; if( dbdriver == NULL ) { eurephia_log(ctx, LOG_FATAL, 0, "No eurephia database driver configured. " "eurephia authentication will not be available"); @@ -101,11 +102,20 @@ int eDBlink_init(eurephiaCTX *ctx, const char *dbdriver, const int minver) } // Configure functions contained in the driver, defined by API version - switch( (eDB_DriverAPIVersion() > minver ? minver : eDB_DriverAPIVersion()) ) { + apiver = (eDB_DriverAPIVersion() > minver ? minver : eDB_DriverAPIVersion()); + switch( apiver ) { + case -1: + eurephia_log(ctx, LOG_FATAL, 0, "Something unexpected happened - apiver==-1"); + ctx->fatal_error = 1; + break; + default: eurephia_log(ctx, LOG_WARNING, 0, "eurephia database driver API is newer than the running eurephia version. Consider " "to upgrade eurephia to take advantage of newer features in the driver."); + case 3: + eDBregister_vpnclientaddr = eGetSym(ctx, ctx->eurephia_driver, "eDBregister_vpnclientaddr"); + case 2: #ifdef ENABLE_EUREPHIADM eDBadminAuthenticate = eGetSym(ctx, ctx->eurephia_driver, "eDBadminAuthenticate"); @@ -135,7 +145,10 @@ int eDBlink_init(eurephiaCTX *ctx, const char *dbdriver, const int minver) eDBregister_attempt = eGetSym(ctx, ctx->eurephia_driver, "eDBregister_attempt"); eDBregister_login = eGetSym(ctx, ctx->eurephia_driver, "eDBregister_login"); - eDBregister_vpnmacaddr = eGetSym(ctx, ctx->eurephia_driver, "eDBregister_vpnmacaddr"); + + // If api version is 3, this function is replaced by eDBregister_vpnclientaddr() + eDBregister_vpnmacaddr = (apiver < 3 ? + eGetSym(ctx, ctx->eurephia_driver, "eDBregister_vpnmacaddr") : NULL); eDBregister_logout = eGetSym(ctx, ctx->eurephia_driver, "eDBregister_logout"); eDBget_firewall_profile = eGetSym(ctx, ctx->eurephia_driver, "eDBget_firewall_profile"); |