]> git.ipfire.org Git - people/stevee/network.git/commitdiff
Make the wireless regulatory domain a global configuration option
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 26 Aug 2014 13:22:30 +0000 (15:22 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 26 Aug 2014 13:22:30 +0000 (15:22 +0200)
It does not make any sense to make this configurable per device
as the kernel does not support this.

man/network-port-batman-adv-port.xml
src/functions/functions.hostapd
src/functions/functions.phy
src/functions/functions.wireless
src/functions/functions.wpa_supplicant
src/helpers/hostapd-config-helper
src/hooks/ports/batman-adv-port
src/hooks/ports/wireless-ap
src/hooks/zones/batman-adv

index 2113a1068cfc91149a2c4d179cd16f9d0e7c2c48..15f2f4e1777af55891d23724c4c85aefa58085c4 100644 (file)
                                </listitem>
                        </varlistentry>
 
-                       <varlistentry>
-                               <term>
-                                       <option>--country-code=<replaceable>CODE</replaceable></option>
-                               </term>
-
-                               <listitem>
-                                       <para>
-                                               Sets the country code for the wireless interface.
-                                       </para>
-                               </listitem>
-                       </varlistentry>
-
                        <varlistentry>
                                <term>
                                        <option>--phy=<replaceable>PHY</replaceable></option>
index 1d10b978fff241cd9c1508bef31fc1f143d80a94..d98bf9fe899471d26b89e2cba365329e4b8e911f 100644 (file)
@@ -33,7 +33,7 @@ function hostapd_config_write() {
 
        local broadcast_ssid
        local channel
-       local country_code
+       local country_code="$(wireless_get_reg_domain)"
        local encryption
        local ieee80211d="1"
        local key
@@ -49,9 +49,6 @@ function hostapd_config_write() {
                        --channel=*)
                                channel=$(cli_get_val ${1})
                                ;;
-                       --country-code=*)
-                               country_code=$(cli_get_val ${1})
-                               ;;
                        --encryption=*)
                                encryption=$(cli_get_val ${1})
                                ;;
@@ -93,7 +90,6 @@ function hostapd_config_write() {
        assert isset channel
        assert isinteger channel
 
-       assert isset country_code
        assert isset mode
        assert isset ssid
 
index f6b749843ca469ba06d179c238a493d2fd265cb4..366eccc2c8245ca4f00c51bcf6a4d676e70fb32a 100644 (file)
@@ -46,7 +46,6 @@ function phy_list() {
 
 function phy_get() {
        local info=${1}
-
        local phy
 
        if listmatch ${info} $(phy_list); then
@@ -65,6 +64,8 @@ function phy_get() {
                done
        fi
 
+       log DEBUG "Searching for phy = ${info}, found ${phy:-none}"
+
        if [ -z "${phy}" ]; then
                return ${EXIT_ERROR}
        fi
index cd17de4cf97d99568933b3137f1c89005d91b09b..f32733acd8d34a43c826c5310d1a3566c7bd9f21 100644 (file)
 #                                                                             #
 ###############################################################################
 
+# Sets the global wireless country code. Default is 00 = world.
+WIRELESS_REGULATORY_DOMAIN="00"
+NETWORK_CONFIG_FILE_PARAMS="${NETWORK_CONFIG_FILE_PARAMS} WIRELESS_REGULATORY_DOMAIN"
+
+init_register wireless_init_reg_domain
+
 function wireless_create() {
        local device=${1}
        assert isset device
@@ -95,6 +101,29 @@ function wireless_remove() {
        return ${ret}
 }
 
+function wireless_get_reg_domain() {
+       # Returns the country code for the wireless device.
+       # Defaults to 00 = world if unset.
+       print "${WIRELESS_REGULATORY_DOMAIN:-00}"
+}
+
+function wireless_init_reg_domain() {
+       local country_code="$(wireless_get_reg_domain)"
+
+       wireless_set_reg_domain "${country_code}"
+}
+
+function wireless_set_reg_domain() {
+       local country_code="${1}"
+       assert isset country_code
+
+       # Before the wireless reg domain is set, it helps to reset to 00 first.
+       iw reg set 00 &>/dev/null
+
+       log INFO "Setting wireless regulatory domain country to '${country_code}'"
+       iw reg set "${country_code}"
+}
+
 function wireless_channel_to_frequency() {
        # http://en.wikipedia.org/wiki/List_of_WLAN_channels
 
index 1c043aff857b81f4ebc9116d9847a73ec77288c0..b2357d59d5a6ce50678ac9a911c7adbdd5086c6a 100644 (file)
@@ -30,7 +30,7 @@ function wpa_supplicant_config_write() {
 
        shift 2
 
-       local ap_scan=1 country_code mode key ssid
+       local ap_scan=1 mode key ssid
 
        local arg
        for arg in "$@"; do
@@ -38,9 +38,6 @@ function wpa_supplicant_config_write() {
                        --ap-scan=*)
                                ap_scan=$(cli_get_val ${arg})
                                ;;
-                       --country-code=*)
-                               country_code=$(cli_get_val ${arg})
-                               ;;
                        --mode=*)
                                mode=$(cli_get_val ${arg})
 
@@ -64,6 +61,7 @@ function wpa_supplicant_config_write() {
        assert isset mode
 
        local auth_alg key_mgmt proto ssid psk wep_key0 wep_tx_keyidx
+       local country_code="$(wireless_get_reg_domain)"
 
        case "${mode}" in
                # Normal WPA.
index 668945b091b20cd2c45b0a2479e832fe1d038a14..5ad2d761c9392db94a9bde4af1f5f9ad1a3b5c48 100644 (file)
@@ -37,7 +37,6 @@ case "${action}" in
                hostapd_config_write ${port} ${config_file} \
                        --broadcast-ssid="${BROADCAST_SSID}" \
                        --channel="${CHANNEL}" \
-                       --country-code="${COUNTRY_CODE}" \
                        --encryption="${ENCRYPTION}" \
                        --key="${KEY}" \
                        --mode="${MODE}" \
index bfa73215a42692a6cd4e17f12c5cfcbc41a4cbf2..b14351e052c52d18bfb58976004cc97532862b6e 100644 (file)
 
 . /usr/lib/network/header-port
 
-HOOK_SETTINGS="HOOK ADDRESS MESH_ID SSID CHANNEL COUNTRY_CODE PHY"
+HOOK_SETTINGS="HOOK ADDRESS MESH_ID SSID CHANNEL PHY"
 
 ADDRESS=$(mac_generate)
 CHANNEL=1
-COUNTRY_CODE="US"
 MESH_ID=
 SSID=
 
@@ -37,7 +36,6 @@ function hook_check() {
        assert isset ADDRESS
        assert ismac ADDRESS
        assert isset CHANNEL
-       assert isset COUNTRY_CODE
        assert isset MESH_ID
        assert ismac MESH_ID
        assert isset PHY
@@ -54,9 +52,6 @@ function hook_create() {
                        --channel=*)
                                CHANNEL=$(cli_get_val ${1})
                                ;;
-                       --country-code=*)
-                               COUNTRY_CODE=$(cli_get_val ${1})
-                               ;;
                        --phy=*)
                                PHY=$(cli_get_val ${1})
                                ;;
@@ -97,9 +92,6 @@ function hook_edit() {
                        --channel=*)
                                CHANNEL=$(cli_get_val ${1})
                                ;;
-                       --country-code=*)
-                               COUNTRY_CODE=$(cli_get_val ${1})
-                               ;;
                        --mesh-id=*)
                                MESH_ID=$(cli_get_val ${1})
                                ;;
index c6d91da042a75b78e06c4132e17abe72a338947d..ba8a7fd529e145709ff80260edc18912c4b4ea8e 100644 (file)
 
 . /usr/lib/network/header-port
 
-HOOK_SETTINGS="HOOK ADDRESS BROADCAST_SSID CHANNEL COUNTRY_CODE MODE PHY SSID"
+HOOK_SETTINGS="HOOK ADDRESS BROADCAST_SSID CHANNEL MODE PHY SSID"
 HOOK_SETTINGS="${HOOK_SETTINGS} ENCRYPTION KEY"
 
 ADDRESS=$(mac_generate)
 BROADCAST_SSID=on
 CHANNEL=1
-COUNTRY_CODE="US"
 ENCRYPTION=""
 KEY=""
 MODE="g"
@@ -39,7 +38,6 @@ function hook_check() {
        assert isset BROADCAST_SSID
        assert isbool BROADCAST_SSID
        assert isset CHANNEL
-       assert isset COUNTRY_CODE
        assert isset MODE
        assert isoneof MODE a b g n
        assert isset PHY
@@ -64,9 +62,6 @@ function hook_create() {
                        --channel=*)
                                CHANNEL=$(cli_get_val ${1})
                                ;;
-                       --country-code=*)
-                               COUNTRY_CODE=$(cli_get_val ${1})
-                               ;;
                        --encryption=*)
                                ENCRYPTION=$(cli_get_val ${1})
                                ;;
@@ -120,9 +115,6 @@ function hook_edit() {
                        --channel=*)
                                CHANNEL=$(cli_get_val ${1})
                                ;;
-                       --country-code=*)
-                               COUNTRY_CODE=$(cli_get_val ${1})
-                               ;;
                        --encryption=*)
                                ENCRYPTION=$(cli_get_val ${1})
                                ;;
index 7390114e17a1ddf1fe46722e1235f41892a8221b..23aa66d7d5506f461ea36273fc22690b39590f1d 100644 (file)
 
 . /usr/lib/network/header-zone
 
-HOOK_SETTINGS="HOOK ADDRESS MESH_ID SSID CHANNEL COUNTRY_CODE PHY"
+HOOK_SETTINGS="HOOK ADDRESS MESH_ID SSID CHANNEL PHY"
 
 # Default values
 ADDRESS=$(mac_generate)
 CHANNEL=1
-COUNTRY_CODE="US"
 MESH_ID=
 SSID=
 
@@ -38,7 +37,6 @@ function hook_check() {
        assert isset ADDRESS
        assert ismac ADDRESS
        assert isset CHANNEL
-       assert isset COUNTRY_CODE
        assert isset MESH_ID
        assert ismac MESH_ID
        assert isset PHY
@@ -55,9 +53,6 @@ function hook_parse_cmdline() {
                        --channel=*)
                                CHANNEL="$(cli_get_val ${1})"
                                ;;
-                       --country-code=*)
-                               COUNTRY_CODE="$(cli_get_val ${1})"
-                               ;;
                        --mesh-id=*)
                                MESH_ID="$(cli_get_val ${1})"
                                ;;