40 #ifndef included_ip_input_h 41 #define included_ip_input_h 63 u16 * next,
int verify_checksum)
65 u8 error0, error1, error2, error3;
66 u32 ip_len0, cur_len0;
67 u32 ip_len1, cur_len1;
68 u32 ip_len2, cur_len2;
69 u32 ip_len3, cur_len3;
70 i32 len_diff0, len_diff1, len_diff2, len_diff3;
72 error0 = error1 = error2 = error3 = IP4_ERROR_NONE;
75 if (
PREDICT_FALSE (ip[0]->ip_version_and_header_length != 0x45))
77 IP4_ERROR_OPTIONS : IP4_ERROR_VERSION;
79 if (
PREDICT_FALSE (ip[1]->ip_version_and_header_length != 0x45))
80 error1 = (ip[1]->ip_version_and_header_length & 0xf) != 5 ?
81 IP4_ERROR_OPTIONS : IP4_ERROR_VERSION;
83 if (
PREDICT_FALSE (ip[2]->ip_version_and_header_length != 0x45))
84 error2 = (ip[2]->ip_version_and_header_length & 0xf) != 5 ?
85 IP4_ERROR_OPTIONS : IP4_ERROR_VERSION;
87 if (
PREDICT_FALSE (ip[3]->ip_version_and_header_length != 0x45))
88 error3 = (ip[3]->ip_version_and_header_length & 0xf) != 5 ?
89 IP4_ERROR_OPTIONS : IP4_ERROR_VERSION;
92 error0 = IP4_ERROR_TIME_EXPIRED;
94 error1 = IP4_ERROR_TIME_EXPIRED;
96 error2 = IP4_ERROR_TIME_EXPIRED;
98 error3 = IP4_ERROR_TIME_EXPIRED;
111 IP4_ERROR_BAD_CHECKSUM : error0;
113 IP4_ERROR_BAD_CHECKSUM : error1;
115 IP4_ERROR_BAD_CHECKSUM : error2;
117 IP4_ERROR_BAD_CHECKSUM : error3;
122 IP4_ERROR_FRAGMENT_OFFSET_ONE : error0;
124 IP4_ERROR_FRAGMENT_OFFSET_ONE : error1;
126 IP4_ERROR_FRAGMENT_OFFSET_ONE : error2;
128 IP4_ERROR_FRAGMENT_OFFSET_ONE : error3;
131 ip_len0 = clib_net_to_host_u16 (ip[0]->length);
132 ip_len1 = clib_net_to_host_u16 (ip[1]->length);
133 ip_len2 = clib_net_to_host_u16 (ip[2]->length);
134 ip_len3 = clib_net_to_host_u16 (ip[3]->length);
137 error0 = ip_len0 <
sizeof (ip[0][0]) ? IP4_ERROR_TOO_SHORT : error0;
138 error1 = ip_len1 <
sizeof (ip[1][0]) ? IP4_ERROR_TOO_SHORT : error1;
139 error2 = ip_len2 <
sizeof (ip[2][0]) ? IP4_ERROR_TOO_SHORT : error2;
140 error3 = ip_len3 <
sizeof (ip[3][0]) ? IP4_ERROR_TOO_SHORT : error3;
147 len_diff0 = cur_len0 - ip_len0;
148 len_diff1 = cur_len1 - ip_len1;
149 len_diff2 = cur_len2 - ip_len2;
150 len_diff3 = cur_len3 - ip_len3;
152 error0 = len_diff0 < 0 ? IP4_ERROR_BAD_LENGTH : error0;
153 error1 = len_diff1 < 0 ? IP4_ERROR_BAD_LENGTH : error1;
154 error2 = len_diff2 < 0 ? IP4_ERROR_BAD_LENGTH : error2;
155 error3 = len_diff3 < 0 ? IP4_ERROR_BAD_LENGTH : error3;
159 if (error0 == IP4_ERROR_TIME_EXPIRED)
162 ICMP4_time_exceeded_ttl_exceeded_in_transit,
167 next[0] = error0 != IP4_ERROR_OPTIONS ?
173 if (error1 == IP4_ERROR_TIME_EXPIRED)
176 ICMP4_time_exceeded_ttl_exceeded_in_transit,
181 next[1] = error1 != IP4_ERROR_OPTIONS ?
187 if (error2 == IP4_ERROR_TIME_EXPIRED)
190 ICMP4_time_exceeded_ttl_exceeded_in_transit,
195 next[2] = error2 != IP4_ERROR_OPTIONS ?
201 if (error3 == IP4_ERROR_TIME_EXPIRED)
204 ICMP4_time_exceeded_ttl_exceeded_in_transit,
209 next[3] = error3 != IP4_ERROR_OPTIONS ?
220 u32 * next0,
u32 * next1,
int verify_checksum)
223 u32 ip_len0, cur_len0;
224 u32 ip_len1, cur_len1;
225 i32 len_diff0, len_diff1;
227 error0 = error1 = IP4_ERROR_NONE;
232 IP4_ERROR_OPTIONS : IP4_ERROR_VERSION;
236 IP4_ERROR_OPTIONS : IP4_ERROR_VERSION;
239 error0 = IP4_ERROR_TIME_EXPIRED;
241 error1 = IP4_ERROR_TIME_EXPIRED;
252 IP4_ERROR_BAD_CHECKSUM : error0;
254 IP4_ERROR_BAD_CHECKSUM : error1;
259 IP4_ERROR_FRAGMENT_OFFSET_ONE : error0;
261 IP4_ERROR_FRAGMENT_OFFSET_ONE : error1;
264 ip_len0 = clib_net_to_host_u16 (ip0->
length);
265 ip_len1 = clib_net_to_host_u16 (ip1->
length);
268 error0 = ip_len0 <
sizeof (ip0[0]) ? IP4_ERROR_TOO_SHORT : error0;
269 error1 = ip_len1 <
sizeof (ip1[0]) ? IP4_ERROR_TOO_SHORT : error1;
274 len_diff0 = cur_len0 - ip_len0;
275 len_diff1 = cur_len1 - ip_len1;
277 error0 = len_diff0 < 0 ? IP4_ERROR_BAD_LENGTH : error0;
278 error1 = len_diff1 < 0 ? IP4_ERROR_BAD_LENGTH : error1;
282 if (error0 == IP4_ERROR_TIME_EXPIRED)
285 ICMP4_time_exceeded_ttl_exceeded_in_transit,
290 *next0 = error0 != IP4_ERROR_OPTIONS ?
296 if (error1 == IP4_ERROR_TIME_EXPIRED)
299 ICMP4_time_exceeded_ttl_exceeded_in_transit,
304 *next1 = error1 != IP4_ERROR_OPTIONS ?
317 u32 ip_len0, cur_len0;
321 error0 = IP4_ERROR_NONE;
326 IP4_ERROR_OPTIONS : IP4_ERROR_VERSION;
336 IP4_ERROR_BAD_CHECKSUM : error0;
341 IP4_ERROR_FRAGMENT_OFFSET_ONE : error0;
344 ip_len0 = clib_net_to_host_u16 (ip0->
length);
347 error0 = ip_len0 <
sizeof (ip0[0]) ? IP4_ERROR_TOO_SHORT : error0;
351 len_diff0 = cur_len0 - ip_len0;
353 error0 = len_diff0 < 0 ? IP4_ERROR_BAD_LENGTH : error0;
357 if (error0 == IP4_ERROR_TIME_EXPIRED)
360 ICMP4_time_exceeded_ttl_exceeded_in_transit,
365 *next0 = error0 != IP4_ERROR_OPTIONS ?
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static int ip4_get_fragment_offset(ip4_header_t *i)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
#define ip4_partial_header_checksum_x1(ip0, sum0)
static u16 ip_csum_fold(ip_csum_t c)