Commit Graph

33 Commits

Author SHA1 Message Date
Neels Hofmeyr 0d39a8de3c osmo_rat_type: add OSMO_RAT_EUTRAN_SGS
osmo-msc is about to implement the SGs interface and requires a RAT indicator
for that.

Change-Id: I00588396bfe03feba38ecb0717d584594f0b2b46
2019-01-04 04:38:54 +01:00
Neels Hofmeyr 5b5c3499cf gsm_utils: add enum osmo_rat_type, from osmo-msc enum ran_type
In the MSC, we have RAN types GERAN_A and UTRAN_IU, now we need a similar enum
in osmo-hlr's GSUP client.

Naming: in the MAP specifications, the RAN type is mostly called RAT type,
(Radio Access Network vs. Radio Access Technology?). Since GSUP is more about
MAP messages, I'm calling the enum osmo_rat_type.

Rationale: osmo-msc and osmo-sgsn want to tell the osmo-hlr which RAT a
subscriber is calling on. A subsequent patch will extend the GSUP protocol and
add a RAT types IE.

Change-Id: I659687aef7a4d67ca372a39fef31dee07aed7631
2019-01-03 02:21:23 +01: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
Philipp Maier b066305016 gsm_utils: add function to get value strings for gsm48_chan_mode
The enum gsm48_chan_mode has value strings, but no function to retrieve
those strings. Lets add one.

Change-Id: If715705e1ebdfcfdfae1c2099932f7bb8b3861a7
2018-09-25 13:07:45 +02:00
Neels Hofmeyr 60f3153125 add and tweak inter-BSC HO API
Add:
gsm0808_create_handover_detect()
gsm0808_create_handover_complete()
gsm0808_create_handover_failure()

To existing structs gsm0808_old_bss_to_new_bss_info and
gsm0808_handover_required, add a final 'more_items' flag that makes future
extensions API and ABI compatible.

Fix the msgb string for Handover Request Ack.

Extend some API doc comments.

Related: OS#2283 (inter-BSC Handover, BSC side, MT)
Change-Id: I03ee7ce840ecfa0b6a33358e7385528aabd4873f
2018-06-18 17:32:58 +00: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
Philipp Maier b808da44ab utils: add function gsm_fn_as_gsmtime_str()
Convert a given frame number into a printable string that displays
the sub components of the frame number.

Change-Id: I8015d2ded3940b01b35df7b72fc35c70c25e9926
2017-07-11 06:11:37 +00:00
Pau Espin 363130f3a1 gsm_utils: Add osmo_dump_gsmtime
Used by osmo-bts, moved from osmo-bts l1sap.c:dump_gsmtime.

Change-Id: Ib5452e2c20f53006c0f6d197fb055728947125d8
2017-07-10 07:44:11 +00:00
Neels Hofmeyr 17518fe393 doxygen: unify use of \file across the board
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-23 00:18:23 +00:00
Neels Hofmeyr 87e4550585 doxygen: enable AUTOBRIEF, drop \brief
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-23 00:18:22 +00: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
Max 402b9b0555 Addditional classmark check against A5/4 support
Add classmark check function according to GSM 04.08 Chapter 10.5.1.7
Fix interface to use unsigned for unsigned value.
2016-04-22 15:09:09 +02:00
Max fb348eeff2 Export names for gsm_chan_t and gsm48_chan_mode
This can be used with get_value_string() to improve debugging output.
2016-03-30 21:50:44 +02:00
Neels Hofmeyr cda988527f fix gsm_7bit_decode API comment: septets, not octets 2016-02-29 09:56:26 +01:00
Harald Welte 1f6aad1c04 Add G-RNTI derived TLLI types defined in 23.003 2015-08-18 19:32:33 +02:00
Harald Welte 1b12d16c4c libosmo-gsm: Add PCHAN/LCHAN types for CBCH 2014-12-28 13:37:01 +01:00
Sylvain Munaut 12ba778afd include: Switch to #pragma once pattern
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 10:17:27 +02:00
Jacob Erlbeck 26cbd459fc sms: Fix gsm_7bit legacy functions return value
The legacy 7bit conversion functions (those without the '_n_' in the
name) gave wrong return values on 64 bit platforms due to unproper
signed/unsigned conversions and the usage of SIZE_MAX.

This patch fixes this by using a smaller max size (see
GSM_7BIT_LEGACY_MAX_BUFFER_SIZE, currently set to 64k) for the legacy
wrappers and by using unsigned int for max_septets.
In addition, there are tests now that check the return values of
legacy encoding and decoding.

Sponsored-by: On-Waves ehf
2014-01-09 08:22:14 +01:00
Jacob Erlbeck 6b2621883f core: Move OSMO_DEPRECATED to new core/defs.h file
Add a new core/defs.h file for definitions that can be used from
within header files without including prototypes and extern
declarations. It's primarily meant for macro definitions and basic
typedefs.

