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

📄 tapi.c

📁 这是一个56K MODEM的驱动程序
💻 C
📖 第 1 页 / 共 5 页
字号:
        IN  ULONG       ulDeviceClassOffset;
        IN  ULONG       ulLibraryNameTotalSize;
        OUT ULONG       ulLibraryNameNeededSize;
        OUT CHAR        szLibraryName[1];

    } NDIS_TAPI_CONFIG_DIALOG, *PNDIS_TAPI_CONFIG_DIALOG;

Return Values:

    NDIS_STATUS_SUCCESS
    NDIS_STATUS_TAPI_INVALDEVICECLASS
    NDIS_STATUS_STRUCTURETOOSMALL
    NDIS_STATUS_TAPI_NODRIVER

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

{
    DBG_FUNC("HtTapiConfigDialog")

    /*
    // A pointer to our link information structure for the selected line device.
    */
    PHTDSU_LINK Link;
    
    /*
    // Remember which device class is being requested.
    */
    UINT DeviceClass;
    
    DBG_ENTER(Adapter);
    DBG_FILTER(Adapter, DBG_PARAMS_ON,
              ("ulDeviceID=%d\n"
               "ulDeviceClassSize=%d\n"
               "ulDeviceClassOffset=%Xh\n"
               "ulLibraryNameTotalSize=%d\n",
               Request->ulDeviceID,
               Request->ulDeviceClassSize,
               Request->ulDeviceClassOffset,
               Request->ulLibraryNameTotalSize
              ));
    /*
    // Make sure this is a tapi/line or ndis request.
    */
    if (_strnicmp((PCHAR) Request + Request->ulDeviceClassOffset,
                  NDIS_DEVICECLASS_NAME, Request->ulDeviceClassSize) == 0)
    {
        DeviceClass = NDIS_DEVICECLASS_ID;
    }
    else if (_strnicmp((PCHAR) Request + Request->ulDeviceClassOffset,
                  TAPI_DEVICECLASS_NAME, Request->ulDeviceClassSize) == 0)
    {
        DeviceClass = TAPI_DEVICECLASS_ID;
    }
    else
    {
        DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INVALDEVICECLASS\n"));
        return (NDIS_STATUS_TAPI_INVALDEVICECLASS);
    }

    /*
    // This request must be associated with a line device.
    */
    Link = GET_LINK_FROM_DEVICEID(Adapter, Request->ulDeviceID);
    if (Link == NULL)
    {
        DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_NODRIVER\n"));
        return (NDIS_STATUS_TAPI_NODRIVER);
    }

    /*
    // Copy the name of our configuration DLL which we read from the registry
    // during startup, and which was placed there during installation.
    //
    // This driver does not provide a configuration DLL.
    // This is just a place holder for future extensions.
    */
    Request->ulLibraryNameNeededSize = strlen(Adapter->ConfigDLLName) + 1;
    if (Request->ulLibraryNameTotalSize < Request->ulLibraryNameNeededSize)
    {
        DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_STRUCTURETOOSMALL\n"));
        return (NDIS_STATUS_TAPI_STRUCTURETOOSMALL);
    }
    NdisMoveMemory(
            Request->szLibraryName,
            Adapter->ConfigDLLName,
            Request->ulLibraryNameNeededSize
            );

    DBG_LEAVE(Adapter);

    return (NDIS_STATUS_SUCCESS);
}


NDIS_STATUS
HtTapiDevSpecific(
    IN PHTDSU_ADAPTER                   Adapter,
    IN PNDIS_TAPI_DEV_SPECIFIC          Request
    )

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

Functional Description:

    This request is used as a general extension mechanism to enable miniports
    to provide access to features not described in other operations. The meaning
    of the extensions are device-specific, and taking advantage of these
    extensions requires the application to be fully aware of them.

Parameters:

    Adapter _ A pointer ot our adapter information structure.

    Request _ A pointer to the NDIS_TAPI request structure for this call.

    typedef struct _NDIS_TAPI_DEV_SPECIFIC
    {
        IN  ULONG       ulRequestID;
        IN  HDRV_LINE   hdLine;
        IN  ULONG       ulAddressID;
        IN  HDRV_CALL   hdCall;
        IN OUT  ULONG   ulParamsSize;
        IN OUT  UCHAR   Params[1];

    } NDIS_TAPI_DEV_SPECIFIC, *PNDIS_TAPI_DEV_SPECIFIC;

Return Values:

    NDIS_STATUS_SUCCESS
    NDIS_STATUS_FAILURE
    NDIS_STATUS_TAPI_OPERATIONUNAVAIL

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

