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>
28 typedef CLIB_PACKED(struct ip_address
38 #define ip_addr_addr(_a) (_a)->ip
39 #define ip_addr_v4(_a) (_a)->ip.v4
40 #define ip_addr_v6(_a) (_a)->ip.v6
41 #define ip_addr_version(_a) (_a)->version
43 int ip_address_cmp (ip_address_t * ip1, ip_address_t * ip2);
44 void ip_address_copy (ip_address_t * dst , ip_address_t * src);
45 void ip_address_copy_addr (void * dst , ip_address_t * src);
46 void ip_address_set(ip_address_t * dst, void * src, u8 version);
48 typedef CLIB_PACKED(struct ip_prefix
54 #define ip_prefix_addr(_a) (_a)->addr
55 #define ip_prefix_version(_a) ip_addr_version(&ip_prefix_addr(_a))
56 #define ip_prefix_len(_a) (_a)->len
57 #define ip_prefix_v4(_a) ip_addr_v4(&ip_prefix_addr(_a))
58 #define ip_prefix_v6(_a) ip_addr_v6(&ip_prefix_addr(_a))
62 /* NOTE: ip addresses are left out on purpose. Use max masked ip-prefixes
73 /* make sure that values corresponds with RFC */
80 struct _gid_address_t;
86 struct _gid_address_t *src;
87 struct _gid_address_t *dst;
94 struct _gid_address_t *gid_addr;
97 #define vni_vni(_a) (_a)->vni
98 #define vni_mask_len(_a) (_a)->vni_mask_len
99 #define vni_gid(_a) (_a)->gid_addr
103 /* the union needs to be at the beginning! */
112 #define lcaf_type(_a) (_a)->type
113 #define lcaf_vni(_a) vni_vni(& (_a)->uni)
114 #define lcaf_vni_len(_a) vni_mask_len(& (_a)->uni)
116 /* might want to expand this in the future :) */
117 typedef struct _gid_address_t
130 u8 * format_ip_address (u8 * s, va_list * args);
131 uword unformat_ip_address (unformat_input_t * input, va_list * args);
132 u8 * format_ip_prefix (u8 * s, va_list * args);
133 uword unformat_ip_prefix (unformat_input_t * input, va_list * args);
135 u16 ip4_address_size_to_put ();
136 u16 ip6_address_size_to_put ();
137 u32 ip4_address_put (u8 * b, ip4_address_t * a);
138 u32 ip6_address_put (u8 * b, ip6_address_t * a);
140 u16 ip_address_size_to_write (ip_address_t * a);
141 u16 ip_address_iana_afi(ip_address_t *a);
142 u8 ip_address_max_len (u8 ver);
143 u32 ip_address_put (u8 * b, ip_address_t * a);
151 LISP_AFI_LCAF = 16387
154 u8 *format_gid_address (u8 * s, va_list * args);
155 uword unformat_gid_address (unformat_input_t * input, va_list * args);
156 int gid_address_cmp (gid_address_t * a1, gid_address_t * a2);
157 void gid_address_free (gid_address_t *a);
159 u16 gid_address_size_to_put (gid_address_t * a);
160 u16 gid_address_put (u8 * b, gid_address_t * gid);
161 u8 gid_address_len (gid_address_t *a);
162 void * gid_address_cast (gid_address_t * gid, gid_address_type_t type);
163 void gid_address_copy(gid_address_t * dst, gid_address_t * src);
164 u32 gid_address_parse (u8 * offset, gid_address_t *a);
166 #define gid_address_type(_a) (_a)->type
167 #define gid_address_ippref(_a) (_a)->ippref
168 #define gid_address_ippref_len(_a) (_a)->ippref.len
169 #define gid_address_ip(_a) ip_prefix_addr(&gid_address_ippref(_a))
170 #define gid_address_ip_version(_a) ip_addr_version(&gid_address_ip(_a))
171 #define gid_address_lcaf(_a) (_a)->lcaf
172 #define gid_address_mac(_a) (_a)->mac
173 #define gid_address_vni(_a) (_a)->vni
174 #define gid_address_vni_mask(_a) (_a)->vni_mask
176 /* 'sub'address functions */
177 #define foreach_gid_address_type_fcns \
183 u16 _n ## _size_to_write (void * pref); \
184 u16 _n ## _write (u8 * p, void * pref); \
185 u8 _n ## _length (void *a); \
186 void * _n ## _cast (gid_address_t * a); \
187 void _n ## _copy (void * dst , void * src);
189 foreach_gid_address_type_fcns
194 /* mark locator as local as opposed to remote */
199 gid_address_t address;
207 u32 locator_parse (void * ptr, locator_t * loc);
208 void locator_copy (locator_t * dst, locator_t * src);
209 u32 locator_cmp (locator_t * l1, locator_t * l2);
210 void locator_free (locator_t * l);
214 /* locator-set name */
217 /* vector of locator indices */
218 u32 * locator_indices;
226 /* index of local locator set */
227 u32 locator_set_index;
236 lcaf_t lcaf_iid_init (u32 vni);
238 #endif /* VNET_LISP_GPE_LISP_TYPES_H_ */