<< | Thread Index | >> ]    [ << | Date Index | >> ]

Subject: "Media status" support for Win32 Cipe
From: Christof Meerwald <cmeerw,AT,web,DOT,de>
Date: Mon, 4 Nov 2002 22:46:38 +0100

Hi,

I have written a small patch for the Win32 CIPE driver to add support for
media connection status: the CIPE driver only returns MediaStateConnected
when the CIPE service is also running.

This way I can have the CIPE adapter always enabled, but as its media state
is "disconnected" when the CIPE service is not running, Windows will not set
up any network routes until the CIPE service is also running. So I can
establish a VPN connection by just starting the CIPE service and
disconnecting by stopping the CIPE service.

I have attached the patch as it is really small...

bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw,AT,jabber,DOT,at
mailto cmeerw at web.de


diff -ur cipe-win32.orig\source\cipdrvr\cipdrvr.c 
cipe-win32\source\cipdrvr\cipdrvr.c

--- cipe-win32.orig\source\cipdrvr\cipdrvr.c    Sat Oct 19 00:09:40 2002

+++ cipe-win32\source\cipdrvr\cipdrvr.c Mon Nov 04 19:16:46 2002

@@ -237,7 +237,7 @@

 
//===========================================================================================

 NDIS_STATUS CreateTapDevice (CipeAdapterPointer p_Adapter)

    {

-    unsigned short l_AdapterLength = strlen (p_Adapter->m_Name);

+    unsigned short l_AdapterLength = (unsigned short) strlen 
+(p_Adapter->m_Name);

     ANSI_STRING l_TapString, l_LinkString;

     CipeTapExtensionPointer l_Extension;

     UNICODE_STRING l_TapUnicode;

@@ -537,7 +537,8 @@

         //                            Device Info

         
//===========================================================================

         case OID_GEN_MEDIA_CONNECT_STATUS:

-           l_Query.m_Long = NdisMediaStateConnected;

+           l_Query.m_Long =

+            (l_Adapter->m_TapOpens > 0) ? NdisMediaStateConnected : 
+NdisMediaStateDisconnected;

            break;

 

         case OID_GEN_HARDWARE_STATUS:

@@ -976,6 +977,12 @@

                {

                 DbgPrint ("[%s] [CIPE] release [%d.%d] open request\n", 
l_Adapter->m_Name, CIPE_DRIVER_MAJOR_VERSION, CIPE_DRIVER_MINOR_VERSION);

                 ++l_Adapter->m_TapOpens;

+               if (l_Adapter->m_TapOpens == 1)

+               {

+                 NdisMIndicateStatus(l_Adapter->m_MiniportAdapterHandle,

+                                     NDIS_STATUS_MEDIA_CONNECT, NULL, 0);

+                 
+NdisMIndicateStatusComplete(l_Adapter->m_MiniportAdapterHandle);

+               }

                }

             else

                {

@@ -996,7 +1003,16 @@

             DbgPrint ("[%s] [CIPE] release [%d.%d] close request\n", 
l_Adapter->m_Name, CIPE_DRIVER_MAJOR_VERSION, CIPE_DRIVER_MINOR_VERSION);

             while (QueueCount (&l_Extension->m_PacketQueue)) QueuePop 
(&l_Extension->m_PacketQueue); // Exhaust packet queue

             // If we were going to CancelIrp() all the IRPs in queue, we 
would do it here :-)

-            if (l_Adapter->m_TapOpens) --l_Adapter->m_TapOpens;

+            if (l_Adapter->m_TapOpens)

+           {

+             --l_Adapter->m_TapOpens;

+             if (l_Adapter->m_TapOpens == 0)

+             {

+               NdisMIndicateStatus(l_Adapter->m_MiniportAdapterHandle,

+                                   NDIS_STATUS_MEDIA_DISCONNECT, NULL, 0);

+               
+NdisMIndicateStatusComplete(l_Adapter->m_MiniportAdapterHandle);

+             }

+           }

             IoCompleteRequest (p_IRP, IO_NO_INCREMENT); 

             break;

            }




<< | Thread Index | >> ]    [ << | Date Index | >> ]