home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / internet / tcpipsrc / h / ICMP < prev    next >
Text File  |  1994-01-07  |  3KB  |  83 lines

  1. /* Internet Control Message Protocol */
  2.  
  3. /* Message types */
  4. #define ECHO_REPLY      0       /* Echo Reply */
  5. #define DEST_UNREACH    3       /* Destination Unreachable */
  6. #define QUENCH          4       /* Source Quench */
  7. #define REDIRECT        5       /* Redirect */
  8. #define ECHO            8       /* Echo Request */
  9. #define TIME_EXCEED     11      /* Time-to-live Exceeded */
  10. #define PARAM_PROB      12      /* Parameter Problem */
  11. #define TIMESTAMP       13      /* Timestamp */
  12. #define TIME_REPLY      14      /* Timestamp Reply */
  13. #define INFO_RQST       15      /* Information Request */
  14. #define INFO_REPLY      16      /* Information Reply */
  15.  
  16. /* Internal format of an ICMP header (checksum is missing) */
  17. struct icmp {
  18.         char type;
  19.         char code;
  20.         union icmp_args {
  21.                 int32 unused;
  22.                 unsigned char pointer;
  23.                 int32 address;
  24.                 struct {
  25.                         int16 id;
  26.                         int16 seq;
  27.                 } echo;
  28.         } args;
  29. };
  30. #define ICMPLEN         8       /* Length of ICMP header on the net */
  31. #define NULLICMP        (union icmp_args *)0
  32.         
  33. /* Destination Unreachable codes */
  34. #define NET_UNREACH     0       /* Net unreachable */
  35. #define HOST_UNREACH    1       /* Host unreachable */
  36. #define PROT_UNREACH    2       /* Protocol unreachable */
  37. #define PORT_UNREACH    3       /* Port unreachable */
  38. #define FRAG_NEEDED     4       /* Fragmentation needed and DF set */
  39. #define ROUTE_FAIL      5       /* Source route failed */
  40. #define ADMIN_PROHIB   13       /* Administrativly prohibbited */
  41.  
  42. /* Time Exceeded codes */
  43. #define TTL_EXCEED      0       /* Time-to-live exceeded */
  44. #define FRAG_EXCEED     1       /* Fragment reassembly time exceeded */
  45.  
  46. /* Redirect message codes */
  47. #define REDR_NET        0       /* Redirect for the network */
  48. #define REDR_HOST       1       /* Redirect for the host */
  49. #define REDR_TOS        2       /* Redirect for Type of Service, or-ed with prev */
  50.  
  51. struct icmp_errors {
  52.         unsigned checksum;              /* ICMP Checksum errors */
  53.         unsigned nospace;               /* alloc_mbuf failed someplace */
  54.         unsigned noloop;                /* No ICMP in response to an ICMP */
  55.         unsigned bdcsts;                /* Ignore broadcast ICMPs */
  56. };
  57. #define ICMP_TYPES      17
  58. struct icmp_stats {
  59.         unsigned input[ICMP_TYPES];     /* ICMP input stats by type */
  60.         unsigned output[ICMP_TYPES];    /* ICMP output stats by type */
  61. };
  62.  
  63. /* In ICMP */
  64. void icmp_input(struct mbuf *, char, int32, int32, char, int16, char);
  65. int  icmp_output(struct ip *, struct mbuf *, char, char, union icmp_args *);
  66. struct mbuf *htonicmp(struct icmp *, struct mbuf *);
  67. int  ntohicmp(struct icmp *, struct mbuf **);
  68.  
  69. /* In ICMPCMD */
  70. int  doicmpstat(void);
  71. void icmpclk(void);
  72. int  doping(int, char **);
  73. int  dohop(int, char **);
  74. void hop_rec(struct icmp *, struct udp *, int32, int16);
  75. void ptimeout(char *);
  76. void echo_proc(int32, int32, struct icmp *);
  77.  
  78. /* In ICMPDUMP */
  79. void icmp_dump(struct mbuf **, int32, int32, int);
  80.  
  81. /* ICMP messages, decoded */
  82. extern char *icmptypes[],*unreach[],*exceed[],*redirect[];
  83.