/[pxelator]/lib/PXElator/wol.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/PXElator/wol.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 295 - (show annotations)
Wed Aug 26 10:21:44 2009 UTC (14 years, 8 months ago) by dpavlin
File size: 531 byte(s)
skeleton for wake on lan

1 package wol;
2
3 use warnings;
4 use strict;
5
6 use IO::Socket::INET;
7
8 sub power_on {
9 my ($mac,$host,$port) = @_;
10
11 $mac ||= 'FF:FF:FF:FF:FF:FF';
12 $host ||= '255.255.255.255';
13 $port ||= 9; # discard
14
15 my $sock = IO::Socket::INET->new( Proto=>'udp' );
16 my $ip_addr = inet_aton($host);
17 my $sock_addr = sockaddr_in($port, $ip_addr);
18 $mac =~ s{:}{}g;
19
20 my $packet = pack('C6H*', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, $mac x 16);
21
22 setsockopt($sock, SOL_SOCKET, SO_BROADCAST, 1);
23 send($sock, $packet, 0, $sock_addr);
24 close ($sock);
25 }
26
27 1;

  ViewVC Help
Powered by ViewVC 1.1.26