Keyboard firmwares for Atmel AVR and Cortex-M
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.

Ethernet.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2014.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaims all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. *
  28. * Header file for Ethernet.c.
  29. */
  30. #ifndef _ETHERNET_H_
  31. #define _ETHERNET_H_
  32. /* Includes: */
  33. #include <avr/io.h>
  34. #include <string.h>
  35. #include <LUFA/Drivers/USB/USB.h>
  36. #include "Config/AppConfig.h"
  37. #include "EthernetProtocols.h"
  38. #include "ProtocolDecoders.h"
  39. #include "ICMP.h"
  40. #include "TCP.h"
  41. #include "UDP.h"
  42. #include "DHCP.h"
  43. #include "ARP.h"
  44. #include "IP.h"
  45. /* Macros: */
  46. /** Physical MAC address of the network broadcast address. */
  47. #define BROADCAST_MAC_ADDRESS {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
  48. /** Performs a comparison between two MAC addresses, indicating if they are identical.
  49. *
  50. * \param[in] MAC1 First MAC address
  51. * \param[in] MAC2 Second MAC address
  52. *
  53. * \return True if the addresses match, \c false otherwise
  54. */
  55. #define MAC_COMPARE(MAC1, MAC2) (memcmp(MAC1, MAC2, sizeof(MAC_Address_t)) == 0)
  56. /** Minimum size of an Ethernet packet in bytes, to conform to the Ethernet V2 packet standard. */
  57. #define ETHERNET_VER2_MINSIZE 0x0600
  58. /** Return value for all sub protocol handling routines, indicating that no response packet has been generated. */
  59. #define NO_RESPONSE 0
  60. /** Return value for all sub protocol handling routines, indicating that the packet has not yet been handled. */
  61. #define NO_PROCESS -1
  62. /* Type Defines: */
  63. /** Type define for an Ethernet frame header. */
  64. typedef struct
  65. {
  66. MAC_Address_t Destination; /**< Physical MAC address of the packet recipient */
  67. MAC_Address_t Source; /**< Physics MAC address of the packet source */
  68. uint16_t EtherType; /**< Ethernet packet sub-protocol type, for Ethernet V2 packets */
  69. } Ethernet_Frame_Header_t;
  70. /* External Variables: */
  71. extern const MAC_Address_t ServerMACAddress;
  72. extern const IP_Address_t ServerIPAddress;
  73. extern const MAC_Address_t BroadcastMACAddress;
  74. extern const IP_Address_t BroadcastIPAddress;
  75. extern const IP_Address_t ClientIPAddress;
  76. /* Function Prototypes: */
  77. void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN,
  78. Ethernet_Frame_Info_t* const FrameOUT);
  79. uint16_t Ethernet_Checksum16(void* Data,
  80. uint16_t Bytes);
  81. #endif