Skip to content

Commit dc574be

Browse files
masapnemesifier
authored andcommitted
[feature] OpenWrt: Made IEEE802.11w configurable #192
This patch is tested on these. - OpenWrt: latest (4b587f25614f3f7215360f96807ce760fa4ef3aa) - hardware: TP-Link Archer C6 v2 Closes #192 Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
1 parent 04e2bf2 commit dc574be

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

netjsonconfig/backends/openwrt/converters/wireless.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ def __netjson_encryption(self, wifi):
271271
if key.startswith('s:'):
272272
key = key[2:]
273273
settings['key'] = key
274+
# Management Frame Protection
275+
if 'ieee80211w' in wifi:
276+
settings['ieee80211w'] = wifi.pop('ieee80211w')
274277
# create NetJSON encryption object
275278
wifi['encryption'] = self.__netjson_encryption_typecast(settings)
276279

netjsonconfig/schema.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,23 @@
443443
}
444444
}
445445
},
446+
"encryption_mfp_property": {
447+
"properties": {
448+
"ieee80211w": {
449+
"type": "string",
450+
"title": "management frame protection",
451+
"enum": ["0", "1", "2"],
452+
"options": {"enum_titles": ["disabled", "optional", "required"]},
453+
"propertyOrder": 4,
454+
}
455+
}
456+
},
446457
"encryption_wpa_personal": {
447458
"title": "WPA2/WPA Personal",
448459
"allOf": [
449460
{"$ref": "#/definitions/encryption_base_settings"},
450461
{"$ref": "#/definitions/encryption_cipher_property"},
462+
{"$ref": "#/definitions/encryption_mfp_property"},
451463
{
452464
"properties": {
453465
"protocol": {
@@ -495,6 +507,7 @@
495507
"allOf": [
496508
{"$ref": "#/definitions/encryption_base_settings"},
497509
{"$ref": "#/definitions/encryption_cipher_property"},
510+
{"$ref": "#/definitions/encryption_mfp_property"},
498511
{"$ref": "#/definitions/encryption_wpa_enterprise_base_settings"},
499512
{
500513
"required": ["server"],
@@ -536,6 +549,7 @@
536549
"additionalProperties": True,
537550
"allOf": [
538551
{"$ref": "#/definitions/encryption_cipher_property"},
552+
{"$ref": "#/definitions/encryption_mfp_property"},
539553
{"$ref": "#/definitions/encryption_wpa_enterprise_base_settings"},
540554
{
541555
"properties": {

tests/openwrt/test_encryption.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class TestEncryption(unittest.TestCase, _TabsMixin):
2020
"protocol": "wpa2_personal",
2121
"cipher": "tkip+ccmp",
2222
"key": "passphrase012345",
23+
"ieee80211w": "2",
2324
},
2425
},
2526
}
@@ -36,6 +37,7 @@ class TestEncryption(unittest.TestCase, _TabsMixin):
3637
config wifi-iface 'wifi_wlan0'
3738
option device 'radio0'
3839
option encryption 'psk2+tkip+ccmp'
40+
option ieee80211w '2'
3941
option ifname 'wlan0'
4042
option key 'passphrase012345'
4143
option mode 'ap'
@@ -65,6 +67,7 @@ def test_parse_wpa2_personal(self):
6567
"protocol": "wpa_personal_mixed",
6668
"cipher": "ccmp",
6769
"key": "passphrase012345",
70+
"ieee80211w": "0",
6871
},
6972
},
7073
}
@@ -81,6 +84,7 @@ def test_parse_wpa2_personal(self):
8184
config wifi-iface 'wifi_wlan0'
8285
option device 'radio0'
8386
option encryption 'psk-mixed+ccmp'
87+
option ieee80211w '0'
8488
option ifname 'wlan0'
8589
option key 'passphrase012345'
8690
option mode 'ap'
@@ -309,6 +313,7 @@ def test_parse_wpa_enterprise_ap(self):
309313
"eap_type": "tls",
310314
"identity": "test-identity",
311315
"password": "test-password",
316+
"ieee80211w": "1",
312317
},
313318
},
314319
}
@@ -328,6 +333,7 @@ def test_parse_wpa_enterprise_ap(self):
328333
option eap_type 'tls'
329334
option encryption 'wpa2'
330335
option identity 'test-identity'
336+
option ieee80211w '1'
331337
option ifname 'wlan0'
332338
option mode 'sta'
333339
option network 'wlan0'

0 commit comments

Comments
 (0)