1 /* 2 * rlm_eap.h Local Header file. 3 * 4 * Version: $Id: 384f7f78d79f1c20a186e6b0512e00affec77f21 $ 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19 * 20 * Copyright 2001 hereUare Communications, Inc. <raghud@hereuare.com> 21 * Copyright 2003 Alan DeKok <aland@freeradius.org> 22 * Copyright 2006 The FreeRADIUS server project 23 */ 24 #ifndef _RLM_EAP_H 25 #define _RLM_EAP_H 26 27 RCSIDH(rlm_eap_h, "$Id: 384f7f78d79f1c20a186e6b0512e00affec77f21 $") 28 29 #include <freeradius-devel/modpriv.h> 30 #include "eap.h" 31 #include "eap_types.h" 32 33 /* 34 * Keep track of which sub modules we've loaded. 35 */ 36 typedef struct eap_module { 37 char const *name; 38 rlm_eap_module_t *type; 39 fr_dlhandle handle; 40 CONF_SECTION *cs; 41 void *instance; 42 } eap_module_t; 43 44 /* 45 * This structure contains eap's persistent data. 46 * sessions = remembered sessions, in a tree for speed. 47 * types = All supported EAP-Types 48 * mutex = ensure only one thread is updating the sessions[] struct 49 */ 50 typedef struct rlm_eap { 51 rbtree_t *session_tree; 52 eap_handler_t *session_head, *session_tail; 53 eap_module_t *methods[PW_EAP_MAX_TYPES]; 54 55 /* 56 * Configuration items. 57 */ 58 uint32_t timer_limit; 59 60 char const *default_method_name; 61 eap_type_t default_method; 62 63 bool ignore_unknown_types; 64 bool mod_accounting_username_bug; 65 66 uint32_t max_sessions; 67 68 #ifdef HAVE_PTHREAD_H 69 pthread_mutex_t session_mutex; 70 pthread_mutex_t handler_mutex; 71 #endif 72 73 char const *xlat_name; /* no xlat's yet */ 74 fr_randctx rand_pool; 75 } rlm_eap_t; 76 77 /* 78 * For simplicity in the rest of the code. 79 */ 80 #ifndef HAVE_PTHREAD_H 81 /* 82 * This is easier than ifdef's throughout the code. 83 */ 84 #define pthread_mutex_init(_x, _y) 85 #define pthread_mutex_destroy(_x) 86 #define pthread_mutex_lock(_x) 87 #define pthread_mutex_unlock(_x) 88 #endif 89 90 /* function definitions */ 91 /* EAP-Type */ 92 int eap_module_instantiate(rlm_eap_t *inst, eap_module_t **method, eap_type_t num, CONF_SECTION *cs); 93 eap_rcode_t eap_method_select(rlm_eap_t *inst, eap_handler_t *handler); 94 95 /* EAP */ 96 int eap_start(rlm_eap_t *inst, REQUEST *request) CC_HINT(nonnull); 97 void eap_fail(eap_handler_t *handler) CC_HINT(nonnull); 98 void eap_success(eap_handler_t *handler) CC_HINT(nonnull); 99 rlm_rcode_t eap_compose(eap_handler_t *handler) CC_HINT(nonnull); 100 eap_handler_t *eap_handler(rlm_eap_t *inst, eap_packet_raw_t **eap_msg, REQUEST *request) CC_HINT(nonnull); 101 102 /* Memory Management */ 103 EAP_DS *eap_ds_alloc(eap_handler_t *handler); 104 eap_handler_t *eap_handler_alloc(rlm_eap_t *inst); 105 void eap_ds_free(EAP_DS **eap_ds); 106 int eaplist_add(rlm_eap_t *inst, eap_handler_t *handler) CC_HINT(nonnull); 107 eap_handler_t *eaplist_find(rlm_eap_t *inst, REQUEST *request, eap_packet_raw_t *eap_packet); 108 void eaplist_free(rlm_eap_t *inst); 109 110 /* State */ 111 void generate_key(void); 112 VALUE_PAIR *generate_state(time_t timestamp); 113 int verify_state(VALUE_PAIR *state, time_t timestamp); 114 115 #endif /*_RLM_EAP_H*/ 116