FD.io VPP  v18.01.2-1-g9b554f3
Vector Packet Processing
buffer.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 #include <vlib/vlib.h>
17 #include <vnet/buffer.h>
18 
19 
20 u8 *
21 format_vnet_buffer (u8 * s, va_list * args)
22 {
23  vlib_buffer_t *b = va_arg (*args, vlib_buffer_t *);
24  u32 indent = format_get_indent (s);
25  u8 *a = 0;
26 
27 #define _(bit, name, v) \
28  if (v && (b->flags & VNET_BUFFER_F_##name)) \
29  a = format (a, "%s ", v);
31 #undef _
32  if (b->flags & VNET_BUFFER_F_L2_HDR_OFFSET_VALID)
33  a = format (a, "l2-hdr-offset %d ", vnet_buffer (b)->l2_hdr_offset);
34 
35  if (b->flags & VNET_BUFFER_F_L3_HDR_OFFSET_VALID)
36  a = format (a, "l3-hdr-offset %d ", vnet_buffer (b)->l3_hdr_offset);
37 
38  if (b->flags & VNET_BUFFER_F_L4_HDR_OFFSET_VALID)
39  a = format (a, "l4-hdr-offset %d ", vnet_buffer (b)->l4_hdr_offset);
40 
41  s = format (s, "%U", format_vlib_buffer, b);
42  if (a)
43  s = format (s, "\n%U%v", format_white_space, indent, a);
44  vec_free (a);
45 
46  return s;
47 }
48 
49 
50 /*
51  * fd.io coding-style-patch-verification: ON
52  *
53  * Local Variables:
54  * eval: (c-set-style "gnu")
55  * End:
56  */
a
Definition: bitmap.h:516
static u32 format_get_indent(u8 *s)
Definition: format.h:72
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
u8 * format_vnet_buffer(u8 *s, va_list *args)
Definition: buffer.c:21
u8 * format_vlib_buffer(u8 *s, va_list *args)
Definition: buffer.c:70
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
unsigned int u32
Definition: types.h:88
unsigned char u8
Definition: types.h:56
#define vnet_buffer(b)
Definition: buffer.h:326
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:75