From 2fc53b15b49e3761897f4b56e1b2f9c49830a445 Mon Sep 17 00:00:00 2001 From: ms Date: Wed, 22 Aug 2007 18:35:37 +0000 Subject: [PATCH] Connectionstatus-Funktion ueberarbeitet. git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@804 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- config/cfgroot/header.pl | 108 ++++----------------------------------- 1 file changed, 10 insertions(+), 98 deletions(-) diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index 0d775f0e1..a3949cba3 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -308,7 +308,7 @@ sub cleanhtml $outstring =~ tr/,/ / if not defined $_[1] or $_[1] ne 'y'; $outstring =~ s/&/&/g; $outstring =~ s/\'/'/g; - $outstring =~ s/\"/"/g; + $outstring =~ s/\"/"/g; #" This is just a workaround for the syntax highlighter $outstring =~ s//>/g; return $outstring; @@ -325,113 +325,25 @@ sub connectionstatus &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); my $profileused=''; - if ( ! ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) { + unless ( $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) { $profileused="- $pppsettings{'PROFILENAME'}"; } - if ( ( $pppsettings{'METHOD'} eq 'DHCP' && $netsettings{'RED_TYPE'} ne 'PPTP') - || $netsettings{'RED_TYPE'} eq 'DHCP' ) { - if (open(IFACE, "${General::swroot}/red/iface")) { - $iface = ; - close IFACE; - chomp ($iface); - $iface =~ /([a-zA-Z0-9]*)/; $iface = $1; - } - } - my ($timestr, $connstate); - if ($netsettings{'CONFIG_TYPE'} =~ /^(0|1|2|3|4)$/ && $pppsettings{'TYPE'} =~ /^isdn/) { - # Count ISDN channels - my ($idmap, $chmap, $drmap, $usage, $flags, $phone); - my @phonenumbers; - my $count=0; - open (FILE, "/dev/isdninfo"); + my $connstate = "$Lang::tr{'idle'} $profileused"; - $idmap = ; chop $idmap; - $chmap = ; chop $chmap; - $drmap = ; chop $drmap; - $usage = ; chop $usage; - $flags = ; chop $flags; - $phone = ; chop $phone; - - $phone =~ s/^phone(\s*):(\s*)//; - - @phonenumbers = split / /, $phone; - - foreach (@phonenumbers) { - if ($_ ne '???') { - $count++; - } - } - close (FILE); - - ## Connection status - my $number; - if ($count == 0) { - $number = 'none!'; - } elsif ($count == 1) { - $number = 'single'; - } else { - $number = 'dual'; - } - - if (-e "${General::swroot}/red/active") { - $timestr = &General::age("${General::swroot}/red/active"); - $connstate = "$Lang::tr{'connected'} - $number channel ($timestr) $profileused"; - } else { - if ($count == 0) { - if (-e "${General::swroot}/red/dial-on-demand") { + if (-e "${General::swroot}/red/active") { + $timestr = &General::age("${General::swroot}/red/active"); + $connstate = "$Lang::tr{'connected'} - ($timestr) $profileused"; + } else { + if (($pppsettings{'RECONNECTION'} eq "dialondemand") && ( -e "${General::swroot}/red/dial-on-demand")) { $connstate = "$Lang::tr{'dod waiting'} $profileused"; } else { - $connstate = "$Lang::tr{'idle'} $profileused"; + $connstate = "$Lang::tr{'connecting'} $profileused" if (system("ps -ef | grep -q '[p]ppd'")); } - } else { - $connstate = "$Lang::tr{'connecting'} $profileused"; } - } - } elsif ($netsettings{'RED_TYPE'} eq "STATIC" || $pppsettings {'METHOD'} eq 'STATIC') { - if (-e "${General::swroot}/red/active") { - $timestr = &General::age("${General::swroot}/red/active"); - $connstate = "$Lang::tr{'connected'} ($timestr) $profileused"; - } else { - $connstate = "$Lang::tr{'idle'} $profileused"; - } - } elsif ( ( (-e "${General::swroot}/dhcpc/dhcpcd-$iface.pid") && $netsettings{'RED_TYPE'} ne 'PPTP' ) || - !system("/bin/ps -ef | /bin/grep -q '[p]ppd'") || !system("/bin/ps -ef | /bin/grep -q '[c]onnectioncheck'")) { - if (-e "${General::swroot}/red/active") { - $timestr = &General::age("${General::swroot}/red/active"); - if ($pppsettings{'TYPE'} =~ /^(modem|bewanadsl|conexantpciadsl|eagleusbadsl)$/) { - my $speed; - if ($pppsettings{'TYPE'} eq 'modem') { - open(CONNECTLOG, "/var/log/connect.log"); - while () { - if (/CONNECT/) { - $speed = (split / /)[6]; - } - } - close (CONNECTLOG); - } elsif ($pppsettings{'TYPE'} eq 'bewanadsl') { - $speed = `/usr/bin/unicorn_status | /bin/grep Rate | /usr/bin/cut -f2 -d ':'`; - } elsif ($pppsettings{'TYPE'} eq 'conexantpciadsl') { - $speed = `/bin/cat /proc/net/atm/CnxAdsl:* | /bin/grep 'Line Rates' | /bin/sed -e 's+Line Rates: Receive+Rx+' -e 's+Transmit+Tx+'`; - } elsif ($pppsettings{'TYPE'} eq 'eagleusbadsl') { - $speed = `/usr/sbin/eaglestat | /bin/grep Rate`; - } - $connstate = "$Lang::tr{'connected'} ($timestr) $profileused (\@$speed)"; - } else { - $connstate = "$Lang::tr{'connected'} ($timestr) $profileused"; - } - } else { - if (-e "${General::swroot}/red/dial-on-demand") { - $connstate = "$Lang::tr{'dod waiting'} $profileused"; - } else { - $connstate = "$Lang::tr{'connecting'} $profileused"; - } - } - } else { - $connstate = "$Lang::tr{'idle'} $profileused"; - } + return $connstate; }