Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / tools / bpf / bpftool / netlink_dumper.h
blob774af6c62ef5ff1c32375ee302eec066d7613872
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 // Copyright (C) 2018 Facebook
4 #ifndef _NETLINK_DUMPER_H_
5 #define _NETLINK_DUMPER_H_
7 #define NET_START_OBJECT \
8 { \
9 if (json_output) \
10 jsonw_start_object(json_wtr); \
13 #define NET_START_OBJECT_NESTED(name) \
14 { \
15 if (json_output) { \
16 jsonw_name(json_wtr, name); \
17 jsonw_start_object(json_wtr); \
18 } else { \
19 fprintf(stdout, "%s {", name); \
20 } \
23 #define NET_START_OBJECT_NESTED2 \
24 { \
25 if (json_output) \
26 jsonw_start_object(json_wtr); \
27 else \
28 fprintf(stdout, "{"); \
31 #define NET_END_OBJECT_NESTED \
32 { \
33 if (json_output) \
34 jsonw_end_object(json_wtr); \
35 else \
36 fprintf(stdout, "}"); \
39 #define NET_END_OBJECT \
40 { \
41 if (json_output) \
42 jsonw_end_object(json_wtr); \
45 #define NET_END_OBJECT_FINAL \
46 { \
47 if (json_output) \
48 jsonw_end_object(json_wtr); \
49 else \
50 fprintf(stdout, "\n"); \
53 #define NET_START_ARRAY(name, fmt_str) \
54 { \
55 if (json_output) { \
56 jsonw_name(json_wtr, name); \
57 jsonw_start_array(json_wtr); \
58 } else { \
59 fprintf(stdout, fmt_str, name); \
60 } \
63 #define NET_END_ARRAY(endstr) \
64 { \
65 if (json_output) \
66 jsonw_end_array(json_wtr); \
67 else \
68 fprintf(stdout, "%s", endstr); \
71 #define NET_DUMP_UINT(name, fmt_str, val) \
72 { \
73 if (json_output) \
74 jsonw_uint_field(json_wtr, name, val); \
75 else \
76 fprintf(stdout, fmt_str, val); \
79 #define NET_DUMP_STR(name, fmt_str, str) \
80 { \
81 if (json_output) \
82 jsonw_string_field(json_wtr, name, str);\
83 else \
84 fprintf(stdout, fmt_str, str); \
87 #define NET_DUMP_STR_ONLY(str) \
88 { \
89 if (json_output) \
90 jsonw_string(json_wtr, str); \
91 else \
92 fprintf(stdout, "%s ", str); \
95 #endif