Commit Graph

55 Commits

Author SHA1 Message Date
Pau Espin bc7c69d170 hnbap: Use specific prefix for HNBAP generated code
Other libraries already use ASN1C_PREFIX except the HNBAP one. Let's use
it here to avoid collisions.

All new include/osmocom/hnbap/HNBAP_*.h and src/hnbap/HNBAP_*.c are
generated using the updated src/hnbap/Makefile.am.
Files such as src/*.c, test/* and include/osmocom/hnbap/hnbap_common.h
are modified manually to update structs/enums to new prefix.

Related: SYS#5516
Change-Id: I6c062f631527ae42811bfec134933671c05ecba6
2021-10-26 16:42:07 +02: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
Pau Espin a008b17f2e Fix compiler warning on signedness of char ptr using OCTET_STRING_fromBuf()
rua_msg_factory.c:19:48: warning: pointer targets in passing argument 2 of ‘OCTET_STRING_fromBuf’ differ in signedness [-Wpointer-sign]

Change-Id: Ie0a2e8e11902dc56720ff8121edde0e148fa587a
2020-03-20 20:32:26 +01:00
Neels Hofmeyr 39d7b5c646 osmo-hnbgw: logging tweaks
Log about:
- sending RESET messages to CN;
- accepting a new hNodeB peer on HNBAP.

Change-Id: I317831dbc6c463e4d4dcde9e6716431e026c4398
2019-03-08 05:10:48 +01:00
Harald Welte 9aad185151 hnbgw_tx_hnb_register_rej(): Missing return statement
Change-Id: I0bdee8ede9ffdc16c16a4f5723acb7b4bceb2158
Fixes: Coverity CID#188869
2018-10-21 11:46:14 +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
Neels Hofmeyr 2293df070c hnbap: log errors on decoding/encoding HNB-REGISTER msgs
Change-Id: I3c039267fa2cc047c5678bcfe4a603f70c21cdd1
2018-01-18 19:01:09 +01:00
Neels Hofmeyr 8a2b6e2b6f cosmetic: hnbgw: hnbap: log rx of unsuccessful outcome
HNBAP isn't really that important to osmo-hnbgw operation, all we do is service
the few requests so that the other side is happy and uses our Iuh.
Nevertheless, could at least log if an UnsuccessfulOutcome was received.

Change-Id: I3f309dc2d3436798e9e76bcc2ebd82403ea538a1
2018-01-15 23:40:38 +01:00
Neels Hofmeyr 02296af07d hnbgw_hnbap: fix missing return in rx [un]successful outcome
Fixes: CID#57732 CID#57733
Change-Id: Iddf76d23c2c7d5824e82708f7da013c88411e832
2018-01-15 23:30:57 +01:00
Neels Hofmeyr 66d6d760aa hnbgw: hnb info: record MCC, MNC, show on 'show hnb'
Before, MCC and MNC were always reported as zero, now the output of 'show hnb all' looks like:

  OsmoHNBGW> show hnb all
  HNB "000295-0000154153@ap.ipaccess.com" MCC 901 MNC 70 LAC 11111 RAC 99 SAC 65535 CID 1048575
     HNBAP ID 0 RUA ID 0

Change-Id: Iae094b36fa1cf18e07ed33914b9425368d7cd34b
2017-12-20 23:17:57 +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
Neels Hofmeyr a6a68e62d9 fix error rc in various ASN.1 decoding functions
Fixes: CID#57945, CID#57946, CID#57947, CID#57948, CID#57950, CID#57951
Change-Id: I2d9ee1aa79959c5973041393f4769faa13720898
2016-11-27 18:27:33 +00:00
Neels Hofmeyr 12181a937f hnbap: accept UE Register Requests with TMSI and pTMSI
Add the option to allow UE Register Requests with a TMSI identity.
Add VTY command to enable this option, 'hnbap-allow-tmsi'.
Add hnbgw_tx_ue_register_acc_tmsi().

HNBGW so far keeps track of UEs that have registered, with their IMSI. When a
UE registers with only a TMSI, we obviously can't store an IMSI. However, since
we're so far never *using* the list of UEs in osmo-hnbgw, we might as well just
accept the TMSI registration and carry on as usual. All that is needed for
proper operation is a valid UE context.

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. So far this caused failures and the need to
make the UE clear its TMSI (wait several minutes or attempt to subscribe to a
different network), so that UE registration switched back to IMSI. When simply
accepting the TMSI in osmo-hngw, no problems are apparent in our current code
state.

For example, a Samsung Galaxy S4 seems to send a UE_Identity_PR_tMSILAI (CS
identity), and a GT-I9100 seems to send a UE_Identity_PR_pTMSIRAI (PS identity)
upon first registration to the network.

Recording the IMSI in hnbgw: we could use the subscriber list during paging, to
page a UE on only its last seen HNB. On the other hand, it doesn't hurt to
anyway always page to all HNBs connected to osmo-hnbgw. The paging procedure
does include a page-to-all-HNBs in case the first HNB paging fails. But we must
be aware that UEs that register by TMSI will simply not have an IMSI recorded
in the list of UE contexts, so a lookup based on IMSI may fail.

Patch-by: Harald Welte <laforge@gnumonks.org>, me
Change-Id: I87bc1aa3e85815ded7ac1dbdca48f1680b468589
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 c94ed09f50 hnbap: add UE Register Reject for pTMSIRAI identity
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.

Sending a proper registration reject speeds up the response seen on the UE and
avoids needless waiting.

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

Change-Id: I03b69613e6ddd8a08d9358ffc2f74954c231fd2c
2016-09-27 05:55:55 +00: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 8345792281 build: fix ranap gen, use same for gen hnbap and rua gen
fix extraneous rebuild for each make invocation: touch the ranap.stamp file in
src/ as the make target suggests.

fix for 'make distcheck': ranap gen: move generated sources to builddir, not
srcdir. Thus we also -I the builddir include to pick up those headers.

hnbap and rua have the same situation as ranap (they generate numerous files
from a single make rule). Use the same makefile semantics for those two
(commit for ranap gen omitted the same changes for hnbap and rua).

The generated headers are thus moved to include/osmocom/*/, so adjust #include
statements accordingly (*_common.h, *_ies_defs.h).

