All of lore.kernel.org
 help / color / mirror / Atom feed
From: asarmanow@gmail.com
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [PATCH] batctl: Add JSON debug support
Date: Wed, 28 Apr 2021 11:40:31 -0000	[thread overview]
Message-ID: <20210428114031.12523.14028@diktynna.open-mesh.org> (raw)
In-Reply-To: <2557512.EezVJnfClc@sven-l14>

Sven Eckelmann wrote:
> On Wednesday, 28 April 2021 12:16:08 CEST Alexander Sarmanow wrote:
> >  Same parameters of the debug tables can be used for
> >  the JSON, except the "-w [interval]" (not useful). The table header is
> >  implemented as a JSON equivalent and can be also optionally omitted.
> >   
> I would like to disagree. Why is it a problem to continuously emit json 
> objects? 
Simon agreed with me to leave that out, but I can add it and the user can decide whether to use it or not. It does not disturb.

> >  --- a/netlink.c
> >  +++ b/netlink.c
> >  @@ -318,15 +318,29 @@ static int info_callback(struct nl_msg *msg, void *arg)
> >                  else
> >                          extra_header = "";
> >   
> >  -               ret = asprintf(&opts->remaining_header,
> >  -                              "[B.A.T.M.A.N. adv %s, MainIF/MAC:
> > %s/%02x:%02x:%02x:%02x:%02x:%02x (%s/%02x:%02x:%02x:%02x:%02x:%02x %s)%s]\n%s",
> >  -                              version, primary_if,
> >  -                              primary_mac[0], primary_mac[1], primary_mac[2],
> >  -                              primary_mac[3], primary_mac[4], primary_mac[5],
> >  -                              mesh_name,
> >  -                              mesh_mac[0], mesh_mac[1], mesh_mac[2],
> >  -                              mesh_mac[3], mesh_mac[4], mesh_mac[5],
> >  -                              algo_name, extra_info, extra_header);
> >  +               if (opts->is_json) {
> >  +                       ret = asprintf(&opts->remaining_header,
> >  +                                     
> > "{\"version\":\"%s\",\"main_if\":\"%s\",\"main_mac\":\"%02x:%02x:%02x:%02x:%02x:%02x\",\"mesh_if\":\"%s\",\"mesh_mac\":\"%02x:%02x:%02x:%02x:%02x:%02x\",\"algo_name\":\"%s\",\"extra_info\":\"%s\",\"data\":[",
> >  +                                      version, primary_if,
> >  +                                      primary_mac[0], primary_mac[1],
> >  +                                      primary_mac[2], primary_mac[3],
> >  +                                      primary_mac[4], primary_mac[5],
> >  +                                      mesh_name,
> >  +                                      mesh_mac[0], mesh_mac[1], mesh_mac[2],
> >  +                                      mesh_mac[3], mesh_mac[4], mesh_mac[5],
> >  +                                      algo_name, extra_info);
> >  +               } else {
> >  +                       ret = asprintf(&opts->remaining_header,
> >  +                                      "[B.A.T.M.A.N. adv %s, MainIF/MAC:
> > %s/%02x:%02x:%02x:%02x:%02x:%02x (%s/%02x:%02x:%02x:%02x:%02x:%02x %s)%s]\n%s",
> >  +                                      version, primary_if,
> >  +                                      primary_mac[0], primary_mac[1],
> >  +                                      primary_mac[2], primary_mac[3],
> >  +                                      primary_mac[4], primary_mac[5],
> >  +                                      mesh_name,
> >  +                                      mesh_mac[0], mesh_mac[1], mesh_mac[2],
> >  +                                      mesh_mac[3], mesh_mac[4], mesh_mac[5],
> >  +                                      algo_name, extra_info, extra_header);
> >  +               } 
> Do we really have to add such kind of output to each table? Can't we just have 
> another command to get the meshif info and print it?
You are right. I just followed the existing debug tables where the header is also always printed out each time and there is no separate command for that. But I can create a separate command to fetch the "header".

Best,
Alex

      reply	other threads:[~2021-04-28 11:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28 10:16 [PATCH] batctl: Add JSON debug support Alexander Sarmanow
2021-04-28 10:45 ` Sven Eckelmann
2021-04-28 11:40   ` asarmanow [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210428114031.12523.14028@diktynna.open-mesh.org \
    --to=asarmanow@gmail.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.