Date: Mon, 16 Jul 2007 14:03:59 +0200 From: Matthias Apitz <m.apitz@oclcpica.org> To: Dennis Melentyev <dennis.melentyev@gmail.com> Cc: freebsd-mobile@freebsd.org Subject: Re: How detecting the Wifi area my iwi0 is in? Message-ID: <20070716120359.GA4550@rebelion.Sisis.de> In-Reply-To: <b84edfa10707160250i360b883eh75305e02040198b0@mail.gmail.com> References: <20070716093136.GA1600@rebelion.Sisis.de> <b84edfa10707160250i360b883eh75305e02040198b0@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <m.apitz@oclcpica.org> - 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070716120359.GA4550>