Commit Graph

4525 Commits

Author SHA1 Message Date
Neels Hofmeyr ddf2d59a62 add utils/osmo-gsm-shark
Change-Id: Ifdfd261f776d9bf2bbfb0a584deac3e9a11bfe47
2023-04-15 00:06:13 +02:00
Neels Hofmeyr 46d1b84c3f add osmo_sockaddr_str_from_128()
Change-Id: Id67f419ad41f614202912500c96d82b6ff873a6a
2023-04-15 00:06:12 +02:00
Neels Hofmeyr f3917b177c logging: add timestamp fmt 'date' = 2018-01-16,01:44:34.681
Add 'date' to 'logging print timestamp (none|date|date-packed|ctime)'

The idea is to have these date formats:

 date         2018-01-16,01:44:34.681  (new, "best" format)
 date-packed  20180116014434681        (current 'print extended-timestamp 1')
 ctime        Sun Jan 1 01:44:34 2018  (current 'timestamp 1')

Rationale: when reading log files, it can be important to see
milliseconds precision on the timestamps. But the current
extended-timestamp format lacks all separators, reading these manually
is a pain. My eyes aren't good at counting digits, I keep getting the
minutes, seconds and millis wrong and waste my time on every glance. So
provide a new detailed timestamp format that is easier to read.

Change-Id: Icbd5192ea835e24b12fe057cc1ab56e9572d75c0
2023-04-15 00:06:12 +02:00
Neels Hofmeyr 3fccef3f23 logging vty: add 'logging print timestamp', deprecate other timestamp cmds
Deprecate previous logging timestamp config commands:

  logging timestamp (0|1)
  logging print extended-timestamp (0|1)

Add new single timestamp configuration command:

  logging print timestamp (none|date-packed|ctime)

Another format called 'date' is added in patch
Icbd5192ea835e24b12fe057cc1ab56e9572d75c0. The idea is to have these
date formats:

 date         2018-01-16,01:44:34.681  (new, "best" format)
 date-packed  20180116014434681        (current 'print extended-timestamp 1')
 ctime        Sun Jan 1 01:44:34 2018  (current 'timestamp 1')

Change-Id: I58c792dda3cbcf8618648ba4429c27fa398a9e15
2023-04-15 00:06:12 +02:00
Neels Hofmeyr 5eb08878cf logging: use enum to set timestamp format
In preparation of adding a new timestamp format, refactor to use an enum to
pick the timestamp style.

Introduce log_set_print_timestamp2() to be able to pass an enum value directly
(for future additions). Deprecate previous API of
log_set_print_timestamp() and log_set_print_extended_timestamp().

Remove the old members of struct log_target members:
- print_timestamp and
- print_ext_timestamp (bool flags),
instead add member
- timestamp_format (enum).
This is an API and ABI incompatibility. (An original patch version
preserved the unused struct members, but code review suggested it makes
more sense to drop them.)

The old API functions log_set_print_timestamp() and
log_set_print_extended_timestamp() still work, but setting
log_set_print_*timestamp(0) changes its behavior: now passing zero to
either of these functions sets LOG_TIMESTAMP_NONE, so it now always
switches off all timestamps, instead of previously maybe going back to
another timestamp depending on the other flag being set or not.

Change-Id: I70ecee543c266df54191d3e86401466cd1a5c0a6
2023-04-15 00:06:12 +02:00
Neels Hofmeyr bd5cda0f83 logging_vty.c: rename static function
Rename 'logging_prnt_timestamp_cmd' to
  logging_timestamp_cmd
to better match its VTY name:
 'logging timestamp (0|1)'

(An actual 'logging print timestamp' command will be added in subsequent
patch I58c792dda3cbcf8618648ba4429c27fa398a9e15, so clarify.)

Change-Id: I5a651e393bd438ea236659ed2c86188a8f9885d1
2023-04-15 00:06:12 +02:00
Neels Hofmeyr 7b342679aa logging: test timestamp formats
Show what timestamp formats we currently feature.
Upcoming patch Icbd5192ea835e24b12fe057cc1ab56e9572d75c0 adds a new
timestamp format.

Change-Id: If3dbf3006a454d4e8a5c758e5c884e12c8bb1fc1
2023-04-15 00:06:12 +02:00
Neels Hofmeyr 8b3ab6f9dc logging: add 'logging timezone (localtime|utc)'
Add ability to print logging timestamps in UTC.

