0

I am trying to get the Channel using the windows API. So far, I have tried to use the wlan_intf_opcode_channel_number with the WlanQueryInterface function. I am not too sure what the reply means on that thread and was hoping someone could clarify.

ULONG channel = 0;
DWORD dwSizeChannel = sizeof(channel);

dwResult = WlanQueryInterface(
    hClient, 
    InterfaceGuid, 
    wlan_intf_opcode_channel_number, 
    NULL, 
    &dwSizeChannel, 
    (PVOID*)&channel, 
    NULL);

I am not sure what to do after here. Any help would be appreciated! After checking i found out that i always get the same value as channel has befor calling the WlanQueryInterface

  • If `dwResult` is equal to `ERROR_SUCCESS` after the call, then you get the value for the channel from your var named `channel`. If `dwResult` instead holds `ERROR_ACCESS_DENIED`, `ERROR_NOT_FOUND` or `ERROR_NOT_SUPPORTED` then you're out of luck. It's all covered in the documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/ms706765(v=vs.85).aspx – enhzflep Jul 25 '15 at 17:40
  • And if i want to set the channel type using WlanSetInterface? – Jenia Sakirko Jul 26 '15 at 10:03
  • I'm not so sure you even can set the channel. I don't recall ever seeing an option for that in either windows or linux. And, if you look at the docs for `WlanSetInterface` (https://msdn.microsoft.com/en-us/library/windows/desktop/ms706791(v=vs.85).aspx) you can see that there is no op-code supplied for channel setting. What is the problem you're trying to solve by setting the current channel? – enhzflep Jul 26 '15 at 11:04
  • For example - i wan't to monitor on a specific channel, or have the ability to do that – Jenia Sakirko Jul 26 '15 at 14:51
  • Here seems like a good place to start: http://superuser.com/questions/520060/how-to-select-wifi-channel-with-windows-7-adhoc - Basically, it comes down to the driver - some wifi hardware drivers facilitate it, some dont. The chipset in this Asus laptop doesn't support it - it's an "Atheros 9485 Wireless Network Adapter" - But still, I've no idea how to go about it if it is supported, sorry. – enhzflep Jul 26 '15 at 15:05

2 Answers2

1

The MS docs for the op-code seems to be wrong. If you try something similar here:


ULONG *channel = NULL;
DWORD dwSizeChannel = sizeof(*channel);

DWORD rc = WlanQueryInterface (
  hClient, InterfaceGuid, 
  wlan_intf_opcode_channel_number, 
  NULL, &dwSizeChannel, &channel, NULL);

if (rc == ERROR_SUCCESS && channel) {
  printf ("Channel: %lu\n", *channel):
  WlanFreeMemory (channel);
}

I do get the expected

Channel: 5
.

The same goes for wlan_intf_opcode_current_operation_mode and possibly other op-codes that's simply an ULONG.

G.Vanem
  • 111
  • 1
  • 5
0

I tried out WlanQueryInterface with the inputs from the documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/ms706765(v=vs.85).aspx

When query based on "wlan_intf_opcode_channel_number" was triggered, I got the data as "13". And the frequency could be made out as 2472Mhz from the WLAN information provided by the following wikipedia link: https://en.wikipedia.org/wiki/List_of_WLAN_channels

Hope this helps.

object
  • 796
  • 1
  • 12
  • 21