0N/A/*
2362N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#ifndef ICMP_H
0N/A#define ICMP_H
0N/A
0N/A/*
0N/A * Structure of an internet header, naked of options.
0N/A *
0N/A * We declare ip_len and ip_off to be short, rather than ushort_t
0N/A * pragmatically since otherwise unsigned comparisons can result
0N/A * against negative integers quite easily, and fail in subtle ways.
0N/A */
0N/Astruct ip {
0N/A unsigned char ip_hl:4, /* header length */
0N/A ip_v:4; /* version */
0N/A unsigned char ip_tos; /* type of service */
0N/A short ip_len; /* total length */
0N/A unsigned short ip_id; /* identification */
0N/A short ip_off; /* fragment offset field */
0N/A#define IP_DF 0x4000 /* dont fragment flag */
0N/A#define IP_MF 0x2000 /* more fragments flag */
0N/A unsigned char ip_ttl; /* time to live */
0N/A unsigned char ip_p; /* protocol */
0N/A unsigned short ip_sum; /* checksum */
0N/A struct in_addr ip_src, ip_dst; /* source and dest address */
0N/A};
0N/A
0N/A/*
0N/A * Structure of an icmp header.
0N/A */
0N/Astruct icmp {
0N/A unsigned char icmp_type; /* type of message, see below */
0N/A unsigned char icmp_code; /* type sub code */
0N/A unsigned short icmp_cksum; /* ones complement cksum of struct */
0N/A union {
0N/A unsigned char ih_pptr; /* ICMP_PARAMPROB */
0N/A struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
0N/A struct ih_idseq {
0N/A unsigned short icd_id;
0N/A unsigned short icd_seq;
0N/A } ih_idseq;
0N/A int ih_void;
0N/A
0N/A /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
0N/A struct ih_pmtu {
0N/A unsigned short ipm_void;
0N/A unsigned short ipm_nextmtu;
0N/A } ih_pmtu;
0N/A
0N/A struct ih_rtradv {
0N/A unsigned char irt_num_addrs;
0N/A unsigned char irt_wpa;
0N/A unsigned short irt_lifetime;
0N/A } ih_rtradv;
0N/A } icmp_hun;
0N/A#define icmp_pptr icmp_hun.ih_pptr
0N/A#define icmp_gwaddr icmp_hun.ih_gwaddr
0N/A#define icmp_id icmp_hun.ih_idseq.icd_id
0N/A#define icmp_seq icmp_hun.ih_idseq.icd_seq
0N/A#define icmp_void icmp_hun.ih_void
0N/A#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
0N/A#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
0N/A union {
0N/A struct id_ts {
0N/A unsigned int its_otime;
0N/A unsigned int its_rtime;
0N/A unsigned int its_ttime;
0N/A } id_ts;
0N/A struct id_ip {
0N/A struct ip idi_ip;
0N/A /* options and then 64 bits of data */
0N/A } id_ip;
0N/A unsigned int id_mask;
0N/A char id_data[1];
0N/A } icmp_dun;
0N/A#define icmp_otime icmp_dun.id_ts.its_otime
0N/A#define icmp_rtime icmp_dun.id_ts.its_rtime
0N/A#define icmp_ttime icmp_dun.id_ts.its_ttime
0N/A#define icmp_ip icmp_dun.id_ip.idi_ip
0N/A#define icmp_mask icmp_dun.id_mask
0N/A#define icmp_data icmp_dun.id_data
0N/A};
0N/A
0N/A#define ICMP_ECHOREPLY 0 /* echo reply */
0N/A#define ICMP_ECHO 8 /* echo service */
0N/A
0N/A/*
0N/A * ICMPv6 structures & constants
0N/A */
0N/A
0N/Atypedef struct icmp6_hdr {
0N/A u_char icmp6_type; /* type field */
0N/A u_char icmp6_code; /* code field */
0N/A u_short icmp6_cksum; /* checksum field */
0N/A union {
0N/A u_int icmp6_un_data32[1]; /* type-specific field */
0N/A u_short icmp6_un_data16[2]; /* type-specific field */
0N/A u_char icmp6_un_data8[4]; /* type-specific field */
0N/A } icmp6_dataun;
0N/A} icmp6_t;
0N/A
0N/A#define icmp6_data32 icmp6_dataun.icmp6_un_data32
0N/A#define icmp6_data16 icmp6_dataun.icmp6_un_data16
0N/A#define icmp6_data8 icmp6_dataun.icmp6_un_data8
0N/A#define icmp6_pptr icmp6_data32[0] /* parameter prob */
0N/A#define icmp6_mtu icmp6_data32[0] /* packet too big */
0N/A#define icmp6_id icmp6_data16[0] /* echo request/reply */
0N/A#define icmp6_seq icmp6_data16[1] /* echo request/reply */
0N/A#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
0N/A
0N/Astruct ip6_pseudo_hdr /* for calculate the ICMPv6 checksum */
0N/A{
0N/A struct in6_addr ip6_src;
0N/A struct in6_addr ip6_dst;
0N/A u_int ip6_plen;
0N/A u_int ip6_nxt;
0N/A};
0N/A
0N/A#define ICMP6_ECHO_REQUEST 128
0N/A#define ICMP6_ECHO_REPLY 129
0N/A#define IPPROTO_ICMPV6 58
0N/A#define IPV6_UNICAST_HOPS 4 /* Set/get IP unicast hop limit */
0N/A
0N/A
0N/A#endif