📄 tapi.c
字号:
DBG_FILTER(Adapter, DBG_PARAMS_ON,
("hdLine=%Xh\n"
"ulAddressID=%d\n"
"hdCall=%Xh\n"
"ulSelect=%Xh\n"
"ulDeviceClassSize=%d\n"
"ulDeviceClassOffset=%Xh\n",
Request->hdLine,
Request->ulAddressID,
Request->hdCall,
Request->ulSelect,
Request->ulDeviceClassSize,
Request->ulDeviceClassOffset
));
/*
// 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);
}
/*
// Find the link structure associated with the request/deviceclass.
*/
if (Request->ulSelect == LINECALLSELECT_LINE)
{
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);
}
if (DeviceClass == TAPI_DEVICECLASS_ID)
{
/*
// TAPI just wants the ulDeviceID for this line.
*/
DeviceID = (ULONG) GET_DEVICEID_FROM_LINK(Adapter, Link);
IDLength = sizeof(DeviceID);
IDPtr = (PUCHAR) &DeviceID;
}
else // UNSUPPORTED DEVICE CLASS
{
DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INVALDEVICECLASS\n"));
return (NDIS_STATUS_TAPI_INVALDEVICECLASS);
}
}
else if (Request->ulSelect == LINECALLSELECT_ADDRESS)
{
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);
}
if (Request->ulAddressID >= HTDSU_TAPI_NUM_ADDRESSES)
{
DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INVALADDRESSID\n"));
return (NDIS_STATUS_TAPI_INVALADDRESSID);
}
/*
// Currently, there is no defined return value for this case...
// This is just a place holder for future extensions.
*/
DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INVALDEVICECLASS\n"));
return (NDIS_STATUS_TAPI_INVALDEVICECLASS);
}
else if (Request->ulSelect == LINECALLSELECT_CALL)
{
Link = GET_LINK_FROM_HDCALL(Adapter, Request->hdCall);
if (Link == NULL)
{
DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INVALCALLHANDLE\n"));
return (NDIS_STATUS_TAPI_INVALCALLHANDLE);
}
if (DeviceClass == NDIS_DEVICECLASS_ID)
{
/*
// This must match ConnectionWrapperID used in LINE_UP event!
*/
DeviceID = (ULONG) Link->htCall;
IDLength = sizeof(DeviceID);
IDPtr = (PUCHAR) &DeviceID;
}
else // UNSUPPORTED DEVICE CLASS
{
DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INVALDEVICECLASS\n"));
return (NDIS_STATUS_TAPI_INVALDEVICECLASS);
}
}
else
{
DBG_WARNING(Adapter, ("Returning NDIS_STATUS_FAILURE\n"));
return (NDIS_STATUS_FAILURE);
}
DBG_NOTICE(Adapter, ("GETID-%d=%Xh\n",Request->ulSelect,DeviceID));
/*
// Now we need to adjust the variable field to place the device ID.
*/
Request->DeviceID.ulNeededSize = sizeof(VAR_STRING) + IDLength;
if (Request->DeviceID.ulTotalSize >= Request->DeviceID.ulNeededSize)
{
Request->DeviceID.ulUsedSize = Request->DeviceID.ulNeededSize;
Request->DeviceID.ulStringFormat = STRINGFORMAT_BINARY;
Request->DeviceID.ulStringSize = IDLength;
Request->DeviceID.ulStringOffset = sizeof(VAR_STRING);
/*
// Now we return the requested ID value.
*/
NdisMoveMemory(
(PCHAR) &Request->DeviceID + sizeof(VAR_STRING),
IDPtr,
IDLength
);
}
DBG_LEAVE(Adapter);
return (NDIS_STATUS_SUCCESS);
}
NDIS_STATUS
HtTapiGetDevConfig(
IN PHTDSU_ADAPTER Adapter,
IN PNDIS_TAPI_GET_DEV_CONFIG Request
)
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Functional Description:
This request returns a data structure object, the contents of which are
specific to the line (miniport) and device class, giving the current
configuration of a device associated one-to-one with the line device.
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_DEV_CONFIG
{
IN ULONG ulRequestID;
IN ULONG ulDeviceID;
IN ULONG ulDeviceClassSize;
IN ULONG ulDeviceClassOffset;
OUT VAR_STRING DeviceConfig;
} NDIS_TAPI_GET_DEV_CONFIG, *PNDIS_TAPI_GET_DEV_CONFIG;
typedef struct _VAR_STRING
{
ULONG ulTotalSize;
ULONG ulNeededSize;
ULONG ulUsedSize;
ULONG ulStringFormat;
ULONG ulStringSize;
ULONG ulStringOffset;
} VAR_STRING, *PVAR_STRING;
Return Values:
NDIS_STATUS_SUCCESS
NDIS_STATUS_TAPI_INVALDEVICECLASS
NDIS_STATUS_TAPI_NODRIVER
---------------------------------------------------------------------------*/
{
DBG_FUNC("HtTapiGetDevConfig")
/*
// 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",
Request->ulDeviceID,
Request->ulDeviceClassSize,
Request->ulDeviceClassOffset
));
/*
// 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);
}
/*
// Now we need to adjust the variable field to place the requested device
// configuration.
*/
# define SIZEOF_DEVCONFIG sizeof(ULONG)
Request->DeviceConfig.ulNeededSize = sizeof(VAR_STRING) + SIZEOF_DEVCONFIG;
if (Request->DeviceConfig.ulTotalSize >= Request->DeviceConfig.ulNeededSize)
{
Request->DeviceConfig.ulUsedSize = Request->DeviceConfig.ulNeededSize;
Request->DeviceConfig.ulStringFormat = STRINGFORMAT_BINARY;
Request->DeviceConfig.ulStringSize = SIZEOF_DEVCONFIG;
Request->DeviceConfig.ulStringOffset = sizeof(VAR_STRING);
/*
// There are currently no return values defined for this case.
// This is just a place holder for future extensions.
*/
*((ULONG *) ((PCHAR) &Request->DeviceConfig + sizeof(VAR_STRING))) =
0xDEADBEEF;
}
DBG_LEAVE(Adapter);
return (NDIS_STATUS_SUCCESS);
}
NDIS_STATUS
HtTapiSetDevConfig(
IN PHTDSU_ADAPTER Adapter,
IN PNDIS_TAPI_SET_DEV_CONFIG Request
)
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Functional Description:
This request restores the configuration of a device associated one-to-one
with the line device from an 摂 data structure previously obtained using
OID_TAPI_GET_DEV_CONFIG. The contents of this data structure are specific
to the line (miniport) and device class.
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_SET_DEV_CONFIG
{
IN ULONG ulRequestID;
IN ULONG ulDeviceID;
IN ULONG ulDeviceClassSize;
IN ULONG ulDeviceClassOffset;
IN ULONG ulDeviceConfigSize;
IN UCHAR DeviceConfig[1];
} NDIS_TAPI_SET_DEV_CONFIG, *PNDIS_TAPI_SET_DEV_CONFIG;
Return Values:
NDIS_STATUS_SUCCESS
NDIS_STATUS_TAPI_INVALDEVICECLASS
NDIS_STATUS_TAPI_INVALPARAM
NDIS_STATUS_TAPI_NODRIVER
---------------------------------------------------------------------------*/
{
DBG_FUNC("HtTapiSetDevConfig")
/*
// 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=%d\n"
"ulDeviceConfigSize=%d\n",
Request->ulDeviceID,
Request->ulDeviceClassSize,
Request->ulDeviceClassOffset,
Request->ulDeviceConfigSize
));
/*
// 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);
}
/*
// Make sure this configuration is the proper size.
*/
if (Request->ulDeviceConfigSize != SIZEOF_DEVCONFIG)
{
DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INVALPARAM\n"));
return (NDIS_STATUS_TAPI_INVALPARAM);
}
/*
// Retore the configuration information returned by HtTapiGetDevConfig.
//
// There are currently no configuration values defined this case.
// This is just a place holder for future extensions.
*/
if (*((ULONG *) ((PCHAR) Request->DeviceConfig)) != 0xDEADBEEF)
{
DBG_WARNING(Adapter, ("Returning NDIS_STATUS_TAPI_INVALPARAM\n"));
return (NDIS_STATUS_TAPI_INVALPARAM);
}
DBG_LEAVE(Adapter);
return (NDIS_STATUS_SUCCESS);
}
NDIS_STATUS
HtTapiConfigDialog(
IN PHTDSU_ADAPTER Adapter,
IN PNDIS_TAPI_CONFIG_DIALOG Request
)
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Functional Description:
This request retrieves the name of a user-mode dynamic link library that
can be loaded and called to configure the specified device. The
configuration DLL shall export the following function by name:
LONG WINAPI
ConfigDialog(
IN HWND hwndOwner,
IN ULONG ulDeviceID,
IN LPCSTR lpszDeviceClass
);
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_CONFIG_DIALOG
{
IN ULONG ulRequestID;
IN ULONG ulDeviceID;
IN ULONG ulDeviceClassSize;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -