Commit Graph

70 Commits

Author SHA1 Message Date
Stefan Sperling bd6e7a9f2d port rest octets encoding code from osmo-bsc
As part of fixing issue OS#3075, we want to migrate support
for encoding system information from osmo-bsc to libosmocore.

This change ports osmo-bsc code for encoding SI rest octets.

The conversion was a bit tricky in some places because some
functions receive a 'struct gsm_bts' parameter in osmo-bsc.
In this libosmocore version, such functions expect parameters
which correspond to the individual fields of 'struct gsm_bts'
which are used by these functions.

Several structs from osmo-bsc's system_information.h are now
also declared in libosmocore headers, with an added osmo_ prefix
to avoid collisions with existing definitions in osmo-bsc.

Some helpers were ported from osmo-bsc's system_information.c
to libosmocore's gsm48_rest_octets.c. Contrary to osmo-bsc's
implementation they are now only visible within this file.

Unfortunately, this code ported from osmo-bsc lacks unit tests.

Change-Id: I47888965ab11bba1186c21987f1365c9270abeab
Related: OS#3075
2019-01-12 09:51:08 +00:00
Stefan Sperling fdf8b7b1be port arfcn range encode support from osmo-bsc
As part of fixing issue OS#3075, we want to migrate support
for encoding system information from osmo-bsc to libosmocore.

This change ports one of the prerequisites for doing so:
osmo-bsc code for range-encoding ARFCNs, including tests.

An osmo_gsm48_ prefix has been prepended to public symbols in
order to avoid clashes with existing symbols in osmo-bsc code.

Change-Id: Ia220764fba451be5e975ae7c5eefb1a25ac2bf2c
Related: OS#3075
2019-01-12 09:51:05 +00:00
Vadim Yanitskiy c2628317cc GSUP/SMS: introduce MO-/MT-FORWARD-SM messages
According to 3GPP TS 29.002, there are two services:

  - MAP-MO-FORWARD-SHORT-MESSAGE (see 12.2),
  - MAP-MT-FORWARD-SHORT-MESSAGE (see 12.9),

which are used to forward MO/MT short messages.

This change replicates both services as GSUP messages:

  - OSMO_GSUP_MSGT_MO_FORWARD_SM_*,
  - OSMO_GSUP_MSGT_MT_FORWARD_SM_*.

Please note, that only the 'must-have' IEs are introduced
by this change, in particular the following:

  - OSMO_GSUP_SM_RP_MR_IE (see note below),
  - OSMO_GSUP_SM_RP_DA_IE (see 7.6.8.1),
  - OSMO_GSUP_SM_RP_OA_IE (see 7.6.8.2),
  - OSMO_GSUP_SM_RP_UI_IE (see 7.6.8.4),
  - OSMO_GSUP_SM_RP_MMS_IE (see 7.6.8.7),
  - OSMO_GSUP_SM_RP_CAUSE_IE (see GSM TS 04.11, 8.2.5.4),

where both SM_RP_DA and SM_RP_OA IEs basically contain
a single nested TV of the following format:

  - T: identity type (see 'osmo_gsup_sms_sm_rp_oda_t'),
  - V: encoded identity itself (optional).

According to GSM TS 04.11, every single message on the SM-RL has
an unique message reference (see 8.2.3), that is used to link
an RP-ACK or RP-ERROR message to the associated (preceding)
RP-DATA or RP-SMMA message transfer attempt.

In case of TCAP/MAP, this message reference is being mapped to the
Invoke ID. But since GSUP has no 'Invoke ID' IE, and it is not
required for other applications (other than SMS), this change
introduces a special 'SM_RP_MR' IE that doesn't exist in MAP.

Change-Id: Ibe325c64ae2d6c626b232533bb4cbc65fc2b5d71
Related Change-Id: (docs) Ie0150756c33c1352bc4eb49421824542c711175c
Related Change-Id: (TTCN) Ibf49474a81235096c032ea21f217170f523bd94e
Related: OS#3587
2018-12-18 21:52:01 +07:00
Max 7918f84aeb LCLS, TS 29.205: add GCR routines
Add functions to encode and decode Global Call Reference as per
3GPP TS 29.205 Table B 2.1.9.1 add corresponding tests.

Change-Id: Iee95aa4e5c056645b6cb5667e4a067097d52dfbf
Related: OS#2487
2018-12-14 13:15:39 +00:00
Philipp Maier e190e032d9 gsm29118: add generator functions for GSM29118 messages
We already have some GSM29118 related definitions and functions in
libosmocore. Lets also add some functions to generate GSM29118 messages
(similar to those we have for GSM0808).

Change-Id: Ic87f8a771b87b52215d0a7451b67794557b80b8a
Related: OS#3615
2018-12-07 18:35:10 +01:00
Harald Welte 6721144c80 SGsAP protocol definitions (header + C file)
Change-Id: Idddfc9b851eb4c2fa7dd661a9ce1b03a04883109
2018-10-21 12:35:34 +00:00
Neels Hofmeyr ba0762d6cb logging vty: rewrite 'logging level' vty cmd generation
Completely drop the implementations of log_vty_command_{str,description}().
These functions have been public API once, marked as deprecated since
c65c5b4ea0 (March 2017). I considered to keep
them, or reduce them to useless stubs, but it is quite silly, really. These
functions are completely and utterly useless outside of libosmocore. Any
program linking these deserves to fail.

Re-implement vty logging level command gen, in logging_vty.c. logging.c is
simply the wrong place for that.

Introduce logging_internal.h to share logging definitions to logging_vty.c
without publishing as API.

Introduce static gen_logging_level_cmd_strs() to compose a list of category
arguments with their descriptions for VTY commands. Use osmo_talloc_asprintf()
instead of the previous error prone and chaotic strlen() counting method.

Do not dynamically generate log level arguments, just keep static strings. We
are super unlikely to ever change the log levels we have.

No changes in logging_vty_test.vty: proves that there is no functional change.

All of this, besides introducing basic sanity, is cosmetic preparation to be
able to re-use the generic command generation code for arbitrary commands with
category or level args (for deprecated and new keywords).

Rationale: I want to hide 'all' and 'everything' from the VTY command
documentation, by means of deprecating. I first tried to simply define a
deprecated 'logging level CAT everything' command:

  logging level (all|rsl|rr|...) (debug|info|notice|error|fatal)
  logging level CAT everything                   # <- deprecated and hidden

But unfortunately, command matching doesn't work as intended when the CAT
argument reflects a valid category; I want it to invoke the deprecated function
as soon as the 'everything' keyword follows, but it stays stuck to the "valid"
command when the category argument matches an explicit keyword in that list,
and will throw an error on the following 'everything' keyword. I.e.:

  logging level rsl everything
  % Unknown command  # <-- leads to config file parse error

  logging level unknown_string everything
  % Ignoring deprecated 'everything'  # <-- works only for invalid categories

So I need to define 'everything' separately, again with a list of each valid
category instead of a generic CAT arg.

Change-Id: I3b083f27e3d751ccec258880ae7676e9af959a63
2018-09-13 15:46:55 +00:00
Harald Welte fdd366ed1b import oap_client into libosmogsm
This imports the code from osmo-msc 6afef893e17bce67e4d4119acd34d480ed03ba77
with minimal changes to make it compile.  Symbol renaming to osmo_
prefix is done separately in a follow-up patch to have a as-clean-as-possible
import first.

Change-Id: I9bc38102318da02d1fe46ef516df3cfd6bf8e3da
2018-07-30 12:16:11 +02: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 9da77abb6b isdnhdlc: Port from kernel to userspace
* prefix all symbols/constants with osmo_
* use stdint.h types instead of kernel types
* use Doxygen API documentation
* use Osmocom CRC16-CCITT functions
* use Osmocom bit-reversal functions
* integrate with Automake

