aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/nl80211.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-01-24 13:38:39 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:19:32 -0500
commitee688b000d35f413f33561ec9c7d3355be561e2f (patch)
treee0814191f873ba6f397ffb419b5e37ed4c0c531c /net/wireless/nl80211.c
parent8318d78a44d49ac1edf2bdec7299de3617c4232e (diff)
nl80211: export hardware bitrate/channel capabilities
This makes nl80211 export the hardware bitrate/channel capabilities as registered in a wiphy. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r--net/wireless/nl80211.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index e3a214f63f91..b123f58d3909 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -98,6 +98,13 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
98 struct cfg80211_registered_device *dev) 98 struct cfg80211_registered_device *dev)
99{ 99{
100 void *hdr; 100 void *hdr;
101 struct nlattr *nl_bands, *nl_band;
102 struct nlattr *nl_freqs, *nl_freq;
103 struct nlattr *nl_rates, *nl_rate;
104 enum ieee80211_band band;
105 struct ieee80211_channel *chan;
106 struct ieee80211_rate *rate;
107 int i;
101 108
102 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_WIPHY); 109 hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_WIPHY);
103 if (!hdr) 110 if (!hdr)
@@ -105,6 +112,73 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
105 112
106 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->idx); 113 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->idx);
107 NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)); 114 NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy));
115
116 nl_bands = nla_nest_start(msg, NL80211_ATTR_WIPHY_BANDS);
117 if (!nl_bands)
118 goto nla_put_failure;
119
120 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
121 if (!dev->wiphy.bands[band])
122 continue;
123
124 nl_band = nla_nest_start(msg, band);
125 if (!nl_band)
126 goto nla_put_failure;
127
128 /* add frequencies */
129 nl_freqs = nla_nest_start(msg, NL80211_BAND_ATTR_FREQS);
130 if (!nl_freqs)
131 goto nla_put_failure;
132
133 for (i = 0; i < dev->wiphy.bands[band]->n_channels; i++) {
134 nl_freq = nla_nest_start(msg, i);
135 if (!nl_freq)
136 goto nla_put_failure;
137
138 chan = &dev->wiphy.bands[band]->channels[i];
139 NLA_PUT_U32(msg, NL80211_FREQUENCY_ATTR_FREQ,
140 chan->center_freq);
141
142 if (chan->flags & IEEE80211_CHAN_DISABLED)
143 NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_DISABLED);
144 if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)
145 NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_PASSIVE_SCAN);
146 if (chan->flags & IEEE80211_CHAN_NO_IBSS)
147 NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_NO_IBSS);
148 if (chan->flags & IEEE80211_CHAN_RADAR)
149 NLA_PUT_FLAG(msg, NL80211_FREQUENCY_ATTR_RADAR);
150
151 nla_nest_end(msg, nl_freq);
152 }
153
154 nla_nest_end(msg, nl_freqs);
155
156 /* add bitrates */
157 nl_rates = nla_nest_start(msg, NL80211_BAND_ATTR_RATES);
158 if (!nl_rates)
159 goto nla_put_failure;
160
161 for (i = 0; i < dev->wiphy.bands[band]->n_bitrates; i++) {
162 nl_rate = nla_nest_start(msg, i);
163 if (!nl_rate)
164 goto nla_put_failure;
165
166 rate = &dev->wiphy.bands[band]->bitrates[i];
167 NLA_PUT_U32(msg, NL80211_BITRATE_ATTR_RATE,
168 rate->bitrate);
169 if (rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
170 NLA_PUT_FLAG(msg,
171 NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE);
172
173 nla_nest_end(msg, nl_rate);
174 }
175
176 nla_nest_end(msg, nl_rates);
177
178 nla_nest_end(msg, nl_band);
179 }
180 nla_nest_end(msg, nl_bands);
181
108 return genlmsg_end(msg, hdr); 182 return genlmsg_end(msg, hdr);
109 183
110 nla_put_failure: 184 nla_put_failure: