Commit Graph

124 Commits

Author SHA1 Message Date
Oliver Smith 04bfb7165b treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I5050285e75cf120407a1d883e99b3c4bcae8ffd7
2021-12-14 12:44:03 +01:00
Neels Hofmeyr 34907fe6e1 revisit some calls of strtol(), stroul(), strtoull()
Replace some with atoi(), where the VTY has already validated correct
range of the argument.

Replace others with the new osmo_str_to_int() or osmo_str_to_int64()
functions, possibly covering more detection of invalid number strings.

Leave those strtol() callers that depend on endptr to provide the next
string token.

Related: SYS#5542
Change-Id: I0ebb06e751c28f7d1cdf328de29cd227a2449391
2021-10-04 11:24:59 +00:00
Harald Welte 53b4bbb955 osmo-auc-gen: Print RFC3310 IMS HTTP-AKA style base64 nonce/res
This is useful when debugging IMS Authentication which uses
RFC3310 representation of the nonce and expected result.

Change-Id: Ibfa72410d8ff8e5b42063f1a12bff69ad2bebbb8
2021-09-21 19:57:56 +00:00
Harald Welte b48f438ae9 osmo-auc-gen: Permit specifying the SQN in hex (0x12345) format
Use base '0' of strtoul to permit both decimal and hexadecimal input
to the SQN parameter.  Some other tools represent the SQN as hex,
so this avoids having to use some external tool to convert and allows
you to copy+paste it to the osmo-auc-gen command line.

Change-Id: I67c6341a989de433451994b824e12afd0c26cb8a
2021-09-17 07:57:23 +02:00
Harald Welte 9fb5d80007 osmo-aka-verify: Fix use case with OP and not OPc
Change-Id: Ic6b5da83276ce2618cd80c6d34d3322bad7b4c48
2021-03-22 11:53:23 +01:00
Vadim Yanitskiy c3c914a5df utils/osmo-aka-verify: fix swapped CK/IK arguments
The positions of arguments in the call to "milenage_check" do not
match the ordering of the parameters:

  * "ck" is passed to "ik"
  * "ik" is passed to "ck"

Let's simply reorder the arguments of milenage_check()
to match the ordering in milenage_f2345().

Change-Id: Ia003d3c9d88fb8f6740791583855a709b8639160
Fixes: CID#220324
2021-03-21 22:36:43 +01:00
Harald Welte 8602106224 utils: osmo-aka-verify to verify UMTS AKA (SIM side)
This new utility implements the UMTS AKA procedures of the SIM
side.  It can be used to manually verify the correctness of
authentication tuples received from the network.

Change-Id: I497747fbf09f633dcd7c592bd9af7fca9a820645
2021-03-20 11:00:27 +00:00
Pau Espin 01e0d3e7fd Drop use of log_set_print_filename() API inside libosmocore
Let's use 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: Ifc78e1dcba5baf0b41f6ccbbbd1e3f06552d73da
2021-02-20 17:13:58 +00:00
Harald Welte 9bbb703a95 osmo-ns-dummy: Add "mirror-mode" to mirror back any received packets
Change-Id: If57bfdeb390d88d1ea058f7a9ce0403e64a5beda
2021-02-02 11:37:48 +00:00
Harald Welte 0b7614b408 osmo-ns-dummy: Add simple NS traffic generator
This adds a simple NS traffic generator that can be used to perform
load testing on NS links, particularly those with limited bandwidth
such as frame-relay E1 lines.

Related: OS#4995
Change-Id: Iad3b694c85962dbbc6b4a27a0ed5bc841add464f
2021-01-30 22:13:03 +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 fd96dc5343 osmo-ns-dummy: don't leak primitive messages
The message in the primitive must be freed by the user

Change-Id: I2a7b19f019485c7b1f15baf20b62edc19b663415
2021-01-19 19:33:41 +01:00
Alexander Couzens 03f88d910e osmo-ns-dummy: allow to create dynamic NSEs
Without setting the flag the osmo-ns-dummy won't create
any dynamic NSEs.
This flag will be removed in a future release but for now
it will be included.

Related: SYS#5208
Change-Id: I196cc454b5d7bc53848f73596a2f92730b78922b
2021-01-17 16:11:36 +01:00
Alexander Couzens c0d02cc163 utils: add osmo-ns-dummy
A dummy client to do integration tests of the ns2 layer.
It drop all unit data. But allows vty tests.

Change-Id: I127c178426bc1a3da8de251740eda93853030d6d
2021-01-01 22:46:57 +01:00
Vadim Yanitskiy 81be7c1175 utils/gsmtap_logread.py: make it executable
Change-Id: I2a3ee31ddc8838ce8e7a58de89a0e606ae918c6a
2020-08-04 14:27:50 +00:00
Harald Welte 3a6bedf1e5 sim: When decoding SW, take application specific SW into account
So far we only looked at SW definitions of the card profile. However,
if we have a currently selected application, we also must check
that application for SW definitions.

This breaks ABI and API all over the place, but as there are no
known users beyond osmo-sim-test, this is acceptable.

Change-Id: I3a1d60898529c173f73587e34c155660ba5f5fb1
2020-05-05 19:41:12 +00:00
Harald Welte 17051403bf osmo-sim-test: Avoid double-close
Change-Id: Ibd67a5461085a77dd9e804a4f1266d67ee91a04a
Closes: CID#208960
2020-03-22 11:26:24 +01:00
Harald Welte 58d173ade1 osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cards
an USIM application can very well exist on a UICC without supporting
classic DF.GSM access.  However, most commonly, both are found on
cards.

Change-Id: I6180a3f81a7d3006e8ece4302c2433db2588bfaa
2020-03-21 16:31:17 +01:00
Harald Welte 429adecfd8 sim: re-structure how we support cards + applications
Before this change, a card application (USIM, ISIM, ...) didn't
exist as a separate concept from a card profile.  This meant,
we had a manual combination of UICC card profile with USIM application,
and another one of UICC card profile and ISIM application.  But what
if there's a combined USIM+ISIM?

In reality, applications exist as separate objects, on top of an
ETSI UICC.  Lets therefore register all known applications to the
osim library core, and add code to osmo-sim-test which dynamically
detects all applications present on a given card (by reading EF.DIR).

Change-Id: Ic4b4ac433a9976842b30a017fb0fc347d87201cd
2020-03-21 16:31:17 +01:00
Harald Welte 870f94d0cc osmo-sim-test: Optionally dump card files to host filesystem
Using the new '--output-dir' command line argument, the user can
instruct osmo-sim-test to dump the file content to a local directory.

osmo-sim-test will create one sub-directory per DF, and create a
text file for each EF.  The contents of the text files are a hexdump
of the contents.  Transparent EF are dumped as one line of hex,
while linear fixed EF are dumped as one record per line, i.e. the
number of lines corresponds to the number of records.

Change-Id: I35176f4a13c3537eaa8de550e231818a22b4c07c
2020-03-21 16:31:10 +01:00
Harald Welte 8d934efbb9 osmo-sim-test: don't print SW in successful case of dump_file()
Change-Id: Ie5a58a89052400d76a8607a2e0063917385beb25
2020-03-21 16:24:53 +01:00
Harald Welte 835ed9644d osmo-sim-test: Use stderr for error messages
Change-Id: I8f36b07b8601af2b0d54d95c3c6374d6c54bafd1
2020-03-21 16:24:53 +01:00
Philipp Maier 31c29ea051 conv: add convolutional coder for AMR SID UPDATE frames
AMR SID update frames are protected using an 1/4 convolutional coder,
wich is similar to the one used with 6,7 kbit voice frames. Except that
there is no puncturing and the length is different.

Change-Id: Ia35ed4178a7f0d816052b7e5d6478b93a1d9744f
Related: OS#2978
2020-03-09 13:40:27 +01:00
Philipp Maier fde9fdc1d3 osmo-sim-test: check tlv_parsed struct tp before access
The variable struct tlv_parsed tp in dump_file() conditionally
initalized by tlv_parse() but later it is accessed under a different
condition without a check that makes sure that tp is only accessed when
tlv_parse() was called beforehand. Lets introduce a check that makes
sure tp can not be accessed when it is uninitalized.

Change-Id: I6b0209b966127a4195e6f4bcb43d49387c7646ce
Fixes: CID#208435
2020-03-04 20:49:13 +00:00
Harald Welte 053bebc7ce osmo-sim-test: Fall-back to classic SIM
If selection of ADF_USIM fails, let's fall-back to reading/dumping
a classic TS 11.11 (51.011) SIM card.

Change-Id: I5a986fc65de76c24c5af52ce7e8c699cf302fda9
2020-02-15 19:04:43 +01:00
Harald Welte 3a1a3bb887 osmo-sim-test: Recurse through subdirectories
Don't just iterate over all files in the current working
directory (cwd), but also recurse through all sub-directories.

Change-Id: I737b01d9a845e37d8be9d4709ef0de04e749daec
2020-02-15 18:59:19 +01:00
Oliver Smith a47d37c946 debian, utils: switch to python 3
Make build and external tests work with python3, so we can drop
the python2 dependency.

