Commit Graph

1985 Commits

Author SHA1 Message Date
Philipp Maier d9f6129350 lapd_core: fix program flow
when the lapd core is in state LAPD_STATE_SABM_SENT, and the
retransmission counter exceeds (link down) lapd_t200_cb() will
send an RELASE_INDICATION and an MDL_ERROR_INDICATION to L3.
This action is done before the state is processed. This seems
to be no problem with standard retransmission counts (n200),
but may cause timing problems that lead to deadlock states when
custom timer configurations are in use. (Ericsson RBS).

This commit moves the functions calls for sending the indications
mentioned above to the very end of the if branch to relax the
timing again. (See lapd_t200_cb())

Change-Id: I1c1beb3701b19744a3ce9946abca7767d20a0b6a
2017-02-07 13:39:01 +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 7132011afa bssgp_fc_test: do not use real time
Employ osmo_gettimeofday_override_* to take bssgp_fc_test off real time. The
jenkins build slave often failed the test based on sporadic time delays due to
server load and randomly rejected good patches. This patch ends that.

Change-Id: Ie5029b85c2a154554d75d7f9af49a3b93425fdd9
Related: OS#1809
2017-02-07 00:39:54 +00: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 18d65be080 osmo-auc-gen: cmdline help: list algorithms; error messages
In the -h help output, list the names of available algorithms.

In case of option parsing failure, also print help() (so that e.g. for a typo
in the algorithm, the list of algorithms is printed along with the error
message).

If there are -2/-3 or -a missing, show an error message that explains this.

Change-Id: I76732b28d7a553a6293d1707fe398d28b5ef4886
2017-02-06 13:47:17 +00:00
Neels Hofmeyr 94e04604fc osmo-auc-gen: cosmetic: clarify output upon AUTS
When calculating a re-sync vector using AUTS, osmo-gen-vec used to print
SQN.MS + 2, the new SQN after vector generation, labeled 'SEQ.MS'.

Firstly, s/SEQ/SQN.

Secondly, print SQN.MS as umts.sqn - 2, which is the actual SQN recovered from
the AUTS. As explained in the comment, SQN.MS + 1 is used to generate the
vector, and then umts.sqn is increased a second time to indicate the next SQN.

With AUTS calculated from SQN.MS == 23, the output was:

  AUTS success: SEQ.MS = 25

Output now:

  AUTS success: SQN.MS = 23, generated vector with SQN = 24, next SQN = 25

Change-Id: I881bbe8246a5e7d3a5065b4b5b533255723b1a9e
2017-02-04 14:46:19 +00:00
Philipp Maier 08177d324a lapd_core: Improve debug output
The debug output of lapd core has no references to the dl objects,
since we have multiple links, seeing which action is for which
object is impossible. This commit adds pointer references (dl=%p)
to each log line.

Change-Id: I3024d1cbd58631e2abac4ce5822528e2e6e15fda
2017-02-03 21:43:38 +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
Holger Hans Peter Freyther 6030ce844e sim: Link to libtalloc as symbols of it are used here
A DSO should link to the libraries that it is using. Linking to
libtalloc will resolve these warnings:

Change-Id: I4c8d5e80e194b9d9b4fa2424c4a22377ecee9c7a
dpkg-shlibdeps: warning: symbol _talloc_zero used by debian/libosmosim0/usr/lib/i386-linux-gnu/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol _talloc_free used by debian/libosmosim0/usr/lib/i386-linux-gnu/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol talloc_strndup used by debian/libosmosim0/usr/lib/i386-linux-gnu/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol talloc_strdup used by debian/libosmosim0/usr/lib/i386-linux-gnu/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol _talloc_memdup used by debian/libosmosim0/usr/lib/i386-linux-gnu/libosmosim.so.0.0.0 found in none of the libraries
2017-01-24 14:26:11 +01:00
Harald Welte abba1537a7 ipa: Remove unneeded #include statement
Change-Id: I69f2891a2bea6f87f079b6778aa01ee27a25001b
2017-01-23 12:20:34 +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
Harald Welte 44c0f63de6 disable various code if building for bare-iron embedded
We don't have file-based I/O nor ethernet devices with mac addresses
when building for OsmocomBB.

Change-Id: I01a9e6d8dbe885dbeac2769b84931a4d44f7a3a5
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 b0a4234c49 Add abis_nm_fail_evt_vrep to libosmogsm.map
Change-Id: If56b521429af497ddd5a47170eb2c085b1fb78ba
2017-01-19 09:07:33 +00:00
Neels Hofmeyr 0aeda1b17f doc: fix doxygen 'utils' group closing brace
osmo_strlcpy() was excluded from the group because the closing brace was above
it.

