first pass at a hostapd service, rough around the edges
This commit is contained in:
43
tests/wlan/configuration.nix
Normal file
43
tests/wlan/configuration.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{ config, pkgs, lib, ... } :
|
||||
let
|
||||
inherit (pkgs.liminix.networking) interface address hostapd route dnsmasq;
|
||||
inherit (pkgs.liminix.services) oneshot longrun bundle target output;
|
||||
in rec {
|
||||
services.loopback =
|
||||
let iface = interface { type = "loopback"; device = "lo";};
|
||||
in bundle {
|
||||
name = "loopback";
|
||||
contents = [
|
||||
(address iface { family = "inet4"; address ="127.0.0.1"; prefixLength = 8;})
|
||||
(address iface { family = "inet6"; address ="::1"; prefixLength = 128;})
|
||||
];
|
||||
};
|
||||
|
||||
services.wlan = interface { type = "hardware"; device = "wlan0"; };
|
||||
|
||||
services.hostap = hostapd (services.wlan) {
|
||||
params = {
|
||||
ssid = "liminix";
|
||||
country_code = "GB";
|
||||
hw_mode="g";
|
||||
channel = "2";
|
||||
wmm_enabled = 1;
|
||||
ieee80211n = 1;
|
||||
wpa_passphrase = "colourless green ideas";
|
||||
auth_algs = 1; # 1=wpa2, 2=wep, 3=both
|
||||
wpa = 2; # 1=wpa, 2=wpa2, 3=both
|
||||
wpa_key_mgmt = "WPA-PSK";
|
||||
wpa_pairwise = "TKIP CCMP"; # auth for wpa (may not need this?)
|
||||
rsn_pairwise = "CCMP"; # auth for wpa2
|
||||
};
|
||||
};
|
||||
|
||||
services.default = target {
|
||||
name = "default";
|
||||
contents = with services; [
|
||||
loopback
|
||||
hostap
|
||||
];
|
||||
};
|
||||
defaultProfile.packages = with pkgs; [ tcpdump ] ;
|
||||
}
|
25
tests/wlan/run.sh
Executable file
25
tests/wlan/run.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
cleanup(){
|
||||
if test -e foo.pid && test -d /proc/`cat foo.pid` ; then
|
||||
echo "killing qemu"
|
||||
kill `cat foo.pid`
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
fatal(){
|
||||
err=$?
|
||||
echo "FAIL: command $(eval echo $BASH_COMMAND) exited with code $err"
|
||||
exit $err
|
||||
}
|
||||
trap fatal ERR
|
||||
|
||||
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/qemu.nix>" -A outputs.default $*
|
||||
|
||||
|
||||
|
||||
../../scripts/run-qemu.sh \
|
||||
--background foo.sock \
|
||||
result/vmlinux result/squashfs \
|
||||
|
||||
nix-shell -p expect --run "expect wait-for-wlan.expect"
|
21
tests/wlan/wait-for-wlan.expect
Normal file
21
tests/wlan/wait-for-wlan.expect
Normal file
@@ -0,0 +1,21 @@
|
||||
set timeout 60
|
||||
|
||||
spawn socat unix-connect:foo.sock -
|
||||
send "\r\n"
|
||||
expect "login:" { send "root\r\n" }
|
||||
expect "/ #"
|
||||
set FINISHED 0
|
||||
set EXIT "1"
|
||||
send "ls -l /run/uncaught-logs/current\r\n"
|
||||
expect "/ #"
|
||||
while { $FINISHED < 10 } {
|
||||
send "grep AP-ENABLED /run/uncaught-logs/current || echo not\r\n"
|
||||
|
||||
expect {
|
||||
"wlan0: AP-ENABLED" { set FINISHED 10; set EXIT 0; }
|
||||
"not" { send_user "waiting ..." ; sleep 5 }
|
||||
}
|
||||
set FINISHED [ expr $FINISHED + 1 ]
|
||||
}
|
||||
|
||||
exit $EXIT
|
Reference in New Issue
Block a user