Commit Graph

16 Commits

Author SHA1 Message Date
Oliver Smith 04bfb7165b treewide: remove FSF address
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-14 12:44:03 +01:00
Pau Espin 74dddefcc7 logging: gsmtap: Store TID instead of PID in pkt hdr
This allows differentiating threads withing an application, while still
keeping same numbering for single-threaded application (since first
thread ID is always the same as the process group ID).

Related: OS#5027
Change-Id: I33da02524fc064e133b2b762af7060139c4cfd81
2021-02-17 18:55:46 +01:00
Pau Espin 2f765f02af logging: gsmtap: Fix fill PID field not stored in network byte order
Recent commit filling this field forgot to convert it to network byte
order.

Related: OS#5027
Fixes: bb149ecda2
Change-Id: I50857f35cb28138fa6f28100afeaa00f492f303a
2021-02-17 18:51:25 +01:00
Pau Espin bb149ecda2 logging: gsmtap: Fill PID field for each message
It was recently discovered that PID field in gsmtap log messages was
always set to 0. Before this patch, the field was never being set.

The approach of this patch is to record the PID of process one, in
order to avoid calling getpid() syscall on each
log line to be sent. The counterpart of this optimization is that
eventual fork() calls would still keep the old incorrect value, but I
think nobody can safely assume that fork() is possible once all this
kind of infrastructure has already been configured (fork() should only
be done really at the start of the program before any osmocom foo is
initialized, or to immediatelly call exec()).

Related: OS#5027
Change-Id: I7db00d1810f0860166bffa0bda8566caa82e06a9
2021-02-16 17:24:48 +01:00
Vadim Yanitskiy ccf7c7c887 logging_gsmtap.c: document all params of log_target_create_gsmtap()
Change-Id: Id7bd6b4fb4be571af351f77aa4a59b9e1076434f
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy 785ecc9e50 logging/gsmtap: fix buffer overflow in _gsmtap_raw_output()
According to the man page, vsnprintf() returns:

  - a negative value in case of error;
  - the number of characters written (excluding '\0');
  - the number of characters which *would have been written*
    if enough space had been available (excluding '\0').

We need to detect if the output was truncated, and properly
limit the amount of bytes to be reserved within a msgb.

Change-Id: Ifa822edf900ed925ba935c54a28c797c4657358a
2018-12-28 23:58:07 +01:00
Neels Hofmeyr 4a8a9f4210 memleak: _gsmtap_raw_output(): free msg in case of vsnprintf failure
Don't just return, free the allocated msg first.

Change-Id: I51431ae7baca33ce5bab085cc3efe25f1a10b6d1
2018-02-16 01:35:08 +01: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
Max 18c014de67 utils: add helper wrapper for osmo_strlcpy()
Add wrapper for osmo_strlcpy() which uses sizeof() to automatically
determine buffer's size and use it for GSMTAP logging. This is pretty
common use case for osmo_strlcpy() so it's a good idea to save some
typing by using generic define.

Related: OS#2864
Change-Id: I03d0d3d32a8d572ad573d03c603e14cdc27a3f7b
2018-02-05 11:34:14 +00:00
Neels Hofmeyr bb62cbc099 logging-gsmtap: send only basename of source file
GSMTAP doesn't have a lot of space for the source file name. It is better to
send only the basename of the file, because only the first bit of a long path
may not convey the source file at all, needing guess work from the line number.

Before:  "Source File Name: ../../../../src/libosmocore/src"
After:   "Source File Name: telnet_interface.c"

Change-Id: Ie8fc9e782bcf8fa6e2e957d02e7d73c3a7c2bca8
2018-01-12 16:55:18 +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
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
Harald Welte aa00f99be2 Implement GSMTAP log target
This target wraps the to-be-logged string (With metadata) into a GSMTAP
packet and sends it to the configured destination address.

Change-Id: I9a7e72b8c9c6f6f2d76d1ea2332dcdee12394625
2016-12-09 17:59:58 +01:00