diff options
author | Lothar Felten <lothar.felten@gmail.com> | 2018-06-22 22:29:54 +0200 |
---|---|---|
committer | Joe Hershberger <joe.hershberger@ni.com> | 2018-07-02 14:14:20 -0500 |
commit | d8970dae276377a0beff1c3e9d8b6f805ecf5cd5 (patch) | |
tree | eb3fdb9ef7d734fbca0d0a92ddd30915c52ba44a /net/net.c | |
parent | 318b5d76b6661dcaf6934b0a925bbcfdf0469069 (diff) |
net: Add new wol command - Wake on LAN
Add a new command 'wol': Wait for an incoming Wake-on-LAN packet or
time out if no WoL packed is received.
If the WoL packet contains a password, it is saved in the environment
variable 'wolpassword' using the etherwake format (dot or colon
separated decimals).
Intended use case: a networked device should boot an alternate image.
It's attached to a network on a client site, modifying the DHCP server
configuration or setup of a tftp server is not allowed.
After power on the device waits a few seconds for a WoL packet. If a
packet is received, the device boots the alternate image. Otherwise
it boots the default image.
This method is a simple way to interact with a system via network even
if only the MAC address is known. Tools to send WoL packets are
available on all common platforms.
Some Ethernet drivers seem to pad the incoming packet. The additional
padding bytes might be recognized as Wake-on-LAN password bytes.
By default enabled in pengwyn_defconfig.
Signed-off-by: Lothar Felten <lothar.felten@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'net/net.c')
-rw-r--r-- | net/net.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -78,6 +78,12 @@ * - own IP address * We want: - network time * Next step: none + * + * WOL: + * + * Prerequisites: - own ethernet address + * We want: - magic packet or timeout + * Next step: none */ @@ -108,6 +114,9 @@ #if defined(CONFIG_CMD_SNTP) #include "sntp.h" #endif +#if defined(CONFIG_CMD_WOL) +#include "wol.h" +#endif /** BOOTP EXTENTIONS **/ @@ -515,6 +524,11 @@ restart: link_local_start(); break; #endif +#if defined(CONFIG_CMD_WOL) + case WOL: + wol_start(); + break; +#endif default: break; } @@ -1281,6 +1295,11 @@ void net_process_received_packet(uchar *in_packet, int len) ntohs(ip->udp_src), ntohs(ip->udp_len) - UDP_HDR_SIZE); break; +#ifdef CONFIG_CMD_WOL + case PROT_WOL: + wol_receive(ip, len); + break; +#endif } } |