/*++

*****************************************************************************
*                                                                           *
*  This software contains proprietary and confiential 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.                                                              *
*                                                                           *
*****************************************************************************

Module Name:

   digix25p.h

Abstract:

   This is the header file for the DIGIX25 MAC driver for providing
   prototypes and various exported information.

Revision History:

   $Log: /Components/Windows/NT/Sync/Wan/DIGIX25P.H $
 * 
 * 9     4/28/97 1:54p Mikez
 * 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.
 * 
 * 8     3/12/97 3:44p Mikez
 * Misc changes to get RAS dialout working.  Still bugchecks after dialout
 * connection completes on multiprocessor NT 3.51, sp5.
 * 
 * 7     3/04/97 11:15p Mikez
 * Removed references to AdapterObject CallObjects field.
 * 
 * 6     3/04/97 2:54p Mikez
 * Added hack to read RAS TapiDevices keys to determine which ports RAS
 * won't accept dialin calls.  Don't indicate incoming calls to these
 * ports.
 * 
 * 5     3/03/97 9:23a Mikez
 * Updated to use async completions on MakeCall, Drop and Answer TAPI OID
 * requests.
 * 
 * 4     2/26/97 10:27a Mikez
 * Misc debug info.  Moved extern data declarations to digix25.h.
 * 
 * 3     12/06/96 2:28p Mikez
 * Modified to support new SXB paridigm of "one NT device per adapter"
 * rather than the older "one NT device per port".
 * 
 * 2     10/28/96 1:25p Mikez
 * Updated to support latest firmware release, v1.1.2b.
 * Revision 1.8  1995/10/06  06:59:50  Craig_Harrison
 * Version 1.0.1.2 
 * 
 * Revision 1.7  1995/09/15  00:00:00  Craig_Harrison
 * First beta release
 * 
 * Revision 1.5  1995/06/01  10:09:45  rik
 * Updated for various problems and enhancements
 * 
 * Revision 1.4  1995/01/23  09:26:52  rik
 * Got direct X25 connections working reliably
 * 
 * Revision 1.3  1994/03/23  22:17:40  rik
 * Updated to compile with first integration
 *
 * Revision 1.2  1994/03/17  10:07:01  rik
 * Updating for integration with Tapi wrapper.
 *
 * Revision 1.1  1994/02/16  14:31:47  rik
 * Initial revision
 *

--*/

#include <ndistapi.h>
#include "digilib.h"

//
// Prototypes for pad.c
//
VOID SendAsyncTransparency( PDIGIWAN_CALL_OBJECT CallObject,
                            PUCHAR OriginalBuffer,
                            ULONG  OriginalLength,
                            PUCHAR NewBuffer,
                            PULONG NewLength,
                            ULONG Type );

VOID QueuePadByteStream( PDIGIWAN_CALL_OBJECT CallObject,
                         PUCHAR ByteBuffer,
                         ULONG Length );

VOID AssembleRASFrame( PDIGIWAN_CALL_OBJECT CallObject,
                       PNDIS_WAN_PACKET Packet,
                       PNDIS_WAN_PACKET OriginalPacket );

VOID AssemblePPPFrame( PDIGIWAN_CALL_OBJECT CallObject,
                       PNDIS_WAN_PACKET Packet,
                       PNDIS_WAN_PACKET OriginalPacket );

//
// call.c
//
NDIS_STATUS InitializeCallList( ULONG nTotalCalls,  
                                HANDLE MiniportAdapterHandle );

VOID FreeCallList();

PDIGIWAN_CALL_OBJECT NewCallObject( PDIGIWAN_ADAPTER_OBJECT AdapterObject, 
                                    ULONG AddressID );

VOID FreeCallObject( PDIGIWAN_CALL_OBJECT CallObject );

ULONG DigiWanCountActiveCalls( VOID );

//
// x25send.c
//
NDIS_STATUS DigiWanSend( IN NDIS_HANDLE LinkContext,
                         IN NDIS_HANDLE NdisLinkHandle,
                         IN PNDIS_WAN_PACKET Packet );

//
// connect.c
//
NDIS_STATUS ConnectRequest( IN HANDLE hStream,
                            IN ULONG Snid,
                            IN PUCHAR pRemoteAddress,
                            IN ULONG AddressLength,
                            IN PDSL_PUTMSG_COMPLETION_ROUTINE CompletionRoutine );

NDIS_STATUS DisconnectRequest( IN HANDLE hStream,
                               IN ULONG ConnId,
                               IN PDSL_PUTMSG_COMPLETION_ROUTINE CompletionRoutine );


VOID X25GetMsgComplete( IN HANDLE hOwner,
                        IN HANDLE Context,
                        IN PVOID pControl,
                        IN ULONG ControlLength,
                        IN PVOID pData,
                        IN ULONG DataLength,
                        IN NTSTATUS IOStatus );

VOID ScheduleGetMsg( IN PKDPC pDpc,
                     IN HANDLE hStream, 
                     IN ULONG ControlLength,
                     IN PVOID pData,
                     IN ULONG DataLength,
                     IN HANDLE Context,
                     IN PDSL_GETMSG_COMPLETION_ROUTINE CompletionRoutine );

VOID DigiWanDeferredGetMsg( IN PKDPC Dpc,
                            IN PVOID DeferredContext,
                            IN PVOID SystemContext1,
                            IN PVOID SystemContext2 );

