Date: Tue, 18 Sep 2012 13:28:50 GMT From: Stephen Workman <workman.stephen@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/171744: [PATCH] Fix wake command not sending proper WOL packet Message-ID: <201209181328.q8IDSow0048866@red.freebsd.org> Resent-Message-ID: <201209181330.q8IDUAkf026839@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 171744 >Category: misc >Synopsis: [PATCH] Fix wake command not sending proper WOL packet >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Sep 18 13:30:10 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Stephen Workman >Release: FreeBSD 9.0-RELEASE-p3 >Organization: >Environment: FreeBSD DarkTower 9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Tue Jun 12 02:52:29 UTC 2012 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64 >Description: The current version of the wake command (/usr/sbin/wake) sends an improperly formatted WOL packet. It is "improper" due to the fact that it sends to the broadcast address of ff:ff:ff:ff:ff:ff instead of the address(es) specified on the command line. Because of this, the packet never makes it to the target host and thus, does not wake up the "sleeping" target. I believe, in my case, the packet isn't even leaving the FreeBSD host. >How-To-Repeat: Run tcpdump on the target host: (tcpdump -i <IF> -nne not tcp and not udp and not icmp) - or use Wireshark on a Windows host. Use "wake" to send a WOL packet to the target's MAC address (e.g.: wake xl0 00:11:22:33:44:55) The packet will not be received on the target. >Fix: Send the packet to the target MAC address instead of the broadcast MAC. The patch I have attached makes this change. I have tested it, and it works as expected. Additionally, I have modified the ether_type value to use 0x0842 as this is recognized by tools such as Wireshark and is also used by some other WOL utilities. Also, emits a message to the screen when it sends a packet. Patch attached with submission follows: --- /usr/src/usr.sbin/wake/wake.c 2012-01-02 22:25:54.000000000 -0500 +++ wake.c 2012-09-18 08:23:32.000000000 -0400 @@ -160,8 +160,18 @@ ssize_t len; int i; - (void)memset(pkt.hdr.ether_dhost, 0xff, sizeof(pkt.hdr.ether_dhost)); - pkt.hdr.ether_type = htons(0); + /* Be useful */ + printf("Sending magic packet to "); + for(i = 0; i < ETHER_ADDR_LEN - 1; i++) + printf("%.2X:", addr->octet[i]); + printf("%.2X\n", addr->octet[ETHER_ADDR_LEN-1]); + + /* The packet MUST be sent to the target MAC address */ + memcpy(pkt.hdr.ether_dhost, addr, ETHER_ADDR_LEN); + + /* EtherType 0x0842 is at least semi-recognizable for WOL */ + pkt.hdr.ether_type = htons(0x0842); + (void)memset(pkt.data, 0xff, SYNC_LEN); for (p = pkt.data + SYNC_LEN, i = 0; i < DESTADDR_COUNT; p += ETHER_ADDR_LEN, i++) >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209181328.q8IDSow0048866>