⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tapi.c

📁 这是一个56K MODEM的驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
/***************************************************************************\
|* Copyright (c) 1994  Microsoft Corporation                               *|
|* Developed for Microsoft by TriplePoint, Inc. Beaverton, Oregon          *|
|*                                                                         *|
|* This file is part of the HT Communications DSU41 WAN Miniport Driver.   *|
\***************************************************************************/
#include "version.h"
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Module Name:

    tapi.c

Abstract:

    This module contains all the Miniport TAPI OID processing routines.  It
    is called by the MiniportSetInformation and MiniportQueryInformation
    routines to handle the TAPI OIDs.

    This driver conforms to the NDIS 3.0 Miniport interface and provides
    extensions to support Telephonic Services.

Author:

    Larry Hattery - TriplePoint, Inc. (larryh@tpi.com) Jun-94

Environment:

    Windows NT 3.5 kernel mode Miniport driver or equivalent.

Revision History:

---------------------------------------------------------------------------*/

#define  __FILEID__     8       // Unique file ID for error logging

#include "htdsu.h"

#   define TAPI_DEVICECLASS_NAME        "tapi/line"
#   define TAPI_DEVICECLASS_ID          1
#   define NDIS_DEVICECLASS_NAME        "ndis"
#   define NDIS_DEVICECLASS_ID          2

/*
// The following is a list of all the possible TAPI OIDs.
*/
const NDIS_OID TapiSupportedArray[] =
{
/*
// REQUIRED TAPI SPECIFIC OIDS
*/
    OID_TAPI_ANSWER,
    OID_TAPI_CLOSE,
    OID_TAPI_CLOSE_CALL,
    OID_TAPI_CONDITIONAL_MEDIA_DETECTION,
    OID_TAPI_DROP,
    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_EXTENSION_ID,
    OID_TAPI_GET_ID,
    OID_TAPI_GET_LINE_DEV_STATUS,
    OID_TAPI_MAKE_CALL,
    OID_TAPI_OPEN,
    OID_TAPI_PROVIDER_INITIALIZE,
    OID_TAPI_PROVIDER_SHUTDOWN,
    OID_TAPI_SET_APP_SPECIFIC,
    OID_TAPI_SET_CALL_PARAMS,
    OID_TAPI_SET_DEFAULT_MEDIA_DETECTION,
    OID_TAPI_SET_DEV_CONFIG,
    OID_TAPI_SET_MEDIA_MODE,
    OID_TAPI_SET_STATUS_MESSAGES,
/*
// OPTIONAL TAPI SPECIFIC OIDS
*/
    OID_TAPI_ACCEPT,
    OID_TAPI_CONFIG_DIALOG,
    OID_TAPI_DEV_SPECIFIC,
    OID_TAPI_DIAL,
    OID_TAPI_NEGOTIATE_EXT_VERSION,
    OID_TAPI_SECURE_CALL,
    OID_TAPI_SELECT_EXT_VERSION,
    OID_TAPI_SEND_USER_USER_INFO,
};

#if DBG

/*
// Make sure the following list is in the same order as the list above!
*/
char *TapiSupportedNames[] =
{
/*
// REQUIRED TAPI SPECIFIC OIDS
*/
    "OID_TAPI_ANSWER",
    "OID_TAPI_CLOSE",
    "OID_TAPI_CLOSE_CALL",
    "OID_TAPI_CONDITIONAL_MEDIA_DETECTION",
    "OID_TAPI_DROP",
    "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_EXTENSION_ID",
    "OID_TAPI_GET_ID",
    "OID_TAPI_GET_LINE_DEV_STATUS",
    "OID_TAPI_MAKE_CALL",
    "OID_TAPI_OPEN",
    "OID_TAPI_PROVIDER_INITIALIZE",
    "OID_TAPI_PROVIDER_SHUTDOWN",
    "OID_TAPI_SET_APP_SPECIFIC",
    "OID_TAPI_SET_CALL_PARAMS",
    "OID_TAPI_SET_DEFAULT_MEDIA_DETECTION",
    "OID_TAPI_SET_DEV_CONFIG",
    "OID_TAPI_SET_MEDIA_MODE",
    "OID_TAPI_SET_STATUS_MESSAGES",
/*
// OPTIONAL TAPI SPECIFIC OIDS
*/
    "OID_TAPI_ACCEPT",
    "OID_TAPI_CONFIG_DIALOG",
    "OID_TAPI_DEV_SPECIFIC",
    "OID_TAPI_DIAL",
    "OID_TAPI_NEGOTIATE_EXT_VERSION",
    "OID_TAPI_SECURE_CALL",
    "OID_TAPI_SELECT_EXT_VERSION",
    "OID_TAPI_SEND_USER_USER_INFO",

    "OID_TAPI_UNKNOWN"
};

