else if (tb[IFLA_GRE_ENCAP_LIMIT]) {
int encap_limit = rta_getattr_u8(tb[IFLA_GRE_ENCAP_LIMIT]);
- fprintf(f, "encaplimit %d ", encap_limit);
+ print_int(PRINT_ANY,
+ "encap_limit",
+ "encaplimit %d ",
+ encap_limit);
}
- if (flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
- fprintf(f, "flowlabel inherit ");
- else
- fprintf(f, "flowlabel 0x%05x ",
- ntohl(flowinfo & IP6_FLOWINFO_FLOWLABEL));
+ if (flags & IP6_TNL_F_USE_ORIG_FLOWLABEL) {
+ print_bool(PRINT_ANY,
+ "ip6_tnl_f_use_orig_flowlabel",
+ "flowlabel inherit ",
+ true);
+ } else {
+ if (is_json_context()) {
+ SPRINT_BUF(b1);
+
+ snprintf(b1, sizeof(b1), "0x%05x",
+ ntohl(flowinfo & IP6_FLOWINFO_FLOWLABEL));
+ print_string(PRINT_JSON, "flowlabel", NULL, b1);
+
+ } else {
+ fprintf(f, "flowlabel 0x%05x ",
+ ntohl(flowinfo & IP6_FLOWINFO_FLOWLABEL));
+ }
+ }
- if (flags & IP6_TNL_F_USE_ORIG_TCLASS)
- fprintf(f, "tclass inherit ");
- else
- fprintf(f, "tclass 0x%02x ",
- ntohl(flowinfo & IP6_FLOWINFO_TCLASS) >> 20);
++ if (flags & IP6_TNL_F_USE_ORIG_TCLASS) {
++ print_bool(PRINT_ANY,
++ "ip6_tnl_f_use_orig_tclass",
++ "tclass inherit ",
++ true);
++ } else {
++ if (is_json_context()) {
++ SPRINT_BUF(b1);
++
++ snprintf(b1, sizeof(b1), "0x%05x",
++ ntohl(flowinfo & IP6_FLOWINFO_TCLASS) >> 20);
++ print_string(PRINT_JSON, "tclass", NULL, b1);
++ } else {
++ fprintf(f, "tclass 0x%02x ",
++ ntohl(flowinfo & IP6_FLOWINFO_TCLASS) >> 20);
++ }
++ }
+
if (flags & IP6_TNL_F_RCV_DSCP_COPY)
- fprintf(f, "dscp inherit ");
+ print_bool(PRINT_ANY,
+ "ip6_tnl_f_rcv_dscp_copy",
+ "dscp inherit ",
+ true);
if (tb[IFLA_GRE_IFLAGS])
iflags = rta_getattr_u16(tb[IFLA_GRE_IFLAGS]);