Commit Graph

666 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 9795cf1b12 fix: DLGSUP logging category "unusable"
All DL* categories are typically negative, but DLGSUP isn't, and it's also not
in libosmocore's internal_cat array.
See: 3b6fb0880c

This means that a program using DLGSUP has to include DLGSUP in its own logging
cat array (typically not needed for DL* categories), which means for osmo-nitb
that DLGSUP (11) replaces DMGCP (also 11), and DMGCP becomes unusable.

Fix this: make DLGSUP -11 and include in internal_cat.

In gsup_test.c, no longer add DLGSUP to the logging categories array.

External follow-ups are otherwise needed only in osmo-hlr.git and some pending
patches for openbsc (Id3938267fa062e1a997d3704cd678874306f86ee).

Change-Id: Id974c7be158e4d60421a98110f5c807aefd31119
2016-12-11 03:42:58 +01:00
Harald Welte aa00f99be2 Implement GSMTAP log target
This target wraps the to-be-logged string (With metadata) into a GSMTAP
packet and sends it to the configured destination address.

Change-Id: I9a7e72b8c9c6f6f2d76d1ea2332dcdee12394625
2016-12-09 17:59:58 +01:00
Harald Welte a65e99331a gsmtap: Add defintions for GSMTAP based remote logging
Often it is useful to have log statements from the osmocom programs
synchronized with protocol traces.  So rather than having to open the
pcap file with GSMTAP or other protocol data side-by-side with the
textual log of one or more network elements, we simply pass the log
lines around as GSMTAP messages, which can then be displayed in-order
and interspersed with the protocol messages inside wireshark.

Change-Id: I33ab530e10ef0311b6f80b731e61894f20b4b3e7
2016-12-09 17:59: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 dda5e7991c doc: fsm timer_cb: explain return value
Change-Id: Ic6fbe95737862ed8b8de78058989c8b2ae330006
2016-12-09 16:10:46 +01:00
Harald Welte d7c0a373ff logging: Extend log_target with call-back for un-formatted log line
Some targets might not want to receive only an opaque, pre-formatted
string, but rather the unformatted arguments with metadata like
sub-system/level/file/line.  We solve this by introducing a
log_target->output_raw() function pointer.  If a target specifies this
function, it takes precedence over the regular log_target->output()
function.

Change-Id: I9dc9205d70dce9581458e7e9dc2d8a92991897bd
2016-12-02 13:52:59 +01:00
Neels Hofmeyr 909cbecbb9 Revert "gsm0408: add chreq_type for CHREQ_T_PDCH_ONE_PHASE and CHREQ_T_PDCH_TWO_PHASE"
This reverts commit c3c28528de.

The reason is that this breaks a static assert in openbsc.
See https://lists.osmocom.org/pipermail/openbsc/2016-December/009906.html

Enlarging the ctype_by_chreq struct and breaks the static assert for
gsm_network->ctype_by_chreq's size:

