Commit Graph

3697 Commits

Author SHA1 Message Date
Daniel Willmann f5b2e28c87 ns2: Split 'initiater' into initiate_{reset,block}
Related: SYS#5002
Change-Id: Iff5aff0cf8d19d9c718dd11c4e731ced2aeb16ba
2020-11-20 15:37:46 +01:00
Alexander Couzens c06aa710d0 ns2: check if ns_vc_alloc() fails in bind_connect()
Change-Id: I82c984b9808451a72a62ff03b0495a1d09473e1c
2020-11-20 08:51:19 +00:00
Vadim Yanitskiy c1c420ce3d bts_features: add missing description for BTS_FEAT_ACCH_REP
Change-Id: Ie1d7f00b1bed43c41274bba4ce767a61cd71bb61
Fixes: Ib4d1d8d8a1a1d58bc320a1c0eff2d52100267f09
2020-11-20 01:41:15 +07:00
Harald Welte 465c9a5937 bssgp: Input argument to bssgp_tlv_parse() should be 'const'
Change-Id: I397b32a6e6ea3e9d218446138cceafa9b27685dd
2020-11-18 12:22:25 +01:00
Harald Welte 702c998391 card_fs_usim: Add definitions of DF.ProSe and DF.ACDC
those are the only two sub-directories of Release 15 we didn't cover
yet.

Change-Id: I1f85430cbb0041766b0725df9fa97c5a82e4f38d
2020-11-17 09:56:01 +00:00
Philipp Maier 439ddbe7a1 gsm_08_58: add struct for RSL_IE_OSMO_REP_ACCH_CAP
The recently added IE is used to transfer a bitfield, lets add a struct
that describes the bitfield. This makes the IE easier to use.

Change-Id: I326e66dae25acfab0b3fddc7278b39a8cbf7d385
Related: SYS#5114, OS#4796, OS#4794, OS#4795
2020-11-17 09:45:42 +00:00
Vadim Yanitskiy 7031ac1dd2 vty/command: add 'hidden only' VTY reference generation mode
Change-Id: I511ce26350cd04bb0f66d130b5286cab84f16df2
Related: SYS#4910
2020-11-17 16:23:11 +07:00
Philipp Maier aa718462bf bts_features: add feature BTS_FEAT_ACCH_REP
Change-Id: Ib4d1d8d8a1a1d58bc320a1c0eff2d52100267f09
Related: SYS#5114, OS#4796, OS#4794, OS#4795
2020-11-16 14:29:31 +00:00
Pau Espin e81c2f44f3 tests: Fix tdef_test on 32bit platforms
100 minutes = 6000000000 microseconds was too big to be stored in an
unsigned long in a 32bit platform, making the test print 4294967295
instead. Let's set a smaller value to have the test happy on 32 bits.

Change-Id: Ic0d009f00a69cee59f2d3fc0b40ecdc97d81c75c
2020-11-15 18:01:51 +01:00
Pau Espin 2299cb52a3 Revert "tests: Fix tdef_test on 32bit platforms"
This was not the issue, see next commit fixing the correct issue.

This reverts commit af10e48c1b.

Change-Id: Ifa1057ac55fcacdeb55ecdaac1ac3ddcca7d6d65
2020-11-15 18:01:45 +01:00
Pau Espin 4fe8a7598a serial: Introduce API osmo_serial_speed_t
This allows usual integer parsing at app level and calling this function
to make sure correct values will be passed to
osmo_serial_set_baudrate().

Change-Id: I41415c99d26128b33a8bf5ef7b38948bd1fe5d50
2020-11-13 22:58:14 +01:00
Pau Espin 28acb21321 serial: Log error if tcgetattr() or tcsetattr() fail
Change-Id: I79121e016f045c9d0555881359cd3008320223ed
2020-11-13 22:58:02 +01:00
Pau Espin 71ba873cc1 serial: Fix typo in debug log line
Change-Id: Ibfe70a42649512719be3c3ae42b5fad8b28a800a
2020-11-13 22:58:00 +01:00
Pau Espin 23999dac6e cosmetic: serial: Fix typo in comment
Change-Id: I5d4901e01af477ebb815f70a5326ada6224c4be8
2020-11-13 22:57:49 +01:00
Pau Espin 4c951adcf4 bitvec: Fix left shifting out of range on signed variable
Fixes following ASan runtime errors spotted by TypeTest osmo-pcu unit test:
libosmocore/src/bitvec.c:275:13: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Change-Id: I70502044d05c0505a4b65c1e12e89ff657afe804
2020-11-13 12:09:02 +01:00
Philipp Maier e36be56fc8 gsm_04_08: add parser for Mobile Station Classmark 3
3GPP TS 24.008 section 10.5.1.7 describes a Mobile Station Classmark 3
IE, which is encoded as CSN.1 struct. This means that it can not be
parsed by just casting a memory location to a struct pointer, so lets
add a parser to parse the CM3 IE.

This is fixed version of Ic8b2bfd00330235f5bed00771e421588abfaac1f,
which got reverted because it used the keyword "class" as struct member,
which lead into problems with c++ builds. This is now fixed.

Change-Id: Id8732551b33616227609cd6fcf6c3133751a89eb
Related: OS#4796 SYS#5114
2020-11-12 15:55:31 +00:00
Pau Espin af10e48c1b tests: Fix tdef_test on 32bit platforms
60 seconds = 6000000000 microseconds was too big to be stored in an
unsigned long in a 32bit platform, making the test print 4294967295
instead. Let's set a smaller value to have the test happy on 32 bits.

Change-Id: I97d53f6b7b410cef4b3f3fbe3162626fcdd7b05a
2020-11-12 14:00:10 +01:00
Harald Welte c2118940aa Revert "gsm_04_08: add parser for Mobile Station Classmark 3"
This reverts commit a4939dc846,
which caused massive build failures in C++ programs like osmo-pcu
- unsurprisingly, as it calls a struct member "class", which is a
reserved keyword in C++.

Change-Id: Ia43e56385e7b580f492c560aee8ff8b1e8a0e1d8
2020-11-11 23:11:15 +01:00
Pau Espin 1b75e4bbd1 tdef: Introduce OSMO_TDEF_US unit
Some applications may need submillisecond timers, such as those
interacting with modbus serial lines (RS-485, RTU), which require
timers of values around 1.5 char-time (T1.5), where a data char is
composed of 11 bits sent on the line: 1 start bit, 8 data bits,
1 stop bit, and and parity bit (or 2nd stop bits if no parity).

For instance, for a baudrate of 9600:
1.5 * 11 / 9600 = 1.718 ms = 1718 us

So having a granularity of MS is not enough here.

Change-Id: I71848d7c1ee0649929ce07680ee7320bb2a42f0e
2020-11-11 20:08:26 +00:00
Philipp Maier a4939dc846 gsm_04_08: add parser for Mobile Station Classmark 3
3GPP TS 24.008 section 10.5.1.7 describes a Mobile Station Classmark 3
IE, which is encoded as CSN.1 struct. This means that it can not be
parsed by just casting a memory location to a struct pointer, so lets
add a parser to parse the CM3 IE.

Change-Id: Ic8b2bfd00330235f5bed00771e421588abfaac1f
Related: OS#4796 SYS#5114
2020-11-10 16:36:54 +01:00
Harald Welte f396b96e66 card_fs_usim.c: Add support for DF.5GS directory
card_fs_usim already contained definitions up to Rel-15, but somehow
didn't add the DF.5GS yet.

Change-Id: I9f8102dc7e5a865193ff9930dfc48c5f2e6ecbcf
2020-11-10 15:33:49 +00:00
Philipp Maier a15967ba98 gsm_08_58: add proprietary IE to signal Repeated ACCH Capability
3GPP TS 24.008, section 10.5.1.7 specifies a Repeated ACCH Capability
bit in the Classmark 3 IE. Unfortunately, there is no way specified how
the Repeated ACCH feature should be controlled on RSL level. Since it is
not unusual that BTS/BSC vendors occassionally add proprietary IEs to
different RSL messages we may pick this as a solution as well and add a
propritary RSL_IE_OSMO_REP_ACCH_CAP IE, so that we can enable repeated
FACCH/SACCH on the BTS side when we send RSL CHAN ACT or RSL CHAN MODE MODIFY
messages.

Change-Id: I61ea6bf54ea90bd69b73ea0f0f3dc19a4214207b
Related: OS#4796 SYS#5114
2020-11-09 23:41:10 +01:00
Alexander Couzens 0ab028c84e ns2: fixup gprs_ns2_prim_strs
The gprs_ns2_prim_strs was merged to early. The renaming
in the last gerrit patchset wasn't done correct.

Change-Id: Ie8e1e003d70af48f2d647b2c2701d4fc0f17e307
2020-11-09 11:07:17 +00:00
Pau Espin 64c67bb088 vty: Mark cpu_sched_vty commands with attr immediate
Change-Id: I85c80376c13c7dddf34dadd2a6c09caf23fd70ce
2020-11-09 11:24:21 +01:00
Daniel Willmann ed1fa018c3 ns2: Improve NSVC output
In show ns lots of info was printed many times. We can just use
gprs_ns2_ll_str() to get the information about an NSVC so use that and
ensure newlines.
The NSVC are still printed twice - at least for the UDP bind: Once in
dump_nse and once in dump_bind.

Change-Id: I6f734d92ec1e17f339f7b32e449ffd614efa7319
Related: SYS#4998
2020-11-06 15:40:27 +01:00
Daniel Willmann 15c09a81e9 ns2: Send NSVC representation in NS_AFF_CAUSE_VC_* status indication
NS_AFF_CAUSE_VC_* failure and recovery should indicate the NSVC in
question. Use the string representation reported by gprs_ns2_ll_str()
for that.

NS_AFF_CAUSE_VC_RECOVERY was never sent so do that on unblock as well.

Change-Id: Iad6f0dc4565a46868cbbe17c361dcd473006c83d
Related: SYS#4998
2020-11-06 11:41:16 +01:00
Daniel Willmann f128654c7f ns2: Add gprs_ns2_nsvc_state_name() to get the current state of a VC
Change-Id: I4c4c5b9142d7240ed452218e263ba12e2b70d1a0
Related: SYS#4998
2020-11-06 10:23:44 +00:00
Alexander Couzens cce8828238 libosmocore: change the memory management of NS2
Until now NS2 always free'd it's own memory. Even when the msg
was sent as primitive to the upper layer.
Change the memory ownership when sending a primitive to the upper layer.
The upper layer has to free the msg buffer.

Merge together with: I180433735bfbb3375c41318d7a7709d5845199ba (osmo-pcu)

Change-Id: Id844d7acbcab102a7dc472d608a5e97a748ecb43
2020-11-03 22:37:45 +00:00
Daniel Willmann 07a923ff14 Add exported function btsctx_alloc to public header
Change-Id: Iddfb8e42d5d9e856c7165d3cff6c39191c86a4a5
2020-11-03 21:26:48 +00:00
Daniel Willmann 2d42b90dbb libosmogb: Add a function to tx BVC RESET by nsei/bvci
This is needed for osmo-gbproxy where we need more control over BSSGP.

Related: SYS#4998
Change-Id: Ifa769bce920a08cf93553dcb164a3fcf50162517
2020-11-03 10:14:00 +00:00
Vadim Yanitskiy f5f0d4304a gsm48: add missing RR cause value definitions
3GPP TS 44.018 version 15.4.0 Release 15 (2019-04).

Change-Id: If7187e005d65fd2bf067d258148281c5df0526ff
2020-10-29 18:23:06 +07:00
Vadim Yanitskiy 65954bac13 fix spelling in 'value_string' arrays: existAnt -> existEnt
It could be that this spelling variant was originally used in the
specs., but now at least in 3GPP TS 44.018 they use 'existEnt'.

Change-Id: I847de910411f2edf7cc45b8c296b43e65fed5447
2020-10-29 18:09:36 +07:00
Alexander Couzens b3b837c5e8 gprs_ns2: convert gprs_ns2_cause_str into an static inline
Be consistent with other implementation of get_value_string() in
libosomocore.

Change-Id: Ic79757df8683e0461c04f7ef9279e4fe645eb821
2020-10-27 14:49:03 +00:00
Alexander Couzens 2498f1db9d ns2: add value strings for ns2_affecting_cause_prim_str & ns2_prim_str
Change-Id: Ibf610fbd929dddc4a4e235152447caff522d4eb2
2020-10-27 15:24:47 +01:00
Alexander Couzens 0346b643b5 gprs_ns2: remove the nsvc fsm timer when cleaning up the fsm
Change-Id: I9c7f767077ed2e354d0980a9f11246c1151c65e2
2020-10-27 13:53:08 +00:00
Pau Espin 0a446a1804 gb: ns2_sns: Add missing value_string entry for GPRS_SNS_EV_NO_NSVC
Change-Id: Ifd4501676217f1a27f3ee02156be4e3dcb847703
2020-10-27 13:30:08 +01:00
Pau Espin 7fbe7cfcd7 gb: ns2_sns: Fix missing trailing newline char in log line
Change-Id: I8dc45237a605e76e852a74a0de91ac2a812387d0
2020-10-27 13:27:18 +01:00
Vadim Yanitskiy 0a2d9bdfae vty/command: fix: restrict the expert mode to the current session
Having the expert mode flag stored in the global 'host' structure
was a bad idea, because this way it applies globally.  In other
words, if user Bob activates the expert mode in his dedicated
session (e.g. a telnet connection), then not only him, but all
other users would see the hidden commands in their VTYs.

Moreover, if somebody deactivates the expert mode, it would also
affect the Bob's VTY session.  And finally, terminating a VTY
session would not deactivate the expert mode.

Let's move that flag from the global 'struct host' to 'struct vty'
representing an individual VTY session, so then the expert mode
would only affect the session where it was activated.

In functions related to the XML VTY reference generation we don't
have access to 'struct vty' (there may be no VTY session at all).
Add two additional arguments to vty_dump_nodes(), indicating the
global flag mask and a matching mode.  This would allow to match
the VTY commands in many different ways, e.g. one can dump hidden
commands only, or all commands except the library specific ones.

Change-Id: Iba13f0949061e3dadf9cf92829d15e97074fe4ad
Related: SYS#4910
2020-10-25 16:52:42 +07:00
Vadim Yanitskiy f36b76211f application: do not document unrelated forward-declarations
Change-Id: Ic04caab15abbd0c0d3a01f6e128935a3ceed903e
2020-10-24 04:08:19 +07:00
Harald Welte b904e428aa select: Migrate over to poll()
select is an ancient interface with weird restrictions, such as
the fact that it cannot be used for file descriptor values > 1024.

This may have been sufficient 40 years ago, but certainly is not in
2020.  I wanted to migrate to epoll(), but unfortunately it doesn't
work well with the fact that existing programs simply set osmo_fd.flags
without making any API calls at the time they change those flags.

So let's do the migration to poll() as a first step, and then consider
epoll() as a second step further down the road, after introducing new
APIs and porting applications over.

The poll() code introduced in this patch is not extremely efficient,
as it needs to do extensive linked list iterations after poll() returns
in order to find the osmo_fd from the fd.  Optimization is possible,
but let's postpone that to a follow-up patch.

At compile time, a new --enable-force-io-select argument can be given
to configure, forcing the use of the old select() backend instead of the
new poll() based backend.

Change-Id: I9e80da68a144b36926066610d0d3df06abe09bca
2020-10-23 15:09:05 +00:00
Vadim Yanitskiy 6760845da6 vty/command: add CMD_ATTR_HIDDEN to CMD_ATTR_PUBLIC_MASK
Otherwise in the expert mode, hidden commands do not get the
associated attribute printed to the XML VTY reference.

Change-Id: I8ded973031beb6d8c7ad55f06641c9651b1d9e71
Related: OS#4910
2020-10-23 20:37:37 +07:00
Vadim Yanitskiy 4165d048f3 vty/command: introduce vty_dump_xml_ref_mode()
This change introduces an enumerated type 'vty_ref_gen_mode' that
(as the name suggests) defines the VTY reference generation mode:

  - DEFAULT - all commands except deprecated and hidden,
  - EXPERT - all commands including hidden, excluding deprecated;

and a new function vty_dump_xml_ref_mode(), that allows to specify
that mode.  The old vty_dump_xml_ref() is now deprecated.

Change-Id: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Related: SYS#4910
2020-10-23 20:20:23 +07:00
Vadim Yanitskiy efe1342b62 vty/command: make some 'struct cmd_element' pointers const
Change-Id: I4a8b3bada44538a5e5711bbc4dccf8b2cf3e2e08
2020-10-21 20:36:21 +07:00
Pau Espin 76190d308d lapdm: Allow SABM L=0 in Timer Recovery State
3GPP TS 44.006 8.6.3 "Procedures for re-establishment" is quite
explicit:
"""
When the data link layer receives in the multiple frame established state
or !!!timer recovery state!!! a DL-ESTABLISH- REQUEST primitive from layer
3 or an SABM (with L=0), the normal establishment procedure of sub-clause
8.4.1.2 shall be initiated.
"""

If L>0 in that state, send a DM as stated in 8.4.1.2:
"""
If the data link layer entity is unable to enter the multiple-frame-established
state, it shall respond to the SABM command with a DM response with the F bit
set to the same binary value as the P bit in the received SABM command.
"""

Related: OS#4549
Related: OS#4819
Change-Id: I7959dc39f883cd5c56c36a21176a2401838d7b62
2020-10-21 13:03:30 +00:00
Pau Espin d5f7147419 lapdm: Split lapd_rx_u() spaghetti into one function per message type
Change-Id: Ia1a49f7ae1d133174fad7a396db72867612fa619
2020-10-21 13:03:30 +00:00
Pau Espin 16333bb58c lapdm: Drop log lines printing fmt=B
Change-Id: Ic8794ee66ddeb45ebcc7b9834f4d5e8321fd91f1
2020-10-21 11:54:23 +00:00
Vadim Yanitskiy 72b90883f9 vty: introduce the expert mode and a command to enable it
Some VTY commands are intentionally hidden, e.g. because they might
by relatively dangerous if used in production operation.  We equip
such commands with a special attribute - CMD_ATTR_HIDDEN.

The problem is that neiter they appear in the XML VTY reference,
nor in the online VTY help, so it's a bit tricky to invoke them.
This change introduces so-called 'expert' mode, in which hidden
(but not deprecated) commands are getting visible.

In the (telnet) VTY session, this mode can be activated by passing
an additional argument to well-known 'enable' command:

  OsmoApp> enable ?
    [expert-mode]  Enable the expert mode (show hidden commands)
  OsmoApp> enable expert-mode
  OsmoApp#

so then hidden commands will appear together with all the other
commands.  They will be marked with a special '^' flag:

  OsmoApp# list with-flags
    ^ ...  foo-hidden [expert-mode]
    . ...  foo-regular-one
    ! ...  foo-immediate
    ^ u..  app-hidden-unbelievable

For the XML reference generation, additional API needs to be
introduced.  This will be implemented in subsequent patches.

Change-Id: Ie69c2a19b22fb31d7bd7f6412f0aeac86ea5048f
Related: SYS#4910
2020-10-21 06:27:48 +07:00
Vadim Yanitskiy e7bf4354b9 logging: introduce 'systemd-journal' target
This change implements 'systemd-journal' logging target, that is
similar to the existing 'syslog' target.  The key difference is
that 'systemd-journal' allows us to offload rendering of the meta
information, such as location (file name, line number), subsystem,
and logging level, to systemd.  Moreover, we can attach arbitrary,
user-specific fields [1] to the logging messages, so they can be
used for advanced log filtering (e.g. by IMSI/TMSI/TLLI):

  $ journalctl OSMO_SUBSYS=DMSC -f

Since we don't want to make libsystemd a required dependency, this
feature is optional, and needs to be enabled at build-time:

  $ ./configure --enable-systemd-logging

The new logging target can be configured in the same way as any
other one - via the VTY interface, or using the configuration file:

  log systemd-journal [raw]
    logging level set-all notice
    logging filter all 1

Two logging handlers are available: generic and raw.  The first one
behaves similarly to both 'syslog' and 'stderr', i.e. all the meta
information is rendered by libosmocore itself, and then passed to
systemd together with the logging message.  The later is more like
the 'gsmtap' target, so all available meta information is handed
over to systemd in form of fields [1]:

  - CODE_FILE / CODE_LINE - location info,
  - PRIORITY - syslog-compatible logging level,
  - OSMO_SUBSYS - Osmocom-specific sub-system (e.g. DMSC),
  - OSMO_SUBSYS_HEX - same as OSMO_SUBSYS, but encoded in hex,
  - MESSAGE - the logging message itself,

and then can be rendered in any supported format (e.g. JSON).

More details about the API can be found in [2].

[1] https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html
[2] https://www.freedesktop.org/software/systemd/man/sd-journal.html

Change-Id: I609f5cf438e6ad9038d8fc95f00add6aac29fb23
2020-10-19 15:02:00 +00:00
Harald Welte 7e65791b66 select: Introduce osmo_fd_{read,write}_{enable,disable}()
If we watn to migrate to something like epoll(), user application
code must call a function of the libosmocore API whenever it changes
its read/write interest in a file descriptor.

Let's introduce API so applications can be ported to this API,
before making direct 'ofd->when' manipulations illegal as a second step.

Change-Id: Idb89ba7bc7c129a6304a76900d17f47daf54d17d
2020-10-19 09:54:17 +00:00
Harald Welte fa2d66ca18 ns2: More verbose comments on gprs_ns2_vc_mode
Change-Id: I647b9d883c1acc47cd352196a819a9c9bf8dc6ff
2020-10-17 13:10:08 +02:00