jdk/src/windows/native/java/net/icmp.h
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 5506 202f599c92aa
child 23010 6dadb192ad81
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef ICMP_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define ICMP_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * Structure of an internet header, naked of options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * We declare ip_len and ip_off to be short, rather than ushort_t
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * pragmatically since otherwise unsigned comparisons can result
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * against negative integers quite easily, and fail in subtle ways.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
struct ip {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        unsigned char   ip_hl:4,        /* header length */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
                        ip_v:4;         /* version */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        unsigned char   ip_tos;                 /* type of service */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        short   ip_len;                 /* total length */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        unsigned short ip_id;                   /* identification */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        short   ip_off;                 /* fragment offset field */
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
    43
#define IP_DF 0x4000                    /* don't fragment flag */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define IP_MF 0x2000                    /* more fragments flag */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        unsigned char   ip_ttl;                 /* time to live */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        unsigned char   ip_p;                   /* protocol */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        unsigned short ip_sum;          /* checksum */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        struct  in_addr ip_src, ip_dst; /* source and dest address */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * Structure of an icmp header.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
struct icmp {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        unsigned char   icmp_type;              /* type of message, see below */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        unsigned char   icmp_code;              /* type sub code */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        unsigned short icmp_cksum;              /* ones complement cksum of struct */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                unsigned char ih_pptr;          /* ICMP_PARAMPROB */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                struct in_addr ih_gwaddr;       /* ICMP_REDIRECT */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
                struct ih_idseq {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                        unsigned short icd_id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                        unsigned short icd_seq;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                } ih_idseq;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                int ih_void;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                struct ih_pmtu {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                        unsigned short ipm_void;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                        unsigned short ipm_nextmtu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                } ih_pmtu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
                struct ih_rtradv {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                        unsigned char irt_num_addrs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                        unsigned char irt_wpa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                        unsigned short irt_lifetime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                } ih_rtradv;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        } icmp_hun;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#define icmp_pptr       icmp_hun.ih_pptr
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
#define icmp_gwaddr     icmp_hun.ih_gwaddr
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#define icmp_id         icmp_hun.ih_idseq.icd_id
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
#define icmp_seq        icmp_hun.ih_idseq.icd_seq
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
#define icmp_void       icmp_hun.ih_void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#define icmp_pmvoid     icmp_hun.ih_pmtu.ipm_void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#define icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                struct id_ts {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                        unsigned int its_otime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                        unsigned int its_rtime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                        unsigned int its_ttime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                } id_ts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                struct id_ip  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                        struct ip idi_ip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                        /* options and then 64 bits of data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                } id_ip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                unsigned int id_mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                char    id_data[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        } icmp_dun;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
#define icmp_otime      icmp_dun.id_ts.its_otime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define icmp_rtime      icmp_dun.id_ts.its_rtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#define icmp_ttime      icmp_dun.id_ts.its_ttime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
#define icmp_ip         icmp_dun.id_ip.idi_ip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
#define icmp_mask       icmp_dun.id_mask
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
#define icmp_data       icmp_dun.id_data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
#define ICMP_ECHOREPLY          0               /* echo reply */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
#define ICMP_ECHO               8               /* echo service */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * ICMPv6 structures & constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
typedef struct icmp6_hdr {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        u_char   icmp6_type;    /* type field */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        u_char   icmp6_code;    /* code field */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        u_short  icmp6_cksum;   /* checksum field */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        union {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                u_int icmp6_un_data32[1];       /* type-specific field */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                u_short icmp6_un_data16[2];     /* type-specific field */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                u_char  icmp6_un_data8[4];      /* type-specific field */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        } icmp6_dataun;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
} icmp6_t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#define icmp6_data32    icmp6_dataun.icmp6_un_data32
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
#define icmp6_data16    icmp6_dataun.icmp6_un_data16
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
#define icmp6_data8     icmp6_dataun.icmp6_un_data8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
#define icmp6_pptr      icmp6_data32[0] /* parameter prob */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
#define icmp6_mtu       icmp6_data32[0] /* packet too big */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
#define icmp6_id        icmp6_data16[0] /* echo request/reply */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
#define icmp6_seq       icmp6_data16[1] /* echo request/reply */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
#define icmp6_maxdelay  icmp6_data16[0] /* mcast group membership */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
struct ip6_pseudo_hdr  /* for calculate the ICMPv6 checksum */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  struct in6_addr ip6_src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
  struct in6_addr ip6_dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
  u_int       ip6_plen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
  u_int       ip6_nxt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
#define ICMP6_ECHO_REQUEST      128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
#define ICMP6_ECHO_REPLY        129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
#define IPPROTO_ICMPV6          58
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
#define IPV6_UNICAST_HOPS       4  /* Set/get IP unicast hop limit */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
#endif