Commit Graph

2221 Commits

Author SHA1 Message Date
Harald Welte 69b61fe510 Bump version: 0.10.1 → 0.10.2
Change-Id: I88c0d0327fb022b0626ab0feff3f34468b122d4b
2017-11-02 18:55:08 +01:00
Neels Hofmeyr 74aa025826 Revert "vty: Fix bad use of vector_slot()"
The patch seemed sensible, but introduces a segfault when hitting tab
on the interactive VTY. Reproduction example:

  osmo-msc
  telnet 127.0.0.1 4254
  OsmoMSC> enable <TAB>

So we need to understand what that line of code actually intends to do.
Until then, revert this to avoid the segfault.

The segfault happens at:

  Program received signal SIGSEGV, Segmentation fault.
  0x00007ffff7bc0894 in cmd_complete_command_real (vline=0x5555558d59e0, vty=0x5555558d57b0, status=0x7fffffffe024) at ../../../../src/libosmocore/src/vty/command.c:1953
  1953                if (*(char *)vector_slot(vline, index) == '\0')

This reverts commit e9e9e427b7.

Change-Id: I3fe213bdfb96de9469aae64e67000dafee59302e
2017-11-01 22:38:29 +00:00
Max 38a49f6276 utils: move linked libraries into common variable
Change-Id: I54f4e439cc232d926b42ddba9648d4f5e7487c3e
2017-10-30 13:56:11 +01:00
Max ba1059c173 Move additional libraries to appropriate place
According to
https://www.gnu.org/software/automake/manual/automake.html#Libtool-Flags
the libraries supposed to be added to *_LDADD or *_LIBADD
while *_LDFLAGS should contain additional libtool linking
flags. Previously we used both. Let's unify this and move all the
libraries into proper automake variable. While at it - also add
libosmocore.la for tests to LDADD since all the tests link against it
anyway.

Change-Id: Ia657a66db75df831421af5df1175a992da5ba80f
2017-10-30 13:50:31 +01:00
Harald Welte d9abb0a708 Tag/Release Version 0.10.1
This is for Change-Id Icf337a430fb367bbca48a1b02822a2cb3b644e5f
to catch repeated calls to osmo_init_logging() whcih is what osmo-pcu
will perform after some upcoming fixes there.

Change-Id: Ie14a7eadf8ba01e8d31a83e330491036358ac650
2017-10-29 10:49:49 +01:00
Harald Welte 16f989ef91 Catch repeated calls to osmo_init_logging()
If an application calls osmo_init_logging() multiple times, let's
bail out in a safe way without corrupting the state + returning an
error.

Change-Id: Icf337a430fb367bbca48a1b02822a2cb3b644e5f
2017-10-29 09:45:21 +00:00
Neels Hofmeyr 229fa070c4 jenkins: use osmo-clean-workspace.sh before and after build
See osmo-ci change I2409b2928b4d7ebbd6c005097d4ad7337307dd93 for rationale.

Depends: I2409b2928b4d7ebbd6c005097d4ad7337307dd93
Change-Id: I99fdd20e7b18c2f4a59a9db35e5efccca6546b77
2017-10-27 22:41:57 +02:00
Harald Welte faee5dead6 Tag/Release version 0.10.0
It's been way too long since the last release.  Almost one year and
468 commits.

A brief summary of the changes below:

