net: select random sequence number to start

This commit is contained in:
K. Lange 2021-06-19 13:11:43 +09:00
parent 8b6d3784ea
commit 653d6a7035
2 changed files with 4 additions and 2 deletions

View File

@ -564,6 +564,8 @@ static long sock_tcp_recv(sock_t * sock, struct msghdr * msg, int flags) {
return resp;
}
extern uint32_t rand(void);
static long sock_tcp_connect(sock_t * sock, const struct sockaddr *addr, socklen_t addrlen) {
const struct sockaddr_in * dest = (const struct sockaddr_in *)addr;
char deststr[16];
@ -594,7 +596,7 @@ static long sock_tcp_connect(sock_t * sock, const struct sockaddr *addr, socklen
response->source = ((struct EthernetDevice*)nic->device)->ipv4_addr;
response->ttl = 64;
response->protocol = IPV4_PROT_TCP;
sock->priv[2] = 1;
sock->priv[2] = rand();
response->ident = htons(sock->priv[2]);
response->flags_fragment = htons(0x0);
response->version_ihl = 0x45;

View File

@ -13,7 +13,7 @@
#include <kernel/vfs.h>
#include <kernel/string.h>
static uint32_t rand(void) {
uint32_t rand(void) {
static uint32_t x = 123456789;
static uint32_t y = 362436069;
static uint32_t z = 521288629;