Skip to content

Commit 659193a

Browse files
author
Eran Leshem
committed
Address comments
1 parent 7f39622 commit 659193a

File tree

2 files changed

+119
-64
lines changed

2 files changed

+119
-64
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
*/
24+
package com.sun.jna.platform.win32;
25+
26+
import com.sun.jna.Library;
27+
import com.sun.jna.Structure;
28+
29+
/**
30+
* Module Name:
31+
* windot11.h
32+
* Abstract:
33+
* Definitions for native 802.11 miniport driver specifications.
34+
*
35+
* @author Eran Leshem
36+
*/
37+
public interface Windot11 extends Library {
38+
int DOT11_SSID_MAX_LENGTH = 32; // 32 bytes
39+
40+
interface DOT11_BSS_TYPE {
41+
int dot11_BSS_type_infrastructure = 1;
42+
int dot11_BSS_type_independent = 2;
43+
int dot11_BSS_type_any = 3;
44+
}
45+
46+
@Structure.FieldOrder({"uSSIDLength", "ucSSID"})
47+
class DOT11_SSID extends Structure {
48+
public WinDef.ULONG uSSIDLength;
49+
public byte[] ucSSID = new byte[DOT11_SSID_MAX_LENGTH];
50+
}
51+
52+
@Structure.FieldOrder("ucDot11MacAddress")
53+
class DOT11_MAC_ADDRESS extends Structure {
54+
public WinDef.UCHAR[] ucDot11MacAddress = new WinDef.UCHAR[6];
55+
}
56+
57+
interface DOT11_PHY_TYPE {
58+
int dot11_phy_type_unknown = 0;
59+
int dot11_phy_type_any = dot11_phy_type_unknown;
60+
int dot11_phy_type_fhss = 1;
61+
int dot11_phy_type_dsss = 2;
62+
int dot11_phy_type_irbaseband = 3;
63+
int dot11_phy_type_ofdm = 4;
64+
int dot11_phy_type_hrdsss = 5;
65+
int dot11_phy_type_erp = 6;
66+
int dot11_phy_type_ht = 7;
67+
int dot11_phy_type_IHV_start = 0x80000000;
68+
int dot11_phy_type_IHV_end = 0xffffffff;
69+
}
70+
71+
// DOT11_AUTH_ALGO_LIST
72+
interface DOT11_AUTH_ALGORITHM {
73+
int DOT11_AUTH_ALGO_80211_OPEN = 1;
74+
int DOT11_AUTH_ALGO_80211_SHARED_KEY = 2;
75+
int DOT11_AUTH_ALGO_WPA = 3;
76+
int DOT11_AUTH_ALGO_WPA_PSK = 4;
77+
int DOT11_AUTH_ALGO_WPA_NONE = 5; // used in NatSTA only
78+
int DOT11_AUTH_ALGO_RSNA = 6;
79+
int DOT11_AUTH_ALGO_RSNA_PSK = 7;
80+
int DOT11_AUTH_ALGO_WPA3 = 8;
81+
int DOT11_AUTH_ALGO_WPA3_ENT_192 = DOT11_AUTH_ALGO_WPA3;
82+
int DOT11_AUTH_ALGO_WPA3_SAE = 9;
83+
int DOT11_AUTH_ALGO_OWE = 10;
84+
int DOT11_AUTH_ALGO_WPA3_ENT = 11;
85+
int DOT11_AUTH_ALGO_IHV_START = 0x80000000;
86+
int DOT11_AUTH_ALGO_IHV_END = 0xffffffff;
87+
}
88+
89+
// Cipher algorithm Ids (for little endian platform)
90+
interface DOT11_CIPHER_ALGORITHM {
91+
int DOT11_CIPHER_ALGO_NONE = 0x00;
92+
int DOT11_CIPHER_ALGO_WEP40 = 0x01;
93+
int DOT11_CIPHER_ALGO_TKIP = 0x02;
94+
int DOT11_CIPHER_ALGO_CCMP = 0x04;
95+
int DOT11_CIPHER_ALGO_WEP104 = 0x05;
96+
int DOT11_CIPHER_ALGO_BIP = 0x06;
97+
int DOT11_CIPHER_ALGO_GCMP = 0x08;
98+
int DOT11_CIPHER_ALGO_GCMP_256 = 0x09;
99+
int DOT11_CIPHER_ALGO_CCMP_256 = 0x0a;
100+
int DOT11_CIPHER_ALGO_BIP_GMAC_128 = 0x0b;
101+
int DOT11_CIPHER_ALGO_BIP_GMAC_256 = 0x0c;
102+
int DOT11_CIPHER_ALGO_BIP_CMAC_256 = 0x0d;
103+
int DOT11_CIPHER_ALGO_WPA_USE_GROUP = 0x100;
104+
int DOT11_CIPHER_ALGO_RSN_USE_GROUP = 0x100;
105+
int DOT11_CIPHER_ALGO_WEP = 0x101;
106+
int DOT11_CIPHER_ALGO_IHV_START = 0x80000000;
107+
int DOT11_CIPHER_ALGO_IHV_END = 0xffffffff;
108+
}
109+
}

