Commit Graph

270 Commits

Author SHA1 Message Date
Harald Welte c0f0007292 import oap message parsing / encoding from openbsc.git; AGPL->GPL
In the process, also:
* Change the license from AGPLv3 to GPLv2-or-later;
* correct spelling of 'sysmocom' to lowercase;
* add '2016' to the copyright;
* rename to osmo_*;
* add API docs;
* add logging category DLOAP: define id and add to internal_cat;
* redirect all oap.c logging to DLOAP.

A unit test will follow in a subsequent patch, since it needs a minor tweak for
decoding of boolean values.

The related openbsc change-id is I2f06aaa6eb54eafa860cfed8e72e41d82ff1c4cf.

Tweaked-by: Neels Hofmeyr
Change-Id: If5099e60681a215e798b6675f21813f26769c253
2016-12-11 03:42:58 +01:00
Neels Hofmeyr 665d48bf15 cosmetic: gsup comments: write 'Generic' for the G in GSUP
The G used to mean GPRS, but the scope is larger now. To satisfy the curious
reader, give the G a name in gsup files' header comments. BTW, logging.h and
gsup_test.c already mentioned "Generic" before this.

Change-Id: I6ac5cf94c215e156ceff6a58da3d9e520ca942d9
2016-12-09 16:47:05 +01:00
Neels Hofmeyr 5f460dee3d license: gsup: libosmogsm requires GPL, not AGPL; say 'sysmocom'
The copyright in gsup.h differed from the one in gsup.c: gsup.c names the GNU
Affero GPL, gsup.h only the GNU GPL. Change both to GPL-v2-or-later.

In gsup.c/h's copyright notice, 'sysmocom' should be spelled lower case.

Change-Id: Ia5748c275501889b9086aef7d20ccb5c9edb8031
2016-12-09 16:47:05 +01:00
Neels Hofmeyr bc1d758299 gsm0480: add gsm0480_create_ussd_notify() and *_release_complete()
Add two functions to create USSD messages. Moves and generalizes code from
openbsc. Pending: use the new functions in openbsc.

It looks like _release_complete() should also set trans_id and direction flag;
but since this is moving code from openbsc that is apparently working, just
place a fixme comment and don't change the functionality.

Change-Id: Ia80e32c7105359915bfad3cc5621a1c09caf20f0
2016-12-01 15:54:35 +00:00
Neels Hofmeyr 25774b9839 gsm0480: code dup: introduce and use gsm0480_l3hdr_push()
Add function gsm0480_l3hdr_push() to push a struct gsm48_hdr to the start of a
msgb. Use in gsm0480.c and gsm0411_utils.c. Further callers of the new function
will follow in openbsc as well as another libosmocore patch for ussd.

Change-Id: I54fce6053ab8362015686fe22dbcd38bf1366700
2016-12-01 15:54:34 +00:00
Harald Welte 1fa78567e4 osmo_gsup_encode(): Make coverity happy by invariant checking
gsm48_encode_bcd_number() can theoretically return a length in excess of
the size of the bcd_buf, but only in case an overly-long IMSI is passed
into the function (which would be illegal in the first place).

Change-Id: If3dc68ee13ff784b487bbc686b777cec9057d537
Fixes: Coverity CID 135216
2016-11-26 13:47:14 +00:00
Max 9b4d065ba5 Extend IPA error logging
Output more information in case of IPA protocol errors to make debugging
easier.

Change-Id: I7632d6e679e076bfbec9abc12da4a46cc27ccea1
Related: SYS#3028
2016-11-16 09:29:23 +00:00
Harald Welte c4193d30e8 gan: Mark gan_pdisc_vals[] as public / non-static symbol
It is actually listed in libosmogsm.map, but still used to be a static
symbol.  That couldn't have worked.

Change-Id: I6f3f04b683d906674ee7da9bab5762bb00cea916
2016-11-11 14:49:14 +00:00
Philipp Maier 72e43f02c3 gsm0408: Completing GSM 04.08 RR message types
- Add missing message types to be up to date with the
  latest specification release (3GPP TS 04.18)

- Add value strings to translate RR message type identifiers
  into human readable strings. (see gsm48_rr_msg_name() in
  gsm48.h

Change-Id: I3ceb070bf4dc8f5a071a5d43c6aa2d4e84c2dec6
2016-10-27 13:36:42 +02:00
Philipp Maier ada0042c58 COSMETIC: moving rr_cause_name() in gsm48.c
rr_cause_name() is located a far of from
value_string rr_cause_names[] while other value string
functions are located right below their related value
string definitions. This commit moves rr_cause_name()
below rr_cause_names[] as it should be

Change-Id: Ie6c03a6ea02c370d8733db5ba2a709610cd70ce7
2016-10-27 13:36:42 +02:00
Vadim Yanitskiy a6b5216ab4 utils/conv_gen.py: add EDGE MCS 1-9 definitions
Change-Id: Ie1452342f524a8b60f2babc07398a1d9c9e06aa3
2016-10-23 07:38:16 +00:00
Vadim Yanitskiy f3d38c4937 utils/conv_gen.py: add RACH, SCH and TCH/AHS definitions
Change-Id: I0ea7151f4e8119a8798a9e129b951559e56b0d93
2016-10-23 07:38:15 +00:00
Vadim Yanitskiy d2d9760c08 utils/conv_gen.py: generate a single file
Instead of generating every convolutional code into a separate
file (such as conv_xcch_gen.c, conv_cs3_gen.c), it is better to
have a single file, containing all definitions, because as many
convolutional codes we add, as many entries we will have to add
into 'src/gsm/Makefile.am'. This approach increases readability
of the Makefile.am, and also makes us able to share some data
between some convolutional code definitions.

For example: xCCH, RACH, SCH, TCH/F, both CS2 and CS3 may use
the same *_state[][2] and *_output[][2] arrays within a single
file. This optimization is currently WIP.

Change-Id: Ib4e4ee5fdde38429e68e3b2fa50ec03a18f59daa
2016-10-23 07:38:15 +00:00
Neels Hofmeyr 2b3c228416 gsm/Makefile.am: use proper top_builddir/top_srcdir paths
This fixes the conv*gen.c targets when building in a different directory
than the source tree.

Notably, building in a different dir worked when the generated sources were
already present from a previous build inside the source directory.

Change-Id: I5a9b780ad4ba607ea39854dcf7207ed05f5447bc
2016-10-12 22:50:24 +00:00
Neels Hofmeyr a95ee5e6e1 fix USSD: SS message type mask should be 0x3f, not 0xbf
See 04.80[1], section 3.4: the highest two bits are used as counter or ignored
and do not contribute to the SS "Miscellaneous message group". Previous mask of
0xbf included the highest bit, fix to 0x3f.

Observed a value of 0xbb that should mean 0x3b="Register" during testing of 3G
USSD requests, which seem to be the first to send a nonzero highest bit to our
code. The erratic mask of 0xbf lead to an unhandled message type of 0xbb.

[1] 3GPP TS 24.080 version 7.2.0 Release 7 / ETSI TS 124 080 V7.2.0 (2006-09)

Change-Id: I299001a9e36c16f55622a0acd5d4a55ca49d0055
2016-10-12 09:26:52 +00:00
Neels Hofmeyr 0318f6b6ca IuPS: add GMM Service Request related constants and value_str
Change-Id: Ie023fc78099932f95cc8f1b3a04fe25dfd14bc35
2016-08-29 13:56:17 +02:00
Harald Welte f92e44c539 lapd_core: Fix crash in lapd_dl_flush_hist()
When lapd_dl_flush_hist() was called before we actually had started a
transmit history from lapd_dl_init(), we woul segfault before this
patch.

Change-Id: Ifa677c9b335dd2884b4f3e44699d901957a0500b
2016-08-01 00:27:37 +02:00
Tom Tsou 9a5bbf36b5 egprs: Add CPS tables from TS 04.60
Includes EGPRS coding and puncturing scheme (CPS) tables from 3GPP
TS 04.60. Currently osmo-bts-trx is the only user of CPS table
values, but this may change with gprsdecode and other utilities.

Change-Id: I09fe6514a0e2e51bb3206f8387633f7e0255345f
2016-07-25 18:33:26 +00:00
Neels Hofmeyr 47390764dd rsl: add rsl_act_type_name()
Change-Id: Ie90c76d8aef42d5e2c9be94f4b206d4994e305f8
2016-07-23 15:32:55 +02:00
Neels Hofmeyr fd80f5a042 dyn TS: add definitions for dynamic TCH/F_TCH/H_PDCH
Add:
* GSM_PCHAN_TCH_F_TCH_H_PDCH
* NM_CHANC_OSMO_TCHFull_TCHHalf_PDCH
* RSL_CHAN_OSMO_PDCH
* RSL_ACT_OSMO_PDCH

Related: OS#1776
Change-Id: Ib1a8b11f37af4686d00ac88beba38557aa29edc2
2016-07-23 15:32:55 +02:00
Neels Hofmeyr 505adee93b fix compiler warning: gsup.c: missing braces
osmo_auth_vector's first member is an array, so for a zero initializer, we
should add a second set of array braces.

Change-Id: Iace448caca8152e46244f26c3af250f2035c99eb
2016-07-17 07:44:11 +00:00
Max 4f169500df Add GEA3 & GEA4 ciphers
Corresponding test code include both official test vectors from the
specs and data from over-the-air tests.

This obsoletes libosmo-crypt-a53 as it was last missing piece
unimplemented in libosmogsm.

Change-Id: I939e4f6b91b4a7c591ef3761fe2d46ed1c2fb2d3
Related: OS#1582
2016-07-11 19:15:24 +00:00
Max f5f773f013 Add strings with GPRS GMM messages
Change-Id: I48477b733e2da72f59349c00554dd3e080c9f445
Related: OS#1582
2016-07-08 15:08:17 +00:00
Max fdca25dfb8 Add function to check GMM encryptability
Check if particular GMM message can be encrypted according to 3GPP TS
24.008 § 4.7.1.2

Related: OS#1582
Change-Id: I7ad0e03c2c738d174dd6bc3453f332eeb8da1e7d
2016-07-07 12:55:46 +00:00
Max 92ce39f3d1 Add missing osmo_c4 export
Change-Id: Iaf53b31b4fa3860301054e970907ada061360b28
Related: OS#1741
2016-07-07 13:00:43 +02:00
Harald Welte 0ee90f8614 lapd_dl_flush_hist(): Don't flush a non-existant history
If lapd_dl_flush_hist() is called after lapd_dl_exit(), dl->tx_hist has
already been free'd and set to NULL.  Check for this before attempting
to de-reference a NULL pointer.

This bug breaks OpenBSC with any E1 based BTSs using DAHDI.

Change-Id: I117ba3445fa5e8097e21c11c5a6337de6ba46c7d
Related: OS#1760
2016-07-03 20:47:06 +02:00
Max a337b9c37a Add function to check MS GEA capabilities
Add function which parses MS network capability IE value for bits
indicating support for particular version of GEA.

Change-Id: I785cef37dd272a2fab9b172f6e1392f865174e9a
Relates: OS#1582
2016-06-29 16:33:25 +00:00
Max ceae123752 Make C4 function globally available
This function perform 64 -> 128 bit key expansion which useful for
converting between UMTS CK and GSM Kc, A5/3 and A5/4, GEA3 and GEA4
keys.

Change-Id: I5a6c6deef6027cd6af144c9062d4c9166be26904
Related: OS#1582
2016-06-29 16:32:55 +00:00
Max b897c42993 Add strings for GPRS ciphers
Change-Id: I050bda5fb50aad42fe2d72de39f8256b4fb12fb2
Related: OS#1582
2016-06-29 16:32:27 +00:00
Harald Welte 82f94ef50f Add UMTS AKA related MM/GMM message type and IE definitions
Change-Id: Id45ea2c631ee589a4df1f8213da6f7e7d1bf6616
Reviewed-on: https://gerrit.osmocom.org/305
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-16 21:43:21 +00:00
Harald Welte db78d2172b gsup.c: Fix encoding of UMTS auth vectors
Encoding auth vectors worked fine for GSM authentication, but didn't
yet include the new IEs for UMTS authentication yet.

Change-Id: I7fa5ba1c950292bd0a9874b3102a27f221ce390d
Reviewed-on: https://gerrit.osmocom.org/302
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-16 21:25:18 +00:00
Neels Hofmeyr 0167e3f355 add rsl_or_ipac_msg_name() for both standard and ip.access msg types
Context: in osmo-bts, I want to look up an RSL message name in rsl_msgt_names
and fall back to rsl_ipac_msgt_names if not found, because the IPAC PDCH ACT
and DEACT messages are sent in a standard ABIS_RSL_MDISC_DED_CHAN.

Change-Id: Ic9ba721a1469cf51aed97ab0f44a7fe055c94b1f
Reviewed-on: https://gerrit.osmocom.org/231
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-13 17:46:48 +00:00
Max adef12a349 Add strings with PH primitive names
It's useful debugging helper while troubleshooting L1-related issues.

Change-Id: Id7a6d478fd725c51f54ad746bdf9b9095579ff77
Reviewed-on: https://gerrit.osmocom.org/117
Tested-by: Jenkins Builder
Reviewed-by: Max <msuraev@sysmocom.de>
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-30 21:21:20 +00:00
Holger Freyther 45abec20dd Revert "gsm48: move to hex TMSI representation"
This is a "flag" day change. Old OpenBSC break with new libosmocore
because suddenly there is the 0x in front. I am afraid we need to
find a better solution here. I think we will need to create a
gsm48_mi_to_string variant that takes a mode parameter to enable the
TMSI mode and deprecate the old method.

Right now we should not break old versions of OpenBSC.

This reverts commit 78ad042f94.

Change-Id: I2f61e626f2f9088b492e1b643c3dcc9bce77d52b
Reviewed-on: https://gerrit.osmocom.org/86
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-20 19:42:50 +00:00
Vadim Yanitskiy 78ad042f94 gsm48: move to hex TMSI representation
Previously, we traditionally displayed a TMSI in its integer
representation, which is quite unusual in the telecom world.
A TMSI is normally printed as a series of 8 hex digits.

Review at https://gerrit.osmocom.org/57/
Change-Id: Ifd25365bfa3b4ee95b16979740c3229948ce17f2
Reviewed-on: https://gerrit.osmocom.org/57
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-20 16:26:51 +00:00
Max 764b022fc6 Add function to make Uplink Measurement
It assembles RSL Uplink Measurement IE according to 3GPP TS 08.58
§9.3.25. The function is based on lchan_build_rsl_ul_meas() from OsmoBTS
but optionally includes DTX information.

Change-Id: Ib37107bcc9909e5105ea711de42d3fb1db7e8d9e
Reviewed-on: https://gerrit.osmocom.org/44
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-05-17 16:10:31 +00:00
Max fe65fa7e36 Set DTX in Cell Options
* rename field of struct gsm48_cell_options to better match the spec
* add comments with spec references
* add function for setting DTX in cell options struct
* add necessary enum type

Change-Id: I5a8924f57669c951b2e51b663d95f1d360062a54
Reviewed-on: https://gerrit.osmocom.org/39
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-05-12 15:56:39 +00:00
Neels Hofmeyr c7bf8d0c84 api doc: auth_core.c: add \returns, cosmetic
Add various missing \returns doxygen entries.

In osmo_auth_3g_from_2g(), also adjust two comment-closing instances to
match common style and add a period to end a sentence.

(The recent addition of osmo_auth_3g_from_2g() raised my attention, and I added
more return value docs while at it.)

Change-Id: Iea71eb666bc061acb6b14215f398bd38d17b3ad3
Reviewed-on: https://gerrit.osmocom.org/33
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-10 11:05:27 +00:00
Harald Welte 766da86877 GSUP: Add support for RAND in SendAuthInfo.req
In the autentication re-sync case, we need not only the AUTS from
the MS/UE, but also the RAND that we sent as part of the failed
authentication challenge.
2016-05-06 11:22:05 +02:00
Harald Welte 48dc1a5a64 GSUP: Add OSMO_GSUP_CN_DOMAIN_IE to differentiate CS and PS plane
We're starting to use GSUP for circuit-switched (CS) plane, so we need
to differentiate the two planes somehow from each other.
2016-05-06 11:21:25 +02:00
Harald Welte 3b6fb0880c import gprs_gsup_message.[ch] from openbsc as gsup.[ch]
Move those routines from OpenBSC to libosmogsm, so they can be
re-used from other programs.  I think it was a mistake to add them only
inside the openbsc repository in the first place.  We need to pay more
attention to this in the future.
2016-05-06 11:21:06 +02:00
Harald Welte fbd02fa8cc tlv: Import osmo_shift_* and osmo_match_shift_* from openbsc
These routines have nothing to do with specifically the BSC, so import
them to the TLV parser we keep in libosmogsm.
2016-05-05 18:49:27 +02:00
Harald Welte 64f38c0410 import gsm_04_08_gprs.[ch] from openbsc.git
The definitions in this header file (and associated strings in the
c file) are generic about the GPRS Layer3 signalling protocols, and
thus should be part of the library.
2016-05-05 18:49:27 +02:00
Harald Welte cd9cb90f45 auth_core: Add osmo_auth_3g_from_2g() to compute CK+IK from Kc
This function performs the C5+C4 conversion to derive UMTS key
material from a 2G-only subscriber.
2016-05-05 18:48:05 +02:00
Holger Hans Peter Freyther 3a96d2837c conv_gen: Use python2 to execute the script
The script does not work with python3:

$ python3 utils/conv_gen.py
  File "utils/conv_gen.py", line 124
    def _print_term(self, fi, num_states, pack = False):

Second there is no 'python' on FreeBSD and one needs to select
the major version to use.

  GEN      conv_cs3_gen.c
  GEN      conv_xcch_gen.c
  GEN      conv_cs2_gen.c
python: not found
python: not found
python: not found

By using python2 we solve both issues. On Debian python2 is located
inside the python-minimal package.
2016-04-29 21:24:48 +02:00
Harald Welte 84da22f964 Add code generator for convolutional codes
Add python utility to generate .c code with convolutional
encoder/decoder based on polynomial description of the code. If argument
given it'll be interpreted as intended output directory, otherwise
current working directory is used.

Codes for *CCH, CS2/3 and TCH/AFS are generated. Corresponding manual
implementations are removed from tests. This introduce build-time
dependency on python.

The main work for this patch was generously contributed by Sylvain
Munaut.

Fixes: OS#1629
2016-04-29 13:17:22 +02:00
Holger Hans Peter Freyther aa16d63c27 milenage/aes: Address undefined behavior on bitshift
Extend the u8 to u32 before going to shift it.

Fixes:
milenage/aes-internal.c:799:4: runtime error: left shift of 128 by 24 places cannot be represented in type 'int'
    #0 0x7f84e9fe86a2 in rijndaelKeySetupEnc (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xfa6a2)
    #1 0x7f84e9febad8 in aes_encrypt_init (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xfdad8)
    #2 0x7f84e9fe7d14 in aes_128_encrypt_block (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xf9d14)
    #3 0x7f84e9febe7d in milenage_f1 (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xfde7d)
    #4 0x7f84e9fee2ce in milenage_generate (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0x1002ce)
    #5 0x7f84e9fe76d7 in milenage_gen_vec (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xf96d7)
    #6 0x7f84e9fe6c08 in osmo_auth_gen_vec (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/src/gsm/.libs/libosmogsm.so.5+0xf8c08)
    #7 0x401441 in main (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/tests/auth/.libs/lt-milenage_test+0x401441)
    #8 0x7f84e8e33a3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
    #9 0x400e58 in _start (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/libosmocore/tests/auth/.libs/lt-milenage_test+0x400e58)
2016-04-24 20:57:30 +02:00
Max 8a5346ba2f Add function for appending range1024 to bitvec
Add convenience function to append range1024 encoded data (see 3GPP TS
44.018 Annex J) to a given bitvec.
2016-04-23 16:37:05 +02:00
Max 1f9d8183be Deprecate comp128
Mark function as deprecated to discourage its usage: people should use
generic API in osmocom/crypt/auth.h
2016-04-22 15:10:55 +02:00
Max fdb3d8ce78 Deprecate osmo_a5_1 and osmo_a5_2
Mark the functions as deprecated to discourage their use: people should
use unified osmo_a5 which supports all the A5/1-4 ciphers.
2016-04-22 15:10:53 +02:00