Skip to content

Commit

Permalink
[WirelessRenderer] Added support for multiple SSIDs #12
Browse files Browse the repository at this point in the history
Closes #12
  • Loading branch information
nemesifier committed Sep 23, 2015
1 parent ca12ccf commit 0aa5e01
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 146 deletions.
48 changes: 26 additions & 22 deletions netjsonconfig/backends/openwrt/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,32 +170,36 @@ def __get_htmode(self, radio):
return 'NONE'

def _get_wifi_interfaces(self):
# select interfaces that have type == "wireless"
wifi_interfaces = [i for i in self.config.get('interfaces', []) if 'wireless' in i]
# results container
uci_wifi_ifaces = []
for wifi_interface in wifi_interfaces:
wireless = wifi_interface['wireless']
# prepare UCI wifi-iface directive
uci_wifi = wireless.copy()
# rename radio to device
uci_wifi['device'] = wireless['radio']
del uci_wifi['radio']
# determine mode
modes = {
'access_point': 'ap',
'station': 'sta',
'adhoc': 'adhoc',
'wds': 'wds',
'monitor': 'monitor',
'802.11s': 'mesh'
}
uci_wifi['mode'] = modes[wireless['mode']]
uci_wifi['network'] = wifi_interface['name']
if uci_wifi.get('encryption'):
del uci_wifi['encryption']
uci_encryption = self.__get_encryption(wireless)
uci_wifi.update(uci_encryption)
uci_wifi_ifaces.append(sorted_dict(uci_wifi))
# each wireless interface
# can have multiple SSIDs
wireless_interfaces = wifi_interface['wireless']
for wireless in wireless_interfaces:
# prepare UCI wifi-iface directive
uci_wifi = wireless.copy()
# rename radio to device
uci_wifi['device'] = wireless['radio']
del uci_wifi['radio']
# determine mode
modes = {
'access_point': 'ap',
'station': 'sta',
'adhoc': 'adhoc',
'wds': 'wds',
'monitor': 'monitor',
'802.11s': 'mesh'
}
uci_wifi['mode'] = modes[wireless['mode']]
uci_wifi['network'] = wifi_interface['name']
if uci_wifi.get('encryption'):
del uci_wifi['encryption']
uci_encryption = self.__get_encryption(wireless)
uci_wifi.update(uci_encryption)
uci_wifi_ifaces.append(sorted_dict(uci_wifi))
return uci_wifi_ifaces

def __get_encryption(self, wireless):
Expand Down
155 changes: 80 additions & 75 deletions netjsonconfig/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,81 +299,86 @@
]
},
"wireless": {
"id": "wireless",
"type": "object",
"title": "Wireless settings",
"additionalProperties": True,
"required": [
"radio",
"mode",
"ssid"
],
"properties": {
"radio": {
"id": "radio",
"type": "string"
},
"mode": {
"id": "mode",
"type": "string",
"enum": [
"access_point",
"station",
"adhoc",
"wds",
"monitor",
"802.11s"
]
},
"ssid": {
"id": "ssid",
"type": "string"
},
"bssid": {
"id": "bssid",
"type": "string"
},
"hidden": {
"id": "bssid",
"type": "boolean",
"default": False
},
"encryption": {
"id": "encryption",
"type": "object",
"title": "Encryption",
"required": [
"enabled",
"protocol",
"key"
],
"properties": {
"enabled": {
"id": "enabled",
"type": "boolean"
},
"protocol": {
"id": "protocol",
"type": "string",
"enum": [
"wep_open",
"wep_shared",
"wpa_personal",
"wpa2_personal",
"wpa_personal_mixed",
"wpa_enterprise",
"wpa2_enterprise",
"wpa_enterprise_mixed",
"wps"
]
},
"ciphers": {
"id": "ciphers",
"type": "array"
},
"key": {
"id": "key",
"type": "string"
"type": "array",
"title": "Wireless interfaces",
"uniqueItems": True,
"additionalItems": True,
"items": {
"type": "object",
"title": "Wireless Interface",
"additionalProperties": True,
"required": [
"radio",
"mode",
"ssid"
],
"properties": {
"radio": {
"id": "radio",
"type": "string"
},
"mode": {
"id": "mode",
"type": "string",
"enum": [
"access_point",
"station",
"adhoc",
"wds",
"monitor",
"802.11s"
]
},
"ssid": {
"id": "ssid",
"type": "string"
},
"bssid": {
"id": "bssid",
"type": "string"
},
"hidden": {
"id": "bssid",
"type": "boolean",
"default": False
},
"encryption": {
"id": "encryption",
"type": "object",
"title": "Encryption",
"required": [
"enabled",
"protocol",
"key"
],
"properties": {
"enabled": {
"id": "enabled",
"type": "boolean"
},
"protocol": {
"id": "protocol",
"type": "string",
"enum": [
"wep_open",
"wep_shared",
"wpa_personal",
"wpa2_personal",
"wpa_personal_mixed",
"wpa_enterprise",
"wpa2_enterprise",
"wpa_enterprise_mixed",
"wps"
]
},
"ciphers": {
"id": "ciphers",
"type": "array"
},
"key": {
"id": "key",
"type": "string"
}
}
}
}
Expand Down
Loading

0 comments on commit 0aa5e01

Please sign in to comment.