NdisQueryPacket

VOID
    NdisQueryPacket(

        IN PNDIS_PACKET Packet,
        OUT PUINT PhysicalBufferCount  OPTIONAL,
        OUT PUINT BufferCount  OPTIONAL,
        OUT PNDIS_BUFFER *FirstBuffer  OPTIONAL,
        OUT PUINT TotalPacketLength  OPTIONAL
        );

NdisQueryPacket returns information about a given packet.

Parameters

Packet
Points to a packet descriptor.
PhysicalBufferCount
Points to a caller-supplied variable in which this function returns the maximum number of physical breaks mapped by the buffer descriptors chained to the given packet. This parameter can be NULL.
BufferCount
Points to a caller-supplied variable in which this function returns the number of buffer descriptors chained to the given packet. This parameter can be NULL.
FirstBuffer
Points to a caller-supplied variable in which this function returns a pointer to the initial buffer descriptor chained to the given packet. This parameter can be NULL.
TotalPacketLength
Points to a caller-supplied variable in which this function returns the number of bytes of packet data mapped by all chained buffer descriptors. This parameter can be NULL.

Comments

NdisQueryPacket returns caller-selected information about a given packet. The caller must specify at least one of the PhysicalBufferCount, BufferCount, FirstBuffer, and TotalPacketLength pointers, along with the Packet parameter. A caller can specify explicit pointers for all parameters.

Specifying an explicit PhysicalBufferCount pointer is equivalent to summing calls to NdisGetBufferPhysicalArraySize for each buffer descriptor in the packet descriptor. A driver can call NdisGetNextBuffer as many times as necessary to retrieve pointers to any subsequent buffer descriptors in the chain, unless the call returns zero indicating the packet descriptor has no data.

If the caller supplies an explicit BufferCount pointer, NdisQueryPacket returns the number of buffer descriptors in the packet chain. The returned value can be used as a loop counter to retrieve buffer descriptors in the chain with either of the NdisUnchainBufferXxx functions.

If the caller supplies an explicit FirstBuffer pointer but the packet’s buffer chain is empty, NdisQueryPacket returns NULL at FirstBuffer. Otherwise, the caller can use NdisQueryBuffer subsequently to get details about the initial buffer descriptor for the packet. As a faster alternative, drivers can call NdisGetFirstBufferFromPacket to get a pointer to the initial buffer descriptor.

If the caller supplies an explicit TotalPacketLength pointer, NdisQueryPacket returns the total number of bytes specified by every buffer descriptor chained to the given packet.

Callers of NdisQueryPacket can run at any IRQL.

See Also

MiniportSend, MiniportSendPackets, MiniportTransferData, MiniportWanSend, NdisGetBufferPhysicalArraySize, NdisGetFirstBufferFromPacket, NdisGetNextBuffer, NdisQueryBuffer, NdisUnchainBufferAtBack, NdisUnchainBufferAtFront, ProtocolReceive, ProtocolReceivePacket