/[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 296 by dpavlin, Wed Aug 26 11:42:33 2009 UTC revision 297 by dpavlin, Wed Aug 26 12:43:47 2009 UTC
# Line 7  use IO::Socket::INET; Line 7  use IO::Socket::INET;
7  use Regexp::Common qw/net/;  use Regexp::Common qw/net/;
8    
9  use client;  use client;
10    use server;
11    
12  sub power_on {  sub power_on {
13          my $target = shift;          my $target = shift;
14    
15          my ( $port, $mac, $ip ) = ( 9 );          my ( $port, $mac ) = ( 9 );
16    
17          if ( $target =~ m/$RE{net}{MAC}{-keep}/ ) {          if ( $target =~ m/$RE{net}{MAC}{-keep}/ ) {
18                  $mac = $1;                  $mac = $1;
                 $ip  = client::ip_from_mac $1;  
19          } elsif ( $target =~ m/$RE{net}{IPv4}{-keep}/ ) {          } elsif ( $target =~ m/$RE{net}{IPv4}{-keep}/ ) {
                 $ip  = $1;  
20                  $mac = client::mac_from_ip $1;                  $mac = client::mac_from_ip $1;
21          } else {          } else {
22                  die "$target isn't IP or MAC";                  die "$target isn't IP or MAC";
23          }          }
24    
25          warn "# power_on $ip $mac";          warn "# power_on $mac";
26    
27          my $sock = IO::Socket::INET->new( Proto=>'udp' );          my $sock = IO::Socket::INET->new( Proto=>'udp' );
28          my $ip_addr = inet_aton($ip);          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.296  
changed lines
  Added in v.297

  ViewVC Help
Powered by ViewVC 1.1.26