mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 10:28:06 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			189 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			189 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From d6510fa7b82b8e9fdd2266142aa7472ec407bcfb Mon Sep 17 00:00:00 2001
 | |
| From: John Crispin <john@phrozen.org>
 | |
| Date: Mon, 7 Feb 2022 11:16:12 +0100
 | |
| Subject: [PATCH 7/7] hostapd: move radius into its own function
 | |
| 
 | |
| Signed-off-by: John Crispin <john@phrozen.org>
 | |
| ---
 | |
|  .../network/services/hostapd/files/hostapd.sh | 127 ++++++++++--------
 | |
|  .../mt7621/base-files/lib/upgrade/platform.sh |   9 ++
 | |
|  2 files changed, 77 insertions(+), 59 deletions(-)
 | |
| 
 | |
| diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
 | |
| index 209ae3dc46..c8e1eca88b 100644
 | |
| --- a/package/network/services/hostapd/files/hostapd.sh
 | |
| +++ b/package/network/services/hostapd/files/hostapd.sh
 | |
| @@ -536,6 +536,69 @@ append_airtime_sta_weight() {
 | |
|  	[ -n "$1" ] && append bss_conf "airtime_sta_weight=$1" "$N"
 | |
|  }
 | |
|  
 | |
| +append_radius_server() {
 | |
| +
 | |
| +	json_get_vars \
 | |
| +		auth_server auth_secret auth_port \
 | |
| +		dae_client dae_secret dae_port \
 | |
| +		ownip radius_client_addr \
 | |
| +		eap_reauth_period request_cui \
 | |
| +		erp_domain mobility_domain \
 | |
| +		fils_realm fils_dhcp
 | |
| +
 | |
| +	# legacy compatibility
 | |
| +	[ -n "$auth_server" ] || json_get_var auth_server server
 | |
| +	[ -n "$auth_port" ] || json_get_var auth_port port
 | |
| +	[ -n "$auth_secret" ] || json_get_var auth_secret key
 | |
| +
 | |
| +	[ "$fils" -gt 0 ] && {
 | |
| +		set_default erp_domain "$mobility_domain"
 | |
| +		set_default erp_domain "$(echo "$ssid" | md5sum | head -c 8)"
 | |
| +		set_default fils_realm "$erp_domain"
 | |
| +
 | |
| +		append bss_conf "erp_send_reauth_start=1" "$N"
 | |
| +		append bss_conf "erp_domain=$erp_domain" "$N"
 | |
| +		append bss_conf "fils_realm=$fils_realm" "$N"
 | |
| +		append bss_conf "fils_cache_id=$(echo "$fils_realm" | md5sum | head -c 4)" "$N"
 | |
| +
 | |
| +		[ "$fils_dhcp" = "*" ] && {
 | |
| +			json_get_values network network
 | |
| +			fils_dhcp=
 | |
| +			for net in $network; do
 | |
| +				fils_dhcp="$(ifstatus "$net" | jsonfilter -e '@.data.dhcpserver')"
 | |
| +				[ -n "$fils_dhcp" ] && break
 | |
| +			done
 | |
| +
 | |
| +			[ -z "$fils_dhcp" -a -n "$network_bridge" -a -n "$network_ifname" ] && \
 | |
| +				fils_dhcp="$(udhcpc -B -n -q -s /lib/netifd/dhcp-get-server.sh -t 1 -i "$network_ifname" 2>/dev/null)"
 | |
| +		}
 | |
| +		[ -n "$fils_dhcp" ] && append bss_conf "dhcp_server=$fils_dhcp" "$N"
 | |
| +	}
 | |
| +
 | |
| +	set_default auth_port 1812
 | |
| +	set_default dae_port 3799
 | |
| +	set_default request_cui 0
 | |
| +
 | |
| +	[ "$eap_server" -eq 0 ] && {
 | |
| +		append bss_conf "auth_server_addr=$auth_server" "$N"
 | |
| +		append bss_conf "auth_server_port=$auth_port" "$N"
 | |
| +		append bss_conf "auth_server_shared_secret=$auth_secret" "$N"
 | |
| +	}
 | |
| +
 | |
| +	[ "$request_cui" -gt 0 ] && append bss_conf "radius_request_cui=$request_cui" "$N"
 | |
| +	[ -n "$eap_reauth_period" ] && append bss_conf "eap_reauth_period=$eap_reauth_period" "$N"
 | |
| +
 | |
| +	[ -n "$dae_client" -a -n "$dae_secret" ] && {
 | |
| +		append bss_conf "radius_das_port=$dae_port" "$N"
 | |
| +		append bss_conf "radius_das_client=$dae_client $dae_secret" "$N"
 | |
| +	}
 | |
| +	json_for_each_item append_radius_auth_req_attr radius_auth_req_attr
 | |
| +
 | |
| +	[ -n "$ownip" ] && append bss_conf "own_ip_addr=$ownip" "$N"
 | |
| +	[ -n "$radius_client_addr" ] && append bss_conf "radius_client_addr=$radius_client_addr" "$N"
 | |
| +	[ "$macfilter" = radius ] && append bss_conf "macaddr_acl=2" "$N"
 | |
| +}
 | |
| +
 | |
