File: listchan-bsd.pl

package info (click to toggle)
kismet 2008-05-R1-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,232 kB
  • ctags: 3,998
  • sloc: cpp: 33,568; sh: 5,544; ansic: 459; makefile: 457; perl: 62; sql: 41
file content (23 lines) | stat: -rwxr-xr-x 572 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl -w
use strict;
use warnings;

my $device = shift or die "No device specified\n";

my @channels = ();

# Set the device to have no channel and automatically mode itself
# Otherwise, we only get A or B channels, depending on the last mode
# used on the device.

system("ifconfig $device -chan mode auto");

for my $chan (1 .. 255) {
	open (my $conf, "ifconfig 2>&1 $device chan $chan|");
        my $out = do { local $/ ; <$conf>};
	next if $out =~ /SIOCS80211CHANNEL: Invalid argument/;
        push @channels, $chan;
}

print join(q{,}, @channels), "\n";