FD.io VPP  v21.10.1-2-g0a485f517
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  };
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);
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 
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;
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 
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  */
ip_address
Definition: ip_types.h:79
locator_t::priority
u8 priority
Definition: lisp_types.h:269
source_dest_t
Definition: lisp_types.h:90
mac
vl_api_mac_address_t mac
Definition: l2.api:559
ip4_address_put
u32 ip4_address_put(u8 *b, ip4_address_t *a)
Definition: lisp_types.c:452
locator_set_t::name
u8 * name
Definition: lisp_types.h:284
fid_address_t
Definition: lisp_types.h:69
mapping_t::packets
counter_t packets
Definition: lisp_types.h:319
ip_prefix
Definition: ip_types.h:116
lisp_cp_messages.h
LCAF_TYPES
@ LCAF_TYPES
Definition: lisp_types.h:58
lcaf_t::sd
source_dest_t sd
Definition: lisp_types.h:142
GID_ADDR_LCAF
@ GID_ADDR_LCAF
Definition: lisp_types.h:40
gid_address_parse
u32 gid_address_parse(u8 *offset, gid_address_t *a)
Definition: lisp_types.c:1223
locator_t::mpriority
u8 mpriority
Definition: lisp_types.h:271
locator_t::mweight
u8 mweight
Definition: lisp_types.h:272
unformat_hmac_key_id
uword unformat_hmac_key_id(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:247
vni
u32 vni
Definition: flow_types.api:160
u16
unsigned short u16
Definition: types.h:57
format_fid_address
u8 * format_fid_address(u8 *s, va_list *args)
Definition: lisp_types.c:166
format_hmac_key_id
u8 * format_hmac_key_id(u8 *s, va_list *args)
Definition: lisp_types.c:342
mapping_t::key
u8 * key
Definition: lisp_types.h:315
GID_ADDR_IP_PREFIX
@ GID_ADDR_IP_PREFIX
Definition: lisp_types.h:39
nsh_t
Definition: lisp_types.h:116
unformat_input_t
struct _unformat_input_t unformat_input_t
gid_address_from_ip
void gid_address_from_ip(gid_address_t *g, ip_address_t *ip)
Definition: lisp_types.c:744
locator_cmp
u32 locator_cmp(locator_t *l1, locator_t *l2)
Definition: lisp_types.c:1427
locator_t
Definition: lisp_types.h:259
locator_free
void locator_free(locator_t *l)
Definition: lisp_types.c:1445
LISP_AFI_IP6
@ LISP_AFI_IP6
Definition: lisp_types.h:185
lcaf_arp_ndp_t::addr
ip_address_t addr
Definition: lisp_types.h:127
vni_t
Definition: lisp_types.h:105
fid_addr_type_t
enum fid_addr_type_t_ fid_addr_type_t
mapping_t::local
u8 local
Definition: lisp_types.h:306
locator_t::local
u8 local
Definition: lisp_types.h:262
lcaf_t::uni
vni_t uni
Definition: lisp_types.h:144
locator_t::state
u8 state
Definition: lisp_types.h:263
format_negative_mapping_action
u8 * format_negative_mapping_action(u8 *, va_list *args)
Definition: lisp_types.c:360
ip_address_put
u32 ip_address_put(u8 *b, ip_address_t *a)
Definition: lisp_types.c:470
GID_ADDR_NO_ADDRESS
@ GID_ADDR_NO_ADDRESS
Definition: lisp_types.h:46
gid_address_put
u16 gid_address_put(u8 *b, gid_address_t *gid)
Definition: lisp_types.c:1172
vni_t::vni_mask_len
u8 vni_mask_len
Definition: lisp_types.h:107
ip_address_max_len
u8 ip_address_max_len(u8 ver)
Definition: lisp_types.c:432
mapping_t::ttl
u32 ttl
Definition: lisp_types.h:302
locator_t::sw_if_index
u32 sw_if_index
Definition: lisp_types.h:266
locator_pair_t
struct locator_pair locator_pair_t
lcaf_arp_ndp_t::bd
u32 bd
Definition: lisp_types.h:128
locator_copy
void locator_copy(locator_t *dst, locator_t *src)
Definition: lisp_types.c:1418
FID_ADDR_IP_PREF
@ FID_ADDR_IP_PREF
Definition: lisp_types.h:63
locator_pair::rmt_loc
ip_address_t rmt_loc
Definition: lisp_types.h:330
mapping_t::delete_after_expiration
u8 delete_after_expiration
Definition: lisp_types.h:312
counter_t
uint64_t counter_t
64bit counters
Definition: counter_types.h:22
fid_addr_type_t_
fid_addr_type_t_
Definition: lisp_types.h:61
mapping_t::authoritative
u8 authoritative
Definition: lisp_types.h:305
GID_ADDR_ARP
@ GID_ADDR_ARP
Definition: lisp_types.h:44
FID_ADDR_MAC
@ FID_ADDR_MAC
Definition: lisp_types.h:64
ip_address_size_to_write
u16 ip_address_size_to_write(ip_address_t *a)
Definition: lisp_types.c:420
uword
u64 uword
Definition: types.h:112
gid_address_size_to_put
u16 gid_address_size_to_put(gid_address_t *a)
Definition: lisp_types.c:1188
locator_pair::weight
u8 weight
Definition: lisp_types.h:333
locator_pair::lcl_loc
ip_address_t lcl_loc
Definition: lisp_types.h:329
mapping_t
Definition: lisp_types.h:291
vni_t::vni
u32 vni
Definition: lisp_types.h:108
mac_to_u64
static foreach_gid_address_type_fcns u64 mac_to_u64(u8 *m)
Definition: lisp_types.h:254
src
vl_api_address_t src
Definition: gre.api:54
mapping_t::pitr_set
u8 pitr_set
Definition: lisp_types.h:309
gid_address_cast
void * gid_address_cast(gid_address_t *gid, gid_address_type_t type)
Definition: lisp_types.c:1197
LCAF_SOURCE_DEST
@ LCAF_SOURCE_DEST
Definition: lisp_types.h:56
ip4_address_t
Definition: ip4_packet.h:50
LCAF_NULL_BODY
@ LCAF_NULL_BODY
Definition: lisp_types.h:53
LISP_AFI_MAC
@ LISP_AFI_MAC
Definition: lisp_types.h:187
lcaf_arp_ndp_t
Definition: lisp_types.h:125
mapping_t::locator_set_index
u32 locator_set_index
Definition: lisp_types.h:298
fid_address_t::type
fid_addr_type_t type
Definition: lisp_types.h:77
gid_address_cmp
int gid_address_cmp(gid_address_t *a1, gid_address_t *a2)
Definition: lisp_types.c:1340
locator_pair
Definition: lisp_types.h:326
mapping_t::key_id
lisp_key_type_t key_id
Definition: lisp_types.h:316
locator_t::weight
u8 weight
Definition: lisp_types.h:270
locator_set_t::locator_indices
u32 * locator_indices
Definition: lisp_types.h:287
ip4_address_size_to_put
u16 ip4_address_size_to_put()
Definition: lisp_types.c:438
unformat_gid_address
uword unformat_gid_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:272
mapping_t::rsvd
u8 rsvd
Definition: lisp_types.h:313
foreach_gid_address_type_fcns
#define foreach_gid_address_type_fcns
Definition: lisp_types.h:233
GID_ADDR_NSH
@ GID_ADDR_NSH
Definition: lisp_types.h:43
vni_t::gid_addr
struct _gid_address_t * gid_addr
Definition: lisp_types.h:109
fid_address_t::nsh
u32 nsh
Definition: lisp_types.h:75
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
clib_bihash_value
template key/value backing page structure
Definition: bihash_doc.h:44
build_src_dst
void build_src_dst(gid_address_t *sd, gid_address_t *src, gid_address_t *dst)
Definition: lisp_types.c:1452
lisp_key_type_t
lisp_key_type_t
Definition: lisp_types.h:25
lisp_afi_e
lisp_afi_e
Definition: lisp_types.h:181
mapping_t::almost_expired
u8 almost_expired
Definition: lisp_types.h:311
mapping_t::is_static
u8 is_static
Definition: lisp_types.h:308
u64
unsigned long u64
Definition: types.h:89
LCAF_INSTANCE_ID
@ LCAF_INSTANCE_ID
Definition: lisp_types.h:55
GID_ADDR_SRC_DST
@ GID_ADDR_SRC_DST
Definition: lisp_types.h:42
ip6_address_size_to_put
u16 ip6_address_size_to_put()
Definition: lisp_types.c:445
version
option version
Definition: sample.api:19
gid_to_dp_address
void gid_to_dp_address(gid_address_t *g, dp_address_t *d)
Definition: lisp_types.c:489
ip.h
u32
unsigned int u32
Definition: types.h:88
mapping_t::timer_handle
u32 timer_handle
Definition: lisp_types.h:318
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
source_dest_t::src
fid_address_t src
Definition: lisp_types.h:92
fid_address_t::ippref
ip_prefix_t ippref
Definition: lisp_types.h:73
LCAF_NSH
@ LCAF_NSH
Definition: lisp_types.h:57
locator_parse
u32 locator_parse(void *ptr, locator_t *loc)
Definition: lisp_types.c:1392
GID_ADDR_NDP
@ GID_ADDR_NDP
Definition: lisp_types.h:45
LISP_AFI_IP
@ LISP_AFI_IP
Definition: lisp_types.h:184
LISP_AFI_NO_ADDR
@ LISP_AFI_NO_ADDR
Definition: lisp_types.h:183
nsh
typedef nsh
Definition: lisp_types.api:45
locator_set_t
Definition: lisp_types.h:281
HMAC_SHA_1_96
@ HMAC_SHA_1_96
Definition: lisp_types.h:28
FID_ADDR_NSH
@ FID_ADDR_NSH
Definition: lisp_types.h:65
HMAC_SHA_256_128
@ HMAC_SHA_256_128
Definition: lisp_types.h:29
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
lcaf_t::arp_ndp
lcaf_arp_ndp_t arp_ndp
Definition: lisp_types.h:143
locator_t::address
gid_address_t address
Definition: lisp_types.h:267
a
a
Definition: bitmap.h:525
ip
vl_api_address_t ip
Definition: l2.api:558
gid_address_ip_set
void gid_address_ip_set(gid_address_t *dst, void *src, u8 version)
mapping_t::eid
gid_address_t eid
Definition: lisp_types.h:293
LISP_AFI_LCAF
@ LISP_AFI_LCAF
Definition: lisp_types.h:186
locator_set_t::local
u8 local
Definition: lisp_types.h:288
dp_address_t
fid_address_t dp_address_t
Definition: lisp_types.h:80
lcaf_t::type
u8 type
Definition: lisp_types.h:146
HMAC_NO_KEY
@ HMAC_NO_KEY
Definition: lisp_types.h:27
locator_pair::priority
u8 priority
Definition: lisp_types.h:332
lcaf_type_t
lcaf_type_t
Definition: lisp_types.h:50
gid_address_t
struct _gid_address_t gid_address_t
gid_address_copy
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
Definition: lisp_types.c:1203
lcaf_t
Definition: lisp_types.h:137
unformat_negative_mapping_action
uword unformat_negative_mapping_action(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:313
GID_ADDR_MAC
@ GID_ADDR_MAC
Definition: lisp_types.h:41
locator_t::probed
u8 probed
Definition: lisp_types.h:273
mapping_t::action
u8 action
Definition: lisp_types.h:303
LCAF_AFI_LIST_TYPE
@ LCAF_AFI_LIST_TYPE
Definition: lisp_types.h:54
ip6_address_put
u32 ip6_address_put(u8 *b, ip6_address_t *a)
Definition: lisp_types.c:461
gid_address_len
u8 gid_address_len(gid_address_t *a)
Definition: lisp_types.c:1158
gid_address_free
void gid_address_free(gid_address_t *a)
Definition: lisp_types.c:733
nsh_t::si
u8 si
Definition: lisp_types.h:119
mapping_t::locators
locator_t * locators
Definition: lisp_types.h:299
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
format_gid_address
u8 * format_gid_address(u8 *s, va_list *args)
Definition: lisp_types.c:187
ip_address_iana_afi
u16 ip_address_iana_afi(ip_address_t *a)
Definition: lisp_types.c:426
nsh_t::spi
u32 spi
Definition: lisp_types.h:118
mapping_t::nsh_set
u8 nsh_set
Definition: lisp_types.h:310
mapping_t::timer_set
u8 timer_set
Definition: lisp_types.h:317
source_dest_t::dst
fid_address_t dst
Definition: lisp_types.h:93
gid_address_type_t
gid_address_type_t
Definition: lisp_types.h:35
GID_ADDR_TYPES
@ GID_ADDR_TYPES
Definition: lisp_types.h:47