Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * RADIUS authentication server |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 3 | * Copyright (c) 2005-2009, 2011, Jouni Malinen <j@w1.fi> |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 4 | * |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef RADIUS_SERVER_H |
| 10 | #define RADIUS_SERVER_H |
| 11 | |
| 12 | struct radius_server_data; |
| 13 | struct eap_user; |
| 14 | |
| 15 | /** |
| 16 | * struct radius_server_conf - RADIUS server configuration |
| 17 | */ |
| 18 | struct radius_server_conf { |
| 19 | /** |
| 20 | * auth_port - UDP port to listen to as an authentication server |
| 21 | */ |
| 22 | int auth_port; |
| 23 | |
| 24 | /** |
Dmitry Shmidt | bd14a57 | 2014-02-18 10:33:49 -0800 | [diff] [blame] | 25 | * acct_port - UDP port to listen to as an accounting server |
| 26 | */ |
| 27 | int acct_port; |
| 28 | |
| 29 | /** |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 30 | * client_file - RADIUS client configuration file |
| 31 | * |
| 32 | * This file contains the RADIUS clients and the shared secret to be |
| 33 | * used with them in a format where each client is on its own line. The |
| 34 | * first item on the line is the IPv4 or IPv6 address of the client |
| 35 | * with an optional address mask to allow full network to be specified |
| 36 | * (e.g., 192.168.1.2 or 192.168.1.0/24). This is followed by white |
| 37 | * space (space or tabulator) and the shared secret. Lines starting |
| 38 | * with '#' are skipped and can be used as comments. |
| 39 | */ |
| 40 | char *client_file; |
| 41 | |
| 42 | /** |
| 43 | * conf_ctx - Context pointer for callbacks |
| 44 | * |
| 45 | * This is used as the ctx argument in get_eap_user() calls. |
| 46 | */ |
| 47 | void *conf_ctx; |
| 48 | |
| 49 | /** |
| 50 | * eap_sim_db_priv - EAP-SIM/AKA database context |
| 51 | * |
| 52 | * This is passed to the EAP-SIM/AKA server implementation as a |
| 53 | * callback context. |
| 54 | */ |
| 55 | void *eap_sim_db_priv; |
| 56 | |
| 57 | /** |
| 58 | * ssl_ctx - TLS context |
| 59 | * |
| 60 | * This is passed to the EAP server implementation as a callback |
| 61 | * context for TLS operations. |
| 62 | */ |
| 63 | void *ssl_ctx; |
| 64 | |
| 65 | /** |
| 66 | * pac_opaque_encr_key - PAC-Opaque encryption key for EAP-FAST |
| 67 | * |
| 68 | * This parameter is used to set a key for EAP-FAST to encrypt the |
| 69 | * PAC-Opaque data. It can be set to %NULL if EAP-FAST is not used. If |
| 70 | * set, must point to a 16-octet key. |
| 71 | */ |
| 72 | u8 *pac_opaque_encr_key; |
| 73 | |
| 74 | /** |
| 75 | * eap_fast_a_id - EAP-FAST authority identity (A-ID) |
| 76 | * |
| 77 | * If EAP-FAST is not used, this can be set to %NULL. In theory, this |
| 78 | * is a variable length field, but due to some existing implementations |
| 79 | * requiring A-ID to be 16 octets in length, it is recommended to use |
| 80 | * that length for the field to provide interoperability with deployed |
| 81 | * peer implementations. |
| 82 | */ |
| 83 | u8 *eap_fast_a_id; |
| 84 | |
| 85 | /** |
| 86 | * eap_fast_a_id_len - Length of eap_fast_a_id buffer in octets |
| 87 | */ |
| 88 | size_t eap_fast_a_id_len; |
| 89 | |
| 90 | /** |
| 91 | * eap_fast_a_id_info - EAP-FAST authority identifier information |
| 92 | * |
| 93 | * This A-ID-Info contains a user-friendly name for the A-ID. For |
| 94 | * example, this could be the enterprise and server names in |
| 95 | * human-readable format. This field is encoded as UTF-8. If EAP-FAST |
| 96 | * is not used, this can be set to %NULL. |
| 97 | */ |
| 98 | char *eap_fast_a_id_info; |
| 99 | |
| 100 | /** |
| 101 | * eap_fast_prov - EAP-FAST provisioning modes |
| 102 | * |
| 103 | * 0 = provisioning disabled, 1 = only anonymous provisioning allowed, |
| 104 | * 2 = only authenticated provisioning allowed, 3 = both provisioning |
| 105 | * modes allowed. |
| 106 | */ |
| 107 | int eap_fast_prov; |
| 108 | |
| 109 | /** |
| 110 | * pac_key_lifetime - EAP-FAST PAC-Key lifetime in seconds |
| 111 | * |
| 112 | * This is the hard limit on how long a provisioned PAC-Key can be |
| 113 | * used. |
| 114 | */ |
| 115 | int pac_key_lifetime; |
| 116 | |
| 117 | /** |
| 118 | * pac_key_refresh_time - EAP-FAST PAC-Key refresh time in seconds |
| 119 | * |
| 120 | * This is a soft limit on the PAC-Key. The server will automatically |
| 121 | * generate a new PAC-Key when this number of seconds (or fewer) of the |
| 122 | * lifetime remains. |
| 123 | */ |
| 124 | int pac_key_refresh_time; |
| 125 | |
| 126 | /** |
| 127 | * eap_sim_aka_result_ind - EAP-SIM/AKA protected success indication |
| 128 | * |
| 129 | * This controls whether the protected success/failure indication |
| 130 | * (AT_RESULT_IND) is used with EAP-SIM and EAP-AKA. |
| 131 | */ |
| 132 | int eap_sim_aka_result_ind; |
| 133 | |
| 134 | /** |
| 135 | * tnc - Trusted Network Connect (TNC) |
| 136 | * |
| 137 | * This controls whether TNC is enabled and will be required before the |
| 138 | * peer is allowed to connect. Note: This is only used with EAP-TTLS |
| 139 | * and EAP-FAST. If any other EAP method is enabled, the peer will be |
| 140 | * allowed to connect without TNC. |
| 141 | */ |
| 142 | int tnc; |
| 143 | |
| 144 | /** |
| 145 | * pwd_group - EAP-pwd D-H group |
| 146 | * |
| 147 | * This is used to select which D-H group to use with EAP-pwd. |
| 148 | */ |
| 149 | u16 pwd_group; |
| 150 | |
| 151 | /** |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 152 | * server_id - Server identity |
| 153 | */ |
| 154 | const char *server_id; |
| 155 | |
| 156 | /** |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 157 | * wps - Wi-Fi Protected Setup context |
| 158 | * |
| 159 | * If WPS is used with an external RADIUS server (which is quite |
| 160 | * unlikely configuration), this is used to provide a pointer to WPS |
| 161 | * context data. Normally, this can be set to %NULL. |
| 162 | */ |
| 163 | struct wps_context *wps; |
| 164 | |
| 165 | /** |
| 166 | * ipv6 - Whether to enable IPv6 support in the RADIUS server |
| 167 | */ |
| 168 | int ipv6; |
| 169 | |
| 170 | /** |
| 171 | * get_eap_user - Callback for fetching EAP user information |
| 172 | * @ctx: Context data from conf_ctx |
| 173 | * @identity: User identity |
| 174 | * @identity_len: identity buffer length in octets |
| 175 | * @phase2: Whether this is for Phase 2 identity |
| 176 | * @user: Data structure for filling in the user information |
| 177 | * Returns: 0 on success, -1 on failure |
| 178 | * |
| 179 | * This is used to fetch information from user database. The callback |
| 180 | * will fill in information about allowed EAP methods and the user |
| 181 | * password. The password field will be an allocated copy of the |
| 182 | * password data and RADIUS server will free it after use. |
| 183 | */ |
| 184 | int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len, |
| 185 | int phase2, struct eap_user *user); |
| 186 | |
| 187 | /** |
| 188 | * eap_req_id_text - Optional data for EAP-Request/Identity |
| 189 | * |
| 190 | * This can be used to configure an optional, displayable message that |
| 191 | * will be sent in EAP-Request/Identity. This string can contain an |
| 192 | * ASCII-0 character (nul) to separate network infromation per RFC |
| 193 | * 4284. The actual string length is explicit provided in |
| 194 | * eap_req_id_text_len since nul character will not be used as a string |
| 195 | * terminator. |
| 196 | */ |
| 197 | const char *eap_req_id_text; |
| 198 | |
| 199 | /** |
| 200 | * eap_req_id_text_len - Length of eap_req_id_text buffer in octets |
| 201 | */ |
| 202 | size_t eap_req_id_text_len; |
| 203 | |
| 204 | /* |
| 205 | * msg_ctx - Context data for wpa_msg() calls |
| 206 | */ |
| 207 | void *msg_ctx; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 208 | |
| 209 | #ifdef CONFIG_RADIUS_TEST |
| 210 | const char *dump_msk_file; |
| 211 | #endif /* CONFIG_RADIUS_TEST */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 212 | }; |
| 213 | |
| 214 | |
| 215 | struct radius_server_data * |
| 216 | radius_server_init(struct radius_server_conf *conf); |
| 217 | |
| 218 | void radius_server_deinit(struct radius_server_data *data); |
| 219 | |
| 220 | int radius_server_get_mib(struct radius_server_data *data, char *buf, |
| 221 | size_t buflen); |
| 222 | |
| 223 | void radius_server_eap_pending_cb(struct radius_server_data *data, void *ctx); |
| 224 | |
| 225 | #endif /* RADIUS_SERVER_H */ |