home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 June / PCpro_2006_06.ISO / files / mstools / MSRMesh-VirtualWIFI.MSI / vwifi.c < prev    next >
Encoding:
C/C++ Source or Header  |  2005-06-24  |  33.1 KB  |  1,132 lines

  1. /*
  2.  * Author    : Ranveer Chandra
  3.  * Directory : VirtualWiFi_Root\driver
  4.  * File Name : vwifi.c
  5.  * Purpose   : Ioctl Handlers, Dispatch Routines, Driver Init
  6.  */
  7.  
  8. #include "precomp.h"
  9. #pragma hdrstop
  10.  
  11. #define MODULE_NUMBER           MODULE_MUX
  12.  
  13. #pragma NDIS_INIT_FUNCTION(DriverEntry)
  14.  
  15.  
  16. #if DEBUG
  17. //
  18. // Debug level for mux driver
  19. // 
  20. INT     muxDebugLevel = MUX_LOUD;
  21.  
  22. #endif //DBG
  23. //
  24. //  G L O B A L   V A R I A B L E S
  25. //  -----------   -----------------
  26. //
  27.  
  28. NDIS_MEDIUM        MediumArray[1] =
  29.                     {
  30.                         NdisMedium802_3,    // Ethernet
  31.                     };
  32.  
  33.  
  34. //
  35. // Global Mutex protects the AdapterList;
  36. // see macros MUX_ACQUIRE/RELEASE_MUTEX
  37. //
  38. MUX_MUTEX          GlobalMutex = {0};
  39.  
  40. //
  41. // List of all bound adapters.
  42. //
  43. LIST_ENTRY         AdapterList;
  44.  
  45. //
  46. // Total number of VELAN miniports in existance:
  47. //
  48. LONG               MiniportCount = 0;
  49.  
  50. //
  51. // Used to assign VELAN numbers (which are used to generate MAC
  52. // addresses).
  53. //
  54. ULONG              NextVElanNumber = 0; // monotonically increasing count
  55.  
  56. //
  57. // Some global NDIS handles:
  58. //
  59. NDIS_HANDLE        NdisWrapperHandle = NULL;// From NdisMInitializeWrapper
  60. NDIS_HANDLE        ProtHandle = NULL;       // From NdisRegisterProtocol
  61. NDIS_HANDLE        DriverHandle = NULL;     // From NdisIMRegisterLayeredMiniport
  62. NDIS_HANDLE        NdisDeviceHandle = NULL; // From NdisMRegisterDevice
  63.  
  64. PDEVICE_OBJECT     ControlDeviceObject = NULL;  // Device for IOCTLs
  65. MUX_MUTEX          ControlDeviceMutex;
  66.  
  67.  
  68.  
  69. NTSTATUS
  70. DriverEntry(
  71.     IN    PDRIVER_OBJECT        DriverObject,
  72.     IN    PUNICODE_STRING        RegistryPath
  73.     )
  74. /*++
  75.  
  76. Routine Description:
  77.  
  78.     First entry point to be called, when this driver is loaded.
  79.     Register with NDIS as an intermediate driver.
  80.  
  81. Arguments:
  82.  
  83.     DriverObject - pointer to the system's driver object structure
  84.         for this driver
  85.     
  86.     RegistryPath - system's registry path for this driver
  87.     
  88. Return Value:
  89.  
  90.     STATUS_SUCCESS if all initialization is successful, STATUS_XXX
  91.     error code if not.
  92.  
  93. --*/
  94. {
  95.     NDIS_STATUS                     Status;
  96.     NDIS_PROTOCOL_CHARACTERISTICS   PChars;
  97.     NDIS_MINIPORT_CHARACTERISTICS   MChars;
  98.     PNDIS_CONFIGURATION_PARAMETER   Param;
  99.     NDIS_STRING                     Name;
  100.  
  101.     NdisInitializeListHead(&AdapterList);
  102.     MUX_INIT_MUTEX(&GlobalMutex);
  103.     MUX_INIT_MUTEX(&ControlDeviceMutex);
  104.  
  105.     NdisMInitializeWrapper(&NdisWrapperHandle, DriverObject, RegistryPath, NULL);
  106.  
  107.     do
  108.     {
  109.         //
  110.         // Register the miniport with NDIS. Note that it is the
  111.         // miniport which was started as a driver and not the protocol.
  112.         // Also the miniport must be registered prior to the protocol
  113.         // since the protocol's BindAdapter handler can be initiated
  114.         // anytime and when it is, it must be ready to
  115.         // start driver instances.
  116.         //
  117.         NdisZeroMemory(&MChars, sizeof(NDIS_MINIPORT_CHARACTERISTICS));
  118.  
  119.         MChars.MajorNdisVersion = MUX_MAJOR_NDIS_VERSION;
  120.         MChars.MinorNdisVersion = MUX_MINOR_NDIS_VERSION;
  121.  
  122.         MChars.InitializeHandler = MPInitialize;
  123.         MChars.QueryInformationHandler = MPQueryInformation;
  124.         MChars.SetInformationHandler = MPSetInformation;
  125.         MChars.TransferDataHandler = MPTransferData;
  126.         MChars.HaltHandler = MPHalt;
  127. #ifdef NDIS51_MINIPORT
  128.         MChars.CancelSendPacketsHandler = MPCancelSendPackets;
  129.         MChars.PnPEventNotifyHandler = MPDevicePnPEvent;
  130.         MChars.AdapterShutdownHandler = MPAdapterShutdown;
  131. #endif // NDIS51_MINIPORT
  132.  
  133.         //
  134.         // We will disable the check for hang timeout so we do not
  135.         // need a check for hang handler!
  136.         //
  137.         MChars.CheckForHangHandler = NULL;
  138.         MChars.ReturnPacketHandler = MPReturnPacket;
  139.  
  140.         //
  141.         // Either the Send or the SendPackets handler should be specified.
  142.         // If SendPackets handler is specified, SendHandler is ignored
  143.         //
  144.         MChars.SendHandler = NULL;   
  145.         MChars.SendPacketsHandler = MPSendPackets;
  146.  
  147.         Status = NdisIMRegisterLayeredMiniport(NdisWrapperHandle,
  148.                                                &MChars,
  149.                                                sizeof(MChars),
  150.                                                &DriverHandle);
  151.         if (Status != NDIS_STATUS_SUCCESS)
  152.         {
  153.             break;
  154.         }
  155.  
  156.         NdisMRegisterUnloadHandler(NdisWrapperHandle, MPUnload);
  157.  
  158.         //
  159.         // Now register the protocol.
  160.         //
  161.         NdisZeroMemory(&PChars, sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
  162.         PChars.MajorNdisVersion = MUX_PROT_MAJOR_NDIS_VERSION;
  163.         PChars.MinorNdisVersion = MUX_PROT_MINOR_NDIS_VERSION;
  164.  
  165.         //
  166.         // Make sure the protocol-name matches the service-name
  167.         // (from the INF) under which this protocol is installed.
  168.         // This is needed to ensure that NDIS can correctly determine
  169.         // the binding and call us to bind to miniports below.
  170.         //
  171.         NdisInitUnicodeString(&Name, L"VWIFIP");    // Protocol name
  172.         PChars.Name = Name;
  173.         PChars.OpenAdapterCompleteHandler = PtOpenAdapterComplete;
  174.         PChars.CloseAdapterCompleteHandler = PtCloseAdapterComplete;
  175.         PChars.SendCompleteHandler = PtSendComplete;
  176.         PChars.TransferDataCompleteHandler = PtTransferDataComplete;
  177.         
  178.         PChars.ResetCompleteHandler = PtResetComplete;
  179.         PChars.RequestCompleteHandler = PtRequestComplete;
  180.         PChars.ReceiveHandler = PtReceive;
  181.         PChars.ReceiveCompleteHandler = PtReceiveComplete;
  182.         PChars.StatusHandler = PtStatus;
  183.         PChars.StatusCompleteHandler = PtStatusComplete;
  184.         PChars.BindAdapterHandler = PtBindAdapter;
  185.         PChars.UnbindAdapterHandler = PtUnbindAdapter;
  186.         PChars.UnloadHandler = NULL;
  187.         PChars.ReceivePacketHandler = PtReceivePacket;
  188.         PChars.PnPEventHandler= PtPNPHandler;
  189.  
  190.         NdisRegisterProtocol(&Status,
  191.                              &ProtHandle,
  192.                              &PChars,
  193.                              sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
  194.  
  195.         if (Status != NDIS_STATUS_SUCCESS)
  196.         {
  197.             NdisIMDeregisterLayeredMiniport(DriverHandle);
  198.             break;
  199.         }
  200.  
  201.         //
  202.         // Let NDIS know of the association between our protocol
  203.         // and miniport entities.
  204.         //
  205.         NdisIMAssociateMiniport(DriverHandle, ProtHandle);
  206.     }
  207.     while (FALSE);
  208.  
  209.     if (Status != NDIS_STATUS_SUCCESS)
  210.     {
  211.         NdisTerminateWrapper(NdisWrapperHandle, NULL);
  212.     }
  213.  
  214.     return(Status);
  215. }
  216.  
  217.  
  218. NDIS_STATUS
  219. PtRegisterDevice(
  220.     VOID
  221.     )
  222. /*++
  223.  
  224. Routine Description:
  225.  
  226.     Register an ioctl interface - a device object to be used for this
  227.     purpose is created by NDIS when we call NdisMRegisterDevice.
  228.  
  229.     This routine is called whenever a new miniport instance is
  230.     initialized. However, we only create one global device object,
  231.     when the first miniport instance is initialized. This routine
  232.     handles potential race conditions with PtDeregisterDevice via
  233.     the ControlDeviceMutex.
  234.  
  235.     NOTE: do not call this from DriverEntry; it will prevent the driver
  236.     from being unloaded (e.g. on uninstall).
  237.  
  238. Arguments:
  239.  
  240.     None
  241.  
  242. Return Value:
  243.  
  244.     NDIS_STATUS_SUCCESS if we successfully register a device object.
  245.  
  246. --*/
  247. {
  248.     NDIS_STATUS         Status = NDIS_STATUS_SUCCESS;
  249.     UNICODE_STRING      DeviceName;
  250.     UNICODE_STRING      DeviceLinkUnicodeString;
  251.     PDRIVER_DISPATCH    DispatchTable[IRP_MJ_MAXIMUM_FUNCTION];
  252.     UINT                i;
  253.  
  254.     DBGPRINT(MUX_LOUD, ("==>PtRegisterDevice\n"));
  255.  
  256.     MUX_ACQUIRE_MUTEX(&ControlDeviceMutex);
  257.  
  258.     ++MiniportCount;
  259.     
  260.     if (1 == MiniportCount)
  261.     {
  262.         for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++)
  263.         {
  264.             DispatchTable[i] = PtDispatch;
  265.         }
  266.  
  267.         NdisInitUnicodeString(&DeviceName, NTDEVICE_STRING);
  268.         NdisInitUnicodeString(&DeviceLinkUnicodeString, LINKNAME_STRING);
  269.  
  270.         //
  271.         // Create a device object and register our dispatch handlers
  272.         //
  273.         Status = NdisMRegisterDevice(
  274.                     NdisWrapperHandle, 
  275.                     &DeviceName,
  276.                     &DeviceLinkUnicodeString,
  277.                     &DispatchTable[0],
  278.                     &ControlDeviceObject,
  279.                     &NdisDeviceHandle
  280.                     );
  281.     }
  282.  
  283.     MUX_RELEASE_MUTEX(&ControlDeviceMutex);
  284.  
  285.     DBGPRINT(MUX_INFO, ("<==PtRegisterDevice: %x\n", Status));
  286.  
  287.     return (Status);
  288. }
  289.  
  290.  
  291. NTSTATUS
  292. PtDispatch(
  293.     IN PDEVICE_OBJECT           DeviceObject,
  294.     IN PIRP                     Irp
  295.     )
  296. /*++
  297. Routine Description:
  298.  
  299.     Process IRPs sent to this device.
  300.  
  301. Arguments:
  302.  
  303.     DeviceObject - pointer to a device object
  304.     Irp      - pointer to an I/O Request Packet
  305.  
  306. Return Value:
  307.  
  308.     NTSTATUS - STATUS_SUCCESS always - change this when adding
  309.     real code to handle ioctls.
  310.  
  311. --*/
  312. {
  313.     PIO_STACK_LOCATION  irpStack;
  314.     NTSTATUS            status = STATUS_SUCCESS;
  315.     ULONG               inlen, outlen;
  316.     PVOID               buffer;
  317.     NDIS_STRING         KeyName;
  318.     WCHAR               Device[100];
  319.     UCHAR               saveControlFlags;
  320.     char                tempBuffer[100];
  321.     ULONG               adapterNum = 1;
  322.     PLIST_ENTRY         p;
  323.     PADAPT              pAdapt;
  324.     ULONG               i = 0;
  325.     BOOLEAN             FoundAdapter = FALSE;
  326.     SetVirtualWiFiTimers setVirtualWiFiTimers;
  327.     SetVirtualWiFiTimersForConnection setVirtualWiFiTimersForConnection;
  328.     NetworkModeAndSSID networkModeAndSSID;
  329.  
  330.     irpStack = IoGetCurrentIrpStackLocation(Irp);
  331.     DBGPRINT(MUX_LOUD, ("==>PtDispatch %d\n", irpStack->MajorFunction));
  332.       
  333.     switch (irpStack->MajorFunction)
  334.     {
  335.         case IRP_MJ_CREATE:
  336.             break;
  337.         case IRP_MJ_CLOSE:
  338.             break;        
  339.         case IRP_MJ_DEVICE_CONTROL: {
  340.  
  341.           buffer = Irp->AssociatedIrp.SystemBuffer;  
  342.           inlen = irpStack->Parameters.DeviceIoControl.InputBufferLength;
  343.           outlen = irpStack->Parameters.DeviceIoControl.OutputBufferLength;
  344.           saveControlFlags = irpStack->Control;
  345.  
  346.           //DBGPRINT(MUX_LOUD, ("The ioctl string is %s\n", buffer));
  347.           //DBGPRINT(MUX_LOUD, ("The Buffer length is %d\n", outlen));
  348.  
  349.           switch (irpStack->Parameters.DeviceIoControl.IoControlCode) {
  350.             //
  351.             // Add code here to handle ioctl commands.
  352.             //
  353.             /*
  354.             // set the time the adapter should take for switching to an IS network
  355.             case IOCTL_SET_SWITCHING_TIME_INFRA:
  356.                 memcpy(tempBuffer, buffer, inlen);
  357.                 // set value of switching time from ioctl buffer
  358.                 g_SwitchingTimeInfra = atol(tempBuffer);
  359.                 DBGPRINT(MUX_LOUD, ("The new infrastructure switching time is %d\n", g_SwitchingTimeInfra));
  360.                 Irp->IoStatus.Information = 0;
  361.                 break;
  362.  
  363.             // set the time, the adapter is active on an IS network
  364.             case IOCTL_SET_WAITING_TIME_INFRA:
  365.                 memcpy(tempBuffer, buffer, inlen);
  366.                 // set value of waiting time from ioctl buffer
  367.                 g_WaitingTimeInfra = atol(tempBuffer);
  368.                 DBGPRINT(MUX_LOUD, ("The new infrastructure waiting time is %d\n", g_WaitingTimeInfra));
  369.                 Irp->IoStatus.Information = 0;
  370.                 break;
  371.  
  372.             // set the time the adapter should take for switching to AH network
  373.             case IOCTL_SET_SWITCHING_TIME_ADHOC:
  374.                 memcpy(tempBuffer, buffer, inlen);
  375.                 // set value of switching time from ioctl buffer
  376.                 g_SwitchingTimeAdhoc = atol(tempBuffer);
  377.                 DBGPRINT(MUX_LOUD, ("The new infrastructure switching time is %d\n", g_SwitchingTimeAdhoc));
  378.                 Irp->IoStatus.Information = 0;
  379.                 break;
  380.  
  381.             // set the time, the adapter is active on an AH network
  382.             case IOCTL_SET_WAITING_TIME_ADHOC:
  383.                 memcpy(tempBuffer, buffer, inlen);
  384.                 // set value of waiting time from ioctl buffer
  385.                 g_WaitingTimeAdhoc = atol(tempBuffer);
  386.                 DBGPRINT(MUX_LOUD, ("The new infrastructure waiting time is %d\n", g_WaitingTimeAdhoc));
  387.                 Irp->IoStatus.Information = 0;
  388.                 break;
  389.  
  390.             // get the time the adapter takes for switching a network to AH mode
  391.             case IOCTL_GET_SWITCHING_TIME_ADHOC:
  392.                 sprintf(tempBuffer, "%d\0", g_SwitchingTimeAdhoc);
  393.                 if(outlen < strlen(tempBuffer)) {
  394.                     status = STATUS_BUFFER_TOO_SMALL;
  395.                     break;
  396.                 }
  397.                 // get value of switching time from ioctl buffer
  398.                 RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  399.                 DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  400.                 Irp->IoStatus.Information = strlen(tempBuffer);
  401.                 break;
  402.  
  403.             // get the time the adapter stays on a network in AH mode
  404.             case IOCTL_GET_WAITING_TIME_ADHOC:
  405.                 sprintf(tempBuffer, "%d\0", g_WaitingTimeAdhoc);
  406.                 if(outlen < strlen(tempBuffer)) {
  407.                     status = STATUS_BUFFER_TOO_SMALL;
  408.                     break;
  409.                 }
  410.                 // get value of switching time from ioctl buffer
  411.                 RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  412.                 DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  413.                 Irp->IoStatus.Information = strlen(tempBuffer);
  414.                 break;
  415.  
  416.             // get the time the adapter takes for switching a network to IS mode
  417.             case IOCTL_GET_SWITCHING_TIME_INFRA:
  418.                 sprintf(tempBuffer, "%d\0", g_SwitchingTimeInfra);
  419.                 if(outlen < strlen(tempBuffer)) {
  420.                     status = STATUS_BUFFER_TOO_SMALL;
  421.                     break;
  422.                 }
  423.                 // get value of switching time from ioctl buffer
  424.                 RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  425.                 DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  426.                 Irp->IoStatus.Information = strlen(tempBuffer);
  427.                 break;
  428.  
  429.             // get the time the adapter stays on a network in IS mode
  430.             case IOCTL_GET_WAITING_TIME_INFRA:
  431.                 sprintf(tempBuffer, "%d\0", g_WaitingTimeInfra);
  432.                 if(outlen < strlen(tempBuffer)) {
  433.                     status = STATUS_BUFFER_TOO_SMALL;
  434.                     break;
  435.                 }
  436.                 // get value of switching time from ioctl buffer
  437.                 RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  438.                 DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  439.                 Irp->IoStatus.Information = strlen(tempBuffer);
  440.                 break;
  441.             */
  442.  
  443.             case IOCTL_GET_NUM_NETWORKS:
  444.                 memcpy(tempBuffer, buffer, inlen);
  445.                 //  get adapter from ioctl buffer
  446.                 adapterNum = atol(tempBuffer);
  447.                 i=0;
  448.                 for(p = AdapterList.Flink;
  449.                     p != &AdapterList;
  450.                     p = p->Flink)
  451.                 {
  452.                     i++;
  453.                     if(i<adapterNum) {
  454.                         continue;
  455.                     }
  456.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  457.                     FoundAdapter = TRUE;
  458.                     break;
  459.                 }
  460.                 if(FoundAdapter)
  461.                 {
  462.                     ULONG count;
  463.                     ULONG numActiveNetworks = 0;
  464.  
  465.                     // find number of networks with active connections
  466.                     for (count=0; count < pAdapt->numConnections; count++) {
  467.                         if(pAdapt->NumActiveConnectionsOnSSID[count] > 0)
  468.                             numActiveNetworks++;
  469.                     }
  470.                     sprintf(tempBuffer, "%d\0", numActiveNetworks);
  471.                     if(outlen < strlen(tempBuffer)) {
  472.                         status = STATUS_BUFFER_TOO_SMALL;
  473.                         break;
  474.                     }
  475.                     // copy numnetworks value from tempBuffer
  476.                     RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  477.                     DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  478.                     Irp->IoStatus.Information = strlen(tempBuffer);
  479.                 }
  480.                 break;
  481.                 
  482.             // return the scheduling scheme that should be used by the service
  483.             case IOCTL_GET_SCHEDULING_SCHEME:
  484.                 memcpy(tempBuffer, buffer, inlen);
  485.                 //  get adapter from ioctl buffer
  486.                 adapterNum = atol(tempBuffer);
  487.                 i=0;
  488.                 for(p = AdapterList.Flink;
  489.                     p != &AdapterList;
  490.                     p = p->Flink)
  491.                 {
  492.                     i++;
  493.                     if(i<adapterNum) {
  494.                         continue;
  495.                     }
  496.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  497.                     FoundAdapter = TRUE;
  498.                     break;
  499.                 }
  500.                 if(FoundAdapter)
  501.                 {
  502.                     if(pAdapt->isAdaptiveScheduling)
  503.                         sprintf(tempBuffer, "%d\0", ADAPTIVE_SCHEDULING);
  504.                     else
  505.                         sprintf(tempBuffer, "%d\0", FIXED_SCHEDULING);
  506.  
  507.                     if(outlen < strlen(tempBuffer)) {
  508.                         status = STATUS_BUFFER_TOO_SMALL;
  509.                         break;
  510.                     } 
  511.                     // copy scheduling scheme from tempBuffer
  512.                     RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  513.                     DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  514.                     Irp->IoStatus.Information = strlen(tempBuffer);
  515.                 }
  516.                 break;
  517.                 
  518.             // return the timing parameters to be used by the service
  519.             case IOCTL_GET_SWITCH_TIME:
  520.                 memcpy(tempBuffer, buffer, inlen);
  521.                 //  get adapter from ioctl buffer
  522.                 adapterNum = atol(tempBuffer);
  523.                 i=0;
  524.                 for(p = AdapterList.Flink;
  525.                     p != &AdapterList;
  526.                     p = p->Flink)
  527.                 {
  528.                     i++;
  529.                     if(i<adapterNum) {
  530.                         continue;
  531.                     }
  532.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  533.                     FoundAdapter = TRUE;
  534.                     break;
  535.                 }
  536.                 if(FoundAdapter)
  537.                 {
  538.                     sprintf(tempBuffer, "%d\0", pAdapt->switchingTime[pAdapt->CurrentActiveConnection]);
  539.                     if(outlen < strlen(tempBuffer)) {
  540.                         status = STATUS_BUFFER_TOO_SMALL;
  541.                         break;
  542.                     }
  543.                     // copy numnetworks value from tempBuffer
  544.                     RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  545.                     DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  546.                     Irp->IoStatus.Information = strlen(tempBuffer);
  547.                 }
  548.                 break;
  549.                 
  550.             // return the timing parameters to be used by the service
  551.             case IOCTL_GET_WAIT_TIME:
  552.                 memcpy(tempBuffer, buffer, inlen);
  553.                 //  get adapter from ioctl buffer
  554.                 adapterNum = atol(tempBuffer);
  555.                 i=0;
  556.                 for(p = AdapterList.Flink;
  557.                     p != &AdapterList;
  558.                     p = p->Flink)
  559.                 {
  560.                     i++;
  561.                     if(i<adapterNum) {
  562.                         continue;
  563.                     }
  564.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  565.                     FoundAdapter = TRUE;
  566.                     break;
  567.                 }
  568.                 if(FoundAdapter)
  569.                 {
  570.                     sprintf(tempBuffer, "%d\0", pAdapt->waitingTime[pAdapt->CurrentActiveConnection]);
  571.                     if(outlen < strlen(tempBuffer)) {
  572.                         status = STATUS_BUFFER_TOO_SMALL;
  573.                         break;
  574.                     }
  575.                     // copy numnetworks value from tempBuffer
  576.                     RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  577.                     DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  578.                     Irp->IoStatus.Information = strlen(tempBuffer);
  579.                 }
  580.                 break;
  581.                 
  582.             // set the timing parameters; to be retrieved later by the service
  583.             case IOCTL_SET_SWITCHING_PARAMETERS:
  584.                 memcpy(&setVirtualWiFiTimers, buffer, inlen);
  585.                 //  get adapter from ioctl buffer
  586.                 adapterNum = atol(setVirtualWiFiTimers.adapterNum);
  587.                 i=0;
  588.                 for(p = AdapterList.Flink;
  589.                     p != &AdapterList;
  590.                     p = p->Flink)
  591.                 {
  592.                     i++;
  593.                     if(i<adapterNum) {
  594.                         continue;
  595.                     }
  596.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  597.                     FoundAdapter = TRUE;
  598.                     break;
  599.                 }
  600.                 if(FoundAdapter)
  601.                 {
  602.                     pAdapt->switchingTime[pAdapt->CurrentActiveConnection] = setVirtualWiFiTimers.switchTime;
  603.                     pAdapt->waitingTime[pAdapt->CurrentActiveConnection] = setVirtualWiFiTimers.waitTime;
  604.                     pAdapt->isAdaptiveScheduling = setVirtualWiFiTimers.isAdaptiveScheduling;
  605.  
  606.                     DBGPRINT(MUX_LOUD, ("Got switch time %d, wait time %d\n", 
  607.                         setVirtualWiFiTimers.switchTime, setVirtualWiFiTimers.waitTime));
  608.                     DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  609.                     Irp->IoStatus.Information = 0;
  610.                 }
  611.                 break;
  612.                 
  613.             // set the timing parameters; to be retrieved later by the service
  614.             case IOCTL_SET_SWITCHING_PARAMETERS_FOR_CONNECTION:
  615.                 memcpy(&setVirtualWiFiTimersForConnection, buffer, inlen);
  616.                 DBGPRINT(MUX_LOUD, ("Got switch time %d, wait time %d\n", 
  617.                     setVirtualWiFiTimersForConnection.switchTime, setVirtualWiFiTimersForConnection.waitTime));
  618.                 //  get adapter from ioctl buffer
  619.                 adapterNum = atol(setVirtualWiFiTimersForConnection.adapterNum);
  620.                 i=0;
  621.  
  622.                 for(p = AdapterList.Flink;
  623.                     p != &AdapterList;
  624.                     p = p->Flink)
  625.                 {
  626.                     i++;
  627.                     if(i<adapterNum) {
  628.                         continue;
  629.                     }
  630.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  631.                     FoundAdapter = TRUE;
  632.                     break;
  633.                 }
  634.                 if(FoundAdapter)
  635.                 {
  636.                     ULONG foundConnection = MAX_NETWORK_CONNECTIONS;
  637.                     NDIS_802_11_NETWORK_INFRASTRUCTURE networkMode;
  638.                     ULONG count, count1;
  639.  
  640.                     if(setVirtualWiFiTimersForConnection.networkMode == MODE_IS)
  641.                         networkMode = Ndis802_11Infrastructure;
  642.                     else if (setVirtualWiFiTimersForConnection.networkMode == MODE_AH)
  643.                         networkMode = Ndis802_11IBSS;
  644.                     else
  645.                         networkMode = Ndis802_11AutoUnknown;
  646.  
  647.                     // find whether this SSID existed
  648.                     for (count=0; count < pAdapt->numConnections; count++)
  649.                     {
  650.                         if(foundConnection < MAX_NETWORK_CONNECTIONS) break;
  651.  
  652.                         // if the SSID lengths do not match
  653.                         if (setVirtualWiFiTimersForConnection.ssidLength != pAdapt->networkSSID[count].SsidLength)
  654.                             continue;
  655.  
  656.                         // if modes do not match
  657.                         if (networkMode != pAdapt->networkMode[count])
  658.                             continue;
  659.  
  660.                         // check whether SSIDs match
  661.                         for (count1=0; count1 < setVirtualWiFiTimersForConnection.ssidLength; count1++)
  662.                         {
  663.                             if(setVirtualWiFiTimersForConnection.networkSSID[count1] != pAdapt->networkSSID[count].Ssid[count1])
  664.                                 break;
  665.                             if(count1 == (setVirtualWiFiTimersForConnection.ssidLength -1))
  666.                             {
  667.                                 // found the network with required SSID and mode
  668.                                 foundConnection = count;
  669.                                 break;
  670.                             }
  671.                         }
  672.                     }
  673.  
  674.                     //if(setVirtualWiFiTimersForConnection.connectionNum <= pAdapt->numConnections)
  675.                     if(foundConnection < MAX_NETWORK_CONNECTIONS)
  676.                     {
  677.                         if(setVirtualWiFiTimersForConnection.switchTime > 0)
  678.                             pAdapt->switchingTime[foundConnection] = setVirtualWiFiTimersForConnection.switchTime;
  679.                         if(setVirtualWiFiTimersForConnection.waitTime > 0)
  680.                             pAdapt->waitingTime[foundConnection] = setVirtualWiFiTimersForConnection.waitTime;
  681.                         if(setVirtualWiFiTimersForConnection.isAdaptiveScheduling < 2)
  682.                             pAdapt->isAdaptiveScheduling = setVirtualWiFiTimersForConnection.isAdaptiveScheduling;
  683.  
  684.                         DBGPRINT(MUX_LOUD, ("Got switch time %d, wait time %d\n", 
  685.                             setVirtualWiFiTimersForConnection.switchTime, setVirtualWiFiTimersForConnection.waitTime));
  686.                         DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  687.                     }
  688.                     Irp->IoStatus.Information = 0;
  689.                 }
  690.                 break;
  691.                 
  692.             // set the timing parameters; to be retrieved later by the service
  693.             case IOCTL_SET_CURRENT_SSID:
  694.                 memcpy(&networkModeAndSSID, buffer, inlen);
  695.                 //  get adapter from ioctl buffer
  696.                 adapterNum = atol(networkModeAndSSID.adapterNum);
  697.                 i=0;
  698.                 for(p = AdapterList.Flink;
  699.                     p != &AdapterList;
  700.                     p = p->Flink)
  701.                 {
  702.                     i++;
  703.                     if(i<adapterNum) {
  704.                         continue;
  705.                     }
  706.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  707.                     FoundAdapter = TRUE;
  708.                     break;
  709.                 }
  710.                 if(FoundAdapter)
  711.                 {
  712.                     NDIS_802_11_NETWORK_INFRASTRUCTURE networkMode;
  713.                     NDIS_802_11_SSID networkSSID;
  714.                     LOCK_STATE      LockState;
  715.                     ULONG ssidToSet = pAdapt->numConnections;
  716.  
  717.                     DBGPRINT(MUX_LOUD, ("Got network mode %d, ssid %s, ssid Length %d\n", 
  718.                         networkModeAndSSID.networkMode, networkModeAndSSID.networkSSID, networkModeAndSSID.ssidLength));
  719.                     DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  720.  
  721.                     if(networkModeAndSSID.networkMode == MODE_IS)
  722.                         networkMode = Ndis802_11Infrastructure;
  723.                     else if (networkModeAndSSID.networkMode == MODE_AH)
  724.                         networkMode = Ndis802_11IBSS;
  725.                     else
  726.                         networkMode = Ndis802_11AutoUnknown;
  727.  
  728.                     networkSSID.SsidLength = networkModeAndSSID.ssidLength;
  729.                     for(i=0; i<SSID_LENGTH; i++) 
  730.                     {
  731.                         networkSSID.Ssid[i] = networkModeAndSSID.networkSSID[i];
  732.                     }
  733.  
  734.                     MUX_ACQUIRE_ADAPT_WRITE_LOCK(pAdapt, &LockState);
  735.  
  736.                     DBGPRINT(MUX_LOUD, ("Setting mode and ssid\n", buffer));
  737.  
  738.                     // Set the mode of the adapter
  739.                     PtRequestAdapterAsync(pAdapt,
  740.                         NdisRequestSetInformation,
  741.                         OID_802_11_INFRASTRUCTURE_MODE,
  742.                         &networkMode,
  743.                         sizeof(networkMode),
  744.                         PtDiscardCompletedRequest);
  745.  
  746.                     // Set the SSID of the adapter
  747.                     PtRequestAdapterAsync(pAdapt,
  748.                         NdisRequestSetInformation,
  749.                         OID_802_11_SSID,
  750.                         &networkSSID,
  751.                         sizeof(networkSSID),
  752.                         PtDiscardCompletedRequest);
  753.  
  754.                     for(i=0; i<pAdapt->numConnections; i++) {
  755.                         if(pAdapt->networkSSID[i].SsidLength == 0) {
  756.                             ssidToSet = i;
  757.                         }
  758.                     }
  759.  
  760.                     if(networkModeAndSSID.networkMode == MODE_IS)
  761.                         pAdapt->networkMode[ssidToSet] = Ndis802_11Infrastructure;
  762.                     else if (networkModeAndSSID.networkMode == MODE_AH)
  763.                         pAdapt->networkMode[ssidToSet] = Ndis802_11IBSS;
  764.                     else
  765.                         pAdapt->networkMode[ssidToSet] = Ndis802_11AutoUnknown;
  766.  
  767.                     pAdapt->networkSSID[ssidToSet].SsidLength = networkModeAndSSID.ssidLength;
  768.                     for(i=0; i<SSID_LENGTH; i++) 
  769.                     {
  770.                         pAdapt->networkSSID[ssidToSet].Ssid[i] = networkModeAndSSID.networkSSID[i];
  771.                     }
  772.  
  773.                     MUX_RELEASE_ADAPT_WRITE_LOCK(pAdapt, &LockState);
  774.  
  775.                     Irp->IoStatus.Information = 0;
  776.  
  777.                 }
  778.                 break;
  779.                 
  780.             // get the SSID of the current network
  781.             case IOCTL_GET_CURRENT_SSID:
  782.                 memcpy(tempBuffer, buffer, inlen);
  783.                 //  get adapter from ioctl buffer
  784.                 adapterNum = atol(tempBuffer);
  785.                 i=0;
  786.                 for(p = AdapterList.Flink;
  787.                     p != &AdapterList;
  788.                     p = p->Flink)
  789.                 {
  790.                     i++;
  791.                     if(i<adapterNum) {
  792.                         continue;
  793.                     }
  794.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  795.                     FoundAdapter = TRUE;
  796.                     break;
  797.                 }
  798.                 if(FoundAdapter)
  799.                 {
  800.                     NDIS_802_11_SSID networkSSID;
  801.                     /*
  802.                     for(i=0; i<pAdapt->networkSSID[pAdapt->CurrentActiveConnection].SsidLength; i++) 
  803.                     {
  804.                         tempBuffer[i]=pAdapt->networkSSID[pAdapt->CurrentActiveConnection].Ssid[i];
  805.                     }
  806.                     tempBuffer[i] = '\0';
  807.                     i=0;
  808.                     */
  809.                     // query the SSID
  810.                     PtQueryAdapterSync(pAdapt,
  811.                                     OID_802_11_SSID,
  812.                                     &networkSSID,
  813.                                     sizeof(networkSSID));
  814.  
  815.                     if(networkSSID.SsidLength < outlen) {
  816.                         for(i=0; i<networkSSID.SsidLength; i++) 
  817.                         {
  818.                             tempBuffer[i] = networkSSID.Ssid[i];
  819.                         }
  820.                         tempBuffer[i] = '\0';
  821.                     }
  822.                     else {
  823.                         strcpy(tempBuffer, "NOTSET");
  824.                         tempBuffer[6] = '\0';
  825.                         //break;
  826.                     }
  827.                     i=0;
  828.                 }
  829.                 else {
  830.                     strcpy(tempBuffer, "NOTFOUND");
  831.                     tempBuffer[8] = '\0';
  832.                 }
  833.                 // copy SSID value from tempBuffer
  834.                 RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  835.                 DBGPRINT(MUX_LOUD, ("The ssid buffer is %s\n", buffer));
  836.                 Irp->IoStatus.Information = strlen(tempBuffer);
  837.                 break;
  838.  
  839.             // get the mode of the current network
  840.             case IOCTL_GET_CURRENT_MODE:
  841.                 memcpy(tempBuffer, buffer, inlen);
  842.                 //  get adapter from ioctl buffer
  843.                 adapterNum = atol(tempBuffer);
  844.                 i=0;
  845.                 for(p = AdapterList.Flink;
  846.                     p != &AdapterList;
  847.                     p = p->Flink)
  848.                 {
  849.                     i++;
  850.                     if(i<adapterNum) {
  851.                         continue;
  852.                     }
  853.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  854.                     FoundAdapter = TRUE;
  855.                     break;
  856.                 }
  857.                 if(FoundAdapter)
  858.                 {
  859.                     NDIS_802_11_NETWORK_INFRASTRUCTURE networkMode;
  860.                     ULONG uNetworkMode;
  861.  
  862.                     // query the mode
  863.                     PtQueryAdapterSync(pAdapt,
  864.                                     OID_802_11_INFRASTRUCTURE_MODE,
  865.                                     &networkMode,
  866.                                     sizeof(networkMode));
  867.  
  868.                     if(networkMode == Ndis802_11Infrastructure)
  869.                         uNetworkMode = MODE_IS;
  870.                     else if (networkMode == Ndis802_11IBSS)
  871.                         uNetworkMode = MODE_AH;
  872.                     else
  873.                         uNetworkMode = 3;
  874.  
  875.                     sprintf(tempBuffer, "%d\0", networkMode);
  876.                     if(outlen < strlen(tempBuffer)) {
  877.                         status = STATUS_BUFFER_TOO_SMALL;
  878.                         break;
  879.                     }
  880.                     // copy mode from tempBuffer
  881.                     RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  882.                     DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  883.                     Irp->IoStatus.Information = strlen(tempBuffer);
  884.                 }
  885.                 break;
  886.  
  887.             // get the length of the buffer
  888.             case IOCTL_GET_BUFFER_QUEUE_LENGTH:
  889.                 memcpy(tempBuffer, buffer, inlen);
  890.                 //  get adapter from ioctl buffer
  891.                 adapterNum = atol(tempBuffer);
  892.                 i=0;
  893.                 for(p = AdapterList.Flink;
  894.                     p != &AdapterList;
  895.                     p = p->Flink)
  896.                 {
  897.                     i++;
  898.                     if(i<adapterNum) {
  899.                         continue;
  900.                     }
  901.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  902.                     FoundAdapter = TRUE;
  903.                     break;
  904.                 }
  905.                 if(FoundAdapter)
  906.                 {
  907.                     sprintf(tempBuffer, "%d\0", pAdapt->nTotalPacketsSeen[pAdapt->CurrentActiveConnection]);
  908.                     if(outlen < strlen(tempBuffer)) {
  909.                         status = STATUS_BUFFER_TOO_SMALL;
  910.                         break;
  911.                     }
  912.                     // copy buffer length from tempBuffer
  913.                     RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  914.                     DBGPRINT(MUX_LOUD, ("The buffer is %s\n", buffer));
  915.                     Irp->IoStatus.Information = strlen(tempBuffer);
  916.                 }
  917.                 break;
  918.  
  919.             // get the length of the buffer
  920.             case IOCTL_GET_CARD_SWITCH_TIME:
  921.                 memcpy(tempBuffer, buffer, inlen);
  922.                 //  get adapter from ioctl buffer
  923.                 adapterNum = atol(tempBuffer);
  924.                 i=0;
  925.                 for(p = AdapterList.Flink;
  926.                     p != &AdapterList;
  927.                     p = p->Flink)
  928.                 {
  929.                     i++;
  930.                     if(i<adapterNum) {
  931.                         continue;
  932.                     }
  933.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  934.                     FoundAdapter = TRUE;
  935.                     break;
  936.                 }
  937.                 if(FoundAdapter)
  938.                 {
  939.                     sprintf(tempBuffer, "%I64d\0", pAdapt->cardSwitchTime);
  940.                     if(outlen < strlen(tempBuffer)) {
  941.                         status = STATUS_BUFFER_TOO_SMALL;
  942.                         break;
  943.                     }
  944.                     // copy buffer length from tempBuffer
  945.                     RtlCopyMemory(buffer, tempBuffer, strlen(tempBuffer));
  946.                     DBGPRINT(MUX_LOUD, ("The switch buffer is %s\n", buffer));
  947.                     Irp->IoStatus.Information = strlen(tempBuffer);
  948.                 }
  949.                 break;
  950.  
  951.             // start switching the card
  952.             case IOCTL_START_SWITCHING:
  953.                 memcpy(tempBuffer, buffer, inlen);
  954.                 //  get adapter from ioctl buffer
  955.                 adapterNum = atol(tempBuffer);
  956.                 for(p = AdapterList.Flink;
  957.                     p != &AdapterList;
  958.                     p = p->Flink)
  959.                 {
  960.                     i++;
  961.                     if(i<adapterNum) {
  962.                         continue;
  963.                     }
  964.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  965.                     FoundAdapter = TRUE;
  966.                     break;
  967.                 }
  968.                 if(FoundAdapter)
  969.                     pAdapt->StartSwitching = TRUE;
  970.                 FoundAdapter = FALSE;
  971.                 i = 0;
  972.                 DBGPRINT(MUX_LOUD, ("The card can switch now\n"));
  973.                 Irp->IoStatus.Information = 0;
  974.                 break;
  975.  
  976.             // start switching the card
  977.             case IOCTL_SWITCH_SSID:
  978.                 memcpy(tempBuffer, buffer, inlen);
  979.                 //  get adapter from ioctl buffer
  980.                 adapterNum = atol(tempBuffer);
  981.                 for(p = AdapterList.Flink;
  982.                     p != &AdapterList;
  983.                     p = p->Flink)
  984.                 {
  985.                     i++;
  986.                     if(i<adapterNum) {
  987.                         continue;
  988.                     }
  989.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  990.                     FoundAdapter = TRUE;
  991.                     break;
  992.                 }
  993.                 if(FoundAdapter)
  994.                     PtIoctlSetAdapterSSID(pAdapt);
  995.                 FoundAdapter = FALSE;
  996.                 i = 0;
  997.                 DBGPRINT(MUX_LOUD, ("The card switched SSIDs\n"));
  998.                 Irp->IoStatus.Information = 0;
  999.                 break;
  1000.  
  1001.             // start switching the card
  1002.             case IOCTL_SEND_BUFFERED_PACKETS:
  1003.                 memcpy(tempBuffer, buffer, inlen);
  1004.                 //  get adapter from ioctl buffer
  1005.                 adapterNum = atol(tempBuffer);
  1006.  
  1007.                 // get the corresponding pAdapt data structure
  1008.                 for(p = AdapterList.Flink;
  1009.                     p != &AdapterList;
  1010.                     p = p->Flink)
  1011.                 {
  1012.                     i++;
  1013.                     if(i<adapterNum) {
  1014.                         continue;
  1015.                     }
  1016.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  1017.                     FoundAdapter = TRUE;
  1018.                     break;
  1019.                 }
  1020.                 // Send the packets for the corresponding adapter
  1021.                 if(FoundAdapter)
  1022.                     PtIoctlSendBufferedPackets(pAdapt);
  1023.                 FoundAdapter = FALSE;
  1024.                 i = 0;
  1025.                 DBGPRINT(MUX_LOUD, ("The card sent the buffered packets\n"));
  1026.                 Irp->IoStatus.Information = 0;
  1027.                 break;
  1028.  
  1029.             // start switching the card
  1030.             case IOCTL_START_BUFFERING_PACKETS:
  1031.                 memcpy(tempBuffer, buffer, inlen);
  1032.                 //  get adapter from ioctl buffer
  1033.                 adapterNum = atol(tempBuffer);
  1034.  
  1035.                 // get the corresponding pAdapt data structure
  1036.                 for(p = AdapterList.Flink;
  1037.                     p != &AdapterList;
  1038.                     p = p->Flink)
  1039.                 {
  1040.                     i++;
  1041.                     if(i<adapterNum) {
  1042.                         continue;
  1043.                     }
  1044.                     pAdapt = CONTAINING_RECORD(p, ADAPT, Link);
  1045.                     FoundAdapter = TRUE;
  1046.                     break;
  1047.                 }
  1048.                 // Set the signal to start buffering packets on that SSID
  1049.                 if(FoundAdapter)
  1050.                     PtIoctlStartBufferingPackets(pAdapt);
  1051.                 FoundAdapter = FALSE;
  1052.                 i = 0;
  1053.                 DBGPRINT(MUX_LOUD, ("The card sent the buffered packets\n"));
  1054.                 Irp->IoStatus.Information = 0;
  1055.                 break;
  1056.  
  1057.             default:
  1058.                 Irp->IoStatus.Information = 0;
  1059.                 break;
  1060.           }
  1061.           break;  
  1062.         }
  1063.         default:
  1064.             break;
  1065.     }
  1066.     //Irp->IoStatus.Information = 0;
  1067.     Irp->IoStatus.Status = status;
  1068.     IoCompleteRequest(Irp, IO_NO_INCREMENT);
  1069.  
  1070.     DBGPRINT(MUX_LOUD, ("<== PtDispatch\n"));
  1071.  
  1072.     return status;
  1073.  
  1074.  
  1075.  
  1076. NDIS_STATUS
  1077. PtDeregisterDevice(
  1078.     VOID
  1079.     )
  1080. /*++
  1081.  
  1082. Routine Description:
  1083.  
  1084.     Deregister the ioctl interface. This is called whenever a miniport
  1085.     instance is halted. When the last miniport instance is halted, we
  1086.     request NDIS to delete the device object
  1087.  
  1088. Arguments:
  1089.  
  1090.     NdisDeviceHandle - Handle returned by NdisMRegisterDevice
  1091.  
  1092. Return Value:
  1093.  
  1094.     NDIS_STATUS_SUCCESS if everything worked ok
  1095.  
  1096. --*/
  1097. {
  1098.     NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
  1099.  
  1100.     DBGPRINT(MUX_LOUD, ("==>PassthruDeregisterDevice\n"));
  1101.  
  1102.     MUX_ACQUIRE_MUTEX(&ControlDeviceMutex);
  1103.  
  1104.     ASSERT(MiniportCount > 0);
  1105.  
  1106.     --MiniportCount;
  1107.     
  1108.     if (0 == MiniportCount)
  1109.     {
  1110.         //
  1111.         // All VELAN miniport instances have been halted.
  1112.         // Deregister the control device.
  1113.         //
  1114.  
  1115.         if (NdisDeviceHandle != NULL)
  1116.         {
  1117.             Status = NdisMDeregisterDevice(NdisDeviceHandle);
  1118.             NdisDeviceHandle = NULL;
  1119.         }
  1120.     }
  1121.  
  1122.     MUX_RELEASE_MUTEX(&ControlDeviceMutex);
  1123.  
  1124.     DBGPRINT(MUX_INFO, ("<== PassthruDeregisterDevice: %x\n", Status));
  1125.     return Status;
  1126.     
  1127. }
  1128.  
  1129.  
  1130.  
  1131.