Commit Graph

71 Commits

Author SHA1 Message Date
Pau Espin e1e1ec31a3 vty: Simplify char escaping in asciidoc output
Change-Id: I7df6858bb98abffc1d5bf420f991ae5854b24638
2019-06-25 21:46:44 +00:00
Pau Espin 32e6710487 vty: command.c: Fix: single-choice optional args are no longer passed incomplete to vty func
For instance, take command "single0 [one]":
If user executes "single0 on", VTY func will receive argv[0]="one"
instead of argv[0]="on".

Related: OS#4045
Change-Id: I5f4e2d16c62a2d22717989c6acc77450957168cb
2019-06-14 17:44:21 +02:00
Pau Espin 7e1b03f763 vty: command.c: Fix: multi-choice args are no longer passed incomplete to vty func
For instance, take command "multi0 (one|two|three)":
If user executes "multi0 tw", VTY func will receive argv[0]="two"
instead of argv[0]="tw".

Fixes: OS#4045
Change-Id: I91b6621ac3d87fda5412a9b415e7bfb4736c8a9a
2019-06-14 17:44:16 +02:00
Pau Espin 8930ace072 vty: command.c: Get rid of big indentation block
This block will become bigger in forthcoming commits.

Change-Id: Ibc1494014b1e77ce10950f7268a44d2d2091a6f2
2019-06-14 12:42:22 +02:00
Pau Espin c17c6d6ea5 command.c: Improve return check condition in cmd_execut_command_real()
Check against MAX argc is changed to == since it cannot be incremented
twice without passing the check.

Change-Id: Ia330e475989fda863bedcc3cbf94deaf8dd83037
2019-06-14 12:38:44 +02:00
Pau Espin 274ac4dcc3 vty: command.c: Get rid of huge indentation block
Huge conditional block inside for loop is negated in this patch
together with a "continue" keyword, similar to what was already done
recently in 4742526645.

Change-Id: I803c4ed38e9ab09bf929528c75a60e6f65da3928
2019-06-12 14:25:11 +00:00
Pau Espin de89099f68 cosmetic: vty: command.c: Use upper case for enum match_type value names
Makes code easier to follow because enum values no longer look like
variables.

Change-Id: Ib6e9592c5962d047869a280c10f9b557fae6f435
2019-06-12 14:25:11 +00:00
Pau Espin 6df2e44404 vty: command.c: Fix is_cmd_ambiguous() returning always 0
inner block defined variable "enum match_type ret" was being masking
outter block variable "int ret = 0". The ret variable was being given
non zero values only inside the inner block, so that change was done on
the inner variable and not the outer one, which is returned.

Fixes: 5314c513f2
Change-Id: Iec87d7db49a096d07e38ff8a060b923a52bfd6ba
2019-06-11 21:50:17 +02:00
Pau Espin 4742526645 vty: command.c: Get rid of huge indentation block
Huge conditional block inside foor loop is negated in this patch
together with a "continue" keyword.

Change-Id: I9715734ed276f002fdc8c3b9742531ad36b2ef9e
2019-06-11 21:04:11 +02:00
Vadim Yanitskiy f5781c9a88 vty/command.c: cosmetic: add missing curly brackets
Otherwise it's a bit hard to read the code.

Change-Id: I807ec71cfb67976251be844cdb2d2776b1837438
2019-06-01 02:27:16 +07:00
Neels Hofmeyr 9ea9dd0d5f vty: enable tab-completion for optional-multi-choice args
In cmd_complete_command_real(), detect and strip square braces from
multi-choice arguments, to enable tab-completion for commands like

 > list
 cmd [(alpha|beta)]
 > cmd <TAB>
 alpha beta
 > cmd be<TAB>
 > cmd beta

Change-Id: I8c304300b3633bb6e9b3457fcfa42121c8272ac0
2019-02-04 16:43:57 +00:00
Neels Hofmeyr b55f4d2df2 vty: enable optional-multi-choice syntax: [(one|two)]
Since very recently we sensibly handle commands like

  cmd ([one]|[two]|[three])

as optional multi-choice arguments. In addition, support the more obvious
syntax of

  cmd [(one|two|three)]

Internally, the tokens are mangled to [one] [two] and [three], which is how the
rest of the code detects optional args, and makes sense in terms of UI:

  > cmd ?
  [one]
  [two]
  [three]

(i.e. optional arguments are always shown in braces in '?' listings)

Before this patch, commands defined with a syntax like [(one|two)], would lead
to an assertion (shows as "multiple") during program startup.

Change-Id: I952b3c00f97e2447f2308b0ec6f5f1714692b5b2
2019-02-04 16:43:57 +00:00
Neels Hofmeyr c197809deb vty: enable optional-multi-choice syntax: ([one]|[two])
Add basic optional multi-choice argument support.

The VTY detects optional arguments by square braces.

 > cmd ?
 [optional-arg]
 > cmd optional-arg
 ok
 > cmd
 ok

However, within multi-choice args, these braces were so far not treated as
optional:

 > list
 cmd2 ([one]|[two]|[three])
 > cmd2
 % Command incomplete

In preparation for I952b3c00f97e2447f2308b0ec6f5f1714692b5b2 which will enable
the more obvious syntax of

  cmd [(one|two)]

for reasons of internal implementation, first support a syntax of

  cmd ([one]|[two])

The internal vty implementation always needs square braces around each option.
There is currently no good way to prevent developers from defining braces
inside multi-arguments, so it is easiest to allow and handle them:

 > list
 cmd2 ([one]|[two]|[three])
 > cmd2
 ok

The VTY doesn't guard against a mix like

 cmd (one|[two])

With this patch, a multi-choice command is treated as optional iff the first
element is in square brackets. The remaining elements' square brackets have no
effect besides confusing the user. This is not explicitly checked against.

In general, I would prefer to check all of these details, but the current VTY
code with its endless code duplication and obscure string mangling just doesn't
provide that luxury. There are numerous worse errors hidden in there.

Change-Id: I9a8474bd89ddc2155c58bfca7bd038d586aaa60a
2019-02-04 16:43:57 +00:00
Neels Hofmeyr 5398911ddb vty: omit HIDDEN from vty reference
During 'show online help', the XML vty node dump, omit all commands marked
HIDDEN.

These commands were already hidden from the VTY reference prior to commit
I1f18e0e41da4772d092d71261b9e489dc1598923, because of broken/confusing bit and
boolean logic mixup. After that commit, HIDDEN commands end up in the doc.  So
practically, this patch here brings back the status quo of before above commit,
even though the previous code clearly "intended" to list HIDDEN commands in the
reference but failed to have that effect.

AFAICT the complete list of commands currently hidden is:

* osmo-bsc: bts/"training_sequence_code <0-7>",
* osmo-bsc: ts/"phys_chan_config PCHAN" for uppercase pchans;
* osmo-bts: bts/"rtp bind-ip A.B.C.D" which actually says
  vty_out(vty, "%% rtp bind-ip is now deprecated%s", VTY_NEWLINE);
* osmo-sgsn: 'reset sgsn state' used for SGSN testing.

Note that the osmo-sgsn build was broken by including hidden commands in the
vty reference, since one of its hidden commands had missing doc strings and
made osmotestconfig.py signal failure. This would fix that from the
hide-hidden-commands angle, and so would osmo-sgsn commit
I8b6e8615e409266910f2f76a10ced9ab33e4de91 from the fix-the-doc-strings angle.

Change-Id: I92c3c66ff69c186234276c64478d6342e061d25e
2018-09-24 19:01:42 +02:00
Neels Hofmeyr a7557fe0f5 vty list: fix deprecation/hidden bit logic
If a command is both hidden and deprecated, still don't show it for the 'list'
command.

