• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef APPLE80211_H
2 #define APPLE80211_H
3 
4 /*
5  * Apple80211 framework definitions
6  * This is an undocumented interface and the definitions here are based on
7  * information from MacStumbler (http://www.macstumbler.com/Apple80211.h) and
8  * whatever related information can be found with google and experiments ;-).
9  */
10 
11 typedef struct __WirelessRef *WirelessRef;
12 typedef SInt32 WirelessError;
13 #define errWirelessNoError 0
14 
15 typedef struct WirelessInfo {
16 	UInt16 link_qual;
17 	UInt16 comms_qual;
18 	UInt16 signal;
19 	UInt16 noise;
20 	UInt16 port_stat;
21 	UInt16 client_mode;
22 	UInt16 res1;
23 	UInt16 power;
24 	UInt16 res2;
25 	UInt8 bssID[6];
26 	UInt8 ssid[34];
27 } WirelessInfo;
28 
29 typedef struct WirelessInfo2 {
30 	/* TODO - these are probably not in correct order or complete */
31 	WirelessInfo info1;
32 	UInt8 macAddress[6];
33 } WirelessInfo2;
34 
35 typedef struct WirelessNetworkInfo {
36 	UInt16 channel;
37 	UInt16 noise;
38 	UInt16 signal;
39 	UInt8 bssid[6];
40 	UInt16 beacon_int;
41 	UInt16 capability;
42 	UInt16 ssid_len;
43 	UInt8 ssid[32];
44 } WirelessNetworkInfo;
45 
46 typedef int wirelessKeyType; /* TODO */
47 
48 int WirelessIsAvailable(void);
49 WirelessError WirelessAttach(WirelessRef *ref, UInt32 res);
50 WirelessError WirelessDetach(WirelessRef ref);
51 WirelessError WirelessPrivate(WirelessRef ref, void *in_ptr, int in_bytes,
52 			      void *out_ptr, int out_bytes);
53 WirelessError WirelessSetEnabled(WirelessRef ref, UInt8 enabled);
54 WirelessError WirelessGetEnabled(WirelessRef ref, UInt8 *enabled);
55 WirelessError WirelessSetPower(WirelessRef ref, UInt8 power);
56 WirelessError WirelessGetPower(WirelessRef ref, UInt8 *power);
57 WirelessError WirelessGetInfo(WirelessRef ref, WirelessInfo *info);
58 WirelessError WirelessGetInfo2(WirelessRef ref, WirelessInfo2 *info);
59 WirelessError WirelessScan(WirelessRef ref, CFArrayRef *results,
60 			   UInt32 strip_dups);
61 WirelessError WirelessScanSplit(WirelessRef ref, CFArrayRef *ap_results,
62 				CFArrayRef *ibss_results, UInt32 strip_dups);
63 WirelessError WirelessDirectedScan(WirelessRef ref, CFArrayRef *results,
64 				   UInt32 strip_dups, CFStringRef ssid);
65 WirelessError WirelessDirectedScan2(WirelessRef ref, CFDataRef ssid,
66 				    UInt32 strip_dups, CFArrayRef *results);
67 WirelessError WirelessJoin(WirelessRef ref, CFStringRef ssid);
68 WirelessError WirelessJoinWEP(WirelessRef ref, CFStringRef ssid,
69 			      CFStringRef passwd);
70 WirelessError WirelessJoin8021x(WirelessRef ref, CFStringRef ssid);
71 /*
72  * Set WEP key
73  * ref: wireless reference from WirelessAttach()
74  * type: ?
75  * key_idx: 0..3
76  * key_len: 13 for WEP-104 or 0 for clearing the key
77  * key: Pointer to the key or %NULL if key_len = 0
78  */
79 WirelessError WirelessSetKey(WirelessRef ref, wirelessKeyType type,
80 			     int key_idx, int key_len,
81 			     const unsigned char *key);
82 /*
83  * Set WPA key (e.g., PMK for 4-way handshake)
84  * ref: wireless reference from WirelessAttach()
85  * type: 0..4; 1 = PMK
86  * key_len: 16, 32, or 0
87  * key: Pointer to the key or %NULL if key_len = 0
88  */
89 WirelessError WirelessSetWPAKey(WirelessRef ref, wirelessKeyType type,
90 				int key_len, const unsigned char *key);
91 WirelessError WirelessAssociate(WirelessRef ref, int type, CFDataRef ssid,
92 				CFStringRef key);
93 WirelessError WirelessAssociate2(WirelessRef ref, CFDictionaryRef scan_res,
94 				 CFStringRef key);
95 WirelessError WirelessDisassociate(WirelessRef ref);
96 
97 /*
98  * Get a copy of scan results for the given SSID
99  * The returned dictionary includes following entries:
100  * beaconInterval: CFNumber(kCFNumberSInt32Type)
101  * SSID: CFData buffer of the SSID
102  * isWPA: CFNumber(kCFNumberSInt32Type); 0 = not used, 1 = WPA, -128 = WPA2
103  * name: Name of the network (SSID string)
104  * BSSID: CFData buffer of the BSSID
105  * channel: CFNumber(kCFNumberSInt32Type)
106  * signal: CFNumber(kCFNumberSInt32Type)
107  * appleIE: CFData
108  * WPSNOPINRequired: CFBoolean
109  * noise: CFNumber(kCFNumberSInt32Type)
110  * capability: CFNumber(kCFNumberSInt32Type)
111  * uniCipher: CFArray of CFNumber(kCFNumberSInt32Type)
112  * appleIE_Version: CFNumber(kCFNumberSInt32Type)
113  * appleIE_Robust: CFBoolean
114  * WPSConfigured: CFBoolean
115  * scanWasDirected: CFBoolean
116  * appleIE_Product: CFNumber(kCFNumberSInt32Type)
117  * authModes: CFArray of CFNumber(kCFNumberSInt32Type)
118  * multiCipher: CFNumber(kCFNumberSInt32Type)
119  */
120 CFDictionaryRef WirelessSafeDirectedScanCopy(WirelessRef ref, CFDataRef ssid);
121 
122 /*
123  * Get information about the current association
124  * The returned dictionary includes following entries:
125  * keyData: CFData buffer of the key (e.g., 32-octet PSK)
126  * multiCipher: CFNumber(kCFNumberSInt32Type); 0 = none, 5 = CCMP?
127  * channel: CFNumber(kCFNumberSInt32Type)
128  * isIBSS: CFBoolean
129  * authMode: CFNumber(kCFNumberSInt32Type); 2 = WPA-Personal; 3 = open,
130  *	129 = WPA2-Enterprise
131  * isWPA: CFNumber(kCFNumberSInt32Type); 0 = not used, 1 = WPA, -128 == WPA2
132  * SSID: CFData buffer of the SSID
133  * cipherMode: CFNumber(kCFNumberSInt32Type); 0 = none, 4 = CCMP?
134  */
135 CFDictionaryRef WirelessGetAssociationInfo(WirelessRef ref);
136 
137 WirelessError WirelessConfigure(WirelessRef ref);
138 
139 /*
140  * Get ASP information
141  * The returned dictionary includes following entries:
142  * Version: version number (e.g., 3.0)
143  * Channel: channel (e.g., 1)
144  * Vendor: vendor (e.g., 2)
145  */
146 CFDictionaryRef WirelessGetInfoASP(void);
147 
148 /*
149  * Get a copy of the interface dictionary
150  * The returned dictionary has a key,value pairs for wireless interfaces.
151  * The key is the interface name and the value is the driver identifier, e.g.,
152  * en1: com.apple.driver.AirPort.Atheros
153  */
154 CFDictionaryRef WirelessCopyInterfaceDict(void);
155 
156 #endif /* APPLE80211_H */
157