blob: 2d5290b4fb131ddf70fded65709e953c1e4a4bb4 [file] [log] [blame]
developer90379572024-05-29 17:23:20 +08001#!/bin/sh
2
3create_hostapdConf() {
4 devidx=0
5 phyidx=0
6 old_path=""
7 pcie7915count=0
8 vap_per_radio=8
9 radio_num="$(iw list | grep Wiphy | wc -l)"
10
11 for _dev in /sys/class/ieee80211/*; do
12 [ -e "$_dev" ] || continue
13
14 dev="${_dev##*/}"
15
16 band="$(uci get wireless.radio${phyidx}.band)"
17 channel="$(uci get wireless.radio${phyidx}.channel)"
18 # Use random MAC to prevent use the same MAC address
19 rand="$(hexdump -C /dev/urandom | head -n 1 | awk '{printf ""$3":"$4""}' &)"
20 killall hexdump
21 MAC="00:0${devidx}:12:34:${rand}"
22 chip="$(cat /sys/class/ieee80211/"$dev"/device/device)"
23
24 if [ $chip == "0x7915" ]; then
25 path="$(realpath /sys/class/ieee80211/"$dev"/device | cut -d/ -f4-)"
26 if [ -n "$path" ]; then
27 if [ "$path" == "$old_path" ] || [ "$old_path" == "" ]; then
28 pcie7915count="1"
29 else
30 pcie7915count="2"
31 fi
32 fi
33 old_path=$path
34 fi
35
36 if [ -e /sys/class/net/wlan$phyidx ]; then
37 iw wlan$phyidx del > /dev/null
38 fi
39
40 if [ "$(uci get wireless.radio${phyidx}.disabled)" == "1" ]; then
41 phyidx=$(($phyidx + 1))
42 continue
43 fi
44 if [ "$band" == "2g" ]; then
45 iw phy phy$phyidx interface add wifi0 type __ap > /dev/null
46 fi
47 if [ "$band" == "5g" ]; then
48 iw phy phy$phyidx interface add wifi1 type __ap > /dev/null
49 fi
50 if [ "$band" == "6g" ]; then
51 iw phy phy$phyidx interface add wifi2 type __ap > /dev/null
52 fi
53 #iw phy phy$phyidx interface add wifi$devidx type __ap > /dev/null
54 #touch /tmp/$dev-wifi$devidx
55 devidx=$(($devidx + 1))
56 phyidx=$(($phyidx + 1))
57
58 done
59}
60#Creating files for tracking AssociatedDevices
61touch /tmp/AllAssociated_Devices_2G.txt
62touch /tmp/AllAssociated_Devices_5G.txt
63
64#Create wps pin request log file
65touch /var/run/hostapd_wps_pin_requests.log
66
67
68create_hostapdConf
69
70exit 0