From patchwork Mon Apr 21 09:15:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weilong Chen X-Patchwork-Id: 28668 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 902DB20341 for ; Mon, 21 Apr 2014 09:15:40 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id 29sf12066479yhl.5 for ; Mon, 21 Apr 2014 02:15:40 -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=x41xu3Zg0CgWAomnSddNs2MhenMOtaT5kT3wuHygAQU=; b=cDJ9vbKocFw9hIFHzyh1SOByk5SQxpqeauLwdoTOCJ9AIwlr7DE69IEyJpV4YjhRRg sDhKsiLSJysYV/3ZMdm32zcTXHOInvhcA1DL85Dt9L8752qMKaxtd0ZPiKaruxlnOe4T is9hLeudtyvGHi7dYUw6Qya0AvATNYHBhDgr8clOsbYAmQpJb/nwvMW0WHcKYf82x3aR Dzc6EOELrGJ0q/pI6tKJ7F7FBTDA9IrZ1G19R2MCeP2yAoKt7cWO9eGAHklfP3Y73d8M Mx8XY9CT/G8k8xfyToHvR73lswnR62w+En1GZ/WUaJIWezBjcIWgXg+kT5DKUSTc2rOT izEw== X-Gm-Message-State: ALoCoQnoAWoX7LjEq0OAeq4nOtifqXSx+e7jp7xrrILdXFqI9ZSWF6vfrQQ+FjQM5ClWqF0yeZL0 X-Received: by 10.236.21.180 with SMTP id r40mr15106048yhr.48.1398071740327; Mon, 21 Apr 2014 02:15:40 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.198 with SMTP id h64ls2346759qgf.84.gmail; Mon, 21 Apr 2014 02:15:40 -0700 (PDT) X-Received: by 10.58.107.65 with SMTP id ha1mr33760670veb.1.1398071740225; Mon, 21 Apr 2014 02:15:40 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id vb6si6166419vec.182.2014.04.21.02.15.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Apr 2014 02:15:40 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jw12so7398396veb.41 for ; Mon, 21 Apr 2014 02:15:40 -0700 (PDT) X-Received: by 10.58.202.133 with SMTP id ki5mr28483866vec.19.1398071740133; Mon, 21 Apr 2014 02:15:40 -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.221.72 with SMTP id ib8csp278520vcb; Mon, 21 Apr 2014 02:15:39 -0700 (PDT) X-Received: by 10.140.20.113 with SMTP id 104mr36126287qgi.71.1398071739550; Mon, 21 Apr 2014 02:15:39 -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 p17si15201718qgp.195.2014.04.21.02.15.37 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 21 Apr 2014 02:15:39 -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 1WcAJr-00083k-K5; Mon, 21 Apr 2014 09:15:19 +0000 Received: from mail-pb0-f53.google.com ([209.85.160.53]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1WcAJk-00083d-RO for lng-odp@lists.linaro.org; Mon, 21 Apr 2014 09:15:12 +0000 Received: by mail-pb0-f53.google.com with SMTP id rp16so3522519pbb.26 for ; Mon, 21 Apr 2014 02:15:24 -0700 (PDT) X-Received: by 10.68.163.3 with SMTP id ye3mr37162731pbb.78.1398071724819; Mon, 21 Apr 2014 02:15:24 -0700 (PDT) Received: from localhost.localdomain ([218.17.215.175]) by mx.google.com with ESMTPSA id ha11sm76706923pbd.17.2014.04.21.02.15.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Apr 2014 02:15:24 -0700 (PDT) From: Weilong Chen To: lng-odp@lists.linaro.org Date: Mon, 21 Apr 2014 17:15:07 +0800 Message-Id: <1398071709-5807-1-git-send-email-weilong.chen@linaro.org> X-Mailer: git-send-email 1.7.9.5 Subject: [lng-odp] [PATCHv2] 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.128.182 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 | 97 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 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..bfa356d --- /dev/null +++ b/include/helper/odp_icmp.h @@ -0,0 +1,97 @@ +/* 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 { + uint8_t type; /** message type */ + uint8_t code; /** type sub-code */ + uint16be_t chksum; + union { + struct { + uint16be_t id; + uint16be_t sequence; + } echo; /** echo datagram */ + uint32be_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