contrib/platform/src/com/sun/jna/platform/win32/WlanApi.java

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.sun.jna.Structure;
3030
import com.sun.jna.ptr.IntByReference;
3131
import com.sun.jna.ptr.PointerByReference;
32+
import com.sun.jna.win32.W32APITypeMapper;
3233

3334
/**
3435
* Module Name:
@@ -41,7 +42,6 @@
4142
public interface WlanApi extends Library {
4243
WlanApi INSTANCE = Native.load("wlanapi", WlanApi.class);
4344
int WLAN_MAX_NAME_LENGTH = 256;
44-
int DOT11_SSID_MAX_LENGTH = 32; // 32 bytes
4545

4646
@Structure.FieldOrder({"dwNumberOfItems", "dwIndex", "InterfaceInfo"})
4747
class WLAN_INTERFACE_INFO_LIST extends Structure {
@@ -138,16 +138,16 @@ interface WLAN_CONNECTION_MODE {
138138
@Structure.FieldOrder({"dot11Ssid", "dot11BssType", "dot11Bssid", "dot11PhyType", "uDot11PhyIndex",
139139
"wlanSignalQuality", "ulRxRate", "ulTxRate"})
140140
class WLAN_ASSOCIATION_ATTRIBUTES extends Structure {
141-
public DOT11_SSID dot11Ssid;
141+
public Windot11.DOT11_SSID dot11Ssid;
142142

143143
/**
144-
* See {@link DOT11_BSS_TYPE} for possible values
144+
* See {@link Windot11.DOT11_BSS_TYPE} for possible values
145145
*/
146146
public int dot11BssType;
147-
public DOT11_MAC_ADDRESS dot11Bssid;
147+
public Windot11.DOT11_MAC_ADDRESS dot11Bssid;
148148

149149
/**
150-
* See {@link DOT11_PHY_TYPE} for possible values
150+
* See {@link Windot11.DOT11_BSS_TYPE} for possible values
151151
*/
152152
public int dot11PhyType;
153153
public WinDef.ULONG uDot11PhyIndex;
@@ -160,78 +160,24 @@ public WLAN_ASSOCIATION_ATTRIBUTES(Pointer p) {
160160
}
161161
}
162162

163-
interface DOT11_BSS_TYPE {
164-
int dot11_BSS_type_infrastructure = 1;
165-
int dot11_BSS_type_independent = 2;
166-
int dot11_BSS_type_any = 3;
167-
}
168-
169-
@Structure.FieldOrder({"uSSIDLength", "ucSSID"})
170-
class DOT11_SSID extends Structure {
171-
public WinDef.ULONG uSSIDLength;
172-
public byte[] ucSSID = new byte[DOT11_SSID_MAX_LENGTH];
173-
}
174-
175-
@Structure.FieldOrder("ucDot11MacAddress")
176-
class DOT11_MAC_ADDRESS extends Structure {
177-
public WinDef.UCHAR[] ucDot11MacAddress = new WinDef.UCHAR[6];
178-
}
179-
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-
}
193-
194163
@Structure.FieldOrder({"bSecurityEnabled", "bOneXEnabled", "dot11AuthAlgorithm", "dot11CipherAlgorithm"})
195164
class WLAN_SECURITY_ATTRIBUTES extends Structure {
196165
public boolean bSecurityEnabled;
197166
public boolean bOneXEnabled;
198167

199168
/**
200-
* See {@link DOT11_AUTH_ALGORITHM} for possible values
169+
* See {@link Windot11.DOT11_AUTH_ALGORITHM} for possible values
201170
*/
202171
public int dot11AuthAlgorithm;
203172

204173
/**
205-
* See {@link DOT11_CIPHER_ALGORITHM} for possible values
174+
* See {@link Windot11.DOT11_CIPHER_ALGORITHM} for possible values
206175
*/
207176
public int dot11CipherAlgorithm;
208-
}
209177

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-
}
222-
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;
178+
public WLAN_SECURITY_ATTRIBUTES() {
179+
super(W32APITypeMapper.UNICODE);
180+
}
235181
}
236182

237183
/**

0 commit comments

Comments
 (0)