Commit Graph

2198 Commits

Author SHA1 Message Date
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
Harald Welte b10d214365 [doc] Ensure stats.h is parsed properly for Doxygen
stats.h uses a rather crude '#ifdef unix' hack, which means that Doxygen
will not scan the body of the file.  This patch ensures 'unix' is defined
to parse the stats.h body and thus have all relevant information in it
is parsed.

Change-Id: I65384e5cc01f2ad7783cf6b71ab78b4422902aa1
2017-10-17 05:47:09 +00:00
Harald Welte 9325d86192 [doc] TLV parser has far grown beyond GSM L3
Let's hence not call the group "GSM L3 compatible TLV parser"

Change-Id: Ic53f9c0d5ee787f994f42cf2aff313c6e131fbe6
2017-10-16 15:32:43 +02:00
Harald Welte 84bd33349c [doc] Rename "RSL" to "A-bis RSL" in documentation.
We also have "A-bis OML" and it's a bit odd to have one with prefix
and the other without.

Change-Id: Ida325f8a9c40b40c1aeaa4edfd1123ced7cc92b8
2017-10-16 15:32:06 +02:00
Harald Welte 8c64825249 [doc] Don't add libosmovty bits to libosmocore groups
Let's not put files of libosmovty into Doxygen groups of libosmocore,
as this seems to confuse Doxygen.  Also, some minor updates/fixes
of libosmovty documentation.

Change-Id: I70e612b8d06aabefe634fcd7861641ffb941d974
2017-10-16 15:17:03 +02:00
Harald Welte 7166094a85 [doc] Expand Doxuygen documentation for osmo_prim
Also, make sure prim.c is actually part of the 'prim' module.

Change-Id: I4363e46a5f606eb2114a9cc1d2086007eaa58d31
2017-10-16 14:52:37 +02:00
Harald Welte df8c57f328 [doc] Introductory text on what the logging ring buffer is about
Change-Id: I876cd31e03a53ca90e658e353c0c8a839dece8ad
2017-10-16 14:37:31 +02:00
Harald Welte efee361ce4 [doc] Make sure loggingrb.c file is in correct Doxygen group.
loggingrb.c, like loggingrb.h should be part of the loggingrb group!

Change-Id: I4822a46631b45df1afda202c00038b6ad2c8b5ae
2017-10-16 14:37:05 +02:00
Harald Welte 096a666712 [doc] Doxygen documentation on osmo_hexdump print buffer size
Change-Id: I83ca2a3a555e5b3c1b7f23bf9e463a5063a8006c
2017-10-16 14:33:11 +02:00
Harald Welte 197a4ac06d [doc] Put CRC-16 and generic CRC code in one Doxygen module
.. and add missing API documentation bits

Change-Id: I67119894bcbf8c779426a0272bae4c5ce1fbd1ed
2017-10-16 14:29:26 +02:00
Harald Welte ef7a44e33d [doc] bits.c: Better / more Doxygen documentation
Change-Id: If824a5c8d8ee6e3dc96a3fddeb105786c0c027c1
2017-10-16 14:19:12 +02:00
Harald Welte 53de0d3169 [doc] rate_ctr: Extend Doxygen API documentation with human-readable text on its use
Change-Id: If9abd46e1b0ebb6114522418fd3b45c1d802968a
2017-10-16 14:19:03 +02:00
Harald Welte f01b2383b1 [doc] src/logging.c: Fix Doxygen syntax to make logging.c show up in logging group
Change-Id: I56718e1eca1739a1b0a790f2f3a1b554899a93ab
2017-10-16 14:19:00 +02:00
Harald Welte eb5b6ce444 [doc] Add Doxygen API documentation for stats.c and stats_statsd.c
Change-Id: I8e49505f5c19beac90290fdba8821714e8eecd97
2017-10-16 14:18:56 +02:00
Harald Welte 17bbaa324b [doc] counter.[ch] Add Doxygen API documentation
This adds a more complete set of API documentation for all
osmo_counter relatedd functions and definitions.

Change-Id: I24283c05620ee86a8beb165af98a85d754549efb
2017-10-16 14:18:54 +02:00
Harald Welte 781951bcf9 [doc] stat_item: Complete doxygen documentation for API
The stat_item code base had some incomplete doxygen documentation
so far.  Let's complete it, and at the same time fix some cosmetic
as well as copy+paste issues in the existing documentation bits.

Change-Id: Ib514c137b40bf7b9791bd74be99af0b65575f2b6
2017-10-16 14:18:50 +02:00
Harald Welte 216338c369 Rename 'statistics.c' to 'counter.c'
With stat_item, stats.c and stats_statsd.c, it is becoming a bit
difficult to understand file naming.  Also, the 'statistics.c' file
actually only contained osmo_counter handling, so let's rename it to
counter.c altogether.

Change-Id: I2cfb2310543902b7da46cb15a76e2da317eaed7d
2017-10-15 19:51:35 +02:00
Neels Hofmeyr 4b7c791e15 gsm: make osmo_imsi_str_valid() NULL-safe
No callers that would pass NULL exist, but let's check against NULL from the
start.

Fixup for recent change I1e94f5b0717b947d2a7a7d36bacdf04a75cb3522.

Change-Id: I111fbf29228929f2cd6ffa06bcb1f69da223224e
2017-10-10 14:38:10 +00:00
Max f624546ed1 Fix build on older systems
Make sure GRND_NONBLOCK is always defined, even when using syscall
directly.

Change-Id: I1bcac37ee1847596b49122f9307bd2689ba71b1b
Related: OS#1694
2017-10-10 03:03:58 +00:00
Neels Hofmeyr 4335badd0e utils: add osmo_is_hexstr(), add unit test
Will be used by OsmoHLR to validate VTY and CTRL input.

Change-Id: Idf75946eb0a84e145adad13fc7c78bb7a267aa0a
2017-10-09 16:30:45 +02:00
Neels Hofmeyr 1a02e36c4c auth: add OSMO_MILENAGE_IND_BITLEN_MAX
Will be used by OsmoHLR to validate VTY and CTRL input.

Change-Id: Ic39f3404d1a49ffd06070aa9897b36f219eacf4d
2017-10-09 16:30:45 +02:00
Neels Hofmeyr 26e30b1309 auth: add value_strings for osmo_sub_auth_type, comment on osmo_auth_alg_name()
Add osmo_sub_auth_type_names[] and osmo_sub_auth_type_name().

Also add a hint to enum osmo_auth_algo's API doc that osmo_auth_alg_name()
already exists (it is defined further below).

Change-Id: I652a929bcd11c694d86812fb03d0a1cbd985efda
2017-10-09 16:30:45 +02:00
Max 4b2b0cc15d Add function to generate random identifier
The function is a wrapper on top of getrandom() (if available via glibc) or
corresponding syscall. If neither is available than failure is always
returned.

It's intended to generate small random data good enough for session
identifiers and keys. To generate long-term cryptographic keys it's
better to use special crypto libraries (like GnuTLS for example)
instead.

As an example it's used to replace old insecure random number generator
in osmo-auc-gen utility.

Change-Id: I0241b814ea4c4ce1458f7ad76e31d390383c2048
Related: OS#1694
2017-10-09 10:18:07 +00:00
Harald Welte 81dc67d03f Ensure __always_inline is defined on operating systems that don't have it
For example, Alpine Linux fails to build libosmocore without us locally
defining __always_inline.

Change-Id: I0c22aac410e668f8fb8d5de57281bcaeb343eeb1
2017-10-09 11:00:56 +08:00