/*++
*******************************************************************************
* Copyright (c) 1990-98 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:

   isdnlan.c

Abstract:

   Handler routines for OID_GEN and OID_802_3 SetInfo and QueryInfo requests.

Author:

   Michael Zarns

--*/
#include "digiisdn.h"

STATIC CONST NDIS_OID SupportedOids[] =
{
	OID_GEN_SUPPORTED_LIST,
	OID_GEN_MEDIA_SUPPORTED,
	OID_GEN_MEDIA_IN_USE,
	OID_GEN_MAC_OPTIONS,
	OID_GEN_MAXIMUM_LOOKAHEAD,
	OID_GEN_VENDOR_ID,
	OID_802_3_CURRENT_ADDRESS,
	OID_802_3_MAXIMUM_LIST_SIZE,
	OID_WAN_PERMANENT_ADDRESS,
	OID_WAN_CURRENT_ADDRESS,
	OID_WAN_QUALITY_OF_SERVICE,
	OID_WAN_HEADER_FORMAT,
	OID_WAN_MEDIUM_SUBTYPE,
	OID_WAN_GET_INFO,
	OID_WAN_GET_LINK_INFO,
	OID_WAN_LINE_COUNT,
	OID_WAN_PROTOCOL_TYPE,
	OID_WAN_HEADER_FORMAT,
	OID_WAN_SET_LINK_INFO,
	OID_TAPI_GET_ADDRESS_CAPS,
	OID_TAPI_GET_ADDRESS_ID,
	OID_TAPI_GET_ADDRESS_STATUS,
	OID_TAPI_GET_CALL_ADDRESS_ID,
	OID_TAPI_GET_CALL_INFO,
	OID_TAPI_GET_CALL_STATUS,
	OID_TAPI_GET_DEV_CAPS,
//	OID_TAPI_GET_DEV_CONFIG,
	OID_TAPI_GET_ID,
	OID_TAPI_GET_LINE_DEV_STATUS,
	OID_TAPI_MAKE_CALL,
	OID_TAPI_OPEN,
	OID_TAPI_PROVIDER_INITIALIZE,
//	OID_TAPI_NEGOTIATE_EXT_VERSION,
	OID_TAPI_ANSWER,
	OID_TAPI_CLOSE,
	OID_TAPI_CLOSE_CALL,
	OID_TAPI_DROP,
	OID_TAPI_PROVIDER_SHUTDOWN,
	OID_TAPI_SET_APP_SPECIFIC,
	OID_TAPI_SET_CALL_PARAMS,
	OID_TAPI_SET_DEFAULT_MEDIA_DETECTION,
	OID_TAPI_SET_MEDIA_MODE,
	OID_TAPI_SET_STATUS_MESSAGES
};


NDIS_STATUS
IsdnLanQuery(
	IN PISDN_ADAPTER pAdapter,
	IN NDIS_OID      Oid,
	IN PVOID         pData,
	IN ULONG         cbData,
	OUT PULONG       pcbWritten,
	OUT PULONG       pcbNeeded )
