1 module ipcmp; 2 3 @nogc nothrow: 4 extern(C): __gshared: 5 /* Copyright (C) 1991, 92, 93, 95, 96, 97, 99 Free Software Foundation, Inc. 6 This file is part of the GNU C Library. 7 8 The GNU C Library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 The GNU C Library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with the GNU C Library; if not, write to the Free 20 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 21 02111-1307 USA. */ 22 23 enum __NETINET_IP_ICMP_H = 1; 24 25 public import core.sys.posix.sys.types; 26 27 struct icmp_hdr 28 { 29 uint type = void; /* message type */ 30 uint code = void; /* type sub-code */ 31 ushort checksum = void; 32 union _Un { 33 struct _Echo { 34 ushort id = void; 35 ushort sequence = void; 36 }_Echo echo = void; /* echo datagram */ 37 uint gateway = void; /* gateway address */ 38 struct _Frag { 39 ushort __unused = void; 40 ushort mtu = void; 41 }_Frag frag = void; /* path mtu discovery */ 42 }_Un un = void; 43 } 44 45 enum ICMP_ECHOREPLY = 0 /* Echo Reply */; 46 enum ICMP_DEST_UNREACH = 3 /* Destination Unreachable */; 47 enum ICMP_SOURCE_QUENCH = 4 /* Source Quench */; 48 enum ICMP_REDIRECT = 5 /* Redirect (change route) */; 49 enum ICMP_ECHO = 8 /* Echo Request */; 50 enum ICMP_TIME_EXCEEDED = 11 /* Time Exceeded */; 51 enum ICMP_PARAMETERPROB = 12 /* Parameter Problem */; 52 enum ICMP_TIMESTAMP = 13 /* Timestamp Request */; 53 enum ICMP_TIMESTAMPREPLY = 14 /* Timestamp Reply */; 54 enum ICMP_INFO_REQUEST = 15 /* Information Request */; 55 enum ICMP_INFO_REPLY = 16 /* Information Reply */; 56 enum ICMP_ADDRESS = 17 /* Address Mask Request */; 57 enum ICMP_ADDRESSREPLY = 18 /* Address Mask Reply */; 58 enum NR_ICMP_TYPES = 18; 59 60 61 /* Codes for UNREACH. */ 62 enum ICMP_NET_UNREACH = 0 /* Network Unreachable */; 63 enum ICMP_HOST_UNREACH = 1 /* Host Unreachable */; 64 enum ICMP_PROT_UNREACH = 2 /* Protocol Unreachable */; 65 enum ICMP_PORT_UNREACH = 3 /* Port Unreachable */; 66 enum ICMP_FRAG_NEEDED = 4 /* Fragmentation Needed/DF set */; 67 enum ICMP_SR_FAILED = 5 /* Source Route failed */; 68 enum ICMP_NET_UNKNOWN = 6; 69 enum ICMP_HOST_UNKNOWN = 7; 70 enum ICMP_HOST_ISOLATED = 8; 71 enum ICMP_NET_ANO = 9; 72 enum ICMP_HOST_ANO = 10; 73 enum ICMP_NET_UNR_TOS = 11; 74 enum ICMP_HOST_UNR_TOS = 12; 75 enum ICMP_PKT_FILTERED = 13 /* Packet filtered */; 76 enum ICMP_PREC_VIOLATION = 14 /* Precedence violation */; 77 enum ICMP_PREC_CUTOFF = 15 /* Precedence cut off */; 78 enum NR_ICMP_UNREACH = 15 /* instead of hardcoding immediate value */; 79 80 /* Codes for REDIRECT. */ 81 enum ICMP_REDIR_NET = 0 /* Redirect Net */; 82 enum ICMP_REDIR_HOST = 1 /* Redirect Host */; 83 enum ICMP_REDIR_NETTOS = 2 /* Redirect Net for TOS */; 84 enum ICMP_REDIR_HOSTTOS = 3 /* Redirect Host for TOS */; 85 86 /* Codes for TIME_EXCEEDED. */ 87 enum ICMP_EXC_TTL = 0 /* TTL count exceeded */; 88 enum ICMP_EXC_FRAGTIME = 1 /* Fragment Reass time exceeded */; 89 90 91 version (__USE_BSD) { 92 /* 93 * Copyright (c) 1982, 1986, 1993 94 * The Regents of the University of California. All rights reserved. 95 * 96 * Redistribution and use in source and binary forms, with or without 97 * modification, are permitted provided that the following conditions 98 * are met: 99 * 1. Redistributions of source code must retain the above copyright 100 * notice, this list of conditions and the following disclaimer. 101 * 2. Redistributions in binary form must reproduce the above copyright 102 * notice, this list of conditions and the following disclaimer in the 103 * documentation and/or other materials provided with the distribution. 104 * 4. Neither the name of the University nor the names of its contributors 105 * may be used to endorse or promote products derived from this software 106 * without specific prior written permission. 107 * 108 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 109 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 110 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 111 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 112 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 113 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 114 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 115 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 116 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 117 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 118 * SUCH DAMAGE. 119 * 120 * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 121 */ 122 123 public import core.sys.posix.netinet; 124 public import core.sys.posix.netinet.in_; 125 public import core.sys.posix.netinet.tcp; 126 127 /* 128 * Internal of an ICMP Router Advertisement 129 */ 130 struct icmp_ra_addr 131 { 132 uint ira_addr; 133 uint ira_preference; 134 } 135 136 struct icmp 137 { 138 uint icmp_type; /* type of message, see below */ 139 uint icmp_code; /* type sub code */ 140 ushort icmp_cksum; /* ones complement checksum of struct */ 141 union _Icmp_hun { 142 u_char ih_pptr; /* ICMP_PARAMPROB */ 143 in_addr ih_gwaddr; /* gateway address */ 144 struct ih_idseq { 145 ushort icd_id; 146 ushort icd_seq; 147 }ih_idseq ih_idseq; 148 uint ih_void; 149 150 /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ 151 struct ih_pmtu { 152 ushort ipm_void; 153 ushort ipm_nextmtu; 154 }ih_pmtu ih_pmtu; 155 156 struct ih_rtradv { 157 uint irt_num_addrs; 158 uint irt_wpa; 159 ushort irt_lifetime; 160 }ih_rtradv ih_rtradv; 161 }_Icmp_hun icmp_hun; 162 enum icmp_pptr = icmp_hun.ih_pptr; 163 enum icmp_gwaddr = icmp_hun.ih_gwaddr; 164 enum icmp_id = icmp_hun.ih_idseq.icd_id; 165 enum icmp_seq = icmp_hun.ih_idseq.icd_seq; 166 enum icmp_void = icmp_hun.ih_void; 167 enum icmp_pmvoid = icmp_hun.ih_pmtu.ipm_void; 168 enum icmp_nextmtu = icmp_hun.ih_pmtu.ipm_nextmtu; 169 enum icmp_num_addrs = icmp_hun.ih_rtradv.irt_num_addrs; 170 enum icmp_wpa = icmp_hun.ih_rtradv.irt_wpa; 171 enum icmp_lifetime = icmp_hun.ih_rtradv.irt_lifetime; 172 union _Icmp_dun { 173 struct _Id_ts { 174 uint its_otime; 175 uint its_rtime; 176 uint its_ttime; 177 }_Id_ts id_ts; 178 struct _Id_ip { 179 ip idi_ip; 180 /* options and then 64 bits of data */ 181 }_Id_ip id_ip; 182 icmp_ra_addr id_radv; 183 uint id_mask; 184 uint[1] id_data; 185 }_Icmp_dun icmp_dun; 186 enum icmp_otime = icmp_dun.id_ts.its_otime; 187 enum icmp_rtime = icmp_dun.id_ts.its_rtime; 188 enum icmp_ttime = icmp_dun.id_ts.its_ttime; 189 enum icmp_ip = icmp_dun.id_ip.idi_ip; 190 enum icmp_radv = icmp_dun.id_radv; 191 enum icmp_mask = icmp_dun.id_mask; 192 enum icmp_data = icmp_dun.id_data; 193 } 194 195 /* 196 * Lower bounds on packet lengths for various types. 197 * For the error advice packets must first insure that the 198 * packet is large enough to contain the returned ip header. 199 * Only then can we do the check to see if 64 bits of packet 200 * data have been returned, since we need to check the returned 201 * ip header length. 202 */ 203 enum ICMP_MINLEN = 8 /* abs minimum */; 204 enum ICMP_TSLEN = (8 + 3 * sizeof(n_time)) /* timestamp */; 205 enum ICMP_MASKLEN = 12 /* address mask */; 206 enum ICMP_ADVLENMIN = (8 + sizeof(ip) + 8) /* min */; 207 version (_IP_VHL) {} else { 208 enum string ICMP_ADVLEN(string p) = `(8 + ((` ~ p ~ `).icmp_ip.ip_hl << 2) + 8)`; 209 /* N.B.: must separately check that ip_hl >= 5 */ 210 } version (_IP_VHL) { 211 enum string ICMP_ADVLEN(string p) = `(8 + (IP_VHL_HL((` ~ p ~ `).icmp_ip.ip_vhl) << 2) + 8)`; 212 /* N.B.: must separately check that header length >= 5 */ 213 } 214 215 /* Definition of type and code fields. */ 216 /* defined above: ICMP_ECHOREPLY, ICMP_REDIRECT, ICMP_ECHO */ 217 enum ICMP_UNREACH = 3 /* dest unreachable, codes: */; 218 enum ICMP_SOURCEQUENCH = 4 /* packet lost, slow down */; 219 enum ICMP_ROUTERADVERT = 9 /* router advertisement */; 220 enum ICMP_ROUTERSOLICIT = 10 /* router solicitation */; 221 enum ICMP_TIMXCEED = 11 /* time exceeded, code: */; 222 enum ICMP_PARAMPROB = 12 /* ip header bad */; 223 enum ICMP_TSTAMP = 13 /* timestamp request */; 224 enum ICMP_TSTAMPREPLY = 14 /* timestamp reply */; 225 enum ICMP_IREQ = 15 /* information request */; 226 enum ICMP_IREQREPLY = 16 /* information reply */; 227 enum ICMP_MASKREQ = 17 /* address mask request */; 228 enum ICMP_MASKREPLY = 18 /* address mask reply */; 229 230 enum ICMP_MAXTYPE = 18; 231 232 /* UNREACH codes */ 233 enum ICMP_UNREACH_NET = 0 /* bad net */; 234 enum ICMP_UNREACH_HOST = 1 /* bad host */; 235 enum ICMP_UNREACH_PROTOCOL = 2 /* bad protocol */; 236 enum ICMP_UNREACH_PORT = 3 /* bad port */; 237 enum ICMP_UNREACH_NEEDFRAG = 4 /* IP_DF caused drop */; 238 enum ICMP_UNREACH_SRCFAIL = 5 /* src route failed */; 239 enum ICMP_UNREACH_NET_UNKNOWN = 6 /* unknown net */; 240 enum ICMP_UNREACH_HOST_UNKNOWN = 7 /* unknown host */; 241 enum ICMP_UNREACH_ISOLATED = 8 /* src host isolated */; 242 enum ICMP_UNREACH_NET_PROHIB = 9 /* net denied */; 243 enum ICMP_UNREACH_HOST_PROHIB = 10 /* host denied */; 244 enum ICMP_UNREACH_TOSNET = 11 /* bad tos for net */; 245 enum ICMP_UNREACH_TOSHOST = 12 /* bad tos for host */; 246 enum ICMP_UNREACH_FILTER_PROHIB = 13 /* admin prohib */; 247 enum ICMP_UNREACH_HOST_PRECEDENCE = 14 /* host prec vio. */; 248 enum ICMP_UNREACH_PRECEDENCE_CUTOFF = 15 /* prec cutoff */; 249 250 /* REDIRECT codes */ 251 enum ICMP_REDIRECT_NET = 0 /* for network */; 252 enum ICMP_REDIRECT_HOST = 1 /* for host */; 253 enum ICMP_REDIRECT_TOSNET = 2 /* for tos and net */; 254 enum ICMP_REDIRECT_TOSHOST = 3 /* for tos and host */; 255 256 /* TIMEXCEED codes */ 257 enum ICMP_TIMXCEED_INTRANS = 0 /* ttl==0 in transit */; 258 enum ICMP_TIMXCEED_REASS = 1 /* ttl==0 in reass */; 259 260 /* PARAMPROB code */ 261 enum ICMP_PARAMPROB_OPTABSENT = 1 /* req. opt. absent */; 262 263 enum string ICMP_INFOTYPE(string type) = ` 264 ((` ~ type ~ `) == ICMP_ECHOREPLY || (` ~ type ~ `) == ICMP_ECHO || 265 (` ~ type ~ `) == ICMP_ROUTERADVERT || (` ~ type ~ `) == ICMP_ROUTERSOLICIT || 266 (` ~ type ~ `) == ICMP_TSTAMP || (` ~ type ~ `) == ICMP_TSTAMPREPLY || 267 (` ~ type ~ `) == ICMP_IREQ || (` ~ type ~ `) == ICMP_IREQREPLY || 268 (` ~ type ~ `) == ICMP_MASKREQ || (` ~ type ~ `) == ICMP_MASKREPLY)`; 269 270 } /* __USE_BSD */