#define NUM_OID_ENTRIES (sizeof(TapiSupportedArray) / sizeof(TapiSupportedArray[0]))

/*
// This debug routine will lookup the printable name for the selected OID.
*/
char *
HtTapiGetOidString(NDIS_OID Oid)
{
    UINT i;

    for (i = 0; i < NUM_OID_ENTRIES-1; i++)
    {
        if (TapiSupportedArray[i] == Oid)
        {
            break;
        }
    }
    return(TapiSupportedNames[i]);
}

#endif // DBG


NDIS_STATUS
HtTapiQueryInformation(
    IN PHTDSU_ADAPTER Adapter,
    IN NDIS_OID Oid,
    IN PVOID InformationBuffer,
    IN ULONG InformationBufferLength,
    OUT PULONG BytesWritten,
    OUT PULONG BytesNeeded
    )

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Functional Description:

    The HtTapiQueryInformation request allows for inspection of the TAPI
    portion of the driver's capabilities and current line status.

    If the Miniport does not complete the call immediately (by returning
    NDIS_STATUS_PENDING), it must call NdisMQueryInformationComplete to
    complete the call.  The Miniport controls the buffers pointed to by
    InformationBuffer, BytesWritten, and BytesNeeded until the request
    completes.

    No other requests will be submitted to the Miniport driver until
    this request has been completed.

    Interrupts are in any state during this call.

Parameters:

    MiniportAdapterContext _ The adapter handle passed to NdisMSetAttributes
                             during MiniportInitialize.

    Oid _ The OID.  (See section 2.2.1 of the Extensions to NDIS 3.0 Miniports
          to support Telephonic Services specification for a complete 
          description of the OIDs.)

    InformationBuffer _ The buffer that will receive the information.

    InformationBufferLength _ The length in bytes of InformationBuffer.

    BytesWritten _ Returns the number of bytes written into
                   InformationBuffer.

    BytesNeeded _ This parameter returns the number of additional bytes
                  needed to satisfy the OID.

Return Values:

    NDIS_STATUS_INVALID_DATA
    NDIS_STATUS_INVALID_LENGTH
    NDIS_STATUS_INVALID_OID
    NDIS_STATUS_NOT_ACCEPTED
    NDIS_STATUS_NOT_SUPPORTED
    NDIS_STATUS_PENDING
    NDIS_STATUS_RESOURCES
    NDIS_STATUS_SUCCESS

---------------------------------------------------------------------------*/

