Commit Graph

1389 Commits

Author SHA1 Message Date
Sylvain Munaut 69b1b8bea6 build: Enable subdir-objects
This fixes warning (and even build on some newer automake).
This should now work in the CI as well thanks to the fix for tests.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-08-19 11:15:14 +02:00
Sylvain Munaut 0d72785568 tests: Don't reference file in src/ to test hidden func. Use static link.
Taken from:
https://qiaomuf.wordpress.com/2011/03/27/handling-unit-test-with-c-visibilityhidden/

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-08-19 11:14:23 +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 538ff49837 Revert "configure.ac: Add subdir-objects"
This reverts commit 7c942ba147.
With automake 1.14 and using the above option the distclean
will fail with:

Making distclean in tests
gmake[2]: Entering directory '/home/builder/source/workspace/libosmocore/label/FreeBSD_amd64/libosmocore-0.8.0.47-7c94/_build/tests'
Makefile:848: ../src/gsm/.deps/a5.Po: No such file or directory
Makefile:849: ../src/gsm/.deps/kasumi.Po: No such file or directory
gmake[2]: *** No rule to make target '../src/gsm/.deps/kasumi.Po'.  Stop.
gmake[2]: Leaving directory '/home/builder/source/workspace/libosmocore/label/FreeBSD_amd64/libosmocore-0.8.0.47-7c94/_build/tests'
Makefile:506: recipe for target 'distclean-recursive' failed
gmake[1]: *** [distclean-recursive] Error 1
gmake[1]: Leaving directory '/home/builder/source/workspace/libosmocore/label/FreeBSD_amd64/libosmocore-0.8.0.47-7c94/_build'
Makefile:714: recipe for target 'distcheck' failed

As we are not required to use the option, let's fix the build
2015-08-18 13:17:53 +02:00
Harald Welte 7c942ba147 configure.ac: Add subdir-objects
Apparently this is required under latest autotools versions.
2015-08-15 10:49:46 +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 c136da587f release: Prepare the 0.8.2 release
I have kind of used 0.8.1 by accident already so let us move
to 0.8.2 now.
2015-08-01 20:20:24 +02:00
Jacob Erlbeck c1cb75eff5 bssgp: Fix IMSI buffer size (Coverity)
Currently the size of the IMSI pointer is used instead of the size of
the talloc'ed buffer.

This commit changes the call to gsm48_mi_to_string to use the same
value that has been used with talloc_zero_size(). The length is
changed to 17 since that value is used for GSM_IMSI_LENGTH in
openbsc.

Fixes: Coverity CID 1040663
Sponsored-by: On-Waves ehf
2015-06-19 20:54:28 +02:00
Jacob Erlbeck 2c58197e5d bssgp/test: Add missing START/END printfs
Sponsored-by: On-Waves ehf
2015-06-19 20:53:31 +02:00
Jacob Erlbeck 7f31c90b80 ipa: Add libosmogsm.map entry for ipa_ccm_idtag_parse_off
Addresses:
  CCLD     utils/utils_test
  utils_test.o: In function `test_idtag_parsing':
  git/libosmocore/tests/utils/utils_test.c:64: undefined reference to `ipa_ccm_idtag_parse_off'

Sponsored-by: On-Waves ehf
2015-06-04 08:52:36 +02: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
Holger Hans Peter Freyther 91ff17c9ef osmo-auc-gen: '-a' is already the algorithm. Fix the help 2015-05-26 00:11:37 +08:00
Holger Hans Peter Freyther a6ea50c4ff debian: New development release with APN changes for the SGSN 2015-05-25 14:17:29 +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
Holger Hans Peter Freyther 0d86c21f6a build: Fix the building of tests as well
In file included from ../../include/osmocom/core/msgb.h:25:0,
                 from ../../tests/sms/sms_test.c:31:
../../include/osmocom/core/bits.h:6:35: fatal error: osmocom/core/bit16gen.h: No such file or directory
 #include <osmocom/core/bit16gen.h>
2015-05-17 19:55:53 +02:00
Andreas Rottmann 9eb1c80020 build: Fix out-of-tree builds
Fixes:
In file included from ../../../include/osmocom/core/msgb.h:25:0,
                 from ../../../include/osmocom/sim/sim.h:4,
                 from ../../../src/sim/reader_pcsc.c:30:
../../../include/osmocom/core/bits.h:6:35: fatal error: osmocom/core/bit16gen.h: No such file or directory
 #include <osmocom/core/bit16gen.h>

In file included from ../../include/osmocom/core/msgb.h:25:0,
                 from ../../utils/osmo-sim-test.c:26:
../../include/osmocom/core/bits.h:6:35: fatal error: osmocom/core/bit16gen.h: No such file or directory
 #include <osmocom/core/bit16gen.h>
2015-05-17 19:19:09 +02:00
Holger Hans Peter Freyther 16082fd3cd debian: Bump version for new local packages 2015-05-06 17:58:45 +02: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
Jacob Erlbeck 455d34f476 bssgp/test: Fix bssgp-fc test
The fix in the commit "bssgp: Fix call to llist_entry in
fc_queue_timer_cfg" prevents the flow control code from generating
certain logging messages ("-BSSGP-FC: fc_timer_cb() but still not
able to send PDU of 10 bytes") during the tests. This breaks the test
suite, since the update of the correseponding stderr output file
misses.

This commit updates the bssgp_fc_tests.err file accordingly.

Sponsored-by: On-Waves ehf
2015-05-04 07:44:43 +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
Jacob Erlbeck 9731935984 bssgp: Fix call to llist_entry in fc_queue_timer_cfg
Currently the DL sometimes hangs and sometimes a lot of messages
(still not able to send PDU) are logged. This is caused by an invalid
timer delay computation, setting msecs either to 0 or to some big value.

This is due to an '&' operator at the wrong place, accessing some
parts in fc instead of the first element of the list.

This commit fixes that issue.

Sponsored-by: On-Waves ehf
2015-04-30 20:02:09 +02:00
Jacob Erlbeck 580af4be00 bssgp: Fix encoding of BVC_FLOW_CONTROL
Currently all 2 byte IE of the message are transmitted in the little
endian byte ordering.

This commit adds htons to the encoding expressions.

Sponsored-by: On-Waves ehf
2015-04-29 15:48:09 +02:00
Jacob Erlbeck 1bda44213e bssgp: Fix output of the VTY 'show bssgp stats' command
The output is terminated by a '\n' instead of VTY_NEWLINE.

This is fixed by the commit.

Sponsored-by: On-Waves ehf
2015-04-29 15:47:25 +02:00
Holger Hans Peter Freyther ad69f89b52 debian: Build new version 2015-04-16 21:23:49 +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 6b1faf7362 logginrb: Fix compiler warning about fprintf
loggingrb/loggingrb_test.c:76:18: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
        fprintf(stderr, log_target_rb_get(ringbuf_target, 0));
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
loggingrb/loggingrb_test.c:77:18: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
        fprintf(stderr, log_target_rb_get(ringbuf_target, 1));
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2015-04-11 19:33:10 +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
Holger Hans Peter Freyther 1885395551 macaddr: Use the BSD code for Darwin as well
It simply compiles, no other testing has been done.
2015-04-11 19:29:52 +02:00
Holger Hans Peter Freyther 9a1a5a1c0a utils: Disable the weak symbol for darwin
We should consider simply removing the alias as we have
had several ABI changes since introducint the alias

utils.c:223:23: error: only weak aliases are supported on darwin
        __attribute__((weak, alias("osmo_hexdump_nospc")));
2015-04-11 19:28:00 +02:00
Jacob Erlbeck a84db61673 gprs: Add assertion for msg != NULL to bssgp_msgb_alloc (Coverity)
Currently out-of-memory is not handled by bssgp_msgb_alloc, leading
to SEGV failures if msgb_alloc_headroom returns NULL.

This commit adds an OSMO_ASSERT to catch this case, which improves
the situation only slightly. But bssgp_msgb_alloc is used in many
places without checking the return value, so just adding a
conditional early NULL return would not fix the issue either.

Fixes: Coverity CID 1293377
Sponsored-by: On-Waves ehf
2015-04-10 08:44:35 +02:00
Jacob Erlbeck d154f8bda2 msgb: Check the return value of msgb_alloc (Coverity)
In some places, the return value of msgb_alloc/msgb_alloc_headroom
is not checked before it is dereferenced.

This commit adds NULL checks to return with -ENOMEM from the calling
functions if the alloc function has failed.

Fixes: Coverity CID 1249692, 1293376
Sponsored-by: On-Waves ehf
2015-04-10 08:44:15 +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
Jacob Erlbeck b535e391b0 bssgp: Ensure non-NULL bctx before calling bssgp_rx_ptp (Coverity)
Currently bssgp_rx_ptp might be called with bctx being NULL, when the
NS BVCI is neither BVCI_SIGNALLING nor BVCI_PTM, but the message is
a BVC_RESET or it contains an BVCI IE != BVCI_SIGNALLING where the
BVCI is not known.

This patch ensures that bssgp_rx_ptp will only be called with a
non-NULL bctx. A log message will be issued, if the bctx is NULL when
this was not expected.

Fixes: Coverity CID 1040674
Sponsored-by: On-Waves ehf
2015-04-07 20:10:09 +02:00
Jacob Erlbeck c641591ae9 bssgp: Always expect dup != NULL in bssgp_tx_dl_ud (Coverity)
Currently the implementation of bssgp_tx_dl_ud conditionally adds
some optional IE if dup != NULL. Later on is dereferences dup to
access qos_profile and fc, but this without checking dup in advance.
This may lead to an segmentation violation fault.

This commit changes the value range of the function to only accept
dup != NULL. An assertion will fail otherwise. All other explicit
checks for non-NULL are removed.

Fixes: Coverity CID 1040673
Sponsored-by: On-Waves ehf
2015-04-07 20:09:48 +02:00
Max a11994ddff fix compiler warnings for a5 tests
Signed-off-by: Max <max.suraev@fairwaves.co>
2015-04-07 20:08:38 +02:00
Holger Hans Peter Freyther 5fb265eaa7 ctrl: Avoid accessing cmd_desc->command out of bounds
We check that the amount of commands is not more than
we have but we don't check it the other way. It appears
that the vector is allowed to be bigger than the amount
of commands. So we match a prefix of a longer command
depending on the installation order.
2015-04-05 14:40:10 +02:00
Michael McTernan 4e0543f730 Tests: Fix broken loggingrb testcase.
The loggingrb (ringbuffer) test case was not actually being built or ran, instead still using the normal logging test.

This patch fixes the makefile, then the loggingrb testcase is changed to use the current loggingrb API so that it builds and passes.

Signed-off-by: Michael McTernan <mike.mcternan@wavemobile.com>
2015-04-01 20:50:26 +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
Michael McTernan 789334640f vty: Fix writing the logging of category
Fix copy and paste issue introduced by Holger in
2d6ad13d8d.
2015-03-20 15:31:30 +01:00
Holger Hans Peter Freyther 267fd86e7d libctrl: Include config.h so we can include netinet/tcp.h
In e15ac060e7 we tried to fix
the nuttx build but we never included "netinet/tcp.h" after
it and the compiler warned about the unused "on" parameter
which we didn't notice because of the other warnings...

Include config.h so we can see if there is a tcp.h and then
include it.
2015-03-18 21:54:37 +01:00
Holger Hans Peter Freyther 6cce3d7153 msgfile: Fix warning on BSDs stdio
msgfile.c:116:16: warning: implicit declaration of function 'getline' is invalid in C99
      [-Wimplicit-function-declaration]
        while (getline(&line, &n, file) != -1) {
2015-03-18 21:54:37 +01:00
Holger Hans Peter Freyther ca8dcb7bff gsm0808: Remove duplicate initialization
These types were compatible so simply remove one.

Fixes:
gsm0808.c:323:37: warning: initializer overrides prior initialization  CC       gsm0480.lo
 of this subobject
        CC       abis_nm.lo
[-Winitializer-overrides]
                [GSM0808_IE_LSA_INFORMATION]            = { TLV_TYPE_TLV },
                                                            ^~~~~~~~~~~~
gsm0808.c:316:36: note: previous initialization is here
                [GSM0808_IE_LSA_INFORMATION]    = { TLV_TYPE_TLV },
                                                    ^~~~~~~~~~~~
2015-03-18 21:54:37 +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
Jacob Erlbeck 49ed9beed1 bssgp: Don't reply with STATUS when receiving a PtP STATUS message
Currently each incoming PtP BSSGP STATUS message is handled as 'not
yet implemented' and a BSSGP STATUS message (cause
BSSGP_CAUSE_PROTO_ERR_UNSPEC) is sent back to the peer. This will
cause endless messages loops if both peers use this BSSGP stack
implementation. This does not apply to signalling messages.

This commit changes the implementation of bssgp_rx_ptp() to just do
logging in this case.

Sponsored-by: On-Waves ehf
2015-03-18 21:54:37 +01:00
Jacob Erlbeck b61b2ca1a0 logging: Implement subsecond resolution of extended timestamps
Currently when using 'logging print extended-timestamp 1', the
subsecond part (milliseconds) of the printed timestamp is always 0.
This makes it difficult to correlate log entries with PCAP file
entries if there are many of them per second.

This patch changes _output in logging.c to use gettimeofday() instead
of time() when extended timestamps are enabled and replaces the '000'
by the milliseconds computed from tv_usec.

Sponsored-by: On-Waves ehf
2015-03-18 21:54:37 +01:00
Holger Hans Peter Freyther 4dafdefa7a debian: Aim for a higher standards version 2015-03-14 19:30:19 +01:00
Holger Hans Peter Freyther 4d45d40c78 debian: Move to multi-arch support in libosmocore
Enable multi-arch support in libosmocore. This means the package
can not be built on squeeze anymore.

The concept of "foreign" is not really well documented but I
think I use it correctly here.
2015-03-14 19:22:34 +01:00
Holger Hans Peter Freyther 879acef394 vty: Fix typo in the state creation
This got introduced in 2d6ad13d8d
and I thought that our vty tests would have caught such mistakes.
2015-01-27 11:08:27 +01:00