📄 ndistapi.c
字号:
{
//
// Note that the driver set pMac->hCall upon reception of the
// LINE_NEWCALL indication.
//
DEBUGMSG(ZONE_TRACE, (TEXT("NdisTapiLineAnswer: hdCall=%x\n"), pMac->hCall));
pTapiAnswer->hdCall = pMac->hCall;
pTapiAnswer->ulUserUserInfoSize = ulUserUserInfoSize;
memcpy(&pTapiAnswer->UserUserInfo[0], pUserUserInfo, ulUserUserInfoSize);
pppUnLock(pMac->session);
PppNdisIssueRequest(&Status,
pMac->pAdapter,
NdisRequestSetInformation,
OID_TAPI_ANSWER,
pTapiAnswer,
dwNeededSize,
pMac,
NdisTapiLineAnswerCompleteCallback,
NULL,
NULL);
pppLock(pMac->session);
}
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: -NdisTapiLineAnswer Status=%x\n"), Status));
return Status;
}
void
NdisTapiCallCloseCompleteCallback(
NDIS_REQUEST_BETTER *pRequest,
macCntxt_t *pMac,
NDIS_STATUS Status)
//
// This function is called when the miniport driver completes
// an OID_TAPI_CLOSE_CALL request that returned NDIS_STATUS_PENDING.
//
{
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: +NdisTapiCallCloseCompleteCallback Status=%x\n"), Status));
pMac->bCallClosed = TRUE;
pMac->bCallCloseRequested = FALSE;
// Issue a final request to obtain call statistics
pppMacIssueWanGetStatsInfo(pMac);
if (Status == NDIS_STATUS_SUCCESS)
{
//
// Call has been deallocated, no longer valid
//
(NDIS_HANDLE)pMac->hCall = INVALID_HANDLE_VALUE;
}
//
// Complete pending call closes
//
pppExecuteCompleteCallbacks(&pMac->pPendingCallCloseCompleteList);
// Free the memory allocated for the request.
pppFreeMemory(pRequest->Request.DATA.SET_INFORMATION.InformationBuffer, sizeof(NDIS_TAPI_CLOSE_CALL));
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: -NdisTapiCallCloseCompleteCallback\n")));
}
NDIS_STATUS
NdisTapiCallClose(
macCntxt_t *pMac,
void (*pCallCloseCompleteCallback)(PVOID), OPTIONAL
PVOID pCallbackData)
//
// Issue a request to the miniport to close the line.
//
{
NDIS_TAPI_CLOSE_CALL *pTapiCloseCall;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
NDIS_HANDLE hCall = (NDIS_HANDLE)pMac->hCall;
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: +NdisTapiCallClose\n")));
if (pMac->bCallClosed)
{
// The call is already closed, just invoke the completion handler
if (pCallCloseCompleteCallback)
pCallCloseCompleteCallback(pCallbackData);
}
else
{
if (pMac->bCallCloseRequested)
{
//
// A close request is already pending, No need to issue another call close request
// to the miniport.
//
pppInsertCompleteCallbackRequest(&pMac->pPendingCallCloseCompleteList, pCallCloseCompleteCallback, pCallbackData);
}
else
{
//
// Issue a new call close request
//
Status = NDIS_STATUS_RESOURCES;
pTapiCloseCall = pppAllocateMemory(sizeof(*pTapiCloseCall));
if (pTapiCloseCall)
{
memset ((char *)pTapiCloseCall, 0, sizeof(*pTapiCloseCall));
pTapiCloseCall->hdCall = (ULONG)hCall;
pppInsertCompleteCallbackRequest(&pMac->pPendingCallCloseCompleteList, pCallCloseCompleteCallback, pCallbackData);
pMac->bCallCloseRequested = TRUE;
pppUnLock(pMac->session);
PppNdisIssueRequest(&Status,
pMac->pAdapter,
NdisRequestSetInformation,
OID_TAPI_CLOSE_CALL,
pTapiCloseCall,
sizeof(*pTapiCloseCall),
pMac,
NdisTapiCallCloseCompleteCallback,
pMac,
NULL);
pppLock(pMac->session);
}
}
}
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: -NdisTapiCallClose Status=%x\n"), Status));
return Status;
}
void
NdisTapiCallDropCompleteCallback(
NDIS_REQUEST_BETTER *pRequest,
macCntxt_t *pMac,
NDIS_STATUS Status)
//
// This function is called when the miniport driver completes
// an OID_TAPI_CLOSE request that returned NDIS_STATUS_PENDING.
//
{
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: +NdisTapiCallDropCompleteCallback\n")));
// Note that the call is not dropped until the LINECALLSTATE_IDLE state
// or LINECALLSTATE_DISCONNECTED is indicated. It is at that point when pending CallDrop requests are
// completed.
// Free the memory allocated for the request.
pppFreeMemory(pRequest->Request.DATA.SET_INFORMATION.InformationBuffer, sizeof(NDIS_TAPI_DROP));
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: -NdisTapiCallDropCompleteCallback\n")));
}
NDIS_STATUS
NdisTapiCallDrop(
macCntxt_t *pMac,
void (*pCallDropCompleteCallback)(PVOID), OPTIONAL
PVOID pCallbackData)
//
// Issue a request to the miniport to drop the call
//
{
NDIS_TAPI_DROP *pTapiDrop;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
NDIS_HANDLE hCall = (NDIS_HANDLE)pMac->hCall;
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: +NdisTapiCallDrop\n")));
if (pMac->dwLineCallState == LINECALLSTATE_IDLE
|| pMac->dwLineCallState == LINECALLSTATE_DISCONNECTED
|| pMac->bLineCloseRequested
|| pMac->bLineClosed)
{
// Call already dropped, just call completion handler, if any
if (pCallDropCompleteCallback)
pCallDropCompleteCallback(pCallbackData);
}
else if (pMac->pPendingCallDropCompleteList)
{
//
// A drop request is already pending, just add this to the
// list of pending drops. No need to issue another call drop request
// to the miniport.
//
pppInsertCompleteCallbackRequest(&pMac->pPendingCallDropCompleteList, pCallDropCompleteCallback, pCallbackData);
}
else
{
//
// Issue a call drop request and call the completion handler when the
// line enters LINECALLSTATE_IDLE.
//
pppInsertCompleteCallbackRequest(&pMac->pPendingCallDropCompleteList, pCallDropCompleteCallback, pCallbackData);
Status = NDIS_STATUS_RESOURCES;
pTapiDrop = pppAllocateMemory(sizeof(*pTapiDrop));
if (pTapiDrop)
{
memset ((char *)pTapiDrop, 0, sizeof(*pTapiDrop));
pTapiDrop->hdCall = (ULONG)hCall;
pppUnLock(pMac->session);
PppNdisIssueRequest(&Status,
pMac->pAdapter,
NdisRequestSetInformation,
OID_TAPI_DROP,
pTapiDrop,
sizeof(*pTapiDrop),
pMac,
NdisTapiCallDropCompleteCallback,
pMac,
NULL);
pppLock(pMac->session);
}
}
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: -NdisTapiCallDrop Status=%x\n"), Status));
return Status;
}
typedef struct
{
macCntxt_t *pMac;
void (*pCompleteCallback)(PVOID);
PVOID pCallbackData;
} HangupCompleteInfo_t;
static void
NdisTapiHangupCallDropComplete(
PVOID *pData)
//
// Called when the call is in the IDLE state
//
{
NDIS_STATUS Status;
HangupCompleteInfo_t *pInfo = (HangupCompleteInfo_t *)pData;
Status = NdisTapiCallClose(pInfo->pMac, pInfo->pCompleteCallback, pInfo->pCallbackData);
pppFreeMemory(pInfo, sizeof(*pInfo));
}
NDIS_STATUS
NdisTapiHangup(
macCntxt_t *pMac,
void (*pHangupCompleteCallback)(PVOID),
PVOID pCallbackData)
//
// Drop and deallocate the call.
// After the call is deallocated, call pHangupCompleteCallback.
//
{
NDIS_STATUS Status = NDIS_STATUS_RESOURCES;
HangupCompleteInfo_t *pInfo;
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: +NdisTapiHangup\n")));
pInfo = pppAllocateMemory(sizeof(*pInfo));
if (pInfo)
{
pInfo->pMac = pMac;
pInfo->pCompleteCallback = pHangupCompleteCallback;
pInfo->pCallbackData = pCallbackData;
Status = NdisTapiCallDrop(pMac, NdisTapiHangupCallDropComplete, pInfo);
}
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: -NdisTapiHangup Status=%x\n"), Status));
return Status;
}
void
NdisTapiLineCloseCompleteCallback(
NDIS_REQUEST_BETTER *pRequest,
macCntxt_t *pMac,
NDIS_STATUS Status)
//
// This function is called when the miniport driver completes
// an OID_TAPI_CLOSE request that returned NDIS_STATUS_PENDING.
//
{
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: +NdisTapiLineCloseCompleteCallback\n")));
pMac->bLineClosed = TRUE;
pMac->bLineCloseRequested = FALSE;
//
// It seems that if a lineDrop request is issued shortly
// after a lineMakeCall, TAPI can fail to indicate a LINECALLSTATE_IDLE ever.
// After the line is closed, TAPI will not issue any LINECALLSTATE_xxx indications
// on that line any more, so if a call drop request is still pending we complete it
// now.
//
pppExecuteCompleteCallbacks(&pMac->pPendingCallDropCompleteList);
// Complete any pending close requests
pppExecuteCompleteCallbacks(&pMac->pPendingLineCloseCompleteList);
// Free the memory allocated for the request.
pppFreeMemory(pRequest->Request.DATA.SET_INFORMATION.InformationBuffer, sizeof(NDIS_TAPI_CLOSE));
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: -NdisTapiLineCloseCompleteCallback\n")));
}
void
closeCallBeforeClosingLineCompleteCallback(
macCntxt_t *pMac)
//
// This is called when a CallClose request, implicitly issued due to a LineClose, completes.
// Now that the Call is closed we can proceed to close the line.
//
{
// Note that the line close complete handler was already queued in the prior
// NdisTapiLineClose call.
NdisTapiLineClose(pMac, NULL, NULL);
}
NDIS_STATUS
NdisTapiLineClose(
macCntxt_t *pMac,
void (*pLineCloseCompleteCallback)(PVOID), OPTIONAL
PVOID pCallbackData)
//
// Issue a request to the miniport to close the line.
//
{
NDIS_TAPI_CLOSE *pTapiClose = NULL;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: +NdisTapiLineClose\n")));
//
// Wait for any pending OID_TAPI_OPEN request to complete prior
// to closing.
//
if (pMac->bLineOpenInProgress)
{
pppUnLock(pMac->session);
WaitForSingleObject(pMac->hEventLineOpenComplete, INFINITE);
pppLock(pMac->session);
}
if (pMac->bLineClosed)
{
//
// Line is already closed, just call the completion handler
//
if (pLineCloseCompleteCallback)
pLineCloseCompleteCallback(pCallbackData);
}
else if (pMac->bLineCloseRequested)
{
//
// A close request is already pending, just add this to the
// list of pending closes. No need to issue another line close request
// to the miniport.
//
pppInsertCompleteCallbackRequest(&pMac->pPendingLineCloseCompleteList, pLineCloseCompleteCallback, pCallbackData);
}
else if (!pMac->bCallClosed)
{
//
// Ensure that the call on the line is closed prior to closing the line.
//
pppInsertCompleteCallbackRequest(&pMac->pPendingLineCloseCompleteList, pLineCloseCompleteCallback, pCallbackData);
Status = NdisTapiCallClose(pMac, closeCallBeforeClosingLineCompleteCallback, pMac);
}
else
{
//
// Initiate a new line close request
//
Status = NDIS_STATUS_RESOURCES;
pTapiClose = pppAllocateMemory(sizeof(*pTapiClose));
if (pTapiClose)
{
memset ((char *)pTapiClose, 0, sizeof(*pTapiClose));
pTapiClose->hdLine = (ULONG)pMac->hLine;
(NDIS_HANDLE)pMac->hLine = INVALID_HANDLE_VALUE;
pppInsertCompleteCallbackRequest(&pMac->pPendingLineCloseCompleteList, pLineCloseCompleteCallback, pCallbackData);
pMac->bLineCloseRequested = TRUE;
pppUnLock(pMac->session);
PppNdisIssueRequest(&Status,
pMac->pAdapter,
NdisRequestSetInformation,
OID_TAPI_CLOSE,
pTapiClose,
sizeof(*pTapiClose),
pMac,
NdisTapiLineCloseCompleteCallback,
pMac,
NULL);
pppLock(pMac->session);
}
}
DEBUGMSG(ZONE_FUNCTION, (TEXT("PPP: -NdisTapiLineClose Status=%x\n"), Status));
return Status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -