FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
arping_api.c
Go to the documentation of this file.
1
/*
2
*------------------------------------------------------------------
3
* Copyright (c) 2021 Cisco and/or its affiliates.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at:
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*------------------------------------------------------------------
16
*/
17
18
#include <
vlib/vlib.h
>
19
#include <
vlib/unix/unix.h
>
20
#include <
vlib/pci/pci.h
>
21
#include <
vnet/ethernet/ethernet.h
>
22
#include <
vnet/format_fns.h
>
23
#include <
vnet/ip/ip_types_api.h
>
24
25
#include <
arping/arping.h
>
26
27
#include <
vlibapi/api.h
>
28
#include <
vlibmemory/api.h
>
29
30
/* define message IDs */
31
#include <arping/arping.api_enum.h>
32
#include <arping/arping.api_types.h>
33
34
#include <
vlibapi/api_helper_macros.h
>
35
36
static
void
37
vl_api_arping_t_handler
(
vl_api_arping_t
*mp)
38
{
39
vlib_main_t
*
vm
=
vlib_get_main
();
40
arping_main_t
*
am
= &
arping_main
;
41
vl_api_arping_reply_t
*rmp;
42
arping_args_t
args = { 0 };
43
int
rv
;
44
45
if
(mp->
sw_if_index
!= ~0)
46
VALIDATE_SW_IF_INDEX
(mp);
47
48
ip_address_decode2
(&mp->
address
, &args.
address
);
49
args.
interval
=
clib_net_to_host_f64
(mp->
interval
);
50
args.
repeat
= ntohl (mp->
repeat
);
51
args.
is_garp
= mp->
is_garp
;
52
args.
sw_if_index
= ntohl (mp->
sw_if_index
);
53
args.
silence
= 1;
54
55
arping_run_command
(
vm
, &args);
56
rv
= args.
rv
;
57
58
BAD_SW_IF_INDEX_LABEL
;
59
60
REPLY_MACRO2
(VL_API_ARPING_REPLY +
am
->msg_id_base,
61
({ rmp->reply_count = ntohl (args.reply_count); }));
62
}
63
64
/* set tup the API message handling tables */
65
#include <arping/arping.api.c>
66
clib_error_t
*
67
arping_plugin_api_hookup
(
vlib_main_t
*
vm
)
68
{
69
arping_main_t
*
am
= &
arping_main
;
70
api_main_t
*vam =
vlibapi_get_main
();
71
72
/* ask for a correctly-sized block of API message decode slots */
73
am
->msg_id_base =
setup_message_id_table
();
74
75
/* Mark API as mp safe */
76
vam->
is_mp_safe
[
am
->msg_id_base + VL_API_ARPING] = 1;
77
78
return
0;
79
}
80
81
/*
82
* fd.io coding-style-patch-verification: ON
83
*
84
* Local Variables:
85
* eval: (c-set-style "gnu")
86
* End:
87
*/
vlib.h
arping_args_t::address
ip_address_t address
Definition:
arping.h:55
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition:
api_helper_macros.h:281
api.h
vl_api_arping_t_handler
static void vl_api_arping_t_handler(vl_api_arping_t *mp)
Definition:
arping_api.c:37
arping_args_t::rv
i32 rv
Definition:
arping.h:63
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition:
api_helper_macros.h:65
arping_args_t::repeat
u32 repeat
Definition:
arping.h:57
am
app_main_t * am
Definition:
application.c:489
arping_run_command
void arping_run_command(vlib_main_t *vm, arping_args_t *args)
Definition:
arping.c:634
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition:
nat44_ei.c:3047
api.h
vl_api_arping_t
Definition:
arping.api:32
arping_args_t::silence
u8 silence
Definition:
arping.h:60
ethernet.h
arping_main_t
Definition:
arping.h:46
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition:
bfd_api.c:451
vl_api_arping_t::interval
f64 interval[default=1.0]
Definition:
arping.api:40
arping_args_t
Definition:
arping.h:53
arping_main
arping_main_t arping_main
Definition:
arping.c:26
vlibapi_get_main
static api_main_t * vlibapi_get_main(void)
Definition:
api_common.h:390
vl_api_arping_t::is_garp
bool is_garp
Definition:
arping.api:38
ip_address_decode2
void ip_address_decode2(const vl_api_address_t *in, ip_address_t *out)
Definition:
ip_types_api.c:192
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition:
api_helper_macros.h:289
api_main_t
API main structure, used by both vpp and binary API clients.
Definition:
api_common.h:228
arping_args_t::interval
f64 interval
Definition:
arping.h:58
format_fns.h
arping_args_t::sw_if_index
u32 sw_if_index
Definition:
arping.h:56
vl_api_arping_t::address
vl_api_address_t address
Definition:
arping.api:36
arping.h
vl_api_arping_t::repeat
u32 repeat[default=1]
Definition:
arping.api:39
api_helper_macros.h
pci.h
arping_args_t::is_garp
u8 is_garp
Definition:
arping.h:59
vlib_main_t
Definition:
main.h:102
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition:
global_funcs.h:38
clib_error_t
Definition:
clib_error.h:21
unix.h
clib_net_to_host_f64
static f64 clib_net_to_host_f64(f64 x)
Definition:
byte_order.h:177
vl_api_arping_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition:
arping.api:37
rv
int __clib_unused rv
Definition:
application.c:491
arping_plugin_api_hookup
clib_error_t * arping_plugin_api_hookup(vlib_main_t *vm)
Definition:
arping_api.c:67
ip_types_api.h
api_main_t::is_mp_safe
u8 * is_mp_safe
Message is mp safe vector.
Definition:
api_common.h:251
vl_api_arping_reply_t
Definition:
arping.api:50
src
plugins
arping
arping_api.c
Generated on Sat Jan 8 2022 10:03:39 for FD.io VPP by
1.8.17