/*++

******************************************************************************
* Copyright (c) 1990-96 Digi International Inc., All Rights Reserved         *
*                                                                            *
* This software contains proprietary and confidential information of Digi    *
* International Inc.  By accepting transfer of this copy, Recipient agrees   *
* to retain this software in confidence, to prevent disclosure to others,    *
* and to make no use of this software other than that for which it was       *
* delivered.  This is an unpublished copyrighted work of Digi International  *
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly  *
* prohibited.                                                                *
*                                                                            *
* Restricted Rights Legend                                                   *
*                                                                            *
* Use, duplication, or disclosure by the Government is subject to            *
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in        *
* Technical Data and Computer Software clause at DFARS 252.227-7031 or       *
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -         *
* Restricted Rights at 48 CFR 52.227-19, as applicable.                      *
*                                                                            *
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343         *
*                                                                            *
******************************************************************************

Module Name:

   wan.c

Abstract:

   This file contains routines which handle Wan requests from MinportSetInfo 
   and MiniportQueryInfo.

Author:

   Michael Zarns

Revision History:

   $History: wan.c $
 * 
 * *****************  Version 7  *****************
 * User: Mikez        Date: 4/28/97    Time: 1:55p
 * Updated in $/Components/Windows/NT/Sync/Wan
 * Updated to use DsApi library.  Uses IoBuildDeviceIoControlRequest to
 * alloc Irps causing two problems.  Because ioctls are METHOD_BUFFERED, a
 * systemBuffer is alloc'd, but, because the completionroutines return
 * STATUS_MORE_PROCESSING_REQUIRED, never gets freed.  Also, SystemBuffer
 * is not copied to OutputBuffer until after completionRoutine returns
 * STATUS_SUCCESS.  Need to move from METHOD_BUFFER or from using
 * IoBuildDeviceIoControlRequest.
 * 
 * *****************  Version 6  *****************
 * User: Mikez        Date: 3/03/97    Time: 9:23a
 * Updated in $/Components/Windows/NT/Sync/Wan
 * Updated to use async completions on MakeCall, Drop and Answer TAPI OID
 * requests.
 * 
 * *****************  Version 5  *****************
 * User: Mikez        Date: 1/28/97    Time: 10:28a
 * Updated in $/Components/Windows/NT/Sync/Wan
 * Removed broken downlevel ras support.
 * 
 * *****************  Version 4  *****************
 * User: Mikez        Date: 12/09/96   Time: 4:20p
 * Updated in $/Components/Windows/NT/Sync/Wan
 * Cleaned up call states.  No longer use bitmasks, check for unique
 * numeric values.
 * 
 * *****************  Version 3  *****************
 * User: Mikez        Date: 12/06/96   Time: 2:28p
 * Updated in $/Components/Windows/NT/Sync/Wan
 * Modified to support new SXB paridigm of "one NT device per adapter"
 * rather than the older "one NT device per port".
 * 
 * *****************  Version 2  *****************
 * User: Mikez        Date: 10/28/96   Time: 1:25p
 * Updated in $/Components/Windows/NT/Sync/Wan
 * Updated to support latest firmware release, v1.1.2b.

--*/
#include <ntddk.h>
#include <ndis.h>
#include <ndiswan.h>
#include <ndistapi.h>

#include "DsApi.h"
#include "digix25.h"
#include "digix25p.h"
#include "compress.h"
#include "digifile.h"


