+
+ /*
+ * The payload isn't encrypted; remove the
+ * ICV length from the lengths, so our caller
+ * doesn't treat it as payload.
+ */
+ if (*lengthp < MACSEC_DEFAULT_ICV_LEN) {
+ nd_print_trunc(ndo);
+ ndo->ndo_protocol = save_protocol;
+ return hdrlen + caplen;
+ }
+ if (*caplenp < MACSEC_DEFAULT_ICV_LEN) {
+ nd_print_trunc(ndo);
+ ndo->ndo_protocol = save_protocol;
+ return hdrlen + caplen;
+ }
+ *lengthp -= MACSEC_DEFAULT_ICV_LEN;
+ *caplenp -= MACSEC_DEFAULT_ICV_LEN;
+ /*
+ * Update the snapend thus the ICV field is not in the payload for
+ * the caller.
+ * The ICV (Integrity Check Value) is at the end of the frame, after
+ * the secure data.
+ */
+ ndo->ndo_snapend -= MACSEC_DEFAULT_ICV_LEN;
+
+ /*
+ * If the SL field is non-zero, then it's the length of the
+ * Secure Data; otherwise, the Secure Data is what's left
+ * ver after the MACsec header and ICV are removed.
+ */
+ if (short_length != 0) {
+ /*
+ * If the short length is more than we *have*,
+ * that's an error.
+ */
+ if (short_length > *lengthp) {
+ nd_print_trunc(ndo);
+ ndo->ndo_protocol = save_protocol;
+ return hdrlen + caplen;
+ }
+ if (short_length > *caplenp) {
+ nd_print_trunc(ndo);
+ ndo->ndo_protocol = save_protocol;
+ return hdrlen + caplen;
+ }
+ if (*lengthp > short_length)
+ *lengthp = short_length;
+ if (*caplenp > short_length)
+ *caplenp = short_length;
+ }
+
+ ndo->ndo_protocol = save_protocol;
+ return -1;