From patchwork Thu Aug 3 15:54:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Fortin X-Patchwork-Id: 797272 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="O1jdSGto"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xNZQs65N3z9s7C for ; Fri, 4 Aug 2017 01:55:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751921AbdHCPzs (ORCPT ); Thu, 3 Aug 2017 11:55:48 -0400 Received: from mail-wr0-f181.google.com ([209.85.128.181]:34815 "EHLO mail-wr0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751209AbdHCPzo (ORCPT ); Thu, 3 Aug 2017 11:55:44 -0400 Received: by mail-wr0-f181.google.com with SMTP id 12so7404613wrb.1 for ; Thu, 03 Aug 2017 08:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=snOOfybiXo/A2yIaf9Eq7MT0O67WdTYqMVm9omCj9cw=; b=O1jdSGtof+nwe0KXMF0F8/YNuV/wWsuX2SBWu/wZ+C5yjNASkmbbU/rdsskcf17lMG qZpoOMgE2C6CW+5Vd3+BxDxKCObir515OpOjRwyyOlMfOy3G/G83VWR4qCFrpxucwLqR 6xGQH4d0HGqoIx9XSkF198VBP0HR4J6LMO3/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=snOOfybiXo/A2yIaf9Eq7MT0O67WdTYqMVm9omCj9cw=; b=cWxtBK078S8RNwxV4lPn61OJ3sPVHLjhsrfSu+aaSseKaXN0q5osWAVMMAoeOxoH4p qtgC0bDUkLKROWtyszDbl3FX15vJjkVlluVHbJtOY5LYOirS09ejlnnQ8LYg4YPR/JOz 1NiLc2OHAJJ54HApUkuMLHQgY3BObINbh4UGg3GX0Q/upn5yBJ9BvlO6Lk9xlQ/3hhzw XGjF9r7QH/UdZTq1LZI7vWTW/HHS6Ab2QQpt8ZOgdMgHbgwe9Q1g60hfMBCUlDUP42R6 oNG7J2j/uaQ4NV8eNdb3xn/fFkX3G3vpWTu7CVho327ApnRLjU/ZfMS0xPIr2eGJcSSd pkaA== X-Gm-Message-State: AIVw110y1b41nTG8V77HVv46gg98XG+5WIZaeZcoAYYZ92I6tITPrCDd DrycFfErNGT34UwO0v8= X-Received: by 10.223.180.66 with SMTP id v2mr1570131wrd.210.1501775743158; Thu, 03 Aug 2017 08:55:43 -0700 (PDT) Received: from localhost.localdomain (91-160-18-219.subs.proxad.net. [91.160.18.219]) by smtp.googlemail.com with ESMTPSA id d91sm2213309wma.23.2017.08.03.08.55.42 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 08:55:42 -0700 (PDT) From: Julien Fortin X-Google-Original-From: Julien Fortin To: netdev@vger.kernel.org Cc: roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com, dsa@cumulusnetworks.com, Julien Fortin Subject: [PATCH 09/27] ip: iplink_hsr.c: add json output support Date: Thu, 3 Aug 2017 17:54:57 +0200 Message-Id: <20170803155515.99226-10-julien@cumulusnetworks.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170803155515.99226-1-julien@cumulusnetworks.com> References: <20170803155515.99226-1-julien@cumulusnetworks.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Julien Fortin 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 --- ip/iplink_hsr.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/ip/iplink_hsr.c b/ip/iplink_hsr.c index 696b2c91..c673ccf7 100644 --- a/ip/iplink_hsr.c +++ b/ip/iplink_hsr.c @@ -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) return; - fprintf(f, "slave1 "); if (tb[IFLA_HSR_SLAVE1]) - fprintf(f, "%s ", - ll_index_to_name(rta_getattr_u32(tb[IFLA_HSR_SLAVE1]))); + print_string(PRINT_ANY, + "slave1", + "slave1 %s ", + ll_index_to_name(rta_getattr_u32(tb[IFLA_HSR_SLAVE1]))); else - fprintf(f, " "); + print_null(PRINT_ANY, "slave1", "slave1 %s ", ""); - fprintf(f, "slave2 "); if (tb[IFLA_HSR_SLAVE2]) - fprintf(f, "%s ", - ll_index_to_name(rta_getattr_u32(tb[IFLA_HSR_SLAVE2]))); + print_string(PRINT_ANY, + "slave2", + "slave2 %s ", + ll_index_to_name(rta_getattr_u32(tb[IFLA_HSR_SLAVE2]))); else - fprintf(f, " "); + print_null(PRINT_ANY, "slave2", "slave2 %s ", ""); if (tb[IFLA_HSR_SEQ_NR]) - fprintf(f, "sequence %d ", - rta_getattr_u16(tb[IFLA_HSR_SEQ_NR])); + print_int(PRINT_ANY, + "seq_nr", + "sequence %d ", + rta_getattr_u16(tb[IFLA_HSR_SEQ_NR])); if (tb[IFLA_HSR_SUPERVISION_ADDR]) - fprintf(f, "supervision %s ", - ll_addr_n2a(RTA_DATA(tb[IFLA_HSR_SUPERVISION_ADDR]), - RTA_PAYLOAD(tb[IFLA_HSR_SUPERVISION_ADDR]), - ARPHRD_VOID, - b1, sizeof(b1))); + print_string(PRINT_ANY, + "supervision_addr", + "supervision %s ", + ll_addr_n2a(RTA_DATA(tb[IFLA_HSR_SUPERVISION_ADDR]), + 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,