From patchwork Thu Jun 30 08:41:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 932312 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 p5U8j6qR009682 for ; Thu, 30 Jun 2011 08:45:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758884Ab1F3IpE (ORCPT ); Thu, 30 Jun 2011 04:45:04 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:59621 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758793Ab1F3IpC (ORCPT ); Thu, 30 Jun 2011 04:45:02 -0400 Received: by mail-iy0-f174.google.com with SMTP id 12so1722525iyb.19 for ; Thu, 30 Jun 2011 01:45:02 -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=0VP3jlU50eV/wmuBzh6EL79OEga7/O+dqPpwM4RLY20=; b=S/kA8GCF0EdbEjJsOvxXGCcscUH2mVNgUlzii30ZiGsLLcfWlz/+JJLjGdSRy0yoUC qJCggo/L3kWYB5oDKyiDeEYZYCuYAHVejCXdpUIRbULMO5tqNBtaYgRoELM/AjPRGBJF YYqFrY12oo2RukEvVp7MwVGGXjT5aalgKkl/8= Received: by 10.42.197.1 with SMTP id ei1mr1945909icb.275.1309423502379; Thu, 30 Jun 2011 01:45:02 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id d6sm1967338icx.1.2011.06.30.01.44.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 30 Jun 2011 01:45:01 -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 17/31] kvm tools: Add helpers to test whether SYN or FIN bit is set. Date: Thu, 30 Jun 2011 16:41:05 +0800 Message-Id: <1309423279-3093-18-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:45:06 +0000 (UTC) This patch adds too helpers uip_tcp_is_syn(), uip_tcp_is_fin() to check if SYN and FIN bit is set. Signed-off-by: Asias He --- tools/kvm/include/kvm/uip.h | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/tools/kvm/include/kvm/uip.h b/tools/kvm/include/kvm/uip.h index a3fd1b0..5585680 100644 --- a/tools/kvm/include/kvm/uip.h +++ b/tools/kvm/include/kvm/uip.h @@ -18,6 +18,13 @@ #define UIP_IP_TTL 0X40 #define UIP_IP_P_UDP 0X11 +#define UIP_TCP_FLAG_FIN 1 +#define UIP_TCP_FLAG_SYN 2 +#define UIP_TCP_FLAG_RST 4 +#define UIP_TCP_FLAG_PSH 8 +#define UIP_TCP_FLAG_ACK 16 +#define UIP_TCP_FLAG_URG 32 + /* * IP package maxium len == 64 KBytes * IP header == 20 Bytes @@ -227,6 +234,16 @@ static inline u8 *uip_tcp_payload(struct uip_tcp *tcp) return (u8 *)&tcp->sport + uip_tcp_hdrlen(tcp); } +static inline bool uip_tcp_is_syn(struct uip_tcp *tcp) +{ + return (tcp->flg & UIP_TCP_FLAG_SYN) != 0; +} + +static inline bool uip_tcp_is_fin(struct uip_tcp *tcp) +{ + return (tcp->flg & UIP_TCP_FLAG_FIN) != 0; +} + static inline u16 uip_eth_hdrlen(struct uip_eth *eth) { return sizeof(*eth);