arping: add arping command
[vpp.git] / src / plugins / arping / arping.h
1 /*
2  * Copyright (c) 2021 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_arping_arping_h
16 #define included_arping_arping_h
17
18 #include <vnet/ip/ip_types.h>
19 #include <vnet/ethernet/arp_packet.h>
20
21 #define ARPING_DEFAULT_INTERVAL 1.0
22 #define ARPING_DEFAULT_REPEAT   1
23
24 typedef struct arping6_ip6_reply_t
25 {
26   mac_address_t mac;
27   ip6_address_t ip6;
28 } arping6_ip6_reply_t;
29
30 typedef CLIB_PACKED (union arping46_reply_ {
31   ethernet_arp_ip4_over_ethernet_address_t from4;
32   arping6_ip6_reply_t from6;
33 }) arping46_reply_t;
34
35 typedef struct arping_intf_t
36 {
37   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
38   f64 interval;
39   u32 repeat;
40   ip_address_t address;
41
42   arping46_reply_t recv;
43   u32 reply_count;
44 } arping_intf_t;
45
46 typedef struct arping_main_t
47 {
48   arping_intf_t *arping_interfaces;
49   arping_intf_t **interfaces;
50   u16 msg_id_base;
51 } arping_main_t;
52
53 typedef struct arping_args_t
54 {
55   ip_address_t address;
56   u32 sw_if_index;
57   u32 repeat;
58   f64 interval;
59   u8 is_garp;
60   u8 silence;
61
62   /* reply */
63   i32 rv;
64   u32 reply_count;
65   arping46_reply_t recv;
66   clib_error_t *error;
67 } arping_args_t;
68
69 extern arping_main_t arping_main;
70
71 extern clib_error_t *arping_plugin_api_hookup (vlib_main_t *vm);
72 extern void arping_run_command (vlib_main_t *vm, arping_args_t *args);
73
74 #endif /* included_arping_arping_h */