--- /usr/local/sbin/wifind Tue Oct 17 12:43:52 2017
+++ bin/wifind Mon Nov 20 14:28:24 2017
@@ -34,7 +34,6 @@
my $ifconfig = '/sbin/ifconfig';
my $head = "-chan -bssid -wpakey\n";
my $global_opts = "";
-my $tail = "dhcp\n";
sub slurp
{
@@ -48,7 +47,7 @@
sub write_hostname_if
{
- my ($if, $ap) = @_;
+ my ($if, $trunk, $ap) = @_;
my $hostname_if = "/etc/hostname.$if";
my $hostname_orig = "$hostname_if.orig";
@@ -61,11 +60,16 @@
printf {$tmp_fh} ' chan "%s"', $ap->{chan} if $ap->{chan};
printf {$tmp_fh} ' lladdr "%s"', $ap->{lladdr} if $ap->{lladdr};
printf {$tmp_fh} ' media %s', $ap->{media} if $ap->{media};
- printf {$tmp_fh} ' description "%s"', $ap->{description} if $ap->{description};
+ printf {$tmp_fh} ' description "%s"', $ap->{description} if
+ $ap->{description};
print {$tmp_fh} "\n";
# wpa needs to be set after nwid
printf {$tmp_fh} "wpakey \"%s\"\n", $ap->{wpakey} if $ap->{wpakey};
- print {$tmp_fh} $tail;
+ printf {$tmp_fh} "wpa wpaakms \"%s\"\n", $ap->{wpaakms} if
+ $ap->{wpaakms};
+ print {$tmp_fh} "up\n";
+ printf {$tmp_fh} "!%s\n", $ap->{command} if $ap->{command};
+ print {$tmp_fh} "dhcp\n" if not defined $trunk;
close $tmp_fh;
# backup hostname.if before overwriting
@@ -88,13 +92,14 @@
my $wlan = $conf->{wlan};
my $if = $conf->{if};
$global_opts = $conf->{global_opts} if $conf->{global_opts};
+my $trunk = $conf->{trunk} if $conf->{trunk};
# initial scan
open L, '-|', $ifconfig, $if, 'scan' or die "Can't open pipe: $!";
pledge(qw( rpath wpath cpath fattr flock exec )) || die "Unable to pledge: $!";
for (<L>) {
- if (/^\s+nwid (.+) chan (\d+) bssid ([0-9a-f:]+) (?:-)?(\d+)(?:(?:dBm)|(?:%)) ([\w-]+) ([\w,-]+)\s*$/) {
+ if (/^\s+nwid (.+) chan (\d+) bssid ([0-9a-f:]+) (?:-)?(\d+)(?:(?:dBm)|(?:%)) ([\w-]+) ([\w|\.|\d,-]+)\s*$/) {
my ($nwid, $chan, $bssid, $quality, $mystery, $csv) =
($1, $2, $3, $4, $5, $6);
my %cap = map { $_ => 1 } split(/,/, $csv);
@@ -125,9 +130,15 @@
next;
}
- write_hostname_if $if, $ap;
- exec '/bin/sh', '/etc/netstart', $if
- or die "exec failed: $!";
+ write_hostname_if $if, $trunk, $ap;
+ if (defined $trunk) {
+ exec '/bin/sh', '/etc/netstart', $if,
+ '&&', '/bin/sh', '/etc/netstart',
+ $trunk or die "exec failed: $!";
+ } else {
+ exec '/bin/sh', '/etc/netstart', $if
+ or die "exec failed: $!";
+ }
}
}
}
Hi,
Just in case it is useful for someone...
----- Forwarded message from Olivier Cherrier <oc@symacx.com> -----
Date: Tue, 21 Nov 2017 15:27:09 +0000
From: Olivier Cherrier <oc@symacx.com>
To: ray@raylai.com
Subject: some wifind modification proposals
User-Agent: Mutt/1.9.1 (2017-09-22)
Hi Ray,
I discoverd wifind some weeks ago and I like it ;-)
I had to change it for my needs. I am sending you a patch with some
explanations about the changes :
_ Allow the possiblity to have the wifi interface part of a trunk.
In that case, no dhclient should be run, it is ran as part of the
thunk.
_ Recognize 'csv' string like :
privacy,short_slottime,radio_measurement,wpa2,802.1x
The 802.1x was preventing the match of the regexp.
In the case of 802.1x, wpa_supplicant should be started ... so it
needs the 2 following changes.
_ Allow the 'wpaakms' setting
_ Allow the 'post command' syntax to fire actions like routing,
wpa_supplicant, ...
Here a configuration example I am using:
{
"if" : "iwm0",
"trunk" : "trunk0",
"wlan" : [
{
"nwid" : "MOBILE",
"bssid" : "a8:22:66:5f:e6:6a",
"wpaprotos" : "wpa2",
"wpaakms" : "802.1x",
"description" : "Kennedy",
"command" : "sleep 1; rcctl restart wpa_supplicant; sleep 4"
},
{
"nwid" : "C84824",
"wpakey" : "54535726",
"description" : "Ma et Pa"
},
{
"nwid" : "zobe",
"wpakey" : "papounet",
"description" : "My GSM hotspot"
},
]
}
Thank you,
Best
--
Olivier Cherrier
Phone: +352691754777
mailto:oc@symacx.com
----- End forwarded message -----
No comments:
Post a Comment