Commit Graph

1111 Commits

Author SHA1 Message Date
Minh-Quang Nguyen 17a8748324 IPAC manufacture-defined measurement pre-processing definitions
Change-Id: Ie1853697f4cff5ff98654fa1cae6c68e28a0076b
2017-07-14 15:54:50 +02:00
Harald Welte 37d204a120 socket: Add new OSMO_SOCK_F_NO_MCAST_ALL option
Using this option at socket creation, the caller can request disabling
the IP_MULTICAST_ALL socket option.

Change-Id: I5ab5de45c0b64ceb3636ea98245a23defa24ffd4
2017-07-13 16:54:23 +02:00
Harald Welte bc43a62f41 socket: Allow disabling multicast loop on socket creation
This introduces a new flag OSMO_SOCK_F_NO_MCAST_LOOP, which can be used
to disable the looping back of multicast packets transmitted throug this
socket to other local sockets on the machine.

As this looping-back is active by default, a single option to deviate
from the default is deemed sufficient.

Change-Id: I24a5b1ebc3f84d2d5d4734e54df50efaea26490b
2017-07-13 16:53:41 +02:00
Harald Welte e30d7e6018 socket.c: Add multicast related convenience functions
Change-Id: Id703e7a7a1e065181a4c76c088b8dcc1b7fe15a2
2017-07-13 16:53:37 +02:00
Harald Welte ea91a51ebe select: Add new osmo_fd_close() function
This is a convenience helper that will both close a fd, mark it as
closed and unregister it from the event loop abstraction.  In most
cases, you probably actually want to use it instead of manually closing
and calling osmo_fd_unregister().

Change-Id: Icd0933eed6a24edde7cdcb378e138897ecc5332c
2017-07-13 16:03:37 +02:00
Harald Welte aa3ba46e0f gsmtap: Add value_strings for GSMTAP_TYPE and GSMTAP_CHANNEL
Change-Id: Iaf8a99912f42a56ef785a1642e18238c0b67cf68
2017-07-13 00:03:29 +02:00
Harald Welte 93713a55b9 gsmtap_util: Add chantype_gsmtap2rsl() as inverse of chantype_rsl2gsmtap()
Change-Id: Ie1bc00670887064da0fea61c3dab036c23ceea25
2017-07-13 00:03:27 +02: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
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 548e371200 gsm_04_08.h: Add struct for 9.1.13b GPRS suspension request
Change-Id: I90113044460a6c511ced14f588876c4280d1cac7
2017-07-10 23:42:02 +02: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
Holger Hans Peter Freyther 5a54dcbc38 gsm_04_08/sgsn: Add another IE for internal usage in the sgsn
The PDP charging characteristics will be returned from the PDP
selection code and be used in the SGSN. It is following the same
approach as the QoS and PDP addr. It is a bit of a pity that we
have to define this in a different project.

Change-Id: I7815c5dfd7b7fb0ea78d816ebfb3abfbf0090afe
2017-07-09 12:46:08 +02:00
Max 15b6d4131c Deprecate wrappers around loglevel_strs
Add deprecation notice for public API use: it shouldn't be used outside
of libosmocore anyway.

Change-Id: I792e30dc44f027fd94e1f65af19fe08bac52b95c
Related: OS#71
2017-07-08 10:39:45 +00:00
Holger Hans Peter Freyther eb55c0d4da gsup: Add encoding/decoding for the pdp charging characteristics
These fields can be in the ISD and the PDP Context inofmration. Store
pointers to this IE in both cases. It needs to be used by the SGSN
when opening a PDP context.

Change-Id: Iedc7c02adcf77ca5c9545119e19c968dfbbb3e6b
2017-07-07 21:54:38 +02:00
Max 4aaa8abcab Add missing BSSGP cause values
Add values from 3GPP TS 48.018

Change-Id: Ie39a6c91a46d179392d861805a106743a07c6fb0
2017-07-01 07:40:09 +00:00
Pau Espin 411402b4df l1sap.h: Add ber10k and lqual_cb to ph_tch_param
These fields are required in osmo-bts to do low link quality checks in a
generic way.

Change-Id: If4ae20c22b881e94585dad710f17b9e37f77bf82
2017-06-30 12:06:06 +02:00
Neels Hofmeyr 9a391e2edf fix map entry and .h declaration for gsm0808_chan_type_to_speech_codec()
Recent commit 3149b0d076 adds function
gsm0808_chan_type_to_speech_codec() but adds a completely mismatching name in
libosmogsm.map, as well as a definition with a typo in the name.

Fix the entry in libosmogsm.map.

Add the missing 'c' in gsm0808_utils.h

Change-Id: I5a621fa5ef6b632eabbe224f3dd383eacaffb695
2017-06-23 02:55:26 +02: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 33370cb18d doxygen: various fixes in core/timer.h
Move a longish comment to the timer group so that it appears in the API doc.

Un-doxygen some floating comments that were associated with unrelated code
items ('/**' --> '/*').

Add braces to some function names so that the API doc will render as reference
links.

Change-Id: I3ea5b88cbe9cb54702429158bf47e768e04e8fe7
2017-06-23 00:18:23 +00:00
Neels Hofmeyr fc47b03f33 api doc typo fix in core/logging.h
Change-Id: I3f1cd5b10e7beccb61f370d7f8fa2666e56542cf
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
Philipp Maier 4703fd215f cosmetic: remove API documentation strings in header file
Typically we don't place comments with the function declarations
in .h files. Not sure why this file has comments for each. The
API doc belongs in the .c file as proper doxygen comments,
and shouldn't be duplicated in the .h file.

In this particular case, doxygen comments are added in the
corresponding c file recently.

Change-Id: I5c4cb55be5ec59a6945b1720b875c5987f1cfaad
2017-06-22 17:08:16 +00:00
Philipp Maier 884ba0f2bc gsm0808: add function gsm0808_speech_codec_from_chan_type()
The contents of the speech codec element (struct gsm0808_speech_codec),
that is also used in the speech codec list element (struct
gsm0808_speech_codec_list) can be generated directly from the
permitted speech parameter in the channel type field (struct
gsm0808_channel_type) when full AoIP with compressed speech via
RTP/UDP/IP is assumed and when the codec configuration on the air
interface exactly matches the codec configuration on the IP backhaul.

This patch adds a function that can be used as a helper to fill
out spech codec fields by only giving a permitted speech parameter
as input.

Change-Id: I257c972e9fdf0dfe940a8d483447085bd62e50a2
2017-06-22 17:08:16 +00:00
Philipp Maier 3149b0d076 gsm0808: add function gsm0808_chan_type_to_speech_code()
The permitted speech field used in channel type element (struct
gsm0808_channel_type) uses a different representation as
the type field in the speech codec element (struct
gsm0808_speech_codec)

This patch adds a function to convert from permitted speech to
speech codec type.

Change-Id: Ib26a9c20864459b2baaa04f49b6e7902ba44b7cb
2017-06-22 17:08:15 +00:00
Philipp Maier a9b9276948 gsm0808: add default speech codec configuration
In an AoIP scenario, the speech codec list field specifies the
codecs used in the RTP interface. This patch adds a table
with default codec configurations that match the codec
configurations that are also used on the air interface.

Change-Id: I9dc0165d76a022b2c1b7418bc3133407e61b7261
2017-06-22 17:08:15 +00:00
Philipp Maier bb8396690e gsm0808: fix AoIP speech codec element parser/generator
The implementation of the parser/generator for the speech codec
information element slightly wrong, making it impossible to use
it properly.

(See also: 3GPP TS 48.008, 3.2.2.103)

Change-Id: Idabb0f9620659557672e1c6b90c75481192e5c89
2017-06-22 17:08:14 +00:00
Philipp Maier da38203418 gsm0808: add speech codec type constants
The codec type to be set in member type in struct gsm0808_speech_codec
has its own coding scheme to reference the used codec types. This patch
declares an enum with valid speech codec types.

Change-Id: Icaa768071d4364e671bc7e6d48b82d1f07f93f93
2017-06-21 20:20:02 +00:00
Philipp Maier 890f1f5a2c cosmetic: Add info about coresponding codecs to permitted speech consts
The constants in enum gsm0808_permitted_speech are not very expressive.
Add comments indicating each constant's corresponding codec.

Change-Id: I9734f7c261becffe38ffd41c304d006d08530c1a
2017-06-21 20:20:02 +00:00
Philipp Maier 3d9191ef2a gsm0408: update bearer capability speech version
3GPP TS 24.008 specifies two new speech versions for half rate and
two new speech modes for full rate. This patch adds the relevant
constants to enum gsm48_bcap_speech_ver in gsm_04_08.h

Change-Id: Id2835384c855f924332d38f01c73bd1cfdb62549
2017-06-21 20:20:02 +00:00
Philipp Maier a9e193b5dc cosmetic: Add codec references to Speech Version Indication
Add the information which GSM Speech codec version coresponds to
which bearer capability speech version.

Change-Id: Ic9493fea139420a52c32b17d00ac7d0b2bf86967
2017-06-21 20:20:02 +00:00
Philipp Maier e05c1f45ed vty: additional nodes for sccp-address configuration
The planned sccp-addressbook implementation in libosmo-sccp
requires two additional VTY nodes.

See also in libosmo-sccp.git:
Change-Id I068ed7f7d113dab88424a9d47bab7fc703bb7942

Change-Id: I42aa29c0cccc97f284b85801c5329b015b189640
2017-06-21 12:56:41 +00:00
Max dd75bacb78 Move NUM_BYTES macro to core library
It's universally useful so it make sense to have it in the shared core:
* move macro from libosmocoding to libosmocore
* add OSMO_ prefix
* add doxygen docs

Change-Id: I5386ba3e1f1cc153ba96c29dc71c9075a052aa02
2017-06-19 11:09:09 +02:00
Pau Espin 69dfe5aeec Fix compilation warning on deprecated macro
A warning was printed even if the deprecation didn't apply to
libosmocore because it is still allowed to use it internally.
This patch fixes this case while still printing a warning if external
projects build using libosmocore headers.

Change-Id: I32212f20756f828af1017482a71e29e4b3adbad4
2017-06-18 10:40:18 +02:00
Harald Welte 96e2a00d7a update/extend doxygen documentation
It's a pity that even with this patch we still are fare away from having
the whole API documented.  However, at least we have a more solid
foundation.  Updates not only extend the documentation, but also make
sure it is rendered properly in the doxygen HTML.

Change-Id: I1344bd1a6869fb00de7c1899a8db93bba9bafce3
2017-06-12 21:55:54 +00:00
Harald Welte 0eb2c5dab2 gsm0503_interleaving: Mark input arguments as 'const *'
The interleaving/deinterleaving functions were missing 'const'
qualifiers on their input data buffers

Change-Id: I2118c34a6353167787b23f877f1d81d60151aaf9
2017-06-12 15:35:27 +02:00
Harald Welte c663678b26 Add doxygen documentation to libosmocoding
This adds the minimum amount of API documentation that we should have on
all our code, particularly new code merged into a library.

Change-Id: I526804f64313867913574e50e5b9e9205ad3aa74
2017-06-12 15:35:23 +02:00
Harald Welte b9946d372c gsm0503_{coding,mapping}: Mark input arguments as 'const'
It is generally our coding style to mark pointers to constant input data
as 'const *'.  For some reason the gsm0503 coding and mapping was not
adhering to this, so let's bring it into compliance.

Change-Id: Id8731d7ae6171dff94741b6ddbb95ab5f03bfd4e
2017-06-12 12:59:21 +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 3f066dde8f Update L3 protocol discriminator definitions
Change-Id: Ia699d3494b93b7f88c36338e4960b35c42a29b9c
2017-06-09 08:49:13 +00:00
Harald Welte 6789ba35a6 osmo_{fr,hr}_check_sid(): Use const input argument
Change-Id: If779cce63f06a18d4f3b0cb3d6dd7a99aa52a646
2017-06-09 08:17:38 +00:00
Pau Espin 75989e677d socket: Add osmo_sock_init2_ofd() function
Will be used by osmo-bts-trx

Change-Id: I3c655a4af64fb80497a5aaa811cce8005dba9cd9
2017-05-26 12:56:07 +02:00
Max 54ca30c8d3 Add human-readable names for signal_ns
Change-Id: Id664355eb8305fb287e4dae0800fb20dc2f9b8cd
Related: SYS#3610
2017-05-24 22:13:14 +00:00
Harald Welte 7711713b7a sercomm: More API documentation
Change-Id: I5d5002ceedd10e10d772693478f4f9cab6b1290a
2017-05-17 15:15:09 +01:00
Harald Welte 799bef5cf6 sercomm: Better integration of driver interface
We cannot assume a certain UART API like uart_baudrate() which only
exists in OsmocomBB.  Rather, use generic function prototypes
(sercomm_drv_*) which are to be provided by the application /
environment to the sercomm core.

Change-Id: I01ea3067baf1791000c1a7d537ccce496a1ab1ee
2017-05-17 15:15:09 +01:00
Harald Welte 7af6d22a4e sercomm: Include in libosmocore Makefile
Change-Id: If9d50d634381f43b2c67b97fea36a462a66e4559
2017-05-17 15:15:09 +01:00
Harald Welte 1d640889df sercomm: remove unrequired helper functions
osmo_sercomm_{bind,get}_uart() are not really needed anymore, as
sercomm_inst is public and thus the user can access the uart_id member
directly.

Change-Id: I6d57709c3764036046202f16a26c9eb87426c8d1
2017-05-17 15:15:09 +01:00
Harald Welte 8a4eb837ab sercomm: Move HDLC related defines into C file
Those values are not relevant to the sercomm user, only to the
implementation and thus can remain inside sercomm.c

Change-Id: I5700a45985b7c119c6338932171aae62ee4e2d22
2017-05-17 15:15:09 +01:00
Harald Welte ea3d3ba595 sercomm: Add doxygen-style documentation to public API
Change-Id: I2d8b11905692920d328262836420f01305be489e
2017-05-17 15:15:09 +01:00
Harald Welte f6adcd7dd6 sercomm: make rx msg size configurable per instance
Change-Id: I835506e26e83232e1e7290c0da04d389c8d7fb40
2017-05-17 10:46:40 +00:00
Harald Welte 1358836282 sercomm: introduce osmo_ naming prefix in struct and function names
Change-Id: If4e22f182a47b72b1fe43146716a4fbccceb62e6
2017-05-17 10:46:40 +00:00
Harald Welte cc95f4b06d sercomm: Enable multiple instances of 'sercomm'
Rather than having one global instance, let's permit multiple instances
of sercomm to co-exist, with all API functions extended by the instance
as first argument.

Change-Id: I0f3b53f464b119d65747bcb0be0af2d631e1cc05
2017-05-17 10:46:39 +00:00
Harald Welte c68af6a64b Import sercomm.c from osmocom-bb
This imports the file src/target/firmware/comm/sercomm.c from
osmocom-bb.git without introducing any modifications.  It will not even
be built yet, as Makefile integration is intentionally left until it has
been adapted to work inside libosmocore.

Change-Id: I9ee199381c7b5986a9540d124836cdddd0f66c86
2017-05-17 10:46:39 +00:00
Philipp Maier 18d49d694f l1sap: Add frame-number to measurement indication struct
The distribution of the channel measurement calculations over
multiple timeslots (continous calculation) requires to keep
track of the frame number in struct info_meas_ind_param

Change-Id: I8c783b4a92ae2c3cc5d17936a146eb49d47eac37
2017-05-17 09:08:15 +00:00
Harald Welte 67bdd80a96 stats: Disable stats*.c on embedded targets
Change-Id: I6beb4fcc394ed7d3f8dd7a097b6e998245ecf401
2017-05-15 19:00:40 +02:00
Vadim Yanitskiy ac9e2d8aa5 gsm/tlv.h: fix copy-paste error
Change-Id: Id52ddd8358fd4af1ecc71142deb09f1e237021f3
2017-05-15 12:51:15 +00:00
Harald Welte 20725b9eea gsm0808 + ipa: fix compilation on systems without sys/socket.h
Change-Id: I60f5d4982cd96ab29f9924ec11b46bf56fbfc346
2017-05-15 13:42:03 +02:00
Harald Welte 50ef73377c tlv: Add tlvp_val{16,32}be() to get TLV values in unaligned host byte order
Change-Id: I3749e1e4974742bc8c32722e0e998775b5394829
2017-05-15 13:42:03 +02: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
Harald Welte 054667fe15 endian.h: Make it work on 'bare iron' builds (and possibly more platforms)
We can use __BYTE_ORDER__ which seems to be defined by both gcc and
clang/llvm.

Change-Id: Id6821c99e88242126d9697099b1dd92c6212526a
2017-05-15 13:01:01 +02:00
Max 91dd219b99 Make EARFCN size calculation more robust
* add osmo_earfcn_bit_size_ext() function which allows to specify how many
  EARFCNs we should skip when estimating required bit size for SI2quater
* make old osmo_earfcn_bit_size() into wrapper over newly added function
  and mark it as deprecated

This is necessary to properly estimate necessary space for EARFCNs when
they are spread over several SI2q messages with different index.

Change-Id: I92e12e91605bdab9916a3f665705287572434f74
Related: RT#8792
2017-05-14 08:51:26 +00:00
Daniel Willmann 6959e3c110 gsm_04_08: Add missing GSM cause value
Table 10.5.157 in 10.5.6.6 of 3GPP TS 04.08 is badly formatted. The first
value 0x19 "LLC or SNDCP failure" is in the same line as the heading and has
not been included in the struct_value so far.

Table 10.5.157 in 10.5.6.6 of 3GPP TS 24.008 fixes this formatting issue and
also defines two more values 0x08 and 0x18 which are now added to the struct
value_string.

Change-Id: I5bcc52f739ff0677011d024448afcc2a54869638
2017-05-12 13:53:12 +00:00
Pablo Neira Ayuso 44f423f117 timer: add osmo_timer_setup()
Add a new function timer function to set up the timer, similar to what
we have in the Linux kernel. This patch also converts existing opencoded
timer setup in the libosmocore tree as initial client of this new
function.

This patch implicitly removes function callback passed by reference that
defeat compile time type validation.

Compile-tested only, but I ran make check that reports success when
testing timer infrastructure.

Change-Id: I2fa49972ecaab3748b25168b26d92034e9145666
2017-05-09 12:10:51 +02:00
Max c65c5b4ea0 vty: cleanup logging functions
* remove unused parameter from logging_vty_add_cmds()
* mark log level descriptors static
* change internal static function int check_log_to_target() to more
  appropriate bool should_log_to_target()
* deprecate log_vty_command_*() from public API as it should only be
  used by logging_vty_add_cmds()

Change-Id: I0e9ddd7ba3ce211302d99a3494eb408907a2916e
Related: OS#71
2017-05-09 09:11:05 +00:00
Max 584f4b69d6 gprs: add value strings for NS PDU type
Add value strings for Service Control PDUs according to 3GPP TS 48.016 §9
and use them for logging.

Change-Id: I0ea3a45f35d68619d4cfa9735ef77abd9f9f0d58
Related: SYS#3610
2017-05-09 09:10:20 +00:00
Max f74cfd35ac Add SW Description (de)marshalling
* data structure representing 3GPP TS 52.021 §9.4.62 SW Description
* function to serialize it into msgb
* function to deserialize it from buffer
* functions to extract/estimate buffer size for SW Description
* test harness (partially taken from OpenBSC)

There are several similar functions to deal with SW Description in
OpenBSC, there's also need to use similar functionality in
OsmoBTS. Hence it's better to put the code into common library with
proper tests and documentation.

Change-Id: Ib63b6b5e83b8914864fc7edd789f8958cdc993cd
Related: OS#1614
2017-04-28 08:45:09 +00:00
Harald Welte 31c0fef2fd control_if: Add control interface commands for FSMs
This allows programmatic access to introspection of FSM instances, which
is quite handy from e.g. external test cases: Send a message to the
code, then use the CTRL interface to check if that message has triggered
the right kind of state transition.

Change-Id: I0f80340ee9c61c88962fdd6764a6098a844d0d1e
2017-04-27 09:50:47 +02:00
Harald Welte f85861d6eb control_if: Add helper function for 'local execution' of control command
Sometimes (particularly when testing), we may want to parse+execute an
arbitrary control command simply form a string buffer, rather than from
a msgb.  Let's add a helper for that.

Change-Id: Iaca748e0d942bb2a1ee7c2776b37485e1439eb0c
2017-04-27 09:50:33 +02:00
Harald Welte 79c137c654 control_if: Add API to initialize control interface without TCP port bind
When executing test cases, we don't want to bind to a local TCP port, as
we cannot make assumptions as to which ports are actually free.

Change-Id: I5717f9dd92d1f143f069cecd4b4c8ba3d03b25f8
2017-04-26 13:47:06 +02:00
Harald Welte d6b1f85fd8 ctrl: Allow installation of additional node lookup helpers
The existing code assumes that the main application knows about all
control command nodes and can thus present one lookup function.

As libraries are getting their own control interface handling, this
is too restrictive, and we need a way how library code can dynamically
register more node lookup helpers.   We can now do this by means of a
ctrl_lookup_register() function.

Change-Id: Ib69908d1c57f5bb721d5496e3b4a5258fca450e3
2017-04-26 09:22:19 +00:00
Harald Welte 4585e6755d osmo_fsm: Lookup functions to find FSM Instance by name or ID
Introduce two lookup helper functions to resolve a fsm_instance based on
the FSM and name or ID.  Also, add related test cases.

Change-Id: I707f3ed2795c28a924e64adc612d378c21baa815
2017-04-16 17:28:23 +02:00
Harald Welte 7bc88bbd7e ipa: Introduce helpers to encode IPA CCM ID RESPONSE
The ipa.c file already contained code to parse an ID RESPONSE into the
'struct ipaccess_unit', but it didn't so far contain code to put
together an ID RESPONSE packet based on that structure.  Let's change
that with ipa_ccm_make_id_resp() and a helper wrapper
ipa_ccm_make_id_resp_from_req().

Change-Id: Icbcd8827a75fd5f3393351c1ca372de85275ad35
2017-04-15 19:05:33 +02:00
Harald Welte 59a9ebf8b8 msgb: Add msgb_pull_to_l2() analogous to msgb_pull_to_l3()
Introduce msgb_pull_to_l2() which pulls (removes) any msgb contents in
front of the L2 header (msg->l2h).

Change-Id: I7786a1b30f9e7eaa3dcdb3cbb2a85a126588f6cd
2017-04-15 19:04:34 +02:00
Harald Welte b522740be5 vty/command.h: Introduce VTY nodes for libosmo-sigtran
This adds several VTY nodes required by the libosmo-sigtran VTY
interface.

Change-Id: I184a7e3187b48c15c71bf773f86e188fe1daad15
2017-04-14 14:01:56 +02:00
Harald Welte dda70fca79 Add osmo_sock_init2() function, allowing both BIND *and* CONNECT
The old osmo_sock_init() function allows only either a bind (for a
server socket), or a connect (for a client socket), but not both
together.  So there's no way to have a client socket that is bound to a
specific local IP and/or port, which is needed for some use cases.