Change-Id: I109085ab3e412c20b19cd42fb7137aa0e4167542
2018-05-11 21:57:46 +02:00
Philipp Maier 680acae725 features: move bts feature related functionality to libosmocore
osmo-bsc and osmo-bts share enums and value strings to describe
feature data that is exchanged via OML (manufacturer id) on startup.
Also the functions to set and get the respecitive bits in the feature
bitvectors are in osmo-bsc and osmo-bts. This is a code duplication
and should be resolved.

- add enum osmo_bts_features (replaces enum gsm_bts_features)
- add osmo_bts_features_descs (replaces gsm_bts_features_descs)
- add osmo_bts_set_feature (replaces gsm_btsmodel_set_feature)
- add osmo_bts_has_feature (replaces gsm_btsmodel_has_feature)

Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
2018-03-02 16:54:16 +01:00
Pau Espin 726ba36201 core: Add timespec helper macros and make timer_compat.h public
If a monotonic clock must be used, then the clock_gettime API is used
which uses timespec structures. Linux systems by default don't provide
helpers to calculate time using timespecs, so let's add them here.

Let's also make this header public so these helpers can be used in other
projects using libosmocore (expected user: libosmo-netif).

Change-Id: I45fc993b9bb0a343763238bf463c8640f47b00f1
2018-02-27 15:44:29 +00:00
Philipp Maier 40def49ac4 libosmocodec: implement ECU (Error Concealment Unit) for FR
When a bad GSM voice frame is received, it's being replaced
by a silence frame. This may cause unpleasant audio effects.

This change implements a functionality to craft a replacement
frame from the last known good frame. Currently, only FR is
supported, support for other codecs may be added latter.

Change-Id: I06a21f60db01bfe1c2b838f93866fad1d53fdcd1
2018-01-15 20:12:03 +00:00
Philipp Maier 6cb9e7d898 libosmocodec: add FR bit offset definitions
This change defines the GSM FR bit positions as described
in RFC 3551, which will be used by further ECU
(Error Correction Unit) implementation.

Change-Id: I1d0a198af0f8dd1f690b5a81f5c9eb92c43aefed
2017-12-20 15:48:38 +00:00
Harald Welte 216338c369 Rename 'statistics.c' to 'counter.c'
With stat_item, stats.c and stats_statsd.c, it is becoming a bit
difficult to understand file naming.  Also, the 'statistics.c' file
actually only contained osmo_counter handling, so let's rename it to
counter.c altogether.

Change-Id: I2cfb2310543902b7da46cb15a76e2da317eaed7d
2017-10-15 19:51:35 +02:00
Harald Welte 1389e86d11 Add pseudo-random bit sequence generator to libosmcoore
These PRBS sequences are specified in ITU-T O.150.  They are typically
used as test data to be transmitted for BER (bit error rate) testing.

Change-Id: I227b6a6e86a251460ecb816afa9a7439d5fb94d1
2017-07-10 23:42:02 +02:00
Harald Welte 2956737681 Add header file with definitions for GSM TS 04.14 / 3GPP TS 44.014
Change-Id: I1f4fc2761b55a4f83544c1c3793ab67fec9fc120
2017-06-12 01:57:41 +02:00
Harald Welte 7af6d22a4e sercomm: Include in libosmocore Makefile
Change-Id: If9d50d634381f43b2c67b97fea36a462a66e4559
2017-05-17 15:15:09 +01:00
Harald Welte 3318c657de introduce byteswap.h with osmo_{htonl,ntohl,htons,ntohs}
We need to have an architecture-independend way of endian conversion /
byte swapping functions which will also work on embedded (bare iron)
builds.   Let's introduce osmocom/core/bytesawp.h for this purpose.

Change-Id: Ibc0cc1e36d4ed63a35cf8ceff3af0f26e5ac7a3d
2017-05-15 13:42:00 +02:00
Philipp Maier 22401433aa gsm0808: Add utils for AoIP Transport Layer Address
The planned support for true A over IP requires the encoding and
decoding of a so called "AoIP Transport Layer Address" element.

This commt adds parsing functionality and tests for the element
mentioned above, however, it is not yet actively used.

