Commit Graph

1592 Commits

Author SHA1 Message Date
Harald Welte e6fb890b98 log_taget_find() should use enum log_target_type, not int
This has shown up in -Wsign-compare

Change-Id: I2f5ba81aa0328db7db29f49f26de4cea3f522789
2022-01-09 12:04:22 +01:00
Harald Welte 7d6166a0e3 utils: Fix -Wsign-compare warnings
Change-Id: I8b1118ca519b0a419a42eab8b7d4ba9e26a0bab5
2022-01-09 12:04:19 +01:00
Harald Welte c85aaed3fb bitvec: Fix -Wsign-compare warnings
Change-Id: I34f65cda83bcd7050bd0cc0fb9e5cb5d33a09086
2022-01-09 12:04:16 +01:00
Pau Espin 604eaba2c3 iuup: Submit RNL-STATUS-Initialization.ind upon rx of Init
This allows init-passive users to get the configured sizes for the RFCIs
and other similar information once engotiated with the peer.

Realted: OS#1937
Change-Id: I63ee780b4aa162ea097410b234e73984000c0965
2022-01-07 13:02:56 +00:00
Philipp Maier ec5b42c8ce stats_tcp: use a default batch size of 5 instead of 1
The configuration defaults for the socket statistics are currently set
to a batch size of 1. This means that only one socket per timer
expiration is scanned. This rate is probably a bit low. To speed things
up a bit we should set the default to 5. Scanning 5 sockets at a time is
still in the affordable range.

Change-Id: I87abc74c00377191f7940c5b8f19d932618fc019
Related: SYS#5701
2022-01-05 20:32:07 +00:00
Sylvain Munaut d5974e9155 conv: Fix the traceback for tail biting codes
When picking the end state, looking only at the path metric
is highly suboptimal because in a tail biting code, we _know_ that
whatever treillis path is correct, it must start and end at the same
state. So we only consider path meeting that condition. We know any
path that doesn't isn't the right one. We only fallback to only
path metric if no path met that condition.

Fixes OS#4508

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: I87e51d3880c0fe7bf3d6cd08fd46517a424a230c
2022-01-05 20:24:49 +00:00
Vadim Yanitskiy 2f4186a3d2 VTY: implement 'no log gsmtap [HOSTNAME]' command
Change-Id: I9a4efa1e35cbc22cea06a64a15a369522c32d3c4
2022-01-05 09:51:34 +00:00
Philipp Maier b1ef8f5f69 select: gather statistics for TCP connections
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-23 14:52:15 +00:00
Harald Welte 9fe1f9fb0b Introduce CRC and FSM for IuUP (user plane) as used in 3G RTP data
Only support for SMpSDU mode is introduced in this commit.

Not supported explicit list:
- Transparent mode
- ATM/AAL2 based Transport layer
- GTP-U based Transport Layer
- Iu Rate Control procedure
- Time Alignment procedure

APIs are provided to allocate the primitives properly inside the related
msgb. This way primitives can be placed in the headroom, leaving the
data part of the msgb for the IuUP payload, hence allowing re-use of the
msgb and 0 copy of IuUP payload when forwarding data over RNL<->TNL.
Since RNL and TNL primitives relu struct osmo_prim_header, which is not
packed, they cannot be set to packed, and hence proper memory alignment
in the msgb must be done to avoid misaligned accesses (Asan errors about
it otherwise).

Related: SYS#5516
Change-Id: Ibe356fa7b1abaca0091e368db8478e79c09c6cb0
2021-12-22 14:58:31 +01:00
Pau Espin 28c438845f include/: Adapt some headers to match contrib/struct_endianess.py format
This way the related files are not changed when running the script to
generate struct fields for big endian systems.

Change-Id: I830e0961331a73f8dceb1a5a1c879798541752fd
2021-12-22 13:57:48 +01:00
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
Eric Wild 63e1b2b024 logging: make LIBOSMOCORE_NO_LOGGING work as expected
The macro introduced in d02090bba5 was not
enough: the actual logging macros are being used, i.e. by the fsm, so
wrap those as well, and provide a flag to disable this at build time.

Change-Id: Ia4c78abe5f198139f96ffa289998855be2477585
2021-12-09 15:25:53 +00:00
Eric Wild d02090bba5 logging: allow disabling macros using a new define: LIBOSMOCORE_NO_LOGGING
This was previously unconditionally defined, so embedded targets were
unable to get rid of the log macros and functions.

Change-Id: I589f93d98a6bc5cf6221c56e2fe3f27bfdd200e8
2021-11-26 09:23:24 +00:00
Harald Welte 9e34f08d0b gsmtap: Add gsmtap_sendmsg_free() as alternative to gsmtap_sendmsg()
gsmtap_sendmsg() places the burden of freeing the msgb in case of
erroneous return codes on the caller.  A review of existing users
shows that this is overly optimistic and many calls get it wrong,
opening up memory leaks.

Let's add a new function gsmtap_sendmsg_free() which behaves like
gsmtap_sendmsg() but always takes ownership: Either it is sent + freed,
or it is just freed.

Change-Id: I106b09f2a49bf24ce0e8d11fd4d4ee93e9cafdf5
Related: OS#5329
2021-11-25 15:52:26 +01:00
Neels Hofmeyr 25c9741445 add osmo_time_cc, moved from osmo-bsc
Related: SYS#4878
Related: Ica9f908a1a30f334a24c59471affa11225117e12 (osmo-bsc)
Change-Id: Iabb17a08e6e1a86f168cdb008fba05ecd4776bdd
2021-11-15 09:06:03 +00:00
Alexander Couzens 6b5a533f4d include: add enum for UTRAN cipher
Change-Id: I4b9baff2c2fbd0e339fc769cc69cce58d3a72cdf
2021-11-11 09:02:24 +00:00
Vadim Yanitskiy bfc8377398 stats: allow configuring reporter's name in the VTY
This allows configuring more than one reporter of the given type.

Change-Id: Ia815c24dc974648985539913012b3b074ea317a9
Related: SYS#5713
2021-11-09 04:35:07 +03:00
Vadim Yanitskiy 190b6efafd gsm/protocol/gsm_04_08.h: add gsm48_meas_res_is_valid()
Change-Id: Iae2bd508a08c4b5093d36e514c22218763e11edf
2021-11-04 17:45:52 +03:00
Vadim Yanitskiy 36c69ed256 gsm/protocol/gsm_44_004.h: fix missing include of 'endian.h'
Without this header, both OSMO_IS_{BIG,LITTLE}_ENDIAN macros are
not defined, and thus the 'struct gsm_sacch_l1_hdr' is empty.

Change-Id: I2c14a1b898fdb743191dab0e6be157ce916e8161
2021-10-29 20:26:20 +03:00
Vadim Yanitskiy 7044d20863 Revert "Prevent GCR encoder/decoder functions from being used directly"
We need this API for communicating GCR over the MNCC and SIP.

Change-Id: I06babb959fdc82f4e82d92260131d60c98b0abd2
Related: OS#5164
2021-10-29 05:47:09 +00:00
Harald Welte b72867f0e6 logging: Change stderr + file target to use non-blocking write
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-26 17:16:47 +02:00
Vadim Yanitskiy 8db64ee810 gsm_08_58: extend struct abis_rsl_osmo_temp_ovp_acch_cap
This change adds new [bit-]fields in order to allow:

  * selectively enabling SACCH and/or FACCH,
  * setting the RxQual (BER) threshold.

Change-Id: Ia28293a12de0af71f55e701fb65c46e905dae217
Related: SYS#5319
2021-10-21 21:11:28 +03:00
Pau Espin 0a9430ee48 {ctrl,vty}/ports.h: Allocate ports for osmo-hnodeb
Change-Id: I6514d040d88d145a321075911368645868e6280e
2021-10-21 12:53:33 +02:00
Vadim Yanitskiy c549719088 utils: introduce osmo_talloc_replace_string_fmt()
Change-Id: I6b84fa0525555a98c531fc558e5dc1298fec00c1
2021-10-13 14:03:26 +03:00
Neels Hofmeyr 137efc9b18 cosmetic: get rid of 3 deprecation warnings
Some deprecated functions are still used in libosmocore .c code. Use
OSMO_DEPRECATED_OUTSIDE() to get rid of those "resident warnings".

Change-Id: I6e79acc87be37ac1aaec900e737e41450b46826a
2021-09-30 18:33:43 +00:00
Neels Hofmeyr e90c7176be refactor stat_item: get rid of FIFO and "skipped" error
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-30 18:33:43 +00:00
Keith Whyte 3f43134b6b GPRS: Add PDP_TYPE_N_IETF_IPv4v6
Change-Id: I1f82f9d8fc13dcc4474760329bd74ae9685b9031
2021-09-29 21:05:20 +02:00
Pau Espin 4e3b594e93 cosmetic: gsm: meas_rep.h: Fix typo in comment
Change-Id: I35c47a69ad1e9a75de6cc82c44a87828ebbb7189
2021-09-28 11:32:44 +02:00
Pau Espin 50e6f06658 gsm: Mark gsm0858_rsl_ul_meas_enc() pointer param const
Change-Id: I9b2704250d8a3f6c6fc6cd2a5136b1408c8ed965
2021-09-28 11:32:00 +02:00
Alexander Couzens 06929166de vty: add vty_out_uptime() print the uptime to the vty
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-23 13:12:34 +02:00
Harald Welte d075e3ae23 base64: reformat using Lindent to conform to our coding style
Change-Id: I2286fa0d2cba7c11359bb48329135dfcd0d8a948
2021-09-21 19:57:56 +00:00
Harald Welte 292f9e7014 base64: Migrate over to osmocom
This containts the osmocom changes to the mbedtls base64 code
merged in the previous commit.

