Commit Graph

37 Commits

Author SHA1 Message Date
Oliver Smith 12f93be607 gsmtap_makemsg_ex: NULL for unknown chan_type
Related: osmo-bts Ic22ab71e520ab44429a93724250d349d16250801
Change-Id: Ib4147a33a75c3cf425c30da8b0678c7fba8a371d
2020-05-20 06:05:38 +00:00
Harald Welte 6773304de8 gsmtap: Solve TCH / FACCH confusion once and for all
* What we used to call TCH/F and TCH/H in gsmtap are actually only
  FACCH/F and FACCH/H, i.e. the signaling part of Bm/Lm channels

* Give them proper names with backwards compatibility #define

* Split VOICE into VOICE_F and VOICE_H.  If we don't differentiate this,
  a receiver is not able to determine the RSL channel ID of a frame
  without looking at external state/context.  That in turn has been a
  design feature of GSMTAP Um format so far, and programs like
  osmo-bts-virtual rely on it.

Change-Id: I952044a17334f35712e087dc41781805000aebc1
Related: OS#2557
2020-03-08 17:27:00 +01:00
Harald Welte 20618cabe7 Add GSMTAP_CHANNEL_VOICE to gsmtap_gsm_channel_names[] value_string
In Change-Id If223020933b083fe359a2e8ff5fab1ce64a363d8 we introduced
GSMTAP_CHANNEL_VOICE, but we didn't add it to gsmtap_gsm_channel_names[]

Change-Id: I7ab696d3e0edb13632e048a9e05be03612d3d28c
Related: OS#2557
2020-03-08 10:42:51 +01:00
Harald Welte ac7fabe34f chantype_rsl2gsmtap(): Add entries for CBCH
This adds missing entries for CBCH in the conversion between RSL-style
channel numbers and GSMTAP channel types.

Without this change, you will see tons of messages like
virtphy[19865]: Wed Feb 26 16:16:28 2020 DVIRPHY <0002> gsmtapl1_if.c:267 MS 0000: Ignoring unknown channel type UNKNOWN (0)
if running virtphy of osmocom-bb with a BTS that broadcasts CBCH.

Change-Id: I19bbd2942adf441f58955ac896ef968bfd8aec5f
2020-02-28 10:46:42 +00:00
Vadim Yanitskiy b9baf02c12 src/gsmtap_util.c: fix possible memleak in gsmtap_source_init()
In gsmtap_source_init() we dynamically allocate a gsmtap_inst struct,
but don't free it if the subsequent call to osmo_fd_register() fails.

Change-Id: I970b493f3a64fbe9c3f68fcfba5097ee3ff72960
2019-03-28 10:07:59 +00:00
Vadim Yanitskiy 2f65bb1b01 Doxygen: fix incorrect / missing parameter description
Change-Id: Ibc63a5d4442a192efab8b5b30e0beb3545642ecc
2019-03-25 15:57:09 +07:00
Harald Welte 1688699c3f select: Rename BSC_FD_* constants to OSMO_FD_*
The naming of these constants dates back to when the code was private
within OpenBSC.  Everything else was renamed (bsc_fd -> osmo_fd) at
the time, but somehow the BSC_FD_* defines have been missed at the
time.

Keep compatibility #defines around, but allow us to migrate the
applications to a less confusing naming meanwhile.

Change-Id: Ifae33ed61a7cf0ae54ad487399e7dd2489986436
2019-03-21 16:02:01 +00:00
Philipp Maier b8a91625dd gsmtap_util: make sure SO_REUSEADDR is applied for GSMTAP
When gsmtap adding a new sink it does not supply OSMO_SOCK_F_UDP_REUSEADDR
in order to have SO_REUSEADDR applied. In most cases, the gsmtap sink is
just receiving packets to toss them immediately, so having one of them
is sufficient.  However, in other use cases - particularly virt_phy -
we actually want to receve and process GSMTAP messages via multicast
Applying SO_REUSEADDR (like we did before disabling it globally for UDP
in I4a8ffb8d598aca88801a4a0322944d7cdd8d4047 on August 1st) resolves
the issue.

Change-Id: I1399a428467ca12f1564a14eb8ffb294d4f59874
Related: OS#3497
2018-08-24 10:31:18 +00:00
Neels Hofmeyr a4952aa436 memleak: fix all libosmocore callers of gsmtap_sendmsg() to free on failure
gsmtap_sendmsg() does not free the msgb if it returns a failure rc, so the
callers must check the rc and free the msg.

Change-Id: I7cf64ed9b14247298ed8b4ab8735627f8235a499
2018-02-16 01:34:26 +01:00
Neels Hofmeyr 90539ac30b memleak: gsmtap_sendmsg(): don't return 0 when no data was written
If less than the msgb size was written by write(), we want to return -EIO.
Hence do not return zero when write() wrote zero bytes, return -EIO in that
case as well.

Previously, if write() returned zero, gsmtap_sendmsg() would return zero
*without* freeing the msg, hence neither would the (ideal) caller. So this
fixes a corner-case memleak.

Change-Id: I099ae1c663c018da5db884f7e9d52c45af3ed817
2018-02-16 01:33:35 +01:00
Neels Hofmeyr c9a4ce600a gsmtap_sendmsg(): clarify API doc concerning msgb ownership
Not freeing on error does enable callers to try to re-send as well, so it is a
kind of useful feature, even though I find it likely for callers to either
forget about freeing the msg on error or double-free by accident...

I considered changing gsmtap_sendmsg() to always free, but since it is public
API, I chose to keep and document its current behavior properly instead. We
don't know what callers may exist out there.

