Damjan Marion | bd846cd | 2017-11-21 13:12:41 +0100 | [diff] [blame] | 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 | |
Dave Barach | 7fff3d2 | 2018-11-27 16:52:59 -0500 | [diff] [blame] | 27 | #define _(bit,name,ss,v) \ |
Damjan Marion | bd846cd | 2017-11-21 13:12:41 +0100 | [diff] [blame] | 28 | if (v && (b->flags & VNET_BUFFER_F_##name)) \ |
Dave Barach | 7fff3d2 | 2018-11-27 16:52:59 -0500 | [diff] [blame] | 29 | a = format (a, "%s ", ss); |
Damjan Marion | dac0352 | 2018-02-01 15:30:13 +0100 | [diff] [blame] | 30 | foreach_vnet_buffer_flag |
Damjan Marion | bd846cd | 2017-11-21 13:12:41 +0100 | [diff] [blame] | 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) |
Steven | 0b26bd7 | 2017-12-01 06:58:56 -0800 | [diff] [blame] | 36 | a = format (a, "l3-hdr-offset %d ", vnet_buffer (b)->l3_hdr_offset); |
Damjan Marion | bd846cd | 2017-11-21 13:12:41 +0100 | [diff] [blame] | 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 | |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 41 | if (b->flags & VNET_BUFFER_F_QOS_DATA_VALID) |
| 42 | a = format (a, "qos %d.%d ", |
| 43 | vnet_buffer2 (b)->qos.bits, vnet_buffer2 (b)->qos.source); |
| 44 | |
Neale Ranns | ce9e0b4 | 2018-08-01 12:53:17 -0700 | [diff] [blame] | 45 | if (b->flags & VNET_BUFFER_F_LOOP_COUNTER_VALID) |
| 46 | a = format (a, "loop-counter %d ", vnet_buffer2 (b)->loop_counter); |
| 47 | |
BenoƮt Ganne | 4354317 | 2019-10-21 15:13:54 +0200 | [diff] [blame] | 48 | s = format (s, "%U", format_vlib_buffer_no_chain, b); |
Damjan Marion | bd846cd | 2017-11-21 13:12:41 +0100 | [diff] [blame] | 49 | if (a) |
| 50 | s = format (s, "\n%U%v", format_white_space, indent, a); |
| 51 | vec_free (a); |
| 52 | |
| 53 | return s; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | /* |
| 58 | * fd.io coding-style-patch-verification: ON |
| 59 | * |
| 60 | * Local Variables: |
| 61 | * eval: (c-set-style "gnu") |
| 62 | * End: |
| 63 | */ |