From 926caee7295597c28bc0b8c6294f94e1d85b78a3 Mon Sep 17 00:00:00 2001 From: Asias He Date: Wed, 29 Jun 2011 16:47:23 +0800 Subject: [PATCH] kvm tools: Add helper to allocate and get TCP initial sequence number Guest's initial sequence number can be found in the SYN package that guest send to us to intialize a TCP session. Remote server's initial sequence number is faked. RFC 793 specifies that the ISN should be viewed as a 32-bit counter that increments by one every 4 microseconds. For simplicity's sake, current implementation in uip just returns a constant. Signed-off-by: Asias He Signed-off-by: Pekka Enberg --- tools/kvm/include/kvm/uip.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/kvm/include/kvm/uip.h b/tools/kvm/include/kvm/uip.h index 558568062dcb..46cec2096d1a 100644 --- a/tools/kvm/include/kvm/uip.h +++ b/tools/kvm/include/kvm/uip.h @@ -244,6 +244,19 @@ static inline bool uip_tcp_is_fin(struct uip_tcp *tcp) return (tcp->flg & UIP_TCP_FLAG_FIN) != 0; } +static inline u32 uip_tcp_isn(struct uip_tcp *tcp) +{ + return ntohl(tcp->seq); +} + +static inline u32 uip_tcp_isn_alloc(void) +{ + /* + * FIXME: should increase every 4ms + */ + return 10000000; +} + static inline u16 uip_eth_hdrlen(struct uip_eth *eth) { return sizeof(*eth); -- 2.39.5