Commit Graph

447 Commits

Author SHA1 Message Date
Harald Welte d54c2ee8c5 initial checkin of 'libosmosim' 2014-10-26 19:09:22 +01:00
Harald Welte cac3cd6fcd msgb: make msgb_get() finally work as expected 2014-10-26 19:08:43 +01:00
Jacob Erlbeck 0540d839ac gprs-ns: Let gprs_nsvc_reset return a value
Currently gprs_nsvc_reset does not return any value.

This patch changes the function to return an integer, where a value
less than zero indicates an error. The value is taken from the
gprs_ns_tx_reset function. In case of failure, an error message is logged.

Sponsored-by: On-Waves ehf
2014-10-09 07:47:20 +02:00
Harald Welte fb84f325b8 logging: Add ability to save/print current log filters
This enables the persistent configuration of let's say
'log filter imsi 012345678' for a given log file in the config
file.
2014-08-25 10:09:42 +02:00
Harald Welte 276ca4b172 gsm48.h: define the reserved TMSI in libosmocore, not openbsc 2014-08-24 17:35:19 +02:00
Harald Welte f39aed6942 add port number 4238 for BTS control interface 2014-08-24 16:52:54 +02:00
Harald Welte 39c9e7b471 libctrl: Add support for 'deferred control commands'
Sometimes a control interface command cannot be processed
and responded immediately, but we need to process it asynchronously.

In order to support this, we introduce the 'ctrl_cmd_def', which
represents such a deferred command.  It is created by the service
implementing the command using ctrl_cmd_def_make(), and a response is
later sent using ctrl_cmd_def_send().

ctrl_cmd_def_is_zombie() must be called to handle the case where
the control connection has disconnected/died between receiving the
command and sending the response.
2014-08-24 16:52:54 +02:00
Harald Welte 5ddd435919 Convert recently-introduced header files to #pragma once 2014-08-21 15:42:44 +02:00
Harald Welte c7947ed1f6 New <osmocom/ctrl/ports.h> file listing tcp ports for CTRL interface 2014-08-21 15:34:19 +02:00
Harald Welte ae2fcb22cf rename controlif_setup() to ctrl_interface_setup()
which means that all control interface related functions now have
the common ctrl_ prefix.
2014-08-21 15:34:19 +02:00
Harald Welte 528134b01c libctrl: Move bulk of control node lookup inti libosmoctrl
The control interface user now only has to register a very short
node lookup function callback.  This function is optional, and only
required if hierarchical command lookup should be supported.
2014-08-21 15:34:18 +02:00
Harald Welte c78e74e3d0 libctrl: remove 'struct gsm_network' references
libctrl doesn't need any knowledge about the type of the user-private
data that it gets passed upon setup time and includes on callbacks.
2014-08-21 15:34:18 +02:00
Harald Welte d8db92c578 libctrl: remove bsc-specific declaration
this was moved by accident when importing the code from openbsc.
2014-08-21 15:34:18 +02:00
Harald Welte 3ff81b1a6b libctrl: autotools build system integration
Now we actually build the recently-imported libctrl
2014-08-21 15:34:18 +02:00
Harald Welte 7fd0c830d9 libctrl: Add DLCTRL as logging context for the control interface
... and make libctrl code use it
2014-08-21 15:34:18 +02:00
Harald Welte f3c7e85d05 libctrl: remove reference to bsc_replace_string()
... and rather introduce a general osmo_talloc_replace_string() to
libosmocore.
2014-08-21 15:34:17 +02:00
Harald Welte 1238cc64d7 libctrl: remove openbsc headers, convert from make_sock to libosmocore 2014-08-21 15:34:17 +02:00
Harald Welte dda4225153 libctr: rename/move control interface to libosmocore naming scheme 2014-08-21 15:34:17 +02:00
Harald Welte 28570a4e62 new <osmocom/vty/ports.h> file listing VTY tcp ports
imported from http://openbsc.osmocom.org/trac/wiki/PortNumbers
2014-08-21 15:34:11 +02:00
Harald Welte e391996947 ipa: rename functions for consistency
As we are breaking builds by moving functions from libosmo-abis to
libosmocore anyway, we might as well give functions more appropriate
names.  ipaccess is a company, while IPA is the multiplex protocol, and
CCM is the protocol used for establishing identities on the IPA
multiplex.
2014-08-20 23:16:36 +02:00
Harald Welte 28aa991c2f import various generic IPA related functions from libosmo-abis
libosmo-abis is about forming A-bis interfaces/lines by means
of E1 or the IPA multiplex (or possibly other link layers).

