libosmocore[master]: VTY: implicit node exit by de-indenting, not parent lookup

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Sep 7 19:53:02 UTC 2017


Patch Set 1:

> Thanks for looking into this.  I think it might be difficult to
 > insist on one space idnent per level. It would be much mor user
 > friendly if there was a notion of 'parent node depth', i.e. you can
 > use any number of additional spaces to indent a new depth level,
 > and as soon as you go back beyond that depthy level we go to the
 > parent.  Not sure how comple that would be to implement?

Currently the VTY only remembers a single node.
It relies on the node commands to pick a child node, and on go_parent_cb() to pick the right parent for each child.

i.e. there is no state about parent nodes at all.
To remember which depths each parent node was on, we would need to create such state per parent node. So the effort is non-trivial.

But nevertheless I like it, because we will hardly ever step in deeper than say five child node levels and keeping the state is far from performance / memory critical. Also it would obsolete the need for the go_parent callbacks, and we could actually define the child->parent relations merely from entering a child. (One step further could even define the parent->child relations statically when defining VTY commands, instead of writing code to enter another node, opening up the possibility to validate that the parent/child structure is sound).

My main question is, how much of this code do we want to change? Is there a consideration like with llist, that we don't want to deviate from upstream too much?

 > Also, if we now have a notion of the "depth", could this somehow be
 > used to automatically generate the required spaces in front of a
 > string when saving the file (config_write_...())?

That's a bit harder, because for writing the config we simply vty_out().
There would need to be some wrapper function prepending indent, plus some function indicating that we stepped in and out of a child node to modify the prepended indent. We still have to take care that we indicate that properly:

  network
   bts 0
    arfcn 123
   bts 1

>From 'arfcn' up to bts 1, we still have to manually indicate that we intended to step out of the bts 0 child node.

Also structures like this are valid:

  network
   bts 0
   bts 1

i.e. bts 0 would intend to enter a child node, but bts 1 follows right away on the same level, i.e. steps out of it again. There isn't any way that saves us from indicating those levels manually; we can only save ourselves from varying spaces while in a specific node by accident. Not sure if it's worth the trouble / easier to just indicate the depth by manual spaces.

 > (and
 > doesn't permit a node to appear at different parent nodes /
 > depths).

For <thing I don't remember> I once wrote a vty_write wrapper that accepted the parent node and level of indent flexibly, so that two different binaries could hook a library vty on arbitrary node depth levels... pretty straightforward.

-- 
To view, visit https://gerrit.osmocom.org/3880
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I24cbb3f6de111f2d31110c3c484c066f1153aac9
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-HasComments: No



More information about the gerrit-log mailing list