FD.io VPP
v18.01.2-1-g9b554f3
Vector Packet Processing
Main Page
Related Pages
Modules
Namespaces
Data Structures
Source
Files
Symbols
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_msg_enum.h
>
34
35
#define vl_typedefs
/* define message structures */
36
#include <
l2e/l2e_all_api_h.h
>
37
#undef vl_typedefs
38
39
#define vl_endianfun
/* define message structures */
40
#include <
l2e/l2e_all_api_h.h
>
41
#undef vl_endianfun
42
43
/* instantiate all the print functions we know about */
44
#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
45
#define vl_printfun
46
#include <
l2e/l2e_all_api_h.h
>
47
#undef vl_printfun
48
49
/* Get the API version number */
50
#define vl_api_version(n,v) static u32 api_version=(v);
51
#include <
acl/acl_all_api_h.h
>
52
#undef vl_api_version
53
54
#include <
vlibapi/api_helper_macros.h
>
55
56
#define foreach_l2e_api_msg \
57
_(L2_EMULATION, l2_emulation)
58
59
/**
60
* L2 Emulation Main
61
*/
62
typedef
struct
l2_emulation_main_t_
63
{
64
u16
msg_id_base
;
65
}
l2_emulation_main_t
;
66
67
static
l2_emulation_main_t
l2_emulation_main
;
68
69
#define L2E_MSG_BASE l2_emulation_main.msg_id_base
70
71
static
void
72
vl_api_l2_emulation_t_handler
(
vl_api_l2_emulation_t
* mp)
73
{
74
vl_api_l2_emulation_reply_t *rmp;
75
int
rv = 0;
76
77
VALIDATE_SW_IF_INDEX
(mp);
78
79
u32
sw_if_index = ntohl (mp->
sw_if_index
);
80
81
if
(mp->
enable
)
82
l2_emulation_enable
(sw_if_index);
83
else
84
l2_emulation_disable
(sw_if_index);
85
86
BAD_SW_IF_INDEX_LABEL
;
87
88
REPLY_MACRO
(VL_API_L2_EMULATION_REPLY +
L2E_MSG_BASE
);
89
}
90
91
/*
92
* l2_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 <
l2e/l2e_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) \
106
vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + L2E_MSG_BASE);
107
foreach_vl_msg_name_crc_l2e;
108
#undef _
109
}
110
111
static
void
112
l2e_api_hookup
(
vlib_main_t
*
vm
)
113
{
114
#define _(N,n) \
115
vl_msg_api_set_handlers(VL_API_##N + L2E_MSG_BASE, \
116
#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_l2e_api_msg
;
123
#undef _
124
}
125
126
static
clib_error_t
*
127
l2e_init
(
vlib_main_t
*
vm
)
128
{
129
api_main_t
*am = &
api_main
;
130
l2_emulation_main_t
*l2em = &
l2_emulation_main
;
131
u8
*name =
format
(0,
"l2e_%08x%c"
, api_version, 0);
132
133
/* Ask for a correctly-sized block of API message decode slots */
134
l2em->
msg_id_base
=
vl_msg_api_get_msg_ids
((
char
*) name,
135
VL_MSG_FIRST_AVAILABLE
);
136
137
l2e_api_hookup
(vm);
138
139
/* Add our API messages to the global name_crc hash table */
140
setup_message_id_table
(am);
141
142
vec_free
(name);
143
return
(
NULL
);
144
}
145
146
VLIB_API_INIT_FUNCTION
(
l2e_init
);
147
148
/* *INDENT-OFF* */
149
VLIB_PLUGIN_REGISTER
() = {
150
.version = VPP_BUILD_VER,
151
.description =
"L2 Emulation"
,
152
};
153
/* *INDENT-ON* */
154
155
156
/*
157
* fd.io coding-style-patch-verification: ON
158
*
159
* Local Variables:
160
* eval: (c-set-style "gnu")
161
* End:
162
*/
foreach_l2e_api_msg
#define foreach_l2e_api_msg
Definition:
l2e_api.c:56
l2e_all_api_h.h
vl_msg_api_get_msg_ids
u16 vl_msg_api_get_msg_ids(const char *name, int n)
Definition:
api_shared.c:872
l2_emulation_main
static l2_emulation_main_t l2_emulation_main
Definition:
l2e_api.c:67
NULL
#define NULL
Definition:
clib.h:55
l2_emulation_main_t_
Grouping of global data for the L2 emulation feature.
Definition:
l2e.c:25
l2_emulation_disable
void l2_emulation_disable(u32 sw_if_index)
Definition:
l2e.c:79
format
u8 * format(u8 *s, const char *fmt,...)
Definition:
format.c:419
plugin.h
l2_emulation_main_t
struct l2_emulation_main_t_ l2_emulation_main_t
L2 Emulation Main.
api.h
VL_MSG_FIRST_AVAILABLE
Definition:
vnet_msg_enum.h:25
api_errno.h
api_helper_macros.h
interface.h
VLIB_PLUGIN_REGISTER
VLIB_PLUGIN_REGISTER()
acl_all_api_h.h
REPLY_MACRO
#define REPLY_MACRO(t)
Definition:
api_helper_macros.h:30
vl_api_l2_emulation_t::enable
u8 enable
Definition:
l2e.api:30
l2e.h
vnet.h
api_main_t
API main structure, used by both vpp and binary API clients.
Definition:
api_common.h:198
l2_emulation_main_t_::msg_id_base
u16 msg_id_base
Definition:
l2e_api.c:64
BAD_SW_IF_INDEX_LABEL
#define BAD_SW_IF_INDEX_LABEL
Definition:
api_helper_macros.h:125
api_main
api_main_t api_main
Definition:
api_shared.c:35
l2e_init
static clib_error_t * l2e_init(vlib_main_t *vm)
Definition:
l2e_api.c:127
vm
vlib_main_t * vm
Definition:
buffer.c:283
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition:
l2e_api.c:103
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition:
vec.h:336
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(l2e_init)
l2e_api_hookup
static void l2e_api_hookup(vlib_main_t *vm)
Definition:
l2e_api.c:112
u32
unsigned int u32
Definition:
types.h:88
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:58
l2e_msg_enum.h
clib_error_t
Definition:
clib_error.h:21
u16
unsigned short u16
Definition:
types.h:57
u8
unsigned char u8
Definition:
types.h:56
api.h
vlib_main_t
Definition:
main.h:59
vl_api_l2_emulation_t
L2 emulation at L3.
Definition:
l2e.api:25
L2E_MSG_BASE
#define L2E_MSG_BASE
Definition:
l2e_api.c:69
vl_api_l2_emulation_t_handler
static void vl_api_l2_emulation_t_handler(vl_api_l2_emulation_t *mp)
Definition:
l2e_api.c:72
vl_api_l2_emulation_t::sw_if_index
u32 sw_if_index
Definition:
l2e.api:29
VALIDATE_SW_IF_INDEX
#define VALIDATE_SW_IF_INDEX(mp)
Definition:
api_helper_macros.h:117
src
plugins
l2e
l2e_api.c
Generated on Wed Sep 5 2018 06:02:03 for FD.io VPP by
1.8.11