extern int show_details;
extern int timestamp;
extern int compress_vlans;
-extern int json_output;
+extern int json;
extern struct rtnl_handle rth;
int show_stats;
int show_details;
int compress_vlans;
-int json_output;
+int json;
int timestamp;
char *batch_file;
int force;
"where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
" -o[neline] | -t[imestamp] | -n[etns] name |\n"
-" -c[ompressvlans] -j{son} }\n");
+" -c[ompressvlans] -p[retty] -j{son} }\n");
exit(-1);
}
} else if (matches(opt, "-force") == 0) {
++force;
} else if (matches(opt, "-json") == 0) {
- ++json_output;
+ ++json;
+ } else if (matches(opt, "-pretty") == 0) {
+ ++pretty;
} else if (matches(opt, "-batch") == 0) {
argc--;
argv++;
if (filter_vlan && filter_vlan != vid)
return 0;
- if (jw_global) {
- jsonw_pretty(jw_global, 1);
+ if (jw_global)
jsonw_start_object(jw_global);
- }
if (n->nlmsg_type == RTM_DELNEIGH) {
if (jw_global)
exit(1);
}
- if (json_output) {
+ if (json) {
jw_global = jsonw_new(stdout);
if (!jw_global) {
fprintf(stderr, "Error allocation json object\n");
exit(1);
}
+ if (pretty)
+ jsonw_pretty(jw_global, 1);
+
jsonw_start_array(jw_global);
}
+
if (rtnl_dump_filter(&rth, print_fdb, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
exit(1);
return -1;
}
- if (!json_output) {
+ if (!json) {
/* Normal output */
if (rtnl_dump_filter(&rth, print_mdb, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
}
return 0;
}
+
/* Json output */
jw_global = jsonw_new(stdout);
- jsonw_pretty(jw_global, 1);
+ if (!jw_global) {
+ fprintf(stderr, "Error allocation json object\n");
+ exit(1);
+ }
+
+ if (pretty)
+ jsonw_pretty(jw_global, 1);
+
jsonw_start_object(jw_global);
jsonw_name(jw_global, "mdb");
jsonw_start_array(jw_global);
static void print_vlan_port(FILE *fp, int ifi_index)
{
if (jw_global) {
- jsonw_pretty(jw_global, 1);
jsonw_name(jw_global,
ll_index_to_name(ifi_index));
jsonw_start_array(jw_global);
if (!show_stats) {
if (rtnl_wilddump_req_filter(&rth, PF_BRIDGE, RTM_GETLINK,
(compress_vlans ?
- RTEXT_FILTER_BRVLAN_COMPRESSED :
- RTEXT_FILTER_BRVLAN)) < 0) {
+ RTEXT_FILTER_BRVLAN_COMPRESSED :
+ RTEXT_FILTER_BRVLAN)) < 0) {
perror("Cannont send dump request");
exit(1);
}
- if (json_output) {
+
+ if (json) {
jw_global = jsonw_new(stdout);
if (!jw_global) {
fprintf(stderr, "Error allocation json object\n");
exit(1);
}
+ if (pretty)
+ jsonw_pretty(jw_global, 1);
+
jsonw_start_object(jw_global);
} else {
if (show_vlan_tunnel_info)
\fB\-s\fR[\fItatistics\fR] |
\fB\-n\fR[\fIetns\fR] name |
\fB\-b\fR[\fIatch\fR] filename |
+\fB\-p\fR[\fIretty\fR] |
\fB\-j\fR[\fIson\fR] }
.ti -8
.BR "\-json"
Display results in JSON format. Currently available for vlan and fdb.
+.TP
+.BR "\-pretty"
+When combined with -j generate a pretty JSON output.
+
+
.SH BRIDGE - COMMAND SYNTAX
.SS