Commit Graph

1743 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 61f28880d5 select: Externalize fd_set filling and dispatch
To integrate with an external event loop (in this case glib) we
need to allow an application to get a filled out fd_set and then
dispatch it. osmo_fds and maxfds are static and I decided to keep
it that way and instead create two routines to fill the fdset and
then one to dispatch the result.

The public header file does not include sys/select.h and we can
compile the library without select, so I didn't want to require
having to include this file, and used void * for the parameter.

Mark the routines as inline to avoid a call from the select
function. I have confirmed that inlining has an effect on x86
using Debian's gcc-4.9.2-10 compiler
2016-03-31 16:56:51 +02:00
Max fb348eeff2 Export names for gsm_chan_t and gsm48_chan_mode
This can be used with get_value_string() to improve debugging output.
2016-03-30 21:50:44 +02:00
Holger Hans Peter Freyther 92c4ec293d sim: Fix compiler warning and by this fixing the test result 2016-03-21 11:29:16 +01:00
Harald Welte 932d2d4ce3 sim: make osim_reader_ops public 2016-03-19 21:18:40 +01:00
Harald Welte 6c33ae2605 Add new osmo_fd_get_by_fd() function
This function can be used to obtain the osmo_fd corresponding to a given
fd.  The latter can be useful when integrating libosmocore main loop
with other libraries.
2016-03-19 21:17:58 +01:00
Harald Welte 676e534462 sim: Add simplistic unit test for APDU class tables 2016-03-17 16:55:11 +01:00
Harald Welte 4acaa13433 sim: add class_tables / card profiles
The tables permit code to determine the APDU class of an APDU
based on it APDU/TPDU header (CLA/INS/P1/P2/P3).
2016-03-17 16:55:11 +01:00
Max 2c34ab4a80 Improve BSSGP debug output
Print string representation of Cause IE and PDU type instead of
numerical value.
2016-03-17 16:55:11 +01:00
Harald Welte 5bed23c6d2 add missing #include <stdbool.h> 2016-03-17 16:50:50 +01:00
Max ea345cdaaa Rename struct to better match libosmocore conventions 2016-03-17 16:49:15 +01:00
Harald Welte c79b3972fa Revert "gsm48: move to hex TMSI representation"
This reverts commit f451ce66eb.
2016-03-17 14:43:02 +01:00
Vadim Yanitskiy f451ce66eb gsm48: move to hex TMSI representation
Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
2016-03-17 14:13:18 +01:00
Max 03309b57e8 Add basic EARFCN support
Add structure representing group of EARFCNs with common priority,
threshold etc.
Add functions to populate this structure.
2016-03-17 14:07:19 +01:00
Max d4793212b5 Add function to add bits from array to bitvec
Add function which adds specified number of bits from each element of
array to the bit vector prefixing each addition with one and finishing
entire sequence with adding 0. This is very common patter for various
repetitive data structures described with CSN.1 in 3GPP standards.

Corresponding test vectors and doxygen headers are added too.
2016-03-17 14:07:19 +01:00
Neels Hofmeyr bdccc1b144 gsm48: factor out MCC+MNC BCD parsing for re-use in UMTS
For 3G, I need a BCD composer/parser similar to gsm48_generate_lai()/
gsm48_decode_lai(). Those functions also handle a trivial extra
member (lac) which I don't need in this way for 3G.

So create new functions to take on the MCC+MNC BCD handling and call those
from gsm48_generate_lai() and gsm48_decode_lai(). In this way, the 3G code
in openbsc can use only the BCD functionality without code duplication.
2016-03-15 14:30:41 +01:00
Neels Hofmeyr da7bf4d55a 04.08: add inline funcs for transaction id bits
Various users of gsm48_hdr apply the same hardcoded shifts/bitmasks to obtain
the transaction ID encoded in the upper nibble of the protocol discriminator.
Centralize. Patch for openbsc.git will follow.
2016-03-15 14:11:49 +01:00
Neels Hofmeyr c656faed12 04.08: switch to r99 msg type bitmasks by default
[hfreyther: Separated from the previous patch to allow an easy
revert]
2016-03-15 14:11:13 +01:00
Neels Hofmeyr 282e908434 04.08: add inline funcs for pdisc + msg type bitmasks
Add inline functions for both release <= 98 and release >= 99 as well as a
default define. Use the release 98 by default since the current code base uses
the r98 bitmasks.

These inline functions relieve callers of the decision on masking bits of the
protocol discriminator and message type octets.

Also add a define for the protocol discriminator extension to one octet length
(GSM48_PDISC_EXTEND).

Apply new pdisc function in gsm0480.c.

