2 * decap.c : IPSec tunnel support
4 * Copyright (c) 2015 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/vnet.h>
19 #include <vnet/api_errno.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/interface.h>
23 #include <vnet/ipsec/ipsec.h>
26 format_ipsec_policy_action (u8 * s, va_list * args)
28 u32 i = va_arg (*args, u32);
33 #define _(v,f,str) case IPSEC_POLICY_ACTION_##f: t = str; break;
34 foreach_ipsec_policy_action
37 s = format (s, "unknown");
39 s = format (s, "%s", t);
44 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
46 u32 *r = va_arg (*args, u32 *);
49 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
50 foreach_ipsec_policy_action
58 format_ipsec_crypto_alg (u8 * s, va_list * args)
60 u32 i = va_arg (*args, u32);
65 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
66 foreach_ipsec_crypto_alg
69 s = format (s, "unknown");
71 s = format (s, "%s", t);
76 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
78 u32 *r = va_arg (*args, u32 *);
81 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
82 foreach_ipsec_crypto_alg
90 format_ipsec_integ_alg (u8 * s, va_list * args)
92 u32 i = va_arg (*args, u32);
97 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
98 foreach_ipsec_integ_alg
101 s = format (s, "unknown");
103 s = format (s, "%s", t);
108 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
110 u32 *r = va_arg (*args, u32 *);
113 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
114 foreach_ipsec_integ_alg
122 format_ipsec_replay_window (u8 * s, va_list * args)
124 u64 w = va_arg (*args, u64);
127 for (i = 0; i < 64; i++)
129 s = format (s, "%u", w & (1ULL << i) ? 1 : 0);
136 * fd.io coding-style-patch-verification: ON
139 * eval: (c-set-style "gnu")