40 #ifndef included_ip_input_h 41 #define included_ip_input_h 67 *error = IP4_ERROR_OPTIONS;
69 *error = IP4_ERROR_BAD_CHECKSUM;
72 *error = IP4_ERROR_VERSION;
77 *error = IP4_ERROR_BAD_CHECKSUM;
84 u16 * next,
int verify_checksum)
86 u8 error0, error1, error2, error3;
87 u32 ip_len0, cur_len0;
88 u32 ip_len1, cur_len1;
89 u32 ip_len2, cur_len2;
90 u32 ip_len3, cur_len3;
91 i32 len_diff0, len_diff1, len_diff2, len_diff3;
93 error0 = error1 = error2 = error3 = IP4_ERROR_NONE;
101 error0 = IP4_ERROR_TIME_EXPIRED;
103 error1 = IP4_ERROR_TIME_EXPIRED;
105 error2 = IP4_ERROR_TIME_EXPIRED;
107 error3 = IP4_ERROR_TIME_EXPIRED;
111 IP4_ERROR_FRAGMENT_OFFSET_ONE : error0;
113 IP4_ERROR_FRAGMENT_OFFSET_ONE : error1;
115 IP4_ERROR_FRAGMENT_OFFSET_ONE : error2;
117 IP4_ERROR_FRAGMENT_OFFSET_ONE : error3;
120 ip_len0 = clib_net_to_host_u16 (ip[0]->length);
121 ip_len1 = clib_net_to_host_u16 (ip[1]->length);
122 ip_len2 = clib_net_to_host_u16 (ip[2]->length);
123 ip_len3 = clib_net_to_host_u16 (ip[3]->length);
126 error0 = ip_len0 <
sizeof (ip[0][0]) ? IP4_ERROR_TOO_SHORT : error0;
127 error1 = ip_len1 <
sizeof (ip[1][0]) ? IP4_ERROR_TOO_SHORT : error1;
128 error2 = ip_len2 <
sizeof (ip[2][0]) ? IP4_ERROR_TOO_SHORT : error2;
129 error3 = ip_len3 <
sizeof (ip[3][0]) ? IP4_ERROR_TOO_SHORT : error3;
136 len_diff0 = cur_len0 - ip_len0;
137 len_diff1 = cur_len1 - ip_len1;
138 len_diff2 = cur_len2 - ip_len2;
139 len_diff3 = cur_len3 - ip_len3;
141 error0 = len_diff0 < 0 ? IP4_ERROR_BAD_LENGTH : error0;
142 error1 = len_diff1 < 0 ? IP4_ERROR_BAD_LENGTH : error1;
143 error2 = len_diff2 < 0 ? IP4_ERROR_BAD_LENGTH : error2;
144 error3 = len_diff3 < 0 ? IP4_ERROR_BAD_LENGTH : error3;
148 if (error0 == IP4_ERROR_TIME_EXPIRED)
151 ICMP4_time_exceeded_ttl_exceeded_in_transit,
156 next[0] = error0 != IP4_ERROR_OPTIONS ?
162 if (error1 == IP4_ERROR_TIME_EXPIRED)
165 ICMP4_time_exceeded_ttl_exceeded_in_transit,
170 next[1] = error1 != IP4_ERROR_OPTIONS ?
176 if (error2 == IP4_ERROR_TIME_EXPIRED)
179 ICMP4_time_exceeded_ttl_exceeded_in_transit,
184 next[2] = error2 != IP4_ERROR_OPTIONS ?
190 if (error3 == IP4_ERROR_TIME_EXPIRED)
193 ICMP4_time_exceeded_ttl_exceeded_in_transit,
198 next[3] = error3 != IP4_ERROR_OPTIONS ?
209 u32 * next0,
u32 * next1,
int verify_checksum)
212 u32 ip_len0, cur_len0;
213 u32 ip_len1, cur_len1;
214 i32 len_diff0, len_diff1;
216 error0 = error1 = IP4_ERROR_NONE;
222 error0 = IP4_ERROR_TIME_EXPIRED;
224 error1 = IP4_ERROR_TIME_EXPIRED;
228 IP4_ERROR_FRAGMENT_OFFSET_ONE : error0;
230 IP4_ERROR_FRAGMENT_OFFSET_ONE : error1;
233 ip_len0 = clib_net_to_host_u16 (ip0->
length);
234 ip_len1 = clib_net_to_host_u16 (ip1->
length);
237 error0 = ip_len0 <
sizeof (ip0[0]) ? IP4_ERROR_TOO_SHORT : error0;
238 error1 = ip_len1 <
sizeof (ip1[0]) ? IP4_ERROR_TOO_SHORT : error1;
243 len_diff0 = cur_len0 - ip_len0;
244 len_diff1 = cur_len1 - ip_len1;
246 error0 = len_diff0 < 0 ? IP4_ERROR_BAD_LENGTH : error0;
247 error1 = len_diff1 < 0 ? IP4_ERROR_BAD_LENGTH : error1;
251 if (error0 == IP4_ERROR_TIME_EXPIRED)
254 ICMP4_time_exceeded_ttl_exceeded_in_transit,
259 *next0 = error0 != IP4_ERROR_OPTIONS ?
265 if (error1 == IP4_ERROR_TIME_EXPIRED)
268 ICMP4_time_exceeded_ttl_exceeded_in_transit,
273 *next1 = error1 != IP4_ERROR_OPTIONS ?
285 u32 ip_len0, cur_len0;
289 error0 = IP4_ERROR_NONE;
294 error0 = IP4_ERROR_TIME_EXPIRED;
298 IP4_ERROR_FRAGMENT_OFFSET_ONE : error0;
301 ip_len0 = clib_net_to_host_u16 (ip0->
length);
304 error0 = ip_len0 <
sizeof (ip0[0]) ? IP4_ERROR_TOO_SHORT : error0;
308 len_diff0 = cur_len0 - ip_len0;
310 error0 = len_diff0 < 0 ? IP4_ERROR_BAD_LENGTH : error0;
314 if (error0 == IP4_ERROR_TIME_EXPIRED)
317 ICMP4_time_exceeded_ttl_exceeded_in_transit,
322 *next0 = error0 != IP4_ERROR_OPTIONS ?
static int ip4_header_bytes(ip4_header_t *i)
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.
#define static_always_inline
static int ip4_get_fragment_offset(ip4_header_t *i)
static_always_inline u16 ip_csum(void *data, u16 n_left)
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)