NDIS_STATUS OidWanPermanentAddress( IN NDIS_HANDLE MiniportAdapterContext,
                                    IN PVOID InformationBuffer,
                                    IN ULONG InformationBufferLength,
                                    OUT PULONG BytesWritten,
                                    OUT PULONG BytesNeeded,
                                    IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:


Return Value:

   None.

--*/
{
   PDIGIWAN_ADAPTER_OBJECT AdapterObject=(PVOID)MiniportAdapterContext;

   DigiDump( DIGIFLOW, ("OidWanPermanentAddress:\n") );

   ASSERT( AdapterObject->Type == DIGIWAN_TYPE_ADAPTER_OBJECT );

   if( InformationBufferLength < 6 )
   {
      *BytesNeeded = 6;
      return( NDIS_STATUS_INVALID_LENGTH );
   }

   NdisMoveMemory( InformationBuffer, (PVOID)(AdapterObject->StationAddress), 6 );

   *BytesNeeded = 0;
   *BytesWritten = 6;

   return( NDIS_STATUS_SUCCESS );
}  // end OidWanPermanentAddress



NDIS_STATUS OidWanCurrentAddress( IN NDIS_HANDLE MiniportAdapterContext,
                                  IN PVOID InformationBuffer,
                                  IN ULONG InformationBufferLength,
                                  OUT PULONG BytesWritten,
                                  OUT PULONG BytesNeeded,
                                  IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:


Return Value:

   None.

--*/
{
   PDIGIWAN_ADAPTER_OBJECT AdapterObject = (PDIGIWAN_ADAPTER_OBJECT)MiniportAdapterContext;

   DigiDump( DIGIFLOW, ("OidWanCurrentAddress:\n") );

   ASSERT( AdapterObject->Type == DIGIWAN_TYPE_ADAPTER_OBJECT );

   if( InformationBufferLength < 6 )
   {
      *BytesNeeded = 6;
      return( NDIS_STATUS_INVALID_LENGTH );
   }

   NdisMoveMemory( InformationBuffer,
                   (PVOID)(AdapterObject->StationAddress),
                   6 );

   *BytesNeeded = 0;
   *BytesWritten = 6;

   return( NDIS_STATUS_SUCCESS );

}  // end OidWanCurrentAddress



NDIS_STATUS OidWanQualityOfService( IN NDIS_HANDLE MiniportAdapterContext,
                                    IN PVOID InformationBuffer,
                                    IN ULONG InformationBufferLength,
                                    OUT PULONG BytesWritten,
                                    OUT PULONG BytesNeeded,
                                    IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:


Return Value:

   None.

--*/
{
   NDIS_WAN_QUALITY WanQuality = NdisWanReliable;

   DigiDump( DIGIFLOW, ("OidWanQualityOfService:\n") );

   ASSERT( ((PDIGIWAN_ADAPTER_OBJECT)MiniportAdapterContext)->Type == DIGIWAN_TYPE_ADAPTER_OBJECT );

   if( InformationBufferLength != sizeof(NDIS_WAN_QUALITY) )
   {
      *BytesNeeded = sizeof(NDIS_WAN_QUALITY);
      return( NDIS_STATUS_INVALID_LENGTH );
   }

   NdisMoveMemory( InformationBuffer,
                   (PVOID)&WanQuality,
                   sizeof(NDIS_WAN_QUALITY) );

   (*BytesNeeded) = 0;
   (*BytesWritten) = sizeof(NDIS_WAN_QUALITY);

   return( NDIS_STATUS_SUCCESS );

}  // end OidWanQualityOfService



NDIS_STATUS OidWanProtocolType( IN NDIS_HANDLE MiniportAdapterContext,
                                IN PVOID InformationBuffer,
                                IN ULONG InformationBufferLength,
                                OUT PULONG BytesWritten,
                                OUT PULONG BytesNeeded,
                                IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:


Return Value:

   None.

--*/
{

   DigiDump( DIGIFLOW, ("OidWanProtocolType:\n") );

   ASSERT( ((PDIGIWAN_ADAPTER_OBJECT)MiniportAdapterContext)->Type == DIGIWAN_TYPE_ADAPTER_OBJECT );

   return( NDIS_STATUS_SUCCESS );

}  // end OidWanProtocolType



NDIS_STATUS OidWanMediumSubType( IN NDIS_HANDLE MiniportAdapterContext,
                                 IN PVOID InformationBuffer,
                                 IN ULONG InformationBufferLength,
                                 OUT PULONG BytesWritten,
                                 OUT PULONG BytesNeeded,
                                 IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:


Return Value:

   None.

--*/
{
   NDIS_WAN_MEDIUM_SUBTYPE Medium = NdisWanMediumX_25;

   DigiDump( DIGIFLOW, ("OidWanMediumSubType:\n") );

   ASSERT( ((PDIGIWAN_ADAPTER_OBJECT)MiniportAdapterContext)->Type == DIGIWAN_TYPE_ADAPTER_OBJECT );

   if( InformationBufferLength != sizeof(NDIS_WAN_MEDIUM_SUBTYPE) )
   {
      *BytesNeeded = sizeof(NDIS_WAN_MEDIUM_SUBTYPE);
      return( NDIS_STATUS_INVALID_LENGTH );
   }

   NdisMoveMemory( InformationBuffer, (PVOID)&Medium, sizeof(NDIS_WAN_MEDIUM_SUBTYPE) );

   (*BytesNeeded) = 0;
   (*BytesWritten) = sizeof(NDIS_WAN_MEDIUM_SUBTYPE);

   return( NDIS_STATUS_SUCCESS );

}  // end OidWanMediumSubType



NDIS_STATUS OidWanHeaderFormat( IN NDIS_HANDLE MiniportAdapterContext,
                                IN PVOID InformationBuffer,
                                IN ULONG InformationBufferLength,
                                OUT PULONG BytesWritten,
                                OUT PULONG BytesNeeded,
                                IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:


Return Value:

   None.

--*/
{
   NDIS_WAN_HEADER_FORMAT HeaderFormat = NdisWanHeaderNative;

   DigiDump( DIGIFLOW, ("OidWanHeaderFormat:\n") );

   if( InformationBufferLength != sizeof(NDIS_WAN_HEADER_FORMAT) )
   {
      *BytesNeeded = sizeof(NDIS_WAN_HEADER_FORMAT);
      return( NDIS_STATUS_INVALID_LENGTH );
   }

   NdisMoveMemory( InformationBuffer,
                   (PVOID)&HeaderFormat,
                   sizeof(NDIS_WAN_HEADER_FORMAT) );

   *BytesNeeded = 0;
   *BytesWritten = sizeof(NDIS_WAN_HEADER_FORMAT);

   return( NDIS_STATUS_SUCCESS );

}  // end OidWanHeaderFormat



NDIS_STATUS OidWanGetInfo( IN NDIS_HANDLE MiniportAdapterContext,
                           IN PVOID InformationBuffer,
                           IN ULONG InformationBufferLength,
                           OUT PULONG BytesWritten,
                           OUT PULONG BytesNeeded,
                           IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:


Return Value:

   None.

--*/
{

   NDIS_PHYSICAL_ADDRESS HighestAcceptableMax = NDIS_PHYSICAL_ADDRESS_CONST(-1,-1);

   DigiDump( DIGIFLOW, ("OidWanGetInfo, NDIS_WAN_INFO struct:\n") );

   if( QueryInfo )
   {
      PDIGIWAN_ADAPTER_OBJECT AdapterObject;
      PNDIS_WAN_INFO Info = (PNDIS_WAN_INFO)InformationBuffer;

      AdapterObject = (PDIGIWAN_ADAPTER_OBJECT)MiniportAdapterContext;

      if( InformationBufferLength != sizeof(NDIS_WAN_INFO) )
      {
         *BytesWritten = 0;
         *BytesNeeded = sizeof(NDIS_WAN_INFO);
         return( NDIS_STATUS_INVALID_LENGTH );
      }

      Info->MaxFrameSize = MAX_FRAME_SIZE;
      Info->MaxTransmit = AdapterObject->MaxSendWindow;
      Info->HeaderPadding = AdapterObject->HeaderPadding;
      Info->TailPadding = AdapterObject->TailPadding;
      Info->Endpoints = AdapterObject->NumberOfEndpoints;
      Info->MemoryFlags = 0;
      Info->HighestAcceptableAddress = HighestAcceptableMax;
      Info->FramingBits = ( PPP_FRAMING |
                            PPP_COMPRESS_PROTOCOL_FIELD |
                            TAPI_PROVIDER |
                            RFC_1356_FRAMING );
      Info->DesiredACCM = 0xFFFFFFFF;

      (*BytesNeeded) = 0;
      (*BytesWritten) = sizeof(NDIS_WAN_INFO);
		DigiDump( DIGIFLOW, ("   MaxFrameSize = 0x%x\n",Info->MaxFrameSize) );
		DigiDump( DIGIFLOW, ("   MaxTransmit = 0x%x\n",Info->MaxTransmit) );
		DigiDump( DIGIFLOW, ("   HeaderPadding = 0x%x\n",Info->HeaderPadding) );
		DigiDump( DIGIFLOW, ("   TailPadding = 0x%x\n",Info->TailPadding) );
		DigiDump( DIGIFLOW, ("   Endpoints = 0x%x\n",Info->Endpoints) );
		DigiDump( DIGIFLOW, ("   MemoryFlags = 0x%x\n",Info->MemoryFlags) );
		DigiDump( DIGIFLOW, ("   HighestAcceptableAddress = 0x%x\n",Info->HighestAcceptableAddress) );
		DigiDump( DIGIFLOW, ("   FramingBits = 0x%x\n",Info->FramingBits) );
		DigiDump( DIGIFLOW, ("   DesiredACCM = 0x%x\n",Info->DesiredACCM) );
   }
   else
   {
      ASSERT( FALSE );
      return( NDIS_STATUS_INVALID_OID );
   }

   return( NDIS_STATUS_SUCCESS );
}  // end OidWanGetInfo



NDIS_STATUS OidWanSetLinkInfo( IN NDIS_HANDLE MiniportAdapterContext,
                               IN PVOID InformationBuffer,
                               IN ULONG InformationBufferLength,
                               OUT PULONG BytesWritten,
                               OUT PULONG BytesNeeded,
                               IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:

   QueryInfo - Indicates SET or GET.
               If TRUE, OID_WAN_GET_LINK_INFO.
               If FALSE, OID_WAN_SET_LINK_INFO.

Return Value:

   None.

--*/
{
   PNDIS_WAN_SET_LINK_INFO SetInfo;
   PDIGIWAN_CALL_OBJECT CallObject;

   //
   // We are being given new information
   //
   // NOTE: We don't really set anything here, we are
   //       being the information for informational
   //       purposes only.
   //

   *BytesNeeded = sizeof(NDIS_WAN_SET_LINK_INFO);

   if( InformationBufferLength != sizeof(NDIS_WAN_SET_LINK_INFO ) )
   {
      DigiDump( DIGIFLOW, ("OidWanSetLinkInfo rc = NDIS_STATUS_INVALID_LENGTH\n") );
      return( NDIS_STATUS_INVALID_LENGTH );
   }

   SetInfo = (PNDIS_WAN_SET_LINK_INFO)InformationBuffer;

   CallObject = (PDIGIWAN_CALL_OBJECT)SetInfo->NdisLinkHandle;
	if( CallObject == NULL )
	{
		DigiDump( DIGIERRORS, ("Error: OidWanSetLinkInfo CallObject = 0\n") );
		return( NDIS_STATUS_INVALID_DATA );
	}
   ASSERT( CallObject->Type == DIGIWAN_TYPE_CALL_OBJECT );

   DigiDump( (DIGIFLOW|DIGIINFO), ("OidWanSetLinkInfo: CallObject = 0x%x\n",
                                   CallObject) );

	DigiDump( DIGIDIAG3, ("   NdisLinkHandle 0x%x\n"
	                      "   MaxSendFrameSize 0x%x, MaxRecvFrameSize 0x%x\n"
	                      "   HeaderPadding 0x%x, TailPadding 0x%x\n"
	                      "   SendFramingBits 0x%x, RecvFramingBits 0x%x\n"
	                      "   SendCompressionBits 0x%x, RecvCompressionBits 0x%x\n"
	                      "   SendACCM 0x%x, RecvACCM 0x%x\n",
								 SetInfo->NdisLinkHandle,
								 SetInfo->MaxSendFrameSize,
								 SetInfo->MaxRecvFrameSize,
								 SetInfo->HeaderPadding,
								 SetInfo->TailPadding,
								 SetInfo->SendFramingBits,
								 SetInfo->RecvFramingBits,
								 SetInfo->SendCompressionBits,
								 SetInfo->RecvCompressionBits,
								 SetInfo->SendACCM,
								 SetInfo->RecvACCM ) );

   //
   // Test for a valid link.  This really seems stupid, because the
   // LinkHandle should be something which was given to the Wan
   // Wrapper on a LINE_UP indication.
   //

   if( CallObject->InternalCallState != INTERNAL_CALL_STATE_CONNECTED )
   {
      DigiDump( DIGIFLOW, ("OidWanSetLinkInfo rc = NDIS_STATUS_INVALID_DATA\n") );
      return( NDIS_STATUS_INVALID_DATA );
   }

   CallObject->MaxSendFrameSize =    SetInfo->MaxSendFrameSize;
   CallObject->MaxRecvFrameSize =    SetInfo->MaxRecvFrameSize;

// Don't accept these!  Wan init's these to 0, we need them to be 
// AdapterObject->HeaderPadding and TailPadding instead!  We'll set them in the 
// WanGetLinkInfo call.
//   CallObject->PreamblePadding =     SetInfo->HeaderPadding;
//   CallObject->PostamblePadding =    SetInfo->TailPadding;

   if( SetInfo->SendFramingBits )
      CallObject->SendFramingBits =     SetInfo->SendFramingBits;

   if( CallObject->SendFramingBits & PPP_FRAMING )
      CallObject->SpecialFlags |= CALL_OBJ_PPP_FRAMING;

#if DBG
	// Sanity check MaxMtuSize
	if ( CallObject->SpecialFlags & CALL_OBJ_PAD_CONNECTION )
	{
		ASSERT( CallObject->CurrentMaxMtuSize == 2 * MAX_MTU_SIZE );
	}
	else
	{
		ASSERT( CallObject->CurrentMaxMtuSize == MAX_MTU_SIZE );
	}
#endif

   CallObject->RecvFramingBits =     SetInfo->RecvFramingBits;
   CallObject->SendCompressionBits = SetInfo->SendCompressionBits;
   CallObject->RecvCompressionBits = SetInfo->RecvCompressionBits;
   CallObject->SendACCM = SetInfo->SendACCM;
   CallObject->RecvACCM = SetInfo->RecvACCM;

   *BytesWritten = sizeof(NDIS_WAN_SET_LINK_INFO);
   *BytesNeeded = 0;

   DigiDump( DIGIINFO, ("   CallObject=0x%x SendFramingBits=0x%x RecvFramingBits=0x%x\n",
                        CallObject,
                        SetInfo->SendFramingBits,
                        SetInfo->RecvFramingBits) );


   return( NDIS_STATUS_SUCCESS );

}  // end OidWanSetLinkInfo



NDIS_STATUS OidWanGetLinkInfo( IN NDIS_HANDLE MiniportAdapterContext,
                               IN PVOID InformationBuffer,
                               IN ULONG InformationBufferLength,
                               OUT PULONG BytesWritten,
                               OUT PULONG BytesNeeded,
                               IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:

   QueryInfo - Indicates SET or GET.
               If TRUE, OID_WAN_GET_LINK_INFO.
               If FALSE, OID_WAN_SET_LINK_INFO.

Return Value:

   None.

--*/
{
   PNDIS_WAN_GET_LINK_INFO GetInfo=InformationBuffer;
   PDIGIWAN_CALL_OBJECT CallObject;

   //
   // We are being queried for the information
   //

   *BytesNeeded = sizeof(NDIS_WAN_GET_LINK_INFO);

   if( InformationBufferLength != sizeof(NDIS_WAN_GET_LINK_INFO) )
   {
      DigiDump( DIGIFLOW, ("OidWanGetLinkInfo rc = NDIS_STATUS_INVALID_LENGTH\n") );
      return( NDIS_STATUS_INVALID_LENGTH );
   }

   CallObject = (PDIGIWAN_CALL_OBJECT)GetInfo->NdisLinkHandle;
	if( CallObject == NULL )
	{
		DigiDump( DIGIERRORS, ("Error: OidWanGetLinkInfo CallObject = 0\n") );
		return( NDIS_STATUS_INVALID_DATA );
	}
   ASSERT( CallObject->Type == DIGIWAN_TYPE_CALL_OBJECT );

   DigiDump( (DIGIFLOW|DIGIINFO), ("OidWanGetLinkInfo: CallObject = 0x%x\n",
                                   CallObject) );

   //
   // Test for a valid link.  This really seems stupid, because the
   // LinkHandle should be something which was given to the Wan
   // Wrapper on a LINE_UP indication.
   //
   if( CallObject->InternalCallState != INTERNAL_CALL_STATE_CONNECTED )
   {
      DigiDump( DIGIFLOW, ("OidWanGetLinkInfo rc = NDIS_STATUS_INVALID_DATA\n") );
      return( NDIS_STATUS_INVALID_DATA );
   }

   GetInfo->MaxSendFrameSize =  CallObject->MaxSendFrameSize;
   GetInfo->MaxRecvFrameSize =  CallObject->MaxRecvFrameSize;
   GetInfo->HeaderPadding  =  CallObject->PreamblePadding;
   GetInfo->TailPadding =  CallObject->PostamblePadding;
   GetInfo->SendFramingBits  =  CallObject->SendFramingBits;
   GetInfo->RecvFramingBits  =  CallObject->RecvFramingBits;
   GetInfo->SendCompressionBits = CallObject->SendCompressionBits;
   GetInfo->RecvCompressionBits = CallObject->RecvCompressionBits;

   *BytesWritten = sizeof(NDIS_WAN_GET_LINK_INFO);
   *BytesNeeded = 0;

   DigiDump( DIGIINFO, ("   CallObject=0x%x SendFramingBits=0x%x RecvFramingBits=0x%x\n",
                        CallObject,
                        GetInfo->SendFramingBits,
                        GetInfo->RecvFramingBits) );

   return( NDIS_STATUS_SUCCESS );
}  // end OidWanGetLinkInfo



NDIS_STATUS OidWanGetSetBridgeInfo( IN NDIS_HANDLE MiniportAdapterContext,
                                    IN PVOID InformationBuffer,
                                    IN ULONG InformationBufferLength,
                                    OUT PULONG BytesWritten,
                                    OUT PULONG BytesNeeded,
                                    IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:


   QueryInfo - Indicates SET or GET.
               If TRUE, OID_WAN_GET_BRIDGE_INFO.
               If FALSE, OID_WAN_SET_BRIDGE_INFO.

Return Value:

   None.

--*/
{

   DigiDump( DIGIFLOW, ("OidWanGetSetBridgeInfo:\n") );

   return( NDIS_STATUS_SUCCESS );

}  // end OidWanGetSetBridgeInfo



NDIS_STATUS OidWanGetCompInfo( IN NDIS_HANDLE MiniportAdapterContext,
                               IN PVOID InformationBuffer,
                               IN ULONG InformationBufferLength,
                               OUT PULONG BytesWritten,
                               OUT PULONG BytesNeeded,
                               IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:


   QueryInfo - Indicates SET or GET.
               If TRUE, OID_WAN_GET_COMP_INFO.
               If FALSE, OID_WAN_SET_COMP_INFO.

Return Value:

   None.

--*/
{
//------------------------------------------------------------ MLZ 03/01/97 {
#if 0
   PNDIS_WAN_GET_COMP_INFO GetInfo;
   PDIGIWAN_CALL_OBJECT CallObject;
   PASYMAC_FEATURES Features;
#endif
//------------------------------------------------------------ MLZ 03/01/97 }

   DigiDump( DIGIFLOW, ("OidWanGetCompInfo:\n") );

//------------------------------------------------------------ MLZ 01/16/97 {
// Don't pretend to do legacy ras compression!
	*BytesNeeded = 0;
	*BytesWritten = 0;
   return( NDIS_STATUS_SUCCESS );
#if 0
   *BytesNeeded = sizeof(NDIS_WAN_GET_COMP_INFO);

   if( InformationBufferLength != sizeof(NDIS_WAN_GET_COMP_INFO) )
   {
      DigiDump( DIGIFLOW, ("OidWanGetLinkInfo rc = NDIS_STATUS_INVALID_LENGTH\n") );
      return( NDIS_STATUS_INVALID_LENGTH );
   }

   GetInfo = (PNDIS_WAN_GET_COMP_INFO)InformationBuffer;

   CallObject = (PDIGIWAN_CALL_OBJECT)GetInfo->NdisLinkHandle;
	if( CallObject == NULL )
	{
		DigiDump( DIGIERRORS, ("Error: OidWanGetCompInfo CallObject = 0\n") );
		return( NDIS_STATUS_INVALID_DATA );
	}
   ASSERT( CallObject->Type == DIGIWAN_TYPE_CALL_OBJECT );

   if( CallObject->SpecialFlags & CALL_OBJ_PAD_CONNECTION )
   {
      GetInfo->SendCapabilities.CompType = COMPTYPE_NT31RAS;
      GetInfo->SendCapabilities.CompLength = sizeof(ASYMAC_FEATURES);

      Features =
         (PASYMAC_FEATURES)GetInfo->SendCapabilities.Public.CompValues;

      Features->SendFeatureBits = CallObject->SendFeatureBits;
      Features->RecvFeatureBits = CallObject->RecvFeatureBits;
      Features->MaxSendFrameSize = CallObject->MaxSendFrameSize;
      Features->MaxRecvFrameSize = CallObject->MaxRecvFrameSize;
      Features->LinkSpeed = CallObject->LocalLinkSpeed;

      GetInfo->RecvCapabilities.CompType = COMPTYPE_NT31RAS;
      GetInfo->RecvCapabilities.CompLength = sizeof(ASYMAC_FEATURES);

      Features =
         (PASYMAC_FEATURES)GetInfo->RecvCapabilities.Public.CompValues;

      Features->SendFeatureBits = CallObject->SendFeatureBits;  
      Features->RecvFeatureBits = CallObject->RecvFeatureBits;  
      Features->MaxSendFrameSize = CallObject->MaxSendFrameSize;
      Features->MaxRecvFrameSize = CallObject->MaxRecvFrameSize;
      Features->LinkSpeed = CallObject->LocalLinkSpeed;

      *BytesWritten = sizeof(NDIS_WAN_GET_COMP_INFO);

      DigiDump( DIGIINFO, ("GET_COMP_INFO: Features: Recv=0x%x, Send=0x%x\n",
                          Features->RecvFeatureBits,
                          Features->SendFeatureBits) );

      DigiDump( DIGIINFO, ("               FrameSize: Recv=0x%x, Send=0x%x\n",
                          Features->MaxRecvFrameSize,
                          Features->MaxSendFrameSize) );
      
      DigiDump( DIGIINFO, ("               LinkSpeed=0x%x(%u)\n",
                          Features->LinkSpeed,
                          Features->LinkSpeed) );
      
      return( NDIS_STATUS_SUCCESS );
   }
   else
      return( NDIS_STATUS_INVALID_OID );
#endif
//------------------------------------------------------------ MLZ 01/16/97 }

}  // end OidWanGetCompInfo



NDIS_STATUS OidWanSetCompInfo( IN NDIS_HANDLE MiniportAdapterContext,
                               IN PVOID InformationBuffer,
                               IN ULONG InformationBufferLength,
                               OUT PULONG BytesWritten,
                               OUT PULONG BytesNeeded,
                               IN BOOLEAN QueryInfo )
/*++

Routine Description:

Arguments:


   QueryInfo - Indicates SET or GET.
               If TRUE, OID_WAN_GET_COMP_INFO.
               If FALSE, OID_WAN_SET_COMP_INFO.

Return Value:

   None.

--*/
{
//------------------------------------------------------------ MLZ 03/01/97 {
#if 0
   PNDIS_WAN_SET_COMP_INFO SetInfo;
   PDIGIWAN_CALL_OBJECT CallObject;
   PASYMAC_FEATURES Features;
#endif
//------------------------------------------------------------ MLZ 03/01/97 }

   DigiDump( DIGIFLOW, ("OidWanSetCompInfo:\n") );

//------------------------------------------------------------ MLZ 01/16/97 {
// Don't pretend to do legacy ras compression!
	*BytesNeeded = 0;
	*BytesWritten = 0;
   return( NDIS_STATUS_SUCCESS );
#if 0
   SetInfo = (PNDIS_WAN_SET_COMP_INFO)InformationBuffer;

   CallObject = (PDIGIWAN_CALL_OBJECT)SetInfo->NdisLinkHandle;
	if( CallObject == NULL )
	{
		DigiDump( DIGIERRORS, ("Error: OidWanSetCompInfo CallObject = 0\n") );
		return( NDIS_STATUS_INVALID_DATA );
	}
   ASSERT( CallObject->Type == DIGIWAN_TYPE_CALL_OBJECT );

   if( CallObject->SpecialFlags & CALL_OBJ_PAD_CONNECTION )
   {
      if( SetInfo->SendCapabilities.CompType == COMPTYPE_NONE )
      {
         CallObject->SendFeatureBits = 0;
         CallObject->RecvFeatureBits = 0;
      }
      else
      {
         Features =
            (PASYMAC_FEATURES)SetInfo->SendCapabilities.Public.CompValues;

         DigiDump( DIGIINFO, ("SET_COMP_INFO: Features: Recv=0x%x, Send=0x%x\n",
                             Features->RecvFeatureBits,
                             Features->SendFeatureBits) );

         DigiDump( DIGIINFO, ("SET_COMP_INFO: FrameSize: Recv=0x%x, Send=0x%x\n",
                             Features->MaxRecvFrameSize,
                             Features->MaxSendFrameSize) );

         if( (Features->SendFeatureBits & ~(CallObject->SendFeatureBits)) ||
             (Features->RecvFeatureBits & ~(CallObject->RecvFeatureBits)) ||
             (Features->MaxSendFrameSize > CallObject->MaxSendFrameSize) ||
             (Features->MaxRecvFrameSize > CallObject->MaxRecvFrameSize) )
         {
            DigiDump( (DIGIERRORS|DIGIINFO), ("SET_COMP_INFO: Bad compression option\n") );
            return( NDIS_STATUS_FAILURE );
         }

         CallObject->SendFeatureBits = Features->SendFeatureBits;
         CallObject->RecvFeatureBits = Features->RecvFeatureBits;
      }

      return( NDIS_STATUS_SUCCESS );
   }
   else
      return( NDIS_STATUS_INVALID_OID );
#endif
//------------------------------------------------------------ MLZ 01/16/97 }

}  // end OidWanSetCompInfo

