/[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

Diff of /lib/PXElator/wol.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 295 by dpavlin, Wed Aug 26 10:21:44 2009 UTC revision 296 by dpavlin, Wed Aug 26 11:42:33 2009 UTC
# Line 4  use warnings; Line 4  use warnings;
4  use strict;  use strict;
5    
6  use IO::Socket::INET;  use IO::Socket::INET;
7    use Regexp::Common qw/net/;
8    
9    use client;
10    
11  sub power_on {  sub power_on {
12          my ($mac,$host,$port) = @_;          my $target = shift;
13    
14            my ( $port, $mac, $ip ) = ( 9 );
15    
16            if ( $target =~ m/$RE{net}{MAC}{-keep}/ ) {
17                    $mac = $1;
18                    $ip  = client::ip_from_mac $1;
19            } elsif ( $target =~ m/$RE{net}{IPv4}{-keep}/ ) {
20                    $ip  = $1;
21                    $mac = client::mac_from_ip $1;
22            } else {
23                    die "$target isn't IP or MAC";
24            }
25    
26          $mac  ||= 'FF:FF:FF:FF:FF:FF';          warn "# power_on $ip $mac";
         $host ||= '255.255.255.255';  
         $port ||= 9;    # discard  
27    
28          my $sock = IO::Socket::INET->new( Proto=>'udp' );          my $sock = IO::Socket::INET->new( Proto=>'udp' );
29          my $ip_addr = inet_aton($host);          my $ip_addr = inet_aton($ip);
30          my $sock_addr = sockaddr_in($port, $ip_addr);          my $sock_addr = sockaddr_in($port, $ip_addr);
31          $mac =~ s{:}{}g;          $mac =~ s{:}{}g;
32    

Legend:
Removed from v.295  
changed lines
  Added in v.296

  ViewVC Help
Powered by ViewVC 1.1.26