Browse Source

Get maximum TX power for each allowed channel from mac80211

Jouni Malinen 16 years ago
parent
commit
bf01d8bc2b
3 changed files with 15 additions and 2 deletions
  1. 11 0
      hostapd/driver_nl80211.c
  2. 3 2
      hostapd/hw_features.c
  3. 1 0
      hostapd/hw_features.h

+ 11 - 0
hostapd/driver_nl80211.c

@@ -1316,6 +1316,9 @@ static int phy_info_handler(struct nl_msg *msg, void *arg)
 		[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
 		[NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
 		[NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG },
+#ifdef NL80211_FREQUENCY_ATTR_MAX_TX_POWER
+		[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 },
+#endif /* NL80211_FREQUENCY_ATTR_MAX_TX_POWER */
 	};
 
 	struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1];
@@ -1405,6 +1408,14 @@ static int phy_info_handler(struct nl_msg *msg, void *arg)
 			if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR])
 				mode->channels[idx].flag |=
 					HOSTAPD_CHAN_RADAR;
+
+#ifdef NL80211_FREQUENCY_ATTR_MAX_TX_POWER
+			if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] &&
+			    !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
+				mode->channels[idx].max_tx_power =
+					nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]) / 100;
+#endif /* NL80211_FREQUENCY_ATTR_MAX_TX_POWER */
+
 			idx++;
 		}
 

+ 3 - 2
hostapd/hw_features.c

@@ -84,10 +84,11 @@ int hostapd_get_hw_features(struct hostapd_iface *iface)
 			if (feature->channels[j].flag & HOSTAPD_CHAN_DISABLED)
 				continue;
 			wpa_printf(MSG_MSGDUMP, "Allowed channel: mode=%d "
-				   "chan=%d freq=%d MHz",
+				   "chan=%d freq=%d MHz max_tx_power=%d dBm",
 				   feature->mode,
 				   feature->channels[j].chan,
-				   feature->channels[j].freq);
+				   feature->channels[j].freq,
+				   feature->channels[j].max_tx_power);
 		}
 	}
 

+ 1 - 0
hostapd/hw_features.h

@@ -25,6 +25,7 @@ struct hostapd_channel_data {
 	short chan; /* channel number (IEEE 802.11) */
 	short freq; /* frequency in MHz */
 	int flag; /* flag for hostapd use (HOSTAPD_CHAN_*) */
+	u8 max_tx_power; /* maximum transmit power in dBm */
 };
 
 #define HOSTAPD_RATE_ERP 0x00000001