eap_methods.c

Go to the documentation of this file.
00001 
00016 #include "includes.h"
00017 
00018 #include "common.h"
00019 #include "eap_i.h"
00020 #include "eap_methods.h"
00021 
00022 
00023 static struct eap_method *eap_methods;
00024 
00025 
00033 const struct eap_method * eap_server_get_eap_method(int vendor, EapType method)
00034 {
00035         struct eap_method *m;
00036         for (m = eap_methods; m; m = m->next) {
00037                 if (m->vendor == vendor && m->method == method)
00038                         return m;
00039         }
00040         return NULL;
00041 }
00042 
00043 
00054 EapType eap_server_get_type(const char *name, int *vendor)
00055 {
00056         struct eap_method *m;
00057         for (m = eap_methods; m; m = m->next) {
00058                 if (os_strcmp(m->name, name) == 0) {
00059                         *vendor = m->vendor;
00060                         return m->method;
00061                 }
00062         }
00063         *vendor = EAP_VENDOR_IETF;
00064         return EAP_TYPE_NONE;
00065 }
00066 
00067 
00081 struct eap_method * eap_server_method_alloc(int version, int vendor,
00082                                             EapType method, const char *name)
00083 {
00084         struct eap_method *eap;
00085         eap = os_zalloc(sizeof(*eap));
00086         if (eap == NULL)
00087                 return NULL;
00088         eap->version = version;
00089         eap->vendor = vendor;
00090         eap->method = method;
00091         eap->name = name;
00092         return eap;
00093 }
00094 
00095 
00101 void eap_server_method_free(struct eap_method *method)
00102 {
00103         os_free(method);
00104 }
00105 
00106 
00117 int eap_server_method_register(struct eap_method *method)
00118 {
00119         struct eap_method *m, *last = NULL;
00120 
00121         if (method == NULL || method->name == NULL ||
00122             method->version != EAP_SERVER_METHOD_INTERFACE_VERSION)
00123                 return -1;
00124 
00125         for (m = eap_methods; m; m = m->next) {
00126                 if ((m->vendor == method->vendor &&
00127                      m->method == method->method) ||
00128                     os_strcmp(m->name, method->name) == 0)
00129                         return -2;
00130                 last = m;
00131         }
00132 
00133         if (last)
00134                 last->next = method;
00135         else
00136                 eap_methods = method;
00137 
00138         return 0;
00139 }
00140 
00141 
00150 int eap_server_register_methods(void)
00151 {
00152         int ret = 0;
00153 
00154         if (ret == 0) {
00155                 int eap_server_identity_register(void);
00156                 ret = eap_server_identity_register();
00157         }
00158 
00159 #ifdef EAP_SERVER_MD5
00160         if (ret == 0) {
00161                 int eap_server_md5_register(void);
00162                 ret = eap_server_md5_register();
00163         }
00164 #endif /* EAP_SERVER_MD5 */
00165 
00166 #ifdef EAP_SERVER_TLS
00167         if (ret == 0) {
00168                 int eap_server_tls_register(void);
00169                 ret = eap_server_tls_register();
00170         }
00171 #endif /* EAP_SERVER_TLS */
00172 
00173 #ifdef EAP_SERVER_MSCHAPV2
00174         if (ret == 0) {
00175                 int eap_server_mschapv2_register(void);
00176                 ret = eap_server_mschapv2_register();
00177         }
00178 #endif /* EAP_SERVER_MSCHAPV2 */
00179 
00180 #ifdef EAP_SERVER_PEAP
00181         if (ret == 0) {
00182                 int eap_server_peap_register(void);
00183                 ret = eap_server_peap_register();
00184         }
00185 #endif /* EAP_SERVER_PEAP */
00186 
00187 #ifdef EAP_SERVER_TLV
00188         if (ret == 0) {
00189                 int eap_server_tlv_register(void);
00190                 ret = eap_server_tlv_register();
00191         }
00192 #endif /* EAP_SERVER_TLV */
00193 
00194 #ifdef EAP_SERVER_GTC
00195         if (ret == 0) {
00196                 int eap_server_gtc_register(void);
00197                 ret = eap_server_gtc_register();
00198         }
00199 #endif /* EAP_SERVER_GTC */
00200 
00201 #ifdef EAP_SERVER_TTLS
00202         if (ret == 0) {
00203                 int eap_server_ttls_register(void);
00204                 ret = eap_server_ttls_register();
00205         }
00206 #endif /* EAP_SERVER_TTLS */
00207 
00208 #ifdef EAP_SERVER_SIM
00209         if (ret == 0) {
00210                 int eap_server_sim_register(void);
00211                 ret = eap_server_sim_register();
00212         }
00213 #endif /* EAP_SERVER_SIM */
00214 
00215 #ifdef EAP_SERVER_AKA
00216         if (ret == 0) {
00217                 int eap_server_aka_register(void);
00218                 ret = eap_server_aka_register();
00219         }
00220 #endif /* EAP_SERVER_AKA */
00221 
00222 #ifdef EAP_SERVER_AKA_PRIME
00223         if (ret == 0) {
00224                 int eap_server_aka_prime_register(void);
00225                 ret = eap_server_aka_prime_register();
00226         }
00227 #endif /* EAP_SERVER_AKA_PRIME */
00228 
00229 #ifdef EAP_SERVER_PAX
00230         if (ret == 0) {
00231                 int eap_server_pax_register(void);
00232                 ret = eap_server_pax_register();
00233         }
00234 #endif /* EAP_SERVER_PAX */
00235 
00236 #ifdef EAP_SERVER_PSK
00237         if (ret == 0) {
00238                 int eap_server_psk_register(void);
00239                 ret = eap_server_psk_register();
00240         }
00241 #endif /* EAP_SERVER_PSK */
00242 
00243 #ifdef EAP_SERVER_SAKE
00244         if (ret == 0) {
00245                 int eap_server_sake_register(void);
00246                 ret = eap_server_sake_register();
00247         }
00248 #endif /* EAP_SERVER_SAKE */
00249 
00250 #ifdef EAP_SERVER_GPSK
00251         if (ret == 0) {
00252                 int eap_server_gpsk_register(void);
00253                 ret = eap_server_gpsk_register();
00254         }
00255 #endif /* EAP_SERVER_GPSK */
00256 
00257 #ifdef EAP_SERVER_VENDOR_TEST
00258         if (ret == 0) {
00259                 int eap_server_vendor_test_register(void);
00260                 ret = eap_server_vendor_test_register();
00261         }
00262 #endif /* EAP_SERVER_VENDOR_TEST */
00263 
00264 #ifdef EAP_SERVER_FAST
00265         if (ret == 0) {
00266                 int eap_server_fast_register(void);
00267                 ret = eap_server_fast_register();
00268         }
00269 #endif /* EAP_SERVER_FAST */
00270 
00271 #ifdef EAP_SERVER_WSC
00272         if (ret == 0) {
00273                 int eap_server_wsc_register(void);
00274                 ret = eap_server_wsc_register();
00275         }
00276 #endif /* EAP_SERVER_WSC */
00277 
00278 #ifdef EAP_SERVER_IKEV2
00279         if (ret == 0) {
00280                 int eap_server_ikev2_register(void);
00281                 ret = eap_server_ikev2_register();
00282         }
00283 #endif /* EAP_SERVER_IKEV2 */
00284 
00285 #ifdef EAP_SERVER_TNC
00286         if (ret == 0) {
00287                 int eap_server_tnc_register(void);
00288                 ret = eap_server_tnc_register();
00289         }
00290 #endif /* EAP_SERVER_TNC */
00291 
00292         return ret;
00293 }
00294 
00295 
00303 void eap_server_unregister_methods(void)
00304 {
00305         struct eap_method *m;
00306 
00307         while (eap_methods) {
00308                 m = eap_methods;
00309                 eap_methods = eap_methods->next;
00310 
00311                 if (m->free)
00312                         m->free(m);
00313                 else
00314                         eap_server_method_free(m);
00315         }
00316 }
00317 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Sat Nov 21 23:16:51 2009 for hostapd by  doxygen 1.6.1