From patchwork Wed Apr 9 03:01:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weilong Chen X-Patchwork-Id: 28056 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E5E8920553 for ; Wed, 9 Apr 2014 03:02:19 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id oz11sf5550663veb.9 for ; Tue, 08 Apr 2014 20:02:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=ny2AJK+EChTMJyYh0V34rCGs2wWPLjo0vcHy4ATV+NQ=; b=ESJ/VukrGq4HImhmRg0TuJksH3a1IjF3OTrZNNPgoXvc4pZu0EcL3IkvFKD0cc7ewn nUyl2st617fRfOW2KvGMVdl33o/5pkjMFKj6oGLFQ61cymgu7VMV09AXPvilxCYrRk6e OM/zjTd+c5sCKAyFroPFK7VAlBfoRppX9hSDjgADKdtTfx/PS/o+LPVMsEm0E4dCeHGi 0c/EDHw4XPqVOxomGb9WHU879PbwAWMVeLlMS06jYqJlBVFgy+fyoER0q1h1jocwEGTb y04XF9kxgbpf/kr+q+i52vVn8TC5EkG1wxCRikQRXg27FXxOhZumtHIgWQgOV0h5ETIC V3Xw== X-Gm-Message-State: ALoCoQk/BhdU+tzREl0reS7vSFUYfu4vxT+B+E4LbXAqvGik/zbjF9LunkusSTGodGNoMnMHkQ+8 X-Received: by 10.236.121.4 with SMTP id q4mr3370019yhh.34.1397012539199; Tue, 08 Apr 2014 20:02:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.66 with SMTP id e60ls454260qge.51.gmail; Tue, 08 Apr 2014 20:02:19 -0700 (PDT) X-Received: by 10.58.31.136 with SMTP id a8mr6643845vei.20.1397012539084; Tue, 08 Apr 2014 20:02:19 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id bp12si761626veb.81.2014.04.08.20.02.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Apr 2014 20:02:18 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id il7so1607648vcb.32 for ; Tue, 08 Apr 2014 20:02:18 -0700 (PDT) X-Received: by 10.220.59.65 with SMTP id k1mr6099607vch.22.1397012538926; Tue, 08 Apr 2014 20:02:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp294785vcv; Tue, 8 Apr 2014 20:02:18 -0700 (PDT) X-Received: by 10.224.169.5 with SMTP id w5mr90381qay.96.1397012538179; Tue, 08 Apr 2014 20:02:18 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id k4si1796358qci.67.2014.04.08.20.02.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 08 Apr 2014 20:02:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WXijv-0004Pg-RF; Wed, 09 Apr 2014 02:59:51 +0000 Received: from mail-pb0-f47.google.com ([209.85.160.47]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WXijq-0004PL-5a for lng-odp@lists.linaro.org; Wed, 09 Apr 2014 02:59:46 +0000 Received: by mail-pb0-f47.google.com with SMTP id up15so1896870pbc.34 for ; Tue, 08 Apr 2014 20:02:05 -0700 (PDT) X-Received: by 10.66.149.37 with SMTP id tx5mr8793346pab.81.1397012525734; Tue, 08 Apr 2014 20:02:05 -0700 (PDT) Received: from localhost.localdomain ([218.17.215.175]) by mx.google.com with ESMTPSA id xr9sm18619787pab.5.2014.04.08.20.01.59 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Apr 2014 20:02:05 -0700 (PDT) From: Weilong Chen To: lng-odp@lists.linaro.org Date: Wed, 9 Apr 2014 11:01:39 +0800 Message-Id: <1397012499-4089-1-git-send-email-weilong.chen@linaro.org> X-Mailer: git-send-email 1.7.9.5 Subject: [lng-odp] [PATCH] Add helper: odp_icmp.h X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: weilong.chen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Weilong Chen --- include/helper/odp_icmp.h | 98 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 include/helper/odp_icmp.h diff --git a/include/helper/odp_icmp.h b/include/helper/odp_icmp.h new file mode 100644 index 0000000..55d18a2 --- /dev/null +++ b/include/helper/odp_icmp.h @@ -0,0 +1,98 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + + +/** + * @file + * + * ODP ICMP header + */ + +#ifndef ODP_ICMP_H_ +#define ODP_ICMP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/** ICMP header length */ +#define ODP_ICMPHDR_LEN 8 + +/** ICMP header */ +typedef struct ODP_PACKED { + u_int8_t type; /** message type */ + u_int8_t code; /** type sub-code */ + uint16be_t chksum; + union { + struct { + uint16be_t id; + uint16be_t sequence; + } echo; /** echo datagram */ + u_int32_t gateway; /** gateway address */ + struct { + uint16be_t __unused; + uint16be_t mtu; + } frag; /** path mtu discovery */ + } un; +} odp_icmphdr_t; + +#define ICMP_ECHOREPLY 0 /** Echo Reply */ +#define ICMP_DEST_UNREACH 3 /** Destination Unreachable */ +#define ICMP_SOURCE_QUENCH 4 /** Source Quench */ +#define ICMP_REDIRECT 5 /** Redirect (change route) */ +#define ICMP_ECHO 8 /** Echo Request */ +#define ICMP_TIME_EXCEEDED 11 /** Time Exceeded */ +#define ICMP_PARAMETERPROB 12 /** Parameter Problem */ +#define ICMP_TIMESTAMP 13 /** Timestamp Request */ +#define ICMP_TIMESTAMPREPLY 14 /** Timestamp Reply */ +#define ICMP_INFO_REQUEST 15 /** Information Request */ +#define ICMP_INFO_REPLY 16 /** Information Reply */ +#define ICMP_ADDRESS 17 /** Address Mask Request */ +#define ICMP_ADDRESSREPLY 18 /** Address Mask Reply */ +#define NR_ICMP_TYPES 18 + + +/** Codes for UNREACH. */ +#define ICMP_NET_UNREACH 0 /** Network Unreachable */ +#define ICMP_HOST_UNREACH 1 /** Host Unreachable */ +#define ICMP_PROT_UNREACH 2 /** Protocol Unreachable */ +#define ICMP_PORT_UNREACH 3 /** Port Unreachable */ +#define ICMP_FRAG_NEEDED 4 /** Fragmentation Needed/DF set */ +#define ICMP_SR_FAILED 5 /** Source Route failed */ +#define ICMP_NET_UNKNOWN 6 +#define ICMP_HOST_UNKNOWN 7 +#define ICMP_HOST_ISOLATED 8 +#define ICMP_NET_ANO 9 +#define ICMP_HOST_ANO 10 +#define ICMP_NET_UNR_TOS 11 +#define ICMP_HOST_UNR_TOS 12 +#define ICMP_PKT_FILTERED 13 /** Packet filtered */ +#define ICMP_PREC_VIOLATION 14 /** Precedence violation */ +#define ICMP_PREC_CUTOFF 15 /** Precedence cut off */ +#define NR_ICMP_UNREACH 15 /** instead of hardcoding immediate value */ + +/** Codes for REDIRECT. */ +#define ICMP_REDIR_NET 0 /** Redirect Net */ +#define ICMP_REDIR_HOST 1 /** Redirect Host */ +#define ICMP_REDIR_NETTOS 2 /** Redirect Net for TOS */ +#define ICMP_REDIR_HOSTTOS 3 /** Redirect Host for TOS */ + +/** Codes for TIME_EXCEEDED. */ +#define ICMP_EXC_TTL 0 /** TTL count exceeded */ +#define ICMP_EXC_FRAGTIME 1 /** Fragment Reass time exceeded */ + +/** @internal Compile time assert */ +ODP_ASSERT(sizeof(odp_icmphdr_t) == ODP_ICMPHDR_LEN, ODP_ICMPHDR_T__SIZE_ERROR); + +#ifdef __cplusplus +} +#endif + +#endif