radius_server.h 6.8 KB

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