home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / network / src_1218.zip / ICMP.H < prev    next >
C/C++ Source or Header  |  1991-07-22  |  5KB  |  155 lines

  1. #ifndef    _ICMP_H
  2. #define    _ICMP_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef    _IFACE_H
  13. #include "iface.h"
  14. #endif
  15.  
  16. #ifndef    _INTERNET_H
  17. #include "internet.h"
  18. #endif
  19.  
  20. #ifndef _IP_H
  21. #include "ip.h"
  22. #endif
  23.  
  24. #ifndef _SESSION_H
  25. #include "session.h"
  26. #endif
  27.  
  28. /* SNMP MIB variables, used for statistics and control. See RFC 1066 */
  29. extern struct mib_entry Icmp_mib[];
  30. #define    icmpInMsgs        Icmp_mib[1].value.integer
  31. #define    icmpInErrors        Icmp_mib[2].value.integer
  32. #define icmpInDestUnreachs    Icmp_mib[3].value.integer
  33. #define icmpInTimeExcds        Icmp_mib[4].value.integer
  34. #define icmpInParmProbs        Icmp_mib[5].value.integer
  35. #define icmpInSrcQuenchs    Icmp_mib[6].value.integer
  36. #define icmpInRedirects        Icmp_mib[7].value.integer
  37. #define icmpInEchos        Icmp_mib[8].value.integer
  38. #define icmpInEchoReps        Icmp_mib[9].value.integer
  39. #define icmpInTimestamps    Icmp_mib[10].value.integer
  40. #define icmpInTimestampReps    Icmp_mib[11].value.integer
  41. #define icmpInAddrMasks        Icmp_mib[12].value.integer
  42. #define icmpInAddrMaskReps    Icmp_mib[13].value.integer
  43. #define icmpOutMsgs        Icmp_mib[14].value.integer
  44. #define icmpOutErrors        Icmp_mib[15].value.integer
  45. #define icmpOutDestUnreachs    Icmp_mib[16].value.integer
  46. #define icmpOutTimeExcds    Icmp_mib[17].value.integer
  47. #define icmpOutParmProbs    Icmp_mib[18].value.integer
  48. #define icmpOutSrcQuenchs    Icmp_mib[19].value.integer
  49. #define icmpOutRedirects    Icmp_mib[20].value.integer
  50. #define icmpOutEchos        Icmp_mib[21].value.integer
  51. #define icmpOutEchoReps        Icmp_mib[22].value.integer
  52. #define icmpOutTimestamps    Icmp_mib[23].value.integer
  53. #define icmpOutTimestampReps    Icmp_mib[24].value.integer
  54. #define icmpOutAddrMasks    Icmp_mib[25].value.integer
  55. #define icmpOutAddrMaskReps    Icmp_mib[26].value.integer
  56. #define    NUMICMPMIB    26
  57.  
  58. /* Internet Control Message Protocol */
  59.  
  60. /* Message types */
  61. #define    ICMP_ECHO_REPLY        0    /* Echo Reply */
  62. #define    ICMP_DEST_UNREACH    3    /* Destination Unreachable */
  63. #define    ICMP_QUENCH        4    /* Source Quench */
  64. #define    ICMP_REDIRECT        5    /* Redirect */
  65. #define    ICMP_ECHO        8    /* Echo Request */
  66. #define    ICMP_TIME_EXCEED    11    /* Time-to-live Exceeded */
  67. #define    ICMP_PARAM_PROB        12    /* Parameter Problem */
  68. #define    ICMP_TIMESTAMP        13    /* Timestamp */
  69. #define    ICMP_TIME_REPLY        14    /* Timestamp Reply */
  70. #define    ICMP_INFO_RQST        15    /* Information Request */
  71. #define    ICMP_INFO_REPLY        16    /* Information Reply */
  72. #define    ICMP_ADDR_MASK        17    /* Address mask request */
  73. #define    ICMP_ADDR_MASK_REPLY    18    /* Address mask reply */
  74. #define    ICMP_TYPES        19
  75.  
  76. /* Internal format of an ICMP header (checksum is missing) */
  77. struct icmp {
  78.     char type;
  79.     char code;
  80.      union icmp_args {
  81.         int16 mtu;
  82.         int32 unused;
  83.         unsigned char pointer;
  84.         int32 address;
  85.         struct {
  86.             int16 id;
  87.             int16 seq;
  88.         } echo;
  89.     } args;
  90. };
  91. #define    ICMPLEN        8    /* Length of ICMP header on the net */
  92. #define    NULLICMP    (union icmp_args *)0
  93.     
  94. /* Destination Unreachable codes */
  95. #define    ICMP_NET_UNREACH    0    /* Net unreachable */
  96. #define    ICMP_HOST_UNREACH    1    /* Host unreachable */
  97. #define    ICMP_PROT_UNREACH    2    /* Protocol unreachable */
  98. #define    ICMP_PORT_UNREACH    3    /* Port unreachable */
  99. #define    ICMP_FRAG_NEEDED    4    /* Fragmentation needed and DF set */
  100. #define    ICMP_ROUTE_FAIL        5    /* Source route failed */
  101. #define ICMP_ADMIN_PROHIB       13      /* Administrativly prohibbited */
  102.  
  103. #define NUNREACH    14
  104.  
  105. /* Time Exceeded codes */
  106. #define    ICMP_TTL_EXCEED        0    /* Time-to-live exceeded */
  107. #define    ICMP_FRAG_EXCEED    1    /* Fragment reassembly time exceeded */
  108.  
  109. #define    NEXCEED        2
  110.  
  111. /* Redirect message codes */
  112. #define    ICMP_REDR_NET    0    /* Redirect for the network */
  113. #define    ICMP_REDR_HOST    1    /* Redirect for the host */
  114. #define    ICMP_REDR_TOS    2    /* Redirect for Type of Service, or-ed with prev */
  115.  
  116. #define    NREDIRECT    3
  117.  
  118. extern int Icmp_trace;
  119.  
  120. struct ping {
  121.     struct session *sp;
  122.     int32 target;        /* Starting target IP address */
  123.     int incflag;        /* If true, increment target after each ping */
  124.     int32 sent;        /* Total number of pings sent */
  125.     int32 srtt;        /* Smoothed round trip time */
  126.     int32 mdev;        /* Mean deviation */
  127.     int32 responses;    /* Total number of responses */
  128.     int32 interval;        /* Inter-ping interval, ticks */
  129.     int16 len;        /* Length of data portion of ping */
  130. };
  131. /* ICMP messages, decoded */
  132. extern char *Icmptypes[],*Unreach[],*Exceed[],*Redirect[];
  133.  
  134. struct icmplink {
  135.     char proto;
  136.     void (*funct) __ARGS((int32,int32,int32,char,char,struct mbuf **));
  137. };
  138. extern struct icmplink Icmplink[];
  139.  
  140. /* In icmp.c: */
  141. void icmp_input __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,
  142.     int rxbroadcast));
  143. int icmp_output __ARGS((struct ip *ip,struct mbuf *data,char type,char code,
  144.     union icmp_args *args));
  145.  
  146. /* In icmpcmd.c: */
  147. void echo_proc __ARGS((int32 source,int32 dest,struct icmp *icmp,struct mbuf *bp));
  148. int pingem __ARGS((int s,int32 target,int16 seq,int16 id,int16 len));
  149.  
  150. /* In icmphdr.c: */
  151. struct mbuf *htonicmp __ARGS((struct icmp *icmp,struct mbuf *data));
  152. int ntohicmp __ARGS((struct icmp *icmp,struct mbuf **bpp));
  153.  
  154. #endif    /* _ICMP_H */
  155.