{
    DBG_FUNC("HtTapiQueryInformation")

    /*
    // Assume the worst, and initialize to handle failure.
    */
    NDIS_STATUS Status = NDIS_STATUS_INVALID_LENGTH;
    ULONG NumBytesNeeded  = 0;
    ULONG NumBytesWritten = 0;

    DBG_ENTER(Adapter);
    DBG_FILTER(Adapter,DBG_REQUEST_ON,
              ("(OID=%s=%08x)\n\t\tInfoLength=%d InfoBuffer=%Xh\n",
               HtTapiGetOidString(Oid),Oid,
               InformationBufferLength,
               InformationBuffer
              ));

    /*
    // Determine which OID is being requested and do the right thing.
    // The switch code will just call the approriate service function
    // to do the real work, so there's not much to worry about here.
    */
    switch (Oid)
    {
    case OID_TAPI_CONFIG_DIALOG:        // OPTIONAL
        if(InformationBufferLength < sizeof(NDIS_TAPI_CONFIG_DIALOG))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_CONFIG_DIALOG);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiConfigDialog(Adapter,
                        (PNDIS_TAPI_CONFIG_DIALOG) InformationBuffer);
        break;

    case OID_TAPI_DEV_SPECIFIC:         // OPTIONAL
        if(InformationBufferLength < sizeof(NDIS_TAPI_DEV_SPECIFIC))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_DEV_SPECIFIC);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiDevSpecific(Adapter,
                        (PNDIS_TAPI_DEV_SPECIFIC) InformationBuffer);
        break;

    case OID_TAPI_GET_ADDRESS_CAPS:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_ADDRESS_CAPS))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_ADDRESS_CAPS);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetAddressCaps(Adapter,
                        (PNDIS_TAPI_GET_ADDRESS_CAPS) InformationBuffer);
        break;

    case OID_TAPI_GET_ADDRESS_ID:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_ADDRESS_ID))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_ADDRESS_ID);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetAddressID(Adapter,
                        (PNDIS_TAPI_GET_ADDRESS_ID) InformationBuffer);
        break;

    case OID_TAPI_GET_ADDRESS_STATUS:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_ADDRESS_STATUS))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_ADDRESS_STATUS);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetAddressStatus(Adapter,
                        (PNDIS_TAPI_GET_ADDRESS_STATUS) InformationBuffer);
        break;

    case OID_TAPI_GET_CALL_ADDRESS_ID:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_CALL_ADDRESS_ID))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_CALL_ADDRESS_ID);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetCallAddressID(Adapter,
                        (PNDIS_TAPI_GET_CALL_ADDRESS_ID) InformationBuffer);
        break;

    case OID_TAPI_GET_CALL_INFO:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_CALL_INFO))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_CALL_INFO);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetCallInfo(Adapter,
                        (PNDIS_TAPI_GET_CALL_INFO) InformationBuffer);
        break;

    case OID_TAPI_GET_CALL_STATUS:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_CALL_STATUS))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_CALL_STATUS);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetCallStatus(Adapter,
                        (PNDIS_TAPI_GET_CALL_STATUS) InformationBuffer);
        break;

    case OID_TAPI_GET_DEV_CAPS:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_DEV_CAPS))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_DEV_CAPS);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetDevCaps(Adapter,
                        (PNDIS_TAPI_GET_DEV_CAPS) InformationBuffer);
        break;

    case OID_TAPI_GET_DEV_CONFIG:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_DEV_CONFIG))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_DEV_CONFIG);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetDevConfig(Adapter,
                        (PNDIS_TAPI_GET_DEV_CONFIG) InformationBuffer);
        break;

    case OID_TAPI_GET_EXTENSION_ID:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_EXTENSION_ID))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_EXTENSION_ID);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetExtensionID(Adapter,
                        (PNDIS_TAPI_GET_EXTENSION_ID) InformationBuffer);
        break;

    case OID_TAPI_GET_ID:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_ID))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_ID);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetID(Adapter,
                        (PNDIS_TAPI_GET_ID) InformationBuffer);
        break;

    case OID_TAPI_GET_LINE_DEV_STATUS:
        if(InformationBufferLength < sizeof(NDIS_TAPI_GET_LINE_DEV_STATUS))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_GET_LINE_DEV_STATUS);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiGetLineDevStatus(Adapter,
                        (PNDIS_TAPI_GET_LINE_DEV_STATUS) InformationBuffer);
        break;

    case OID_TAPI_MAKE_CALL:
        if(InformationBufferLength < sizeof(NDIS_TAPI_MAKE_CALL))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_MAKE_CALL);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiMakeCall(Adapter,
                        (PNDIS_TAPI_MAKE_CALL) InformationBuffer);
        break;

    case OID_TAPI_NEGOTIATE_EXT_VERSION:// OPTIONAL
        if(InformationBufferLength < sizeof(NDIS_TAPI_NEGOTIATE_EXT_VERSION))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_NEGOTIATE_EXT_VERSION);
            break;
        }
        NumBytesWritten = NumBytesNeeded = InformationBufferLength;
        Status = HtTapiNegotiateExtVersion(Adapter,
                        (PNDIS_TAPI_NEGOTIATE_EXT_VERSION) InformationBuffer);
        break;

    case OID_TAPI_OPEN:
        if(InformationBufferLength < sizeof(NDIS_TAPI_OPEN))
        {
            NumBytesNeeded = sizeof(NDIS_TAPI_OPEN);
            break;
        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -