1
0

ETHInterface.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef ETHInterface_H
  16. #define ETHInterface_H
  17. #include "interface/addressable/AddrIface.h"
  18. #include "benc/List.h"
  19. #include "util/events/EventBase.h"
  20. #include "net/InterfaceController.h"
  21. #include "util/Gcc.h"
  22. #include "util/Assert.h"
  23. #include "util/log/Log.h"
  24. #include "memory/Allocator.h"
  25. #include "util/Linker.h"
  26. Linker_require("interface/ETHInterface_" + builder.config.systemName + ".c")
  27. Gcc_PACKED
  28. struct ETHInterface_Header
  29. {
  30. /** ETHInterface_CURRENT_VERSION, no communication is possible with different versions. */
  31. uint8_t version;
  32. /** padding and for future use. */
  33. uint8_t zero;
  34. /** Length of the content (excluding header) */
  35. uint16_t length_be;
  36. /** Pad to align boundry, also magic. */
  37. uint16_t fc00_be;
  38. };
  39. #define ETHInterface_Header_SIZE 6
  40. Assert_compileTime(sizeof(struct ETHInterface_Header) == ETHInterface_Header_SIZE);
  41. /** The content of a Sockaddr emitted from ETHInterface. */
  42. struct ETHInterface_Sockaddr
  43. {
  44. struct Sockaddr generic;
  45. uint8_t mac[6];
  46. uint16_t zero;
  47. };
  48. #define ETHInterface_Sockaddr_SIZE 16
  49. Assert_compileTime(sizeof(struct ETHInterface_Sockaddr) == ETHInterface_Sockaddr_SIZE);
  50. #define ETHInterface_CURRENT_VERSION 0
  51. struct ETHInterface
  52. {
  53. struct AddrIface generic;
  54. };
  55. struct ETHInterface* ETHInterface_new(struct EventBase* eventBase,
  56. const char* bindDevice,
  57. struct Allocator* alloc,
  58. struct Except* exHandler,
  59. struct Log* logger);
  60. List* ETHInterface_listDevices(struct Allocator* alloc, struct Except* eh);
  61. #endif