Change-Id: I6701261f5854342ac4cd4f2da62e49eb40362938
2017-01-18 01:50:39 +00:00
Max 6e8c172476 libosmogsm.map: fix typo
Change-Id: I71413fbe703e459782a235e5b1d8487265de3780
Related: OS#1615
2017-01-17 15:37:06 +00: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
Vadim Yanitskiy d8494bc9b7 tests/conv: whitespece fix
Change-Id: I73ab4614c5c23390862d3ecaa2561a6749604a15
2017-01-16 12:54:32 +00:00
Vadim Yanitskiy 1214295062 tests/conv: add LTE PBCH test vector
Change-Id: I1a3a48bba9ee32a0bacc0b05d25358496dbcbc1b
2017-01-16 12:52:01 +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
Max ace80bb569 Mark deprecated function as such
Mark abis_nm_debugp_foh() function superseded by macro with the same
name as deprecated.

Change-Id: I2d3ea2b56aff6b687f72f832360b8cb8a24164e9
2017-01-16 08:53:20 +00:00
Neels Hofmeyr b41b48e76a stats_test: fix mismatching osmo_stats_reporter->send_item signature
The function pointer expects the last arg as int64_t, stats_test.c uses
an int instead. Fix the argument type as well as the printf format for it.

Fixes this compiler warning seen on our FreeBSD build slave:

    CC       stats/stats_test.o
  ../../tests/stats/stats_test.c:288:18: warning: incompatible pointer types assigning to 'int (*)(struct osmo_stats_reporter *, const struct osmo_stat_item_group *, const struct osmo_stat_item_desc *, int64_t)' from 'int (struct osmo_stats_reporter *, const struct osmo_stat_item_group *, const struct osmo_stat_item_desc *, int)' [-Wincompatible-pointer-types]
          srep->send_item = stats_reporter_test_send_item;
                          ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 warning generated.

Change-Id: I91cbfd4dd25a881b803943430101dabf07dafc7c
2017-01-15 18:10:15 +00:00
Neels Hofmeyr df83eced68 doc: clarify osmo_strlcpy() doc
Stating that it 'truncates src' is misleading. Also clarify whether siz
includes the space needed for the terminating NUL.

Change-Id: I01c1a94408b471f7f54576178a60938bf9ee3261
2017-01-15 17:58:29 +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
Harald Welte 1a7d64ccd1 configure.ac: Disable PCSC related code on EMBEDDED
The EMBEDDED conditional is used for building inside 'bare iron'
embedded devices like OsmocomBB phones.  There's no PC/SC in them.

Change-Id: I2ef7561d7fdb1ef1c060f8ac73d8588fc0f8eb3f
2017-01-15 18:04:02 +01:00
Harald Welte 1c67e754b8 configure.ac: Introduce --disable-ctrl
Using --disable-ctrl, one can disable the building of libosmoctrl.

The 'embedded' target will also automaticall disable ctrl.

Change-Id: I6912396338c5b23ae860fef2a55854d6df9a579d
2017-01-15 18:04:02 +01:00
Max 2f0b0c955b Fix compilation warnings: missing includes: gsm0411_utils.c, lapd_core.c, oap_test.c
Change-Id: Id524327b3f44e22e3aa44c5e8e4965b084cb326a
2017-01-13 09:36:25 +00:00
Neels Hofmeyr c32bfd5824 gprs_ns_vty: guard against duplicate VTY elements
The TbfTest in osmo-pcu calls gprs_ns_vty_init() repeatedly, which aborts
because of duplicate VTY elements. Fix this by skipping the VTY init if
it already happened.

Change-Id: I05c7f25a4e873ae76b206819180b8b043b60103e
2017-01-12 22:32:36 +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 b632e03f65 Remove obsolete .deb patch
Change-Id: Icbf911540fcc840833c5012363c2ba48fd71db52
Related: OS#1694
2017-01-10 23:29:47 +00:00
Max 87218edb9a LAPD: improve logging
Log error cause and state names in case of SABM errors.

Change-Id: I2c7fa276e03f8b14ba41cc1fb6e19d0aae77d127
2017-01-10 23:28:40 +00:00
Jean-Francois Dionne d02c8af6cc DTX: fix AMR SID-FIRST detection
Max's note: adjusted test output.

Change-Id: I46477c631bf86345cb757f31d7f2e2935b12adcc
Related: OS#1801
2017-01-10 23:28:12 +00: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
Vadim Yanitskiy c0c8432345 gitignore: ignore *.pyc files
Change-Id: I148584e1664b20741c0ade02cbda635c24268d2e
2017-01-08 14:02:51 +00: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
Harald Welte addeaa39b1 vty: OSMO_ASSERT() if two identical commands are installed
When the caller installs two identical commands at a given VTY node, the
result is that neither of the two commands can ever be executed: The VTY
would always complain about "Ambiguous command.".  Let's fail fast at
program start when two identical commands are intalled.

Change-Id: I85ff4640ebb3d8b75a6a9ab5d2f668edb5b7189e
2017-01-07 12:14:48 +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