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.
17 * @brief Segment Routing header
19 * @note sr_replicate only works using DPDK today
21 #ifndef included_vnet_sr_h
22 #define included_vnet_sr_h
24 #include <vnet/vnet.h>
25 #include <vnet/sr/sr_packet.h>
26 #include <vnet/ip/ip6_packet.h>
28 #include <openssl/opensslconf.h>
32 #include <openssl/crypto.h>
33 #include <openssl/sha.h>
34 #include <openssl/opensslv.h>
35 #include <openssl/hmac.h>
38 * @brief Segment Route tunnel key
44 } ip6_sr_tunnel_key_t;
47 * @brief Segment Route tunnel
51 /** src, dst address */
52 ip6_sr_tunnel_key_t key;
54 /** Pptional tunnel name */
57 /** Mask width for FIB entry */
60 /** First hop, to save 1 elt in the segment list */
61 ip6_address_t first_hop;
68 /** The actual ip6 SR header */
71 /** Indicates that this tunnel is part of a policy comprising
72 of multiple tunnels. If == ~0 tunnel is not part of a policy */
77 * @brief Shared secret for keyed-hash message authentication code (HMAC).
85 * @brief Args required for add/del tunnel.
87 * Else we end up passing a LOT of parameters around.
91 /** Key (header imposition case) */
92 ip6_address_t *src_address;
93 ip6_address_t *dst_address;
98 /** optional name argument - for referencing SR tunnel/policy by name */
101 /** optional policy name */
104 /** segment list, when inserting an ip6 SR header */
105 ip6_address_t *segments;
108 * "Tag" list, aka segments inserted at the end of the list,
113 /** Shared secret => generate SHA-256 HMAC security fields */
116 /** Flags, e.g. cleanup, policy-list flags */
117 u16 flags_net_byte_order;
119 /** Delete the tunnnel? */
121 } ip6_sr_add_del_tunnel_args_t;
124 * @brief Args for creating a policy.
126 * Typically used for multicast replication.
127 * ie a multicast address can be associated with a policy,
128 * then replicated across a number of unicast SR tunnels.
138 /** Delete the policy? */
140 } ip6_sr_add_del_policy_args_t;
143 * @brief Segment Routing policy.
145 * Typically used for multicast replication.
146 * ie a multicast address can be associated with a policy,
147 * then replicated across a number of unicast SR tunnels.
151 /** name of policy */
154 /** vector to SR tunnel index */
160 * @brief Args for mapping of multicast address to policy name.
162 * Typically used for multicast replication.
163 * ie a multicast address can be associated with a policy,
164 * then replicated across a number of unicast SR tunnels.
168 /** multicast IP6 address */
169 ip6_address_t *multicast_address;
171 /** name of policy to map to */
174 /** Delete the mapping */
177 } ip6_sr_add_del_multicastmap_args_t;
180 * @brief Segment Routing state.
184 /** pool of tunnel instances, sr entry only */
185 ip6_sr_tunnel_t *tunnels;
187 /** find an sr "tunnel" by its outer-IP src/dst */
188 uword *tunnel_index_by_key;
190 /** find an sr "tunnel" by its name */
191 uword *tunnel_index_by_name;
194 ip6_sr_policy_t *policies;
196 /** find a policy by name */
197 uword *policy_index_by_policy_name;
199 /** multicast address to policy mapping */
200 uword *policy_index_by_multicast_address;
202 /** hmac key id by shared secret */
203 uword *hmac_key_by_shared_secret;
205 /** ip6-rewrite next index for reinstalling the original dst address */
206 u32 ip6_rewrite_sr_next_index;
208 /** ip6-replicate next index for multicast tunnel */
209 u32 ip6_lookup_sr_replicate_index;
211 /** application API callback */
214 /** validate hmac keys */
217 /** pool of hmac keys */
218 ip6_sr_hmac_key_t *hmac_keys;
225 /** enable debug spew */
229 vlib_main_t *vlib_main;
231 vnet_main_t *vnet_main;
234 ip6_sr_main_t sr_main;
236 format_function_t format_ip6_sr_header;
237 format_function_t format_ip6_sr_header_with_length;
239 vlib_node_registration_t ip6_sr_input_node;
242 extern vlib_node_registration_t sr_replicate_node;
245 int ip6_sr_add_del_tunnel (ip6_sr_add_del_tunnel_args_t * a);
246 int ip6_sr_add_del_policy (ip6_sr_add_del_policy_args_t * a);
247 int ip6_sr_add_del_multicastmap (ip6_sr_add_del_multicastmap_args_t * a);
249 void vnet_register_sr_app_callback (void *cb);
251 void sr_fix_hmac (ip6_sr_main_t * sm, ip6_header_t * ip,
252 ip6_sr_header_t * sr);
254 #endif /* included_vnet_sr_h */
257 * fd.io coding-style-patch-verification: ON
260 * eval: (c-set-style "gnu")