Commit Graph

1268 Commits

Author SHA1 Message Date
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
Holger Hans Peter Freyther 777b056fb4 gprs-ns: Re-initialize the list head and free the unknown_nsvc
Fix re-initialize issue of the GPRS NS. This was found while
working on the GB Proxy tests.

==27800== Invalid write of size 4
==27800==    at 0x403C263: rate_ctr_group_alloc (linuxlist.h:65)
==27800==    by 0x4050974: gprs_nsvc_create (gprs_ns.c:209)
==27800==    by 0x405320D: gprs_ns_instantiate (gprs_ns.c:1330)
==27800==    by 0x804B212: main (gbproxy_test.c:797)
==27800==  Address 0x434173c is 52 bytes inside a block of size 784 free'd
==27800==    at 0x4029DA8: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==27800==    by 0x4041BBD: _talloc_free (talloc.c:609)
==27800==    by 0x40432B2: talloc_free (talloc.c:578)
==27800==    by 0x40532D3: gprs_ns_destroy (gprs_ns.c:1363)
==27800==    by 0x804B1FE: main (gbproxy_test.c:791)
2014-07-07 20:00:35 +02:00
Holger Hans Peter Freyther eb55e6aa88 write_queue: Use EBADF instead of EBABDFD for portability
EBADFD is linux specific while EBADF is POSIX. Fix the build on
FreeBSD and use EBADF throughout the file.
2014-07-01 19:42:49 +02:00
Daniel Willmann 77ab2f723e vty: Avoid use-after-free in VTY telnet interface
If the read callback closes the connection conn is already freed so we
can't derefernce it. Instead return -EBADFD in the read function if it
closed the connection and check for that.
2014-06-22 16:57:22 +02:00
Holger Hans Peter Freyther 17aa6b25cb osmo-auc-gen: Fix compiler warnings about aliasing
I ran "./utils/osmo-auc-gen -2 -a COMP128v1" and verified that
the RAND doen't look empty

Fixes:
osmo-auc-gen.c: In function ‘main’:
osmo-auc-gen.c:219:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   *(uint32_t *)&_rand[0] = rand();
   ^
osmo-auc-gen.c:220:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   *(uint32_t *)(&_rand[4]) = rand();
   ^
osmo-auc-gen.c:221:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   *(uint32_t *)(&_rand[8]) = rand();
   ^
osmo-auc-gen.c:222:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   *(uint32_t *)(&_rand[12]) = rand();
2014-06-22 16:53:55 +02:00
Daniel Willmann bd8a89debc write_queue: Avoid possible use-after-free if fd is read-/writable
If the FD is both readable and writable and the read callback closes the
connection (and frees the surrounding structure) we shouldn't call the
write callback (or check anything else in the read fd).

With this patch callback functions can return -EBADFD if they don't want
the FD to be handled any more.
2014-06-22 16:40:59 +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 26ea7068e7 tests/bits: Make sure all 'inline' are also static
Not doing so seems to break the BSD build

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 15:57:36 +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 ece46d2a43 Add missing entry in .gitignore for utils_test
Submitted-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 14:34:22 +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
Sylvain Munaut e28bc6876d build: Add .version to EXTRA_DIST
This is required to make distcheck work and apparently that's
the "good way" to do it.

See http://comments.gmane.org/gmane.comp.lib.gnulib.bugs/27780

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-15 18:47:03 +02:00
Holger Hans Peter Freyther da73aa640e gsm0411_smr: Fix the size of the array
The code is lacking a "," at the end of a string and we ended up
doing string concatination instead of having an invalid state.

Fixes Coverity CID 1206564
2014-05-23 08:51:22 +02:00
Holger Hans Peter Freyther 61d33925a0 gsm0411_smr: Make the look-up table static 2014-05-23 08:49:34 +02:00
Holger Hans Peter Freyther 8e5435a864 timer: Use the now parameter when it is not NULL
The code would have used an uninitialized current_time in case
"now" was not NULL. As now is const and timersub expects a non
const parameter I decided to copy now into current_time.

