package H1::Davolink;
use warnings;
use strict;

use Net::Telnet;

sub info {
	my ( $self, $ip ) = @_;

	my $telnet = new Net::Telnet (Telnetmode => 1);
	$telnet->open(Host => $ip,Port => 23);
	$telnet->login('support','support');

	my $rec;

	foreach my $line ( $telnet->cmd("adsl info --show") ) {
		chomp $line;
		if ( $line =~ /^([^:]+):\s+(\S+)\s+(\S+)\s*$/ ) {
			my $name = $1;
			my ( $down, $up ) = ( $2,$3 );
			$name =~ s/\s*\(.+?\)//g;
			$name =~ s/\s+/_/g;

			$rec->{"${name}_down"} = $down;
			$rec->{"${name}_up"}   = $up;
			warn "## $line\n";
		} else {
			warn "#S $line\n";
		}
	}
        foreach my $line ( $telnet->cmd("ifconfig br0") ) {
		chomp $line;
		if ($line=~/^br0.*/) {
			my ($mac) = ($line=~/^br0.*HWaddr\s(\S+)/);
			$rec->{"MAC"} = $mac;
		}
	}
	return $rec;
}

1;
