40 #ifndef included_ip_input_h 41 #define included_ip_input_h 65 *error = IP4_ERROR_OPTIONS;
67 *error = IP4_ERROR_BAD_CHECKSUM;
70 *error = IP4_ERROR_VERSION;
75 *error = IP4_ERROR_BAD_CHECKSUM;
82 u16 * next,
int verify_checksum)
84 u8 error0, error1, error2, error3;
85 u32 ip_len0, cur_len0;
86 u32 ip_len1, cur_len1;
87 u32 ip_len2, cur_len2;
88 u32 ip_len3, cur_len3;
89 i32 len_diff0, len_diff1, len_diff2, len_diff3;
91 error0 = error1 = error2 = error3 = IP4_ERROR_NONE;
99 error0 = IP4_ERROR_TIME_EXPIRED;
101 error1 = IP4_ERROR_TIME_EXPIRED;
103 error2 = IP4_ERROR_TIME_EXPIRED;
105 error3 = IP4_ERROR_TIME_EXPIRED;
109 IP4_ERROR_FRAGMENT_OFFSET_ONE : error0;
111 IP4_ERROR_FRAGMENT_OFFSET_ONE : error1;
113 IP4_ERROR_FRAGMENT_OFFSET_ONE : error2;
115 IP4_ERROR_FRAGMENT_OFFSET_ONE : error3;
118 ip_len0 = clib_net_to_host_u16 (ip[0]->
length);
119 ip_len1 = clib_net_to_host_u16 (ip[1]->
length);
120 ip_len2 = clib_net_to_host_u16 (ip[2]->
length);
121 ip_len3 = clib_net_to_host_u16 (ip[3]->
length);
124 error0 = ip_len0 <
sizeof (ip[0][0]) ? IP4_ERROR_TOO_SHORT : error0;
125 error1 = ip_len1 <
sizeof (ip[1][0]) ? IP4_ERROR_TOO_SHORT : error1;
126 error2 = ip_len2 <
sizeof (ip[2][0]) ? IP4_ERROR_TOO_SHORT : error2;
127 error3 = ip_len3 <
sizeof (ip[3][0]) ? IP4_ERROR_TOO_SHORT : error3;
134 len_diff0 = cur_len0 - ip_len0;
135 len_diff1 = cur_len1 - ip_len1;
136 len_diff2 = cur_len2 - ip_len2;
137 len_diff3 = cur_len3 - ip_len3;
139 error0 = len_diff0 < 0 ? IP4_ERROR_BAD_LENGTH : error0;
140 error1 = len_diff1 < 0 ? IP4_ERROR_BAD_LENGTH : error1;
141 error2 = len_diff2 < 0 ? IP4_ERROR_BAD_LENGTH : error2;
142 error3 = len_diff3 < 0 ? IP4_ERROR_BAD_LENGTH : error3;
146 if (error0 == IP4_ERROR_TIME_EXPIRED)
149 ICMP4_time_exceeded_ttl_exceeded_in_transit,
154 next[0] = error0 != IP4_ERROR_OPTIONS ?
160 if (error1 == IP4_ERROR_TIME_EXPIRED)
163 ICMP4_time_exceeded_ttl_exceeded_in_transit,
168 next[1] = error1 != IP4_ERROR_OPTIONS ?
174 if (error2 == IP4_ERROR_TIME_EXPIRED)
177 ICMP4_time_exceeded_ttl_exceeded_in_transit,
182 next[2] = error2 != IP4_ERROR_OPTIONS ?
188 if (error3 == IP4_ERROR_TIME_EXPIRED)
191 ICMP4_time_exceeded_ttl_exceeded_in_transit,
196 next[3] = error3 != IP4_ERROR_OPTIONS ?
207 u32 * next0,
u32 * next1,
int verify_checksum)
210 u32 ip_len0, cur_len0;
211 u32 ip_len1, cur_len1;
212 i32 len_diff0, len_diff1;
214 error0 = error1 = IP4_ERROR_NONE;
220 error0 = IP4_ERROR_TIME_EXPIRED;
222 error1 = IP4_ERROR_TIME_EXPIRED;
226 IP4_ERROR_FRAGMENT_OFFSET_ONE : error0;
228 IP4_ERROR_FRAGMENT_OFFSET_ONE : error1;
231 ip_len0 = clib_net_to_host_u16 (ip0->
length);
232 ip_len1 = clib_net_to_host_u16 (ip1->
length);
235 error0 = ip_len0 <
sizeof (ip0[0]) ? IP4_ERROR_TOO_SHORT : error0;
236 error1 = ip_len1 <
sizeof (ip1[0]) ? IP4_ERROR_TOO_SHORT : error1;
241 len_diff0 = cur_len0 - ip_len0;
242 len_diff1 = cur_len1 - ip_len1;
244 error0 = len_diff0 < 0 ? IP4_ERROR_BAD_LENGTH : error0;
245 error1 = len_diff1 < 0 ? IP4_ERROR_BAD_LENGTH : error1;
249 if (error0 == IP4_ERROR_TIME_EXPIRED)
252 ICMP4_time_exceeded_ttl_exceeded_in_transit,
257 *next0 = error0 != IP4_ERROR_OPTIONS ?
263 if (error1 == IP4_ERROR_TIME_EXPIRED)
266 ICMP4_time_exceeded_ttl_exceeded_in_transit,
271 *next1 = error1 != IP4_ERROR_OPTIONS ?
283 u32 ip_len0, cur_len0;
287 error0 = IP4_ERROR_NONE;
292 error0 = IP4_ERROR_TIME_EXPIRED;
296 IP4_ERROR_FRAGMENT_OFFSET_ONE : error0;
299 ip_len0 = clib_net_to_host_u16 (ip0->
length);
302 error0 = ip_len0 <
sizeof (ip0[0]) ? IP4_ERROR_TOO_SHORT : error0;
306 len_diff0 = cur_len0 - ip_len0;
308 error0 = len_diff0 < 0 ? IP4_ERROR_BAD_LENGTH : error0;
312 if (error0 == IP4_ERROR_TIME_EXPIRED)
315 ICMP4_time_exceeded_ttl_exceeded_in_transit,
320 *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.
#define static_always_inline
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static_always_inline u16 ip_csum(void *data, u16 n_left)
static u16 ip4_get_fragment_offset(const ip4_header_t *i)
VLIB buffer representation.
static int ip4_header_bytes(const ip4_header_t *i)
static_always_inline void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)