Commit Graph

93 Commits

Author SHA1 Message Date
Harald Welte 09d635ce9b hnbgw: Add missing break statement
We don't want to print usage information after the VTY reference XML.

Change-Id: Ia729134a8f18d53274bbc063aa39508c7dcc1f72
2021-02-24 09:00:01 +01:00
Pau Espin ff8c223440 Workaround ASan report memleak during call to --vty-ref-xml
For some unknown reason, using size=0 instead of 1 makes LeakSanitizer
report a leak when calling osmo-hnbgw --vty-ref-xml:
"""
==19857==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 96 byte(s) in 1 object(s) allocated from:
    #0 0x7f083b4d0d28 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.3+0xc1d28)
    #1 0x7f083a8e5661 in talloc_named_const (/usr/lib/x86_64-linux-gnu/libtalloc.so.2+0x6661)
"""

It seems iu_client.c is already using size=1.

Change-Id: I383653c981e68a053babd33dee1f0df8731752b0
2021-02-23 19:55:03 +01:00
Pau Espin 79d001fcb6 hnbgw: Avoid re-defining same global variable twice
This global variable is already defined in iu_client.c provided by
libosmo-ranap (and used by libasn1c).
Fixes ASan warning at starutp.

Change-Id: I7dbae83ce0dc4ac25dc10879e223280414f7b561
2021-02-23 19:08:48 +01:00
Harald Welte d24839fea0 main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
Change-Id: If07b00e928fbecc596a7f75fc55e811bd9199b72
Depends: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Relates: OS#5041
2021-02-23 17:44:47 +01:00
Harald Welte f05c5bf6cd hnbgw: Use LOGHNB() to add log context information to log lines
So far we don't really have any way of matching a given log message
to a specific hNB.  Let's use the newly-introduced LOGHNB() macro.

Change-Id: Ia16eed4ca5e9ef231259e94c65105f7586f366bc
2021-02-03 08:45:04 +00:00
Harald Welte c6d93452b2 hnbgw: Introduce LOGHNB() macro for log context information
So far we don't really have any way of matching a given log message
to a specific hNB.  Let's introduce a new log macro, together with
a configuration directive to select whether the hNB-ID or the
UMTS CellID shall be used.

Change-Id: I6113925216c6f88add2c6d27bdf47ccbb017f293
2020-12-30 14:23:54 +01:00
Harald Welte dc529f3d78 hnbgw: use OSMO_STRLCPY_ARRAY() instead of open coding it
Change-Id: I4c539168597187408c31b906fd57844e0f165c9b
2020-12-30 14:23:54 +01:00
Pau Espin 4875f09f85 hnbgw: Mark SCTP conn as NODELAY
We don't want messages to be sent being delayed.

Related: OS#4499
Change-Id: I333e7f868e426f7d7ebb328ea2a441d769ea8ebd
2020-10-12 16:04:18 +02:00
Pau Espin 9074d91451 Change default SCTP conn NULL->127.0.0.1 to localhost->localhost
"127.0.0.1" is changed to "localhost" to let local NSS decide whether to
use IPv4 or IPv6. In newish systems, IPv6 ::1 will be selected since
IPv6 takes precedence over IPv4.

Similarly, the default source addr needs to be changed from NULL to "localhost"
since for some yet unknwon reason, getaddrinfo(AF_UNSPEC, NULL) returns
first IPv4 "0.0.0.0" and later "::", which is inconsistent with
getaddrinfo("localhost") result, resulting in src=IPv4(0.0.0.0) and
dst=IPv6(::1), which is incompatible and will fail. In any case, since
the default remote address is a local one and it's the client side,
there's no real logical change since the kernel would anyway should have
taken a local address anyway.