We currently have no such nodes, as it seems, though.

Related: OS#3584
Change-Id: I07ec15cab057a3e09064e0420a69121ee8eb4253
2018-09-24 06:40:04 +00:00
Neels Hofmeyr cf8def25d5 vty reference: fix deprecation bit evaluation
In vty_dump_nodes(), make sure the bitwise & is evaluated first.

For the deprecation flag (0x1), the practical effect is most likely identical,
assuming that the boolean ! operator flips the first bit, so I expect no
visible functional difference. It still was confusing and wrong to look at.

Related: OS#3584
Change-Id: I1f18e0e41da4772d092d71261b9e489dc1598923
2018-09-24 06:40:04 +00:00
Neels Hofmeyr 5314c513f2 vty: fix use-after-free and memleaks in is_cmd_ambiguous()
vty_test: add test against ambiguous cmd causing use-after-free and memory
leaks. Add this test along with the fix, because the new test triggers the
memory use-after-free and leaks, causing build failures.

Add cmd_deopt_with_ctx() to allow passing a specific talloc ctx.

is_cmd_ambiguous(): keep all cmd_deopt() allocations until the function exits.
Add a comment explaining why. Before this, if a command matched an optional
"[arg]" with square brackets, we would keep it in local var 'matched', but we
would free the string it points to at the end of that loop iteration; upon
encountering another match, we would attempt to strcmp against the freed
'matched'. Instead of adding hard-to-read and -verify free/alloc dances to keep
the 'matched' accurately freed/non-freed/..., just keep all cmd_deopt() string
allocated until done.

Needless to say that this should have been implemented on a lower level upon
inventing optional args, but at least this is fixing a program crash.

Related: OS#33903390
Change-Id: Ia71ba742108b5ff020997bfb612ad5eb30d04fcd
2018-07-11 15:47:08 +02:00
Neels Hofmeyr 4e0add239f vty: cosmetic: cmd_deopt(): use talloc_strndup(), not memcpy()
Change-Id: Ibf870ae02be706f802482f7cff6589a70cde8320
2018-07-09 23:41:11 +02:00
Neels Hofmeyr f2d323ef0f vty/command.c: talloc from tall_vty_cmd_ctx, not NULL
Change-Id: Iaa409b4f63557c8fb028bbb322b5e7253393c05c
2018-07-09 23:41:11 +02:00
Harald Welte 23a299f096 vty: Don't dump deprecated commands in XML export
we don't want to include deprecated commands in our VTY reference
manuals.

Change-Id: I5e179c9dca297b8c4bdbdf4e0e5b1d69eecc4232
2018-06-09 17:43:33 +02:00
Neels Hofmeyr d65f3ea18e vty/command.c: write_config_file(): sanely compose temp path
Fix GCC version 7.3.0 (Debian 7.3.0-12) compiler warning:

../../../../src/libosmocore/src/vty/command.c: In function ‘write_config_file’:
../../../../src/libosmocore/src/vty/command.c:2741:2: error: null destination pointer [-Werror=format-overflow=]
  sprintf(config_file_tmp, "%s.XXXXXX", config_file);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check agains NULL after each _talloc_zero() in write_config_file().

While at it, add a comment explaining why we don't use talloc_asprintf() instead.

Change-Id: I7bdc52afe724c1d21f419fe49a6e2ebca9420969
2018-03-28 16:19:00 +02:00
Neels Hofmeyr 3b6815715f vty: set name for VIEW+ENABLE nodes, for VTY reference
This leaves no unnamed chapters in future VTY reference documents.

Change-Id: Iefb8b78094208a1a4c5d70bd6c69a3deca8da54f
2017-12-10 13:34:35 +00:00
Neels Hofmeyr 453e37e3c8 VTY reference: use node names as section names
In 'show online-help' output, add the node names (currently all derived from
the prompt) as <node><name> entry, so that in the osmo-gsm-manuals, each
section of node commands gets a title. So far, each section of commands has no
name at all, and it is entirely up for guessing which part of the VTY the
commands are about.

Node section names, e.g. for OsmoHLR, will be like

  1 VTY reference
  1.4 config
  1.5 config-log
  1.6 config-line
  1.7 config-ctrl
  1.8 config-hlr
  1.9 config-hlr-gsup

Before this patch, all but '1 VTY reference' were plain empty.

A better solution would be to list the actual command name that enters the
node, and to nest the commands identically to VTY node nesting, but since this
information is currently hidden in node command implementations, it is
impossible to derive it. So we should actually make the VTY reflect the node
nesting structure in its data model, which would resolve both the accurate node
name problem as well as produce well-structured output to generate the VTY
references from. This patch is a workaround for lack of a more profound fix of
the VTY data model. At least it makes the VTY references' sections even
remotely useful.

Change-Id: Iaf745b2ab3d9b02fc47025a0eba3beb711068bfe
2017-12-10 13:34:35 +00:00
Neels Hofmeyr f7162771d7 VTY reference: do not list empty nodes
In 'show online-help' output, don't list nodes that have no commands (the
'Password' node).

Change-Id: I3bd6883a87b8b893e560ceadfffbf41bc380109c
2017-12-10 13:34:35 +00:00
Neels Hofmeyr 69054e28ad vty XML export: avoid repeating common node commands for each node
We use 'show online-help' to generate VTY reference manuals. It is not helpful
to include the common node commands on each and every node level, it clutters
the actual useful help.

Have a separate first section called 'Common Commands', but omit them
elsewhere.

Change-Id: Ie802eccad80887968b10269ff9c0e9797268e0d4
2017-12-10 13:34:35 +00:00
Harald Welte e08da97570 Fix/Update copyright notices; Add SPDX annotation
Let's fix some erroneous/accidential references to wrong license,
update copyright information where applicable and introduce a
SPDX-License-Identifier to all files.

Change-Id: I39af26c6aaaf5c926966391f6565fc5936be21af
2017-11-13 01:35:12 +09:00
Pau Espin 0f7bcb5f17 vty: Fix bad use of vector_slot()
Commit in e9e9e427b7 attempted to fix a
compilation warning but introduced a regression documented in OS#2613.

The commit was reverted in 4aa0258269296f078e685e21fb08b115567e814.

After closer lookup and testing, it seems vector_slot(vline, index) is
expected to be NULL in this case as set by vty_complete_command:
	/* In case of 'help \t'. */
	if (isspace((int)vty->buf[vty->length - 1]))
		vector_set(vline, NULL);

As a result, the correct fix for the compilation warning is to test
against NULL instead of testing for empty string.

Change-Id: Id9e02bbf89e0a94e1766b1efd236538712415c8a
2017-11-10 16:45:02 +00:00
Neels Hofmeyr 74aa025826 Revert "vty: Fix bad use of vector_slot()"
The patch seemed sensible, but introduces a segfault when hitting tab
on the interactive VTY. Reproduction example:

  osmo-msc
  telnet 127.0.0.1 4254
  OsmoMSC> enable <TAB>

So we need to understand what that line of code actually intends to do.
Until then, revert this to avoid the segfault.

The segfault happens at:

  Program received signal SIGSEGV, Segmentation fault.
  0x00007ffff7bc0894 in cmd_complete_command_real (vline=0x5555558d59e0, vty=0x5555558d57b0, status=0x7fffffffe024) at ../../../../src/libosmocore/src/vty/command.c:1953
  1953                if (*(char *)vector_slot(vline, index) == '\0')

This reverts commit e9e9e427b7.

Change-Id: I3fe213bdfb96de9469aae64e67000dafee59302e
2017-11-01 22:38:29 +00:00
Pau Espin e9e9e427b7 vty: Fix bad use of vector_slot()
Fixes the compilation warning below:

git/libosmocore/src/vty/command.c: In function ‘cmd_complete_command_real’:
git/libosmocore/src/vty/command.c:1953:33: warning: comparison between pointer and zero character const
ant [-Wpointer-compare]
   if (vector_slot(vline, index) == '\0')
                                 ^~
git/libosmocore/src/vty/command.c:37:0:
git/libosmocore/include/osmocom/vty/vector.h:39:27: note: did you mean to dereference the pointer?
 #define vector_slot(V,I)  ((V)->index[(I)])
                           ^
git/libosmocore/src/vty/command.c:1953:7: note: in expansion of macro ‘vector_slot’
   if (vector_slot(vline, index) == '\0')
       ^~~~~~~~~~~

Change-Id: Iaba9e3450d68c51e16a7bda2fc0fc370992ca866
2017-10-24 10:51:23 +00:00
Neels Hofmeyr f4f23bd682 vty: install 'exit', 'end',... commands on *all* nodes
In many callers of the VTY API, we are lacking the vty_install_default() step
at certain node levels. This creates nodes that lack the 'exit' command, and
hence the only way to exit such a node is to restart the telnet session.

Historically, the VTY looked for missing commands on the immediate parent node,
and hence possibly found the parent's 'exit' command when the local node was
missing it. That is why we so far did not notice the missing default commands.

Furthermore, some callers call install_default() instead of
vty_install_default(). Only vty_install_default() also includes the 'exit' and
'end' commands. There is no reason why there are two sets of default commands.

To end this confusion, to catch all missing 'exit' commands and to prevent this
from re-appearing in the future, simply *always* install all default commands
implicitly when calling install_node().

In cmd_init(), there are some top-level nodes that apparently do not want the
default commands installed. Keep those the way they are, by changing the
invocation to new install_node_bare() ({VIEW,AUTH,AUTH_ENABLE}_NODE).

Make both install_default() and vty_install_default() no-ops so that users of
the API may still call them without harm. Do not yet deprecate yet, which
follows in Icf5d83f641e838cebcccc635a043e94ba352abff.

Drop all invocations to these two functions found in libosmocore.

Change-Id: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
2017-09-27 14:04:09 +00:00
Neels Hofmeyr 657c5b6cad vty: derive node name from prompt, use as XML ids
The 'show online-help' produces XML output with <node id="..."> ids.  We
reference those from the osmo-gsm-manuals.

Instead of numeric IDs coming from internal code, rather use a human-readable
node ID -- referencing id='config-msc' is much easier than referencing id='23'.

Add a char name[] to struct cmd_node, to hold this name. This may be provided
upon struct definition.

Since callers of the VTY API so far don't have a name yet, we would need to add
names everywhere to get meaningful node IDs. There is a way to get node ID
names without touching dependent code:

My first idea was to find out which command entered the node, i.e. command
'msc' enters the MSC_NODE. But it is impossible to derive which command entered
which node from data structs, it's hidden in the vty command definition.

But in fact all (TM) known API callers indeed provide a prompt string that
contains a logical and human readable string name. Thus, if the name is unset
in the struct, parse the prompt string and strip all "weird" characters to
obtain a node name from that. We can still set names later on, but for now will
have meaningful node IDs (e.g. 'config-msc' from '%s(config-msc)# ') without
touching any dependent code.

When VTY nodes get identical node names, which is quite possible, the XML
export de-dups these by appending _2, _3,... suffixes. The first occurence is
called e.g. 'name', the second 'name_2', then 'name_3', and so forth.

If a node has no name (even after parsing the prompt), it will be named merely
by the suffix. The first empty node will become id='_1', then '_2', '_3', and
so forth. This happens for nodes like VIEW_NODE or AUTH_NODE.

