Commit Graph

38 Commits

Author SHA1 Message Date
Neels Hofmeyr cb5c4edda9 ctrl_type_vals: fix range check
In ctrl_cmd_parse(), fix missing check for not parseable ctrl type.

Fixup for Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28.

Change-Id: I7f8055225e3ee04b2a723bae07b12c42618963a0
2017-03-06 14:35:54 +00:00
Max 2ed3659cac Handle replies in ctrl_cmd_handle()
Previously *_REPLY and ERROR messages were not explicitly handled which
would lead to sending error in response to them which in turn would
prompt other party to send error as well which would result in infinite
cycle.

Handle it explicitly by logging message id and other relevant data.

Change-Id: Id96f3a2fc81fa4549f49556d83f062c6b2f59e28
Related: OS#1615
2017-03-01 16:37:59 +00:00
Max 70c7d4160d Use value_string for ctrl_type
Use value_string for enum ctrl_type instead of custom code. Add
corresponding unit tests.

Related: OS#1615
Change-Id: Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28
2017-03-01 16:37:59 +00:00
Max 9756c4691d Fix client-side ctrl interface helpers
* remove unused ctrl_interface_connect() which is not part of public API
* add default read callback to osmo_ctrl_conn_alloc()

Change-Id: Iaa209e34a849ce0dfe2e29b482c3208ade1a32a4
Related: OS#1615
2017-03-01 16:37:59 +00:00
Harald Welte a1004640ce libosmoctrl: Fix typo in ctrl_interface_connect()
it's osmo_sock_init_ofd(), not osmo_sock_init_ifd()

Change-Id: Ia6a82031a691403f641815862613d99b31a3a159
2017-02-23 21:07:01 +01:00
Max fa9e05e7e8 Expand and expose ctrl connection allocation
Add function for allocating CTRL connection to public headers and
replace call to previous static function with it. Add doxygen docs for
this function.

It's useful if we need to allocate ctrl connection but don't need to
bind to any interfaces: when we act as ctrl client.

Related: OS#1615
Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32
2017-02-23 17:30:44 +00:00
Max 32ee5af893 Document ctrl_interface_setup_dynip() function
Change-Id: Ie1d5881dda7a9b797d15e9e1eead8281a994d91e
2017-02-19 08:54:27 +00:00
Harald Welte f12d40f4df fix various compiler warnings (on FreeBSD-11.0)
FreeBSD 11.0 uses clang version 3.8.0 which spits various warnings
during libosmocore compilation.  Let's clean this up a bit.

Change-Id: Ic14572e6970bd0b8916604fabf807f1608fa07e5
2017-02-08 16:49:14 +01:00
Harald Welte f2899c674e Always include <osmocom/core/talloc.h> and not <talloc.h>
In EMBEDDED builds we don't have a system-wide talloc

Change-Id: Icc526016bda45b36e584afee8669996752d6d89c
2017-01-15 18:04:02 +01:00
Harald Welte 1c67e754b8 configure.ac: Introduce --disable-ctrl
Using --disable-ctrl, one can disable the building of libosmoctrl.

The 'embedded' target will also automaticall disable ctrl.

Change-Id: I6912396338c5b23ae860fef2a55854d6df9a579d
2017-01-15 18:04:02 +01:00
Max 4e72ee0d0f Catch-up with git version tags
* update debian/changelog
* update TODO-RELEASE
* add comments to Makefile.am and TODO-RELEASE to simplify the process
  in future
* add link to libtool docs to Makefile.am to simplify LIBVERSION
  maintenance

Related: OS#1861
Change-Id: I22c257e357f597519120232d742d6a61289db021
2016-12-21 10:31:17 +00:00
Harald Welte edf6fe75b7 ctrl_cmd_parse: Make coverity FORWARD_NULL happy
The 'strtok_r' function requires passing a NULL as the first parameter
on subsequent calls in order to ensure the code picks up where it left
off on a previous call.  However, Coverity doesn't quite realize this
and points out that if a NULL was passed in as the third argument it
would result in a possible NULL deref because the strtok_r function will
assign the third argument to the first in the call is NULL.

