MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / usb / net / Zydas / zdutils.h
blob5d2ebfc33da311ff009614c54f52b80a5ea71bbe
1 #ifndef __ZDUTILS_H__
2 #define __ZDUTILS_H__
3 #include "zdsorts.h"
6 #define isGroup(pMac) (((U8*)pMac)[0] & 0x01)
7 #define eLen(elm) ((elm)->buf[1])
8 #define body(f, n) ((f)->body[n])
11 #define addr1(f) ((MacAddr_t*)&((f)->header[4]))
12 #define addr2(f) ((MacAddr_t*)&((f)->header[10]))
13 #define addr3(f) ((MacAddr_t*)&((f)->header[16]))
14 #define addr4(f) ((MacAddr_t*)&((f)->header[24]))
15 #define setAddr1(f, addr) (memcpy((char*)&((f)->header[4]), (char*)addr, 6))
16 #define setAddr2(f, addr) (memcpy((char*)&((f)->header[10]), (char*)addr, 6))
17 #define setAddr3(f, addr) (memcpy((char*)&((f)->header[16]), (char*)addr, 6))
18 #define setAddr4(f, addr) (memcpy((char*)&((f)->header[24]), (char*)addr, 6))
19 #define setFrameType(f, ft) do {\
20 f->header[0] = ft;\
21 f->header[1] = 0;\
22 } while (0)
23 #define baseType(f) ((f)->header[0] & 0x0C)
24 #define frmType(f) ((f)->header[0] & 0xFC)
26 #define wepBit(f) (((f)->header[1] & WEP_BIT) ? 1 : 0)
27 #define orderBit(f) (((f)->header[1] & ORDER_BIT) ? 1 : 0)
28 #define durId(f) (((f)->header[2]) + ((f)->header[3]*256))
29 #define setAid(f, aid) do {\
30 f->header[2] = (U8)aid;\
31 f->header[3] = ((U8)(aid >> 8) | 0xc0);\
32 } while (0)
34 #define status(f) (body(f, 2) + (body(f, 3) * 256))
35 #define authType(f) (body(f, 0) + (body(f, 1) * 256))
36 #define authSeqNum(f) (body(f, 2) + (body(f, 3) * 256))
37 #define authStatus(f) (body(f, 4) + (body(f, 5) * 256))
38 #define reason(f) (body(f, 0) + (body(f, 1) * 256))
39 #define listenInt(f) (body(f, 2) + (body(f, 3) * 256))
40 #define cap(f) (body(f, 0) + (body(f, 1) * 256))
41 #define setTs(f, loTm, hiTm) do {\
42 body(f, 0) = (U8)loTm;\
43 body(f, 1) = (U8)(loTm >> 8);\
44 body(f, 2) = (U8)(loTm >> 16);\
45 body(f, 3) = (U8)(loTm >> 24);\
46 body(f, 4) = (U8)hiTm;\
47 body(f, 5) = (U8)(hiTm >> 8);\
48 body(f, 6) = (U8)(hiTm >> 16);\
49 body(f, 7) = (U8)(hiTm >> 24);\
50 } while (0)
51 #define trafficMap(trafficmap, aid) (((trafficmap)->t[(aid/8)] & (1<<(7-(aid%8))) ) == 0 ? 0 : 1)
54 #define beaconInt(f) (body(f, 8) + (body(f, 9) * 256))
55 #define cap1(f) (body(f, 10) + (body(f, 11) * 256))
56 #define aid(f) (body(f, 4) + (body(f, 5) * 256))
57 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
58 #define MAC2STR(a) (a)[0],(a)[1],(a)[2],(a)[3],(a)[4],(a)[5]
60 #endif