tools/ios_convert: parse DisplayedOperatorName

Some hotspot networks do not contain SSID_STR, which was required
for both naming the provisioning file as well as the 'Name' key.
The DisplayedOperatorName is a better option for this 'Name' key
and could also be used for the filename.

Now, DisplayedOperatorName is preferred, and if not found SSID_STR
is used.
This commit is contained in:
James Prestwood 2019-08-26 16:34:18 -07:00 committed by Denis Kenzior
parent 9e81a8115a
commit ab0c8cae3c
1 changed files with 13 additions and 3 deletions

View File

@ -17,6 +17,7 @@ class Network:
self.username = None
self.password = None
self.ssid = None
self.display_name = None
def process_eap_config(eap_conf, network):
for m in range(len(eap_conf)):
@ -50,6 +51,8 @@ def process_payload_array(parray):
network.is_hotspot = False
elif parray[l].text == "SSID_STR":
network.ssid = parray[l + 1].text
elif parray[l].text == "DisplayedOperatorName":
network.display_name = parray[l + 1].text
elif parray[l].text == "EAPClientConfiguration":
process_eap_config(parray[l + 1], network)
@ -119,9 +122,16 @@ def write_network(network, root_ca_path):
output += "EAP-%s-Phase2-Password=%s\n" % \
(eap, network.password)
if network.display_name:
name = network.display_name
elif network.ssid:
name = network.ssid
else:
name = "NameUnknown"
if network.is_hotspot:
conf_file = iwd_dir + '/hotspot/' + \
os.path.splitext(args.input)[0] + '.conf'
name + '.conf'
output += "[Hotspot]\n"
output += "NAIRealmNames="
@ -132,10 +142,10 @@ def write_network(network, root_ca_path):
output += ','
output += "\n"
output += "Name=%s\n" % network.ssid
output += "Name=%s\n" % name
else:
conf_file = iwd_dir + '/' + network.ssid + '.8021x'
conf_file = iwd_dir + '/' + name + '.8021x'
# Some AP's require older protocol versions. There should be no harm in
# setting this all the time.