Change-Id: Idab124bcca47872f55311a82d6818aed590965e6
2017-04-09 21:46:21 +02:00
Harald Welte acd08feb8f Add struct osmo_prim_event_map and osmo_event_for_prim()
This can be used to map from an osmo_prim to an osmo_fsm event.

Change-Id: I52350f4ebe97811b2a692e5a69a2cd39a853583c
2017-04-09 17:54:28 +00:00
Philipp Maier c6144a2448 gsm0808: Add create functions for BSS_MAP_MSG_ASSIGMENT_RQST
gsm0808.h/c lacks functionality to generate BSS_MAP_MSG_ASSIGMENT_RQST messages.
These messages are required if the code is used in an MSC implementation.

This commit adds a gsm0808_create_assignment() function, that generates an
A/AoiP BSS_MAP_MSG_PAGING message.

Change-Id: I4d1d455a1e1cf95407e23ded7b7defbcf2dd6ff0
2017-04-08 07:44:47 +00:00
Philipp Maier 3d48ec06a9 gsm0808: Add create functions for BSS_MAP_MSG_PAGING
gsm0808.h/c lacks functionality to generate BSS_MAP_MSG_PAGING messages. These
messages are required if the code is used in an MSC implementation.

This commit adds a gsm0808_create_paging() function, that generates an A/AoiP
BSS_MAP_MSG_PAGING message.

Change-Id: I9afecf0109305ca5153bf081bb29cd94071dd2b7
2017-04-08 07:44:46 +00:00
Philipp Maier b478dd38d2 gsm0808: Add create functions for CIPHER MODE COMMAND
gsm0808.h/c lacks functionality to generate CIPHER MODE COMMAND messages. These
messages are required if the code is used in an MSC implementation.

This commit adds a gsm0808_create_cipher() function, that generates an A/AoiP
CIPHER MODE COMMAND message.

Change-Id: I8eb1c357860c3e740b0f5d17e1c256bc87920958
2017-04-08 07:44:46 +00:00
Philipp Maier 783047e86e gsm0808: Add utils for Cell Identifier List
The planned support for true A over IP requires the encoding of
the a Cell Identifier List element (see also BSS_MAP_MSG_PAGING).

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

Change-Id: I625245dd1dd396fc2bc189e8cd2c444a33042528
2017-04-08 07:44:46 +00:00
Philipp Maier 14e76b9958 gsm0808: Add utils for Encryption Information
The planned support for true A over IP requires the encoding of
the an Encryption Information element (see also BSS_MAP_MSG_CIPHER_MODE_CMD).

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

Change-Id: I8262050a9d9fd3f17462cfbb046c6e034dccc6fb
2017-04-08 07:44:46 +00:00
Philipp Maier e0c65301d5 gsm0808: Add utils for Channel Type
The planned support for true A over IP requires the encoding of
the a Channel Type element (see also ASSIGNMENT REQUEST).

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

Change-Id: Id0e2164d84b8cbcc6fe6a090fc7f40a1251421d7
2017-04-08 07:44:46 +00:00
Philipp Maier fa896abbb3 gsm0808: Add AoIP specific elements to gsm0808_create_... functions
the classic A implementation in libosmocore lacks support for AoIP
message elements. This patch adds support for AoIP by adding a set
of new gsm0808_create_..., which support the missing AoIP message
elements

Change-Id: I77f866abec1822d19871052f3c647ad782785b34
2017-04-08 07:44:45 +00:00
Philipp Maier 6f725d6da3 gsm0808: Add utils for Speech Codec List and Speech Codec
The planned support for true A over IP requires the encoding and
decoding of a so called "Speech Codec Element" element.

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

Change-Id: I0e1e2edf47adaa45b22d4b0bcae3640dba7ca200
2017-04-08 07:44:45 +00: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
Harald Welte f7add0889c add VTY port number for osmo-stp
Change-Id: I978e1b73aa8097a7db6318d78f9f93457e6ce2af
2017-04-08 09:34:04 +02:00
Harald Welte 62d3296c14 logging.h: #define DLSS7, DLSCCP, DLSUA, DLM3UA for libosmo-sigtran
Change-Id: I61f452208088dc7097165deecef7c058ebb4bd4e
2017-04-03 19:38:37 +02:00
Max 7f9c7e7b8b Add support for PCU version report
Expand 3GPP TS 52.021 §9.4.43 Probable Cause with Osmocom-specific value
for PCU version reporting to enable sending it via OML alarms.

Change-Id: If57459c0610f2c7b36d599b13087c8deef8bdd9e
Related: OS#1614
2017-03-23 09:56:56 +00:00
Max 5d994e4f75 abis: add message type names
Add human-readable names for Message Types from 3GPP TS 52.021 §9.1

Related: OS#1614

Change-Id: Ide8202b4387351f57ceee34a9eb8c30aef09a663
2017-03-22 15:26:35 +01:00
Max 62d6f25703 abis: add attribute names
Add human-readable names for Attributes from 3GPP TS 52.021 §9.4

Change-Id: I861247c01557dac7e484ef6fb9b170f69c8a7f55
Related: OS#1614
2017-03-21 17:38:49 +01: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
Neels Hofmeyr 00ab9ed6e2 add gsm48_pdisc_msgtype_name()
Composing the message type string requires knowing the protocol discriminator.
To ease printing the message type, add this function to switch between the
defined value_string[]s depending on pdisc.

Also publish the message type value_string[]s -- without inline functions to
access them because it is anyway more convenient to use
gsm48_pdisc_msgtype_name() instead.

Since gsm48_pdisc_msgtype_name() is nontrivial, do not add as inline function
-- in case the message type is not known, it needs a static string buffer.

Change-Id: I0fca8e95ed5c2148b1a7440eff3fc9c7583898df
2017-03-16 12:54:18 +00:00
Neels Hofmeyr dbd994c05b add gsm48_pdisc_names and gsm48_pdisc_name()
I often want to log the protocol discriminator in the openbsc debug log. It's
more useful to get the name directly instead of looking it up every time.

Change-Id: I0f053e2a4360b27ffccda7cf82469fb1b1cbb3ae
2017-03-16 12:54:18 +00:00
Neels Hofmeyr 8a5d60b996 fix OSMO_VALUE_STRING macro: don't use OSMO_STRINGIFY()
To be able to use OSMO_VALUE_STRING() on a #defined constant, don't use
OSMO_STRINGIFY(): the second indirection resolves the #define to its value, so
for example

   OSMO_VALUE_STRING(GSM48_PDISC_MM)

would resolve to

   { 0x05, "0x05" }

When using '#x' directly, this becomes the desired

   { 0x05, "GSM48_PDISC_MM" }

With enum values as we've used until now, this problem does not appear, because
enum values are not resolved by the preprocessor.

Keep OSMO_STRINGIFY() because it is used directly in openbsc (composing FSM
state names).

Change-Id: I91ecfcef61be8cf73d59ea821cc4fd9d2ad5c9c7
2017-03-15 13:54:26 +00:00
Neels Hofmeyr 7c1ec8c8e7 ctrl_type_vals: explicitly terminate
Don't use CTRL_TYPE_UNKNOWN as value_string[] terminator, use an explicit, more
obvious { 0, NULL } termination. Set an explicit string for CTRL_TYPE_UNKNOWN.
No other value_string[]s to date have such a "hidden" terminator.

BTW, a { 0, "string" } item is not a terminator, only { 0, NULL } is, so we can
set a string for CTRL_TYPE_UNKNOWN == 0.

Also, having a string value for CTRL_TYPE_UNKNOWN is not harmful because all
code paths explicitly check for the CTRL_TYPE_*s that are valid.

Adjust the test expectation.

From the ctrl_type_vals enum, remove the = 0, because it is implicitly 0
anyway.

One motivation to press this fixup: I am trying to add a script that checks
whether all value_string[]s are terminated to our jenkins jobs, and to find
that this one is terminated, it would need to interpret the CTRL_TYPE_UNKNOWN
constant, which would make things far more complex. At this point, all of the
value_string[]s have an explicit termination, and I would like to enforce this
from now on -- for readable code and to not spend more time on the validator.

The patch adding ctrl_type_vals (Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28) was
accepted by another reviewer before I could reconfirm my -1, so this is a fixup
to enable the termination checking script patches.

Related: I2bc93ab4781487e7685cfb63091a489cd126b1a8 (adds script to libosmocore)
         I7fe3678b524d602fc6aa14bc0ed06308df809a3e (uses in jenkins.sh)
	 Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28 (adds ctrl_type_vals)

Change-Id: Ia99f37464c7b36b587da2cc78f52c82725f02cbc
2017-03-15 13:47:20 +00:00
Neels Hofmeyr 4cb0c8b45e linuxlist.h: add llist_first/last_entry macros
Copy list_first_entry, list_first_entry_or_null and list_last_entry from
current linux kernel's tools/include/linux/list.h and rename to llist_*.
Slightly adjust API doc but stay as close to the source as possible.

This can replace similar implementations in osmo-bts-octphy's l1_if.c,
in openbsc's gtphub.c and in osmo-hlr's gsup_server.c.

Change-Id: I4eac5be0c0b2cede04464c4c3a0873102d952453
2017-03-15 12:58:00 +00:00
Neels Hofmeyr bb6f7b7bec osmo_auth_gen_vec: UMTS auth: fix SQN as SEQ || IND
So far we incremented SQN by 1, which doesn't match the procedures described in
3GPP TS 33.102. An IND (index) denotes a non-significant part of SQN, and the
significant SEQ part needs to be incremented.

In OsmoHLR we furthermore want to use the "exception" suggested in annex C.3.4,
so that each HLR's client has a fixed IND index. In other words, we will not
assign IND cyclically, but keep IND unchanged per auth vector consumer.

Add 'ind_bitlen' and 'ind' to the osmo_sub_auth_data.u.umts structure and
increment SQN accordingly.

Add a comment explaining the details.

Because 'ind_bitlen' is still passed as zero, the milenage_test does not change
its behavior, which is a feature I want to clearly show in this patch. The test
will be expanded for the newly implemented SQN scheme in a subsequent patch.

Adjust osmo-auc-gen.c to still show the right SQN and SQN.MS -- because it is
passing ind_bitlen == 0, osmo-auc-gen can rely on single increments and know
SQN.MS is sqn - 1. Note that osmo-auc-gen_test output remains unchanged.

Related: OS#1968
Change-Id: Ibc97e1736a797ffcbf8c1f7d41c5c4518f4e41bf
2017-03-15 12:46:08 +00:00
Alexander Couzens 953f929797 gsm_04_08: add _NUM_CHREQ_T to enum
_NUM_CHREQ_T defines the last element of the enum

Change-Id: Id67ba8de89dd6288e449197438e9e1c5d7f5a134
2017-03-14 13:47:29 +01:00
Alexander Couzens f48e8a8ba9 gsm0408: add chreq_type for CHREQ_T_PDCH_ONE_PHASE and CHREQ_T_PDCH_TWO_PHASE
The previous version of this commit got reverted to avoid a breakage in openbsc.
The problem is openbsc use an array of chreq_type with a manual defined size. This array
is using enums as index which breaks if any elements got added into the
middle, because the size of the array can't hold elements greater or
equal than the size.

Change-Id: I6676105507fe4e5627f740dfe4c2770f766ad068
2017-03-14 13:30:13 +01: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
Neels Hofmeyr fca04bba5a fsm: convenience: add inline osmo_fsm_inst_state_name()
Change-Id: If9a6ecc4d6e2beaf716569e9a6053d73488e860b
2017-03-01 23:52:55 +00:00
Max 70c7d4160d Use value_string for ctrl_type
Use value_string for enum ctrl_type instead of custom code. Add
corresponding unit tests.

Related: OS#1615
Change-Id: Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28
2017-03-01 16:37:59 +00:00
Neels Hofmeyr fa5dc93fd0 ports.h: rename CSCN to MSC
See OS#1958

Change-Id: I85aee0f8fdfc9c69d0ba9240988c633d3e707f2d
2017-02-24 19:57:48 +00:00
Max fa9e05e7e8 Expand and expose ctrl connection allocation
Add function for allocating CTRL connection to public headers and
replace call to previous static function with it. Add doxygen docs for
this function.

It's useful if we need to allocate ctrl connection but don't need to
bind to any interfaces: when we act as ctrl client.

Related: OS#1615
Change-Id: I522ed809cbebfd3d7dd08b4ed9137b39ff192e32
2017-02-23 17:30:44 +00:00
Neels Hofmeyr 8b86cd76cf logging.h: fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_*
My recent logging patch was merged to master a bit too soon. Accomodate the
request for naming that matches the general "LOG" prefix instead of "LOGGING".

libosmocore will not be backwards-compatible with the few commits from
change-id I5c343630020f4b108099696fd96c2111614c8067 up to this one. This and
following commits are backwards compatible with those before that short window.

See also:
* openbsc change-id Ib2ec5e4884aa90f48051ee2f832af557aa525991
* osmo-pcu change-id I4db4a668f2be07f3d55f848d38d1b490d8a7a685

Change-Id: I424fe3f12ea620338902b2bb8230544bde3f1a93
2017-02-23 18:08:12 +01:00
Neels Hofmeyr 492e1808b0 logging.h: fixup: add API doc for logging enums recently added
Change-Id: Ic459b04219abe70171c8f80ed09df53d412dcfb2
2017-02-23 17:53:23 +01:00
Neels Hofmeyr 0d6420b302 logging.h: fix backwards compat broken by recent commit
Commit 812ba6dc63
"logging: centrally define ctx and filter indexes"
Removed definitions, which causes older e.g. openbsc and osmo-pcu code trees to
fail to build against a newer libosmocore. Re-introduce the legacy definitions
to redirect to the new ones and re-establish backwards compatibility.

The GPRS_* constants used to be defined in gprs_msgb.h, but since that header
also includes logging.h, rather place the legacy shims in logging.h next to the
other ones.

Change-Id: I455bb1bb474d758af0fd5b6397f7e57260ad739d
2017-02-23 17:53:07 +01:00
Neels Hofmeyr d1c2fc6de1 gsm_04_08.h: add R99 MSCR and CBQ3 to SI3 Ctrl Chan Descr
MSCR and CBQ3 are Release 1999 additions to the Control Channel Description IE
of SI3.

Assuming that no-one is using the spare bits, this will not cause any code
conflicts.

In the R99 struct, spare1 and spare2 are in different places, so rather rename
them to spare_1 and spare_2 to make sure we get a compiler barf *if* anyone
tries to use them with the wrong structure.

Adjust the spec reference to TS 44.018; TS 04.08 Figure 10.5.33 is replaced by
TS 44.018 Figure 10.5.2.11.1 which is right there in the named Section
10.5.2.11, so drop the explicit reference.

Motivation: the R99 Control Channel Description defines MSCR to indicate
whether the MSC is R99+ or not. To use UMTS AKA on GSM networks, we want to
indicate that our libmsc is capable of R99, like OsmoSGSN already does.

CBQ3 is merely added for completeness, no particular use case in mind.

Related: OS#1593
Change-Id: If87e07b5d04e1617155383e14c98d2125fdd0608
2017-02-23 03:39:36 +01:00
Neels Hofmeyr 812ba6dc63 logging: centrally define ctx and filter indexes
It is too easy for calling code to use the same filter and context indexes for
different filters and structs. For example, openbsc's IMSI filter and libgb's
GPRS_BVC filter both fall on index 1 even though there are plenty more indexes
to choose from. To alleviate this, have one central definition here, sort of
like ports.h does for VTY and CTRL port numbers.

Add static asserts to make sure the indexes fit in the available array and bit
mask space.

Calling code like openbsc.git and osmo-pcu need adjustments and/or should move
to using these enum values instead of their local definitions.

Taking this opportunity to also prepare for a split of struct gsm_subscriber in
openbsc into bsc_subsciber and vlr_subscriber with appropriate separate filter
index constants for both subscriber types.

Include previous LOG_FILTER_ALL in the LOGGING_FILTER_* enum, and replace its
use by (1 << LOGGING_FILTER_ALL).

Change-Id: I5c343630020f4b108099696fd96c2111614c8067
2017-02-22 16:08:38 +00:00
Neels Hofmeyr 10f5fb49db gsup: add osmo_gsup_message_type_name()
Change-Id: Ic29b588b72893821d73fe90ecc16c6bf78d5a360
2017-02-15 23:26:07 +00:00
Max af4bb17a93 Add CTRL port for OsmoHLR
Change-Id: I1328c89ec8e908bf4b4d2c0a398690278369e0f5
Related: OS#1645
2017-02-14 12:13:32 +01:00
Philipp Maier b288853ffa select: add functionality to check socket state
osmo_fd_register() is used to register socket file descriptors,
after registering a socket, there is no way to test if the socket
is still registered or actually registered at all.

This commit adds a new function osmo_fd_register_check() that can
be used to check in advance, if the socket fd is registered,
before performing further operations.

Change-Id: I48ec7098d6bba586c81bf0d5c9088108e2c081c6
2017-02-07 13:39:00 +01:00
Neels Hofmeyr 03ab9a6500 osmo_auth*: fix ordering of function args
milenage_gen_vec() has parameter ordering of (..., auts, rand_auts, rand).

osmo_auth_gen_vec_auts() has (..., rand_auts, auts, rand), but actually feeds
args in the same order, so that its rand_auts becomes auts, and its auts
becomes rand_auts.

Interestingly enough, API user osmo-gen-vec.c also adheres to this misordering
and in turn passes auts for osmo_auth_gen_vec_auts()'s rand_auts and vice
versa, so that it matches milenage_gen_vec().

So both the implementation (milenage_*) and the API user use the same ordering,
just osmo_auth_gen_vec_auts() and osmo_auth_impl{ .gen_vec_auts() } in-between
have the argument names swapped.

Any current user of this API would need to adhere to this swapping or will not
get successful AUTS resolution to a SQN. So the least impact fix is to rename
the args without any actual functional change.

So swap the names rand_auts and auts for osmo_auth_gen_vec_auts() and
osmo_auth_impl{ .gen_vec_auts() }. (Also adjust API doc ordering)

Change-Id: I0dcbd49759fc32d3b8974102dbd1d6703364ebf4
2017-02-06 14:09:31 +00:00
Neels Hofmeyr 55a43b8013 gsm48: add UMTS AKA res+sync IEIs, msg type and cause val
According to 3GPP TS 24.008 9.2.3a, 9.2.3, 10.5.3.6

Change-Id: I745061ce8eb88aa23080dadcdbfe2d703c362a30
2017-02-02 20:34:16 +01:00
Neels Hofmeyr 8352d31a86 GSUP, OAP, osmo-gen-vec: fix AUTS length to 14, not 16
GSUP transmits AUTS for UMTS authentication procedures, and OAP uses the same
procedures to authenticate. osmo-gen-vec is a utility program that passes AUTS
to our osmo_auth_gen_vec_auts() API.

According to 3GPP 33.102 6.3.3, AUTS = SQN^AK || MAC-S, which are 6 || 8 == 14
bytes. This is confirmed by 24.008 9.2.3a where the TLV has 16 bytes, TL = 2
and AUTS being the V = 14.

It is not harmful for milenage_gen_vec_auts() to pass two more AUTS bytes. But
writing 16 bytes to a GSUP struct is a potential problem when passing in a 14
byte long AUTS buffer to the GSUP API, which then reads past the AUTS buffer.
The API implies the length, so far to be 16, so passing in a 14 byte buffer to
GSUP would require copying to a larger buffer first.

Fix this by using a length of 14 for AUTS everywhere instead.

This constitues an ABI breakage, we may handle it as a "fix before an official
release", otherwise we need a version bump.

The OAP protocol document has also been updated, needs an update in the
osmo-gsm-manuals as well.

Change-Id: If25b173d9ec57ea4c504d860954912b7d82af455
2017-02-02 20:34:16 +01:00
Neels Hofmeyr 4a7f87cdc8 comment: ports.h: more visibly remind to keep docs+wiki synced
It is still too easy to forget syncing, so add another reminder at the end
of the list.

Change-Id: I95191906afa8e6ada31310d0e36de33e3fccf268
2017-01-30 12:57:47 +01:00
Neels Hofmeyr 92fa18e6b8 vty/ports.h: reserve port 4258 for OsmoHLR VTY
Change-Id: I08cb52d9399a27e6876e45da36f434708c4fddef
2017-01-28 04:02:53 +01:00
Harald Welte 48f5583347 socket: Introduce function to obtain socket name
Using this function, one can obtain a human-readable string identifying
the host and port names of the socket.

Change-Id: Ib5de5c7b9effe1b0a363e4473a7be7fa38ca6ef3
2017-01-27 10:28:58 +01:00
Max 319f321da5 OML: add external alerts
Add special cause for alerts produced by external processes.

Change-Id: Idd7ee085321f8172c72ecfdba320186049f4d988
Related: OS#1615
2017-01-25 11:49:08 +00:00
Harald Welte 75c0e2f371 utils.h: #include <stdio.h> as we use fprintf()
Change-Id: I911c7f4bcadde414ce0b384e13a3a9a4a953e2fb
2017-01-23 12:20:33 +00:00
Neels Hofmeyr 505a22fc51 linuxlist.h: add llist_count()
After subchan_demux.c in libosmo-abis, osmo-bts/common/vty.c and openbsc's
gtphub_test.c, more places would like to count the llist items (mostly unit
tests). Instead of proliferating numerous local implementations, add here.

NOTE: other than the previous llist_len() implementations, this one returns an
*unsigned* length, which might need some adjusting of current callers.

Call this llist_count() rather than llist_len() to highlight the fact that this
is actively iterating. This also avoids a potential naming conflict when
library versions mismatch.

Change-Id: Ic49adc7a346f5722bf624d7d3b4a735e4220ae15
2017-01-21 01:12:32 +01:00
Max aa1bc012c8 logging: remove code duplication
* make DEBUGP* macro into simple wrappers around LOGP*
* deprecate unused logp() function

Related: OS#71
Change-Id: Ia6c92bd4824c44fc22cc733ce7a88da86e58ed93
2017-01-16 14:12:13 +00:00
Max 8928747a3e CTRL: add write-only helpers
Similar to CTRL_CMD_DEFINE_RO() add helper for control commands which
are not meant to be read, only to set. Similarly, add
CTRL_CMD_DEFINE_WO_NOVRF() for commands which do not perform inbound
data verification.

Change-Id: I66b7990db590c1f8e56326e392e6c1d2eafebd9a
2017-01-16 08:54:17 +00:00
Harald Welte 449324b264 bitvec: Ensure bitvec.h and bitvec.c agree on function argument type
uint32_t may or may not be unsigned int.

Change-Id: I21c96985fcbb72372b6df949301c21f1ebca41f2
2017-01-15 18:04:02 +01:00
Harald Welte f2899c674e Always include <osmocom/core/talloc.h> and not <talloc.h>
In EMBEDDED builds we don't have a system-wide talloc

