Commit f42a95ac authored by Hamza Dely's avatar Hamza Dely
Browse files

Ajout d'options au Makefile

parent da0181a3
......@@ -22,6 +22,18 @@ SECRET:=$(shell PYTHONPATH=/etc/crans/secrets/ python -c "import secrets; print
MODEL=
WAN:=$(CONFIG_PACKAGE_CRANS_AP_WAN)
RADIUS:=$(CONFIG_PACKAGE_CRANS_RADIUS_SERVER)
CHANNEL_2_4:=$(CONFIG_PACKAGE_CRANS_CHANNEL_2_4)
CHANNEL_5:=$(CONFIG_PACKAGE_CRANS_CHANNEL_5)
# Les VLANs dynamiques ont-ils été activés
ifeq ($(CONFIG_PACKAGE_CRANS_DYNAMIC_VLAN),y)
DYNAMIC_VLAN:=".dynamic"
else
DYNAMIC_VLAN:=".static"
endif
# Pour installer les confs spécifiques, il faut regarder quel est le type de borne ciblé
ifeq ($(CONFIG_TARGET_ar71xx_generic_ESR1750),y)
MODEL:="esr1750"
......@@ -42,10 +54,53 @@ define Package/crans
TITLE:=Crans-specific configuration for OpenWrt
DEPENDS:=+base-files +kmod-mac80211 +dropbear +!TARGET_ar71xx_generic_TLWR841:monit +TARGET_ar71xx_generic_TLWR841:monit-nossl
VERSION:=$(PKG_RELEASE)
MENU:=1
endef
define Package/crans/config
if PACKAGE_crans
config PACKAGE_CRANS_CHANNEL_2_4
depends on PACKAGE_crans
int "2.4 GHz band channel"
default 11
help
Select channel to use for the 2.4 GHz band Wi-Fi
config PACKAGE_CRANS_CHANNEL_5
depends on PACKAGE_crans
int "5 GHz band channel"
default 36
help
Select channel to use for the 5 GHz band Wi-Fi
config PACKAGE_CRANS_RADIUS_SERVER
depends on PACKAGE_crans
string "RADIUS server IP address"
default 10.231.148.11
config PACKAGE_CRANS_DYNAMIC_VLAN
depends on PACKAGE_crans
bool "Add support for dynamic VLANs"
default n
help
Select this option to add dynamic VLAN support
to the generated OpenWRT image.
This allows several networks to share the same SSID by assigning
different VLANs to clients, depending on RADIUS server's replies.
if TARGET_ar71xx_generic_TLWR841
config PACKAGE_CRANS_AP_WAN
depends on PACKAGE_CRANS_DYNAMIC_VLAN
string "Access Point WAN interface"
default eth1
endif
if !TARGET_ar71xx_generic_TLWR841
config PACKAGE_CRANS_AP_WAN
depends on PACKAGE_CRANS_DYNAMIC_VLAN
string "Access Point WAN interface"
default eth0
endif
endif
endef
define Package/crans/description
Configuration spécifique au Crans
Configuration spécifique au Crans
endef
define Package/base-files/conffiles
......@@ -61,7 +116,6 @@ define Package/base-files/conffiles
/etc/dropbear/authorized_keys
/etc/monit
/etc/uci-defaults/dhcp.crans
/lib/wifi/mac80211.sh
$(call $(TARGET)/conffiles)
endef
......@@ -80,7 +134,7 @@ define Package/crans/install
$(INSTALL_DIR) $(1)/usr/share/watch_net/
$(INSTALL_BIN) files/usr/share/watch_net/watch_net.sh $(1)/usr/share/watch_net/watch_net.sh
$(INSTALL_DIR) $(1)/lib/wifi/
$(INSTALL_BIN) files/lib/wifi/mac80211.sh $(1)/lib/wifi/mac80211.sh
$(INSTALL_BIN) files/lib/wifi/mac80211.sh$(DYNAMIC_VLAN) $(1)/lib/wifi/mac80211.sh
$(INSTALL_DIR) $(1)/etc/uci-defaults/
$(INSTALL_BIN) files/etc/uci-defaults/dhcp.crans $(1)/etc/uci-defaults/dhcp.crans
$(INSTALL_DIR) $(1)/lib/netifd/
......@@ -90,8 +144,11 @@ define Package/crans/install
$(1)/etc/banner \
$(1)/etc/openwrt_version
touch $(1)/etc/config/eap_radius_key
echo -n $(SECRET) > $(1)/etc/config/eap_radius_key
$(SED) s/%%iface%%/$(WAN)/g $(1)/lib/wifi/mac80211.sh
$(SED) s/%%eap_radius_key%%/$(SECRET)/g $(1)/lib/wifi/mac80211.sh
$(SED) s/%%channel_2_4%%/$(CHANNEL_2_4)/g $(1)/lib/wifi/mac80211.sh
$(SED) s/%%channel_5%%/$(CHANNEL_5)/g $(1)/lib/wifi/mac80211.sh
$(SED) s/%%radius_server%%/$(RADIUS)/g $(1)/lib/wifi/mac80211.sh
endef
define Build/Prepare
......
#!/bin/sh
append DRIVERS "mac80211"
lookup_phy() {
[ -n "$phy" ] && {
[ -d /sys/class/ieee80211/$phy ] && return
}
local devpath
config_get devpath "$device" path
[ -n "$devpath" ] && {
for phy in $(ls /sys/class/ieee80211 2>/dev/null); do
case "$(readlink -f /sys/class/ieee80211/$phy/device)" in
*$devpath) return;;
esac
done
}
local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
[ -n "$macaddr" ] && {
for _phy in /sys/class/ieee80211/*; do
[ -e "$_phy" ] || continue
[ "$macaddr" = "$(cat ${_phy}/macaddress)" ] || continue
phy="${_phy##*/}"
return
done
}
phy=
return
}
find_mac80211_phy() {
local device="$1"
config_get phy "$device" phy
lookup_phy
[ -n "$phy" -a -d "/sys/class/ieee80211/$phy" ] || {
echo "PHY for wifi device $1 not found"
return 1
}
config_set "$device" phy "$phy"
config_get macaddr "$device" macaddr
[ -z "$macaddr" ] && {
config_set "$device" macaddr "$(cat /sys/class/ieee80211/${phy}/macaddress)"
}
return 0
}
check_mac80211_device() {
config_get phy "$1" phy
[ -z "$phy" ] && {
find_mac80211_phy "$1" >/dev/null || return 0
config_get phy "$1" phy
}
[ "$phy" = "$dev" ] && found=1
}
detect_mac80211() {
devidx=0
config_load wireless
while :; do
config_get type "radio$devidx" type
[ -n "$type" ] || break
devidx=$(($devidx + 1))
done
for _dev in /sys/class/ieee80211/*; do
[ -e "$_dev" ] || continue
dev="${_dev##*/}"
found=0
config_foreach check_mac80211_device wifi-device
[ "$found" -gt 0 ] && continue
mode_band="g"
channel="%%channel_2_4%%"
htmode=""
ht_capab=""
iw phy "$dev" info | grep -q 'Capabilities:' && htmode=HT20
iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="%%channel_5%%"; }
vht_cap=$(iw phy "$dev" info | grep -c 'VHT Capabilities')
cap_5ghz=$(iw phy "$dev" info | grep -c "Band 2")
[ "$vht_cap" -gt 0 -a "$cap_5ghz" -gt 0 ] && {
mode_band="a";
channel="%%channel_5%%"
htmode="VHT80"
}
[ -n $htmode ] && append ht_capab " option htmode $htmode" "$N"
if [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${dev} ]; then
path="$(readlink -f /sys/class/ieee80211/${dev}/device)"
else
path=""
fi
if [ -n "$path" ]; then
path="${path##/sys/devices/}"
case "$path" in
platform*/pci*) path="${path##platform/}";;
esac
dev_id=" option path '$path'"
else
dev_id=" option macaddr $(cat /sys/class/ieee80211/${dev}/macaddress)"
fi
cat <<EOF
config wifi-device radio$devidx
option type mac80211
option channel ${channel}
option hwmode 11${mode_band}
$dev_id
$ht_capab
option country FR
option country_ie 1
option disabled 0
config wifi-iface
option device radio$devidx
option mode ap
option ssid FedeRez
option encryption wpa2
option server %%radius_server%%
option dynamic_vlan 2
option vlan_tagged_interface %%iface%%
option vlan_bridge br-vlan
option vlan_naming 0
option key %%eap_radius_key%%
option wmm 1
option wds 1
option disabled 0
config wifi-iface
option device radio$devidx
option network vlan7
option mode ap
option ssid Cr@ns-accueil
option encryption none
option test_connect 'ping fe80::1%br-vlan7 -c 4'
option isolate 1
option wmm 1
option disabled 0
EOF
devidx=$(($devidx + 1))
done
}
#!/bin/sh
append DRIVERS "mac80211"
eap_radius_key=$(cat /etc/config/eap_radius_key)
lookup_phy() {
[ -n "$phy" ] && {
[ -d /sys/class/ieee80211/$phy ] && return
......@@ -79,18 +77,18 @@ detect_mac80211() {
[ "$found" -gt 0 ] && continue
mode_band="g"
channel="11"
channel="%%channel_2_4%%"
htmode=""
ht_capab=""
iw phy "$dev" info | grep -q 'Capabilities:' && htmode=HT20
iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="36"; }
iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="%%channel_5%%"; }
vht_cap=$(iw phy "$dev" info | grep -c 'VHT Capabilities')
cap_5ghz=$(iw phy "$dev" info | grep -c "Band 2")
[ "$vht_cap" -gt 0 -a "$cap_5ghz" -gt 0 ] && {
mode_band="a";
channel="36"
channel="%%channel_5%%"
htmode="VHT80"
}
......@@ -129,32 +127,31 @@ config wifi-iface
option wmm 1
option ssid Cr@ns
option encryption wpa2
option server 10.231.148.11
option vlan_bridge br-vlan
option key $eap_radius_key
option server %%radius_server%%
option key %%eap_radius_key%%
option disabled 0
config wifi-iface
option device radio$devidx
option network vlan22
option network vlan7
option mode ap
option ssid Cr@ns-accueil
option encryption none
option test_connect 'ping fe80::1%br-vlan7 -c 4'
option wmm 1
option ssid FedeRez
option encryption wpa2
option server 10.231.148.11
option vlan_bridge br-vlan
option key $eap_radius_key
option isolate 1
option disabled 0
config wifi-iface
option device radio$devidx
option network vlan7
option network vlan22
option mode ap
option ssid Cr@ns-accueil
option encryption none
option test_connect 'ping fe80::1%br-vlan7 -c 4'
option isolate 1
option ssid FedeRez
option encryption wpa2
option server %%radius_server%%
option key %%eap_radius_key%%
option wmm 1
option disabled 0
EOF
devidx=$(($devidx + 1))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment