54 u8 code = va_arg (*args,
int);
57 #define _(n,f) case n: t = #f; break; 70 return format (s,
"unknown 0x%x", type);
75 switch ((type << 8) | code)
77 #define _(a,n,f) case (ICMP4_##a << 8) | (n): t = #f; break; 92 icmp46_header_t * icmp = va_arg (*args, icmp46_header_t *);
93 u32 max_header_bytes = va_arg (*args,
u32);
96 if (max_header_bytes <
sizeof (icmp[0]))
97 return format (s,
"ICMP header truncated");
99 s =
format (s,
"ICMP %U checksum 0x%x",
101 clib_net_to_host_u16 (icmp->checksum));
130 u8 ip4_input_next_index_by_type[256];
142 u32 * from, * to_next;
143 u32 n_left_from, n_left_to_next, next;
146 n_left_from = n_packets;
154 while (n_left_from > 0)
158 while (n_left_from > 0 && n_left_to_next > 0)
162 icmp46_header_t * icmp0;
174 bi0 = to_next[0] = from[0];
187 p0->
error = node->
errors[ICMP4_ERROR_UNKNOWN_TYPE];
207 .name =
"ip4-icmp-input",
209 .vector_size =
sizeof (
u32),
228 u32 * from, * to_next;
229 u32 n_left_from, n_left_to_next, next;
231 u16 * fragment_ids, * fid;
235 n_left_from = n_packets;
245 n_packets * sizeof (fragment_ids[0]));
247 while (n_left_from > 0)
251 while (n_left_from > 2 && n_left_to_next > 2)
255 icmp46_header_t * icmp0, * icmp1;
260 bi0 = to_next[0] = from[0];
261 bi1 = to_next[1] = from[1];
279 sum0 = icmp0->checksum;
280 sum1 = icmp1->checksum;
282 ASSERT (icmp0->type == ICMP4_echo_request);
283 ASSERT (icmp1->type == ICMP4_echo_request);
284 sum0 =
ip_csum_update (sum0, ICMP4_echo_request, ICMP4_echo_reply,
285 icmp46_header_t,
type);
286 sum1 =
ip_csum_update (sum1, ICMP4_echo_request, ICMP4_echo_reply,
287 icmp46_header_t,
type);
288 icmp0->type = ICMP4_echo_reply;
289 icmp1->type = ICMP4_echo_reply;
314 ip0->
ttl = host_config_ttl;
315 ip1->
ttl = host_config_ttl;
333 while (n_left_from > 0 && n_left_to_next > 0)
337 icmp46_header_t * icmp0;
341 bi0 = to_next[0] = from[0];
355 sum0 = icmp0->checksum;
357 ASSERT (icmp0->type == ICMP4_echo_request);
358 sum0 =
ip_csum_update (sum0, ICMP4_echo_request, ICMP4_echo_reply,
359 icmp46_header_t,
type);
360 icmp0->type = ICMP4_echo_reply;
373 ip0->
ttl = host_config_ttl;
389 ICMP4_ERROR_ECHO_REPLIES_SENT,
397 .name =
"ip4-icmp-echo-request",
399 .vector_size =
sizeof (
u32),
405 [0] =
"ip4-rewrite-local",
427 case ICMP4_destination_unreachable:
428 return ICMP4_ERROR_DEST_UNREACH_SENT;
429 case ICMP4_time_exceeded:
430 return ICMP4_ERROR_TTL_EXPIRE_SENT;
431 case ICMP4_parameter_problem:
432 return ICMP4_ERROR_PARAM_PROBLEM_SENT;
434 return ICMP4_ERROR_DROP;
443 u32 * from, * to_next;
444 uword n_left_from, n_left_to_next;
457 while (n_left_from > 0) {
460 while (n_left_from > 0 && n_left_to_next > 0) {
463 u8 error0 = ICMP4_ERROR_NONE;
466 icmp46_header_t * icmp0;
467 u32 sw_if_index0, if_add_index0;
502 icmp0 = (icmp46_header_t *) &out_ip0[1];
511 out_ip0->
protocol = IP_PROTOCOL_ICMP;
524 error0 = ICMP4_ERROR_DROP;
531 *((
u32 *)(icmp0 + 1)) = clib_host_to_net_u32(
vnet_buffer(p0)->ip.icmp.data);
537 if (error0 == ICMP4_ERROR_NONE)
543 to_next, n_left_to_next,
554 .name =
"ip4-icmp-error",
555 .vector_size =
sizeof (
u32),
572 icmp46_header_t * h = va_arg (*args, icmp46_header_t *);
579 h->type = (i >> 8) & 0xff;
580 h->code = (i >> 0) & 0xff;
602 u32 ip_offset, icmp_offset;
605 ip_offset = (g-1)->start_byte_offset;
607 while (n_packets >= 1)
611 icmp46_header_t * icmp0;
619 ip0 = (
void *) (p0->
data + ip_offset);
620 icmp0 = (
void *) (p0->
data + icmp_offset);
635 #define _(f) pg_edit_init (&p->f, icmp46_header_t, f); 724 #define _(n,t) hash_set_mem (cm->type_by_name, #t, (n)); 729 #define _(a,n,t) hash_set_mem (cm->type_by_name, #t, (n) | (ICMP4_##a << 8)); void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
always_inline void * clib_random_buffer_get_data(clib_random_buffer_t *b, uword n_bytes)
always_inline void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
sll srl srl sll sra u16x4 i
static uword ip4_icmp_error(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
ip_interface_address_t * if_address_pool
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
static u8 * format_icmp_input_trace(u8 *s, va_list *va)
static void pg_edit_set_fixed(pg_edit_t *e, u64 value)
static char * icmp_error_strings[]
always_inline void pg_icmp_header_init(pg_icmp46_header_t *p)
uword unformat_pg_edit(unformat_input_t *input, va_list *args)
ip_lookup_main_t lookup_main
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
always_inline void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
unformat_function_t * unformat_pg_edit
always_inline pg_edit_group_t * pg_stream_get_group(pg_stream_t *s, u32 group_index)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define vlib_prefetch_buffer_with_index(vm, bi, type)
Prefetch buffer metadata by buffer index The first 64 bytes of buffer contains most header informatio...
ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
#define VLIB_INIT_FUNCTION(x)
u32 local_interface_sw_if_index
static uword unformat_icmp_type_and_code(unformat_input_t *input, va_list *args)
uword unformat_pg_payload(unformat_input_t *input, va_list *args)
always_inline int ip4_header_bytes(ip4_header_t *i)
#define vlib_call_init_function(vm, x)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
#define hash_create_string(elts, value_bytes)
#define VLIB_BUFFER_NEXT_PRESENT
void ip4_icmp_register_type(vlib_main_t *vm, icmp4_type_t type, u32 node_index)
always_inline u16 ip_csum_fold(ip_csum_t c)
static clib_error_t * icmp4_init(vlib_main_t *vm)
#define pool_elt_at_index(p, i)
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
u16 current_length
Nbytes between current data and the end of this buffer.
format_function_t * format_header
static uword unformat_pg_icmp_header(unformat_input_t *input, va_list *args)
static u8 * format_ip4_icmp_type_and_code(u8 *s, va_list *args)
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
always_inline u16 ip4_header_checksum(ip4_header_t *i)
static void icmp4_pg_edit_function(pg_main_t *pg, pg_stream_t *s, pg_edit_group_t *g, u32 *packets, u32 n_packets)
always_inline void * pg_create_edit_group(pg_stream_t *s, int n_edit_bytes, int n_packet_bytes, u32 *group_index)
clib_error_t * ip_main_init(vlib_main_t *vm)
#define CLIB_PREFETCH(addr, size, type)
static u8 * format_ip4_icmp_header(u8 *s, va_list *args)
void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
uword * type_and_code_by_name
static uword ip4_icmp_echo_request(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
u32 * if_address_pool_index_by_sw_if_index
struct ip4_main_t::@97 host_config
vlib_node_registration_t ip4_icmp_echo_request_node
(constructor) VLIB_REGISTER_NODE (ip4_icmp_echo_request_node)
u32 next_buffer
Next buffer for this linked-list of buffers.
#define VLIB_NODE_FLAG_TRACE
uword edit_function_opaque
always_inline uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
void vlib_trace_frame_buffers_only(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, uword n_buffers, uword next_buffer_stride, uword n_buffer_data_bytes_in_trace)
void(* edit_function)(struct pg_main_t *pg, struct pg_stream_t *s, struct pg_edit_group_t *g, u32 *buffers, u32 n_buffers)
always_inline void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define ip_csum_update(sum, old, new, type, field)
vlib_node_registration_t ip4_icmp_error_node
(constructor) VLIB_REGISTER_NODE (ip4_icmp_error_node)
always_inline void * ip4_next_header(ip4_header_t *i)
uword unformat_pg_number(unformat_input_t *input, va_list *args)
vlib_node_registration_t ip4_icmp_input_node
(constructor) VLIB_REGISTER_NODE (ip4_icmp_input_node)
#define VLIB_REGISTER_NODE(x,...)
u8 ip4_input_next_index_by_type[256]
static uword ip4_icmp_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
static u8 icmp4_icmp_type_to_error(u8 type)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
always_inline void pg_free_edit_group(pg_stream_t *s)
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
clib_random_buffer_t random_buffer