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