Change-Id: I82c1bf5f827c8def370dbcb80b146e9e4184c4a3
2021-09-21 19:57:56 +00:00
Harald Welte c757239fd3 copy base64 implementation from mbedtls
Using mbedtls commit f9c599cd8ac9d00c484d4f5b027e18c6af4f9fdf before
they re-licensed to Apache 2.0, so we have a GPL-v2-or-later bsae64
implementation and avoid having code under a different license in the
tree.

This code is the unmodified import, so we can record any local changes
compared to the original version.

Change-Id: I39a9d3ab98257d21b9439b00528c744efa372c14
2021-09-21 19:57:56 +00:00
Neels Hofmeyr 049fd5ccc0 stat_item: cosmetic: s/desc/group_desc in osmo_stat_item_group_alloc()
There also is an osmo_stat_item_desc, so the name 'desc' makes it hard
to read the code / the upcoming refactoring patches. It is an
osmo_stat_item_group_desc, so call it group_desc.

Related: SYS#5542
Change-Id: I07bc011450549a44ebf043e7d8a70718ddfd900e
2021-09-20 13:04:54 +00:00
Neels Hofmeyr 7fcfefbcf7 add osmo_stat_item_get_group_by_name_idxname()
Add "missing" API for looking up a stat_item_group by its index-name.
A subsequent patch, which adds stat_items to the CTRL interface, will
use this to look up stat item groups by object name.

In stat item groups, there are group names, having a number of indexes
denoting different objects. An object can have, besides the index, also
a name that is equivalent to the index.

Apologies for the weird function name, it's still the best one I
could come up with: "group_by_name" refers to the group name, and
"idxname" refers to the name that the object index is associated with.

We already have osmo_stat_item_get_group_by_name_idx().
Other contestants for name of this new function were:

- osmo_stat_item_get_group_by_name_name()
  because there is a "name" instead of "idx", but I find it confusing.

- osmo_stat_item_get_group_by_name_idx_name()
  but I find that the last "name" should be closer to the "idx".

Related: SYS#5542
Change-Id: Ia1a77a1e4657ba624dd4f4bf7ad274e7751d0141
2021-09-14 10:28:02 +02:00
Neels Hofmeyr 47773344fb utils: add osmo_str_to_int() and osmo_str_to_int64()
Properly converting a string to an integer while validating against all
possible errors is not trivial. It is a recurring theme in code review,
and there are places in osmo code that do it wrong.
End this by providing a simple API, if for nothing else then as an
example of how to use strol() / strtoul() / strtoll() / strtoull()
in an airtight way.

A subsequent patch, adding stat items to the CTRL interface, uses this
to properly validate indexes in CTRL variables and convert them to int.

Related: SYS#5542
Change-Id: I4dac826aab00bc1780a5258b6b55d34ce7d50c60
2021-09-12 21:24:50 +02:00
Eric Wild 11a58a1b34 vty: allow flushing
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-09-10 14:50:26 +02:00
Pau Espin 51933840ff gsm_08_58.h: Extend IPA Power Control Params IEs to pass C/I params
This commit adds new Osmocom specific IEs required to pass C/I related
Power Control Parameters osmo-bsc => osmo-bts to be used by the MS Power
Control Loop being implemented.

Related: SYS#4917
Change-Id: Iffef0611430ad6c90606149c398d80158633bbca
2021-09-03 15:32:50 +00:00
Philipp Maier e67edfdec2 gsm_08_58: fix sourcecode formatting
Change-Id: Ia58c25441911d6f872a8ec5664c71e56ad895f97
2021-08-31 19:54:28 +00:00
Philipp Maier 55ce87da69 gsm_08_58: fix sourcecode formatting
struct abis_rsl_osmo_rep_acch_cap has an indentation level that is too
deep.

Change-Id: Ie15feac75d1aa4fe5e5e237b14119addf09e5d77
2021-08-31 19:54:28 +00:00
Philipp Maier 58f76d8b90 bts_features: Add new feature to indicate support for temporary overpower
To indicate to the BSC that a BTS supports temporary overpower of
SACCH/FACCH channels a new feature BTS_FEAT_ACCH_TOP is added.

