Moved TLS stack to its own library
[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 address of the RADIUS server.
65 *
66 * @return address, internal data
67 */
68 host_t* (*get_address)(radius_server_t *this);
69
70 /**
71 * Destroy a radius_server_t.
72 */
73 void (*destroy)(radius_server_t *this);
74 };
75
76 /**
77 * Create a radius_server instance.
78 *
79 * @param server server address
80 * @param port server port
81 * @param nas_identifier NAS-Identifier to use with this server
82 * @param sockets number of sockets to create in pool
83 * @param preference preference boost for this server
84 */
85 radius_server_t *radius_server_create(char *server, u_int16_t port,
86 char *nas_identifier, char *secret, int sockets, int preference);
87
88 #endif /** RADIUS_SERVER_H_ @}*/