From: Asias He Date: Wed, 29 Jun 2011 08:47:23 +0000 (+0800) Subject: kvm tools: Add helper to allocate and get TCP initial sequence number X-Git-Tag: next-20110824~3^2~169 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=926caee7295597c28bc0b8c6294f94e1d85b78a3;p=karo-tx-linux.git 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 --- 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);