Hi,

For a netwrok card (ie. ethernet), how does windows know
if the network cable is unplugged? Does the driver handle
any polling routine?

The reason I am asking is because I am trying to a virtual
network driver which drives the traffic to an
application. I need to find some way to determine if that
application is running.

Thanks,
Billy.

Re: How to detect Network Cable Unplugged? by Calvin

Calvin
Mon Oct 20 17:11:57 CDT 2003

NDIS sends OID_GEN_MEDIA_CONNECT_STATUS to query the link status of a
miniport. Miniport driver returns
NdisMediaStateConnected or NdisMediaStateDisconnected in reponse to such an
OID query.

Also, Miniport calls NdisMIndicateStatus with NDIS_STATUS_MEDIA_CONNECT or
NDIS_STATUS_MEDIA_DISCONNECT to indicate a detected link status change.

HTH
Calvin
--
Calvin Guan, Software Developer cguan@nospam.ati.com
SW2D-Radeon NT Core Drivers
ATI Technologies Inc.
1 Commerce Valley Drive East
Markham, Ontario, Canada L3T 7X6
Tel: (905) 882-2600 Ext. 8654
Find a driver: http://www.ati.com/support/driver.html

"Billy Ng" <ngbh@nswc.navy.mil> wrote in message
news:03bb01c39752$aa0b0ff0$a401280a@phx.gbl...
> Hi,
>
> For a netwrok card (ie. ethernet), how does windows know
> if the network cable is unplugged? Does the driver handle
> any polling routine?
>
> The reason I am asking is because I am trying to a virtual
> network driver which drives the traffic to an
> application. I need to find some way to determine if that
> application is running.
>
> Thanks,
> Billy.



Re: How to detect Network Cable Unplugged? by Pavel

Pavel
Mon Oct 20 18:40:47 CDT 2003

"Billy Ng" <ngbh@nswc.navy.mil> wrote in message news:03bb01c39752$aa0b0ff0$a401280a@phx.gbl...
> The reason I am asking is because I am trying to a virtual
> network driver which drives the traffic to an
> application. I need to find some way to determine if that
> application is running.

Drivers can receive notification on loading apps, so you can check for your app.
OTOH, if yor app knows about your driver, it can send it some special message (custom OID).

-- PA



Re: How to detect Network Cable Unplugged? by Arkady

Arkady
Tue Oct 21 16:26:13 CDT 2003

Additional way is to use wmi for that
Arkady

"Billy Ng" <ngbh@nswc.navy.mil> wrote in message
news:03bb01c39752$aa0b0ff0$a401280a@phx.gbl...
> Hi,
>
> For a netwrok card (ie. ethernet), how does windows know
> if the network cable is unplugged? Does the driver handle
> any polling routine?
>
> The reason I am asking is because I am trying to a virtual
> network driver which drives the traffic to an
> application. I need to find some way to determine if that
> application is running.
>
> Thanks,
> Billy.



Re: How to detect Network Cable Unplugged? by Billy

Billy
Wed Oct 22 15:30:47 CDT 2003

Thanks, Calvin. What is the difference between these two
ways of checking network status (I mean
OID_GEN_MEDIA_CONNECT_STATUS vs. NdisMIndicateStatus)?
By the way, I tried to call NdisMIndicateStatus in
MPCheckForHang routine of NDIS Virtual Minidriver (sample
from DDK). The driver crashed. Any experience before?

>-----Original Message-----
>NDIS sends OID_GEN_MEDIA_CONNECT_STATUS to query the link
status of a
>miniport. Miniport driver returns
>NdisMediaStateConnected or NdisMediaStateDisconnected in
reponse to such an
>OID query.
>
>Also, Miniport calls NdisMIndicateStatus with
NDIS_STATUS_MEDIA_CONNECT or
>NDIS_STATUS_MEDIA_DISCONNECT to indicate a detected link
status change.
>
>HTH
>Calvin
>--
>Calvin Guan, Software Developer cguan@nospam.ati.com
>SW2D-Radeon NT Core Drivers
>ATI Technologies Inc.
>1 Commerce Valley Drive East
>Markham, Ontario, Canada L3T 7X6
>Tel: (905) 882-2600 Ext. 8654
>Find a driver: http://www.ati.com/support/driver.html
>
>"Billy Ng" <ngbh@nswc.navy.mil> wrote in message
>news:03bb01c39752$aa0b0ff0$a401280a@phx.gbl...
>> Hi,
>>
>> For a netwrok card (ie. ethernet), how does windows know
>> if the network cable is unplugged? Does the driver
handle
>> any polling routine?
>>
>> The reason I am asking is because I am trying to a
virtual
>> network driver which drives the traffic to an
>> application. I need to find some way to determine if
that
>> application is running.
>>
>> Thanks,
>> Billy.
>
>
>.
>

Re: How to detect Network Cable Unplugged? by Calvin

Calvin
Wed Oct 22 16:38:32 CDT 2003

> Thanks, Calvin. What is the difference between these two
> ways of checking network status (I mean
> OID_GEN_MEDIA_CONNECT_STATUS vs. NdisMIndicateStatus)?

From protocol's perspective, sort of like interrupt vs. polling.

NdisMIndicateStatus notifies NDIS actively. It will in turn call
ProtocolStatus routine for all bound protocols and write to some system
defined WMI events.

OID_GEN_MEDIA_CONNECT_STATUS doesn't notify NDIS. Instead, NDIS/OS polls
the driver for link state.

