services: Add 'hostapd-service-type'.
* gnu/services/networking.scm (<hostapd-configuration>): New record type. (hostapd-configuration-file, hostapd-shepherd-services): New procedures. (hostapd-service-type): New variable. * doc/guix.texi (Networking Services): Document it.
This commit is contained in:
parent
4313e6ec55
commit
a03943ec00
2 changed files with 122 additions and 0 deletions
|
|
@ -13633,6 +13633,57 @@ List of additional command-line arguments to pass to the daemon.
|
||||||
@end table
|
@end table
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
||||||
|
@cindex hostapd service, for Wi-Fi access points
|
||||||
|
@cindex Wi-Fi access points, hostapd service
|
||||||
|
@defvr {Scheme Variable} hostapd-service-type
|
||||||
|
This is the service type to run the @uref{https://w1.fi/hostapd/,
|
||||||
|
hostapd} daemon to set up WiFi (IEEE 802.11) access points and
|
||||||
|
authentication servers. Its associated value must be a
|
||||||
|
@code{hostapd-configuration} as shown below:
|
||||||
|
|
||||||
|
@lisp
|
||||||
|
;; Use wlan1 to run the access point for "My Network".
|
||||||
|
(service hostapd-service-type
|
||||||
|
(hostapd-configuration
|
||||||
|
(interface "wlan1")
|
||||||
|
(ssid "My Network")
|
||||||
|
(channel 12)))
|
||||||
|
@end lisp
|
||||||
|
@end defvr
|
||||||
|
|
||||||
|
@deftp {Data Type} hostapd-configuration
|
||||||
|
This data type represents the configuration of the hostapd service, with
|
||||||
|
the following fields:
|
||||||
|
|
||||||
|
@table @asis
|
||||||
|
@item @code{package} (default: @code{hostapd})
|
||||||
|
The hostapd package to use.
|
||||||
|
|
||||||
|
@item @code{interface} (default: @code{"wlan0"})
|
||||||
|
The network interface to run the WiFi access point.
|
||||||
|
|
||||||
|
@item @code{ssid}
|
||||||
|
The SSID (@dfn{service set identifier}), a string that identifies this
|
||||||
|
network.
|
||||||
|
|
||||||
|
@item @code{broadcast-ssid?} (default: @code{#t})
|
||||||
|
Whether to broadcast this SSID.
|
||||||
|
|
||||||
|
@item @code{channel} (default: @code{1})
|
||||||
|
The WiFi channel to use.
|
||||||
|
|
||||||
|
@item @code{driver} (default: @code{"nl80211"})
|
||||||
|
The driver interface type. @code{"nl80211"} is used with all Linux
|
||||||
|
mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
|
||||||
|
RADIUS server that does # not control any wireless/wired driver.
|
||||||
|
|
||||||
|
@item @code{extra-settings} (default: @code{""})
|
||||||
|
Extra settings to append as-is to the hostapd configuration file. See
|
||||||
|
@uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
|
||||||
|
configuration file reference.
|
||||||
|
@end table
|
||||||
|
@end deftp
|
||||||
|
|
||||||
@cindex iptables
|
@cindex iptables
|
||||||
@defvr {Scheme Variable} iptables-service-type
|
@defvr {Scheme Variable} iptables-service-type
|
||||||
This is the service type to set up an iptables configuration. iptables is a
|
This is the service type to set up an iptables configuration. iptables is a
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
(define-module (gnu services networking)
|
(define-module (gnu services networking)
|
||||||
#:use-module (gnu services)
|
#:use-module (gnu services)
|
||||||
#:use-module (gnu services base)
|
#:use-module (gnu services base)
|
||||||
|
#:use-module (gnu services configuration)
|
||||||
#:use-module (gnu services shepherd)
|
#:use-module (gnu services shepherd)
|
||||||
#:use-module (gnu services dbus)
|
#:use-module (gnu services dbus)
|
||||||
#:use-module (gnu system shadow)
|
#:use-module (gnu system shadow)
|
||||||
|
|
@ -140,6 +141,16 @@
|
||||||
wpa-supplicant-configuration-extra-options
|
wpa-supplicant-configuration-extra-options
|
||||||
wpa-supplicant-service-type
|
wpa-supplicant-service-type
|
||||||
|
|
||||||
|
hostapd-configuration
|
||||||
|
hostapd-configuration?
|
||||||
|
hostapd-configuration-package
|
||||||
|
hostapd-configuration-interface
|
||||||
|
hostapd-configuration-ssid
|
||||||
|
hostapd-configuration-broadcast-ssid?
|
||||||
|
hostapd-configuration-channel
|
||||||
|
hostapd-configuration-driver
|
||||||
|
hostapd-service-type
|
||||||
|
|
||||||
openvswitch-service-type
|
openvswitch-service-type
|
||||||
openvswitch-configuration
|
openvswitch-configuration
|
||||||
|
|
||||||
|
|
@ -1358,6 +1369,66 @@ whatever the thing is supposed to do).")))
|
||||||
implements authentication, key negotiation and more for wireless networks.")
|
implements authentication, key negotiation and more for wireless networks.")
|
||||||
(default-value (wpa-supplicant-configuration)))))
|
(default-value (wpa-supplicant-configuration)))))
|
||||||
|
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; Hostapd.
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(define-record-type* <hostapd-configuration>
|
||||||
|
hostapd-configuration make-hostapd-configuration
|
||||||
|
hostapd-configuration?
|
||||||
|
(package hostapd-configuration-package
|
||||||
|
(default hostapd))
|
||||||
|
(interface hostapd-configuration-interface ;string
|
||||||
|
(default "wlan0"))
|
||||||
|
(ssid hostapd-configuration-ssid) ;string
|
||||||
|
(broadcast-ssid? hostapd-configuration-broadcast-ssid? ;Boolean
|
||||||
|
(default #t))
|
||||||
|
(channel hostapd-configuration-channel ;integer
|
||||||
|
(default 1))
|
||||||
|
(driver hostapd-configuration-driver ;string
|
||||||
|
(default "nl80211"))
|
||||||
|
;; See <https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf> for a list of
|
||||||
|
;; additional options we could add.
|
||||||
|
(extra-settings hostapd-configuration-extra-settings ;string
|
||||||
|
(default "")))
|
||||||
|
|
||||||
|
(define (hostapd-configuration-file config)
|
||||||
|
"Return the configuration file for CONFIG, a <hostapd-configuration>."
|
||||||
|
(match-record config <hostapd-configuration>
|
||||||
|
(interface ssid broadcast-ssid? channel driver extra-settings)
|
||||||
|
(plain-file "hostapd.conf"
|
||||||
|
(string-append "\
|
||||||
|
# Generated from your Guix configuration.
|
||||||
|
|
||||||
|
interface=" interface "
|
||||||
|
ssid=" ssid "
|
||||||
|
ignore_broadcast_ssid=" (if broadcast-ssid? "0" "1") "
|
||||||
|
channel=" (number->string channel) "\n"
|
||||||
|
extra-settings "\n"))))
|
||||||
|
|
||||||
|
(define* (hostapd-shepherd-services config #:key (requirement '()))
|
||||||
|
"Return Shepherd services for hostapd."
|
||||||
|
(list (shepherd-service
|
||||||
|
(provision '(hostapd))
|
||||||
|
(requirement `(user-processes ,@requirement))
|
||||||
|
(documentation "Run the hostapd WiFi access point daemon.")
|
||||||
|
(start #~(make-forkexec-constructor
|
||||||
|
(list #$(file-append hostapd "/sbin/hostapd")
|
||||||
|
#$(hostapd-configuration-file config))
|
||||||
|
#:log-file "/var/log/hostapd.log"))
|
||||||
|
(stop #~(make-kill-destructor)))))
|
||||||
|
|
||||||
|
(define hostapd-service-type
|
||||||
|
(service-type
|
||||||
|
(name 'hostapd)
|
||||||
|
(extensions
|
||||||
|
(list (service-extension shepherd-root-service-type
|
||||||
|
hostapd-shepherd-services)))
|
||||||
|
(description
|
||||||
|
"Run the @uref{https://w1.fi/hostapd/, hostapd} daemon for Wi-Fi access
|
||||||
|
points and authentication servers.")))
|
||||||
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Open vSwitch
|
;;; Open vSwitch
|
||||||
|
|
|
||||||
Reference in a new issue