Change-Id: I3c07e6aa0c87b752c9ea22eb4936f6993de6571f
2020-08-21 18:07:26 +02:00
Philipp Maier 554dbf4fb7 hnbgw: do not use LOGL_DEBUG as default loglevel
The hnbgw application uses LOGL_DEBUG for all its log categories. This
is way to verbose, lets set LOGL_NOTICE as default loglevel instead.

Change-Id: If3dbed88307814764bab9e7f1821e1dc0d8be43b
Related: OS#2577
2020-04-14 13:19:52 +00:00
Vadim Yanitskiy 11a1639b2d osmo-hnbgw: make sure osmo_ss7_init() executed successfully
Change-Id: Ia9ecf903e79b282aa4fa88a291424681d0fe9d89
Fixes: CID#206089
2020-01-01 14:05:57 +01:00
Harald Welte cc0914d018 exit(2) on unsupported positional arguments on command line
Change-Id: Id33caf93325074f9e5b2b322ac497b1c21c3f406
2019-12-03 21:53:08 +01:00
Pau Espin 965d53348e hnbgw: Add libosmoctrl's VTY CTRL command initialization
Otherwise, the "ctrl" VTY node is not available and CTRL ip address
cannot be set.

Change-Id: I73f64b951690ec23f829c4855b2caeefa66ad35d
2019-09-20 17:21:23 +02:00
Pau Espin 92ea15a53f Remove undefined param passed to {logging,osmo_stats}_vty_add_cmds
Since March 15th 2017, libosmocore API logging_vty_add_cmds() had its
parameter removed (c65c5b4ea075ef6cef11fff9442ae0b15c1d6af7). However,
definition in C file doesn't contain "(void)", which means number of
parameters is undefined and thus compiler doesn't complain. Let's remove
parameters from all callers before enforcing "(void)" on it.

Change-Id: I31a286bebe3229671d9960ae32a753d260a26b1d
Related: OS#4138
2019-08-05 14:49:35 +02:00
Neels Hofmeyr f8d5f37c20 osmo-hnbgw: set a proper talloc ctx for logging
Change-Id: I006103d8d7fb15e2612fff619879940d8405e045
2019-03-04 22:41:14 +01:00
Neels Hofmeyr 3c839966b6 osmo-hnbgw: fix cmdline: do not force-disable colored logging
Un-jam the commandline option to disable color: it is so far stuck in
--disable-color and overrides everything so that we never see any colored
logging from osmo-hnbgw, whichever cmdline or cfg we pass.

Change-Id: I00400b626925fa9da707ad6679d8448941dbfa98
2019-03-04 22:38:59 +01:00
Stefan Sperling 319c28581e add a VTY command which shows a specific HNB
Add the 'show hnb NAME' VTY command which displays just
one specific HNB, addressed by its identity string.
This augments the functionality provided by 'show hnb all'.

Change-Id: Iab12aa4ab090b72c472358b84daf6919b30747f6
Related: OS#2774
2018-10-31 12:18:02 +01:00
Neels Hofmeyr b876b421e3 hnbgw: vty: add SCCP related vty commands
Depends: I214ea51fc6bfa2a9a4dd7c34b43add0c77ffe22e (libosmo-sccp)
Change-Id: I2f81e078d7a26dd39f8ff9d0f9273ee1a3434232
2018-09-27 03:35:15 +02:00
Alexander Couzens ad4ea3b10e hnbgw: remove close_cb() to fix a crash when releasing a hnbgw
The read callback should catch all errors already.
Previous when a read fails it:

* hnb_context_release() -> osmo_stream_srv_destroy() -> hnb_context_release()
On the second hnb_context_release() the hnbgw will crash because calling
llist_del() twice on the same object.

Fixes: OS#3416
Change-Id: Ic84b2184b7fc850c0de2acacf179e86771e17510
2018-07-24 19:08:19 +02:00
Stefan Sperling c964a2cfa1 ensure unique CellIDs in HNB-GW
If we receive a HNB-REGISTER-REQ with a cell ID which is already used
by another registered NNB, log an error and send HNB-REGISTER-REJECT.

Tested manually by running two 'hnb-test' programs concurrently (they
need to listen on different telnet ports; this port is hard-coded so
I compiled two different hnb-test binaries).
Then I issued the 'hnbap hnb register' command on the telnet interface
of each, and verified that the correct action is logged by osmo-hnbgw.
Both hnb-test programs can connect, but only one of them can register
at a time. Killing a registered 'hnb-test' program terminates its
connection and allows the previously rejected one to register.

The new rejection log message looks like this:
 hnbgw_hnbap.c:429 rejecting HNB-REGISTER-REQ with duplicate cell
 identity MCC=901,MNC=99,LAC=49406,RAC=66,SAC=43947,CID=182250155
 from (r=127.0.0.1:42828<->l=127.0.0.1:29169)

This change depends on a new API in libosmo-netif, which is added in
https://gerrit.osmocom.org/#/c/6844/

Change-Id: Iffd441eb2b6b75dfbe001b49b01bea015ca6e11c
Depends: I8ed78fe39c463e9018756700d13ee5ebe003b57f
Related: OS#2789
2018-02-22 20:29:06 +00:00
Max bfeea6713b Expand ctrl interface
Add commands to get number of connected HNBs and identity string of
connected HNB based on Cell ID.

Change-Id: I3a2d6fa3d6d0829ccee4ecc0998d9299c97820e9
2017-12-31 11:02:07 +00:00
Max ef727410b2 Add control interface
* add libosmoctrl dependency
* bind control interface

Change-Id: I4637e88da00bac1ab0237c29ac73806d024863ba
2017-12-31 11:02:07 +00:00
Max 1e57ba503e Use proper package version
Use actual application version instead of hardcoded "0".

Change-Id: I8711b9d819454d810291d57b97119d9fe4a47f8e
2017-12-28 12:27:41 +01:00
Neels Hofmeyr 4e2681df26 osmo-hnbgw: startup: log the RNC-Id that is going to be used
Change-Id: I8aeb93fe8037e5fdc0784f5fc3bdb527de3b76bd
2017-12-25 00:46:12 +01:00
Neels Hofmeyr ade7e8b19b hnbgw: use proper talloc ctx for vty telnet init
Change-Id: I355c6e5489f24566612528cd679c5cab21eed008
2017-12-20 16:00:11 +00:00
Neels Hofmeyr 2c56f6d454 hnbgw: use proper VTY port number defined in libosmocore (4261)
We used to have hardcoded 2323 from early development, use the proper
libosmocore definition instead.

Depends: Ife52a968a41cb286f640006587877971ff66c1a4 (libosmocore)
Change-Id: Id67d89695ebdc6288f507338c15ad773b8adf6e4
2017-12-20 13:57:54 +00:00
Neels Hofmeyr accb78000b osmo-hnbgw: don't configure specific local IP address for STP connection
It's not necessary to set a local IP to connect to OsmoSTP with, 'any' is as
good as any.

Related: OS#2663
Change-Id: If5d0a1500de5e2c4b80acf025761d0264a8a51a0
2017-12-04 15:39:17 +01:00
Harald Welte da86fe5ae3 Fix various compiler warnings in hnb-gw code
Since we finally started to use -Wall, the related warnings became
visible.

Change-Id: I516700eab2aa7c3412dd62775c4960aed9d4b682
2017-11-21 11:08:56 +00:00
Harald Welte ee69470da6 hnbgw.c: Remove dead code creating libsctp linker dependency
Since I8ac15fa2fd25bedb26297177e416976a5389b573 in July 2017 we are
not using sctp_*() functions directly anymore but go via
libosmo-sigtran.  However, some dead code remained in hnbgw.c, which
means that linkage will fail if compiled without any optimization,
i.e. without -O present.

