Renamed radius_server to radius_config, as some real RADIUS server functionality...
authorMartin Willi <martin@revosec.ch>
Mon, 5 Mar 2012 17:31:30 +0000 (18:31 +0100)
committerMartin Willi <martin@revosec.ch>
Mon, 5 Mar 2012 17:31:30 +0000 (18:31 +0100)
src/libcharon/plugins/eap_radius/eap_radius_plugin.c
src/libradius/Makefile.am
src/libradius/radius_client.c
src/libradius/radius_client.h
src/libradius/radius_config.c [new file with mode: 0644]
src/libradius/radius_config.h [new file with mode: 0644]
src/libradius/radius_server.c [deleted file]
src/libradius/radius_server.h [deleted file]

index 0caecc1..8ee0ab8 100644 (file)
@@ -21,7 +21,7 @@
 #include "eap_radius_forward.h"
 
 #include <radius_client.h>
-#include <radius_server.h>
+#include <radius_config.h>
 
 #include <daemon.h>
 #include <threading/rwlock.h>
@@ -49,12 +49,12 @@ struct private_eap_radius_plugin_t {
        eap_radius_plugin_t public;
 
        /**
-        * List of RADIUS servers
+        * List of RADIUS server configurations
         */
-       linked_list_t *servers;
+       linked_list_t *configs;
 
        /**
-        * Lock for server list
+        * Lock for configs list
         */
        rwlock_t *lock;
 
@@ -82,10 +82,10 @@ static private_eap_radius_plugin_t *instance = NULL;
 /**
  * Load RADIUS servers from configuration
  */
-static void load_servers(private_eap_radius_plugin_t *this)
+static void load_configs(private_eap_radius_plugin_t *this)
 {
        enumerator_t *enumerator;
-       radius_server_t *server;
+       radius_config_t *config;
        char *nas_identifier, *secret, *address, *section;
        int auth_port, acct_port, sockets, preference;
 
@@ -106,14 +106,14 @@ static void load_servers(private_eap_radius_plugin_t *this)
                                        "charon.plugins.eap-radius.port", AUTH_PORT);
                sockets = lib->settings->get_int(lib->settings,
                                        "charon.plugins.eap-radius.sockets", 1);
-               server = radius_server_create(address, address, auth_port, ACCT_PORT,
+               config = radius_config_create(address, address, auth_port, ACCT_PORT,
                                                                          nas_identifier, secret, sockets, 0);
-               if (!server)
+               if (!config)
                {
                        DBG1(DBG_CFG, "no RADUIS server defined");
                        return;
                }
-               this->servers->insert_last(this->servers, server);
+               this->configs->insert_last(this->configs, config);
                return;
        }
 
@@ -150,20 +150,20 @@ static void load_servers(private_eap_radius_plugin_t *this)
                        "charon.plugins.eap-radius.servers.%s.sockets", 1, section);
                preference = lib->settings->get_int(lib->settings,
                        "charon.plugins.eap-radius.servers.%s.preference", 0, section);
