FD.io VPP  v20.01-48-g3e0dafb74
Vector Packet Processing
ip_types.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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 __IP_TYPES_H__
17 #define __IP_TYPES_H__
18 
19 #include <vnet/fib/fib_types.h>
20 
22 {
26 
28  va_list * args);
29 extern u8 *format_ip_address_family (u8 * s, va_list * args);
30 
31 #define FOR_EACH_IP_ADDRESS_FAMILY(_af) \
32  for (_af = AF_IP4; _af <= AF_IP6; _af++)
33 
34 #define u8_ptr_add(ptr, index) (((u8 *)ptr) + index)
35 #define u16_net_add(u, val) clib_host_to_net_u16(clib_net_to_host_u16(u) + (val))
36 
37 /* *INDENT-OFF* */
38 typedef struct ip_address
39 {
40  union
41  {
44  } ip;
46 } __clib_packed ip_address_t;
47 /* *INDENT-ON* */
48 
49 #define ip_addr_addr(_a) (_a)->ip
50 #define ip_addr_v4(_a) (_a)->ip.v4
51 #define ip_addr_v6(_a) (_a)->ip.v6
52 #define ip_addr_version(_a) (_a)->version
53 
54 extern int ip_address_cmp (const ip_address_t * ip1,
55  const ip_address_t * ip2);
56 extern void ip_address_copy (ip_address_t * dst, const ip_address_t * src);
57 extern void ip_address_copy_addr (void *dst, const ip_address_t * src);
58 extern void ip_address_set (ip_address_t * dst, const void *src, u8 version);
59 extern u16 ip_address_size (const ip_address_t * a);
60 extern u16 ip_version_to_size (u8 ver);
61 extern u8 *format_ip_address (u8 * s, va_list * args);
62 extern uword unformat_ip_address (unformat_input_t * input, va_list * args);
63 extern void ip_address_to_46 (const ip_address_t * addr,
64  ip46_address_t * a, fib_protocol_t * proto);
65 
66 /* *INDENT-OFF* */
67 typedef struct ip_prefix
68 {
71 } __clib_packed ip_prefix_t;
72 /* *INDENT-ON* */
73 
74 #define ip_prefix_addr(_a) (_a)->addr
75 #define ip_prefix_version(_a) ip_addr_version(&ip_prefix_addr(_a))
76 #define ip_prefix_len(_a) (_a)->len
77 #define ip_prefix_v4(_a) ip_addr_v4(&ip_prefix_addr(_a))
78 #define ip_prefix_v6(_a) ip_addr_v6(&ip_prefix_addr(_a))
79 
80 extern int ip_prefix_cmp (ip_prefix_t * p1, ip_prefix_t * p2);
81 extern void ip_prefix_normalize (ip_prefix_t * a);
82 
83 extern void ip_address_to_fib_prefix (const ip_address_t * addr,
85 extern void ip_prefix_to_fib_prefix (const ip_prefix_t * ipp,
86  fib_prefix_t * fibp);
87 extern u8 *format_ip_prefix (u8 * s, va_list * args);
88 extern uword unformat_ip_prefix (unformat_input_t * input, va_list * args);
89 
90 #endif /* __IP_TYPES_H__ */
91 
92 /*
93  * fd.io coding-style-patch-verification: ON
94  *
95  * Local Variables:
96  * eval: (c-set-style "gnu")
97  * End:
98  */
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:130
u8 * format_ip_address(u8 *s, va_list *args)
Definition: ip_types.c:20
u8 proto
Definition: acl_types.api:47
struct ip_address ip_address_t
int ip_address_cmp(const ip_address_t *ip1, const ip_address_t *ip2)
Definition: ip_types.c:98
u16 ip_address_size(const ip_address_t *a)
Definition: ip_types.c:83
a
Definition: bitmap.h:538
u8 len
Definition: ip_types.h:70
vl_api_address_t src
Definition: gre.api:60
vl_api_prefix_t prefix
Definition: ip.api:144
enum ip_address_family_t_ ip_address_family_t
vhost_vring_addr_t addr
Definition: vhost_user.h:147
int ip_prefix_cmp(ip_prefix_t *p1, ip_prefix_t *p2)
Definition: ip_types.c:258
unsigned char u8
Definition: types.h:56
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
u8 * format_ip_address_family(u8 *s, va_list *args)
Definition: ip.c:283
Aggregate type for a prefix.
Definition: fib_types.h:203
struct ip_prefix ip_prefix_t
void ip_address_copy_addr(void *dst, const ip_address_t *src)
Definition: ip_types.c:131
u16 ip_version_to_size(u8 ver)
Definition: ip_types.c:137
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
vl_api_address_t dst
Definition: gre.api:61
uword unformat_ip_address_family(unformat_input_t *input, va_list *args)
uword unformat_ip_prefix(unformat_input_t *input, va_list *args)
Definition: ip_types.c:63
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:151
ip6_address_t v6
Definition: ip_types.h:43
ip_address_family_t version
Definition: ip_types.h:45
uword unformat_ip_address(unformat_input_t *input, va_list *args)
Definition: ip_types.c:40
ip_address_t addr
Definition: ip_types.h:69
ip4_address_t v4
Definition: ip_types.h:42
void ip_address_set(ip_address_t *dst, const void *src, u8 version)
Definition: ip_types.c:152
void ip_prefix_normalize(ip_prefix_t *a)
Definition: ip_types.c:232
u64 uword
Definition: types.h:112
union ip_address::@304 ip
ip_address_family_t_
Definition: ip_types.h:21
void ip_address_copy(ip_address_t *dst, const ip_address_t *src)
Definition: ip_types.c:115
void ip_address_to_46(const ip_address_t *addr, ip46_address_t *a, fib_protocol_t *proto)
Definition: ip_types.c:159
u8 * format_ip_prefix(u8 *s, va_list *args)
Definition: ip_types.c:55