Change-Id: Icc526016bda45b36e584afee8669996752d6d89c
2017-01-15 18:04:02 +01:00
Max 1251afe254 Add abis_nm_fail_evt_vrep() function
It accept fixed number of arguments including va_list instead of variable
number of arguments in abis_nm_fail_evt_rep() - similar to vprintff() vs
printf().

Related: OS#1615
Change-Id: Ib293dec1c2de9b664584a8456c782ea7b6dd8555
2017-01-11 18:12:32 +01:00
Max 85908a9c2f Add value strings for Probable Cause Type
Add string representation of Probable Cause Type from 3GPP TS 12.21 §
9.4.43.

Change-Id: I9fe14ed3b5398f59dd06a509e4d419e074cc20a7
Related: OS#1615
2017-01-10 17:49:23 +01:00
Harald Welte ebcf02de6c gsmtap: Add GSMTAP_TYPE_QC_DIAG
This adds a definition for wrapping Qualcomm DIAG frames into GSMTAP for
transporting them over an IP network.

Change-Id: I1b357b7d11a370685671c7b01e55f4f36dec2f25
2017-01-09 13:19:16 +01:00
Harald Welte 3419391422 fsm: Add VTY introspection of osmo_fsm and their instances
Change-Id: I89212e4f149f019099115a85bab353c04170df90
2017-01-07 12:21:11 +00:00
Harald Welte 8808bb49a2 Add osmo_fsm_find_by_name() and avoid registering FSM with same name
This addresses a FIXME in the fsm.c code: osmo_fsm_register() should
fail in case a FSM with the given name already exists.

Change-Id: I5fd882939859c79581eba70c14cbafd64560b583
2017-01-07 12:20:59 +00:00
Max ecbcdf52ec Add OML Failure Event Report support
Add 3GPP TS 12.21 § 8.8.2 Failure Event Report function which pack given
vararg string and parameters into msgb.

Change-Id: I58c198d8ea588432c62520928b08f0b2a7035e93
Related: OS#1615
2017-01-06 18:05:49 +01:00
Max 07352fee09 Add event cause string descriptions
Add human-readable descriptions to event causes from 3GPP TS 12.21 §
9.4.43.

Change-Id: Id173c978616c98b7831fbafb5401064257f1cf73
Related: OS#1615
2017-01-06 11:37:09 +00:00
Pravin Kumarvel 848de8f1df Add function to get uninterrupted bit run
Function bitvec_rl_curbit added to get number of  uninterrupted
bits run in vector starting from the current bit till max number
of bits.
Test case is added to check bitvec_rl_curbit.

Change-Id: Iae153d3639ea6b891c1fc10d7801a435c9492e26
2017-01-06 10:37:42 +00:00
Minh-Quang Nguyen 592fcc97c0 Add cause enum for OML fail reports
Add 3GPP TS 12.21 §9.4.43 Probable Cause values of type 03 (Manufacturer
specific values).

Max's note: renamed to make it clear that values are vendor-specific.

Related: OS#1615
Change-Id: Ie9ba4b53fb19a151447aec9ea309284e20613585
2017-01-06 10:21:11 +00:00
Max dbd3a92f70 Add parsed TLV helpers from OsmoBTS
Add functions to copy and merge parsed TLV structures from OsmoBTS.

Change-Id: Ieaaaed19da9c069fe451faa53d24c5b84d7d5615
2017-01-06 10:21:11 +00:00
Max 0bee65c0d8 Add OML definitions from OsmoBTS
Change-Id: I9c3bc15662949654e7bba6aad5488c69ee7d0c45
Related: OS#1615
2017-01-06 10:21:11 +00:00
Neels Hofmeyr c014f606d0 fsm: factor out osmo_fsm_inst_term_children() from osmo_fsm_inst_term()
osmo_fsm_inst_term() has code for safe child removal, publish that part as
osmo_fsm_inst_term_children(); also use from osmo_fsm_inst_term().

As with osmo_fsm_inst_term(), add osmo_fsm_inst_term_children() macro to pass
the caller's source file and line to new _osmo_fsm_inst_term_children().

Rationale: in openbsc's VLR, I want to discard child FSMs when certain events
are handled. I could keep a pointer to each one, or simply iterate all
children, making the code a lot simpler in some places.

(Unfortunately, the patch may be displayed subobtimally. This really only moves
the children-loop to a new function, replaces it with a call to
_osmo_fsm_inst_term_children(fi, OSMO_FSM_TERM_PARENT, NULL, file, line) and
drops two local iterator variables. No other code changes are made, even though
the diff may show large removal + addition chunks)

Change-Id: I8dac1206259cbd251660f793ad023aaa1dc705a2
2016-12-24 17:11:52 +00:00
Neels Hofmeyr eeacf906dd fsm: move LOGPFSMSRC and LOGPFSMLSRC to .h
LOGPFSM and LOGPFSML are in the header file, put the *SRC variants also there
so users of the osmo_fsm_inst API may conveniently create own functions that
log the caller's source file and line.

Very useful if many action functions call the same event dispatching function,
like foo_fsm_done(), and one needs to know which of the callers to debug.

Change-Id: I39447b1d15237b28f88d8c5f08d82c764679dc80
2016-12-24 17:11:52 +00:00
Harald Welte a0f74f218b add CRC16-CCITT to libosmocore
Use the implementation from Linux lib/crc-ccitt.c (GPLv2)

Change-Id: I26bb54038f5ab36bbb34da7f5fb8ae6c0c0386a4
2016-12-23 22:16:08 +01:00
Neels Hofmeyr 18080960e1 utils.h: add OSMO_STRINGIFY and OSMO_VALUE_STRING macros
OSMO_STRINGIFY particularly allows putting port numbers from a #define into VTY
doc strings, like:

  #define FOO_PORT 2342
  DEFUN(...,
        "Foo UDP port (default: " OSMO_STRINGIFY(FOO_PORT) ")\n")

OSMO_VALUE_STRING creates value_string items with the string being exactly the
enum value's name. Replaces a similar macro def in fsm.c

Change-Id: I857af45ae602bb9a647ba26cf8b0d1b23403b54c
2016-12-21 10:37:13 +00:00
Neels Hofmeyr 42b59c1bf0 fsm api doc: fix typo in doxygen marker '\breif'
Change-Id: I5c57e35b29d50cb409becada6b9b120ce5210ae0
2016-12-20 12:39:32 +01:00
Neels Hofmeyr 5c5c78aacd add value strings for enum osmo_fsm_term_cause and use for logging
Change-Id: Iaf63d3cadb0d46bf454e3314ebb439240cafd834
2016-12-15 11:35:56 +01:00
Neels Hofmeyr 725698a4f1 fsm: log caller's source for events and state changes, not fsm.c lines
When looking at log output, it is not interesting to see that a state
transition's petty details are implemented in fsm.c. Rather log the *caller's*
source file and line that caused an event, state change and cascading events.

To that end, introduce LOGPSRC() absorbing the guts of LOGP(), to be able to
explicitly pass the source file and line information.

Prepend an underscore to the function names of osmo_fsm_inst_state_chg(),
osmo_fsm_inst_dispatch() and osmo_fsm_inst_term(), and add file and line
arguments to them. Provide the previous names as macros that insert the
caller's __BASE_FILE__ and __LINE__ constants for the new arguments. Hence no
calling code needs to be changed.

In fsm.c, add LOGPFSMSRC to call LOGPSRC, and add LOGPFSMLSRC, and use them in
above _osmo_fsm_inst_* functions.

In addition, in _osmo_fsm_inst_term(), pass the caller's source file and line
on to nested event dispatches, so showing where a cascade originated from.

Change-Id: Iae72aba7bbf99e19dd584ccabea5867210650dcd
2016-12-14 18:00:52 +01:00
Neels Hofmeyr 6a13e7f563 fsm: add LOGPFSML to pass explicit logging level
Provide one central LOGPFSML to print FSM information, take the FSM logging
subsystem from the FSM instance but use an explicitly provided log level
instead of the FSM's default level.

Use to replace some, essentially, duplications of the LOGPFSM macro.

In effect, the fsm_test's expected error changes, since the previous code dup
for logging events used round braces to indicate the fi's state, while the
central macro uses curly braces.

Change-Id: If295fdabb3f31a0fd9490d1e0df57794c75ae547
2016-12-14 17:56:48 +01: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
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
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 dda9dffca9 Clarify GPRS algorithm
Add spec reference and set explicit values for enum representing
ciphering algorithm for GPRS encryption.

Change-Id: Ia9ee429b73a37d52599fce70778cfe87b767411c
Related: OS#1582
2016-06-29 16:34:14 +00:00
Max c57e5daf22 Clarify GPRS ciphering direction
Add spec reference and set explicit values for enum representing
direction parameter for GPRS encryption.

Change-Id: Iaf1b13da2e889d55cc9dd7516710104dba48c992
Related: OS#1582
2016-06-29 16:33:57 +00: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 14bf28a43d Mark input parameter to bitvec_set_bits() as 'const'
The input data is accessed in a read-only manner, so it should be marked
with the const qualifier.

Change-Id: I0d6b86289fa647594f3da1f1c0e0168685307a37
2016-06-27 15:19:10 +02:00
Harald Welte f627c0f0af fsm: Introduce default time-out handling
If a FSM doesn't specify any timer_cb, simply terminate the FSM by
default on time-out.  This is a reasonable default for most cases, and
avoids copy+pasting a one-line timer_cb function in every FSM.

Also, even if there is a timer_cb, let it have a return value to decide
if the core should terminate after return from timer_cb or not.

Change-Id: I0461a9593bfb729c82b7d1d1cf9f30b1079d0212
2016-06-27 15:17:53 +02:00
Max e0a7d9e2c2 Add octet-aligned/unaligned shift functions
The actual code is from OsmoBTS' tch.c by Harald Welte. Add unit tests,
doxygen annotation and extra memory safety check. Those functions are
used in several BTS implementations but seems generic enough to be
generally useful.

Change-Id: I2b1901c4161e8035f059585901dca593b661556d
2016-06-20 19:02:56 +02: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 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 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 de960cbc0c gsup: Add OSMO_GSUP_MSGT_AUTH_FAIL_REPORT
The VLR must be able to notify the HLR of authentication failures.

Change-Id: I156cff76e092b3548b05534141b61887ee6be3f3
Reviewed-on: https://gerrit.osmocom.org/303
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-16 21:25:22 +00:00
Alexander Couzens ad580ba7c4 add vty call show asciidoc: generate a documentation for counters
For each counter group a ascii doc table is generated
containing all single counter with a reference to a section to
add additional information to the counter

Change-Id: Ia8af883167e5ee631059299b107ea83c8bbffdfb
Reviewed-on: https://gerrit.osmocom.org/70
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Harald Welte <laforge@gnumonks.org>
2016-06-14 10:38:17 +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
Neels Hofmeyr 8d6dcd9bca add get_value_string_or_null() to handle unknown items
Add get_value_string_or_null() to return NULL in case the given value is not
found in the list of strings, to be able to cleanly fall back to another list
of strings. Absorb the lookup loop from get_value_string().

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.
In a subsequent commit, get_value_string_or_null() will be used by new
rsl_or_ipac_msg_name().

Change-Id: I1fa3907e28d528d2758bc3eae9d19e6c1168f5e5
Reviewed-on: https://gerrit.osmocom.org/230
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-13 17:46:20 +00:00
Max ec8f192fec Add functions to detect HR/FR SID frames
Add functions which check if given FR or HR frame (packed in RTP)
contains SID (SIlence Descriptor) and corresponding tests.

Related: OS#22
Change-Id: I4051e3c0d4fb9ee93d7e9e0ef4abaf9f18e227ca
Reviewed-on: https://gerrit.osmocom.org/160
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-01 10:44:06 +00:00
Ruben Undheim 720ac4a4e1 Patched structs for big-endian architectures
Change-Id: I29eafe481e112d18c624b1c83add0d53c354dbe4
Reviewed-on: https://gerrit.osmocom.org/124
Tested-by: Jenkins Builder
Reviewed-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-05-31 11:52:12 +00:00
Max 92db150488 Add helper functions for AMR codec
* add functions to encode/decode various codec paramters from RTP payload with
  AMR frame according to RFC 4867
* those functions are extended version based on code from osmo-bts'
  amr.c by Andreas Eversberg
* add corresponding enum types and strings for logging
* add regression tests

It's useful both to replace manual parsing in osmo-bts with fuctions
covered by test suite and as a debugging helpers for issues related to
AMR.

Change-Id: Ia217679a07d3fbc970f435e20f6eac33d34bd597
Related: OS#1562
Reviewed-on: https://gerrit.osmocom.org/118
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-31 10:11:51 +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
Beshr Al Nahas e4c294f79b Fixing build on Mac OSX
Fix minor syntax error

Change-Id: I67f9a1e41fa5b1da3a4b10fc76138e153b767241
Reviewed-on: https://gerrit.osmocom.org/125
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-28 16:59:56 +00:00
Arran Cudbard-Bell cc3694b650 Fix build for OSX
Change-Id: I580a500edcf4812e570be586890abef746083a8c
Reviewed-on: https://gerrit.osmocom.org/74
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-20 16:32:58 +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
Harald Welte 3d79240fb4 logging: Use __BASE_FILE__ instead of __FILE__
Apparently __FILE__ expands to nasty '../../..' paths when BUILDDIR !=
SRCDIR.  This in turn leads to ugly log lines like:

<0000> ../../../../osmo-bts/src/common/rsl.c:1642 (bts=0,trx=0,ts=0,ss=0) Handing RLL msg UNIT_DATA_IND from LAPDm to MEAS REP

Where we certainly wouldn't want the "../../../../osmo-bts" part.

Change-Id: If6d2de33c3b6bb2943954bbd81eff261dc279d58
Reviewed-on: https://gerrit.osmocom.org/38
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-05-12 11:15:22 +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 9709b2e6fd Import osmo_{encode,decode}_big_endian() from openbsc 2016-05-05 18:49:27 +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 2d2e2cca0d Update doxygen annotations in libosmocore
This adds and improves doxygen API descriptions all over libosmocore,
reducing the 'white spots' that don't have any documentation.
2016-05-05 18:49:27 +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 69e6c3c7cd Add log_fini() function to release all memory allocated by logging framework
This is e.g. quite useful to call at the end of test code, in order to
show that all memory allocated actually is released before exit().
2016-05-05 18:49:22 +02:00
Harald Welte eea18a6f29 add two missing files (gsm0503.h / conv_gen.py) to previous commit 2016-04-29 15:18:35 +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
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
Max bf990bb8fd Update internal GPRS cipher API
Update internal API (for GPRS cipher implementors): make it compliant
with ETSI TS 155.22. External API left untouched.
2016-04-22 15:09:27 +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 fbb8bfa514 Add function to get osmo_earfcn bit size
This function returns the number of bits necessary to pack osmo_earfcn
into Repeated E-UTRAN Neighbour Cells IE (3GPP TS 44.018 Table
10.5.2.33b.1).
2016-04-16 13:41:56 +02:00
Max d8fb14226f Add ubit <-> sbit convertors
Move functions for conversion between soft and unpacked bits to main
library as they are generally useful.
2016-04-12 10:10:44 -04:00
Holger Hans Peter Freyther 793a2907d5 vty: Make a reservation for the osmo-sip-connector
The osmo-sip-connector is a new application and is a MNCC to SIP
bridge. It is not implementing transcoding or RTP proxying at all.
2016-03-31 16:59:23 +02:00
Holger Hans Peter Freyther 61f28880d5 select: Externalize fd_set filling and dispatch
To integrate with an external event loop (in this case glib) we
need to allow an application to get a filled out fd_set and then
dispatch it. osmo_fds and maxfds are static and I decided to keep
it that way and instead create two routines to fill the fdset and
then one to dispatch the result.

The public header file does not include sys/select.h and we can
compile the library without select, so I didn't want to require
having to include this file, and used void * for the parameter.

Mark the routines as inline to avoid a call from the select
function. I have confirmed that inlining has an effect on x86
using Debian's gcc-4.9.2-10 compiler
2016-03-31 16:56:51 +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
Harald Welte 932d2d4ce3 sim: make osim_reader_ops public 2016-03-19 21:18:40 +01:00
Harald Welte 6c33ae2605 Add new osmo_fd_get_by_fd() function
This function can be used to obtain the osmo_fd corresponding to a given
fd.  The latter can be useful when integrating libosmocore main loop
with other libraries.
2016-03-19 21:17:58 +01: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
Harald Welte 5bed23c6d2 add missing #include <stdbool.h> 2016-03-17 16:50:50 +01:00
Max ea345cdaaa Rename struct to better match libosmocore conventions 2016-03-17 16:49:15 +01:00
Max 03309b57e8 Add basic EARFCN support
Add structure representing group of EARFCNs with common priority,
threshold etc.
Add functions to populate this structure.
2016-03-17 14:07:19 +01:00
Max d4793212b5 Add function to add bits from array to bitvec
Add function which adds specified number of bits from each element of
array to the bit vector prefixing each addition with one and finishing
entire sequence with adding 0. This is very common patter for various
repetitive data structures described with CSN.1 in 3GPP standards.

Corresponding test vectors and doxygen headers are added too.
2016-03-17 14:07:19 +01:00
Neels Hofmeyr bdccc1b144 gsm48: factor out MCC+MNC BCD parsing for re-use in UMTS
For 3G, I need a BCD composer/parser similar to gsm48_generate_lai()/
gsm48_decode_lai(). Those functions also handle a trivial extra
member (lac) which I don't need in this way for 3G.

So create new functions to take on the MCC+MNC BCD handling and call those
from gsm48_generate_lai() and gsm48_decode_lai(). In this way, the 3G code
in openbsc can use only the BCD functionality without code duplication.
2016-03-15 14:30:41 +01:00
Neels Hofmeyr da7bf4d55a 04.08: add inline funcs for transaction id bits
Various users of gsm48_hdr apply the same hardcoded shifts/bitmasks to obtain
the transaction ID encoded in the upper nibble of the protocol discriminator.
Centralize. Patch for openbsc.git will follow.
2016-03-15 14:11:49 +01:00
Neels Hofmeyr c656faed12 04.08: switch to r99 msg type bitmasks by default
[hfreyther: Separated from the previous patch to allow an easy
revert]
2016-03-15 14:11:13 +01:00
Neels Hofmeyr 282e908434 04.08: add inline funcs for pdisc + msg type bitmasks
Add inline functions for both release <= 98 and release >= 99 as well as a
default define. Use the release 98 by default since the current code base uses
the r98 bitmasks.

These inline functions relieve callers of the decision on masking bits of the
protocol discriminator and message type octets.

Also add a define for the protocol discriminator extension to one octet length
(GSM48_PDISC_EXTEND).

Apply new pdisc function in gsm0480.c.

[hfreyther: Make the hdr param const]
2016-03-15 14:10:45 +01:00
Max c0d9a6c083 Add helper function to convert numerical BSSGP PDU type to string 2016-03-11 22:29:39 +07:00
Max e859aec952 Add support for SI2quater messages
Add basic data structure for System information Type 2quater.
2016-03-11 22:09:21 +07:00
Harald Welte 5ffb50371e rename osim_file_find_* to osim_file_desc_find_*
they return an osim_file_desc, and not an osim_file, so fix the naming
2016-03-11 22:05:25 +07:00
Harald Welte c28f4cdd6d sim: Add osim_file_find_{fid,sfid}() functions
We don't always want to look-up by name, but the latter is the only
implemented 'find' function so far.  Let's change that.
2016-03-11 22:05:25 +07:00
Jacob Erlbeck a89d22c0f0 log: Add conditional logging based on log_check_level
Currently the LOGP/DEBUGP arguments are always evaluated even if
no logging will happen at all. This can be expensive, for instance
if hexdumps or pretty printed object names are generated. This causes
high base load especially on embedded devices and is a major part of
CPU usage e.g. of the osmo-pcu.

This commit uses the log_check_level function to avoid the evaluation
of the parameters if it is known in advance, that no logging entry
will be generated.

Sponsored-by: On-Waves ehf
2016-02-29 14:30:14 +01:00
Jacob Erlbeck de6dd72dbb log: Add log_check_level function
This commit adds this predicate function which can be used to
avoid the execution of code if a certain log level is not enabled.

The function will only return 0 (false), if it is sure that a logging
call for the same facility and level will not produce any output.
This safety criterion shall ensure, that no logging output is lost
due to the use of this predicate as a guard. On the other hand, even
if the predicate returns != 0 (true), no logging output might get
generated by a similar logging command.

Note that the current implementation is not focussed on performance,
which could be improved by using a lookup table instead of iterating
through every target.

Sponsored-by: On-Waves ehf
2016-02-29 14:30:14 +01:00
Neels Hofmeyr cda988527f fix gsm_7bit_decode API comment: septets, not octets 2016-02-29 09:56:26 +01:00
Max 6a5ef46dd0 Add byte printing macros
It's sometimes handy for debugging to be able to immediately see which
bits are set in a given byte. Generalize macro used for that in bitvec
tests and make it available for the rest of the library.
2016-02-25 22:35:44 +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
Neels Hofmeyr 4934309dab add ctrl_interface_setup_dynip() for bind address
Make the ctrl interface bind address configurable, so that it may be made
available on other addresses than 127.0.0.1. The specific aim is to allow
running multiple osmo-nitbs alongside each other (commits in openbsc follow).
2016-02-25 11:02:35 +01:00
Neels Hofmeyr 96172f0100 vty: add bind command for telnet vty line
Add VTY command
    line vty
     bind A.B.C.D

The command merely stores the configured IP-address, which can then be used by
the calling main program to set the telnet port of the VTY line. (Commits in
openbsc and osmo-iuh will follow up on this.)

Add function vty_get_bind_addr() to publish the address in the vty.h API.

Add static vty_bind_addr to store.

For allocation/freeing reasons, a NULL address defaults to 127.0.0.1.

BTW, I decided against allowing keywords 'any' and 'localhost' in place of an
actual IP address to make sure a written config is always identical to the
parsed config.
2016-02-25 11:02:34 +01:00
Max cc00bf8779 Extend L1SAP PH-DATA with presence information
Previously the presence of header and data blocks were communicated
in-band which decreases code readability and makes it unnecessary hard
to add support for new hardware.

Note: OsmoBTS have to be modified to take advantage of extended
ph_data_param structure.
2016-02-22 11:08:44 +01:00
Jacob Erlbeck f78ec5ce0d gb: Add bssgp_msgb_copy function
This function originates from openbsc/src/gprs but is just specific
to BSSGP/Gb on the same level like bssgp_msgb_alloc.

This commit puts the former gprs_msgb_copy function beside
bssgp_msgb_alloc.

Renamed function:

  gprs_msgb_copy -> bssgp_msgb_copy