The IPA multiplex is used in other contexts, such as the Control
interface, or the A interface.  In that context, it makes sense to
have generic IPA related functions in libosmocore.
2014-08-20 23:16:34 +02:00
Harald Welte fe3e42bdcb Add osmo_get_macaddr() function to obtain etherent mac address
This used to be private in osmo-bts/common/abis.c, where it really
didn't belong.
2014-08-18 19:19:45 +02:00
Harald Welte 40d56f96b9 osmocore: Add function osmo_macaddr_parse() to parse ETH MAC address 2014-08-18 19:03:40 +02:00
Harald Welte cc27fa6479 TLV: add TLVP_PRES_LEN() definition to check for existance + minimum length
This is an import from osmo-bts where it was introduced in
6b561bb7ba5f10c5fd96542a7e42de2822352a67
2014-08-18 15:31:04 +02:00
Harald Welte 900e180f91 ipaccess.h: Add IPAC_PROTO_EXT_ORC for OML Router Control 2014-08-18 11:34:17 +02:00
Harald Welte 8d5180e003 abis_nm: add abis_nm_msg_disc_names[] value_string 2014-08-17 19:36:26 +02:00
Harald Welte 604d552e49 abis_nm: introduce abis_nm_{osmo,ipa}_magic[]
... used to be oml_{osmo,ipa}_magic in osmo-bts
2014-08-17 18:42:58 +02:00
Harald Welte 92107dfd3b update TS 08.08 header + TLV definitions to TS 48.008 / 11.7.0
This adds support for A-over-IP and LCLS related message/IEI
definitions.

Old definitions are in decimal, which is very hard (at least for me)
to compare with the binary tables in the spec.  Hex is much easier
to manually compare for completeness/correctness.  I didn't touch
the existing definitions, but think they should move to hex, too.
2014-06-21 23:16:20 +02:00
Harald Welte c8585cf408 update gsm_08_08.h to Release 11 2014-06-21 22:28:12 +02:00
Sylvain Munaut 5469ef837a core/bitXXgen: Don't do 'return' in functions returning void
ISO C forbids 'return' with expression, in function returning void

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 16:39:08 +02:00
Sylvain Munaut 3baa0d6ab5 core/bitXXgen: Use explicit cast of void* to uint8_t
Turns out we use this header in C++ code ...

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 16:38:31 +02:00
Sylvain Munaut 579a7103a1 gsm: Add Kasumi cipher implementation
Submitted-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 14:59:30 +02:00
Max e2c1390d1b bits: Add left circular shift function
Submitted-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 14:36:37 +02:00
Max 5377701746 core: Add generic LE/BE load/store uint type convertors and use them in msgb
Submitted-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 14:33:27 +02:00
Sylvain Munaut 12ba778afd include: Switch to #pragma once pattern
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 10:17:27 +02:00
Max b0a3c2f1de gsmtap: add LTE defines to GSMTAP v2
Submitted-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-15 18:52:55 +02:00
Álvaro Neira Ayuso 550b06c04c abis_nm: Add the abis_nm_osmo_att_tlvdef to the abis header
Avoid compiler warnings and declare the presence of the new
tlv_description.

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-05-20 08:45:59 +02:00
Harald Welte 5b5650f3de Fix introducing osmocom speficic OML attributes
Rename NM_ATT_O_REDUCEPOWER to NM_ATT_OSMO_REDUCEPOWER, which
makes it more clear that this is an osmcoom specific attribute.

Also, we cannot simply overload 0x01 as an already defined OML
attribute.  The problem is quite simple: When we use abis_nm_att_tlvdef
during the TLV parse, 0x01 will match to NM_ATT_ABIS_CHANNEL,
which is defined as { TLV_TYPE_FIXED, 3 }.

So instead, we need to introduce a new abis_nm_osmo_att_tlvdef[],
which has to be patched into abis_nm_att_tlvdef[] by the means of
tlv_def_patch(), exactly how we do it for bs-11 and nanobts specific
attributes.