I want to test logging timestamps in vty transcript tests. To get
deterministic timestamps, I can use osmo_gettimeofday_override().
However, so far we log in the server's local time zone: the dates
printed after osmo_gettimeofday_override() still change according to the
locally configured timezone -- not good for regression testing. For UTC,
it is always the same.

The intended use is for regression testing of timestamps, but maybe
logging in UTC may be useful to some user out there, too.

Change-Id: I7f868b47bf8f8dfcf85e735f490ae69b18111af4
2023-04-15 00:06:12 +02:00
Neels Hofmeyr 55d68e0136 logging vty: probe 'print' and 'logging timestamp' cmds
Upcoming patch I58c792dda3cbcf8618648ba4429c27fa398a9e15 aims to change
the timestamp configuration. Show current state before these changes.

Change-Id: I8e0a373496130004e453a2044c1091665fe02a05
2023-04-15 00:06:12 +02:00
Pau Espin 5e79a302d5 gsm_04_08_gprs.h: Add missing GMM IEs for T3302 and T3346
As specified in TS 24.008 9.4.4 "Attach reject"

Change-Id: I2d36d76ee6fe8ed1a36e37a7d74fbbdc9c27c2c7
2023-04-13 13:46:34 +02:00
Max 028813414c logging: print talloc report on exit from vty test
There's not much point in deallocating memory in a test fixture
which is about to terminate anyway. Having talloc report though
is handy to make sure we're not leaking smth.

Change-Id: I5739bceb90d36164fd4cbf21242bbe26bd1e7075
2023-04-05 10:41:48 +00:00
Vadim Yanitskiy 37dc995234 core: remove unnecessary #include <osmocom/core/talloc.h>
Including this header just for TALLOC_CTX is an overkill, we use
'void *' for talloc contexts in nearly all other Osmocom projects.

Change-Id: I4b9ffd7a329081df3d2c0b0ee8698a3cf759e94e
Related: OS#5960
2023-03-31 05:39:24 +07:00
Vadim Yanitskiy 48c60f9771 fixup (partial revert): "coding: clean up Makefile.am"
This is a partial revert of "9dca9027 coding: clean up Makefile.am".

Even though libosmocoding does not use talloc API, it still depends on
this library indirectly via libosmo{core,codec,gsm}.  Furthermore, some
of libosmocore's header files do #include <osmocom/core/talloc.h>, and
thus #include <talloc.h> via this internal header.

Under Slackware 14.2 talloc.h header lives in /usr/include/samba-4.0,
and without $(TALLOC_CFLAGS) compilation of libmsocoding fails due
to the preprocessor failing to find this header.  The culprit is my
recent patch 9dca9027 removing $(TALLOC_CFLAGS) and $(TALLOC_LIBS).

Put $(TALLOC_CFLAGS) back to AM_CFLAGS;  it will likely be emply under
distributions having talloc.h header in the standard include dir.  The
$(TALLOC_LIBS) does not need to be resurrected because libtool will
add '-ltalloc' automatically for each libosmo*.la in LIBADD.

Change-Id: Ic1bd82159a827af21fe36bea998f8f58f732473a
Related: OS#5960
2023-03-31 05:10:52 +07:00
Vadim Yanitskiy 89a3fc95af tests: make VTY tests depend on the respective binaries
Change-Id: I784fe3b5737b804f7b55da01d8beb619c57bafd6
2023-03-30 12:32:53 +00:00
Pau Espin ec7d5029ef gsm: Add missing TS 24.008 SM layer IEs
Change-Id: Iec0dbf617c8d0f2c8c44156d936244cedda9b303
2023-03-28 18:22:09 +02:00
Mychaela N. Falconia 7f91880534 codec: add osmo_efr_check_sid() function
Previously existing code provides osmo_fr_check_sid() and
osmo_hr_check_sid() functions for FR1 and HR1 codecs; these functions
are used by various RTP-touching programs in the Osmocom CNI suite
when they need to differentiate between speech and SID frames.
However, there was no corresponding function of this form for EFR
codec, with the result being that the same programs that handle
speech vs SID distinction correctly for FR1 and HR1 fail to do so
for EFR.

The present change adds an osmo_efr_check_sid() function to libosmocodec
that fully mirrors previously existing osmo_fr_check_sid() and
osmo_hr_check_sid(), providing the first step toward more correct
EFR handling in programs where a SID check may be needed.

