Date: Tue, 19 Apr 2011 12:29:26 +0200 From: Maciej Milewski <milu@dat.pl> To: freebsd-wireless@freebsd.org Subject: Re: RFC: supporting multiple hostap instances in /etc/rc.conf Message-ID: <201104191229.26974.milu@dat.pl> In-Reply-To: <201104171605.59340.bschmidt@freebsd.org> References: <BANLkTikGsV7AMYG7GaJ5BN7yUKgugN%2BfBg@mail.gmail.com> <BANLkTimFRR2TE%2BH5Vop%2BTYms8mP4p4FPBg@mail.gmail.com> <201104171605.59340.bschmidt@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104191229.26974.milu>