Move the definition of OSMO_DEPRECATED there and use compiler version
info to avoid compiler errors.
2013-08-14 15:31:38 +02:00
Jacob Erlbeck 3f69ceb3a4 sms: Disable deprecated message
This is a workaround to make the FreeBSD8.4 and Debian6.0 target
build again. The deprecated attribute doesn't have arguments.
2013-08-12 18:46:25 +02:00
Jacob Erlbeck 1d7f3b5eb2 sms: Added result buffer size parameter to 7bit conv funs
The 7bit<->8bit encoding/decoding functions didn't check whether
there is still enough space in the destination buffer. Therefore a
buffer size parameter has been added to each of the functions which
is used to truncate the output if the buffer is too small.

In addition, the return value of the decoding functions has been
changed to number of characters written (excluding \0), so this
value is always equal to strlen(decoded).

The old functions are still available as wrapper functions.
2013-08-12 17:22:27 +02:00
Andreas Eversberg 9597555a36 Add special 7-bit encoding and decoding functions for USSD coding
Handling 7-bit coding is a little different for USSD, as TS 03.38
states:

To avoid the situation where the receiving entity confuses 7 binary
zero pad bits as the @ character, the carriage return or <CR>
character shall be used for padding in this situation [...].

If <CR> is intended to be the last character and the message
(including the wanted <CR>) ends on an octet boundary, then another
<CR> must be added together with a padding bit 0. The receiving entity
will perform the carriage return function twice, but this will not
result in misoperation as the definition of <CR> [...] is identical to
the definition of <CR><CR>.

The receiving entity shall remove the final <CR> character where the
message ends on an octet boundary with <CR> as the last character.

Jacob has verified the fix with fakeBTS and the wireshark dissector.

Fixes: OW#947
Reviewed-by: Jacob Erlbeck <jerlbeck@sysmocom.de>
2013-08-08 14:27:13 +02:00
Holger Hans Peter Freyther 6bfa7445fc encoding: Provide an overload for the gsm_7bit_encode and a simple test
This is required for encoding the SMS header using the alpha numeric
rules.

Reviewed-by: Jacob Erlbeck <jerlbeck@sysmocom.de>
2013-08-08 14:25:09 +02:00
Holger Hans Peter Freyther 94b2f64ae7 gsm: Try to clarify why we have gsm_septet_encode in the header file
These functions are not meant to be used by applications and are
only here for the unit tests. Try to document that.
2013-08-07 11:10:57 +02:00
Bhaskar 6b30f925e2 gsm_utils: refer to ETSI TS 05.08 instead of TS 08.05 2013-05-23 07:53:57 +02:00
Harald Welte ca69388be8 gsm_septets2octets(): Input parameter should be const 2013-03-13 15:16:47 +01:00
Sylvain Munaut 5572031749 gsm: Add method to find ARFCN based on frequency
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2012-12-11 23:44:41 +01:00
Harald Welte 81cd54a0c3 add GSM_LCHAN_PDTCH 2012-04-19 23:19:10 +02:00
Dennis Wehrle 291e61346b sms: SMS where cropped (from VTY), concatenation of SMS where not possible
Additionally it wasn't possible to send concatenated sms from the vty.
To send multiple sms, it is necessary to use padding bits and add a user_data_header.
Therefore the gsm_7bit_encode function was splitted to gsm_7bit_encode and gsm_septets2octets.
gsm_septets2octets: this is the old gsm_7bit_encode function + additional padding parameter

Additionally the gsm_7bit_decode function was modified to take account for the user_data_header.
With the new gsm_get_octet_len function you can get the octet length for a given septet length.

I also added several sms tests.
2011-07-24 20:14:13 +02:00
Harald Welte b7b61236d8 don't call a function argoment 'class' for the benefit of c++ users
This had broken lcr compilation...
2011-07-23 10:50:36 +02:00
Andreas Eversberg 2a68c7c8cd gsm/utils: Adding conversion of "mobile power class" to dBm
Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-06-26 11:41:48 +02:00
Harald Welte 11c7193ad8 Import abis_nm_{chcomb4pchan,pchan4chcomb}() from openbsc 2011-05-24 17:22:55 +02:00
Pablo Neira Ayuso 8341934844 include: reorganize headers file to include/osmocom/[gsm|core]
This patch moves all GSM-specific definitions to include/osmocom/gsm.
Moreover, the headers in include/osmocore/ have been moved to
include/osmocom/core.

This has been proposed by Harald Welte and Sylvain Munaunt.

Tested with `make distcheck'.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-03-23 18:09:28 +01:00