-               server = radius_server_create(section, address, auth_port, acct_port,
+               config = radius_config_create(section, address, auth_port, acct_port,
                                                                nas_identifier, secret, sockets, preference);
-               if (!server)
+               if (!config)
                {
                        DBG1(DBG_CFG, "loading RADIUS server '%s' failed, skipped", section);
                        continue;
                }
-               this->servers->insert_last(this->servers, server);
+               this->configs->insert_last(this->configs, config);
        }
        enumerator->destroy(enumerator);
 
        DBG1(DBG_CFG, "loaded %d RADIUS server configuration%s",
-                this->servers->get_count(this->servers),
-                this->servers->get_count(this->servers) == 1 ? "" : "s");
+                this->configs->get_count(this->configs),
+                this->configs->get_count(this->configs) == 1 ? "" : "s");
 }
 
 METHOD(plugin_t, get_name, char*,
@@ -190,10 +190,10 @@ METHOD(plugin_t, reload, bool,
        private_eap_radius_plugin_t *this)
 {
        this->lock->write_lock(this->lock);
-       this->servers->destroy_offset(this->servers,
-                                                                 offsetof(radius_server_t, destroy));
-       this->servers = linked_list_create();
-       load_servers(this);
+       this->configs->destroy_offset(this->configs,
+                                                                 offsetof(radius_config_t, destroy));
+       this->configs = linked_list_create();
+       load_configs(this);
        this->lock->unlock(this->lock);
        return TRUE;
 }
@@ -207,8 +207,8 @@ METHOD(plugin_t, destroy, void,
                this->forward->destroy(this->forward);
        }
        DESTROY_IF(this->dae);
-       this->servers->destroy_offset(this->servers,
-                                                                 offsetof(radius_server_t, destroy));
+       this->configs->destroy_offset(this->configs,
+                                                                 offsetof(radius_config_t, destroy));
        this->lock->destroy(this->lock);
        charon->bus->remove_listener(charon->bus, &this->accounting->listener);
        this->accounting->destroy(this->accounting);
@@ -232,13 +232,13 @@ plugin_t *eap_radius_plugin_create()
                                .destroy = _destroy,
                        },
                },
-               .servers = linked_list_create(),
+               .configs = linked_list_create(),
                .lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
                .accounting = eap_radius_accounting_create(),
                .forward = eap_radius_forward_create(),
        );
 
-       load_servers(this);
+       load_configs(this);
        instance = this;
 
        if (lib->settings->get_bool(lib->settings,
@@ -267,28 +267,28 @@ radius_client_t *eap_radius_create_client()
        if (instance)
        {
                enumerator_t *enumerator;
-               radius_server_t *server, *selected = NULL;
+               radius_config_t *config, *selected = NULL;
                int current, best = -1;
 
                instance->lock->read_lock(instance->lock);
-               enumerator = instance->servers->create_enumerator(instance->servers);
-               while (enumerator->enumerate(enumerator, &server))
+               enumerator = instance->configs->create_enumerator(instance->configs);
+               while (enumerator->enumerate(enumerator, &config))
                {
-                       current = server->get_preference(server);
+                       current = config->get_preference(config);
                        if (current > best ||
                                /* for two with equal preference, 50-50 chance */
                                (current == best && random() % 2 == 0))
                        {
                                DBG2(DBG_CFG, "RADIUS server '%s' is candidate: %d",
-                                        server->get_name(server), current);
+                                        config->get_name(config), current);
                                best = current;
                                DESTROY_IF(selected);
-                               selected = server->get_ref(server);
+                               selected = config->get_ref(config);
                        }
                        else
                        {
                                DBG2(DBG_CFG, "RADIUS server '%s' skipped: %d",
-                                        server->get_name(server), current);
+                                        config->get_name(config), current);
                        }
                }
                enumerator->destroy(enumerator);
index 8723a78..618dbbc 100644 (file)
@@ -6,4 +6,4 @@ libradius_la_SOURCES = \
        radius_message.h radius_message.c \
        radius_socket.h radius_socket.c \
        radius_client.h radius_client.c \
-       radius_server.h radius_server.c
+       radius_config.h radius_config.c
index 9c12be4..57bd743 100644 (file)
@@ -14,7 +14,7 @@
  */
 
 #include "radius_client.h"
-#include "radius_server.h"
+#include "radius_config.h"
 
 #include <unistd.h>
 #include <errno.h>
@@ -38,9 +38,9 @@ struct private_radius_client_t {
        radius_client_t public;
 
        /**
-        * Selected RADIUS server
+        * Selected RADIUS server configuration
         */
-       radius_server_t *server;
+       radius_config_t *config;
 
        /**
         * RADIUS servers State attribute
@@ -89,31 +89,31 @@ METHOD(radius_client_t, request, radius_message_t*,
        req->add(req, RAT_NAS_PORT_TYPE, chunk_create(virtual, sizeof(virtual)));
        /* add our NAS-Identifier */
        req->add(req, RAT_NAS_IDENTIFIER,
-                        this->server->get_nas_identifier(this->server));
+                        this->config->get_nas_identifier(this->config));
        /* add State attribute, if server sent one */
        if (this->state.ptr)
        {
                req->add(req, RAT_STATE, this->state);
        }
-       socket = this->server->get_socket(this->server);
+       socket = this->config->get_socket(this->config);
        DBG1(DBG_CFG, "sending RADIUS %N to server '%s'", radius_message_code_names,
-                req->get_code(req), this->server->get_name(this->server));
+                req->get_code(req), this->config->get_name(this->config));
        res = socket->request(socket, req);
        if (res)
        {
                DBG1(DBG_CFG, "received RADIUS %N from server '%s'",
                         radius_message_code_names, res->get_code(res),
-                        this->server->get_name(this->server));
+                        this->config->get_name(this->config));
                save_state(this, res);
                if (res->get_code(res) == RMC_ACCESS_ACCEPT)
                {
                        chunk_clear(&this->msk);
                        this->msk = socket->decrypt_msk(socket, req, res);
                }