Sponsored-by: On-Waves ehf
2016-02-22 10:20:49 +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
Max 0a59e9899f Expand bitvec interface
Add bit filling, shifting and other functions necessary for bit
compression implementation. Add corresponding tests.
2016-02-18 19:45:40 +01:00
Neels Hofmeyr 8684714966 Add CSCN ctrl port defs 2016-02-15 12:02:02 +01:00
Neels Hofmeyr 620dfa6be2 add vty port nr for osmo-cscn 2016-02-10 13:28:00 +01:00
Holger Hans Peter Freyther a9301a1a1f bitvec: Test and fix regression for C++->C conversion
bitvec_read_field/bitvec_write_field in the PCU used a C++ reference
and when porting to C it was decided to pass the parameter by value
and this lost the "back propagation" of the new index. Change the
parameter to be an in/out parameter and this way do not have a silent
semantic break in the osmo-pcu (where we copy the reference in csn.1
by value) and have a true compile failure.

Add Max's simple test for bitvec_unhex function leaving the checking
of bitvec_read_field and the side effect in the datastructure about
the number of bits still open.
2016-01-30 10:54:43 +01:00
Max a15f05f1b4 Add bitvec-related functions from Osmo-PCU
Allocation, pack/unpack, field access and helper routines used
extensively by Osmo-PCU. Whenever memory allocation happens, alocator
context is passed explicitly by caller.
2016-01-26 11:01:23 +01:00
Max e49af08f5b bitvec: Fix interface to consistently use unsigned int
Use unsigned int for the length throughout the interface. We will
never have a a negative length.

Sponsored-by: On-Waves ehf
2016-01-22 23:22:48 +01:00
Neels Hofmeyr f6d9f3759c comment typo 2016-01-18 10:44:36 +01:00
Jacob Erlbeck ff42b26520 msgb: Assert len >= 0 in msgb_trim
Currently msgb_trim only checks for len > data_len and returns -1
in that case, allowing the caller to fix it somehow. Using a negative
length will always lead to a corrupt msgb, but this is not being
checked.

This commit adds a check for len < 0 and a conditional call to MSGB_ABORT.

Sponsored-by: On-Waves ehf
2016-01-15 18:11:58 +01:00
Jacob Erlbeck 5f349be820 bitvec: Add get/set byte sequences
The new functions bitvec_get_bytes and bitvec_set_bytes copy
byte sequences from bitvecs to uint8_t arrays and vice versa.
While the bytes in the bitvecs do not need to be aligned, the uint8_t
arrays always are. In case the bytes in the bitvec are aligned, the
implementation uses memcpy.

Note that the implementation like the other existing functions assume
MSB first encoding.

[hfreyther: Squash the comment fix into this commit as well]

Sponsored-by: On-Waves ehf
2016-01-15 14:51:32 +01:00
Jacob Erlbeck 8114294bf2 gsm: Add APN conversion functions
These functions are currently part of openbsc but also needed by
other projects.

The function have been renamed as follows:

  gprs_apn_to_str -> osmo_apn_to_str
  gprs_str_to_apn -> osmo_apn_from_str

Sponsored-by: On-Waves ehf
2016-01-15 14:46:19 +01:00
Harald Welte c959afdcd9 osmo_prim_op_names should be extern 2015-12-25 17:14:07 +01:00
Harald Welte a2db75f28c Add osmo_prim_op_names[] symbol and _SAP_SS7_BASE define 2015-12-23 14:11:54 +01:00
Jacob Erlbeck 8db1134c72 msgb: Add msgb_test_invariant function
This adds a function that verifies whether a mgsb is consistent.

Sponsored-by: On-Waves ehf
2015-12-21 16:22:57 +01:00
Jacob Erlbeck cdd05f0ed4 msgb: Add msgb_resize_area and msgb_copy
These functions originate from openbsc/src/gprs but are generic
msgb helper functions.

  msgb_copy:  This function allocates a new msgb, copies the data
              buffer of msg, and adjusts the pointers (incl. l1h-l4h)
              accordingly.

  msgb_resize_area:
              This resizes a sub area of the msgb data and adjusts the
              pointers (incl. l1h-l4h) accordingly.

Sponsored-by: On-Waves ehf
2015-12-21 16:14:23 +01:00
Neels Hofmeyr 9e57a5a697 some comments / fixed typos 2015-12-21 11:25:05 +01:00
Harald Welte fad5752ab5 RSL: Add enum + TLV definitions for ip.access style embedded IEs 2015-12-13 21:57:29 +01:00
Ruben Undheim 771a58feee gsm_03_41: Fix structure definitions for big-endian machines
this was detected by debian packaging, as the associated gsm_03_41 test
case fails on big endian machines like ppc.
2015-12-09 20:22:42 +01:00
Jacob Erlbeck ac4ed17dbd stats: Add OSMO prefix to STAT_ITEM_NOVALUE_ID
This symbol is globally visible and therefore should have an OSMO
prefix like the other identifiers exported by stat_item.h.

Sponsored-by: On-Waves ehf
2015-12-08 10:33:15 +01:00
Jacob Erlbeck af5bad5ed0 stat: Explicitly support stat_items without unit
Add OSMO_STAT_ITEM_NO_UNIT for stat items without an unit. The
statsd reporter uses gauges ("g") to report them.

Sponsored-by: On-Waves ehf
2015-12-08 10:33:04 +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
Jacob Erlbeck b6e6bea4ec stats: Move statsd related code into a separate file
This commit moves the stats specific code parts into stats_statsd.c
while keeping the generic parts in stats.c. The code in stats.c no
longer contains references to statsd symbols.

Note that the VTY code still needs to know about every stats reporter
backend.

Sponsored-by: On-Waves ehf
2015-11-26 12:52:24 +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
Jaroslav Škarvada 2b82c1c6c8 fix FSF address in sources/headers
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
2015-11-12 13:46:05 +01:00
Jacob Erlbeck aed7c125fd stats: Send all values on reporter update
Currently only counter changes and new item values are being
reported. This makes it cumbersome to configure reporting clients,
since there is nothing like a list of all parameters.

This commit changes this behaviour such that all currently existing
counters and items that would be reported eventually, are passed to
the reporter when it has been reconfigured or enabled. If a counter
has not been incremented, 0 is sent. If a stat item value has not
been added, the last item value (or the default value if there is
none) is resent again.

Note that this will not catch transient counters/items that will be
created later on, e.g. triggered by new peers or subscribers.

To just force this kind of dump on a running reporter, it is
sufficient to invoke the 'enable' command in its configuration node.

Sponsored-by: On-Waves ehf
2015-11-09 14:49:49 +01:00
Holger Hans Peter Freyther 495b0dbd24 gprs-ns/stats: When the NSVCI is updated, update the stats counter
The NS object is created with an unknown identity and only after
the reset procedure has progressed (completed?) we know the real
ID for this peer. Before nobody has looked at the idx values (this
could have been seen with the CTRL interface) but with statsd the
wrong NSVCI becomes obvious.

Add routines to update the idx and I don't know if the change of
idx is causing any issues but we will find that out soon.
2015-11-04 14:39:37 +01:00
Jacob Erlbeck 59b90bc444 stats/vty: Add selective show stats command
Currently there is only the 'show stats' command which shows all
counter and stat_item values. This can lead to many lines of output
if there are per-subscriber rate counters.

The new command added by this commit allows it to only show groups of
a certain level (class_id), similar to the 'level' configuration
command for stats reporter.

The new command is

  show stats level (global|peer|subscriber)

Sponsored-by: On-Waves ehf
2015-08-22 01:47:55 +00:00
Holger Hans Peter Freyther c337693c4c stats: Fix build on FreeBSD
include stdint.h for int64_t and use netinet/in.h and not
netinet/ip.h for getting sockaddr_in and such.
2015-08-21 19:56:54 +00:00
Neels Hofmeyr 07cf861e25 gtphub: add OSMO_VTY_PORT_GTPHUB.
This is for gtphub, being developed in openbsc.git.

Sponsored-by: On-Waves ehi
2015-11-02 20:24:06 +01:00
Neels Hofmeyr 667e83d71e fix some typos
Sponsored-by: On-Waves ehi
2015-11-02 20:23:34 +01:00
Jacob Erlbeck 79125ecf7d log: Add new DLSTATS log level
This log level is used by the stats subsystem log reporter to report
statistics to level INFO. Note that the default level of DLSTATS is
NOTICE.

Sponsored-by: On-Waves ehf
2015-11-02 15:39:31 +01:00
Jacob Erlbeck bc9d9aced8 stats: Limit reporting by class id
This commit adds class_id fields to the rate_ctr and stat_item group
descriptions. The stats reporter code is extended to only process
groups whose class_id does not exceed a per reporter max_class level.

If the class_id is not set, the code assumes 'global' for groups with
idx == 0 and 'subscriber' otherwise.

The following vty command is added to config-stats:

  level (global|peer|subscriber)  Set the maximum group level

Sponsored-by: On-Waves ehf
2015-11-02 15:39:31 +01:00
Jacob Erlbeck 34eec7da8d vty: Add reserved nodes to enum node_type
Currently every time a node is added to enum node_type, this
constitutes an ABI change, since _LAST_OSMOVTY_NODE will get
incremented accordingly. In this case, every project that adds new
node type based on that value will have to be recompiled.

This commit adds 4 spare node type values, which can be replaced
one-by-one by new real types until they are exhausted to avoid
this kind of ABI change.

Sponsored-by: On-Waves ehf
2015-11-02 15:39:31 +01:00
Jacob Erlbeck fc9533d6c4 stats: Add osmo_ name prefix to identifiers
Since the the stat_item and stats functions and data types are meant
to be exported, they get an osmo_ prefix.

Sponsored-by: On-Waves ehf

[hfreyther: Prepended the enum values too. This was requested by
Jacob]
2015-11-02 15:39:01 +01:00
Jacob Erlbeck bc4f7ae512 stats: Add log reporter
This reporter passes the measurement values to the logging subsystem
as DSTATS (which is currently DLGLOBAL) level INFO messages.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:07 +01:00
Jacob Erlbeck 490b38f57a stats: Use function pointers in reporter objects
Currently case statements are used to select the right reporter
functions. This makes it difficult to add new reporter types,
especially if they are not going to reside in the same file.

This commit introduces per reporter function pointer for
open, close, send_count, and send_item. They are checked for
non-NULL before being called or skipped.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:07 +01:00
Jacob Erlbeck ed197fd4f9 stats: Make net config optional
To support reporters without network configuration, this commit
introduces the have_net_config flag to provide corresponding error
messages.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck d01acfcc75 stats: Support statsd Multi-Metric Packets
If the MTU is given, combine several messages into a single UDP
packet until the limit is reached. Flush all reporters after the
values have been scanned.

New vty commands (node config-stats):
  mtu <100-65535>     Enable multi-metric packets and set the maximum
                      packet size (in byte)
  no mtu              Disable multi-metric packets

Note that single messages that are longer than the given MTU (minus
28 octets protocol overhead) will be dropped.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck 80db4ec387 core: Add difference function to osmo_counter
The osmo_counter_difference returns the counter value difference
since the last call of this function with the given counter object.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck b1dbfb4c41 stats: Implement timer based reporting
This calls stats_flush in regular intervals which polls the
statistical values and calls the active reporters when values have
changed.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck adc900e0e3 stats/vty: Add stats configuration
This commit provides stats configuration similar to the log
configuration.

The following vty commands are added to the config node:
  stats reporter statsd          Create/Modify a statsd reporter
  no stats reporter statsd       Remove a statsd reporter

To actually configure a reporter, the config-stats node is entered
when the "stats reporter" command has succeeded. The following new
vty commands are available there:
  local-ip ADDR          Set the IP address to which we bind locally
  no local-ip            Do not bind to a certain IP address
  remote-ip ADDR         Set the remote IP address to which we connect
  remote-port <1-65535>  Set the remote port to which we connect
  prefix PREFIX          Set the item/counter name prefix
  no prefix              Do not use a prefix
  enable                 Enable the reporter
  disable                Disable the reporter

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +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 7211fe157e stat/vty: Add vty_out_statistics_full to show all statistics
This functions shows the state of all osmo_counters, stat_item
groups, and counter groups.

