New WPA-capable version of prism2.device.
[AROS.git] / workbench / devs / networks / prism2 / device.h
blob348726a8565cf24208603ed68dc744524ca77f5c
1 /*
3 Copyright (C) 2001-2012 Neil Cafferkey
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 MA 02111-1307, USA.
22 #ifndef DEVICE_H
23 #define DEVICE_H
26 #include <exec/types.h>
27 #include <exec/devices.h>
28 #include <exec/interrupts.h>
29 #include <exec/semaphores.h>
30 #include <devices/sana2.h>
31 #include <devices/sana2specialstats.h>
32 #include <devices/sana2wireless.h>
33 #include <devices/timer.h>
34 #include <dos/dosextens.h>
36 #include "wireless.h"
37 #include "io.h"
39 #define DEVICE_NAME "prism2.device"
40 #define VERSION 2
41 #define REVISION 5
42 #define DATE "9.10.2012"
44 #define UTILITY_VERSION 39
45 #define PROMETHEUS_VERSION 2
46 #define POWERPCI_VERSION 2
47 #define CYBPCI_VERSION 2
48 #define EXPANSION_VERSION 50
49 #define OPENPCI_VERSION 1
50 #define PCCARD_VERSION 1
51 #define DOS_VERSION 36
53 #ifndef UPINT
54 #ifdef __AROS__
55 typedef IPTR UPINT;
56 typedef SIPTR PINT;
57 #else
58 typedef ULONG UPINT;
59 typedef LONG PINT;
60 #endif
61 #endif
63 #ifndef REG
64 #if defined(__mc68000) && !defined(__AROS__)
65 #define _REG(A, B) B __asm(#A)
66 #define REG(A, B) _REG(A, B)
67 #else
68 #define REG(A, B) B
69 #endif
70 #endif
72 #define _STR(A) #A
73 #define STR(A) _STR(A)
75 #ifndef __AROS__
76 #define USE_HACKS
77 #endif
79 #if defined(__mc68000)
80 #define AddResetCallback(callback) TRUE
81 #define RemResetCallback(callback)
82 #endif
85 struct DevBase
87 struct Device device;
88 APTR seg_list;
89 struct ExecBase *sys_base;
90 struct UtilityBase *utility_base;
91 struct Library *prometheus_base;
92 struct Library *powerpci_base;
93 struct Library *cybpci_base;
94 struct Library *openpci_base;
95 struct Library *pccard_base;
96 APTR card_base;
97 struct DosLibrary *dos_base;
98 struct MinList pci_units;
99 struct MinList pccard_units;
100 struct timerequest timer_request;
101 #ifdef __amigaos4__
102 struct Library *expansion_base;
103 struct ExecIFace *i_exec;
104 struct UtilityIFace *i_utility;
105 struct PCIIFace *i_pci;
106 struct CardIFace *i_card;
107 struct PCCardIFace *i_pccard;
108 struct DOSIFace *i_dos;
109 struct TimerIFace *i_timer;
110 #endif
111 VOID (*wrapper_int_code)();
112 VOID (*wrapper_card_code)();
116 enum
118 WRITE_QUEUE,
119 ADOPT_QUEUE,
120 EVENT_QUEUE,
121 SCAN_QUEUE,
122 GENERAL_QUEUE,
123 REQUEST_QUEUE_COUNT
126 enum
128 PCI_BUS,
129 TMD_BUS,
130 PLX_BUS,
131 PCCARD_BUS
134 enum
136 INTERSIL_FIRMWARE,
137 SYMBOL_FIRMWARE,
138 // AIRONET_FIRMWARE
139 LUCENT_FIRMWARE,
140 HERMES2_FIRMWARE,
141 HERMES2G_FIRMWARE,
144 #define IO_WINDOW_SIZE 0x40
146 #define ETH_ADDRESSSIZE 6
147 #define ETH_HEADERSIZE 14
148 #define ETH_MTU 1500
149 #define ETH_MAXPACKETSIZE (ETH_HEADERSIZE + ETH_MTU)
151 #define ETH_PACKET_DEST 0
152 #define ETH_PACKET_SOURCE 6
153 #define ETH_PACKET_TYPE 12
154 #define ETH_PACKET_IEEELEN 12
155 #define ETH_PACKET_DATA 14
157 #define SNAP_HEADERSIZE 8
159 #define SNAP_FRM_TYPE 6
161 #define IV_SIZE 4
162 #define EIV_SIZE 8
163 #define ICV_SIZE 4
164 #define MIC_SIZE 8
166 #define ENC_COUNT 4
167 #define STAT_COUNT 3
169 #define RX_BUFFER_COUNT 10
172 struct KeyUnion
174 UWORD type;
175 union
177 struct WEPKey
179 UWORD length;
180 UBYTE key[13];
181 ULONG tx_iv;
183 wep;
184 struct TKIPKey
186 UWORD key[8];
187 ULONG tx_mic_key[2];
188 ULONG rx_mic_key[2];
189 UWORD tx_iv_low;
190 ULONG tx_iv_high;
191 UWORD rx_iv_low;
192 ULONG rx_iv_high;
193 UWORD tx_ttak[5];
194 BOOL tx_ttak_set;
195 UWORD rx_ttak[5];
196 BOOL rx_ttak_set;
198 tkip;
199 struct CCMPKey
201 UBYTE key[16];
202 BOOL stream_set;
203 ULONG stream[44];
204 UWORD tx_iv_low;
205 ULONG tx_iv_high;
206 UWORD rx_iv_low;
207 ULONG rx_iv_high;
209 ccmp;
215 struct DevUnit
217 struct MinNode node;
218 ULONG index;
219 ULONG open_count;
220 ULONG flags;
221 UWORD bus;
222 struct Task *task;
223 struct MsgPort *request_ports[REQUEST_QUEUE_COUNT];
224 struct DevBase *device;
225 APTR card;
226 BOOL (*insertion_function)(APTR, struct DevBase *);
227 VOID (*removal_function)(APTR, struct DevBase *);
228 VOID (*WordsIn)(APTR, ULONG, UWORD *, ULONG);
229 VOID (*WordsOut)(APTR, ULONG, const UWORD *, ULONG);
230 VOID (*BEWordOut)(APTR, ULONG, UWORD);
231 UWORD (*LEWordIn)(APTR, ULONG);
232 VOID (*LEWordOut)(APTR, ULONG, UWORD);
233 UBYTE *rx_buffer;
234 UBYTE *rx_buffers;
235 LONG rx_fragment_nos[RX_BUFFER_COUNT];
236 UBYTE *tx_buffer;
237 UBYTE *rx_descriptor;
238 UBYTE *tx_descriptor;
239 UBYTE ssid[WIFI_MAXIDLEN];
240 ULONG card_removed_signal;
241 ULONG card_inserted_signal;
242 ULONG scan_complete_signal;
243 ULONG range_count;
244 UBYTE address[ETH_ADDRESSSIZE];
245 UBYTE default_address[ETH_ADDRESSSIZE];
246 UBYTE bssid[ETH_ADDRESSSIZE + 2];
247 struct MinList openers;
248 struct MinList type_trackers;
249 struct MinList multicast_ranges;
250 struct Interrupt status_int;
251 struct Interrupt rx_int;
252 struct Interrupt tx_int;
253 struct Interrupt info_int;
254 struct Interrupt reset_handler;
255 struct Sana2DeviceStats stats;
256 ULONG special_stats[STAT_COUNT];
257 ULONG speed;
258 struct Sana2SignalQuality signal_quality;
259 struct SignalSemaphore access_lock;
260 UWORD tx_frame_id;
261 UWORD mode;
262 UWORD channel;
263 UWORD firmware_type;
264 UWORD auth_types;
265 UWORD ssid_length; // ???
266 UWORD tx_key_no;
267 struct KeyUnion keys[WIFI_KEYCOUNT];
268 UWORD iv_sizes[ENC_COUNT];
269 VOID (*fragment_encrypt_functions[ENC_COUNT])(struct DevUnit *, UBYTE *,
270 UBYTE *, UWORD *, UBYTE *, struct DevBase *);
271 BOOL (*fragment_decrypt_functions[ENC_COUNT])(struct DevUnit *, UBYTE *,
272 UBYTE *, UWORD *, UBYTE *, struct DevBase *);
273 UWORD *scan_results_rec;
274 UBYTE *beacons;
275 UBYTE *next_beacon;
276 UBYTE wpa_ie[100];
277 UWORD beacon_count;
278 UWORD ethernet_offset;
279 UWORD data_offset;
280 UWORD datalen_offset;
281 UWORD txcontrol_offset;
285 struct Opener
287 struct MinNode node;
288 struct MsgPort read_port;
289 BOOL (*rx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
290 BOOL (*tx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
291 UBYTE *(*dma_tx_function)(REG(a0, APTR));
292 struct Hook *filter_hook;
293 struct MinList initial_stats;
294 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
295 const VOID *real_rx_function;
296 const VOID *real_tx_function;
297 const VOID *real_dma_tx_function;
298 #endif
302 struct TypeStats
304 struct MinNode node;
305 ULONG packet_type;
306 struct Sana2PacketTypeStats stats;
310 struct TypeTracker
312 struct MinNode node;
313 ULONG packet_type;
314 struct Sana2PacketTypeStats stats;
315 ULONG user_count;
319 struct AddressRange
321 struct MinNode node;
322 ULONG add_count;
323 ULONG lower_bound_left;
324 ULONG upper_bound_left;
325 UWORD lower_bound_right;
326 UWORD upper_bound_right;
330 /* Unit flags */
332 #define UNITF_SHARED (1 << 0)
333 #define UNITF_ONLINE (1 << 1)
334 #define UNITF_HAVEADAPTER (1 << 3)
335 #define UNITF_CONFIGURED (1 << 4)
336 #define UNITF_PROM (1 << 5)
337 #define UNITF_WASONLINE (1 << 6) /* card was online at time of removal */
338 #define UNITF_HASWEP (1 << 7)
339 #define UNITF_HASTKIP (1 << 8)
340 #define UNITF_HARDWEP (1 << 9)
341 #define UNITF_HARDTKIP (1 << 10)
342 #define UNITF_ALLMCAST (1 << 11)
343 #define UNITF_HASADHOC (1 << 12)
344 #define UNITF_INTADDED (1 << 13)
345 #define UNITF_RESETADDED (1 << 14)
346 #define UNITF_HASCCMP (1 << 15)
347 #define UNITF_ASSOCIATED (1 << 16)
350 /* Endianness macros */
352 #define FlipWord(A) \
353 ({ \
354 UWORD _FlipWord_A = (A); \
355 _FlipWord_A = (_FlipWord_A << 8) | (_FlipWord_A >> 8); \
358 #define FlipLong(A) \
359 ({ \
360 ULONG _FlipLong_A = (A); \
361 _FlipLong_A = \
362 (FlipWord(_FlipLong_A) << 16) | FlipWord(_FlipLong_A >> 16); \
365 #ifndef __i386__ /* Big endian */
367 #define BEWord(A) \
370 #define BELong(A) \
373 #define LEWord(A) \
374 FlipWord(A)
376 #define LELong(A) \
377 FlipLong(A)
379 #else
381 #define BEWord(A) \
382 FlipWord(A)
384 #define BELong(A) \
385 FlipLong(A)
387 #define LEWord(A) \
390 #define LELong(A) \
393 #endif
395 #define MakeBEWord(A) \
396 BEWord(A)
398 #define MakeBELong(A) \
399 BELong(A)
401 #define MakeLEWord(A) \
402 LEWord(A)
404 #define MakeLELong(A) \
405 LELong(A)
408 /* Library and device bases */
410 #define SysBase (base->sys_base)
411 #define CardResource (base->card_base)
412 #define UtilityBase (base->utility_base)
413 #define ExpansionBase (base->expansion_base)
414 #define OpenPciBase (base->openpci_base)
415 #define PrometheusBase (base->prometheus_base)
416 #define PowerPCIBase (base->powerpci_base)
417 #define CybPCIBase (base->cybpci_base)
418 #define PCCardBase (base->pccard_base)
419 #define DOSBase (base->dos_base)
420 #define TimerBase (base->timer_request.tr_node.io_Device)
422 #ifdef __amigaos4__
423 #define IExec (base->i_exec)
424 #define IUtility (base->i_utility)
425 #define ICard (base->i_card)
426 #define IPCCard (base->i_pccard)
427 #define IDOS (base->i_dos)
428 #define ITimer (base->i_timer)
429 #endif
431 #ifndef BASE_REG
432 #define BASE_REG a6
433 #endif
436 #endif