wol.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * wol - Wake-on-LAN
  4. *
  5. * Supports both Wake-on-LAN packet types:
  6. * - EtherType 0x0842 packets
  7. * - UDP packets on ports 0, 7 and 9.
  8. *
  9. * Copyright 2018 Lothar Felten, lothar.felten@gmail.com
  10. */
  11. #if defined(CONFIG_CMD_WOL)
  12. #ifndef __WOL_H__
  13. #define __WOL_H__
  14. #include <net.h>
  15. /**********************************************************************/
  16. #define WOL_SYNC_BYTE 0xFF
  17. #define WOL_SYNC_COUNT 6
  18. #define WOL_MAC_REPETITIONS 16
  19. #define WOL_DEFAULT_TIMEOUT 5000
  20. #define WOL_PASSWORD_4B 4
  21. #define WOL_PASSWORD_6B 6
  22. /*
  23. * Wake-on-LAN header
  24. */
  25. struct wol_hdr {
  26. u8 wol_sync[WOL_SYNC_COUNT]; /* sync bytes */
  27. u8 wol_dest[WOL_MAC_REPETITIONS * ARP_HLEN]; /* 16x MAC */
  28. u8 wol_passwd[0]; /* optional */
  29. };
  30. /*
  31. * Initialize wol (beginning of netloop)
  32. */
  33. void wol_start(void);
  34. /*
  35. * Check incoming Wake-on-LAN packet for:
  36. * - sync bytes
  37. * - sixteen copies of the target MAC address
  38. *
  39. * Optionally store the four or six byte password in the environment
  40. * variable "wolpassword"
  41. *
  42. * @param ip IP header in the packet
  43. * @param len Packet length
  44. */
  45. void wol_receive(struct ip_udp_hdr *ip, unsigned int len);
  46. /*
  47. * Set the timeout for the reception of a Wake-on-LAN packet
  48. *
  49. * @param timeout in milliseconds
  50. */
  51. void wol_set_timeout(ulong timeout);
  52. /**********************************************************************/
  53. #endif /* __WOL_H__ */
  54. #endif