-               this->server->put_socket(this->server, socket, TRUE);
+               this->config->put_socket(this->config, socket, TRUE);
                return res;
        }
-       this->server->put_socket(this->server, socket, FALSE);
+       this->config->put_socket(this->config, socket, FALSE);
        return NULL;
 }
 
@@ -126,7 +126,7 @@ METHOD(radius_client_t, get_msk, chunk_t,
 METHOD(radius_client_t, destroy, void,
        private_radius_client_t *this)
 {
-       this->server->destroy(this->server);
+       this->config->destroy(this->config);
        chunk_clear(&this->msk);
        free(this->state.ptr);
        free(this);
@@ -135,7 +135,7 @@ METHOD(radius_client_t, destroy, void,
 /**
  * See header
  */
-radius_client_t *radius_client_create(radius_server_t *server)
+radius_client_t *radius_client_create(radius_config_t *config)
 {
        private_radius_client_t *this;
 
@@ -145,7 +145,7 @@ radius_client_t *radius_client_create(radius_server_t *server)
                        .get_msk = _get_msk,
                        .destroy = _destroy,
                },
-               .server = server,
+               .config = config,
        );
 
        return &this->public;
index 4ec344b..cf5f79b 100644 (file)
@@ -22,7 +22,7 @@
 #define RADIUS_CLIENT_H_
 
 #include "radius_message.h"
-#include "radius_server.h"
+#include "radius_config.h"
 
 typedef struct radius_client_t radius_client_t;
 
@@ -60,9 +60,9 @@ struct radius_client_t {
 /**
  * Create a RADIUS client.
  *
- * @param server       reference to a server configuration, gets owned
+ * @param config       reference to a server configuration, gets owned
  * @return                     radius_client_t object
  */
-radius_client_t *radius_client_create(radius_server_t *server);
+radius_client_t *radius_client_create(radius_config_t *config);
 
 #endif /** RADIUS_CLIENT_H_ @}*/
diff --git a/src/libradius/radius_config.c b/src/libradius/radius_config.c
new file mode 100644 (file)
index 0000000..6e3394b
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * 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; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * 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.
+ */
+
+#include "radius_config.h"
+
+#include <threading/mutex.h>
+#include <threading/condvar.h>
+#include <utils/linked_list.h>
+
+typedef struct private_radius_config_t private_radius_config_t;
+
+/**
+ * Private data of an radius_config_t object.
+ */
+struct private_radius_config_t {
+
+       /**
+        * Public radius_config_t interface.
+        */
+       radius_config_t public;
+
+       /**
+        * list of radius sockets, as radius_socket_t
+        */
+       linked_list_t *sockets;
+
+       /**
+        * Total number of sockets, in list + currently in use
+        */
+       int socket_count;
+
+       /**
+        * mutex to lock sockets list
+        */
+       mutex_t *mutex;
+
+       /**
+        * condvar to wait for sockets
+        */
+       condvar_t *condvar;
+
+       /**
+        * Server name
+        */
+       char *name;
+
+       /**
+        * NAS-Identifier
+        */
+       chunk_t nas_identifier;
+
+       /**
+        * Preference boost for this server
+        */
+       int preference;
+
+       /**
+        * Is the server currently reachable
+        */
+       bool reachable;
+
+       /**
+        * Retry counter for unreachable servers
+        */
+       int retry;
+
+       /**
+        * reference count
+        */
+       refcount_t ref;
+};
+
+METHOD(radius_config_t, get_socket, radius_socket_t*,
+       private_radius_config_t *this)
+{
+       radius_socket_t *skt;
+
+       this->mutex->lock(this->mutex);
+       while (this->sockets->remove_first(this->sockets, (void**)&skt) != SUCCESS)
+       {
+               this->condvar->wait(this->condvar, this->mutex);
+       }
+       this->mutex->unlock(this->mutex);
+       return skt;
+}
+
+METHOD(radius_config_t, put_socket, void,
+       private_radius_config_t *this, radius_socket_t *skt, bool result)
+{
+       this->mutex->lock(this->mutex);
+       this->sockets->insert_last(this->sockets, skt);
+       this->mutex->unlock(this->mutex);
+       this->condvar->signal(this->condvar);
+       this->reachable = result;
+}
+
+METHOD(radius_config_t, get_nas_identifier, chunk_t,
+       private_radius_config_t *this)
+{
+       return this->nas_identifier;
+}
+
+METHOD(radius_config_t, get_preference, int,
+       private_radius_config_t *this)
+{
+       int pref;
+
+       if (this->socket_count == 0)
+       {       /* don't have sockets, huh? */
+               return -1;
+       }
+       /* calculate preference between 0-100 + boost */
+       pref = this->preference;
+       pref += this->sockets->get_count(this->sockets) * 100 / this->socket_count;
+       if (this->reachable)
+       {       /* reachable server get a boost: pref = 110-210 + boost */
+               return pref + 110;
+       }
+       /* Not reachable. Increase preference randomly to let it retry from
+        * time to time, especially if other servers have high load. */
+       this->retry++;
+       if (this->retry % 128 == 0)
+       {       /* every 64th request gets 210, same as unloaded reachable */
+               return pref + 110;
+       }
+       if (this->retry % 32 == 0)
+       {       /* every 32th request gets 190, wins against average loaded */
+               return pref + 90;
+       }
+       if (this->retry % 8 == 0)
+       {       /* every 8th request gets 110, same as server under load */
+               return pref + 10;
+       }
+       /* other get ~100, less than fully loaded */
+       return pref;
+}
+
+METHOD(radius_config_t, get_name, char*,
+       private_radius_config_t *this)
+{
+       return this->name;
+}
+
+METHOD(radius_config_t, get_ref, radius_config_t*,
+       private_radius_config_t *this)
+{
+       ref_get(&this->ref);
+       return &this->public;
+}
+
+
+METHOD(radius_config_t, destroy, void,
+       private_radius_config_t *this)
+{
+       if (ref_put(&this->ref))
+       {
+               this->mutex->destroy(this->mutex);
+               this->condvar->destroy(this->condvar);
+               this->sockets->destroy_offset(this->sockets,
+                                                                         offsetof(radius_socket_t, destroy));
+               free(this);
+       }
+}
+
+/**
+ * See header
+ */
+radius_config_t *radius_config_create(char *name, char *address,
+                                                                         u_int16_t auth_port, u_int16_t acct_port,
+                                                                         char *nas_identifier, char *secret,
+                                                                         int sockets, int preference)
+{
+       private_radius_config_t *this;
+       radius_socket_t *socket;
+
+       INIT(this,
+               .public = {
+                       .get_socket = _get_socket,
+                       .put_socket = _put_socket,
+                       .get_nas_identifier = _get_nas_identifier,
+                       .get_preference = _get_preference,
+                       .get_name = _get_name,
+                       .get_ref = _get_ref,
+                       .destroy = _destroy,
+               },
+               .reachable = TRUE,
+               .nas_identifier = chunk_create(nas_identifier, strlen(nas_identifier)),
+               .socket_count = sockets,
+               .sockets = linked_list_create(),
+               .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
+               .condvar = condvar_create(CONDVAR_TYPE_DEFAULT),
+               .name = name,
+               .preference = preference,
+               .ref = 1,
+       );
+
+       while (sockets--)
+       {
+               socket = radius_socket_create(address, auth_port, acct_port,
+                                                                         chunk_create(secret, strlen(secret)));
+               if (!socket)
+               {
+                       destroy(this);
+                       return NULL;
+               }
+               this->sockets->insert_last(this->sockets, socket);
+       }
+       return &this->public;
+}
diff --git a/src/libradius/radius_config.h b/src/libradius/radius_config.h
new file mode 100644 (file)
index 0000000..40ed619
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2010 Martin Willi
+ * Copyright (C) 2010 revosec AG
+ *
+ * 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; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * 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.
+ */
+
+/**
+ * @defgroup radius_config radius_config
+ * @{ @ingroup libradius
+ */
+
+#ifndef RADIUS_CONFIG_H_
+#define RADIUS_CONFIG_H_
+
+typedef struct radius_config_t radius_config_t;
+
+#include "radius_socket.h"
+
+/**
+ * RADIUS server configuration.
+ */
+struct radius_config_t {
+
+       /**
+        * Get a RADIUS socket from the pool to communicate with this config.
+        *
+        * @return                      RADIUS socket
+        */
+       radius_socket_t* (*get_socket)(radius_config_t *this);
+
+       /**
+        * Release a socket to the pool after use.
+        *
+        * @param skt           RADIUS socket to release
+        * @param result        result of the socket use, TRUE for success
+        */
+       void (*put_socket)(radius_config_t *this, radius_socket_t *skt, bool result);
+
+       /**
+        * Get the NAS-Identifier to use with this server.
+        *
+        * @return                      NAS-Identifier, internal data
+        */
+       chunk_t (*get_nas_identifier)(radius_config_t *this);
+
+       /**
+        * Get the preference of this server.
+        *
+        * Based on the available sockets and the server reachability a preference
+        * value is calculated: better servers return a higher value.
+        */
+       int (*get_preference)(radius_config_t *this);
+
+       /**
+        * Get the name of the RADIUS server.
+        *
+        * @return                      server name
+        */
+       char* (*get_name)(radius_config_t *this);
+
+       /**
+        * Increase reference count of this server configuration.
+        *
+        * @return                      this
+        */
+       radius_config_t* (*get_ref)(radius_config_t *this);
+
+       /**
+        * Destroy a radius_config_t.
+        */
+       void (*destroy)(radius_config_t *this);
+};
+
+/**
+ * Create a radius_config_t instance.
+ *
+ * @param name                         server name
+ * @param address                      server address
+ * @param auth_port                    server port for authentication
+ * @param acct_port                    server port for accounting
+ * @param nas_identifier       NAS-Identifier to use with this server
+ * @param secret                       secret to use with this server
+ * @param sockets                      number of sockets to create in pool
+ * @param preference           preference boost for this server
+ */
+radius_config_t *radius_config_create(char *name, char *address,
+                                                                         u_int16_t auth_port, u_int16_t acct_port,
+                                                                         char *nas_identifier, char *secret,
+                                                                         int sockets, int preference);
+
+#endif /** RADIUS_CONFIG_H_ @}*/
diff --git a/src/libradius/radius_server.c b/src/libradius/radius_server.c
deleted file mode 100644 (file)
index 282f508..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 2010 Martin Willi
- * Copyright (C) 2010 revosec AG
- *
- * 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; either version 2 of the License, or (at your
- * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * 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.
- */
-
-#include "radius_server.h"
-
-#include <threading/mutex.h>
-#include <threading/condvar.h>
-#include <utils/linked_list.h>
-
-typedef struct private_radius_server_t private_radius_server_t;
-
-/**
- * Private data of an radius_server_t object.
- */
-struct private_radius_server_t {
-
-       /**
-        * Public radius_server_t interface.
-        */
-       radius_server_t public;
-
-       /**
-        * list of radius sockets, as radius_socket_t
-        */
-       linked_list_t *sockets;
-
-       /**
-        * Total number of sockets, in list + currently in use
-        */
-       int socket_count;
-
-       /**
-        * mutex to lock sockets list
-        */
-       mutex_t *mutex;
-
-       /**
-        * condvar to wait for sockets
-        */
-       condvar_t *condvar;
-
-       /**
-        * Server name
-        */
-       char *name;
-
-       /**
-        * NAS-Identifier
-        */
-       chunk_t nas_identifier;
-
-       /**
-        * Preference boost for this server
-        */
-       int preference;
-
-       /**
-        * Is the server currently reachable
-        */
-       bool reachable;
-
-       /**
-        * Retry counter for unreachable servers
-        */
-       int retry;
-
-       /**
-        * reference count
-        */
-       refcount_t ref;
-};
-
-METHOD(radius_server_t, get_socket, radius_socket_t*,
-       private_radius_server_t *this)
-{
-       radius_socket_t *skt;
-
-       this->mutex->lock(this->mutex);
-       while (this->sockets->remove_first(this->sockets, (void**)&skt) != SUCCESS)
-       {
-               this->condvar->wait(this->condvar, this->mutex);
-       }
-       this->mutex->unlock(this->mutex);
-       return skt;
-}
-
-METHOD(radius_server_t, put_socket, void,
-       private_radius_server_t *this, radius_socket_t *skt, bool result)
-{
-       this->mutex->lock(this->mutex);
-       this->sockets->insert_last(this->sockets, skt);
-       this->mutex->unlock(this->mutex);
-       this->condvar->signal(this->condvar);
-       this->reachable = result;
-}
-
-METHOD(radius_server_t, get_nas_identifier, chunk_t,
-       private_radius_server_t *this)
-{
-       return this->nas_identifier;
-}
-
-METHOD(radius_server_t, get_preference, int,
-       private_radius_server_t *this)
-{
-       int pref;
-
-       if (this->socket_count == 0)
-       {       /* don't have sockets, huh? */
-               return -1;
-       }
-       /* calculate preference between 0-100 + boost */
-       pref = this->preference;
-       pref += this->sockets->get_count(this->sockets) * 100 / this->socket_count;
-       if (this->reachable)
-       {       /* reachable server get a boost: pref = 110-210 + boost */
-               return pref + 110;
-       }
-       /* Not reachable. Increase preference randomly to let it retry from
-        * time to time, especially if other servers have high load. */
-       this->retry++;
-       if (this->retry % 128 == 0)
-       {       /* every 64th request gets 210, same as unloaded reachable */
-               return pref + 110;
-       }
-       if (this->retry % 32 == 0)
-       {       /* every 32th request gets 190, wins against average loaded */
-               return pref + 90;
-       }
-       if (this->retry % 8 == 0)
-       {       /* every 8th request gets 110, same as server under load */
-               return pref + 10;
-       }
-       /* other get ~100, less than fully loaded */
-       return pref;
-}
-
-METHOD(radius_server_t, get_name, char*,
-       private_radius_server_t *this)
-{
-       return this->name;
-}
-
-METHOD(radius_server_t, get_ref, radius_server_t*,
-       private_radius_server_t *this)
-{
-       ref_get(&this->ref);
-       return &this->public;
-}
-
-
-METHOD(radius_server_t, destroy, void,
-       private_radius_server_t *this)
-{
-       if (ref_put(&this->ref))
-       {
-               this->mutex->destroy(this->mutex);
-               this->condvar->destroy(this->condvar);
-               this->sockets->destroy_offset(this->sockets,
-                                                                         offsetof(radius_socket_t, destroy));
-               free(this);
-       }
-}
-
-/**
- * See header
- */
-radius_server_t *radius_server_create(char *name, char *address,
-                                                                         u_int16_t auth_port, u_int16_t acct_port,
-                                                                         char *nas_identifier, char *secret,
-                                                                         int sockets, int preference)
-{
-       private_radius_server_t *this;
-       radius_socket_t *socket;
-
-       INIT(this,
-               .public = {
-                       .get_socket = _get_socket,
-                       .put_socket = _put_socket,
-                       .get_nas_identifier = _get_nas_identifier,
-                       .get_preference = _get_preference,
-                       .get_name = _get_name,
-                       .get_ref = _get_ref,
-                       .destroy = _destroy,
-               },
-               .reachable = TRUE,
-               .nas_identifier = chunk_create(nas_identifier, strlen(nas_identifier)),
-               .socket_count = sockets,
-               .sockets = linked_list_create(),
-               .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
-               .condvar = condvar_create(CONDVAR_TYPE_DEFAULT),
-               .name = name,
-               .preference = preference,
-               .ref = 1,
-       );
-
-       while (sockets--)
-       {
-               socket = radius_socket_create(address, auth_port, acct_port,
-                                                                         chunk_create(secret, strlen(secret)));
-               if (!socket)
-               {
-                       destroy(this);
-                       return NULL;
-               }
-               this->sockets->insert_last(this->sockets, socket);
-       }
-       return &this->public;
-}
diff --git a/src/libradius/radius_server.h b/src/libradius/radius_server.h
deleted file mode 100644 (file)
index 2cc281c..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2010 Martin Willi
- * Copyright (C) 2010 revosec AG
- *
- * 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; either version 2 of the License, or (at your
- * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * 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.
- */
-
-/**
- * @defgroup radius_server radius_server
- * @{ @ingroup libradius
- */
-
-#ifndef RADIUS_SERVER_H_
-#define RADIUS_SERVER_H_
-
-typedef struct radius_server_t radius_server_t;
-
-#include "radius_socket.h"
-
-/**
- * RADIUS server configuration.
- */
-struct radius_server_t {
-
-       /**
-        * Get a RADIUS socket from the pool to communicate with this server.
-        *
-        * @return                      RADIUS socket
-        */
-       radius_socket_t* (*get_socket)(radius_server_t *this);
-
-       /**
-        * Release a socket to the pool after use.
-        *
-        * @param skt           RADIUS socket to release
-        * @param result        result of the socket use, TRUE for success
-        */
-       void (*put_socket)(radius_server_t *this, radius_socket_t *skt, bool result);
-
-       /**
-        * Get the NAS-Identifier to use with this server.
-        *
-        * @return                      NAS-Identifier, internal data
-        */
-       chunk_t (*get_nas_identifier)(radius_server_t *this);
-
-       /**
-        * Get the preference of this server.
-        *
-        * Based on the available sockets and the server reachability a preference
-        * value is calculated: better servers return a higher value.
-        */
-       int (*get_preference)(radius_server_t *this);
-
-       /**
-        * Get the name of the RADIUS server.
-        *
-        * @return                      server name
-        */
-       char* (*get_name)(radius_server_t *this);
-
-       /**
-        * Increase reference count of this server.
-        *
-        * @return                      this
-        */
-       radius_server_t* (*get_ref)(radius_server_t *this);
-
-       /**
-        * Destroy a radius_server_t.
-        */
-       void (*destroy)(radius_server_t *this);
-};
-
-/**
- * Create a radius_server instance.
- *
- * @param name                         server name
- * @param address                      server address
- * @param auth_port                    server port for authentication
- * @param acct_port                    server port for accounting
- * @param nas_identifier       NAS-Identifier to use with this server
- * @param secret                       secret to use with this server
- * @param sockets                      number of sockets to create in pool
- * @param preference           preference boost for this server
- */
-radius_server_t *radius_server_create(char *name, char *address,
-                                                                         u_int16_t auth_port, u_int16_t acct_port,
-                                                                         char *nas_identifier, char *secret,
-                                                                         int sockets, int preference);
-
-#endif /** RADIUS_SERVER_H_ @}*/