aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/install/exception/ssh:/git@git.mageia.org/software
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/install/exception/ssh:/git@git.mageia.org/software')
0 files changed, 0 insertions, 0 deletions
'>43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
package network::monitor;

use common;
use dbus_object;

our @ISA = qw(dbus_object);

my $monitor_service = "org.mageia.monitoring";
my $monitor_path = "/org/mageia/monitoring/wireless";
my $monitor_interface = "org.mageia.monitoring.wireless";

sub new {
    my ($type, $bus) = @_;
    dbus_object::new($type, $bus, $monitor_service, $monitor_path, $monitor_interface);
}

sub list_wireless {
    my ($monitor, $o_intf) = @_;
    my ($results, $list, %networks);
    my $has_roaming;
    #- first try to use mandi
    eval {
        $results = $monitor->call_method('ScanResults');
        $list = $monitor->call_method('ListNetworks');
        $has_roaming = 1;
    } if $monitor;
    #- try wpa_cli if we're root
    if (!$has_roaming && !$>) {
        $results = `$::prefix/usr/sbin/wpa_cli scan_results 2>/dev/null`;
        $list = `$::prefix/usr/sbin/wpa_cli list_networks 2>/dev/null`;
        s/^Selected interface (.*)\n//g foreach $results, $list;
    }
    if ($results && $list) {
        #- bssid / frequency / signal level / flags / ssid
        while ($results =~ /^((?:[0-9a-f]{2}:){5}[0-9a-f]{2})\t(\d+)\t(\d+)\t(.*?)\t(.*)$/mg) {
            my ($ap, $frequency, $signal_strength, $flags, $essid) = ($1, $2, $3, $4, $5);
            $networks{$ap}{ap} ||= $ap;
            #- wpa_supplicant may list the network two times, use ||=
            $networks{$ap}{frequency} ||= $frequency;
            $networks{$ap}{signal_strength} ||= $signal_strength;
            my $adhoc = $flags =~ s/\[ibss\]//i;
            $networks{$ap}{mode} ||=  $adhoc ? "Ad-Hoc" : "Managed";
            $networks{$ap}{flags} ||= $flags;
            $networks{$ap}{essid} ||= $essid;
        }
        if (any { $_->{signal_strength} > 100 } values %networks) {
            #- signal level is really too high in wpa_supplicant
            #- this should be standardized at some point
            $_->{signal_strength} = int($_->{signal_strength}/3.5)
              foreach values %networks;
        }

        #- network id / ssid / bssid / flags
        while ($list =~ /^(\d+)\t(.*?)\t(.*?)\t(.*)$/mg) {