Also move hnbap_common.h to include/osmocom/hnbap and rua_common.h to
include/osmocom/rua, since the *_ies_defs.h want to include them; and since
*_ies_defs.h are now in include/osmocom/*, we want a '<foo>' include now.

Also adjust gitignore.

Change-Id: I32213666fcdfc144008fa7d46497c0938d093e86
2016-09-09 06:43:31 +00:00
Neels Hofmeyr 1a0bb5108c UE Register with TMSI: reply with a Register Reject
When receiving a UE Register Request with TMSI and no IMSI, compose a
Register Reject with the same UE Identity and send.

The accepting function expects a ue_context argument and composes the
message from the IMSI found there. This new rejection message cannot rely
on a ue_context struct and hence uses the asn1 uE_Identity directly.

Change-Id: Ia47e398e50e316842cd260dc0d9a4e2d8a1c627c
2016-09-09 06:34:24 +00:00
Neels Hofmeyr b248c8c8ca UE Register: fix: free ies when no IMSI is found 2016-04-25 15:34:28 +02:00
Neels Hofmeyr 9246cc9e1e cosmetic: comments, log typo, explicit pointer
Fix log typo 'REGSITER' and add some comments on UE Register with TMSI.

The container_pair struct starts with 'list', so passing the container_pair
pointer is equivalent to passing the list; but instead, explicitly mention the
list member to avoid confusion.
2016-04-25 15:25:12 +02:00
Daniel Willmann 0118839829 Revert "hnbgw_hnbap: Zero IEs_t before decode is called"
This reverts commit a8b6b1e3a1.
Zeroing is now done inside of the decode function
2016-01-12 10:14:11 +01:00
Daniel Willmann a8b6b1e3a1 hnbgw_hnbap: Zero IEs_t before decode is called
This ensures that presenceMask is zero and optional fields will be freed
correctly.
This needs to happen for ranap and rua as well.
2016-01-07 18:01:06 +01:00
Daniel Willmann d10002cf8d asn1tostruct: Add memory free functions and use them in HNBAP 2016-01-07 12:27:41 +01:00
Daniel Willmann b433b97474 hnbgw_hnbap: Handle hnb deregister message as well 2016-01-07 11:01:15 +01:00
Daniel Willmann 6480cadd8e hnbgw: Use libosmo-netif for SCCP connection handling 2016-01-07 11:01:12 +01:00
Neels Hofmeyr 96979af054 move ranap_*.h,iu_helpers.h to include/osmocom/ranap/
A bit hacky: the ranap_ies_defs.h is generated together with the
ranap_encoder.c and ranap_decoder.c. See comments in src/Makefile.am and
include/osmocom/ranap/Makefile.am.
2016-01-05 15:37:23 +01:00
Harald Welte 056984fab1 merge (+rename) iu_helpers.c into libosmo-ranap 2016-01-03 16:31:31 +01:00
Harald Welte 706213ac4b Fix typo / spelling mistakes 2015-12-25 10:33:09 +01:00
Harald Welte 2963ee2505 hnbgw_hnbap: Print HNBAP Cause during UE De-Register 2015-12-25 10:32:37 +01:00
Harald Welte c4338deee9 hnbgw: Bring all parts together
We now have the RUA and SUA parts interconnected by the
context ID mapper, and should be able to pass messages back and forward
between both sides.

Unfortunately this touches a bit of everything, but the structures are
all still very much in flux.  Hopefully they will start to stabilize at
some point soon...
2015-12-24 00:41:45 +01:00
Harald Welte ffa7c0ad39 use msgb_sctp_ppid() from libosmo-netif, remove local declaration 2015-12-23 00:04:05 +01:00
Daniel Willmann 541e429a39 hnbgw_hnbap.c: Clean up after encoding a UE register accept
Need to free the ASN.1 structs after using them to encode the UE
register accept message.
2015-12-22 16:40:46 +01:00
Daniel Willmann 5f810f4222 hnbgw_hnbap: Initialize return value and always return something 2015-12-17 17:57:51 +01:00
Daniel Willmann 59d17d8961 hnbap: Free ASN.1 components after they are no longer needed 2015-12-17 17:56:56 +01:00
Daniel Willmann bded9841b5 hnbgw: Change logging priorities and add HNBAP category
Log hnbap messages to the HNBAP category. Change MAIN category to only
log INFO and above and change SCTP notification message to debug.
2015-12-17 13:09:18 +01:00
Daniel Willmann efceb187aa hnbgw_hnbap: Process UEDeRegister and try to free correct UE 2015-12-17 13:09:18 +01:00
Daniel Willmann 9224731379 asn1helpers: Fix 24 bit conversion function and use it in hnbgw_hnbap
The 32 bit int needs to be shifted left one byte so the correct bytes
end up at the beginning of the bit string buffer.
2015-12-14 10:36:36 +01:00
Daniel Willmann d6a45b402c asn1helpers: Add 28 bit conversion function and use it for Cell ID
The padding bits in the bit string are at the end and the byte-order is
MSB-first. This means the number needs to be shifted left so the padding
bits are the least significant.
2015-12-14 10:21:51 +01:00
Harald Welte 77847ad020 add copyright statement and AGPLv3 headers to source code files 2015-10-06 22:07:04 +02:00
Harald Welte 6286880caa the Context ID is a 24bit number, we cannot use len = 4 bytes! 2015-09-18 01:23:55 +02:00
Harald Welte 1d2c39d83b various cleanups (compiler warnings, coding style) 2015-09-11 17:49:37 +02:00
Harald Welte 393f2bd9fb move BCD string encoding/decoding functions to iu_helpers.[ch] 2015-09-11 17:13:51 +02:00
Harald Welte 3af1db87ed hnbap: Print error messages in error cases 2015-09-11 17:03:16 +02:00
Harald Welte 10dfc5a97d respond to HNBAP UE REGISTER REQ withe correspnding ACCEPT
The Accept incudes the IMSI that the phone presented, but
somehow we fail to encode the Context ID as bitstring,  see
../pcap/20150911-hnbap-ue_register.pcap
2015-09-11 01:36:44 +02:00
Harald Welte b534e5c085 introduce ue_context management
We keep one 'ue_context' structure for every UE that we see
a UE REGISTER REQUEST for.
2015-09-11 00:15:54 +02:00
Harald Welte 7b54e32c63 hnbap: Don't enqueue a NULL msgb for transmit 2015-09-07 22:41:45 +02:00
Harald Welte 3f71256750 Use implement HNBAP transmit using per-hnb write_queue 2015-09-07 22:25:35 +02:00
Harald Welte 2204f9d43d hnbgw: zero-initialize the output struct before aper_decode()
asn1c has this strange behavior that the _output_ struct must be
zero-initialized.
2015-09-07 22:25:35 +02:00
Harald Welte 27f9c4ab4b migration of code from ffasn1c to asn1c + asn1tostruct.py 2015-08-30 22:48:59 +02:00