- gaIPv4_Callbacks[hdr->Protocol]( iface, &hdr->Source, dataLength, data );
+ gaIPv4_Callbacks[hdr->Protocol].rx_cb( iface, &hdr->Source, dataLength, data );
+}
+
+/*
+ * Handles an error from the ICMPv4 code, 'Buf' contains part of an IPv4 packet
+ */
+void IPv4_HandleError(tInterface *Iface, tIPErrorMode Mode, size_t Length, const void *Buf)
+{
+ if(Length < sizeof(tIPv4Header)) return;
+ const tIPv4Header* hdr = Buf;
+ if(hdr->Version != 4) return;
+
+ // Get Data and Data Length
+ size_t dataLength = MIN(Length, ntohs(hdr->TotalLength)) - sizeof(tIPv4Header);
+ const void *data = &hdr->Options[0];
+
+ if( gaIPv4_Callbacks[hdr->Protocol].err_cb )
+ gaIPv4_Callbacks[hdr->Protocol].err_cb(Iface, Mode, &hdr->Source, dataLength, data);