2 * tunnel_api.c - tunnel api
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <vnet/api_errno.h>
19 #include <vnet/tunnel/tunnel_types_api.h>
21 #include <vnet/tunnel/tunnel_types.api_enum.h>
22 #include <vnet/tunnel/tunnel_types.api_types.h>
25 STATIC_ASSERT (sizeof (vl_api_tunnel_encap_decap_flags_t) ==
26 sizeof (tunnel_encap_decap_flags_t),
27 "tunnel API and internal flags enum size differ");
30 tunnel_encap_decap_flags_decode (vl_api_tunnel_encap_decap_flags_t f,
31 tunnel_encap_decap_flags_t * o)
33 if (f & ~TUNNEL_FLAG_MASK)
34 /* unknown flags set */
35 return (VNET_API_ERROR_INVALID_VALUE_2);
37 *o = (tunnel_encap_decap_flags_t) f;
41 vl_api_tunnel_encap_decap_flags_t
42 tunnel_encap_decap_flags_encode (tunnel_encap_decap_flags_t f)
44 return ((vl_api_tunnel_encap_decap_flags_t) f);
48 tunnel_mode_decode (vl_api_tunnel_mode_t in, tunnel_mode_t * out)
53 case TUNNEL_API_MODE_##n: \
54 *out = TUNNEL_MODE_##n; \
60 return (VNET_API_ERROR_INVALID_VALUE_2);
64 tunnel_mode_encode (tunnel_mode_t in)
66 vl_api_tunnel_mode_t out = TUNNEL_API_MODE_P2P;
71 case TUNNEL_MODE_##n: \
72 out = TUNNEL_API_MODE_##n; \
82 * fd.io coding-style-patch-verification: ON
85 * eval: (c-set-style "gnu")