1#!/usr/bin/env python3
2#
3#   Copyright 2017 - Google
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#         http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17import itertools
18
19BAND_2G = '2g'
20BAND_5G = '5g'
21CHANNEL_BANDWIDTH_20MHZ = 20
22CHANNEL_BANDWIDTH_40MHZ = 40
23CHANNEL_BANDWIDTH_80MHZ = 80
24CHANNEL_BANDWIDTH_160MHZ = 160
25WEP = 0
26WPA1 = 1
27WPA2 = 2
28WPA3 = 2  # same as wpa2, distinguished by wpa_key_mgmt
29MIXED = 3
30ENT = 4  # get the correct constant
31MAX_WPA_PSK_LENGTH = 64
32MIN_WPA_PSK_LENGTH = 8
33MAX_WPA_PASSWORD_LENGTH = 63
34WPA_STRICT_REKEY = 1
35WPA_DEFAULT_CIPHER = 'TKIP'
36WPA2_DEFAULT_CIPER = 'CCMP'
37WPA_GROUP_KEY_ROTATION_TIME = 600
38WPA_STRICT_REKEY_DEFAULT = True
39WPA_STRING = 'wpa'
40WPA2_STRING = 'wpa2'
41WPA_MIXED_STRING = 'wpa/wpa2'
42WPA3_STRING = 'wpa3'
43WPA3_KEY_MGMT = 'SAE'
44ENT_STRING = 'ent'
45ENT_KEY_MGMT = 'WPA-EAP'
46IEEE8021X = 1
47WLAN0_STRING = 'wlan0'
48WLAN1_STRING = 'wlan1'
49WLAN2_STRING = 'wlan2'
50WLAN3_STRING = 'wlan3'
51WLAN0_GALE = 'wlan-2400mhz'
52WLAN1_GALE = 'wlan-5000mhz'
53WEP_STRING = 'wep'
54WEP_DEFAULT_KEY = 0
55WEP_HEX_LENGTH = [10, 26, 32, 58]
56WEP_STR_LENGTH = [5, 13, 16]
57AP_DEFAULT_CHANNEL_2G = 6
58AP_DEFAULT_CHANNEL_5G = 36
59AP_DEFAULT_MAX_SSIDS_2G = 8
60AP_DEFAULT_MAX_SSIDS_5G = 8
61AP_SSID_LENGTH_2G = 8
62AP_SSID_MIN_LENGTH_2G = 1
63AP_SSID_MAX_LENGTH_2G = 32
64AP_PASSPHRASE_LENGTH_2G = 10
65AP_SSID_LENGTH_5G = 8
66AP_SSID_MIN_LENGTH_5G = 1
67AP_SSID_MAX_LENGTH_5G = 32
68AP_PASSPHRASE_LENGTH_5G = 10
69INTERFACE_2G_LIST = [WLAN0_STRING, WLAN0_GALE]
70INTERFACE_5G_LIST = [WLAN1_STRING, WLAN1_GALE]
71HIGH_BEACON_INTERVAL = 300
72LOW_BEACON_INTERVAL = 100
73HIGH_DTIM = 3
74LOW_DTIM = 1
75
76# A mapping of frequency to channel number.  This includes some
77# frequencies used outside the US.
78CHANNEL_MAP = {
79    2412: 1,
80    2417: 2,
81    2422: 3,
82    2427: 4,
83    2432: 5,
84    2437: 6,
85    2442: 7,
86    2447: 8,
87    2452: 9,
88    2457: 10,
89    2462: 11,
90    # 12, 13 are only legitimate outside the US.
91    2467: 12,
92    2472: 13,
93    # 14 is for Japan, DSSS and CCK only.
94    2484: 14,
95    # 34 valid in Japan.
96    5170: 34,
97    # 36-116 valid in the US, except 38, 42, and 46, which have
98    # mixed international support.
99    5180: 36,
100    5190: 38,
101    5200: 40,
102    5210: 42,
103    5220: 44,
104    5230: 46,
105    5240: 48,
106    # DFS channels.
107    5260: 52,
108    5280: 56,
109    5300: 60,
110    5320: 64,
111    5500: 100,
112    5520: 104,
113    5540: 108,
114    5560: 112,
115    5580: 116,
116    # 120, 124, 128 valid in Europe/Japan.
117    5600: 120,
118    5620: 124,
119    5640: 128,
120    # 132+ valid in US.
121    5660: 132,
122    5680: 136,
123    5700: 140,
124    # 144 is supported by a subset of WiFi chips
125    # (e.g. bcm4354, but not ath9k).
126    5720: 144,
127    # End DFS channels.
128    5745: 149,
129    5755: 151,
130    5765: 153,
131    5775: 155,
132    5795: 159,
133    5785: 157,
134    5805: 161,
135    5825: 165
136}
137FREQUENCY_MAP = {v: k for k, v in CHANNEL_MAP.items()}
138
139US_CHANNELS_2G = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
140US_CHANNELS_5G = [
141    36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128,
142    132, 136, 140, 144, 149, 153, 157, 161, 165
143]
144
145MODE_11A = 'a'
146MODE_11B = 'b'
147MODE_11G = 'g'
148MODE_11N_MIXED = 'n-mixed'
149MODE_11N_PURE = 'n-only'
150MODE_11AC_MIXED = 'ac-mixed'
151MODE_11AC_PURE = 'ac-only'
152
153N_CAPABILITY_LDPC = object()
154N_CAPABILITY_HT20 = object()
155N_CAPABILITY_HT40_PLUS = object()
156N_CAPABILITY_HT40_MINUS = object()
157N_CAPABILITY_GREENFIELD = object()
158N_CAPABILITY_SGI20 = object()
159N_CAPABILITY_SGI40 = object()
160N_CAPABILITY_TX_STBC = object()
161N_CAPABILITY_RX_STBC1 = object()
162N_CAPABILITY_RX_STBC12 = object()
163N_CAPABILITY_RX_STBC123 = object()
164N_CAPABILITY_DSSS_CCK_40 = object()
165N_CAPABILITY_LSIG_TXOP_PROT = object()
166N_CAPABILITY_40_INTOLERANT = object()
167N_CAPABILITY_MAX_AMSDU_7935 = object()
168N_CAPABILITY_DELAY_BLOCK_ACK = object()
169N_CAPABILITY_SMPS_STATIC = object()
170N_CAPABILITY_SMPS_DYNAMIC = object()
171N_CAPABILITIES_MAPPING = {
172    N_CAPABILITY_LDPC: '[LDPC]',
173    N_CAPABILITY_HT20: '[HT20]',
174    N_CAPABILITY_HT40_PLUS: '[HT40+]',
175    N_CAPABILITY_HT40_MINUS: '[HT40-]',
176    N_CAPABILITY_GREENFIELD: '[GF]',
177    N_CAPABILITY_SGI20: '[SHORT-GI-20]',
178    N_CAPABILITY_SGI40: '[SHORT-GI-40]',
179    N_CAPABILITY_TX_STBC: '[TX-STBC]',
180    N_CAPABILITY_RX_STBC1: '[RX-STBC1]',
181    N_CAPABILITY_RX_STBC12: '[RX-STBC12]',
182    N_CAPABILITY_RX_STBC123: '[RX-STBC123]',
183    N_CAPABILITY_DSSS_CCK_40: '[DSSS_CCK-40]',
184    N_CAPABILITY_LSIG_TXOP_PROT: '[LSIG-TXOP-PROT]',
185    N_CAPABILITY_40_INTOLERANT: '[40-INTOLERANT]',
186    N_CAPABILITY_MAX_AMSDU_7935: '[MAX-AMSDU-7935]',
187    N_CAPABILITY_DELAY_BLOCK_ACK: '[DELAYED-BA]',
188    N_CAPABILITY_SMPS_STATIC: '[SMPS-STATIC]',
189    N_CAPABILITY_SMPS_DYNAMIC: '[SMPS-DYNAMIC]'
190}
191N_CAPABILITIES_MAPPING_INVERSE = {
192    v: k
193    for k, v in N_CAPABILITIES_MAPPING.items()
194}
195N_CAPABILITY_HT40_MINUS_CHANNELS = object()
196N_CAPABILITY_HT40_PLUS_CHANNELS = object()
197AC_CAPABILITY_VHT160 = object()
198AC_CAPABILITY_VHT160_80PLUS80 = object()
199AC_CAPABILITY_RXLDPC = object()
200AC_CAPABILITY_SHORT_GI_80 = object()
201AC_CAPABILITY_SHORT_GI_160 = object()
202AC_CAPABILITY_TX_STBC_2BY1 = object()
203AC_CAPABILITY_RX_STBC_1 = object()
204AC_CAPABILITY_RX_STBC_12 = object()
205AC_CAPABILITY_RX_STBC_123 = object()
206AC_CAPABILITY_RX_STBC_1234 = object()
207AC_CAPABILITY_SU_BEAMFORMER = object()
208AC_CAPABILITY_SU_BEAMFORMEE = object()
209AC_CAPABILITY_BF_ANTENNA_2 = object()
210AC_CAPABILITY_BF_ANTENNA_3 = object()
211AC_CAPABILITY_BF_ANTENNA_4 = object()
212AC_CAPABILITY_SOUNDING_DIMENSION_2 = object()
213AC_CAPABILITY_SOUNDING_DIMENSION_3 = object()
214AC_CAPABILITY_SOUNDING_DIMENSION_4 = object()
215AC_CAPABILITY_MU_BEAMFORMER = object()
216AC_CAPABILITY_MU_BEAMFORMEE = object()
217AC_CAPABILITY_VHT_TXOP_PS = object()
218AC_CAPABILITY_HTC_VHT = object()
219AC_CAPABILITY_MAX_A_MPDU_LEN_EXP0 = object()
220AC_CAPABILITY_MAX_A_MPDU_LEN_EXP1 = object()
221AC_CAPABILITY_MAX_A_MPDU_LEN_EXP2 = object()
222AC_CAPABILITY_MAX_A_MPDU_LEN_EXP3 = object()
223AC_CAPABILITY_MAX_A_MPDU_LEN_EXP4 = object()
224AC_CAPABILITY_MAX_A_MPDU_LEN_EXP5 = object()
225AC_CAPABILITY_MAX_A_MPDU_LEN_EXP6 = object()
226AC_CAPABILITY_MAX_A_MPDU_LEN_EXP7 = object()
227AC_CAPABILITY_VHT_LINK_ADAPT2 = object()
228AC_CAPABILITY_VHT_LINK_ADAPT3 = object()
229AC_CAPABILITY_RX_ANTENNA_PATTERN = object()
230AC_CAPABILITY_TX_ANTENNA_PATTERN = object()
231AC_CAPABILITY_MAX_MPDU_7991 = object()
232AC_CAPABILITY_MAX_MPDU_11454 = object()
233AC_CAPABILITIES_MAPPING = {
234    AC_CAPABILITY_VHT160: '[VHT160]',
235    AC_CAPABILITY_VHT160_80PLUS80: '[VHT160-80PLUS80]',
236    AC_CAPABILITY_RXLDPC: '[RXLDPC]',
237    AC_CAPABILITY_SHORT_GI_80: '[SHORT-GI-80]',
238    AC_CAPABILITY_SHORT_GI_160: '[SHORT-GI-160]',
239    AC_CAPABILITY_TX_STBC_2BY1: '[TX-STBC-2BY1]',
240    AC_CAPABILITY_RX_STBC_1: '[RX-STBC-1]',
241    AC_CAPABILITY_RX_STBC_12: '[RX-STBC-12]',
242    AC_CAPABILITY_RX_STBC_123: '[RX-STBC-123]',
243    AC_CAPABILITY_RX_STBC_1234: '[RX-STBC-1234]',
244    AC_CAPABILITY_SU_BEAMFORMER: '[SU-BEAMFORMER]',
245    AC_CAPABILITY_SU_BEAMFORMEE: '[SU-BEAMFORMEE]',
246    AC_CAPABILITY_BF_ANTENNA_2: '[BF-ANTENNA-2]',
247    AC_CAPABILITY_BF_ANTENNA_3: '[BF-ANTENNA-3]',
248    AC_CAPABILITY_BF_ANTENNA_4: '[BF-ANTENNA-4]',
249    AC_CAPABILITY_SOUNDING_DIMENSION_2: '[SOUNDING-DIMENSION-2]',
250    AC_CAPABILITY_SOUNDING_DIMENSION_3: '[SOUNDING-DIMENSION-3]',
251    AC_CAPABILITY_SOUNDING_DIMENSION_4: '[SOUNDING-DIMENSION-4]',
252    AC_CAPABILITY_MU_BEAMFORMER: '[MU-BEAMFORMER]',
253    AC_CAPABILITY_MU_BEAMFORMEE: '[MU-BEAMFORMEE]',
254    AC_CAPABILITY_VHT_TXOP_PS: '[VHT-TXOP-PS]',
255    AC_CAPABILITY_HTC_VHT: '[HTC-VHT]',
256    AC_CAPABILITY_MAX_A_MPDU_LEN_EXP0: '[MAX-A-MPDU-LEN-EXP0]',
257    AC_CAPABILITY_MAX_A_MPDU_LEN_EXP1: '[MAX-A-MPDU-LEN-EXP1]',
258    AC_CAPABILITY_MAX_A_MPDU_LEN_EXP2: '[MAX-A-MPDU-LEN-EXP2]',
259    AC_CAPABILITY_MAX_A_MPDU_LEN_EXP3: '[MAX-A-MPDU-LEN-EXP3]',
260    AC_CAPABILITY_MAX_A_MPDU_LEN_EXP4: '[MAX-A-MPDU-LEN-EXP4]',
261    AC_CAPABILITY_MAX_A_MPDU_LEN_EXP5: '[MAX-A-MPDU-LEN-EXP5]',
262    AC_CAPABILITY_MAX_A_MPDU_LEN_EXP6: '[MAX-A-MPDU-LEN-EXP6]',
263    AC_CAPABILITY_MAX_A_MPDU_LEN_EXP7: '[MAX-A-MPDU-LEN-EXP7]',
264    AC_CAPABILITY_VHT_LINK_ADAPT2: '[VHT-LINK-ADAPT2]',
265    AC_CAPABILITY_VHT_LINK_ADAPT3: '[VHT-LINK-ADAPT3]',
266    AC_CAPABILITY_RX_ANTENNA_PATTERN: '[RX-ANTENNA-PATTERN]',
267    AC_CAPABILITY_TX_ANTENNA_PATTERN: '[TX-ANTENNA-PATTERN]',
268    AC_CAPABILITY_MAX_MPDU_11454: '[MAX-MPDU-11454]',
269    AC_CAPABILITY_MAX_MPDU_7991: '[MAX-MPDU-7991]'
270}
271AC_CAPABILITIES_MAPPING_INVERSE = {
272    v: k
273    for k, v in AC_CAPABILITIES_MAPPING.items()
274}
275VHT_CHANNEL_WIDTH_40 = 0
276VHT_CHANNEL_WIDTH_80 = 1
277VHT_CHANNEL_WIDTH_160 = 2
278VHT_CHANNEL_WIDTH_80_80 = 3
279
280VHT_CHANNEL = {
281    40: VHT_CHANNEL_WIDTH_40,
282    80: VHT_CHANNEL_WIDTH_80,
283    160: VHT_CHANNEL_WIDTH_160
284}
285
286# This is a loose merging of the rules for US and EU regulatory
287# domains as taken from IEEE Std 802.11-2012 Appendix E.  For instance,
288# we tolerate HT40 in channels 149-161 (not allowed in EU), but also
289# tolerate HT40+ on channel 7 (not allowed in the US).  We take the loose
290# definition so that we don't prohibit testing in either domain.
291HT40_ALLOW_MAP = {
292    N_CAPABILITY_HT40_MINUS_CHANNELS:
293    tuple(
294        itertools.chain(range(6, 14), range(40, 65, 8), range(104, 145, 8),
295                        [153, 161])),
296    N_CAPABILITY_HT40_PLUS_CHANNELS:
297    tuple(
298        itertools.chain(range(1, 8), range(36, 61, 8), range(100, 141, 8),
299                        [149, 157]))
300}
301
302PMF_SUPPORT_DISABLED = 0
303PMF_SUPPORT_ENABLED = 1
304PMF_SUPPORT_REQUIRED = 2
305PMF_SUPPORT_VALUES = (PMF_SUPPORT_DISABLED, PMF_SUPPORT_ENABLED,
306                      PMF_SUPPORT_REQUIRED)
307
308DRIVER_NAME = 'nl80211'
309
310CENTER_CHANNEL_MAP = {
311    VHT_CHANNEL_WIDTH_40: {
312        'delta':
313        2,
314        'channels': ((36, 40), (44, 48), (52, 56), (60, 64), (100, 104),
315                     (108, 112), (116, 120), (124, 128), (132, 136),
316                     (140, 144), (149, 153), (157, 161))
317    },
318    VHT_CHANNEL_WIDTH_80: {
319        'delta':
320        6,
321        'channels':
322        ((36, 48), (52, 64), (100, 112), (116, 128), (132, 144), (149, 161))
323    },
324    VHT_CHANNEL_WIDTH_160: {
325        'delta': 14,
326        'channels': ((36, 64), (100, 128))
327    }
328}
329
330OFDM_DATA_RATES = {'supported_rates': '60 90 120 180 240 360 480 540'}
331
332CCK_DATA_RATES = {'supported_rates': '10 20 55 110'}
333
334CCK_AND_OFDM_DATA_RATES = {
335    'supported_rates': '10 20 55 110 60 90 120 180 240 360 480 540'
336}
337
338OFDM_ONLY_BASIC_RATES = {'basic_rates': '60 120 240'}
339
340CCK_AND_OFDM_BASIC_RATES = {'basic_rates': '10 20 55 110'}
341
342WEP_AUTH = {
343    'open': {
344        'auth_algs': 1
345    },
346    'shared': {
347        'auth_algs': 2
348    },
349    'open_and_shared': {
350        'auth_algs': 3
351    }
352}
353
354WMM_11B_DEFAULT_PARAMS = {
355    'wmm_ac_bk_cwmin': 5,
356    'wmm_ac_bk_cwmax': 10,
357    'wmm_ac_bk_aifs': 7,
358    'wmm_ac_bk_txop_limit': 0,
359    'wmm_ac_be_aifs': 3,
360    'wmm_ac_be_cwmin': 5,
361    'wmm_ac_be_cwmax': 7,
362    'wmm_ac_be_txop_limit': 0,
363    'wmm_ac_vi_aifs': 2,
364    'wmm_ac_vi_cwmin': 4,
365    'wmm_ac_vi_cwmax': 5,
366    'wmm_ac_vi_txop_limit': 188,
367    'wmm_ac_vo_aifs': 2,
368    'wmm_ac_vo_cwmin': 3,
369    'wmm_ac_vo_cwmax': 4,
370    'wmm_ac_vo_txop_limit': 102
371}
372
373WMM_PHYS_11A_11G_11N_11AC_DEFAULT_PARAMS = {
374    'wmm_ac_bk_cwmin': 4,
375    'wmm_ac_bk_cwmax': 10,
376    'wmm_ac_bk_aifs': 7,
377    'wmm_ac_bk_txop_limit': 0,
378    'wmm_ac_be_aifs': 3,
379    'wmm_ac_be_cwmin': 4,
380    'wmm_ac_be_cwmax': 10,
381    'wmm_ac_be_txop_limit': 0,
382    'wmm_ac_vi_aifs': 2,
383    'wmm_ac_vi_cwmin': 3,
384    'wmm_ac_vi_cwmax': 4,
385    'wmm_ac_vi_txop_limit': 94,
386    'wmm_ac_vo_aifs': 2,
387    'wmm_ac_vo_cwmin': 2,
388    'wmm_ac_vo_cwmax': 3,
389    'wmm_ac_vo_txop_limit': 47
390}
391
392WMM_NON_DEFAULT_PARAMS = {
393    'wmm_ac_bk_cwmin': 5,
394    'wmm_ac_bk_cwmax': 9,
395    'wmm_ac_bk_aifs': 3,
396    'wmm_ac_bk_txop_limit': 94,
397    'wmm_ac_be_aifs': 2,
398    'wmm_ac_be_cwmin': 2,
399    'wmm_ac_be_cwmax': 8,
400    'wmm_ac_be_txop_limit': 0,
401    'wmm_ac_vi_aifs': 1,
402    'wmm_ac_vi_cwmin': 7,
403    'wmm_ac_vi_cwmax': 10,
404    'wmm_ac_vi_txop_limit': 47,
405    'wmm_ac_vo_aifs': 1,
406    'wmm_ac_vo_cwmin': 6,
407    'wmm_ac_vo_cwmax': 10,
408    'wmm_ac_vo_txop_limit': 94
409}
410
411WMM_ACM_BK = {'wmm_ac_bk_acm': 1}
412WMM_ACM_BE = {'wmm_ac_be_acm': 1}
413WMM_ACM_VI = {'wmm_ac_vi_acm': 1}
414WMM_ACM_VO = {'wmm_ac_vo_acm': 1}
415
416UAPSD_ENABLED = {'uapsd_advertisement_enabled': 1}
417
418UTF_8_SSID = {'utf8_ssid': 1}
419
420ENABLE_RRM_BEACON_REPORT = {'rrm_beacon_report': 1}
421ENABLE_RRM_NEIGHBOR_REPORT = {'rrm_neighbor_report': 1}
422
423VENDOR_IE = {
424    'correct_length_beacon': {
425        'vendor_elements': 'dd0411223301'
426    },
427    'too_short_length_beacon': {
428        'vendor_elements': 'dd0311223301'
429    },
430    'too_long_length_beacon': {
431        'vendor_elements': 'dd0511223301'
432    },
433    'zero_length_beacon_with_data': {
434        'vendor_elements': 'dd0011223301'
435    },
436    'zero_length_beacon_without_data': {
437        'vendor_elements': 'dd00'
438    },
439    'simliar_to_wpa': {
440        'vendor_elements': 'dd040050f203'
441    },
442    'correct_length_association_response': {
443        'assocresp_elements': 'dd0411223301'
444    },
445    'too_short_length_association_response': {
446        'assocresp_elements': 'dd0311223301'
447    },
448    'too_long_length_association_response': {
449        'assocresp_elements': 'dd0511223301'
450    },
451    'zero_length_association_response_with_data': {
452        'assocresp_elements': 'dd0011223301'
453    },
454    'zero_length_association_response_without_data': {
455        'assocresp_elements': 'dd00'
456    }
457}
458
459ENABLE_IEEE80211D = {'ieee80211d': 1}
460
461COUNTRY_STRING = {
462    'ALL': {
463        'country3': '0x20'
464    },
465    'OUTDOOR': {
466        'country3': '0x4f'
467    },
468    'INDOOR': {
469        'country3': '0x49'
470    },
471    'NONCOUNTRY': {
472        'country3': '0x58'
473    },
474    'GLOBAL': {
475        'country3': '0x04'
476    }
477}
478
479COUNTRY_CODE = {
480    'AFGHANISTAN': {
481        'country_code': 'AF'
482    },
483    'ALAND_ISLANDS': {
484        'country_code': 'AX'
485    },
486    'ALBANIA': {
487        'country_code': 'AL'
488    },
489    'ALGERIA': {
490        'country_code': 'DZ'
491    },
492    'AMERICAN_SAMOA': {
493        'country_code': 'AS'
494    },
495    'ANDORRA': {
496        'country_code': 'AD'
497    },
498    'ANGOLA': {
499        'country_code': 'AO'
500    },
501    'ANGUILLA': {
502        'country_code': 'AI'
503    },
504    'ANTARCTICA': {
505        'country_code': 'AQ'
506    },
507    'ANTIGUA_AND_BARBUDA': {
508        'country_code': 'AG'
509    },
510    'ARGENTINA': {
511        'country_code': 'AR'
512    },
513    'ARMENIA': {
514        'country_code': 'AM'
515    },
516    'ARUBA': {
517        'country_code': 'AW'
518    },
519    'AUSTRALIA': {
520        'country_code': 'AU'
521    },
522    'AUSTRIA': {
523        'country_code': 'AT'
524    },
525    'AZERBAIJAN': {
526        'country_code': 'AZ'
527    },
528    'BAHAMAS': {
529        'country_code': 'BS'
530    },
531    'BAHRAIN': {
532        'country_code': 'BH'
533    },
534    'BANGLADESH': {
535        'country_code': 'BD'
536    },
537    'BARBADOS': {
538        'country_code': 'BB'
539    },
540    'BELARUS': {
541        'country_code': 'BY'
542    },
543    'BELGIUM': {
544        'country_code': 'BE'
545    },
546    'BELIZE': {
547        'country_code': 'BZ'
548    },
549    'BENIN': {
550        'country_code': 'BJ'
551    },
552    'BERMUDA': {
553        'country_code': 'BM'
554    },
555    'BHUTAN': {
556        'country_code': 'BT'
557    },
558    'BOLIVIA': {
559        'country_code': 'BO'
560    },
561    'BONAIRE': {
562        'country_code': 'BQ'
563    },
564    'BOSNIA_AND_HERZEGOVINA': {
565        'country_code': 'BA'
566    },
567    'BOTSWANA': {
568        'country_code': 'BW'
569    },
570    'BOUVET_ISLAND': {
571        'country_code': 'BV'
572    },
573    'BRAZIL': {
574        'country_code': 'BR'
575    },
576    'BRITISH_INDIAN_OCEAN_TERRITORY': {
577        'country_code': 'IO'
578    },
579    'BRUNEI_DARUSSALAM': {
580        'country_code': 'BN'
581    },
582    'BULGARIA': {
583        'country_code': 'BG'
584    },
585    'BURKINA_FASO': {
586        'country_code': 'BF'
587    },
588    'BURUNDI': {
589        'country_code': 'BI'
590    },
591    'CAMBODIA': {
592        'country_code': 'KH'
593    },
594    'CAMEROON': {
595        'country_code': 'CM'
596    },
597    'CANADA': {
598        'country_code': 'CA'
599    },
600    'CAPE_VERDE': {
601        'country_code': 'CV'
602    },
603    'CAYMAN_ISLANDS': {
604        'country_code': 'KY'
605    },
606    'CENTRAL_AFRICAN_REPUBLIC': {
607        'country_code': 'CF'
608    },
609    'CHAD': {
610        'country_code': 'TD'
611    },
612    'CHILE': {
613        'country_code': 'CL'
614    },
615    'CHINA': {
616        'country_code': 'CN'
617    },
618    'CHRISTMAS_ISLAND': {
619        'country_code': 'CX'
620    },
621    'COCOS_ISLANDS': {
622        'country_code': 'CC'
623    },
624    'COLOMBIA': {
625        'country_code': 'CO'
626    },
627    'COMOROS': {
628        'country_code': 'KM'
629    },
630    'CONGO': {
631        'country_code': 'CG'
632    },
633    'DEMOCRATIC_REPUBLIC_CONGO': {
634        'country_code': 'CD'
635    },
636    'COOK_ISLANDS': {
637        'country_code': 'CK'
638    },
639    'COSTA_RICA': {
640        'country_code': 'CR'
641    },
642    'COTE_D_IVOIRE': {
643        'country_code': 'CI'
644    },
645    'CROATIA': {
646        'country_code': 'HR'
647    },
648    'CUBA': {
649        'country_code': 'CU'
650    },
651    'CURACAO': {
652        'country_code': 'CW'
653    },
654    'CYPRUS': {
655        'country_code': 'CY'
656    },
657    'CZECH_REPUBLIC': {
658        'country_code': 'CZ'
659    },
660    'DENMARK': {
661        'country_code': 'DK'
662    },
663    'DJIBOUTI': {
664        'country_code': 'DJ'
665    },
666    'DOMINICA': {
667        'country_code': 'DM'
668    },
669    'DOMINICAN_REPUBLIC': {
670        'country_code': 'DO'
671    },
672    'ECUADOR': {
673        'country_code': 'EC'
674    },
675    'EGYPT': {
676        'country_code': 'EG'
677    },
678    'EL_SALVADOR': {
679        'country_code': 'SV'
680    },
681    'EQUATORIAL_GUINEA': {
682        'country_code': 'GQ'
683    },
684    'ERITREA': {
685        'country_code': 'ER'
686    },
687    'ESTONIA': {
688        'country_code': 'EE'
689    },
690    'ETHIOPIA': {
691        'country_code': 'ET'
692    },
693    'FALKLAND_ISLANDS_(MALVINAS)': {
694        'country_code': 'FK'
695    },
696    'FAROE_ISLANDS': {
697        'country_code': 'FO'
698    },
699    'FIJI': {
700        'country_code': 'FJ'
701    },
702    'FINLAND': {
703        'country_code': 'FI'
704    },
705    'FRANCE': {
706        'country_code': 'FR'
707    },
708    'FRENCH_GUIANA': {
709        'country_code': 'GF'
710    },
711    'FRENCH_POLYNESIA': {
712        'country_code': 'PF'
713    },
714    'FRENCH_SOUTHERN_TERRITORIES': {
715        'country_code': 'TF'
716    },
717    'GABON': {
718        'country_code': 'GA'
719    },
720    'GAMBIA': {
721        'country_code': 'GM'
722    },
723    'GEORGIA': {
724        'country_code': 'GE'
725    },
726    'GERMANY': {
727        'country_code': 'DE'
728    },
729    'GHANA': {
730        'country_code': 'GH'
731    },
732    'GIBRALTAR': {
733        'country_code': 'GI'
734    },
735    'GREECE': {
736        'country_code': 'GR'
737    },
738    'GREENLAND': {
739        'country_code': 'GL'
740    },
741    'GRENADA': {
742        'country_code': 'GD'
743    },
744    'GUADELOUPE': {
745        'country_code': 'GP'
746    },
747    'GUAM': {
748        'country_code': 'GU'
749    },
750    'GUATEMALA': {
751        'country_code': 'GT'
752    },
753    'GUERNSEY': {
754        'country_code': 'GG'
755    },
756    'GUINEA': {
757        'country_code': 'GN'
758    },
759    'GUINEA-BISSAU': {
760        'country_code': 'GW'
761    },
762    'GUYANA': {
763        'country_code': 'GY'
764    },
765    'HAITI': {
766        'country_code': 'HT'
767    },
768    'HEARD_ISLAND_AND_MCDONALD_ISLANDS': {
769        'country_code': 'HM'
770    },
771    'VATICAN_CITY_STATE': {
772        'country_code': 'VA'
773    },
774    'HONDURAS': {
775        'country_code': 'HN'
776    },
777    'HONG_KONG': {
778        'country_code': 'HK'
779    },
780    'HUNGARY': {
781        'country_code': 'HU'
782    },
783    'ICELAND': {
784        'country_code': 'IS'
785    },
786    'INDIA': {
787        'country_code': 'IN'
788    },
789    'INDONESIA': {
790        'country_code': 'ID'
791    },
792    'IRAN': {
793        'country_code': 'IR'
794    },
795    'IRAQ': {
796        'country_code': 'IQ'
797    },
798    'IRELAND': {
799        'country_code': 'IE'
800    },
801    'ISLE_OF_MAN': {
802        'country_code': 'IM'
803    },
804    'ISRAEL': {
805        'country_code': 'IL'
806    },
807    'ITALY': {
808        'country_code': 'IT'
809    },
810    'JAMAICA': {
811        'country_code': 'JM'
812    },
813    'JAPAN': {
814        'country_code': 'JP'
815    },
816    'JERSEY': {
817        'country_code': 'JE'
818    },
819    'JORDAN': {
820        'country_code': 'JO'
821    },
822    'KAZAKHSTAN': {
823        'country_code': 'KZ'
824    },
825    'KENYA': {
826        'country_code': 'KE'
827    },
828    'KIRIBATI': {
829        'country_code': 'KI'
830    },
831    'DEMOCRATIC_PEOPLE_S_REPUBLIC_OF_KOREA': {
832        'country_code': 'KP'
833    },
834    'REPUBLIC_OF_KOREA': {
835        'country_code': 'KR'
836    },
837    'KUWAIT': {
838        'country_code': 'KW'
839    },
840    'KYRGYZSTAN': {
841        'country_code': 'KG'
842    },
843    'LAO': {
844        'country_code': 'LA'
845    },
846    'LATVIA': {
847        'country_code': 'LV'
848    },
849    'LEBANON': {
850        'country_code': 'LB'
851    },
852    'LESOTHO': {
853        'country_code': 'LS'
854    },
855    'LIBERIA': {
856        'country_code': 'LR'
857    },
858    'LIBYA': {
859        'country_code': 'LY'
860    },
861    'LIECHTENSTEIN': {
862        'country_code': 'LI'
863    },
864    'LITHUANIA': {
865        'country_code': 'LT'
866    },
867    'LUXEMBOURG': {
868        'country_code': 'LU'
869    },
870    'MACAO': {
871        'country_code': 'MO'
872    },
873    'MACEDONIA': {
874        'country_code': 'MK'
875    },
876    'MADAGASCAR': {
877        'country_code': 'MG'
878    },
879    'MALAWI': {
880        'country_code': 'MW'
881    },
882    'MALAYSIA': {
883        'country_code': 'MY'
884    },
885    'MALDIVES': {
886        'country_code': 'MV'
887    },
888    'MALI': {
889        'country_code': 'ML'
890    },
891    'MALTA': {
892        'country_code': 'MT'
893    },
894    'MARSHALL_ISLANDS': {
895        'country_code': 'MH'
896    },
897    'MARTINIQUE': {
898        'country_code': 'MQ'
899    },
900    'MAURITANIA': {
901        'country_code': 'MR'
902    },
903    'MAURITIUS': {
904        'country_code': 'MU'
905    },
906    'MAYOTTE': {
907        'country_code': 'YT'
908    },
909    'MEXICO': {
910        'country_code': 'MX'
911    },
912    'MICRONESIA': {
913        'country_code': 'FM'
914    },
915    'MOLDOVA': {
916        'country_code': 'MD'
917    },
918    'MONACO': {
919        'country_code': 'MC'
920    },
921    'MONGOLIA': {
922        'country_code': 'MN'
923    },
924    'MONTENEGRO': {
925        'country_code': 'ME'
926    },
927    'MONTSERRAT': {
928        'country_code': 'MS'
929    },
930    'MOROCCO': {
931        'country_code': 'MA'
932    },
933    'MOZAMBIQUE': {
934        'country_code': 'MZ'
935    },
936    'MYANMAR': {
937        'country_code': 'MM'
938    },
939    'NAMIBIA': {
940        'country_code': 'NA'
941    },
942    'NAURU': {
943        'country_code': 'NR'
944    },
945    'NEPAL': {
946        'country_code': 'NP'
947    },
948    'NETHERLANDS': {
949        'country_code': 'NL'
950    },
951    'NEW_CALEDONIA': {
952        'country_code': 'NC'
953    },
954    'NEW_ZEALAND': {
955        'country_code': 'NZ'
956    },
957    'NICARAGUA': {
958        'country_code': 'NI'
959    },
960    'NIGER': {
961        'country_code': 'NE'
962    },
963    'NIGERIA': {
964        'country_code': 'NG'
965    },
966    'NIUE': {
967        'country_code': 'NU'
968    },
969    'NORFOLK_ISLAND': {
970        'country_code': 'NF'
971    },
972    'NORTHERN_MARIANA_ISLANDS': {
973        'country_code': 'MP'
974    },
975    'NORWAY': {
976        'country_code': 'NO'
977    },
978    'OMAN': {
979        'country_code': 'OM'
980    },
981    'PAKISTAN': {
982        'country_code': 'PK'
983    },
984    'PALAU': {
985        'country_code': 'PW'
986    },
987    'PALESTINE': {
988        'country_code': 'PS'
989    },
990    'PANAMA': {
991        'country_code': 'PA'
992    },
993    'PAPUA_NEW_GUINEA': {
994        'country_code': 'PG'
995    },
996    'PARAGUAY': {
997        'country_code': 'PY'
998    },
999    'PERU': {
1000        'country_code': 'PE'
1001    },
1002    'PHILIPPINES': {
1003        'country_code': 'PH'
1004    },
1005    'PITCAIRN': {
1006        'country_code': 'PN'
1007    },
1008    'POLAND': {
1009        'country_code': 'PL'
1010    },
1011    'PORTUGAL': {
1012        'country_code': 'PT'
1013    },
1014    'PUERTO_RICO': {
1015        'country_code': 'PR'
1016    },
1017    'QATAR': {
1018        'country_code': 'QA'
1019    },
1020    'RÉUNION': {
1021        'country_code': 'RE'
1022    },
1023    'ROMANIA': {
1024        'country_code': 'RO'
1025    },
1026    'RUSSIAN_FEDERATION': {
1027        'country_code': 'RU'
1028    },
1029    'RWANDA': {
1030        'country_code': 'RW'
1031    },
1032    'SAINT_BARTHELEMY': {
1033        'country_code': 'BL'
1034    },
1035    'SAINT_KITTS_AND_NEVIS': {
1036        'country_code': 'KN'
1037    },
1038    'SAINT_LUCIA': {
1039        'country_code': 'LC'
1040    },
1041    'SAINT_MARTIN': {
1042        'country_code': 'MF'
1043    },
1044    'SAINT_PIERRE_AND_MIQUELON': {
1045        'country_code': 'PM'
1046    },
1047    'SAINT_VINCENT_AND_THE_GRENADINES': {
1048        'country_code': 'VC'
1049    },
1050    'SAMOA': {
1051        'country_code': 'WS'
1052    },
1053    'SAN_MARINO': {
1054        'country_code': 'SM'
1055    },
1056    'SAO_TOME_AND_PRINCIPE': {
1057        'country_code': 'ST'
1058    },
1059    'SAUDI_ARABIA': {
1060        'country_code': 'SA'
1061    },
1062    'SENEGAL': {
1063        'country_code': 'SN'
1064    },
1065    'SERBIA': {
1066        'country_code': 'RS'
1067    },
1068    'SEYCHELLES': {
1069        'country_code': 'SC'
1070    },
1071    'SIERRA_LEONE': {
1072        'country_code': 'SL'
1073    },
1074    'SINGAPORE': {
1075        'country_code': 'SG'
1076    },
1077    'SINT_MAARTEN': {
1078        'country_code': 'SX'
1079    },
1080    'SLOVAKIA': {
1081        'country_code': 'SK'
1082    },
1083    'SLOVENIA': {
1084        'country_code': 'SI'
1085    },
1086    'SOLOMON_ISLANDS': {
1087        'country_code': 'SB'
1088    },
1089    'SOMALIA': {
1090        'country_code': 'SO'
1091    },
1092    'SOUTH_AFRICA': {
1093        'country_code': 'ZA'
1094    },
1095    'SOUTH_GEORGIA': {
1096        'country_code': 'GS'
1097    },
1098    'SOUTH_SUDAN': {
1099        'country_code': 'SS'
1100    },
1101    'SPAIN': {
1102        'country_code': 'ES'
1103    },
1104    'SRI_LANKA': {
1105        'country_code': 'LK'
1106    },
1107    'SUDAN': {
1108        'country_code': 'SD'
1109    },
1110    'SURINAME': {
1111        'country_code': 'SR'
1112    },
1113    'SVALBARD_AND_JAN_MAYEN': {
1114        'country_code': 'SJ'
1115    },
1116    'SWAZILAND': {
1117        'country_code': 'SZ'
1118    },
1119    'SWEDEN': {
1120        'country_code': 'SE'
1121    },
1122    'SWITZERLAND': {
1123        'country_code': 'CH'
1124    },
1125    'SYRIAN_ARAB_REPUBLIC': {
1126        'country_code': 'SY'
1127    },
1128    'TAIWAN': {
1129        'country_code': 'TW'
1130    },
1131    'TAJIKISTAN': {
1132        'country_code': 'TJ'
1133    },
1134    'TANZANIA': {
1135        'country_code': 'TZ'
1136    },
1137    'THAILAND': {
1138        'country_code': 'TH'
1139    },
1140    'TIMOR-LESTE': {
1141        'country_code': 'TL'
1142    },
1143    'TOGO': {
1144        'country_code': 'TG'
1145    },
1146    'TOKELAU': {
1147        'country_code': 'TK'
1148    },
1149    'TONGA': {
1150        'country_code': 'TO'
1151    },
1152    'TRINIDAD_AND_TOBAGO': {
1153        'country_code': 'TT'
1154    },
1155    'TUNISIA': {
1156        'country_code': 'TN'
1157    },
1158    'TURKEY': {
1159        'country_code': 'TR'
1160    },
1161    'TURKMENISTAN': {
1162        'country_code': 'TM'
1163    },
1164    'TURKS_AND_CAICOS_ISLANDS': {
1165        'country_code': 'TC'
1166    },
1167    'TUVALU': {
1168        'country_code': 'TV'
1169    },
1170    'UGANDA': {
1171        'country_code': 'UG'
1172    },
1173    'UKRAINE': {
1174        'country_code': 'UA'
1175    },
1176    'UNITED_ARAB_EMIRATES': {
1177        'country_code': 'AE'
1178    },
1179    'UNITED_KINGDOM': {
1180        'country_code': 'GB'
1181    },
1182    'UNITED_STATES': {
1183        'country_code': 'US'
1184    },
1185    'UNITED_STATES_MINOR_OUTLYING_ISLANDS': {
1186        'country_code': 'UM'
1187    },
1188    'URUGUAY': {
1189        'country_code': 'UY'
1190    },
1191    'UZBEKISTAN': {
1192        'country_code': 'UZ'
1193    },
1194    'VANUATU': {
1195        'country_code': 'VU'
1196    },
1197    'VENEZUELA': {
1198        'country_code': 'VE'
1199    },
1200    'VIETNAM': {
1201        'country_code': 'VN'
1202    },
1203    'VIRGIN_ISLANDS_BRITISH': {
1204        'country_code': 'VG'
1205    },
1206    'VIRGIN_ISLANDS_US': {
1207        'country_code': 'VI'
1208    },
1209    'WALLIS_AND_FUTUNA': {
1210        'country_code': 'WF'
1211    },
1212    'WESTERN_SAHARA': {
1213        'country_code': 'EH'
1214    },
1215    'YEMEN': {
1216        'country_code': 'YE'
1217    },
1218    'ZAMBIA': {
1219        'country_code': 'ZM'
1220    },
1221    'ZIMBABWE': {
1222        'country_code': 'ZW'
1223    },
1224    'NON_COUNTRY': {
1225        'country_code': 'XX'
1226    }
1227}
1228
1229ALL_CHANNELS_2G = {
1230    1: {20, 40},
1231    2: {20, 40},
1232    3: {20, 40},
1233    4: {20, 40},
1234    5: {20, 40},
1235    6: {20, 40},
1236    7: {20, 40},
1237    8: {20, 40},
1238    9: {20, 40},
1239    10: {20, 40},
1240    11: {20, 40},
1241    12: {20, 40},
1242    13: {20, 40},
1243    14: {20}
1244}
1245
1246ALL_CHANNELS_5G = {
1247    36: {20, 40, 80},
1248    40: {20, 40, 80},
1249    44: {20, 40, 80},
1250    48: {20, 40, 80},
1251    52: {20, 40, 80},
1252    56: {20, 40, 80},
1253    60: {20, 40, 80},
1254    64: {20, 40, 80},
1255    100: {20, 40, 80},
1256    104: {20, 40, 80},
1257    108: {20, 40, 80},
1258    112: {20, 40, 80},
1259    116: {20, 40, 80},
1260    120: {20, 40, 80},
1261    124: {20, 40, 80},
1262    128: {20, 40, 80},
1263    132: {20, 40, 80},
1264    136: {20, 40, 80},
1265    140: {20, 40, 80},
1266    144: {20, 40, 80},
1267    149: {20, 40, 80},
1268    153: {20, 40, 80},
1269    157: {20, 40, 80},
1270    161: {20, 40, 80},
1271    165: {20}
1272}
1273
1274ALL_CHANNELS = {**ALL_CHANNELS_2G, **ALL_CHANNELS_5G}
1275