home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / detk45he.zip / stack16 / netinet / ip_icmp.h < prev    next >
Text File  |  1999-05-11  |  7KB  |  161 lines

  1. #ifndef __IP_ICMP_32H
  2. #define __IP_ICMP_32H
  3. /*
  4.  * Copyright (c) 1982, 1986 Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms are permitted
  8.  * provided that this notice is preserved and that due credit is given
  9.  * to the University of California at Berkeley. The name of the University
  10.  * may not be used to endorse or promote products derived from this
  11.  * software without specific prior written permission. This software
  12.  * is provided ``as is'' without express or implied warranty.
  13.  *
  14.  *      @(#)ip_icmp.h   7.3 (Berkeley) 12/7/87
  15.  */
  16.  
  17. /*
  18.  * Interface Control Message Protocol Definitions.
  19.  * Per RFC 792, September 1981.
  20.  */
  21.  
  22. /*
  23.  * Structure of an icmp header.
  24.  */
  25. struct icmp {
  26.         u_char  icmp_type;              /* type of message, see below */
  27.         u_char  icmp_code;              /* type sub code */
  28.         u_short icmp_cksum;             /* ones complement cksum of struct */
  29.         union {
  30.                 u_char ih_pptr;                 /* ICMP_PARAMPROB */
  31.                 struct in_addr ih_gwaddr;       /* ICMP_REDIRECT */
  32.                 struct ih_idseq {
  33.                         n_short icd_id;
  34.                         n_short icd_seq;
  35.                 } ih_idseq;
  36.                 int ih_void;
  37.         } icmp_hun;
  38. #define icmp_pptr       icmp_hun.ih_pptr
  39. #define icmp_gwaddr     icmp_hun.ih_gwaddr
  40. #define icmp_id         icmp_hun.ih_idseq.icd_id
  41. #define icmp_seq        icmp_hun.ih_idseq.icd_seq
  42. #define icmp_void       icmp_hun.ih_void
  43.         union {
  44.                 struct id_ts {
  45.                         n_time its_otime;
  46.                         n_time its_rtime;
  47.                         n_time its_ttime;
  48.                 } id_ts;
  49.                 struct id_ip  {
  50.                         struct ip idi_ip;
  51.                         /* options and then 64 bits of data */
  52.                 } id_ip;
  53.                 u_long  id_mask;
  54.                 char    id_data[1];
  55.         } icmp_dun;
  56. #define icmp_otime      icmp_dun.id_ts.its_otime
  57. #define icmp_rtime      icmp_dun.id_ts.its_rtime
  58. #define icmp_ttime      icmp_dun.id_ts.its_ttime
  59. #define icmp_ip         icmp_dun.id_ip.idi_ip
  60. #define icmp_mask       icmp_dun.id_mask
  61. #define icmp_data       icmp_dun.id_data
  62. };
  63.  
  64. /*
  65.  * Lower bounds on packet lengths for various types.
  66.  * For the error advice packets must first insure that the
  67.  * packet is large enought to contain the returned ip header.
  68.  * Only then can we do the check to see if 64 bits of packet
  69.  * data have been returned, since we need to check the returned
  70.  * ip header length.
  71.  */
  72. #define ICMP_MINLEN     8                               /* abs minimum */
  73. #define ICMP_TSLEN      (8 + 3 * sizeof (n_time))       /* timestamp */
  74. #define ICMP_MASKLEN    12                              /* address mask */
  75. #define ICMP_ADVLENMIN  (8 + sizeof (struct ip) + 8)    /* min */
  76. #define ICMP_ADVLEN(p)  (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
  77.         /* N.B.: must separately check that ip_hl >= 5 */
  78.  
  79. /*
  80.  * Definition of type and code field values.
  81.  */
  82. #define ICMP_ECHOREPLY          0               /* echo reply */
  83. #define ICMP_UNREACH            3               /* dest unreachable, codes: */
  84. #define         ICMP_UNREACH_NET        0               /* bad net */
  85. #define         ICMP_UNREACH_HOST       1               /* bad host */
  86. #define         ICMP_UNREACH_PROTOCOL   2               /* bad protocol */
  87. #define         ICMP_UNREACH_PORT       3               /* bad port */
  88. #define         ICMP_UNREACH_NEEDFRAG   4               /* IP_DF caused drop */
  89. #define         ICMP_UNREACH_SRCFAIL    5               /* src route failed */
  90. #define ICMP_SOURCEQUENCH       4               /* packet lost, slow down */
  91. #define ICMP_REDIRECT           5               /* shorter route, codes: */
  92. #define         ICMP_REDIRECT_NET       0               /* for network */
  93. #define         ICMP_REDIRECT_HOST      1               /* for host */
  94. #define         ICMP_REDIRECT_TOSNET    2               /* for tos and net */
  95. #define         ICMP_REDIRECT_TOSHOST   3               /* for tos and host */
  96. #define ICMP_ECHO               8               /* echo service */
  97. #define ICMP_TIMXCEED           11              /* time exceeded, code: */
  98. #define         ICMP_TIMXCEED_INTRANS   0               /* ttl==0 in transit */
  99. #define         ICMP_TIMXCEED_REASS     1               /* ttl==0 in reass */
  100. #define ICMP_PARAMPROB          12              /* ip header bad */
  101. #define ICMP_TSTAMP             13              /* timestamp request */
  102. #define ICMP_TSTAMPREPLY        14              /* timestamp reply */
  103. #define ICMP_IREQ               15              /* information request */
  104. #define ICMP_IREQREPLY          16              /* information reply */
  105. #define ICMP_MASKREQ            17              /* address mask request */
  106. #define ICMP_MASKREPLY          18              /* address mask reply */
  107.  
  108. #define ICMP_MAXTYPE            18
  109.  
  110. #define ICMP_INFOTYPE(type) \
  111.         ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
  112.         (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
  113.         (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
  114.         (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
  115.  
  116.  
  117. #pragma pack(1)
  118.  
  119. struct  icmpstat {
  120. /* statistics related to icmp packets generated */
  121.         short   icps_error;             /* # of calls to icmp_error */
  122.         short   icps_oldshort;          /* no error 'cuz old ip too short */
  123.         short   icps_oldicmp;           /* no error 'cuz old was icmp */
  124.         short   icps_outhist[ICMP_MAXTYPE + 1];
  125. /* statistics related to input messages processed */
  126.         short   icps_badcode;           /* icmp_code out of range */
  127.         short   icps_tooshort;          /* packet < ICMP_MINLEN */
  128.         short   icps_checksum;          /* bad checksum */
  129.         short   icps_badlen;            /* calculated bound mismatch */
  130.         short   icps_reflect;           /* number of responses */
  131.         short   icps_inhist[ICMP_MAXTYPE + 1];
  132.         u_long  icps_OutMsgs;
  133.         u_long  icps_OutErrors;
  134.         u_long  icps_InMsgs;
  135.         u_long  icps_InDestUnreachs;
  136.         u_long  icps_InTimeExcds;
  137.         u_long  icps_InParmProbs;
  138.         u_long  icps_InSrcQuenchs;
  139.         u_long  icps_InRedirects;
  140.         u_long  icps_InEchos;
  141.         u_long  icps_InEchoReps;
  142.         u_long  icps_InTimestamps;
  143.         u_long  icps_InTimestampReps;
  144.         u_long  icps_InAddrMasks;
  145.         u_long  icps_InAddrMaskReps;
  146.         u_long  icps_OutDestUnreachs;
  147.         u_long  icps_OutTimeExcds;
  148.         u_long  icps_OutParmProbs;
  149.         u_long  icps_OutSrcQuenchs;
  150.         u_long  icps_OutRedirects;
  151.         u_long  icps_OutEchos;
  152.         u_long  icps_OutEchoReps;
  153.         u_long  icps_OutTimestamps;
  154.         u_long  icps_OutTimestampReps;
  155.         u_long  icps_OutAddrMasks;
  156.         u_long  icps_OutAddrMaskReps;
  157. };
  158. #pragma pack()
  159.  
  160. #endif /* __IP_ICMP_32H */
  161.