Because the feeling of the hand shares part of the feeling that it should belong to the head, it would be better to find something to replace the hand.
_ U32 secure_tcp_syn_cookie (_ u32 saddr, _ u32 daddr, _ 2010sport,
_ 2010dport, _ u32 sseq, _ u32 count, _ u32 data)
{
_ U32 TMP [16 + hash_buffer_size + hash_extra_size];
_ U32 seq;
... // Lazy Initialization
Memcpy (TMP + 3, syncookie_secret [0], sizeof (syncookie_secret [0]);
TMP [0] = saddr;
TMP [1] = daddr;
TMP [2] = (sport <16) + dport;
Hash_transform (TMP + 16, TMP );
SEQ = TMP [17] + sseq + (count <cookiebits); // Add the SYN serial number to the digest value calculated based on 4 elements, and add the current jiffies to the high 8 bit, SEQ is set to S, sseq is set to SS
Memcpy (TMP + 3, syncookie_secret [1], sizeof (syncookie_secret [1]);
TMP [0] = saddr;
TMP [1] = daddr;
TMP [2] = (sport <16) + dport;
TMP [3] = count;
Hash_transform (TMP + 16, TMP); // calculate another TMP [17]
Return seq + (TMP [17] + Data) & cookiemask); // calculate the final syn-cookie without affecting the 8-bit height and set it to K
}
_ U32 check_tcp_syn_cookie (_ u32 cookie, _ u32 saddr, _ u32 daddr, _ 2010sport,
_ 2010dport, _ u32 sseq, _ u32 count, _ u32 maxdiff)
{
_ U32 TMP [16 + hash_buffer_size + hash_extra_size];
_ U32 diff;
... // And lazy Initialization
Memcpy (TMP + 3, syncookie_secret [0], sizeof (syncookie_secret [0]);
TMP [0] = saddr;
TMP [1] = daddr;
TMP [2] = (sport <16) + dport;
Hash_transform (TMP + 16, TMP );
Cookie-= TMP [17] + sseq; // cookie is K, which is the digest calculated by the SS and 4 elements.
Diff = (count-(cookie> cookiebits) & (_ u32)-1> cookiebits );
If (diff> = maxdiff) // obtain the time when the SYN packet arrives from the top 8 bits. If it takes too long for ACK to arrive, it is regarded as an abnormal phenomenon and discarded.
Return (_ u32)-1;
Memcpy (TMP + 3, syncookie_secret [1], sizeof (syncookie_secret [1]);
TMP [0] = saddr;
TMP [1] = daddr;
TMP [2] = (sport <16) + dport;
TMP [3] = count-diff; get the jiffies of the original SYN Packet
Hash_transform (TMP + 16, TMP );
Return (cookie-TMP [17]) & cookiemask; // finally get the data
}