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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 #ifndef included_vnet_sr_h
16 #define included_vnet_sr_h
18 #include <vnet/vnet.h>
19 #include <vnet/sr/sr_packet.h>
20 #include <vnet/ip/ip6_packet.h>
22 #include <openssl/opensslconf.h>
26 #include <openssl/crypto.h>
27 #include <openssl/sha.h>
28 #include <openssl/opensslv.h>
29 #include <openssl/hmac.h>
34 } ip6_sr_tunnel_key_t;
37 /* src, dst address */
38 ip6_sr_tunnel_key_t key;
40 /* optional tunnel name */
43 /* mask width for FIB entry */
46 /* first hop, to save 1 elt in the segment list */
47 ip6_address_t first_hop;
53 /* The actual ip6 sr header */
56 /* Indicates that this tunnel is part of a policy comprising
57 of multiple tunnels. */
66 /* Key (header imposition case) */
67 ip6_address_t *src_address;
68 ip6_address_t *dst_address;
73 /* optional name argument - for referencing SR tunnel/policy by name */
76 /* optional policy name */
79 /* segment list, when inserting an ip6 SR header*/
80 ip6_address_t *segments;
83 * "Tag" list, aka segments inserted at the end of the list,
88 /* Shared secret => generate SHA-256 HMAC security fields */
91 /* Flags, e.g. cleanup, policy-list flags */
92 u16 flags_net_byte_order;
94 /* Delete the tunnnel? */
96 } ip6_sr_add_del_tunnel_args_t;
105 /* Delete the policy? */
107 } ip6_sr_add_del_policy_args_t;
114 /* vector to SR tunnel index */
115 u32 * tunnel_indices;
120 /* multicast IP6 address */
121 ip6_address_t *multicast_address;
123 /* name of policy to map to */
126 /* Delete the mapping */
129 } ip6_sr_add_del_multicastmap_args_t;
132 /* pool of tunnel instances, sr entry only */
133 ip6_sr_tunnel_t *tunnels;
135 /* find an sr "tunnel" by its outer-IP src/dst */
136 uword * tunnel_index_by_key;
138 /* find an sr "tunnel" by its name */
139 uword * tunnel_index_by_name;
142 ip6_sr_policy_t * policies;
144 /* find a policy by name */
145 uword * policy_index_by_policy_name;
147 /* multicast address to policy mapping */
148 uword * policy_index_by_multicast_address;
150 /* ip6-lookup next index for imposition FIB entries */
151 u32 ip6_lookup_sr_next_index;
153 /* hmac key id by shared secret */
154 uword * hmac_key_by_shared_secret;
156 /* ip6-rewrite next index for reinstalling the original dst address */
157 u32 ip6_rewrite_sr_next_index;
159 /* ip6-replicate next index for multicast tunnel */
160 u32 ip6_lookup_sr_replicate_index;
162 /* application API callback */
165 /* validate hmac keys */
168 /* pool of hmac keys */
169 ip6_sr_hmac_key_t * hmac_keys;
175 /* enable debug spew */
179 vlib_main_t * vlib_main;
180 vnet_main_t * vnet_main;
183 ip6_sr_main_t sr_main;
185 format_function_t format_ip6_sr_header;
186 format_function_t format_ip6_sr_header_with_length;
188 vlib_node_registration_t ip6_sr_input_node;
191 extern vlib_node_registration_t sr_replicate_node;
194 int ip6_sr_add_del_tunnel (ip6_sr_add_del_tunnel_args_t * a);
195 int ip6_sr_add_del_policy (ip6_sr_add_del_policy_args_t * a);
196 int ip6_sr_add_del_multicastmap (ip6_sr_add_del_multicastmap_args_t * a);
198 void vnet_register_sr_app_callback (void *cb);
200 void sr_fix_hmac (ip6_sr_main_t * sm, ip6_header_t * ip,
201 ip6_sr_header_t * sr);
203 #endif /* included_vnet_sr_h */