interface: RX/TX direction type in API
[vpp.git] / src / vnet / interface_types_api.c
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2020 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 <vnet/interface_types_api.h>
19
20 STATIC_ASSERT_SIZEOF (vl_api_direction_t, 1);
21
22 int
23 direction_decode (vl_api_direction_t _dir, vlib_dir_t * out)
24 {
25   switch (_dir)
26     {
27     case RX:
28       *out = VLIB_RX;
29       return (0);
30     case TX:
31       *out = VLIB_TX;
32       return (0);
33     }
34   return (VNET_API_ERROR_INVALID_VALUE);
35 }
36
37 vl_api_direction_t
38 direction_encode (vlib_dir_t dir)
39 {
40   return (vl_api_direction_t) dir;
41 }
42
43 /*
44  * fd.io coding-style-patch-verification: ON
45  *
46  * Local Variables:
47  * eval: (c-set-style "gnu")
48  * End:
49  */