]> git.ipfire.org Git - thirdparty/hostap.git/blob - src/common/hw_features_common.c
Introduce common hw features
[thirdparty/hostap.git] / src / common / hw_features_common.c
1 /*
2 * Common hostapd/wpa_supplicant HW features
3 * Copyright (c) 2002-2013, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2015, Qualcomm Atheros, Inc.
5 *
6 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
8 */
9
10 #include "includes.h"
11
12 #include "common.h"
13 #include "defs.h"
14 #include "hw_features_common.h"
15
16
17 struct hostapd_channel_data * hw_get_channel_chan(struct hostapd_hw_modes *mode,
18 int chan, int *freq)
19 {
20 int i;
21
22 if (freq)
23 *freq = 0;
24
25 if (!mode)
26 return NULL;
27
28 for (i = 0; i < mode->num_channels; i++) {
29 struct hostapd_channel_data *ch = &mode->channels[i];
30 if (ch->chan == chan) {
31 if (freq)
32 *freq = ch->freq;
33 return ch;
34 }
35 }
36
37 return NULL;
38 }
39
40
41 struct hostapd_channel_data * hw_get_channel_freq(struct hostapd_hw_modes *mode,
42 int freq, int *chan)
43 {
44 int i;
45
46 if (chan)
47 *chan = 0;
48
49 if (!mode)
50 return NULL;
51
52 for (i = 0; i < mode->num_channels; i++) {
53 struct hostapd_channel_data *ch = &mode->channels[i];
54 if (ch->freq == freq) {
55 if (chan)
56 *chan = ch->chan;
57 return ch;
58 }
59 }
60
61 return NULL;
62 }
63
64
65 int hw_get_freq(struct hostapd_hw_modes *mode, int chan)
66 {
67 int freq;
68
69 hw_get_channel_chan(mode, chan, &freq);
70
71 return freq;
72 }
73
74
75 int hw_get_chan(struct hostapd_hw_modes *mode, int freq)
76 {
77 int chan;
78
79 hw_get_channel_freq(mode, freq, &chan);
80
81 return chan;
82 }