From owner-freebsd-mobile@FreeBSD.ORG Mon Jul 16 12:04:02 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 E8B9A16A404 for ; Mon, 16 Jul 2007 12:04:02 +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 461F713C4A8 for ; Mon, 16 Jul 2007 12:04:01 +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); Mon, 16 Jul 2007 14:04:14 +0200 Received: (from guru@localhost) by rebelion.Sisis.de (8.13.8/8.13.8/Submit) id l6GC40hP004756; Mon, 16 Jul 2007 14:04:00 +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: Mon, 16 Jul 2007 14:03:59 +0200 From: Matthias Apitz To: Dennis Melentyev Message-ID: <20070716120359.GA4550@rebelion.Sisis.de> References: <20070716093136.GA1600@rebelion.Sisis.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.2i X-Operating-System: FreeBSD 6.2-RELEASE (i386) X-OriginalArrivalTime: 16 Jul 2007 12:04:14.0470 (UTC) FILETIME=[6D88EA60:01C7C7A1] Cc: 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: Mon, 16 Jul 2007 12:04:03 -0000 El día Monday, July 16, 2007 a las 12:50:24PM +0300, Dennis Melentyev escribió: > Hello Mattias, > > Have you tried wpa_supplicant for this? It can perfectly autodetect > networks for me (office/home). With iwi driver on 7.0-CURRENT-200706 > snapshot (HP/Compaq nc8230). Hello Dennis, In some of the offices I'm as well using wpa_supplicant, at home I have only WEP (maybe this would work as well with wpa_supplicant, I've never tried it and just putting the wepkey with ifconfig into the interface); but all this is more complex then just doing the association, because I have also (sometimes) use a dedicated IP addr, sometimes I must fetch it with DHCP, and/or have to set other network related files accordingly (/etc/hosts, /etc/resolv.conf and others); thats why my idea was having a script in /usr/local/etc/rc.d/wlan.sh with the logic like: #!/bin/sh ifconfig iwi0 scan ifconfig iwi0 list ap | fgrep -q office1 && wifi=office1 ifconfig iwi0 list ap | fgrep -q office2 && wifi=office2 ifconfig iwi0 list ap | fgrep -q office3 && wifi=office3 #.... # # switch IP layout: office1 / office2 / ... based on ${wifi} # case ${wifi} in office1) printf "Found Wifi 'office1' ... " ; cat /home/guru/sys/hosts.office1 > /etc/hosts cat /home/guru/sys/resolv.conf.office1 > /etc/resolv.conf cat /home/guru/sys/nsswitch.conf.office1 > /etc/nsswitch.conf route delete default > /dev/null ifconfig bge0 down ssid=office1 wepkey=xxxxxxxxxxxxxxxxxxxxxxxxxx inet=192.168.2.3 netmask=0xffffff00 ifconfig iwi0 inet ${inet} \ netmask ${netmask} \ ssid ${ssid} \ wepkey ${wepkey} \ channel 9 weptxkey 1 wepmode on ping -c3 -o smc route add default 192.168.2.1 > /dev/null printf "... done.\n" ; ;; office2) printf "Found Wifi 'office2' ... " ; route flush > /dev/null route delete 193.31.10.32/27 > /dev/null wpa_supplicant -B -i iwi0 -c /etc/wpa_supplicant.conf # let the WPA client come up and init the iwi0 interface sleep 1 ifconfig iwi0 inet 193.31.10.34 netmask 255.255.255.224 route add default 193.31.10.58 > /dev/null cat /home/guru/sys/hosts.office2 > /etc/hosts cat /home/guru/sys/resolv.conf.office2 > /etc/resolv.conf cat /home/guru/sys/nsswitch.conf.office2 > /etc/nsswitch.conf # .... I'm clearer now what I want to do? matthias -- Matthias Apitz Manager Technical Support - OCLC PICA GmbH Gruenwalder Weg 28g - 82041 Oberhaching - Germany t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 e - w http://www.oclcpica.org/ http://www.UnixArea.de/ b http://gurucubano.blogspot.com/ OCLC PICA GmbH, Geschaeftsfuehrer: Christine Magin-Weeger, Norbert Weinberger Sitz der Gesellschaft: Oberhaching, HRB Muenchen: 113261