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
[-- Attachment #1 --]
Dnia niedziela, 17 kwietnia 2011 o 16:05:58 Bernhard Schmidt napisał(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 way
> > > 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="" and iterate over it, that should do the trick.
> > >
> > > But I'm not sure how to handle the pidfile, or how to name it..
> >
> > > I was thinking of say:
> > hostapd_instances="a b c"
> > hostapd_a_conf="/etc/hostapd.wlan0.conf"
> > hostapd_a_flags="-B -p /var/run/hostapd.wlan0.pid"
> > hostapd_a_cmd="/usr/sbin/hostapd"
> >
> > hostapd_b_conf="/etc/hostapd.wlan1.conf"
> > hostapd_b_flags="-B -p /var/run/hostapd.wlan1.pid"
> > hostapd_b_cmd="/usr/sbin/hostapd"
> >
> > It's not terribly automagic, but it'll work well enough to run multiple
> > hostapds.
> >
> > How's that sound?
>
> Way to complex for my taste :)
>
> How about
>
> hostapd_enable="YES"
> hostapd_interfaces="wlan0 wlan1 .." # defaults to empty
>
> and then
>
> if [ -n $hostapd_interfaces ]; then
> for interface in $interface; do
> pidfile=/var/run/hostapd/$interface.pid
> conffile=/etc/hostapd-$interface.conf
> ..
> done
> else
> pidfile=/var/run/hostapd.pid
> conffile=/etc/hostapd.conf
> fi
One simpler thing for quick running multiple instaces is giving multiple
configs to the hostapd. Hostapd supports it from around 2005. This would run
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
/etc/hostapd2.conf /etc/hostapd3.conf
Attached patch doesn't change default behaviour and adding multiple configs
into rc.conf:
hostapd_conf="/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
interface would be done by hand or by additional logic in the rc-script.
Maciej Milewski
[-- Attachment #2 --]
--- /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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104191229.26974.milu>
