Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed wrong offsets for WlanGetAvailableNetworkList, added enums for … #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,22 @@
<groupId>net.java.dev.wlanapi</groupId>
<artifactId>jwlanapi</artifactId>
<version>0.0.1-PRE-ALPHA</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.5.0</version>
</dependency>
</dependencies>
</project>
48 changes: 48 additions & 0 deletions src/main/java/net/java/dev/wlanapi/Dot11AuthAlgorithm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package net.java.dev.wlanapi;

import java.util.Arrays;

/*
typedef enum _DOT11_AUTH_ALGORITHM {
#endif
DOT11_AUTH_ALGO_80211_OPEN = 1,
DOT11_AUTH_ALGO_80211_SHARED_KEY = 2,
DOT11_AUTH_ALGO_WPA = 3,
DOT11_AUTH_ALGO_WPA_PSK = 4,
DOT11_AUTH_ALGO_WPA_NONE = 5, // used in NatSTA only
DOT11_AUTH_ALGO_RSNA = 6,
DOT11_AUTH_ALGO_RSNA_PSK = 7,
DOT11_AUTH_ALGO_WPA3 = 8,
DOT11_AUTH_ALGO_WPA3_SAE = 9,
DOT11_AUTH_ALGO_IHV_START = 0x80000000,
DOT11_AUTH_ALGO_IHV_END = 0xffffffff
} DOT11_AUTH_ALGORITHM, * PDOT11_AUTH_ALGORITHM;
*/

public enum Dot11AuthAlgorithm {
DOT11_AUTH_ALGO_80211_OPEN(1),
DOT11_AUTH_ALGO_80211_SHARED_KEY(2),
DOT11_AUTH_ALGO_WPA(3),
DOT11_AUTH_ALGO_WPA_PSK(4),
DOT11_AUTH_ALGO_WPA_NONE(5),
DOT11_AUTH_ALGO_RSNA(6),
DOT11_AUTH_ALGO_RSNA_PSK(7),
DOT11_AUTH_ALGO_WPA3(8),
DOT11_AUTH_ALGO_WPA3_SAE(9),
DOT11_AUTH_ALGO_IHV_START(0x80000000),
DOT11_AUTH_ALGO_IHV_END(0xffffffff);

private int flag;

private Dot11AuthAlgorithm(int flag) {
this.flag = flag;
}

public int getFlag() {
return this.flag;
}

public static Dot11AuthAlgorithm findByFlag(final int flag){
return Arrays.stream(values()).filter(value -> value.getFlag() == flag).findFirst().orElse(null);
}
}
31 changes: 31 additions & 0 deletions src/main/java/net/java/dev/wlanapi/Dot11BssType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.java.dev.wlanapi;

/*
typedef enum _DOT11_BSS_TYPE {
dot11_BSS_type_infrastructure = 1,
dot11_BSS_type_independent = 2,
dot11_BSS_type_any = 3
} DOT11_BSS_TYPE, * PDOT11_BSS_TYPE;
*/

import java.util.Arrays;

public enum Dot11BssType {
dot11_BSS_type_infrastructure(1),
dot11_BSS_type_independent(2),
dot11_BSS_type_any(3);

private int flag;

private Dot11BssType(int flag) {
this.flag = flag;
}

public int getFlag() {
return this.flag;
}

public static Dot11BssType findByFlag(final int flag){
return Arrays.stream(values()).filter(value -> value.getFlag() == flag).findFirst().orElse(null);
}
}
50 changes: 50 additions & 0 deletions src/main/java/net/java/dev/wlanapi/Dot11CipherAlgorithm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package net.java.dev.wlanapi;

import java.util.Arrays;

/*
typedef enum _DOT11_CIPHER_ALGORITHM {
#endif
DOT11_CIPHER_ALGO_NONE = 0x00,
DOT11_CIPHER_ALGO_WEP40 = 0x01,
DOT11_CIPHER_ALGO_TKIP = 0x02,
DOT11_CIPHER_ALGO_CCMP = 0x04,
DOT11_CIPHER_ALGO_WEP104 = 0x05,
DOT11_CIPHER_ALGO_BIP = 0x06,
DOT11_CIPHER_ALGO_GCMP = 0x08,
DOT11_CIPHER_ALGO_WPA_USE_GROUP = 0x100,
DOT11_CIPHER_ALGO_RSN_USE_GROUP = 0x100,
DOT11_CIPHER_ALGO_WEP = 0x101,
DOT11_CIPHER_ALGO_IHV_START = 0x80000000,
DOT11_CIPHER_ALGO_IHV_END = 0xffffffff
} DOT11_CIPHER_ALGORITHM, * PDOT11_CIPHER_ALGORITHM;
*/

public enum Dot11CipherAlgorithm {
DOT11_CIPHER_ALGO_NONE(0x00),
DOT11_CIPHER_ALGO_WEP40( 0x01),
DOT11_CIPHER_ALGO_TKIP( 0x02),
DOT11_CIPHER_ALGO_CCMP( 0x04),
DOT11_CIPHER_ALGO_WEP104( 0x05),
DOT11_CIPHER_ALGO_BIP( 0x06),
DOT11_CIPHER_ALGO_GCMP( 0x08),
DOT11_CIPHER_ALGO_WPA_USE_GROUP( 0x100),
DOT11_CIPHER_ALGO_RSN_USE_GROUP( 0x100),
DOT11_CIPHER_ALGO_WEP( 0x101),
DOT11_CIPHER_ALGO_IHV_START(0x80000000),
DOT11_CIPHER_ALGO_IHV_END(0xffffffff);

private int flag;

private Dot11CipherAlgorithm(int flag) {
this.flag = flag;
}

public int getFlag() {
return this.flag;
}

public static Dot11CipherAlgorithm findByFlag(final int flag){
return Arrays.stream(values()).filter(value -> value.getFlag() == flag).findFirst().orElse(null);
}
}
64 changes: 52 additions & 12 deletions src/main/java/net/java/dev/wlanapi/Dot11PhyType.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,58 @@
*******************************************************************************/
package net.java.dev.wlanapi;

