Removed libcharon dependencies from generic RADIUS protocol support
[strongswan.git] / src / libcharon / plugins / eap_radius / radius_server.h
1 /*
2 * Copyright (C) 2010 Martin Willi
3 * Copyright (C) 2010 revosec AG
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 /**
17 * @defgroup radius_server radius_server
18 * @{ @ingroup eap_radius
19 */
20
21 #ifndef RADIUS_SERVER_H_
22 #define RADIUS_SERVER_H_
23
24 typedef struct radius_server_t radius_server_t;
25
26 #include "radius_socket.h"
27
28 /**
29 * RADIUS server configuration.
30 */
31 struct radius_server_t {
32
33 /**
34 * Get a RADIUS socket from the pool to communicate with this server.
35 *
36 * @return RADIUS socket
37 */
38 radius_socket_t* (*get_socket)(radius_server_t *this);
39
40 /**
41 * Release a socket to the pool after use.
42 *
43 * @param skt RADIUS socket to release
44 * @param result result of the socket use, TRUE for success
45 */
46 void (*put_socket)(radius_server_t *this, radius_socket_t *skt, bool result);
47
48 /**
49 * Get the NAS-Identifier to use with this server.
50 *
51 * @return NAS-Identifier, internal data
52 */
53 chunk_t (*get_nas_identifier)(radius_server_t *this);
54
55 /**
56 * Get the preference of this server.
57 *
58 * Based on the available sockets and the server reachability a preference
59 * value is calculated: better servers return a higher value.
60 */
61 int (*get_preference)(radius_server_t *this);
62
63 /**
64 * Get the name of the RADIUS server.
65 *
66 * @return server name
67 */
68 char* (*get_name)(radius_server_t *this);
69
70 /**
71 * Increase reference count of this server.
72 *
73 * @return this
74 */
75 radius_server_t* (*get_ref)(radius_server_t *this);
76
77 /**
78 * Destroy a radius_server_t.
79 */
80 void (*destroy)(radius_server_t *this);
81 };
82
83 /**
84 * Create a radius_server instance.
85 *
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
94 */
95 radius_server_t *radius_server_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);
99
100 #endif /** RADIUS_SERVER_H_ @}*/