From owner-freebsd-mobile@FreeBSD.ORG Tue Jul 17 12:30:35 2007 Return-Path: X-Original-To: freebsd-mobile@freebsd.org Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BEB9116A400 for ; Tue, 17 Jul 2007 12:30:35 +0000 (UTC) (envelope-from M.Apitz@oclcpica.org) Received: from mail.pica.nl (mail.pica.nl [192.87.44.30]) by mx1.freebsd.org (Postfix) with ESMTP id 048AF13C4B2 for ; Tue, 17 Jul 2007 12:30:34 +0000 (UTC) (envelope-from M.Apitz@oclcpica.org) Received: from rebelion.Sisis.de ([193.31.10.34]) by mail.pica.nl with Microsoft SMTPSVC(6.0.3790.3959); Tue, 17 Jul 2007 14:30:47 +0200 Received: (from guru@localhost) by rebelion.Sisis.de (8.13.8/8.13.8/Submit) id l6HCUJ4H005020; Tue, 17 Jul 2007 14:30:19 +0200 (CEST) (envelope-from m.apitz@oclcpica.org) X-Authentication-Warning: rebelion.Sisis.de: guru set sender to m.apitz@oclcpica.org using -f Date: Tue, 17 Jul 2007 14:30:19 +0200 From: Matthias Apitz To: Sam Leffler Message-ID: <20070717123019.GA4691@rebelion.Sisis.de> References: <20070716093136.GA1600@rebelion.Sisis.de> <20070716120359.GA4550@rebelion.Sisis.de> <469B9D56.6000103@errno.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <469B9D56.6000103@errno.com> User-Agent: Mutt/1.4.2.2i X-Operating-System: FreeBSD 6.2-RELEASE (i386) X-OriginalArrivalTime: 17 Jul 2007 12:30:47.0297 (UTC) FILETIME=[4D58C710:01C7C86E] Cc: Dennis Melentyev , Matthias Apitz , freebsd-mobile@freebsd.org Subject: Re: How detecting the Wifi area my iwi0 is in? X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Matthias Apitz List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jul 2007 12:30:35 -0000 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 - w http://www.oclcpica.org/ http://www.UnixArea.de/ b http://gurucubano.blogspot.com/