http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n267.

    Positional arguments:
    data -- bytearray data to read.

    Returns:
    Dict.

def get_country(_, data):
    """http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n267.

    Positional arguments:
    data -- bytearray data to read.

    Returns:
    Dict.
    """
    answers = {'Environment': country_env_str(chr(data[2]))}
    data = data[3:]

    while len(data) >= 3:
        triplet = ieee80211_country_ie_triplet(data)
        if triplet.ext.reg_extension_id >= IEEE80211_COUNTRY_EXTENSION_ID:
            answers['Extension ID'] = triplet.ext.reg_extension_id
            answers['Regulatory Class'] = triplet.ext.reg_class
            answers['Coverage class'] = triplet.ext.coverage_class
            answers['up to dm'] = triplet.ext.coverage_class * 450
            data = data[3:]
            continue
        if triplet.chans.first_channel <= 14:  # 2 GHz.
            end_channel = triplet.chans.first_channel + (triplet.chans.num_channels - 1)
        else:
            end_channel = triplet.chans.first_channel + (4 * (triplet.chans.num_channels - 1))
        answers['Channels dBm'] = triplet.chans.max_power
        answers['Channels'] = (triplet.chans.first_channel, end_channel)
        data = data[3:]
    return answers