/* exact copy of tcp_sequence number function from net/core/secure.c */ __u32 secure_tcp_sequence_number(u32 saddr, u32 daddr, u16 sport, u16 dport) { u32 hash[MD5_DIGEST_WORDS]; hash[0] = saddr; hash[1] = daddr; hash[2] = (sport << 16) + dport; hash[3] = net_secret[15]; md5_transform(hash, net_secret); return seq_scale(hash[0]); }
__u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport) { u32 hash[MD5_DIGEST_WORDS]; hash[0] = (__force u32)saddr; hash[1] = (__force u32)daddr; hash[2] = ((__force u16)sport << 16) + (__force u16)dport; hash[3] = net_secret[15]; md5_transform(hash, net_secret); return seq_scale(hash[0]); }
__u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr, __be16 sport, __be16 dport) { u32 secret[MD5_MESSAGE_BYTES / 4]; u32 hash[MD5_DIGEST_WORDS]; u32 i; memcpy(hash, saddr, 16); for (i = 0; i < 4; i++) secret[i] = net_secret[i] + daddr[i]; secret[4] = net_secret[4] + (((__force u16)sport << 16) + (__force u16)dport); for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++) secret[i] = net_secret[i]; md5_transform(hash, secret); return seq_scale(hash[0]); }