* Doxygen for libosmo{coding,gb}
* pseudotalloc for embedded builds, jenkins for arm-none-gnueabi
* --disable-doxygen, --disable-ctrl, --disable-simd
* update debian packaging
* gsm0503 coding routines
* osmo_hton[sl]
* statistics.h -> counter.h
* QCDIAG in gsmtap
* llist_{first,last}_entry()
* llist_count()
* LOGPSRC() macro
* msgb_pull_to_l2()
* msgb_printf()
* prbs
* osmo_sock_init2()
* osmo_sock_mcast_{name,loop_set,ttl_set,all_set,subscribe,ip}()
* OSMO_STRINGIFY()
* OSMO_VALUE_STRING()
* OSMO_BYTES_FOR_BITS()
* osmo_talloc_asprintf()
* osmo_sub_auth_type_name()
* osmo_sub_auth_data support for IND/SQN_MS
* osmo_fsm ctrl interface
* ctrl_handle_alloc2()
* ctrl_interface_setup_dynip2()
* OSMO_CTRL_PORT_HLR
* bssgp_tx_bvc_ptp_reset()
* gprs_ns_inst connect/remote_{ip,port}
* osmo_gprs_{ul,dl}_block_size_{bits,bytes}()
* osmo_gprs_{dl,ul}_cs_by_block_bytes()
* gprs_ns_pdu_strings[]
* more BSSGP cause values
* abis_nm_admin_name()
* AoIP support in gsm0808
* gsm_fn_as_gsmtime_str()
* osmo_dump_gsmtime()
* gsup charging support
* ipa_ccm_make_id_resp()
* ipa_ccm_make_id_resp_from_req()
* struct gsm48_gprs_susp_req
* gsm_04_14.h
* rsl measurement preprocessing related IEs
* abis_nm_event_cause_names[]
* abis_nm_sw_desc and friends
* more SYSINFO_TYPE_ values
* osmo_earfcn_bit_size_ext()
* t16lv_put()
* msgb_t16lv_put()
* tlvp_val16be()
* tlvp_val32be()
* osmo_tlvp_copy()
* osmo_tlvp_merge()
* many additional VTY nodes
* cmd_node.name member
* bitvec_set_u64()
* bitvec_rl_curbit
* ctrl_lookup_register()
* osmo_fsm_find_by_name()
* osmo_fsm_inst_find_by_name()
* osmo_fsm_inst_find_by_id()

Change-Id: Ieb5db2e910a90db780ea058b3280f2facbd68d76
2017-10-27 20:18:49 +02:00
Harald Welte 504caac641 Add unit tests for bcd2char and char2bcd conversion
Sounds stupid, but we actually didn't support hex nibbles in one of
the two directions of the conversion, so let's make sure we test for
this.

Change-Id: I8445da54cc4f9b1cd64f286c2b238f4f7c87accb
2017-10-27 17:24:19 +02:00
Harald Welte fa8983d2dd osmo_char2bcd(): Implment hex digits a-f and A-F
osmo_bcd2char() has always supported both decimal and hex.

However, osmo_char2bcd() use to only implement decimal digits.

With this patch, it also suppots conversion of hex characters from ASCII
to BCD.

This would be relevant in cases where somebdoy would want to use 'code
11', 'code 12' or 'ST' signals in any addresses (SCCP GT e.g.)

Change-Id: I7bbcc6de08024567ab64765c12d7de71df787a7a
2017-10-27 16:55:16 +02:00
Neels Hofmeyr bcf9f23456 utils: avoid segfault when calling osmo_strlcpy(src=NULL)
Change-Id: Ieba7ba262ace2e370a4b9a550b3131fb13f07413
2017-10-25 04:19:11 +02:00
Harald Welte b48e82ca9e rate_ctr: Fix null pointer dereference in error path
In Change-Id Ifc6ac824f5dae9a848bb4a5d067c64a69eb40b56 we introduced
a variable de-reference before we check if it's NULL.

Let's reorder the statements to avoid this.

Fixes: Coverity CID#178219
Change-Id: I99265a7ee76f85c479543c19ce8c05ce5d43ae69
2017-10-24 16:46:33 +00:00
Max cbf5cdfe7e GPRS: constify NS printing routine parameters
Change-Id: I549ab7c26ac1489e01f281594bafe44b0681dc83
2017-10-24 16:34:41 +00:00
Max 296511befc GPRS: add vty command to show only persistent NS
The regular 'sh ns' lists all available NS. Sometimes it's handy to know
which of those are persistent.

* add "show ns persistent" command
* adjust parameters of dump-ns*() functions to use bool where
  appropriate

Change-Id: Ib812864bae3ea414cc107a7b4f49bea4e6161795
2017-10-24 16:34:40 +00:00
Harald Welte 04c881207f stats_test: Extend check to include test for counter group name mangling
In Change-Id Ifc6ac824f5dae9a848bb4a5d067c64a69eb40b56 we introduce
name mangling to replace any '.' in counter (group) names to be
converted to ':'. Let's test for this functionality explicitly as part
of the stats_test.

Change-Id: Ie35682aa79526e2ffeab6995cd640b7847d855bf
2017-10-24 16:00:45 +00:00
Harald Welte a7a5065385 Convert lib-internal rate_ctr from '.' separator to ':' separator
The rate_ctr.c code would do this mangling automatically, but let's
avoid using this from new versions of our code for
simplicity/explicitness.

Change-Id: I24a556f447cfac25efb6e83cac2d0c2972d98fe3
2017-10-24 16:00:45 +00:00
Harald Welte ae510dc4a7 rate_ctr: Enforce counter (and ctr_group) names are valid identifiers
As rate counters are automatically exposed on the CTRL interface,
we need to make sure they don't contain special characters such as '.'
which are not permitted/supported by CTRL.

In order to be able to run old versions of osmocom programs with
libosmocore versions after this commit, we introduce some special
name mangling:  Any '.' in the names are replaced with ':' during
counter group registration, if valid identifiers can be obtained
this way.

Change-Id: Ifc6ac824f5dae9a848bb4a5d067c64a69eb40b56
2017-10-24 16:00:45 +00:00
Harald Welte 8c4f5457aa fsm: Enforce FSM and FSM instance names are valid osmocom identifiers
Let's enforce that the names of FSMs and their instances are valid
osmocom identifiers.  This is important as the FSMs are automatically
exported via those names on the CTRL inteface, and we have to make sure
CTRL syntax actually permits them.

Change-Id: I9ef59432f43a3cdb94e4cbb0c44ac3f9b2aac0f2
2017-10-24 16:00:45 +00:00
Harald Welte febe83c424 Introduce osmo_identifier_valid() function to check validity of identifier
We define the notion of an 'osmocom identifier' which is basically a
7-bit US-ASCII without any special characters beyond "-_:@".  We
introduce a function to verify if an identifier consists only of the
permitted characters.

Change-Id: I96a8d345c5a69238a12d040f39b70c485a5c421c
2017-10-24 16:00:44 +00:00
Neels Hofmeyr c8ef736370 jenkins: bail early if $MAKE env var is not set
If $MAKE is unset, it produces confusing errors, rather check explicitly.

Change-Id: I59b111dfdee4e1edea04155144f01d99f5f72aa1
2017-10-24 15:31:07 +00:00
Neels Hofmeyr 754e6877cc fixups for recent "Cleanup jenkins build scripts"
Change I24e500e132f5c8e8133d35548cb7b4e4552331d0 was merged, but IMHO needs
improvement. Fix these:

- clean the git source tree before each build step, in common prep_build().
- fix indenting inside the build() macros.
- change build() arg to be build_dir, to absorb cleanup steps into build().
- in jenkins.sh, use $ENABLE_SANITIZE as global env, not passed as arg.
- in jenkins.sh, don't do 'make distcheck' twice. It is not necessary to do it
  from source tree as well as separately from source tree, since distcheck
  already moves to a different build dir.

Change-Id: I09d306350602f21943d5bd45f7388c83ede9b524
2017-10-24 15:31:07 +00:00
Neels Hofmeyr a568af25d2 contrib/fsm-to-dot.py: some tweaks that help with osmo-bsc's new FSMs
Combine the C source file name and the string name into the fsm's internal name
token, and use it in most places instead of the plain struct name: osmo-bsc's
new FSMs have identical struct names in each static c context.

Output in a file name that includes all of these more detailed name tokens.

Also parse '(1 << EVENT)' as event names.

Note that besides this patch, there are also some tweaks to the osmo-bsc patch
that improve the fsm-to-dot experience...
- call fsm-to-dot for single files to avoid name conflicts, or rename each
  struct as a unique name.
- Add comments for the event name a callback is intended for, so that not all
  transitions are interpreted as TEARDOWN (because it is invoked in common
  error handling, which causes the script to interpret it as the causing
  event). (or change the event-checking if into a switch that names the valid
  event and has a default case for all others.)

Change-Id: Ib60df7fd19efc99ba9fe797f14c0e3239c4bea20
2017-10-24 15:30:58 +00:00
Max 37f465e275 GPRS: check and report local address used for NSE
When dumping NSE via vty:
* check which local address would be used to communicate with a given
  NSE and print it
* print link layer type last to make output more consistent

Change-Id: I6932a29c7899d36bcc275f05dda9670b0e69bef0
Related: SYS#3610
2017-10-24 14:33:31 +00:00
Max 9530859654 GPRS: clarify ip/frgre union use
* add comment about underlying assumption that structs in ip/frgre union
  members in gprs_nsvc struct have the same memory layout
* remove such assumption from gprs_ns_ll_str()
* use gprs_ns_ll_str() for NSE dump

Change-Id: Idcb912b7b3f7460fd2b058e16650c0bde8f757ee
2017-10-24 14:33:31 +00:00
Max c513c0f562 GPRS: wrap NS state assignment in macro
This enables logging for every state transition which makes NS
troubleshooting easier.

Change-Id: I5d6eaef0432d9be810bf93d07e40787b9ca59142
Related: SYS#3610
2017-10-24 14:33:30 +00:00
Max 4ce24c45b9 GPRS: unify NS state printing
* introduce defines with NS state names
* use them for vty and tests
* expand test output to print complete NS state

Change-Id: I69f8d536135ae76dbca623c2f1ffba625adcb1e9
Related: SYS#3610
2017-10-24 14:33:30 +00:00
Neels Hofmeyr abdd7a28ed add osmo_talloc_asprintf() and ctrl_cmd_reply_printf()
Add macro to append to a CTRL commands' reply string, ctrl_cmd_reply_printf().
The talloc_asprintf() part of it is generic enough to qualify for a separate
macro, osmo_talloc_asprintf().

The idea is to not have to decide for each bit added to a string whether the
string is already allocated or not, but simply be able to issue printf commands
and let the macro worry about initial allocation or reallocation.

This originally came from osmo-hlr change
I1bd62ae0d4eefde7e1517db15a2155640a1bab58, where it was requested to move this
bit to libosmocore.

Change-Id: Ic9dba0e4a1eb5a7dc3cee2f181b9024ed4fc7005
2017-10-24 10:54:07 +00:00
Pau Espin e9e9e427b7 vty: Fix bad use of vector_slot()
Fixes the compilation warning below:

git/libosmocore/src/vty/command.c: In function ‘cmd_complete_command_real’:
git/libosmocore/src/vty/command.c:1953:33: warning: comparison between pointer and zero character const
ant [-Wpointer-compare]
   if (vector_slot(vline, index) == '\0')
                                 ^~
git/libosmocore/src/vty/command.c:37:0:
git/libosmocore/include/osmocom/vty/vector.h:39:27: note: did you mean to dereference the pointer?
 #define vector_slot(V,I)  ((V)->index[(I)])
                           ^
git/libosmocore/src/vty/command.c:1953:7: note: in expansion of macro ‘vector_slot’
   if (vector_slot(vline, index) == '\0')
       ^~~~~~~~~~~

Change-Id: Iaba9e3450d68c51e16a7bda2fc0fc370992ca866
2017-10-24 10:51:23 +00:00
Philipp Maier 224a6dda02 gb: optionally allow nsip packets only from a specific host
When listening for nsip connections is enabled, then every remote
host may send packets. This is useful for an SGSN that serves
multiple PCUs, but contraproductive for a PCU that awaits packets
from a single SGSN.

