NDIS_SET_ORIGINAL_PACKET (Windows Embedded CE 6.0)
This macro sets the information in a given packet descriptor to the information from a packet descriptor that was originally indicated up by a lower-level driver.
PNDIS_PACKET NDIS_SET_ORIGINAL_PACKET( PNDIS_PACKET _P, PNDIS_PACKET _OP );
If intermediate drivers are present in a layered stack of NDIS drivers, those intermediate drivers must repackage packets that they receive before indicating the packets up to the next layer. In this situation, intermediate drivers should call NDIS_SET_ORIGINAL_PACKET to set the contents of a new packet from a packet that was indicated up by a lower-level driver. To retrieve a packet that was received from a lower-level driver, drivers call the NdisGetReceivedPacket function. To obtain a pointer to the original packet that was indicated up by the lowest-level driver in the layered stack, drivers call the NDIS_GET_ORIGINAL_PACKET macro and pass the pointer to the received packet. Using this method of retrieving and repackaging, each driver in the layered stack can access the OOB data block that is associated with packets that are received from the network without requiring that packets be copied to each layer.
Before calling NDIS_SET_ORIGINAL_PACKET, intermediate drivers must allocate a packet descriptor and map this packet descriptor's chain of buffer descriptors to the original packet descriptor's chain of buffer descriptors. Intermediate drivers should always allocate their packet descriptors from packet pools that the drivers set up during initialization.
The NDIS_SET_ORIGINAL_PACKET macro is defined as followed.
#define NDIS_SET_ORIGINAL_PACKET(_P, _OP) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, OriginalPacketInfo) = _OP
The following example code retrieves a packet that was received from the driver below, obtains the original packet from OldPkt, and then sets MyPkt with the original-packet contents.
// Get the original packet, which could be the received packet // or the packet originating from the lowest-level driver. // This result is based on the number of layered drivers in the stack. // Then, set the result on the packet that will be indicated to the // next level so the OOB data block is accessible. // OldPkt = NdisGetReceivedPacket(BindingHandle, MacReceiveContext); NdisDprAllocatePacket(&Status, &MyPkt, RecvPacketPoolHandle); MyPkt->Private.Head = OldPkt->Private.Head; MyPkt->Private.Tail = OldPkt->Private.Tail; NDIS_SET_ORIGINAL_PACKET(MyPkt, NDIS_GET_ORIGINAL_PACKET(OldPkt));