aboutsummaryrefslogtreecommitdiffstats
path: root/src/vty
AgeCommit message (Collapse)AuthorFilesLines
5 daysvty: fix memleak in host_config_set()Vadim Yanitskiy1-1/+1
Not only we call this function from vty_read_config_file(), but also from config_write_file_cmd. Thus we leak memory when doing 'write file FILE' in the VTY. Change-Id: I356818aae3addab6db39de9a625453b7435b7cc1
2024-03-20Revert "Revert "logging: add log level cache""Hoernchen1-0/+7
This reverts commit 7f1fb3ea817578f3f2f63e8065aa50f8355caa3b - slightly amended with the new log_cache_enalbe() function. The cache is hence disabled by default, and applications can enable it, if they wish to benefit from it. Reason for the original revert was: some fallout expected due to log manipulation in test code Change-Id: I539872fc9e3c50b407e6bc388f1e091fa2c826c3
2024-01-09Revert "logging: add log level cache"Hoernchen1-7/+0
This reverts commit 7dc6d4a629a37bb081d62f6ce61f4e5ee0237247. Reason for revert: other tests are failing Change-Id: Ife4c49d1bb933e983ac68c57970c9c49b40e08be
2024-01-09logging: add log level cacheEric1-0/+7
This ensures multithreaded logging attempts, in particular ones that do nothing, do not hold the lock just for checking the level, which interferes with other logging attempts. Closes: OS#5818 Change-Id: I35f8dd9127dd6e7feae392094fd6b3ce2d32558d
2024-01-05vty: suppress warnings about len being set but not usedVadim Yanitskiy1-0/+1
This commit fixes the following warning seen with CC=clang: utils.c:376:6: warning: variable 'len' set but not used [-Wunused-but-set-variable] int len = 0, offset = 0, ret, rem; ... and finally allows to build libosmocore with --enable-werror. Change-Id: I0040ef20ba3fc53ee7ccefc4885170f333f80566
2023-09-12Bump version: 1.8.0.252-13c29 → 1.9.01.9.0Pau Espin Pedrol1-1/+1
Change-Id: I6f8eccbccb73c6c094f13f2d4bdee931cf5b9010
2023-06-28Allow 'configure <cr>' at VTY to enter config modeAndreas Eversberg1-1/+1
Similar to HP/Aruba, only the word or abbreviation of 'configure' is required to enter config mode. This is the default. It is still possible to add other configuration sources than 'terminal' if implemented in the future. Change-Id: I56d5d1bd5526603a397c62542e667c413f4952ca
2023-05-06vty: move struct vty_parent_node to private APINeels Hofmeyr1-0/+15
Change-Id: Id2070f03b09feea966c5342361d409551e557d38
2023-05-06vty: fix vty->index for implicit go_parent_nodeNeels Hofmeyr1-0/+3
After this patch, most vty_go_parent() functions are really obsolete, as originally intended: A vty_go_parent() is only needed if the program requires an action to run on VTY node exit. vty_transcript_test.vty shows the fixed behavior. For details, see preceding patch "vty: show bug in implicit go_parent_node" I2472daed7436a1947655b06d34eb217e595bc7f3 Change-Id: Id408c678d18ba19b1c1394c3fb657536153d2094
2023-02-07Bump version: 1.7.0.119-b31a-dirty → 1.8.01.8.0osmith/1.8.1Pau Espin Pedrol1-1/+1
Change-Id: I5e953cedc041371a9c192f58348b673a787f542e
2023-01-18Fix all references to config.hPau Espin Pedrol5-5/+5
config.h is created in $(top_buildir)/config.h. Let's make sure all CPPFLAGS add correct -Ipath includes, and that all code includes the correct file. Change-Id: Ie9ea38bb009bc715b01cde4d66d181f7bec2e7bd
2023-01-18Move src/*.{c,h} to src/core/Pau Espin Pedrol1-1/+1
This way we have all libosmocore.so in an own subdir instead of having lots of files in the parent dir, which also contains subdirs to other libraries. This also matches the schema under include/osmocom/. Change-Id: I6c76fafebdd5e961aed88bbecd2c16bc69d580e2
2023-01-09libosmocore: Deprecate APIs telnet_init(_dynip)()arehbein1-20/+28
Related: OS#5809 Change-Id: Ibd05d3bc2736256aa45e9e7ec15a98bd14a10454
2022-12-04telnet_init_dynif: don't allow negative portMax1-0/+3
Binding to a negative port should not be allowed. Using signed value for unsigned parameter is a mistake to begin with. Change-Id: I24f957641f2d8e230ccceb331a719496df0fdb1f
2022-12-04telnet_init_dynif: propagate errorMax1-1/+1
Return actual error from osmo_sock_init_ofd() to the caller. Change-Id: Ib09f4315b3868ec031ecbced8a63069e7c2de7da
2022-12-04vty: fix doc typoMax1-1/+1
Change-Id: I9f1112fc27dfe967b4a007648ddda1050e9bd9fa
2022-11-03Support building with -Werror=strict-prototypes / -Werror=old-style-definitionHarald Welte3-3/+3
Unfortunately "-std=c99" is not sufficient to make gcc ignore code that uses constructs of earlier C standards, which were abandoned in C99. See https://lwn.net/ml/fedora-devel/Y1kvF35WozzGBpc8@redhat.com/ for some related discussion. Change-Id: I84fd99442d0cc400fa562fa33623c142649230e2
2022-09-15vty: Allow using hex representations in cmd numeric rangesPau Espin Pedrol1-6/+55
Ranges can now be specified in hexadecimal notation. In this case, only hexadecimal values are accepted (prefixed with "0x"). In order to allow using a hexadecimal value as an input argument, the command must specify the range in hexadecimal form. This way all existing commands (decimal) won't get an hexadecimal value unless they are further extended in the future, avoiding hard to notice breakage due to use of stroul() without using base=0 or even worse, using atoi() directly (which only understands decimal and provides no error checking mechanism). A command argument can be expanded to accept both decimal and hex in a range by means of specifying both, example: "mycmd (<0-255>|<0x0-0xff>)". Related: OS#5631 Change-Id: Ia2b7fbbf5502c28374c21dbff548232680da27d4
2022-06-28Bump version: 1.6.0.132-0239-dirty → 1.7.01.7.0Pau Espin Pedrol1-1/+1
Change-Id: Idb0d20aa4336a69cb100e140fb1fa9e7ac25b984
2022-06-17vty: command.c: Add assertPau Espin Pedrol1-0/+1
a program being developed right now crashed at this point, without providing any meaningful information on where did it crash. Change-Id: Ia14f43142e7409f72eb9efd5c9131bea5eed6e82
2022-05-17fsm_vty: use unsigned int when left-shifting 31 bits!Harald Welte1-1/+1
fsm_vty.c:64:8: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Change-Id: I637bce52fae947922cbb8642a0313d174c827422
2022-05-08stats: don't try to save unknown stats reporter typesHarald Welte1-0/+5
The point of having a public API to register further stats reporters is to enable applications or other libraries to do so. As we in libosmocore don't know anything about the parameters of such a stats reporter, don't try to do a partial save of them when saving the config file. Change-Id: I2986313375daec1c4959a6a914e3fb2980a5d7ca
2022-04-28vty: Add a 'skip-zero' version of 'show stats' and 'show rate-counters'Harald Welte2-32/+92
In many cases, a lot of the counters are zero, and we're likely not interested in those, but only the non-zero counters. Add a version of the 'show stats' command which dumps only those items with a non-zero total value. Change-Id: Ie4df1c139e3c82deca1dd3cdab5d3909e0513684
2022-04-27Use internal <osmocom/core/talloc.h> everywhereVadim Yanitskiy1-1/+1
Change-Id: If40e1eefcfa88a2b376becfe057836acdd3a1cc2
2022-03-29vty: Support platforms that don't support pthread_getname_np()Harald Welte1-0/+4
pthread_getname_np() is a non-portable extension of pthreads. While it exists in glibc, for example musl didn't have it until rather recently (April 2021) and there still hasn't yet been a musl release with this change, resulting even current OpenWRT not yet supporting pthread_getname_np. So let's check if pthread_getname_np is supported, and only use it in that case. Change-Id: Ibd01485af24e2fe574006f8d049bf37226dda966
2022-03-27libosmovty: Link libosmovty against libpthreadHarald Welte1-2/+2
Ever since Change-Id If76a4bd2cc7b3c7adf5d84790a944d78be70e10a in 2020 (part of libosmocore >= 1.4.0) we have introduced cpu_sched_vty.c, which directly uses libpthread. As a result, libosmovty should be using pthread compiler flags and link against libpthread. This missing dependency is causing osmocom applications to fail to link on OpenWRT (at leats for ath79-generic). Change-Id: I7febbf88cbe61eacd05f46a9316e773b5c148e77 Related: SYS#4986
2022-01-05VTY: implement 'no log gsmtap [HOSTNAME]' commandVadim Yanitskiy1-0/+22
Change-Id: I9a4efa1e35cbc22cea06a64a15a369522c32d3c4
2021-12-23select: gather statistics for TCP connectionsPhilipp Maier1-0/+33
osmocom applications are deployed in a variety of different situations. Dependung on the medium that interconnects the network components unexpected behaviour may occur. To debug problems with the interconnection between network components it might help to monitor the health of the related TCP connections. Change-Id: I1416f95aff2adcf13689646b7574845de169fa3d Related: SYS#5701
2021-12-14treewide: remove FSF addressOliver Smith7-29/+0
Remove the paragraph about writing to the Free Software Foundation's mailing address. The FSF has changed addresses in the past, and may do so again. In 2021 this is not useful, let's rather have a bit less boilerplate at the start of source files. Change-Id: I5050285e75cf120407a1d883e99b3c4bcae8ffd7
2021-12-07VTY: enable talloc introspection for OTC_GLOBALVadim Yanitskiy1-1/+4
Change-Id: I831722174ecbac7f2d53f2427ba7e2615fa28c8a
2021-11-17tests/tdef: rename the binaries to end with '_test'Vadim Yanitskiy1-1/+1
It's the usual naming for unit test binaries. Without the '_test' endig, the tdef_vty_test_{config_root,config_subnode,dynamic} binaries do not match the 'tests/*/*_test' pattern and appear as untracked files in git. Change-Id: I828fa45132e11a41c527d4b25df850c19871cb75
2021-11-16Bump version: 1.5.1.282-ab5e-dirty → 1.6.01.6.0Pau Espin Pedrol1-1/+1
Change-Id: Ia3ac0a36b9e898996f596c6d2787e03cd59bfc11
2021-11-09stats: clarify error messages in cfg_no_stats_reporter_{statsd,log}Vadim Yanitskiy1-4/+4
Change-Id: I287130213c7de31a510f293bed0f3daddd53ce04 Related: SYS#5713
2021-11-09stats: don't mark reporter as 'disable' beforehandVadim Yanitskiy1-2/+2
Change-Id: I330a079807cca48b7cc43767abcd2b58830a05fc Related: SYS#5713
2021-11-09stats: cosmetic: print 'stats interval' before the reportersVadim Yanitskiy1-2/+2
It's better to have the common parameters printed first. Change-Id: Ifb401d4d363fb70e89960ca739baba5ee55eefe8 Related: SYS#5713
2021-11-09stats: allow configuring reporter's name in the VTYVadim Yanitskiy1-23/+49
This allows configuring more than one reporter of the given type. Change-Id: Ia815c24dc974648985539913012b3b074ea317a9 Related: SYS#5713
2021-10-26logging: Change stderr + file target to use non-blocking writeHarald Welte1-7/+25
So far, we used blocking, buffered fwrite() to write to stderr and file targets. This causes problems if there are [slow] consumers causing delays, such as gnome-terminal (when the program is started interactively) or systemd/journald (where we observe 64..128ms blocks on stderr). This patch introduces stderr/file based logging via write_queue and osmo_select_main(), i.e. switch from glibc-buffered, blocking to internally buffered, non-blocking writes. * when osmo_stderr_target is created via application.c, we create it in blocking stream mode for backwards compatibility, particularly for [smaller] programs that don't use osmo_select_main() * when the VTY code encounters 'log stderr' or 'log file FILENAME', we switch that respective target to non-blocking write-queue mode, as this means the application is in fact using osmo_select_main() * The config file can now state 'log stderr blocking-io' or 'log file FILENAME blocking-io' to explicitly enforce using blocking stream based I/O * The application can at any time use API functions to switch either way Closes: OS#4311 Change-Id: Ia58fd78535c41b3da3aeb7733aadc785ace610da
2021-10-04revisit some calls of strtol(), stroul(), strtoull()Neels Hofmeyr3-37/+10
Replace some with atoi(), where the VTY has already validated correct range of the argument. Replace others with the new osmo_str_to_int() or osmo_str_to_int64() functions, possibly covering more detection of invalid number strings. Leave those strtol() callers that depend on endptr to provide the next string token. Related: SYS#5542 Change-Id: I0ebb06e751c28f7d1cdf328de29cd227a2449391
2021-09-30refactor stat_item: get rid of FIFO and "skipped" errorNeels Hofmeyr2-7/+7
Intead of attempting to store all distinct values of a reporting period, just store min, max, last as well as a sum and N of each reporting period. This gets rid of error messages like DLSTATS ERROR stat_item.c:285 num_bts:oml_connected: 44 stats values skipped while at the same time more accurately reporting the max value for each reporting period. (So far stats_item only reports the max value; keep that part unchanged, as shown in stats_test.c.) With the other so far unused values (min, sum), we are ready to also report the minimum value as well as an average value per reporting period in the future, if/when our stats reporter allows for it. Store the complete record of the previous reporting period. So far we only compare the 'max' value, but like this we are ready to also see changes in min, last and average value between reporting periods. This patch breaks API by removing: - struct members osmo_stats_item.stats_next_id, .last_offs and .values[] - struct osmo_stats_item_value - osmo_stat_item_get_next() - osmo_stat_item_discard() - osmo_stat_item_discard_all() and by making struct osmo_stats_item opaque. In libosmocore, we do have a policy of never breaking API. But since the above should never be accessed by users of the osmo_stats_item API -- or if they are, would no longer yield useful results, we decided to make an exception in this case. The alternative would be to introduce a new osmo_stats_item2 API and maintaining an unused legacy osmo_stats_item forever, but we decided that the effort is not worth it. There are no known users of the removed items. Related: SYS#5542 Change-Id: I137992a5479fc39bbceb6c6c2af9c227bd33b39b
2021-09-23vty: add vty_out_uptime() print the uptime to the vtyAlexander Couzens2-12/+23
vty_out_uptime() calculates the time difference to a given timespec and print it in a human readable format (days, hours, minutes, seconds) to the vty. Related: OS#5028 Change-Id: I264a3f49096b96646e0a1f5366623ac20d860793
2021-09-10vty: allow flushingEric1-0/+6
It was so far sufficient to wait for the buffers to drain at some random point in time, but this is not always the case, sometimes it is important that the output is flushed immediately. Change-Id: If984b9ad2eba9f400bc29a7aa8825e241fd1d2a9
2021-08-23vty 'stats reset': do not reset stat_itemsNeels Hofmeyr1-8/+1
Exempt all stat_item statistics from 'stats reset'. Only reset rate_ctr statistics to zero. The rate_ctr statistics have an implicit time scale, counting occurences per time unit. For them it makes sense to reset all ratings and start from zero, for example in a test suite (e.g. our TTCN3 BSC_Tests). In contrast, stat_item statistics count number of objects or nr of specific object stati at any given time, and they do not deteriorate over time. Many stat items depend on increment/decrement to be sane. For example, in osmo-bsc, if the nr of connected BTS is 3, that does not make sense to be reset to zero. There are still 3 BTS connected, only the stat_item would suddenly reflect zero. From then on, it'd be wrong. All stat_items are by definition wrong after a 'stats reset'. - Those that depend on increment/decrement will be wrong until the program exits, and - those that are set to absolute values will be wrong up until the next value is set. That could be seconds or hours later, depending. Related: SYS#5542 Change-Id: If2134768b1076e7af189276c45f2a09a4944303e
2021-07-27vty: clear screen with ^LOliver Smith1-0/+17
Use ANSI escape characters to clear the screen with ^L, like it works in typical Linux shells. I always found it slightly inconvenient that this didn't work in the VTY. Change-Id: Ie2356cd92f39b4dc28b5c20bbe4557fb0d972747
2021-07-19vty: show uptime: use timespecsubOliver Smith1-5/+7
Related: OS#4609 Change-Id: If94795b3cd74040c49bdcbed8c410bf6e950afff
2021-07-15vty: add "shutdown"Oliver Smith1-0/+16
Kill programs with SIGTERM with the new vty command, as it would happen with "systemctl stop". I've considered running the select shutdown logic too in order to ensure that pending OSMO_FD_WRITE requests are serviced. But as noted in review, it's better to ensure that the regular SIGTERM code path works as expected and call that instead of introducing an alternative code path. Closes: OS#4609 Change-Id: I3596a35b0f4a24e49484ec3f24a98e4d4f583e1e
2021-07-15vty: add "show pid"Oliver Smith1-0/+8
Related: OS#4609 Change-Id: Ib636050afc1eed134f450f2f1cdd3b51153b0160
2021-07-15vty: add "show uptime"Oliver Smith1-0/+27
Related: OS#4609 Change-Id: Ic7d9d5d3c8a9abd06a7e626aed7679f68406040c
2021-06-18vty: make function cmd_range_match() publicPhilipp Maier1-4/+4
Certain control interface commands also may require to verfy a range in their verify function. cmd_range_match() from the VTY does exactly that and the range can be specified as string, the same way as we would specify it in the VTY. Change-Id: I53fc207677f52b1dc748b01d58424839cdba807c related: SYS#5369
2021-06-16stats_vty: Improve generation of osmo countersDaniel Willmann1-11/+10
Use section for all counter headings, the idea is that the generated doc is included below a chapter describing the implemented counters which can optionally describe individual items. If not osmo_counters are present simply omit the whole section to tidy up the manual. Those are deprecated anyway and not used in the osmo-* projects that I checked. Change-Id: I126b39cb9458e0f62efa338967e07151a0eece0f Related: SYS#5005, OS#4523
2021-06-07stats_vty: also show rate counter group name (if present)Vadim Yanitskiy1-1/+4
Change-Id: I358f52e81a85f041fc21960634d04d18e7883dd5