Commit Graph

1985 Commits

Author SHA1 Message Date
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
Thorsten Alteholz a81055db1d fix spelling in API docu, command reply, logging, descriptions
sections: ctrl, gb, gsm, vty

Change-Id: Iac211b5cd8504da36b699777b95a2448dd7c3e70
2017-04-23 14:34:18 +00:00
Harald Welte 9e83c3d5ca fsm: Re-set fsm_inst->T to 0 after timer expiration
If the user starts the FSM timer with a given timer number during
fsm_inst_state_chg() with a timeout, we should remove that "T" number
after timer expiration.  Otherwise it might be confusing if e.g. the VTY
interface shows FSM instances with a certain timer number assigned, but
that timer is not actually running anymore.

Change-Id: I71167ec1000dc4c6954d851d3b92f6bf12984925
2017-04-16 17:28:23 +02: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
Tom Tsou 35536807ab core/conv: implement optimized Viterbi decoder
Add a separate, faster convolution decoding implementation for rates
up to N=4 and constraint lengths of K=5 and K=7, which covers the
most GSM code uses. The decoding algorithm exploits the symmetric
structure of the Viterbi add-compare-select (ACS) operation - commonly
known as the ACS butterfly. This shift-register optimization can be
found in the well-known text by Dave Forney.

Forney, G.D., "The Viterbi Algorithm," Proc. of the IEEE, March 1973.

Implementation is non-architecture specific and improves performance on
x86 as well as ARM processors. Existing API is unchanged with optimized
code being called internally for supported codes.

The original code was relicensed under GPLv2-or-later with permission
of copyright holder - Tom Tsou.

Change-Id: I74d355274b4176a7d924f91ef3c96912ce338fb2
2017-04-11 00:36:08 +00: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
Thorsten Alteholz 18a62b0488 compiler warnings: take care of compiler warning "unused-result"
Though it makes no sense to handle the return code of freopen() here,
the compiler complains about it. The #pragma statements take care of
that.

Change-Id: Ia2caadbed2a24f84d1d55a47236b398b74224e82
2017-04-08 07:45:13 +00:00
Philipp Maier 15596e2a7f gsm0808: make gsm0808_create_reset_ack() accessible
The create function to generate the RESET ACKNOWLEDGE
message is not accessible from outside, as it does not
appear in limosmogsm.map. It also has not testcase.

This commit adds gsm0808_create_reset_ack() to the
map file and also adds a testcase.

Change-Id: I82d3411484f82b4a9205d407fa0442244678f183
2017-04-08 07:44:47 +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
Holger Hans Peter Freyther ff20641d9e select: Find the highest fd when filling the fd_sets
Instead of returning maxfd, which is the highest fd ever seen, take
the highest we have seen on this iteration.

This makes a tiny difference for the osmo-sip-connector and its
event loop integration. select.c ignores the return value of this
function right now.

This was seen while debugging the eventloop integration of the
osmo-sip-connector before and after a VTY connection. The fds
being polled didn't go down.

Change-Id: I1a6d7271273ec08bb511c21b936891bc508843e4
2017-04-04 20:14:32 +00:00
Harald Welte 059c40476c logging: Add log_info_cat for DLSS7/DLSCCP/DLSUA/DLM3UA
In Change-Id I61f452208088dc7097165deecef7c058ebb4bd4e we introduced
the #defines but didn't introduce the new log_info_cat information.

Change-Id: I218aa4cb1fc7640a75663be29bac672dfa8770f5
2017-04-03 22:20:49 +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
Neels Hofmeyr d4089f4b07 jenkins: also test build in separate dir
To make sure that new patches don't break a build done in another dir than
srcdir, make jenkins verify that it still works.

Even though 'make distcheck' also tests a build from a separate dir, this does
not verify that BUILT_SOURCES are generated properly. If these already exist in
the source tree from a previous 'make' issued in the source tree, the
BUILT_SOURCES are not regenerated during 'make distcheck'. Hence a separate
test run is necessary to ensure stability of new patches.

Change-Id: I4b31538c155941fd241bcd33b0d39f2f8491ac1e
2017-03-31 12:06:13 +00:00
Jean-Francois Dionne d78c973cd8 Fix LAPD UA message buffer memory leak.
The state check in lapd_dl_reset causes some buffers
never to be released. Using talloc report LAPD UA
message buffers are never released after each call
and cause a memory leak.

