From owner-freebsd-wireless@FreeBSD.ORG Tue Apr 19 10:44:33 2011 Return-Path: <owner-freebsd-wireless@FreeBSD.ORG> Delivered-To: freebsd-wireless@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 631CA106564A for <freebsd-wireless@freebsd.org>; Tue, 19 Apr 2011 10:44:33 +0000 (UTC) (envelope-from milu@dat.pl) Received: from jab.dat.pl (dat.pl [80.51.155.34]) by mx1.freebsd.org (Postfix) with ESMTP id DD82B8FC15 for <freebsd-wireless@freebsd.org>; Tue, 19 Apr 2011 10:44:32 +0000 (UTC) Received: from jab.dat.pl (jsrv.dat.pl [127.0.0.1]) by jab.dat.pl (Postfix) with ESMTP id 381195B for <freebsd-wireless@freebsd.org>; Tue, 19 Apr 2011 12:29:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at dat.pl Received: from jab.dat.pl ([127.0.0.1]) by jab.dat.pl (jab.dat.pl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id QqzQYKfkksID for <freebsd-wireless@freebsd.org>; Tue, 19 Apr 2011 12:29:04 +0200 (CEST) Received: from snifi.localnet (unknown [212.69.68.42]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by jab.dat.pl (Postfix) with ESMTPSA id 8CC8F49 for <freebsd-wireless@freebsd.org>; Tue, 19 Apr 2011 12:29:04 +0200 (CEST) From: Maciej Milewski <milu@dat.pl> To: freebsd-wireless@freebsd.org Date: Tue, 19 Apr 2011 12:29:26 +0200 User-Agent: KMail/1.13.6 (Linux/2.6.38-ARCH; KDE/4.6.2; x86_64; ; ) References: <BANLkTikGsV7AMYG7GaJ5BN7yUKgugN+fBg@mail.gmail.com> <BANLkTimFRR2TE+H5Vop+TYms8mP4p4FPBg@mail.gmail.com> <201104171605.59340.bschmidt@freebsd.org> In-Reply-To: <201104171605.59340.bschmidt@freebsd.org> MIME-Version: 1.0 X-UID: 9 Content-Type: Multipart/Mixed; boundary="Boundary-00=_GQWrNmDoafgnJKc" Message-Id: <201104191229.26974.milu@dat.pl> Subject: Re: RFC: supporting multiple hostap instances in /etc/rc.conf X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." <freebsd-wireless.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-wireless>, <mailto:freebsd-wireless-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-wireless> List-Post: <mailto:freebsd-wireless@freebsd.org> List-Help: <mailto:freebsd-wireless-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-wireless>, <mailto:freebsd-wireless-request@freebsd.org?subject=subscribe> X-List-Received-Date: Tue, 19 Apr 2011 10:44:33 -0000 --Boundary-00=_GQWrNmDoafgnJKc Content-Type: Text/Plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Dnia niedziela, 17 kwietnia 2011 o 16:05:58 Bernhard Schmidt napisa=B3(a): > On Sunday 17 April 2011 15:25:55 Adrian Chadd wrote: > > On 17 April 2011 15:09, Bernhard Schmidt <bschmidt@freebsd.org> wrote: > > > Given that hostapd needs to be started with a configuration file as an > > > argument and not an interface like wpa_supplicant you need to add a w= ay > > > to add multiple configuration files. The conf_file variable is > > > currently hard-coded to /etc/hostapd.conf, if you add another one like > > > hostapd_conf_files=3D"" and iterate over it, that should do the trick. > > >=20 > > > But I'm not sure how to handle the pidfile, or how to name it.. > >=20 > > > I was thinking of say: > > hostapd_instances=3D"a b c" > > hostapd_a_conf=3D"/etc/hostapd.wlan0.conf" > > hostapd_a_flags=3D"-B -p /var/run/hostapd.wlan0.pid" > > hostapd_a_cmd=3D"/usr/sbin/hostapd" > >=20 > > hostapd_b_conf=3D"/etc/hostapd.wlan1.conf" > > hostapd_b_flags=3D"-B -p /var/run/hostapd.wlan1.pid" > > hostapd_b_cmd=3D"/usr/sbin/hostapd" > >=20 > > It's not terribly automagic, but it'll work well enough to run multiple > > hostapds. > >=20 > > How's that sound? >=20 > Way to complex for my taste :) >=20 > How about >=20 > hostapd_enable=3D"YES" > hostapd_interfaces=3D"wlan0 wlan1 .." # defaults to empty >=20 > and then >=20 > if [ -n $hostapd_interfaces ]; then > for interface in $interface; do > pidfile=3D/var/run/hostapd/$interface.pid > conffile=3D/etc/hostapd-$interface.conf > .. > done > else > pidfile=3D/var/run/hostapd.pid > conffile=3D/etc/hostapd.conf > fi One simpler thing for quick running multiple instaces is giving multiple=20 configs to the hostapd. Hostapd supports it from around 2005. This would ru= n=20 one instance of hostapd listening on all interfaces given in config files. Manual way: /usr/sbin/hostapd -P /var/run/hostapd.pid -B /etc/hostapd.conf=20 /etc/hostapd2.conf /etc/hostapd3.conf Attached patch doesn't change default behaviour and adding multiple configs= =20 into rc.conf: hostapd_conf=3D"/etc/hostapd.conf /etc/hostapd2.conf /etc/hostapd3.conf" makes it work with more interfaces. More elegant would be one instance for every interface but restarting only = one=20 interface would be done by hand or by additional logic in the rc-script. Maciej Milewski --Boundary-00=_GQWrNmDoafgnJKc Content-Type: text/x-patch; charset="UTF-8"; name="hostapd-one-instance-multi-config.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="hostapd-one-instance-multi-config.patch" --- /etc/rc.d/hostapd.org 2011-04-18 23:50:08.000000000 +0000 +++ /etc/rc.d/hostapd 2011-04-18 23:46:16.000000000 +0000 @@ -16,11 +16,21 @@ conf_file="/etc/${name}.conf" pidfile="/var/run/${name}.pid" -command_args="-P ${pidfile} -B ${conf_file}" -required_files="${conf_file}" +hostapd_conf=${hostapd_conf:-"/etc/${name}.conf"} + required_modules="wlan_xauth wlan_wep wlan_tkip wlan_ccmp" extra_commands="reload" +hostapd_prestart() +{ + rc_flags="-P ${pidfile} -B ${rc_flags} ${hostapd_conf}" + return 0 +} + load_rc_config ${name} + +start_precmd=hostapd_prestart +required_files="${hostapd_conf}" + run_rc_command "$1" --Boundary-00=_GQWrNmDoafgnJKc--