Date: Sat, 9 Aug 2003 00:50:31 +0200 (CEST) From: Martin Blapp <mb@imp.ch> To: jhb@freebsd.org, "" <imp@imp.com>, "" <rwatson@freebsd.org>, Larry Rosenman <ler@lerctr.org> Cc: freebsd-mobile@freebsd.org Subject: Make pccard.ether working if there is already a dhclient running Message-ID: <20030809004120.T49451@cvs.imp.ch>
next in thread | raw e-mail | index | archive | help
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, <mb@imp.ch> <mbr@FreeBSD.org> ------------------------------------------------------------------ ImproWare AG, UNIXSP & ISP, Zurlindenstrasse 29, 4133 Pratteln, CH Phone: +41 61 826 93 00 Fax: +41 61 826 93 01 PGP: <finger -l mbr@freebsd.org> PGP Fingerprint: B434 53FC C87C FE7B 0A18 B84C 8686 EF22 D300 551E ------------------------------------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030809004120.T49451>