[hfreyther: Make the hdr param const]
2016-03-15 14:10:45 +01:00
Max c0d9a6c083 Add helper function to convert numerical BSSGP PDU type to string 2016-03-11 22:29:39 +07:00
Max e859aec952 Add support for SI2quater messages
Add basic data structure for System information Type 2quater.
2016-03-11 22:09:21 +07:00
Harald Welte 5ffb50371e rename osim_file_find_* to osim_file_desc_find_*
they return an osim_file_desc, and not an osim_file, so fix the naming
2016-03-11 22:05:25 +07:00
Harald Welte c28f4cdd6d sim: Add osim_file_find_{fid,sfid}() functions
We don't always want to look-up by name, but the latter is the only
implemented 'find' function so far.  Let's change that.
2016-03-11 22:05:25 +07:00
Harald Welte 1cc66f093f merge_doc.xsl: Don't copy the 'descripiton' element of commands
If a vty_additions.xml file contained a <description> element inside a
command> element, then the description was copied twice (once during the
<node> copy, and once during the <command> copy).  Let's avoid one of
the two copies.
2016-03-11 22:05:25 +07:00
Holger Hans Peter Freyther 57f253a792 debian: Make sure that libtalloc-dev is installed
This way libosmo-abis, libosmo-sccp, openggsn, openbsc does not
need to install it.
2016-03-05 08:36:26 +01:00
Holger Hans Peter Freyther ed0ce47fa9 logging: Remove unused variable after recent changes
The variable is not used anymore as the decision is done in the
newly added check_log_to_target method.
2016-02-29 14:41:12 +01:00
Holger Hans Peter Freyther 5dd3f1dd67 Merge branch 'sysmocom/shared/log-speed' 2016-02-29 14:34:34 +01:00
Holger Hans Peter Freyther 79599acd66 logging: Move the filter check up as well
There doesn't seem to be a reason not to check the filter. Update
and extend the test. Currently the filter function will be called
once for the log check and once for the output of it.
2016-02-29 14:30:14 +01:00
Holger Hans Peter Freyther e0dc6a1c7c logging: Remove some code duplication
Extract the mapping of the subsystem number and the checking for
the loglevel to a inline method that is shared between the new
and old.
2016-02-29 14:30:14 +01:00
Jacob Erlbeck 64e0eb56fd log/test: Extend test case for log_check_level
This commit adds OSMO_ASSERTs for mandatory conditions related to
log_check_level, and fprintfs for optional conditions, since it is
always safe for log_check_level to return != 0.

Sponsored-by: On-Waves ehf
2016-02-29 14:30:14 +01:00
Jacob Erlbeck a89d22c0f0 log: Add conditional logging based on log_check_level
Currently the LOGP/DEBUGP arguments are always evaluated even if
no logging will happen at all. This can be expensive, for instance
if hexdumps or pretty printed object names are generated. This causes
high base load especially on embedded devices and is a major part of
CPU usage e.g. of the osmo-pcu.

This commit uses the log_check_level function to avoid the evaluation
of the parameters if it is known in advance, that no logging entry
will be generated.

Sponsored-by: On-Waves ehf
2016-02-29 14:30:14 +01:00
Jacob Erlbeck de6dd72dbb log: Add log_check_level function
This commit adds this predicate function which can be used to
avoid the execution of code if a certain log level is not enabled.

The function will only return 0 (false), if it is sure that a logging
call for the same facility and level will not produce any output.
This safety criterion shall ensure, that no logging output is lost
due to the use of this predicate as a guard. On the other hand, even
if the predicate returns != 0 (true), no logging output might get
generated by a similar logging command.

Note that the current implementation is not focussed on performance,
which could be improved by using a lookup table instead of iterating
through every target.

