FD.io VPP
v18.04-17-g3a0d853
Vector Packet Processing
Main Page
Related Pages
Modules
Namespaces
Data Structures
Source
Files
Symbols
cop_api.c
Go to the documentation of this file.
1
/*
2
*------------------------------------------------------------------
3
* cop_api.c - cop api
4
*
5
* Copyright (c) 2016 Cisco and/or its affiliates.
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at:
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*------------------------------------------------------------------
18
*/
19
20
#include <
vnet/vnet.h
>
21
#include <
vlibmemory/api.h
>
22
23
#include <
vnet/interface.h
>
24
#include <
vnet/api_errno.h
>
25
#include <
vnet/cop/cop.h
>
26
27
#include <
vnet/vnet_msg_enum.h
>
28
29
#define vl_typedefs
/* define message structures */
30
#include <
vnet/vnet_all_api_h.h
>
31
#undef vl_typedefs
32
33
#define vl_endianfun
/* define message structures */
34
#include <
vnet/vnet_all_api_h.h
>
35
#undef vl_endianfun
36
37
/* instantiate all the print functions we know about */
38
#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
39
#define vl_printfun
40
#include <
vnet/vnet_all_api_h.h
>
41
#undef vl_printfun
42
43
#include <
vlibapi/api_helper_macros.h
>
44
45
#define foreach_vpe_api_msg \
46
_(COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable) \
47
_(COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable)
48
49
static
void
vl_api_cop_interface_enable_disable_t_handler
50
(
vl_api_cop_interface_enable_disable_t
* mp)
51
{
52
vl_api_cop_interface_enable_disable_reply_t *rmp;
53
int
rv;
54
u32
sw_if_index = ntohl (mp->
sw_if_index
);
55
int
enable_disable;
56
57
VALIDATE_SW_IF_INDEX
(mp);
58
59
enable_disable = (int) mp->
enable_disable
;
60
61
rv =
cop_interface_enable_disable
(sw_if_index, enable_disable);
62
63
BAD_SW_IF_INDEX_LABEL
;
64
65
REPLY_MACRO
(VL_API_COP_INTERFACE_ENABLE_DISABLE_REPLY);
66
}
67
68
static
void
vl_api_cop_whitelist_enable_disable_t_handler
69
(
vl_api_cop_whitelist_enable_disable_t
* mp)
70
{
71
vl_api_cop_whitelist_enable_disable_reply_t *rmp;
72
cop_whitelist_enable_disable_args_t
_a, *
a
= &_a;
73
u32
sw_if_index = ntohl (mp->
sw_if_index
);
74
int
rv;
75
76
VALIDATE_SW_IF_INDEX
(mp);
77
78
a->
sw_if_index
= sw_if_index;
79
a->
ip4
= mp->
ip4
;
80
a->
ip6
= mp->
ip6
;
81
a->
default_cop
= mp->
default_cop
;
82
a->
fib_id
= ntohl (mp->
fib_id
);
83
84
rv =
cop_whitelist_enable_disable
(a);
85
86
BAD_SW_IF_INDEX_LABEL
;
87
88
REPLY_MACRO
(VL_API_COP_WHITELIST_ENABLE_DISABLE_REPLY);
89
}
90
91
/*
92
* cop_api_hookup
93
* Add vpe's API message handlers to the table.
94
* vlib has alread mapped shared memory and
95
* added the client registration handlers.
96
* See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
97
*/
98
#define vl_msg_name_crc_list
99
#include <
vnet/vnet_all_api_h.h
>
100
#undef vl_msg_name_crc_list
101
102
static
void
103
setup_message_id_table
(
api_main_t
* am)
104
{
105
#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
106
foreach_vl_msg_name_crc_cop;
107
#undef _
108
}
109
110
static
clib_error_t
*
111
cop_api_hookup
(
vlib_main_t
*
vm
)
112
{
113
api_main_t
*am = &
api_main
;
114
115
#define _(N,n) \
116
vl_msg_api_set_handlers(VL_API_##N, #n, \
117
vl_api_##n##_t_handler, \
118
vl_noop_handler, \
119
vl_api_##n##_t_endian, \
120
vl_api_##n##_t_print, \
121
sizeof(vl_api_##n##_t), 1);
122
foreach_vpe_api_msg
;
123
#undef _
124
125
/*
126
* Set up the (msg_name, crc, message-id) table
127
*/
128
setup_message_id_table
(am);
129
130
return
0;
131
}
132
133
VLIB_API_INIT_FUNCTION
(
cop_api_hookup
);
134
135
/*
136
* fd.io coding-style-patch-verification: ON
137
*
138
* Local Variables:
139
* eval: (c-set-style "gnu")
140
* End:
141
*/
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(cop_api_hookup)
vl_api_cop_whitelist_enable_disable_t
cop: enable/disable whitelist filtration features on an interface Note: the supplied fib_id must matc...
Definition:
cop.api:45
vl_api_cop_whitelist_enable_disable_t::ip6
u8 ip6
Definition:
cop.api:52
vl_api_cop_whitelist_enable_disable_t_handler
static void vl_api_cop_whitelist_enable_disable_t_handler(vl_api_cop_whitelist_enable_disable_t *mp)
Definition:
cop_api.c:69
vl_api_cop_whitelist_enable_disable_t::default_cop
u8 default_cop
Definition:
cop.api:53
a
a
Definition:
bitmap.h:516
cop_api_hookup
static clib_error_t * cop_api_hookup(vlib_main_t *vm)
Definition:
cop_api.c:111
cop_whitelist_enable_disable_args_t::sw_if_index
u32 sw_if_index
Definition:
cop.h:80
cop_whitelist_enable_disable_args_t::default_cop
u8 default_cop
Definition:
cop.h:83
vl_api_cop_interface_enable_disable_t::sw_if_index
u32 sw_if_index
Definition:
cop.api:29
vnet_msg_enum.h
cop_whitelist_enable_disable_args_t::ip4
u8 ip4
Definition:
cop.h:81
vl_api_cop_whitelist_enable_disable_t::ip4
u8 ip4
Definition:
cop.api:51
cop.h
api_errno.h
api_helper_macros.h
interface.h
REPLY_MACRO
#define REPLY_MACRO(t)
Definition:
api_helper_macros.h:30
cop_whitelist_enable_disable
int cop_whitelist_enable_disable(cop_whitelist_enable_disable_args_t *a)
Definition:
cop.c:229
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition:
cop_api.c:103
cop_whitelist_enable_disable_args_t::fib_id
u32 fib_id
Definition:
cop.h:84
vnet.h
api_main_t
API main structure, used by both vpp and binary API clients.
Definition:
api_common.h:199
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition:
api_helper_macros.h:125
vm
vlib_main_t * vm
Definition:
buffer.c:294
vl_api_cop_interface_enable_disable_t
cop: enable/disable junk filtration features on an interface
Definition:
cop.api:25
vl_api_cop_interface_enable_disable_t_handler
static void vl_api_cop_interface_enable_disable_t_handler(vl_api_cop_interface_enable_disable_t *mp)
Definition:
cop_api.c:50
cop_interface_enable_disable
int cop_interface_enable_disable(u32 sw_if_index, int enable_disable)
Definition:
cop.c:151
cop_whitelist_enable_disable_args_t
Definition:
cop.h:79
vl_api_cop_interface_enable_disable_t::enable_disable
u8 enable_disable
Definition:
cop.api:30
foreach_vpe_api_msg
#define foreach_vpe_api_msg
Definition:
cop_api.c:45
cop_whitelist_enable_disable_args_t::ip6
u8 ip6
Definition:
cop.h:82
u32
unsigned int u32
Definition:
types.h:88
clib_error_t
Definition:
clib_error.h:21
vnet_all_api_h.h
api.h
vlib_main_t
Definition:
main.h:59
vl_api_cop_whitelist_enable_disable_t::sw_if_index
u32 sw_if_index
Definition:
cop.api:49
vl_api_cop_whitelist_enable_disable_t::fib_id
u32 fib_id
Definition:
cop.api:50
api_main
api_main_t api_main
Definition:
api_shared.c:35
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition:
api_helper_macros.h:117
src
vnet
cop
cop_api.c
Generated on Mon Oct 1 2018 08:02:34 for FD.io VPP by
1.8.11