Commit Graph

1563 Commits

Author SHA1 Message Date
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
Holger Hans Peter Freyther 19d00517af debian: Add pcsc build depends and pkg-config for the m4 macro 2015-01-27 11:08:27 +01:00
altaf f6a0ceb92f core/gsmtap: LTE RRC message types and LTE MAC define
Submitted-by: altaf <altaf329@gmail.com>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-01-18 23:16:03 +01:00
Holger Hans Peter Freyther 25aeab7a82 Prepare a new libosmocore release 2015-01-18 19:20:42 +01:00
Holger Hans Peter Freyther 4deb2dfa25 ctrl: Link to libraries we use symbols from
Fixes:
dpkg-shlibdeps: warning: symbol vector_free used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_set used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_set_index used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol tall_vty_vec_ctx used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol ipa_msg_recv_buffered used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol cmd_free_strvec used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_lookup used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_lookup_ensure used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol cmd_make_strvec used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol vector_init used by debian/libosmoctrl0/usr/lib/libosmoctrl.so.0.0.0 found in none of the libraries
2015-01-18 19:20:42 +01:00
Holger Hans Peter Freyther c869069950 sim: Link to libosmocore and libosmogsm
The big LIBOSMOCORE_CFLAGS and LIBOSMOCORE_LIBS macros are not
defined when building linosmocore. Use the .la files directly

Fixes:
dpkg-shlibdeps: warning: symbol osmo_hexdump used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol gsm48_parse_ra used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol _talloc_zero used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol _talloc_memdup used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol talloc_strndup used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol msgb_length used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol msgb_alloc used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol msgb_free used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol talloc_strdup used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
dpkg-shlibdeps: warning: symbol talloc_free used by debian/libosmosim0/usr/lib/libosmosim.so.0.0.0 found in none of the libraries
2015-01-18 19:18:36 +01:00
Holger Hans Peter Freyther 78ffdb8ab2 misc: Ignore a file generated by doxygen 2015-01-18 19:18:31 +01:00
Tobias Engel 419684e30c Supplementary Services (de)activation, interrogation added
These patches enhance the Supplementary Service (SS) processing from
only being able to handle USSD to other SS, specifically activation,
deactivation and interrogation of those SS. Registration is not yet
implemented.

include/osmocom/gsm/protocol/gsm_09_02.h has been added with needed
values for SS.

Modified by Harald Welte to keep the old ussd-only functiosn for API/ABI
stability.
2015-01-01 14:19:17 +01:00
Harald Welte c13cf8bbd3 SMS-CB: introduce and use GSM341_7BIT_PADDING 2014-12-30 13:25:44 +01:00
Harald Welte c993a07ceb use the new GSM341 / GSM412 size constants 2014-12-30 13:22:56 +01:00
Harald Welte 61ced83a70 SMS-CB: Add #defines for maximum block/msg size and payload chars 2014-12-30 13:18:26 +01:00
Daniel Willmann f626123f83 smscb/gsm0341_test: Add \r padding to the message 2014-12-30 12:07:17 +01:00
Harald Welte be4bbeb01b add missing gsm0341.h 2014-12-30 01:22:26 +01:00
Harald Welte 65f676dac5 test 2014-12-30 00:43:39 +01:00
Harald Welte 63b156a9e0 fixup 2014-12-30 00:43:32 +01:00
Harald Welte 783d073a37 add gsm0341_test to generate SMSCB hex strings
Those hex strings can then be copy+pasted into the OSmoNITB VTY
2014-12-29 17:09:11 +01:00
Harald Welte a19717a7c5 Add Cell Broadcast MSGIDs from TS 23.041 v12.6.0 Release 12 2014-12-29 13:14:48 +01:00
Holger Hans Peter Freyther 6ec6bd9d88 log: "logging level everything" is a badly named option.
We tried to fix it but it isn't that easy. The original fix was
cd6ed82d1f but we had to revert it
as "everything" is present/used in existing config files.

If we ever change the ABI we can make everything be something
that is > 0. For now use a wording that makes it obvious that
people should not use "everything".
2014-12-28 18:30:59 +01:00
Holger Hans Peter Freyther c8c33094af bitvec: Fix typo in the csn1 encoding code
We can curse about CSN.1 and 3GPP but I think we want to call
it cursor here.
2014-12-28 18:22:48 +01:00
Harald Welte 1b12d16c4c libosmo-gsm: Add PCHAN/LCHAN types for CBCH 2014-12-28 13:37:01 +01:00
Jacob Erlbeck a6be224b88 ipa: Return -errno instead of -1 in ipa_send
Currently, the ipa_send function returns -1 in one execution branch
to indicate an error and -EIO in another. This is not consistent and
can lead to a misinterpretation of the error code, since -1 is -EPERM
and in general, EPERM is not returned by write(2).

This patch changes the return code to -errno instead of -1 for the
case that write(2) fails for same reason. So -rc is always a sensible
error value if there is a failure.

Sponsored-by: On-Waves ehf
2014-12-22 14:44:59 +01:00
Jacob Erlbeck 3cd6753a11 ipa: Add forward declaration of struct osmo_fd
A pointer to struct osmo_fd is used in a few prototypes declared in
gsm/ipa.h, but is neither declared explicitly nor is such a
declaration reachable via the given include directives.

This patch adds a forward declaration of this type to ensure proper
compilation.

Sponsored-by: On-Waves ehf
2014-12-22 14:44:52 +01:00
Holger Hans Peter Freyther 4448048828 ipa: Make a reservation for the GSUP protocol
GSUP is a protocol to have the OpenBSC SGSN talk
to an exterbal system for 3GPP MAP connectivity.
2014-12-14 19:01:14 +01:00
Holger Hans Peter Freyther 5f91a40068 logging: Call color only once and use the result
First we check if a color is defined and then we call it again
and use the result. Avoid the second call and use the result of
the previous call.
2014-12-05 10:29:45 +01:00
Holger Hans Peter Freyther 2d6ad13d8d logging: Make it possible to print category/subsys and timestamps
We want to see from which category/subsystem a certain log message
is coming from and use a different timestamp format as well. Add
two new bitfields. This doesn't change the size of the structure
and on 32bit we still have 27bits left.

The extended timestamp will take preference over the current and
default timestamp format.

Fixes: SYS#602
2014-12-05 10:23:28 +01:00
Holger Hans Peter Freyther a5dc19dc40 gtp: Add a global region for the gtp library of OpenGGSN
We want to use libosmocore/libosmovty in the GGSN sourcecode
and reserve a global region here.
2014-12-04 14:39:14 +01:00
Holger Hans Peter Freyther 9f0f978c8d vty: Check with the application before writing the config
For the BSC/NITB application we see that people modify the band
without modifying the ARFCN. This creates an unbootable config.
Using the new hook the BSC/NITB can check if the config is
consistent and prevent the config file being written.

Related: SYS#739
2014-12-04 14:39:14 +01:00