Change-Id: Iab9fb60028f4135375287bc42f5da7ca7838b5f0
2023-03-25 08:04:04 +00:00
Harald Welte 8969298a77 rate_ctr: Add rate_ctr_add2() similar to rate_ctr_inc2()
The convenience wrapper relieves the caller from manually resolving
the individual counter, and instead specify just the counter group
and the index.

Change-Id: If93e8b4fb0b86a87358f32d2b45438ca1887e9f3
2023-03-24 14:08:08 +01:00
Harald Welte 5e3aaf9f0d gsmtap.h: Define a packet type for encapsulation of GSM RLP frames
This allows us to feed RLP frames (occurring in GSM CSD) into wireshark
for dissection.

Change-Id: Ibb7f0731c31e5a5cd2911f733da5510ce0f3a1d6
2023-03-24 13:07:58 +00:00
Vadim Yanitskiy c57cc4bf64 gsm0808: handle new enum gsm48_chan_mode speech/data values
Change-Id: I87d977228b1e039c2876941d1c6df1f69d1a54d4
Related: OS#1572
2023-03-23 18:38:11 +07:00
Vadim Yanitskiy 173c84c52e gsm_04_08: add more enum gsm48_chan_mode data values
From 3GPP TS 44.018 (version 15.4.0), table 10.5.2.6.1.

Change-Id: Ia6b428e5b6aaecf151cbfa980b89eff6d0fe6006
Related: OS#1572
2023-03-23 18:38:11 +07:00
Vadim Yanitskiy 1c88ff9ba5 gsm_04_08: add more enum gsm48_chan_mode speech values
From 3GPP TS 44.018 (version 15.4.0), table 10.5.2.6.1.

Change-Id: I6adda28698c0e479ef20f5d090c1f7f76a2ec97e
Related: OS#1572
2023-03-23 18:38:11 +07:00
Vadim Yanitskiy 8c7f023784 gsm_04_08: document/clarify enum gsm48_chan_mode values
The values are defined in 3GPP TS 44.018, section 10.5.2.6.  Only the
radio interface rates for CSD (GSM48_CMODE_DATA_*) are given, but the
respective service rates can be found in 3GPP TS 45.003.

Change-Id: I716027f73ab6f20037f6de16e4a3740811aa38a2
Related: OS#1572
2023-03-23 18:38:11 +07:00
Pau Espin 559a6ee683 Fix parsing of TLV_TYPE_SINGLE_TV
The decoding path of TLV_TYPE_SINGLE_TV is wrong, since it is not
shifting right the tag before using it. On the other hand, the encoding
path (tlv_encode_one) is doing that, so it is clear there's a bug.

It seems that in order to workaround the bug some IEs in gsm_04_08.h (TS
24.008 and TS 44.018) were defined incorrectly (eg 0x80) while the spec
clearly assigns eg. "8" to it, and makes sure no full byte IEI collides.
Some other IEIs like GSM48_IE_GMM_CIPH_CKSN which are also of the same
type were already correctly defined as 0x08.

Change-Id: I799e35dc8d4d153fa63bf50563a5482cdf4de2d7
2023-03-22 14:23:51 +01:00
Vadim Yanitskiy 25127fb749 isdn: fix identical operands in v110_adapt_IR8000_to_2400()
Change-Id: I7df8b214e813cbd14726d5043f666547353e2947
Fixes: CID#310966
2023-03-17 17:08:23 +07:00
Vadim Yanitskiy 8f6d2f349c tests/v110: assert(user_data_chunk_bits) in test_ra1()
Coverity warns that osmo_v110_sync_ra1_get_user_data_chunk_bitlen() may
return a negative value, which is used as loop boundary.  Even though
this is unlikely, let's add an assert().

Change-Id: I0fc0e0bac74bd96351030432ef1b140b727acb0d
Fixes: CID#310968
2023-03-17 16:35:53 +07:00
Vadim Yanitskiy 0a60e422a8 gsmtap: add missing entries to gsmtap_type_names[]
Change-Id: I67dc578c62f89039f35856da1f29caab4b5db1d8
Fixes: fae779ac5 "GSMTAP: Import changes from Wireshark"
Fixes: f9b1e5556 "gsmtap.h: Introduce new GSMTAP type for LTE NAS messages"
Fixes: 161d42a61 "gsmtap: Add definitions for E1/T1 payload (LAPD, TRAU, FR) in GSMTAP"
2023-03-17 16:30:19 +07:00
Harald Welte b394d6fc85 New osmo-gsmtap-logsend utility
This utility can be used to "pipe" stdin or some file as log lines
via GSMTAP logging.

Change-Id: Ida96e87d84e0c349c5069edc67fec1c3cf19d1ab
2023-03-15 11:53:08 +00:00
Neels Hofmeyr 5761c44609 error log: osmo_sock_init2_multiaddr() v4/v6 mix
Provide some more information for the error case when local and remote
addresses mix v4 and v6.

Change-Id: I0fd12b08e0788ce3af6dc519ff8c82ad196a115f
2023-03-14 20:15:05 +00:00
Neels Hofmeyr e1c4f24cb9 contrib/talloc_count.sh: improve hexadecimal masking
Also mask hexadecimal without leading 0x. But take care to not match on
every letter a-f,A-F in normal words and names.

before:

    10 map_rua(NffffNfNecN-example-com-RUA-N)[N]
    10 map_sccp(NffffNfNecN-example-com-SCCP-N)[N]
    17 map_rua(NffffNcN-example-com-RUA-N)[N]
    17 map_sccp(NffffNcN-example-com-SCCP-N)[N]
    18 map_rua(NffffNeNbN-example-com-RUA-N)[N]
    18 map_sccp(NffffNeNbN-example-com-SCCP-N)[N]
    82 map_rua(NffffNfNdN-example-com-RUA-N)[N]
    82 map_sccp(NffffNfNdN-example-com-SCCP-N)[N]
    85 map_rua(NffffNfN-example-com-RUA-N)[N]
    85 map_sccp(NffffNfN-example-com-SCCP-N)[N]
   224 struct hnbgw_context_map

after:

   224 map_rua(N-example-com-RUA-N)[N]
   224 map_sccp(N-example-com-SCCP-N)[N]
   224 struct hnbgw_context_map

Change-Id: I1b42ce3e67c7ed2d38d3e5c9cbfa90ba185a07b7
2023-03-14 20:12:57 +00:00
Neels Hofmeyr 141dffddf5 fix 'make vty-test' for --disable-external-tests --enable-gb
Change-Id: I80ac270bfb563a769a7746d8fbceac09e267ce03
2023-03-14 18:08:35 +00:00
Neels Hofmeyr 439ffc2a3e fix 'make vty-test' for --disable-gb
Change-Id: Ib6aec784d3b20cd56cb6bfab9ff17da35a282406
2023-03-14 18:08:35 +00:00
Oliver Smith b46cfba995 on_dso_load_select: run after on_dso_load_ctx
Add priorities to ensure on_dso_load_select runs after on_dso_load_ctx.
Otherwise osmo_ctx->global (used via define OTC_GLOBAL) points to NULL
and causes a segfault in osmo_fd_lookup_table_extend.

Use numbers 101 and 102, as "0 to 100 are reserved for the
implementation" and cause an error from GCC.

Fixes: OS#5946
Fixes: c46a15d8 ("select: Optimize osmo_fd_get_by_fd")
Change-Id: Ia2518e82530b93c535f8f5105513e21559b895ba
2023-03-14 15:22:20 +00:00
Pau Espin fc37650381 logging.c: Sanitize calls to osmo_fd_unregister()
It makes no sense to call osmo_fd_unregister() on a negative fd.
Let's also make sure we set fd to negative value after unregistering +
closing, even if the struct is going to be freed afterwards.

Change-Id: I0790a63e603028c11cc475d483c6528e4d9aa9ab
2023-03-14 14:32:54 +01:00
Pau Espin ff666997b2 tests/Makefile.am: Move LDADD to right position
LDADD var contains both local and system libraries. Use it at the right
place (after list of local libs, before list of system libs).

Change-Id: Ifb3686f78432ac877c596004646506c540b23c53
2023-03-14 14:20:21 +01:00
Pau Espin 34537d4de8 tests/Makefile.am: Drop duplicated libosmogb.la in LDADD
Change-Id: I20e815ba5dc473c644e1098f2347b183f215a51a
2023-03-14 14:13:07 +01:00
Pau Espin 6020d139eb tests/Makefile.am: Move system libs at the end of list
Change-Id: Iad6b9e39e3587849ccfd475899cbd610bf7145cd
2023-03-14 14:09:43 +01:00
Pau Espin 6fd7f41672 select.c: osmo_fd_unregister(): Avoid assert hit with old buggy users of the API
Change-Id: If77b84d603a42a216d550d9708eb62f645634a61
2023-03-14 13:13:47 +01:00
Pau Espin 3b450f0233 configure.ac: Fix typo in enable flag description
Change-Id: Ida390c50379a429a4b42434e32954eeb832a11ff
2023-03-14 13:13:40 +01:00
Pau Espin 5ef158fbbb configure.ac: Fix logic enabling osmo_fd fd checks
The logic testing the and setting the define was inverted, which made it
enabled by default.

Take the chance to rename the enable flag to be "ofd" instead of
"bsc-fd" (since anyway the flag was broken).

Change-Id: I81112fa1f6ce1a8e5fe85468241ad385ed8805d3
2023-03-14 13:13:40 +01:00
Pau Espin 25729cf531 select.c: Clarify osmo_fd_unregister() can only be called on registered osmo_fds
Change-Id: I5e397e121f2fe2254c7f4b474e6eefd7aebe7a83
2023-03-14 12:26:37 +01:00
Pau Espin 153519f5fb select.c: Clarify osmo_fd_(un)register() API expectations of registered fd
Those restrictions were implicitly required for a while and most of the
users of this API already followed them, but just a few didn't. All
known users have now been fixed. Let's explicitly document the
restrictions imposed by the API to ease avoiding similar issues in the
future.

Change-Id: I53d95aad15b33dd66aa5c7dd11745a35c4481f33
2023-03-14 12:01:45 +01:00
Pau Espin c46a15d876 select: Optimize osmo_fd_get_by_fd
Optimize osmo_fd_get_by_fd() from O(n) to O(k) by means of allocating
dynamically growing array.

Make use from the fact that the kernel always tries to use the smallest
 possible unused value when allocating a new fd.

Change-Id: I8b71547df8bed84192cb160479fa3debf9b7eade
2023-03-13 15:26:21 +00:00
Vadim Yanitskiy b7bf36f81c utils/osmo-stat-dummy/Makefile.am: drop empty variables
Change-Id: I1b9497900b0eebd77fd226f52a9050cdbd9e6cdc
2023-03-11 06:49:47 +07:00
Vadim Yanitskiy a8e2e5f78a utils/Makefile.am: do not overwrite AM_CFLAGS
* $(TALLOC_CFLAGS) is already present in AM_CFLAGS,
* osmo-sim-test: do not redefine but append $(PCSC_CFLAGS).

Change-Id: I7b9af3a1a9493a432af89198e291f4523388751e
2023-03-11 06:45:06 +07:00
Vadim Yanitskiy 6160419b03 utils/Makefile.am: remove duplicate libosmogsm.la
It's already listed in $(LDADD), no need to append it again.

Change-Id: I03f5f4330e828a938dafd93b9fdb576afb2b7f12
2023-03-11 06:41:12 +07:00
Vadim Yanitskiy 9dca9027b7 coding: clean up Makefile.am
* Remove TALLOC_{CFLAGS,LIBS} - talloc is not used directly
* Keep conditional ENABLE_PSEUDOTALLOC for embedded builds

Change-Id: I18f0a65a47c37989f03928f99c4687bf8007d437
2023-03-11 06:31:50 +07:00
Pau Espin 040548f790 logging: Unregister osmo_fd before closing fd
Change-Id: I0754ac3110b63d2a380068010830af6c85b0a653
2023-03-10 13:41:17 +00:00
Pau Espin 8d1532af92 cosmetic: stats_tcp: Fix typo in comment
Take the chance to shorten a bit the lengthy lines

Change-Id: I3215dea7e3198b728745a779ad1b6ebfa3795cb5
2023-03-09 21:18:08 +00:00
Harald Welte a41bd22349 gsm_08_58: Document IPAC RTP CSD modes in at least a few words
Let's clarify what those modes mean

Change-Id: I77fc7b24ccd387f54a7c7edad666737252af6bd9
2023-03-08 20:43:15 +01:00
Harald Welte c4cfb802df gsm: TS 44.021 modified V.110 frame encoding/decoding support
3GPP TS 44.021 specifies the format for modified V.110 frames as used
on the GSM air (radio) interface.  Implement encoders and decoders for
this modified V.110 format.

Related: OS#1572
Change-Id: I60a2f2690459359437df20cf4da9043fa7c3ad11
2023-03-08 20:43:15 +01:00