FD.io VPP  v16.06
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 typedef enum
23 {
24  IP4,
27 
28 typedef CLIB_PACKED(struct ip_address
29 {
30  union
31  {
32  ip4_address_t v4;
33  ip6_address_t v6;
34  } ip;
35  u8 version;
36 }) ip_address_t;
37 
38 int ip_address_cmp (ip_address_t * ip1, ip_address_t * ip2);
39 void ip_address_copy (ip_address_t * dst , ip_address_t * src);
40 void ip_address_copy_addr (void * dst , ip_address_t * src);
41 
42 typedef CLIB_PACKED(struct ip_prefix
43 {
44  ip_address_t addr;
45  u8 len;
46 }) ip_prefix_t;
47 
48 #define ip_addr_addr(_a) (_a)->ip
49 #define ip_addr_v4(_a) (_a)->ip.v4
50 #define ip_addr_v6(_a) (_a)->ip.v6
51 #define ip_addr_version(_a) (_a)->version
52 
53 #define ip_prefix_addr(_a) (_a)->addr
54 #define ip_prefix_version(_a) ip_addr_version(&ip_prefix_addr(_a))
55 #define ip_prefix_len(_a) (_a)->len
56 #define ip_prefix_v4(_a) ip_addr_v4(&ip_prefix_addr(_a))
57 #define ip_prefix_v6(_a) ip_addr_v6(&ip_prefix_addr(_a))
58 
59 typedef enum
60 {
61  /* NOTE: ip addresses are left out on purpose. Use max masked ip-prefixes
62  * instead */
68 
69 typedef enum
70 {
71  /* make sure that values corresponds with RFC */
76 } lcaf_type_t;
77 
78 struct _gid_address_t;
79 
80 typedef struct
81 {
84  struct _gid_address_t *gid_addr;
85 } vni_t;
86 
87 #define vni_vni(_a) (_a)->vni
88 #define vni_mask_len(_a) (_a)->vni_mask_len
89 #define vni_gid(_a) (_a)->gid_addr
90 
91 typedef struct
92 {
95  struct _gid_address_t *src;
96  struct _gid_address_t *dst;
98 
99 typedef struct
100 {
101  /* the union needs to be at the beginning! */
102  union
103  {
106  };
108 } lcaf_t;
109 
110 #define lcaf_type(_a) (_a)->type
111 #define lcaf_vni(_a) vni_vni(& (_a)->uni)
112 #define lcaf_vni_len(_a) vni_mask_len(& (_a)->uni)
113 #define lcaf_gid (_a) vni_gid(& (_a)->uni)
114 
115 /* might want to expand this in the future :) */
116 typedef struct _gid_address_t
117 {
118  union
119  {
120  ip_prefix_t ippref;
121  lcaf_t lcaf;
122  };
123  u8 type;
124 } gid_address_t;
125 
126 u8 * format_ip_address (u8 * s, va_list * args);
127 uword unformat_ip_address (unformat_input_t * input, va_list * args);
128 u8 * format_ip_prefix (u8 * s, va_list * args);
129 uword unformat_ip_prefix (unformat_input_t * input, va_list * args);
130 
135 
136 u16 ip_address_size_to_write (ip_address_t * a);
137 u16 ip_address_iana_afi(ip_address_t *a);
138 u8 ip_address_max_len (u8 ver);
139 u32 ip_address_put (u8 * b, ip_address_t * a);
140 
141 /* LISP AFI codes */
142 typedef enum {
147 } lisp_afi_e;
148 
149 u8 *format_gid_address (u8 * s, va_list * args);
150 uword unformat_gid_address (unformat_input_t * input, va_list * args);
153 
155 u16 gid_address_put (u8 * b, gid_address_t * gid);
157 void * gid_address_cast (gid_address_t * gid, gid_address_type_t type);
158 void gid_address_copy(gid_address_t * dst, gid_address_t * src);
159 u32 gid_address_parse (u8 * offset, gid_address_t *a);
160 
161 #define gid_address_type(_a) (_a)->type
162 #define gid_address_ippref(_a) (_a)->ippref
163 #define gid_address_ippref_len(_a) (_a)->ippref.len
164 #define gid_address_ip(_a) ip_prefix_addr(&gid_address_ippref(_a))
165 #define gid_address_lcaf(_a) (_a)->lcaf
166 #define gid_address_vni(_a) ( (GID_ADDR_LCAF == gid_address_type(_a)) ? \
167  lcaf_vni(&gid_address_lcaf(_a)) : 0)
168 /* setter for vni */
169 #define gid_address_set_vni(_a, _val) \
170  (lcaf_vni(&gid_address_lcaf(_a)) = (_val))
171 
172 /* 'sub'address functions */
173 u16 ip_prefix_size_to_write (void * pref);
174 u16 ip_prefix_write (u8 * p, void * pref);
175 u8 ip_prefix_length (void *a);
176 void *ip_prefix_cast (gid_address_t * a);
177 void ip_prefix_copy (void * dst , void * src);
178 
179 int lcaf_cmp (lcaf_t * lcaf1, lcaf_t * lcaf2);
180 u16 lcaf_size_to_write (void * pref);
181 u16 lcaf_write (u8 * p, void * pref);
182 u8 lcaf_prefix_length (void *a);
183 void *lcaf_cast (gid_address_t * a);
184 void lcaf_copy (void * dst , void * src);
185 
186 typedef struct
187 {
188  /* mark locator as local as opposed to remote */
191  union {
194  };
199 } locator_t;
200 
201 u32 locator_parse (void * ptr, locator_t * loc);
202 void locator_copy (locator_t * dst, locator_t * src);
203 u32 locator_cmp (locator_t * l1, locator_t * l2);
204 void locator_free (locator_t * l);
205 
206 typedef struct
207 {
208  /* locator-set name */
209  u8 * name;
210 
211  /* vector of locator indices */
214 } locator_set_t;
215 
216 typedef struct
217 {
219 
220  /* index of local locator set */
222 
226 
228 } mapping_t;
229 
230 #endif /* VNET_LISP_GPE_LISP_TYPES_H_ */
u8 vni_mask_len
Definition: lisp_types.h:82
u16 ip_address_iana_afi(ip_address_t *a)
Definition: lisp_types.c:258
void locator_free(locator_t *l)
Definition: lisp_types.c:817
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
Definition: lisp_types.c:656
typedef CLIB_PACKED(struct ip_address{union{ip4_address_t v4;ip6_address_t v6;}ip;u8 version;}) ip_address_t
a
Definition: bitmap.h:393
gid_address_type_t
Definition: lisp_types.h:59
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
lcaf_type_t
Definition: lisp_types.h:69
vni_t uni
Definition: lisp_types.h:105
u16 ip_prefix_write(u8 *p, void *pref)
Definition: lisp_types.c:444
u16 gid_address_put(u8 *b, gid_address_t *gid)
Definition: lisp_types.c:636
u8 mpriority
Definition: lisp_types.h:197
u32 vni
Definition: lisp_types.h:83
u16 ip6_address_size_to_put()
Definition: lisp_types.c:277
uword unformat_ip_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:123
u16 ip_address_size_to_write(ip_address_t *a)
Definition: lisp_types.c:252
int ip_address_cmp(ip_address_t *ip1, ip_address_t *ip2)
Definition: lisp_types.c:403
void lcaf_copy(void *dst, void *src)
Definition: lisp_types.c:509
u32 locator_parse(void *ptr, locator_t *loc)
Definition: lisp_types.c:765
struct _gid_address_t * src
Definition: lisp_types.h:95
u32 gid_address_parse(u8 *offset, gid_address_t *a)
Definition: lisp_types.c:664
void * lcaf_cast(gid_address_t *a)
Definition: lisp_types.c:525
u16 lcaf_write(u8 *p, void *pref)
Definition: lisp_types.c:545
u8 lcaf_prefix_length(void *a)
Definition: lisp_types.c:519
u8 type
Definition: lisp_types.h:107
void ip_address_copy(ip_address_t *dst, ip_address_t *src)
Definition: lisp_types.c:419
struct _gid_address_t * dst
Definition: lisp_types.h:96
struct _gid_address_t * gid_addr
Definition: lisp_types.h:84
u8 gid_address_len(gid_address_t *a)
Definition: lisp_types.c:629
u8 authoritative
Definition: lisp_types.h:225
void ip_address_copy_addr(void *dst, ip_address_t *src)
Definition: lisp_types.c:425
lisp_afi_e
Definition: lisp_types.h:142
u16 lcaf_size_to_write(void *pref)
Definition: lisp_types.c:613
u8 ip_prefix_length(void *a)
Definition: lisp_types.c:460
uword unformat_gid_address(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:166
u32 ip4_address_put(u8 *b, ip4_address_t *a)
Definition: lisp_types.c:284
u8 * format_ip_prefix(u8 *s, va_list *args)
Definition: lisp_types.c:136
u32 sw_if_index
Definition: lisp_types.h:192
u32 ip_address_put(u8 *b, ip_address_t *a)
Definition: lisp_types.c:302
int lcaf_cmp(lcaf_t *lcaf1, lcaf_t *lcaf2)
u32 locator_set_index
Definition: lisp_types.h:221
void gid_address_free(gid_address_t *a)
Definition: lisp_types.c:392
u16 gid_address_size_to_put(gid_address_t *a)
Definition: lisp_types.c:643
u8 * format_gid_address(u8 *s, va_list *args)
Definition: lisp_types.c:151
int gid_address_cmp(gid_address_t *a1, gid_address_t *a2)
Definition: lisp_types.c:730
struct _gid_address_t gid_address_t
void * gid_address_cast(gid_address_t *gid, gid_address_type_t type)
Definition: lisp_types.c:650
unsigned int u32
Definition: types.h:88
void ip_prefix_copy(void *dst, void *src)
Definition: lisp_types.c:466
u16 ip_prefix_size_to_write(void *pref)
Definition: lisp_types.c:437
u8 ip_address_max_len(u8 ver)
Definition: lisp_types.c:264
u16 ip4_address_size_to_put()
Definition: lisp_types.c:270
u64 uword
Definition: types.h:112
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
u8 * format_ip_address(u8 *s, va_list *args)
Definition: lisp_types.c:103
u32 locator_cmp(locator_t *l1, locator_t *l2)
Definition: lisp_types.c:799
Definition: lisp_types.h:24
gid_address_t eid
Definition: lisp_types.h:218
gid_address_t address
Definition: lisp_types.h:193
u32 ip6_address_put(u8 *b, ip6_address_t *a)
Definition: lisp_types.c:293
void locator_copy(locator_t *dst, locator_t *src)
Definition: lisp_types.c:790
vhost_vring_addr_t addr
Definition: vhost-user.h:78
struct _unformat_input_t unformat_input_t
Definition: lisp_types.h:25
ip_address_type_t
Definition: lisp_types.h:22
source_dest_t sd
Definition: lisp_types.h:104
u32 * locator_indices
Definition: lisp_types.h:212
uword unformat_ip_prefix(unformat_input_t *input, va_list *args)
Definition: lisp_types.c:143
void * ip_prefix_cast(gid_address_t *a)
Definition: lisp_types.c:431