TCPIP_UDP_PACKET_HANDLER Type

C

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

Returns

true - if the packet is processed by the external handler. In this case the UDP module will no longer process the packet false - the packet needs to be processed internally by the UDP as usual

Description

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

Remarks

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

  • the rxPkt->pktFlags has the bit 9 (value 0x0200) set for an IPv6 packet, cleared for IPv4

  • the rxPkt->pTransportLayer points to an UDP_HEADER data structure.

  • the rxPkt->pNetLayer points to an IPV4_HEADER/IPV6_HEADER data structure.

  • the rxPkt->pktIf points to the interface receiving the packet

  • the first data segment segLen is adjusted to store the size of the UDP data 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.

Preconditions

None

Parameters

ParametersDescription
hNetnetwork handle on which the packet has arrived
rxPktpointer to incoming packet
hParamuser passed parameter when handler was registered