/[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 297 by dpavlin, Wed Aug 26 12:43:47 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    use server;
11    
12  sub power_on {  sub power_on {
13          my ($mac,$host,$port) = @_;          my $target = shift;
14    
15            my ( $port, $mac ) = ( 9 );
16    
17            if ( $target =~ m/$RE{net}{MAC}{-keep}/ ) {
18                    $mac = $1;
19            } elsif ( $target =~ m/$RE{net}{IPv4}{-keep}/ ) {
20                    $mac = client::mac_from_ip $1;
21            } else {
22                    die "$target isn't IP or MAC";
23            }
24    
25          $mac  ||= 'FF:FF:FF:FF:FF:FF';          warn "# power_on $mac";
         $host ||= '255.255.255.255';  
         $port ||= 9;    # discard  
26    
27          my $sock = IO::Socket::INET->new( Proto=>'udp' );          my $sock = IO::Socket::INET->new( Proto=>'udp' );
28          my $ip_addr = inet_aton($host);          my $ip_addr = inet_aton($server::bcast);
29          my $sock_addr = sockaddr_in($port, $ip_addr);          my $sock_addr = sockaddr_in($port, $ip_addr);
30          $mac =~ s{:}{}g;          $mac =~ s{:}{}g;
31    

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

  ViewVC Help
Powered by ViewVC 1.1.26