FD.io VPP
v20.01-48-g3e0dafb74
Vector Packet Processing
l2e_api.c
Go to the documentation of this file.
1
/*
2
*------------------------------------------------------------------
3
* l2e_api.c - layer 2 emulation 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 <
vnet/plugin/plugin.h
>
22
23
#include <
vnet/interface.h
>
24
#include <
vnet/api_errno.h
>
25
#include <vpp/app/version.h>
26
27
#include <
l2e/l2e.h
>
28
29
#include <
vlibapi/api.h
>
30
#include <
vlibmemory/api.h
>
31
32
/* define message IDs */
33
#include <l2e/l2e.api_enum.h>
34
#include <l2e/l2e.api_types.h>
35
36
#include <
vlibapi/api_helper_macros.h
>
37
38
#define L2E_MSG_BASE l2em->msg_id_base
39
40
static
void
41
vl_api_l2_emulation_t_handler
(
vl_api_l2_emulation_t
* mp)
42
{
43
l2_emulation_main_t
*l2em = &
l2_emulation_main
;
44
vl_api_l2_emulation_reply_t *rmp;
45
int
rv = 0;
46
47
VALIDATE_SW_IF_INDEX
(mp);
48
49
u32
sw_if_index
= ntohl (mp->
sw_if_index
);
50
51
if
(mp->
enable
)
52
l2_emulation_enable
(sw_if_index);
53
else
54
l2_emulation_disable
(sw_if_index);
55
56
BAD_SW_IF_INDEX_LABEL
;
57
58
REPLY_MACRO
(VL_API_L2_EMULATION_REPLY +
L2E_MSG_BASE
);
59
}
60
61
#include <l2e/l2e.api.c>
62
static
clib_error_t
*
63
l2e_init
(
vlib_main_t
*
vm
)
64
{
65
l2_emulation_main_t
*l2em = &
l2_emulation_main
;
66
67
/* Ask for a correctly-sized block of API message decode slots */
68
l2em->
msg_id_base
=
setup_message_id_table
();
69
70
return
(
NULL
);
71
}
72
73
VLIB_API_INIT_FUNCTION
(
l2e_init
);
74
75
/* *INDENT-OFF* */
76
VLIB_PLUGIN_REGISTER
() = {
77
.version = VPP_BUILD_VER,
78
.description =
"Layer 2 (L2) Emulation"
,
79
};
80
/* *INDENT-ON* */
81
82
83
/*
84
* fd.io coding-style-patch-verification: ON
85
*
86
* Local Variables:
87
* eval: (c-set-style "gnu")
88
* End:
89
*/
NULL
#define NULL
Definition:
clib.h:58
l2_emulation_main_t_
Grouping of global data for the L2 emulation feature.
Definition:
l2e.h:46
l2_emulation_disable
void l2_emulation_disable(u32 sw_if_index)
Definition:
l2e.c:53
plugin.h
sw_if_index
vl_api_interface_index_t sw_if_index
Definition:
gre.api:59
api.h
api_errno.h
u32
unsigned int u32
Definition:
types.h:88
api_helper_macros.h
interface.h
VLIB_PLUGIN_REGISTER
VLIB_PLUGIN_REGISTER()
l2_emulation_main
l2_emulation_main_t l2_emulation_main
Definition:
l2e.c:23
REPLY_MACRO
#define REPLY_MACRO(t)
Definition:
api_helper_macros.h:30
l2e.h
vm
vlib_main_t * vm
Definition:
in2out_ed.c:1810
vnet.h
l2_emulation_main_t_::msg_id_base
u16 msg_id_base
Definition:
l2e.h:48
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition:
api_helper_macros.h:140
l2e_init
static clib_error_t * l2e_init(vlib_main_t *vm)
Definition:
l2e_api.c:63
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(l2e_init)
l2_emulation_enable
void l2_emulation_enable(u32 sw_if_index)
L2 Emulation is a feautre that is applied to L2 ports to 'extract' IP packets from the L2 path and in...
Definition:
l2e.c:31
clib_error_t
Definition:
clib_error.h:21
api.h
vlib_main_t
Definition:
main.h:83
vl_api_l2_emulation_t
L2 emulation at L3.
Definition:
l2e.api:26
vl_api_l2_emulation_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition:
l2e.api:30
L2E_MSG_BASE
#define L2E_MSG_BASE
Definition:
l2e_api.c:38
setup_message_id_table
static void setup_message_id_table(snat_main_t *sm, api_main_t *am)
Definition:
nat_api.c:3410
vl_api_l2_emulation_t_handler
static void vl_api_l2_emulation_t_handler(vl_api_l2_emulation_t *mp)
Definition:
l2e_api.c:41
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition:
api_helper_macros.h:132
vl_api_l2_emulation_t::enable
bool enable
Definition:
l2e.api:31
src
plugins
l2e
l2e_api.c
Generated on Wed Sep 9 2020 00:03:48 for FD.io VPP by
1.8.13