def _generate_wireless_settings_data(settings):
    """Generates a wireless settings data array to push to
    the router from the given wireless settings."""
    WirelessSettings = settings.__class__
    settings.ensure_valid()
    data = {}
    data['ssid'] = settings.ssid
    data['channel'] = settings.channel
    data['Save'] = 'Save'
    for k in ('region', 'mode'):
        data[k] = settings.get_internal_param(k)
    if settings.is_enabled:
        data['ap'] = 2
    if settings.is_broadcasting_ssid:
        data['broadcast'] = 2
    if settings.security_type_is_wep:
        data['secType'] = 1
        data['secOpt'] = 3
        data['keynum'] = 1
        merge_with = {'key2': '', 'key3': '', 'key4': '', 'length2': 0,
            'length3': 0, 'length4': 0}
        data = dict(data, **merge_with)
        bit_length = (5 if settings.security_type == WirelessSettings.
            SECURITY_TYPE_WEP64 else 13)
        data['key1'] = settings.password
        data['length1'] = bit_length
        data['keytype'] = 1 if settings.is_wep_password_in_hex else 2
    elif settings.security_type_is_wpa:
        data['secType'] = 3
        data['encrptType'] = 1
        data['interval'] = 0
        data['pskSecret'] = settings.password
        if settings.security_type == WirelessSettings.SECURITY_TYPE_WPA:
            data['secOpt'] = 1
        else:
            data['secOpt'] = 2
    else:
        data['secType'] = 1
        data['keytype'] = 1
        merge_with = {'key1': '', 'key2': '', 'key3': '', 'key4': '',
            'length1': 0, 'length2': 0, 'length3': 0, 'length4': 0}
        data = dict(data, **merge_with)
    if settings.security_type != WirelessSettings.SECURITY_TYPE_NONE:
        data['secStatus'] = 2
    return data
