eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

diagnostic.c (4578B)


      1 /*
      2  *
      3  *  Wireless daemon for Linux
      4  *
      5  *  Copyright (C) 2021  Intel Corporation. All rights reserved.
      6  *
      7  *  This library is free software; you can redistribute it and/or
      8  *  modify it under the terms of the GNU Lesser General Public
      9  *  License as published by the Free Software Foundation; either
     10  *  version 2.1 of the License, or (at your option) any later version.
     11  *
     12  *  This library is distributed in the hope that it will be useful,
     13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  *  Lesser General Public License for more details.
     16  *
     17  *  You should have received a copy of the GNU Lesser General Public
     18  *  License along with this library; if not, write to the Free Software
     19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20  *
     21  */
     22 
     23 #ifdef HAVE_CONFIG_H
     24 #include <config.h>
     25 #endif
     26 
     27 #include <ell/ell.h>
     28 
     29 #include "src/diagnostic.h"
     30 #include "src/dbus.h"
     31 #include "src/ie.h"
     32 
     33 /*
     34  * Appends values from diagnostic_station_info into a DBus dictionary. This
     35  * assumes the DBus dictionary array has already been 'entered', and expects the
     36  * caller to 'leave' once called. This does not append the station address
     37  * since the dictionary key name may be different depending on the caller.
     38  */
     39 bool diagnostic_info_to_dict(const struct diagnostic_station_info *info,
     40 				struct l_dbus_message_builder *builder)
     41 {
     42 	int16_t rssi = (int16_t)info->cur_rssi;
     43 	int16_t avg_rssi = (int16_t)info->avg_rssi;
     44 
     45 	if (info->have_cur_rssi)
     46 		dbus_append_dict_basic(builder, "RSSI", 'n', &rssi);
     47 
     48 	if (info->have_avg_rssi)
     49 		dbus_append_dict_basic(builder, "AverageRSSI", 'n', &avg_rssi);
     50 
     51 	if (info->have_rx_mcs) {
     52 		switch (info->rx_mcs_type) {
     53 		case DIAGNOSTIC_MCS_TYPE_HT:
     54 			dbus_append_dict_basic(builder, "RxMode", 's',
     55 						"802.11n");
     56 			dbus_append_dict_basic(builder, "RxMCS", 'y',
     57 						&info->rx_mcs);
     58 			break;
     59 		case DIAGNOSTIC_MCS_TYPE_VHT:
     60 			dbus_append_dict_basic(builder, "RxMode", 's',
     61 						"802.11ac");
     62 			dbus_append_dict_basic(builder, "RxMCS", 'y',
     63 						&info->rx_mcs);
     64 			break;
     65 		case DIAGNOSTIC_MCS_TYPE_HE:
     66 			dbus_append_dict_basic(builder, "RxMode", 's',
     67 						"802.11ax");
     68 			dbus_append_dict_basic(builder, "RxMCS", 'y',
     69 						&info->rx_mcs);
     70 			break;
     71 		default:
     72 			break;
     73 		}
     74 	}
     75 
     76 	if (info->have_tx_mcs) {
     77 		switch (info->tx_mcs_type) {
     78 		case DIAGNOSTIC_MCS_TYPE_HT:
     79 			dbus_append_dict_basic(builder, "TxMode", 's',
     80 						"802.11n");
     81 			dbus_append_dict_basic(builder, "TxMCS", 'y',
     82 						&info->tx_mcs);
     83 			break;
     84 		case DIAGNOSTIC_MCS_TYPE_VHT:
     85 			dbus_append_dict_basic(builder, "TxMode", 's',
     86 						"802.11ac");
     87 			dbus_append_dict_basic(builder, "TxMCS", 'y',
     88 						&info->tx_mcs);
     89 			break;
     90 		case DIAGNOSTIC_MCS_TYPE_HE:
     91 			dbus_append_dict_basic(builder, "TxMode", 's',
     92 						"802.11ax");
     93 			dbus_append_dict_basic(builder, "TxMCS", 'y',
     94 						&info->tx_mcs);
     95 			break;
     96 		default:
     97 			break;
     98 		}
     99 	}
    100 
    101 	if (info->have_tx_bitrate)
    102 		dbus_append_dict_basic(builder, "TxBitrate", 'u',
    103 					&info->tx_bitrate);
    104 
    105 	if (info->have_rx_bitrate)
    106 		dbus_append_dict_basic(builder, "RxBitrate", 'u',
    107 					&info->rx_bitrate);
    108 
    109 	if (info->have_expected_throughput)
    110 		dbus_append_dict_basic(builder, "ExpectedThroughput", 'u',
    111 					&info->expected_throughput);
    112 
    113 	if (info->have_inactive_time)
    114 		dbus_append_dict_basic(builder, "InactiveTime", 'u',
    115 					&info->inactive_time);
    116 
    117 	if (info->have_connected_time)
    118 		dbus_append_dict_basic(builder, "ConnectedTime", 'u',
    119 					&info->connected_time);
    120 
    121 	return true;
    122 }
    123 
    124 const char *diagnostic_akm_suite_to_security(enum ie_rsn_akm_suite akm,
    125 						bool wpa)
    126 {
    127 	if (akm == 0)
    128 		return "Open";
    129 
    130 	switch (akm) {
    131 	case IE_RSN_AKM_SUITE_8021X:
    132 	case IE_RSN_AKM_SUITE_8021X_SHA256:
    133 		return "WPA2-Enterprise";
    134 	case IE_RSN_AKM_SUITE_PSK:
    135 		if (wpa)
    136 			return "WPA1-Personal";
    137 
    138 		/* Fall through */
    139 	case IE_RSN_AKM_SUITE_PSK_SHA256:
    140 		return "WPA2-Personal";
    141 	case IE_RSN_AKM_SUITE_FT_OVER_8021X:
    142 	case IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384:
    143 		return "WPA2-Enterprise + FT";
    144 	case IE_RSN_AKM_SUITE_FT_USING_PSK:
    145 		return "WPA2-Personal + FT";
    146 	case IE_RSN_AKM_SUITE_SAE_SHA256:
    147 		return "WPA3-Personal";
    148 	case IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256:
    149 		return "WPA3-Personal + FT";
    150 	case IE_RSN_AKM_SUITE_OWE:
    151 		return "OWE";
    152 	case IE_RSN_AKM_SUITE_FILS_SHA256:
    153 	case IE_RSN_AKM_SUITE_FILS_SHA384:
    154 		return "FILS";
    155 	case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA256:
    156 	case IE_RSN_AKM_SUITE_FT_OVER_FILS_SHA384:
    157 		return "FILS + FT";
    158 	case IE_RSN_AKM_SUITE_OSEN:
    159 		return "OSEN";
    160 	default:
    161 		return "Unknown";
    162 	}
    163 }