A.2.3.4.2 Packets

NDIS 3.0 defines a packet as a chain of one or more buffers that composes a network message. The NIC driver or a transport driver can locate the source and destination start locations for various packet copy operations at any offset in any buffer of the associated packet. The NDIS interface library includes functions that NDIS 3.0 drivers can call to allocate, construct, and inspect packets.

A driver forms a packet descriptor by building a chain of buffer descriptors. NDIS 3.0 (ndis.h) describes a packet descriptor by an NDIS_PACKET structure. The descriptor consists of two parts: a public component that a driver can see and a private component that is invisible to the driver. The public component allows a NIC or transport driver to maintain context information about the packet. A driver can use this component to link packets into data transfer queues.

Table A.2.7 Packet Functions

Function

Definition

NdisAllocatePacket

Allocates and initializes a packet descriptor.

NdisAllocatePacketPool

Allocates and initializes storage for a pool of packet descriptors.

NdisCopyFromPacketToPacket

Copies data between two packets.

NdisFreePacket

Returns a packet descriptor to the packet pool.

NdisFreePacketPool

Terminates use of the packet pool.

NdisQueryPacket

Retrieves information about a packet.

NdisRecalculatePacketCounts

Recalculates packet counts and lengths.

NdisReinitializePacket

Reinitializes a packet descriptor to its initial state.

 

In allocating packets to describe data to send over the network, a transport driver assigns a packet descriptor; allocates and maps a buffer descriptor for each virtually contiguous buffer that contains packet data; chains the buffer descriptors into a packet descriptor; and issues an NdisSend request, passing a pointer to the packet descriptor. The NIC driver can then inspect the packet descriptor and its component buffer descriptors using the packet and buffer functions of the NDIS interface library.

A transport driver also builds a packet descriptor to describe the non-contiguous area into which it wants the NIC driver to copy a packet received from the network. The transport driver can then make a call to NdisTransferData to request the NIC driver to copy data into the area the packet descriptor indicates.