FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
lisp_types.h
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #ifndef VNET_LISP_GPE_LISP_TYPES_H_
17 #define VNET_LISP_GPE_LISP_TYPES_H_
18 
19 #include <vnet/ip/ip.h>
21 
22 #define SHA1_AUTH_DATA_LEN 20
23 #define SHA256_AUTH_DATA_LEN 32
24 
25 typedef enum
26 {
31 
32 uword unformat_hmac_key_id (unformat_input_t * input, va_list * args);
33 u8 *format_hmac_key_id (u8 * s, va_list * args);
34 
35 typedef enum
36 {
37  IP4,
40 
41 /* *INDENT-OFF* */
42 typedef CLIB_PACKED(struct ip_address
43 {
44  union
45  {
46  ip4_address_t v4;
47  ip6_address_t v6;
48  } ip;
49  u8 version;
50 }) ip_address_t;
51 /* *INDENT-ON* */
52 
53 #define ip_addr_addr(_a) (_a)->ip
54 #define ip_addr_v4(_a) (_a)->ip.v4
55 #define ip_addr_v6(_a) (_a)->ip.v6
56 #define ip_addr_version(_a) (_a)->version
57 
58 int ip_address_cmp (const ip_address_t * ip1, const ip_address_t * ip2);
59 void ip_address_copy (ip_address_t * dst, const ip_address_t * src);
60 void ip_address_copy_addr (void *dst, const ip_address_t * src);
61 void ip_address_set (ip_address_t * dst, const void *src, u8 version);
62 
63 /* *INDENT-OFF* */
64 typedef CLIB_PACKED(struct ip_prefix
65 {
66  ip_address_t addr;
67  u8 len;
68 }) ip_prefix_t;
69 /* *INDENT-ON* */
70 
71 #define ip_prefix_addr(_a) (_a)->addr
72 #define ip_prefix_version(_a) ip_addr_version(&ip_prefix_addr(_a))
73 #define ip_prefix_len(_a) (_a)->len
74 #define ip_prefix_v4(_a) ip_addr_v4(&ip_prefix_addr(_a))
75 #define ip_prefix_v6(_a) ip_addr_v6(&ip_prefix_addr(_a))
76 
77 void ip_prefix_normalize (ip_prefix_t * a);
78 
79 extern void ip_address_to_fib_prefix (const ip_address_t * addr,
80  fib_prefix_t * prefix);
81 extern void ip_prefix_to_fib_prefix (const ip_prefix_t * ipp,
82  fib_prefix_t * fibp);
83 
84 typedef enum
85 {
86  /* NOTE: ip addresses are left out on purpose. Use max masked ip-prefixes
87  * instead */
95 
96 typedef enum
97 {
98  /* make sure that values corresponds with RFC */
104 } lcaf_type_t;
105 
106 typedef enum fid_addr_type_t_
107 {
110 } __attribute__ ((packed)) fid_addr_type_t;
111 
112 /* flat address type */
113 typedef struct
114 {
115  union
116  {
117  ip_prefix_t ippref;
118  u8 mac[6];
119  };
120  fid_addr_type_t type;
121 } fid_address_t;
122 
124 
125 #define fid_addr_ippref(_a) (_a)->ippref
126 #define fid_addr_mac(_a) (_a)->mac
127 #define fid_addr_type(_a) (_a)->type
128 u8 *format_fid_address (u8 * s, va_list * args);
129 
130 typedef struct
131 {
134 } source_dest_t;
135 
136 #define sd_dst(_a) (_a)->dst
137 #define sd_src(_a) (_a)->src
138 #define sd_src_ippref(_a) fid_addr_ippref(&sd_src(_a))
139 #define sd_dst_ippref(_a) fid_addr_ippref(&sd_dst(_a))
140 #define sd_src_mac(_a) fid_addr_mac(&sd_src(_a))
141 #define sd_dst_mac(_a) fid_addr_mac(&sd_dst(_a))
142 #define sd_src_type(_a) fid_addr_type(&sd_src(_a))
143 #define sd_dst_type(_a) fid_addr_type(&sd_dst(_a))
144 
145 typedef struct
146 {
149  struct _gid_address_t *gid_addr;
150 } vni_t;
151 
152 #define vni_vni(_a) (_a)->vni
153 #define vni_mask_len(_a) (_a)->vni_mask_len
154 #define vni_gid(_a) (_a)->gid_addr
155 
156 typedef struct
157 {
158  /* the union needs to be at the beginning! */
159  union
160  {
163  };
165 } lcaf_t;
166 
167 #define lcaf_type(_a) (_a)->type
168 #define lcaf_vni(_a) vni_vni(& (_a)->uni)
169 #define lcaf_vni_len(_a) vni_mask_len(& (_a)->uni)
170 
171 /* might want to expand this in the future :) */
172 typedef struct _gid_address_t
173 {
174  union
175  {
176  ip_prefix_t ippref;
177  lcaf_t lcaf;
178  u8 mac[6];
179  source_dest_t sd;
180  };
181  u8 type;
182  u32 vni;
183  u8 vni_mask;
184 } gid_address_t;
185 
186 u8 *format_ip_address (u8 * s, va_list * args);
187 uword unformat_ip_address (unformat_input_t * input, va_list * args);
188 u8 *format_ip_prefix (u8 * s, va_list * args);
189 uword unformat_ip_prefix (unformat_input_t * input, va_list * args);
190 u8 *format_mac_address (u8 * s, va_list * args);
191 uword unformat_mac_address (unformat_input_t * input, va_list * args);
192 
197 
198 u16 ip_address_size_to_write (ip_address_t * a);
199 u16 ip_address_iana_afi (ip_address_t * a);
200 u8 ip_address_max_len (u8 ver);
201 u32 ip_address_put (u8 * b, ip_address_t * a);
202 void ip_address_to_46 (const ip_address_t * addr,
203  ip46_address_t * a, fib_protocol_t * proto);
204 
205 /* LISP AFI codes */
206 typedef enum
207 {
211  LISP_AFI_LCAF = 16387,
212  LISP_AFI_MAC = 16389
213 } lisp_afi_e;
214 
215 u8 *format_gid_address (u8 * s, va_list * args);
216 uword unformat_gid_address (unformat_input_t * input, va_list * args);
219 
221 u16 gid_address_put (u8 * b, gid_address_t * gid);
223 void *gid_address_cast (gid_address_t * gid, gid_address_type_t type);
224 void gid_address_copy (gid_address_t * dst, gid_address_t * src);
226 void gid_address_ip_set (gid_address_t * dst, void *src, u8 version);
227 
228 #define gid_address_type(_a) (_a)->type
229 #define gid_address_ippref(_a) (_a)->ippref
230 #define gid_address_ippref_len(_a) (_a)->ippref.len
231 #define gid_address_ip(_a) ip_prefix_addr(&gid_address_ippref(_a))
232 #define gid_address_ip_version(_a) ip_addr_version(&gid_address_ip(_a))
233 #define gid_address_lcaf(_a) (_a)->lcaf
234 #define gid_address_mac(_a) (_a)->mac
235 #define gid_address_vni(_a) (_a)->vni
236 #define gid_address_vni_mask(_a) (_a)->vni_mask
237 #define gid_address_sd_dst_ippref(_a) sd_dst_ippref(&(_a)->sd)
238 #define gid_address_sd_src_ippref(_a) sd_src_ippref(&(_a)->sd)
239 #define gid_address_sd_dst_mac(_a) sd_dst_mac(&(_a)->sd)
240 #define gid_address_sd_src_mac(_a) sd_src_mac(&(_a)->sd)
241 #define gid_address_sd(_a) (_a)->sd
242 #define gid_address_sd_src(_a) sd_src(&gid_address_sd(_a))
243 #define gid_address_sd_dst(_a) sd_dst(&gid_address_sd(_a))
244 #define gid_address_sd_src_type(_a) sd_src_type(&gid_address_sd(_a))
245 #define gid_address_sd_dst_type(_a) sd_dst_type(&gid_address_sd(_a))
246 
247 /* 'sub'address functions */
248 #define foreach_gid_address_type_fcns \
249  _(ip_prefix) \
250  _(lcaf) \
251  _(mac) \
252  _(sd)
253 
254 /* *INDENT-OFF* */
255 #define _(_n) \
256 u16 _n ## _size_to_write (void * pref); \
257 u16 _n ## _write (u8 * p, void * pref); \
258 u8 _n ## _length (void *a); \
259 void * _n ## _cast (gid_address_t * a); \
260 void _n ## _copy (void * dst , void * src);
261 
263 #undef _
264 /* *INDENT-ON* */
265 
268 {
269  return (*((u64 *) m) & 0xffffffffffff);
270 }
271 
272 typedef struct
273 {
274  /* mark locator as local as opposed to remote */
277  union
278  {
281  };
287 } locator_t;
288 
289 u32 locator_parse (void *ptr, locator_t * loc);
290 void locator_copy (locator_t * dst, locator_t * src);
291 u32 locator_cmp (locator_t * l1, locator_t * l2);
292 void locator_free (locator_t * l);
293 
294 typedef struct
295 {
296  /* locator-set name */
298 
299  /* vector of locator indices */
302 } locator_set_t;
303 
304 typedef struct
305 {
307 
308  /* index of local locator set */
309  union
310  {
312  locator_t *locators; /* used for map register message */
313  };
314 
318 
320  /* valid only for remote mappings */
322  u8 *key;
323  lisp_key_type_t key_id;
325 } mapping_t;
326 
327 uword
328 unformat_negative_mapping_action (unformat_input_t * input, va_list * args);
329 u8 *format_negative_mapping_action (u8 *, va_list * args);
330 
331 typedef struct locator_pair
332 {
333  /* local and remote locators (underlay attachment points) */
334  ip_address_t lcl_loc;
335  ip_address_t rmt_loc;
336 
340 
341 void
343 
344 void gid_address_from_ip (gid_address_t * g, ip_address_t * ip);
345 
346 #endif /* VNET_LISP_GPE_LISP_TYPES_H_ */
347 
348 /*
349  * fd.io coding-style-patch-verification: ON
350  *
351  * Local Variables:
352  * eval: (c-set-style "gnu")
353  * End:
354  */
u8 vni_mask_len
Definition: lisp_types.h:147
u16 ip_address_iana_afi(ip_address_t *a)
Definition: lisp_types.c:485
void locator_free(locator_t *l)
Definition: lisp_types.c:1534
u8 timer_set
Definition: lisp_types.h:324
fid_address_t dst
Definition: lisp_types.h:133
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
Definition: lisp_types.c:1295
typedef CLIB_PACKED(struct ip_address{union{ip4_address_t v4;ip6_address_t v6;}ip;u8 version;}) ip_address_t
void ip_address_copy(ip_address_t *dst, const ip_address_t *src)
Definition: lisp_types.c:750
void build_src_dst(gid_address_t *sd, gid_address_t *src, gid_address_t *dst)
Definition: lisp_types.c:1541
uword unformat_mac_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:190
gid_address_type_t
Definition: lisp_types.h:84
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
lcaf_type_t
Definition: lisp_types.h:96
uword unformat_hmac_key_id(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:273
vni_t uni
Definition: lisp_types.h:162
u16 gid_address_put(u8 *b, gid_address_t *gid)
Definition: lisp_types.c:1264
struct locator_pair locator_pair_t
u8 mpriority
Definition: lisp_types.h:284
u32 vni
Definition: lisp_types.h:148
u16 ip6_address_size_to_put()
Definition: lisp_types.c:504
uword unformat_ip_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:147
enum fid_addr_type_t_ fid_addr_type_t
u16 ip_address_size_to_write(ip_address_t *a)
Definition: lisp_types.c:479
u8 * format_negative_mapping_action(u8 *, va_list *args)
Definition: lisp_types.c:380
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
ip_prefix_t ippref
Definition: lisp_types.h:117
u32 locator_parse(void *ptr, locator_t *loc)
Definition: lisp_types.c:1482
#define always_inline
Definition: clib.h:84
u32 gid_address_parse(u8 *offset, gid_address_t *a)
Definition: lisp_types.c:1315
uword unformat_negative_mapping_action(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:333
u8 * key
Definition: lisp_types.h:322
Aggregrate type for a prefix.
Definition: fib_types.h:145
static foreach_gid_address_type_fcns u64 mac_to_u64(u8 *m)
Definition: lisp_types.h:267
unsigned long u64
Definition: types.h:89
u8 type
Definition: lisp_types.h:164
struct _gid_address_t * gid_addr
Definition: lisp_types.h:149
u8 gid_address_len(gid_address_t *a)
Definition: lisp_types.c:1250
u8 authoritative
Definition: lisp_types.h:317
ip_address_t lcl_loc
Definition: lisp_types.h:334
lisp_afi_e
Definition: lisp_types.h:206
void ip_address_to_fib_prefix(const ip_address_t *addr, fib_prefix_t *prefix)
convert from a LISP address to a FIB prefix
Definition: control.c:138
uword unformat_gid_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:298
u32 ip4_address_put(u8 *b, ip4_address_t *a)
Definition: lisp_types.c:511
u8 * format_ip_prefix(u8 *s, va_list *args)
Definition: lisp_types.c:162
void ip_address_copy_addr(void *dst, const ip_address_t *src)
Definition: lisp_types.c:766
u32 sw_if_index
Definition: lisp_types.h:279
u32 ip_address_put(u8 *b, ip_address_t *a)
Definition: lisp_types.c:529
int ip_address_cmp(const ip_address_t *ip1, const ip_address_t *ip2)
Definition: lisp_types.c:733
fid_addr_type_t_
Definition: lisp_types.h:106
u32 locator_set_index
Definition: lisp_types.h:311
void gid_address_free(gid_address_t *a)
Definition: lisp_types.c:714
u16 gid_address_size_to_put(gid_address_t *a)
Definition: lisp_types.c:1280
u8 * format_gid_address(u8 *s, va_list *args)
Definition: lisp_types.c:226
int gid_address_cmp(gid_address_t *a1, gid_address_t *a2)
Definition: lisp_types.c:1433
void ip_address_set(ip_address_t *dst, const void *src, u8 version)
Definition: lisp_types.c:772
void gid_address_ip_set(gid_address_t *dst, void *src, u8 version)
Definition: lisp_types.c:1361
lisp_key_type_t key_id
Definition: lisp_types.h:323
fid_addr_type_t type
Definition: lisp_types.h:120
void ip_prefix_normalize(ip_prefix_t *a)
Definition: lisp_types.c:852
struct _gid_address_t gid_address_t
void * gid_address_cast(gid_address_t *gid, gid_address_type_t type)
Definition: lisp_types.c:1289
unsigned int u32
Definition: types.h:88
u8 * format_mac_address(u8 *s, va_list *args)
Definition: lisp_types.c:198
u8 is_static
Definition: lisp_types.h:321
fid_address_t dp_address_t
Definition: lisp_types.h:123
void ip_prefix_to_fib_prefix(const ip_prefix_t *ipp, fib_prefix_t *fibp)
convert from a LISP to a FIB prefix
Definition: control.c:159
u8 ip_address_max_len(u8 ver)
Definition: lisp_types.c:491
u16 ip4_address_size_to_put()
Definition: lisp_types.c:497
u64 uword
Definition: types.h:112
template key/value backing page structure
Definition: bihash_doc.h:44
unsigned short u16
Definition: types.h:57
lisp_key_type_t
Definition: lisp_types.h:25
fid_address_t src
Definition: lisp_types.h:132
u8 * format_fid_address(u8 *s, va_list *args)
Definition: lisp_types.c:206
unsigned char u8
Definition: types.h:56
u8 * format_ip_address(u8 *s, va_list *args)
Definition: lisp_types.c:127
void gid_address_from_ip(gid_address_t *g, ip_address_t *ip)
Definition: lisp_types.c:725
u32 locator_cmp(locator_t *l1, locator_t *l2)
Definition: lisp_types.c:1516
Definition: lisp_types.h:37
gid_address_t eid
Definition: lisp_types.h:306
gid_address_t address
Definition: lisp_types.h:280
#define foreach_gid_address_type_fcns
Definition: lisp_types.h:248
ip_address_t rmt_loc
Definition: lisp_types.h:335
u32 ip6_address_put(u8 *b, ip6_address_t *a)
Definition: lisp_types.c:520
void locator_copy(locator_t *dst, locator_t *src)
Definition: lisp_types.c:1507
vhost_vring_addr_t addr
Definition: vhost-user.h:81
struct _unformat_input_t unformat_input_t
Definition: lisp_types.h:38
ip_address_type_t
Definition: lisp_types.h:35
void ip_address_to_46(const ip_address_t *addr, ip46_address_t *a, fib_protocol_t *proto)
Definition: lisp_types.c:779
source_dest_t sd
Definition: lisp_types.h:161
u32 * locator_indices
Definition: lisp_types.h:300
uword unformat_ip_prefix(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:170
locator_t * locators
Definition: lisp_types.h:312
u8 * format_hmac_key_id(u8 *s, va_list *args)
Definition: lisp_types.c:362