+ /*
+ * the sequence number is less than the lower bound.
+ */
+ if (seq <= tl)
+ {
+ /*
+ * the packet is within the window upper bound.
+ * check for duplicates.
+ */
+ sa->seq_hi = th;
+ return (sa->replay_window & (1ULL << diff)) ? 1 : 0;
+ }
+ else
+ {
+ /*
+ * the packet is less the window lower bound or greater than
+ * the higher bound, depending on how you look at it...
+ * We're assuming, given that the last sequence number received,
+ * TL < WINDOW_SIZE, that a largeer seq num is more likely to be
+ * a packet that moves the window forward, than a packet that has
+ * wrapped the high sequence again. If it were the latter then
+ * we've lost close to 2^32 packets.
+ */
+ sa->seq_hi = th;
+ return 0;
+ }