TCPIP_IPV6_PACKET_HANDLER Type

C

typedef bool (* TCPIP_IPV6_PACKET_HANDLER)(TCPIP_NET_HANDLE hNet, struct _tag_TCPIP_MAC_PACKET* rxPkt, const void* hParam);

Desscription

IPv6 packet handler pointer.

Pointer to a function that will be called by the IPv6 module when a RX packet is available.

Preconditions

None.

Parameters

ParametersDescription
hNetNetwork handle on which the packet has arrived.
rxPktPointer to incoming packet.
hParamUser passed parameter when handler was registered.

Returns

  • True - if the packet is processed by the external handler. In this case the IPv6 module will no longer process the packet.

  • False - The packet needs to be processed internally by the IPv6 as usual.

Remarks

The packet handler is called in the IPv6 context. The handler should be kept as short as possible as it affects the processing of all the other IPv6 RX traffic.

Before calling the external packet handler:

  • The rxPkt->pktIf is updated.

  • The rxPkt->pNetLayer points to an IPV6_HEADER data structure.

IMPORTANT: When the packet handler returns true, once it's done processing the packet, it needs to acknowledge it, i.e. return to the owner, which is the MAC driver serving the network interface. This means that the packet acknowledge function needs to be called, with a proper acknowledge parameter and the QUEUED flag needs to be cleared, if needed:

if((*rxPkt->ackFunc)(rxPkt, rxPkt->ackParam)) { rxPkt->pktFlags &= ~TCPIP_MAC_PKT_FLAG_QUEUED; } 

Failure to do that will result in memory leaks and starvation of the MAC driver. See the tcpip_mac.h for details.