summaryrefslogtreecommitdiffstats
path: root/include/osmocom/ctrl/control_cmd.h
Commit message (Collapse)AuthorAgeFilesLines
* ctrl: use #define for TRAP idMax2018-12-031-0/+1
| | | | | | | We always use id = 0 when sending TRAP messages. Let's make this more obvious by introducing appropriate define. Change-Id: I33d7d4c6a1885a75a85d6f2f017430e0860b4126
* ctrl: Introduce ctrl_cmd_parse3 APIPau Espin Pedrol2018-07-161-0/+1
| | | | | | | | | Callers require to know whether the returned ERROR cmd was received or generated locally, in order to send it or do something with it locally. Related: OS#3394 Change-Id: Ide9170e5c31967c353f8fe4e8227e64130b91eae
* ctrl: Add doxygen API documentation; generate html from itHarald Welte2018-05-261-6/+77
| | | | | Closes: OS#3293 Change-Id: I8dc2f24d4bf557ff7bb0f2f46881f9f8d9d7f86f
* ctrl: fix deferred commands (and hence fix osmo-bts-sysmo 'clock-info' cmd)Neels Hofmeyr2018-04-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CTRL interface has a ctrl_cmd_def_* API that allows deferring a CTRL command reply until later. However, the command handling currently fails to acknowledge this and deallocates the struct ctrl_cmd anyway. Fix: in struct ctrl_cmd, add a defer pointer to be populated by ctrl_cmd_def_make(). A cmd thus marked as deferred is not deallocated at the end of command handling. This fix needs no change in calling code. (Another idea was to return a different code than CTRL_CMD_HANDLED when the command is to be deferred, but that would require adjusting each user of ctrl_cmd_def_make(). The implicit marking is safer and easier.) Show that handling deferred commands is fixed by adjusting the expectations of ctrl_test.c's test_deferred_cmd() and removing the now obsolete exit_early label. One symptom of the breakage is that osmo-bts-sysmo crashes when asked to report a trx's clock-info, which is aggravated by the fact that the sysmobts-mgr does ask osmo-bts-sysmo for a clock-info. The crash appears since Id583b413f8b8bd16e5cf92a8a9e8663903646381 -- it looked like just fixing an obvious memory leak, which it did as shown by the unit test, but deferred ctrl commands actually relied on that leak. Both fixed now. Related: OS#3120 Change-Id: I24232be7dcf7be79f4def91ddc8b8f8005b56318
* add ctrl_cmd_parse2() to return parsing errorsNeels Hofmeyr2017-12-181-0/+1
| | | | | | | | | | | | | | | | | | | | | If a control command fails to parse, we so far discard specific error messages and instead send just "Command parser error". In ctrl_cmd_parse() we actually compose detailed error replies, but in the end simply talloc_free() them and return NULL. A first step to report these errors to the ctrl command issuer is to not return NULL and instead return the cmd with type = CTRL_TYPE_ERROR. Add ctrl_cmd_parse2() to return such instead of NULL. To stay API compatible, provide ctrl_cmd_parse2() to return a cmd on errors. ctrl_cmd_parse() retains identical behavior but becomes just a simple wrapper around ctrl_cmd_parse2() which discards the cmd on error. No need really to deprecate ctrl_cmd_parse() yet; especially as long as compiler warnings might break jenkins builds. Change-Id: I5047c9f977d70b03eea77cbcfd2b96d43ea46880
* add osmo_talloc_asprintf() and ctrl_cmd_reply_printf()Neels Hofmeyr2017-10-241-0/+3
| | | | | | | | | | | | | | | | Add macro to append to a CTRL commands' reply string, ctrl_cmd_reply_printf(). The talloc_asprintf() part of it is generic enough to qualify for a separate macro, osmo_talloc_asprintf(). The idea is to not have to decide for each bit added to a string whether the string is already allocated or not, but simply be able to issue printf commands and let the macro worry about initial allocation or reallocation. This originally came from osmo-hlr change I1bd62ae0d4eefde7e1517db15a2155640a1bab58, where it was requested to move this bit to libosmocore. Change-Id: Ic9dba0e4a1eb5a7dc3cee2f181b9024ed4fc7005
* doxygen: unify use of \file across the boardNeels Hofmeyr2017-06-231-0/+2
| | | | | | | | | | | | | | | | | 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
* control_if: Add control interface commands for FSMsHarald Welte2017-04-271-0/+2
| | | | | | | | | This allows programmatic access to introspection of FSM instances, which is quite handy from e.g. external test cases: Send a message to the code, then use the CTRL interface to check if that message has triggered the right kind of state transition. Change-Id: I0f80340ee9c61c88962fdd6764a6098a844d0d1e
* ctrl_type_vals: explicitly terminateNeels Hofmeyr2017-03-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't use CTRL_TYPE_UNKNOWN as value_string[] terminator, use an explicit, more obvious { 0, NULL } termination. Set an explicit string for CTRL_TYPE_UNKNOWN. No other value_string[]s to date have such a "hidden" terminator. BTW, a { 0, "string" } item is not a terminator, only { 0, NULL } is, so we can set a string for CTRL_TYPE_UNKNOWN == 0. Also, having a string value for CTRL_TYPE_UNKNOWN is not harmful because all code paths explicitly check for the CTRL_TYPE_*s that are valid. Adjust the test expectation. From the ctrl_type_vals enum, remove the = 0, because it is implicitly 0 anyway. One motivation to press this fixup: I am trying to add a script that checks whether all value_string[]s are terminated to our jenkins jobs, and to find that this one is terminated, it would need to interpret the CTRL_TYPE_UNKNOWN constant, which would make things far more complex. At this point, all of the value_string[]s have an explicit termination, and I would like to enforce this from now on -- for readable code and to not spend more time on the validator. The patch adding ctrl_type_vals (Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28) was accepted by another reviewer before I could reconfirm my -1, so this is a fixup to enable the termination checking script patches. Related: I2bc93ab4781487e7685cfb63091a489cd126b1a8 (adds script to libosmocore) I7fe3678b524d602fc6aa14bc0ed06308df809a3e (uses in jenkins.sh) Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28 (adds ctrl_type_vals) Change-Id: Ia99f37464c7b36b587da2cc78f52c82725f02cbc
* Use value_string for ctrl_typeMax2017-03-011-2/+4
| | | | | | | | Use value_string for enum ctrl_type instead of custom code. Add corresponding unit tests. Related: OS#1615 Change-Id: Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28
* CTRL: add write-only helpersMax2017-01-161-0/+24
| | | | | | | | | Similar to CTRL_CMD_DEFINE_RO() add helper for control commands which are not meant to be read, only to set. Similarly, add CTRL_CMD_DEFINE_WO_NOVRF() for commands which do not perform inbound data verification. Change-Id: I66b7990db590c1f8e56326e392e6c1d2eafebd9a
* Revert "Constify ctrl_cmd struct fields where appropriate"Neels Hofmeyr2016-10-201-3/+3
| | | | | | | | | | | | | This reverts commit ed9d6da5df98538adc70aa03cb569eb9505d04b6. The commit is good as such, but it causes many compiler warnings in the OpenBSC build. We want this to be re-applied as soon as we have patches ready that fix the fallout in openbsc.git. See also https://lists.osmocom.org/pipermail/openbsc/2016-October/009802.html Related: OS#1829 Change-Id: I722ad60232a6ef5b4cb984b92c42851de26b3ccd
* Constify ctrl_cmd struct fields where appropriateMax2016-10-111-3/+3
| | | | Change-Id: I3f55c1d4b965d215dc9b16f4b284b7fea4bde9e9
* libctrl: Add support for 'deferred control commands'Harald Welte2014-08-241-0/+15
| | | | | | | | | | | | | | Sometimes a control interface command cannot be processed and responded immediately, but we need to process it asynchronously. In order to support this, we introduce the 'ctrl_cmd_def', which represents such a deferred command. It is created by the service implementing the command using ctrl_cmd_def_make(), and a response is later sent using ctrl_cmd_def_send(). ctrl_cmd_def_is_zombie() must be called to handle the case where the control connection has disconnected/died between receiving the command and sending the response.
* Convert recently-introduced header files to #pragma onceHarald Welte2014-08-211-4/+1
|
* libctrl: remove reference to bsc_replace_string()Harald Welte2014-08-211-1/+1
| | | | | ... and rather introduce a general osmo_talloc_replace_string() to libosmocore.
* libctrl: remove openbsc headers, convert from make_sock to libosmocoreHarald Welte2014-08-211-2/+1
|
* libctr: rename/move control interface to libosmocore naming schemeHarald Welte2014-08-211-0/+179