Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

eapol.h 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. */
  19. #ifndef _IPXE_EAPOL_H
  20. #define _IPXE_EAPOL_H
  21. /** @file
  22. *
  23. * Definitions for EAPOL (Extensible Authentication Protocol over
  24. * LANs) frames. Definitions for the packets usually encapsulated in
  25. * them are elsewhere.
  26. */
  27. #include <ipxe/tables.h>
  28. #include <stdint.h>
  29. FILE_LICENCE ( GPL2_OR_LATER );
  30. /**
  31. * @defgroup eapol_type EAPOL archetype identifiers
  32. * @{
  33. */
  34. #define EAPOL_TYPE_EAP 0 /**< EAP authentication handshake packet */
  35. #define EAPOL_TYPE_START 1 /**< Request by Peer to begin (no data) */
  36. #define EAPOL_TYPE_LOGOFF 2 /**< Request by Peer to terminate (no data) */
  37. #define EAPOL_TYPE_KEY 3 /**< EAPOL-Key packet */
  38. /** @} */
  39. /** Expected EAPOL version field value
  40. *
  41. * Version 2 is often seen and has no format differences from version 1;
  42. * however, many older APs will completely drop version-2 packets, so
  43. * we advertise ourselves as version 1.
  44. */
  45. #define EAPOL_THIS_VERSION 1
  46. /** Length of an EAPOL frame header */
  47. #define EAPOL_HDR_LEN 4
  48. /** An EAPOL frame
  49. *
  50. * This may encapsulate an eap_pkt, an eapol_key_pkt, or a Start or
  51. * Logoff request with no data attached. It is transmitted directly in
  52. * an Ethernet frame, with no IP packet header.
  53. */
  54. struct eapol_frame
  55. {
  56. /** EAPOL version identifier, always 1 */
  57. u8 version;
  58. /** EAPOL archetype identifier indicating format of payload */
  59. u8 type;
  60. /** Length of payload, in network byte order */
  61. u16 length;
  62. /** Payload, if @a type is EAP or EAPOL-Key */
  63. u8 data[0];
  64. } __attribute__ (( packed ));
  65. /** An EAPOL frame type handler
  66. *
  67. * Normally there will be at most two of these, one for EAP and one
  68. * for EAPOL-Key frames. The EAPOL interface code handles Start and
  69. * Logoff directly.
  70. */
  71. struct eapol_handler
  72. {
  73. /** EAPOL archetype identifier for payload this handler will handle */
  74. u8 type;
  75. /** Receive EAPOL-encapsulated packet of specified type
  76. *
  77. * @v iob I/O buffer containing packet payload
  78. * @v netdev Network device from which packet was received
  79. * @V ll_dest Destination link-layer address
  80. * @v ll_source Source link-layer address
  81. * @ret rc Return status code
  82. *
  83. * The I/O buffer will have the EAPOL header pulled off it, so
  84. * @c iob->data points to the first byte of the payload.
  85. *
  86. * This function takes ownership of the I/O buffer passed to it.
  87. */
  88. int ( * rx ) ( struct io_buffer *iob, struct net_device *netdev,
  89. const void *ll_dest, const void *ll_source );
  90. };
  91. #define EAPOL_HANDLERS __table ( struct eapol_handler, "eapol_handlers" )
  92. #define __eapol_handler __table_entry ( EAPOL_HANDLERS, 01 )
  93. extern struct net_protocol eapol_protocol __net_protocol;
  94. #endif /* _IPXE_EAPOL_H */