blob: f1faa998f7df0b340562ddecee9ba98897f623fb [file] [log] [blame]
Andrew Yourtchenko7e682202016-08-04 13:39:35 +00001/*
2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef included_vnet_ping_h
16#define included_vnet_ping_h
17
18
19#include <vnet/ip/ip.h>
20
21#include <vnet/ip/lookup.h>
22
Dave Barachd7cb1b52016-12-09 09:52:16 -050023typedef enum
24{
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000025 PING_RESPONSE_IP6 = 42,
26 PING_RESPONSE_IP4,
27} ping_response_type_t;
28
Neale Rannse9239c92018-10-15 05:47:58 -070029#define foreach_ip46_ping_result \
30 _ (OK, "OK") \
31 _ (ALLOC_FAIL, "packet allocation failed") \
32 _ (NO_INTERFACE, "no egress interface") \
Andrew Yourtchenkocc8fa162018-10-26 15:13:56 +020033 _ (NO_TABLE, "no FIB table for lookup") \
Neale Rannse9239c92018-10-15 05:47:58 -070034 _ (NO_SRC_ADDRESS, "no source address for egress interface") \
Andrew Yourtchenkocc8fa162018-10-26 15:13:56 +020035 _ (NO_BUFFERS, "could not allocate a new buffer") \
Neale Rannse9239c92018-10-15 05:47:58 -070036
Dave Barachd7cb1b52016-12-09 09:52:16 -050037typedef enum
38{
Neale Rannse9239c92018-10-15 05:47:58 -070039#define _(v, s) SEND_PING_##v,
40 foreach_ip46_ping_result
41#undef _
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000042} send_ip46_ping_result_t;
43
44/*
45 * Currently running ping command.
46 */
Dave Barachd7cb1b52016-12-09 09:52:16 -050047typedef struct ping_run_t
48{
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000049 u16 icmp_id;
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000050 uword cli_process_id;
51} ping_run_t;
52
Dave Barachd7cb1b52016-12-09 09:52:16 -050053typedef struct ping_main_t
54{
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000055 ip6_main_t *ip6_main;
56 ip4_main_t *ip4_main;
Andrew Yourtchenkocc8fa162018-10-26 15:13:56 +020057 /* a vector of current ping runs. */
58 ping_run_t *active_ping_runs;
59 /* a lock held while add/remove/search on active_ping_runs */
60 clib_spinlock_t ping_run_check_lock;
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000061} ping_main_t;
62
Dave Wallace71612d62017-10-24 01:32:41 -040063extern ping_main_t ping_main;
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000064
65#define PING_DEFAULT_DATA_LEN 60
66#define PING_DEFAULT_INTERVAL 1.0
67
Andrew Yourtchenkocc8fa162018-10-26 15:13:56 +020068#define PING_MAXIMUM_DATA_SIZE 32768
69
70#define PING_CLI_UNKNOWN_NODE (~0)
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000071
Andrew Yourtchenko61459c92017-01-28 15:31:19 +000072/* *INDENT-OFF* */
73
74typedef CLIB_PACKED (struct {
75 u16 id;
76 u16 seq;
Andrew Yourtchenkocc8fa162018-10-26 15:13:56 +020077 u64 time_sent;
Andrew Yourtchenko61459c92017-01-28 15:31:19 +000078 u8 data[0];
79}) icmp46_echo_request_t;
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000080
Andrew Yourtchenko61459c92017-01-28 15:31:19 +000081/* *INDENT-ON* */
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000082
83
Dave Barachd7cb1b52016-12-09 09:52:16 -050084typedef enum
85{
Andrew Yourtchenkocc8fa162018-10-26 15:13:56 +020086 ICMP46_ECHO_REPLY_NEXT_DROP,
87 ICMP46_ECHO_REPLY_NEXT_PUNT,
88 ICMP46_ECHO_REPLY_N_NEXT,
89} icmp46_echo_reply_next_t;
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000090
91#endif /* included_vnet_ping_h */