{
    DBG_FUNC("HtTapiDevSpecific")

    DBG_ENTER(Adapter);
    DBG_FILTER(Adapter, DBG_PARAMS_ON,
              ("hdLine=%Xh\n"
               "ulAddressID=%d\n"
               "hdCall=%Xh\n"
               "ulParamsSize=%d\n"
               "Params=%Xh\n",
               Request->hdLine,
               Request->ulAddressID,
               Request->hdCall,
               Request->ulParamsSize,
               Request->Params
              ));
    /*
    // You can do what ever you want here, so long as the application
    // agrees with you.
    */

    DBG_LEAVE(Adapter);

    return (NDIS_STATUS_TAPI_OPERATIONUNAVAIL);
}


NDIS_STATUS
HtTapiGetAddressID(
    IN PHTDSU_ADAPTER                   Adapter,
    IN PNDIS_TAPI_GET_ADDRESS_ID        Request
    )

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

Functional Description:

    This request returns the address ID associated with address in a different
    format on the specified line.

Parameters:

    Adapter _ A pointer ot our adapter information structure.

    Request _ A pointer to the NDIS_TAPI request structure for this call.

    typedef struct _NDIS_TAPI_GET_ADDRESS_ID
    {
        IN  ULONG       ulRequestID;
        IN  HDRV_LINE   hdLine;
        OUT ULONG       ulAddressID;
        IN  ULONG       ulAddressMode;
        IN  ULONG       ulAddressSize;
        IN  CHAR        szAddress[1];

    } NDIS_TAPI_GET_ADDRESS_ID, *PNDIS_TAPI_GET_ADDRESS_ID;

Return Values:

    NDIS_STATUS_SUCCESS
    NDIS_STATUS_FAILURE
    NDIS_STATUS_TAPI_INVALLINEHANDLE
    NDIS_STATUS_TAPI_RESOURCEUNAVAIL

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

{
    DBG_FUNC("HtTapiGetAddressID")

    /*
    // A pointer to our link information structure for the selected line device.
    */
    PHTDSU_LINK Link;

    DBG_ENTER(Adapter);
    DBG_FILTER(Adapter, DBG_PARAMS_ON,
              ("hdLine=%Xh\n"
               "ulAddressMode=%Xh\n"
               "ulAddressSize=%d\n"
               "szAddress=%Xh\n",
               Request->hdLine,
               Request->ulAddressMode,
               Request->ulAddressSize,
               Request->szAddress
              ));
    /*
    // This request must be associated with a line device.
    */
    Link = GET_LINK_FROM_HDLINE(Adapter, Request->hdLine);
    if (Link == NULL)
    {
        DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INVALLINEHANDLE\n"));
        return (NDIS_STATUS_TAPI_INVALLINEHANDLE);
    }

    /*
    // The spec sez it has to be this mode!  Otherwise, we already know
    // that the address ID is (0..N-1).
    */
    if (Request->ulAddressMode != LINEADDRESSMODE_DIALABLEADDR)
    {
        DBG_WARNING(Adapter, ("Returning NDIS_STATUS_FAILURE\n"));
        return (NDIS_STATUS_FAILURE);
    }

    /*
    // Make sure we have enough room set aside for this address string.
    */
    if (Request->ulAddressSize > sizeof(Link->LineAddress)-1)
    {
        DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_RESOURCEUNAVAIL\n"));
        return (NDIS_STATUS_TAPI_RESOURCEUNAVAIL);
    }

    /*
    // You may need to search each link to find the associated Address.
    // However, this adapter has only one address per link so it's an 
    // easy task.
    */
    Request->ulAddressID = HTDSU_TAPI_ADDRESSID;

    DBG_LEAVE(Adapter);

    return (NDIS_STATUS_SUCCESS);
}


NDIS_STATUS
HtTapiGetAddressCaps(
    PHTDSU_ADAPTER                      Adapter,
    PNDIS_TAPI_GET_ADDRESS_CAPS         Request
    )

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

Functional Description:

    This request queries the specified address on the specified line device
    to determine its telephony capabilities.

