aboutsummaryrefslogtreecommitdiffstats
path: root/utils
AgeCommit message (Collapse)AuthorFilesLines
2020-05-05sim: When decoding SW, take application specific SW into accountHarald Welte1-2/+2
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-03-22osmo-sim-test: Avoid double-closeHarald Welte1-4/+1
Change-Id: Ibd67a5461085a77dd9e804a4f1266d67ee91a04a Closes: CID#208960
2020-03-21osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cardsHarald Welte1-2/+2
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-21sim: re-structure how we support cards + applicationsHarald Welte1-51/+98
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-21osmo-sim-test: Optionally dump card files to host filesystemHarald Welte1-11/+97
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-21osmo-sim-test: don't print SW in successful case of dump_file()Harald Welte1-1/+0
Change-Id: Ie5a58a89052400d76a8607a2e0063917385beb25
2020-03-21osmo-sim-test: Use stderr for error messagesHarald Welte1-7/+7
Change-Id: I8f36b07b8601af2b0d54d95c3c6374d6c54bafd1
2020-03-09conv: add convolutional coder for AMR SID UPDATE framesPhilipp Maier1-0/+19
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-04osmo-sim-test: check tlv_parsed struct tp before accessPhilipp Maier1-4/+8
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-02-15osmo-sim-test: Fall-back to classic SIMHarald Welte1-20/+103
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-15osmo-sim-test: Recurse through subdirectoriesHarald Welte1-13/+39
Don't just iterate over all files in the current working directory (cwd), but also recurse through all sub-directories. Change-Id: I737b01d9a845e37d8be9d4709ef0de04e749daec
2019-12-12debian, utils: switch to python 3Oliver Smith2-2/+2
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-09sim: allow opening reader# > 0Eric Wild1-1/+49
Change-Id: I4b1abc8d8aae4bd9a32f927269d7ebfef902d7c5
2019-12-03utils: exit(2) on unsupported positional arguments on command lineHarald Welte2-0/+10
Change-Id: Icc76cae2225ec4e664b950176dd861fa15712f59
2019-12-03osmo-arfcn: Fix '-h' optionHarald Welte1-1/+1
Change-Id: I13decca25dcdb75191c1e78058704ae8efa69b33
2019-10-09logging: Introduce mutex API to manage log_target in multi-thread envsPau Espin Pedrol1-2/+2
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-06-04utils: add gsmtap_logread.py a gsmtap log readerAlexander Couzens2-0/+167
Receive gsmtap logs and feeds it into the python logging framework. Allows to use generic logging features and further utilities. Change-Id: I24478d8e16066c6118e867bdba54c6418c15e170
2019-02-22Add multipatch capability to osmo-config-mergeMax1-21/+45
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
2018-11-20gsm: Deprecate buggy gsm_arfcn2band API and introduce gsm_arfcn2band_rcPau Espin Pedrol1-1/+7
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-10-21osmo-config-merge: fclose() what we fopen()Harald Welte1-0/+2
Change-Id: Ib44f902e5bca2277f1b340d34fabbd2a298d683e Fixes: Coverity CID#188851
2018-09-28osmo-config-merge: Fix some small issuesDaniel Willmann1-4/+15
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-27utils/osmo-config-merge: explicitly return from main()Vadim Yanitskiy1-0/+2
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-25osmo-config-merge: Don't use C99 'for' loop initial declarationsHarald Welte1-2/+4
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-25Add new osmo-config-merge utilityHarald Welte2-1/+271
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-07-27cosmetic: osmo-sim-test.c: use memcpy instead of strncpyNeels Hofmeyr1-1/+2
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-02Don't enforce Python 2 for utilitiesVadim Yanitskiy2-2/+3
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-02-09Revert "Use python 3 for utilities"Harald Welte2-2/+2
This reverts commit 76c6c50405c6cbb1d08bdd7b5d27c657fa5d38b6, 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-08Use python 3 for utilitiesMax2-2/+2
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
2017-12-11Add functions for extended RACH codingMax1-1/+10
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-11-16utils: Fix false positive in compiler warningPau Espin Pedrol1-1/+1
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-10-30utils: move linked libraries into common variableMax1-3/+2
Change-Id: I54f4e439cc232d926b42ddba9648d4f5e7487c3e
2017-10-09Add function to generate random identifierMax1-8/+6
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-09-12osmo-auc-gen.c: squelch compiler warnings, move local varNeels Hofmeyr1-4/+3
The compiler thinks that ind or ind_mask may be used uninitialized, because it doesn't analyze the conditionality of command line arguments and other variables set accordingly. Make the compiler happy by zero initializing. Change-Id: I9ddcb0525159da520aceaeb6e908a735a003bb5a
2017-08-29umts aka: add sqn_ms out-param, print SQN.MS in osmo-auc-genNeels Hofmeyr1-0/+2
When doing UMTS AKA with AUTS, it can be interesting to know the SQN.MS that was encoded in the AUTS. The only way to know this is to provide it as a separate out-parameter from milenage_gen_vec_auts(), because the SQN.MS from AUTS stored in umts.sqn is immediately modified non-trivially by milenage_gen_vec(). Add sqn_ms to struct osmo_sub_auth_data to retain SQN.MS even after a vector was generated. Use this to print out SQN.MS for 'osmo-auc-gen -3 -A'. Adjust test suite expectations. Related: OS#2464 Change-Id: I9fc05bbf169d06716f40b995154fd42a3f91bef3
2017-08-29osmo-auc-gen: umts: print out the IND of the SQN usedNeels Hofmeyr1-3/+7
Make ind_mask available in the main(){} scope, in order to print out IND = SQN & ind_mask. Adjust test suite expectations. Related: OS#2465 Change-Id: I91eac53c4af66a58b9372d9baf5781fc9f29b1fc
2017-08-29osmo-auc-gen: umts: add --ind-len argNeels Hofmeyr1-1/+10
osmo-auc-gen so far does not allow indicating the IND bit length of SQN. A default of 5 serves most practical cases, nevertheless we should allow passing arbitrary IND lengths. Enhance the test suite to test --ind-len. Related: OS#2465 Change-Id: Ia1d8b6a823ffc92290b3e39e4e4665aeff80ccc0
2017-08-29osmo-auc-gen: umts: add --ind argNeels Hofmeyr1-1/+29
During UMTS AKA, the caller typically indicates which IND slot the next used SQN should belong to. Without this option, osmo-auc-gen will always produce SQN from IND-slot 0. Add --ind option. Enhance the osmo-auc-gen_test.sh to expect errors with useful printouts on stderr, and add tests that verify valid --ind ranges. Related: OS#2465 Change-Id: Ib60eec80d58ca9a0a01e7fbd2bcbbd4339b1a6d8
2017-08-29osmo-auc-gen: umts: use default of ind_bitlen = 5 instead of 0Neels Hofmeyr1-0/+1
Most USIM out there seem to use IND-length = 5 bits, so do sysmousim-sjs1. Currently from initialization we are using an IND length of zero in osmo-auc-gen, which produces confusing SQN results after AUTS: Where want SQN to be incremented to the next IND array, usually +32, an IND-len of 0 makes for only +1. As result, the osmo-auc-gen_test.sh produces SQN 32 instead of 24 after receiving SQN.MS = 23 from AUTS: adjust test expectations. Related: OS#2465 Change-Id: I9fcc11fa2b5816302dcc6b72249b1ee40d5a61f5
2017-08-29osmo-auc-gen: umts: properly request --sqnNeels Hofmeyr1-5/+17
The user supplied an --sqn to generate a vector for, but milenage_gen_vec() performs a nontrivial SQN increment before generating the vector. To end up with the user supplied SQN, we need to reverse this increment beforehand. Do this after all cmdline args have been parsed, in case one of them modifies the IND-bitlen parameter, which affects the SQN calculations. Related: OS#2464 OS#2465 Change-Id: Ic51a8f6333fee9c02b4073ca360991d0aa69c74f
2017-08-29osmo-auc-gen: umts: remove erratic SQN.MS printoutNeels Hofmeyr1-6/+0
osmo-auc-gen tries to be helpful by deriving the SQN.MS from the SQN that resulted from AUTS + milenage_gen_vec(), but there is actually no way to derive the actual AUTS SQN.MS from the resulting SQN. Completely drop the printout to prevent confusion. Adjust test suite expectations. Related: OS#2464 Change-Id: Ie2432c6d6a23818f7b3a29b1295dcbb505e2be53
2017-06-23doxygen: unify use of \file across the boardNeels Hofmeyr2-4/+6
Considering the various styles and implications found in the sources, edit scores of files to follow the same API doc guidelines around the doxygen grouping and the \file tag. Many files now show a short description in the generated API doc that was so far only available as C comment. The guidelines and reasoning behind it is documented at https://osmocom.org/projects/cellular-infrastructure/wiki/Guidelines_for_API_documentation In some instances, remove file comments and add to the corresponding group instead, to be shared among several files (e.g. bitvec). Change-Id: Ifa70e77e90462b5eb2b0457c70fd25275910c72b
2017-06-23doxygen: enable AUTOBRIEF, drop \briefNeels Hofmeyr1-2/+1
Especially for short descriptions, it is annoying to have to type \brief for every single API doc. Drop all \brief and enable the AUTOBRIEF feature of doxygen, which always takes the first sentence of an API doc as the brief description. Change-Id: I11a8a821b065a128108641a2a63fb5a2b1916e87
2017-06-22osmo-sim-test.c: Remove unused functionsPau Espin Pedrol1-37/+0
Change-Id: I3060cfee8ece86c4c89a65f93c9f5424df0c410b
2017-05-17utils/osmo-sim-test.c: strip unused variablesVadim Yanitskiy1-5/+1
Change-Id: Id577d9df5a814ad5aa00e1d04c4790d75d17ad7e
2017-03-20build: fix distcheck: include gen scripts in EXTRA_DISTNeels Hofmeyr1-0/+2
Change-Id: Id94d2fe83f080a18a2a686206bd21cf5fafe2fa7
2017-03-20build: conv_gen.py: ensure parent dirs of written files existNeels Hofmeyr1-3/+9
Previously, this would fail when generating to $builddir if that subtree did not exist yet in $builddir. Change-Id: Ia4fba96dcf74a25cf3e515eb3e4f970e0c3cdd54
2017-03-20osmo-auc-gen: fix --sqn limit on 32bit systems, fixing buildNeels Hofmeyr1-3/+1
osmo-auc-gen on 32bit systems allowed only --sqn up to 32bits width. However, the recently added regression test for osmo-auc-gen includes an ivocation with a 48bit wide --sqn, which now causes the builds to fail on 32bit systems. Fix the --sqn argument parsing for larger integers by using strtoull(). Do away with the intermediate variable 'ul' and place the value directly in the auth data struct. Change-Id: Ifb73b3b3de06576e36076ca573d52327f90a1f77
2017-03-15osmo_auth_gen_vec: UMTS auth: store last used SQN, not nextNeels Hofmeyr1-5/+7
Prepare for the implementation of splitting SQN increments in SEQ and an IND part; particularly to clearly show where the changes in auth/milenage_test's expectations originate. Rationale: the source of UMTS auth vectors, for us usually OsmoHLR, typically stores the last used SQN, not the next one to be used. Particularly with the upcoming fix of the SQN scheme, this change is important: the next SQN will depend on which entity asks for it, because each auth consumer may have a particular slot in the IND part of SQN. It does not make sense to store the next SQN, because we will not know which consumer that will be for. The milenage_test has always calculated a tuple for SQN == 34. To account for the increment now happening before calculating a tuple, lower the test_aud->sqn by one to 0x21 == 33, so that it is still calculating for SQN == 34. Because we are no longer incrementing SQN after the tuple is generated, milenage_test's expected output after doing an AUTS resync to 31 changes to the next SQN = 32, the SQN used for the generated tuple. (BTW, a subsequent patch will illustrate AUTS in detail.) osmo-auc-gen now needs to pass the user requested SQN less one, because the SQN will be incremented befor generating the auth vector. Also the SQN remains the same after generating, so SQN output needs less decrementing. Note that the expected output for osmo-auc-gen_test remains unchanged, hence the same input arguments (particularly -s <sqn> and -A <auts>) still produce the same results. Note: osmo-hlr regression tests will require adjustments when this patch is merged, because it must now pass desired_sqn - 1 instead of just desired_sqn. See osmo-hlr change-id I4ec5a578537acb1d9e1ebfe00a72417fc3ca5894 . Related: OS#1968 Change-Id: Iadf43f21e0605e9e85f7e8026c40985f7ceff1a3
2017-03-15osmo-auc-gen: clarify SQN output, prepare for SQN changesNeels Hofmeyr1-15/+10
Upcoming patches will change the way SQN are incremented. Change the SQN related output by osmo-auc-gen so that it also makes sense after these changes, and so that its output is proven to remain unchanged for the same arguments: Always show the SQN used for vector generation when a UMTS vector was generated. Don't show the next SQN, it will not make sense anymore (see later patches). The adjustments of expected output of osmo-auc-gen_test illustrates how the output changes. Related: OS#1968 Change-Id: I35d9c669002ff3e8570e07b444cca34ce57c3b0c
2017-03-07libosmocoding: migrate transcoding routines from OsmoBTSVadim Yanitskiy1-0/+24
There are some projects, such as GR-GSM and OsmocomBB, which would benefit from using one shared implementation of GSM 05.03 code. So, this commit introduces a new sub-library called libosmocoding, which (for now) provides GSM, GPRS and EDGE transcoding routines, migrated from OsmoBTS. The original GSM 05.03 code from OsmoBTS was relicensed under GPLv2-or-later with permission of copyright holders (Andreas Eversberg, Alexander Chemeris and Tom Tsou). The following data types are currently supported: - xCCH - PDTCH (CS 1-4 and MCS 1-9) - TCH/FR - TCH/HR - TCH/AFS - RCH/AHS - RACH - SCH Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1