/*++

Description:

	Handle all OID_GEN and OID_802_3 QueryInfo requests.

--*/
{
	NDIS_STATUS Status = NDIS_STATUS_SUCCESS;	// Assume success!
	ULONG cbWritten = 0;
	ULONG cbNeeded = 0;
	
	DigiDump( DIGIOID, ( "ISDN!LanQuery: pAdapter 0x%x, Oid 0x%08x\n", pAdapter, Oid ) );

	switch ( Oid )
	{
		case OID_GEN_SUPPORTED_LIST:
		{
			if ( cbData >= sizeof SupportedOids )
			{
				NdisMoveMemory( pData, &SupportedOids, sizeof SupportedOids );
				cbWritten = sizeof SupportedOids;
			}
			else
			{
				Status = NDIS_STATUS_INVALID_LENGTH;
				cbNeeded = sizeof SupportedOids;
			}
			break;
		}

		case OID_GEN_MEDIA_SUPPORTED:
		{
			PULONG pOptions = pData;
			ASSERT( cbData >= sizeof *pOptions );
			DigiDump( DIGILANOID, ( "ISDN: OID_GEN_MEDIA_SUPPORTED, pAdapter 0x%x\n", pAdapter ) );
			*pOptions = NdisMediumWan;
			cbWritten = sizeof *pOptions;
			break;
		}

		case OID_GEN_MEDIA_IN_USE:
		{
			PULONG pOptions = pData;
			ASSERT( cbData >= sizeof *pOptions );
			DigiDump( DIGILANOID, ( "ISDN: OID_GEN_MEDIA_IN_USE, pAdapter 0x%x\n", pAdapter ) );
			*pOptions = NdisMediumWan;
			cbWritten = sizeof *pOptions;
			break;
		}

		case OID_GEN_MAC_OPTIONS:
		{
			PULONG pOptions = pData;
			ASSERT( cbData >= sizeof *pOptions );
			DigiDump( DIGILANOID, ( "ISDN: OID_GEN_MAC_OPTIONS, pAdapter 0x%x\n", pAdapter ) );
			*pOptions = NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA | 
			            NDIS_MAC_OPTION_TRANSFERS_NOT_PEND | 
			            NDIS_MAC_OPTION_NO_LOOPBACK | 
			            NDIS_MAC_OPTION_RECEIVE_SERIALIZED;
			cbWritten = sizeof *pOptions;
			break;
		}

		case OID_GEN_MAXIMUM_LOOKAHEAD:
		{
			PULONG pMax = pData;
			ASSERT( cbData >= sizeof *pMax );
			DigiDump( DIGILANOID, ( "ISDN: OID_GEN_MAXIMUM_LOOKAHEAD, pAdapter 0x%x\n", pAdapter ) );
			*pMax = ISDN_MAX_FRAME_SIZE + 14;
			cbWritten = sizeof *pMax;
			break;
		}

		case OID_GEN_VENDOR_ID:
		{
			PUCHAR pId = pData;
			UCHAR Id[] = {0xFF, 0xFF, 0xFF};
			ASSERT( cbData >= sizeof Id );
			DigiDump( DIGILANOID, ( "ISDN: OID_GEN_VENDOR_ID, pAdapter 0x%x\n", pAdapter ) );
			RtlCopyMemory( pData, Id, sizeof Id );
			cbWritten = sizeof Id;
			break;
		}

		case OID_802_3_CURRENT_ADDRESS:
		{
			CHAR Addr[6] = {'D','i','g','i','0','2'};
			ASSERT( cbData >= sizeof Addr );
			DigiDump( DIGILANOID, ( "ISDN: OID_802_3_CURRENT_ADDRESS, pAdapter 0x%x\n", pAdapter ) );
			NdisMoveMemory( pData, &Addr, sizeof Addr );
			cbWritten = sizeof Addr;
			break;
		}

		case OID_802_3_MAXIMUM_LIST_SIZE:
		{
			PULONG pListSize = pData;
			DigiDump( DIGILANOID, ( "ISDN: OID_802_3_MAXIMUM_LIST_SIZE, pAdapter 0x%x\n", pAdapter ) );
			// BUGBUG: Figure out what to do with this list size!  Alloc space for it.
			*pListSize = 16;
			cbWritten = sizeof *pListSize;
			break;
		}

		default:
			DigiDump( DIGIWARN, ( "ISDN!OidLanQuery: Unsupported Oid 0x%08x on pAdapter 0x%x\n", Oid, pAdapter ) );
			Status = NDIS_STATUS_NOT_SUPPORTED;
			break;
	}

	*pcbWritten = cbWritten;
	*pcbNeeded  = cbNeeded;
	return Status;
}


NDIS_STATUS
IsdnLanSet(
	IN PISDN_ADAPTER pAdapter,
	IN NDIS_OID      Oid,
	IN PVOID         pData,
	IN ULONG         cbData,
	OUT PULONG       pcbRead,
	OUT PULONG       pcbNeeded )
/*++

Description:

	Handle all OID_GEN SetInfo requests.

--*/
{
	NDIS_STATUS Status = NDIS_STATUS_SUCCESS;	// Assume success!
	ULONG cbRead   = 0;
	ULONG cbNeeded = 0;
	
	DigiDump( DIGIOID, ( "ISDN!LanSet: pAdapter 0x%x, Oid 0x%08x\n", pAdapter, Oid ) );

#if 0
	switch ( Oid )
	{
		case OID_GEN_:
		{
			DigiDump( DIGILANOID, ( "ISDN: OID_GEN_, pAdapter 0x%x\n", pAdapter ) );
			cbRead = ;
			break;
		}

		default:
#endif
			DigiDump( DIGIWARN, ( "ISDN!OidLanSet: Unsupported Oid 0x%08x on pAdapter 0x%x\n", Oid, pAdapter ) );
			Status = NDIS_STATUS_NOT_SUPPORTED;
#if 0
			break;
	}
#endif

	*pcbRead   = cbRead;
	*pcbNeeded = cbNeeded;
	return Status;
}
