NdisAdjustBufferLength

VOID
   NdisAdjustBufferLength(

       IN PNDIS_BUFFER Buffer,
       IN UINT Length
       );

NdisAdjustBufferLength modifies the length specified in a buffer descriptor allocated or copied by the caller.

Parameters

Buffer

Points to the buffer descriptor, previously allocated with NdisAllocateBuffer or NdisCopyBuffer.

Length

Specifies the new length in bytes to be set in the buffer descriptor.

Comments

The caller of NdisAdjustBufferLength can pass only a buffer descriptor that was allocated by the caller. It cannot pass a buffer descriptor that was allocated by another driver.

For example, the driver of a busmaster DMA NIC calls this function with buffer descriptors that it allocated to specify receive buffers in its shared memory block. Before such a driver indicates received data, it calls NdisAdjustBufferLength to make the buffer descriptor that it will include in the receive indication match the size of the received data if it is less than the size of the NIC’s receive buffer. When a receive packet with such an adjusted buffer descriptor has been consumed and returned to the miniport, the driver again calls NdisAdjustBufferLength to make the buffer descriptor match the actual size of its receive buffer again.

The Length passed to NdisAdjustBufferLength cannot be larger than the Length that was passed to NdisAllocateBuffer or NdisCopyBuffer when the buffer descriptor was allocated.

The caller of NdisAdjustBufferLength must restore the length to its original value before it frees the buffer descriptor with NdisFreeBuffer.

The driver must release any spin lock it is currently holding before calling NdisAdjustBufferLength.

Callers of NdisAdjustBufferLength can run at any IRQL, but usually run at IRQL <= DISPATCH_LEVEL.

See Also

NdisAllocateBuffer, NdisCopyBuffer, NdisFreeBuffer, NdisReleaseSpinLock