Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 91 additions & 5 deletions lnxrouter
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Options:
for both Internet and AP
--virt-name <name> Set name of virtual interface
-c <channel> Channel number (default: 1)
--force_channel Force the use of channel provided by -c flag
--country <code> Set two-letter country code for regularity
(example: US)
--freq-band <GHz> Set frequency band: 2.4 or 5 (default: 2.4)
Expand All @@ -102,13 +103,29 @@ Options:
(defaults to /etc/hostapd/hostapd.accept)
--hostapd-debug <level> 1 or 2. Passes -d or -dd to hostapd
--isolate-clients Disable wifi communication between clients

--no-haveged Do not run haveged automatically when needed
--hs20 Enable Hotspot 2.0 (Make sure your hostapd build supports it)

WiFi 4(802.11N) Config:
--ieee80211n Enable IEEE 802.11n (HT)
--ieee80211ac Enable IEEE 802.11ac (VHT)
--use_ht Enable High Throughput mode
--ht_capab <HT> HT capabilities (default: [HT40+])

WiFi 5(802.11AC) Config:
--ieee80211ac Enable IEEE 802.11ac (VHT)
--use_vht Enable Very High Thoughtput mode
--vht_capab <VHT> VHT capabilities

--no-haveged Do not run haveged automatically when needed
--vht_channel_width <index>
Index of VHT Channel Width:
0 for 20MHz or 40MHz (default)
1 for 80MHz
2 for 160MHz
3 for 80+80MHz (Non-contigous 160MHz)
--seg0_center_freq_idx <channel>
Channel index of Center frequency for primary segment, use with --vht_channel_width
--seg1_center_freq_idx <channel>
Channel index of Center frequency for secondary (second 80MHz) segment, use with --vht_channel_width=3
Pick above 2 values from the F0 index column from the 5GHz table in https://en.wikipedia.org/wiki/List_of_WLAN_channels#5_GHz_(802.11a/h/n/ac/ax)

Instance managing:
--daemon Run in background
Expand Down Expand Up @@ -179,13 +196,20 @@ define_global_variables(){
HIDDEN=0 # hidden wifi hotspot
WIFI_IFACE=
CHANNEL=default
FORCECHANNEL=0 # Forces channel provided by -c flag
HOTSPOT20=0 # For enabling Hotspot 2.0
WPA_VERSION=2
MAC_FILTER=0
MAC_FILTER_ACCEPT=/etc/hostapd/hostapd.accept
IEEE80211N=0
REQUIREHT=0
IEEE80211AC=0
REQUIREVHT=0
HT_CAPAB='[HT40+]'
VHT_CAPAB=
VHTCHANNELWIDTH=0
VHTSEG0CHINDEX=0
VHTSEG1CHINDEX=0
DRIVER=nl80211
NO_VIRT=0 # not use virtual interface
COUNTRY=
Expand Down Expand Up @@ -373,6 +397,14 @@ parse_user_options(){
CHANNEL="$1"
shift
;;
--force_channel)
shift
FORCECHANNEL=1
;;
--hs20)
shift
HOTSPOT20=1
;;
-w)
shift
WPA_VERSION="$1"
Expand All @@ -384,10 +416,18 @@ parse_user_options(){
shift
IEEE80211N=1
;;
--use_ht)
shift
REQUIREHT=1
;;
--ieee80211ac)
shift
IEEE80211AC=1
;;
--use_vht)
shift
REQUIREVHT=1
;;
--ht_capab)
shift
HT_CAPAB="$1"
Expand All @@ -398,6 +438,21 @@ parse_user_options(){
VHT_CAPAB="$1"
shift
;;
--vht_channel_width)
shift
VHTCHANNELWIDTH="$1"
shift
;;
--seg0_center_freq_idx)
shift
VHTSEG0CHINDEX="$1"
shift
;;
--seg1_center_freq_idx)
shift
VHTSEG1CHINDEX="$1"
shift
;;
--driver)
shift
DRIVER="$1"
Expand Down Expand Up @@ -1648,7 +1703,7 @@ prepare_wifi_interface() {

if [[ $NO_VIRT -eq 0 ]]; then
## Will generate virtual wifi interface
if is_interface_wifi_connected ${WIFI_IFACE}; then
if is_interface_wifi_connected ${WIFI_IFACE} && [[ FORCECHANNEL -eq 0 ]]; then
WIFI_IFACE_FREQ=$(iw dev ${WIFI_IFACE} link | grep -i freq | awk '{print $2}')
WIFI_IFACE_CHANNEL=$(ieee80211_frequency_to_channel ${WIFI_IFACE_FREQ})
echo "${WIFI_IFACE} already in channel ${WIFI_IFACE_CHANNEL} (${WIFI_IFACE_FREQ} MHz)"
Expand Down Expand Up @@ -1748,21 +1803,51 @@ write_hostapd_conf() {
EOF
fi

if [[ $HOTSPOT20 -eq 1 ]]; then
echo "hs20=1" >> "$CONFDIR/hostapd.conf"
fi

if [[ $IEEE80211N -eq 1 ]]; then
cat <<- EOF >> "$CONFDIR/hostapd.conf"
ieee80211n=1
ht_capab=${HT_CAPAB}
EOF
fi

if [[ $REQUIREHT -eq 1 ]]; then
echo "require_ht=1" >> "$CONFDIR/hostapd.conf"
fi

if [[ $IEEE80211AC -eq 1 ]]; then
echo "ieee80211ac=1" >> "$CONFDIR/hostapd.conf"
fi

if [[ $REQUIREVHT -eq 1 ]]; then
echo "require_vht=1" >> "$CONFDIR/hostapd.conf"
fi

if [[ -n "$VHT_CAPAB" ]]; then
echo "vht_capab=${VHT_CAPAB}" >> "$CONFDIR/hostapd.conf"
fi

if [[ $VHTCHANNELWIDTH -gt 0 ]]; then
cat <<- EOF >> "$CONFDIR/hostapd.conf"
vht_oper_chwidth=${VHTCHANNELWIDTH}
EOF
fi

if [[ $VHTSEG0CHINDEX -gt 0 ]]; then
cat <<- EOF >> "$CONFDIR/hostapd.conf"
vht_oper_centr_freq_seg0_idx=${VHTSEG0CHINDEX}
EOF
fi

if [[ $VHTSEG1CHINDEX -gt 0 ]]; then
cat <<- EOF >> "$CONFDIR/hostapd.conf"
vht_oper_centr_freq_seg1_idx=${VHTSEG1CHINDEX}
EOF
fi

if [[ $IEEE80211N -eq 1 ]] || [[ $IEEE80211AC -eq 1 ]]; then
echo "wmm_enabled=1" >> "$CONFDIR/hostapd.conf"
fi
Expand All @@ -1784,6 +1869,7 @@ write_hostapd_conf() {
else
echo "WARN: WiFi is not protected by password" >&2
fi
echo "Config for current session is $CONFDIR/hostapd.conf" # Useful for sharing with other hostapd users.
chmod 600 "$CONFDIR/hostapd.conf"
}

Expand Down