Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jul 2007 14:30:19 +0200
From:      Matthias Apitz <m.apitz@oclcpica.org>
To:        Sam Leffler <sam@errno.com>
Cc:        Dennis Melentyev <dennis.melentyev@gmail.com>, Matthias Apitz <m.apitz@oclcpica.org>, freebsd-mobile@freebsd.org
Subject:   Re: How detecting the Wifi area my iwi0 is in?
Message-ID:  <20070717123019.GA4691@rebelion.Sisis.de>
In-Reply-To: <469B9D56.6000103@errno.com>
References:  <20070716093136.GA1600@rebelion.Sisis.de> <b84edfa10707160250i360b883eh75305e02040198b0@mail.gmail.com> <20070716120359.GA4550@rebelion.Sisis.de> <469B9D56.6000103@errno.com>

next in thread | previous in thread | raw e-mail | index | archive | help

El día Monday, July 16, 2007 a las 09:31:18AM -0700, Sam Leffler escribió:

> wpa_supplicant grok's WEP and should also handle open auth (no crypto). 
>  The intended way to handle the rest of your needs is to hook into devd 
> and launch a script the link UP event (or similar).  For the latter 
> you'll probably want to write your script to work only on first link UP 
> so you don't repeat work for each DOWN/UP transition (as happens when 
> the AP dumps the station for inactivity).
> 
> You can find the ssid of the associated ap with ifconfig (e.g. ifconfig 
> iwi0 list sta | awk '{print $1;}') or use wpa_cli to query the info from 
> wpa_supplicant if you use it to setup your network.  Given the wealth of 
> wireless state displayed by ifconfig I've also considered adding a new 
> program that's designed for shell scripts; it could be used to query 
> individual settings and/or generate shell syntax for multiple params; e.g.
> 
> SSID=`wlanconfig iwi0 ssid`
> eval `wlanconfig iwi0 ssid channel authmode`
> 
> Another thing to look at is the wlanwatch program in 
> tools/tools/net80211; you can use it to write a program that waits for 
> the first link UP event (on associate) and then have it print the SSID 
> of the ap to stdout.
> 
> I think all the mechanisms for doing stuff are present in the system; 
> we're just lacking better integration to autoconfig network state.

Sam,

Thanks for that very usefull hint. I've put a user script into
/usr/local/etc/devd/iwi.conf (the dir /usr/local/etc/devd will
be scanned by devd(8) by default) and this watches the iwi0
as:

# cat /usr/local/etc/devd/iwi.conf

notify 1 {
        match "system"          "IFNET";
        match "subsystem"       "iwi0";
        match "type"            "LINK_UP";
        action "/home/guru/devd.sh $subsystem $type";
};

My script 'devd.sh' (which will later do the real work) sees the
LINK_UP fine and the MAC addr (not the SSID) of the AP is

ap=`/sbin/ifconfig iwi0 list sta | awk '{print $1;}' | fgrep -v ADDR`

but the MAC addr should be even better in that case:

Tue Jul 17 14:07:50 CEST 2007: /home/guru/devd.sh iwi0 LINK_DOWN
ap [00:04:e2:a1:76:0b] seems to be the OH office
Tue Jul 17 14:08:18 CEST 2007: /home/guru/devd.sh iwi0 LINK_UP
ap [00:04:e2:a1:76:0b] seems to be the OH office

The above LINK_DOWN / LINK_UP was just a power-cycle of the AP
itself. I'm still thinking how to avoid with some lock file
that on any LINK_UP the script does its work, but only on a first
time; perhaps it's safe enough to remove a stale lock file before
the launch of the wpa_supplicant and just touch it on 1st LINK_UP;

btw: are there any Wifi-like PCMCIA cards which I could use with
FBSD-current in the other laptop?

	matthias
-- 
e <m.apitz@oclcpica.org> - w http://www.oclcpica.org/ http://www.UnixArea.de/
b http://gurucubano.blogspot.com/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070717123019.GA4691>