If this is merged, we need to adjust the references in osmo-gsm-manuals.git.
This can happen in our own time though, because we manually create the vty
reference xml and copy it to the osmo-gsm-manuals.git and then update the
references from the vty_additions.xml. This anyway has to happen because
currently the references tend to be hopelessly out of sync anyway, placing
comments at wildly unrelated VTY commands.

Change-Id: I8fa555570268b231c5e01727c661da92fad265de
2017-09-23 12:24:58 +00:00
Neels Hofmeyr 0b723f6a6c vty: use internal node id for xml ids
The 'show online-help' produces XML output with <node id="..."> ids.  We
reference those from the osmo-gsm-manuals, but until now, these ids fall out of
sync when the amount of VTY nodes changes.

Change these ids to use the internal node ID constant (as in enum bsc_vty_node)
instead of a simple counter.

If this is merged, we need to adjust the references in osmo-gsm-manuals.git.

Change-Id: Ib07fb9d9106e19f5be6539493e82b5d5991f8bc2
2017-09-23 12:24:56 +00:00
Neels Hofmeyr 00b5ed3d92 comment: describe indent_cmp()
Change-Id: Ia58c16d995f6751bdd69defe8a46665aee163f3d
2017-09-20 00:57:33 +02:00
Neels Hofmeyr 430636328c fix vty regression: empty parent node
The recent exit-by-indent patch breaks a VTY case where a node is entered but
directly followed by a sibling or ancestor without listing any child nodes.
Regression introduced by I24cbb3f6de111f2d31110c3c484c066f1153aac9.

An example is a common usage in osmo-bts, where 'phy N' / 'instance N' is a
parent node that is commonly left empty:

	phy 0
	 instance 0
	bts 0
	 band 1800

Before this patch, this case produces the error:

	There is no such command.
	Error occurred during reading the below line:
	bts 0

Fix indentation parsing logic in command.c to accomodate this case.

Add a unit test for empty parent node.

Change-Id: Ia0880a17ae55accb092ae8585cc3a1bec9986891
2017-09-20 00:57:33 +02:00
Neels Hofmeyr 4a31ffa2f0 VTY: implicit node exit by de-indenting, not parent lookup
Note: This will break users' config files if they do not use consistent
indenting. (see below for a definition of "consistent".)

When reading VTY commands from a file, use indenting as means to implicitly
exit child nodes. Do not look for commands in the parent node implicitly.

The VTY so far implies 'exit' commands if a VTY line cannot be parsed on the
current node, but succeeds on the parent node. That is the mechanism by which
our VTY config files do not need 'exit' at the end of each child node.

We've hit problems with this in the following scenarios, which will show
improved user experience after this patch:

*) When both a parent and its child node have commands with identical names:

  cs7 instace 0
   point-code 1.2.3
   sccp-address osmo-msc
    point-code 0.0.1

If I put the parent's command below the child, it is still interpreted in the
context of the child node:

  cs7 instace 0
   sccp-address osmo-msc
    point-code 0.0.1
   point-code 1.2.3

Though the indenting lets me assume I am setting the cs7 instance's global PC
to 1.2.3, I'm actually overwriting osmo-msc's PC with 1.2.3 and discarding the
0.0.1.

*) When a software change moves a VTY command from a child to a parent. Say
'timezone' moved from 'bts' to 'network' level:

  network
   timezone 1 2

Say a user still has an old config file with 'timezone' on the child level:

  network
   bts 0
    timezone 1 2
    trx 0

The user would expect an error message that 'timezone' is invalid on the 'bts'
level. Instead, the VTY finds the parent node's 'timezone', steps out of 'bts'
to the 'network' level, and instead says that the 'trx' command does not exist.

Format:

Consistent means that two adjacent indenting lines have the exact
same indenting characters for the common length:

Weird mix if you ask me, but correct and consistent:

  ROOT
  <space>PARENT
  <space><tab><space>CHILD
  <space><tab><space><tab><tab>GRANDCHILD
  <space><tab><space><tab><tab>GRANDCHILD2
  <space>SIBLING

