本文整理汇总了C++中NdisAcquireSpinLock函数的典型用法代码示例。如果您正苦于以下问题:C++ NdisAcquireSpinLock函数的具体用法?C++ NdisAcquireSpinLock怎么用?C++ NdisAcquireSpinLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NdisAcquireSpinLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OvsExtAttach
/*
* --------------------------------------------------------------------------
* Implements filter driver's FilterAttach function.
*
* This function allocates the switch context, and initializes its necessary
* members.
* --------------------------------------------------------------------------
*/
NDIS_STATUS
OvsExtAttach(NDIS_HANDLE ndisFilterHandle,
NDIS_HANDLE filterDriverContext,
PNDIS_FILTER_ATTACH_PARAMETERS attachParameters)
{
NDIS_STATUS status = NDIS_STATUS_FAILURE;
NDIS_FILTER_ATTRIBUTES ovsExtAttributes;
POVS_SWITCH_CONTEXT switchContext = NULL;
UNREFERENCED_PARAMETER(filterDriverContext);
OVS_LOG_TRACE("Enter: ndisFilterHandle %p", ndisFilterHandle);
ASSERT(filterDriverContext == (NDIS_HANDLE)gOvsExtDriverObject);
if (attachParameters->MiniportMediaType != NdisMedium802_3) {
status = NDIS_STATUS_INVALID_PARAMETER;
goto cleanup;
}
if (gOvsExtDriverHandle == NULL) {
OVS_LOG_TRACE("Exit: OVSEXT driver is not loaded.");
ASSERT(FALSE);
goto cleanup;
}
NdisAcquireSpinLock(gOvsCtrlLock);
if (gOvsSwitchContext) {
NdisReleaseSpinLock(gOvsCtrlLock);
OVS_LOG_TRACE("Exit: Failed to create OVS Switch, only one datapath is"
"supported, %p.", gOvsSwitchContext);
goto cleanup;
}
if (gOvsInAttach) {
NdisReleaseSpinLock(gOvsCtrlLock);
/* Just fail the request. */
OVS_LOG_TRACE("Exit: Failed to create OVS Switch, since another attach"
"instance is in attach process.");
goto cleanup;
}
gOvsInAttach = TRUE;
NdisReleaseSpinLock(gOvsCtrlLock);
status = OvsInitIpHelper(ndisFilterHandle);
if (status != STATUS_SUCCESS) {
OVS_LOG_ERROR("Exit: Failed to initialize IP helper.");
goto cleanup;
}
status = OvsCreateSwitch(ndisFilterHandle, &switchContext);
if (status != NDIS_STATUS_SUCCESS) {
OvsCleanupIpHelper();
goto cleanup;
}
ASSERT(switchContext);
/*
* Register the switch context with NDIS so NDIS can pass it back to the
* Filterxxx callback functions as the 'FilterModuleContext' parameter.
*/
RtlZeroMemory(&ovsExtAttributes, sizeof(NDIS_FILTER_ATTRIBUTES));
ovsExtAttributes.Header.Revision = NDIS_FILTER_ATTRIBUTES_REVISION_1;
ovsExtAttributes.Header.Size = sizeof(NDIS_FILTER_ATTRIBUTES);
ovsExtAttributes.Header.Type = NDIS_OBJECT_TYPE_FILTER_ATTRIBUTES;
ovsExtAttributes.Flags = 0;
NDIS_DECLARE_FILTER_MODULE_CONTEXT(OVS_SWITCH_CONTEXT);
status = NdisFSetAttributes(ndisFilterHandle, switchContext, &ovsExtAttributes);
if (status != NDIS_STATUS_SUCCESS) {
OVS_LOG_ERROR("Failed to set attributes.");
OvsCleanupIpHelper();
goto cleanup;
}
/* Setup the state machine. */
switchContext->controlFlowState = OvsSwitchAttached;
switchContext->dataFlowState = OvsSwitchPaused;
gOvsSwitchContext = switchContext;
KeMemoryBarrier();
cleanup:
gOvsInAttach = FALSE;
if (status != NDIS_STATUS_SUCCESS) {
if (switchContext != NULL) {
OvsDeleteSwitch(switchContext);
}
}
OVS_LOG_TRACE("Exit: status %x", status);
return status;
}
示例2: divert_filter_send
int divert_filter_send(PADAPT pAdapt, PNDIS_PACKET Packet, int in)
{
#define HDR_SIZE 54
int len, cnt;
PNDIS_BUFFER buf;
char crap[HDR_SIZE];
int rc = 0, rd;
struct ether_header *pEthHdr; // See ../B2Winet/ethernet.h
struct ip *pIPHeader;
struct tcphdr *tcp;
struct divert_packet *dp;
int off = 0; // 14;
NDISPROT_ETH_HEADER UNALIGNED *pEthHeader;
NdisAcquireSpinLock(&pAdapt->Lock);
NdisQueryPacket(Packet, NULL, &cnt, &buf, &len);
if (len < HDR_SIZE)
goto Out;
FltReadOnPacket(Packet, crap, HDR_SIZE, 0, &rd);
if (rd < HDR_SIZE)
goto Out;
pEthHdr = (struct ether_header*) crap;
pEthHeader = pEthHdr;
if (ntohs( pEthHdr->ether_type ) != ETHERTYPE_IP)
goto Out;
if (in && get_pa(pEthHeader->SrcAddr))
goto Out;
pIPHeader = (struct ip * ) (pEthHdr + 1);
if (pIPHeader->ip_p != IPPROTO_TCP)
goto Out;
tcp = (struct tcphr*) (pIPHeader + 1);
#if 0
if (ntohs(tcp->th_dport) == 666)
rc = 1;
#endif
lock();
if (!_open)
goto Fuck;
dp = get_packet();
if (!dp) {
DbgPrint("divert_packet() - outta space dude\n");
goto Fuck;
}
dp->dp_len = len - off;
FltReadOnPacket(Packet, dp->dp_packet, dp->dp_len, off, &rd);
// rd = dp->dp_len;
if (rd != dp->dp_len)
goto Fuck;
dp->dp_flags = 1;
kick_pending();
rc = 1;
Fuck:
unlock();
Out:
NdisReleaseSpinLock(&pAdapt->Lock);
return rc;
#undef HDR_SIZE
}
示例3: RTUSBCancelPendingBulkOutIRP
//.........这里部分代码省略.........
VOID RTUSBCancelPendingBulkOutIRP(
IN PRTMP_ADAPTER pAd)
{
PHT_TX_CONTEXT pHTTXContext;
PTX_CONTEXT pMLMEContext;
PTX_CONTEXT pBeaconContext;
PTX_CONTEXT pNullContext;
PTX_CONTEXT pPsPollContext;
PTX_CONTEXT pRTSContext;
UINT i, Idx;
// unsigned int IrqFlags;
// NDIS_SPIN_LOCK *pLock;
// BOOLEAN *pPending;
// pLock = &pAd->BulkOutLock[MGMTPIPEIDX];
// pPending = &pAd->BulkOutPending[MGMTPIPEIDX];
for (Idx = 0; Idx < 4; Idx++)
{
pHTTXContext = &(pAd->TxContext[Idx]);
if (pHTTXContext->IRPPending == TRUE)
{
// Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself
// remove it from the HeadPendingSendList and NULL out HeadPendingSendList
// when the last IRP on the list has been cancelled; that's how we exit this loop
//
RTUSB_UNLINK_URB(pHTTXContext->pUrb);
// Sleep 200 microseconds to give cancellation time to work
RTMPusecDelay(200);
}
pAd->BulkOutPending[Idx] = FALSE;
}
//RTMP_IRQ_LOCK(pLock, IrqFlags);
for (i = 0; i < MGMT_RING_SIZE; i++)
{
pMLMEContext = (PTX_CONTEXT)pAd->MgmtRing.Cell[i].AllocVa;
if(pMLMEContext && (pMLMEContext->IRPPending == TRUE))
{
// Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself
// remove it from the HeadPendingSendList and NULL out HeadPendingSendList
// when the last IRP on the list has been cancelled; that's how we exit this loop
//
RTUSB_UNLINK_URB(pMLMEContext->pUrb);
pMLMEContext->IRPPending = FALSE;
// Sleep 200 microsecs to give cancellation time to work
RTMPusecDelay(200);
}
}
pAd->BulkOutPending[MGMTPIPEIDX] = FALSE;
//RTMP_IRQ_UNLOCK(pLock, IrqFlags);
for (i = 0; i < BEACON_RING_SIZE; i++)
{
pBeaconContext = &(pAd->BeaconContext[i]);
if(pBeaconContext->IRPPending == TRUE)
{
// Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself
// remove it from the HeadPendingSendList and NULL out HeadPendingSendList
// when the last IRP on the list has been cancelled; that's how we exit this loop
//
RTUSB_UNLINK_URB(pBeaconContext->pUrb);
// Sleep 200 microsecs to give cancellation time to work
RTMPusecDelay(200);
}
}
pNullContext = &(pAd->NullContext);
if (pNullContext->IRPPending == TRUE)
RTUSB_UNLINK_URB(pNullContext->pUrb);
pRTSContext = &(pAd->RTSContext);
if (pRTSContext->IRPPending == TRUE)
RTUSB_UNLINK_URB(pRTSContext->pUrb);
pPsPollContext = &(pAd->PsPollContext);
if (pPsPollContext->IRPPending == TRUE)
RTUSB_UNLINK_URB(pPsPollContext->pUrb);
for (Idx = 0; Idx < 4; Idx++)
{
NdisAcquireSpinLock(&pAd->BulkOutLock[Idx]);
pAd->BulkOutPending[Idx] = FALSE;
NdisReleaseSpinLock(&pAd->BulkOutLock[Idx]);
}
}
示例4: NdisAcquireSpinLock
REPEATER_CLIENT_ENTRY *RTMPLookupRepeaterCliEntry(
IN PVOID pData,
IN BOOLEAN bRealMAC,
IN PUCHAR pAddr,
IN BOOLEAN bIsPad,
OUT PUCHAR pIsLinkValid)
{
ULONG HashIdx;
UCHAR tempMAC[6];
REPEATER_CLIENT_ENTRY *pEntry = NULL;
REPEATER_CLIENT_ENTRY_MAP *pMapEntry = NULL;
if (bIsPad == TRUE) {
NdisAcquireSpinLock(&((PRTMP_ADAPTER)pData)->ApCfg.ReptCliEntryLock);
} else {
NdisAcquireSpinLock(((REPEATER_ADAPTER_DATA_TABLE *)pData)->EntryLock);
}
COPY_MAC_ADDR(tempMAC, pAddr);
HashIdx = MAC_ADDR_HASH_INDEX(tempMAC);
*pIsLinkValid = TRUE;
if (bRealMAC == TRUE)
{
if (bIsPad == TRUE) {
pMapEntry = ((PRTMP_ADAPTER)pData)->ApCfg.ReptMapHash[HashIdx];
} else
pMapEntry = *((((REPEATER_ADAPTER_DATA_TABLE *)pData)->MapHash) + HashIdx) ;
while (pMapEntry)
{
pEntry = pMapEntry->pReptCliEntry;
if (MAC_ADDR_EQUAL(pEntry->OriginalAddress, tempMAC))
{
if (pEntry->CliValid == FALSE) {
*pIsLinkValid = FALSE;
pEntry = NULL;
}
break;
}
else
{
pEntry = NULL;
pMapEntry = pMapEntry->pNext;
}
}
}
else
{
if (bIsPad == TRUE) {
pEntry = ((PRTMP_ADAPTER)pData)->ApCfg.ReptCliHash[HashIdx];
} else {
pEntry = *((((REPEATER_ADAPTER_DATA_TABLE *)pData)->CliHash) + HashIdx) ;
}
while (pEntry)
{
if (MAC_ADDR_EQUAL(pEntry->CurrentAddress, tempMAC))
{
if (pEntry->CliValid == FALSE) {
*pIsLinkValid = FALSE;
pEntry = NULL;
}
break;
}
else
pEntry = pEntry->pNext;
}
}
if (bIsPad == TRUE) {
NdisReleaseSpinLock(&((PRTMP_ADAPTER)pData)->ApCfg.ReptCliEntryLock);
} else {
NdisReleaseSpinLock(((REPEATER_ADAPTER_DATA_TABLE *)pData)->EntryLock);
}
return pEntry;
}
示例5: CMDHandler
VOID CMDHandler(
IN PRTMP_ADAPTER pAd)
{
PCmdQElmt cmdqelmt;
PUCHAR pData;
NDIS_STATUS NdisStatus = NDIS_STATUS_SUCCESS;
// ULONG Now = 0;
NTSTATUS ntStatus;
// unsigned long IrqFlags;
while (pAd && pAd->CmdQ.size > 0)
{
NdisStatus = NDIS_STATUS_SUCCESS;
NdisAcquireSpinLock(&pAd->CmdQLock);
RTThreadDequeueCmd(&pAd->CmdQ, &cmdqelmt);
NdisReleaseSpinLock(&pAd->CmdQLock);
if (cmdqelmt == NULL)
break;
pData = cmdqelmt->buffer;
if(!(RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST) || RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)))
{
switch (cmdqelmt->command)
{
case CMDTHREAD_CHECK_GPIO:
{
#ifdef CONFIG_STA_SUPPORT
UINT32 data;
#endif // CONFIG_STA_SUPPORT //
#ifdef RALINK_ATE
if(ATE_ON(pAd))
{
ATEDBGPRINT(RT_DEBUG_TRACE, ("The driver is in ATE mode now\n"));
break;
}
#endif // RALINK_ATE //
#ifdef CONFIG_STA_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
{
// Read GPIO pin2 as Hardware controlled radio state
RTUSBReadMACRegister( pAd, GPIO_CTRL_CFG, &data);
if (data & 0x04)
{
pAd->StaCfg.bHwRadio = TRUE;
}
else
{
pAd->StaCfg.bHwRadio = FALSE;
}
if(pAd->StaCfg.bRadio != (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio))
{
pAd->StaCfg.bRadio = (pAd->StaCfg.bHwRadio && pAd->StaCfg.bSwRadio);
if(pAd->StaCfg.bRadio == TRUE)
{
DBGPRINT_RAW(RT_DEBUG_ERROR, ("!!! Radio On !!!\n"));
MlmeRadioOn(pAd);
// Update extra information
pAd->ExtraInfo = EXTRA_INFO_CLEAR;
}
else
{
DBGPRINT_RAW(RT_DEBUG_ERROR, ("!!! Radio Off !!!\n"));
MlmeRadioOff(pAd);
// Update extra information
pAd->ExtraInfo = HW_RADIO_OFF;
}
}
}
#endif // CONFIG_STA_SUPPORT //
}
break;
#ifdef CONFIG_STA_SUPPORT
case CMDTHREAD_QKERIODIC_EXECUT:
{
StaQuickResponeForRateUpExec(NULL, pAd, NULL, NULL);
}
break;
#endif // CONFIG_STA_SUPPORT //
case CMDTHREAD_RESET_BULK_OUT:
{
UINT32 MACValue;
UCHAR Index;
int ret=0;
PHT_TX_CONTEXT pHTTXContext;
// RTMP_TX_RING *pTxRing;
unsigned long IrqFlags;
//.........这里部分代码省略.........
示例6: RTUSBCancelPendingBulkOutIRP
/*
========================================================================
Routine Description:
Arguments:
Return Value:
Note:
========================================================================
*/
VOID RTUSBCancelPendingBulkOutIRP(
IN PRTMP_ADAPTER pAd)
{
PHT_TX_CONTEXT pHTTXContext;
PTX_CONTEXT pMLMEContext;
PTX_CONTEXT pNullContext;
PTX_CONTEXT pPsPollContext;
UINT i, Idx;
/* unsigned int IrqFlags;*/
/* NDIS_SPIN_LOCK *pLock;*/
/* BOOLEAN *pPending;*/
/* pLock = &pAd->BulkOutLock[MGMTPIPEIDX];*/
/* pPending = &pAd->BulkOutPending[MGMTPIPEIDX];*/
for (Idx = 0; Idx < 4; Idx++)
{
pHTTXContext = &(pAd->TxContext[Idx]);
if (pHTTXContext->IRPPending == TRUE)
{
/* Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself*/
/* remove it from the HeadPendingSendList and NULL out HeadPendingSendList*/
/* when the last IRP on the list has been cancelled; that's how we exit this loop*/
RTUSB_UNLINK_URB(pHTTXContext->pUrb);
/* Sleep 200 microseconds to give cancellation time to work*/
RTMPusecDelay(200);
}
#ifdef RALINK_ATE
pHTTXContext->bCopySavePad = 0;
pHTTXContext->CurWritePosition = 0;
pHTTXContext->CurWriteRealPos = 0;
pHTTXContext->bCurWriting = FALSE;
pHTTXContext->NextBulkOutPosition = 0;
pHTTXContext->ENextBulkOutPosition = 0;
#endif /* RALINK_ATE */
pAd->BulkOutPending[Idx] = FALSE;
}
/*RTMP_IRQ_LOCK(pLock, IrqFlags);*/
for (i = 0; i < MGMT_RING_SIZE; i++)
{
pMLMEContext = (PTX_CONTEXT)pAd->MgmtRing.Cell[i].AllocVa;
if(pMLMEContext && (pMLMEContext->IRPPending == TRUE))
{
/* Get the USB_CONTEXT and cancel it's IRP; the completion routine will itself*/
/* remove it from the HeadPendingSendList and NULL out HeadPendingSendList*/
/* when the last IRP on the list has been cancelled; that's how we exit this loop*/
RTUSB_UNLINK_URB(pMLMEContext->pUrb);
pMLMEContext->IRPPending = FALSE;
/* Sleep 200 microsecs to give cancellation time to work*/
RTMPusecDelay(200);
}
}
pAd->BulkOutPending[MGMTPIPEIDX] = FALSE;
/*RTMP_IRQ_UNLOCK(pLock, IrqFlags);*/
pNullContext = &(pAd->NullContext);
if (pNullContext->IRPPending == TRUE)
RTUSB_UNLINK_URB(pNullContext->pUrb);
pPsPollContext = &(pAd->PsPollContext);
if (pPsPollContext->IRPPending == TRUE)
RTUSB_UNLINK_URB(pPsPollContext->pUrb);
for (Idx = 0; Idx < 4; Idx++)
{
NdisAcquireSpinLock(&pAd->BulkOutLock[Idx]);
pAd->BulkOutPending[Idx] = FALSE;
NdisReleaseSpinLock(&pAd->BulkOutLock[Idx]);
}
}
开发者ID:3a1fa340-312c-11e6-8775-0016d322cfd3,项目名称:4b204d7c-312f-11e6-bd79-0016d322cfd3,代码行数:95,代码来源:rtusb_bulk.c
示例7: ssh_interceptor_iodevice_dispatch_ioctl
NTSTATUS
ssh_interceptor_iodevice_dispatch_ioctl(PDEVICE_OBJECT device,
PIRP irp)
{
#ifdef HAS_IOCTL_HANDLERS
PIO_STACK_LOCATION io_stack = IoGetCurrentIrpStackLocation(irp);
ULONG ioctl_code = io_stack->Parameters.DeviceIoControl.IoControlCode;
SshInterceptorIoDevice io_dev = SSH_NTDEV_TO_SSHDEV(device);
SshIoDeviceIoctlHandler handler = NULL;
PLIST_ENTRY entry;
NdisAcquireSpinLock(&io_dev->ioctl_handler_list_lock);
entry = io_dev->ioctl_handler_list.Flink;
while (entry != &io_dev->ioctl_handler_list)
{
SshIoDeviceIoctlHandler h;
h = CONTAINING_RECORD(entry, SshIoDeviceIoctlHandlerStruct, link);
if (h->ioctl_code == ioctl_code)
{
handler = h;
InterlockedIncrement(&handler->ref_count);
break;
}
entry = entry->Flink;
}
NdisReleaseSpinLock(&io_dev->ioctl_handler_list_lock);
if (handler != NULL)
{
SshIoDeviceIoctlRequest ioctl;
ioctl = ssh_calloc(1, sizeof(*ioctl));
if (ioctl == NULL)
{
irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
irp->IoStatus.Information = 0;
IoCompleteRequest(irp, IO_NO_INCREMENT);
return STATUS_UNSUCCESSFUL;
}
/* Initialize te IOCTL request */
ioctl->public_data.device = io_dev;
ioctl->public_data.ioctl_code = ioctl_code;
ioctl->public_data.context = handler;
ioctl->public_data.cancel_id = ioctl;
ioctl->public_data.input_buf_len =
io_stack->Parameters.DeviceIoControl.InputBufferLength;
ioctl->public_data.output_buf_len =
io_stack->Parameters.DeviceIoControl.OutputBufferLength;
switch (ioctl_code & 0x00000003)
{
case METHOD_BUFFERED:
ioctl->public_data.input_buf = irp->AssociatedIrp.SystemBuffer;
ioctl->public_data.output_buf = irp->AssociatedIrp.SystemBuffer;
break;
case METHOD_NEITHER:
ioctl->public_data.input_buf =
io_stack->Parameters.DeviceIoControl.Type3InputBuffer;
ioctl->public_data.output_buf = irp->UserBuffer;
break;
case METHOD_IN_DIRECT:
case METHOD_OUT_DIRECT:
default:
SSH_NOTREACHED;
break;
}
ioctl->public_data.bytes_read = 0;
ioctl->public_data.bytes_written = 0;
ioctl->private_data.irp = irp;
NdisAcquireSpinLock(&io_dev->ioctl_req_list_lock);
InsertTailList(&io_dev->active_ioctl_req_list,
&ioctl->private_data.link);
NdisReleaseSpinLock(&io_dev->ioctl_req_list_lock);
irp->IoStatus.Status = STATUS_PENDING;
IoMarkIrpPending(irp);
#pragma warning(disable: 4311 4312)
IoSetCancelRoutine(irp, ssh_interceptor_iodevice_cancel_queued_ioctl);
#pragma warning(default: 4311 4312)
(*(handler->ioctl_handler))(handler->context, &ioctl->public_data);
return STATUS_PENDING;
}
#endif /* HAS_IOCTL_HANDLERS */
//.........这里部分代码省略.........
示例8: ssh_interceptor_iodevice_do_reads
static void
ssh_interceptor_iodevice_do_reads(SshInterceptorIoDevice io_dev)
{
SshDeviceBuffer buffer;
PIO_STACK_LOCATION irp_stack = NULL;
char *dest = NULL;
char *base_addr = NULL;
PIRP irp = NULL;
NdisAcquireSpinLock(&io_dev->output_queue_lock);
buffer = io_dev->current_read_buf;
NdisReleaseSpinLock(&io_dev->output_queue_lock);
/* Complete as many queued output buffers and pending reads as possible */
while (TRUE)
{
PLIST_ENTRY entry;
unsigned bytes_copied;
/* Try to find some data to write */
if (buffer == NULL)
{
NdisAcquireSpinLock(&io_dev->output_queue_lock);
if (!IsListEmpty(&io_dev->output_queue))
{
entry = RemoveHeadList(&io_dev->output_queue);
buffer = CONTAINING_RECORD(entry, SshDeviceBufferStruct, link);
/* If this is an unreliable message, it must also be removed
from the unreliable_output_queue! */
if (buffer->reliable == 0)
RemoveEntryList(&buffer->unreliable_list_link);
}
io_dev->current_read_buf = buffer;
NdisReleaseSpinLock(&io_dev->output_queue_lock);
/* Exit the loop if no data was available in output queue */
if (buffer == NULL)
goto complete;
}
/* Try to find queued read IRP */
if (irp == NULL)
{
entry = NdisInterlockedRemoveHeadList(&io_dev->read_queue,
&io_dev->read_queue_lock);
if (entry)
{
irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.ListEntry);
irp_stack = IoGetCurrentIrpStackLocation(irp);
/* There is no need to check for canceled status, because
cancelation is protected by the same lock as the queue
itself. We may actually pop off an IRP for which cancel
has already been issued, but we can complete it as usual. */
#pragma warning(disable: 4311 4312)
IoSetCancelRoutine(irp, NULL);
#pragma warning(default: 4311 4312)
irp->IoStatus.Information = 0;
irp->IoStatus.Status = STATUS_SUCCESS;
base_addr = ssh_iodevice_map_buffer(irp->MdlAddress);
if (base_addr == NULL)
{
/* Mapping of user-mode buffer could fail if the system is
very low on resources. */
IoCompleteRequest(irp, IO_NETWORK_INCREMENT);
irp = NULL;
continue;
}
dest = base_addr;
}
else
{
/* No read IRPs available, exit the loop */
goto complete;
}
}
/* We copy either the whole buffer or part of it if there isn't enough
space left in the currently processed read IRP. */
bytes_copied = buffer->len;
if (irp->IoStatus.Information + bytes_copied >
irp_stack->Parameters.Read.Length)
{
bytes_copied = irp_stack->Parameters.Read.Length -
(unsigned int)irp->IoStatus.Information;
}
NdisMoveMemory(dest, buffer->addr + buffer->offset, bytes_copied);
buffer->offset += bytes_copied;
buffer->len -= bytes_copied;
if (buffer->len == 0)
{
NdisAcquireSpinLock(&io_dev->output_queue_lock);
io_dev->current_read_buf = NULL;
NdisReleaseSpinLock(&io_dev->output_queue_lock);
ssh_iodevice_buffer_free(io_dev, buffer);
//.........这里部分代码省略.........
示例9: ElnkStagedAllocation
VOID
ElnkStagedAllocation(
IN PELNK_ADAPTER Adapter
)
/*++
Routine Description:
This routine attempts to take a packet through a stage of allocation.
Arguments:
Adapter - The adapter that the packets are coming through.
Return Value:
None.
--*/
{
UINT CbIndex;
PNDIS_PACKET FirstPacket = Adapter->FirstStagePacket;
if ELNKDEBUG DPrint1("StagedAllocation\n");
//
// For each stage, we check to see that it is open,
// that somebody else isn't already processing,
// and that there is some work from the previous
// stage to do.
//
ASSERT (Adapter->StageOpen &&
!Adapter->AlreadyProcessingStage &&
Adapter->FirstStagePacket);
//
// If we successfully acquire a command block, this
// is the index to it.
//
Adapter->AlreadyProcessingStage = TRUE;
//
// We look to see if there is an available Command Block.
// If there isn't then stage 2 will close.
//
IF_LOG('p');
if (ElnkAcquireCommandBlock(
Adapter,
&CbIndex
)) {
IF_LOG('a');
//
// Remove from queue
//
Adapter->FirstStagePacket = PELNK_RESERVED_FROM_PACKET(FirstPacket)->Next;
if (!Adapter->FirstStagePacket) {
Adapter->LastStagePacket = NULL;
}
NdisReleaseSpinLock(&Adapter->Lock);
//
// We have a command block. Assign all packet
// buffers to the command block.
//
ElnkAssignPacketToCommandBlock(
Adapter,
FirstPacket,
CbIndex
);
//
// We need exclusive access to the Command Queue so
// that we can move this packet on to the next stage.
//
NdisAcquireSpinLock(&Adapter->Lock);
ElnkPutPacketOnFinishTrans(
Adapter,
FirstPacket
);
ElnkSubmitCommandBlock(
Adapter,
CbIndex
);
//.........这里部分代码省略.........
示例10: ElnkSend
NDIS_STATUS
ElnkSend(
IN NDIS_HANDLE MacBindingHandle,
IN PNDIS_PACKET Packet
)
/*++
Routine Description:
The ElnkSend request instructs a MAC to transmit a packet through
the adapter onto the medium.
Arguments:
MacBindingHandle - The context value returned by the MAC when the
adapter was opened. In reality, it is a pointer to ELNK_OPEN.
Packet - A pointer to a descriptor for the packet that is to be
transmitted.
Return Value:
The function value is the status of the operation.
--*/
{
//
// Holds the status that should be returned to the caller.
//
NDIS_STATUS StatusToReturn = NDIS_STATUS_PENDING;
//
// Pointer to the adapter.
//
PELNK_ADAPTER Adapter;
if ELNKDEBUG DPrint2("ElnkSend Packet = %x\n",Packet);
Adapter = PELNK_ADAPTER_FROM_BINDING_HANDLE(MacBindingHandle);
NdisAcquireSpinLock(&Adapter->Lock);
Adapter->References++;
if (!Adapter->ResetInProgress) {
PELNK_OPEN Open;
Open = PELNK_OPEN_FROM_BINDING_HANDLE(MacBindingHandle);
if (!Open->BindingShuttingDown) {
UINT TotalPacketSize;
//
// Increment the references on the open while we are
// accessing it in the interface.
//
Open->References++;
NdisReleaseSpinLock(&Adapter->Lock);
//
// It is reasonable to do a quick check and fail if the packet
// is larger than the maximum an ethernet can handle.
//
NdisQueryPacket(
Packet,
NULL,
NULL,
NULL,
&TotalPacketSize
);
NdisAcquireSpinLock(&Adapter->Lock);
if ((!TotalPacketSize) ||
(TotalPacketSize > MAXIMUM_ETHERNET_PACKET_SIZE)) {
Open->References--;
StatusToReturn = NDIS_STATUS_RESOURCES;
} else {
PELNK_RESERVED Reserved = PELNK_RESERVED_FROM_PACKET(Packet);
PNDIS_BUFFER FirstBuffer;
PUCHAR BufferVA;
UINT Length;
//
// Set Reserved->Loopback.
//
NdisQueryPacket(Packet, NULL, NULL, &FirstBuffer, NULL);
//
// Get VA of first buffer
//
NdisQueryBuffer(
//.........这里部分代码省略.........
示例11: PtDeregisterDevice
NDIS_STATUS
PtDeregisterDevice(
VOID
)
/*++
Routine Description:
Deregister the ioctl interface. This is called whenever a miniport
instance is halted. When the last miniport instance is halted, we
request NDIS to delete the device object
Arguments:
NdisDeviceHandle - Handle returned by NdisMRegisterDevice
Return Value:
NDIS_STATUS_SUCCESS if everything worked ok
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
DBGPRINT(("==>PassthruDeregisterDevice\n"));
NdisAcquireSpinLock(&GlobalLock);
ASSERT(MiniportCount > 0);
--MiniportCount;
if (0 == MiniportCount)
{
//
// All miniport instances have been halted. Deregister
// the control device.
//
ASSERT(ControlDeviceState == PS_DEVICE_STATE_READY);
//
// Block PtRegisterDevice() while we release the control
// device lock and deregister the device.
//
ControlDeviceState = PS_DEVICE_STATE_DELETING;
NdisReleaseSpinLock(&GlobalLock);
if (NdisDeviceHandle != NULL)
{
Status = NdisMDeregisterDevice(NdisDeviceHandle);
NdisDeviceHandle = NULL;
}
NdisAcquireSpinLock(&GlobalLock);
ControlDeviceState = PS_DEVICE_STATE_READY;
}
NdisReleaseSpinLock(&GlobalLock);
DBGPRINT(("<== PassthruDeregisterDevice: %x\n", Status));
return Status;
}
示例12: PtRegisterDevice
NDIS_STATUS
PtRegisterDevice(
VOID
)
/*++
Routine Description:
Register an ioctl interface - a device object to be used for this
purpose is created by NDIS when we call NdisMRegisterDevice.
This routine is called whenever a new miniport instance is
initialized. However, we only create one global device object,
when the first miniport instance is initialized. This routine
handles potential race conditions with PtDeregisterDevice via
the ControlDeviceState and MiniportCount variables.
NOTE: do not call this from DriverEntry; it will prevent the driver
from being unloaded (e.g. on uninstall).
Arguments:
None
Return Value:
NDIS_STATUS_SUCCESS if we successfully register a device object.
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
UNICODE_STRING DeviceName;
UNICODE_STRING DeviceLinkUnicodeString;
PDRIVER_DISPATCH DispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1];
DBGPRINT(("==>PtRegisterDevice\n"));
NdisAcquireSpinLock(&GlobalLock);
++MiniportCount;
if (1 == MiniportCount)
{
ASSERT(ControlDeviceState != PS_DEVICE_STATE_CREATING);
//
// Another thread could be running PtDeregisterDevice on
// behalf of another miniport instance. If so, wait for
// it to exit.
//
while (ControlDeviceState != PS_DEVICE_STATE_READY)
{
NdisReleaseSpinLock(&GlobalLock);
NdisMSleep(1);
NdisAcquireSpinLock(&GlobalLock);
}
ControlDeviceState = PS_DEVICE_STATE_CREATING;
NdisReleaseSpinLock(&GlobalLock);
NdisZeroMemory(DispatchTable, (IRP_MJ_MAXIMUM_FUNCTION+1) * sizeof(PDRIVER_DISPATCH));
DispatchTable[IRP_MJ_CREATE] = NdisProtOpen;
DispatchTable[IRP_MJ_CLEANUP] = NdisProtCleanup;
DispatchTable[IRP_MJ_CLOSE] = NdisProtClose;
// DispatchTable[IRP_MJ_READ] = NdisProtRead;
DispatchTable[IRP_MJ_READ] = divert_read;
// DispatchTable[IRP_MJ_WRITE] = PtDispatch;
DispatchTable[IRP_MJ_WRITE] = divert_write;
// DispatchTable[IRP_MJ_DEVICE_CONTROL] = NdisProtIoControl;
DispatchTable[IRP_MJ_DEVICE_CONTROL] = PtDispatch;
NdisInitUnicodeString(&DeviceName, NTDEVICE_STRING);
NdisInitUnicodeString(&DeviceLinkUnicodeString, LINKNAME_STRING);
//
// Create a device object and register our dispatch handlers
//
Status = NdisMRegisterDevice(
NdisWrapperHandle,
&DeviceName,
&DeviceLinkUnicodeString,
&DispatchTable[0],
&ControlDeviceObject,
&NdisDeviceHandle
);
ControlDeviceObject->Flags |= DO_DIRECT_IO;
NdisAcquireSpinLock(&GlobalLock);
ControlDeviceState = PS_DEVICE_STATE_READY;
}
NdisReleaseSpinLock(&GlobalLock);
//.........这里部分代码省略.........
示例13: NdisAcquireSpinLock
MAC_TABLE_ENTRY *MacTableInsertEntry(
IN RTMP_ADAPTER *pAd,
IN UCHAR *pAddr,
IN struct wifi_dev *wdev,
IN UINT32 ent_type,
IN UCHAR OpMode,
IN BOOLEAN CleanAll)
{
UCHAR HashIdx;
int i, FirstWcid;
MAC_TABLE_ENTRY *pEntry = NULL, *pCurrEntry;
if (pAd->MacTab.Size >= MAX_LEN_OF_MAC_TABLE)
return NULL;
FirstWcid = 1;
/* allocate one MAC entry*/
NdisAcquireSpinLock(&pAd->MacTabLock);
for (i = FirstWcid; i< MAX_LEN_OF_MAC_TABLE; i++) /* skip entry#0 so that "entry index == AID" for fast lookup*/
{
/* pick up the first available vacancy*/
if (IS_ENTRY_NONE(&pAd->MacTab.Content[i]))
{
pEntry = &pAd->MacTab.Content[i];
mac_entry_reset(pAd, pEntry, CleanAll);
/* ENTRY PREEMPTION: initialize the entry */
pEntry->wdev = wdev;
pEntry->wcid = i;
pEntry->func_tb_idx = wdev->func_idx;
pEntry->bIAmBadAtheros = FALSE;
pEntry->pAd = pAd;
pEntry->CMTimerRunning = FALSE;
COPY_MAC_ADDR(pEntry->Addr, pAddr);
pEntry->Sst = SST_NOT_AUTH;
pEntry->AuthState = AS_NOT_AUTH;
pEntry->Aid = (USHORT)i;
pEntry->CapabilityInfo = 0;
pEntry->AssocDeadLine = MAC_TABLE_ASSOC_TIMEOUT;
pEntry->PsMode = PWR_ACTIVE;
pEntry->NoDataIdleCount = 0;
pEntry->ContinueTxFailCnt = 0;
#ifdef WDS_SUPPORT
pEntry->LockEntryTx = FALSE;
#endif /* WDS_SUPPORT */
pEntry->TimeStamp_toTxRing = 0;
// TODO: shiang-usw, remove upper setting becasue we need to migrate to tr_entry!
pAd->MacTab.tr_entry[i].PsMode = PWR_ACTIVE;
pAd->MacTab.tr_entry[i].NoDataIdleCount = 0;
pAd->MacTab.tr_entry[i].ContinueTxFailCnt = 0;
pAd->MacTab.tr_entry[i].LockEntryTx = FALSE;
pAd->MacTab.tr_entry[i].TimeStamp_toTxRing = 0;
pAd->MacTab.tr_entry[i].PsDeQWaitCnt = 0;
pEntry->EnqueueEapolStartTimerRunning = EAPOL_START_DISABLE;
pEntry->GTKState = REKEY_NEGOTIATING;
pEntry->PairwiseKey.KeyLen = 0;
pEntry->PairwiseKey.CipherAlg = CIPHER_NONE;
pEntry->PMKID_CacheIdx = ENTRY_NOT_FOUND;
pEntry->RSNIE_Len = 0;
NdisZeroMemory(pEntry->R_Counter, sizeof(pEntry->R_Counter));
pEntry->ReTryCounter = PEER_MSG1_RETRY_TIMER_CTR;
do
{
#ifdef CONFIG_AP_SUPPORT
#ifdef APCLI_SUPPORT
if (ent_type == ENTRY_APCLI)
{
SET_ENTRY_APCLI(pEntry);
//SET_ENTRY_AP(pEntry);//Carter, why set entry to APCLI then set to AP????
COPY_MAC_ADDR(pEntry->bssid, pAddr);
pEntry->AuthMode = pAd->ApCfg.ApCliTab[pEntry->func_tb_idx].wdev.AuthMode;
pEntry->WepStatus = pAd->ApCfg.ApCliTab[pEntry->func_tb_idx].wdev.WepStatus;
if (pEntry->AuthMode < Ndis802_11AuthModeWPA)
{
pEntry->WpaState = AS_NOTUSE;
pEntry->PrivacyFilter = Ndis802_11PrivFilterAcceptAll;
}
else
{
pEntry->WpaState = AS_PTKSTART;
pEntry->PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
}
break;
}
#endif /* APCLI_SUPPORT */
#ifdef WDS_SUPPORT
if (ent_type == ENTRY_WDS)
{
SET_ENTRY_WDS(pEntry);
COPY_MAC_ADDR(pEntry->bssid, pAd->ApCfg.MBSSID[MAIN_MBSSID].wdev.bssid);
pEntry->AuthMode = Ndis802_11AuthModeOpen;
pEntry->WepStatus = Ndis802_11EncryptionDisabled;
//.........这里部分代码省略.........
示例14: RTUSBWatchDog
//.........这里部分代码省略.........
RTMP_IRQ_LOCK(&pAd->BulkOutLock[idx], irqFlags);
if ((pAd->BulkOutPending[idx] == TRUE) && pAd->watchDogTxPendingCnt)
{
pAd->watchDogTxPendingCnt[idx]++;
if ((pAd->watchDogTxPendingCnt[idx] > 2) &&
(!RTMP_TEST_FLAG(pAd, (fRTMP_ADAPTER_RESET_IN_PROGRESS | fRTMP_ADAPTER_HALT_IN_PROGRESS | fRTMP_ADAPTER_NIC_NOT_EXIST | fRTMP_ADAPTER_BULKOUT_RESET)))
)
{
// FIXME: Following code just support single bulk out. If you wanna support multiple bulk out. Modify it!
pHTTXContext = (PHT_TX_CONTEXT)(&pAd->TxContext[idx]);
if (pHTTXContext->IRPPending)
{ // Check TxContext.
pUrb = pHTTXContext->pUrb;
}
else if (idx == MGMTPIPEIDX)
{
PTX_CONTEXT pMLMEContext, pNULLContext, pPsPollContext;
//Check MgmtContext.
pMLMEContext = (PTX_CONTEXT)(pAd->MgmtRing.Cell[pAd->MgmtRing.TxDmaIdx].AllocVa);
pPsPollContext = (PTX_CONTEXT)(&pAd->PsPollContext);
pNULLContext = (PTX_CONTEXT)(&pAd->NullContext);
if (pMLMEContext->IRPPending)
{
ASSERT(pMLMEContext->IRPPending);
pUrb = pMLMEContext->pUrb;
}
else if (pNULLContext->IRPPending)
{
ASSERT(pNULLContext->IRPPending);
pUrb = pNULLContext->pUrb;
}
else if (pPsPollContext->IRPPending)
{
ASSERT(pPsPollContext->IRPPending);
pUrb = pPsPollContext->pUrb;
}
}
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
DBGPRINT(RT_DEBUG_TRACE, ("Maybe the Tx Bulk-Out hanged! Cancel the pending Tx bulks request of idx(%d)!\n", idx));
if (pUrb)
{
DBGPRINT(RT_DEBUG_TRACE, ("Unlink the pending URB!\n"));
// unlink it now
RTUSB_UNLINK_URB(pUrb);
// Sleep 200 microseconds to give cancellation time to work
RTMPusecDelay(200);
needDumpSeq = TRUE;
}
else
{
DBGPRINT(RT_DEBUG_ERROR, ("Unkonw bulkOut URB maybe hanged!!!!!!!!!!!!\n"));
}
}
else
{
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
}
}
else
{
RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags);
}
}
#ifdef DOT11_N_SUPPORT
// For Sigma debug, dump the ba_reordering sequence.
if((needDumpSeq == TRUE) && (pAd->CommonCfg.bDisableReordering == 0))
{
USHORT Idx;
PBA_REC_ENTRY pBAEntry = NULL;
UCHAR count = 0;
struct reordering_mpdu *mpdu_blk;
Idx = pAd->MacTab.Content[BSSID_WCID].BARecWcidArray[0];
pBAEntry = &pAd->BATable.BARecEntry[Idx];
if((pBAEntry->list.qlen > 0) && (pBAEntry->list.next != NULL))
{
DBGPRINT(RT_DEBUG_TRACE, ("NICUpdateRawCounters():The Queueing pkt in reordering buffer:\n"));
NdisAcquireSpinLock(&pBAEntry->RxReRingLock);
mpdu_blk = pBAEntry->list.next;
while (mpdu_blk)
{
DBGPRINT(RT_DEBUG_TRACE, ("\t%d:Seq-%d, bAMSDU-%d!\n", count, mpdu_blk->Sequence, mpdu_blk->bAMSDU));
mpdu_blk = mpdu_blk->next;
count++;
}
DBGPRINT(RT_DEBUG_TRACE, ("\npBAEntry->LastIndSeq=%d!\n", pBAEntry->LastIndSeq));
NdisReleaseSpinLock(&pBAEntry->RxReRingLock);
}
}
#endif // DOT11_N_SUPPORT //
}
示例15: ssh_interceptor_iodevice_create_device
Boolean __fastcall
ssh_interceptor_iodevice_create_device(SshInterceptorIoDevice io_dev)
{
SshInterceptor interceptor;
PDRIVER_OBJECT driver;
PSECURITY_DESCRIPTOR new_sd;
PDRIVER_DISPATCH *fn_table;
NTSTATUS st;
#ifndef SSH_IM_INTERCEPTOR
PDEVICE_OBJECT device;
#else
PDRIVER_DISPATCH major_function[IRP_MJ_MAXIMUM_FUNCTION + 1];
#endif /* SSH_IM_INTERCEPTOR */
SSH_ASSERT(io_dev != NULL);
SSH_ASSERT(io_dev->interceptor != NULL);
interceptor = io_dev->interceptor;
SSH_ASSERT(interceptor->driver_object != NULL);
driver = interceptor->driver_object;
NdisAcquireSpinLock(&io_dev->output_queue_lock);
if (io_dev->destroy_after_close)
{
SSH_DEBUG(SSH_D_NICETOKNOW, ("Clearing delayed destroy flag..."));
io_dev->destroy_after_close = FALSE;
}
NdisReleaseSpinLock(&io_dev->output_queue_lock);
if (InterlockedCompareExchange(&io_dev->io_device_created, 1, 0) != 0)
{
SSH_DEBUG(SSH_D_HIGHSTART,
("I/O device already exists; ignoring this call"));
return TRUE;
}
SSH_DEBUG(SSH_D_HIGHSTART, ("Creating I/O device and symbolic link..."));
#ifndef SSH_IM_INTERCEPTOR
#pragma warning(disable : 28175)
fn_table = driver->MajorFunction;
#pragma warning(default : 28175)
#else
memset(&major_function, 0, sizeof(major_function));
fn_table = major_function;
#endif /* SSH_IM_INTERCEPTOR */
/* Create the I/O device and symbolic link and limit the access permissions
of the I/O device. */
/* Initialize dispatch function table */
fn_table[IRP_MJ_CREATE] = ssh_interceptor_iodevice_dispatch_create;
fn_table[IRP_MJ_CLOSE] = ssh_interceptor_iodevice_dispatch_close;
fn_table[IRP_MJ_CLEANUP] = ssh_interceptor_iodevice_dispatch_cleanup;
fn_table[IRP_MJ_READ] = ssh_interceptor_iodevice_dispatch_read;
fn_table[IRP_MJ_WRITE] = ssh_interceptor_iodevice_dispatch_write;
fn_table[IRP_MJ_DEVICE_CONTROL] = ssh_interceptor_iodevice_dispatch_ioctl;
#ifdef SSH_IM_INTERCEPTOR
/* Try to register our I/O device with NDIS */
st = NdisMRegisterDevice(io_dev->interceptor->wrapper_handle,
&io_dev->device_name,
&io_dev->symlink_name,
fn_table,
&io_dev->device,
&io_dev->handle);
if (!NT_SUCCESS(st))
{
SSH_DEBUG(SSH_D_FAIL, ("NdisMRegisterDevice() failed - %08x", st));
return FALSE;
}
#else /* not SSH_IM_INTERCEPTOR */
st = IoCreateDevice(driver, sizeof(void *),
&io_dev->device_name,
FILE_DEVICE_NETWORK, 0,
(BOOLEAN)io_dev->exclusive_access,
&device);
if (!NT_SUCCESS(st))
{
SSH_DEBUG(SSH_D_FAIL, ("IoCreateDevice() failed - %08x", st));
return FALSE;
}
io_dev->device = device;
*((SshInterceptorIoDevice *)device->DeviceExtension) = io_dev;
#endif /* not SSH_IM_INTERCEPTOR */
io_dev->device->AlignmentRequirement = FILE_QUAD_ALIGNMENT;
io_dev->device->Flags |= DO_DIRECT_IO;
/* Remove world access to newly created device object */
#pragma warning(disable : 28175)
if (ssh_access_permissions_limit(io_dev->device->SecurityDescriptor,
&new_sd) != FALSE)
{
io_dev->orig_sd = io_dev->device->SecurityDescriptor;
io_dev->device->SecurityDescriptor = new_sd;
}
else
{
SSH_DEBUG(SSH_D_FAIL, ("ssh_access_permissions_limit() failed!"));
}
//.........这里部分代码省略.........