Add struct members remote_ip, and remote_port to struct gprs_ns_inst,
when set, then the listening end uses connect() to ensure that only
the expected host may send packets.

Related: OS#2401
Change-Id: Ifeb201d9006eec275a46708007ff342cdfc14e45
2017-10-24 10:50:07 +00:00
Max f0e392ac2d Simplify bitvec_write_field()
Use existing function instead of copy-pasted loop.

Change-Id: I9fe27c06125ac52e02e63dcded056a5f1cf68f41
Related: OS#1526
2017-10-24 12:08:34 +02:00
Max 0b3db5039d Replace bitvec_set_uint() with bitvec_set_u64()
Old bitvec_set_uint() uses "unsigned int" as input parameter which
length is not guaranteed. It does not allow to specify which bit_value
to set and does not check for incorrect length. Overall this makes it
harder to re-use and more error-prone.

Let's replace it with extended implementation which uses fixed type
length parameters and extra checks. The additional parameter allows
caller to explicitly indicate the need to use L/H instead of 0/1 for bit
vector elements. It's necessary to properly encode some of the messages
from 3GPP TS 44.018, for example §10.5.2.16 IA Rest Octets.

The old function is left for backward compatibility as a tiny wrapper
around new function and will be deprecated in follow-up patches.

Change-Id: I1b670dacb55fb3063271d045f9faa10fccba10a6
Related: OS#1526
2017-10-24 08:22:02 +00:00
Max 9818664315 Add tests for bitvec_write_field()
This function is actively used by OsmoPCU but have not been covered by
tests so far. The test code is based on
Minh-Quang Nguyen <minh-quang.nguyen@nutaq.com> submission with some
modifications.

The test's FIXME will be addressed in follow-up patches.

Change-Id: I2ee544256b8675bc62a42493aab66a8eeee54f90
Related: OS#1526
2017-10-24 08:21:59 +00:00
Neels Hofmeyr ea66852a62 ctrl: allow more nodes than those in enum ctrl_node_type
Add ctrl_interface_setup_dynip2() to add a node_count parameter, which can be
used to define more ctrl nodes without having to merge a patch to libosmocore.

In consequence, also add ctrl_handle_alloc2(), since
ctrl_interface_setup_dynip() uses ctrl_handle_alloc() to allocate the node
slots, and add node_count param to static ctrl_init().

Passing zero as node_count indicates to use the default of _LAST_CTRL_NODE as
before, i.e. to not define more ctrl nodes. Assert that we never allocate less
than _LAST_CTRL_NODE slots.

The current ctrl_interface_setup_dynip() and ctrl_handle_alloc() become simple
wrappers that pass zero as node_count. Their use is still valid and they do not
need to be deprecated.

The API comment to ctrl_interface_setup_dynip2() explains how to define more
node IDs.

This patch was verified to work by osmo-hlr.git change
I98ee6a06b3aa6a67adb868e0b63b0e04eb42eb50 which adds two node IDs for use by
osmo-hlr only.

Change-Id: I1bd62ae0d4eefde7e1517db15a2155640a1bab58
2017-10-23 22:31:01 +00:00
Max 1fa8dfbaf4 Expand osmo_gettimeofday() docs
Change-Id: I9bc835aea56f5f2fb652bb5ab3405e354ba3b95c
Related: OS#2586
2017-10-23 17:53:11 +00:00
Pau Espin 4b45669761 abis_nm: Add abis_nm_admin_name() API
Similar APIs exist for opstate and availability status.

This patch does not break backward compatibility because osmo-bsc still
requires direct use of the structure in get_string_value().

Change-Id: Ieace734aaff3f07606113feddde65b75202d96d6
2017-10-23 16:59:57 +00:00
Philipp Maier 2d2490ed4e socket: add function osmo_sock_local_ip() to query local ip
In some cases it is required to know the ip-address of the interface
through that a given remote IP-Address can be reached.