Change-Id: I2799b70623f2ec4dbc725eb213e332e98da02a3e
2017-03-29 13:40:34 +00: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 e64d5bd29b build: fix distcheck: include gen scripts in EXTRA_DIST
Change-Id: Id94d2fe83f080a18a2a686206bd21cf5fafe2fa7
2017-03-20 14:30:43 +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 d1537e033f build: conv_gen.py: ensure parent dirs of written files exist
Previously, this would fail when generating to $builddir if that subtree did
not exist yet in $builddir.

Change-Id: Ia4fba96dcf74a25cf3e515eb3e4f970e0c3cdd54
2017-03-20 12:33:36 +00: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 9b22686134 build: coding/gsm0503: fix build in sep. dir: -I builddir
To allow building coding/gsm0503_interleaving.c which includes the generated
bit*gen.h (via bits.h), add -I to the builddir include path in order to find
the generated bit*gen.h headers there.

Change-Id: I0d465bc109765b1315d615243bea6af027afa368
2017-03-20 12:32:43 +00:00
Neels Hofmeyr 14477997c1 osmo-auc-gen: fix --sqn limit on 32bit systems, fixing build
osmo-auc-gen on 32bit systems allowed only --sqn up to 32bits width. However,
the recently added regression test for osmo-auc-gen includes an ivocation with
a 48bit wide --sqn, which now causes the builds to fail on 32bit systems.

Fix the --sqn argument parsing for larger integers by using strtoull(). Do away
with the intermediate variable 'ul' and place the value directly in the auth
data struct.

Change-Id: Ifb73b3b3de06576e36076ca573d52327f90a1f77
2017-03-20 00:21:42 +00:00
Harald Welte 1c260c0a09 README.md: Make sure all hyperlinks use <>
Change-Id: Ic81b68aef010e17f6b18232064958e0d4193e192
2017-03-17 21:31:42 +01:00
Harald Welte 18a7d81932 logging: fail gracefully if log_info() was not called
The logging code crashes if osmo_log_info is not set, which is typically
achieved by calling log_init().  Let's fail with a reasonable assert
and error message if the user forgets that.

Change-Id: If3007860d2efe6ea9aec27e7d7439d44a7cd19c2
2017-03-16 23:56:01 +01:00
Neels Hofmeyr 9ab00721e5 jenkins: add value_string termination check
Change-Id: I7fe3678b524d602fc6aa14bc0ed06308df809a3e
2017-03-16 19:00:04 +00:00
Harald Welte 220fa74016 Add a README file for some background information about this repo
Let's add some general information about this repository, links to
redmine, gerrit, the mailing list, etc.

Change-Id: If034c6f551ff9bfaff0b8368fd0963f3147155b9
2017-03-16 15:31:37 +01: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 d80a217f7f contrib: add script to find unterminated value_string arrays
Unterminated value_string arrays are dangerous since get_value_string() and
get_string_value() need to know where the struct ends. If the terminator is
missing, they might run through and return arbitrary memory locations.

Employ some regexes to find such unterminated value string arrays and return
nonzero if any are found.

This can be used in our jenkins build jobs to avoid committing unterminated
value_string arrays. In fact I've found one in current libosmocore:
gsm0808_bssap_names in gsm/gsm0808.c, fixed in a separate patch.

Change-Id: I2bc93ab4781487e7685cfb63091a489cd126b1a8
2017-03-16 12:53:50 +00:00
Neels Hofmeyr e0cb0eeb3f auth_milenage: fix check against too large ind
To ensure that the IND index appended to SEQ does not affect the SEQ, the check
should read '>= seq_1', not '>'.

Change-Id: Ib1251159eee02aa07fae1b429ffec2e4604bf6a8
2017-03-16 05:32:30 +01: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 6761c3f626 milenage_test: cosmetic: verify AUTS in comments
In a comment and by code #if'd away, illustrate that the AUTS used in the unit
test is accurate.

Related: OS#1968
Change-Id: Iefeaaf33570f8e40245fdf9b810390ec61cfc7e0
2017-03-15 13:46:58 +00:00
Thorsten Alteholz 49daf56319 fix wrong return code
In case we are a daemon, we do not need to daemonize again.
On the other hand everything is fine and we also do not need
to bail out with an error.

The daemonize template at [1] does the same.

[1] http://www.itp.uzh.ch/~dpotter/howto/daemonize

Change-Id: Ia4dcf7344bd65934faa3d7d46563f6e0532c232e
2017-03-15 13:08:13 +00:00