FD.io VPP  v18.10-34-gcce845e
Vector Packet Processing
util.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 /*
17  * Non-LB specific stuff comes here
18  */
19 
20 #ifndef LB_PLUGIN_LB_UTIL_H_
21 #define LB_PLUGIN_LB_UTIL_H_
22 
23 #include <vnet/vnet.h>
24 #include <vnet/ip/ip.h>
25 
26 #define ip46_address_type(ip46) (ip46_address_is_ip4(ip46)?IP46_TYPE_IP4:IP46_TYPE_IP6)
27 #define ip46_prefix_is_ip4(ip46, len) ((len) >= 96 && ip46_address_is_ip4(ip46))
28 #define ip46_prefix_type(ip46, len) (ip46_prefix_is_ip4(ip46, len)?IP46_TYPE_IP4:IP46_TYPE_IP6)
29 
30 void ip46_prefix_normalize(ip46_address_t *prefix, u8 plen);
31 uword unformat_ip46_prefix (unformat_input_t * input, va_list * args);
32 u8 *format_ip46_prefix (u8 * s, va_list * args);
33 
34 /**
35  * 32 bits integer comparison for running values.
36  * 1 > 0 is true. But 1 > 0xffffffff also is.
37  */
38 #define clib_u32_loop_gt(a, b) (((u32)(a)) - ((u32)(b)) < 0x7fffffff)
39 
40 #endif /* LB_PLUGIN_LB_UTIL_H_ */
unsigned char u8
Definition: types.h:56
struct _unformat_input_t unformat_input_t
u8 * format_ip46_prefix(u8 *s, va_list *args)
Definition: util.c:54
void ip46_prefix_normalize(ip46_address_t *prefix, u8 plen)
Definition: util.c:18
uword unformat_ip46_prefix(unformat_input_t *input, va_list *args)
Definition: util.c:32
u64 uword
Definition: types.h:112
typedef prefix
Definition: ip_types.api:40