Change-Id: I57933b0a06a3f54ec2a41e6ecb6ced9fbbc89332
2017-04-08 07:44:45 +00:00
Neels Hofmeyr f444600afe build: fix build dependencies for generated sources
Ensure that a changed conv_gen.py and/or conv_codes_gsm.py result in
regeneration of the gsm0503* generated sources. Before this patch, manual
cleaning of the generated files was necessary to benefit from a code update.

Change-Id: Ib4328662c21280c0ea6aa9391a64ada2c6598704
2017-03-20 14:30:43 +01:00
Neels Hofmeyr 9e4c17075c build: generate gsm0503.h to builddir, not srcdir
To ensure that a separate build dir keeps the source dir clean of state,
generate the gsm0503.h to the builddir instead of the srcdir. Adjustments for
everyone to access the right paths were added in previous patches.

Change-Id: Ia773ef5893a2018feb416061aefcf51835df18d2
2017-03-20 12:32:43 +00:00
Vadim Yanitskiy 3262f820b5 libosmocoding: migrate transcoding routines from OsmoBTS
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
2017-03-07 01:06:38 +07:00
Vadim Yanitskiy 77a5b0946f gsm0503.h: generate header automatically
Since we have automatic header generation, implemented in the
utils/conv_gen.py, it's time to use this feature!

Change-Id: I21caa4e433b2cc1861611e35350a9671da444c2a
2017-03-06 17:06:45 +00:00
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
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
Tom Tsou 9394dbd8e0 Add EGPRS RLC/MAC headers from 3GPP TS 04.60
For shared use by osmo-pcu and osmo-bts-trx.

Change-Id: I500cdc87cd30faf36c8cd92d234642f809c8f2aa
2016-07-12 06:06:33 +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
Harald Welte 136e73764e Add Finite State Machine abstraction code
This code is supposed to formalize some of the state machine handling in
Osmocom code.

Change-Id: I0b0965a912598c1f6b84042a99fea9d522642466
Reviewed-on: https://gerrit.osmocom.org/163
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-16 21:43:45 +00:00
Harald Welte bda26c0901 Add structures defining decoded TS 23.003 identities
Change-Id: I6423f8d75bb3e7aeca285854ab3232a087d62b57
Reviewed-on: https://gerrit.osmocom.org/304
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-16 21:25:26 +00: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 0996c87925 add new header file for TS 23.003 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 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
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
Harald Welte 4acaa13433 sim: add class_tables / card profiles
The tables permit code to determine the APDU class of an APDU
based on it APDU/TPDU header (CLA/INS/P1/P2/P3).
2016-03-17 16:55:11 +01:00
Neels Hofmeyr f81eb328b6 vty: add ctrl section for Control interface bind address
This may seem like overkill for a mere const char * config item, but it makes
the Control interface VTY commands reusable in any main() scope (inspired by
libosmo-abis' VTY config).

Add API functions ctrl_vty_init() and ctrl_vty_get_bind_addr(), in new files
src/ctrl/control_vty.c and include/osmocom/ctrl/control_vty.h, compiled and/or
installed dependent on ENABLE_VTY.

Using these functions allows configuring a static const char* with the VTY
commands

    ctrl
     bind A.B.C.D

which callers shall subsequently use to bind the Control interface to a
specific local interface address, by passing the return value of
ctrl_vty_get_bind_addr() to control_interface_setup().

Add CTRL_NODE to enum node_type, "eating" RESERVED4_NODE to heed that comment
on avoiding ABI changes.
2016-02-25 11:02:35 +01:00
Max 5c18e26bc2 Add T4 bit map compression routines
Add bit map encoder and decoder functions: decoder is fully functional
while encoder is good enough for testing - no backtracking to find
the best possible compression is implemented. If somebody is willing to
implement MS side of EDGE than this has to be expanded.
Add corresponding tests.
N. B: the encoding is implemented according to ETSI TS 44.060 which is
slightly different from T4 used for fax according to CCITT G31D (RFC 804).

Ticket: OW#2407
Sponsored-by: On-Waves ehf

Signed-off-by: Max <msuraev@sysmocom.de>
2016-02-18 19:45:44 +01:00
Harald Welte 90e614f7cc remove our internal copy of talloc, use system libtalloc
Shipping our own private copy of talloc was a good idea in 2008,
when it was not readily available on most target platforms.  Today,
the situation is quite different, as it is a standard library on
major Linux distributions.
2015-12-05 23:38:18 +01:00
Harald Welte a10ef29b47 use system-wide libtalloc with --enable-system-talloc
This introduces a new configure flag by which the libosmocore-internal
talloc code is not compiled, but rather a system-wide libtalloc is used.

When we started openbsc/libosmocore in 2008, libtalloc was not widely
present on systems yet.  This has changed meanwhile, and we should
simply use the system-wide library
2015-11-21 00:50:19 +01:00
Jacob Erlbeck 95bf828003 stats: Add the reporting framework
This commit provides the stats reporting framework that can manage
several types of measurement reporters. Initially support for
rate_ctr and the statsd protocol is included.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:03 +01:00
Jacob Erlbeck 45513e6040 stats/vty: Add stats_vty.c
This file will contain the VTY code related to statistics.

This commit adds a minimal file with just as single VTY command:

- show stats    This command shows all statistical values

To enable this and future commands, the main program needs to call
stats_vty_add_cmds().

Sponsored-by: On-Waves ehf
2015-10-29 00:09:04 +01:00
Jacob Erlbeck 9732cb4a92 stats: Add stat_item for value monitoring
This commit adds instrumentation function to gather measurement
and statistical values similar to counter groups.

Multiple values can be stored per item, which can be retrieved in
FIFO order. Getting values from the item does not modify its state to
allow for multiple independant backends (e.g. VTY and statd).

When a new value is set, the oldest value gets silently overwritten.
Lost values are skipped when getting values from the item.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:04 +01:00
Harald Welte 908085ccbc Add APN utility function to libosmogsm
The current functions are used to 'qualify' an APN from the
user-supplied APN name (name identifier) towards the fully-qualified
APN name which is used in the .grps DNS zone.
2015-05-25 11:12:16 +08:00
Holger Hans Peter Freyther 249a81b7ff endian: Be able to detect endian on GNU and BSD
On GNU __BYTE_ORDER and __LITTLE_ENDIAN is defined and
the include is "endian.h" on FreeBSD it is "sys/endian.h"
and LITTLE_ENDIAN/_LITTLE_ENDIAN and BYTE_ORDER/_BYTE_ORDER
is defined.

Create a header file that defines OSMO_IS_LITTLE_ENDIAN
and OSMO_IS_BIG_ENDIAN and can be used as

 #if OSMO_IS_LITTLE_ENDIAN
   do_little_endian
 #elif OSMO_IS_BIG_ENDIAN
   do_big_endian
 #else
   #error "Unknown endian"
 #endif
2015-03-22 09:03:42 +01:00
Tobias Engel 419684e30c Supplementary Services (de)activation, interrogation added
These patches enhance the Supplementary Service (SS) processing from
only being able to handle USSD to other SS, specifically activation,
deactivation and interrogation of those SS. Registration is not yet
implemented.

include/osmocom/gsm/protocol/gsm_09_02.h has been added with needed
values for SS.

Modified by Harald Welte to keep the old ussd-only functiosn for API/ABI
stability.
2015-01-01 14:19:17 +01:00
Harald Welte 783d073a37 add gsm0341_test to generate SMSCB hex strings
Those hex strings can then be copy+pasted into the OSmoNITB VTY
2014-12-29 17:09:11 +01:00
Harald Welte d54c2ee8c5 initial checkin of 'libosmosim' 2014-10-26 19:09:22 +01:00
Harald Welte c7947ed1f6 New <osmocom/ctrl/ports.h> file listing tcp ports for CTRL interface 2014-08-21 15:34:19 +02:00
Harald Welte 3ff81b1a6b libctrl: autotools build system integration
Now we actually build the recently-imported libctrl
2014-08-21 15:34:18 +02:00