Change-Id: Ifbcb21d43e17bf512bc7b219e590410e06c434ca
2017-11-21 08:25:52 +01:00
Neels Hofmeyr ecbdc5cb06 make point codes configurable by SCCP address book
In the vty config, use the SCCP address book to configure the local and remote
SCCP addresses. Add VTY commands to set the remote SCCP addresses by name,
derive the ss7 instance from these addresses:

  cs7 instance 1
   point-code 0.23.0
   sccp-address msc
    point-code 0.0.1
   sccp-address sgsn
    point-code 0.0.2
  hnbgw
   iucs
    remote-addr msc
   iups
    remote-addr sgsn

Enforce that both IuCS and IuPS use the same ss7 instance. In the future, we
may add the feature to use two separate instances.

Depends: libosmo-sccp I75c67d289693f1c2a049ac61cf2b2097d6e5687d,
         Ie1aedd7894acd69ddc887cd65a8a0df4b888838c,
         I85b46269dbe7909e52873ace3f720f6292a4516c

Change-Id: I33a7ba11eb7c2d9a5dc74d10fb0cf04bf664477b
2017-08-09 15:30:14 +02:00
Neels Hofmeyr 0f88c11009 migrate osmo-hnbgw to libosmo-sigtran's SCCP/M3UA
libosmo-sigtran now has a "proper" SCCP/M3UA stack, so we can make our hnb-gw
3GPP compliant by switching from the old SUA code to the new universal SCCP
user API with support for (currently) M3UA and SUA.

Main changes:

Use one cn_link to STP: We will connect to the core network using an (Osmo)STP
instance that routes to MSC and SGSN, so we want one SCCP link instead of two.
The only difference between IuCS and IuPS is a different remote osmo_sccp_addr.

This has various effects through the messaging code; the patch is a bit larger
than I would like, but it is hard to separate out truly independent smaller
changes.

CS or PS domain was previously flagged in the separate cn_link, as ctx pointer
for two separate sccp_sap_up()s. Now there's just one such ctx, so determine
is_ps from the RANAP Domain Indicator, or from the conn's hnbgw_context_map:

- Add is_ps to context_map_alloc_by_hnb().
- To find a matching context, the RUA ID alone is no longer sufficient, also
  match is_ps (possible optimization todo: separate lists).

We would send separate CS or PS Reset messages based on the cn_link, instead
send both CS and PS Reset at the same time for the single cn_link. This could
be adjusted to detect presence of MSC or SGSN instead.

Pending: adjust the VTY config to reflect that there is only one remote
address. Place a TODO comment for that.

Smaller changes:

rua_to_scu(): populate called and calling addresses for N_CONNECT and
N_UNITDATA.

Remove DSUA.

Don't build dummy_cn, which is still implemented on SUA. Mark todo to maybe
re-include it based on M3UA later.

In hnbgw_cnlink, place sccp related items in a separate sub-struct.

Do not keep an llist of cn_links, just have the one. Remove iteration and list
management.

Change jenkins script to build libosmo-sccp master.

Patch-by: hwelte, nhofmeyr
Change-Id: I8ac15fa2fd25bedb26297177e416976a5389b573
2017-07-05 13:04:15 +02:00
Harald Welte e08cdd92a6 ue_context_alloc(): Avoid ue->imsi without NULL termination
Change-Id: I152e84206e0b2b80fa79956f5adbbe84ff10b4ab
Fixes: Coverity CID 57625
2016-11-26 00:04:44 +01:00
Neels Hofmeyr 5ee050c1e7 hnbgw: parameterize IuCS and IuPS ips and ports: add vty cmds
Basically copy-paste the Iuh local-ip and local-port code to provide
parameterization of the IuCS and IuPS remote addresses.

Add IUCS and IUPS nodes, enhance go_parent_cb and config writing accordingly.

