Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/windows/native/java/net/icmp.h
32287 views
/*1* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef ICMP_H26#define ICMP_H2728/*29* Structure of an internet header, naked of options.30*31* We declare ip_len and ip_off to be short, rather than ushort_t32* pragmatically since otherwise unsigned comparisons can result33* against negative integers quite easily, and fail in subtle ways.34*/35struct ip {36unsigned char ip_hl:4, /* header length */37ip_v:4; /* version */38unsigned char ip_tos; /* type of service */39short ip_len; /* total length */40unsigned short ip_id; /* identification */41short ip_off; /* fragment offset field */42#define IP_DF 0x4000 /* don't fragment flag */43#define IP_MF 0x2000 /* more fragments flag */44unsigned char ip_ttl; /* time to live */45unsigned char ip_p; /* protocol */46unsigned short ip_sum; /* checksum */47struct in_addr ip_src, ip_dst; /* source and dest address */48};4950/*51* Structure of an icmp header.52*/53struct icmp {54unsigned char icmp_type; /* type of message, see below */55unsigned char icmp_code; /* type sub code */56unsigned short icmp_cksum; /* ones complement cksum of struct */57union {58unsigned char ih_pptr; /* ICMP_PARAMPROB */59struct in_addr ih_gwaddr; /* ICMP_REDIRECT */60struct ih_idseq {61unsigned short icd_id;62unsigned short icd_seq;63} ih_idseq;64int ih_void;6566/* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */67struct ih_pmtu {68unsigned short ipm_void;69unsigned short ipm_nextmtu;70} ih_pmtu;7172struct ih_rtradv {73unsigned char irt_num_addrs;74unsigned char irt_wpa;75unsigned short irt_lifetime;76} ih_rtradv;77} icmp_hun;78#define icmp_pptr icmp_hun.ih_pptr79#define icmp_gwaddr icmp_hun.ih_gwaddr80#define icmp_id icmp_hun.ih_idseq.icd_id81#define icmp_seq icmp_hun.ih_idseq.icd_seq82#define icmp_void icmp_hun.ih_void83#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void84#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu85union {86struct id_ts {87unsigned int its_otime;88unsigned int its_rtime;89unsigned int its_ttime;90} id_ts;91struct id_ip {92struct ip idi_ip;93/* options and then 64 bits of data */94} id_ip;95unsigned int id_mask;96char id_data[1];97} icmp_dun;98#define icmp_otime icmp_dun.id_ts.its_otime99#define icmp_rtime icmp_dun.id_ts.its_rtime100#define icmp_ttime icmp_dun.id_ts.its_ttime101#define icmp_ip icmp_dun.id_ip.idi_ip102#define icmp_mask icmp_dun.id_mask103#define icmp_data icmp_dun.id_data104};105106#define ICMP_ECHOREPLY 0 /* echo reply */107#define ICMP_ECHO 8 /* echo service */108109/*110* ICMPv6 structures & constants111*/112113typedef struct icmp6_hdr {114u_char icmp6_type; /* type field */115u_char icmp6_code; /* code field */116u_short icmp6_cksum; /* checksum field */117union {118u_int icmp6_un_data32[1]; /* type-specific field */119u_short icmp6_un_data16[2]; /* type-specific field */120u_char icmp6_un_data8[4]; /* type-specific field */121} icmp6_dataun;122} icmp6_t;123124#define icmp6_data32 icmp6_dataun.icmp6_un_data32125#define icmp6_data16 icmp6_dataun.icmp6_un_data16126#define icmp6_data8 icmp6_dataun.icmp6_un_data8127#define icmp6_pptr icmp6_data32[0] /* parameter prob */128#define icmp6_mtu icmp6_data32[0] /* packet too big */129#define icmp6_id icmp6_data16[0] /* echo request/reply */130#define icmp6_seq icmp6_data16[1] /* echo request/reply */131#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */132133struct ip6_pseudo_hdr /* for calculate the ICMPv6 checksum */134{135struct in6_addr ip6_src;136struct in6_addr ip6_dst;137u_int ip6_plen;138u_int ip6_nxt;139};140141#define ICMP6_ECHO_REQUEST 128142#define ICMP6_ECHO_REPLY 129143#define IPPROTO_ICMPV6 58144#define IPV6_UNICAST_HOPS 4 /* Set/get IP unicast hop limit */145146147#endif148149150