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>
29 typedef CLIB_PACKED(struct ip_address
40 #define ip_addr_addr(_a) (_a)->ip
41 #define ip_addr_v4(_a) (_a)->ip.v4
42 #define ip_addr_v6(_a) (_a)->ip.v6
43 #define ip_addr_version(_a) (_a)->version
45 int ip_address_cmp (const ip_address_t * ip1, const ip_address_t * ip2);
46 void ip_address_copy (ip_address_t * dst, const ip_address_t * src);
47 void ip_address_copy_addr (void *dst, const ip_address_t * src);
48 void ip_address_set (ip_address_t * dst, const void *src, u8 version);
51 typedef CLIB_PACKED(struct ip_prefix
58 #define ip_prefix_addr(_a) (_a)->addr
59 #define ip_prefix_version(_a) ip_addr_version(&ip_prefix_addr(_a))
60 #define ip_prefix_len(_a) (_a)->len
61 #define ip_prefix_v4(_a) ip_addr_v4(&ip_prefix_addr(_a))
62 #define ip_prefix_v6(_a) ip_addr_v6(&ip_prefix_addr(_a))
64 void ip_prefix_normalize (ip_prefix_t * a);
66 extern void ip_address_to_fib_prefix (const ip_address_t * addr,
67 fib_prefix_t * prefix);
68 extern void ip_prefix_to_fib_prefix (const ip_prefix_t * ipp,
73 /* NOTE: ip addresses are left out on purpose. Use max masked ip-prefixes
85 /* make sure that values corresponds with RFC */
89 LCAF_SOURCE_DEST = 12,
99 /* flat address type */
107 u8 type; /* fid_addr_type_t */
110 typedef fid_address_t dp_address_t;
112 #define fid_addr_ippref(_a) (_a)->ippref
113 #define fid_addr_mac(_a) (_a)->mac
114 #define fid_addr_type(_a) (_a)->type
115 u8 *format_fid_address (u8 * s, va_list * args);
123 #define sd_dst(_a) (_a)->dst
124 #define sd_src(_a) (_a)->src
125 #define sd_src_ippref(_a) fid_addr_ippref(&sd_src(_a))
126 #define sd_dst_ippref(_a) fid_addr_ippref(&sd_dst(_a))
127 #define sd_src_mac(_a) fid_addr_mac(&sd_src(_a))
128 #define sd_dst_mac(_a) fid_addr_mac(&sd_dst(_a))
134 struct _gid_address_t *gid_addr;
137 #define vni_vni(_a) (_a)->vni
138 #define vni_mask_len(_a) (_a)->vni_mask_len
139 #define vni_gid(_a) (_a)->gid_addr
143 /* the union needs to be at the beginning! */
152 #define lcaf_type(_a) (_a)->type
153 #define lcaf_vni(_a) vni_vni(& (_a)->uni)
154 #define lcaf_vni_len(_a) vni_mask_len(& (_a)->uni)
156 /* might want to expand this in the future :) */
157 typedef struct _gid_address_t
171 u8 *format_ip_address (u8 * s, va_list * args);
172 uword unformat_ip_address (unformat_input_t * input, va_list * args);
173 u8 *format_ip_prefix (u8 * s, va_list * args);
174 uword unformat_ip_prefix (unformat_input_t * input, va_list * args);
175 u8 *format_mac_address (u8 * s, va_list * args);
176 uword unformat_mac_address (unformat_input_t * input, va_list * args);
178 u16 ip4_address_size_to_put ();
179 u16 ip6_address_size_to_put ();
180 u32 ip4_address_put (u8 * b, ip4_address_t * a);
181 u32 ip6_address_put (u8 * b, ip6_address_t * a);
183 u16 ip_address_size_to_write (ip_address_t * a);
184 u16 ip_address_iana_afi (ip_address_t * a);
185 u8 ip_address_max_len (u8 ver);
186 u32 ip_address_put (u8 * b, ip_address_t * a);
194 LISP_AFI_LCAF = 16387,
198 u8 *format_gid_address (u8 * s, va_list * args);
199 uword unformat_gid_address (unformat_input_t * input, va_list * args);
200 int gid_address_cmp (gid_address_t * a1, gid_address_t * a2);
201 void gid_address_free (gid_address_t * a);
203 u16 gid_address_size_to_put (gid_address_t * a);
204 u16 gid_address_put (u8 * b, gid_address_t * gid);
205 u8 gid_address_len (gid_address_t * a);
206 void *gid_address_cast (gid_address_t * gid, gid_address_type_t type);
207 void gid_address_copy (gid_address_t * dst, gid_address_t * src);
208 u32 gid_address_parse (u8 * offset, gid_address_t * a);
209 void gid_address_ip_set (gid_address_t * dst, void *src, u8 version);
211 #define gid_address_type(_a) (_a)->type
212 #define gid_address_ippref(_a) (_a)->ippref
213 #define gid_address_ippref_len(_a) (_a)->ippref.len
214 #define gid_address_ip(_a) ip_prefix_addr(&gid_address_ippref(_a))
215 #define gid_address_ip_version(_a) ip_addr_version(&gid_address_ip(_a))
216 #define gid_address_lcaf(_a) (_a)->lcaf
217 #define gid_address_mac(_a) (_a)->mac
218 #define gid_address_vni(_a) (_a)->vni
219 #define gid_address_vni_mask(_a) (_a)->vni_mask
220 #define gid_address_sd_dst_ippref(_a) sd_dst_ippref(&(_a)->sd)
221 #define gid_address_sd_src_ippref(_a) sd_src_ippref(&(_a)->sd)
222 #define gid_address_sd_dst_mac(_a) sd_dst_mac(&(_a)->sd)
223 #define gid_address_sd_src_mac(_a) sd_src_mac(&(_a)->sd)
224 #define gid_address_sd(_a) (_a)->sd
225 #define gid_address_sd_src(_a) sd_src(&gid_address_sd(_a))
226 #define gid_address_sd_dst(_a) sd_dst(&gid_address_sd(_a))
228 /* 'sub'address functions */
229 #define foreach_gid_address_type_fcns \
237 u16 _n ## _size_to_write (void * pref); \
238 u16 _n ## _write (u8 * p, void * pref); \
239 u8 _n ## _length (void *a); \
240 void * _n ## _cast (gid_address_t * a); \
241 void _n ## _copy (void * dst , void * src);
243 foreach_gid_address_type_fcns
250 return (*((u64 *) m) & 0xffffffffffff);
255 /* mark locator as local as opposed to remote */
261 gid_address_t address;
269 u32 locator_parse (void *ptr, locator_t * loc);
270 void locator_copy (locator_t * dst, locator_t * src);
271 u32 locator_cmp (locator_t * l1, locator_t * l2);
272 void locator_free (locator_t * l);
276 /* locator-set name */
279 /* vector of locator indices */
280 u32 *locator_indices;
288 /* index of local locator set */
289 u32 locator_set_index;
296 /* valid only for remote mappings */
301 unformat_negative_mapping_action (unformat_input_t * input, va_list * args);
302 u8 *format_negative_mapping_action (u8 *, va_list * args);
304 typedef struct locator_pair
306 /* local and remote locators (underlay attachment points) */
307 ip_address_t lcl_loc;
308 ip_address_t rmt_loc;
310 u8 priority; /* TODO remove */
314 #endif /* VNET_LISP_GPE_LISP_TYPES_H_ */
317 * fd.io coding-style-patch-verification: ON
320 * eval: (c-set-style "gnu")