Inconsistent:

  ROOT
  <space>PARENT
  <tab><space>CHILD
  <space><space><tab>GRANDCHILD
  <space><tab><tab>GRANDCHILD2
  <tab>SIBLING

Also, when going back to a parent level, the exact same indenting must be used
as before in that node:

Incorrect:

  ROOT
  <tab>PARENT
  <tab><tab><tab>CHILD
  <tab><tab>SIBLING

As not really intended side effect, it is also permitted to indent the entire
file starting from the root level. We could guard against it but there's no
harm:

Correct and consistent:

  <tab>ROOT
  <tab><tab>PARENT
  <tab><tab><tab><tab>CHILD
  <tab><tab>SIBLING

Implementation:

Track parent nodes state: whenever a command enters a child node, push a parent
node onto an llist to remember the exact indentation characters used for that
level.

As soon as the first line on a child node is parsed, remember this new
indentation (which must have a longer strlen() than its parent level) to apply
to all remaining child siblings and grandchildren.

If the amount of spaces that indent a following VTY command are less than this
expected indentation, call vty_go_parent() until it matches up.

At any level, if the common length of indentation characters mismatch, abort
parsing in error.

Transitions to child node are spread across VTY implementations and are hard to
change. But transitions to the parent node are all handled by vty_go_parent().
By popping a parent from the list of parents in vty_go_parent(), we can also
detect that a command has changed the node without changing the parent, hence
it must have stepped into a child node, and we can push a parent frame.

The behavior on the interactive telnet VTY remains unchanged.

Change-Id: I24cbb3f6de111f2d31110c3c484c066f1153aac9
2017-09-19 01:35:30 +00:00
Neels Hofmeyr d64b6aed23 VTY: interactive: never look for matching commands on parent node
For interactive telnet VTY, remove the implicit move up to the parent node when
a command did not succeed on the current node level.

When reading config files, this behavior was useful to allow skipping explicit
'exit' commands. (A different patch deals with that.)

In the telnet VTY, this behavior was never necessary. Explicit 'exit' commands
can move to the parent node, and typically uninformed users expect to require
that.

On a telnet VTY, counting indents like for reading config files is not an
option: a user will always type from the first column or may paste some leading
spaces without intended meaning.

After this patch, it is thus no longer possible to paste a complete config
across several node levels directly to a telnet session, unless it contains
'exit' commands.

Change-Id: Id73cba2dd34676bad8a130e9c45e67a272f19588
2017-09-08 23:45:52 +00:00
Neels Hofmeyr 17518fe393 doxygen: unify use of \file across the board
Considering the various styles and implications found in the sources, edit
scores of files to follow the same API doc guidelines around the doxygen
grouping and the \file tag.

Many files now show a short description in the generated API doc that was so
far only available as C comment.

The guidelines and reasoning behind it is documented at
https://osmocom.org/projects/cellular-infrastructure/wiki/Guidelines_for_API_documentation

In some instances, remove file comments and add to the corresponding group
instead, to be shared among several files (e.g. bitvec).

Change-Id: Ifa70e77e90462b5eb2b0457c70fd25275910c72b
2017-06-23 00:18:23 +00:00
Neels Hofmeyr 87e4550585 doxygen: enable AUTOBRIEF, drop \brief
Especially for short descriptions, it is annoying to have to type \brief for
every single API doc.

Drop all \brief and enable the AUTOBRIEF feature of doxygen, which always takes
the first sentence of an API doc as the brief description.

Change-Id: I11a8a821b065a128108641a2a63fb5a2b1916e87
2017-06-23 00:18:22 +00:00
Vadim Yanitskiy 49a0dec1fe vty/command.c: drop useless assignment
Change-Id: Ia30b6481ee570c6cf3e3b38e7a78028c66c036b7
2017-06-13 20:22:19 +07:00
Harald Welte 96e2a00d7a update/extend doxygen documentation
It's a pity that even with this patch we still are fare away from having
the whole API documented.  However, at least we have a more solid
foundation.  Updates not only extend the documentation, but also make
sure it is rendered properly in the doxygen HTML.

