2 * Copyright (c) 2016 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.
16 #ifndef VNET_LISP_GPE_LISP_TYPES_H_
17 #define VNET_LISP_GPE_LISP_TYPES_H_
19 #include <vnet/ip/ip.h>
20 #include <vnet/lisp-cp/lisp_cp_messages.h>
22 #define SHA1_AUTH_DATA_LEN 20
23 #define SHA256_AUTH_DATA_LEN 32
32 uword unformat_hmac_key_id (unformat_input_t * input, va_list * args);
33 u8 *format_hmac_key_id (u8 * s, va_list * args);
37 /* NOTE: ip addresses are left out on purpose. Use max masked ip-prefixes
52 /* make sure that values corresponds with RFC */
56 LCAF_SOURCE_DEST = 12,
61 typedef enum fid_addr_type_t_
66 } __attribute__ ((packed)) fid_addr_type_t;
68 /* flat address type */
80 typedef fid_address_t dp_address_t;
82 #define fid_addr_ippref(_a) (_a)->ippref
83 #define fid_addr_prefix_length(_a) ip_prefix_len(&fid_addr_ippref(_a))
84 #define fid_addr_ip_version(_a) ip_prefix_version(&fid_addr_ippref(_a))
85 #define fid_addr_mac(_a) (_a)->mac
86 #define fid_addr_nsh(_a) (_a)->nsh
87 #define fid_addr_type(_a) (_a)->type
88 u8 *format_fid_address (u8 * s, va_list * args);
96 #define sd_dst(_a) (_a)->dst
97 #define sd_src(_a) (_a)->src
98 #define sd_src_ippref(_a) fid_addr_ippref(&sd_src(_a))
99 #define sd_dst_ippref(_a) fid_addr_ippref(&sd_dst(_a))
100 #define sd_src_mac(_a) fid_addr_mac(&sd_src(_a))
101 #define sd_dst_mac(_a) fid_addr_mac(&sd_dst(_a))
102 #define sd_src_type(_a) fid_addr_type(&sd_src(_a))
103 #define sd_dst_type(_a) fid_addr_type(&sd_dst(_a))
109 struct _gid_address_t *gid_addr;
112 #define vni_vni(_a) (_a)->vni
113 #define vni_mask_len(_a) (_a)->vni_mask_len
114 #define vni_gid(_a) (_a)->gid_addr
122 #define nsh_spi(_a) (_a)->spi
123 #define nsh_si(_a) (_a)->si
131 #define lcaf_arp_ndp_ip(_a) (_a)->addr
132 #define lcaf_arp_ndp_ip_ver(_a) ip_addr_version(&lcaf_arp_ndp_ip(_a))
133 #define lcaf_arp_ndp_ip4(_a) ip_addr_v4(&lcaf_arp_ndp_ip(_a))
134 #define lcaf_arp_ndp_ip6(_a) ip_addr_v6(&lcaf_arp_ndp_ip(_a))
135 #define lcaf_arp_ndp_bd(_a) (_a)->bd
139 /* the union needs to be at the beginning! */
143 lcaf_arp_ndp_t arp_ndp;
149 #define lcaf_type(_a) (_a)->type
150 #define lcaf_vni(_a) vni_vni(& (_a)->uni)
151 #define lcaf_vni_len(_a) vni_mask_len(& (_a)->uni)
153 /* might want to expand this in the future :) */
154 typedef struct _gid_address_t
162 lcaf_arp_ndp_t arp_ndp;
170 u16 ip4_address_size_to_put ();
171 u16 ip6_address_size_to_put ();
172 u32 ip4_address_put (u8 * b, ip4_address_t * a);
173 u32 ip6_address_put (u8 * b, ip6_address_t * a);
175 u16 ip_address_size_to_write (ip_address_t * a);
176 u16 ip_address_iana_afi (ip_address_t * a);
177 u8 ip_address_max_len (u8 ver);
178 u32 ip_address_put (u8 * b, ip_address_t * a);
186 LISP_AFI_LCAF = 16387,
190 u8 *format_gid_address (u8 * s, va_list * args);
191 uword unformat_gid_address (unformat_input_t * input, va_list * args);
192 int gid_address_cmp (gid_address_t * a1, gid_address_t * a2);
193 void gid_address_free (gid_address_t * a);
195 u16 gid_address_size_to_put (gid_address_t * a);
196 u16 gid_address_put (u8 * b, gid_address_t * gid);
197 u8 gid_address_len (gid_address_t * a);
198 void *gid_address_cast (gid_address_t * gid, gid_address_type_t type);
199 void gid_address_copy (gid_address_t * dst, gid_address_t * src);
200 u32 gid_address_parse (u8 * offset, gid_address_t * a);
201 void gid_address_ip_set (gid_address_t * dst, void *src, u8 version);
203 #define gid_address_type(_a) (_a)->type
204 #define gid_address_ippref(_a) (_a)->ippref
205 #define gid_address_ippref_len(_a) (_a)->ippref.len
206 #define gid_address_ip(_a) ip_prefix_addr(&gid_address_ippref(_a))
207 #define gid_address_ip_version(_a) ip_addr_version(&gid_address_ip(_a))
208 #define gid_address_lcaf(_a) (_a)->lcaf
209 #define gid_address_mac(_a) (_a)->mac
210 #define gid_address_nsh(_a) (_a)->nsh
211 #define gid_address_nsh_spi(_a) nsh_spi(&gid_address_nsh(_a))
212 #define gid_address_nsh_si(_a) nsh_si(&gid_address_nsh(_a))
213 #define gid_address_vni(_a) (_a)->vni
214 #define gid_address_vni_mask(_a) (_a)->vni_mask
215 #define gid_address_sd_dst_ippref(_a) sd_dst_ippref(&(_a)->sd)
216 #define gid_address_sd_src_ippref(_a) sd_src_ippref(&(_a)->sd)
217 #define gid_address_sd_dst_mac(_a) sd_dst_mac(&(_a)->sd)
218 #define gid_address_sd_src_mac(_a) sd_src_mac(&(_a)->sd)
219 #define gid_address_sd(_a) (_a)->sd
220 #define gid_address_sd_src(_a) sd_src(&gid_address_sd(_a))
221 #define gid_address_sd_dst(_a) sd_dst(&gid_address_sd(_a))
222 #define gid_address_sd_src_type(_a) sd_src_type(&gid_address_sd(_a))
223 #define gid_address_sd_dst_type(_a) sd_dst_type(&gid_address_sd(_a))
224 #define gid_address_arp_ndp(_a) (_a)->arp_ndp
225 #define gid_address_arp_ndp_bd(_a) lcaf_arp_ndp_bd(&gid_address_arp_ndp(_a))
226 #define gid_address_arp_ndp_ip(_a) lcaf_arp_ndp_ip(&gid_address_arp_ndp(_a))
227 #define gid_address_arp_ip4(_a) lcaf_arp_ndp_ip4(&gid_address_arp_ndp(_a))
228 #define gid_address_ndp_ip6(_a) lcaf_arp_ndp_ip6(&gid_address_arp_ndp(_a))
229 #define gid_address_ndp_bd gid_address_arp_ndp_bd
230 #define gid_address_arp_bd gid_address_arp_ndp_bd
232 /* 'sub'address functions */
233 #define foreach_gid_address_type_fcns \
243 u16 _n ## _size_to_write (void * pref); \
244 u16 _n ## _write (u8 * p, void * pref); \
245 u8 _n ## _length (void *a); \
246 void * _n ## _cast (gid_address_t * a); \
247 void _n ## _copy (void * dst , void * src);
249 foreach_gid_address_type_fcns
256 return (*((u64 *) m) & 0xffffffffffff);
261 /* mark locator as local as opposed to remote */
267 gid_address_t address;
276 u32 locator_parse (void *ptr, locator_t * loc);
277 void locator_copy (locator_t * dst, locator_t * src);
278 u32 locator_cmp (locator_t * l1, locator_t * l2);
279 void locator_free (locator_t * l);
283 /* locator-set name */
286 /* vector of locator indices */
287 u32 *locator_indices;
295 /* index of local locator set */
298 u32 locator_set_index;
299 locator_t *locators; /* used for map register message */
307 /* valid only for remote mappings */
312 u8 delete_after_expiration:1;
316 lisp_key_type_t key_id;
323 unformat_negative_mapping_action (unformat_input_t * input, va_list * args);
324 u8 *format_negative_mapping_action (u8 *, va_list * args);
326 typedef struct locator_pair
328 /* local and remote locators (underlay attachment points) */
329 ip_address_t lcl_loc;
330 ip_address_t rmt_loc;
337 build_src_dst (gid_address_t * sd, gid_address_t * src, gid_address_t * dst);
339 void gid_address_from_ip (gid_address_t * g, ip_address_t * ip);
340 void gid_to_dp_address (gid_address_t * g, dp_address_t * d);
342 #endif /* VNET_LISP_GPE_LISP_TYPES_H_ */
345 * fd.io coding-style-patch-verification: ON
348 * eval: (c-set-style "gnu")