wiki:libosmocore

libosmocore

libosmocore is a library with various utility functions that were originally developed as part of the OpenBSC project, but which are of a more generic nature and thus useful to (at least) other programs that we develop in the sphere of Free Software / Open Source mobile communications.

There is no clear scope of it. We simply move all shared code between OsmocomBB and OpenBSC in this library to avoid code duplication.

To build osmocom-bb it is mandatory to install libosmocom in advance.

Browsing its source code

You can do that using our cgit installation at http://cgit.osmocom.org/cgit/libosmocore/

Obtaining it

To obtain libosmocore, you can use the following git URL:

git clone git://git.osmocom.org/libosmocore.git

Compiling and installing it

To compile and install it as standalone:

cd libosmocore/
autoreconf -i
./configure
make
sudo make install
cd ..

Licensing

This library is GPL licensed, as the code is taken from the similarly GPL-licensed OpenBSC codebase.

This means you cannot use this library from non-GPL licensed code without infringing copyright!

Features

Select loop abstraction

This is implemented in select.[ch] and enables you to build complex asynchronous/non-blocking I/O programs in a single thread.

Message buffer handling

Inspired by the Linux kernel struct sk_buff, this is our message buffer struct msgb implementation. It provides handling of packet buffers, putting them in queues, prepending and appending data to it, etc.

Bitvector

A convenient set of routines to deal with bit-vectors in C. This was originally written for rest-octet parsing.

TLV handling

The GSM Layer3 and above are full of TV / TLV / TL16V and other data fields. Our implementation provides parser and generator functions, tightly coupled to struct msgb

Timers

Provides a timer core where you can register timers with a callback function. The function is called when the timer expires.

COMP128v1-3

A COMP128v1 implementation by Sylvain Munaut and COMP128v23 is included.

Rate Counter

Provides infrastructure for maintaining rate counters, i.e. counters that can be incremented and will also keep track of the rate of events per second, minute, hour and day. A group of rate counters is defined as an abstract class, from which you can then allocate instances. The class description includes information about the counter names.

Protocol helper code

GSM utils

  • conversion functions for ARFCN, RxLevel?, 7bit GSM character set, power level, frame numbers, ...

GSM 04.08

  • extensive header files for the GSM 04.08 (Layer 3 RR/MM/CC) messages
  • TLV parser definitions to parse the optional IEs
  • utility functions such as
    • human readable strings for RR cause names
    • converting GSM Mobile Identities (MI) to string and back
  • encoding and decoding functions for call control IEs

GSM 08.08 (A Interface)

  • API to wrap 04.08 messages in BSSMAP/DTAP message
  • TLV parser definitions

GSM 08.58 (A-bis RSL)

  • header file with structure and enum definitions for GSM 08.58 protocol
  • TLV parser definitions for RSL optional IEs
  • human readable strings for RSL Error values and RLM cause values
  • encoding and decoding of RSL channel number

GSM 12.21 (A-bis OML)

  • header file with structure and enum definitions for GSM 12.21 (and 08.59) protocol

GSM 04.11 (SMS)

  • header file with structure and enum definitions for GSM 04.11 (SMS RP and CP layers) protocol

Talloc memory allocator

The talloc memory allocator from the Samba project is (optionally) part of libosmocore. It provides hierarchical memory allocation and extensive debugging features such as dumping the currently allocated objects (at runtime) to the console.

Logging framework

A generic logging implementation, supporting a dynamic number of 'log targets', understanding the notion of log levels and log categories. Filtering based on levels and categories is implemented in the core, while context-specific filtering can be implemented by the application using libosmocore.

  • logging with various log levels for various subsystems inside the application
  • logging to stderr, syslog or application-defined targets
  • runtime reconfigurable per-subsystem log levels
  • timestamping of log lines
  • colorized log output

Write Queue

This is a write queue implementation on top of libosmocore's select loop abstraction. It allows you to simply say "write this msg_buff to this file descriptor as soon as the file descriptor is writable".

Development Cycle

As we are still developing the GSM protocol stacks on the network side (OpenBSC) and phone side (OsmocomBB), every so often there is a need to add some new code to libosmocore. Even worse, we sometimes need to break the API and ABI of the library.

However, by keeping libosmocore in a separate git repository, we run into one problem: Checking out an old version of e.g. OpenBSC or OsmocomBB will result in failed builds, as we don't remember which old version of libosmocore was required. This makes debugging and things like git bisect very hard to impossible.

In order to solve this problem, we use git-subtree to import the full libosmocore.git repository into OsmocomBB.

This way, we ensure that there is always a compatible version of libosmocore inside the tree if we check out old OsmocomBB versions from git.

Making changes to libosmocore

NEVER COMMIT CHANGES DIRECTLY TO osmocom-bb.git:src/shared/libosmocore

Instead, use the following process:

  1. make your changes to your local copy of libosmocore
  2. test them together with OsmocomBB and OpenBSC
  3. test if libosmocore still builds for both host and target (ARM)
  4. create a diff of your local libosmocore changes
  5. apply that diff to the libosmocore.git repository
  6. use the script in osmocom-bb.git/src/shared/update-libosmocore.sh (uses git-subtree) to import your changes from libosmocore.git
  7. test + commit your OsmocomBB changes that depend on the newly introduced code to libosmocore

It is important that the steps are followed in the order state above to ensure consistency of our repositories

Last modified 4 months ago Last modified on Jun 4, 2014, 10:52:34 AM