../../../src/libbsc/gsm_04_08_utils.c:138:1: error: size of array ‘dummyassert_size’ is negative
 osmo_static_assert(sizeof(ctype_by_chreq) ==
 ^

What this patch lacks is, in openbsc.git:

* adjustment of ctype_by_chreq[] according to the new additions in
  libbsc/gsm_04_08_utils.c
* same for reason_by_chreq[], also in libbsc/gsm_04_08_utils.c
* enlarge ctype_by_chreq[] in gsm_network to 18, in openbsc/gsm_data.h.

Leaving it up to the original authors to follow up and commit a complete patch
series in one go.
2016-12-02 02:30:51 +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
Alexander Couzens c3c28528de gsm0408: add chreq_type for CHREQ_T_PDCH_ONE_PHASE and CHREQ_T_PDCH_TWO_PHASE
For BSC-located pcu the BSC must understand the PDCH chan request.

Change-Id: Ice44dcaaf798f93af3652a96c567f8e16a6cf784
2016-12-01 15:26:29 +00:00
Harald Welte aeecc48c45 Introduce osmo_strlcpy() function so we can stop using strncpy()
I'm aware of the existing criticism on stlrcpy(), but I think it is
still better than what we have now: stnrcpy(), sometimes with Coverity
warnings and sometimes with a manual setting of the termination byte.

The implementation follows the linux kernel strlcpy() which is claimed
to be BSD compatible.

We could of course link against libbsd on Linux instead, but I think
it's reasonably small and simple to provide our own implementation.
Future versions of libosmocore could use some autoconf magic and
preprocessor macros to use the system-provided strlcpy() if it exists.

Change-Id: Ifdc99b0e3b8631f1e771e58acaf9efb00a9cd493
2016-11-26 16:42:17 +00:00
Harald Welte 6e363e7e31 gsm_08_58.h: Add more Ericsson specific RSL IE Identifiers
Change-Id: Ib43948da956f23609b1b0995ecac0c796cc7c629
2016-11-16 16:58:52 +01:00
Philipp Maier 00b1539007 RSL: Add defines for ericsson systinfo SI13
Ericsson uses non standard information element tags when setting
up the SI13 system information configuration. This applies to
RSL_SYSTEM_INFO_13, which is normally 0x28, instead Ericsson
uses RSL_ERIC_SYSTEM_INFO_13, which is set to 0x0C. Furthermore,
Ericsson adds a propritary field called BCCH-Mapping, which is
tagged as 0xf2 (RSL_IE_ERIC_BCCH_MAPPING)

This patch addes these two information element tags in
gsm_08_58.h

Change-Id: Idc27352e286b9b8bbcbf0b31bdb676c3d13487a9
2016-11-16 10:08:54 +00:00
Harald Welte 8593f1f57a msgb: add msgb_push_u{8,16,32}() functions
Those work analoguous to msgb_put_*() but pre-pend the given value
into the msg headroom, rather than appending it to the end.

Change-Id: I7de63e9d04c2d2b678f1f20eef37f9be2c4f5ec2
2016-11-11 19:28:32 +01:00
Harald Welte 1554f80f5e statsd: Fix compiler warning (int32_t vs. int64_t)
Fixes the following compiler warning:

stats_statsd.c: In function ‘osmo_stats_reporter_create_statsd’: stats_statsd.c:54:18: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
  srep->send_item = osmo_stats_reporter_statsd_send_item;

Change-Id: Id36914906e0982f6ac092a311210727de66b343a
2016-11-11 15:24:24 +01:00
Holger Hans Peter Freyther bf173a3df5 bitcomp: Remove the t4 decoding from libosmocore
As outlined by mail on the 13th of July the tree based approach to
decoding in the PCU is faster by order of magnitude. Instead of having a
slow implementation in the library and a quick one in the PCU, let's
only have a quick one in the PCU and at some point in the future move it
to libosmocore.

Execute the plan and remove t4_decode.

Change-Id: I021424444625a097560d086c217c81eac4a5ee44
2016-11-10 17:07:45 +00:00
Max 8b25a3f5c3 Add osmo_fsm_unregister() to header
Previously function was defined but not exposed so there were a way to
register FSM but no way to unregister it.

Change-Id: I2e749d896009784b77d6d5952fcc38e1c131db2b
2016-11-02 08:56:29 +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
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 c7a01d554e gsm/gsm0503.h: fix typo
Change-Id: I263d61111544eeb7227e1e0e8f2d14479eae2079
2016-10-23 07:38:15 +00:00
Neels Hofmeyr 694f72d148 Revert "Constify ctrl_cmd struct fields where appropriate"
This reverts commit ed9d6da5df.

The commit is good as such, but it causes many compiler warnings in the OpenBSC
build. We want this to be re-applied as soon as we have patches ready that fix
the fallout in openbsc.git.

See also https://lists.osmocom.org/pipermail/openbsc/2016-October/009802.html

Related: OS#1829
Change-Id: I722ad60232a6ef5b4cb984b92c42851de26b3ccd
2016-10-20 17:53:10 +02:00
Max bc067eb0a2 Add function to send TRAP over Control Interface
Change-Id: Ic0b8d88c4f5c4d42c3f8fb754f8eabf049c9e388
Related: OS#1646
2016-10-12 11:37:49 +00:00
Philipp Maier 349784c72d gsm0408: Adding 3g spcific RR message types
GSM 04.18, which is the successor of GSM 04.08, describes
additional RR 3g specific message types. This commit adds
four new message types related to paging and notifiction

See also 3GPP TS 04.18, section 10.4, table 10.4.1

Change-Id: I071cc9ecac342b5221fa0ec0b782b04b51b40e93
2016-10-12 09:29:35 +00:00
Max ed9d6da5df Constify ctrl_cmd struct fields where appropriate
Change-Id: I3f55c1d4b965d215dc9b16f4b284b7fea4bde9e9
2016-10-11 18:27:22 +02:00
Max 2bb65be159 Mark inline header function as static
Change-Id: Ib751f7467d54cbcae76f72448a38e30f2ecc63d4
2016-09-30 12:31:50 +00:00
Max 74a8f0831d AMR: add function to check speech frames
Add convenience function osmo_amr_is_speech() to check if given AMR
frame is speech frame: non-speech frames often require special
processing.

Change-Id: Ifaab02a2f581acc302b367d34fd2fc28a4d1e2e3
2016-09-28 10:34:02 +00:00
Neels Hofmeyr f45334be29 msgb: add msgb_talloc_ctx_init(), deprecate msgb_set_talloc_ctx()
So far each and every main() scope creates a msgb talloc context and either
passes it to msgb_set_talloc_ctx() or sets tall_msgb_ctx directly (by defining
it extern first).

Remove some code duplication: add one central function that creates the "msgb"
talloc context for all.

Most users of msgb employ a talloc_named_const(), but osmo-bts uses a
talloc_pool() instead. Offer both ways by means of the pool_size argument, and
for both ways make sure the context is called "msgb".

Suggest that msgb users should move to this new function: deprecate
msgb_set_talloc_ctx(). To be able to do so, include core/defs.h in msgb.h.

There's a tradeoff between hiding the msgb talloc context behind API that tries
to guess all use cases versus avoiding code dup. This patch opts against code
dup and boldly assumes that all future use is covered.

Also, the new function suggests to not access tall_msgb_ctx directly, which can
be considered a style improvement.

It seems that not all main scopes that use msgb actually initialize the msgb
ctx. As a fallback for these, explicitly initialize tall_msgb_ctx to NULL.

Change-Id: I747fbbf977c4d2c868c8dead64cfc5fd86eb8d4c
2016-09-27 11:46:38 +02:00
Daniel Willmann ba34a2fd73 gprs: Increase NS_ALLOC_SIZE to 3k
2k can be insufficient when responding with a STATUS message to a long LLC
packet because the original message is included in the STATUS.

Change-Id: I6f76751cfadf61e87ce4367a38907083e1c98562
Ticket: SYS#2967
Sponsored-by: On-Waves ehf
2016-09-23 02:42:46 +00:00
Neels Hofmeyr 8e2f7e87f4 add osmo_gettimeofday as a shim around gettimeofday
This allows feeding a custom time for unit tests by overriding
osmo_gettimeofday.

Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
2016-09-22 07:18:39 +02:00
Neels Hofmeyr 1a587bd782 fix GGSN Ctrl port to 4257
4253 used to collide with the sysmobts-mgr VTY port.
Note, openggsn does not actually have a Ctrl interface yet.

Change-Id: If0fa0e606dabd5bc89907a56ef18cdbbbdedb4b7
2016-09-09 16:23:18 +02:00
Neels Hofmeyr 56313c84c8 comment: */ports.h: link to wiki + manuals, indicate used ports
Change-Id: I6a7bf04e589ccfaea98f20900a9bfe9dd4808dce
2016-09-09 16:22:39 +02:00
Max c69de3e25c Add Marker to ph_tch_param
Extend struct ph_tch_param with Marker bit from RTP header to indicate
speech onset in case of DTX.

Change-Id: Ic664902630b9d335ff9abc7a9ca7249eaf80e05f
Related: OS#1750
2016-09-09 06:35:42 +00:00
Neels Hofmeyr 418ca58085 fix error msg: msgb_put(): say "msgb_put", not "msgb_push"
Change-Id: I72f31ebad693f98eb088a99b83aeb10cf9acc29e
2016-09-09 02:04:39 +02:00
Alexander Couzens e65315fb37 core/counter: add osmo_counter_dec()
Change-Id: I030140a45afa295c3ebc4d3ccaffd437b984f515
2016-08-30 12:02:58 +02: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
Max d1dcda01f8 Add control interface port for GGSN
Change-Id: Ie7232189fe3265a8631fd3652b2c8c152cdee918
Related: OS#1646
2016-08-08 17:42:17 +00:00
Max 9a9739c6ab Extend L1SAP with Measurements
We already have RSSI parameter in PH-DATA. Add other measurement
information (BER, BTO, Link Quality).

Change-Id: I2b127eb1856c4cd1bc46490a89592a595f1ee86b
Related: OS#1616
2016-08-04 15:05:57 +00:00
Harald Welte 881dcaf7aa Mark input string to osmo_talloc_replace_string() as const
This allows us to pass in strings that are 'const', which for the
source of a copy should be the normal/regular case anyway.

Change-Id: Icee6a5f88babd3a4e30bf0886f0f8d3b865d80ce
2016-07-28 08:02:48 +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
bhargava 1a96946875 Update structure in libosmocore for 11 bit RACH
Parameters are added to the structure ph_rach_ind_param to
differentiate the type of RACH received from Layer 1. This is to
further support the 11 bit RACH.

Change-Id: Ic4f0f2424a3af7599d986044be25ea4fcc0ca477
2016-07-24 14:15:03 +00:00
Max da34bf01a3 Add define for invalid TA
Add GSM48_TA_INVALID which is invalid Timing Advance value according to
3GPP TS 44.018 § 10.5.2.40.

Change-Id: I061760ccac656f39164562a7883f8ab522cd0911
Related: OS#1526
2016-07-23 19:31:30 +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 15b96ff70c gsm_08_58.h: introduce RSL_CHAN_NR_1 constant
Using the RSL_CHAN_* constants, we sometimes need to add 1 to the chan bits
to indicate e.g. the second TCH/H channel.

RSL_CHAN_NR_1 marks this lowest channel bit that needs to be added.

The name is analogous to RSL_CHAN_NR_MASK.

Change-Id: Iea06432039d1cd23cc6b5acec308bb829b596d47
2016-07-23 15:25:18 +02:00
Max edb57e7709 Add function to check TA validity
Check if given Timing Advance is valid according to 3GPP TS 44.018 §
10.5.2.40.

Change-Id: I5cb6149d6e36fda8cb3f557e4d6d3a724da805a5
Related: OS#1545
2016-07-16 21:00:00 +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