Home | History | Annotate | Download | only in gpxe
      1 /*
      2  * Copyright (c) 2009 Joshua Oreman <oremanj (at) rwcr.net>.
      3  *
      4  * This program is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU General Public License as
      6  * published by the Free Software Foundation; either version 2 of the
      7  * License, or any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful, but
     10  * WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  * General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU General Public License
     15  * along with this program; if not, write to the Free Software
     16  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     17  */
     18 
     19 #ifndef _GPXE_SEC80211_H
     20 #define _GPXE_SEC80211_H
     21 
     22 FILE_LICENCE ( GPL2_OR_LATER );
     23 
     24 #include <gpxe/net80211.h>
     25 #include <errno.h>
     26 
     27 /** @file
     28  *
     29  * Definitions for general secured-network routines.
     30  *
     31  * Any function in this file which may be referenced by code which is
     32  * not exclusive to encryption-enabled builds (e.g. sec80211_detect(),
     33  * which is called by net80211_probe_step() to fill the net80211_wlan
     34  * structure's security fields) must be declared as a weak symbol,
     35  * using an inline interface similar to that used for
     36  * sec80211_detect() below. This prevents secure network support from
     37  * bloating general builds by any more than a few tiny hooks to call
     38  * crypto functions when crypto structures are non-NULL.
     39  */
     40 
     41 int _sec80211_detect ( struct io_buffer *iob,
     42 		       enum net80211_security_proto *secprot,
     43 		       enum net80211_crypto_alg *crypt )
     44 	__attribute__ (( weak ));
     45 
     46 
     47 /**
     48  * Inline safety wrapper for _sec80211_detect()
     49  *
     50  * @v iob	I/O buffer containing beacon frame
     51  * @ret secprot	Security handshaking protocol used by network
     52  * @ret crypt	Cryptosystem used by network
     53  * @ret rc	Return status code
     54  *
     55  * This function transparently calls _sec80211_detect() if the file
     56  * containing it was compiled in, or returns an error indication of
     57  * @c -ENOTSUP if not.
     58  */
     59 static inline int sec80211_detect ( struct io_buffer *iob,
     60 				    enum net80211_security_proto *secprot,
     61 				    enum net80211_crypto_alg *crypt ) {
     62 	if ( _sec80211_detect )
     63 		return _sec80211_detect ( iob, secprot, crypt );
     64 	return -ENOTSUP;
     65 }
     66 
     67 int sec80211_detect_ie ( int is_rsn, u8 *start, u8 *end,
     68 			 enum net80211_security_proto *secprot,
     69 			 enum net80211_crypto_alg *crypt );
     70 u8 * sec80211_find_rsn ( union ieee80211_ie *ie, void *ie_end,
     71 			 int *is_rsn, u8 **end );
     72 
     73 int sec80211_install ( struct net80211_crypto **which,
     74 		       enum net80211_crypto_alg crypt,
     75 		       const void *key, int len, const void *rsc );
     76 
     77 u32 sec80211_rsn_get_crypto_desc ( enum net80211_crypto_alg crypt, int rsnie );
     78 u32 sec80211_rsn_get_akm_desc ( enum net80211_security_proto secprot,
     79 				int rsnie );
     80 enum net80211_crypto_alg sec80211_rsn_get_net80211_crypt ( u32 desc );
     81 
     82 #endif /* _GPXE_SEC80211_H */
     83 
     84