Sponsored-by: On-Waves ehf
2015-10-28 23:53:46 +01:00
Jacob Erlbeck e5b0fe2e3c core: Update osmo_counters_for_each doc
Fix type and add a note about the semantics of the handler's return
code.

Sponsored-by: On-Waves ehf
2015-10-28 23:53:45 +01:00
Jacob Erlbeck c6a7108828 stats: Add stat_item_for_each functions
This commit adds the following functions:

  stat_item_for_each_group     Call a handler for each group
  stat_item_for_each_item      Call a handler for each item of a
                               group

Sponsored-by: On-Waves ehf
2015-10-28 23:51:24 +01:00
Jacob Erlbeck 423c1e5a4f core: Extend rate_ctr by helper functions
For global value reporting, some additional helper functions are
needed. The statsd protocol expects differential counter values,
which are currently not provided by rate_ctr (except for s/m/h/d
intervals).

This commit adds several helper functions to rate_ctr:

- rate_ctr_difference  returns the counter delta since the last
                       call to this function for a given counter
- rate_ctr_for_each_counter
                       iterates through each counter of a group
- rate_ctr_for_each_group
                       iterates through all globally registered
                       counter groups

Note that the rate_ctr_difference function can only be used by a
single backend, since it modifies the 'previous' field in the
rate_ctr obj.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:24 +01:00
Jacob Erlbeck b27b352e93 stats: Use a global index for stat item values
Currently each stat item has a separate index value which basically
counts each single value added to the item and which can be used by
a reporter to get all new values that have not been reported yet.
The drawback is, that such an index must be stored for each stat
item.

This commit introduces a global index which is incremented for each
new stat item value. This index is then stored together with the item
value. So a single stored index per reporter is sufficient to make
sure that only new values are reported.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:24 +01:00
Jacob Erlbeck 0a1400fc83 ns: Add statistics for some events
The following counters are added to the ns.nsvc counter group:
  lost.alive             The number of missing ALIVE ACK messages
  lost.reset             The number of missing RESET ACK messages

The following items are added to the ns.nsvc stat item group:
  alive.delay            The time in ms between sending ALIVE and
                         receiving the next ALIVE ACK

Sponsored-by: On-Waves ehf
2015-10-28 23:51:24 +01:00
Jacob Erlbeck 738d9e2210 stats: Add vty_out_stat_item_group
This functions dumps a whole stat item group to the VTY.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:12 +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
Neels Hofmeyr c84851bccc comments 2015-10-09 00:01:06 +02:00
Neels Hofmeyr 5eeb17a017 ipaccess: add OAP proto_ext (in design). 2015-09-23 23:18:15 +02:00
Harald Welte 1a8c4e05fb Introduce gsm48_mi_type_name() function 2015-08-18 19:32:33 +02:00
Harald Welte 1f6aad1c04 Add G-RNTI derived TLLI types defined in 23.003 2015-08-18 19:32:33 +02:00
Holger Hans Peter Freyther a9e5252128 vty: Change API to have node installation be done by int
We are mixing enums and hope that no short-enums are used. This
is leading to a lot compiler warnings generated by clang. Change
the API to work with integers.

Porting:
The go_parent_cb implementations in the applications need to be
fixed. The API change leads to a compile time warning.

Fixes:
abis_om2000_vty.c:46:2: warning: implicit conversion from enumeration type 'enum bsc_vty_node' to
      different enumeration type 'enum node_type' [-Wenum-conversion]
        OM2K_NODE,
        ^~~~~~~~~
2015-08-05 04:22:56 +00:00
Holger Hans Peter Freyther f558ed4bb9 ipa: Properly parse LV stream of a ID_GET request
For some reason the structure is closer to be a LV (length
and value). The value is actually a tag but it is counted
inside the length. Introduce an overload of the parse function
to provide an offset for the length. This will be taken from
the returned length.
2015-06-02 15:52:06 +02: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
Jacob Erlbeck 9385d1e01b bssgp: Fix bssgp_tx_fc_bvc parameter type
Currently large values for Bmax default MS get sliced since a uint16_t is
used as the type of the corresponding parameter of bssgp_tx_fc_bvc.
GSM 48.018, 11.3.2 which in turn refers to 11.3.5 specifies a maximum
of 6MB (0xffff * 100).

This commit changes the type to uint32_t to cover the full value
range.

Sponsored-by: On-Waves ehf
2015-05-06 17:55:55 +02:00
Holger Hans Peter Freyther 780bba625d linuxlist: Remove casting of ptr from container_of macro
The cast is not present in the original macro and was added
in OpenBSC with commit (be68f6fc6cde1367a4481d2e774a64e2cd657267)
to help using the header with C++. Due the recent issue in
the bssgp flow control code, let's remove the cast to see
wrong pointer usage. In case C++ code doesn't compile anymore
we can see how to add a cast back to it.

Change was proposed by Michael McTernan
2015-05-02 07:59:00 +02:00
Holger Hans Peter Freyther 0f40ae12c8 osmo_static_assert: Put back the typedef in the code
In OSX the int declares linkage and for libosmo-abis we have
two static asserts with the same name in two different compilation
units. When adding the "unused" attribute I removed the typedef.
I verified with a gcc 4.9.2 that no new warnings will be shown
when compiling libosmo-abis.
2015-04-13 09:21:05 +02:00
Holger Hans Peter Freyther c2b4458e07 sim: Use extern for these structs to generate a linkage
Fixes:
duplicate symbol _ts102221_fcp_vals in:
    .libs/core.o
    .libs/card_fs_usim.o
duplicate symbol _pcsc_reader_ops in:
    .libs/reader.o
    .libs/card_fs_usim.o
2015-04-11 19:31:03 +02:00
Jacob Erlbeck 8d192d7153 ns: Log when sending fails (Coverity)
Currently the return value of the gprs_ns_tx family of functions is
often ignored. This is not a serious issue, since the successful
delivery of the messages is neither guaranteed nor acknowledged by
the network layer anyway.

Nevertheless this commit adds logging (level INFO) to gprs_ns_tx and
gprs_ns_msgb_alloc. The definition of the latter has been moved from
the header file to gprs_ns.c.

Fixes: Coverity CID 1040678, 1040679, 1040680, 1040681, 1040682,
   1040683, 1040684, 1040686, 1040687, 1040688, 1111545,
   1240203, 1240204
Sponsored-by: On-Waves ehf
2015-04-07 20:10:23 +02:00
Max f8699ca51e gsm: Add A5/3-4 cipher support
Signed-off-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-03-28 18:07:05 +01: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
Jacob Erlbeck 36153dc61a bssgp: Handle BSSGP STATUS messages
Currently incoming BSSGP STATUS messages are just logged and no other
action is taken. This makes it impossible for higher layers to react
to failures which are indicated by corresponding STATUS messages
unless a timeout is triggered as a result of that failure later on.

This commit adds a bssgp_rx_status() function and calls it on
incoming STATUS messages. That function logs a message, increments the
new BSSGP_CTR_STATUS counter if the bctx context exists and invokes
an NM_STATUS status indication. The latter will allow the application
to handle failures immediately. Since all STATUS messages should be
handled, the function is already called in bssgp_rcvmsg and the
message is no longer handled in (and will not reach) bssgp_rx_sign
and bssgp_rx_ptp.

Ticket: OW#1414
Sponsored-by: On-Waves ehf
2015-03-18 21:54:37 +01:00
altaf f6a0ceb92f core/gsmtap: LTE RRC message types and LTE MAC define
Submitted-by: altaf <altaf329@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-01-18 23:16:03 +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 c13cf8bbd3 SMS-CB: introduce and use GSM341_7BIT_PADDING 2014-12-30 13:25:44 +01:00
Harald Welte 61ced83a70 SMS-CB: Add #defines for maximum block/msg size and payload chars 2014-12-30 13:18:26 +01:00
Harald Welte be4bbeb01b add missing gsm0341.h 2014-12-30 01:22:26 +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 a19717a7c5 Add Cell Broadcast MSGIDs from TS 23.041 v12.6.0 Release 12 2014-12-29 13:14:48 +01:00
Holger Hans Peter Freyther c8c33094af bitvec: Fix typo in the csn1 encoding code
We can curse about CSN.1 and 3GPP but I think we want to call
it cursor here.
2014-12-28 18:22:48 +01:00
Harald Welte 1b12d16c4c libosmo-gsm: Add PCHAN/LCHAN types for CBCH 2014-12-28 13:37:01 +01:00
Jacob Erlbeck 3cd6753a11 ipa: Add forward declaration of struct osmo_fd
A pointer to struct osmo_fd is used in a few prototypes declared in
gsm/ipa.h, but is neither declared explicitly nor is such a
declaration reachable via the given include directives.

This patch adds a forward declaration of this type to ensure proper
compilation.

Sponsored-by: On-Waves ehf
2014-12-22 14:44:52 +01:00
Holger Hans Peter Freyther 4448048828 ipa: Make a reservation for the GSUP protocol
GSUP is a protocol to have the OpenBSC SGSN talk
to an exterbal system for 3GPP MAP connectivity.
2014-12-14 19:01:14 +01:00
Holger Hans Peter Freyther 2d6ad13d8d logging: Make it possible to print category/subsys and timestamps
We want to see from which category/subsystem a certain log message
is coming from and use a different timestamp format as well. Add
two new bitfields. This doesn't change the size of the structure
and on 32bit we still have 27bits left.

The extended timestamp will take preference over the current and
default timestamp format.

Fixes: SYS#602
2014-12-05 10:23:28 +01:00
Holger Hans Peter Freyther a5dc19dc40 gtp: Add a global region for the gtp library of OpenGGSN
We want to use libosmocore/libosmovty in the GGSN sourcecode
and reserve a global region here.
2014-12-04 14:39:14 +01:00
Holger Hans Peter Freyther 9f0f978c8d vty: Check with the application before writing the config
For the BSC/NITB application we see that people modify the band
without modifying the ARFCN. This creates an unbootable config.
Using the new hook the BSC/NITB can check if the config is
consistent and prevent the config file being written.

Related: SYS#739
2014-12-04 14:39:14 +01:00
Harald Welte 7b74dda31b remove references to u_char type, use 'unsigned char' instead
... u_char not being defined on Nuttx.
2014-11-14 15:22:14 +01:00
Harald Welte 33e940b862 sttrb / loggingrb: Use GPLv2+ as license, not AGPLv3+
according to Holger, using AGPLv3+ at the time was a mistake and the
license should always have indicated GPLv2+.
2014-10-26 20:52:25 +01:00
Harald Welte 7fa89c2e88 Change license of libosmogb from AGPLv3+ to GPLv2+
The copyright holders Harald Welte, Holger Freyther, Andreas Eversberg
and sysmocom - s.f.m.c. GmbH (represented by Holger and Harald) agree
that the license of libosmogb should be GPLv2+ and not AGPLv3+.

The reason the source files stated AGPLv3+ is due to the history, as
they were moved from OpenBSC to libosmocore at the time we needed to use
them from osmo-pcu.  It was an oversight back then to not re-license
them accordingly.
2014-10-26 20:50:19 +01:00
Harald Welte 6729a9776a make sure to register DF.TELECOM and DF.GSM for SIM, USIM + TSIM
before we only did it partially, and by exporting data from sim,
rather than the new osim_int_cprof_add_{gsm,telecom}() functions.
2014-10-26 19:50:55 +01:00