-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add WlanApi module #1697
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
base: master
Are you sure you want to change the base?
Add WlanApi module #1697
Conversation
matthiasblaesing
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I made a first pass. Please have a look at the inline comments.
| } | ||
|
|
||
| int WlanOpenHandle(int dwClientVersion, Pointer pReserved, IntByReference pdwNegotiatedVersion, | ||
| PointerByReference phClientHandle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| PointerByReference phClientHandle); | |
| HANDLEByReference phClientHandle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| @Override | ||
| protected List<String> getFieldOrder() { | ||
| return Arrays.asList("dwNumberOfItems", "dwIndex", "InterfaceInfo"); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use @FieldOrder annotation. See https://github.com/eranl/jna/blob/4073685fec63fb1418ed42d5c0cf4037251f96aa/contrib/platform/src/com/sun/jna/platform/win32/WinCrypt.java#L51-L104 for an example. Applies to all structures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| @@ -0,0 +1,188 @@ | |||
| package com.sun.jna.platform.win32; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The license header is missing (see for example
jna/contrib/platform/src/com/sun/jna/platform/win32/Crypt32.java
Lines 1 to 23 in dc44b98
| /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved | |
| * | |
| * The contents of this file is dual-licensed under 2 | |
| * alternative Open Source/Free licenses: LGPL 2.1 or later and | |
| * Apache License 2.0. (starting with JNA version 4.0.0). | |
| * | |
| * You can freely decide which license you want to apply to | |
| * the project. | |
| * | |
| * You may obtain a copy of the LGPL License at: | |
| * | |
| * http://www.gnu.org/licenses/licenses.html | |
| * | |
| * A copy is also included in the downloadable source code package | |
| * containing JNA, in file "LGPL2.1". | |
| * | |
| * You may obtain a copy of the Apache License at: | |
| * | |
| * http://www.apache.org/licenses/ | |
| * | |
| * A copy is also included in the downloadable source code package | |
| * containing JNA, in file "AL2.0". | |
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
| class WLAN_INTERFACE_INFO extends Structure { | ||
| public GUID InterfaceGuid; | ||
| public char[] strInterfaceDescription = new char[WLAN_MAX_NAME_LENGTH]; | ||
| public int isState; // WLAN_INTERFACE_STATE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this javadoc, then people might see this in IDE help. I.e.:
/**
* See {@link WLAN_INTERFACE_STATE} for possible values
*/
public int isState;This applies to other similar constructs in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| return Arrays.asList("dwNumberOfItems", "dwIndex", "InterfaceInfo"); | ||
| } | ||
|
|
||
| public void read() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing @Override
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
| public int wlanConnectionMode; // WLAN_CONNECTION_MODE | ||
| public char[] strProfileName = new char[WLAN_MAX_NAME_LENGTH]; | ||
| public WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes; | ||
| // Other fields omitted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break hard, if there is ever a use in an array or embedded inside another structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it acceptable to just add a warning about this in the doc, or should I complete these structures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If necessary I can live with a warning, on the other hand here is a single field missing which is admittedly a structure itself, but that is also not that big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completed structures.
| class HANDLE extends WinNT.HANDLE { | ||
| public HANDLE() { | ||
| } | ||
|
|
||
| public HANDLE(Pointer p) { | ||
| super(p); | ||
| } | ||
| } | ||
|
|
||
| class GUID extends Guid.GUID {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These redefinitions are not necessary and should not be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
matthiasblaesing
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. I checked the type definitions against MSDN and the headers are a bit convoluted. I see:
-
Definitions from
Wlantypes.h(or Windot11.h, see blow):DOT11_SSID_MAX_LENGTHDOT11_AUTH_ALGORITHMDOT11_CIPHER_ALGORITHMDOT11_BSS_TYPE(it is defined in Wlantypes.h, MSDN says you should includewindot11.h...)DOT11_SSID(it is defined in Wlantypes.h, MSDN says you should includewindot11.h...)
-
Definitions from
Windot11.h:DOT11_MAC_ADDRESSDOT11_PHY_TYPE
I think moving the referenced types to Windot11.java might be the cleanest solution.
For the type mapping of WLAN_SECURITY_ATTRIBUTES, please ensure, that a correct typemapper is active. boolean is not well defined. In Windows it is BOOL (32bit), but people would like to have boolean be a C bool, which is one byte (commonly). Use the com.sun.jna.win32.W32APITypeMapper.UNICODE mapper.
| int DOT11_AUTH_ALGO_WPA_PSK = 4; | ||
| int DOT11_AUTH_ALGO_WPA_NONE = 5; // used in NatSTA only | ||
| int DOT11_AUTH_ALGO_RSNA = 6; | ||
| int DOT11_AUTH_ALGO_RSNA_PSK = 7; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| int DOT11_AUTH_ALGO_RSNA_PSK = 7; | |
| int DOT11_AUTH_ALGO_RSNA_PSK = 7; | |
| int DOT11_AUTH_ALGO_WPA3 = 8; | |
| int DOT11_AUTH_ALGO_WPA3_ENT_192 = DOT11_AUTH_ALGO_WPA3; | |
| int DOT11_AUTH_ALGO_WPA3_SAE = 9; | |
| int DOT11_AUTH_ALGO_OWE = 10; | |
| int DOT11_AUTH_ALGO_WPA3_ENT = 11; |
| int DOT11_CIPHER_ALGO_WEP40 = 0x01; | ||
| int DOT11_CIPHER_ALGO_TKIP = 0x02; | ||
| int DOT11_CIPHER_ALGO_CCMP = 0x04; | ||
| int DOT11_CIPHER_ALGO_WEP104 = 0x05; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| int DOT11_CIPHER_ALGO_WEP104 = 0x05; | |
| int DOT11_CIPHER_ALGO_WEP104 = 0x05; | |
| int DOT11_CIPHER_ALGO_BIP = 0x06; | |
| int DOT11_CIPHER_ALGO_GCMP = 0x08; | |
| int DOT11_CIPHER_ALGO_GCMP_256 = 0x09; | |
| int DOT11_CIPHER_ALGO_CCMP_256 = 0x0a; | |
| int DOT11_CIPHER_ALGO_BIP_GMAC_128 = 0x0b; | |
| int DOT11_CIPHER_ALGO_BIP_GMAC_256 = 0x0c; | |
| int DOT11_CIPHER_ALGO_BIP_CMAC_256 = 0x0d; |
This is a partial mapping of
WlanApi.h.