Commit Graph

1606 Commits

Author SHA1 Message Date
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
Pau Espin d9825c0a2c bts_feature: Introduce feature to confiure dyn ts as sdcch8
This feature signals support to configure Osmocom Dynamic Timeslot type
as SDCCH8, on top of historically supported TCH/H and TCH/F.
The idea is that when unneeded, the TS is configured as PDCH, and as
soon as there's need for an SDCCH and there's none available, the TS is
dynamically reconfigured to SDCCH8. Once all logical channels in the
dynamic TS are released and hence becomes free, the BSC will reconfigure
it to PDCH.

Related: SYS#5309
Change-Id: Ifc0ca8916bd3e93e5a60a7dd7391d2588fdb5532
2021-06-30 13:15:02 +02:00
Pau Espin 45dc9d00fe Rename osmo dyn ts enums
They will gain support to be activated as SDCCH/8 soon too. Since new
name would start to be too large, use a more generic naming for it.

Related: OS#5309
Change-Id: I56dcfe4d17899630b17f80145c3ced72f1e91e68
2021-06-30 13:14:08 +02:00
Pau Espin 3265ded36c cosmetic: gsm_12_21.h: Fix trailing whitespace
Change-Id: Ifdcdcfe30c41da233899101e1057bfca7d645a66
2021-06-28 12:12:26 +02:00
Vadim Yanitskiy 1c2a329f85 bts_features: add feature for BCCH carrier power reduction mode
Change-Id: I69283b3f35988fc7a1a1dcf1a1ad3b67f08ec716
Related: SYS#4919
2021-06-25 19:34:52 +02:00
Neels Hofmeyr e4378b7e38 gsm0808: add Kc128 to Handover Request
Change-Id: Ieb6e43eef9e57281d54d4b7c63664668df5aef3e
2021-06-25 08:19:04 +00:00
Neels Hofmeyr 4a9756c17a add Kc128 to gsm0808 Create Ciphering Command
Prepare for A5/4 support in osmo-msc.

Add new function gsm0808_create_cipher2() which takes a struct as
argument instead of individual fields. This is akin to e.g.
gsm0808_create_handover_request() below in the file, and allows
backwards compatibly extending the argument list without needing a new
function signature every time.

Add struct gsm0808_cipher_mode_command, as argument list for
gsm0808_create_cipher2(), with kc128 included.

Encode the Kc128 IE in gsm0808_create_cipher2().

Implement gsm0808_create_cipher() by calling gsm0808_create_cipher2().

Change-Id: Ib3906085e0c6e5a496a9f755f0f786238a86ca34
2021-06-21 00:36:46 +02:00
Philipp Maier eabc6fd4b1 vty: make function cmd_range_match() public
Certain control interface commands also may require to verfy a range in
their verify function. cmd_range_match() from the VTY does exactly that
and the range can be specified as string, the same way as we would
specify it in the VTY.

Change-Id: I53fc207677f52b1dc748b01d58424839cdba807c
related: SYS#5369
2021-06-18 12:31:01 +00:00
Neels Hofmeyr ac49bda4d4 osmo_select_shutdown_request(): allow finishing pending writes on SIGTERM
Allow telling osmo_select_main* to only service pending writes (shutdown
mode). Introduce API fuctions to indicate a shutdown request, and find
out whether shutdown is complete.

Some osmo programs have a curious sleep of few seconds upon receiving
SIGTERM. The idea presumably was to finish off pending writes before
halting the program. But a sleep() on program exit is annoying,
especially when there usually are no pending writes, and when osmo-bsc
is launched numerous times for tests.

Change-Id: Ib94d4316924103459577087c2214188679db2227
2021-06-18 12:22:44 +00:00
Pau Espin af40b0b6b9 msgb_alloc_headroom: Change size args to be uint16_t
Underlaying APIs (msgb_alloc) use a uint16_t as a type, which means
until now passing a value > 2^16 would succeed providing a msgb with
less space than requested.

Since those are static inline, there's no symbols used by apps, so we
should be safe enough changing the type to be uint16_t, since change
would only be applied at re-compile time.

Change-Id: I83c8222484e4856c68134a1a9d8cf96eb91af1b8
2021-06-13 18:20:09 +00:00
Pau Espin 42bb125df1 bts_feature: Introduce feature to speak to PCU
This feature provides the BSC with information on whether the BTS talks
the IPAC_PROTO_EXT_PCU osmocom extension over the underlying IPA
multiplex of the OML link.

Related: SYS#5303
Change-Id: Id62421f7f5540875ac877a187757f2cf0556bd02
2021-06-11 16:36:29 +00:00
Pau Espin 8082c14a95 ipaccess: Add new osmo extension IPAC_PROTO_EXT_PCU
This new extension protocol is used to forward Osmocom PCUIF messages
BSC<->BTS<->PCU.
It will be sent re-using the IPA multiplex of the OML link between
BSC and BTS. BTS is responsible for forwarding the message over the unix
socket to the PCU.

Related: SYS#5303
Change-Id: I68b04def49946b6915dbd4e476999f249751cd28
2021-06-11 16:36:29 +00:00
Eric Wild c3fa007610 kdf: add key derivation functions
generic sha code from git://w1.fi/hostap.git commit
5ea93947ca67ba83529798b806a15b247cdb2e93 which also happens
to be the source of our milenage code.

Related: SYS#5324
Change-Id: Ibf2e49edada944d91ceba62bd0d6b6ce69261fcd
2021-06-08 02:38:15 +02:00
Pau Espin 09f075fad6 stat,rate_ctr: Allow setting group name and use it at report time
This patch adds a new field "name" to the rate_ctr and osmo_stat_item_group
structs, together with an API to set it. This new field allows for easy
identification of specific group instances when several of them exists,
rather than using a sometimes random/increasing index value.

If set, this name (string) is used instead of the index by the stats
reporter.

The name, if set, is also printed during "show stats" VTY commands.

It's up to the user or application to set up unique or meaningful names
to fullfill one's needs.

WARNING: this commit breaks ABI and possibly creates unexpected behavior
when run with non-rebuilt apps which use the modified structs directly
to get the coutners, or if use the static inline API rate_ctr_inc2().
Existing users of these structs should migrate to use new APIs
introduced in follow-up commits instead of accessing the field directly.

Related: SYS#5456
Change-Id: I0dc510783dd9ae8436dae8005a7b3330e80d36f3
2021-06-05 15:46:27 +00:00
Vadim Yanitskiy 442ff64ad4 gsm_08_58.h: add mask for Osmocom specific VAMOS C-bits
Applying and reverting this mask allows one to quickly convert
between VAMOS and non-VAMOS variants of Bm/Lm C-bits.

Change-Id: Ia0bd8695a3f12331b696fe69117189cdd48b584d
Related: SYS#4895, OS#4941, SYS#5315, OS#4940
2021-06-03 03:33:27 +00:00
Pau Espin 5fe3de5313 stat,rate_ctr: Introduce new API to get counter at given index
Having this API and forcing apps to use it will allow easily adding new
members to the group structure without having so much impact in users of
this struct.

Related: SYS#5456
Change-Id: Iebbf401f11e36645f8964d389460918eb9e0910e
2021-06-01 21:06:55 +00:00
Harald Welte 20199da02d sim: Add osim_card_{reset,close}() API
This is required to reset and close a card under software control
after opening it with osim_card_open()

Change-Id: Ie9ec66db4d54fdb1331f4ae05ca3ca4274912e9d
2021-06-01 20:29:17 +02:00
Vadim Yanitskiy fc02ff459a gsm_08_58.h: add Osmocom specific Bm/Lm CBITs for VAMOS
Change-Id: If33c1695922d110c0d2c60d5c0136caf2587194e
Related: SYS#4895, OS#4941, SYS#5315, OS#4940
2021-05-26 21:18:11 +02:00
Neels Hofmeyr fef61cd2dd add RSL_CMOD_CRT_OSMO_TCH_VAMOS_Bm, RSL_CMOD_CRT_OSMO_TCH_VAMOS_Lm
These indicate VAMOS mode to osmo-bts during channel activation and
channel mode modification.

Change-Id: Ib4ea11c870683a58f0bbc8c9cd942faceba8c4d9
2021-05-19 18:36:12 +02:00
Neels Hofmeyr dd6f13636e add RSL_IE_OSMO_TRAINING_SEQUENCE
This IE is explained in the Abis manual in osmo-bts commit
Ie583bd5969fdb45f772af198033e58d7c4077306
http://git.osmocom.org/osmo-bts/commit/?id=823cd529649b667af20bfa4e383255a8ed5931f1

Change-Id: I573c26b1431ee789e42f6fa620947b003c384dc0
2021-05-19 18:34:33 +02:00
Pau Espin 645aec8237 vty: Introduce API vty_read_config_filep
This new API doesn't use host_config_set(), and allows passing a FILE*
from any source, not only a filesystem path.

Related: SYS#5369
Change-Id: I720ac04386261628c0798a1bfcaa91e2490a86c3
2021-05-18 14:56:52 +02:00
Pau Espin ebb6c1fc4d vty: Implement missing public API host_config_file()
The API was defined in the header file but not implemented.

Change-Id: I69de9864fa7cd421557b9fc630beefea6d90b4cc
2021-05-17 18:54:23 +02:00
Pau Espin adef546ff9 Revert "gb: Fix naming and export symbol bssgp_enc_rim_pdu"
This reverts commit 43ad616e4b.

 _enc_ functions are for some ies while the _encode_ and _decode_ are
for the full pdu.  so the old name is correct.

Change-Id: Ib0b4a6fd7f8c96e4647a373541e3cccb324c6a11
2021-05-06 18:28:12 +00:00
Pau Espin 43ad616e4b gb: Fix naming and export symbol bssgp_enc_rim_pdu
The symbol was not in the list of exported symbols.
Take the chance that it was not used anywhere outside libosmocore to
rename it in order to follow similar naming as other existing APIs.

Change-Id: I534db7d8bc5ceb19a2a6866f07d5f5c70e456c5c
2021-05-06 17:56:47 +02:00
Pau Espin a488639e42 osmo_timer_pending: Make arg const
Change-Id: I250c25c3ac61ac364335f81d8ba50cb32fd6976e
2021-04-29 20:14:51 +00:00
Harald Welte d99e4eee2b ns2: Allow setting the socket priority for a UDP bind
Change-Id: Ifdfa086ce1c8d62b256abb3454b70cf53da9dcdb
2021-04-29 19:55:34 +02:00
Neels Hofmeyr 87fa1caf4b fix default_timeout type of osmo_tdef_fsm_inst_state_chg default_timeout
The api doc indicates the possibility to pass -1, and calling
osmo_tdef_get() actually casts the arg to a signed long. To end the
confusion, change default_timeout from unsigned long to long.

Change-Id: I51b9172603984839448346c9836e43c8c802fcf8
2021-04-28 18:31:31 +00:00
Harald Welte c545ff6f3e socket: QoS support for all our socket init functions
Every socket function that can be passed a 'flags' argument now
supports the following two additional macros that can be or-ed in
with the flags:
* OSMO_SOCK_F_DSCP(x) -- specify the IP DSCP of the socket
* OSMO_SOCK_F_PRIO(x) -- specify the priority of the socket

The existing osmo_sock_set_{dscp,priority}() functions are useful,
but  you cannot call them in between the socket creation and the
connect() operation when using our socket helpers.  This means that
the first packet sent will have the default DSCP/priority, and only
later packets would have the desired values.

When using the functionality introduced by this patch, we can ensure
that even the very first packet of e.g. a TCP or SCTP connect()
will have the correct DSCP/priority applied.

Change-Id: If22988735fe05e51226c6b091a5348dcf1208cdf
Related: SYS#5427
2021-04-28 13:15:20 +02:00
Harald Welte ecc0bd8d42 socket: Introduce osmo_sock_set_priority() helper function
In some situations we want to set the SO_PRIORITY socket option
to determine the in-kernel priority of packets generated by this
socket.

Change-Id: I89abffcd125e6d073338a5c6437b9433220e1823
Related: SYS#5427
2021-04-27 22:25:13 +02:00
Harald Welte ce53e03dc9 socket: Introduce osmo_sock_set_dscp() to set socket DSCP value
At least on Linux, sockets have a IP_TOS socket option that can be
configured to set the TOS.  However, TOS (of RFC791) was replaced
by the DSCP (of RFC2474) in 1998.

As the DCSP bits are only the upper 6 bits of the TOS bits, let's
introduce a helper to get, mask and set the DSCP values in the TOS
bits.

Related: OS#5136, SYS#5427
Change-Id: Ia4ba389a5b7e3e9d5f17a742a900d6fd68c08e40
2021-04-27 21:53:32 +02:00
Harald Welte 069967be86 ns2: Dump frame relay state to VTY during "show ns"
When doing a "show ns", let's also dump the state of the frame
relay network, with all its links and DLCs (if any).

Change-Id: I798af3e97dc014b6e0fcde86560a1809852f7510
Related: OS#4877
2021-04-25 21:09:23 +02:00
Harald Welte 47cc55ceac frame_relay: Export osmo_fr_network_free()
The function already existed, it was just not declared and not
exported.

Change-Id: I3f2a7e2fd1a4eda6bbed8510cf82951d73bb3f84
2021-04-25 21:09:23 +02:00
Harald Welte 22117a7164 sim: Obtain card ATR when opening the card
Change-Id: I42e387535c40f371b06f384af0ca5dc1e42ed00e
2021-04-25 21:09:23 +02:00
Pau Espin cde47795d1 gsm0808: Introduce gsm0808_old_bss_to_new_bss_info_att_tlvdef
Introduce TLV attribute definition for "Old BSS to New BSS Information"
container.

Related: SYS#5337
Change-Id: I0e55e947b6fef6dad0cf1a6c16b781bef4cc76c5
2021-04-21 19:02:31 +02:00
Neels Hofmeyr 4b44ac4012 RR: add missing Extended TSC Set IE
Defined in 48.018 10.5.2.82.
This will be used by Channel Mode Modify for VAMOS.

Related: SYS#4895 SYS#5315
Change-Id: I9bad6e7121af43dfa9706635e58279ce672a4e14
2021-04-20 02:43:40 +02:00
Neels Hofmeyr a9da9f7640 RR: add VAMOS channel modes
Also add functions to convert between VAMOS and non-VAMOS speech modes.

Related: SYS#4895 SYS#5315
Change-Id: Ie0ea592da5610ae70290106d004e549cf3212a89
2021-04-20 02:42:42 +02:00
Pau Espin 1b625cb134 gsm: Support Sending Last EUTRAN PLMN Id in Handover Required
Related: SYS#5337
Change-Id: I6280ce1abc283f1491bc6f391b2dd952df33a16b
2021-04-19 10:55:43 +02:00
Vadim Yanitskiy e731a7da05 protocol/gsm_08_58.h: add asymmetric CSD data rates
The new values are present in 3GPP TS 48.058, V16.0.0 (2020-09).

Change-Id: Icf4c83fa443b8410f4362c119b0a85419036b9cd
2021-04-19 05:02:37 +02:00
Vadim Yanitskiy 307b201e8e protocol/gsm_08_58.h: add more 'Channel rate and type' values
The new values are present in 3GPP TS 48.058, V16.0.0 (2020-09).

Change-Id: I0aaea1549e6de01c374d6b46353312e6246078e0
2021-04-19 04:43:30 +02:00
Vadim Yanitskiy 99f6cd5f54 protocol/gsm_08_58.h: add RSL_CMOD_SP_{GSM4,GSM5,GSM6}
The new values are present in 3GPP TS 48.058, V16.0.0 (2020-09):

 * RSL_CMOD_SP_GSM4 - OFR AMR-WB or OHR AMR-WB,
 * RSL_CMOD_SP_GSM5 - FR AMR-WB,
 * RSL_CMOD_SP_GSM6 - OHR AMR.

Change-Id: I40eca759380c8895d7923b2b4259d37a50978160
2021-04-19 04:27:53 +02:00
Pau Espin 4da98cc943 cosmetic: Fix trailing whitespace
Change-Id: Ib79b0e0c728a7f4de0b3884785c73ab2d0d44f4e
2021-04-14 21:28:19 +02:00
Pau Espin 8b913af11e gsm_08_08.h: Add extra field elements defined in other sections
The Signalling Field Element Coding list defined in 3.2.3 is used in
"Old BSS to New BSS Information" and "New BSS to old BSS Information"
IEs. However, the former IE (Old->New Info) defines 2 extra Field
Elements in 3.2.2.58 (3GPP TS 48.008 version 16.0.0 Release 16) not
present in 3.2.3.

Related: SYS#5337
Change-Id: I4db3f7974887e4c798a30c5b51a19472ceeee27d
2021-04-14 16:30:32 +02:00
Neels Hofmeyr 47c7b4fc24 add osmo_bts_features_names: short BTS feature strings
This will be used by osmo-bts-omldummy to parse features strings from
the cmdline.

Note that osmo_bts_feature_name() already exists to return the longer
descriptive value_strings from osmo_bts_features_descs (_descs!).
Luckily that misses the plural 'features' in the name, so that I can
still add a properly named osmo_bts_features_name() function that only
returns the name, matching the common pattern used in osmocom code.

Related: SYS#4895
Change-Id: I699cd27512887d64d824be680303e70fff3677c1
2021-04-09 00:10:44 +02:00
Neels Hofmeyr 524b4f802f deprecate osmo_bts_feature_name(), add osmo_bts_features_desc()
The function osmo_bts_feature_name() is ill-named for two reasons:
- it returns descriptive text instead of just a string representation of
  the name.
- The enum is named "osmo_bts_features", so the function name lacks the
  "s" for "features".

Rationale: An upcoming patch adds a function to return just the name,
properly called osmo_bts_features_name(), so deprecate the weirdly named
one first.

Change-Id: I9dfdb5e81037b6000effbd340af4e5db0dcfd69c
2021-04-08 23:11:45 +02:00
Oliver Smith 6140194347 stat_item: make value ids item specific
Fix counting of values missed because of FIFO overflow in
osmo_stat_item_get_next(), by assigning a new item value id effectively
as item->value[n + 1].id = item->value[n].id + 1, instead of increasing
a global_value_id that is shared between all items and groups. With
global_value_id, the count of values missed was wrong for one item, as
soon as a new value was added to another item.

This partially reverts b27b352e ("stats: Use a global index for stat
item values") from 2015, right after stats was added to libosmocore. It
was supposed to make multiple readers (reporters) possible, which could
read independently from stat_item (and later added comments explain it
like that). But this remained unused, stats has implemented multiple
reporters by reading all stat_items once and sending the same data to
all enabled reporters. The patch caused last_value_index in struct
osmo_stat_item to always remain at -1.

Replace this unused last_value_index with stats_next_id, so stats can
store the item-specific next_id in the struct again. It appears that
stats is the only direct user of osmo_stat_item, but if there are
others, they can bring their own item-specific next_id: functions in
stat_item.c still accept a next_id argument.

Related: OS#5088
Change-Id: Ie65dcdf52c8fc3d916e20d7f0455f6223be6b64f
2021-04-07 18:38:54 +00:00
Oliver Smith d3490bc442 stat_item: make next_id argument name consistent
Let osmo_stat_item_get_next, osmo_stat_item_discard,
osmo_stat_item_discard_all consistently refer to their next_id arg as
such (and not idx or next_idx). It refers to an ID (item->values[i].id),
not an index (item->values[i]), and it is always the next one, never the
current one.

Do the same change for _index/_idx variables in stats.c, which are used
as arguments to these functions. Replace rd_ with next_id_ in
stats_test.c, too.

Related: OS#5088
Change-Id: I5dd566b08dff7174d1790f49abd2d6ac020e120e
2021-04-06 11:27:34 +02:00
Neels Hofmeyr 158bc795e5 add BTS_FEAT_VAMOS
Change-Id: Ic3bd1b8075f76d1f35499faa68fad70698ee9a00
2021-03-27 17:14:57 +01:00
Alexander Couzens 6cf65d9d81 gprs_ns2: rework logging of Rx and Tx NS PDU
Introduce 2 new logging sub systems for signal and unit data.
Unify log messages so all log messages look similiar.
Log also Rx PDUs. Ensure dropped Tx packets (BLOCK/RESET on SNS)
contain *Tx*.

Change-Id: I34b8fde2955ecc010d1dcd9512e1bba9211e2c0d
2021-03-24 15:42:45 +00:00
Harald Welte 5b034fbab0 gprs_ns2: Introduce gprs_ns2_create_nse2() for SGSN side SNS
gprs_ns2_create_nse() doesn't allow the caller to specify if the
BSS or the SGSN role of IP-SNS shall be implemented.  Add
gprs_ns2_create_nse2() to fix that.

Change-Id: I6db8c36f7c69b592d7d0fbcf323804f7e9912be2
Related: OS#3373
2021-03-24 00:25:56 +01:00
Daniel Willmann 2fa0e9df68 tlv: Fix length returned by t{l16,16l}v_put
Every other function returns a pointer to the first byte after the tlv
that was just written.

tl16v seems to be a copy and paste error from tlv16 above and t16lv seems
to count the 16-bit tag twice.

The new tests verify that the return value of *_put(buf, tag, len, val)
points to buf + *_GROSS_LEN(len).

Change-Id: I268a7e11fb5dce67ce1bd7974ab86c4d2bd002f7
2021-03-18 14:20:35 +01:00
Harald Welte a0fb37627f TODO-RELEASE: Request increasing _LAST_OSMOVTY_NODE next release
We've used up all but one "library reserved" VTY nodes at this point,
and we should definitely add some more reserved nodes in the next
libosmovty ABI version / release.

Change-Id: Idfe1e7d97f3f29fc219e80dcb6ce6bb768733adf
2021-03-05 17:06:38 +01:00
Alexander Couzens 7819ff6959 gprs_bssgp: add support for SGSN oriented RESET
To support SGSN oriented RESET introduce a role flag to
track what's running the gprs_bssgp (local side).

Related: OS#3879
Change-Id: Ibcbaffa94cbdc4296a8a7c372304ac11d50d9559
2021-03-01 19:44:02 +00:00
Pau Espin 6e9dd02bf8 logging: Deprecate API log_set_print_filename
Let's flag the API as deprecated so that people start using
log_set_print_filename2() API instead, which has less ackward
behavior implications like changing the print status of category-hex.

Related: OS#5034
Change-Id: If9b6b322989536a12094e6105c3aabc84d8be24a
2021-02-20 17:13:58 +00:00
Pau Espin 662d10dcda logging: Allow prefixing thread ID to each log line
Related: OS#5032
Change-Id: I38fc93ab0182b4edbd639c7ed0f31ce51964ee18
2021-02-19 11:21:46 +00:00
Alexander Couzens 6b9d232421 gprs_ns2: rework IP-SNS binds
Introduce a `ip-sns-bind BINDID` vty command within a `nse` vty object.
The ip-sns-bind defines the binds which will be used by the dynamic
configuration with IP-SNS.
This is only the first part which only uses the binds when doing a
new SNS configuration.
The outgoing add procedure will be supported in a later patch
when the SNS fsm supports outgoing procedures.

This is a behaviour change of the API and must be synchronized with
the osmo-pcu. Otherwise SNS won't work with osmo-pcu.

Related: SYS#5354
Change-Id: I9ab8092bf286e7d90e92f5702a5404425e959c84
2021-02-19 10:41:50 +00:00
Pau Espin Pedrol d7a209bce9 gsm: Introduce API osmo_gsm48_rest_octets_si13_decode
Related: SYS#5358
Change-Id: I74fb0a3afc1ac4aadbfc609b882d929401f790eb
2021-02-18 00:54:33 +00:00
Pau Espin 88e4058fc4 Introduce osmo_gettid() API
This API wraps conventional gettid() linux-specific API, which even in
Linux itself is sometimes not properly supported/announced.

This API also allows future porting to other platforms if needed, and so
far falls back to getpid() if no gettid(9 can be found.

Code ported from osmo-trx.git, see commit 7a07de1efd4eb7cc11c33d3ad25cb2df70aa1ef1.

Related: OS#5027
Change-Id: Id7534beeb22fcd50813dab76dd68818e2ff87ec2
2021-02-17 18:24:17 +01:00
Philipp Maier ca770ae77e gsm_08_58, gsm_44_004: add struct for l1 information
Libosmocore currently does not offer any structs to encode and decode
the l1 information on RSL level and the sacch l1 header on the air
interface level. Both structs are identical but the field order in the
first octet is reversed.

Change-Id: I23c1890b89d5a0574eb05dace9f64cc59d6f6df7
2021-02-16 21:42:04 +01:00
Alexander Couzens 4f1128fcbd gprs_ns2: inform the NS user (BSSGP) about the MTU of a NSE
The BSSGP layer needs to know the MTU of the NS UNIDATA payload.
The MTU can be 0 if the NSE doesn't contain any NSVC.
Every status indication will contain the mtu value.
The MTU in the status indication contains the maximum transfer
unit of a BSSGP message. From NS side the maximum SDU.

Related: OS#4889
Change-Id: I5016b295db6185ec131d83089cf6c806e34ef1b6
2021-02-16 16:29:47 +01:00
Pau Espin Pedrol 288f9b2486 gsm: Fix bitfield order in dtap_header
This bitfield was added later and all osmocom code still uses the old
field contain 1 byte "link_id". There's only one known user of the new
bitfield which only uses it to log the SAPI name in osmocom, so no
logical breakage is expected with this change (other than fixing a log
line).

While at it, fix a typo in comment describing related enum.

Related: SYS#4909
Fixes: 392f607f2d
Change-Id: I84866f03ee642aa7f1da273c93a16a38234cfa67
2021-02-13 08:05:30 +00:00
Daniel Willmann 4e5cdad658 bssgp_bvc_fsm: Consistent naming
bssgp_bvc_get_features_* are fsm "methods" and the name should indicate
that just lika all other function names in bssgp_bvc_fsm.h

Change-Id: I30fbbe36cdabf9635eaf4dfb1e93c8ce0f667b39
2021-02-12 22:27:56 +01:00
Daniel Willmann fa632b8e80 bssgp2_enc_status: Truncate STATUS message to maximum PDU length
Related: OS#4889
Change-Id: Ic39d918c56399ceb0431299ce938e3bf276f678a
2021-02-12 14:19:20 +00:00
Daniel Willmann 1ff86f7cec bssgp_bvc_fsm: Set/get maximum BSSGP PDU length
Add functions to get/set the maximum supported BSSGP PDU size by the NS
layer.

IPv4 and IPv6 should not matter since we can just enable IP
fragmentation and send NS PDUs up to 2**16 + bytes. Frame relay does not
support fragmentation and this is the reason we need to be aware of the
maximum PDU size. Luckily with 1600 bytes the MTU in frame relay can hold a
regular IP packet including NS/BSSGP overhead.

On the NS layer this corresponds to the size of an NS SDU in NS-UNITDATA
(3GPP TS 48.016 Ch. 9.2.10)

Change-Id: I9bb82ead27366b7370c9ff968e03ca2113ec11f0
Related: OS#4889
2021-02-12 14:19:20 +00:00
Alexander Couzens c470476923 gprs_ns2: add signalling & data weights for UDP binds
Allow to assign a signalling and data weight to UDP binds.
Those weights will be used when doing dynamic configuration over
IP-SNS.
This is only the first part which only uses the assigned weights
when doing a new SNS configuration.
The outgoing change weight procedure will be supported in a later patch
when the SNS fsm supports outgoing procedures.

Related: SYS#5354
Change-Id: I5133e4229377d44772a9af28628a2bc420fea34b
2021-02-12 03:34:32 +01:00
Pau Espin 15b5acb332 Fix struct bitfields on big endian systems
Changes done by contrib/struct_endianess.py.

Change-Id: Ia9cb1ef2ba2bfff9ef713c7d1cf388931dae1c46
2021-02-08 17:23:25 +00:00
Vadim Yanitskiy 53aff13af4 tlv: clarify documentation for msgb_tv{16,32}_put()
Change-Id: Ie439822e0587012e108f67ba4e73771dc684b95b
2021-02-06 16:09:13 +00:00
Vadim Yanitskiy d397a53cfc tlv: add msgb_tv32_put(), similar to msgb_tv16_put()
Change-Id: I11301b20038aa5d90d46d968f7eda3d53b560022
2021-02-06 16:07:54 +00:00
Philipp Maier d11a5d5b9a gsm48: add compare function for struct gprs_ra_id
Comparing struct gprs_ra_id using memcmp can be error prone, so lets add
a compare function to compare two struct gprs_ra_id values reliably.

Change-Id: I4d7558c04d9d01761516526086be5104bb2eeada
Related: SYS#5103
2021-02-04 15:17:41 +01:00
Harald Welte 2cc1d4d7df frame_relay: Add status call-backs for link + DLC status changes
Change-Id: Iec19db4e48642c3fcb0aa11fa7787b8323fd0e5a
Related: Os#4999
2021-02-02 11:37:48 +00:00
Vadim Yanitskiy 943133cad8 gsm_7bit_encode_n(): fix integer overflow in gsm_septets2octets()
Using 'uint8_t' for the length argument is definitely a bad idea.
Because of this, packing more than 255 septets would not work as
expected.  Deprecate the old function and use 'size_t' instead.

Change-Id: Ib1aac538afeb0a5c76a1df472d555139a496e12e
2021-02-01 17:47:54 +00:00
Oliver Smith af916f1c7b sim: fix gcc 4.9.2 + -std=gnu11 error
Remove "(const struct osim_card_sw)" infront of OSIM_CARD_SW_LAST, so
debian 8's gcc 4.9.2 doesn't fail anymore with the following error each
time the macro is used:
	card_fs_sim.c:105:1: error: initializer element is not constant

I verified with docker that there aren't any other build errors with gcc
4.9.2.

Fixes: OS#4991
Change-Id: I9d3abbf9812dc09201eff0e9f7542cddedb6848b
2021-02-01 09:19:34 +00:00
Harald Welte a3f7323288 ns2: Fix typos in comments
Change-Id: I155fd697e229621561f7d00204421ac941101d77
2021-02-01 09:39:29 +01:00
Philipp Maier 4d40047c50 gprs_bssgp: agregate RIM related code in gprs_bssgp_rim.c
gprs_bssgp and gprs_bssgp_util.c also contains code related to send and
receive RIM PDUs via BSSGP and also code to encode and decode RAN
INFORMATION PDUs. Lets move this to gprs_bssgp_rim.c

Change-Id: Icda279452962b06e552cb1361d2a27b7dc8a6b04
Related: SYS#5103
2021-01-29 21:27:18 +00:00
Pau Espin 3e3f377749 gsm: bts_features: Introduce BTS_FEAT_CCN
This feature is used by BSC to gain knowledge on whether a given BTS
supports GPRS Cell Change Notification (CCN) related procedures on PDCH,
and as a result enable or not by default the CCN_ACTIVE bit in SI13 to
announce the support it is allowed to use the feature.

Related: SYS#4909
Change-Id: I61991266b95d0c13d51b47906cc07846e9cf1390
2021-01-29 18:01:14 +01:00
Pau Espin 5f2b8e5edf cosmetic: fix typo in comment
Change-Id: I787cca5a032c57202a86dab18e1790ef3ad1509a
2021-01-29 17:04:14 +01:00
Alexander Couzens 2e1a3a982a gprs_ns2: remove api call gprs_ns2_dynamic_create_nse
The call was only introduced as workaround for the first implementation
of vty. There is no need for this anymore. The configuration can
just add "accept-ipaccess" to the bind to allow creation of dynamic
ipaccess NSE.

Change-Id: Ie924ead6da17657f3da334068c8ada82c8845495
2021-01-28 13:54:32 +01:00
Alexander Couzens da1bf8e835 gprs_ns2: drop gprs_ns2_vty, rename vty2 -> vty
Drop the vty(1) code and replace it with vty2. The vty(1) was only
used as intermediate to not develop a vty while developing a new
code base behind. Users of gprs_ns2_ has to use the new vty code.

API change which must be synchronized with osmo-pcu,
osmo-gbproxy, osmo-sgsn.

Change-Id: Ic2059e75d8ede8e5c29c4fef6be608ed79c8a97c
2021-01-28 13:54:24 +01:00
Pau Espin caf5317412 Revert "gprs_ns2: drop gprs_ns2_vty, rename vty2 -> vty"
This reverts commit b306094448.

It was merged too quickly and patches for projects using related
features are not yet prepared.

Change-Id: I8a2aaf74a47de8f4f0adb37d16426d199788e3fe
2021-01-28 13:38:23 +01:00
Alexander Couzens b306094448 gprs_ns2: drop gprs_ns2_vty, rename vty2 -> vty
Drop the vty(1) code and replace it with vty2. The vty(1) was only
used as intermediate to not develop a vty while developing a new
code base behind. Users of gprs_ns2_ has to use the new vty code.

API change which must be synchronized with osmo-pcu,
osmo-gbproxy, osmo-sgsn.

Change-Id: I8c3f2afecc74b78f7f914f7dce166cbcb63444eb
2021-01-28 11:56:37 +00:00
Alexander Couzens 138b96f21c gprs_ns2: refactor: ensure all enums have GPRS_NS2_
All public enum should have the prefix GPRS_NS2_.

API change which must be synchronized with osmo-pcu,
osmo-gbproxy, osmo-sgsn.

Change-Id: I548ff12f7277cbb7e1a630a3dc02b738ce89be72
2021-01-28 11:56:37 +00:00
Philipp Maier c08a3fd30e gprs_bssgp_rim: add functions to convert a RIM-RI to a string
RIM routing formation structs can contain different variants of address
identifiers, so it is difficult for an API user to pick the _name()
function to generate a human readable string. Lets add
bssgp_rim_ri_name() and bssgp_rim_ri_name_buf() to make printing a
routing identifier easier.

Change-Id: Idca6bdccffe663aea71a0183ca3ea5bb5b59e702
Related: SYS#5103
2021-01-26 16:36:53 +01:00
Pau Espin 445a366c8a gprs_bssgp_prim.h: Add missing includes
Includes for struct gprs_ra_id and osmo_eutran_tai were missing.

Change-Id: I1c068b6841561003d4d7722daa6c2abb21363dda
2021-01-26 13:06:53 +01:00
Philipp Maier cf11411ebb gprs_bssgp_rim: add value strings for enum bssgp_rim_routing_info_discr
Change-Id: Idd06d2e3df0d60409a89a474018a9d97f7772090
Related: SYS#5103
2021-01-22 19:59:31 +00:00
Philipp Maier 8b19d06643 gprs_bssgp_rim: add value strings for enum bssgp_ran_inf_app_id
Change-Id: I581d1176f82d6657d6136c32daa9c76dffb802a6
Related: SYS#5103
2021-01-22 19:59:31 +00:00
Philipp Maier 139c4ae003 gprs_bssgp_rim: add value strings for enum bssgp_nacc_cause
Change-Id: I3354699555569c2b0bd1b4313cffd32a0cbeffe9
Related: SYS#5103
2021-01-22 19:59:31 +00:00
Pau Espin d426ba6730 gsm: Introduce osmo_{rai,cgi_ps}_cmp() APIs
Similar to what we already have for other data types, such as
osmo_lai_cmp or osmo_cgi_cmp.

Change-Id: I00e329bc5be8674b30267dec238e7656ddfc21db
2021-01-22 20:32:45 +01:00
Harald Welte cec4bbed73 vty/fsm_vty: Add vty_out_fsm2() + vty_out_fsm_inst2() with prefix
Callers other than "show fsm" / "show fsm-instances" may want to
indent the output.

Change-Id: I10e01ef91116369868cdb878a99634c8681728af
2021-01-20 14:59:03 +00:00