Add function osmo_sock_local_ip() to determine the local ip-address
for a given remote ip-address

Change-Id: I2988cc52b196fc8476703d1287e24cb4a48491c2
2017-10-23 08:47:38 +00:00
Max a19c126e76 GPRS: log NS socket
Let's log NS UDP socket creation similar to the way we log it for telnet
and ctrl interfaces.

Change-Id: Ic9d0f94ab2c1bb33f67cd4f1c9236b64108c0bb6
2017-10-23 08:39:42 +00:00
Philipp Maier c5b47cc032 add function msgb_printf() to print formatted text into msg buf
In ASCII string based protocols it a printf() version that prints
directly to the message buffer may be useful.

Add function msgb_printf(), make sure that msg buffer bounderies
are not exceeded. If the end of the tail buffer is hit, return
with an error code.

Change-Id: I15e1af68616309555d0ed9ac5da027c9833d42e3
2017-10-22 20:09:26 +00:00
Max fcf81b5deb Make osmo_apn_to_str() more robust
Previously it would crash on NULL input. Let's handle it gracefully
instead. Corresponding test case is also added.

Change-Id: I587153e49d1c92128fac3ae5c124adba9592378e
2017-10-20 18:19:58 +00:00
Max d7ee5759cb Disable doxygen in jenkins for embedded tests
There's no point in regenerating documentation with Doxygen in embedded
environment.

Change-Id: I6504db04445f5e9c1117379c8803e10df5634324
2017-10-20 18:17:42 +00:00
Max 15b05fef76 Cleanup jenkins build scripts
* reorder builds to avoid rm -rf invocation
* avoid useless double autoreconf
* move common parts into shared helper
* move common build steps into separate function

Change-Id: I24e500e132f5c8e8133d35548cb7b4e4552331d0
2017-10-20 18:17:42 +00:00
Max 32f9971a71 GPRS: print remote state info for NS peer
Change-Id: I1714c68909507eae6ef2933661a085859aca3b54
Related: SYS#3610
2017-10-20 12:27:49 +02:00
Neels Hofmeyr b525b9ea44 api doc: fix two doxygen group closing braces
Change-Id: I6c1f47d13c5b7a9cb2281de9f017df4f1ed88ba7
2017-10-17 11:53:45 +00:00
Harald Welte 37b6165513 [doc] Properly define gsm0800 group and move all related files into it
Change-Id: I91920c69c86d6a1932172becacb76faff2d3eb1e
2017-10-17 07:53:02 +02:00
Harald Welte a338983d3b [doc] Properly define 'oap' group and add introductory text
Change-Id: I1e875991ae1dd93862f850f85d40b3dac61ece72
2017-10-17 07:53:02 +02:00
Harald Welte 381a1aa1c1 [doc] Define 'gsup' group with proper name, add intro text
Change-Id: Ieee6213dc5aad082a2d439c7418b51f281b80b1a
2017-10-17 07:53:02 +02:00
Harald Welte 55d724addc [doc] make sure all SMS related code is part of the 'sms' group
Change-Id: I24c56ccb56d5b39cfb887808f91b715da54c0f8b
2017-10-17 07:53:02 +02:00
Harald Welte 8cc2767891 [doc] gea has separate group; A5 is not part of crypto but a5 group
Change-Id: I2fd24c86f9b52244073ec800a3287e3d38e660d9
2017-10-17 07:53:02 +02:00
Harald Welte c368b5420a [doc] Provide proper name for 'auth' group
Change-Id: I5fb1c34475ea9db36c2ec5cddc988074a72a35f7
2017-10-17 07:53:02 +02:00
Harald Welte 45c0ad845d [doc] Ensure include/crypt/* is part of libosmogsm documentation
Change-Id: Ic41f807dabb3b0d2d20b9d8963cad639e98f04dd
2017-10-17 05:52:04 +00:00