Parameters:

    Adapter _ A pointer ot our adapter information structure.

    Request _ A pointer to the NDIS_TAPI request structure for this call.

    typedef struct _NDIS_TAPI_GET_ADDRESS_CAPS
    {
        IN  ULONG       ulRequestID;
        IN  ULONG       ulDeviceID;
        IN  ULONG       ulAddressID;
        IN  ULONG       ulExtVersion;
        OUT LINE_ADDRESS_CAPS   LineAddressCaps;

    } NDIS_TAPI_GET_ADDRESS_CAPS, *PNDIS_TAPI_GET_ADDRESS_CAPS;

    typedef struct _LINE_ADDRESS_CAPS
    {
        ULONG   ulTotalSize;
        ULONG   ulNeededSize;
        ULONG   ulUsedSize;

        ULONG   ulLineDeviceID;

        ULONG   ulAddressSize;
        ULONG   ulAddressOffset;

        ULONG   ulDevSpecificSize;
        ULONG   ulDevSpecificOffset;

        ULONG   ulAddressSharing;
        ULONG   ulAddressStates;
        ULONG   ulCallInfoStates;
        ULONG   ulCallerIDFlags;
        ULONG   ulCalledIDFlags;
        ULONG   ulConnectedIDFlags;
        ULONG   ulRedirectionIDFlags;
        ULONG   ulRedirectingIDFlags;
        ULONG   ulCallStates;
        ULONG   ulDialToneModes;
        ULONG   ulBusyModes;
        ULONG   ulSpecialInfo;
        ULONG   ulDisconnectModes;

        ULONG   ulMaxNumActiveCalls;
        ULONG   ulMaxNumOnHoldCalls;
        ULONG   ulMaxNumOnHoldPendingCalls;
        ULONG   ulMaxNumConference;
        ULONG   ulMaxNumTransConf;

        ULONG   ulAddrCapFlags;
        ULONG   ulCallFeatures;
        ULONG   ulRemoveFromConfCaps;
        ULONG   ulRemoveFromConfState;
        ULONG   ulTransferModes;
        ULONG   ulParkModes;

        ULONG   ulForwardModes;
        ULONG   ulMaxForwardEntries;
        ULONG   ulMaxSpecificEntries;
        ULONG   ulMinFwdNumRings;
        ULONG   ulMaxFwdNumRings;

        ULONG   ulMaxCallCompletions;
        ULONG   ulCallCompletionConds;
        ULONG   ulCallCompletionModes;
        ULONG   ulNumCompletionMessages;
        ULONG   ulCompletionMsgTextEntrySize;
        ULONG   ulCompletionMsgTextSize;
        ULONG   ulCompletionMsgTextOffset;

    } LINE_ADDRESS_CAPS, *PLINE_ADDRESS_CAPS;

Return Values:

    NDIS_STATUS_SUCCESS
    NDIS_STATUS_TAPI_INVALADDRESSID
    NDIS_STATUS_TAPI_INCOMPATIBLEEXTVERSION
    NDIS_STATUS_TAPI_NODRIVER

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

{
    DBG_FUNC("HtTapiGetAddressCaps")

    /*
    // A pointer to our link information structure for the selected line device.
    */
    PHTDSU_LINK Link;

    /*
    // Length of the address string assigned to this line device.
    */
    UINT AddressLength;

    DBG_ENTER(Adapter);
    DBG_FILTER(Adapter, DBG_PARAMS_ON,
              ("ulDeviceID=%d\n"
               "ulAddressID=%d\n"
               "ulExtVersion=%Xh\n",
               Request->ulDeviceID,
               Request->ulAddressID,
               Request->ulExtVersion
              ));
    /*
    // Make sure the address is within range - we only support one per line.
    */
    if (Request->ulAddressID >= HTDSU_TAPI_NUM_ADDRESSES)
    {
        DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INVALADDRESSID\n"));
        return (NDIS_STATUS_TAPI_INVALADDRESSID);
    }

    /*
    // Make sure we are speaking the same language.
    */
#ifdef NDISTAPI_BUG_FIXED
    if (Request->ulExtVersion != 0 &&
        Request->ulExtVersion != HTDSU_TAPI_EXT_VERSION)
    {
        DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INCOMPATIBLEEXTVERSION\n"));
        return (NDIS_STATUS_TAPI_INCOMPATIBLEEXTVERSION);
    }
#endif

    /*
    // This request must be associated with a line device.
    */
    Link = GET_LINK_FROM_DEVICEID(Adapter, Request->ulDeviceID);
    if (Link == NULL)
    {
        DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_NODRIVER\n"));
        return (NDIS_STATUS_TAPI_NODRIVER);
    }

#ifndef NDISTAPI_BUG_FIXED
    Request->LineAddressCaps.ulNeededSize =
    Request->LineAddressCaps.ulUsedSize = sizeof(Request->LineAddressCaps);
#endif

    Request->LineAddressCaps.ulLineDeviceID = Request->ulDeviceID;

    /*
    // RASTAPI requires the "I L A" be placed in the Address field at the end
    // of this structure.  Where:
    // I = The device intance assigned to this adapter in the registry

⌨️ 快捷键说明

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