vici: Properly handle absence of peer ID on mediation connections
[strongswan.git] / src / libradius / radius_config.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 * Copyright (C) 2015 Thom Troy
18 *
19 * Permission is hereby granted, free of charge, to any person obtaining a copy
20 * of this software and associated documentation files (the "Software"), to deal
21 * in the Software without restriction, including without limitation the rights
22 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 * copies of the Software, and to permit persons to whom the Software is
24 * furnished to do so, subject to the following conditions:
25 *
26 * The above copyright notice and this permission notice shall be included in
27 * all copies or substantial portions of the Software.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 * THE SOFTWARE.
36 */
37
38 /**
39 * @defgroup radius_config radius_config
40 * @{ @ingroup libradius
41 */
42
43 #ifndef RADIUS_CONFIG_H_
44 #define RADIUS_CONFIG_H_
45
46 typedef struct radius_config_t radius_config_t;
47
48 #include "radius_socket.h"
49
50 /**
51 * RADIUS server configuration.
52 */
53 struct radius_config_t {
54
55 /**
56 * Get a RADIUS socket from the pool to communicate with this config.
57 *
58 * @return RADIUS socket
59 */
60 radius_socket_t* (*get_socket)(radius_config_t *this);
61
62 /**
63 * Release a socket to the pool after use.
64 *
65 * @param skt RADIUS socket to release
66 * @param result result of the socket use, TRUE for success
67 */
68 void (*put_socket)(radius_config_t *this, radius_socket_t *skt, bool result);
69
70 /**
71 * Get the NAS-Identifier to use with this server.
72 *
73 * @return NAS-Identifier, internal data
74 */
75 chunk_t (*get_nas_identifier)(radius_config_t *this);
76
77 /**
78 * Get the preference of this server.
79 *
80 * Based on the available sockets and the server reachability a preference
81 * value is calculated: better servers return a higher value.
82 */
83 int (*get_preference)(radius_config_t *this);
84
85 /**
86 * Get the name of the RADIUS server.
87 *
88 * @return server name
89 */
90 char* (*get_name)(radius_config_t *this);
91
92 /**
93 * Increase reference count of this server configuration.
94 *
95 * @return this
96 */
97 radius_config_t* (*get_ref)(radius_config_t *this);
98
99 /**
100 * Destroy a radius_config_t.
101 */
102 void (*destroy)(radius_config_t *this);
103 };
104
105 /**
106 * Create a radius_config_t instance.
107 *
108 * @param name server name
109 * @param address server address
110 * @param auth_port server port for authentication
111 * @param acct_port server port for accounting
112 * @param nas_identifier NAS-Identifier to use with this server
113 * @param secret secret to use with this server
114 * @param sockets number of sockets to create in pool
115 * @param preference preference boost for this server
116 * @param tries number of times we retransmit messages
117 * @param timeout retransmission timeout
118 * @param base base to calculate retransmission timeout
119 */
120 radius_config_t *radius_config_create(char *name, char *address,
121 uint16_t auth_port, uint16_t acct_port,
122 char *nas_identifier, char *secret,
123 int sockets, int preference,
124 u_int tries, double timeout, double base);
125
126 #endif /** RADIUS_CONFIG_H_ @}*/