Change-Id: I2c28977011009df4e1fa472290bbbc359e406971
2016-10-27 14:01:25 +02:00
Neels Hofmeyr c510fc29fc hnbgw: vty: set explicit go_parent_cb
A second level of depth will be added to the hnbgw node soon, which will need
explicit go-parent logic.

Change-Id: I8d1c18a396c215e8425ae49872b5c73316087d7d
2016-10-27 14:01:25 +02:00
Neels Hofmeyr 6e3e594ee3 hnbgw: cosmetic: local-ip config: drop getter function
Use the g_hnb_gw->config.iuh_local_ip directly, drop hnbgw_get_iuh_local_ip().

Change-Id: Ie91aea82ae5d128ad735a0857ea814b440c3232c
Suggested-by: hwelte
2016-10-27 13:43:03 +02:00
Neels Hofmeyr c7ccdd490f cosmetic: hnbgw: addr related renames, move define, move comment
Prepare for parameterization of IuCS and IuPS addresses:

Conform internal variable naming to local-ip, local-port, remote-ip,
remote-port (instead of bind-ip).

Rename HNBGW_IUH_LOCAL_IP_DEFAULT to HNGGW_LOCAL_IP_DEFAULT to be more general
and move it to the top.

Move a function doc comment to the .c file.

Change-Id: Ice85941c978498e3ddf41d151248507e7f56cb5d
2016-10-13 15:17:06 +02:00
Neels Hofmeyr 4ff1a5a957 fix msgb talloc context initialization
Properly initialize msgb talloc context in hnbgw and all tests, using the new
msgb_talloc_ctx_init().

test-ranap.c: since msgb talloc ctx is now in test_common_init(), remove msgb
talloc init here.

Change-Id: I807c799aff1239184728551ed77fdafa73bd683f
2016-10-13 04:17:40 +02:00
Neels Hofmeyr 39ee926062 hnbgw: vty conformance: rename iuh 'bind' command to 'local-ip'
The standard osmo VTY terminology is 'remote-ip', 'remote-port', 'local-ip',
'local-port'. Conform to that. osmo-hnbgw is so far not rolled out widely, so
it makes sense to do this now.

Change-Id: Ifda2653bf58044552a5f1477cd7008dec3fb9100
2016-09-27 05:55:55 +00:00
Neels Hofmeyr 0476e2854e log: hnbgw: add hnbap UE context allocation info log
Change-Id: Iac0ca948d6e699d984c6e424afe7106dcaf2ab1e
2016-09-27 05:55:55 +00:00
Neels Hofmeyr f33e8358cc hnbgw: UE context: add handling by tmsi identification
To prepare for an upcoming commit that accepts TMSI identification upon UE
Register Requests:

Add tmsi arg to ue_context_alloc().
Add ue_context_by_tmsi().

This is aimed at the ip.access nano3G femto cell, as it apparently feeds
whichever identification the UE sends through to HNBAP (TMSI+LAI, pTMSI+RAI),
instead of an IMSI as expected.

See the upcoming commit that enables accepting TMSI identities for further
detail.

Change-Id: I138458443319cc4cbea5ee7906cf5dd72d582130
2016-09-27 05:55:55 +00:00
Neels Hofmeyr c83e49fc8d log VTY telnet bind only once
After libosmocore 55dc2edc89c1a85187ef8aafc09f7d922383231f which outputs
'telnet at <ip> <port>' from telnet_init_dynif(), there's no need to log the
telnet VTY bind here anymore.

