blob: 1887314a93c0252c6713df8f04312aa9705a562d [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
Dave Barachd7cb1b52016-12-09 09:52:16 -050029typedef enum
30{
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000031 SEND_PING_OK = 0,
32 SEND_PING_ALLOC_FAIL,
33 SEND_PING_NO_INTERFACE,
Neale Rannsf06aea52016-11-29 06:51:37 -080034 SEND_PING_NO_TABLE,
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000035} send_ip46_ping_result_t;
36
37/*
38 * Currently running ping command.
39 */
Dave Barachd7cb1b52016-12-09 09:52:16 -050040typedef struct ping_run_t
41{
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000042 u16 icmp_id;
43 u16 curr_seq;
44 uword cli_process_id;
45} ping_run_t;
46
Dave Barachd7cb1b52016-12-09 09:52:16 -050047typedef struct ping_main_t
48{
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000049 ip6_main_t *ip6_main;
50 ip4_main_t *ip4_main;
51 ping_run_t *ping_runs;
52 /* hash table to find back the CLI process for a reply */
53 // uword *cli_proc_by_icmp_id;
54 ping_run_t *ping_run_by_icmp_id;
55} ping_main_t;
56
57ping_main_t ping_main;
58
59#define PING_DEFAULT_DATA_LEN 60
60#define PING_DEFAULT_INTERVAL 1.0
61
Andrew Yourtchenko61459c92017-01-28 15:31:19 +000062#define PING_MAXIMUM_DATA_SIZE (VLIB_BUFFER_DATA_SIZE - sizeof(ip6_header_t) - sizeof(icmp46_header_t) - offsetof(icmp46_echo_request_t, data))
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000063
Andrew Yourtchenko61459c92017-01-28 15:31:19 +000064/* *INDENT-OFF* */
65
66typedef CLIB_PACKED (struct {
67 u16 id;
68 u16 seq;
69 f64 time_sent;
70 u8 data[0];
71}) icmp46_echo_request_t;
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000072
73
Andrew Yourtchenko61459c92017-01-28 15:31:19 +000074typedef CLIB_PACKED (struct {
75 ip6_header_t ip6;
76 icmp46_header_t icmp;
77 icmp46_echo_request_t icmp_echo;
78}) icmp6_echo_request_header_t;
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000079
Andrew Yourtchenko61459c92017-01-28 15:31:19 +000080typedef CLIB_PACKED (struct {
81 ip4_header_t ip4;
82 icmp46_header_t icmp;
83 icmp46_echo_request_t icmp_echo;
84}) icmp4_echo_request_header_t;
85
86/* *INDENT-ON* */
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000087
88
Dave Barachd7cb1b52016-12-09 09:52:16 -050089typedef struct
90{
Alexander Popovskyc90dfdc2016-12-04 02:39:38 -080091 u16 id;
92 u16 seq;
93 u8 bound;
94} icmp_echo_trace_t;
Andrew Yourtchenko7e682202016-08-04 13:39:35 +000095
96
97
98
Dave Barachd7cb1b52016-12-09 09:52:16 -050099typedef enum
100{
Alexander Popovskyc90dfdc2016-12-04 02:39:38 -0800101 ICMP6_ECHO_REPLY_NEXT_DROP,
102 ICMP6_ECHO_REPLY_NEXT_PUNT,
Andrew Yourtchenko7e682202016-08-04 13:39:35 +0000103 ICMP6_ECHO_REPLY_N_NEXT,
104} icmp6_echo_reply_next_t;
105
Dave Barachd7cb1b52016-12-09 09:52:16 -0500106typedef enum
107{
Alexander Popovskyc90dfdc2016-12-04 02:39:38 -0800108 ICMP4_ECHO_REPLY_NEXT_DROP,
109 ICMP4_ECHO_REPLY_NEXT_PUNT,
Andrew Yourtchenko7e682202016-08-04 13:39:35 +0000110 ICMP4_ECHO_REPLY_N_NEXT,
111} icmp4_echo_reply_next_t;
112
113#endif /* included_vnet_ping_h */