Commit Graph

1494 Commits

Author SHA1 Message Date
Max 73de5c18de Add osmo_sock_get_name_multiaddr_buf()
It's similar to osmo_sock_get_name_buf() but supports multi-homed SCTP sockets
bound to several addresses.

Related: OS#5581
Change-Id: If76595ebd1cf26ba904887a36c4cc14a1b5c4521
2022-10-01 23:22:58 +07:00
Vadim Yanitskiy 395db204b4 include: use '#pragma once' everywhere
Change-Id: Iecc1754caae401aca28444d3e3d0cca04b398f26
2022-09-29 05:44:09 +00:00
Alexander Couzens 71ad530f7e gb: add bssgp2_enc_flush_ll encode FLUSH-LL
Change-Id: I76dc3b08a63cfd78c9f7657fb58c2ddfa9b4b7e2
2022-09-28 18:14:28 +02:00
Neels Hofmeyr 70093f23ad comments: gsm_08_08.h: AMR cfg: explain in much more detail
Change-Id: I1864a6beeeedc301c6dc7e2e0c52a3f94b2fef01
2022-09-25 20:26:21 +02:00
Pau Espin 812766e231 utils.h: protect param with parenthesis in OSMO_BYTES_FOR_BITS()
While at it, drop 8-1 in favour of 7. I don't think it is really more
understandable for readers to see some subtraction there...

Change-Id: I8b21eba9b9aa952f86abe7a6d4cdb1d1a61d9deb
2022-09-08 15:03:44 +02:00
Neels Hofmeyr 709da278ca Revert "Add function to guess AF_UNSPEC address"
This reverts commit a4063efa7d.

Reason for revert: It is not possible to guess the IP address
family from uninitialized memory. This function simply glorifies
random noise into an IPv6 address. It makes no sense to have it.

Change-Id: Ifadd614604cf9d0c2ed1a405493c1c3fcb37ae23
2022-08-17 14:05:18 +00:00
Neels Hofmeyr 9e4c2ebf18 Revert "Add osmo_sockaddr_strs_to_str()"
This reverts commit e145e28a91.

Reason for revert:
The function osmo_sockaddr_strs_to_str() should not be part of the
osmo_sockaddr_str API. The implementation of this should live in
the function multiaddr_snprintf() added in patch
Icef53fe4b6e51563d97a1bc48001d67679b3b6e9
and should not use dynamic allocation.

Change-Id: I263dfd68313b896c5b474025fbca13c22ce41cdc
2022-08-17 01:01:16 +00:00
Max e145e28a91 Add osmo_sockaddr_strs_to_str()
This will come in handy for working with multihomes sockets like SCTP.

Related: OS#5581
Change-Id: Ic0d7c08f669994e37a2314555ecac85d28c42c89
2022-08-14 12:21:12 +07:00
Max a4063efa7d Add function to guess AF_UNSPEC address
Sometimes we receive generic "struct sockaddr" with unspecified (AF_UNSPEC)
address family. It's handy to try to guess
the proper address (there're just 2 variants ATM in most practical applications).

Use the added function to relax input checks in osmo_sockaddr_str_from_in*()

Related: OS#5581
Change-Id: I1c90c56ce832f53b65e0d18d3cea94621c02a69a
2022-08-09 08:58:49 +00:00
Pau Espin 83287ba41c gsm: rsl: Define new osmocom extension TLV IE to pass Osmux CID
This is similar to what we already do between BSC<->MSC to pass Osmux
CID (GSM0808_IE_OSMO_OSMUX_CID).
We now want to support Osmux between BSC and Osmocom BTS, hence add an
extension IE which will be used in ipaccess CRCX messages to tell the
BTS to use Osmux.

Change-Id: I580fe99c01bc0a844d877994ec6cd954310e265d
2022-08-09 08:35:55 +00:00
Pau Espin 306400786d gsm: Add BTS feature for Osmux
This feature is used by the BTS to signal to the BSC that it supports
using Osmux instead of RTP on the BTS<->BSC(MGW) data plane.

Related: SYS#5987
Change-Id: Ie79bfb6d0a7a8fe2842d2596b3244e7b74a0d5b6
2022-08-09 08:35:55 +00:00
Pau Espin 862dd36318 tlv.h: Fix TLVP_PRESENT returning a pointer instead of a boolean
I was warned by gcc about comparing a pointer with an integer when using
TLVP_PRESENT with something like:
bool expect = ...;
if (expect != TLV_PRESENT(...))

That's indeed dangerous because TLV_PRESENT is considered to return a
boolean, as opposite to TLV_VAL.

Change-Id: I45cc2745c695e30c37b10f592903ec3775a55492
2022-08-08 20:07:15 +00:00
Pau Espin 6960b6a855 cosmetic: tlv.h: Fix trailing whistespace
Change-Id: Ief318882def539b35ef15c85566f69220e7edbfe
2022-08-08 20:07:15 +00:00
Neels Hofmeyr aafa2b3a67 enrich API doc for gsm0808_speech_codec
Change-Id: Iee52f38c1040b7f7ee37aaa58cfdb0cb6cf33f4d
2022-08-08 18:47:25 +02:00
Vadim Yanitskiy 8137d9a0f0 logging: add a new category DLCSN1 for libosmo-csn1
This new category is going to be used by CSN.1 codec in libosmo-csn1.

Change-Id: Ie8c0effb764547a0f9cc8c6825e11a6617501e95
2022-08-04 02:32:13 +07:00
Vadim Yanitskiy b3e3a5d215 fsm: osmo_fsm_{event,inst,state}_name(): make *fi pointer const
Change-Id: I98cde213deb5a3bf39eb9f5e5451f40223632844
2022-07-29 00:06:48 +07:00
Pau Espin 0893f0f631 gsm_23_041.h: Define CBS ETWS Warning Type values
Change-Id: I3a5bb9b2c77b8e4a984631d199fc073183691c31
2022-07-25 10:43:45 +02:00
Pau Espin 0cdd0abd53 cbsp: Add enum and value string for Cause
Change-Id: I35592bb4fff2e7b442d0e0cd537b66687862baf2
2022-06-09 18:17:43 +02:00
Vadim Yanitskiy cc4213e927 coding: add gsm0503_detect_a[fh]s_dtx_frame2()
The new functions accept an additional mode_id poiner, which is
currently set for the following frames: AFS_ONSET, AHS_ONSET,
AHS_SID_FIRST_P2 with N * 16 - M bit pattern.

Also, the new API accepts soft-bits instead of hard-bits.
Converting bits from soft to hard is now performed internally.

Change-Id: Ibcac395f800bb64150c97fcdaca3523ecfc5fcee
Related: OS#5570
2022-05-27 08:31:30 +00:00
Pau Espin fe1dcebe3a cosmetic: iuup.h: Fix indentation
Change-Id: I10a2d2a872fd6fdae8b4af94995300af3144b551
2022-05-25 19:43:13 +02:00
Pau Espin 510f4c9d63 iuup: Rework API to support RFCI IDs != RFCI index
The initially merged IuUP API and implementation assumed that RFCI with
ID was always in the position of its ID inside the list of RFCIs. This
was the case for messages sent by ip.access nano3g as well as our own
osmocom implementation. However it was noticed that other nodes from
other vendors actually use other order, as allowed by the IuUP message
format.
Hence, we need to break the assumption and provide explicit ID
information in the list.

NOTICE: This commit breaks API and ABI compatibility with older versions
of libosmogsm, but not with any previous release of libosmocore since
the API is only available in master so far (it was added in
9fe1f9fb0b).
Similary, it's only user (osmo-mgw) only uses the API in master, so
there's no API breakage with older releases.

Related: SYS#5969
Change-Id: Ib21cee2e30bf83dff4e167f79541796007af9845
2022-05-25 14:10:17 +00:00
Harald Welte 1e1436ce75 stats: Functions with no arguments should specify(void)
... otherwise callers might pass arbitrary arguments without raising
a compiler error or warning.

Change-Id: Ia2de1d13df5f00dcc42493090734a635029d76b5
2022-05-08 09:57:04 +02:00
Pau Espin 7ac0451ae8 gsm_12_21.h: Add header description pointing to TS files
Change-Id: I20d5bb659d84228a951b66228b7c172bce3ee929
2022-05-04 17:08:38 +02:00
Pau Espin 7813cc95aa gsm_12_21.h: Fix abis_nm_avail_state InTest and Failed values
This has always been wrong since at least libosmocore initial commit in
2010.

Change-Id: Ib854a1284fbd38951bb2d1cb3706c42ba7e14ccb
2022-05-04 17:08:34 +02:00
Pau Espin 9d3cfeff3e cosmetic: logging.h: fix indentation
Change-Id: Ia7f43e061275da1a8233f90df173d1ae18691964
2022-04-28 14:53:21 +00:00
Harald Welte 3b007f86ac vty: Add a 'skip-zero' version of 'show stats' and 'show rate-counters'
In many cases, a lot of the counters are zero, and we're likely
not interested in those, but only the non-zero counters.  Add a version
of the 'show stats' command which dumps only those items with a non-zero
total value.

Change-Id: Ie4df1c139e3c82deca1dd3cdab5d3909e0513684
2022-04-28 06:05:29 +00:00
Pau Espin 1dac8756fd gsm: Introduce helper rach_tx_integer_raw2val()
Change-Id: I6ef085ee92b2064cb46fa5ec3ae98a0ca59ad599
2022-04-26 17:47:57 +02:00
Pau Espin b0c2f75665 jenkins: Validate gsm 08.58 IEs are added to tlv_definition
It was recently found that several IEs which were added in the header
file were not actually added to the tlv_definition, and hence the tlv
parser failed to decode them. Let's make sure we don't foget to add new
IEs in the future.

Related: SYS#5915

Change-Id: Id8a679ca43eb0fcc4882780e9a95ec21c7f51972
2022-04-05 17:38:25 +02:00
Daniel Willmann 767bfd8c87 bssgp_bvc_fsm: Add a hook to notify when a reset was acknowledged
There are cases where we want to be notified of a successful BVC reset,
e.g. for a signalling because we can then start resetting the PtP-BVCs.
With this hook it's now possible to do that.

Change-Id: If240dd13f0f674693018c93390386b2c8afb97af
Related: SYS#5908
2022-03-30 18:00:56 +02:00
Vadim Yanitskiy be1338789a bssmap_le: support additional IEs in Perform Location Request
Change-Id: I8775a93cf4089b1752d040e43d2cba6b8997f955
Related: SYS#5891
2022-03-22 18:38:19 +03:00
Pau Espin e8b69138f7 cosmetic: gsm_08_08.h: Add space between assignment sides
This allows easier parsing of all the enum fields using scripts.

Change-Id: Iebd51985551a98978b81f76f778ac7892a440d5c
2022-03-18 17:36:46 +01:00
Oliver Smith 5e24eea15c Cosmetic: linuxlist.h: fix misleading comment
Whenever iterating over a list and removing entries,
llist_for_each_entry_safe must be used instead of llist_for_each_entry.

The comment with "non-consecutive(!)" entries sounds like this is not
needed as long as one is iterating over the list consecutively. I guess
that might have worked with prefetch logic, however the prefetch
function is just a stub in linuxlist.h. (Also prefetch has been removed
from list.h in linux.git e66eed651fd18a961f11cda62f3b5286c8cc4f9f.)

Change-Id: I217e6871afe121edba26e4c6fd1a461e397c9e72
2022-03-13 21:36:27 +00:00
Neels Hofmeyr 9c7f7f85c8 add osmo_sockaddr_set_port()
Do it like osmo_sockaddr_port() in reverse.

Related: SYS#5599
Change-Id: I9512e44c3203daebb3fe3435fceef167613c1a73
2022-03-01 16:33:40 +00:00
Neels Hofmeyr a25a6dca25 BSSAP: HO Request Ack: add missing Codec List (BSS Supported)
Related: SYS#5839
Related: I3c0576505a3ceb3cd5cc31dc69c5bc4a86a4ea08 (osmo-bsc)
Change-Id: Iab0a7b4d81592157fc111d1adb9e9f4cb53a94e9
2022-02-28 11:04:08 +00:00
Pau Espin b5551eec33 gsm: [ABI BREAK] Support CellId SAI, change CellId CGI-PS id number
Those are available in 3GPP TS 48.008 version 16.0.0 Release 16, section
3.2.2.17 Cell Identifier. It can be seen that we have a collision
between the osmocom non-standard format and the SAI standard one.

This is because CGI-PS is not really a TS 48.008 Cell Identifier, but only
specified in TS 48.018 and has no ID number assigned. The CGI-PS was
added there because the whole osmo-bsc neighbour configuration works
with CellIds to manage neighbours, so it felt natural to extend the APIs
to also provide means to use CGI-PS format (TS 48.018 even refers 48.008
existance and mentions there's no explicit ID).

At the time this Cell Identifier was added, the firstly available number
(11) was taken, which was of course a really bad idea since newer
versions of the spec can at some point use it, which is the case if one
checks for instance TS 48.008 Release 16 SAI Cell Id.

There no perfect way to fix this bad decision at the time, but the
CGI-PS is only used in osmo-bsc and only for RIM related purposes, so by
changing the ID of CELL_IDENT_WHOLE_GLOBAL_PS, we only break RIM under
some specific CIs being used, and when an osmo-bsc is built against
older libosmocore and then used at runtime against a newer libosmocore
(which should be rare).
Hence, the downside is acceptable, and by moving the new ID number to be
ouside of the spec proto TS 48.008 range (4 bits), we make sure we don't
have the same problem again in the future.

Related: SYS#5838
Fixes: ca33a71ca8
Change-Id: Id25e563febdb7640174540136225f399515a0089
2022-02-16 17:59:23 +01:00
Vadim Yanitskiy c797e25f3e core/utils.h: make use of OSMO_LIKELY in OSMO_ASSERT
Theoretically, this should improve performance of the code where
we frequently invoke OSMO_ASSERT(), like osmo-msc and osmo-bsc.

Change-Id: I29b32a2477ec92762f8f0ce5e5c5a30810f6abbe
2022-02-09 10:05:25 +00:00
Vadim Yanitskiy 85c7831b65 core/msgb.h: make use of OSMO_LIKELY / OSMO_UNLIKELY
Change-Id: Iff666b5fa0b320ae47b6c8c5dfd39debd2d9b8b7
2022-02-08 19:48:52 +00:00
Vadim Yanitskiy 9ac355ad51 core/utils.h: wrap OSMO_ASSERT() with do { ... } while (0)
Using do-while is a common practice for complex macros.  This allows
invoking OSMO_ASSERT in simple if-else statements without braces.

Change-Id: I42d9c315c9c30bce828564a63c496ee62e5c1431
2022-02-08 12:50:48 +06:00
Vadim Yanitskiy e59e839dd9 core/utils.h: add OSMO_LIKELY / OSMO_UNLIKELY macros
These macros are built on top of the __builtin_expect() function [1],
which provides the compiler with branch prediction information.

Similar macros exist in the Linux kernel: likely() / unlikely().

[1] https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

Change-Id: I0b029654ba050f079eed4a0574a3fa8019677067
2022-02-08 12:48:28 +06:00
Neels Hofmeyr cf7f7924d2 add osmo_sockaddr_from/to_octets()
Shorthand for the INET/INET6 switch() to get/put the addr part, useful
for encoding and decoding message buffers.

Related: OS#5599
Change-Id: Ie9e33bfac525c59c30714663d2bfcc62ec9eeb81
2022-02-07 22:13:20 +01:00
Neels Hofmeyr 1633735e9b add osmo_quote_str_buf3, osmo_escape_str_buf3
There already are osmo_quote_str_buf() and osmo_quote_str_buf2(), same
for _escape_, but none of them return the snprintf() like string length.
A private function does, publish this in the API.

The returned chars_needed is required to accurately allocate sufficient
size in string functions that call osmo_quote_str/osmo_escape_str. I am
adding such in osmo-upf.git.

Related: SYS#5599
Change-Id: I05d75a40599e3133da099a11e8babaaad0e9493a
2022-02-07 22:10:29 +01:00
Neels Hofmeyr 09d6574a45 add osmo_sockaddr_to_str_c(), osmo_sockaddr_to_str_buf2()
To easily log and print a sockaddr using OTC_SELECT, add
osmo_sockaddr_to_str_c().

Implement osmo_sockaddr_to_str_buf2() using osmo_strbuf, so that we can
return the chars_needed which osmo_sockaddr_to_str_c() uses.

From previous osmo_sockaddr_to_str_buf(), call
osmo_sockaddr_to_str_buf2() and return NULL if the buf_len was
insufficient, to mimick previous behavior. This makes it more
consistently returning NULL for insufficient buf_len, as shown in the
tweak that is needed in socket_test.c. Before osmo_sockaddr_to_str_buf()
would return a truncated port number, now it's all or NULL.

I will use osmo_sockaddr_to_str_c() in the new osmo-upf implementation.

Related: SYS#5599
Change-Id: I12771bf8a021e6785217b1faad03c09ec1cfef0e
2022-01-31 15:03:53 +00:00
Philipp Maier 4c44d46308 logging: log to stderr when logging is not initialized
When the logging framework is not initialized we get an error:

"ERROR: osmo_log_info == NULL! You must call log_init() before
using logging in ..."

There are sometimes situations where some code tries to log before
logging was initialied. This is a problem because the actual log
line with the debug info we need is covered up by the error message
from the logging framework.

Lets introduce a fallback logging function that is called when the
the logging framework is not available. This function can just use
fprintf to output to stderr.

Change-Id: I9b1b0988e02322e3e44fd4ceea3e1bc2d4df3c45
2022-01-25 17:49:20 +01:00
Neels Hofmeyr 1d1ab74fdf ports.h: add osmo-pfcp-tool ports
Related: SYS#5599
Change-Id: I8a5f437d934b9bda11ea593b50bd18c7d5d71ce9
2022-01-21 00:55:51 +01:00
Neels Hofmeyr 13fa00e183 PFCP: add DLPFCP and osmo-upf port numbers
Related: SYS#5599
Change-Id: I0a46b147ec6a76d909df28136cfd2b764b2c75ea
2022-01-21 00:55:51 +01:00
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