1 typedef struct Wkey Wkey; 2 typedef struct Wnode Wnode; 3 typedef struct Wifi Wifi; 4 typedef struct Wifipkt Wifipkt; 5 6 enum { 7 Essidlen = 32, 8 }; 9 10 /* cipher */ 11 enum { 12 TKIP = 1, 13 CCMP = 2, 14 }; 15 16 struct Wkey 17 { 18 int cipher; 19 int len; 20 uvlong tsc; 21 uchar key[]; 22 }; 23 24 struct Wnode 25 { 26 uchar bssid[Eaddrlen]; 27 char ssid[Essidlen+2]; 28 29 char *status; 30 31 int rsnelen; 32 uchar rsne[258]; 33 Wkey *txkey[1]; 34 Wkey *rxkey[5]; 35 36 int aid; /* association id */ 37 ulong lastsend; 38 ulong lastseen; 39 40 uchar *minrate; /* pointers into wifi->rates */ 41 uchar *maxrate; 42 uchar *actrate; 43 44 ulong txcount; /* statistics for rate adaption */ 45 ulong txerror; 46 47 /* stuff from beacon */ 48 int ival; 49 int cap; 50 int channel; 51 int brsnelen; 52 uchar brsne[258]; 53 }; 54 55 struct Wifi 56 { 57 Ether *ether; 58 59 int debug; 60 61 RWlock crypt; 62 Queue *iq; 63 ulong watchdog; 64 ulong lastauth; 65 Ref txseq; 66 void (*transmit)(Wifi*, Wnode*, Block*); 67 68 /* for searching */ 69 uchar bssid[Eaddrlen]; 70 char essid[Essidlen+2]; 71 72 /* supported data rates by hardware */ 73 uchar *rates; 74 75 /* effective base station */ 76 Wnode *bss; 77 78 Wnode node[32]; 79 }; 80 81 struct Wifipkt 82 { 83 uchar fc[2]; 84 uchar dur[2]; 85 uchar a1[Eaddrlen]; 86 uchar a2[Eaddrlen]; 87 uchar a3[Eaddrlen]; 88 uchar seq[2]; 89 uchar a4[Eaddrlen]; 90 }; 91 92 Wifi *wifiattach(Ether *ether, void (*transmit)(Wifi*, Wnode*, Block*)); 93 void wifiiq(Wifi*, Block*); 94 int wifihdrlen(Wifipkt*); 95 void wifitxfail(Wifi*, Block*); 96 97 long wifistat(Wifi*, void*, long, ulong); 98 long wifictl(Wifi*, void*, long); 99 void wificfg(Wifi*, char*); 100