/*
typedef enum _DOT11_PHY_TYPE {
#endif
dot11_phy_type_unknown = 0,
dot11_phy_type_any = dot11_phy_type_unknown,
dot11_phy_type_fhss = 1,
dot11_phy_type_dsss = 2,
dot11_phy_type_irbaseband = 3,
dot11_phy_type_ofdm = 4, // 11a
dot11_phy_type_hrdsss = 5, // 11b
dot11_phy_type_erp = 6, // 11g
dot11_phy_type_ht = 7, // 11n
dot11_phy_type_vht = 8, // 11ac
dot11_phy_type_dmg = 9, // 11ad
dot11_phy_type_he = 10, // 11ax
dot11_phy_type_IHV_start = 0x80000000,
dot11_phy_type_IHV_end = 0xffffffff
} DOT11_PHY_TYPE, * PDOT11_PHY_TYPE;

*/

import java.util.Arrays;

public enum Dot11PhyType
{
UNKNOWN,
ANY,
FHSS,
DSSS,
IRBASEBAND,
OFDM,
HRDSSS,
ERP,
HT,
VHT,
IHV_start, //0x80000000
IHV_end //0xffffffff
UNKNOWN(0),
ANY(0),
FHSS(1),
DSSS(2),
IRBASEBAND(3),
_11a(4),
_11b(5),
_11g(6),
_11n(7),
_11ac(8),
_11ad(9),
_11ax(10),
IHV_start(0x80000000), //0x80000000
IHV_end(0xffffffff); //0xffffffff


private int flag;

private Dot11PhyType(int flag) {
this.flag = flag;
}

public int getFlag() {
return this.flag;
}

public static Dot11PhyType findByFlag(final int flag){
return Arrays.stream(values()).filter(value -> value.getFlag() == flag).findFirst().orElse(null);
}
}
62 changes: 50 additions & 12 deletions src/main/java/net/java/dev/wlanapi/ScanResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package net.java.dev.wlanapi;

import java.util.Set;

/**
* Describes information about a detected access point. In addition
* to the attributes described here, the supplicant keeps track of
Expand All @@ -23,15 +25,21 @@
*/
public class ScanResult
{


/** The network name. */
public String SSID;
/** The address of the access point. */
public String BSSID;

/**
* Describes the authentication, key management, and encryption schemes
* supported by the access point.
* A DOT11_BSS_TYPE value that specifies whether the network is infrastructure or ad hoc.
*/
public String capabilities;
public final Dot11BssType bssType;

public final Set<Dot11PhyType> phyTypes;

/** The address of the access point. */
public String BSSID;

/**
* The detected signal level in dBm. At least those are the units used by
* the TI driver.
Expand All @@ -43,20 +51,42 @@ public class ScanResult
*/
public int frequency;

/**
* Indicates whether the network is connectable or not. If set to TRUE the network is connectable,
* otherwise the network cannot be connected to.
*/
public boolean connectable;

/**
* A DOT11_AUTH_ALGORITHM value that indicates the default authentication algorithm used to join this
* network for the first time.
*/
public final Dot11AuthAlgorithm authAlgorithm;

/**
* A DOT11_CIPHER_ALGORITHM value that indicates the default cipher algorithm to be used when
* joining this network.
*/
public final Dot11CipherAlgorithm cipherAlgorithm;

/**
* We'd like to obtain the following attributes,
* but they are not reported via the socket
* interface, even though they are known
* internally by wpa_supplicant.
* {@hide}
*/
public ScanResult(String SSID, String BSSID, String caps, int level, int frequency) {
public ScanResult(String SSID, Dot11BssType bssType, Set<Dot11PhyType> phyTypes, String BSSID, int level, int frequency, boolean connectable,
Dot11AuthAlgorithm authAlgorithm, Dot11CipherAlgorithm cipherAlgorithm) {
this.SSID = SSID;
this.bssType = bssType;
this.phyTypes = phyTypes;
this.BSSID = BSSID;
this.capabilities = caps;
this.level = level;
this.frequency = frequency;
//networkConfig = null;
this.connectable = connectable;
this.authAlgorithm = authAlgorithm;
this.cipherAlgorithm = cipherAlgorithm;
}

@Override
Expand All @@ -68,13 +98,21 @@ public String toString() {
append(SSID == null ? none : SSID).
append(", BSSID: ").
append(BSSID == null ? none : BSSID).
append(", capabilities: ").
append(capabilities == null ? none : capabilities).
append(", bssType: ").
append(bssType).
append(", phyTypes: ").
append(phyTypes).
append(", level: ").
append(level).
append(", frequency: ").
append(frequency);

append(frequency).
append(", connectable: ").
append(connectable).
append(", authAlgorithm: ").
append(authAlgorithm).
append(", cipherAlgorithm: ").
append(cipherAlgorithm)
;
return sb.toString();
}
}
Loading