Change-Id: I7a9d08d0d4eae76a5207d285e32a25d1b384a57f
Fixes: Coverity CID 135186
2016-11-26 18:37:57 +00:00
Max bc067eb0a2 Add function to send TRAP over Control Interface
Change-Id: Ic0b8d88c4f5c4d42c3f8fb754f8eabf049c9e388
Related: OS#1646
2016-10-12 11:37:49 +00:00
Neels Hofmeyr 38d232ee5d log CTRL bind address and port
Log 'CTRL at 1.2.3.4 5678' from ctrl_interface_setup*. All callers can now drop
any extra 'CTRL at 1.2.3.4 5678' logging.

Change-Id: If449d0514e3d0cc1b346d7452194d931aa090166
2016-09-23 02:39:12 +00:00
Neels Hofmeyr 5b34f773e4 remove unused local variable in get_rate_ctr()
Unused after 22886d9e32
"Fix retrieving rate_ctr over control interface"

Change-Id: Ib5411da80c4eb4f905a5ed87c60477eca2cdff42
2016-09-19 14:18:38 +02:00
Neels Hofmeyr 2e38d358b6 remove unused function get_rate_ctr_group()
Unused after 22886d9e32
"Fix retrieving rate_ctr over control interface"

Change-Id: I405367ef6ba5833957778a79dd398ce5ea29307e
2016-09-19 14:18:38 +02:00
Max 22886d9e32 Fix retrieving rate_ctr over control interface
Allow getting either particular
counter (e. g. rate_ctr.per_hour.e1inp.0.hdlc.abort) or entire rate
counter group for a given index (e. g. rate_ctr.per_hour.e1inp.0).

