wakeonlan-0.41/0000755000076400007640000000000010176212761013032 5ustar jpojpo00000000000000wakeonlan-0.41/README0000644000076400007640000000643110176203460013712 0ustar jpojpo00000000000000 This is some premature documentation for this project. Feel free to contact with comments or additions. (good or bad) Jose Pedro Oliveira Ico Doornekamp 1. What is wakeonlan 2. How does it work ? 3. How is it implemented here ? 4. Known to work hardware 1. What is wakeonlan This script sends 'magic packets' to wake-on-lan enabled ethernet adapters, in order to switch on the called PC. 2. How does WOL work ? WOL is based on the following principle : When the PC shuts down, the NIC still gets power, and keeps listening on the network for a 'magic' packet to arrive. This packet must contain a certain byte-sequence, but can be encapsulated in any kind of packet (IPX, IP, anything). Take a look at the code for the magic sequence. This program uses UDP for sending the packet. The complete UDP packet, sent over an ethernet interface, looks something like this [ethernet header][IP header][UDP header][Magic sequence][CRCS] The only goal of the script is to send this packet over the network. It expects no returning data, since the NIC only listens, and does not reply anything. For a more detailed description of the protocol, see the whitepaper available in the followin AMD web page: http://www.amd.com/products/npd/overview/20212.html 3. How is it implemented here ? The scripts takes 2 arguments, the MAC-address of the NIC, and an IP address. The IP-address is tricky : For a NIC on your local subnet, use the broadcast-address of this subnet. (e.g. subnet 192.168.10.0 with netmask 255.255.255.0, use 192.168.10.255) For waking up a PC on a network behind one or more routers, some tricks must be used. When the routers forward directed subnet broadcasts, it is possible to use the broadcast address of the destination network. The problem is that many routers dont forward broadcast packets, so the packet will never arrive at the network. It is possible to send the packet to the remote net however, by sending it to the IP address of another host on that network that's alive at that moment. The remote hosts will probably ignore the packet, but it has been seen by the listening NIC that's also on the same subnet, and it will turn on the computer... Feel free to experiment on this. 4. Known-to-work hardware : - 3Com 3c905B Cyclone 100baseTx on an Abit BP6 Motherboard (Ico Doornekamp) - Intel EtherExpress Pro (i82557 with management chip built onto an IBM IntelliStation motherboard (Sean-Paul Rees) - Intel EtherExpress PRO/100+ (chipset 82559) with a PXE boot agent on an ASUS P2B motherboard (Jose Pedro Oliveira) - Motherboard: ASUS TUSL2-C BIOS: Award BIOS / Power / Power Up Control / Wake On LAN or PCI Modem [Enable] Network card: Intel Pro/100 S Desktop Adapter (chipset 82550) with PXE boot agent v4.0.22 (José Pedro Oliveira) - Motherboard: ASUS TUSL2-C BIOS: Award BIOS / Power / Power Up Control / Wake On LAN or PCI Modem [Enable] Network card: 3Com Fast Etherlink TX 10/100 PCI (3C905C-TXM) with Managed PC Boot Agent (MBA) v4.30 (build 3) Pre-boot eXecution Environment (PXE) v2.20 (José Pedro Oliveira) - nVidia Corporation nForce2 Ethernet Controller on ASUS and EPOX motherboards. (Antoniu-George) - Macs: Al Powerbook. Energy Prefs: Wake on ethernet network Administrator access (Denis Ahrens) wakeonlan-0.41/Makefile.PL0000644000076400007640000000067707272671757015037 0ustar jpojpo00000000000000use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'wakeonlan', 'VERSION_FROM' => 'wakeonlan', # finds $VERSION 'EXE_FILES' => [wakeonlan], ($] ge '5.005') ? ( 'AUTHOR' => 'Jose Pedro Oliveira (jpo@di.uminho.pt)', 'ABSTRACT' => "Script to send 'magic packets' to wakeable computers" ) : ( ), ); # vim:set ai ts=4 sw=4: wakeonlan-0.41/META.yml0000644000076400007640000000044710176212760014307 0ustar jpojpo00000000000000# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: wakeonlan version: 0.41 version_from: wakeonlan installdirs: site requires: distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 wakeonlan-0.41/SIGNATURE0000644000076400007640000000214010176212627014314 0ustar jpojpo00000000000000This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.44. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 d0aef405a4cd9014c7282def045be4bdaf2dc989 Changes SHA1 03b1ea4280c6d0f1f0f8b06990be3271e1f26009 MANIFEST SHA1 ccae8de92a2cd8bc7403e217532cf6e188a4f5d7 META.yml SHA1 9b72a0a4867ec107e298f19570dd44f41c94e13b Makefile.PL SHA1 2efea729ee31a6665a0fddcf30c406d469125c90 README SHA1 5d6930f66f58bf33c01de1e4760c2eed6c33170d examples/lab001.wol SHA1 03d093883fb557e4e2272600167c02a07f5768ce wakeonlan -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQFB+RWXl0metZG9hRsRAudSAJ9zr//9ZzFks59rtjtEht8msX1whQCg7jLL 5MXJHe/j/TYIX4onAByFDKk= =NCeu -----END PGP SIGNATURE----- wakeonlan-0.41/Changes0000644000076400007640000000321110176205212014313 0ustar jpojpo00000000000000Revision history for Perl script wakeonlan. 0.10 2000-04-19 ico@edd.dhs.org - Inital release. This works for me... - Tested with 3Com 3c905B Cyclone 100baseTx 0.20 2000-04-23 ico@edd.dhs.org - Major bugfix. When the called system is not known in the ARP-table, no packets are sent. Solved by allowing broadcast-addresses. Use broadcast address as IP and all should work.... (Thanks to Egon Kastelijn for making the problem clear to me ) 0.30 2000-07-01 ico@edd.dhs.org - Some cleaning done by Jose Pedro Oliveira : 1. Forced variable declaration with the pragma 'use strict' 2. Removed the bind call (we don't expect to receive any reply) 3. Simplified the packet generation 0.31 2000-07-17 ico@edd.dhs.org - Changes made by Jose Pedro Oliveira 1. Changed the destination port from the echo (7) to the discard port (9) in order to avoid the reply from an awaken computer with an active echo service. 2. Removed variables $laddr and $me 3. Closed the socket 4. Added the variable $VERSION 5. Added a link in the README file of the Whitepaper subdirectory - Other changes : 6. Completer checks for valid HW-address (Ico Doornekamp) 7. Fixed wrong return value on 'die' (Oliver Jones) 0.32 2000-07-23 jpo@di.uminho.pt - created by h2xs 1.19 ($ h2xs -A -X -n wakeonlan) - not released 0.40 2000-08-01 jpo@di.uminho.pt - New command line parameters - Ability to load ethernet addresses from file 0.41 2005-01-27 jpo@di.uminho.pt - Minor documentation updates (including several typo corrections). # vim:set ai ts=4 sw=4: wakeonlan-0.41/MANIFEST0000644000076400007640000000023310176211167014160 0ustar jpojpo00000000000000Changes Makefile.PL MANIFEST README wakeonlan examples/lab001.wol META.yml Module meta-data (added by MakeMaker) SIGNATURE wakeonlan-0.41/examples/0000755000076400007640000000000010176212761014650 5ustar jpojpo00000000000000wakeonlan-0.41/examples/lab001.wol0000644000076400007640000000114210176174067016356 0ustar jpojpo00000000000000# # This an example of a text file containing hardware addresses # # File structure # -------------- # - blank lines are ignored # - comment lines are ignored (lines starting with a hash mark '#') # - other lines are considered valid records and can have 3 columns: # # Hardware address, IP address, destination port # # the last two are optional, in which case the following defaults # are used: # # IP address: 255.255.255.255 (the limited broadcast address) # port: 9 (the discard port) # 01:02:03:04:05:06 192.168.1.255 9 07:09:09:0A:0B:0C 255.255.255.255 0D:0E:0F:00:10:11 wakeonlan-0.41/wakeonlan0000755000076400007640000001215710176210352014737 0ustar jpojpo00000000000000#!/usr/bin/perl -w # # $Id: wakeonlan,v 1.4.2.3 2005/01/27 16:03:54 jpo Exp $ # ######################################################################### use strict; use Socket; use Getopt::Std; use vars qw($VERSION $opt_v $opt_h $opt_i $opt_p $opt_f); $VERSION = '0.41'; my $DEFAULT_IP = '255.255.255.255'; my $DEFAULT_PORT = getservbyname('discard', 'udp'); # # Process the command line # getopts("hvp:i:f:"); if ($opt_h) { usage(); exit(0); } if ($opt_v) { print "wakeonlan version $VERSION\n"; exit(0); } if (!$opt_f and !@ARGV) { usage(); exit(0); } if ($opt_i) { $DEFAULT_IP = $opt_i; } # override default value if ($opt_p) { $DEFAULT_PORT = $opt_p; } # override default value if ($opt_f) { process_file($opt_f); } # The rest of the command line is a list of hardware addresses foreach (@ARGV) { wake($_, $opt_i, $opt_p); } # # wake # # The 'magic packet' consists of 6 times 0xFF followed by 16 times # the hardware address of the NIC. This sequence can be encapsulated # in any kind of packet, in this case an UDP packet targeted at the # discard port (9). # sub wake { my $hwaddr = shift; my $ipaddr = shift || $DEFAULT_IP; my $port = shift || $DEFAULT_PORT; my ($raddr, $them, $proto); my ($hwaddr_re, $pkt); # Validate hardware address (ethernet address) $hwaddr_re = join(':', ('[0-9A-Fa-f]{1,2}') x 6); if ($hwaddr !~ m/^$hwaddr_re$/) { warn "Invalid hardware address: $hwaddr\n"; return undef; } # Generate magic sequence foreach (split /:/, $hwaddr) { $pkt .= chr(hex($_)); } $pkt = chr(0xFF) x 6 . $pkt x 16; # Allocate socket and send packet $raddr = gethostbyname($ipaddr); $them = pack_sockaddr_in($port, $raddr); $proto = getprotobyname('udp'); socket(S, AF_INET, SOCK_DGRAM, $proto) or die "socket : $!"; setsockopt(S, SOL_SOCKET, SO_BROADCAST, 1) or die "setsockopt : $!"; print "Sending magic packet to $ipaddr:$port with $hwaddr\n"; send(S, $pkt, 0, $them) or die "send : $!"; close S; } # # process_file # sub process_file { my $filename = shift; my ($hwaddr, $ipaddr, $port); open (F, "<$filename") or die "open : $!"; while() { next if /^\s*#/; # ignore comments next if /^\s*$/; # ignore empty lines chomp; ($hwaddr, $ipaddr, $port) = split; wake($hwaddr, $ipaddr, $port); } close F; } # # Usage # sub usage { print <<__USAGE__; Usage wakeonlan [-h] [-v] [-i IP_address] [-p port] [-f file] [[hardware_address] ...] Options -h this information -v displays the script version -i ip_address set the destination IP address default: 255.255.255.255 (the limited broadcast address) -p port set the destination port default: 9 (the discard port) -f file uses file as a source of hardware addresses See also wakeonlan(1) __USAGE__ } __END__ # Script documentation =head1 NAME wakeonlan - Perl script to wake up computers =head1 SYNOPSIS wakeonlan [-h] [-v] [-i IP_address] [-p port] [-f file] [[hardware_address] ...] =head1 DESCRIPTION This script sends 'magic packets' to wake-on-lan enabled ethernet adapters and motherboards, in order to switch on the called PC. Be sure to connect the NIC with the motherboard if neccesary, and enable the WOL function in the BIOS. The 'magic packet' consists of 6 times 0xFF followed by 16 times the hardware address of the NIC. This sequence can be encapsulated in any kind of packet. This script uses UDP packets. =head1 OPTIONS =over =item B<-h> Displays the help information. =item B<-v> Displays the script version. =item B<-i ip_address> Destination IP address. Unless you have static ARP tables you should use some kind of broadcast address (the broadcast address of the network where the computer resides or the limited broadcast address). Default: 255.255.255.255 (the limited broadcast address). =item B<-p port> Destination port. Default: 9 (the discard port). =item B<-f file> File with hardware addresses of wakeable computers. For an example check the file lab001.wol in the examples subdirectory. =back =head1 EXAMPLES Using the limited broadcast address (255.255.255.255): $ wakeonlan 01:02:03:04:05:06 $ wakeonlan 01:02:03:04:05:06 01:02:03:04:05:07 Using a subnet broadcast address: $ wakeonlan -i 192.168.1.255 01:02:03:04:05:06 Using another destination port: $ wakeonlan -i 192.168.1.255 -p 1234 01:02:03:04:05:06 Using a file as source of hardware and IP addresses: $ wakeonlan -f examples/lab001.wol $ wakeonlan -f examples/lab001.wol 01:02:03:04:05:06 =head1 AUTHOR José Pedro Oliveira maintaining and expanding original work done by Ico Doornekamp . =head1 COPYRIGHT Copyright (c) 2000-2005 José Pedro Oliveira. This is free software. You may modify it and distribute it under Perl's Artistic Licence. Modified versions must be clearly indicated. =head1 SEE ALSO For more information regarding this script and Wakeonlan technology just check the following address http://gsd.di.uminho.pt/jpo/software/wakeonlan/. =cut