Change-Id: I62fbfc30acd5d67b20727b75a8f256e6b5d31e06
Related: SYS#5319
2021-08-31 19:54:28 +00:00
Philipp Maier 0e44a7203c rsl: add new RSL IE to signal temporary overpower
To transfer the temporary overpower value from the BSC to the BTS, a new
RSL IE (RSL_IE_OSMO_TOP_ACCH_CAP) is added.

Change-Id: I31c5be4bceb9140d63ab8e2f197f0acc68699426
Related: SYS#5319
2021-08-31 19:54:28 +00:00
Pau Espin 9da16b5bbc cosmetic: Fix missing space in comment
Change-Id: If0940a2e1c66c3498f5e3d6ac641029290955175
2021-08-26 15:25:16 +02:00
Philipp Maier 2bd4bc94f6 codec: add missing osmo_amr_type_name function.
We have value strings for osmo_amr_type, but we do not have a function
that returns us the strings.

Change-Id: I694f56b032537440db6264df5e6a6aa3a2992175
2021-08-23 15:44:00 +02:00
Oliver Smith 11da4a4abd stats: send real last value if no new values come
Background:
* Individual values can be added to osmo_stat_item.values at any time.
* Stats are reported at a fixed interval (see vty 'stats interval'),
  e.g. every 10 seconds.
* In order to report a new stat value, we use the maximum of all
  osmo_stat_item.values added since the last report.
* By default, we do not send new stat values if they did not change
  (see vty 'config-stats' -> 'flush-period' default of 0).

Fix the following bug:
* If 'flush-period' is 0, and no new osmo_stat_item.values are coming
  in, the last value that gets reported is not necessarily the last
  entry in osmo_stat_item.values.
* For attached reporters (statsd), it could then be that the given stat
  stays at the wrong value for a long stretch of time (think of several
  hours/days/forever).

Explanation of how the test shows that it is fixed:
* stats get reported (value is irrelevant)
* osmo_stat_item gets a new value: 20
* osmo_stat_item gets a new value: 10
* stats get reported (value: 20, the maximum of both new values)
* osmo_stat_item gets no new values
* stats get reported (value: 10, this is new because of the bug fix,
  the real last value in osmo_stat_item, different from the 20 sent
  earlier, without the fix it would not send anything here and the last
  sent value would be 20)
* osmo_stat_item gets no new values
* stats get reported (nothing gets sent, since the real last value was
  already sent and 'flush-period' is 0)

Fixes: OS#5215
Change-Id: Ibeefd0e3d1dbe4be454ff05a21df4848b2abfabe
2021-08-20 14:04:54 +00:00
Oliver Smith 6a138891da vty/ports: move pcap server/client ports
Resolve conflict with other Osmocom software by moving ports:

osmo-pcap-client 4237 -> 4227
osmo-pcap-server 4238 -> 4228

Remove wrong previous comments that claimed 4240 and 4241 were used.

Related: OS#5203
Related: osmo-pcap I3b18b1fbbca2799f868f28104e2f5d513f93d46c
Change-Id: I098f211370bba61995ce424ab64029bdd4c49e2d
2021-08-06 16:13:34 +02:00
Oliver Smith d8f8919a58 vty/ports: prepare formatting for a long define
Add one more tab between the define and the port number, to prepare for
longer defines in the next patch.

Related: OS#5203
Change-Id: I46655e33651814f41a1fea93406a83334d2fc529
2021-08-06 16:11:16 +02:00
Pau Espin 7af860fb78 utils: Fix c++ warn in OSMO_STRBUF_APPEND
It's really a false positive since _sb_l is compared and granted to be
psotivie by the time we compare, so we don't really care, but c++ is not
happy about it.

"""
/osmocom/core/utils.h:227:40: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
  227 |                 if (_sb_l < 0 || _sb_l > _sb_remain) \
      |                                  ~~~~~~^~~~~~~~~~~~
"""

Change-Id: I90e7374aa959468670f1c0ea65a427398d423ddb
2021-07-28 20:14:14 +00:00
Philipp Maier 466be65176 command: fix sourcecode formatting
Change-Id: Icc75c3b45821c24360e0fdb4a29077994e73ae05
2021-07-27 07:34:32 +00:00
Philipp Maier ff84de7e18 linuxlist: add macro to get last element of a list
It is not be obvious on the first look that ->prev actually points to the last
element of a list, lets add a macro for that to make the API easier to use

Change-Id: Icf455bf6ba9d60bd311af17c9e80febaa42cacc9
Related: SYS#4971
2021-07-07 16:53:47 +02:00