dswifi9.inc 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. (*
  2. $Id: dswifi9.inc 25 2007-12-10 21:06:46Z p4p3r0 $
  3. ------------------------------------------------------------------------------
  4. DSWifi Project - Arm9 Library Header File (dswifi9.h)
  5. (C) 2005-2006 Stephen Stair - [email protected] - http://www.akkit.org
  6. ******************************************************************************
  7. DSWifi Lib and test materials are licenced under the MIT open source licence:
  8. Copyright (c) 2005-2006 Stephen Stair
  9. Permission is hereby granted, free of charge, to any person obtaining a copy of
  10. this software and associated documentation files (the "Software"), to deal in
  11. the Software without restriction, including without limitation the rights to
  12. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  13. of the Software, and to permit persons to whom the Software is furnished to do
  14. so, subject to the following conditions:
  15. The above copyright notice and this permission notice shall be included in all
  16. copies or substantial portions of the Software.
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. SOFTWARE.
  24. ------------------------------------------------------------------------------
  25. Conversion by Legolas (http://itaprogaming.free.fr) for freepascal compiler
  26. (http://www.freepascal.org)
  27. Copyright (C) 2006 Francesco Lombardi
  28. Check http://sourceforge.net/projects/libndsfpc for updates
  29. ------------------------------------------------------------------------------
  30. Comments:
  31. *)
  32. {$include dswifi_version.inc}
  33. {$include sys/socket.inc}
  34. {$include netinet/in.inc}
  35. {$include netdb.inc}
  36. {$ifdef NDS_INTERFACE}
  37. const
  38. WIFIINIT_OPTION_USELED = $0002;
  39. WIFIINIT_OPTION_USEHEAP_128 = $0000;
  40. WIFIINIT_OPTION_USEHEAP_64 = $1000;
  41. WIFIINIT_OPTION_USEHEAP_256 = $2000;
  42. WIFIINIT_OPTION_USEHEAP_512 = $3000;
  43. WIFIINIT_OPTION_USECUSTOMALLOC = $4000;
  44. WIFIINIT_OPTION_HEAPMASK = $F000;
  45. WFLAG_PACKET_DATA = $0001;
  46. WFLAG_PACKET_MGT = $0002;
  47. WFLAG_PACKET_BEACON = $0004;
  48. WFLAG_PACKET_CTRL = $0008;
  49. WFLAG_PACKET_ALL = $FFFF;
  50. WFLAG_APDATA_ADHOC = $0001;
  51. WFLAG_APDATA_WEP = $0002;
  52. WFLAG_APDATA_WPA = $0004;
  53. WFLAG_APDATA_COMPATIBLE = $0008;
  54. WFLAG_APDATA_EXTCOMPATIBLE = $0010;
  55. WFLAG_APDATA_SHORTPREAMBLE = $0020;
  56. WFLAG_APDATA_ACTIVE = $8000;
  57. type
  58. TWIFI_RETURN = (
  59. WIFI_RETURN_OK = 0,
  60. WIFI_RETURN_LOCKFAILED = 1,
  61. WIFI_RETURN_ERROR = 2,
  62. WIFI_RETURN_PARAMERROR = 3
  63. );
  64. TWIFI_STATS = (
  65. WSTAT_RXQUEUEDPACKETS,
  66. WSTAT_TXQUEUEDPACKETS,
  67. WSTAT_RXQUEUEDBYTES,
  68. WSTAT_TXQUEUEDBYTES,
  69. WSTAT_RXQUEUEDLOST,
  70. WSTAT_TXQUEUEDREJECTED,
  71. WSTAT_RXPACKETS,
  72. WSTAT_RXBYTES,
  73. WSTAT_RXDATABYTES,
  74. WSTAT_TXPACKETS,
  75. WSTAT_TXBYTES,
  76. WSTAT_TXDATABYTES,
  77. WSTAT_HW_1B0,WSTAT_HW_1B1,WSTAT_HW_1B2,WSTAT_HW_1B3,WSTAT_HW_1B4,WSTAT_HW_1B5,WSTAT_HW_1B6,WSTAT_HW_1B7,
  78. WSTAT_HW_1B8,WSTAT_HW_1B9,WSTAT_HW_1BA,WSTAT_HW_1BB,WSTAT_HW_1BC,WSTAT_HW_1BD,WSTAT_HW_1BE,WSTAT_HW_1BF,
  79. WSTAT_HW_1C0,WSTAT_HW_1C1,WSTAT_HW_1C4,WSTAT_HW_1C5,
  80. WSTAT_HW_1D0,WSTAT_HW_1D1,WSTAT_HW_1D2,WSTAT_HW_1D3,WSTAT_HW_1D4,WSTAT_HW_1D5,WSTAT_HW_1D6,WSTAT_HW_1D7,
  81. WSTAT_HW_1D8,WSTAT_HW_1D9,WSTAT_HW_1DA,WSTAT_HW_1DB,WSTAT_HW_1DC,WSTAT_HW_1DD,WSTAT_HW_1DE,WSTAT_HW_1DF,
  82. NUM_WIFI_STATS
  83. );
  84. TWIFI_MODE = (
  85. WIFIMODE_DISABLED,
  86. WIFIMODE_NORMAL,
  87. WIFIMODE_SCAN,
  88. WIFIMODE_ASSOCIATE,
  89. WIFIMODE_ASSOCIATED,
  90. WIFIMODE_DISASSOCIATE,
  91. WIFIMODE_CANNOTASSOCIATE
  92. );
  93. TWIFI_AUTHLEVEL = (
  94. WIFI_AUTHLEVEL_DISCONNECTED,
  95. WIFI_AUTHLEVEL_AUTHENTICATED,
  96. WIFI_AUTHLEVEL_ASSOCIATED,
  97. WIFI_AUTHLEVEL_DEASSOCIATED
  98. );
  99. TWIFIGETDATA = (
  100. WIFIGETDATA_MACADDRESS,
  101. WIFIGETDATA_NUMWFCAPS,
  102. MAX_WIFIGETDATA
  103. );
  104. TWEPMODES = (
  105. WEPMODE_NONE = 0,
  106. WEPMODE_40BIT = 1,
  107. WEPMODE_128BIT = 2
  108. );
  109. TWIFI_ASSOCSTATUS = (
  110. ASSOCSTATUS_DISCONNECTED,
  111. ASSOCSTATUS_SEARCHING,
  112. ASSOCSTATUS_AUTHENTICATING,
  113. ASSOCSTATUS_ASSOCIATING,
  114. ASSOCSTATUS_ACQUIRINGDHCP,
  115. ASSOCSTATUS_ASSOCIATED,
  116. ASSOCSTATUS_CANNOTCONNECT
  117. );
  118. WIFI_TXHEADER = record
  119. enable_flags: cuint16;
  120. unknown: cuint16;
  121. countup: cuint16;
  122. beaconfreq: cuint16;
  123. tx_rate: cuint16;
  124. tx_length: cuint16;
  125. end;
  126. TWIFI_TXHEADER = WIFI_TXHEADER;
  127. PWIFI_TXHEADER = ^WIFI_TXHEADER;
  128. WIFI_RXHEADER = record
  129. a: cuint16;
  130. b: cuint16;
  131. c: cuint16;
  132. d: cuint16;
  133. byteLength: cuint16;
  134. rssi_: cuint16;
  135. end;
  136. TWIFI_RXHEADER = WIFI_RXHEADER;
  137. PWIFI_RXHEADER = ^WIFI_RXHEADER;
  138. WIFI_ACCESSPOINT = packed record
  139. ssid: array [0..32] of cchar;
  140. ssid_len: cchar;
  141. bssid: array [0..5] of cuint8;
  142. macaddr: array [0..5] of cuint8;
  143. maxrate: cuint16;
  144. timectr: cuint32;
  145. rssi: cuint16;
  146. flags: cuint16;
  147. spinlock: cuint32;
  148. channel: cuint8;
  149. rssi_past: array [0..7] of cuint8;
  150. base_rates: array [0..15] of cuint8;
  151. end;
  152. TWIFI_ACCESSPOINT = WIFI_ACCESSPOINT;
  153. PWIFI_ACCESSPOINT = ^WIFI_ACCESSPOINT;
  154. WifiPacketHandler = procedure(packetID, packetlength: cint);
  155. WifiSyncHandler = procedure;
  156. function Wifi_Init(initflags: cint): culong; cdecl; external;
  157. function Wifi_CheckInit(): cint; cdecl; external;
  158. procedure Wifi_DisableWifi(); cdecl; external;
  159. procedure Wifi_EnableWifi(); cdecl; external;
  160. procedure Wifi_SetPromiscuousMode(enable: cint); cdecl; external;
  161. procedure Wifi_ScanMode(); cdecl; external;
  162. procedure Wifi_SetChannel(channel: cint); cdecl; external;
  163. function Wifi_GetNumAP(): cint; cdecl; external;
  164. function Wifi_GetAPData(apnum: cint; apdata: PWifi_AccessPoint): cint; cdecl; external;
  165. function Wifi_FindMatchingAP(numaps: cint; apdata: PWifi_AccessPoint; match_dest: PWifi_AccessPoint): cint; cdecl; external;
  166. function Wifi_ConnectAP(apdata: PWifi_AccessPoint; wepmode, wepkeyid: cint; wepkey: pcuchar): cint; cdecl; external;
  167. procedure Wifi_AutoConnect(); cdecl; external;
  168. function Wifi_AssocStatus(): cint; cdecl; external;
  169. function Wifi_DisconnectAP(): cint; cdecl; external;
  170. procedure Wifi_Timer(num_ms: cint); cdecl; external;
  171. function Wifi_GetIP(): cuint32; cdecl; external;
  172. function Wifi_GetIPInfo(pGateway, pSnmask, pDns1, pDns2: pcuint32): cuint32; cdecl; external;
  173. procedure Wifi_SetIP(IPaddr, gateway, subnetmask, dns1, dns2: u32); cdecl; external;
  174. function Wifi_GetData(datatype, bufferlen: cint; buffer: pcuchar): cint; cdecl; external;
  175. function Wifi_GetStats(statnum: cint): cuint32; cdecl; external;
  176. function Wifi_RawTxFrame(datalen, rate: cuint16; data: pcuint16): cint; cdecl; external;
  177. procedure Wifi_RawSetPacketHandler(wphfunc: WifiPacketHandler); cdecl; external;
  178. function Wifi_RxRawReadPacket(packetID, readlength: cint32; data: pcuint16): cint; cdecl; external;
  179. procedure Wifi_Update(); cdecl; external;
  180. procedure Wifi_Sync(); cdecl; external;
  181. procedure Wifi_SetSyncHandler(sh: WifiSyncHandler); cdecl; external;
  182. //procedure Wifi_SetSyncHandler(sh: pointer); cdecl; external;
  183. {$endif NDS_INTERFACE}