|
| 1 | +package com.sun.jna.platform.win32; |
| 2 | + |
| 3 | +import com.sun.jna.Library; |
| 4 | +import com.sun.jna.Native; |
| 5 | +import com.sun.jna.Pointer; |
| 6 | +import com.sun.jna.Structure; |
| 7 | +import com.sun.jna.ptr.IntByReference; |
| 8 | +import com.sun.jna.ptr.PointerByReference; |
| 9 | + |
| 10 | +import java.util.Arrays; |
| 11 | +import java.util.List; |
| 12 | + |
| 13 | +/** |
| 14 | + * Module Name: |
| 15 | + * wlanapi.h |
| 16 | + * Abstract: |
| 17 | + * Definitions and data structures for wlan auto config client side API. |
| 18 | + */ |
| 19 | +public interface WlanApi extends Library { |
| 20 | + WlanApi INSTANCE = Native.load("wlanapi", WlanApi.class); |
| 21 | + int WLAN_MAX_NAME_LENGTH = 256; |
| 22 | + int DOT11_SSID_MAX_LENGTH = 32; // 32 bytes |
| 23 | + |
| 24 | + class WLAN_INTERFACE_INFO_LIST extends Structure { |
| 25 | + public int dwNumberOfItems; |
| 26 | + public int dwIndex; |
| 27 | + public WLAN_INTERFACE_INFO[] InterfaceInfo = new WLAN_INTERFACE_INFO[1]; |
| 28 | + |
| 29 | + public WLAN_INTERFACE_INFO_LIST() { |
| 30 | + setAutoSynch(false); |
| 31 | + } |
| 32 | + |
| 33 | + public WLAN_INTERFACE_INFO_LIST(Pointer p) { |
| 34 | + super(p); |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + protected List<String> getFieldOrder() { |
| 39 | + return Arrays.asList("dwNumberOfItems", "dwIndex", "InterfaceInfo"); |
| 40 | + } |
| 41 | + |
| 42 | + public void read() { |
| 43 | + // First element contains array size |
| 44 | + dwNumberOfItems = getPointer().getInt(0); |
| 45 | + if (dwNumberOfItems > 0) { |
| 46 | + InterfaceInfo = (WLAN_INTERFACE_INFO[]) new WLAN_INTERFACE_INFO().toArray(dwNumberOfItems); |
| 47 | + super.read(); |
| 48 | + } else { |
| 49 | + InterfaceInfo = new WLAN_INTERFACE_INFO[0]; |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + class WLAN_INTERFACE_INFO extends Structure { |
| 55 | + public GUID InterfaceGuid; |
| 56 | + public char[] strInterfaceDescription = new char[WLAN_MAX_NAME_LENGTH]; |
| 57 | + public int isState; // WLAN_INTERFACE_STATE |
| 58 | + |
| 59 | + @Override |
| 60 | + protected List<String> getFieldOrder() { |
| 61 | + return Arrays.asList("InterfaceGuid", "strInterfaceDescription", "isState"); |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + |
| 66 | + class WLAN_CONNECTION_ATTRIBUTES extends Structure { |
| 67 | + public int isState; // WLAN_INTERFACE_STATE |
| 68 | + public int wlanConnectionMode; // WLAN_CONNECTION_MODE |
| 69 | + public char[] strProfileName = new char[WLAN_MAX_NAME_LENGTH]; |
| 70 | + public WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes; |
| 71 | + // Other fields omitted |
| 72 | + |
| 73 | + public WLAN_CONNECTION_ATTRIBUTES(Pointer p) { |
| 74 | + super(p); |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + protected List<String> getFieldOrder() { |
| 79 | + return Arrays.asList("isState", "wlanConnectionMode", "strProfileName", "wlanAssociationAttributes"); |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + interface WLAN_INTERFACE_STATE { |
| 84 | + int wlan_interface_state_not_ready = 0; |
| 85 | + int wlan_interface_state_connected = 1; |
| 86 | + int wlan_interface_state_ad_hoc_network_formed = 2; |
| 87 | + int wlan_interface_state_disconnecting = 3; |
| 88 | + int wlan_interface_state_disconnected = 4; |
| 89 | + int wlan_interface_state_associating = 5; |
| 90 | + int wlan_interface_state_discovering = 6; |
| 91 | + int wlan_interface_state_authenticating = 7; |
| 92 | + } |
| 93 | + |
| 94 | + interface WLAN_CONNECTION_MODE { |
| 95 | + int wlan_connection_mode_profile = 0; |
| 96 | + int wlan_connection_mode_temporary_profile = 1; |
| 97 | + int wlan_connection_mode_discovery_secure = 2; |
| 98 | + int wlan_connection_mode_discovery_unsecure = 3; |
| 99 | + int wlan_connection_mode_auto = 4; |
| 100 | + int wlan_connection_mode_invalid = 5; |
| 101 | + } |
| 102 | + |
| 103 | + class WLAN_ASSOCIATION_ATTRIBUTES extends Structure { |
| 104 | + public DOT11_SSID dot11Ssid; |
| 105 | + public int dot11BssType; // DOT11_BSS_TYPE |
| 106 | + // Other fields omitted |
| 107 | + |
| 108 | + public WLAN_ASSOCIATION_ATTRIBUTES(Pointer p) { |
| 109 | + super(p); |
| 110 | + } |
| 111 | + |
| 112 | + @Override |
| 113 | + protected List<String> getFieldOrder() { |
| 114 | + return Arrays.asList("dot11Ssid", "dot11BssType"); |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + interface DOT11_BSS_TYPE { |
| 119 | + int dot11_BSS_type_infrastructure = 1; |
| 120 | + int dot11_BSS_type_independent = 2; |
| 121 | + int dot11_BSS_type_any = 3; |
| 122 | + } |
| 123 | + |
| 124 | + class DOT11_SSID extends Structure { |
| 125 | + public WinDef.ULONG uSSIDLength; |
| 126 | + public byte[] ucSSID = new byte[DOT11_SSID_MAX_LENGTH]; |
| 127 | + |
| 128 | + @Override |
| 129 | + protected List<String> getFieldOrder() { |
| 130 | + return Arrays.asList("uSSIDLength", "ucSSID"); |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + class HANDLE extends WinNT.HANDLE { |
| 135 | + public HANDLE() { |
| 136 | + } |
| 137 | + |
| 138 | + public HANDLE(Pointer p) { |
| 139 | + super(p); |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + class GUID extends Guid.GUID {} |
| 144 | + |
| 145 | + interface WLAN_INTF_OPCODE { |
| 146 | + int wlan_intf_opcode_autoconf_start = 0x000000000; |
| 147 | + int wlan_intf_opcode_autoconf_enabled = 1; |
| 148 | + int wlan_intf_opcode_background_scan_enabled = 2; |
| 149 | + int wlan_intf_opcode_media_streaming_mode = 3; |
| 150 | + int wlan_intf_opcode_radio_state = 4; |
| 151 | + int wlan_intf_opcode_bss_type = 5; |
| 152 | + int wlan_intf_opcode_interface_state = 6; |
| 153 | + int wlan_intf_opcode_current_connection = 7; |
| 154 | + int wlan_intf_opcode_channel_number = 8; |
| 155 | + int wlan_intf_opcode_supported_infrastructure_auth_cipher_pairs = 9; |
| 156 | + int wlan_intf_opcode_supported_adhoc_auth_cipher_pairs = 10; |
| 157 | + int wlan_intf_opcode_supported_country_or_region_string_list = 11; |
| 158 | + int wlan_intf_opcode_current_operation_mode = 12; |
| 159 | + int wlan_intf_opcode_supported_safe_mode = 13; |
| 160 | + int wlan_intf_opcode_certified_safe_mode = 14; |
| 161 | + int wlan_intf_opcode_hosted_network_capable = 15; |
| 162 | + int wlan_intf_opcode_autoconf_end = 0x0fffffff; |
| 163 | + int wlan_intf_opcode_msm_start = 0x10000100; |
| 164 | + int wlan_intf_opcode_statistics = 0x10000101; |
| 165 | + int wlan_intf_opcode_rssi = 0x10000102; |
| 166 | + int wlan_intf_opcode_msm_end = 0x1fffffff; |
| 167 | + int wlan_intf_opcode_security_start = 0x20010000; |
| 168 | + int wlan_intf_opcode_security_end = 0x2fffffff; |
| 169 | + int wlan_intf_opcode_ihv_start = 0x30000000; |
| 170 | + int wlan_intf_opcode_ihv_end = 0x3fffffff; |
| 171 | + } |
| 172 | + |
| 173 | + interface WLAN_OPCODE_VALUE_TYPE { |
| 174 | + int wlan_opcode_value_type_query_only = 0; |
| 175 | + int wlan_opcode_value_type_set_by_group_policy = 1; |
| 176 | + int wlan_opcode_value_type_set_by_user = 2; |
| 177 | + int wlan_opcode_value_type_invalid = 3; |
| 178 | + } |
| 179 | + |
| 180 | + 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 */, |
| 185 | + Pointer pReserved, IntByReference pDataSize, PointerByReference ppData, |
| 186 | + IntByReference pWlanOpcodeValueType /* WLAN_OPCODE_VALUE_TYPE */); |
| 187 | + void WlanFreeMemory(Pointer pMemory); |
| 188 | +} |
0 commit comments