From patchwork Sun Feb 14 06:05:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Allen Simpson X-Patchwork-Id: 45281 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 16D96B7CB6 for ; Sun, 14 Feb 2010 17:06:17 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752210Ab0BNGFx (ORCPT ); Sun, 14 Feb 2010 01:05:53 -0500 Received: from mail-iw0-f201.google.com ([209.85.223.201]:47141 "EHLO mail-iw0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751621Ab0BNGFw (ORCPT ); Sun, 14 Feb 2010 01:05:52 -0500 Received: by iwn39 with SMTP id 39so1257881iwn.1 for ; Sat, 13 Feb 2010 22:05:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type; bh=z4d41wkW0+9zH5RR7XPyWznTyOMQCQJLQo4bJ/vJfFU=; b=UsG0LWOIHlfTRPxL5WwZyX4ZmfIvxTWUXzhsqIs6t6j530Mg9eEbUw6HIU76mDHzmQ qD221s9vS9rraFFDt/rKS041CzESVLB7K7P5KxQr9hOMjSVUgvgAK17GoklrQgO819In e+cjiXW0QZg4GV+FJzuC3FwzdQvfV3ExwumFQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; b=ioLuGcWpxOU/ppxdjNhuJE8OtINB67SMc3WSkj4bSC4tnYiU0720P+VYTm5wmmJhu5 SCo6wSDVUqU3LALOuwRzkgRlFaGTcPOt4Bk+5Cf6NfVld0pW2A/uVUHjH9NxPvAl+gUf vIzZwo7Gl5iQMkzKKjYEpfxev9VjXYG3ZBMlc= Received: by 10.231.156.205 with SMTP id y13mr1799381ibw.27.1266127551317; Sat, 13 Feb 2010 22:05:51 -0800 (PST) Received: from Wastrel.local (c-68-40-195-221.hsd1.mi.comcast.net [68.40.195.221]) by mx.google.com with ESMTPS id 21sm4827758iwn.10.2010.02.13.22.05.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 13 Feb 2010 22:05:49 -0800 (PST) Message-ID: <4B7792BC.8090704@gmail.com> Date: Sun, 14 Feb 2010 01:05:48 -0500 From: William Allen Simpson User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Linux Kernel Developers , Linux Kernel Network Developers CC: Andrew Morton , David Miller Subject: [PATCH v3 1/7] net: tcp_header_len_th and tcp_option_len_th References: <4B7791CF.9030201@gmail.com> In-Reply-To: <4B7791CF.9030201@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Redefine two TCP header functions to accept TCP header pointer. When subtracting, return signed int to allow error checking. These functions will be used in subsequent patches that implement additional features. Signed-off-by: William.Allen.Simpson@gmail.com --- include/linux/tcp.h | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 7fee8a4..d0133cf 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -223,6 +223,18 @@ static inline unsigned int tcp_optlen(const struct sk_buff *skb) return (tcp_hdr(skb)->doff - 5) * 4; } +/* Length of fixed header plus standard options. */ +static inline unsigned int tcp_header_len_th(const struct tcphdr *th) +{ + return th->doff * 4; +} + +/* Length of standard options only. This could be negative. */ +static inline int tcp_option_len_th(const struct tcphdr *th) +{ + return (int)(th->doff * 4) - sizeof(*th); +} + /* This defines a selective acknowledgement block. */ struct tcp_sack_block_wire { __be32 start_seq;