2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * @defgroup radius_config radius_config
18 * @{ @ingroup libradius
21 #ifndef RADIUS_CONFIG_H_
22 #define RADIUS_CONFIG_H_
24 typedef struct radius_config_t radius_config_t
;
26 #include "radius_socket.h"
29 * RADIUS server configuration.
31 struct radius_config_t
{
34 * Get a RADIUS socket from the pool to communicate with this config.
36 * @return RADIUS socket
38 radius_socket_t
* (*get_socket
)(radius_config_t
*this);
41 * Release a socket to the pool after use.
43 * @param skt RADIUS socket to release
44 * @param result result of the socket use, TRUE for success
46 void (*put_socket
)(radius_config_t
*this, radius_socket_t
*skt
, bool result
);
49 * Get the NAS-Identifier to use with this server.
51 * @return NAS-Identifier, internal data
53 chunk_t (*get_nas_identifier
)(radius_config_t
*this);
56 * Get the preference of this server.
58 * Based on the available sockets and the server reachability a preference
59 * value is calculated: better servers return a higher value.
61 int (*get_preference
)(radius_config_t
*this);
64 * Get the name of the RADIUS server.
68 char* (*get_name
)(radius_config_t
*this);
71 * Increase reference count of this server configuration.
75 radius_config_t
* (*get_ref
)(radius_config_t
*this);
78 * Destroy a radius_config_t.
80 void (*destroy
)(radius_config_t
*this);
84 * Create a radius_config_t instance.
86 * @param name server name
87 * @param address server address
88 * @param auth_port server port for authentication
89 * @param acct_port server port for accounting
90 * @param nas_identifier NAS-Identifier to use with this server
91 * @param secret secret to use with this server
92 * @param sockets number of sockets to create in pool
93 * @param preference preference boost for this server
95 radius_config_t
*radius_config_create(char *name
, char *address
,
96 u_int16_t auth_port
, u_int16_t acct_port
,
97 char *nas_identifier
, char *secret
,
98 int sockets
, int preference
);
100 #endif /** RADIUS_CONFIG_H_ @}*/