Dual mode

This commit is contained in:
Giulio 2020-09-17 14:00:05 +02:00
parent df8c164bc6
commit a296daa70c
8 changed files with 28 additions and 10 deletions

View File

@ -1,4 +1,4 @@
interface=wlan0 interface=ap0
hw_mode=g hw_mode=g
channel=1 channel=1
wmm_enabled=1 wmm_enabled=1

View File

@ -0,0 +1,16 @@
#!/bin/sh
case "$1" in
start)
printf "Starting wireless device: "
iw dev wlan0 del
iw phy phy0 interface add ap0 type __ap
iw phy phy0 interface add client0 type station
[ $? = 0 ] && echo "OK" || echo "FAIL"
;;
*)
echo "Usage: $0 {start}"
exit 1
esac
exit 0

View File

@ -3,7 +3,7 @@
# $Id: dhcp3-server.init.d,v 1.4 2003/07/13 19:12:41 mdz Exp $ # $Id: dhcp3-server.init.d,v 1.4 2003/07/13 19:12:41 mdz Exp $
# #
INTERFACES="wlan0" INTERFACES="ap0"
OPTIONS="" OPTIONS=""
NAME="dhcpd" NAME="dhcpd"

View File

@ -4,7 +4,10 @@ iface lo inet loopback
auto eth0 auto eth0
iface eth0 inet dhcp iface eth0 inet dhcp
auto wlan0 auto ap0
iface wlan0 inet static iface ap0 inet static
address 192.168.77.1 address 192.168.77.1
netmask 255.255.255.0 netmask 255.255.255.0
auto client0
iface client0 inet dhcp

View File

@ -10,4 +10,4 @@ Defaults insults
Defaults log_input,log_output Defaults log_input,log_output
www-data ALL=(admin) NOPASSWD: /bin/sh /update.sh www-data ALL=(admin) NOPASSWD: /bin/sh /update.sh
upgrade ALL=(root) NOPASSWD: /usr/sbin/iw wlan0 scan, /sbin/iw wlan0 link, /bin/cat /etc/wpa_supplicant.conf, /bin/sh /wifi/connect.sh *, /bin/sh /wifi/disconnect.sh upgrade ALL=(root) NOPASSWD: /usr/sbin/iw client0 scan, /sbin/iw client0 link, /bin/cat /etc/wpa_supplicant.conf, /bin/sh /wifi/connect.sh *, /bin/sh /wifi/disconnect.sh

View File

@ -6,5 +6,4 @@ if [ "$#" -ne 2 ]; then
fi fi
/usr/bin/wpa_passphrase "$1" "$2" > /etc/wpa_supplicant.conf /usr/bin/wpa_passphrase "$1" "$2" > /etc/wpa_supplicant.conf
/usr/sbin/wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf /usr/sbin/wpa_supplicant -B -i client0 -c /etc/wpa_supplicant.conf
/usr/sbin/dhclient wlan0

View File

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
/usr/sbin/wpa_cli -i wlan0 terminate /usr/sbin/wpa_cli -i client0 terminate

View File

@ -151,7 +151,7 @@ char *get_mac()
{ {
FILE * fp; FILE * fp;
char *mac = malloc(18* sizeof(char)); char *mac = malloc(18* sizeof(char));
fp = fopen("/sys/class/net/wlan0/address", "r"); fp = fopen("/sys/class/net/ap0/address", "r");
fgets(mac, 17, fp); fgets(mac, 17, fp);
fclose(fp); fclose(fp);
return mac; return mac;
@ -276,4 +276,4 @@ int main()
gen_key(mac, serial); gen_key(mac, serial);
return 0; return 0;
} }