You can register for a change notification through netio!NotifyUnicatIpAddressChange. When something happens (like media disconnect event), you’ll get a notification with the 3rd parameter set to MibParameterNotification. Check if Row->Address matches an IP address that you care about – if not, disregard the notification. Now you know that *something* changed, but it doesn’t tell you *what*. To figure out what has changed (or a better way to look at it: to figure out if you need to do anything), call GetIfEntry2 with the NET_LUID from the notification. This will tell you buckets of information, including the media connect state and the oper status. From there you can start/stop sending UDP packets or flush your queues, whatever. (If your processing will take a long time, be polite and schedule a work item so you don’t hog TCPIP’s worker thread).
The process for detecting when the link goes back up is exactly the same.
It’s worth pointing out that this notification will also notify you if the IP address is completely removed for some reason (e.g., the adapter is unplugged, or somebody runs “ipconfig /release” from the console). In that case, the notification type is MibDeleteInstance. I should imagine that you’d want to handle this case too.
BTW, I encourage you to stick with WSK instead of resorting to writing an NDIS protocol driver. With WSK, you are reusing a ton of code in the OS to handle the tedious plumbing of IPv4/IPv6. This will save you a lot of time, and prevent our customers from seeing weird corner case bugs. Also, you automatically get a lot of features for free, like native WWAN support, correct IP packet counters, and built-in firewalling.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, March 14, 2011 5:13 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Kernel Winsock UDP
Hi,
I am using Kernel Winsock interface to send UDP data grams out.
I am using an queue of IRP s in WSKSendTo. For every send an IRP is taken from queue. In send completion routine , the IRP is again put back to queue.
I am using a wirless interface. During data transmission , I switch off the receiver. But my kernel application keep on sending data out without knowing the connection is no longer there. Is there any call back (socket or kernel event) in WSK to know the connection is not there? But the real problem is that , the send completion routine is not getting called immediately. So my IRP queue gets used up. After that if I try to close the socket, it does not get closed. It takes a long time for all the completion routine to get called and get the socket closed.
Is there any way to check the interface link status in WSK library? (something similar to link status OID from NDIS protocol driver.) OR do I need to convert my WSK application to NDIS protocol driver?
Please help.
Regards,
Subhash
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer