Commit Graph

870 Commits

Author SHA1 Message Date
Pau Espin 8698f273d2 .gitignore: Ignore *.pyc
vty/config tests were added recently, which use python and end up
generating __pycache__/osmoappdesc.cpython-311.pyc when run.

Ignore those files as done in other projects such as osmo-bsc.

Change-Id: I8129a4a124457411c8163089ec2bac32f3e1c2b7
2023-06-08 13:57:01 +02:00
Oliver Smith 7e6bce7322 systemd: depend on networking-online.target
Related: SYS#6400
Change-Id: I7e88d7f48fb1f359fc9147acf3e69525c856d4e8
2023-05-26 14:10:12 +02:00
Vadim Yanitskiy 1f50d451a0 copyright: fix typo: sysmocom s/s.m.f.c./s.f.m.c./ GmbH
Change-Id: Ibb6e904b3a2bb6e569bed76cad5e0c982e055612
2023-05-18 17:22:26 +07:00
Neels Hofmeyr 083ea4b1fc add public API: osmo_sccp_instance_next_conn_id()
In struct osmo_sccp_instance, we have a next_id, to find an unused SCCP
connection ID. This is used for inbound SCCP connections.

At the same time, in each of our SCCP client programs, we have a
separate mechanism to find a connection ID for outbound connections.

See for example bsc_sccp.c: bsc_sccp_inst_next_conn_id()

It makes much more sense for callers to use the same
osmo_sccp_instance->next_id counter:

- Currently the inbound and outbound counters go out of sync: For
  example, in osmo-bsc, if we have three MS doing a usual Complete Layer
  3, osmo-bsc's counter increments by three. If we then have one
  Handover Required coming back from the MSC, i.e. inbound SCCP
  connection, the sccp_inst->next_id is behind by three, and will
  iterate SCCP connections three times before finding an unused id.

- Each implementation has to take care to properly wrap the ID in its
  valid range, e.g. in osmo-bsc:

                test_id = (test_id + 1) & 0x00FFFFFF;
                if (OSMO_UNLIKELY(test_id == 0x00FFFFFF))
                        test_id = 0;

Add public API so that callers can benefit from the internal
osmo_sccp_instance->next_id and do not need to duplicate the code for
staying within the proper range.

Change-Id: If59d524fbe1088a59ae1b69908e2d4bf67113439
2023-05-10 02:17:07 +02:00
Neels Hofmeyr 8bc881f31a sccp_scoc.c: fix infinite loop on conn ID exhaustion
Looking for an unused SCCP connection ID has no exit condition if all
connection IDs are in use. However unlikely it is that there are
16777215 active connections on one SCCP instance, add an exit condition.

Do so by implementing the ID lookup in a new separate function, which
qualifies for public API (upcoming patch).

So far, use an exit condition closest to previous behavior: iterate the
entire SCCP conn id number space before exiting in failure.

Change-Id: Ib64e0cb1ae0cc8b7bebcb2a352d4068b496b304a
2023-05-10 02:17:04 +02:00
Neels Hofmeyr d5139548f2 add osmo_sccp_set_max_optional_data()
So far, the optional data limit can only be modified via cs7 VTY,
because struct osmo_sccp_instance is private. Provide public API to set
this limit from C.

Change-Id: If3d22a0f65a7ed0be043027652402b32c356e322
2023-05-10 02:00:25 +02:00
Oliver Smith 42ebd023b7 debian: set compat level to 10
Related: OS#5958
Change-Id: I6ee4aace6bf7c246338408c41f790189d75d5488
2023-04-27 12:27:46 +00:00
Neels Hofmeyr a0fbeeb4d2 SCCP: implement variable limit on Optional Data (CR,CC,CREF,RLSD)
When the Optional Data surpasses 130 bytes, it is not sent as part of
SCCP CR, CC, CREF or RLSD messages, but gets sent separately in a Data
Form 1.

Make this 130 user configurable. This is specified to be 130 bytes
exactly, but to interop with non-conforming peers, make this limit
adjustable per cs7 instance, via osmo_sccp_vty_init().

Add and test new VTY config:

	cs7 instance N
	 sccp max-optional-data (<0-999999>|standard)

Related: ITU-T Q.713 4.2 to 4.5
Related: Ia68dad973ef18513b52f5accb5264c557c7295ea osmo-ttcn3-hacks
Related: SYS#6423
Change-Id: If35697234796af8943691b2de62218e7dc93a08c
2023-04-24 18:45:37 +02:00
Harald Welte 460ba631b5 ASPAC/ASPIA: Don't add routing context IE in ASP-role if routing context 0
If there is only one routing key (and hence routing context, and hence
AS) within one ASP, *and* the routing context is configured as 0 (zero),
we should not include the routing context IE.  This is the way how
libosmo-sigtran has always been special-casing routing context 0 meaning
"routing context is not used".  However, that was only working in SG
role (typical STP use case).  When operating in ASP role, the
special-case handling was missing, causing a routing context IE
containing zero to be included in the related transmitted M3UA ASPAC
and ASPIA messages.

Change-Id: I5ce89b393a3b950ab7fd1eace9038718c9efcc51
Closes: OS#6003
2023-04-15 20:34:33 +08:00
Harald Welte a54c714df3 cosmetic: Fix log message in routing table add error case
* crate -> create (typo)
* linkset -> AS (we're adding a route for an AS here, not a linkset)

Change-Id: I901aa68f64de3bee1766c356a1403b6ca57d5237
2023-04-15 01:35:21 +08:00
Neels Hofmeyr c3604fe9a9 comment: fix typo 'OSMO_ASCU_'
Change-Id: I1c0f501a7f828499c6112cab8aece20f7c34c118
2023-04-05 02:30:59 +02:00
Neels Hofmeyr 078622128a add two value_string[]s related to N-PCSTATE
Related: SYS#6319
Change-Id: I873ea30e8f64280487769668c748c67ce4ff4023
2023-04-05 02:30:59 +02:00
Vadim Yanitskiy 79c64ab555 osmoappdesc.py: also test doc/examples/osmo-stp-multihome.cfg
Change-Id: Ib6d0b0cdcfad165ad34d304069843c71f6eb06de
2023-03-30 02:36:26 +07:00
Vadim Yanitskiy 463888c1dc tests: execute osmotest{vty,config}.py against osmo-stp
Change-Id: Idd57757f251dd1c4d1c74d275b4c5d8beff304e5
2023-03-30 02:35:23 +07:00
Vadim Yanitskiy c5cae83315 tests: $(BUILT_SOURCES) is not defined, depend on osmo-stp
Change-Id: I4864f4d78095187f566bcde772b71665fa6e4729
2023-03-29 19:16:11 +07:00
Neels Hofmeyr 2e476c692b fix sccp_scoc state S_WAIT_CONN_CONF out_state_mask
In sccp_scoc_states, allow the state transitions present in
S_WAIT_CONN_CONF's event handler function scoc_fsm_wait_conn_conf(), and
thus fix handling of N-DISCONNECT while waiting for SCCP Conn Confirm.

Fixes this error:

 DLSCCP ERROR SCCP-SCOC(1016){WAIT_CONN_CONF}: transition to state IDLE not permitted! (sccp_scoc.c:1213)

S_WAIT_CONN_CONF happens when the caller sends an N-DISCONNECT during
S_CONN_PEND_OUT -- that means, while we are waiting for a CC from the
peer, the caller ends the conn. SCCP-SCOC still waits for the CC first.

When S_WAIT_CONN_CONF expires, the intended path is state change to
S_IDLE, which then deallocates the connection. Allow this state
transition from S_WAIT_CONN_CONF to S_IDLE.

When S_WAIT_CONN_CONF receives a CC, the intended path is to send a
RELRE and state change to S_DISCONN_PEND. Allow this state transition
from S_WAIT_CONN_CONF to S_DISCONN_PEND.

Change-Id: I8145e53124cabd76bd2cee159ab01306a1afaa27
2023-03-24 03:26:42 +01:00
Vadim Yanitskiy 2790599e56 tests: use -no-install libtool flag to avoid ./lt-* scripts
This option should be used for any executables which are used only
for testing, or for generating other files and are consequently never
installed.  By specifying this option, we are telling Libtool that
the executable it links will only ever be executed from where it is
built in the build tree.  Libtool is usually able to considerably
speed up the link process for such executables.

Change-Id: I9758aaaa56b2453f33f90400342ebd1fd412ec3a
2023-03-13 10:54:34 +00:00
Vadim Yanitskiy 002b4d29f9 tests/*/Makefile.am: -Wall is not a preprocessor flag
Change-Id: I1a143636dfc5d4ea85938472fd367ac88e3cc4ae
2023-03-13 10:54:34 +00:00
Vadim Yanitskiy 0e065be375 {examples,stp}/Makefile.am: fix typo in $(COVERAGE_[C]FLAGS)
Change-Id: I8dc7119765df97f44a6f2c5d6eecec847fcc46dc
2023-03-13 10:54:34 +00:00
Pau Espin 1e288b9614 sccp: Introduce APIs to get/set osmo_sccp_instance priv data pointer
The field already exists in the struct, but it's not really used
anywhere internally yet (and was not available externally).
Let's make it available to users of the API, similar to osmo_sccp_user_{get,set}_priv().
This way apps can easily store per-sccp-instance state.

Change-Id: I5643e6b14590b1478b3c8dabc8a7a619f5505409
2023-03-13 11:20:31 +01:00
Pau Espin 253c45307e Implement sccp_instance->connections as rbtree
As a result we move from:
INSERT=O(1) SEARCH=O(n) REMOVE=O(1)

to:
INSERT=O(log(N)) SEARCH=O(log(N)) REMOVE=O(log(N))

So we get rid of O(n) complexity every time we need to find a conn
object based on conn_id. When a big number of SCCP conns is handled,
this saves a lot of CPU time every time a conn needs to be looked up,
for instance each time a message is received.
For instance, given 1500 SCCP conns, searching is ~10 steps while it
took 1500 steps beforehand.

Morever, since when creating a new conn_id the code looks if it exists
prior to it, that means in practice inserting used to took O(n), while
now it takes O(log(N)).

Change-Id: I28ac67038207e2fad89ea291629cec5b2f912461
2023-03-10 17:56:42 +01:00
Pau Espin a19cf68c65 cosmetic: sccp.h: Fix trailing whitespace
Change-Id: I6b9cb5acffdf690f65e14dbdda7213b2e75c7ee1
2023-03-10 17:33:39 +01:00
Pau Espin d66c70208f sccp_scpc.c: Simplify conn_create()
Drop local variable with no real use, dereference sccp_instance pointer
once instead of potentially thousands of times.

Change-Id: Iee333fb38d7a37877c37c1de9719a6b67d9e8ed3
2023-03-10 16:25:38 +01:00
Pau Espin f031be9141 Avoid allocating conn_id 0x00FFFFFF
The 0x00FFFFFF source local reference is reserved in M3UA/SCCP, hence
avoid allocating a conn_id with that value since later on when reused as
a source local reference it would fail to be encoded.

Change-Id: Ifcf710ef6024286a1cc3473d6ea3f858552b9926
2023-03-10 16:21:30 +01:00
arehbein 41089524a3 Transition to use of 'telnet_init_default'
Related: OS#5809
Change-Id: Icc57c68337d55c6594c1c36e9bf41624d11dab0a
2023-02-28 10:32:07 +00:00
Vadim Yanitskiy 36d3877483 mtp_pcap: remove unused static_assert() macro definition
Change-Id: Ib0419a2de3aa09a2e1fba1fc2628f12295d83bda
2023-02-24 18:16:00 +07:00
Neels Hofmeyr f9b0746d7d fixup for: add osmo_scu_prim_name_c() / _buf()
I would like to tweak the names for the recently added functions, so
that they are more clear -- quickly before we release it or anyone uses
these.

Depends: libosmocore I9f43428af654a5674ac3035fe4db1394aac7a7af
Related: I4c1998fd7fee7282d107846dae2cff4b5ceb3a7b
Change-Id: If381f537ab91af1feef7f0e51921217f27e18e6a
2023-02-22 16:02:51 +01:00
Max 6e8241356b SS7: do not attempt transfer if AS is down
The attempt to route message via AS which is down will fail anyway:
let's make it explicit.

Add osmo_ss7_as_down() and use it to check AS state before transferring the message.

Change-Id: I0d5f3b6265e7fdaa79e32fbc30f829ef79e7dad1
2023-02-21 08:51:22 +00:00
Oliver Smith e753f21047 Run struct_endianness.py
Ensure there is no diff to prepare to run this in CI.

Related: OS#5884
Change-Id: I3909fd5a406e21f348ad8c1d5adc267551bfe2b2
2023-02-20 09:50:38 +01:00
Neels Hofmeyr 4c761ba304 add osmo_scu_prim_name_c() / _buf()
Add non-legacy string functions for osmo_scu_prim_name in the form of
_buf() and _c() signatures.

So far there is only osmo_scu_prim_name() using a static buffer.
Implement that using osmo_scu_prim_name_buf().

Change-Id: I4c1998fd7fee7282d107846dae2cff4b5ceb3a7b
2023-02-18 02:45:14 +01:00
Neels Hofmeyr ed4e7dbf86 sccp_scmg: ignore PCSTATE.indication
Silence the error log for PCSTATE.indication prims.

When running the HNBGW_Tests.ttcn suite, the osmo-hnbgw LOGL_ERROR is
spammed with messages like:

 DLSCCP ERROR unsupported SCCP user primitive N-PCSTATE.indication (sccp_scmg.c:298)

Add this prim to scmg_prim_cb() to just log on DEBUG that it is ignored.

Related: OS#5679
Change-Id: I5fd38afea94f48ed2f2fcd2d9baa8ec22a571b6b
2023-02-18 02:45:14 +01:00
Pau Espin dc9713a672 Bump version: 1.6.0.20-8b67-dirty → 1.7.0
Change-Id: I431dc58d5c4adfcb2c4ff19a95b31853618034b5
2023-02-07 14:37:23 +01:00
Harald Welte 8b671b073f cosmetic: fix typo in comment
Change-Id: I2e2b5ec36da9b50dcf13a0d7f497a9ca16e6a7a3
2022-12-10 12:52:58 +01:00
Harald Welte 99b912f94a SCOC: dump SUA header when logging "mismatching remote pc"
Provide some more information in the logs when this happens

Change-Id: Idd889b57e8f842e22e5ed54bea0821dcec0cd8ce
2022-12-10 12:51:47 +01:00
Pau Espin 2f648b2daf sccp: Validate local references > 0x00fffffe are not used
SUA allows references of 4 bytes, but SCCP/M3UA doesn't.

SUA: RFC3868 sec 3.10.4:
      The source reference number is a 4 octet long integer.
      This isallocated by the source SUA instance.
M3UA/SCCP: ITU-T Q.713 sec 3.3:
      The "source local reference" parameter field is a three-octet field containing a reference number
      which is generated and used by the local node to identify the connection section after the connection
      section is set up.
      The coding "all ones" is reserved for future use.

Related: SYS#6211
Change-Id: Ia547346bdae54a032d2198ecd4972fb3f8dd073e
2022-11-23 18:11:58 +01:00
Oliver Smith bd92ec7256 contrib/jenkins.sh: add missing 'make check'
Change-Id: I09b7e2223d19c9e055ecddf3b2690cdea26b9be7
2022-11-11 10:19:19 +01:00
Oliver Smith ef0d676741 tests: fix old-style function definition
Fix for:
  xua_test.c:575:6: error: old-style function definition [-Werror=old-style-definition]

Change-Id: Iccc942f9f25fb091045d906eb8be658b54c58529
2022-11-11 10:13:24 +01:00
Harald Welte 2ce7b758e3 Add -Werror=implicit-int -Werror=int-conversion -Werror=old-style-definition
... if --enable-werror is used

Change-Id: If344ef88121111db5365b8cee3cf3cd1283303c1
2022-11-03 11:58:36 +01:00
Max 71fc322431 Set working directory in systemd service file
By default systemd will execute service with root directory
(or home directory for user instance) which might result in
attempts to create files in unexpected place. Let's set it
to 'osmocom' subdir of state directory
(/var/lib for system instance) instead.

Related: OS#4821
Change-Id: If21e3471ec129892ff8b410db30d8ce0e4014e05
2022-09-09 18:39:08 +07:00
Max e5d615efdc SIGTRAN: cache Optional Data for SCCP CR/CC/RLSD
The length limit of optional Data parameter is 130 bytes according to ITU-T Rec Q.713 §4.2..§4.5. If we receive CR, CC or
RLSD message with bigger data - cache it if necessary and send via separate DT1 message after connection becomes active.

Fixes: OS#5579
Change-Id: I0033faf9da393418930252233ce74d62cd1cef8a
2022-09-07 17:36:30 +07:00
Max 56b7700910 SIGTRAN: arrange the comments in the encoder to match the spec
Related: OS#5579
Change-Id: Ib986137057856afb8725541d912db210a9a46294
2022-09-07 17:33:03 +07:00
Max e7228dbdd2 examples: update vty code
* document optional data parameter
* use argc to check for optional parameter presence

Related: OS#5579
Change-Id: I52d0823b7843aa61594e728a0fac19d884ff78fe
2022-08-22 20:33:12 +07:00
Max bb760c5915 SIGTRAN: add osmo_sccp_tx_disconn_data() helper
SCCP RLSD message might have up to 130 bytes of optional data according to ITU-T Rec Q.713 §4.5 - add helper which
allows sending it and use it in example code.

Related: OS#5579
Change-Id: I92ae22d2cab5863245fba3d904a300055fda34fe
2022-08-22 20:33:12 +07:00
Max 768f36440f SIGTRAN: error if attempting to send exceedingly big data
Previously DT1 message sent via osmo_sccp_tx_data() was silently truncating data if it was over 256 bytes. Let's fail
explicitly and let caller handle this.

Related: OS#5579
Change-Id: I8a67bc40080eb1405ab3b0df874e3ea20941a850
2022-08-22 18:36:51 +07:00
Max 196ddcbb05 SIGTRAN: add function to check connection existence
Add convenience helper to check if particular connection ID exists and use it to
properly report errors when attempting to send messages over non-existent connections.

Change-Id: Iffedf55b4c292ee6b2f97bcdeef6dc13c050ce01
2022-08-22 18:36:51 +07:00
Max 28a8e3e836 SIGTRAN: don't advance FSM on failed connection request
Return proper error code from packet encoding routine and check for it before switching FSM state as it creates
confusing mismatch with actual protocol state.

Related: OS#5579
Change-Id: I8431c77632014e2551d1da779afddffcd1bb541c
2022-08-22 18:33:23 +07:00
Max 43d7455089 Add basic readme for example code
Related: OS#5579
Change-Id: I4c76a48a76ca9afc960ea2f08229bacc79b6fe77
2022-08-21 21:53:40 +07:00
Max f4301b7f45 [cosmetic] sccp_scoc.c: constify function parameters
Related: OS#5579
Change-Id: I398e3efa3e097de8907617cfdf363e1d3b96f666
2022-08-21 21:52:45 +07:00
Max d388dead51 SCCP: Log more data on CR size error
Related: OS#5579
Change-Id: I4d7fc44fde5b900907ec5ebec0450040a764802a
2022-08-18 21:15:19 +07:00
Max 4f9c66dc0f SCCP: enforce optional data length limits
Limit length of optional Data parameter to 130 bytes to conform with ITU-T Rec Q.713 §4.2..§4.5 while receiving SCCP messages.

Related: OS#5579
Change-Id: Icc3bd0a71b29cf61a259c5d97e7dd85beb4397bd
2022-08-17 11:36:04 +07:00