blob: ebc81f24b6e53658333c8e5f507e165f5f07b5b1 [file] [log] [blame]
Lothar Feltend8970da2018-06-22 22:29:54 +02001/* 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
12#if defined(CONFIG_CMD_WOL)
13
14#ifndef __WOL_H__
15#define __WOL_H__
16
17#include <net.h>
18
19/**********************************************************************/
20
21#define WOL_SYNC_BYTE 0xFF
22#define WOL_SYNC_COUNT 6
23#define WOL_MAC_REPETITIONS 16
24#define WOL_DEFAULT_TIMEOUT 5000
25#define WOL_PASSWORD_4B 4
26#define WOL_PASSWORD_6B 6
27
28/*
29 * Wake-on-LAN header
30 */
31struct wol_hdr {
32 u8 wol_sync[WOL_SYNC_COUNT]; /* sync bytes */
33 u8 wol_dest[WOL_MAC_REPETITIONS * ARP_HLEN]; /* 16x MAC */
34 u8 wol_passwd[0]; /* optional */
35};
36
37/*
38 * Initialize wol (beginning of netloop)
39 */
40void wol_start(void);
41
42/*
43 * Check incoming Wake-on-LAN packet for:
44 * - sync bytes
45 * - sixteen copies of the target MAC address
46 *
47 * Optionally store the four or six byte password in the environment
48 * variable "wolpassword"
49 *
50 * @param ip IP header in the packet
51 * @param len Packet length
52 */
53void wol_receive(struct ip_udp_hdr *ip, unsigned int len);
54
55/*
56 * Set the timeout for the reception of a Wake-on-LAN packet
57 *
58 * @param timeout in milliseconds
59 */
60void wol_set_timeout(ulong timeout);
61
62/**********************************************************************/
63
64#endif /* __WOL_H__ */
65#endif