Sponsored-by: On-Waves ehf
2016-02-29 14:30:14 +01:00
Neels Hofmeyr f20f5fd508 comment typo 2016-02-29 09:56:39 +01:00
Neels Hofmeyr cda988527f fix gsm_7bit_decode API comment: septets, not octets 2016-02-29 09:56:26 +01:00
Max 6a5ef46dd0 Add byte printing macros
It's sometimes handy for debugging to be able to immediately see which
bits are set in a given byte. Generalize macro used for that in bitvec
tests and make it available for the rest of the library.
2016-02-25 22:35:44 +01:00
Neels Hofmeyr f81eb328b6 vty: add ctrl section for Control interface bind address
This may seem like overkill for a mere const char * config item, but it makes
the Control interface VTY commands reusable in any main() scope (inspired by
libosmo-abis' VTY config).

Add API functions ctrl_vty_init() and ctrl_vty_get_bind_addr(), in new files
src/ctrl/control_vty.c and include/osmocom/ctrl/control_vty.h, compiled and/or
installed dependent on ENABLE_VTY.

Using these functions allows configuring a static const char* with the VTY
commands

    ctrl
     bind A.B.C.D

which callers shall subsequently use to bind the Control interface to a
specific local interface address, by passing the return value of
ctrl_vty_get_bind_addr() to control_interface_setup().

Add CTRL_NODE to enum node_type, "eating" RESERVED4_NODE to heed that comment
on avoiding ABI changes.
2016-02-25 11:02:35 +01:00
Neels Hofmeyr 4934309dab add ctrl_interface_setup_dynip() for bind address
Make the ctrl interface bind address configurable, so that it may be made
available on other addresses than 127.0.0.1. The specific aim is to allow
running multiple osmo-nitbs alongside each other (commits in openbsc follow).
2016-02-25 11:02:35 +01:00
Neels Hofmeyr 96172f0100 vty: add bind command for telnet vty line
Add VTY command
    line vty
     bind A.B.C.D

The command merely stores the configured IP-address, which can then be used by
the calling main program to set the telnet port of the VTY line. (Commits in
openbsc and osmo-iuh will follow up on this.)

Add function vty_get_bind_addr() to publish the address in the vty.h API.

Add static vty_bind_addr to store.

For allocation/freeing reasons, a NULL address defaults to 127.0.0.1.

BTW, I decided against allowing keywords 'any' and 'localhost' in place of an
actual IP address to make sure a written config is always identical to the
parsed config.
2016-02-25 11:02:34 +01:00
Max cc00bf8779 Extend L1SAP PH-DATA with presence information
Previously the presence of header and data blocks were communicated
in-band which decreases code readability and makes it unnecessary hard
to add support for new hardware.

Note: OsmoBTS have to be modified to take advantage of extended
ph_data_param structure.
2016-02-22 11:08:44 +01:00
Jacob Erlbeck f78ec5ce0d gb: Add bssgp_msgb_copy function
This function originates from openbsc/src/gprs but is just specific
to BSSGP/Gb on the same level like bssgp_msgb_alloc.

This commit puts the former gprs_msgb_copy function beside
bssgp_msgb_alloc.

Renamed function:

  gprs_msgb_copy -> bssgp_msgb_copy

Sponsored-by: On-Waves ehf
2016-02-22 10:20:49 +01:00
Holger Hans Peter Freyther ab0eb96dd9 bitvec: Untested speculative UBAN fix for the new routine
int << 31 does not seem to be defined, let's try to make it an
unsigned variable and see if that is pleasing the system.

Fixes:
bitvec.c:219:15: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
2016-02-18 20:28:25 +01:00
Max 5c18e26bc2 Add T4 bit map compression routines
Add bit map encoder and decoder functions: decoder is fully functional
while encoder is good enough for testing - no backtracking to find
the best possible compression is implemented. If somebody is willing to
implement MS side of EDGE than this has to be expanded.
Add corresponding tests.
N. B: the encoding is implemented according to ETSI TS 44.060 which is
slightly different from T4 used for fax according to CCITT G31D (RFC 804).

Ticket: OW#2407
Sponsored-by: On-Waves ehf

Signed-off-by: Max <msuraev@sysmocom.de>
2016-02-18 19:45:44 +01:00
Max 0a59e9899f Expand bitvec interface
Add bit filling, shifting and other functions necessary for bit
compression implementation. Add corresponding tests.
2016-02-18 19:45:40 +01:00
Neels Hofmeyr 8684714966 Add CSCN ctrl port defs 2016-02-15 12:02:02 +01:00
Neels Hofmeyr 620dfa6be2 add vty port nr for osmo-cscn 2016-02-10 13:28:00 +01:00
Holger Hans Peter Freyther 5710804a42 bivec: Fix the output of the testcase
osmo_hexdump_nospc/osmo_hexdump is an old school C routine with a
static internal array. This means that printf will most likely one
of the two strings twice. For Linux/glibc this is the first string
(for whatever reason?) and for FreeBSD it is the last call of the
osmo_hexdump_nospc. We could have noticed by both strings being
of the same length besides the different length input. The second
issue is that we cast a hexstring to uint8_t and dump the string
as hex. So the two strings should not match at all.

Fix it by printing the hex string as plain hex and separating the
two printf calls. Update the test output.
2016-01-30 16:19:33 +01:00
Holger Hans Peter Freyther a9301a1a1f bitvec: Test and fix regression for C++->C conversion
bitvec_read_field/bitvec_write_field in the PCU used a C++ reference
and when porting to C it was decided to pass the parameter by value
and this lost the "back propagation" of the new index. Change the
parameter to be an in/out parameter and this way do not have a silent
semantic break in the osmo-pcu (where we copy the reference in csn.1
by value) and have a true compile failure.

Add Max's simple test for bitvec_unhex function leaving the checking
of bitvec_read_field and the side effect in the datastructure about
the number of bits still open.
2016-01-30 10:54:43 +01:00
Max 912bc6ff50 Add doxygen comments to clarify function use 2016-01-30 10:18:38 +01:00
Holger Hans Peter Freyther 2745b48940 bitvec: Fix build on older gcc
bitvec.c: In function 'bitvec_unhex':
bitvec.c:389: error: 'for' loop initial declarations are only allowed in C99 mode
bitvec.c:389: note: use option -std=c99 or -std=gnu99 to compile your code
2016-01-27 17:08:02 +01:00
Max a15f05f1b4 Add bitvec-related functions from Osmo-PCU
Allocation, pack/unpack, field access and helper routines used
extensively by Osmo-PCU. Whenever memory allocation happens, alocator
context is passed explicitly by caller.
2016-01-26 11:01:23 +01:00
Holger Hans Peter Freyther fdb4667609 test: Fix compiler warnings on 64bit systems
Use %td to print ptrdiff_t use %zu to print size_t,
include time.h on FreeBSD. Some more compiler warnings are
left but they require more thinking.
2015-11-09 16:46:03 +00:00