net: Add inet_addr lookup by table
[linux-2.6/btrfs-unstable.git] / drivers / staging / rtl8192e / rtllib_module.c
blob224dc99af13193a3bb15db033c67625862d3fbb9
1 /*******************************************************************************
3 Copyright(c) 2004 Intel Corporation. All rights reserved.
5 Portions of this file are based on the WEP enablement code provided by the
6 Host AP project hostap-drivers v0.1.3
7 Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
8 <jkmaline@cc.hut.fi>
9 Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
11 This program is free software; you can redistribute it and/or modify it
12 under the terms of version 2 of the GNU General Public License as
13 published by the Free Software Foundation.
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 more details.
20 You should have received a copy of the GNU General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc., 59
22 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 The full GNU General Public License is included in this distribution in the
25 file called LICENSE.
27 Contact Information:
28 James P. Ketrenos <ipw2100-admin@linux.intel.com>
29 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
31 *******************************************************************************/
33 #include <linux/compiler.h>
34 #include <linux/errno.h>
35 #include <linux/if_arp.h>
36 #include <linux/in6.h>
37 #include <linux/in.h>
38 #include <linux/ip.h>
39 #include <linux/kernel.h>
40 #include <linux/module.h>
41 #include <linux/netdevice.h>
42 #include <linux/pci.h>
43 #include <linux/proc_fs.h>
44 #include <linux/skbuff.h>
45 #include <linux/slab.h>
46 #include <linux/tcp.h>
47 #include <linux/types.h>
48 #include <linux/wireless.h>
49 #include <linux/etherdevice.h>
50 #include <linux/uaccess.h>
51 #include <net/arp.h>
53 #include "rtllib.h"
56 u32 rt_global_debug_component = COMP_ERR;
57 EXPORT_SYMBOL(rt_global_debug_component);
61 static inline int rtllib_networks_allocate(struct rtllib_device *ieee)
63 if (ieee->networks)
64 return 0;
66 ieee->networks = kzalloc(
67 MAX_NETWORK_COUNT * sizeof(struct rtllib_network),
68 GFP_KERNEL);
69 if (!ieee->networks)
70 return -ENOMEM;
72 return 0;
75 static inline void rtllib_networks_free(struct rtllib_device *ieee)
77 if (!ieee->networks)
78 return;
79 kfree(ieee->networks);
80 ieee->networks = NULL;
83 static inline void rtllib_networks_initialize(struct rtllib_device *ieee)
85 int i;
87 INIT_LIST_HEAD(&ieee->network_free_list);
88 INIT_LIST_HEAD(&ieee->network_list);
89 for (i = 0; i < MAX_NETWORK_COUNT; i++)
90 list_add_tail(&ieee->networks[i].list,
91 &ieee->network_free_list);
94 struct net_device *alloc_rtllib(int sizeof_priv)
96 struct rtllib_device *ieee = NULL;
97 struct net_device *dev;
98 int i, err;
100 pr_debug("rtllib: Initializing...\n");
102 dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv);
103 if (!dev) {
104 pr_err("Unable to allocate net_device.\n");
105 return NULL;
107 ieee = (struct rtllib_device *)netdev_priv_rsl(dev);
108 memset(ieee, 0, sizeof(struct rtllib_device)+sizeof_priv);
109 ieee->dev = dev;
111 err = rtllib_networks_allocate(ieee);
112 if (err) {
113 pr_err("Unable to allocate beacon storage: %d\n", err);
114 goto failed;
116 rtllib_networks_initialize(ieee);
119 /* Default fragmentation threshold is maximum payload size */
120 ieee->fts = DEFAULT_FTS;
121 ieee->scan_age = DEFAULT_MAX_SCAN_AGE;
122 ieee->open_wep = 1;
124 /* Default to enabling full open WEP with host based encrypt/decrypt */
125 ieee->host_encrypt = 1;
126 ieee->host_decrypt = 1;
127 ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
129 ieee->rtllib_ap_sec_type = rtllib_ap_sec_type;
131 spin_lock_init(&ieee->lock);
132 spin_lock_init(&ieee->wpax_suitlist_lock);
133 spin_lock_init(&ieee->reorder_spinlock);
134 atomic_set(&(ieee->atm_swbw), 0);
136 /* SAM FIXME */
137 lib80211_crypt_info_init(&ieee->crypt_info, "RTLLIB", &ieee->lock);
139 ieee->wpa_enabled = 0;
140 ieee->tkip_countermeasures = 0;
141 ieee->drop_unencrypted = 0;
142 ieee->privacy_invoked = 0;
143 ieee->ieee802_1x = 1;
144 ieee->raw_tx = 0;
145 ieee->hwsec_active = 0;
147 memset(ieee->swcamtable, 0, sizeof(struct sw_cam_table) * 32);
148 rtllib_softmac_init(ieee);
150 ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL);
151 if (ieee->pHTInfo == NULL)
152 return NULL;
154 HTUpdateDefaultSetting(ieee);
155 HTInitializeHTInfo(ieee);
156 TSInitialize(ieee);
157 for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
158 INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
160 for (i = 0; i < 17; i++) {
161 ieee->last_rxseq_num[i] = -1;
162 ieee->last_rxfrag_num[i] = -1;
163 ieee->last_packet_time[i] = 0;
166 return dev;
168 failed:
169 free_netdev(dev);
170 return NULL;
172 EXPORT_SYMBOL(alloc_rtllib);
174 void free_rtllib(struct net_device *dev)
176 struct rtllib_device *ieee = (struct rtllib_device *)
177 netdev_priv_rsl(dev);
179 kfree(ieee->pHTInfo);
180 ieee->pHTInfo = NULL;
181 rtllib_softmac_free(ieee);
183 lib80211_crypt_info_free(&ieee->crypt_info);
185 rtllib_networks_free(ieee);
186 free_netdev(dev);
188 EXPORT_SYMBOL(free_rtllib);
190 static int __init rtllib_init(void)
192 return 0;
195 static void __exit rtllib_exit(void)
199 module_init(rtllib_init);
200 module_exit(rtllib_exit);
202 MODULE_LICENSE("GPL");