Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Feb 2011 11:20:28 -0500
From:      John Nielsen <lists@jnielsen.net>
To:        freebsd-rc@freebsd.org
Subject:   [patch] rc support for multiple hostapd instances
Message-ID:  <D55ECF60-8BB5-4458-9BCC-495C39F50A78@jnielsen.net>

next in thread | raw e-mail | index | archive | help

--Apple-Mail-7--409034666
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

I've been tinkering with various wireless setups recently, one of which =
required running WPA on two hostap virtual access points. I was =
surprised to see that support for this is not already present in our rc =
infrastructure. Running multiple instances of hostapd works just fine, =
so I hacked together the following. It add support for a new rc variable =
hostapd_conf_files, which defaults to only "/etc/hostapd.conf" but may =
contain a list of files. An instance of hostapd is started for each file =
in the list. For testing I have used

hostapd_conf_files=3D"/etc/hostapd.conf /etc/hostapd2.conf"

in /etc/rc.conf.

Any suggestions or concerns? I would love to see this or something like =
it committed. I have not yet written a patch for rc.conf.5 but would be =
happy to.

JN


--Apple-Mail-7--409034666
Content-Disposition: attachment;
	filename=multi-hostap.patch
Content-Type: application/octet-stream;
	name="multi-hostap.patch"
Content-Transfer-Encoding: 7bit

--- defaults/rc.conf.orig	2011-02-16 10:27:51.000000000 -0500
+++ defaults/rc.conf	2011-02-16 10:30:13.000000000 -0500
@@ -256,7 +256,8 @@
 # profile3 uses default ppp_mode and ppp_nat
 
 ### Network daemon (miscellaneous) ###
-hostapd_enable="NO"		# Run hostap daemon.
+hostapd_enable="NO"		# Run hostap daemon(s).
+hostapd_conf_files="/etc/hostapd.conf" # List of config files to start a daemon with.
 syslogd_enable="YES"		# Run syslog daemon (or NO).
 syslogd_program="/usr/sbin/syslogd" # path to syslogd, if you want a different one.
 syslogd_flags="-s"		# Flags to syslogd (if enabled).
--- rc.d.norun/hostapd	2011-01-04 20:19:40.000000000 -0500
+++ rc.d/hostapd	2011-02-16 10:24:28.000000000 -0500
@@ -12,14 +12,17 @@
 name="hostapd"
 command="/usr/sbin/${name}"
 rcvar=`set_rcvar`
+load_rc_config ${name}
 
-conf_file="/etc/${name}.conf"
-pidfile="/var/run/${name}.pid"
-
-command_args="-P ${pidfile} -B ${conf_file}"
-required_files="${conf_file}"
 required_modules="wlan_xauth wlan_wep wlan_tkip wlan_ccmp"
 extra_commands="reload"
 
-load_rc_config ${name}
-run_rc_command "$1"
+for conf_file in ${hostapd_conf_files}; do
+	#conf_file="/etc/${name}.conf"
+	pidfile="/var/run/hostapd`echo ${conf_file} | sed -e "s/\//_/g"`.pid"
+
+	command_args="-P ${pidfile} -B ${conf_file}"
+	required_files="${conf_file}"
+
+	run_rc_command "$1"
+done

--Apple-Mail-7--409034666
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii




--Apple-Mail-7--409034666--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D55ECF60-8BB5-4458-9BCC-495C39F50A78>