Change-Id: I1344bd1a6869fb00de7c1899a8db93bba9bafce3
2017-06-12 21:55:54 +00:00
Harald Welte addeaa39b1 vty: OSMO_ASSERT() if two identical commands are installed
When the caller installs two identical commands at a given VTY node, the
result is that neither of the two commands can ever be executed: The VTY
would always complain about "Ambiguous command.".  Let's fail fast at
program start when two identical commands are intalled.

Change-Id: I85ff4640ebb3d8b75a6a9ab5d2f668edb5b7189e
2017-01-07 12:14:48 +00:00
Neels Hofmeyr 8e2f7e87f4 add osmo_gettimeofday as a shim around gettimeofday
This allows feeding a custom time for unit tests by overriding
osmo_gettimeofday.

Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
2016-09-22 07:18:39 +02:00
Alexander Couzens ad580ba7c4 add vty call show asciidoc: generate a documentation for counters
For each counter group a ascii doc table is generated
containing all single counter with a reference to a section to
add additional information to the counter

Change-Id: Ia8af883167e5ee631059299b107ea83c8bbffdfb
Reviewed-on: https://gerrit.osmocom.org/70
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Harald Welte <laforge@gnumonks.org>
2016-06-14 10:38:17 +00:00
Harald Welte a99d45ac59 vty: Don't call exit() but rather use OSMO_ASSERT()
This was pointed out by Jaroslav Skarvada during fedora packaging,
and he has a valid point...
2015-11-12 13:48:23 +01:00
Jaroslav Škarvada 2b82c1c6c8 fix FSF address in sources/headers
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-11-12 13:46:05 +01:00
Holger Hans Peter Freyther a9e5252128 vty: Change API to have node installation be done by int
We are mixing enums and hope that no short-enums are used. This
is leading to a lot compiler warnings generated by clang. Change
the API to work with integers.

Porting:
The go_parent_cb implementations in the applications need to be
fixed. The API change leads to a compile time warning.

Fixes:
abis_om2000_vty.c:46:2: warning: implicit conversion from enumeration type 'enum bsc_vty_node' to
      different enumeration type 'enum node_type' [-Wenum-conversion]
        OM2K_NODE,
        ^~~~~~~~~
2015-08-05 04:22:56 +00:00
Holger Hans Peter Freyther 9f0f978c8d vty: Check with the application before writing the config
For the BSC/NITB application we see that people modify the band
without modifying the ARFCN. This creates an unbootable config.
Using the new hook the BSC/NITB can check if the config is
consistent and prevent the config file being written.

Related: SYS#739
2014-12-04 14:39:14 +01:00
Jacob Erlbeck b3657e1216 vty: Allow vty_go_parent() in all nodes.
This patch removes an assertion of node > CONFIG_NODE and changes
the function to handle all nodes properly.
For the sake of completeness, the generic 'exit' command
implementation is extended to work properly with all nodes, too.
2013-09-11 09:36:45 +02:00
Jacob Erlbeck 2349721d80 vty: Replace 'enum node_type' by 'int' for last_node
In this case the last_node variable may hold values that are not
in enum node_type, so int is used instead.
2013-09-10 11:04:00 +02:00
Jacob Erlbeck 0c987bd83b vty: Add vty_install_default() and use for the vty nodes
This adds the vty_install_default() function that is basically the
install_default() function plus the registration of the commands
'exit' and 'end'. The latter is only provided in subnodes of
ENABLED_NODE and CONFIG_NONE.

The VTY test program is extended to check these commands.

Ticket: OW#952
2013-09-08 10:49:52 +02:00