This should be merged shortly after osmo-python-tests was migrated to
python3, and the jenkins build slaves were (automatically) updated to
have the new osmo-python-tests installed.

Related: OS#2819
Depends: osmo-python-tests I3ffc3519bf6c22536a49dad7a966188ddad351a7
Change-Id: I84ef43f700e125c7a65f92347f12844e07e65655
2019-12-12 09:24:04 +00:00
Eric Wild 94cd4acef8 sim: allow opening reader# > 0
Change-Id: I4b1abc8d8aae4bd9a32f927269d7ebfef902d7c5
2019-12-09 12:54:43 +01:00
Harald Welte 278a6c8fcf utils: exit(2) on unsupported positional arguments on command line
Change-Id: Icc76cae2225ec4e664b950176dd861fa15712f59
2019-12-03 21:35:48 +01:00
Harald Welte f7404bb473 osmo-arfcn: Fix '-h' option
Change-Id: I13decca25dcdb75191c1e78058704ae8efa69b33
2019-12-03 21:35:48 +01:00
Pau Espin d12f698dbb logging: Introduce mutex API to manage log_target in multi-thread envs
log_enable_multithread() enables use of locks inside the
implementation. Lock use is disabled by default, this way only
multi-thread processes need to enable it and suffer related
complexity/performance penalties.

Locks are required around osmo_log_target_list and items inside it,
since targets can be used, modified and deleted by different threads
concurrently (for instance, user writing "logging disable" in VTY while
another thread is willing to write into that target).

Multithread apps and libraries aiming at being used in multithread apps
should update their code to use the locks introduced here when
containing code iterating over osmo_log_target_list explictly or
implicitly by obtaining a log_target (eg. osmo_log_vty2tgt()).

Related: OS#4088
Change-Id: Id7711893b34263baacac6caf4d489467053131bb
2019-10-09 14:19:52 +02:00
Alexander Couzens 9b20741910 utils: add gsmtap_logread.py a gsmtap log reader
Receive gsmtap logs and feeds it into the python logging
framework. Allows to use generic logging features and
further utilities.

Change-Id: I24478d8e16066c6118e867bdba54c6418c15e170
2019-06-04 08:37:06 +00:00
Max 2e717c968d Add multipatch capability to osmo-config-merge
That's pretty straightforward and convenient extention: handle all
extra positional arguments as patch file names. This makes it similar to
'cp' and other coreutils basic tools. For example:
osmo-config-merge base.cfg patch1.cfg patch2.cfg patch3.cfg
will apply 3 patches to the base config file.

Change-Id: I212cbdc3bf6f251c1a3175737ac74242fb004c6d
2019-02-22 21:28:45 +00:00
Pau Espin c8772517d9 gsm: Deprecate buggy gsm_arfcn2band API and introduce gsm_arfcn2band_rc
ARFCNs are values in well defined ranges. Until this patch, ARFCNs not
belonging to any band were blindly assigned to DCS1800 by
gsm_arfcn2band, causing unnoticed bugs and misconfigurations in
osmo-bsc.

Previous API gsm_arfcn2band cannot accomodate this kind of check easily,
so let's deprecate it to tell people to use a new API gsm_arfcn2band_rc
which performs this kind of checks and allows callers to log failures,
misconfigurations, etc.
At the same time, modify implementation of gsm_arfcn2band to abort if an
invalid ARFCN is passed, this way users of this API can notice they are
passing wrong data to it that most probably will produce unexpected
results.

Related: OS#3063
Change-Id: I780d452dcebce385469e32ef2fd844df6033393a
2018-11-20 16:56:28 +00:00
Harald Welte 41b6b5e3fc osmo-config-merge: fclose() what we fopen()
Change-Id: Ib44f902e5bca2277f1b340d34fabbd2a298d683e
Fixes: Coverity CID#188851
2018-10-21 10:58:33 +02:00
Daniel Willmann 83c7134c7a osmo-config-merge: Fix some small issues
Allocate NULL context after exit_usage() calls and free it before exit
so * sanitizer is happy.
Also handle the error cases gracefully when a file is unreadable or
formatted wrong.

Change-Id: I966e63a3f7d0ff71ee0b88922aa3807d073aa232
2018-09-28 16:00:11 +02:00
Vadim Yanitskiy f7aec792f7 utils/osmo-config-merge: explicitly return from main()
This change fixes the following compiler warning:

  osmo-config-merge.c: In function ‘main’:
  osmo-config-merge.c:268:1: warning: control reaches end
                             of non-void function [-Wreturn-type]

Despite it isn't critical, let's get rid of this warning.

Change-Id: I7a80a85c8b3180dc086cd9fd20356aab16ea8100
2018-09-27 04:43:47 +07:00
Harald Welte eda6fe42a5 osmo-config-merge: Don't use C99 'for' loop initial declarations
The existing code passed gerrit build verification but failed the master
builds with the following error:

osmo-config-merge.c:148:4: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    for (int i = 0; i < cur_indent - indent; i++) {
    ^
osmo-config-merge.c:148:4: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your
code

Change-Id: Ia29e85b648c1a427be88242306634efe890e250d
2018-09-25 22:52:22 +02:00
Harald Welte 81bfef931a Add new osmo-config-merge utility
This utility allows you to merge an incremental config "patch"
into an osmocom-style config file.

The patch file follows the same syntax as the original config file.

It works by appending the leaf nodes of the patch file to the respective
nodes of the input config file.

This process allows configuration file changes/updates to be performed
in a more stable/reliable way than by means of [unified] diff files,
as they break every time the context lines break.

osmo-config-merge doesn't suffer from this problem, as it understands
the tree-like nature of VTY config files.

NITE: This only works with configuration files that have proper
indenting, i.e. every level in the hierarchy must be indented excatly
one character, not multiple.

Change-Id: I61997a3668cc3a40d12ca023272f6d782e6fbefe
2018-09-25 20:05:02 +02:00
Neels Hofmeyr 95fdbc14ff cosmetic: osmo-sim-test.c: use memcpy instead of strncpy
gcc 8.1.0 complains that the terminating \0 is not copied by strncpy, while
this code intends to do exactly that. Use memcpy instead.

Change-Id: I8d66fa22502c04d11ae153b9856d7e54f3492dd6
2018-07-27 18:15:44 +00:00
Vadim Yanitskiy 94c0031297 Don't enforce Python 2 for utilities
The conv_gen.py utility was tested against both Python 2 and 3,
so there is no need to enforce Python 2. Also, having:

  #!/usr/local/bin/python{2|3}

is a bad idea, because Python may be installed in a different location.

Change-Id: I6007d481047b584db13d6eda70fb99f11f9ddaa1
2018-07-02 20:30:31 +07:00
Harald Welte 4e4521b3d5 Revert "Use python 3 for utilities"
This reverts commit 76c6c50405, which broke the obs builds. I'm really starting to get annoyed by ongoing python related breakage without ever fixing any bugs!

Change-Id: I4d76e897d4f746ff9ea4e06f2efc708a12cc2944
2018-02-09 08:49:26 +00:00
Max 76c6c50405 Use python 3 for utilities
There're no python2-specific code in there so we can switch right away
without waiting till 2020 for python 2 deprecation.

Related: OS#2819
Change-Id: I8d34aed124b00c5dd2ab1bcc84bbfa8c620282cc
2018-02-08 09:31:04 +00:00
Max 32e5641dbb Add functions for extended RACH coding
Add support for extended RACH (11 bit) according 3GPP TS 45.003 §5.3.2:

* convolutional code with puncturing
* encoding/decoding routines
* corresponding tests

Change-Id: I85a34a82d5cd39a594ee89d91a2338226066ab5d
Related: OS#1548
2017-12-11 10:36:47 +00:00
Pau Espin c30a76b2d4 utils: Fix false positive in compiler warning
Fixes the warning below:
warning: ‘sqn’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    fprintf(stderr, "Requesting --sqn %"PRIu64" implies IND=%u,"
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     " so no further --ind argument is allowed.\n",
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     sqn, test_aud.u.umts.ind);
     ~~~~~~~~~~~~~~~~~~~~~~~~~

The warning is a false positive as sqn is only used in case
sqn_is_set!=0, and in that code path, sqn is set.

Change-Id: Ib5903db01ea6765bd6bb688e63f70925c5012f98
2017-11-16 16:16:08 +00:00
Max 38a49f6276 utils: move linked libraries into common variable
Change-Id: I54f4e439cc232d926b42ddba9648d4f5e7487c3e
2017-10-30 13:56:11 +01:00
Max 4b2b0cc15d Add function to generate random identifier
The function is a wrapper on top of getrandom() (if available via glibc) or
corresponding syscall. If neither is available than failure is always
returned.

It's intended to generate small random data good enough for session
identifiers and keys. To generate long-term cryptographic keys it's
better to use special crypto libraries (like GnuTLS for example)
instead.

As an example it's used to replace old insecure random number generator
in osmo-auc-gen utility.

Change-Id: I0241b814ea4c4ce1458f7ad76e31d390383c2048
Related: OS#1694
2017-10-09 10:18:07 +00:00