home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / comm / amitcp-sdk-4.0.lha / AmiTCP-SDK / netinclude / netinet / ip_icmp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-06  |  3.7 KB  |  108 lines

  1. #ifndef NETINET_IP_ICMP_H
  2. #define NETINET_IP_ICMP_H \
  3.        "$Id: ip_icmp.h,v 4.1 1994/10/05 23:16:35 ppessi Exp $"
  4. /*
  5.  *      Interface Control Message Protocol Definitions.
  6.  *      Per RFC 792, September 1981.
  7.  *
  8.  *      Copyright © 1994 AmiTCP/IP Group,
  9.  *                       Network Solutions Development, Inc.
  10.  *                       All rights reserved.
  11.  */
  12.  
  13. /*
  14.  * Structure of an icmp header.
  15.  */
  16. struct icmp {
  17.     u_char    icmp_type;        /* type of message, see below */
  18.     u_char    icmp_code;        /* type sub code */
  19.     u_short    icmp_cksum;        /* ones complement cksum of struct */
  20.     union {
  21.         u_char ih_pptr;            /* ICMP_PARAMPROB */
  22.         struct in_addr ih_gwaddr;    /* ICMP_REDIRECT */
  23.         struct ih_idseq {
  24.             n_short    icd_id;
  25.             n_short    icd_seq;
  26.         } ih_idseq;
  27.         int ih_void;
  28.     } icmp_hun;
  29. #define    icmp_pptr    icmp_hun.ih_pptr
  30. #define    icmp_gwaddr    icmp_hun.ih_gwaddr
  31. #define    icmp_id        icmp_hun.ih_idseq.icd_id
  32. #define    icmp_seq    icmp_hun.ih_idseq.icd_seq
  33. #define    icmp_void    icmp_hun.ih_void
  34.     union {
  35.         struct id_ts {
  36.             n_time its_otime;
  37.             n_time its_rtime;
  38.             n_time its_ttime;
  39.         } id_ts;
  40.         struct id_ip  {
  41.             struct ip idi_ip;
  42.             /* options and then 64 bits of data */
  43.         } id_ip;
  44.         u_long    id_mask;
  45.         char    id_data[1];
  46.     } icmp_dun;
  47. #define    icmp_otime    icmp_dun.id_ts.its_otime
  48. #define    icmp_rtime    icmp_dun.id_ts.its_rtime
  49. #define    icmp_ttime    icmp_dun.id_ts.its_ttime
  50. #define    icmp_ip        icmp_dun.id_ip.idi_ip
  51. #define    icmp_mask    icmp_dun.id_mask
  52. #define    icmp_data    icmp_dun.id_data
  53. };
  54.  
  55. /*
  56.  * Lower bounds on packet lengths for various types.
  57.  * For the error advice packets must first insure that the
  58.  * packet is large enought to contain the returned ip header.
  59.  * Only then can we do the check to see if 64 bits of packet
  60.  * data have been returned, since we need to check the returned
  61.  * ip header length.
  62.  */
  63. #define    ICMP_MINLEN    8                /* abs minimum */
  64. #define    ICMP_TSLEN    (8 + 3 * sizeof (n_time))    /* timestamp */
  65. #define    ICMP_MASKLEN    12                /* address mask */
  66. #define    ICMP_ADVLENMIN    (8 + sizeof (struct ip) + 8)    /* min */
  67. #define    ICMP_ADVLEN(p)    (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
  68.     /* N.B.: must separately check that ip_hl >= 5 */
  69.  
  70. /*
  71.  * Definition of type and code field values.
  72.  */
  73. #define    ICMP_ECHOREPLY        0        /* echo reply */
  74. #define    ICMP_UNREACH        3        /* dest unreachable, codes: */
  75. #define        ICMP_UNREACH_NET    0        /* bad net */
  76. #define        ICMP_UNREACH_HOST    1        /* bad host */
  77. #define        ICMP_UNREACH_PROTOCOL    2        /* bad protocol */
  78. #define        ICMP_UNREACH_PORT    3        /* bad port */
  79. #define        ICMP_UNREACH_NEEDFRAG    4        /* IP_DF caused drop */
  80. #define        ICMP_UNREACH_SRCFAIL    5        /* src route failed */
  81. #define    ICMP_SOURCEQUENCH    4        /* packet lost, slow down */
  82. #define    ICMP_REDIRECT        5        /* shorter route, codes: */
  83. #define        ICMP_REDIRECT_NET    0        /* for network */
  84. #define        ICMP_REDIRECT_HOST    1        /* for host */
  85. #define        ICMP_REDIRECT_TOSNET    2        /* for tos and net */
  86. #define        ICMP_REDIRECT_TOSHOST    3        /* for tos and host */
  87. #define    ICMP_ECHO        8        /* echo service */
  88. #define    ICMP_TIMXCEED        11        /* time exceeded, code: */
  89. #define        ICMP_TIMXCEED_INTRANS    0        /* ttl==0 in transit */
  90. #define        ICMP_TIMXCEED_REASS    1        /* ttl==0 in reass */
  91. #define    ICMP_PARAMPROB        12        /* ip header bad */
  92. #define    ICMP_TSTAMP        13        /* timestamp request */
  93. #define    ICMP_TSTAMPREPLY    14        /* timestamp reply */
  94. #define    ICMP_IREQ        15        /* information request */
  95. #define    ICMP_IREQREPLY        16        /* information reply */
  96. #define    ICMP_MASKREQ        17        /* address mask request */
  97. #define    ICMP_MASKREPLY        18        /* address mask reply */
  98.  
  99. #define    ICMP_MAXTYPE        18
  100.  
  101. #define    ICMP_INFOTYPE(type) \
  102.     ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
  103.     (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
  104.     (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
  105.     (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
  106.  
  107. #endif /* !NETINET_IP_ICMP_H */
  108.