> By the way, I tried to call NdisMIndicateStatus in
> MPCheckForHang routine of NDIS Virtual Minidriver (sample
> from DDK). The driver crashed. Any experience before?

I didn't call NdisMIndicateStatus from my MPCheckForHang routine. It would
be hard to say why's crashing without further info. What does !analyze -v
say?

--
Calvin Guan, Software Developer cguan@nospam.ati.com
SW2D-Radeon NT Core Drivers
ATI Technologies Inc.
1 Commerce Valley Drive East
Markham, Ontario, Canada L3T 7X6
Tel: (905) 882-2600 Ext. 8654
Find a driver: http://www.ati.com/support/driver.html




Re: How to detect Network Cable Unplugged? by Billy

Billy
Tue Oct 28 09:00:32 CST 2003

>
>> By the way, I tried to call NdisMIndicateStatus in
>> MPCheckForHang routine of NDIS Virtual Minidriver
(sample
>> from DDK). The driver crashed. Any experience before?
>
>I didn't call NdisMIndicateStatus from my MPCheckForHang
routine. It would
>be hard to say why's crashing without further info. What
does !analyze -v
>say?
>
It turns out that the driver crahes when I use
NdisMIndicateStatus as NdisMIndicateStatus(Adapter-
>AdapterHandle, NDIS_STATUS_MEDIA_DISCONNECT, (PVOID)0,
0). It does not crash if I put NdisMIndicateStatus
(Adapter->AdapterHandle,
NDIS_STATUS_MEDIA_DISCONNECT, 'x', sizeof('x')) instead.
Even if the driver does not crash, Windows does not
show "Network status" as connected.

Is there anyway I can poll and
call "OID_GEN_MEDIA_CONNECT_STATUS" periodically?

Re: How to detect Network Cable Unplugged? by Eliyas

Eliyas
Tue Oct 28 10:46:07 CST 2003

> The reason I am asking is because I am trying to a virtual
> network driver which drives the traffic to an
> application. I need to find some way to determine if that
> application is running.
>

What do you mean by "which drives the traffic to an application". Are you
redirecting network packets that you receive in your driver to an
application? How do you do that?


--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx



Re: How to detect Network Cable Unplugged? by Billy

Billy
Tue Oct 28 10:58:45 CST 2003


>-----Original Message-----
>> The reason I am asking is because I am trying to a
virtual
>> network driver which drives the traffic to an
>> application. I need to find some way to determine if
that
>> application is running.
>>
>
>What do you mean by "which drives the traffic to an
application". Are you
>redirecting network packets that you receive in your
driver to an
>application? How do you do that?
>
I am planning to use a DLL for memory sharing. The DLL
would have routines for allocating memory, setting and
getting data.

Re: How to detect Network Cable Unplugged? by Eliyas

Eliyas
Tue Oct 28 13:11:57 CST 2003

That doesn't answer my question. How does the DLL (which is loaded by an
application) talk to the virtual network driver? Does you driver call
NdisMRegisterDevice to create a named deviceobject.



--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx



Re: How to detect Network Cable Unplugged? by Billy

Billy
Wed Oct 29 10:41:42 CST 2003

>-----Original Message-----
>That doesn't answer my question. How does the DLL (which
is loaded by an
>application) talk to the virtual network driver? Does you
driver call
>NdisMRegisterDevice to create a named deviceobject.
>
I am currently using the DDK sample (netvmini) to start
the development. In the sample, I do see that
NdisMRegisterDevice is used at initialization.

Also, I am new in Windows Software developement (I used to
write C++ programs in Unix); therefore, I don't know a lot
about DLL. From my reading, Dll should have a set of
routines which communicate with the driver and allocate
memory. The driver should use those routines for sending
or receiving packets. Meanwhile, the Dll should have
another set for the other application (the one which the
driver wants to share information with).
Is there anything I should worry ahead?

Billy.

Re: How to detect Network Cable Unplugged? by Eliyas

Eliyas
Wed Oct 29 12:13:52 CST 2003

Okay, let us get back to your original question.

> I need to find some way to determine if that application is running.


An application (which includes your DLL) can talk to you by opening the
device registered using NdisMRegisterDevice. When they do, you will get
IRP_MJ_CREATE request and when it closes the handle, you will get
IRP_MJ_CLOSE request. By tracking the number of create and close requests,
you can find out whether your application is running or not.

Now it's time for your to pick up Walter Oney's and OSR's driver development
book and do some serious reading. Since you are new to Windows, you should
also read Programming application for Windows by Jeffrey Richter.

--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx



Re: How to detect Network Cable Unplugged? by Billy

Billy
Mon Nov 03 10:23:25 CST 2003

>An application (which includes your DLL) can talk to you
by opening the
>device registered using NdisMRegisterDevice. When they
do, you will get
>IRP_MJ_CREATE request and when it closes the handle, you
will get
>IRP_MJ_CLOSE request. By tracking the number of create
and close requests,
>you can find out whether your application is running or
not.
>
If I use NdisMRegisterDevice in the DLL, I need to use
DDK to compile this DDL files. Am I correct?

>Now it's time for your to pick up Walter Oney's and OSR's
driver development
>book and do some serious reading. Since you are new to
Windows, you should
>also read Programming application for Windows by Jeffrey
Richter.
>
I ordered both book. Walter Oney seems pretty good on the
driver programming in general. I am waiting the other book
for learning about DLL.

Thanks,
Billy.