WlanDisconnect does not release the assigned IP address

Hello, I would like to ask if anyone can confirm that the Wifi Native function WlanDisconnect() does not work on Windows Compact 7 as asserted by this post: WINCE 7 WlanDisconnect API not working. And if yes, what is the best way to disconnect from a wireless network?

We have confirmed that calling WlanDisconnect() appears to disconnect the WLAN from the network. We can even see the wlan_notification_acm_disconnecting and wlan_notification_acm_disconnected notifications (using WlanRegisterNotification). However, we can still ping the IP address that the WiFi was assigned to.

In the post from the link I put above, there was a suggestion to UNBIND the adapter but this seems to disable the WiFi module altogether. We want it to be just in a disconnected state but still enabled so that scanning for wireless networks would still work.

Dear @dennisL,

If you disable connection manager as you said here : http://www.toradex.com/community/comments/39628/view.html then I guess it would not create this issue.

Please let us know did you try that already?

Hello, @raja.tx, Yes, actually our setup is that we have disabled Connection Manager and manage the WLAN through Native Wi-Fi api and we still get the issue where we can still ping the device after calling the WlanDisconnect() function.

I would also like to confirm if what this post https://social.msdn.microsoft.com/Forums/en-US/f9d1de2f-f98b-46ff-9b33-00ea8daacdd7/wince-7-wlandisconnect-api-not-working?forum=winembnatapp asserts is true.

“I don’t believe that API (WlanDisconnect) works in CE7.”

Dear @dennisL,

Could you manage this problem with IOCTL_NDIS_UNBIND_ADAPTER as described with your shared link?

We didn’t do too much code investigation as of now. But we would like to give some references. ReactOS uses WlanAPI : https://doxygen.reactos.org/d5/d9f/wlanconf_8c_source.html. you may find some useful information from there.

Also, refer \WINCE700\public\common\oak\drivers\netui code for IpReleaseAddress API usage.

Related forum question link: https://www.toradex.com/community/questions/29897/wince7-wifi-connection-manager-1.html

Hello @raja.tx. Thank you for the hint regarding IpReleaseAddress(). That was actually the solution we used in the end.

Before that, however, we actually tried the other DeviceIoControl request: IOCTL_NDIS_REBIND_ADAPTER. The problem with IOCTL_NDIS_UNBIND_ADAPTER is that it disables the WLAN driver itself. We only needed to disconnect from an Access Point but still be able to scan for available networks so we went for IOCTL_NDIS_REBIND_ADAPTER.

This presented other problems as well because then we were getting the wlan_notification_acm_interface_removal and wlan_notification_acm_interface_arrival notifications which was disturbing our state-machine but we managed this by making some adjustments to the notification-handlers and state-machine.

But then we tried your suggestion to use IpReleaseAddress() and it worked! To be honest, I was not so hopeful at first because the documentation described it as

The IpReleaseAddress function releases an IPv4 address previously obtained through the Dynamic Host Configuration Protocol (DHCP).

but we needed something that will also work for manually-configured IP address. I tried it anyway and found IpReleaseAddress() worked there as well.

Dear @dennisL,

Thank you for sharing the result with us.