1 mod dest_unreachable_header; 2 pub use dest_unreachable_header::*; 3 4 mod parameter_problem_header; 5 pub use parameter_problem_header::*; 6 7 mod redirect_code; 8 pub use redirect_code::*; 9 10 mod redirect_header; 11 pub use redirect_header::*; 12 13 mod time_exceeded_code; 14 pub use time_exceeded_code::*; 15 16 mod timestamp_message; 17 pub use timestamp_message::*; 18 19 /// ICMPv4 type value indicating a "Echo Reply" message (defined in [RFC 792](https://tools.ietf.org/html/rfc792)). 20 pub const TYPE_ECHO_REPLY: u8 = 0; 21 22 /// ICMPv4 type value indicating a "Destination Unreachable" message (defined in [RFC 792](https://tools.ietf.org/html/rfc792)). 23 pub const TYPE_DEST_UNREACH: u8 = 3; 24 25 /// ICMPv4 type value indicating a "Source Quench (Deprecated)" message (defined in in [RFC 792](https://tools.ietf.org/html/rfc792), deprecated in [RFC 6633](https://tools.ietf.org/html/rfc6633)). 26 pub const TYPE_SOURCE_QUENCH: u8 = 4; 27 28 /// ICMPv4 type value indicating a "Redirect" message (defined in [RFC 792](https://tools.ietf.org/html/rfc792)). 29 pub const TYPE_REDIRECT: u8 = 5; 30 31 /// ICMPv4 type value indicating a "Alternate Host Address (Deprecated)" message (deprecated in [RFC 6918](https://tools.ietf.org/html/rfc6918)). 32 pub const TYPE_ALTERNATE_HOST_ADDRESS: u8 = 6; 33 34 /// ICMPv4 type value indicating a "Echo Request" message (defined in [RFC 792](https://tools.ietf.org/html/rfc792)). 35 pub const TYPE_ECHO_REQUEST: u8 = 8; 36 37 /// ICMPv4 type value indicating a "Router Advertisement" message (defined in [RFC 1256](https://tools.ietf.org/html/rfc1256)). 38 pub const TYPE_ROUTER_ADVERTISEMENT: u8 = 9; 39 40 /// ICMPv4 type value indicating a "Router Solicitation" message (defined in [RFC 1256](https://tools.ietf.org/html/rfc1256)). 41 pub const TYPE_ROUTER_SOLICITATION: u8 = 10; 42 43 /// ICMPv4 type value indicating a "Time Exceeded" message (defined in [RFC 792](https://tools.ietf.org/html/rfc792)). 44 pub const TYPE_TIME_EXCEEDED: u8 = 11; 45 46 /// ICMPv4 type value indicating a "Parameter Problem" message (defined in [RFC 792](https://tools.ietf.org/html/rfc792)). 47 pub const TYPE_PARAMETER_PROBLEM: u8 = 12; 48 49 /// ICMPv4 type value indicating a "Timestamp" message (defined in [RFC 792](https://tools.ietf.org/html/rfc792)). 50 pub const TYPE_TIMESTAMP: u8 = 13; 51 52 /// ICMPv4 type value indicating a "Timestamp Reply" message (defined in [RFC 792](https://tools.ietf.org/html/rfc792)). 53 pub const TYPE_TIMESTAMP_REPLY: u8 = 14; 54 55 /// ICMPv4 type value indicating a "Information Request (Deprecated)" message (defined in in [RFC 792](https://tools.ietf.org/html/rfc792), deprecated in [RFC 6918](https://tools.ietf.org/html/rfc6918)). 56 pub const TYPE_INFO_REQUEST: u8 = 15; 57 58 /// ICMPv4 type value indicating a "Information Reply (Deprecated)" message (defined in in [RFC 792](https://tools.ietf.org/html/rfc792), deprecated in [RFC 6918](https://tools.ietf.org/html/rfc6918)). 59 pub const TYPE_INFO_REPLY: u8 = 16; 60 61 /// ICMPv4 type value indicating a "Address Mask Request (Deprecated)" message (defined in in [RFC 950](https://tools.ietf.org/html/rfc950), deprecated in [RFC 6918](https://tools.ietf.org/html/rfc6918)). 62 pub const TYPE_ADDRESS: u8 = 17; 63 64 /// ICMPv4 type value indicating a "Address Mask Reply (Deprecated)" message (defined in in [RFC 950](https://tools.ietf.org/html/rfc950), deprecated in [RFC 6918](https://tools.ietf.org/html/rfc6918)). 65 pub const TYPE_ADDRESSREPLY: u8 = 18; 66 67 /// ICMP destination unreachable code for "Net Unreachable" (defined in [RFC 792](https://tools.ietf.org/html/rfc792)) 68 pub const CODE_DST_UNREACH_NET: u8 = 0; 69 70 /// ICMP destination unreachable code for "Host Unreachable" (defined in [RFC 792](https://tools.ietf.org/html/rfc792)) 71 pub const CODE_DST_UNREACH_HOST: u8 = 1; 72 73 /// ICMP destination unreachable code for "Protocol Unreachable" (defined in [RFC 792](https://tools.ietf.org/html/rfc792)) 74 pub const CODE_DST_UNREACH_PROTOCOL: u8 = 2; 75 76 /// ICMP destination unreachable code for "Port Unreachable" (defined in [RFC 792](https://tools.ietf.org/html/rfc792)) 77 pub const CODE_DST_UNREACH_PORT: u8 = 3; 78 79 /// ICMP destination unreachable code for "Fragmentation Needed and Don't Fragment was Set" (defined in [RFC 792](https://tools.ietf.org/html/rfc792)) 80 pub const CODE_DST_UNREACH_NEED_FRAG: u8 = 4; 81 82 /// ICMP destination unreachable code for "Source Route Failed" (defined in [RFC 792](https://tools.ietf.org/html/rfc792)) 83 pub const CODE_DST_UNREACH_SOURCE_ROUTE_FAILED: u8 = 5; 84 85 /// ICMP destination unreachable code for "Destination Network Unknown" (defined in [RFC 1122](https://tools.ietf.org/html/rfc1122)) 86 pub const CODE_DST_UNREACH_NET_UNKNOWN: u8 = 6; 87 88 /// ICMP destination unreachable code for "Destination Host Unknown" (defined in [RFC 1122](https://tools.ietf.org/html/rfc1122)) 89 pub const CODE_DST_UNREACH_HOST_UNKNOWN: u8 = 7; 90 91 /// ICMP destination unreachable code for "Source Host Isolated" (defined in [RFC 1122](https://tools.ietf.org/html/rfc1122)) 92 pub const CODE_DST_UNREACH_ISOLATED: u8 = 8; 93 94 /// ICMP destination unreachable code for "Communication with Destination Network is Administratively Prohibited" (defined in [RFC 1122](https://tools.ietf.org/html/rfc1122)) 95 pub const CODE_DST_UNREACH_NET_PROHIB: u8 = 9; 96 97 /// ICMP destination unreachable code for "Communication with Destination Host is Administratively Prohibited" (defined in [RFC 1122](https://tools.ietf.org/html/rfc1122)) 98 pub const CODE_DST_UNREACH_HOST_PROHIB: u8 = 10; 99 100 /// ICMP destination unreachable code for "Destination Network Unreachable for Type of Service" (defined in [RFC 1122](https://tools.ietf.org/html/rfc1122)) 101 pub const CODE_DST_UNREACH_TOS_NET: u8 = 11; 102 103 /// ICMP destination unreachable code for "Destination Host Unreachable for Type of Service" (defined in [RFC 1122](https://tools.ietf.org/html/rfc1122)) 104 pub const CODE_DST_UNREACH_TOS_HOST: u8 = 12; 105 106 /// ICMP destination unreachable code for "Communication Administratively Prohibited" (defined in [RFC 1812](https://tools.ietf.org/html/rfc1812)) 107 pub const CODE_DST_UNREACH_FILTER_PROHIB: u8 = 13; 108 109 /// ICMP destination unreachable code for "Host Precedence Violation" (defined in [RFC 1812](https://tools.ietf.org/html/rfc1812)) 110 pub const CODE_DST_UNREACH_HOST_PRECEDENCE_VIOLATION: u8 = 14; 111 112 /// ICMP destination unreachable code for "Precedence cutoff in effect" (defined in [RFC 1812](https://tools.ietf.org/html/rfc1812)) 113 pub const CODE_DST_UNREACH_PRECEDENCE_CUTOFF: u8 = 15; 114 115 /// ICMPv4 "Redirect" code value for "Redirect Datagram for the Network (or subnet)". 116 pub const CODE_REDIRECT_FOR_NETWORK: u8 = 0; 117 118 /// ICMPv4 "Redirect" code value for "Redirect Datagram for the Host". 119 pub const CODE_REDIRECT_FOR_HOST: u8 = 1; 120 121 /// ICMPv4 "Redirect" code value for "Redirect Datagram for the Type of Service and Network". 122 pub const CODE_REDIRECT_TYPE_OF_SERVICE_AND_NETWORK: u8 = 2; 123 124 /// ICMPv4 "Redirect" code value for "Redirect Datagram for the Type of Service and Host". 125 pub const CODE_REDIRECT_TYPE_OF_SERVICE_AND_HOST: u8 = 3; 126 127 /// ICMPv4 "Time Exceeded" code value for "Time to Live exceeded in Transit". 128 pub const CODE_TIME_EXCEEDED_TTL_EXCEEDED_IN_TRANSIT: u8 = 0; 129 130 /// ICMPv4 "Time Exceeded" code value for "Fragment Reassembly Time Exceeded". 131 pub const CODE_TIME_EXCEEDED_FRAG_REASSEMBLY_TIME_EXCEEDED: u8 = 1; 132 133 /// ICMPv4 "Parameter Problem" code value for "Pointer indicates the error". 134 pub const CODE_PARAMETER_PROBLEM_POINTER_INDICATES_ERROR: u8 = 0; 135 136 /// ICMPv4 "Parameter Problem" code value for "Missing a Required Option". 137 pub const CODE_PARAMETER_PROBLEM_MISSING_REQUIRED_OPTION: u8 = 1; 138 139 /// ICMPv4 "Parameter Problem" code value for "Bad Length". 140 pub const CODE_PARAMETER_PROBLEM_BAD_LENGTH: u8 = 2; 141 142 #[cfg(test)] 143 mod test { 144 use super::*; 145 146 #[test] constants()147 fn constants() { 148 // icmp type numbers according to 149 // https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml#icmp-parameters-types 150 assert_eq!(TYPE_ECHO_REPLY, 0); 151 assert_eq!(TYPE_DEST_UNREACH, 3); 152 assert_eq!(TYPE_SOURCE_QUENCH, 4); 153 assert_eq!(TYPE_REDIRECT, 5); 154 assert_eq!(TYPE_ALTERNATE_HOST_ADDRESS, 6); 155 assert_eq!(TYPE_ECHO_REQUEST, 8); 156 assert_eq!(TYPE_ROUTER_ADVERTISEMENT, 9); 157 assert_eq!(TYPE_ROUTER_SOLICITATION, 10); 158 assert_eq!(TYPE_TIME_EXCEEDED, 11); 159 assert_eq!(TYPE_PARAMETER_PROBLEM, 12); 160 assert_eq!(TYPE_TIMESTAMP, 13); 161 assert_eq!(TYPE_TIMESTAMP_REPLY, 14); 162 assert_eq!(TYPE_INFO_REQUEST, 15); 163 assert_eq!(TYPE_INFO_REPLY, 16); 164 assert_eq!(TYPE_ADDRESS, 17); 165 assert_eq!(TYPE_ADDRESSREPLY, 18); 166 167 // destination unreachable code numbers according to 168 // https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml#icmp-parameters-codes-3 169 assert_eq!(0, CODE_DST_UNREACH_NET); 170 assert_eq!(1, CODE_DST_UNREACH_HOST); 171 assert_eq!(2, CODE_DST_UNREACH_PROTOCOL); 172 assert_eq!(3, CODE_DST_UNREACH_PORT); 173 assert_eq!(4, CODE_DST_UNREACH_NEED_FRAG); 174 assert_eq!(5, CODE_DST_UNREACH_SOURCE_ROUTE_FAILED); 175 assert_eq!(6, CODE_DST_UNREACH_NET_UNKNOWN); 176 assert_eq!(7, CODE_DST_UNREACH_HOST_UNKNOWN); 177 assert_eq!(8, CODE_DST_UNREACH_ISOLATED); 178 assert_eq!(9, CODE_DST_UNREACH_NET_PROHIB); 179 assert_eq!(10, CODE_DST_UNREACH_HOST_PROHIB); 180 assert_eq!(11, CODE_DST_UNREACH_TOS_NET); 181 assert_eq!(12, CODE_DST_UNREACH_TOS_HOST); 182 assert_eq!(13, CODE_DST_UNREACH_FILTER_PROHIB); 183 assert_eq!(14, CODE_DST_UNREACH_HOST_PRECEDENCE_VIOLATION); 184 assert_eq!(15, CODE_DST_UNREACH_PRECEDENCE_CUTOFF); 185 186 // redirect code numbers according to 187 // https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml#icmp-parameters-codes-5 188 assert_eq!(0, CODE_REDIRECT_FOR_NETWORK); 189 assert_eq!(1, CODE_REDIRECT_FOR_HOST); 190 assert_eq!(2, CODE_REDIRECT_TYPE_OF_SERVICE_AND_NETWORK); 191 assert_eq!(3, CODE_REDIRECT_TYPE_OF_SERVICE_AND_HOST); 192 193 // time exceeded code numbers according to 194 // https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml#icmp-parameters-codes-11 195 assert_eq!(0, CODE_TIME_EXCEEDED_TTL_EXCEEDED_IN_TRANSIT); 196 assert_eq!(1, CODE_TIME_EXCEEDED_FRAG_REASSEMBLY_TIME_EXCEEDED); 197 198 // parameter problem code numbers according to 199 // https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml#icmp-parameters-codes-12 200 assert_eq!(0, CODE_PARAMETER_PROBLEM_POINTER_INDICATES_ERROR); 201 assert_eq!(1, CODE_PARAMETER_PROBLEM_MISSING_REQUIRED_OPTION); 202 assert_eq!(2, CODE_PARAMETER_PROBLEM_BAD_LENGTH); 203 } 204 } 205