You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sec80211.h 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) 2009 Joshua Oreman <oremanj@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. #ifndef _GPXE_SEC80211_H
  19. #define _GPXE_SEC80211_H
  20. FILE_LICENCE ( GPL2_OR_LATER );
  21. #include <gpxe/net80211.h>
  22. #include <errno.h>
  23. /** @file
  24. *
  25. * Definitions for general secured-network routines.
  26. *
  27. * Any function in this file which may be referenced by code which is
  28. * not exclusive to encryption-enabled builds (e.g. sec80211_detect(),
  29. * which is called by net80211_probe_step() to fill the net80211_wlan
  30. * structure's security fields) must be declared as a weak symbol,
  31. * using an inline interface similar to that used for
  32. * sec80211_detect() below. This prevents secure network support from
  33. * bloating general builds by any more than a few tiny hooks to call
  34. * crypto functions when crypto structures are non-NULL.
  35. */
  36. int _sec80211_detect ( struct io_buffer *iob,
  37. enum net80211_security_proto *secprot,
  38. enum net80211_crypto_alg *crypt )
  39. __attribute__ (( weak ));
  40. /**
  41. * Inline safety wrapper for _sec80211_detect()
  42. *
  43. * @v iob I/O buffer containing beacon frame
  44. * @ret secprot Security handshaking protocol used by network
  45. * @ret crypt Cryptosystem used by network
  46. * @ret rc Return status code
  47. *
  48. * This function transparently calls _sec80211_detect() if the file
  49. * containing it was compiled in, or returns an error indication of
  50. * @c -ENOTSUP if not.
  51. */
  52. static inline int sec80211_detect ( struct io_buffer *iob,
  53. enum net80211_security_proto *secprot,
  54. enum net80211_crypto_alg *crypt ) {
  55. if ( _sec80211_detect )
  56. return _sec80211_detect ( iob, secprot, crypt );
  57. return -ENOTSUP;
  58. }
  59. int sec80211_detect_ie ( int is_rsn, u8 *start, u8 *end,
  60. enum net80211_security_proto *secprot,
  61. enum net80211_crypto_alg *crypt );
  62. u8 * sec80211_find_rsn ( union ieee80211_ie *ie, void *ie_end,
  63. int *is_rsn, u8 **end );
  64. int sec80211_install ( struct net80211_crypto **which,
  65. enum net80211_crypto_alg crypt,
  66. const void *key, int len, const void *rsc );
  67. u32 sec80211_rsn_get_crypto_desc ( enum net80211_crypto_alg crypt, int rsnie );
  68. u32 sec80211_rsn_get_akm_desc ( enum net80211_security_proto secprot,
  69. int rsnie );
  70. enum net80211_crypto_alg sec80211_rsn_get_net80211_crypt ( u32 desc );
  71. #endif /* _GPXE_SEC80211_H */