Apple80211.h 5.4 KB

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