FD.io VPP  v20.05-21-gb1500e9ff
Vector Packet Processing
tunnel_types_api.c
Go to the documentation of this file.
1 /*
2  * tunnel_api.c - tunnel api
3  *
4  * Copyright (c) 2018 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vnet/api_errno.h>
20 
21 #include <vnet/tunnel/tunnel_types.api_enum.h>
22 #include <vnet/tunnel/tunnel_types.api_types.h>
23 
24 
25 STATIC_ASSERT (sizeof (vl_api_tunnel_encap_decap_flags_t) ==
27  "tunnel API and internal flags enum size differ");
28 
29 int
30 tunnel_encap_decap_flags_decode (vl_api_tunnel_encap_decap_flags_t f,
32 {
33  if (f & ~TUNNEL_FLAG_MASK)
34  /* unknown flags set */
35  return (VNET_API_ERROR_INVALID_VALUE_2);
36 
38  return (0);
39 }
40 
41 vl_api_tunnel_encap_decap_flags_t
43 {
44  return ((vl_api_tunnel_encap_decap_flags_t) f);
45 }
46 
47 int
48 tunnel_mode_decode (vl_api_tunnel_mode_t in, tunnel_mode_t * out)
49 {
50  switch (in)
51  {
52 #define _(n, v) \
53  case TUNNEL_API_MODE_##n: \
54  *out = TUNNEL_MODE_##n; \
55  return (0);
57 #undef _
58  }
59 
60  return (VNET_API_ERROR_INVALID_VALUE_2);
61 }
62 
63 vl_api_tunnel_mode_t
65 {
66  vl_api_tunnel_mode_t out = TUNNEL_API_MODE_P2P;
67 
68  switch (in)
69  {
70 #define _(n, v) \
71  case TUNNEL_MODE_##n: \
72  out = TUNNEL_API_MODE_##n; \
73  break;
75 #undef _
76  }
77 
78  return (out);
79 }
80 
81 /*
82  * fd.io coding-style-patch-verification: ON
83  *
84  * Local Variables:
85  * eval: (c-set-style "gnu")
86  * End:
87  */
vl_api_tunnel_encap_decap_flags_t tunnel_encap_decap_flags_encode(tunnel_encap_decap_flags_t f)
STATIC_ASSERT(sizeof(vl_api_tunnel_encap_decap_flags_t)==sizeof(tunnel_encap_decap_flags_t), "tunnel API and internal flags enum size differ")
int tunnel_mode_decode(vl_api_tunnel_mode_t in, tunnel_mode_t *out)
enum tunnel_encap_decap_flags_t_ tunnel_encap_decap_flags_t
vl_api_tunnel_mode_t tunnel_mode_encode(tunnel_mode_t in)
point-to-point
int tunnel_encap_decap_flags_decode(vl_api_tunnel_encap_decap_flags_t f, tunnel_encap_decap_flags_t *o)
Conversion functions to/from (decode/encode) API types to VPP internal types.
enum tunnel_mode_t_ tunnel_mode_t
#define TUNNEL_FLAG_MASK
Definition: tunnel.h:55