FD.io VPP  v16.06
Vector Packet Processing
sr.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef included_vnet_sr_h
16 #define included_vnet_sr_h
17 
18 #include <vnet/vnet.h>
19 #include <vnet/sr/sr_packet.h>
20 #include <vnet/ip/ip6_packet.h>
21 
22 #include <openssl/opensslconf.h>
23 #include <stdlib.h>
24 #include <string.h>
25 
26 #include <openssl/crypto.h>
27 #include <openssl/sha.h>
28 #include <openssl/opensslv.h>
29 #include <openssl/hmac.h>
30 
31 typedef struct {
35 
36 typedef struct {
37  /* src, dst address */
39 
40  /* optional tunnel name */
41  u8 * name;
42 
43  /* mask width for FIB entry */
45 
46  /* first hop, to save 1 elt in the segment list */
48 
49  /* Fib indices */
52 
53  /* The actual ip6 sr header */
55 
56  /* Indicates that this tunnel is part of a policy comprising
57  of multiple tunnels. */
60 
61 typedef struct {
64 
65 typedef struct {
66  /* Key (header imposition case) */
72 
73  /* optional name argument - for referencing SR tunnel/policy by name */
74  u8 * name;
75 
76  /* optional policy name */
78 
79  /* segment list, when inserting an ip6 SR header*/
81 
82  /*
83  * "Tag" list, aka segments inserted at the end of the list,
84  * past last_seg
85  */
87 
88  /* Shared secret => generate SHA-256 HMAC security fields */
90 
91  /* Flags, e.g. cleanup, policy-list flags */
93 
94  /* Delete the tunnnel? */
97 
98 typedef struct {
99  /* policy name */
100  u8 * name;
101 
102  /* tunnel names */
104 
105  /* Delete the policy? */
108 
109 
110 typedef struct {
111  /* name of policy */
112  u8 * name;
113 
114  /* vector to SR tunnel index */
116 
118 
119 typedef struct {
120  /* multicast IP6 address */
122 
123  /* name of policy to map to */
125 
126  /* Delete the mapping */
128 
130 
131 typedef struct {
132  /* pool of tunnel instances, sr entry only */
134 
135  /* find an sr "tunnel" by its outer-IP src/dst */
137 
138  /* find an sr "tunnel" by its name */
140 
141  /* policy pool */
143 
144  /* find a policy by name */
146 
147  /* multicast address to policy mapping */
149 
150  /* ip6-lookup next index for imposition FIB entries */
152 
153  /* hmac key id by shared secret */
155 
156  /* ip6-rewrite next index for reinstalling the original dst address */
158 
159  /* ip6-replicate next index for multicast tunnel */
161 
162  /* application API callback */
163  void *sr_local_cb;
164 
165  /* validate hmac keys */
167 
168  /* pool of hmac keys */
170 
171  /* Openssl vbls */
172  EVP_MD * md;
173  HMAC_CTX * hmac_ctx;
174 
175  /* enable debug spew */
177 
178  /* convenience */
181 } ip6_sr_main_t;
182 
184 
187 
189 
190 #if DPDK > 0
191 extern vlib_node_registration_t sr_replicate_node;
192 #endif /* DPDK */
193 
197 
198 void vnet_register_sr_app_callback (void *cb);
199 
200 void sr_fix_hmac (ip6_sr_main_t * sm, ip6_header_t * ip,
201  ip6_sr_header_t * sr);
202 
203 #endif /* included_vnet_sr_h */
HMAC_CTX * hmac_ctx
Definition: sr.h:173
uword * tunnel_index_by_key
Definition: sr.h:136
a
Definition: bitmap.h:393
u32 tx_fib_index
Definition: sr.h:51
u32 policy_index
Definition: sr.h:58
u32 dst_mask_width
Definition: sr.h:44
ip6_address_t * multicast_address
Definition: sr.h:121
u8 * name
Definition: sr.h:41
struct _vlib_node_registration vlib_node_registration_t
ip6_address_t * tags
Definition: sr.h:86
ip6_sr_tunnel_key_t key
Definition: sr.h:38
u32 rx_fib_index
Definition: sr.h:50
ip6_address_t dst
Definition: sr.h:33
ip6_address_t src
Definition: sr.h:32
u8 * name
Definition: sr.h:112
ip6_address_t * segments
Definition: sr.h:80
EVP_MD * md
Definition: sr.h:172
int ip6_sr_add_del_policy(ip6_sr_add_del_policy_args_t *a)
Definition: sr.c:1287
ip6_sr_hmac_key_t * hmac_keys
Definition: sr.h:169
int ip6_sr_add_del_multicastmap(ip6_sr_add_del_multicastmap_args_t *a)
Definition: sr.c:1503
format_function_t format_ip6_sr_header_with_length
Definition: sr.h:186
void sr_fix_hmac(ip6_sr_main_t *sm, ip6_header_t *ip, ip6_sr_header_t *sr)
Definition: sr.c:26
vlib_main_t * vlib_main
Definition: sr.h:179
void vnet_register_sr_app_callback(void *cb)
Definition: sr.c:2665
void * sr_local_cb
Definition: sr.h:163
u8 * shared_secret
Definition: sr.h:62
u8 is_debug
Definition: sr.h:176
int ip6_sr_add_del_tunnel(ip6_sr_add_del_tunnel_args_t *a)
Definition: sr.c:740
u32 ip6_lookup_sr_replicate_index
Definition: sr.h:160
ip6_address_t * src_address
Definition: sr.h:67
vnet_main_t * vnet_main
Definition: sr.h:180
u8 * rewrite
Definition: sr.h:54
vlib_node_registration_t ip6_sr_input_node
Definition: sr.h:188
u32 * tunnel_indices
Definition: sr.h:115
u8 validate_hmac
Definition: sr.h:166
ip6_address_t first_hop
Definition: sr.h:47
unsigned int u32
Definition: types.h:88
ip6_sr_tunnel_t * tunnels
Definition: sr.h:133
uword * policy_index_by_policy_name
Definition: sr.h:145
uword * tunnel_index_by_name
Definition: sr.h:139
u8 *( format_function_t)(u8 *s, va_list *args)
Definition: format.h:48
u64 uword
Definition: types.h:112
u32 ip6_lookup_sr_next_index
Definition: sr.h:151
format_function_t format_ip6_sr_header
Definition: sr.h:185
uword * hmac_key_by_shared_secret
Definition: sr.h:154
unsigned short u16
Definition: types.h:57
uword * policy_index_by_multicast_address
Definition: sr.h:148
unsigned char u8
Definition: types.h:56
ip6_sr_policy_t * policies
Definition: sr.h:142
ip6_address_t * dst_address
Definition: sr.h:68
ip6_sr_main_t sr_main
Definition: sr.h:183
u32 ip6_rewrite_sr_next_index
Definition: sr.h:157