|  hostapd_set_bss_options() {
 | |
|  	local var="$1"
 | |
|  	local phy="$2"
 | |
| @@ -659,6 +722,10 @@ hostapd_set_bss_options() {
 | |
|  			# Here we make the assumption that if we're in open mode
 | |
|  			# with WPS enabled, we got to be in unconfigured state.
 | |
|  			wps_not_configured=1
 | |
| +			[ "$macfilter" = radius ] && {
 | |
| +				append_radius_server
 | |
| +				vlan_possible = 1
 | |
| +			}
 | |
|  		;;
 | |
|  		psk|sae|psk-sae)
 | |
|  			json_get_vars key wpa_psk_file
 | |
| @@ -682,67 +749,9 @@ hostapd_set_bss_options() {
 | |
|  			wps_possible=1
 | |
|  		;;
 | |
|  		eap|eap192|eap-eap256|eap256)
 | |
| -			json_get_vars \
 | |
| -				auth_server auth_secret auth_port \
 | |
| -				dae_client dae_secret dae_port \
 | |
| -				ownip radius_client_addr \
 | |
| -				eap_reauth_period request_cui \
 | |
| -				erp_domain mobility_domain \
 | |
| -				fils_realm fils_dhcp
 | |
| -
 | |
| +			append_radius_server
 | |
|  			# radius can provide VLAN ID for clients
 | |
|  			vlan_possible=1
 | |
| -
 | |
| -			# legacy compatibility
 | |
| -			[ -n "$auth_server" ] || json_get_var auth_server server
 | |
| -			[ -n "$auth_port" ] || json_get_var auth_port port
 | |
| -			[ -n "$auth_secret" ] || json_get_var auth_secret key
 | |
| -
 | |
| -			[ "$fils" -gt 0 ] && {
 | |
| -				set_default erp_domain "$mobility_domain"
 | |
| -				set_default erp_domain "$(echo "$ssid" | md5sum | head -c 8)"
 | |
| -				set_default fils_realm "$erp_domain"
 | |
| -
 | |
| -				append bss_conf "erp_send_reauth_start=1" "$N"
 | |
| -				append bss_conf "erp_domain=$erp_domain" "$N"
 | |
| -				append bss_conf "fils_realm=$fils_realm" "$N"
 | |
| -				append bss_conf "fils_cache_id=$(echo "$fils_realm" | md5sum | head -c 4)" "$N"
 | |
| -
 | |
| -				[ "$fils_dhcp" = "*" ] && {
 | |
| -					json_get_values network network
 | |
| -					fils_dhcp=
 | |
| -					for net in $network; do
 | |
| -						fils_dhcp="$(ifstatus "$net" | jsonfilter -e '@.data.dhcpserver')"
 | |
| -						[ -n "$fils_dhcp" ] && break
 | |
| -					done
 | |
| -
 | |
| -					[ -z "$fils_dhcp" -a -n "$network_bridge" -a -n "$network_ifname" ] && \
 | |
| -						fils_dhcp="$(udhcpc -B -n -q -s /lib/netifd/dhcp-get-server.sh -t 1 -i "$network_ifname" 2>/dev/null)"
 | |
| -				}
 | |
| -				[ -n "$fils_dhcp" ] && append bss_conf "dhcp_server=$fils_dhcp" "$N"
 | |
| -			}
 | |
| -
 | |
| -			set_default auth_port 1812
 | |
| -			set_default dae_port 3799
 | |
| -			set_default request_cui 0
 | |
| -
 | |
| -			[ "$eap_server" -eq 0 ] && {
 | |
| -				append bss_conf "auth_server_addr=$auth_server" "$N"
 | |
| -				append bss_conf "auth_server_port=$auth_port" "$N"
 | |
| -				append bss_conf "auth_server_shared_secret=$auth_secret" "$N"
 | |
| -			}
 | |
| -
 | |
| -			[ "$request_cui" -gt 0 ] && append bss_conf "radius_request_cui=$request_cui" "$N"
 | |
| -			[ -n "$eap_reauth_period" ] && append bss_conf "eap_reauth_period=$eap_reauth_period" "$N"
 | |
| -
 | |
| -			[ -n "$dae_client" -a -n "$dae_secret" ] && {
 | |
| -				append bss_conf "radius_das_port=$dae_port" "$N"
 | |
| -				append bss_conf "radius_das_client=$dae_client $dae_secret" "$N"
 | |
| -			}
 | |
| -			json_for_each_item append_radius_auth_req_attr radius_auth_req_attr
 | |
| -
 | |
| -			[ -n "$ownip" ] && append bss_conf "own_ip_addr=$ownip" "$N"
 | |
| -			[ -n "$radius_client_addr" ] && append bss_conf "radius_client_addr=$radius_client_addr" "$N"
 | |
|  			append bss_conf "eapol_key_index_workaround=1" "$N"
 | |
|  			append bss_conf "ieee8021x=1" "$N"
 | |
|  
 | |
| diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
 | |
| index f044325752..924f259e25 100755
 | |
| --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
 | |
| +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
 | |
| @@ -46,6 +46,15 @@ platform_do_upgrade() {
 | |
|  		dd if=/dev/mtd5 bs=1024 count=52224 >> /tmp/backup_firmware.bin
 | |
|  		mtd -e firmware2 write /tmp/backup_firmware.bin firmware2
 | |
|  		;;
 | |
| +	actiontec,web7200)
 | |
| +		if grep -q bootselect=0 /proc/cmdline; then
 | |
| +			PART_NAME=firmware2
 | |
| +			fw_setenv bootselect 1 || exit 1
 | |
| +		else
 | |
| +			PART_NAME=firmware1
 | |
| +			fw_setenv bootselect 0 || exit 1
 | |
| +		fi
 | |
| +		;;
 | |
|  	esac
 | |
|  
 | |
|  	case "$board" in
 | |
| -- 
 | |
| 2.25.1
 | |
| 
 | 