Fixes: CID #1040661
2014-05-23 08:37:02 +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
Holger Hans Peter Freyther 92e1e70dba select: Fix english in comment 2014-05-15 21:40:15 +02:00
Holger Hans Peter Freyther c2c042dfd7 backtrace: Speculative fix for FreeBSD10.0 and execinfo.h
FreeBSD 10.0 ships an execinfo.h but one needs to link to an
additional library for the backtrace functions. Check if there
is a backtrace symbol in libexecinfo and if so link to that
library.
2014-04-17 23:19:10 +02:00
Holger Hans Peter Freyther 0c50b17a26 Release: Prepare the release of 0.6.6 2014-03-31 15:40:46 +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
Alexander Chemeris cc0645b26d sms: Add missing brackets in the relative validity time calculation. 2014-03-26 19:35:33 +01:00
Holger Hans Peter Freyther d0ed9218bc Merge remote-tracking branch 'daniel/lapdm-desync'
This should fix long delays when sending a long SMS on an encrypted
channel. It is the most minimal change to the polling mode. One
option we discussed internally is to queue a higher level representation
and generate the actual LAPDm frames later.
2014-03-26 18:15:57 +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 09129352f9 tests/lapd: Add a testcase to check for LAPDm sync issues
Regression test for LAPDm recording the current state
2014-03-26 14:53:29 +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 e4c50d5a43 sms_test: Do not crash on logging. 2014-03-20 22:02:46 +01:00
Holger Hans Peter Freyther 1512ea6452 lapd: Improve log message and mention the SAPI the dl is on
When debugging an issue that involves SAPI=0 and SAPI=3 the
log file does not have enough context. Add the SAPI to this
message so we at least understand which SAPI we are talking
about.
2014-03-16 23:59:58 +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
Holger Hans Peter Freyther 4b3de6840e Merge branch 'jerlbeck/fixes/ladp-sms' 2014-03-10 15:00:20 +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 7d5f17aa21 lapd/test: Check for empty ACCH queue, too
This just adds a single test to verify that the ACCH queue is
actually empty.

Sponsored-by: On-Waves ehf
2014-03-04 13:34:38 +01:00
Jacob Erlbeck c893c2233a lapd/test: Extend test case to test msgs having data before l2h
Since e.g. the IPA input driver leaves it's specific header in front
of msg->l2h, so that msg->l2h != msg->data. The lapdm code does not expect this at least in
rslms_rx_rll_est_req().

This patch modifies the test program to add a dummy L1 header to
generated messages (unless the test would abort when doing so).

Note that the ok file reflects the current state which is not
correct.

Sponsored-by: On-Waves ehf
2014-03-04 13:34:38 +01:00
Jacob Erlbeck 2462cf6ee1 lapd/test: Show dequeued messages
This adds and uses a wrapper for lapdm_phsap_dequeue_prim() that
prints information about the message that has been taken from the
queue.
2014-03-04 13:34:38 +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
Holger Hans Peter Freyther 10f0bdecad lapd: Use the right struct for the talloc_zero_array call
I saw this while playing with talloc pools and wondered why
lapd_core is creating a log_info. Use the right struct for
the array.
2014-02-09 20:05:17 +01:00
Holger Hans Peter Freyther f4f5a8489c sms: The msg_ref is passed from the outside so remove the wrong fixme 2014-02-08 15:15:40 +01:00
Jacob Erlbeck 90937fe2c5 lapd/test: Add test case for RSL EST REQ -> LAPD
This test case processes RSL establish requests for SMS (SAPI 3)
on the SDCCH and the SACCH channels. The TX queues are checked
after processing each message.

Ticket: SYS#192
Sponsored-by: On-Waves ehf
2014-01-26 08:39:20 +01:00