Contents

replaceOrCopyPacket

A helper method that combines the functionality of copyPacket() and replacePacket() to process a packet containing a received frame.

Declaration

virtual mbuf_t replaceOrCopyPacket(
 mbuf_t *mp, 
 UInt32length, 
 bool *replaced);

Parameters

  • mp:

    A handle to the existing packet that may be replaced.

  • length:

    The number of bytes received held in the packet. Must be greater than zero.

  • replaced:

    Pointer to a return value that is set to true to indicate that the existing packet was replaced, or false to indicate that the existing packet was not replaced, and a copy was created.

Return Value

Returns a replacement or a copy of the existing packet, or 0 if packet allocation failed.

Overview

This method will either make a copy or replace the existing packet, whichever is more time efficient. Packets containing small frames are copied, otherwise they are replaced. If replaced, then the existing packet is returned, and a new packet with the same buffer size is created to take its place. If copied, the existing packet is left intact, while a copy is returned that will hold a copy of the data from the source packet.

See Also

Miscellaneous