Function

mbuf_outbound_finalize

Declaration

void mbuf_outbound_finalize(mbuf_t mbuf, u_int32_t protocol_family, size_t protocol_offset);

Parameters

mbuf

The mbuf that should be finalized.

protocol_family

The protocol family of the packet in the mbuf.

protocol_offset

The offset from the start of the mbuf to the protocol header. For an IP packet with an ethernet header, this would be the length of an ethernet header.

Discussion

This function will "finalize" the packet allowing your code to inspect the final packet.

There are a number of operations that are performed in hardware, such as calculating checksums. This function will perform in software the various opterations that were scheduled to be done in hardware. Future operations may include IPSec processing or vlan support. If you are redirecting a packet to a new interface which may not have the same hardware support or encapsulating the packet, you should call this function to force the stack to calculate and fill out the checksums. This will bypass hardware checksums but give you a complete packet to work with. If you need to inspect aspects of the packet which may be generated by hardware, you must call this function to get an aproximate final packet. If you plan to modify the packet in any way, you should call this function.

This function should be called before modifying any outbound packets.

This function may be called at various levels, in some cases additional headers may have already been prepended, such as the case of a packet seen by an interface filter. To handle this, the caller must pass the protocol family of the packet as well as the offset from the start of the packet to the protocol header.