00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _NETINET_IP_ICMP_H_
00034 #define _NETINET_IP_ICMP_H_
00035
00036
00037
00038
00039
00040
00041 typedef u_int32_t n_time;
00042
00043
00044
00045
00046 struct icmp {
00047 u_char icmp_type;
00048 u_char icmp_code;
00049 u_short icmp_cksum;
00050 union {
00051 u_char ih_pptr;
00052 struct in_addr ih_gwaddr;
00053 struct ih_idseq {
00054 u_short icd_id;
00055 u_short icd_seq;
00056 } ih_idseq;
00057 int ih_void;
00058
00059
00060 struct ih_pmtu {
00061 u_short ipm_void;
00062 u_short ipm_nextmtu;
00063 } ih_pmtu;
00064 } icmp_hun;
00065 #define icmp_pptr icmp_hun.ih_pptr
00066 #define icmp_gwaddr icmp_hun.ih_gwaddr
00067 #define icmp_id icmp_hun.ih_idseq.icd_id
00068 #define icmp_seq icmp_hun.ih_idseq.icd_seq
00069 #define icmp_void icmp_hun.ih_void
00070 #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
00071 #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
00072 union {
00073 struct id_ts {
00074 n_time its_otime;
00075 n_time its_rtime;
00076 n_time its_ttime;
00077 } id_ts;
00078 struct id_ip {
00079 struct ip idi_ip;
00080
00081 } id_ip;
00082 uint32_t id_mask;
00083 char id_data[1];
00084 } icmp_dun;
00085 #define icmp_otime icmp_dun.id_ts.its_otime
00086 #define icmp_rtime icmp_dun.id_ts.its_rtime
00087 #define icmp_ttime icmp_dun.id_ts.its_ttime
00088 #define icmp_ip icmp_dun.id_ip.idi_ip
00089 #define icmp_mask icmp_dun.id_mask
00090 #define icmp_data icmp_dun.id_data
00091 };
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 #define ICMP_MINLEN 8
00102 #define ICMP_TSLEN (8 + 3 * sizeof (n_time))
00103 #define ICMP_MASKLEN 12
00104 #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8)
00105 #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
00106
00107
00108
00109
00110
00111 #define ICMP_ECHOREPLY 0
00112 #define ICMP_UNREACH 3
00113 #define ICMP_UNREACH_NET 0
00114 #define ICMP_UNREACH_HOST 1
00115 #define ICMP_UNREACH_PROTOCOL 2
00116 #define ICMP_UNREACH_PORT 3
00117 #define ICMP_UNREACH_NEEDFRAG 4
00118 #define ICMP_UNREACH_SRCFAIL 5
00119 #define ICMP_UNREACH_NET_UNKNOWN 6
00120 #define ICMP_UNREACH_HOST_UNKNOWN 7
00121 #define ICMP_UNREACH_ISOLATED 8
00122 #define ICMP_UNREACH_NET_PROHIB 9
00123 #define ICMP_UNREACH_HOST_PROHIB 10
00124 #define ICMP_UNREACH_TOSNET 11
00125 #define ICMP_UNREACH_TOSHOST 12
00126 #define ICMP_SOURCEQUENCH 4
00127 #define ICMP_REDIRECT 5
00128 #define ICMP_REDIRECT_NET 0
00129 #define ICMP_REDIRECT_HOST 1
00130 #define ICMP_REDIRECT_TOSNET 2
00131 #define ICMP_REDIRECT_TOSHOST 3
00132 #define ICMP_ECHO 8
00133 #define ICMP_ROUTERADVERT 9
00134 #define ICMP_ROUTERSOLICIT 10
00135 #define ICMP_TIMXCEED 11
00136 #define ICMP_TIMXCEED_INTRANS 0
00137 #define ICMP_TIMXCEED_REASS 1
00138 #define ICMP_PARAMPROB 12
00139 #define ICMP_PARAMPROB_OPTABSENT 1
00140 #define ICMP_TSTAMP 13
00141 #define ICMP_TSTAMPREPLY 14
00142 #define ICMP_IREQ 15
00143 #define ICMP_IREQREPLY 16
00144 #define ICMP_MASKREQ 17
00145 #define ICMP_MASKREPLY 18
00146
00147 #define ICMP_MAXTYPE 18
00148
00149 #define ICMP_INFOTYPE(type) \
00150 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
00151 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
00152 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
00153 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
00154 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
00155
00156 void icmp_input _P((struct mbuf *, int));
00157 void icmp_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
00158 const char *message);
00159 void icmp_reflect _P((struct mbuf *));
00160
00161 #endif