1 /******************************************************************************
3 Copyright(c) 2005 Intel Corporation. All rights reserved.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of version 2 of the GNU General Public License as
7 published by the Free Software Foundation.
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc., 59
16 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 The full GNU General Public License is included in this distribution in the
22 James P. Ketrenos <ipw2100-admin@linux.intel.com>
23 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25 ******************************************************************************/
26 #include <linux/compiler.h>
27 #include <linux/config.h>
28 #include <linux/errno.h>
29 #include <linux/if_arp.h>
30 #include <linux/in6.h>
33 #include <linux/kernel.h>
34 #include <linux/module.h>
35 #include <linux/netdevice.h>
36 #include <linux/proc_fs.h>
37 #include <linux/skbuff.h>
38 #include <linux/slab.h>
39 #include <linux/tcp.h>
40 #include <linux/types.h>
41 #include <linux/version.h>
42 #include <linux/wireless.h>
43 #include <linux/etherdevice.h>
44 #include <asm/uaccess.h>
46 #include <net/ieee80211.h>
48 int ieee80211_is_valid_channel(struct ieee80211_device
*ieee
, u8 channel
)
52 /* Driver needs to initialize the geography map before using
53 * these helper functions */
54 BUG_ON(ieee
->geo
.bg_channels
== 0 && ieee
->geo
.a_channels
== 0);
56 if (ieee
->freq_band
& IEEE80211_24GHZ_BAND
)
57 for (i
= 0; i
< ieee
->geo
.bg_channels
; i
++)
58 /* NOTE: If G mode is currently supported but
59 * this is a B only channel, we don't see it
61 if ((ieee
->geo
.bg
[i
].channel
== channel
) &&
62 (!(ieee
->mode
& IEEE_G
) ||
63 !(ieee
->geo
.bg
[i
].flags
& IEEE80211_CH_B_ONLY
)))
64 return IEEE80211_24GHZ_BAND
;
66 if (ieee
->freq_band
& IEEE80211_52GHZ_BAND
)
67 for (i
= 0; i
< ieee
->geo
.a_channels
; i
++)
68 if (ieee
->geo
.a
[i
].channel
== channel
)
69 return IEEE80211_52GHZ_BAND
;
74 int ieee80211_channel_to_index(struct ieee80211_device
*ieee
, u8 channel
)
78 /* Driver needs to initialize the geography map before using
79 * these helper functions */
80 BUG_ON(ieee
->geo
.bg_channels
== 0 && ieee
->geo
.a_channels
== 0);
82 if (ieee
->freq_band
& IEEE80211_24GHZ_BAND
)
83 for (i
= 0; i
< ieee
->geo
.bg_channels
; i
++)
84 if (ieee
->geo
.bg
[i
].channel
== channel
)
87 if (ieee
->freq_band
& IEEE80211_52GHZ_BAND
)
88 for (i
= 0; i
< ieee
->geo
.a_channels
; i
++)
89 if (ieee
->geo
.a
[i
].channel
== channel
)
95 u8
ieee80211_freq_to_channel(struct ieee80211_device
* ieee
, u32 freq
)
99 /* Driver needs to initialize the geography map before using
100 * these helper functions */
101 BUG_ON(ieee
->geo
.bg_channels
== 0 && ieee
->geo
.a_channels
== 0);
105 if (ieee
->freq_band
& IEEE80211_24GHZ_BAND
)
106 for (i
= 0; i
< ieee
->geo
.bg_channels
; i
++)
107 if (ieee
->geo
.bg
[i
].freq
== freq
)
108 return ieee
->geo
.bg
[i
].channel
;
110 if (ieee
->freq_band
& IEEE80211_52GHZ_BAND
)
111 for (i
= 0; i
< ieee
->geo
.a_channels
; i
++)
112 if (ieee
->geo
.a
[i
].freq
== freq
)
113 return ieee
->geo
.a
[i
].channel
;
118 int ieee80211_set_geo(struct ieee80211_device
*ieee
,
119 const struct ieee80211_geo
*geo
)
121 memcpy(ieee
->geo
.name
, geo
->name
, 3);
122 ieee
->geo
.name
[3] = '\0';
123 ieee
->geo
.bg_channels
= geo
->bg_channels
;
124 ieee
->geo
.a_channels
= geo
->a_channels
;
125 memcpy(ieee
->geo
.bg
, geo
->bg
, geo
->bg_channels
*
126 sizeof(struct ieee80211_channel
));
127 memcpy(ieee
->geo
.a
, geo
->a
, ieee
->geo
.a_channels
*
128 sizeof(struct ieee80211_channel
));
132 const struct ieee80211_geo
*ieee80211_get_geo(struct ieee80211_device
*ieee
)
137 EXPORT_SYMBOL(ieee80211_is_valid_channel
);
138 EXPORT_SYMBOL(ieee80211_freq_to_channel
);
139 EXPORT_SYMBOL(ieee80211_channel_to_index
);
140 EXPORT_SYMBOL(ieee80211_set_geo
);
141 EXPORT_SYMBOL(ieee80211_get_geo
);