"Fossies" - the Fresh Open Source Software Archive

Member "tcpflow-1.6.1/src/wifipcap/icmp.h" (19 Feb 2021, 7350 Bytes) of package /linux/misc/tcpflow-1.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "icmp.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996
    3  *  The Regents of the University of California.  All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that: (1) source code distributions
    7  * retain the above copyright notice and this paragraph in its entirety, (2)
    8  * distributions including binary code include the above copyright notice and
    9  * this paragraph in its entirety in the documentation or other materials
   10  * provided with the distribution, and (3) all advertising materials mentioning
   11  * features or use of this software display the following acknowledgement:
   12  * ``This product includes software developed by the University of California,
   13  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
   14  * the University nor the names of its contributors may be used to endorse
   15  * or promote products derived from this software without specific prior
   16  * written permission.
   17  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
   18  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
   19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
   20  */
   21 
   22 /*
   23  * Interface Control Message Protocol Definitions.
   24  * Per RFC 792, September 1981.
   25  */
   26 
   27 /*
   28  * Structure of an icmp header.
   29  */
   30 struct icmp {
   31     u_int8_t  icmp_type;        /* type of message, see below */
   32     u_int8_t  icmp_code;        /* type sub code */
   33     u_int16_t icmp_cksum;       /* ones complement cksum of struct */
   34     union {
   35         u_int8_t ih_pptr;           /* ICMP_PARAMPROB */
   36         struct in_addr ih_gwaddr;   /* ICMP_REDIRECT */
   37         struct ih_idseq {
   38             u_int16_t icd_id;
   39             u_int16_t icd_seq;
   40         } ih_idseq;
   41         u_int32_t ih_void;
   42 
   43         /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
   44         struct ih_pmtu {
   45             u_int16_t ipm_void;
   46             u_int16_t ipm_nextmtu;
   47         } ih_pmtu;
   48     } icmp_hun;
   49 #define icmp_pptr   icmp_hun.ih_pptr
   50 #define icmp_gwaddr icmp_hun.ih_gwaddr
   51 #define icmp_id     icmp_hun.ih_idseq.icd_id
   52 #define icmp_seq    icmp_hun.ih_idseq.icd_seq
   53 #define icmp_void   icmp_hun.ih_void
   54 #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
   55 #define icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
   56     union {
   57         struct id_ts {
   58             u_int32_t its_otime;
   59             u_int32_t its_rtime;
   60             u_int32_t its_ttime;
   61         } id_ts;
   62         struct id_ip  {
   63             struct ip idi_ip;
   64             /* options and then 64 bits of data */
   65         } id_ip;
   66                 struct mpls_ext {
   67                     u_int8_t legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
   68                     u_int8_t version_res[2];
   69                     u_int8_t checksum[2];
   70                     u_int8_t data[1];
   71                 } mpls_ext;
   72         u_int32_t id_mask;
   73         u_int8_t id_data[1];
   74     } icmp_dun;
   75 #define icmp_otime  icmp_dun.id_ts.its_otime
   76 #define icmp_rtime  icmp_dun.id_ts.its_rtime
   77 #define icmp_ttime  icmp_dun.id_ts.its_ttime
   78 #define icmp_ip     icmp_dun.id_ip.idi_ip
   79 #define icmp_mask   icmp_dun.id_mask
   80 #define icmp_data   icmp_dun.id_data
   81 #define icmp_mpls_ext_version   icmp_dun.mpls_ext.version_res
   82 #define icmp_mpls_ext_checksum  icmp_dun.mpls_ext.checksum
   83 #define icmp_mpls_ext_data  icmp_dun.mpls_ext.data
   84 };
   85 
   86 #define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4) 
   87 #define ICMP_MPLS_EXT_VERSION 2
   88 
   89 /*
   90  * Lower bounds on packet lengths for various types.
   91  * For the error advice packets must first insure that the
   92  * packet is large enought to contain the returned ip header.
   93  * Only then can we do the check to see if 64 bits of packet
   94  * data have been returned, since we need to check the returned
   95  * ip header length.
   96  */
   97 #define ICMP_MINLEN 8               /* abs minimum */
   98 #define ICMP_EXTD_MINLEN (156 - sizeof (struct ip))     /* draft-bonica-icmp-mpls-02 */
   99 #define ICMP_TSLEN  (8 + 3 * sizeof (u_int32_t))    /* timestamp */
  100 #define ICMP_MASKLEN    12              /* address mask */
  101 #define ICMP_ADVLENMIN  (8 + sizeof (struct ip) + 8)    /* min */
  102 #define ICMP_ADVLEN(p)  (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8)
  103     /* N.B.: must separately check that ip_hl >= 5 */
  104 
  105 /*
  106  * Definition of type and code field values.
  107  */
  108 #define ICMP_ECHOREPLY      0       /* echo reply */
  109 #define ICMP_UNREACH        3       /* dest unreachable, codes: */
  110 #define     ICMP_UNREACH_NET    0       /* bad net */
  111 #define     ICMP_UNREACH_HOST   1       /* bad host */
  112 #define     ICMP_UNREACH_PROTOCOL   2       /* bad protocol */
  113 #define     ICMP_UNREACH_PORT   3       /* bad port */
  114 #define     ICMP_UNREACH_NEEDFRAG   4       /* IP_DF caused drop */
  115 #define     ICMP_UNREACH_SRCFAIL    5       /* src route failed */
  116 #define     ICMP_UNREACH_NET_UNKNOWN 6      /* unknown net */
  117 #define     ICMP_UNREACH_HOST_UNKNOWN 7     /* unknown host */
  118 #define     ICMP_UNREACH_ISOLATED   8       /* src host isolated */
  119 #define     ICMP_UNREACH_NET_PROHIB 9       /* prohibited access */
  120 #define     ICMP_UNREACH_HOST_PROHIB 10     /* ditto */
  121 #define     ICMP_UNREACH_TOSNET 11      /* bad tos for net */
  122 #define     ICMP_UNREACH_TOSHOST    12      /* bad tos for host */
  123 #define ICMP_SOURCEQUENCH   4       /* packet lost, slow down */
  124 #define ICMP_REDIRECT       5       /* shorter route, codes: */
  125 #define     ICMP_REDIRECT_NET   0       /* for network */
  126 #define     ICMP_REDIRECT_HOST  1       /* for host */
  127 #define     ICMP_REDIRECT_TOSNET    2       /* for tos and net */
  128 #define     ICMP_REDIRECT_TOSHOST   3       /* for tos and host */
  129 #define ICMP_ECHO       8       /* echo service */
  130 #define ICMP_ROUTERADVERT   9       /* router advertisement */
  131 #define ICMP_ROUTERSOLICIT  10      /* router solicitation */
  132 #define ICMP_TIMXCEED       11      /* time exceeded, code: */
  133 #define     ICMP_TIMXCEED_INTRANS   0       /* ttl==0 in transit */
  134 #define     ICMP_TIMXCEED_REASS 1       /* ttl==0 in reass */
  135 #define ICMP_PARAMPROB      12      /* ip header bad */
  136 #define     ICMP_PARAMPROB_OPTABSENT 1      /* req. opt. absent */
  137 #define ICMP_TSTAMP     13      /* timestamp request */
  138 #define ICMP_TSTAMPREPLY    14      /* timestamp reply */
  139 #define ICMP_IREQ       15      /* information request */
  140 #define ICMP_IREQREPLY      16      /* information reply */
  141 #define ICMP_MASKREQ        17      /* address mask request */
  142 #define ICMP_MASKREPLY      18      /* address mask reply */
  143 
  144 #define ICMP_MAXTYPE        18
  145 
  146 #define ICMP_INFOTYPE(type) \
  147     ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
  148     (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
  149     (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
  150     (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
  151     (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
  152 #define ICMP_MPLS_EXT_TYPE(type) \
  153     ((type) == ICMP_UNREACH || (type) == ICMP_TIMXCEED)
  154 /* rfc1700 */
  155 #ifndef ICMP_UNREACH_NET_UNKNOWN
  156 #define ICMP_UNREACH_NET_UNKNOWN    6   /* destination net unknown */
  157 #endif
  158 #ifndef ICMP_UNREACH_HOST_UNKNOWN
  159 #define ICMP_UNREACH_HOST_UNKNOWN   7   /* destination host unknown */
  160 #endif
  161 #ifndef ICMP_UNREACH_ISOLATED
  162 #define ICMP_UNREACH_ISOLATED       8   /* source host isolated */
  163 #endif
  164 #ifndef ICMP_UNREACH_NET_PROHIB
  165 #define ICMP_UNREACH_NET_PROHIB     9   /* admin prohibited net */
  166 #endif
  167 #ifndef ICMP_UNREACH_HOST_PROHIB
  168 #define ICMP_UNREACH_HOST_PROHIB    10  /* admin prohibited host */
  169 #endif
  170 #ifndef ICMP_UNREACH_TOSNET
  171 #define ICMP_UNREACH_TOSNET     11  /* tos prohibited net */
  172 #endif
  173 #ifndef ICMP_UNREACH_TOSHOST
  174 #define ICMP_UNREACH_TOSHOST        12  /* tos prohibited host */
  175 #endif
  176 
  177 /* rfc1716 */
  178 #ifndef ICMP_UNREACH_FILTER_PROHIB
  179 #define ICMP_UNREACH_FILTER_PROHIB  13  /* admin prohibited filter */
  180 #endif
  181 #ifndef ICMP_UNREACH_HOST_PRECEDENCE
  182 #define ICMP_UNREACH_HOST_PRECEDENCE    14  /* host precedence violation */
  183 #endif
  184 #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
  185 #define ICMP_UNREACH_PRECEDENCE_CUTOFF  15  /* precedence cutoff */
  186 #endif