From owner-freebsd-mobile@FreeBSD.ORG Fri Aug 8 15:51:17 2003 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A100337B47A; Fri, 8 Aug 2003 15:51:17 -0700 (PDT) Received: from mail.imp.ch (mail.imp.ch [157.161.1.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B5B644082; Fri, 8 Aug 2003 15:50:44 -0700 (PDT) (envelope-from mb@imp.ch) Received: from nbs.imp.ch (nbs.imp.ch [157.161.4.7]) by mail.imp.ch (8.12.6p2/8.12.3) with ESMTP id h78MoWYc099840; Sat, 9 Aug 2003 00:50:32 +0200 (CEST) (envelope-from Martin.Blapp@imp.ch) Received: from cvs.imp.ch (cvs.imp.ch [157.161.4.9]) by nbs.imp.ch (8.12.8/8.12.3) with ESMTP id h78MoVlH8760352; Sat, 9 Aug 2003 00:50:31 +0200 (MES) Date: Sat, 9 Aug 2003 00:50:31 +0200 (CEST) From: Martin Blapp To: jhb@freebsd.org, "" , "" , Larry Rosenman Message-ID: <20030809004120.T49451@cvs.imp.ch> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-mobile@freebsd.org Subject: Make pccard.ether working if there is already a dhclient running X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Aug 2003 22:51:20 -0000 Hi Folks, what do you think about this temporary solution untill we have a full working dhcp client which does the same as win XP :P ? This patch does read the fix dhcp interfaces from rc.conf, starts itself with the pccard interface _AND_ the system interface (if one or more exist). Then, after removal, it kills the existing dhclient, and starts again one from rc.conf without the pccard one. I could fix that just easy to work with more pccards. Currently it only works with one. And of course rc.d/dhclient needs to be fixed to include the pccard interface if it has been attached _before_ devd has been started. My rc.conf config is simple: ifconfig_sis0="DHCP" pccard_ifconfig=DHCP removable_interfaces="an0 wi0" It just works great. (Btw. the IMAPI way of adding/removinf interfaces is complety broken, and even the authors told be that it not working and difficult to fix) Comments ? --- etc/pccard_ether Thu Jun 26 04:44:08 2003 +++ /etc/pccard_ether Sat Aug 9 00:32:06 2003 @@ -7,20 +7,48 @@ # example: pccard_ether fxp0 start link0 # +. /etc/network.subr + +dhclient_common() +{ + dhcp_list="`list_net_interfaces dhcp`" + if [ -z "$dhcp_list" ]; then + return 1 + fi + + # Determine the scope of the command + # + _cooked_list="$dhcp_list" + if [ -n "$_cmdifn" ]; then + eval _cooked_list=\"`expr "$dhcp_list" : ".*\($_cmdifn\).*"`\" + if [ -z "$_cooked_list" ]; then + err "No such network interface: $_cmdifn" + return 1 + fi + fi +} + stop_dhcp() { if [ -s /var/run/dhclient.${interface}.pid ]; then pidfile="/var/run/dhclient.${interface}.pid" + restart="/etc/rc.d/dhclient start" elif [ -s /var/run/dhcpc.${interface}.pid ]; then pidfile="/var/run/dhcpc.${interface}.pid" + restart="/etc/rc.d/dhclient start" + elif [ -s /var/run/dhclient.pid ]; then + pidfile="/var/run/dhclient.pid" + restart="" else return fi kill `cat ${pidfile}` rm -f ${pidfile} + sh `$restart` } start_dhcp() { stop_dhcp + dhclient_common case ${pccard_ether_delay} in [Nn][Oo]) ;; @@ -35,7 +63,8 @@ pidfile="/var/run/dhclient.${interface}.pid" dhclient_flags="${dhclient_flags} -pf ${pidfile}" fi - ${dhclient_program} ${dhclient_flags} ${interface} + eval __cooked_list=\"`echo ${interface} $_cooked_list | tr -cs '[:alnum:]' '\n' | sort -u | tr '\n' ' '`\" + ${dhclient_program} ${dhclient_flags} $__cooked_list else echo "${dhclient_program}: DHCP client software not available" fi Martin Blapp, ------------------------------------------------------------------ ImproWare AG, UNIXSP & ISP, Zurlindenstrasse 29, 4133 Pratteln, CH Phone: +41 61 826 93 00 Fax: +41 61 826 93 01 PGP: PGP Fingerprint: B434 53FC C87C FE7B 0A18 B84C 8686 EF22 D300 551E ------------------------------------------------------------------