FD.io VPP  v21.01.1
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  /* NOTE: ip addresses are left out on purpose. Use max masked ip-prefixes
38  * instead */
49 
50 typedef enum
51 {
52  /* make sure that values corresponds with RFC */
57  LCAF_NSH = 17,
59 } lcaf_type_t;
60 
61 typedef enum fid_addr_type_t_
62 {
66 } __attribute__ ((packed)) fid_addr_type_t;
67 
68 /* flat address type */
69 typedef struct
70 {
71  union
72  {
74  u8 mac[6];
76  };
77  fid_addr_type_t type;
79 
81 
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);
89 
90 typedef struct
91 {
95 
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))
104 
105 typedef struct
106 {
109  struct _gid_address_t *gid_addr;
110 } vni_t;
111 
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
115 
116 typedef struct
117 {
120 } nsh_t;
121 
122 #define nsh_spi(_a) (_a)->spi
123 #define nsh_si(_a) (_a)->si
124 
125 typedef struct
126 {
130 
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
136 
137 typedef struct
138 {
139  /* the union needs to be at the beginning! */
140  union
141  {
145  };
147 } lcaf_t;
148 
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)
152 
153 /* might want to expand this in the future :) */
154 typedef struct _gid_address_t
155 {
156  union
157  {
158  ip_prefix_t ippref;
159  lcaf_t lcaf;
160  u8 mac[6];
161  source_dest_t sd;
162  lcaf_arp_ndp_t arp_ndp;
163  nsh_t nsh;
164  };
165  u8 type;
166  u32 vni;
167  u8 vni_mask;
168 } gid_address_t;
169 
173 u32 ip6_address_put (u8 * b, ip6_address_t * a);
174 
177 u8 ip_address_max_len (u8 ver);
178 u32 ip_address_put (u8 * b, ip_address_t * a);
179 
180 /* LISP AFI codes */
181 typedef enum
182 {
186  LISP_AFI_LCAF = 16387,
187  LISP_AFI_MAC = 16389
188 } lisp_afi_e;
189 
190 u8 *format_gid_address (u8 * s, va_list * args);
191 uword unformat_gid_address (unformat_input_t * input, va_list * args);
194 
196 u16 gid_address_put (u8 * b, gid_address_t * gid);
198 void *gid_address_cast (gid_address_t * gid, gid_address_type_t type);
202 
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
231 
232 /* 'sub'address functions */
233 #define foreach_gid_address_type_fcns \
234  _(no_addr) \
235  _(ip_prefix) \
236  _(lcaf) \
237  _(mac) \
238  _(nsh) \
239  _(sd)
240 
241 /* *INDENT-OFF* */
242 #define _(_n) \
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);
248 
250 #undef _
251 /* *INDENT-ON* */
252 
255 {
256  return (*((u64 *) m) & 0xffffffffffff);
257 }
258 
259 typedef struct
260 {
261  /* mark locator as local as opposed to remote */
264  union
265  {
268  };
274 } locator_t;
275 
276 u32 locator_parse (void *ptr, locator_t * loc);
278 u32 locator_cmp (locator_t * l1, locator_t * l2);
279 void locator_free (locator_t * l);
280 
281 typedef struct
282 {
283  /* locator-set name */
285 
286  /* vector of locator indices */
289 } locator_set_t;
290 
291 typedef struct
292 {
294 
295  /* index of local locator set */
296  union
297  {
299  locator_t *locators; /* used for map register message */
300  };
301 
304 
307  /* valid only for remote mappings */
313  u8 rsvd:1;
314 
315  u8 *key;
316  lisp_key_type_t key_id;
320 } mapping_t;
321 
322 uword
323 unformat_negative_mapping_action (unformat_input_t * input, va_list * args);
324 u8 *format_negative_mapping_action (u8 *, va_list * args);
325 
326 typedef struct locator_pair
327 {
328  /* local and remote locators (underlay attachment points) */
331 
335 
336 void
338 
340 void gid_to_dp_address (gid_address_t * g, dp_address_t * d);
341 
342 #endif /* VNET_LISP_GPE_LISP_TYPES_H_ */
343 
344 /*
345  * fd.io coding-style-patch-verification: ON
346  *
347  * Local Variables:
348  * eval: (c-set-style "gnu")
349  * End:
350  */
u8 vni_mask_len
Definition: lisp_types.h:107
u16 ip_address_iana_afi(ip_address_t *a)
Definition: lisp_types.c:426
void locator_free(locator_t *l)
Definition: lisp_types.c:1445
u16 vni
Definition: flow_types.api:160
counter_t packets
Definition: lisp_types.h:319
u8 timer_set
Definition: lisp_types.h:317
fid_address_t dst
Definition: lisp_types.h:93
vl_api_mac_address_t mac
Definition: l2.api:502
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
Definition: lisp_types.c:1203
void build_src_dst(gid_address_t *sd, gid_address_t *src, gid_address_t *dst)
Definition: lisp_types.c:1452
gid_address_type_t
Definition: lisp_types.h:35
lcaf_type_t
Definition: lisp_types.h:50
uword unformat_hmac_key_id(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:247
vni_t uni
Definition: lisp_types.h:144
unsigned long u64
Definition: types.h:89
u16 gid_address_put(u8 *b, gid_address_t *gid)
Definition: lisp_types.c:1172
struct locator_pair locator_pair_t
void gid_to_dp_address(gid_address_t *g, dp_address_t *d)
Definition: lisp_types.c:489
vl_api_address_t src
Definition: gre.api:54
u8 mpriority
Definition: lisp_types.h:271
u32 vni
Definition: lisp_types.h:108
u16 ip6_address_size_to_put()
Definition: lisp_types.c:445
enum fid_addr_type_t_ fid_addr_type_t
u16 ip_address_size_to_write(ip_address_t *a)
Definition: lisp_types.c:420
u8 * format_negative_mapping_action(u8 *, va_list *args)
Definition: lisp_types.c:360
unsigned char u8
Definition: types.h:56
ip_prefix_t ippref
Definition: lisp_types.h:73
u32 locator_parse(void *ptr, locator_t *loc)
Definition: lisp_types.c:1392
u32 spi
Definition: lisp_types.h:118
u32 gid_address_parse(u8 *offset, gid_address_t *a)
Definition: lisp_types.c:1223
uword unformat_negative_mapping_action(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:313
u8 * key
Definition: lisp_types.h:315
uint64_t counter_t
64bit counters
Definition: counter_types.h:22
static foreach_gid_address_type_fcns u64 mac_to_u64(u8 *m)
Definition: lisp_types.h:254
unsigned int u32
Definition: types.h:88
u8 delete_after_expiration
Definition: lisp_types.h:312
u8 type
Definition: lisp_types.h:146
vl_api_fib_path_type_t type
Definition: fib_types.api:123
struct _gid_address_t * gid_addr
Definition: lisp_types.h:109
u8 gid_address_len(gid_address_t *a)
Definition: lisp_types.c:1158
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
u8 authoritative
Definition: lisp_types.h:305
#define always_inline
Definition: ipsec.h:28
ip_address_t lcl_loc
Definition: lisp_types.h:329
vl_api_address_t dst
Definition: gre.api:55
lisp_afi_e
Definition: lisp_types.h:181
uword unformat_gid_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:272
u32 ip4_address_put(u8 *b, ip4_address_t *a)
Definition: lisp_types.c:452
u32 sw_if_index
Definition: lisp_types.h:266
u32 ip_address_put(u8 *b, ip_address_t *a)
Definition: lisp_types.c:470
fid_addr_type_t_
Definition: lisp_types.h:61
u32 locator_set_index
Definition: lisp_types.h:298
void gid_address_free(gid_address_t *a)
Definition: lisp_types.c:733
u8 almost_expired
Definition: lisp_types.h:311
u16 gid_address_size_to_put(gid_address_t *a)
Definition: lisp_types.c:1188
u8 * format_gid_address(u8 *s, va_list *args)
Definition: lisp_types.c:187
int gid_address_cmp(gid_address_t *a1, gid_address_t *a2)
Definition: lisp_types.c:1340
void gid_address_ip_set(gid_address_t *dst, void *src, u8 version)
Definition: lisp_types.c:1268
lisp_key_type_t key_id
Definition: lisp_types.h:316
fid_addr_type_t type
Definition: lisp_types.h:77
u8 si
Definition: lisp_types.h:119
struct _gid_address_t gid_address_t
void * gid_address_cast(gid_address_t *gid, gid_address_type_t type)
Definition: lisp_types.c:1197
lcaf_arp_ndp_t arp_ndp
Definition: lisp_types.h:143
typedef nsh
Definition: lisp_types.api:45
u8 is_static
Definition: lisp_types.h:308
fid_address_t dp_address_t
Definition: lisp_types.h:80
u8 ip_address_max_len(u8 ver)
Definition: lisp_types.c:432
u16 ip4_address_size_to_put()
Definition: lisp_types.c:438
template key/value backing page structure
Definition: bihash_doc.h:44
u32 timer_handle
Definition: lisp_types.h:318
lisp_key_type_t
Definition: lisp_types.h:25
fid_address_t src
Definition: lisp_types.h:92
vl_api_address_t ip
Definition: l2.api:501
u8 * format_fid_address(u8 *s, va_list *args)
Definition: lisp_types.c:166
ip_address_t addr
Definition: lisp_types.h:127
u64 uword
Definition: types.h:112
void gid_address_from_ip(gid_address_t *g, ip_address_t *ip)
Definition: lisp_types.c:744
u32 locator_cmp(locator_t *l1, locator_t *l2)
Definition: lisp_types.c:1427
gid_address_t eid
Definition: lisp_types.h:293
gid_address_t address
Definition: lisp_types.h:267
option version
Definition: sample.api:19
#define foreach_gid_address_type_fcns
Definition: lisp_types.h:233
ip_address_t rmt_loc
Definition: lisp_types.h:330
u32 ip6_address_put(u8 *b, ip6_address_t *a)
Definition: lisp_types.c:461
void locator_copy(locator_t *dst, locator_t *src)
Definition: lisp_types.c:1418
source_dest_t sd
Definition: lisp_types.h:142
u32 * locator_indices
Definition: lisp_types.h:287
locator_t * locators
Definition: lisp_types.h:299
u8 * format_hmac_key_id(u8 *s, va_list *args)
Definition: lisp_types.c:342