Commit Graph

1296 Commits

Author SHA1 Message Date
Daniel Willmann 9f97316fcf ctrl: Improve error handling if controlif setup fails 2014-08-21 15:34:14 +02:00
Daniel Willmann 35a1b3b493 libctrl: Add function ctrl_cmd_send_to_all
Sends a command to all ctrl connections except the one it originated
from.
2014-08-21 15:34:14 +02:00
Daniel Willmann f2e75d4371 libctrl: Add trap helper function 2014-08-21 15:34:14 +02:00
Daniel Willmann 782974b6c9 libctrl: Change controlif_setup so it returns the ctrl handle
nat: Catch up with controlif_setup API change
We now save a control handle reference in the nat
osmo-bsc: Catch up with controlif_setup API change
We now save a control handle reference in the gsm network
2014-08-21 15:34:14 +02:00
Daniel Willmann 0e0cf37c44 libctrl: Keep track of connections in struct ctrl_handle 2014-08-21 15:34:13 +02:00
Holger Hans Peter Freyther ad6451fc98 misc: Use other size modifiers to fix compiler warnings
control_if.c:521:2: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat]
osmo_bsc_bssap.c:473:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘unsigned int’ [-Wformat]
mgcp_main.c:162:4: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformatt]
2014-08-21 15:34:13 +02:00
Alexander Huemer 1d3634e0cb libctrl: only free() msgb if it was alloc()ed
Before this patch a SIGABRT was caused when doing e.g.:
$ ncat 127.0.0.1 4249
^C
2014-08-21 15:34:13 +02:00
Alexander Huemer 4376bcc1b0 fix some "implicit declaration" warnings in osmo-nitb 2014-08-21 15:34:13 +02:00
Holger Hans Peter Freyther a6b34015af libctrl: Add a function to create the cmd 2014-08-21 15:34:13 +02:00
Daniel Willmann 9225ab1ecc libctrl: Don't overwrite error reply if the verify function sets one 2014-08-21 15:34:13 +02:00
Daniel Willmann f7c74e5879 libctrl: Mark the cmd set/get/verify functions static 2014-08-21 15:34:13 +02:00
Daniel Willmann b06dd3010f libctrl: Bind control interface to localhost 2014-08-21 15:34:13 +02:00
Holger Hans Peter Freyther 19abc95970 libctrl: Use DCTRL as logging destination in libctrl 2014-08-21 15:34:12 +02:00
Pablo Neira Ayuso 10dfc26e8f src: port openBSC over libosmo-abis
This is a big patch that ports openBSC over libosmo-abis.
Sorry, the changes that are included here are all dependent
of libosmo-abis, splitting them into smaller pieces would
leave the repository in some intermediate state, which is
not desired.

The main changes are:

- The directory libabis/ has been removed as it now lives in
  libosmo-abis.

- new configuration file format for nanoBTS and HSL femto, we
  need to define the virtual e1_line and attach it to the OML
  link.

- all the existing BTS drivers (nanoBTS, hsl femto, Nokia site,
  BS11 and rbs2000) now use the new libosmo-abis framework.

- use r232 input driver available in libosmo-abis for bs11_config.

- use ipa_msg_recv instead of old ipaccess_read_msg function.

- delete definition of gsm_e1_subslot and input_signal_data.
  These structures now lives in libosmo-abis.

Most of this patch are deletions of libabis/ which has been
moved to libosmo-abis.

This patch also modifies openBSC to use all the new definitions
available in libosmocore and libosmo-abis. In order to do that,
we have replaced the following:

- DINP, DMI, DMIB and DMUX by their respective DL* correspondences.
- SS_GLOBAL by SS_L_GLOBAL
- SS_INPUT by SS_L_INPUT
- S_GLOBAL_SHUTDOWN by S_L_GLOBAL_SHUTDOWN
- SS_INPUT by SS_L_INPUT
- S_INP_* by S_L_INP_* sub-signals
- E1INP_NODE by L_E1INP_NODE vty node

This patch has been tested with:
- one nanoBTS
- the HSL femto with the examples available under libosmo-abis
- BS11 with both dahdi and misdn drivers.
2014-08-21 15:34:12 +02:00
Daniel Willmann 0834a34063 libctrl: Use inttypes.h macros to make uint64_t printfs portable. 2014-08-21 15:34:12 +02:00
Harald Welte 18b70b5b81 controlif: declare controlif_setup() in control_cmd.h
this avoids us to copy+paste external declarations over all 'main'
files.
2014-08-21 15:34:12 +02:00
Daniel Willmann 8b7a9626a2 libctrl: Add ctrl_cmd_cpy() to copy a command 2014-08-21 15:34:12 +02:00
Daniel Willmann e9f5894e2c libctrl: Add commands to query counters and rate_cntr
These commands are installed in controlif_setup. Query them like this:
"rate_ctr.<interval>.<counter group>.<index>.<counter name>" for rate
counters and "counter.<counter name>" for regular counters. <interval>
may be either "abs" for absolute values or one or
"per_{sec,min,hour,day}".

It is possible to query all rate counters in a group (regardless of
index) or all counters in a group and with a certain index if you omit
<counter name> and <index> or just <counter name>.
2014-08-21 15:34:12 +02:00
Daniel Willmann fcf010f721 libctrl: Add macros to help define commands 2014-08-21 15:34:12 +02:00
Daniel Willmann 1264cb404f Add libctrl, an SNMP-like control interface
In contrast to the VTY interface the control interface is meant to be
used by programs.
This patch adds basic support, no commands are defined.
2014-08-21 15:34:11 +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
Holger Hans Peter Freyther 715e945055 gsm0808: Fix copy and paste pointed out by clang
The element following the identifier list was the
GSM0808_IE_LSA_INFORMATION. It is a TLV type as well
and the issue got introduced in
92107dfd3b.

Fixes:
gsm0808.c:316:40: warning: initializer overrides prior initialization of this subobject
      [-Winitializer-overrides]
                [GSM0808_IE_LSA_IDENTIFIER_LIST]        = { TLV_TYPE_TLV },
                                                            ^~~~~~~~~~~~
gsm0808.c:315:40: note: previous initialization is here
                [GSM0808_IE_LSA_IDENTIFIER_LIST]        = { TLV_TYPE_TLV },
2014-08-21 14:19:37 +02:00
Holger Hans Peter Freyther efe0100189 macaddr: Add some code for FreeBSD (it should work on the others too)
There doesn't seem to be a way to share this code with Linux as
it doesn't have the sockaddr_dl concept inside the getifaddrs.

I manually verified this on a FreeBSD10 box and hex decoding gave
me the correct mac address and rc was 0.
2014-08-21 14:19:37 +02:00
Harald Welte f196a02a65 ipa: use %z as format string whne printing sizeof() result
thanks to Holger for reminding me
2014-08-21 09:42:03 +02:00
Harald Welte 11bca8b8aa ipa: fix compiler warning regarding printf (%d -> %lu) 2014-08-21 02:39:48 +02:00
Harald Welte 78b0868302 macaddr: add #include unistd.h for close() function
this fixes a compile warning
2014-08-21 02:38:34 +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
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