FD.io VPP  v18.07-rc0-415-g6c78436
Vector Packet Processing
ipsec_format.c
Go to the documentation of this file.
1 /*
2  * decap.c : IPSec tunnel support
3  *
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:
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/vnet.h>
19 #include <vnet/api_errno.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/interface.h>
22 
23 #include <vnet/ipsec/ipsec.h>
24 
25 u8 *
26 format_ipsec_policy_action (u8 * s, va_list * args)
27 {
28  u32 i = va_arg (*args, u32);
29  char *t = 0;
30 
31  switch (i)
32  {
33 #define _(v,f,str) case IPSEC_POLICY_ACTION_##f: t = str; break;
35 #undef _
36  default:
37  s = format (s, "unknown");
38  }
39  s = format (s, "%s", t);
40  return s;
41 }
42 
43 uword
45 {
46  u32 *r = va_arg (*args, u32 *);
47 
48  if (0);
49 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
51 #undef _
52  else
53  return 0;
54  return 1;
55 }
56 
57 u8 *
58 format_ipsec_crypto_alg (u8 * s, va_list * args)
59 {
60  u32 i = va_arg (*args, u32);
61  u8 *t = 0;
62 
63  switch (i)
64  {
65 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
67 #undef _
68  default:
69  s = format (s, "unknown");
70  }
71  s = format (s, "%s", t);
72  return s;
73 }
74 
75 uword
77 {
78  u32 *r = va_arg (*args, u32 *);
79 
80  if (0);
81 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
83 #undef _
84  else
85  return 0;
86  return 1;
87 }
88 
89 u8 *
90 format_ipsec_integ_alg (u8 * s, va_list * args)
91 {
92  u32 i = va_arg (*args, u32);
93  u8 *t = 0;
94 
95  switch (i)
96  {
97 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
99 #undef _
100  default:
101  s = format (s, "unknown");
102  }
103  s = format (s, "%s", t);
104  return s;
105 }
106 
107 uword
109 {
110  u32 *r = va_arg (*args, u32 *);
111 
112  if (0);
113 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
115 #undef _
116  else
117  return 0;
118  return 1;
119 }
120 
121 u8 *
122 format_ipsec_replay_window (u8 * s, va_list * args)
123 {
124  u64 w = va_arg (*args, u64);
125  u8 i;
126 
127  for (i = 0; i < 64; i++)
128  {
129  s = format (s, "%u", w & (1ULL << i) ? 1 : 0);
130  }
131 
132  return s;
133 }
134 
135 /*
136  * fd.io coding-style-patch-verification: ON
137  *
138  * Local Variables:
139  * eval: (c-set-style "gnu")
140  * End:
141  */
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:90
unsigned long u64
Definition: types.h:89
int i
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
unsigned char u8
Definition: types.h:56
uword unformat_ipsec_crypto_alg(unformat_input_t *input, va_list *args)
Definition: ipsec_format.c:76
u8 * format_ipsec_replay_window(u8 *s, va_list *args)
Definition: ipsec_format.c:122
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:58
unsigned int u32
Definition: types.h:88
struct _unformat_input_t unformat_input_t
#define foreach_ipsec_integ_alg
Definition: ipsec.h:88
#define foreach_ipsec_crypto_alg
Definition: ipsec.h:66
#define foreach_ipsec_policy_action
Definition: ipsec.h:52
uword unformat_ipsec_integ_alg(unformat_input_t *input, va_list *args)
Definition: ipsec_format.c:108
u8 * format_ipsec_policy_action(u8 *s, va_list *args)
Definition: ipsec_format.c:26
uword unformat_ipsec_policy_action(unformat_input_t *input, va_list *args)
Definition: ipsec_format.c:44
u64 uword
Definition: types.h:112