1+ /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
2+ *
3+ * The contents of this file is dual-licensed under 2
4+ * alternative Open Source/Free licenses: LGPL 2.1 or later and
5+ * Apache License 2.0. (starting with JNA version 4.0.0).
6+ *
7+ * You can freely decide which license you want to apply to
8+ * the project.
9+ *
10+ * You may obtain a copy of the LGPL License at:
11+ *
12+ * http://www.gnu.org/licenses/licenses.html
13+ *
14+ * A copy is also included in the downloadable source code package
15+ * containing JNA, in file "LGPL2.1".
16+ *
17+ * You may obtain a copy of the Apache License at:
18+ *
19+ * http://www.apache.org/licenses/
20+ *
21+ * A copy is also included in the downloadable source code package
22+ * containing JNA, in file "AL2.0".
23+ */
124package com .sun .jna .platform .win32 ;
225
326import com .sun .jna .Library ;
730import com .sun .jna .ptr .IntByReference ;
831import com .sun .jna .ptr .PointerByReference ;
932
10- import java .util .Arrays ;
11- import java .util .List ;
12-
1333/**
1434 * Module Name:
1535 * wlanapi.h
1636 * Abstract:
1737 * Definitions and data structures for wlan auto config client side API.
38+ *
39+ * @author Eran Leshem
1840 */
1941public interface WlanApi extends Library {
2042 WlanApi INSTANCE = Native .load ("wlanapi" , WlanApi .class );
2143 int WLAN_MAX_NAME_LENGTH = 256 ;
2244 int DOT11_SSID_MAX_LENGTH = 32 ; // 32 bytes
2345
46+ @ Structure .FieldOrder ({"dwNumberOfItems" , "dwIndex" , "InterfaceInfo" })
2447 class WLAN_INTERFACE_INFO_LIST extends Structure {
2548 public int dwNumberOfItems ;
2649 public int dwIndex ;
2750 public WLAN_INTERFACE_INFO [] InterfaceInfo = new WLAN_INTERFACE_INFO [1 ];
2851
2952 public WLAN_INTERFACE_INFO_LIST () {
30- setAutoSynch (false );
53+ setAutoSynch (false );
3154 }
3255
3356 public WLAN_INTERFACE_INFO_LIST (Pointer p ) {
3457 super (p );
3558 }
3659
3760 @ Override
38- protected List <String > getFieldOrder () {
39- return Arrays .asList ("dwNumberOfItems" , "dwIndex" , "InterfaceInfo" );
40- }
41-
4261 public void read () {
4362 // First element contains array size
4463 dwNumberOfItems = getPointer ().getInt (0 );
@@ -51,35 +70,47 @@ public void read() {
5170 }
5271 }
5372
73+ /**
74+ * Sruct WLAN_INTERFACE_INFO defines the basic information for an interface.
75+ */
76+ @ Structure .FieldOrder ({"InterfaceGuid" , "strInterfaceDescription" , "isState" })
5477 class WLAN_INTERFACE_INFO extends Structure {
55- public GUID InterfaceGuid ;
78+ public Guid . GUID InterfaceGuid ;
5679 public char [] strInterfaceDescription = new char [WLAN_MAX_NAME_LENGTH ];
57- public int isState ; // WLAN_INTERFACE_STATE
5880
59- @ Override
60- protected List < String > getFieldOrder () {
61- return Arrays . asList ( "InterfaceGuid" , "strInterfaceDescription" , "isState" );
62- }
81+ /**
82+ * See {@link WLAN_INTERFACE_STATE} for possible values
83+ */
84+ public int isState ;
6385 }
6486
65-
87+ /**
88+ * Structure WLAN_CONNECTION_ATTRIBUTES defines attributes of a wireless connection.
89+ */
90+ @ Structure .FieldOrder ({"isState" , "wlanConnectionMode" , "strProfileName" , "wlanAssociationAttributes" ,
91+ "wlanSecurityAttributes" })
6692 class WLAN_CONNECTION_ATTRIBUTES extends Structure {
67- public int isState ; // WLAN_INTERFACE_STATE
68- public int wlanConnectionMode ; // WLAN_CONNECTION_MODE
93+ /**
94+ * See {@link WLAN_INTERFACE_STATE} for possible values
95+ */
96+ public int isState ;
97+
98+ /**
99+ * See {@link WLAN_CONNECTION_MODE} for possible values
100+ */
101+ public int wlanConnectionMode ;
69102 public char [] strProfileName = new char [WLAN_MAX_NAME_LENGTH ];
70103 public WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes ;
71- // Other fields omitted
104+ public WLAN_SECURITY_ATTRIBUTES wlanSecurityAttributes ;
72105
73106 public WLAN_CONNECTION_ATTRIBUTES (Pointer p ) {
74107 super (p );
75108 }
76-
77- @ Override
78- protected List <String > getFieldOrder () {
79- return Arrays .asList ("isState" , "wlanConnectionMode" , "strProfileName" , "wlanAssociationAttributes" );
80- }
81109 }
82110
111+ /**
112+ * The states of the network (interface).
113+ */
83114 interface WLAN_INTERFACE_STATE {
84115 int wlan_interface_state_not_ready = 0 ;
85116 int wlan_interface_state_connected = 1 ;
@@ -100,19 +131,33 @@ interface WLAN_CONNECTION_MODE {
100131 int wlan_connection_mode_invalid = 5 ;
101132 }
102133
134+ /**
135+ * Structure WLAN_ASSOCIATION_ATTRIBUTES defines attributes of a wireless association.
136+ * The unit for Rx/Tx rate is Kbits/second.
137+ */
138+ @ Structure .FieldOrder ({"dot11Ssid" , "dot11BssType" , "dot11Bssid" , "dot11PhyType" , "uDot11PhyIndex" ,
139+ "wlanSignalQuality" , "ulRxRate" , "ulTxRate" })
103140 class WLAN_ASSOCIATION_ATTRIBUTES extends Structure {
104141 public DOT11_SSID dot11Ssid ;
105- public int dot11BssType ; // DOT11_BSS_TYPE
106- // Other fields omitted
142+
143+ /**
144+ * See {@link DOT11_BSS_TYPE} for possible values
145+ */
146+ public int dot11BssType ;
147+ public DOT11_MAC_ADDRESS dot11Bssid ;
148+
149+ /**
150+ * See {@link DOT11_PHY_TYPE} for possible values
151+ */
152+ public int dot11PhyType ;
153+ public WinDef .ULONG uDot11PhyIndex ;
154+ public WinDef .ULONG wlanSignalQuality ; // WLAN_SIGNAL_QUALITY
155+ public WinDef .ULONG ulRxRate ;
156+ public WinDef .ULONG ulTxRate ;
107157
108158 public WLAN_ASSOCIATION_ATTRIBUTES (Pointer p ) {
109159 super (p );
110160 }
111-
112- @ Override
113- protected List <String > getFieldOrder () {
114- return Arrays .asList ("dot11Ssid" , "dot11BssType" );
115- }
116161 }
117162
118163 interface DOT11_BSS_TYPE {
@@ -121,27 +166,77 @@ interface DOT11_BSS_TYPE {
121166 int dot11_BSS_type_any = 3 ;
122167 }
123168
169+ @ Structure .FieldOrder ({"uSSIDLength" , "ucSSID" })
124170 class DOT11_SSID extends Structure {
125171 public WinDef .ULONG uSSIDLength ;
126172 public byte [] ucSSID = new byte [DOT11_SSID_MAX_LENGTH ];
173+ }
127174
128- @ Override
129- protected List <String > getFieldOrder () {
130- return Arrays .asList ("uSSIDLength" , "ucSSID" );
131- }
175+ @ Structure .FieldOrder ("ucDot11MacAddress" )
176+ class DOT11_MAC_ADDRESS extends Structure {
177+ public WinDef .UCHAR [] ucDot11MacAddress = new WinDef .UCHAR [6 ];
132178 }
133179
134- class HANDLE extends WinNT .HANDLE {
135- public HANDLE () {
136- }
180+ interface DOT11_PHY_TYPE {
181+ int dot11_phy_type_unknown = 0 ;
182+ int dot11_phy_type_any = dot11_phy_type_unknown ;
183+ int dot11_phy_type_fhss = 1 ;
184+ int dot11_phy_type_dsss = 2 ;
185+ int dot11_phy_type_irbaseband = 3 ;
186+ int dot11_phy_type_ofdm = 4 ;
187+ int dot11_phy_type_hrdsss = 5 ;
188+ int dot11_phy_type_erp = 6 ;
189+ int dot11_phy_type_ht = 7 ;
190+ int dot11_phy_type_IHV_start = 0x80000000 ;
191+ int dot11_phy_type_IHV_end = 0xffffffff ;
192+ }
137193
138- public HANDLE (Pointer p ) {
139- super (p );
140- }
194+ @ Structure .FieldOrder ({"bSecurityEnabled" , "bOneXEnabled" , "dot11AuthAlgorithm" , "dot11CipherAlgorithm" })
195+ class WLAN_SECURITY_ATTRIBUTES extends Structure {
196+ public boolean bSecurityEnabled ;
197+ public boolean bOneXEnabled ;
198+
199+ /**
200+ * See {@link DOT11_AUTH_ALGORITHM} for possible values
201+ */
202+ public int dot11AuthAlgorithm ;
203+
204+ /**
205+ * See {@link DOT11_CIPHER_ALGORITHM} for possible values
206+ */
207+ public int dot11CipherAlgorithm ;
141208 }
142209
143- class GUID extends Guid .GUID {}
210+ // DOT11_AUTH_ALGO_LIST
211+ interface DOT11_AUTH_ALGORITHM {
212+ int DOT11_AUTH_ALGO_80211_OPEN = 1 ;
213+ int DOT11_AUTH_ALGO_80211_SHARED_KEY = 2 ;
214+ int DOT11_AUTH_ALGO_WPA = 3 ;
215+ int DOT11_AUTH_ALGO_WPA_PSK = 4 ;
216+ int DOT11_AUTH_ALGO_WPA_NONE = 5 ; // used in NatSTA only
217+ int DOT11_AUTH_ALGO_RSNA = 6 ;
218+ int DOT11_AUTH_ALGO_RSNA_PSK = 7 ;
219+ int DOT11_AUTH_ALGO_IHV_START = 0x80000000 ;
220+ int DOT11_AUTH_ALGO_IHV_END = 0xffffffff ;
221+ }
144222
223+ // Cipher algorithm Ids (for little endian platform)
224+ interface DOT11_CIPHER_ALGORITHM {
225+ int DOT11_CIPHER_ALGO_NONE = 0x00 ;
226+ int DOT11_CIPHER_ALGO_WEP40 = 0x01 ;
227+ int DOT11_CIPHER_ALGO_TKIP = 0x02 ;
228+ int DOT11_CIPHER_ALGO_CCMP = 0x04 ;
229+ int DOT11_CIPHER_ALGO_WEP104 = 0x05 ;
230+ int DOT11_CIPHER_ALGO_WPA_USE_GROUP = 0x100 ;
231+ int DOT11_CIPHER_ALGO_RSN_USE_GROUP = 0x100 ;
232+ int DOT11_CIPHER_ALGO_WEP = 0x101 ;
233+ int DOT11_CIPHER_ALGO_IHV_START = 0x80000000 ;
234+ int DOT11_CIPHER_ALGO_IHV_END = 0xffffffff ;
235+ }
236+
237+ /**
238+ * OpCodes for set/query interfaces.
239+ */
145240 interface WLAN_INTF_OPCODE {
146241 int wlan_intf_opcode_autoconf_start = 0x000000000 ;
147242 int wlan_intf_opcode_autoconf_enabled = 1 ;
@@ -178,11 +273,16 @@ interface WLAN_OPCODE_VALUE_TYPE {
178273 }
179274
180275 int WlanOpenHandle (int dwClientVersion , Pointer pReserved , IntByReference pdwNegotiatedVersion ,
181- PointerByReference phClientHandle );
182- int WlanCloseHandle (HANDLE hClientHandle , Pointer pReserved );
183- int WlanEnumInterfaces (HANDLE hClientHandle , Pointer pReserved , PointerByReference ppInterfaceList );
184- int WlanQueryInterface (HANDLE hClientHandle , GUID pInterfaceGuid , int OpCode /* WLAN_INTF_OPCODE */ ,
276+ WinNT .HANDLEByReference phClientHandle );
277+ int WlanCloseHandle (WinNT .HANDLE hClientHandle , Pointer pReserved );
278+ int WlanEnumInterfaces (WinNT .HANDLE hClientHandle , Pointer pReserved , PointerByReference ppInterfaceList );
279+
280+ /**
281+ * @param OpCode See {@link WLAN_INTF_OPCODE} for possible values
282+ * @param pWlanOpcodeValueType See {@link WLAN_OPCODE_VALUE_TYPE} for possible values
283+ */
284+ int WlanQueryInterface (WinNT .HANDLE hClientHandle , Guid .GUID pInterfaceGuid , int OpCode ,
185285 Pointer pReserved , IntByReference pDataSize , PointerByReference ppData ,
186- IntByReference pWlanOpcodeValueType /* WLAN_OPCODE_VALUE_TYPE */ );
286+ IntByReference pWlanOpcodeValueType );
187287 void WlanFreeMemory (Pointer pMemory );
188288}
0 commit comments