Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

eapol.c 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. FILE_LICENCE ( GPL2_OR_LATER );
  20. /** @file
  21. *
  22. * 802.1X Extensible Authentication Protocol over LANs demultiplexer
  23. *
  24. */
  25. #include <ipxe/netdevice.h>
  26. #include <ipxe/iobuf.h>
  27. #include <ipxe/if_ether.h>
  28. #include <ipxe/eapol.h>
  29. #include <errno.h>
  30. #include <byteswap.h>
  31. /**
  32. * Receive EAPOL network-layer packet
  33. *
  34. * @v iob I/O buffer
  35. * @v netdev Network device
  36. * @v ll_dest Link-layer destination address
  37. * @v ll_source Link-layer source address
  38. * @v flags Packet flags
  39. *
  40. * This function takes ownership of the I/O buffer passed to it.
  41. */
  42. static int eapol_rx ( struct io_buffer *iob, struct net_device *netdev,
  43. const void *ll_dest, const void *ll_source,
  44. unsigned int flags __unused ) {
  45. struct eapol_frame *eapol = iob->data;
  46. struct eapol_handler *handler;
  47. if ( iob_len ( iob ) < EAPOL_HDR_LEN ) {
  48. free_iob ( iob );
  49. return -EINVAL;
  50. }
  51. for_each_table_entry ( handler, EAPOL_HANDLERS ) {
  52. if ( handler->type == eapol->type ) {
  53. iob_pull ( iob, EAPOL_HDR_LEN );
  54. return handler->rx ( iob, netdev, ll_dest, ll_source );
  55. }
  56. }
  57. free_iob ( iob );
  58. return -( ENOTSUP | ( ( eapol->type & 0x1f ) << 8 ) );
  59. }
  60. /**
  61. * Transcribe EAPOL network-layer address
  62. *
  63. * @v net_addr Network-layer address
  64. * @ret str String representation of network-layer address
  65. *
  66. * EAPOL doesn't have network-layer addresses, so we just return the
  67. * string @c "<EAPOL>".
  68. */
  69. static const char * eapol_ntoa ( const void *net_addr __unused )
  70. {
  71. return "<EAPOL>";
  72. }
  73. /** EAPOL network protocol */
  74. struct net_protocol eapol_protocol __net_protocol = {
  75. .name = "EAPOL",
  76. .rx = eapol_rx,
  77. .ntoa = eapol_ntoa,
  78. .net_proto = htons ( ETH_P_EAPOL ),
  79. };