Change-Id: Icd9e670c1d30c156f7bd5d0d34892150aeba95e9
2016-09-26 22:44:18 +02:00
Neels Hofmeyr df63de2e37 build: move headers to include/osmocom/*
This came up while fixing 'make distcheck'; this is certainly not the easiest
way but it makes sense to have the headers in include/, like we do in openbsc.

The easy alternative might be to add -I$(top_srcdir)/src to src/Makefile.am.

Remove -I$(top_srcdir)/src from src/tests/Makefile.am, no longer needed.

Change-Id: I5a82e029dcdc4df0a60a31271a4883393fe59234
2016-09-09 06:43:32 +00:00
Neels Hofmeyr f495b2347b hnbgw: make Iuh bind address configurable via VTY
Add config node hnbgw/iuh/bind, taking an IPv4 address.

Use this address to bind the Iuh server.

This is particularly useful for the ip.access nano3G, which is very sensitive
with SCTP addresses that don't respond to SCTP heartbeats. If the hnbgw listens
on 0.0.0.0, there will be SCTP heartbeats for all local interfaces on the
machine that the hnbgw runs on; the nano3G will interpret the "missing", or
rather, redundant heartbeat acks for the interfaces that aren't really related
to the Iuh server and assume a broken Iuh link, leading to an Iuh shutdown and
reconnection, looping every minute or so. By binding the hnbgw to only one
local interface, the SCTP addresses can be reduced and "missing" heartbeat acks
can be avoided.

Change-Id: Ie2749c152b878e17aa65dfb806826357d5c494f1
2016-08-18 03:21:22 +02:00
Neels Hofmeyr 4d8eb4cbd7 hnbgw: move vty commands out to new hnbgw_vty.c
Pass g_hnb_gw and tall_hnb_ctx to hnbgw_vty_init() as they are no longer
statically available.

Change-Id: If85c1b97a240bd1dcf9f367ea6fca857d542ab22
2016-08-18 03:21:22 +02:00
Neels Hofmeyr 1d03f19e06 hnbgw: make cmdline options stronger than config file
Now that a config file gets parsed after the command line options, e.g. the
'logging timestamp 0' config item is stronger than a -T commandline option. So
rather store the cmdline options to take effect after config file parsing.

This adds a stupid 'log_disable_color = true' reverse boolean logic, which is
unavoidable if we want to use the same default cmdline options as osmo-nitb /
osmo-cscn.

Change-Id: I16ad55b173a443c36b71dc6b70f58695f6665312
2016-08-18 03:18:03 +02:00
Neels Hofmeyr 085cd67672 hnbgw: add config file and -c cmdline option
Change-Id: I6ac9fa17b35260031c55aab664124d466f60c937
2016-08-18 02:37:11 +02:00
Neels Hofmeyr 4d675a7df9 hnbgw: add cmdline arg parsing with default options
Default options taken from osmo-nitb:

    -h --help                  This text.
    -d option --debug=DHNBAP:DSUA:DRUA:DRANAP:DMAIN  Enable debugging.
    -D --daemonize             Fork the process into a background daemon.
    -s --disable-color
    -T --timestamp             Prefix every log line with a timestamp.
    -V --version               Print the version of OsmoHNBGW.
    -e --log-level number      Set a global loglevel.

Change-Id: I931cee01c605c1b507c16041ada226cf963ea433
2016-08-18 02:36:03 +02:00
Neels Hofmeyr 4c45d2b9fd hnbgw: add copyright to vty_info
Change-Id: I702b606837199ab64c3590546900d4d30357b919
2016-08-18 02:35:57 +02:00
Neels Hofmeyr 0a43722a48 fix compiler warnings with new libosmo-sccp: rename to osmo_sccp_*
See libosmo-sccp.git 1a3875092f93df3c3054d26eac52bb0ea9bd09c3

Note: at time of commit, osmo-iuh still depends on the libosmo-sccp sysmocom/iu
branch to build.

The same rename has been committed to both sysmocom/iu and master on
libosmo-sccp. Above commit hash is on sysmocom/iu. The master commit is
03ad002c28073b347b92bcde16d5af80a06389e4.

Change-Id: Id9c0065d7398a6205ff24477d47c9663caac669c
2016-07-12 00:51:21 +02:00
Neels Hofmeyr 0a461568f0 hnbgw: dumb fix of context map hnb_list double delete 2016-05-01 15:45:26 +02:00