/[Intel-AMT]/trunk/lib/Intel/AMT/Redir.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

Annotation of /trunk/lib/Intel/AMT/Redir.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations)
Sun Aug 9 12:03:19 2009 UTC (14 years, 10 months ago) by dpavlin
File size: 1074 byte(s)
begin work on SOL redirection

1 dpavlin 8 package Intel::AMT::Redir;
2    
3     use warnings;
4     use strict;
5    
6     use IO::Socket::INET;
7     use Data::Dump qw/dump/;
8    
9     sub hdump {
10     my $data = shift;
11     my $out = unpack('H*', $data),$/;
12     $out =~ s/(..)/$1 /g;
13     warn $out,$/;
14     }
15    
16     our $sock;
17    
18     sub connect {
19     my ( $host ) = shift;
20     my $port = 16994;
21    
22     my $user = 'admin';
23     my $passwd = $ENV{AMT_PASSWORD};
24    
25     warn 'connect ', $host, ':', $port;
26    
27     $sock = IO::Socket::INET->new(
28     PeerAddr => $host,
29     PeerPort => $port,
30     );
31    
32     $sock->autoflush(1);
33    
34     put( pack('C4A4', 0x10, 0, 0, 0, "SOL ") );
35     get( 0x11, 13 );
36    
37     my $credentials = pack('CA*CA*', length($user), $user, length($passwd), $passwd);
38    
39     put( pack('C9', 0x13, 0, 0, 0, 0x01, length($credentials), 0, 0, 0) . $credentials );
40     get( 0x14, 9 );
41    
42     }
43    
44     sub put {
45     my ( $data ) = shift;
46     hdump $data;
47     syswrite $sock, $data, length($data);
48     }
49    
50     sub get {
51     my ( $expect, $len ) = @_;
52    
53     my $reply;
54     sysread $sock,$reply,$len;
55     hdump $reply;
56    
57     my ( $op, $error ) = unpack('CC', $reply);
58     die "expected $expect got $op" unless $op == $expect;
59     die "error" unless $error == 0x00;
60    
61     return $reply;
62     }
63    
64     1;
65    

  ViewVC Help
Powered by ViewVC 1.1.26