Change-Id: I2b0109536170f7b5388d3236df30b98f457aa98d
Fixes: OS#1730
Reviewed-on: https://gerrit.osmocom.org/274
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-14 22:21:24 +00:00
Neels Hofmeyr f81eb328b6 vty: add ctrl section for Control interface bind address
This may seem like overkill for a mere const char * config item, but it makes
the Control interface VTY commands reusable in any main() scope (inspired by
libosmo-abis' VTY config).

Add API functions ctrl_vty_init() and ctrl_vty_get_bind_addr(), in new files
src/ctrl/control_vty.c and include/osmocom/ctrl/control_vty.h, compiled and/or
installed dependent on ENABLE_VTY.

Using these functions allows configuring a static const char* with the VTY
commands

    ctrl
     bind A.B.C.D

which callers shall subsequently use to bind the Control interface to a
specific local interface address, by passing the return value of
ctrl_vty_get_bind_addr() to control_interface_setup().

Add CTRL_NODE to enum node_type, "eating" RESERVED4_NODE to heed that comment
on avoiding ABI changes.
2016-02-25 11:02:35 +01:00
Neels Hofmeyr 4934309dab add ctrl_interface_setup_dynip() for bind address
Make the ctrl interface bind address configurable, so that it may be made
available on other addresses than 127.0.0.1. The specific aim is to allow
running multiple osmo-nitbs alongside each other (commits in openbsc follow).
2016-02-25 11:02:35 +01:00
Harald Welte 90e614f7cc remove our internal copy of talloc, use system libtalloc
Shipping our own private copy of talloc was a good idea in 2008,
when it was not readily available on most target platforms.  Today,
the situation is quite different, as it is a standard library on
major Linux distributions.
2015-12-05 23:38:18 +01:00
Holger Hans Peter Freyther 5fb265eaa7 ctrl: Avoid accessing cmd_desc->command out of bounds
We check that the amount of commands is not more than
we have but we don't check it the other way. It appears
that the vector is allowed to be bigger than the amount
of commands. So we match a prefix of a longer command
depending on the installation order.
2015-04-05 14:40:10 +02:00
Holger Hans Peter Freyther 267fd86e7d libctrl: Include config.h so we can include netinet/tcp.h
In e15ac060e7 we tried to fix
the nuttx build but we never included "netinet/tcp.h" after
it and the compiler warned about the unused "on" parameter
which we didn't notice because of the other warnings...

Include config.h so we can see if there is a tcp.h and then
include it.
2015-03-18 21:54:37 +01:00
Holger Hans Peter Freyther 4deb2dfa25 ctrl: Link to libraries we use symbols from
Fixes:
dpkg-shlibdeps: warning: symbol vector_free used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_set used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_set_index used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol tall_vty_vec_ctx used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol ipa_msg_recv_buffered used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol cmd_free_strvec used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_lookup used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_lookup_ensure used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol cmd_make_strvec used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_init used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
2015-01-18 19:20:42 +01:00
Harald Welte e15ac060e7 fix libosmocore build for NuttX target
this fixes some compilation issues with libosmocore under NuttX,
particularly as some #defines are missing or some header files are
slightly different.
2014-12-04 14:15:36 +01:00
Holger Hans Peter Freyther 96af78650d misc: Look into the build directory for generated files
the bits/crc files are not inside the sourcedirectory but will end
in the build directory. Go and look there as well. This somehow
doesn't fail with make distcheck but when building for Yocto Dizzy.
2014-09-25 18:18:49 +02:00
Harald Welte 39c9e7b471 libctrl: Add support for 'deferred control commands'
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.
2014-08-24 16:52:54 +02:00
Holger Hans Peter Freyther 5e21131c8d ctrl: Attempt fix the build on FreeBSD and add include file
IPPROTO_TCP is defined in netinet/in.h. Include it and hope the
build is fixed for FreeBSD.
2014-08-21 16:33:32 +02:00
Harald Welte ae2fcb22cf rename controlif_setup() to ctrl_interface_setup()
which means that all control interface related functions now have
the common ctrl_ prefix.
2014-08-21 15:34:19 +02:00
Harald Welte bfdc259824 libctrl: Make two internal helper functions static 2014-08-21 15:34:18 +02:00
Harald Welte 528134b01c libctrl: Move bulk of control node lookup inti libosmoctrl
The control interface user now only has to register a very short
node lookup function callback.  This function is optional, and only
required if hierarchical command lookup should be supported.
2014-08-21 15:34:18 +02:00
Harald Welte c78e74e3d0 libctrl: remove 'struct gsm_network' references
libctrl doesn't need any knowledge about the type of the user-private
data that it gets passed upon setup time and includes on callbacks.
2014-08-21 15:34:18 +02:00
Harald Welte acbb4c91b6 libctrl: adopt to recent ipaccess/ipa naming change 2014-08-21 15:34:18 +02:00
Harald Welte 3ff81b1a6b libctrl: autotools build system integration
Now we actually build the recently-imported libctrl
2014-08-21 15:34:18 +02:00
Harald Welte 7fd0c830d9 libctrl: Add DLCTRL as logging context for the control interface
... and make libctrl code use it
2014-08-21 15:34:18 +02:00
Harald Welte c9df37d84a libctrl: Avoid using external tall_bsc_ctx
Instead of using one flat talloc context (and one that is specific to
openbsc), we should attach the objects to whatever parent context they
are being used in.
2014-08-21 15:34:17 +02:00
Harald Welte 1238cc64d7 libctrl: remove openbsc headers, convert from make_sock to libosmocore 2014-08-21 15:34:17 +02:00
Harald Welte e1a502b0df libctrl: Remove reference to 'DNAT' in favor of 'DCTRL' 2014-08-21 15:34:17 +02:00
Harald Welte dda4225153 libctr: rename/move control interface to libosmocore naming scheme 2014-08-21 15:34:17 +02:00