I'm using 0xfe for the attribute, as 0xfe doesn't overlap with the IPA
specific attribues (and we might want to combine/merge the 12.21 plus
IPA plus osmocom spefici attributes)
2014-05-19 11:25:46 +02:00
Álvaro Neira Ayuso c22d72cded protocol/gsm_12_21.h: Add the Manufacturer Attribute ID O_REDUCEPOWER.
Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-05-15 21:40:59 +02:00
Álvaro Neira Ayuso 5ade61a4f4 src/socket: Adding unix domain socket support
Added some function for adding the unix domain socket support.

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-03-26 19:50:46 +01:00
Daniel Willmann 3dc4e16786 gsm/lapdm: Prevent LAPD tx_queue from filling up in polling mode
If LAPDm receives an I-Frame while there already is an I-Frame in the
tx_queue the code generates an additional RR (to acknowledge the
received I-Frame). Instead, N(R) of the I-Frame in the tx_queue should
be updated to ACK the data.
2014-03-26 18:11:07 +01:00
Daniel Willmann 55405fb40b lapdm: Make lapdm_datalink_for_sapi public
This API allows you to get the lapdm_datalink for a SAPI. It's needed in
the lapdm_test, so make it public.
2014-03-26 13:52:27 +01:00
Alexander Chemeris e47523874d sms: Fix typo in a macros name: GSM340_SMS_RESSERVED -> GSM340_SMS_RESERVED. 2014-03-12 13:33:01 +01:00
Jacob Erlbeck 8dac4159ad ladpm: Fix msgb handling and SAPI=3 establishment delay
Currently it takes 3s to establish a SAPI 3 SACCH connection with
osmo-bts. This is due to the fact, that a broken SABME request is
sent first and and is ignored by the MS. Then, after a T200 timeout
(2s) the SABME command is sent again (this time correctly) and
answered by the MS.

The first SABME message is broken (it has a length field of 3 and
ends with 3 bytes from the tail of the original RSL message),
because of it is expected throughout lapdm.c that msg buffers
containing RSL have msg->l2h == msg->data. Some abis input drivers
fulfill this but IPA doesn't, thus the 3 bytes of the IPA header
are still part of the msg and confuse length computation.

Since internal fields of the msg are modified directly, this is
difficult to see.

This patch adds a new function msgb_pull_to_l3() that explicitely
skips over all headers prepending L3 and therefore resets l1h and
l2h. This function is then used instead of msgb_pull_l2h() which
only worked correctly when msg->l2h == msg->data. In addition,
code manipulating msg->tail and msg->len directly has been replaced
by calls to msgb_trim().

Note that this patch does not fix all issues of this case in the LADP
related code.

Ticket: SYS#192
Sponsored-by: On-Waves ehf
2014-03-10 14:57:26 +01:00
Jacob Erlbeck baa225ed86 msgb: Add msgb_hexdump() function
This function works like osmo_hexdump() and returns a static buffer
containing hex bytes along with markers for the layers.

Note that it uses osmo_hexdump() internally, thus a call to
msgb_hexdump() invalidates the buffer that has been returned by an
earlier call to osmo_hexdump(). In short: don't mix them in a single
call printf().

Sponsored-by: On-Waves ehf
2014-03-04 13:30:12 +01:00
Jacob Erlbeck 26cbd459fc sms: Fix gsm_7bit legacy functions return value
The legacy 7bit conversion functions (those without the '_n_' in the
name) gave wrong return values on 64 bit platforms due to unproper
signed/unsigned conversions and the usage of SIZE_MAX.

This patch fixes this by using a smaller max size (see
GSM_7BIT_LEGACY_MAX_BUFFER_SIZE, currently set to 64k) for the legacy
wrappers and by using unsigned int for max_septets.
In addition, there are tests now that check the return values of
legacy encoding and decoding.

Sponsored-by: On-Waves ehf
2014-01-09 08:22:14 +01:00
Holger Hans Peter Freyther d4d87c5427 abis: Use the right return value for abis_nm_pchan4chcomb
abis_nm_pchan4chcomb will return a pchan for a given channel
combination but returned a value of the channel combination.

Fix it to return the physical channel combination.

Fixes: Coverity CID 1040767
2014-01-02 14:10:25 +01:00
Max 4f0abc0e3e Refactor COMP128v23 implementation and add test suit 2013-12-07 18:10:38 +01:00
Kevin Redon be355cd78a implement COMP128 version 2 and 3 A3/A8 algorithm
simple copy into C from reversed code from www.hackingprojects.net
2013-11-03 15:05:25 +01:00
Jacob Erlbeck 5405a104bb gb: Fix NS RESET/RESET_ACK abnormal cases
This changes the implementations for the reception of RESET and
RESET_ACK to be compatible with 3GPP TS 08.16, 7.3.1:

- Just send a RESET_ACK with correct values back to the SGSN when a
  RESET with an invalid NSVCI or NSEI has been received.
- Check RESET_ACK for matching NSEI and NSVCI.
- Ignore unexpected RESET_ACKs.

In addition, use RESET_ACK from a BSS to update the BSS source
address based on the NSVCI to be tolerant with changing UDP source
addresses/ports.

Sponsored-by: On-Waves ehf
2013-10-24 10:01:18 +02:00