From patchwork Thu Jun 30 08:41:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 932302 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5U8iwpq003795 for ; Thu, 30 Jun 2011 08:44:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758858Ab1F3Ioz (ORCPT ); Thu, 30 Jun 2011 04:44:55 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:44108 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758793Ab1F3Iox (ORCPT ); Thu, 30 Jun 2011 04:44:53 -0400 Received: by mail-iy0-f174.google.com with SMTP id 12so1722680iyb.19 for ; Thu, 30 Jun 2011 01:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=i+/b+1NApyUxP6AXMjfjzopwyZrnePFR3EdZFW/vnj4=; b=K2yqduXj1U3wq3+ycnTVotVUhnLn52PZGXLUD8Z4NR1TAeEiDTg2EzdcnqlDSC56ej WQhw8sitXhR9Y8C5VrDvUUVe7rRZ6Il6ZeXrfmbdaqp7dPBC0qDpOsaViSE4PIIIp2Bo U/lxocI3ywknORGiBnwAKhRew9e1Bfv38l+J4= Received: by 10.42.142.194 with SMTP id t2mr1856431icu.393.1309423493657; Thu, 30 Jun 2011 01:44:53 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id d6sm1967338icx.1.2011.06.30.01.44.49 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 30 Jun 2011 01:44:53 -0700 (PDT) From: Asias He To: Pekka Enberg Cc: Cyrill Gorcunov , Ingo Molnar , Sasha Levin , Prasad Joshi , kvm@vger.kernel.org, Asias He Subject: [PATCH v2 15/31] kvm tools: Add helpers to return TCP {header, total, payload} length Date: Thu, 30 Jun 2011 16:41:03 +0800 Message-Id: <1309423279-3093-16-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1309423279-3093-1-git-send-email-asias.hejun@gmail.com> References: <1309423279-3093-1-git-send-email-asias.hejun@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 30 Jun 2011 08:44:58 +0000 (UTC) This patch adds three helpers uip_tcp_hdrlen(), uip_tcp_len(), uip_tcp_payloadlen() to return TCP header length, TCP totoal length, and tcp payload length. Signed-off-by: Asias He --- tools/kvm/include/kvm/uip.h | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/tools/kvm/include/kvm/uip.h b/tools/kvm/include/kvm/uip.h index a772fdf..2ac48d7 100644 --- a/tools/kvm/include/kvm/uip.h +++ b/tools/kvm/include/kvm/uip.h @@ -203,6 +203,25 @@ static inline u16 uip_udp_len(struct uip_udp *udp) return ntohs(udp->len); } +static inline u16 uip_tcp_hdrlen(struct uip_tcp *tcp) +{ + return (tcp->off >> 4) * 4; +} + +static inline u16 uip_tcp_len(struct uip_tcp *tcp) +{ + struct uip_ip *ip; + + ip = &tcp->ip; + + return uip_ip_len(ip) - uip_ip_hdrlen(ip); +} + +static inline u16 uip_tcp_payloadlen(struct uip_tcp *tcp) +{ + return uip_tcp_len(tcp) - uip_tcp_hdrlen(tcp); +} + static inline u16 uip_eth_hdrlen(struct uip_eth *eth) { return sizeof(*eth);