FD.io VPP  v21.01.1
Vector Packet Processing
ip_format_fns.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 included_ip_format_fns_h
17 #define included_ip_format_fns_h
18 
19 static inline u8 *format_vl_api_ip6_address_t (u8 * s, va_list * args);
20 static inline u8 *format_vl_api_ip4_address_t (u8 * s, va_list * args);
21 
22 #include <vnet/ip/format.h>
23 #include <vnet/ip/ip_types.api_types.h>
24 
25 static inline u8 *
26 format_vl_api_ip6_address_t (u8 * s, va_list * args)
27 {
28  vl_api_ip6_address_t *a = va_arg (*args, vl_api_ip6_address_t *);
29  u32 indent __attribute__((unused)) = va_arg (*args, u32);
30 
31  return format (s, "%U", format_ip6_address, a);
32 }
33 
34 static inline u8 *
35 format_vl_api_ip6_prefix_t (u8 * s, va_list * args)
36 {
37  vl_api_ip6_prefix_t *a = va_arg (*args, vl_api_ip6_prefix_t *);
38  u32 indent __attribute__((unused)) = va_arg (*args, u32);
39 
40  return format (s, "%U/%u", format_ip6_address, &a->address, a->len);
41 }
42 
43 static inline u8 *
44 format_vl_api_ip4_address_t (u8 * s, va_list * args)
45 {
46  vl_api_ip4_address_t *a = va_arg (*args, vl_api_ip4_address_t *);
47  u32 indent __attribute__((unused)) = va_arg (*args, u32);
48 
49  return format (s, "%U", format_ip4_address, a);
50 }
51 
52 static inline u8 *
53 format_vl_api_ip4_prefix_t (u8 * s, va_list * args)
54 {
55  vl_api_ip4_prefix_t *a = va_arg (*args, vl_api_ip4_prefix_t *);
56  u32 indent __attribute__((unused)) = va_arg (*args, u32);
57 
58  return format (s, "%U/%u", format_ip4_address, &a->address, a->len);
59 }
60 
61 static inline u8 *
62 format_vl_api_address_t (u8 * s, va_list * args)
63 {
64  vl_api_address_t *a = va_arg (*args, vl_api_address_t *);
65  u32 indent __attribute__((unused)) = va_arg (*args, u32);
66 
67  switch (a->af) {
68  case ADDRESS_IP4:
69  return format(s, "%U", format_ip4_address, &a->un.ip4);
70  case ADDRESS_IP6:
71  return format(s, "%U", format_ip6_address, &a->un.ip6);
72  }
73  return format (s, "unknown-af");
74 }
75 
76 static inline u8 *
77 format_vl_api_prefix_t (u8 * s, va_list * args)
78 {
79  vl_api_prefix_t *a = va_arg (*args, vl_api_prefix_t *);
80  u32 indent __attribute__((unused)) = va_arg (*args, u32);
81 
82  return format (s, "%U/%u", format_vl_api_address_t, &a->address, indent, a->len);
83 }
84 
85 static inline u8 *
87 {
88  return format_vl_api_prefix_t (s, args);
89 }
90 
91 static inline u8 *
93 {
94  return format_vl_api_ip4_prefix_t (s, args);
95 }
96 
97 static inline u8 *
99 {
100  return format_vl_api_ip6_prefix_t (s, args);
101 }
102 
103 #endif
a
Definition: bitmap.h:544
static u8 * format_vl_api_ip6_prefix_t(u8 *s, va_list *args)
Definition: ip_format_fns.h:35
unsigned char u8
Definition: types.h:56
format_function_t format_ip4_address
Definition: format.h:73
static u8 * format_vl_api_ip4_prefix_t(u8 *s, va_list *args)
Definition: ip_format_fns.h:53
description fragment has unexpected format
Definition: map.api:433
static u8 * format_vl_api_ip4_address_with_prefix_t(u8 *s, va_list *args)
Definition: ip_format_fns.h:92
unsigned int u32
Definition: types.h:88
static u8 * format_vl_api_ip4_address_t(u8 *s, va_list *args)
Definition: ip_format_fns.h:44
static u8 * format_vl_api_ip6_address_with_prefix_t(u8 *s, va_list *args)
Definition: ip_format_fns.h:98
format_function_t format_ip6_address
Definition: format.h:91
static u8 * format_vl_api_address_with_prefix_t(u8 *s, va_list *args)
Definition: ip_format_fns.h:86
static u8 * format_vl_api_address_t(u8 *s, va_list *args)
Definition: ip_format_fns.h:62
static u8 * format_vl_api_prefix_t(u8 *s, va_list *args)
Definition: ip_format_fns.h:77
static u8 * format_vl_api_ip6_address_t(u8 *s, va_list *args)
Definition: ip_format_fns.h:26