//
// listen.c
//
NDIS_STATUS ListenRequest( IN HANDLE hStream );

NDIS_STATUS CancelListen( IN HANDLE hStream );

VOID ListenGetMsgComplete( IN HANDLE hOwner,
                           IN HANDLE Context,
                           IN PVOID pControl,
                           IN ULONG ControlLength,
                           IN PVOID pData,
                           IN ULONG DataLength,
                           IN NTSTATUS IOStatus );

NDIS_STATUS RejectIncoming( PDIGIWAN_PHYS_ADAPTER PhysAdapter,
                            ULONG ConnId );

VOID
CallOfferingTimeout(
	IN PVOID SystemSpecific1, 
	IN PVOID FunctionContext, 
	IN PVOID SystemSpecific2, 
	IN PVOID SystemSpecific3 );

//
// setquery.c
//
NDIS_STATUS MiniportSetInfo( IN NDIS_HANDLE MiniportAdapterContext,
                             IN NDIS_OID Oid,
                             IN PVOID InformationBuffer,
                             IN ULONG InformationBufferLength,
                             OUT PULONG BytesRead,
                             OUT PULONG BytesNeeded );

NDIS_STATUS MiniportQueryInfo( IN NDIS_HANDLE MiniportAdapterContext,
                               IN NDIS_OID Oid,
                               IN PVOID InformationBuffer,
                               IN ULONG InformationBufferLength,
                               OUT PULONG BytesWritten,
                               OUT PULONG BytesNeeded );


//
// lanoid.c
//
NDIS_STATUS LanOidHandler( NDIS_HANDLE AdapterContext,
                           NDIS_OID Oid,
                           PVOID InfoBuffer,
                           ULONG InfoBufferLen,
                           PULONG BytesReadWritten,
                           PULONG BytesNeeded );


//
// adptcntx.c
//
VOID AdapterContextTimerFunction( IN PVOID SystemSpecific1,
                                  IN PVOID FunctionContext,
                                  IN PVOID SystemSpecific2,
                                  IN PVOID SystemSpecific3 );

VOID AdapterContextWanLineup( PDIGIWAN_CALL_OBJECT CallObject,
                              NDIS_HANDLE EndPoint );

VOID AdapterContextWanLinedown( PDIGIWAN_CALL_OBJECT CallObject,
                                NDIS_HANDLE EndPoint );

VOID AdapterContextSendTapiEvent( PDIGIWAN_CALL_OBJECT CallObject,
                                  ULONG ulMsg,
                                  ULONG_PTR Param1,
                                  ULONG_PTR Param2,
                                  ULONG_PTR Param3 );

VOID AdapterContextWanSendComplete( PDIGIWAN_CALL_OBJECT CallObject,
                                    PNDIS_WAN_PACKET WanPacket,
                                    NDIS_STATUS StatusToComplete );

VOID AdapterContextWanIndicateReceive( IN PDIGIWAN_CALL_OBJECT CallObject,
                                       IN PUCHAR pBuffer,
                                       IN ULONG Length );

VOID AdapterContextWanIndicateFragment( PDIGIWAN_CALL_OBJECT CallObject,
                                        ULONG Error );

VOID AdapterContextSetInfoComplete( IN PDIGIWAN_CALL_OBJECT CallObject,
                                    IN NDIS_STATUS Status );

VOID AdapterContextQueryInfoComplete( IN PDIGIWAN_CALL_OBJECT CallObject,
                                      IN NDIS_STATUS Status );

//
// tapimisc.c
//

VOID SendTapiEvent( HANDLE MiniportAdapterHandle,
                    HTAPI_LINE htLine,
                    HTAPI_CALL htCall,
                    ULONG ulMsg,
                    PULONG_PTR Param1,
                    PULONG_PTR Param2,
                    PULONG_PTR Param3 );

//
// wanindic.c
//
VOID WanLineup( PDIGIWAN_CALL_OBJECT CallObject,
                NDIS_HANDLE EndPoint );

VOID WanLinedown( PDIGIWAN_CALL_OBJECT CallObject );

VOID WanFragment( PDIGIWAN_CALL_OBJECT CallObject,
                  ULONG FragmentErrors );

//
// Prototypes for x25misc.c
//

DIGI_MEM_COMPARES DigiMemCompare( IN PHYSICAL_ADDRESS A,
                                  IN ULONG SpanOfA,
                                  IN PHYSICAL_ADDRESS B,
                                  IN ULONG SpanOfB );

USHORT DigiWstrLength( IN PWSTR WStr );

BOOLEAN IsAdapterCreated( IN PUNICODE_STRING DeviceName,
                          IN PLIST_ENTRY PhysAdaptersList,
                          OUT PDIGIWAN_PHYS_ADAPTER *pPhysAdapter );

BOOLEAN GetNextMultistringString( IN PUNICODE_STRING SrcMultiString, 
                                  IN OUT PUNICODE_STRING DestString );

//
// X25route.c
//

NDIS_STATUS BuildX25RouterTable( NDIS_HANDLE RegistryHandle,
                                 PLIST_ENTRY PhysAdapters );

NDIS_STATUS BuildX25AliasTable( NDIS_HANDLE RegistryHandle );

NDIS_STATUS X25Router( OUT PDIGIWAN_PHYS_ADAPTER *pPhysAdapter,
                       OUT PULONG pSnid,
                       IN PUCHAR X25Address,
                       IN ULONG Length );