Change-Id: Id3266ce36442024f16eaf6afa3f516d201930c41
2018-02-16 01:29:37 +01: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
Harald Welte 3b7cd0b5cb chantype_rsl2gsmtap/gsmtap2rsl: Fix PDCH channel type conversion
Change-Id: I88a06e8ba894f16006a8efa259fc536cf300de32
2017-07-28 21:26:10 +00:00
Harald Welte aa3ba46e0f gsmtap: Add value_strings for GSMTAP_TYPE and GSMTAP_CHANNEL
Change-Id: Iaf8a99912f42a56ef785a1642e18238c0b67cf68
2017-07-13 00:03:29 +02:00
Harald Welte 93713a55b9 gsmtap_util: Add chantype_gsmtap2rsl() as inverse of chantype_rsl2gsmtap()
Change-Id: Ie1bc00670887064da0fea61c3dab036c23ceea25
2017-07-13 00:03:27 +02: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
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 95871dadbd use osmo_{htonl,htons,ntohl,ntohs}() functions all over libosmocore
This gets us one step closer to fixing the embedded build

Change-Id: I3fc2639b6ade9ab138766987eceab7ec9498fdc7
2017-05-15 13:42:03 +02:00
Max edc8db21fa Remove direct logging
Drop perror() calls from GSMTAP code: it's application job to do the
proper logging - library code should not write to stdout/stderr
directly.

Change-Id: Ifa149e65d76c6e64fda2946725c16672233aff2e
2017-01-06 10:12:24 +00:00
Harald Welte 9d862c8998 Fix unchecked return valueof osmo_fd_register()
Change-Id: Ib040a7f94eb1bbec8270b66fd4c2aedef9d5346a
Fixes: Coverity CID 57636
2016-11-26 00:10:07 +01:00
Harald Welte 2d2e2cca0d Update doxygen annotations in libosmocore
This adds and improves doxygen API descriptions all over libosmocore,
reducing the 'white spots' that don't have any documentation.
2016-05-05 18:49:27 +02:00
Katerina Barone-Adesi c28c6a02d2 misc: Doxygen tweaks: fixed some typos and minor errors
Doxygen generates quite a lot of warnings on libosmocore. Some of them
are obvious typos - this patch aims to fix such low-hanging fruit.
2013-02-15 13:27:59 +01:00
Harald Welte de6e4983e7 add some missing doxygen annotation for libosmocore functions 2013-01-11 09:43:32 +01:00
Sylvain Munaut abf66e75cb gsmtap: Fix doxygen doc for the recent additions
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-09-26 13:23:19 +02:00
Sylvain Munaut 15ae715b0d gsmtap: Add a _ex version of gsmtap_{makemsg,send} to specify content type
From: iZsh <izsh@fail0verflow.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-09-26 13:05:07 +02:00
Harald Welte 47379ca95b doxygen: Add documentation for gsmtap_util.[ch] 2011-08-17 17:14:12 +02:00
Pablo Neira Ayuso 0849c9af2a socket: add OSMO_SOCK_F_[CONNECT|BIND|NON_BLOCK] flags
This extends the socket infrastructure in libosmocore to allow
to create non-blocking sockets.

Basically, it replaces the connect0_bind1 parameter by one
flags parameter.
2011-06-13 19:15:59 +02:00
Sylvain Munaut 3710e462f8 gsmtap_util: Remove msg_free from the wq call back
write_queue already frees the message after the callback is called.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-05-29 19:48:15 +02:00
Harald Welte 13692a6bd3 gsmtap: deal with apps that call gsmtap_send*() with NULL gsmtap_inst 2011-05-22 20:06:11 +02:00
Harald Welte e476442cf0 GSMTAP/socket code: Check for sys/socket.h and conditionally compile 2011-05-22 12:25:57 +02:00
Harald Welte 33cb71ac91 gsmtap: rework GSMTAP API to be more future-proof
* use write_queue where applicable
* provide functions that work on raw FD and those with osmo_fd
* add support for multiple gsmtap instances (no global variables)
2011-05-22 11:43:23 +02:00
Pablo Neira Ayuso f7f89d0cfe select: use namespace prefix osmo_fd* and osmo_select*
Summary of changes:

s/struct bsc_fd/struct osmo_fd/g
s/bsc_register_fd/osmo_fd_register/g
s/bsc_unregister_fd/osmo_fd_unregister/g
s/bsc_select_main/osmo_select_main/g
2011-05-07 13:00:51 +02:00
Harald Welte d58ba465f1 GSMTAP: add function to create a 'sink' for gsmtap packets
This can be helpful where we send GSMTAP messages to the loopback
device (localhost, 127.0.0.1) from where the kernel would then
send ICMP reject packets as nobody is listening on that port.
2011-05-04 11:09:21 +02:00
Pablo Neira Ayuso 8341934844 include: reorganize headers file to include/osmocom/[gsm|core]
This patch moves all GSM-specific definitions to include/osmocom/gsm.
Moreover, the headers in include/osmocore/ have been moved to
include/osmocom/core.

This has been proposed by Harald Welte and Sylvain Munaunt.

Tested with `make distcheck'.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-03-23 18:09:28 +01:00
Harald Welte e34a940542 [gsmtap] add new gsmtap_makemsg() function
This generates a gsmtap message without actually enqueueing to a
bsc_select style queue.
2010-06-29 22:31:21 +02:00
Harald Welte e779c364ac Add gsmtap utility functions to libosmocore
This is imported from OsmocomBB/Layer23
2010-06-29 21:57:25 +02:00