ip: iplink_hsr.c: add json output support
Schema:
hsr: IFLA_INFO_DATA
{
"slave1": {
"type": "string",
"attr": "IFLA_HSR_SLAVE1"
},
"slave2": {
"type": "string",
"attr": "IFLA_HSR_SLAVE2"
},
"seq_nr": {
"type": "int",
"attr": "IFLA_HSR_SEQ_NR"
},
"supervision_addr": {
"type": "int",
"attr": "IFLA_HSR_SUPERVISION_ADDR"
}
}
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
parent
707cce5a63
commit
69ffd27325
|
|
@ -110,30 +110,36 @@ static void hsr_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
|
||||||
RTA_PAYLOAD(tb[IFLA_HSR_SUPERVISION_ADDR]) < ETH_ALEN)
|
RTA_PAYLOAD(tb[IFLA_HSR_SUPERVISION_ADDR]) < ETH_ALEN)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf(f, "slave1 ");
|
|
||||||
if (tb[IFLA_HSR_SLAVE1])
|
if (tb[IFLA_HSR_SLAVE1])
|
||||||
fprintf(f, "%s ",
|
print_string(PRINT_ANY,
|
||||||
ll_index_to_name(rta_getattr_u32(tb[IFLA_HSR_SLAVE1])));
|
"slave1",
|
||||||
|
"slave1 %s ",
|
||||||
|
ll_index_to_name(rta_getattr_u32(tb[IFLA_HSR_SLAVE1])));
|
||||||
else
|
else
|
||||||
fprintf(f, "<none> ");
|
print_null(PRINT_ANY, "slave1", "slave1 %s ", "<none>");
|
||||||
|
|
||||||
fprintf(f, "slave2 ");
|
|
||||||
if (tb[IFLA_HSR_SLAVE2])
|
if (tb[IFLA_HSR_SLAVE2])
|
||||||
fprintf(f, "%s ",
|
print_string(PRINT_ANY,
|
||||||
ll_index_to_name(rta_getattr_u32(tb[IFLA_HSR_SLAVE2])));
|
"slave2",
|
||||||
|
"slave2 %s ",
|
||||||
|
ll_index_to_name(rta_getattr_u32(tb[IFLA_HSR_SLAVE2])));
|
||||||
else
|
else
|
||||||
fprintf(f, "<none> ");
|
print_null(PRINT_ANY, "slave2", "slave2 %s ", "<none>");
|
||||||
|
|
||||||
if (tb[IFLA_HSR_SEQ_NR])
|
if (tb[IFLA_HSR_SEQ_NR])
|
||||||
fprintf(f, "sequence %d ",
|
print_int(PRINT_ANY,
|
||||||
rta_getattr_u16(tb[IFLA_HSR_SEQ_NR]));
|
"seq_nr",
|
||||||
|
"sequence %d ",
|
||||||
|
rta_getattr_u16(tb[IFLA_HSR_SEQ_NR]));
|
||||||
|
|
||||||
if (tb[IFLA_HSR_SUPERVISION_ADDR])
|
if (tb[IFLA_HSR_SUPERVISION_ADDR])
|
||||||
fprintf(f, "supervision %s ",
|
print_string(PRINT_ANY,
|
||||||
ll_addr_n2a(RTA_DATA(tb[IFLA_HSR_SUPERVISION_ADDR]),
|
"supervision_addr",
|
||||||
RTA_PAYLOAD(tb[IFLA_HSR_SUPERVISION_ADDR]),
|
"supervision %s ",
|
||||||
ARPHRD_VOID,
|
ll_addr_n2a(RTA_DATA(tb[IFLA_HSR_SUPERVISION_ADDR]),
|
||||||
b1, sizeof(b1)));
|
RTA_PAYLOAD(tb[IFLA_HSR_SUPERVISION_ADDR]),
|
||||||
|
ARPHRD_VOID,
|
||||||
|
b1, sizeof(b1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hsr_print_help(struct link_util *lu, int argc, char **argv,
|
static void hsr_print_help(struct link_util *lu, int argc, char **argv,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue