Compare commits

...

3154 Commits

Author SHA1 Message Date
Oliver Smith a13cc20c98 doc: set state-dir to /var/lib/osmocom/osmo-sgsn
Be consistent with osmo-ggsn, and set the state dir to
/var/lib/osmocom/osmo-sgsn. Without this patch, it defaults to the
current directory, which means in case of running with the systemd
service, /var/lib/osmocom.

Copy osmo-sgsn.cfg and osmo-sgsn-accept-all.cfg to the tests dir and do
not set the state-dir there. Usually the user that runs the VTY and CTRL
tests is not allowed to write to /var/lib/osmocom. (I've also tried
generating these on the fly, but that breaks in 'make distcheck', as I
would need to write to the source dir or would need to change
osmo-python-tests etc. to read the config file from another directory.)

Related: osmo-ggsn I5b51529b4f8bd2462e54f58a1ce2e2d7c76ff46a
Depends: osmo-python-tests Ic312d546da1c21f68a80b6a188616ef9bc84f4c6
Change-Id: I309807ff0bc125d4653222b2b4ba69ded3bbff70
2024-05-27 14:36:01 +02:00
Oliver Smith 1fd4a4c135 debian/osmo-gtphub.init: delete
Remove SysV init scripts. These are not really maintained anymore and
this makes it consistent with other Osmocom projects.

Avoids synchronizing with SysV scripts on debian:
  # systemctl enable osmo-gtphub
  Synchronizing state of osmo-gtphub.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
  Executing: /usr/lib/systemd/systemd-sysv-install enable osmo-gtphub

Change-Id: I9008944369314a4cbb345bfbf01bdb57aa7590fb
2024-05-22 13:33:52 +02:00
Oliver Smith b3ce06058c sgsn/sgsn_vty: create state-dir
Prepare to change the state-dir in the default config in a follow-up
commit. Create the directory if it does not exist.

Change-Id: I8db4898cdaa2fcbd6bbf7c543764b9cdf828de83
2024-05-16 10:50:56 +02:00
Oliver Smith 0a6fe9727f debian/postinst: add checks, be verbose
Do not attempt to change permissions/ownership if the package gets
upgraded from a version higher than the next release.

Do not fail if the user deleted the config file.

Be verbose when changing permissions.

Related: OS#4107
Change-Id: I2b01a7625cf66fbb7d203f939ddcc1cbab43cf33
2024-05-14 15:21:06 +02:00
Oliver Smith 7ba62d3061 contrib: remove rpm spec file
Related: https://osmocom.org/news/255
Related: OS#6446
Change-Id: I9e7a3beb861faab1b6852aa5b57847c590986976
2024-05-13 08:39:35 +00:00
Vadim Yanitskiy 62b28ffe1b VTY: sync default UMTS UEA config with osmo-msc
As was reported in OS#6442, nano3g S16 is unhappy when CS and PS
domains use different UEA configuration for simultaneous RANAP
connections.  Bring osmo-sgsn in sync with osmo-msc to avoid this.

Change-Id: I4eb9451b4267fc1436ed90a55ff200cf36f16bf6
Related: OS#6442
2024-05-09 10:50:08 +02:00
Vadim Yanitskiy cdf716cf9a VTY: move default settings to sgsn_instance_alloc()
It's cleaner to have all configuration defaults in one place.

Change-Id: I1a439dcc76272a181986b6ec9368ef16441dc098
Related: OS#6442
2024-05-09 10:48:29 +02:00
Oliver Smith a9c39c04de .deb/.rpm: various fixes related to non-root
* Explicitly chown /var/lib/osmocom to osmocom:osmocom, instead of
  relying on systemd to do it when the service starts up. This does not
  work with the systemd versions in debian 10 and almalinux 8.
* deb: Use "useradd" instead of the interactive "adduser" perl script
  from Debian. This makes it consistent with how we do it in rpm, and
  avoids the dependency on "adduser".
* deb: Consistently use tabs through the file, instead of mixing tabs
  and spaces.
* deb: Remove support for the "dpkg-statoverride --list" logic. This
  seems to be a rather obscure feature to override permissions for
  certain files or directories, for which it does not seem to be a good
  idea to make the postinst script less maintainable. Something similar
  can be achieved by using your own Osmocom config file in a different
  path with different permissions.

Related: OS#4107
Change-Id: I406ff0d625b02991d580c8382aa4be04dba45a00
2024-05-08 06:46:32 +00:00
Vadim Yanitskiy 282de031f1 gmm: mmctx_timer_stop(): warn about timer not running
This turns errors like:

  DMM ERROR MM(262420000000038/e2ff704e) Stopping MM timer 3350 but 0 is running

into warnings with a more accurate reason:

  DMM NOTICE MM(262420000000037/e2ff704e) Stopping *inactive* MM timer 3350

Change-Id: I56ecad9d8f1049974b0896f6d0e7fc61580155ec
2024-05-01 10:44:27 +02:00
Vadim Yanitskiy c3156193da gmm: cosmetic: fix preprocessor macro formatting
Change-Id: I77171d65db23794d8fd9872e0cc4d6f3b50dda0d
2024-05-01 10:44:27 +02:00
Alexander Couzens cd3a8cfad6 docs: front page: use https:// instead of http://
Change-Id: If3c3b8e79f94da7a3bcc9262808da09f6a5a601c
2024-04-28 12:17:10 +00:00
Alexander Couzens e51b3be379 docs: update year to 2024
Change-Id: I85a987eee470d2040c91289d33c5d97c3e90674d
2024-04-28 12:17:10 +00:00
Alexander Couzens b34e0a5720 docs: replace legacy NS with new NS2 chapters
osmo-sgsn already switched to the new NS2 code. Use the correct
NS2 chapter

Change-Id: I9cc86d234e029b5192e36aeb14b0e39d1496842d
2024-04-28 12:17:10 +00:00
Oliver Smith 05363e0a32 contrib/osmo-sgsn.spec: fix build for almalinux:8
Add the missing "%if 0%{?suse_version}" around %service_del/add
commands, as these are only available on opensuse.

Fix for:
  error: line 106: Too many names: %preun  -n osmo-gtphub %service_del_preun   osmo-gtphub.service

Fixes: a07e6d9c (".deb/.rpm: add osmocom user during package install")
Change-Id: I89802f926bfccc0f7b4bb1ff64115b232b1db022
2024-04-26 09:58:51 +02:00
Max a07e6d9c58 .deb/.rpm: add osmocom user during package install
Create osmocom user & group during package installation.
Fix the configuration dir/files permission to match.

Related: OS#4107
Tweaked-By: Oliver Smith <osmith@sysmocom.de>
Change-Id: I55ce205d4b314d01b2641c8f3d52455c051d6282
2024-04-24 11:52:50 +02:00
Harald Welte 1ede89a35a README.md: Add Forum and Issue Tracker sections
Change-Id: I69dfe4124c2a2be30c9ef04e70e3f15d10a2305c
2024-03-23 17:15:07 +01:00
Harald Welte 647304fbe5 README.md: Overhaul (more links; improved formatting)
Change-Id: I0cf9898877aab2f834c886491f4d203d55a8b4b9
2024-03-23 17:07:07 +01:00
Harald Welte 370d6e8b59 Add funding link to github mirror
see https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository

Change-Id: Icf0fd068742eba60c23f0e567e6e72b42063f2c0
2024-03-23 17:03:36 +01:00
Pau Espin dc4c294f94 gsup: Use new libosmogsm struct osmo_gsup_pdp_info fields
This also makes sure it doesn't compile against older libosmogsm gsup
versions which would break ABI.

Change-Id: I0d03d368e73ab62ec631420769f6af91f2ff9987
Related: OS#6091
Depends: libosmocore.git Change-Id 70be3560659c58f24b8db529c4fc85da4bb0ec04
2024-01-29 11:07:03 +01:00
Vadim Yanitskiy f2545b1b8f build: include README.md into the release tarball
Change-Id: Ia467ae8cc6eec0dc9fb36d4c159d2762e965c4f8
2024-01-26 23:37:30 +07:00
Andreas Eversberg 1f1d90f175 Use uniform log format for default config files
Related: OS#6272
Change-Id: I6b6aa5a5100cf0045dcba1b062acc9376d34b0ae
2023-12-01 12:40:54 +01:00
Oliver Smith 2a89bbf66f Bump version: 1.11.0.5-67677-dirty → 1.11.1
Depends: osmo-ggsn I1f116e1cded135f231f22ebc9b817aebf3736fc2
Change-Id: I869eef2032d6025c8ed59a1b25192c6c5c08977e
2023-11-28 13:43:15 +01:00
Daniel Willmann 676777c5f9 libgtp: Check for all successful create_pdp_conf causes
Related: OS#6268
Change-Id: I11ce72908c2dfb983887e6c1db316fd7de42f027
2023-11-23 18:00:07 +01:00
Daniel Willmann ff9c46cc61 vty-tests: Test encryption options
Change-Id: I471c04602dedfb2a80d4408c09125e51c465a8b8
2023-11-22 16:06:43 +01:00
Daniel Willmann 75a0aa78a3 sgsn_vty: Correctly indent encryption cipher-plugin-path
Change-Id: I16b3450c3919bebbceb8d27f73d7c6dde102d0f7
2023-11-22 16:06:43 +01:00
Daniel Willmann 20aef4de28 sgsn_vty: Fix output in config_write_sgsn
The encryption uea option was missing

Change-Id: I2c81ced87c53d69a94b3894441323201f81f1a76
2023-11-22 13:14:25 +01:00
Philipp Maier e746b0bef6 sgsn_rim: forward message based on RIM ROUTING ADDRESS
At the moment we parse the RAN TRANSPARENT CONTAINER to look at the
destination RIM ROUTING INFORMATION. This is not correct. The SGSN
should not decode the RAN TRANSPARENT CONTAINER and use the RIM ROUTING
ADDRESS / RIM ROUTING ADDRESS DISCRIMINATOR IE to make the routing
decision.

Related: OS#6095
Depends: libosmocore.git Ibca1f08906c4ffeecdae80d4e91c6c7b05fe4f8a
Change-Id: Ifd2b915ed2f05130cff8ee77714b82005c17de3d
2023-09-18 21:53:39 +02:00
Pau Espin 57567968ea Bump version: 1.10.0.16-7e4d-dirty → 1.11.0
Change-Id: Ia56d2e1c4247396522f02df2c95b842db655e171
2023-09-12 16:57:03 +02:00
Philipp Maier 7e4dbb4b34 sgsn_rim: do not check the origin of a RIM message
When we forward RIM messages from GTP to BSSGP, we do not have to check
the origin of the message since it does not matter from which origin the
message came when we are forwarding it.

Related: OS#6095
Change-Id: Iea8176dcfe64c25d207bafc0ef61ca9d9ad415be
2023-08-10 10:24:23 +02:00
Philipp Maier 7840375d51 sgsn_rim: get rid of MME check in sgsn_rim_rx_from_gtp:
There is no point in checking the MME any further. When the message has
reached this code path it is about to be forwarded to BSSGP, so the MME
does not play a role in the following code pathes.

The check also relys on the source RIM ROUTING INFORMATION IE inside the
RAN TRANSPARENT CONTAINER, which we are not supposed to decode.

Change-Id: I97c89aeb11537ae54d1fbea48c75619d8a92af61
Related: OS#6095
2023-08-10 10:23:06 +02:00
Philipp Maier 429d332ece sgsn_rim: cosmetic: improve comment
Let's describe more clear what we do in sgsn_bssgp_fwd_rim_to_geran

Related: OS#6095
Change-Id: I54aa82845515bcaa6badc9e0e87fa6248333430e
2023-08-10 10:19:37 +02:00
Philipp Maier f24970a7ca sgsn_rim: fix typo
Related: OS#6095
Change-Id: I86f70ea9a1a3e43523ec327165bfeb1737ad300a
2023-07-28 13:23:49 +02:00
Pau Espin 2365fec0fb gmm: Add missing GSM48_IE_GMM_RX_NPDU_NUM_LIST IE in gsm48_gmm_att_tlvdef
Depends: libosmocore.git Change-Id Ifac09653141758af345efe2eb9cef25ebf4dcff9
Change-Id: I5b43384407b1c9c33790cae9c48c2816213578e6
2023-07-18 17:41:09 +02:00
Pau Espin 5df65b6c30 gmm: Update DRX params during rx RAU REQ
The DRX params where already parsed in GMM Attached Req and transmitted
to PCU over BSSGP DL UD packets, but it was not being updated if the MS
changed it during RAU Req.

TS 24.008 9.4.14.3 DRX parameter:
"This IE shall be included if the MS changes the access network
from GSM to UMTS, or the MS wants to indicate new DRX parameters
to the network."

Change-Id: I1dd7f8f161280dd017c337eacc3aa2be4ccd65ea
2023-07-14 18:11:31 +02:00
Pau Espin 5f1020b963 Write explicit role & sctp-role fields in ASP configurations
Change-Id: I44e251ca2df02e4f1fdfc1492306ec25d0653ef6
2023-06-08 19:34:21 +02:00
Oliver Smith eda1b83f75 systemd: depend on networking-online.target
Related: SYS#6400
Change-Id: Idadcbbf55e976ae035cfac4b85ccd870e0f27b82
2023-05-26 14:10:48 +02:00
Vadim Yanitskiy b83aabaa95 copyright: fix typo: sysmocom s/s.m.f.c./s.f.m.c./ GmbH
Change-Id: Ie2d864d5171e0da2e8a6c8551d151fd14f89bf05
2023-05-18 17:22:26 +07:00
Pau Espin 1bebd08a4b gprs_sm.c: Fix load of misaligned ptr address
Got this Asan runtime error in osmo-sgsn while implementing the MS side of SM:
"""
DMM gprs_sm.c:427 MM(901700000015254/c655d609) -> ACTIVATE PDP CONTEXT REQ: SAPI=3 NSAPI=6 IETF IPv4 /osmo-sgsn/src/sgsn/gprs_sm.c:453:16: runtime error: load of misaligned address 0x61f000064ba3 for type 'uint32_t', which requires 4 byte alignment
0x61f000064ba3: note: pointer points here
 00  06 01 21 00 00 00 00 28  09 27 01 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00
              ^
"""

Change-Id: I8069e3457120b22bb6514fd5d192bff486d7d87f
2023-05-03 11:35:24 +02:00
Oliver Smith a86056fdf3 debian: set compat level to 10
Related: OS#5958
Change-Id: Ib45ad7c44cdefa4c5acab2da09f24796253a133d
2023-04-25 16:48:32 +02:00
Vadim Yanitskiy 99ec755643 tests: $(BUILT_SOURCES) is not defined, depend on osmo-sgsn
Change-Id: I4f9e99ed3673bb51fa5f7d374c35c3c92735eacb
2023-03-30 02:11:21 +07:00
Pau Espin d5dca3a67f gmm: Ciphering Key Sequence Number IE has half octet tag
As per 3GPP TS 24.008:
* 10.5.1.2 Ciphering Key Sequence Number
* Table 9.4.9/TS 24.00

The IE is so far being encoded manually, hence why it worked fine until
now.

Change-Id: Ic220113f30377a14cbe3550a04cd04f3caef49cf
2023-03-22 13:36:35 +01:00
Vadim Yanitskiy 3c26a1dc3c tests: use -no-install libtool flag to avoid ./lt-* scripts
This option should be used for any executables which are used only
for testing, or for generating other files and are consequently never
installed.  By specifying this option, we are telling Libtool that
the executable it links will only ever be executed from where it is
built in the build tree.  Libtool is usually able to considerably
speed up the link process for such executables.

Change-Id: I8af6a38d7abbf06aa8268981c80c3bfda2f80a27
2023-03-11 05:02:17 +07:00
arehbein 642019f288 Transition to use of 'telnet_init_default'
Related: OS#5809
Change-Id: Icc57c68337d55c6594c1c36e9bf41624d11dab0a
2023-02-26 21:16:12 +01:00
Oliver Smith f8a5066ad0 Run struct_endianness.py
Ensure there is no diff to prepare to run this in CI.

Related: OS#5884
Change-Id: I808afd0e9833e6e99d30a37675cbd200ced027e4
2023-02-20 10:51:48 +01:00
Pau Espin 8c42673eba Bump version: 1.9.0.56-07fe-dirty → 1.10.0
Change-Id: I89eb79ffeb28b8dae5b4a5c3cc1142d07052692c
2023-02-07 17:34:27 +01:00
Pau Espin 07feb06d54 Fix extra whitespace in pdpctx_ctr_description
Change-Id: I4d9145c681e725b709fde38f6e9b4516d37b4d8c
2023-01-11 12:58:23 +01:00
Pau Espin 86b630cfe1 vty: Introduce encryption cipher-plugin-path command
The load of plugins will eventually be moved to libosmo-gprs
implementation, and path will be passed as a parameter. Once it's moved
inside libosmo-gprs, it will be more strict on load failures, which can
cause internally if the path doesn't exist (unless NULL is passed).
Hence, add a VTY config to allow configuring the right path, and have it
disabled by default.

Change-Id: I4f965c7afafa193f4d7486750dd3e43cca22bb65
2023-01-11 12:58:23 +01:00
Pau Espin 93bc518b53 Move global mmctx list into struct sgsn_instance
Change-Id: Idf8458902321da03b9b0831dad3ad383a9c7afa1
2023-01-11 12:58:23 +01:00
Pau Espin 58101ea587 Split gprs_sgsn.{c,h} -> {auth,mmctx,sgsn}.{c,h}
Some level of split already existed, like sgsn_auth.c, but headers were
entangled together.
Let's clearly separate application centric code (sgsn.c/h), auth related
code (auth.c/h) and mmctx related code (mmctx.c/h).

Change-Id: I048a082851c1275c959649942904205b02acce2a
2023-01-11 12:58:15 +01:00
Pau Espin 6aad14c3fa gtphub.h: Remove dependency on sgsn/gprs_sgsn.h
It is only really needed to import define GSM_APN_LENGTH, which is
actually also available in libosmogsm. Hence simply use the one from
libosmogsm.

Change-Id: I4c6110feeeaa1adfb6b1f0147eeb56dfe34636ec
2023-01-11 12:51:38 +01:00
Pau Espin f44dfa8a0e Rename bscconfig.h -> config.h
Change-Id: I007103be34c1aaab7a9375c44b226d4590fe5b24
2023-01-11 12:51:38 +01:00
Pau Espin e931b39b3c Move LOGGSUBSCRP to gprs_subscriber.h
The define belongs to gprs_subscriber.h header.

Change-Id: Icdb7e55ca8e90dd2ba79ccdb1a8ba650a3942ab3
2023-01-11 12:51:38 +01:00
Pau Espin fd9e82da31 Move sgsn_ctrl_cmds_install() declaration to sgsn.h
sgsn.h is the main header containing all misc app related contents.
This is another step towards shrinking gprs_sgsn.h mess.

Change-Id: I80e3a68e2e368d8c73135c850e4728bdf6cf5f09
2023-01-11 12:51:38 +01:00
Pau Espin f2307c483f Move gtphub header to include/osmocom/gtphub/
Change-Id: I82e1f2a3bc8e22b28747a540879bd661f1704cde
2023-01-11 12:51:38 +01:00
Pau Espin 15a52d92c4 Move global pdp_list inside struct sgsn_instance
This way pdp contexts are managed by the lifcycle of the main global struct
sgsn_instance automatically.

Change-Id: I725218fd54adcc68dceded5eb43675f25771bb96
2023-01-11 12:51:38 +01:00
Pau Espin 05190c36bb Move sgsn_pdp_ctx to its own file pdpctx.{c,h}
This further shrinks the mess in gprs_sgsn.h, and allows to easily see
layer violations (like pdpctx.c requiring llc.h)

Change-Id: Iad4da06efee7d8514ff48423bdaebc0f26413cc1
2023-01-11 12:51:34 +01:00
Pau Espin 3d3c8c55f0 Drop extern declarations of global sgsn_instance in source files
There's an extern declaration already in sgsn.h.

Change-Id: I2375e13c8436a069e8fe60136c8e1759a9adc2d1
2023-01-11 12:46:34 +01:00
Pau Espin 164a1eeb8a Move extern declarations of tall_sgsn_ctx to sgsn.h
Change-Id: Ifbd54b2e92db8d4a0e0cd1c569cfd83dd85165b8
2023-01-11 12:43:18 +01:00
Pau Espin 69569879ae gtp_{ggsn,mme}: Allocate contexts under struct sgsn_instance
This way apns are managed by the lifcycle of the main global struct
sgsn_instance automatically.

Change-Id: Ie65d59632a368c6957c33dca64e856ace792b2c6
2023-01-11 12:31:23 +01:00
Pau Espin fd4d435442 Move global apn_list inside struct sgsn_instance
This way apns are managed by the lifcycle of the main global struct
sgsn_instance automatically.

Change-Id: I8cc8e540cfb64d0f130e9c0aaedf7b0835f8fe16
2023-01-05 19:37:07 +01:00
Pau Espin 8ec269a0e0 Move gtp related functions to gtp.h
The functions are implemented in sgsn_libgtp.c and hence belong to
header file gtp.h

Change-Id: I7f5cf2895b05e03435769548b61051e6284ccb3c
2023-01-05 19:20:43 +01:00
Pau Espin 4bd6f663a7 sndcp: Standarize unitdata function naming
Use sndcp_<sap>_type>_<op> so that it's easier to distinguish and
identify them.

Change-Id: Ib8825570a8f61d0a28d631f86f5244e70d3194aa
2023-01-05 19:00:56 +01:00
Pau Espin 52c9b8e593 Move func defintions of funcs implemented in gprs_sndcp.c to gprs_sndcp.h
Move them to the correct header where they belong, so that the all the
related protocol stuff is placed together.

Change-Id: I9052f48a0af125bb445194f4ae94ebbe49508fda
2023-01-05 18:57:39 +01:00
Pau Espin 51028e2c16 Properly split llc->sndcp->gtp unitdata pathi through extra func call
Beforehand the function handling the LL-UNITDATA primitive from LLC was
already submitting the packet to GTP code which had an SNDCP related
name, so everything was really confusing and layer separation was not
clean.

Change-Id: Ia544a9dd4c0c7647b0c1b64ca110351f40820618
2023-01-05 18:46:23 +01:00
Pau Espin e69f460ae7 sgsn.h: Drop declaration of non existing function
Change-Id: Idabea56d1ff89e51b517b15771a5a1ed3b050ec9
2023-01-05 18:23:03 +01:00
Pau Espin 0e707fc83a Move struct sgsn_subscriber_pdp_data to gprs_subscriber.h
The functions driving its lifcyecles are already in gprs_subscriber.c,
and are used mainly by functions in the same file, hence move it to the
related header to further shrink gprs_sgsn.h.

Change-Id: Iff7be91af130a3317d57d3649c17e3d5d2540e7a
2023-01-05 17:48:17 +01:00
Pau Espin ffd6e37eb5 Move struct apn_ctx and APN related definitions to its own file
This allows further shrinking of gprs_sgsn.{c,h} and also being able to
use GSM_APN_LENGTH on different headers easily (needed by follow-up
patch).

Change-Id: Id225ed8b84e1376f4a30f17dd4b153b6b1a6efa8
2023-01-05 17:45:28 +01:00
Pau Espin 44bde6b85a Move global ggsn_list into struct sgsn_instance
Change-Id: I9d4c74476b777a866af2796dd376ed50da7b5d01
2023-01-05 17:23:43 +01:00
Pau Espin e659f75cf1 Keep sgsn subsystems under struct sgsn_instance lifecycle
Rework initialization and destruction of several sgsn subsystems to be
allocated & released together with the struct sgsn_instance.

This makes it easier to destroy and recreate the entire context and
allows us to start moving global variables scattered around to be under
struct sgsn_instance.

Change-Id: Idf60519b8e475b94d38bbb69e737132a5afaefab
2023-01-05 17:23:43 +01:00
Pau Espin 67e71eac1c Remove unneeded extern declaration from libosmocotrl
Change-Id: I464df2d03538c71f6666046c67170746690e723d
2023-01-05 17:23:43 +01:00
Pau Espin c1cf4af11b Move related structs to gprs_subscriber.h
This allows shrinking a bit more gprs_sgsn.h and and in turn have
everything much more tidy.

Change-Id: Ie39b48a0d612aa632327cc5a21c833b05f5bf297
2023-01-05 15:43:29 +01:00
Pau Espin f37aedbf76 Fix -Werror=old-style-definition
Change-Id: I119d4ba58d9c68df12b433b0cee924468a1473d8
2023-01-05 14:25:47 +01:00
Pau Espin 920c6c8c81 Introduce new header file sgsn/gtp.h
It will be used to store all stuff relatd to libgtp use and GTP
protocol, similar to what we already do for other protocols.

Change-Id: I4aae35cd0ea401856cd822cb507d668350d07a89
2023-01-05 14:15:52 +01:00
Pau Espin df203361e8 Move gprs_sndcp_vty_init() declaration to gprs_sndcp.h
Change-Id: Iea9692e7ef9bd017d89ef654d2f2ae5b30cc4550
2023-01-05 14:15:52 +01:00
Pau Espin b61ab9b9ac gprs_subscriber: Move API declarations to correct header
Change-Id: Iaa1032c38fa54ad57c472d9120cfbb34b2ae90e9
2023-01-05 14:15:50 +01:00
Pau Espin 5f4736aa85 Move struct sgsn_ggsn_ctx to its own file gtp_ggsn.{c,h}
Similar to what we already have for struct sgsn_mme_ctx in
gtp_mme.{c,h}.

This is just the nth step of properly splitting different
protocol layers, data model, etc.

Change-Id: Iad1895f09e43e299df7bb126bf52fdb98268392e
2023-01-05 00:11:57 +01:00
Pau Espin fc1a5538d0 Replace gprs_str_to_apn() with libosmocore API osmo_apn_from_str()
The exact same function exists in libosmocore with a different naming.

Change-Id: Ibef55a648f2d58f4fdd24fa553efde530982af2d
2023-01-04 19:56:39 +01:00
Pau Espin eb967fccb2 Remove unused function gprs_parse_mi_tmsi()
Change-Id: I6fb7688bf54c7ae3ca3e06bf3a1b729fa62d82f9
2023-01-04 16:29:43 +01:00
Pau Espin 13c00008b4 Standarize lle and llme state enum & value_string
Change-Id: Iaf102ce5ca60854fe7eb1af17c73a80e7c76181b
2023-01-04 13:57:52 +01:00
Pau Espin e5614e434f vty: Fix wrong value_string used to print llme state
Change-Id: Id3eec91b47029964092087858e4ae3a824929ce3
2023-01-04 13:53:57 +01:00
Pau Espin b0b582bff8 cosmetic: gprs_llc_vty.c: Fix trailing whitespace
Change-Id: I543fd784f7e1a0f7c82bd7c79e073104becc88da
2023-01-04 13:49:22 +01:00
Pau Espin bc46812bd7 Move gprs_tmr_to_secs() to tests/gprs/gprs_test.c
That function is only used in the test. Let's hence move the function to
the same test file in order to simplify osmo-sgsn code.

Change-Id: I69d80810362d75eb93974af34f61639514f99f8a
2023-01-02 13:38:01 +01:00
Pau Espin 4398ac073b Rename gprs_gb.[c,h] -> gprs_ns.[c,h]
All remaining code in that file is NS protocol related, hence let's
rename it so that we end up with one file per protocol in the Gb stack.

Change-Id: I8312c8a70d60cab48764950c5b57ca02964e9db2
2022-12-28 23:14:20 +01:00
Pau Espin 05d5f28e93 Move some functions gprs_gb.[c,h] -> gprs_gmm.[c,h]
This leaves only NS protocol related code in gprs_gb.[c,h], which will
be renamed to gprs_ns.[c,h] in a follow up patch.

Change-Id: I3dcbe1d0f75cb91ec8b700e239e2ba16fff030a2
2022-12-28 23:12:47 +01:00
Pau Espin 7a74ae492e Create new specific file for BSSGP code
Right now there's no much code there since the related code is totally
entangled with the LLC one.
This will eventually change in the future when we switch to use
libosmo-gprs.
Hence, this commit is a preparation to have already some place to put
new BSSGP specific code in the future.

Change-Id: I816396ab5ccb86032bbc21b41a959934a7768780
2022-12-28 23:11:49 +01:00
Pau Espin 749ca7c850 Move gprs_gb_parse.[c,h] to tests/sgsn/
That big file is really only used by tests/sgsn/sgsn_test nowadays, so
let's keep it out of osmo-sgsn app code base.

Change-Id: Ia5a639832f52b2f015a2800bd0d94a28d7bc689b
2022-12-22 19:49:39 +01:00
Max e7ccfdb4aa ctrl: take both address and port from vty config
Change-Id: Ie1330b152a2e5cdcdb80a1c958e7c1d784b78eab
2022-12-17 21:16:58 +03:00
Oliver Smith e39ff86dd9 osmo-gtphub.cfg: fix conflict with osmo-ggsn.cfg
Change bind-to-ggsns from 127.0.0.2 to 127.0.0.20, so osmo-gtphub's
default config does not confligt with the osmo-ggsn default config. This
change is for the effort of making the configs of all Osmocom programs
not conflict with each other.

A similar change was made in Id892e1f4ab2daabbe9824b819b5fed985373b97a
with bind-to-sgsns.

Related: OS#5817
Change-Id: I57ee457b62139d831707b6ebd6baaea8d33c2d9c
2022-12-08 16:28:32 +01:00
Pau Espin 57b63875c7 sndcp: Put decompress handling code into helper function
This further simplifies code and avoids duplicating it.

Change-Id: Id83f9e4a87139de2b2f64c8523460c186d5b5649
2022-12-06 12:06:26 +01:00
Oliver Smith 55e3dc8ec8 sgsn_libgtp: cb_data_ind: remove mm_idle assert
Log an error message and drop the packet instead of asserting if
mm state fsm is in ST_MM_IDLE while the gmm fsm is in
ST_GMM_REGISTERED_NORMAL.

Fixes: OS#5725
Change-Id: I9dab98917c622b36dae22399bb359d747a598208
2022-11-17 14:08:30 +01:00
Oliver Smith acd967a177 contrib/jenkins.sh: use enable-werror with IU too
Now that the warnings in osmo-iuh have been fixed, we should be able to
build the IU version of OsmoSGSN with --enable-werror too.

Related: OS#4462
Change-Id: I8cc4e209e21acfe513bef72927499f1ccdead783
2022-11-15 13:01:25 +01:00
Pau Espin 8501126031 vty: Make new libgtp tdefs configurable through VTY
Related: OS#5485
Depends: osmo-ggsn.git Change-Id I10bc8e2e197c0e8753b23b684b5ae41025672bf7
Change-Id: I46e9cd158a9f2f721c69f807beb7bb67a459f4a4
2022-11-04 14:27:30 +01:00
Max b43496a60d GMM: permit E_GMM_COMMON_PROC_SUCCESS in normal state
The FSM might be moved out of ST_GMM_COMMON_PROC_INIT state either
by E_GMM_ATTACH_SUCCESS or by E_GMM_COMMON_PROC_SUCCESS events
which are not mutually exclusive. Hence the later event will arrive when we're already in
the ST_GMM_REGISTERED_NORMAL state.

Let's have both events permitted to keep the logs clean from useless error.

Related: OS#5349
Change-Id: Ia97b50aac6c665812ddca9010de7f97b17b78bd5
2022-10-14 15:04:36 +03:00
Max caff83e702 Constify LLC/SNDCP parameters
That makes it easier to track side-effects while reading the code.

Related: OS#5349
Change-Id: I903f8a747a8d3b7f734dac7b0c12373ecbb90b11
2022-10-11 10:54:39 +03:00
Max 61f2186592 GTP: migrate from deprecated function
The gtp_set_cb_recovery3() is similar to gtp_set_cb_recovery2()
with extra parameter representing GSN.

Change-Id: I8b46cf8c52e36b0312eddf37f3e136662b95732e
2022-10-11 10:54:39 +03:00
Max 559636a4a2 SNDCP: log more details on failure
Related: OS#5349
Change-Id: Iad3ebbc28909a827db7b3a0ae2d3e1de7991210f
2022-10-08 20:24:22 +03:00
Vadim Yanitskiy 13ccbc1e61 llc: gprs_llc_fcs(): make the input data pointer const
Change-Id: If95210fe69f915ab1010fe5916cb6bee3faeb7b9
2022-09-08 12:51:54 +00:00
Vadim Yanitskiy d32852664d gprs_llc.h: use '#pragma once'
Change-Id: Iff748fe68dbef83589bfb5e3bea5183deb365fa6
2022-09-08 12:51:43 +00:00
Max 77cdc424cb Set working directory in systemd service file
By default systemd will execute service with root directory (or home directory for user instance) which might result in
attempts to create files in unexpected place. Let's set it to 'osmocom' subdir of state directory (/var/lib for system instance) instead.

Related: OS#4821
Change-Id: I950d84853c6737276d02b3275127b499ae567c38
2022-08-30 19:42:59 +07:00
Vadim Yanitskiy fb6cf3221e gprs_llc: fix misleading spacing in gprs_llc_rcvmsg()
Change-Id: I7ec97a7d9b37f0541887bc13e31f547613f8945e
2022-08-26 05:38:33 +07:00
Vadim Yanitskiy c63a8381e5 configure.ac: do not require unused dlsym/dlopen
Change-Id: I90b383ed45b27d8b59272116dd81acb72912349d
2022-08-16 23:31:22 +07:00
Pau Espin 328ed94040 Bump version: 1.8.0.9-c230-dirty → 1.9.0
Change-Id: If8d3bad88dbd57b620e3aca61d99073e178c2fb6
2022-06-29 11:45:09 +02:00
Harald Welte c230f0c283 README: Major update
* convert to markdown syntax
* bring in-line with other osmo-* README.md files, in terms of
  links to git, mailing list, manuals, etc.

Change-Id: Ia4a4329c6ef6b8c833aa26832776dad662cdc7e9
2022-06-20 10:16:56 +00:00
Harald Welte e2b9b7ee57 update git URLs (git -> https; gitea)
Change-Id: Ib8d2953a6c3f1e65b7c638feea4d8a97ee02e443
2022-06-20 10:15:50 +00:00
Vadim Yanitskiy 199f295d36 tests: use 'check_PROGRAMS' instead of 'noinst_PROGRAMS'
When using 'check_PROGRAMS', autoconf/automake generates smarter
Makefiles, so that the test programs are not being compiled during
the normal 'make all', but only during 'make check'.

Change-Id: I8118ee3d3da9bdcd0c691471ef91b95dba21004a
2022-04-13 19:55:36 +03:00
Neels Hofmeyr 3c7656a481 Iu: add UEA encryption
Add vty 'encryption uea 0 1 2', defaults to 'encryption uea 0' to yield
previous behavior.

If any UEA above 0 is enabled, include the UEA key in the Iu Security
Mode Command.

I noticed that only the code bit in st_iu_security_cmd_on_enter()
affects the test. The same code in gsm48_gmm_authorize() seems to be
dead code? But applying the patch there as well just to be safe.

We cannot yet verify the chosen UEA to match a configured UEA level,
because the iu_client.c does not send us message details with the
RANAP_IU_EVENT_SECURITY_MODE_COMPLETE.
Also we cannot yet send the set of configured UEA to the hNodeB, since,
again, iu_client.c does not provide the proper API for it.
The proper solution here is to completely dissolve iu_client.c and do
all Iu handling in osmo-sgsn itself -- see OS#5487.

Related: SYS#5516
Related: I1a7c3b156830058c43f15f55883ea301d2d01d5f (osmo-ttcn3-hacks)
Change-Id: I27e8e0078c45426bf227bb44aac82a4875d18d0f
2022-03-10 19:07:38 +01:00
Neels Hofmeyr 340a7e9339 s/cipher_support_mask/gea_encryption_mask
will add uea_encryption_mask, and find that the name
'cipher_support_mask' is not concise enough.

Related: SYS#5516
Change-Id: Ie8d4a0534c5b751f698bce425427bb1d28ddea31
2022-03-07 15:37:26 +01:00
Pau Espin 938ebfb129 Revert "sgsn: Handle different levels of QoS"
This reverts commit 4bd931f96d.

The commit was wrong, and previous code is correct.
Relevant specs:
* TS 29.060 7.7.34 Quality of Service (QoS) Profile
* TS 24.008 10.5.6.5 Quality of service

As can be seen in TS 24.008 10.5.6.5, OSMO_IE_GSM_REQ_QOS never comes
with the the ARP byte prepended. This is actually always prepended when
sending the GTP message, as explained in TS 29.060 7.7.34.

As a result, the Qos Service sent in Create PDP Context Request sent to
the GGSN contained wrongly formatted Qos Profile IE, which was observed
checking wireshark with a real phone. This was found due to open5gs-smfd
being more strict about the possible lengths of the IE, since the
wrongly formatted IE send in GTP had length=14, which is incorrect due
to folllowing TS 24.008 10.5.6.5 wording:
"Octets 15-22 are optional. If octet 15 is included, then octet 16 shall also be included, and octets 17-22may be
included."
In this case, due to the wrong format it was seen as including octet 15
but not 16.

Change-Id: I4fc5ab823a27d27482858a7459337a2f8ae593c3
Related: SYS#5793
2022-02-18 17:26:14 +01:00
Pau Espin d06c717e30 Drop unneeded ax_check_compile_flag.m4
The macro is no longer used since 2d0e22960c.

Change-Id: I230005acc27e29c679a4ddbb2b316a3aae70874e
2022-01-11 18:13:46 +01:00
Oliver Smith 57425a3805 treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I9bc57a7152015e0f37e3d1573921d6d5d3c0449b
2021-12-14 12:21:06 +01:00
Oliver Smith f76428500a llme_free: clean up related sndcp
Fix crash in vty_dump_sne when sndcp->lle has already been deallocated.

Context:
* sndcp->lle is set only once in gprs_sndcp_entity_alloc()
* sndcp->lle is a struct gprs_llc_lle, which gets allocated and
  deallocated together with struct gprs_llc_llme. From gprs_llc.h:

    struct gprs_llc_llme {
            ...
            struct gprs_llc_lle lle[NUM_SAPIS];

Fixes: OS#4824
Change-Id: I707029f78222bc6335837241e5a08c54c5ae6eb3
2021-12-07 17:13:12 +01:00
Pau Espin 0f9966e307 Bump version: 1.7.0.28-245ac-dirty → 1.8.0
Change-Id: I62daba59b9dd1a0cade5292c8705ee5ec5b103c2
2021-11-16 17:57:50 +01:00
Vadim Yanitskiy 245ac9501b tests/Makefile.am: do not try removing non-existing files
Change-Id: Ie9f4a9aa4061e4e4c659b1ad71596846ce75df7b
2021-11-15 04:39:57 +03:00
Oliver Smith 2d0e22960c Revert "Turn some compiler warnings into errors"
Do not turn some compiler warnings into errors by default. This patch
was added before --enable-werror was available.

We build with --enable-werror during development and in CI. If the code
is built with a different compiler that throws additional warnings, it
should not stop the build.

This reverts commit 34f012639d.

Related: OS#5289
Change-Id: I24e0a0d7f93f196dc642e37b03f68464024c09d4
2021-11-04 10:55:57 +01:00
Keith Whyte 6cee1a1ded VTY: Don't display 'PDP Address: invalid' for IPv4v6
We were not handling the case of PDP_TYPE_N_IETF_IPv4v6
in gprs_pdpaddr2str() and showed "invalid" for these addresses.

Depends: libosmocore Change-Id: I1f82f9d8fc13dcc4474760329bd74ae9685b9031
Change-Id: Id36b7520677e4a0af40d05dc503b26d1b0b74a26
2021-09-30 20:45:19 +02:00
Oliver Smith c0e146467a debian/control: remove dh-systemd build-depend
Related: OS#5223
Change-Id: I769bf61a2f3a97d55c65999436d2cb079c9170a0
2021-09-01 16:07:07 +02:00
Oliver Smith ab39b622cc vty: add "page imsi"
Make it easy to manually test pagings from SGSN to the PCU.

Related: SYS#4878
Change-Id: I8a73caa234f6b841e641be866e22e7fa03152eb7
2021-08-06 22:25:10 +02:00
Oliver Smith 3aba7ad2ae gtphub: remove llist_first, llist_last macros
Use list_first_entry_or_null instead of llist_first, which has been
present in libosmocore since the 0.10.0 release.

Use llist_last_entry instead of llist_last (also present since
libosmocore 0.10.0). This macro does not have a check for an empty
list, however the only user is already checking for an empty list
before using the macro.

This solves a build error, as llist_last was defined in libosmocore
Icf455bf6ba9d60bd311af17c9e80febaa42cacc9 (should probably be reverted
for backwards compatibility with previous osmo-sgsn versions?):

gtphub.c:68:0: error: "llist_last" redefined [-Werror]
 #define llist_last(head, type, entry) \

In file included from /build/deps/install/stow/libosmocore/include/osmocom/core/timer.h:46:0,
                 from /build/deps/install/stow/osmo-ggsn/include/gtp.h:17,
                 from gtphub.c:32:
/build/deps/install/stow/libosmocore/include/osmocom/core/linuxlist.h:245:0: note: this is the location of the previous definition
 #define llist_last(head) (head)->prev

Change-Id: Ia0496c24386cd13b1e9e604aa2d425d3fa28d352
2021-07-12 12:20:52 +02:00
Vadim Yanitskiy e9336a72a0 doc/manuals: update configuration.adoc to use new command syntax
The old command is deprecated since [1] has been merged.

Change-Id: Iac985f373de98206fdfb3196295ebec160189780
Related: [1] Ie6700c4e9d2df1eb5fde1b971e287b62668cc2de
Related: SYS#5324
2021-07-03 21:07:43 +02:00
Eric Wild 2f898265d0 add support for multiple encryption algorithms and a5/4
Change-Id: Ie6700c4e9d2df1eb5fde1b971e287b62668cc2de
Related: SYS#5324
2021-06-16 16:43:23 +02:00
Pau Espin a33f00637e Use new stat item/ctr getter APIs
Generated with spatch:
"""
@@
expression E1, E2;
@@
- &E2->ctr[E1]
+ rate_ctr_group_get_ctr(E2, E1)
"""

Change-Id: I2e064883ac6dafa89e41a297a886a9ebd26ce925
2021-06-04 17:27:05 +02:00
Keith Whyte c12c1a6b0c vty: Fix optional display of pdp with mm-context
The vty is randomly including the pdp context when the vty
command 'show mm-context all' is issued without the pdp
parameter.
I do not know why, but I assume that relying on a true/false
test of argv[0] has unpredictable results.

Change-Id: Idcde4dd30a39625b24a1c3a38901349875e0949a
2021-05-20 04:41:22 +02:00
Pau Espin e5c8998f9c Support forwarding RIM messages over GTPCv1 EUTRAN<->GERAN
MMEs connect over Gn interface using GTPCv1 towards the SGSN in order to
exchange RIM PDUs by using "RAN Information Relay" GTPCv1 message type.
For more info, see 3GPP TS 29.060 sec 7.5.14.1 "RAN Information Relay"

In order to support it, this commit does the following:

* Uses new libgtp APIs to rx and tx RAN Information Relay messages. The
  same "gsn" object is reused, ie. the local GTPCv1 socket address used
  for exchanging messages against GGSN is reused.
* Adds a new "sgsn_mme_ctx" struct holding information about MMEs
  allowed by the SGSN, each one containing information about the GTP
  address it uses, the in/out routing based on TAI requests, etc. The
  set of MMEs and their config can be set up using new VTY node introduced
  in this commit.
* The RIM related code in SGSN is refactored to allow forwarding from
  and to several types of addresses/interfaces.

Depends: osmo-ggsn.git Change-Id Iea3eb032ccd4aed5187baca7f7719349d76039d4
Depends: libosmocore.git Change-Id I534db7d8bc5ceb19a2a6866f07d5f5c70e456c5c
Related: SYS#5314
Change-Id: I396450b8d8b66595dab8ff7bf41cbf964bb40d93
2021-05-19 11:45:05 +02:00
Pau Espin 8969db7a49 gtp: Delete ctx upon receive UpdateCtxResp with cause Non-existent
Related: SYS#5435
Change-Id: Ic5f682a79663acc65fd364dd7a3a7cc554534414
2021-05-08 09:00:45 +00:00
Pau Espin 0b0b59a8ff Drop unused GBRPOXY enum field
Change-Id: I85dbc65addfbb072a75b6f62fcc4306b7fbb6a91
2021-05-03 18:19:23 +02:00
Pau Espin 888052e71c mm_state_{gb,iu}_fsm: Improve naming for detach event
The E_(P)MM_IMPLICIT_DETACH event was actually sent and handled when the
UE was considered to be detached, no matter the reason, be it due to
implicit detach, or Detach Request received, etc.
So, let's properly name the event to avoid confusions in the code.

Related: SYS#5389
Change-Id: I224ea9db80b4d96696934cea06349dab036f919b
2021-04-14 13:27:36 +02:00
Pau Espin 913dbcd552 mm_state_{gb,iu}_fsm: Add missing license block, improve spec references
Change-Id: Ifcfd9c11005a388220c599e7b2f6901175141f1c
2021-04-14 13:18:31 +02:00
Pau Espin 922684f318 gprs_ranap.c: Clean up code path releasing IU conn
Let's always send the event to the FSM and keep logic of whether it's a
good event to sent or not inside the FSM, not in the caller.
The logic is kept the same: if the event is not expected (not handled),
keep forcing free of the IU connection.
In theory this should never happen since only a PMM in Connected state
should have a established connection (hence only a PMM in Connected
state can have it released). In any case let's keep the safety check,
but let the FSM receive the event and log an error about unexpected
event, which is more interesting from debug point of view.

While at it, clean up the related logging line: There's no need to print
the imsi explicitly, since LOGMMCTXP already does it. Furthermore, print
the exact low level event which triggered the code path.

Related: SYS#5389
Change-Id: I45017562ea7f27c2248b7de56f99ce7ca88e89b2
2021-04-14 12:42:02 +02:00
Pau Espin 3caa7f6d97 Iu: Drop timer X3314
This Iu timer is Osmocom specific, but is made to resemble T3314
timer from GERAN (also named READY timer).

The idea of this activity timer was to arm it whenever PMM state
transitions to CONNECTED, and then rearm it every time there's some
sort of activity, until there's none for some time, then we send a
Release Command to close the conn with the HNGBW/RNC. That's the
same principle as per spec-defined READY timer T3314.

However, there's still a fundamental problem with it: GTP-U in
GERAN passes through the SGSN, but in UTRAN, the GTP-U stream
goes directly from the HnodeB to the GGSN. Hence, there's no proper
way to re-arm this timer upon activity in UTRAN, basically because
the SGSN will never see (userplane data) activity. That explains why
the E_MM_PDU_RECEPTION event exists for mm_state_gb_fsm, but doesn't
exist for mm_state_iu_fsm.
As a result, the timer is currently never rearmed, which means it
will transition to IDLE always after 44 seconds (default value) once
it went into CONNECTED state.

In UTRAN, there is a SCCP connection for each subscriber between
RNC/hNB and SGSN. If the subscriber is no longer in the respective
state, the RNC/hNB should release that IuPS SCCP connection, whcih
in turn means the SGSN cleans up its state.
Furthermore, SCCP has a built-in IT (inactivity timer). So should
the RNC/hNB die, that timer would time out, and the SGSN-side local
SCCP stack (provider) wold send a RELEASE.ind for that connection
to the user (SGSN).

TLDR; this timer is not really needed and cannot be implemented
properly in UTRAN, so let's remove it.

Related: OS#5116
Change-Id: Ibc71829e417bf2dd0c27deb842369dd4f17010d6
2021-04-14 12:14:52 +02:00
Pau Espin 223754fde5 mm_state_iu_fsm: T3314 expiry must lead to PMM IDLE, not PMM DETACHED
This Iu timer is Osmocom specific, but is made to resemble T3314 timer
from GERAN (also named READY timer). The READY timer mission is to make
the MM state transition from READY to STANDBY, which in PMM (UTRAN)
matches the transition from CONNECTED to IDLE.
Instead, the patch introducing the timer was making it transition to
DETACHED directly, but this was clearly not the intention:
* Detaching a UE after 44 seconds (default value for T3314) is overkill.
* The comment describing it says: "Iu User inactivity timer. On expiry
  release Iu connection". The release of Iu connection happens during
  the CONNECTED->IDLE transition (that's basically the difference between
  both states).

The transition CONNECTED->IDLE is done by means of calling
sgsn_ranap_iu_release_free(), which will eventually answer with a event
RANAP_IU_EVENT_IU_RELEASE from lower layers when the Release Complete is
received. At that point, osmo-sgsn code frees the connection and
transitions to IDLE state. This way we maintain the state according to
the connection existance.

Related: SYS#5389
Related: osmo-iuh.git Change-Id Iac822c74e56750dc40e94573eae0e20853ff68c0
Fixes: 3bad31bcb4
Change-Id: I7279102ad51b0c39eb6d04c129986984112d15cc
2021-04-13 20:36:06 +02:00
Pau Espin f025e582bb gprs_gmm.c: State proper GMM prefix logging rx/tx of GMM messages
Change-Id: I58af41acdc4a04870b4cf2ea34a272d46d896254
2021-04-13 11:58:59 +02:00
Pau Espin e8cd6856a5 mm_iu: Expect E_PMM_PS_ATTACH when in ST_PMM_IDLE
It can happen that the MS tries to attach while SGSN's MM Iu state is
ST_PMM_IDLE (eg because UE was hard rebooted). Since Attach is a
specific case of getting a Connection Established, also allow it as a
trigger to transit to state ST_PMM_CONNECTED.

Related: SYS#5389
Change-Id: Ia74a062ddc3052faad569f1428f0ddd02e5b188d
2021-03-25 17:58:07 +01:00
Pau Espin c67c90b47e mm_iu: Send event E_PMM_PS_CONN_ESTABLISH upon rx GMM SERVICE REQUEST
Attach event should only be triggered by rx Attach Request, not other
messages. Furthermore, currently E_PMM_PS_CONN_ESTABLISH is defined and
expected in FSM but not sent by anyone.
Also, The opposite transition is done by E_PMM_PS_CONN_RELEASE:

"""
MM_STATE_Iu(0)[0x81379b0]{Connected}: Received Event E_PMM_PS_CONN_RELEASE
MM_STATE_Iu(0)[0x81379b0]{Connected}: state_chg to Idle
...
MM(001010123456063/c8b8bd08) -> GMM SERVICE REQUEST MI(3367550216) type="signalling"
MM_STATE_Iu(0)[0x81379b0]{Idle}: Received Event E_PMM_PS_ATTACH
MM_STATE_Iu(0)[0x81379b0]{Idle}: Event E_PMM_PS_ATTACH not permitted
"""

Related: SYS#5389
Change-Id: Ica00891f91834522f4dea2508b62af34e4c4eca7
2021-03-25 17:58:03 +01:00
Pau Espin c26072a77f gmm_fsm: Expect E_GMM_COMMON_PROC_INIT_REQ when in ST_GMM_COMMON_PROC_INIT
Due to whatever errors, the MS may re-init the Common Procedure by
retransmitting a GPRS Attach Request while we are for instance aiting
for Identity to be resolved.

See this log:
MM(---/ffffffff) -> GMM ATTACH REQUEST MI(3903513414) type="GPRS attach"
GMM(gmm_fsm)[0x8136110]{Deregistered}: Allocated
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x81383c0]{Init}: Allocated
MM_STATE_Gb[0x8138ac0]{Idle}: Allocated
MM_STATE_Iu[0x8138bb0]{Detached}: Allocated
GMM(gmm_fsm)[0x8136110]{Deregistered}: Received Event E_GMM_COMMON_PROC_INIT_REQ
GMM(gmm_fsm)[0x8136110]{Deregistered}: state_chg to CommonProcedureInitiated
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x81383c0]{Init}: Received Event E_ATTACH_REQ_RECV
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x81383c0]{Init}: state_chg to CheckIdentity
MM(/fba673a2) <- GPRS IDENTITY REQUEST: mi_type=IMEI
UE(0x2){001-01-10422-99} Received GSM 04.08 message type 0x16, but no MM context available
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x81383c0]{CheckIdentity}: Timeout of T3370
MM(/fba673a2) <- GPRS IDENTITY REQUEST: mi_type=IMEI
[Failure to handle GSM48_MT_GMM_ID_RESP and subsequent retransmission of GPRS IDENTITY REQUEST happens a couple times here]
MM(---/ffffffff) -> GMM ATTACH REQUEST MI(3903513414) type="GPRS attach"
GMM(gmm_fsm)[0x8136110]{CommonProcedureInitiated}: Received Event E_GMM_COMMON_PROC_INIT_REQ
GMM(gmm_fsm)[0x8136110]{CommonProcedureInitiated}: Event E_GMM_COMMON_PROC_INIT_REQ not permitted
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x81383c0]{CheckIdentity}: Received Event E_ATTACH_REQ_RECV
[Here IDENTITY REQUEST is sent again, and this time MS answers ID RESPONSE back and goes forward]

Related: SYS#5389
Change-Id: I93d7d6bc694c84223a11d075d24c234b82b73389
2021-03-25 16:57:24 +01:00
Pau Espin ce0a0e9beb gmm: Expect E_VLR_ANSWERED when in ST_IU_SECURITY_CMD
GSUP message is sent immediately before moving onto state
ST_IU_SECURITY_CMD, so it's expected to receive a response for it, which
will trigger event E_VLR_ANSWERED being sent.
See following log showing the scenario:

"""
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x8137b88]{Authenticate}: Received Event E_AUTH_RESP_RECV_SUCCESS
MM(001010123456789/f8bab3dc) Requesting authorization
MM(001010123456789/f8bab3dc) Missing information, requesting subscriber data
MM(001010123456789/f8bab3dc) Requesting subscriber data update
SUBSCR(001010123456789) subscriber data is not available
SUBSCR(001010123456789) Sending GSUP, will send: 04 01 08 00 01 01 21 43 65 60 f3 28 01 01
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x8137b88]{Authenticate}: state_chg to IuSecurityCommand
SUBSCR(001010123456789) Received GSUP message OSMO_GSUP_MSGT_INSERT_DATA_REQUEST
SUBSCR(001010123456789) Will set PDP info, context id = 1, APN = 01 2a
SUBSCR(001010123456789) Updating subscriber data
MM(001010123456789/f8bab3dc) Subscriber data update
MM(001010123456789/f8bab3dc) Updating authorization (authenticate -> accepted)
MM(001010123456789/f8bab3dc) Got authorization update: state authenticate -> accepted
MM(001010123456789/f8bab3dc) Authorized, continuing procedure, IMSI=001010123456789
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x8137b88]{IuSecurityCommand}: Received Event E_VLR_ANSWERED
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x8137b88]{IuSecurityCommand}: Event E_VLR_ANSWERED not permitted
SUBSCR(001010123456789) Sending GSUP, will send: 12 01 08 00 01 01 21 43 65 60 f3 28 01 01
SUBSCR(001010123456789) Received GSUP message OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT
SUBSCR(001010123456789) Updating subscriber data
MM(001010123456789/f8bab3dc) Subscriber data update
MM(001010123456789/f8bab3dc) Updating authorization (accepted -> accepted)
sccp_sap_up(N-DATA.indication)
N-DATA.ind(2, 20 06 00 08 00 00 01 00 06 00 01 00 )
handle_co(dir=2, proc=6)
Transmitting RANAP CommonID (SCCP conn_id 2)
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x8137b88]{IuSecurityCommand}: Received Event E_IU_SECURITY_CMD_COMPLETE
GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x8137b88]{IuSecurityCommand}: state_chg to WaitAttachComplete
"""

Related: SYS#5389
Change-Id: If348ff32faa4a709b59ee1b9b043883a7d46cf93
2021-03-25 16:35:07 +01:00
Pau Espin c8ace5a03c gmm: log GMM msg type name instead of number
Change-Id: I2dc6eb5bfb0f44caf2687e582d660f71fdd647a2
2021-03-25 16:03:05 +01:00
Pau Espin 183e6c3367 ranap: log ranap iu event type name instead of number
Change-Id: If66e9d5989b46abe01855a5c1183d567d358abeb
2021-03-25 15:54:45 +01:00
Vadim Yanitskiy 8de4be261d main: resurrect removed 'ns' logging category as deprecated
This logging category has been removed completely in [1], and now
osmo-sgsn fails to start with old configuration files:

  There is no such command.
  Error occurred during reading the below line:
   logging level ns info

Let's accept it and print a deprecation warning.

Change-Id: I2036170af41db89484c299e18e0b703c97427dc1
Fixes: [1] Ia4723ab344ad6a1927029a2d5d0dda020266b39d
2021-03-14 20:59:08 +01:00
Daniel Willmann 6fd19da165 manuals: Regenerate counters/VTY through docker
Change-Id: I09b01d2e4bc7b1c17588100b16ac9f04cf72cf99
2021-03-12 07:27:24 +00:00
Harald Welte adcf97d095 Remove bogus DNS log category
When we switched to the libosmogb NS2 implementation, we should have
removed the DNS category, as NS2 uses DLNS internally and hence DNS
is unused.

Change-Id: Ia4723ab344ad6a1927029a2d5d0dda020266b39d
Closes: OS#5058
2021-03-10 12:30:05 +00:00
Pau Espin 80adb30e93 Bump version: 1.6.0.157-b05c1-dirty → 1.7.0
Change-Id: Ifa861bb0109f433b103a75d5140425bf19c66943
2021-02-23 19:39:45 +00:00
Harald Welte ebd39830cb main: change initialization order
We must have initialized e.g. the NS protocol stack before calling
handle_options(), as that might want to dumpy the VTY XML, and it
can obviously only dump those nodes that are registered at that
point.

Change-Id: Icd1b8fb3f466cdace67ff0d4f7c85183d8266c41
2021-02-23 16:43:37 +01:00
Harald Welte b05c1d0ce4 manuals: generate vty reference xml at build time
Move 'doc' subdir further down to "make sure" the osmo-bsc binary is built
before the docs

Rremove sgsn_vty_reference from the source tree.

In manuals//Makefile.am use the new BUILT_REFERENCE_XML feature recently added
to osmo-gsm-manuals, and add a build target to generate the XML using the new
osmo-sgsn --vty-ref-xml cmdline switch.

Change-Id: Ied75fdd13283aa592350994fb4febce06c213d3a
Depends: I613d692328050a036d05b49a436ab495fc2087ba
2021-02-23 15:52:54 +01:00
Harald Welte 999a776b70 main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
Change-Id: I893fc869d5900eff8395bfded0c2fa3883c5a1e7
Depends: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Related: SYS#5359
2021-02-23 15:52:54 +01:00
Pau Espin 11ccc4305d Fix nsei+bvci not updated on rx UL SNDCP data
msgid2mmctx() was already being called for signalling messages in
gsm0408_gprs_rcvmsg_gb() before calling gprs_gb_recv_pdu(), but it was
not called in sndcp_llunitdata_ind().

Let's move msgid2mmctx() inside gprs_gb_recv_pdu() since we want to
always update the nsei+bvci, regardless of message containing data or
control content.

This commit fixes the scenario where an MS changes to a new cell (PCU)
and then continues transmitting UL data. Prior to this patch, the SGSN
kept sending DL content to the old cell (PCU nsei+bvci) instead of the
new one even after the MS transmitted Ul content fro mthe new cell.

Related: SYS#4909
Change-Id: I2c14e1d65575f54212924f7c5f0a2f4c1b76ec81
2021-02-16 13:59:07 +01:00
Oliver Smith 901ed14c89 gbproxy: remove (moved to own repository)
New repository:
https://git.osmocom.org/osmo-gbproxy/

Related: OS#4992
Change-Id: I37f7cebaf2a06bd93627a452f5df44edcfc0f87a
2021-02-08 11:52:53 +00:00
Pau Espin 4be5ab3707 sndcp: Fix struct bit fields on big endian
Change-Id: I30014bf84e7a69fa3d85d542d03e41d56506beb7
2021-02-04 12:49:40 +01:00
Pau Espin c999c223ae .gitignore: Ignore new autofoo tmp files
Change-Id: I20b03d40214fe1822aab8df01e3c79404a795f01
2021-02-04 12:48:17 +01:00
Philipp Maier 2ce050ba46 sgsn_rim: Add routing for (GERAN) BSSGP RIM messages
The SGSN currently does not forward BSSGP RIM messages.

Related: SYS#5103
Depends: libosmocore Icd667f41d5735de56cd9fb257670337c679dd258
Change-Id: I6fde8ab8955660b48000ca1b650cfc7c7b2e24ba
2021-01-28 23:20:31 +01:00
Alexander Couzens 43e5f8a2c6 follow libosmocore/gprs_ns2 API changes (gprs_ns2_dynamic_create_nse)
The call gprs_ns2_dynamic_create_nse has been removed because it
was a workaround for the old/dropped vty api.

Depends-on: Ie924ead6da17657f3da334068c8ada82c8845495 (libosmocore)
Change-Id: Ie636cfd18d6d43da0e42f2c2de68dfa5c571d55c
2021-01-28 21:19:59 +00:00
Alexander Couzens caf73b803c sgsn: migrate to the new gprs_ns2_vty configuration
Change the whole vty configuration for NS to be more flexible
and support more setups. Old configurations are invalid.

API change which must be synchronized with libosmocore

For further information see:
https://osmocom.org/projects/libosmocore/wiki/Network_service_(NS)

Depends-on: I8c3f2afecc74b78f7f914f7dce166cbcb63444eb (libosmocore)
Change-Id: Ie9306ab4d4738c2c57a69987086e22771b30657e
2021-01-28 21:19:59 +00:00
Alexander Couzens 0018d3e0ec gbproxy: follow gprs_ns2 API vty changes
The gprs_ns2_vty2 has been renamed to gprs_ns2_vty. The old
vty has been complete dropped.

API change which must be synchronized with libosmocore.

Depends-on: I8c3f2afecc74b78f7f914f7dce166cbcb63444eb (libosmocore)
Change-Id: If5bd6b86e130772e6c93d640b0c637985416136d
2021-01-28 21:19:59 +00:00
Daniel Willmann f955d078ed manuals/gbproxy: Move pooling to separate chapter
Change-Id: Ie2ad652c8261ce56cb2ed1a6f16a81486ccdf063
Related: SYS#5115, SYS#5005
2021-01-28 20:57:16 +01:00
Daniel Willmann 93ccc3cf5d manuals/gbproxy: MSC -> SGSN for pooling chapter
Mostly just change the chapter so it makes sense for gbproxy. Some todos
are still left

Change-Id: I905835c2be7be43fe376fbc9d743107948c7e6d4
Related: SYS#5115, SYS#5005
2021-01-28 20:57:16 +01:00
Daniel Willmann 10e0fcaae2 manuals/gbproxy: Add osmo-bsc MSC pooling chapter from Neels as a base
Related: SYS#5115, SYS#5005
Change-Id: I930f5df847ea6f40d0ee0c75dd25b6dd20e00839
2021-01-28 20:57:16 +01:00
Daniel Willmann 592eb140f0 manuals/gbproxy: Update configuration chapter
Change-Id: I01f8d47f9fa384a2528ddf2e6c936ff28d11409e
Related: SYS#5115, SYS#5005
2021-01-28 20:57:16 +01:00
Daniel Willmann c7b6aabac1 Rename OsmoGbPROXY -> *Proxy
Change-Id: I7542ac1d5242f1784146de2df7cecaf70fe93c6c
Related: SYS#5115, SYS#5005
2021-01-28 20:57:16 +01:00
Daniel Willmann 873c8a55e7 manual/gbproxy: Update overview chapter
* Remove mention of features that are no longer supported
* Update the data model

Related: SYS#5115, SYS#5005
Change-Id: Icb9095f4002f2a0a4562fccecae109075cb93c7b
2021-01-28 20:57:16 +01:00
Harald Welte e0876bda26 gbproxy: Avoid depending on any of the SGSN code
The last remaining functin of the SGSN code base we used was
gprs_gb_parse_tlli().

Let's simply copy this function over and become  self-contained.

This would allow migrating osmo-gbproxy to a separate repository.

Change-Id: I6f3f86581b47ad71a3d97f07611a2e2709876d69
2021-01-28 19:14:32 +01:00
Alexander Couzens 21afdf9a32 follow libosmocore/gprs_ns2 API changes of GPRS enums
All gprs_ns2 enums have now GPRS_NS2 as prefix.

API change which must be synchronized with libosmocore

Depends-on: I548ff12f7277cbb7e1a630a3dc02b738ce89be72 (libosmocore)
Change-Id: I1af704cdd62ddaff4304479b837dc185b80d7dd6
2021-01-27 21:07:01 +01:00
Daniel Willmann c09cb29d78 gbproxy: Fix radio status routing by TMSI
If a radio status message contains a TMSI it should be routed as if it
was a TLLI. Convert the TMSI to (foreign) TLLI so NRI-routing works.

Both foreign and local TLLIs are routed the same.

Fixes: OS#4954
Change-Id: Ifd64f02fa16b44f8e2e19eb8ba973f50a829ead5
2021-01-22 12:42:14 +01:00
Daniel Willmann 6ad4040f55 gbproxy: Improve log messages in gbproxy_select_sgsn
Change-Id: Id7bc755b90c35ed7c8cfa8408073e2866d639f2d
Related: OS#4954
2021-01-22 12:36:13 +01:00
Daniel Willmann 45bf92feb4 gbproxy: Print the correct message type for dummy paging/paging reject
Change-Id: I5337abb27587fa2e8320b5bfc3765c9de5c57f6c
2021-01-19 11:37:55 +01:00
Daniel Willmann d367b8bc78 gbproxy: Use IMSI cache for PTP paging and implement DUMMY_PAGING_PS
Some code was missing to support PAGING_REJECT and DUMMY_PAGING_PS over both PTP
and signalling. This commit adds the missing pieces, notably:

* Use and route according to the IMSI cache for paging on PTP
* Ensure DUMMY_PAGING_PS is broadcast if no routing area is included

Change-Id: I7243e0d4470cb62fa6db36d26002ccd6542b5147
Related: OS#4951, OS#4472
2021-01-19 09:59:01 +01:00
Harald Welte 5037b6817f gb_proxy: Don't use orphan log subsystem DPCU
DPCU is defined in debug.h, but never registered as log subsystem,
so we shall not use it.  Also remove other similar "orphan" log
subsystems from debug.h

Change-Id: I8be54ee49e10d4004128352613923c4700063aa3
2021-01-18 20:32:25 +00:00
Daniel Willmann d245c0e542 gbproxy: Add VTY commands to query the TLLI/IMSI cache
OsmoGbProxy# show gbproxy tlli-cache
TLLI cache timeout 10s
 TLLI c2200024 -> NSE(02001/BSS) valid 10s
TLLI cache contains 1 entries

OsmoGbProxy# show gbproxy imsi-cache
IMSI cache timeout 10s
 IMSI 262420000001000 -> NSE(00102/SGSN): valid 5s
 IMSI 262420000000000 -> NSE(00101/SGSN): valid 3s
IMSI cache contains 2 entries

Change-Id: I03f1050573de9b241eb4fa82460c434155c15c6a
Related: OS#4951, OS#4472
2021-01-18 18:47:41 +01:00
Daniel Willmann 4380f94cf2 gbproxy: Define and use help string for gbproxy
Change-Id: Ic9336c83147903e5af6622179f9394130f969a77
2021-01-18 18:46:32 +01:00
Daniel Willmann 0d170d61aa gbproxy: Fix VTY cmd name
Change-Id: I5bb5f7cf93779a7a07965f2f35fdb59a7a2b731b
2021-01-18 18:46:32 +01:00
Daniel Willmann fb5ccb468a gbproxy: Remove unused variable assignment
Change-Id: I79684e0b27211d756912a63be5cae890ea44be82
2021-01-17 13:51:57 +01:00
Daniel Willmann b96d5a6ead gbproxy: Move helper function to a more logical place
Change-Id: I3b39991fe2441334aaa9dda6c33c0b7b4484e455
2021-01-17 13:51:57 +01:00
Daniel Willmann 6ff8d21fed gbproxy: Use C-style comments
Change-Id: Ia3d27ef79a3370147395e7441149fd1231a760d5
2021-01-17 13:51:57 +01:00
Daniel Willmann 5b1122f717 gbproxy: Use IMSI cache to handle PAGING_PS_REJECT
Change-Id: I7d91d9ecfba757dc81edcf05efb7a2158348099d
Related: OS#4472, OS#4951
2021-01-17 13:51:57 +01:00
Daniel Willmann 914484d561 gbproxy: Implement IMSI cache
When SGSN pooling is enabled we need to route some responses based on
IMSI back to the correct SGSN, e.g. PAGING_PS_REJECT.

The IMSI cache keeps track of this IMSI <-> NSE(SGSN) mapping.

Change-Id: If0a8d6cc1d63f2fb2c395cc5d4373a915bc2cb87
Related: OS#4951, OS#4472
2021-01-17 13:51:57 +01:00
Oliver Smith b6343a72d8 contrib/jenkins: don't build osmo-gsm-manuals
Related: OS#4912
Change-Id: I3fc43b1afb7cdfd2b78c062e36ccf2491700f988
2021-01-14 14:58:41 +00:00
Daniel Willmann ef0c2a4b85 gbproxy: Increase TLLI cache timeout to 10s
The range of SUSPEND/RESUME timers T3/T4 is up to 10s so we should keep
the cache entries valid for this time.

Fixes: OS#4895
Change-Id: I9e88e49981098831f3255938deb868f4503f650f
Related: SYS#5235
2021-01-13 18:21:48 +01:00
Daniel Willmann 02b24c5a44 gbproxy: Implement TLLI cache and use it for SUSPEND/RESUME
When routing a SUSPEND/RESUME we need to keep track of where it came
from so we can send the (N)ACK back to the correct BSS. Use the TLLI
which is present in both messages to cache and retrieve the correct BSS.

A timer runs every two seconds and expires entries that are older than
the timeout (hardcoded to 5 seconds for now).

Related: SYS#4865, OS#4472
Change-Id: I42adf70f560d2bb358a9e1c7614281e8d2967568
2021-01-11 15:09:05 +01:00
Alexander Couzens cd7c7a74b7 configure.ac: define a c standard instead of using the compilers default
Change-Id: I9867adbed211db0a7b42ac3557f56c3042a67936
2021-01-08 02:32:33 +00:00
Daniel Willmann ddb3fbb0f2 Fix gbproxy_sgsn_by_tlli wraparound
Change-Id: I74ecb655f4d433f7ac14d00d934d237325aab606
Related: SYS#4865, OS#4472
2021-01-05 18:29:39 +01:00
Vadim Yanitskiy e245677cdd gb_proxy_peer: fix NULL pointer dereference in gbproxy_sgsn_alloc()
LOGPSGSN_CAT() dereferences sgsn->nse in order to get NSEI.

Change-Id: I1c592dd6f0da5f167290f38de3b30a1a04c4313d
Fixes: CID#215868
2021-01-05 15:26:30 +01:00
Vadim Yanitskiy 1c33e4af05 gb_proxy_peer: sgsn can never be NULL in gbproxy_sgsn_by_nri()
Redundant check makes Coverity think that sgsn can be NULL...

Change-Id: Iffdeb18e0a5575a2a09129eed9b8a41c3340dcbf
Fixes: CID#215870
2021-01-05 14:38:05 +01:00
Daniel Willmann 3844da98f8 gbproxy: Add VTY command to override the node selection function
This is mainly useful when testing SGSN pooling

Change-Id: I2894320413dbd0b9aec9a9bc9b88ce7cdeed206b
Related: SYS#5115, OS#4472
2021-01-04 18:33:52 +01:00
Daniel Willmann dee0bcc8e9 gbproxy: Add config option to name an SGSN
This is useful for logging and configuration to identify an SGSN by name

Change-Id: I2a3410dd9bebb242957e13a63ed70e447204203c
Related: SYS#5115, OS#4472
2021-01-04 18:33:52 +01:00
Alexander Couzens 51730f7a8c gbproxy: use ns2 vty2
The new gprs_ns2 vty2 support ip-sns and reorganize the
network service configuration

Depends: I163279cf57e84198dc8c53e1c109f5a9474670e9 (libosmocore)
Change-Id: I2a18dcf035f1fc7304a0c7c7c83b5e8e15429d2b
2021-01-04 16:27:41 +00:00
Alexander Couzens f23e2db752 sgsn: Use the new NS2 api
The new NS2 api supports NSE with multiple NS-VC and contains a NS-VC
fsm. FR/GRE support is not working.
The configuration is compatible except for FR/GRE.

Relates: OS#4629
Depends-on: Iaad7b53d44338e5dd81dc2202f23bdcb715af804 (libosmocore)
Depends-on: I6cef42749555e577d5573f2ed8b8bce4cf842a98 (libosmocore)
Change-Id: I92a3bcaf166b091a22d74c7c1586964d33d7cc9d
2021-01-04 16:06:13 +00:00
Harald Welte 8a33528854 gbproxy: Fix build on Deiban 8
[  258s]   CC       gb_proxy.o
[  258s] gb_proxy.c: In function 'gbproxy_select_sgsn_bvc':
[  258s] gb_proxy.c:293:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
[  258s]   for (int i = 0; i < ARRAY_SIZE(cell->sgsn_bvc); i++) {
[  258s]   ^
[  258s] gb_proxy.c:293:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your
code

Change-Id: I717410b11f1ee38d49e9ca5af593cb59a244ae0a
2020-12-30 12:13:56 +01:00
Daniel Willmann 00c1f91ed7 gbproxy: Add comments to sgsn functions
Change-Id: I8c96308045112f25292b0e57c306d8486a2524cc
2020-12-29 16:41:43 +01:00
Daniel Willmann 8d382c5337 gbproxy: Add SGSN pooling support
Change-Id: I58b9f55065f6bd43450e4b07cffe7ba132b1fd9b
Related: OS#4472
2020-12-29 16:41:29 +01:00
Daniel Willmann ef3c9af0f9 gbproxy: Add SGSN NRI configuration
In order to support SGSN pooling we need to configure the various NRI
parameters such as the bitlen, NULL NRI, and which NRIs are assigned to
which SGSN.

Related: OS#4890, OS#4472
Change-Id: Id67592aa7712e5e04e7264b2fb8f26d57eb7e69e
2020-12-29 16:38:49 +01:00
Harald Welte 5a21f07dff gbproxy: Add "show gbproxy cell ..." VTY command
This allows the user to inspect CELL related gb-proxy state.

Change-Id: Iad1e8bbc358df9a3b3392404a70445a169dfebd5
2020-12-22 19:33:34 +00:00
Daniel Willmann ea0b5d0df6 gbproxy: Fix confusing log message in gbprox_relay2nse
This function is now used to transmit messages in both directions,
BSS->SGSN and SGSN->BSS.
Print the actual direction in the logs

Change-Id: I31682156dfe88f7ca121a711968e625caed8bd5e
Related: OS#4472
2020-12-22 12:32:16 +01:00
Daniel Willmann 3054213e87 osmo-gbproxy: Initialize all hash_maps
Change-Id: I9578af77a7b2f61b57c918a703768ca20221c294
Related: OS#4472
2020-12-21 18:44:08 +01:00
Alexander Couzens 3326ba7d4c sgsn: check for NULL of gprs_subscr_get_or_create()
gprs_subscr_get_or_create() can return NULL if no memory can
be allocated. Detected by the compiler on Ubuntu s390x.

Signed-off-by: Steve Langasek <steve.langasek@ubuntu.com>
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>

Change-Id: I86b3652d46bdd581fe6cbab16b52395a0daaa082
2020-12-15 11:57:16 +01:00
Harald Welte b6b2f14197 gbproxy: rename vty command "show gbproxy ..." to "show gbproxy bvc ..."
we have other objects to show, and the orthogoanl way to do this is
to rename the existing one.

Change-Id: I7836a37533a2de81720acedda712d61f429df12c
2020-12-14 12:21:17 +01:00
Harald Welte 959f77e34b gbproxy: Improve VTY state introspection
* allow to print not only BSS-side BVCs, but also SGSN-side
* differentiate between SIG and PTP BVC
* print the actual BVC FSM state name instead of just UNBLOCKED/nothing

Change-Id: I8e09a9dc296b15094d191b0451d04457c815d116
2020-12-12 19:12:52 +01:00
Harald Welte 9e917647ae gbproxy: Implement scaling of BVC flow control in SGSN pool
When there are multiple SGSNs inside a pool, we need to decide
how much of the per-BVC capacity advertised by the BSS in its
BVC-FLOW-CONTROL we should announce to each of the pool members.

A conservative approach would be to advertise 1/num_sgsn, but
there may also be use case where over-provisioning (announcing more
than an equal share of the capacity) is useful.

Hence, let's introduce "pool bvc-flow-control-ratio <1-100>" in order
to allow the administrator to decide.

Related: OS#4891
Change-Id: Ibe5addf657e7237499ca0205bacfe999ecd1e771
2020-12-12 19:12:18 +01:00
Harald Welte 784c59f87e gbproxy: Add FSM related VTY commands
Change-Id: Id84ce52722d705eb25a12ee6f108ad3107a9f8d2
2020-12-12 17:33:49 +01:00
Harald Welte 1aa0ae9db1 gbproxy: Fix segfault when receiving PAGING for unknown destination
The 'nse' variable had been used both as the input argument of the
SGSN-side NSE, as well as a loop iteration variable.  Let's separate
this clearly.

Closes: OS#4904
Change-Id: I375a219cd72eb11a9a0cb7d55a3efb7b83b771ac
2020-12-12 16:16:57 +01:00
Harald Welte cab8588242 gbproxy: (Re)allocate SGSN-side PTP BVC even if CELL already exists
After a SGSN-side RESET of the SIG-BVC, all PTP BVC on the SGSN side
are gone.  However, the CELLs and the BSS side BVCs continue to exist
(as there may be other SGSNs).

So if a PTP-BVC RESET from the BSS side arrives in such a situation,
and we can find a matching CELL, we still need to check if we need
to create any SGSN-side PTP BVCs instead of simply being happy with
the CELLs already existing.

Change-Id: I1d1562e421082fa4399c73ac31290e4c95718e49
Closes: OS#4903
2020-12-12 15:18:05 +01:00
Harald Welte 4b4c997dc5 gbproxy: Copy RA-ID from BSS side BVC to CELL and SGSN-side BVC
Change-Id: I18669f269c4a959fcfa51885aafb719b662a7f8a
Related: OS#4894
2020-12-12 15:17:33 +01:00
Daniel Willmann c4c1db9e78 gbproxy: Fix bvci check in gbprox_rx_ptp_from_*
The check for bvci in _rx_ptp_from_* was always false.

Change-Id: I16a0284ba3201c146c307db6997a416589d7e693
Related: OS#4472
2020-12-10 18:11:47 +01:00
Harald Welte 61ff273365 gbproxy: Implement handling of BVC Flow Control
We must locally terminate + acknowledge any inbound BSSGP-FC-BVC,
and ourselves trigger the transmission of BSSGP-FC-BVC to each
SGSN in the pool.

Related: OS#4891
Depends: libosmcoore.git Ie59be6761177c43456898be9148727f15861a622
Change-Id: Ib6495e5de4bfcf748a98e08743d1a8f2565f8b69
2020-12-10 18:09:21 +01:00
Harald Welte bf69833b6d gbproxy: Don't create an extra msgb copy for SGSN DL SIG
That copy may have made sense while we were doing patching/buffering,
but we're not doing any of that anymore.

Related: OS#4472
Change-Id: I207a869ffac8bf60104f80f9ed58faf0021e5e95
2020-12-10 18:08:58 +01:00
Harald Welte 7cb76a4321 gbproxy: Introduce new DOBJ log category; log object allocation/release
Related: OS#4472
Change-Id: I43bcbcda8667d193e7a17fd8e8e9109597b01484
2020-12-10 18:06:34 +01:00
Harald Welte c91f53ca0a gbproxy: Use "(nsei << 16) | bvci" as rate_ctr_group index
As we now have gbproxy_bvc on both the SGSN and the BSS side
with the same BVCI, using the BVCI alone will no longer render
unique indexes.

Related: OS#4472
Change-Id: I13f3c9e69562a56ad7d3742fdeb2ba48f134fdaa
2020-12-10 18:06:06 +01:00
Harald Welte 5687ae65fa gbproxy major rewrite for SGSN pool support
Rewrite of a large part of osmo-gbproxy in order to prepare
for SGSN pool support.  The amount of changes are of such fundamental
nature that it doesn't make sense to try to split this into hundreds
of individual changesets.

Related: OS#4472
Change-Id: Ie0746f17927a9509c3806cc80dc1a31d25df7937
2020-12-10 18:05:52 +01:00
Daniel Willmann 7c86a1efce mm_state_gb_fsm: Handle implicit detach from mm_standby
Change-Id: I63d04a2dcdc17b4df6616c515641c435d919c787
Related: OS#2737
2020-12-10 15:25:51 +00:00
Harald Welte 453a51d1a1 migrate to DLBSSGP as log sub-system for BSSGP
Change-Id: I69ee10b6fad1da2053cf6f3ae99d3ecf62a144ce
Depends: libosmocore.git Change-Id I506190aae9217c0956e4b5764d1a0c0772268e93
2020-12-10 15:42:15 +01:00
Harald Welte a54ed46bac gbproxy: Log FSM timeouts
Change-Id: I5c48e42083ab6f8622808457ca3f017adf35cdff
2020-12-07 18:30:01 +01:00
Harald Welte 052d855449 gb_proxy: Use osmo_tlv_prot_parse() to validate mandatory IEs
We recently introduced code to libosmocore which allows us to validate
the mandatory IE presence (and length) in a generic way.  Let's use it.

Change-Id: I0ea3f5f9566d9bf5a8429c3ee748e3e90cda6cd7
Depends: libosmocore.git I7e4226463f3c935134b5c2c737696fbfd1dd5815
2020-12-07 18:22:20 +01:00
Harald Welte 11ad5713f2 gbproxy: use gbprox_relay2peer() whenever possible
gbprox_relay2peer() is a small wrapper around gbprox_relay2nse(),
but as it manages the transmit error counter, we should use it whenever
possible.

Change-Id: I85ab49ca0a25dd7c54b88c4fdc8838843e6d2209
2020-12-07 18:22:20 +01:00
Harald Welte d651edcce0 gb_proxy: Introduce more validation / constraint checks
* ensure the BSSGP PDU header length before reading pdu_type field
* ensure we never process uplink PDUs in downlink and vice-versa
* ensure we never proceses PTP PDUs on SIGNALING BVCI and vice-versa

Change-Id: I6e40aed0283f1a0860ab273606605f7fb28717cf
Depends: libosmocore.git I7e4226463f3c935134b5c2c737696fbfd1dd5815
2020-12-07 18:22:20 +01:00
Harald Welte 56f5e74d7d gbproxy: Delete gbproxy_test
The test is actually performing invalid operations such as
sending empty NS packets without even a BSSGP header - and assumes
that gbproxy should route those.

Given that we have a much more comprehensive tset suite in
GBProxy_Tests.ttcn in osmo-ttch3-hacks.git, it makes sense to remove
the testsuite.  It may contain many more wrong assumptions, or
assumptions that no longer hold true with the "gbproxy 2020".

Change-Id: I053aebab6bf5d0ee955f2221bf27925b36140cf3
2020-12-07 18:22:20 +01:00
Harald Welte 4bf53ef19a gb_proxy: cosmetic: Use function rather than open-coding is_sgsn
Change-Id: Id41d74ebd41e5084377a986f4a1acd53cae12bc1
2020-12-05 17:50:50 +01:00
Harald Welte 91bb720449 gbproxy: Remove patching, TLLI-tracking and SGSN2 support
Those features were introduced a long time ago for one specific use
case at one specific user, and they are not needed anymore.  They
complicate the code base significantly and are hard to maintain with
all the upcoming modifications regarding SGSN pool supoprt.

Change-Id: Id9cc2e1c63486491ac5bb68876088a615075fde6
2020-12-05 14:05:36 +01:00
Harald Welte 993d3f4d9a gbproxy: convert nse->bvcs from llist_head to hashtable
For the common lookup-by-bvci, this should reduce the computational
complexity significantly.

Depends: libosmocore.git I8ef73a62fe9846ce45058eb21cf999dd3eed5741
Change-Id: Ic8e9279fd61a3c514fc3203429f36a468f0e81d3
2020-12-05 13:55:06 +01:00
Harald Welte 78db244b42 gbproxy: convert bss_nses from llist_head to hashtable
For the common lookup-by-nsei, this should reduce the computational
complexity significantly.

Depends: libosmocore.git I8ef73a62fe9846ce45058eb21cf999dd3eed5741
Change-Id: Idbb6a362332bb6e3ce22102e7409ae80d0980f44
2020-12-05 13:49:37 +01:00
Harald Welte 0e1b791c81 gbproxy: Rename gbproxy_cfg.nses to gbproxy_cfg.bss_nses
We will soon also have a list of sgsn-side NSEs, and we need to
differentiate those.

Change-Id: If5accec0c70c01b88927ea07beba6f6488bd9d5a
Related: OS#4472
2020-12-05 12:08:10 +01:00
Harald Welte 8cd74407ab gb_proxy: Rename gbproxy_peer to gbproxy_bvc
I cannot really read the code while it contains its historical weird
naming.  A "peer" used to be a strange amalgamation of NSE + BVC,
while in reality we can have any number of BVC on top of each NSE.

We recently started to split the peer into a gbproxy_nse_peer + gbproxy_peer.
This takes it one step further and renames gbproxy_peer to gbproxy_bvc,
as that's really what it is.

Change-Id: Iae01067282a6401f6af4cab731202872d2cdb080
2020-12-05 12:06:42 +01:00
Harald Welte 6c4c6f08ae gb_proxy: Use TLVP_PRES_LEN instead of TLVP_PRESENT
With TLVP_PRESENT we only check if a tiven TLV/IE is present,
but don't verify that it's length matches our expectation.  This can
lead to out-of-bounds reads, so let's always use TLVP_PRES_LEN.

Change-Id: I1519cff0f6b2fe77f9a91eee17e0055d9df1bce6
2020-12-05 11:44:39 +01:00
Harald Welte fb7f8c5f07 gbproxy: Send BVC-STATUS if BSS sends us BVC-RESET without mandatory IEs
Change-Id: I198ca70f5e0947735f76d32cd9d3eed159349a94
2020-12-05 11:44:38 +01:00
Daniel Willmann 9a2fc908df gbproxy: Delete gbproxy_nse in delete-gbproxy-peer VTY command
The gbproxy_nse is created when the signalling BVC is resetted. When
we delete all bvcs of an nsei we need to remove it as well.

Change-Id: I997b29fef93188565f81bd403bc68840473958c3
Related: SYS#5002
2020-12-04 17:49:19 +01:00
Daniel Willmann e794c1f00b gbproxy: Allow gbproxy_nse_free(NULL)
Calling free() with a null-pointer is usually supported and does
nothing. Change gbproxy_{peer,nse}_free() to reflect that behaviour.

Change-Id: Ia32084f81ca8f8cb9ddea3adabd4b44fd766f1c7
2020-12-04 17:49:19 +01:00
Daniel Willmann bd356a6d84 gbproxy: Add newline to log message
Change-Id: I91a076872b5d744a237f6d325857b95362455e8d
2020-12-04 01:31:05 +01:00
Daniel Willmann e8c8ec9683 gbproxy: Add BVC log filters
Since gbproxy doesn't use bssgp_rcvmsg from libosmocore we need to
implement our own filtering.

Change-Id: I4d1b57b89990945d307f27a58a7f630be0253d5b
Related: SYS#5232
2020-12-04 01:31:05 +01:00
Harald Welte 55253716d2 gbproxy: Cosmetics: use longer lines
Change-Id: I9426bf4be2faa0da7848cb102b20cc539948b3f5
2020-12-02 23:06:37 +01:00
Harald Welte 1239cf457e gb_proxy: Slightly restructure processing of BSS-originated BVC-RESET
* explicit else clause rather than implicit
* don't continue processing if mandatory BVCI missing from message

Change-Id: I038576b91ae1ece149149d8663de7b8495d24e06
2020-12-02 23:03:22 +01:00
Harald Welte ac44d6b2a2 gbproxy: Move BSS-side BVC-RESET processing to its own function
The switch clause was getting a bit too long/nested, let's add
a separate gbprox_rx_bvc_reset_from_bss() function.

Change-Id: If262566e275cca96035045d1194ce102c0942eb6
2020-12-02 23:01:47 +01:00
Harald Welte c8d98ac8f9 gb_proxy: Broadcast SGSN-INVOKE-TRACE and OVERLOAD
Both BSSGP messages appear from the SGSN in downlink on BVCI=0.

We must send a copy of this message to each of the BSS side NSEs.

Change-Id: Ia19791b143989eb1490f461d88b9edbd8e3b82be
Closes: OS#4875
2020-12-02 22:45:42 +01:00
Daniel Willmann 6626bbc215 gbproxy: Add todos encountered while going through the code
Change-Id: I8c3a788f008d3cb2d067d974c2b1b9ca45185d8d
2020-12-02 22:42:48 +01:00
Daniel Willmann 103a7ec033 gbproxy: Change generic LOG messages so BVCI/NSEI fmt is consistent
We actually need to alter our compiler flags to avoid -Werror=trigraphs
creating trouble:

gb_proxy.c: In function ‘block_unblock_peer’:
gb_proxy.c:875:37: error: trigraph ??) ignored, use -trigraphs to enable [-Werror=trigraphs]
  875 |   LOGP(DGPRS, LOGL_ERROR, "BVC(%05u/??) Cannot find BSS\n",
      |

Fixes: SYS#5233
Change-Id: I93296353dd964602699480faae1248096e331c6a
2020-12-02 22:42:42 +01:00
Daniel Willmann 6e8ed2784e gbproxy: Use LOG macros for NSE/BVC
Change-Id: If445f18bc8390c338b5aeb9085951ea392e68b3a
Related: SYS#5233
2020-12-02 17:47:49 +01:00
Daniel Willmann 7418797027 gbproxy: Add logging macros for NSE and BVC
Change-Id: Ibb2bcf3344bdc750869223b4c4861b4bbc6f417c
Related: SYS#5233
2020-12-02 17:17:17 +01:00
Harald Welte d97ff681c3 gb_proxy: More precise + readable log messages
* use string representations instead of magic numbers whenever possible
* make text actually describe the specific case, rather than copy+paste
* proper order (foobar indication) not (indication ..... foobar)

Change-Id: I232038da26a9963763c5fc9051b87c9182b27d94
2020-12-01 11:56:57 +00:00
Pau Espin 83142beca2 gmm: Introduce comment to ease addition of Network feature support IE later
Change-Id: I131cba3de3c80c61d5549e7c31b4eacaaeddb040
2020-12-01 11:47:58 +00:00
Pau Espin 8c3d7fd263 gmm: fix build without define PTMSI_ALLOC
Change-Id: Idcac01c4634af81ef884dc2b1b20dec3f8d12236
2020-12-01 11:47:58 +00:00
Daniel Willmann 9e583c8d89 gbproxy: Separate function to move gbproxy_peer to different nse
Change-Id: I0a8b1e4b78384ea99d50109f050ca501b18ba5d9
Related: SYS#5226
2020-11-30 18:30:35 +01:00
Daniel Willmann 5937dfd39f gbproxy: Only send paging to each matching NSE once
Fixes: SYS#5226
Change-Id: Ia33e7816b354266b9d2659ef96b798db60c134f3
2020-11-30 18:30:35 +01:00
Daniel Willmann cafa3881ad gbproxy: Ensure BVC0 is reset before handling PtP BVCs
Change-Id: I9c67f973f7bca00e8eb22a024ef2282c007dd84b
Related: SYS#5226
2020-11-30 18:30:35 +01:00
Daniel Willmann 447ad441e6 gbproxy: Add NSE peer that can have multiple gbproxy_peers
We want this level of indirection to support multiple BVCs per NSE. The
current code assumes that an NSE only has one BVC which breaks messages
on the signalling BVC which should only be sent once to an NSE
regardless of the number of BVCs it contains.

Change-Id: I97cc6c8f8c0f1b91577ab8f679c4ae217cc88076
Related: SYS#5226
2020-11-30 18:30:35 +01:00
Daniel Willmann f7a1aed0e6 gbproxy: Remove test testing NSVCI change
This was overlooked in commit 82182d which already removed lots of
NS-specific code in gbproxy_test.c

From that commit message:
"""
Since NS2 has a different abstraction we mock up the prim send/recv
functions and don't test NS like the old tests did.
"""

Change-Id: Ic1d7e646e633c9fa62812f5005ed10c0108a06f2
Related: SYS#5226
2020-11-30 18:26:38 +01:00
Harald Welte eb4233e505 gb_proxy_peer: Add some FIXMEs regarding invalid assumptions
Change-Id: Ibf3d4a3bd58e706dfa44e8cc9ff4823a7759dea5
2020-11-27 23:15:18 +01:00
Harald Welte 2636e89ff0 gbproxy: Pass TLLI as LSP towards NS to facilitate load sharing
Change-Id: I6aef26c126b330a393fc2be5f558b6d5f1d9f7f4
2020-11-27 23:15:18 +01:00
Pau Espin bcd7709452 sgsn: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: I65f70a53b6982bff9ea4bd6ff786d8a2f8181eac
Fixes: OS#4865
2020-11-25 18:28:55 +01:00
Pau Espin 7ffc6603e2 gtphub: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: I1cab4a716cf2fda6353f698888edbcec6228d78b
Fixes: OS#4865
2020-11-25 18:22:21 +01:00
Pau Espin 826eaa327b gbproxy: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: I97559b29328101c7cf340aaf1052c0c406634065
Fixes: OS#4865
2020-11-25 18:22:12 +01:00
Harald Welte 952fbf20c9 gprs_gb_parse: Add function to determine TLLI from encoded BSSGP
This will be needed to use the TLLI as link selector parameter
in osmo-gbproxy in an upcoming patch.

Depends: libosmocore.git I397b32a6e6ea3e9d218446138cceafa9b27685dd
Change-Id: Ia6d5300e63ad23987cbdca824db620305bd583d7
2020-11-24 11:33:16 +01:00
Harald Welte 8553f5532a gbproxy: Implement paging to entire BSS area
When we receive a PAGING for PS or CS with destination to the entire
BSS area, we need to iterate over all peers and send one copy of the
paging to each of them.

Change-Id: Iecf244238500a354d5a5b40c76f0c0bb8f8c2511
2020-11-24 11:33:16 +01:00
Harald Welte 3375fa4d64 gbproxy: Properly implement paging to LAC/RAC
There may very well be many PCUs connected within the same RAC or LAC.

This means we'll need to iterate the list of peers and dispatch it to
each matching peer.

Change-Id: I2c44959661fb53730586f4347cbfbbcece065e13
2020-11-24 11:33:12 +01:00
Harald Welte e1ba4239b4 Use osmo_fd_*_{disable,enable}
Change-Id: Ia207cd2ee68d657ee88cb0152a5b1faa4161c967
Depends: libosmocore.git Idb89ba7bc7c129a6304a76900d17f47daf54d17d
2020-11-11 20:15:09 +00:00
Daniel Willmann 638cddd8f1 osmo-gbproxy: Implement nsvc-state ctrl command
Change-Id: I0beb572103803f3ee4ecb28d9bf2e3139e0f8aa4
2020-11-11 20:11:50 +00:00
Daniel Willmann 58937ce333 configure.ac: Require python3 for ext_tests
The python scripts already use #!/usr/bin/env python3 so it was pure
coincidence that the tests are working.

Change-Id: I96ac31e7862fe102e5baee0c2e25458ff0451a50
2020-11-09 10:54:14 +00:00
Daniel Willmann 02f2c34f8a osmo-gbproxy: Free msgb in ns2 prim callback
Commit cce88282388f in libosmocore changed the msg ownership model - the
callback that the user registers is now responsible for freeing the msg.

Change-Id: Iee940aba7d94afefb5957dbe5f0b04dcf951b31c
Related: SYS#4998
2020-11-09 10:54:09 +00:00
Daniel Willmann 62fa6198ae Let libosmocore handle VTY parent node tracking
* is_config_node is deprecated, so don't set it
* go_parent_cb is only used if we want to do special stuff upon exiting
  a node, in osmo-sgsn and gtphub only osmo_ss7_vty_go_parent() needs to
  be called

Change-Id: I2008dd9026922d29ee703c59e70d3fecced0ee18
2020-11-06 22:21:21 +01:00
Daniel Willmann c42331f359 gbproxy: Get the peer if paging by BVCI on SIG_BVC
Currently the code reports routing the message to a BVCI but never even
tries to get the peer for it.

Change-Id: Ic72f0f03e5886ab76404915fc60a2796e6881a7a
Related: SYS#4998
2020-11-06 22:21:21 +01:00
Daniel Willmann 15c9da226b gbproxy: Add todo for BVC RESET logic
When we receive a signalling BVC RESET from the SGSN we want to reset
the signalling BVCs for every peer.

Change-Id: I98c1a53d0e4b9a988e9ddec97ce0c67ded6f6326
Related: SYS#4998
2020-11-06 22:21:16 +01:00
Daniel Willmann 8bca8de5cb gbproxy: Whitespace fixes
Change-Id: Id70c15050b6314fdcd452e89e358d657e1f86e57
2020-11-06 18:45:05 +01:00
Alexander Couzens 82182d09c7 Port gbproxy to NS2
Since NS2 has a different abstraction we mock up the prim send/recv
functions and don't test NS like the old tests did.

Related: SYS#4998
Change-Id: Iecfd0408a35a11638d254c1db3c1d477b1a11524
2020-11-06 18:45:05 +01:00
Pau Espin 08395b3369 process_ms_ctx_status: Fix crash deleting PDP Ctx if GTP side was already released
sgsn_delete_pdp_ctx() should never be called without checking if the GTP
side is available, since it may happen that it has already been released
by the time the mmctx tells us the pdp ctx is gone on the MS side.

Fixes: OS#4817
Change-Id: Ie618874545172ec98355174a2ee041fc4a8bec16
2020-10-23 13:25:13 +02:00
Pau Espin 25998ddcc5 process_ms_ctx_status: refactor to avoid code duplication
Change-Id: I1d1a1284c1563b3a5598e79d8ffd544288de4d62
2020-10-23 13:23:18 +02:00
Pau Espin 60581ae7c9 sgsn_delete_pdp_ctx: Add documentation and assert assumptions
This function is only expected to be called if the GTP side of the PDP
ctx is still alive, since it will tear down the GTP side and then finish
the pending MS side if needed.

The asserts are added to ease debugging since it was noted that a few
callers were using this function without properly checking the status of
the pdp ctx.

Related: OS#4817
Change-Id: I4248e2e9846fec5ae2c8557384da2deb86668c50
2020-10-23 13:04:48 +02:00
Keith Whyte c70e8388c7 VTY: Add gtp state-dir command
The SGSN initialises GTP with gtp_statedir of "./" which may
not be the desired path for writing the gsn_restart file.
When starting from systemd for example, we might write
to the system root.

This patch allows override via the config file.

Closes: OS#4820
Change-Id: Ib3ffb7fd6ea1d9b0286111d8c2cba9da5394ca58
2020-10-20 13:21:37 +00:00
Pau Espin 5ce54ba1e6 Fix crash rx DeactPdpReq while waiting for DeactPdpAck after gtp side is freed
Scenario:
1- For an unknwon reason, sgsn sends DeletePdpCtxReq on GTP towards GGSN.
2- GGSN answers with Error Indication to that pdp ctx which calls
   gtp_freepdp()
3- gtp_freepdp() calls libgtp callback cb_delete_context() before freeing the
   pointer, in osmo-sgsn callback points to cb_delete_context(), which
   removes pctx->ggsn and tries to drop the pdp on the NS side by sending a
   DeactPdpReq.
4- While waiting for DeactPdpAck, the MS/PCU sends a DeactPdpReq, and
   code was unconditionalyl trying to release the gtp side without checking
   if it was alreay released, using pctx->ggsn==NULL and crashing.

This is basically the same logic already in place in regular path
gsm48_rx_gsm_deact_pdp_ack.

Related: OS#4817
Change-Id: I02587a3dc812823d893fc00b904142b75fd190b9
2020-10-19 15:06:55 +00:00
Pau Espin ff5b59a821 Log error if pdp ctx is freed while holding an active timer
Change-Id: Iae520be36377b27a12441defa722fd41a3cdba0a
2020-10-19 15:06:55 +00:00
Harald Welte be2330fde4 Use osmo_fd_setup() whenever applicable
Change-Id: I68d14b1c19dd8f1764fdf65afe1a957278255e40
2020-10-19 10:50:45 +00:00
Pau Espin 8d2d7db818 contrib/jenkins: Enable parallel make in make distcheck
Change-Id: I423c4b1d854fa6ec7df504353ce666766ba0c787
Related: OS#4421
2020-10-12 19:34:04 +02:00
Alexander Couzens 92ef0c8675 gtphub: fix compilation with gcc 10.2.0
gtphub.c:2915:2: error: ‘snprintf’ argument 4 may overlap destination object ‘buf’ [-Werror=restrict]
 2915 |  snprintf(pos, len, " port %s", portbuf);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Be better safe and use the stack instead of byte counting in the buffer.

Change-Id: Ied9665ce6bd2633797bbc3a2171e911ada357a22
2020-10-03 20:37:15 +02:00
Alexander Couzens 68d9c5a468 gtphub_test: fix compilation error on gcc 10.2.0
Ensure dump && hex can't be zero.

gtphub_test.c: In function ‘_reply_is.constprop’:
gtphub_test.c:535:3: error: ‘%s’ directive argument is null [-Werror=format-overflow=]

Change-Id: Id27bf46855a228935fe706584f9b27cf3facf623
2020-10-02 20:44:34 +00:00
Philipp Maier ef6205ba00 gprs_sndcp: fix use after free
When compression is turned on, an extra buffer "expnd" is allocated in
the context of msg. This means that when msg is freed, expnd is freed as
well and there is no need for freein it explcicitly, which, when it is
done after freeng msg, causes talloc to abort.

Change-Id: I8959b75e241ffabf9fa34c4cf014721584372b26
2020-10-02 17:38:12 +02:00
Daniel Willmann 86336af2a3 gbproxy-usermanual: Explain BSSGP/BVC handling
Related: SYS#5005
Change-Id: I383fcd3864a94177f13909c6b8c15648900d3201
2020-09-25 09:54:26 +02:00
Keith Whyte 6d92f148aa Fix Radio Priority in MM Attach and PDP Context Activation
3GPP TS 24.008 Section 10.5.7.2 Radio Priority states that the Radio Priority IE is
3 bits as follows:

--------------------------------------------
0 0 1   priority level 1 (highest)
0 1 0   priority level 2
0 1 1   priority level 3
1 0 0   priority level 4 (lowest)

All other values are interpreted as priority
 level 4 by this version of the protocol.
--------------------------------------------

However at least the MediaTek MT6753 and MT6592 have been
observed to interpret a value of 0 0 0 in an undetermined way
resulting in lack of access to RACH in the cell.

Fixes: OS#4506
Change-Id: I810cd541eb5764ee3f2c238bcd3a10836228d0b5
2020-09-21 00:18:48 +02:00
Alexander Couzens 27a0bf70e7 gmm: on invalid RA id reject the MS with an implicit detach
As long the SGSN doesn't support PS handover treat unknown RA as invalid
and do an implicit detach.

Fixes ttcn3 crash when an RAU happen within an Attach Request

Change-Id: I6a0b335d51f58c26349f7e0a62b2107d7d351d07
2020-09-20 09:52:24 +00:00
Alexander Couzens d3c3ddeb51 gprs_llc: _bssgp_tx_dl_ud: ensure the LLME is valid before using it
In rare cases the LLME is NULL even when the mmctx is valid.
Ensure not accessing a NULL pointer.

Change-Id: Id9fdfb0d88264671546f8dfc4655032ff27bf43e
2020-09-18 18:32:04 +02:00
Pau Espin e6c5b4a970 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: I2f599e1aa449d44136ef20ba5f516ca9b61f3223
2020-08-21 18:07:11 +02:00
Pau Espin aae7daff81 Support setting rt-prio and cpu-affinity mask through VTY
Change-Id: I1af1b154d14de6d6d6fba08f15f167f4b2ed9aa2
Depends: libosmocore.git Change-Id If76a4bd2cc7b3c7adf5d84790a944d78be70e10a
Depends: osmo-gsm-masnuals.git Change-Id Icd75769ef630c3fa985fc5e2154d5521689cdd3c
Related: SYS#4986
2020-08-18 13:50:00 +02:00
Pau Espin b32936d823 doc: Update VTY reference xml file
Change-Id: I787bbc254ef10766fe8d480ffd93a16d9926a50e
2020-08-18 13:46:17 +02:00
Pau Espin d5dc143001 configure.ac: Fix trailing whitespace
Change-Id: I5abdce5daef43dad772bf52576b47c0867d65c98
2020-08-18 13:45:09 +02:00
Vadim Yanitskiy 65a5a0a27b debian/control: change maintainer to the Osmocom team / mailing list
Change-Id: Ic6956c4d5cc9913c06b9e293dc5bb156f6510285
2020-08-13 16:09:03 +07:00
Harald Welte 9d16b14345 Send a BVC-RESET to all persistent Gb interfaces at start-up
3GPP TS 48.018 Section 8.4:

> After any failure affecting the NSE, the party (BSS or SGSN) where
> the failure resided shall reset the signalling BVC. After sending or
> receiving a BVC-RESET PDU for the signalling BVC, the BSS shall stop all
> traffic and initiate the BVC-RESET procedure for all BVCs corresponding
> to PTP functional entities of the underlying network service entity. The
> BSS must complete the BVC-RESET procedure for signalling BVC before
> starting PTP BVC-RESET procedures.

TODO: We should not just trigger a single outbound BVC-RESET message,
but we should re-transmit them until we get a response.   This would
likely entail adding FSMs to libosmogb, which we will leave for a later
point - it's anticipated that the NS + BSSGP code is undergoing quite
some changes in the coming months anyway, so leave it for then.

Change-Id: I0b46035b40709c38bb9ab9493c11031a577e3ee0
Closes: OS#4629
Depends: libosmocore.git I353adc1aa72377f7d4b3336d2ff47791fb73d62c
2020-07-27 14:43:36 +00:00
Alexander Couzens dd930a25ad gtphub: rename sgsn's oww osmo_sockaddr into sgsn_sockaddr
The osmo_ prefix should be only used for official struct/apis of libosmocore.
This commit was done via `sed -i 's/osmo_sockaddr/sgsn_sockaddr/g'`.

In prepartion of introducing a different api of osmo_sockaddr to
libosmocore.

Change-Id: Ibb1ddce9ff1ffe7494de5cdb8ea1843c45fe4566
2020-07-18 21:43:49 +00:00
Pau Espin b3e10aa8eb sgsn_libgtp: Avoid ps-paging MS on GMM Suspended state
The MS notifies movement to GMM SUSPEND state because it is for instance
handling a call and cannot use PDCH anymore. Once it releases the TCH it
will ASAP move to either dedicated mode or trigger RAU, which means it
will get out of SUSPEND state. So it doesn't make sense to try paging
the MS when in that state.

This change makes test TC_suspend_nopaging pass.

Related: OS#4616
Change-Id: Ia245899eb9f16c7f839785def4ceb721a1c3a11b
2020-06-26 12:20:57 +02:00
Pau Espin 36ecddb705 gprs_gmm_fsm.c: Add missing license header
The file was created by myself on September 2019,
31c4657c97.

Change-Id: I94299b9ccf760ad13429e149067f06ed60d37de3
2020-06-26 12:07:12 +02:00
Harald Welte 90dedcb2e7 *.spec.in: Use %config(noreplace) to retain current config file
Change-Id: I4e7f0a44d5e2d132b24ca0f38dc6f520b59112da
2020-06-22 15:20:33 +02:00
Pau Espin cfd307b4e8 sgsn_libgtp: Improve ps-paging logging
Change-Id: I0c3d48d54295824c3ba5b0fa9e3c035983556326
2020-06-18 11:39:13 +00:00
Neels Hofmeyr b26a5a82db use new osmo_mobile_identity API everywhere
Depends: If4f7be606e54cfa1c59084cf169785b1cbda5cf5 (libosmocore)
Change-Id: I4cacb10bac419633ca0c14f244f9903f7f517b49
2020-06-18 11:23:35 +00:00
Neels Hofmeyr 7369d449f1 gbproxy_test.c: fix mobile identity test data
Fix the final nibble of all IMSI BCD digits to 0xf, since it is a filler digit.

The encoded IMSI has an even amount of digits (14) and must contain a 0xf
filler nibble at the end. The test data looked correct due to repeated '1'
digits.

wrong hex: 11 12 13 14 15 16 17 18
correct:   11 12 13 14 15 16 17 f8
order:     1T 32 54 76 98 ba dc Xe  T = type, X = filler, 1..e = 14 digits

This error was found when applying the new osmo_mobile_identity API.

Change-Id: Ia006a3da6779ad1984f642e8ea29790a4daeb8b9
2020-06-18 11:23:35 +00:00
Harald Welte 5e1a486a72 Treat RAU as implicit RESUME if GMM is suspended
We so far only resumed from suspend upon receiving an explicit BSSGP
RESUME message from the BSS.  The latter is only possible in
BSC-colocated PCU, where the BSC can trigger the message when releasing
the dedicated channel.  In BTS-colocated PCUs, this is not possible,
and we have to rely on the MS resuming by RAU.

See 3GPP TS 23.060 section 16.2.1.1.1 clause 6:

The MS shall resume GPRS services by sending a Routeing Area Update Request message to the SGSN:
* if the BSS did not successfully request the SGSN to resume GPRS services,
* if the RR Channel Release message was not received before the MS left dedicated mode,
* if the MS locally determines that the conditions for the GPRS suspension have disappeared

Without this patch, the GMM state would forever be stuck in SUSPEND,
which in turn causes the SGSN to page the MS all the time.

Change-Id: I3c09187a27483d95fa0070bbb467f94a2ea3978f
Related: OS4616
2020-06-17 21:09:03 +00:00
Harald Welte 627e285fd0 Fix memory leak when SNDCP de-fragmentation is used
As msgb ownership is not passed along, we need to free the message
buffer memory we allocate in defrag_segments() after calling
sgsn_rx_sndcp_ud_ind().

Change-Id: I1185b1aa99bb167d616eb469e5445e4ed5ad949d
Closes: OS#4603
2020-06-08 20:46:53 +02:00
Oliver Smith 5e0b829884 Makefile.am: EXTRA_DIST: debian, contrib/*.spec.in
Change-Id: I15d4c9ca2c7ed0467b44f57bbaa1a2177feff154
2020-05-22 13:45:48 +02:00
Oliver Smith bd6d677179 contrib: integrate RPM spec
Remove OpenSUSE bug report link, set version to @VERSION@, make it build
with CentOS 8 etc.

Related: OS#4550
Change-Id: I824b67f2d590ac2aa9f2e4fa4387a5283cf22521
2020-05-19 16:49:33 +02:00
Oliver Smith 482bb07301 contrib: import RPM spec
Copy the RPM spec file from:
https://build.opensuse.org/project/show/home:mnhauke:osmocom:nightly

Related: OS#4550
Change-Id: Ia18f44f1b6dc259c3d0474b88b33f4657d96fd7a
2020-05-14 11:52:28 +02:00
Neels Hofmeyr b63e19d7d2 gsup: send RAT type on LU
At 36c3, osmo-hlr was run with a patch that records the RAN type of attached
subscribers. Even though this is not in osmo-hlr master, it is nice information
to send along.

Change-Id: I5dbe610738aed7ea1edf6b33543b1c03818cc274
2020-05-12 13:52:24 +02:00
Neels Hofmeyr c6548bbaab fix nullpointer: in gsm48_rx_gmm_ra_upd_req()
This caused frequent crashes at 36c3. The "proper" fix is probably elsewhere
(lynxis mentions an unfinished patch), but at least this prevented some crashes
during active operation.

Once this is merged, we can (re)enable SGSN_Tests_Iu.TC_geran_attach_iu_rau,
which tests exactly for this scenario:  A Subscriber / MM context that is so
far attached via GERAN, but now receives a RAU via UTRAN/Iu.

Closes: OS#4339
Change-Id: Ifde15dc4151d84748f0e67b32c9c260cb2d9d8fc
2020-05-10 22:33:27 +00:00
Pau Espin b2ebc59f30 Use OSMO_FD_* instead of deprecated BSC_FD_*
New define is available since libosmocore 1.1.0, and we already require
1.2.0, so no need to update dependenices.
Let's change it to avoid people re-using old BSC_FD_* symbols when
copy-pasting somewhere else.

Change-Id: Iaebd049e383b02204a12f39cc6c932a53d25fd72
2020-05-09 19:21:15 +02:00
Harald Welte 9d550cb369 gtphub_test: Fix compilation with gcc-10
/usr/bin/ld: ../../src/gtphub/gtphub.o:/home/laforge/projects/git/osmo-sgsn/src/gtphub/gtphub.c:50: multiple definition of `osmo_gtphub_ctx'; gtphub_test.o:/home/laforge/projects/git/osmo-sgsn/tests/gtphub/gtphub_test.c:57: first defined here
collect2: error: ld returned 1 exit status

See also https://alioth-lists.debian.net/pipermail/debian-mobcom-maintainers/Week-of-Mon-20200413/000653.html

Change-Id: I19c1eef6649d2747f0b624f5292d7ae47c4ca839
2020-04-20 19:47:19 +02:00
Eric Wild e6b2883f10 configure.ac: fix libtool issue with clang and sanitizer
As pointed out at https://github.com/libexpat/libexpat/issues/312
libtool does not play nice with clang sanitizer builds at all.
For those builds LD shoud be set to clang too (and LDFLAGS needs the
sanitizer flags as well), because the clang compiler driver knows how
linking to the sanitizer libs works, but then at a later stage libtool
fails to actually produce the shared libraries and the build fails. This
is fixed by this patch.

Addtionally LD_LIBRARY_PATH has no effect on conftest runs during
configure time, so the rpath needs to be set to the asan library path to
ensure the configure run does not fail due to a missing asan library,
i.e.:

SANS='-fsanitize=memory -fsanitize-recover=all -shared-libsan'
export CC=clang-10
ASANPATH=$(dirname `$CC -print-file-name=libclang_rt.asan-x86_64.so`)
export LDFLAGS="-Wl,-rpath,$ASANPATH $SANS $LDFLAGS"

Change-Id: I7402b019c191304f639806a3c29e6bb698b398ed
2020-04-11 01:04:28 +02:00
Eric Wild 6528e8c1cb tests: dlopen does not imply availability of dlsym..
Check for both.

Change-Id: If41a20bf499f791432f5f207e40688e97fb6e9f7
2020-04-11 01:04:08 +02:00
Neels Hofmeyr 6e4cd085b5 manual: explain IuPS, add SCCP/M3UA section from common chapters
Add 'cs7' default configuration, link to the
osmo-gsm-manuals/common/cs7-config.adoc chapter to fully explain the 'cs7'
client configuration.

Related: OS#2767
Depends: Ia2508d4c7b0fef9cdc57e7e122799a480e340bf7 (osmo-gsm-manuals)
Change-Id: If0f7c8fc4b94eb40b62570cf90999d5074dc00ee
2020-03-23 20:06:12 +01:00
Alexander Couzens 91a8bbd5db gprs_gmm_fsm.c: Implement RAT change between 2g and 3g
Related: OS#2737
Change-Id: I3fc614da6ba137e871ee0fe86ca22b6a4a354dd2
2020-02-04 10:21:12 +01:00
Daniel Willmann d999e54aa2 gprs_gmm: Check for RAT change and ensure this only happens for RAU/ATT
Change-Id: I38cb31907eddeade5350cdb648df179408d908d2
Related: OS#3727
2020-02-04 09:27:20 +01:00
Pau Espin 394aa533e9 Bump version: 1.5.0.91-5997-dirty → 1.6.0
Change-Id: I99e6950db3f54c6291dd259bed9b5c46cc26c465
2020-01-03 19:17:56 +01:00
Oliver Smith 5997357c69 osmoappdesc.py, tests: switch to python 3
Make build and external tests work with python3, so we can drop
the python2 dependency.

This should be merged shortly after osmo-python-tests was migrated to
python3, and the jenkins build slaves were (automatically) updated to
have the new osmo-python-tests installed.

Related: OS#2819
Depends: osmo-python-tests I3ffc3519bf6c22536a49dad7a966188ddad351a7
Change-Id: I8c07d99c1bc9f0383e4bce17544e0998998cc54d
2019-12-11 09:41:27 +01:00
Harald Welte de67c001b7 exit(2) on unsupported positional arguments on command line
Change-Id: I4f2d70d0b0f1b7bdb8604c930aba8fbb53d8bd54
2019-12-03 22:28:19 +01:00
Oliver Smith ad08d17e07 regen_doc.sh: support gbproxy, run without docker
Do not only update the VTY reference and counters of osmo-sgsn, but also
the VTY reference of gbproxy.

This was not possible with the old code path of calling "regen_doc.sh"
inside docker-playground.git, as it expects the program to be updated to
have the same name as the docker image. Using the docker-playground
script also has the disadvantage, that one must push the development
branch to git.osmocom.org before updating the VTY reference/counters,
because that script would build a new docker container with a freshly
cloned repository, check out the same commit that we have already
locally, build that and then finally regenerate the docs.

So instead of adding another parameter for the docker image to the
script in docker-playground.git and calling it twice, simplify the
process by rewriting the regen_doc.sh script in osmo-sgsn.git. Make it
start the locally installed osmo-sgsn and osmo-gbproxy binaries and
call osmo_interact_vty.py on them.

Related: OS#4292
Change-Id: I8b5bd5347ea34266ad650383372630f2a84d5cce
2019-12-03 11:41:21 +01:00
Oliver Smith 118c411e81 doc: add OsmoGbProxy VTY reference
Depends: (osmo-gsm-manuals) I4dea3e07b88175b2a88e577129360af7ec5f87e1
Related: OS#4292
Change-Id: I24c3ca2fc2446673edceefb797c7d800c3a1a5d2
2019-12-03 11:39:26 +01:00
Oliver Smith fa2656d14e gitignore: fix paths to binaries
Change-Id: Ia968bbc5de34e9068d4b414e5a701b958ae517e5
2019-12-02 14:40:31 +01:00
Harald Welte 6e6347613d manual: Fix copy+paste error
Change-Id: I5753ded676951998a1fd76e4d2c2bf3311213f53
2019-12-01 14:31:16 +01:00
Harald Welte 61557f42c1 check for osmo_ss7_init() error return value
Change-Id: Ic228273aa6fb197b78c70c467a4a99af317e8098
2019-12-01 12:43:17 +00:00
Harald Welte a868e17c5e check for osmo_fsm_register() error return values
Change-Id: I2028c82ac1b0421101c3f5d04fd999b65abdbf08
2019-12-01 12:43:17 +00:00
Harald Welte 1fd50d9abe Initial OsmoGbPROXY user manual
This adds a very basic manual consisting of nothing more than
the common chapters and a high-level description of what it is
all about.

Change-Id: I80d4ea016376c59995ccfcd8685c7c0e86745bd2
2019-12-01 12:42:58 +00:00
Harald Welte 4146121cc9 LLC: Don't use hard-coded N201-U / N201-I values in XID
The N201 values are negotiated per SAPI, and there are default values
per each SAPI.  Let's use those rather than hard-coded values.

Closes: OS#3954
Change-Id: I447a3c6dd85311772a6e219c62dc820d2726857f
2019-11-30 18:50:50 +00:00
Max 85386dcfad Use libosmocore constant for IMSI length in ACL entry
Presumably the length is chosen to match that of imsi in
osmo_gsup_message.

Change-Id: I138aea409aab0c748c75546e628797fc7498bf40
2019-11-23 19:12:45 +07:00
Pau Espin 9203da58e2 gprs_gmm.c: Send XID reset with received TLLI
Otherwise lower layers will end up using a TLLI from PTMSI which was not
yet announced to the MS if it is still not in GMM attached state, as
showcased by SGSN_Tests.TC_attach_req_id_req_ra_update.

Related: OS#3957, OS#4245
Change-Id: Ide51726abb82f5784eca4ab8d62b2ad8512be843
2019-11-21 16:39:23 +01:00
Pau Espin b71d2c5ddd gprs_llc.c: Use enum instead of hardcoded value
Change-Id: I89815f44f615a188f46a13f3785b3f7484f73bb3
2019-11-21 16:15:52 +01:00
Pau Espin 029a70e493 Improve logging in gprs_llc.c code
Change-Id: Id89cc6760179fb9b1709a30b5d1af41d466b280b
2019-11-21 14:15:10 +01:00
Pau Espin de80976d94 gmm: Fix assertion hit during RA UPD REQ before completting gmm attach
Output:
20191107021548500 DMM <0002> gprs_gb.c:40 MM_STATE_Gb(2596296189)[0x6120000084a0]{Idle}: Received Event E_MM_PDU_RECEPTION
20191107021548500 DMM <0002> gprs_gmm.c:1531 MM(/d4b6d7af) -> GMM RA UPDATE REQUEST type="RA updating"
20191107021548501 DMM <0002> gprs_gmm.c:1615 MM(/d4b6d7af) The MM context cannot be used, RA: 901-70-2758-208
Assert failed mmctx->gb.llme == NULL gprs_gmm.c:1620

Scenario reproducing the crash can be triggered with TTCN3
SGSN_Tests.TC_attach_req_id_req_ra_update.

Basically, SGSN first receives an ATTACH REQ with a given RA ID, then
SGSN switches to state CommonProcedureInitiated and sends GMM ID REQ,
and MS/PCU answers immediatelly with a RA Update instead with a new RA
ID.

Related: OS#3957, OS#4245
Change-Id: I64fa5cf1b427d3abb99e553e584897261a827ce6
2019-11-08 18:50:29 +01:00
Pau Espin 284314ab0a sgsn_libgtp.c: Drop use of deprecated libgtp APIs gtp_retrans*()
Since osmo-ggsn.git c94837c6a401bf0f80791b619a9b4cfbe9160afd, those
APIs are a no-op since timers are tracked internally through osmocom
APIs (and at the same time, new implementation fixes some timing related
bugs).

As a result, osmo-sgsn depends now on at least that libgtp commit. Since
it's not yet avaiable on latest libgtp release, let's track it down in
TODO-RELESE to not forget to update libgtp requirements during osmo-sgsn
release.

Related: OS#4178
Change-Id: Ia9a93d4a6ed63cd0c736f9a99d81d730b958d82e
2019-10-21 08:31:31 +00:00
Alexander Couzens 4d1d2e78b1 sgsn: Gb: implementing PS Paging when MS is MM_STANDBY
When the MS is in MM_STANDBY, the Routing Area is known,
but not the exact cell.
Start the paging procedure. (Even this is only supported
for the last known cell, not the Routing Area. Routing Area
paging is not yet supported.)

Change-Id: Icc2c6ba70f8f74054546a1e31741fc90b232a23c
2019-10-17 08:01:16 +00:00
Alexander Couzens 030824e172 sgsn_libgtp: refactor ps paging into gprs_gb
Paging should be done in gprs_gb
Change-Id: I3020020f52005aa460ca6b245ee2297aec9821b3
2019-10-17 08:01:10 +00:00
Vadim Yanitskiy 0e124d3131 gprs_mm_state_iu_fsm.c: fix: assign timer_cb to mm_state_iu_fsm
GCC warns us that 'pmm_state_fsm_timer_cb' is defined but not used.
This function was introduced in [1], but was not assigned to the FSM.

[1] I66c2ac0350cb074aefd9a22c5121acf723f239d3

Change-Id: Ib040befc87b2676aad2b8fe3671404fb3f5b030b
2019-10-09 18:32:55 +07:00
Alexander Couzens 865bf6f1bf sgsn_mm_ctx_alloc(): check for unallocated fsms
Change-Id: I867612a60236eaf7009400c92f5d871006aaf008
2019-10-08 23:13:10 +00:00
Alexander Couzens 10af11dacc gprs_gmm: release Iu connection on RAU failures
When a RAU fails without an a GMM context, release the Iu
connection after sending a response.

Change-Id: I05a9200f55d608ccfb3f86184c324a2b428da76b
2019-10-08 20:31:56 +00:00
Alexander Couzens afadd102bf ranap: add non-spec X1001
When the SGSN releases a RANAP connection, it sends a Release Command
and waits for a Release Complete. Use X1001 to release the Iu connection
when the Release Complete is lost/never received.

Change-Id: I39a0169c22a4ac430b3d6f3c281d1f381eaa4756
2019-10-08 20:31:25 +00:00
Alexander Couzens 12235310af sgsn: MM Gb Fsm: fix event handling for implicit detach
Implicit detach means there won't be any Gb state afterwards.

Change-Id: Iececb730e7135e14ebd94f82edb79b03ced1f9e3
2019-10-08 12:38:35 +00:00
Alexander Couzens d597ee260a gprs_sgsn: always allocate Gb/Iu mm fsm
When moving between RANs we need them at a later point.
Allocate them always to not make the code (more) complex.

Change-Id: I1724790335b0820f153a0cbdb5cfd1cfea36d1e9
2019-10-08 12:38:14 +00:00
Alexander Couzens 743e687496 gprs_ranap: add missing rc = 0
After processing the event, set the return code to success.
Thanks to manatails (redmine).

Change-Id: I73b3b3c3dd330bc953835737758854cf68539495
Fixes: #3969
2019-10-08 12:02:19 +00:00
Alexander Couzens 4c7609a508 gprs_mm_state_gb_fsm: ensure T3350 is not running when entering IDLE
In IDLE there is not further context with the MS. Prevents the Timer from sending
packages to a MS which can not respond

Change-Id: Ibdd913173af11d0e6d04aa392e047d5d9aee1243
2019-10-08 10:34:57 +00:00
Alexander Couzens 62f6f9aebf gprs_ranap: on Iu release, stop the attach fsm if running
A Iu release should stop any active procedure.

Change-Id: I78c6c0c4024657212d6abef51e226ce233018fee
2019-10-08 10:34:28 +00:00
Alexander Couzens 3bad31bcb4 Iu: implement a user inactivity timer
The user inactivity timer is similiar to the Gb READY timer and reduces
the resources taken by an idle UE.

Change-Id: I66c2ac0350cb074aefd9a22c5121acf723f239d3
2019-10-08 10:34:09 +00:00
Alexander Couzens eb5aee580d gprs_ranap: release Iu UE Context when exiting PMM Connected
PMM Connected defines a Iu signaling connection. The 2 other
PMM states do not have an active Iu signaling connection.

Change-Id: Ie05d2bdf8dfb593b4c7e837107a3a06f22e90119
2019-10-03 20:29:37 +00:00
Alexander Couzens e30f19542b Avoid compiling unneeded files when building without Iu
Remove gprs_ranap.c and gprs_mm_state_iu_fsm.c
from the Makefile when building without IU.

Change-Id: I2386f8e86bbf0b87eedce9f57eb86b1b64998a69
2019-10-03 19:51:03 +00:00
Alexander Couzens a8f782502b sgsn: when receiving data PDU notify the Gb GMM fsm
When receiving a PDU, the GMM fsm will change to state MM_READY
and will re-arm the T3314

Relates: OS#1941
Change-Id: I78f40762fb17bbd4a6f35608a793f8e5271e9b86
2019-09-28 17:55:19 +00:00
Pau Espin 324bb5a11e Introduce TODO-RELEASE file
It's going to be useful to track new dependency APIs being used which
require dependency version release and version bump during release of
osmo-sgsn.

Change-Id: Ia495a8577001c6a223c31f4ddd7eee289e3523c7
2019-09-19 16:15:32 +02:00
Alexander Couzens 1cb4be9db0 gprs_ranap: refactor REQUIRE_MM define
All branches need a MM context. Exit early if no MM context
present.

Change-Id: Ifa4c55f1f2c199fa63bd755311026b8586a65f3f
2019-09-12 01:43:16 +02:00
Alexander Couzens 6888021bf2 mm_gb_fsm: unassign the llme when entering MM_IDLE
MM_IDLE means there is no known state to this MM.

Change-Id: Ieb0d6cea828842763c13942fe1a63dd89399f799
2019-09-12 01:43:16 +02:00
Alexander Couzens 10b3d70fea gprs_ranap: send CommonId after receiving Security Mode Complete
After Security Mode Complete, the sender has been authenticated.
Send a CommonId to enable paging coordination between CS and PS.

Change-Id: If195c26e87ba3054e159746671babf93a12e7013
2019-09-12 01:43:16 +02:00
Alexander Couzens 8e3766cd38 sgsn_pdp_ctx_terminate: check llme before accessing
Change-Id: Ib4361cdc12f9c1674c89c6fafeeb52a3f42abe1d
2019-09-10 16:01:46 +02:00
Pau Espin d7276bde55 sgsn: Reject PdpActReq if no GTP pdp ctx exists
It could happen that SGSN drops GTP side of a pdp ctx (pdp->lib=NULL)
while still maintaing the other side (to notify about the entire pdp ctx
being torn down). If a PdpActReq arrives during that time, we need to
account for that situation, otherwise osmo-sgsn crashes accessing
pdp->lib.
If no pdp->lib is found at that time, let's reject the request and
expect at some point later in time the entire pdp context will be
destroyed and reestablished.

Related: OS#4173
Change-Id: I6dd87557ebb26fdbd280504abde10d976acecf64
2019-09-06 21:34:31 +02:00
Pau Espin 35f0e664bf Split out GPRS SM layer into its own file
Change-Id: Ie61d22e7868af6de73cdf9c731f07130b282599d
2019-09-03 15:22:15 +02:00
Pau Espin 31c4657c97 Implement GMM State using osmocom FSM
State machine inspired in the one from TS 24.008 4.1.3.3.1. Some state
transitions are inroduced in the code but are still commented out since
we lack some functionalitites or improvements in the code to handle
different scenarios.

Most of the logic is still outside of the FSM, but at least now the
states are handled in a sane way triggered by events.

Change-Id: Idecb43c10d66224d4f9ba9320825040ce6cf9a07
2019-09-03 15:22:12 +02:00
Pau Espin 2e91fee1ad enum gprs_gmm_state: Fix spec reference
Change-Id: I62121e46e5091e5b559397aa01f107ddc23e2c18
2019-09-02 14:03:04 +02:00
Pau Espin 33ebedc3d5 gmm: Move code handling GMM PTMSI Realloc Complete to its own function
Change-Id: I3b21a976c6683bea5419a33f0ccb8b56483d6e21
2019-09-02 14:03:04 +02:00
Pau Espin ab264ebba8 gmm: Move code handling GMM Routing Area Update Complete to its own function
Change-Id: I8e28ac03edf82374e804701ebe635e1171a2b36a
2019-09-02 14:03:04 +02:00
Pau Espin a0bcfad99b gmm: Move code handling GMM Attach Complete to its own function
Change-Id: I2d8d947ab1eb4100f404b885461f7a30583c9ac6
2019-09-02 14:03:04 +02:00
Pau Espin 762c39ccc6 Move out sgsn to its own subdir
Change-Id: I16fccc0eadf588599b9e5578d0f4dbaf9df81737
2019-09-02 14:03:04 +02:00
Pau Espin ea05d5c5f8 Move out gtphub to its own subdir
Change-Id: I707d5e9b775179e732d281ce3d245de83d648eea
2019-09-02 14:03:04 +02:00
Pau Espin 9d016fd499 Move out gbproxy to its own subdir
Change-Id: I2cc98d3a276d953609bbbbaa9782a0112687791e
2019-09-02 14:03:04 +02:00
Pau Espin b8f22bd6c7 src/gprs/Makefile.am: Move build of shared .c files to an internal lib
Build files shared by osmo-sgsn, osmo-gbpy and osmo-gtphub into a .la
library, so we can later split each application into its own subdir and
clearly identify what's used by who.

Due to a dependency error with .Po files,  I cannot depend on the specific
.o files directly in LDADD for each binary, but it works fine on follow up
commits when binaries are splitted into different makefiles, so it will be
done later.

Change-Id: Ib7665c530c086a5f3135c395bb8bf19ed4a882b6
2019-09-02 14:03:00 +02:00
Pau Espin fd815bba12 vty: Print MM state and RAN type in show mm-context
Value presviosuly printed as MM state is actually usually refereed as
GMM state, so rename it.

Change-Id: Ia06c53f0cd2a6348237ed3abeb9367d965745aba
2019-09-02 11:44:58 +02:00
Pau Espin ccd1252bd7 Introduce FSM mm_state_iu_fsm
Implement TS 23.060 6.1.2 Mobility Management States (Iu mode) using
osmocom FSM and drop old implementation.
Most of the logic on each state is still kept in gprs_gmm.c, will be
inserted into the FSM later.

Change-Id: I4c9cf8c27194817c56e8949af0205e1cc14af317
2019-09-02 11:44:58 +02:00
Pau Espin 02514bc592 Introduce FSM mm_state_gb_fsm
Implement TS 23.060 6.1.1 Mobility Management States (A/Gb mode) using
osmocom FSM and drop old implementation.
Most of the logic on each state is still kept in gprs_gmm.c, will be
inserted into the FSM later.

Change-Id: I04004423e993107374d5a3549b8a93ac169251dd
2019-09-02 11:44:58 +02:00
Pau Espin 9119d50849 sgsn_vty: Print correct Iu mmctx id in 'show mm-context'
Change-Id: I79333bef4a4bf743fcad07812c9a213b368ff2b6
2019-09-02 11:44:58 +02:00
Pau Espin 3b848bdc42 sgsn_vty: Fix mmctx rate_ctr output indentation
Change-Id: I1b89c179e1ba08b65e31727fdce90c7b578f4d6d
2019-09-02 11:44:58 +02:00
Pau Espin 8b88f5f7f3 sgsn_cdr.c: Fix ip addr string buffer size
INET(6)_ADDRSTRLEN already contains the required extra null byte at the
end, no need to add +1 to it.

Change-Id: I5a16659e007c6883fe21582cce5dac544e6d4bb9
2019-09-02 11:44:58 +02:00
Pau Espin a794811416 gprs_gmm.c: Replace inet_ntoa with inet_ntop
inet_ntop manual states:
"inet_ntoa(3) is now considered to be deprecated in favor of
inet_ntop()".

Change-Id: I0c708d047122f349acf46797a9e5973040e7ae04
2019-09-02 09:42:21 +00:00
Pau Espin 87264e6454 Merge common allocation steps for Gb and Iu ctx
This way it's easier to add new common functionalitites without
forgetting to add it on both sides, and simplifies the code.

Change-Id: Ib6c0427ac7b35295cf1caf2f28cb2a5c155b9d9c
2019-09-02 09:42:21 +00:00
Pau Espin 0b72240799 Split enum gprs_pmm_state into Iu and Gb counterparts
Those two state sets are not part of the same state machine, and are
used in different scenarios, so let's split them and handle them in Gb
and Iu specific parts of struct sgsn_mm_ctx. This is required in order
to improve related code (for instance, use osmocom fsm).

Change-Id: I6100d607da316da0595886c6968704dd9ccfbde9
2019-09-02 09:42:21 +00:00
Pau Espin 8333ef10c9 Move llc->MM/SM Gb specific glue code to its own file
Now that we have RANAP/Iu handling specificities in its own file, let's
have also Gb specific glue code for messages coming from llc up to MM/SM
layer in its own file. This way same entry points in gprs_gmm.c are used
by Gb and Iu: gsm0408_rcv_gmm() (for MM) and gsm0408_rcv_gsm() (for SM).

Change-Id: Iaf57922a0970c1d03f6f1d6337d27ae3d4aaf32c
2019-09-02 09:42:21 +00:00
Pau Espin 6dfb5fef40 Move lots of Iu/ranap specific code into its own file
RANAP related functionalities were splitted among several files
(gprs_gmm.c, gprs_sgsn.c and sgsn_libgtp.c). Let's move it into its own
file to shrink complexity/size of existing files.
It also allows to keep a lot of conditionally enabled code (BUILD_IU)
and its dependencies (osmo-iuh) together.

Change-Id: I549042aaff045a378de77d657cc396ee08f22f33
2019-09-02 09:42:21 +00:00
Pau Espin 259e303436 sgsn: gtp: Drop related pdp contexts on echo timeout against GGSN
Change-Id: I7e97bac1c13a2c26203eb64e590fd75d77eb44bd
2019-09-02 09:06:13 +00:00
Pau Espin 6ec5dc26b3 Introduce log helper LOGGGSN and log category DGTP
It will be used in forthcoming commits.

Change-Id: I30f46f44af1d0eee324b1a995c1dad2e1315af7c
2019-09-02 09:02:38 +00:00
Alexander Couzens 4ec21769b2 gprs_gmm: gsm48_rx_gmm_att_req(): refactor duplicated code
Change-Id: I709f847802a975e1a75d0b87ac5125240cfd0854
2019-09-02 08:59:43 +00:00
Alexander Couzens c44af53d1e gprs_gmm: clarify comment of Iu follow-on request
Change-Id: Ib6b3a1b250de373656310a3c8f88d1d39bdcee60
2019-09-02 08:59:43 +00:00
Alexander Couzens f8d3e7fe05 gprs_gmm: only update gb/iu cell information when Iu/Gb present
This function should not do the transistion of Iu/Gb. Only copy simple data

Change-Id: Id52761f3ea655a2d0cc663a950154c6b7c1b5f7a
2019-09-02 08:59:43 +00:00
Pau Espin d8037bcedc gtp: cb_delete_context(): Clarify why pdp->lib is set to NULL
Change-Id: I02c46062d6dc9802d9cae057587e66a68a65436c
2019-08-30 08:24:48 +00:00
Pau Espin aa89f5dffc gtp: make echo_interval unsigned
There's no real need to use -1 to indicate echo timer as disabled, since
0 can also be used (it doesn't make sense to have a timer timeout of 0).
This way code is simplified.

Change-Id: I689034887188a53590eddeffda781629694eb5ed
2019-08-28 16:08:49 +02:00
Pau Espin 5623eb8439 gprs_gmm.c: Add spec document to function documentation
Change-Id: Ibb89499e9c1ab588336df34fde26faf3fbf2c72c
2019-08-21 17:18:14 +02:00
Pau Espin d956e16c7b gprs_gmm.c: Print value_string of reject cause
Change-Id: I71d9abcf7e3a836c475b7adbb95a82580e41ae6d
2019-08-21 17:17:11 +02:00
Pau Espin 2c90899bc4 vty: Introduce cs7-instance-iu
Similar to what we already have in osmo-msc.

Change-Id: Iaa9e1d06dd0430848ef4f7498a3c15d13f899904
2019-08-21 11:11:09 +02:00
Pau Espin 1aaeea4900 examples: Add osmo-sgsn_custom-sccp.cfg
Change-Id: Id3a3ccbf168fbbc28153cbf7f0249294eee34d3d
2019-08-21 09:08:19 +00:00
Pau Espin 99bd9d3139 gprs_gmm.c: Use osmo_rai_name() in log line
Change-Id: Ieab9b7696c93de9a5d3d42f614072a6f2181e37d
2019-08-20 17:48:47 +02:00
Alexander Couzens 39cbecd273 gprs/gprs_gmm: implement T3314. Timeout to reset MM state READY->STANDBY
When a MS MM state is READY its exact location is known (PCU).
On Gb, T3314 (aka TS 23.060 "READY timer") sets the MM state from
READY to STANDBY, where only the RA is known.

Introduce a second set of timer variables, because state timer
can run while another packet state timer is timing out.

Related: OS#1941
Change-Id: I4ce23ebe50d141076c20c9c56990b7103cd25e55
2019-08-20 17:48:47 +02:00
Pau Espin 5ed3f67f96 tests: Introduce vty-transcript-test tests
Add a few commands to make sure it's working fine, and print all
available timers with default values.

Change-Id: Ifd092b9561d49be1f62769d95ba49f6e4aeb4066
2019-08-20 17:48:47 +02:00
Pau Espin a299d65114 Replace own timer infra with libosmocore osmo_tdef
VTY command "show timer" is also available now.

Change-Id: Ia0cf5f0a49737fbc419e2ccc86312d01c6e0056e
2019-08-20 17:48:31 +02:00
Pau Espin a43fb7b8e5 tests: Verify that timers can be set over VTY
Change-Id: I486fc2a56e235a539836894d2042c1ca6e514ab9
2019-08-20 10:34:29 +00:00
Pau Espin f913265309 gprs_gmm: Avoid spaces in fsm events and enum strings
FSM doesn't expect receiving event names containing spaces (log lines
generated are confusing).

Similar for enums, it's better using code names to match easily and make
log lines more clear.

Change-Id: I16ede8bf8352b09bc772fd7b43fad2c2274b3ec1
2019-08-20 10:34:29 +00:00
Pau Espin 5b6c4b8ccd Introduce and use log macros when no mm ctx available
Change-Id: Iba22060d8646bc8ec6227684ccb91d98cb4c7be2
2019-08-20 10:34:29 +00:00
Pau Espin 2179dec71d gprs_gmm.c: Call mmctx_set_(p)mm_state only on related ran_type
For new readers it's very confusing why PMM states and MM states are in
the same enum, but handled with different functions, and sometimes
called one right after the other with different enums. Calling them when
on a different ran_type makes the function early return, so let's better
conditionally call the function to make it clear in the flow when the
function is expected to do something.

Change-Id: I65ad9e180177bc9fc7c4a037cd85cfe33b161f73
2019-08-20 10:34:29 +00:00
Pau Espin 2844b5ea00 gprs_gmm.c: Fix typo in log message
Change-Id: I357f0af89f5d14d304c3e889a49a5f6c23b7fb7a
2019-08-19 17:29:38 +00:00
Pau Espin f0f596f3d9 sgsn: use sccp_simple_client API to setup ss7 id 0 instead of 1
Implementation of osmo_sccp_simple_client() API internally uses ss7 id
1, which is confusing since there's no 0 in use in osmo-sgsn. Let's
explicitly use the 0 one so it is configured by "cs7 instance 0" in the
VTY.

Related: OS#4157
Change-Id: I0e23a6a76ebcba0b1b424e3d3b20d06c1da44cbe
2019-08-19 17:57:16 +02:00
Pau Espin 6e3112579e gprs_gmm.c: Flag mmctx_set_(p)mm_state() functions static
Change-Id: I061144b6994ee40d5b32eb321dd4f3d3786d028d
2019-08-15 13:15:48 +02:00
Pau Espin 05140b8dfe gprs_sgsn.h: Flag MM_CTX_T_GERAN_Iu as not supported
Change-Id: I3b53a530ab25434e2b2f4d80ad70a8a5f22bfcac
2019-08-15 13:15:21 +02:00
Pau Espin c21be62380 gprs_gmm.c: Use correct function to set MM_IDLE state during cleanup
Change-Id: Ic6912269d0d69c86f19e57f3271ebda1328e968f
2019-08-15 13:12:36 +02:00
Pau Espin 1927052de6 gprs_gmm: Introduce assert to guard against unexpected condition
This may well be the culprit of OS#3957, were already freed llme is accessed from
mmctx context later on, upon some timer is triggered in mmctx.

Related: OS#3957

Change-Id: I8e1eaeb9b3ebee8e45704b4fe007190c7db609e4
2019-08-15 13:12:11 +02:00
Pau Espin c488665f92 gprs_sgsn.c: Remove recently introduced assert
Recent commit added an assert to make sure unexpected conditions were
happening in sgsn_mm_ctx_cleanup_free(). Old code was passing
mm->gb.tlli to gprs_llgmm_assign with "new tlli" being all-1's (aka
unassign mm->gb.tlli).
The commit changed the code to use gprs_llgmm_unassign, which uses
llme->tlli instead of mm->gb.tlli, and the assert was used to make sure
no behavior change occured with the commit.
It seems TTCN3 test TC_attach_auth_id_timeout triggers that assert, and
after closer debug it seems mm->gb.tlli == llme->old_tlli, which makes
sense since there's a mm->gb.tlli_new which is expected to be
llme->tlli.
When TLLI changes in GMM (Attach Request or RA Update), it is stored
into mm->gb.tlli_new and assigned on the LLC layer using gprs_llgm_assign(),
and upon completion signalling from MS, (after handling response to initial request)
it is assigned to mm->gb.tlli (and value kept in mm->gb.tlli_new).
So mm->gb.tlli and mm->gb.tlli_new usually contain the same value unless
a new TLLI is allocated, and during the span of
Request->Response->Complete it is kept different, the LLC layer having assigned
the value of mm->gb.tlli_new.
So, old code (before the commit adding the assert) was wrongly using
mm->gb.tlli instead of mm->gb.tlli_new at the moment of unassigning (but
not really problematic in practice since behavior is the same as long as
"old TLLI" value is not all-1's.
So we are fine and correct using gprs_llgm_unassign() (which passes llme->tlli
as "old TLLI") instead of what used to be done before.
In any case, the expected behavior is to free the llme object and get
rid of everything...

Fixes: 788863cda5
Change-Id: I482acdbdf05ce0cb0a5804206672512854067f5b
2019-08-13 20:58:17 +02:00
Pau Espin 982e130144 gprs_gmm: Clarify comment during TLLI assignment
TS 04.64 sec 7.2.1.1 LLGMM-ASSIGN specifies:
"""
If TLLI Old  all 1's and TLLI New  all 1's then TLLI Old and TLLI New are assigned, and TLLI New shall
be used when (re-)transmitting LLC frames. Both TLLI Old and TLLI New shall be accepted when received
from the peer. It shall be treated as a TLLI change according to subclause 8.3.2.
"""

Change-Id: I3a17715bf2dba7b03c1335ad106307eb4d5f564a
2019-08-13 20:23:08 +02:00
Pau Espin 788863cda5 gprs_sgsn.c: Warn upon llme free unexpected scenarios
May be useful to detect unexpected conditions which could end up in
memory leaks.

Related: OS#3957
Change-Id: I0d175501083ce458ff1c07ad38761d2cbf4ea470
2019-08-12 18:33:39 +02:00
Pau Espin 404d9b8bba Introduce define TLLI_UNASSIGNED
Change-Id: Ib8be5af2a5e92a7403505b73ce4c1751832de40d
2019-08-12 17:50:00 +02:00
Pau Espin d723a97fae gprs_gmm.c: Drop unneeded brackets
Change-Id: Ie8ba2b9da695de8730834abb591df64295bb6172
2019-08-12 17:43:35 +02:00
Pau Espin 72b61e4344 gprs_gmm.c: Improve doc on nullable parameters
Change-Id: Iefb9b6dc34d87b4088c7535ef0a246103fe3f7e9
2019-08-12 16:43:58 +02:00
Pau Espin 39aa9ee6df gprs_llc.h: Improve documentation of some structs
Change-Id: I1b45f45addc87c74f3ae109e544143a1335180de
2019-08-12 16:23:04 +02:00
Pau Espin dfd7c24e16 gprs_gmm: Introduce macros to access msgb's associated IU UE ctx
Change-Id: I4d1d47af332d4557e8a3a70c1055bcc172166016
2019-08-12 16:06:49 +02:00
Pau Espin d7ef94c0bb Bump version: 1.4.1 → 1.5.0
Change-Id: Ife43559f395b9602f0b131a672f8d87d6ee48ea2
2019-08-08 16:46:31 +02:00
Pau Espin 37bc0ff580 Require newer versions of dependencies
New APIs only available since libgtp 1.4.0 are needed, and in turn that
libgtp version requires newer libosmocore 1.1.0.

osmo-sgsn itself requires libosmocore 1.2.0 since it uses GSM23003_TMSI_SGSN_MASK.

Change-Id: I1c67d3e7dda093b4869756c7a63dc7a4549084ae
2019-08-08 16:44:05 +02:00
Pau Espin e456e32f15 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.
API osmo_stats_vty_add_cmds never had a param list but has seem problem
(no "void"), so some users decided to pass a parameter to it.

Change-Id: Ic4af704958819e6f65ac01be33ef5b3d69628ad0
Related: OS#4138
2019-08-05 16:03:39 +02:00
Daniel Willmann c9e8d90982 configuration.adoc: Add a section about encryption
Change-Id: I3a2b84d386f55447e9eed35e59fdc0272e5147d1
Related: OS#1720
2019-07-30 09:02:27 +02:00
Daniel Willmann 862bc62975 configuration.adoc: Small fixes
Fix some typos, correct data compression command, add example to turn
off compression.

Change-Id: I6beff8c66eacf12f1081d51dd6b124bdd4478558
Related: OS#1720
2019-07-30 08:59:39 +02:00
Oliver Smith e18df0e28d osmo-gbproxy.cfg: fix conflict with osmo-sgsn.cfg
Listen on 127.0.0.100 by default, so there is no conflict on
127.0.0.1:23000. This allows starting both services with their default
configuration, like we are doing it in the Osmocom-Debian-install-*
jenkins jobs.

Related: OS#3369
Change-Id: I6e3053de8885a7954296d820c6a069d06276e4df
2019-07-29 08:26:37 +00:00
Daniel Willmann 5f0bce6636 osmo-sgsn: Fix outdated information in usermanual
Quite a few features that are listed as not-implemented in the overview
section are actually implemented now.

Change-Id: I8d499a25293b69babc2aebb2d697438f8ba8141f
Related: OS#1720
2019-07-26 12:05:12 +02:00
Daniel Willmann 03a2ed5b30 Add/fix help string for version option
osmo-sgsn was missing the help text of the -V option
gb_proxy still thought of itself as OpenBSC
Omit the name of the program in the help text to avoid such issues in
the future.

Related: OS#1720
Change-Id: Ib57694b6bff7c98a269dc4b4dbb7173349a57b81
2019-07-26 11:59:00 +02:00
Oliver Smith 40fce10e46 osmo-gtphub.cfg: fix conflict with osmo-sgsn.cfg
Change bind-to-sgsns from 127.0.0.1 to 127.0.0.10, so osmo-gtphub's
default config does not conflict with the osmo-sgsn default config. The
value of bind-to-ggsns does not clash with osmo-ggsn's config, so it was
left unchanged.

Related: OS#3369
Change-Id: Id892e1f4ab2daabbe9824b819b5fed985373b97a
2019-07-24 19:32:05 +00:00
Daniel Willmann 6daac87bd2 manuals: Update vty/counter documentation
Change-Id: Id7245eb1011d1f04d5dfa1503a96d100bc98344c
Related: OS#1700
2019-07-24 10:41:28 +02:00
Eric Wild 05fee6dbee turn -Werror=null-dereference into a warning
There is unfortunately no way to suppres this witha pragma,
and gcc 9 uncovers quite a few new instaces with enabled LTO that can't/won't be fixed
"error: potential null pointer dereference"

Related: OS#4123
Change-Id: I4d1219bf84d3b8dcaf925a60cf54abe733fba263
2019-07-22 19:57:02 +00:00
Vadim Yanitskiy 4b8e309f57 sgsn_mm_ctx_find_ggsn_ctx(): fix: always set gsm_cause
GCC 9 complains that variable 'gsm_cause' in do_act_pdp_req() may
be uninitialized. This may happen if sgsn_mm_ctx_find_ggsn_ctx()
would return NULL due to no static GGSN configured.

Change-Id: I09c608045dd35b9898b82e236a306ab9a6c2c0b9
2019-07-18 15:05:04 +07:00
Ruben Undheim 55fcf111e1 Spelling fixes
Change-Id: Id1511c5022a239db5d0b44ec7adf048cca307751
2019-07-17 10:59:24 +00:00
Oliver Smith 43f16ec403 contrib/jenkins.sh: run "make maintainer-clean"
Related: OS#3047
Change-Id: Ic887518bd149f325a92c3517ee90c655b1368fd8
2019-07-10 13:24:35 +02:00
Daniel Willmann 43c5b7023b manuals: Add script to regenerate vty/counter documentation
Change-Id: I8ee63a3da532285def8de7fe5e90873152adb21e
Related: OS#1700
2019-06-19 14:24:13 +02:00
Eric Wild df9b39142f replace magic tmsi constant with define
Depends: libosmocore I52b9f6b5f3e96d85a390ba2af21d7814df8aaeec
Change-Id: Icf9f466efce520779c926b47b6e6d6c9815120eb
2019-06-17 13:50:13 +02:00
Pau Espin d1463bc365 sgsn: Have authentication required on by default
Previous commit introduced command "authentication (optional|required)",
which is only meaningful if auth-policy is remote. Upon adding the cmd,
it changed the default logic for remote policy to not require
authentication, which broke TTCN3 tests because sgsn no longer tries to
authenticate the users.

Since it's actually good to enable authentication by default where
possible, let's enable it by default when on auth-policy remote.

In order to do so, let's simply not care about the value of variable
require_authentication if auth_policy is not REMOTE. As a result, we
drop parts of the previous patch and remove unneeded checks (which are
only partially useful based on order of commands during VTY read).

Fixes: 794f446a28
Change-Id: Ic707a95af178b44f08809df3d3bc8354bf34273c
2019-06-13 19:23:36 +02:00
Vadim Yanitskiy 794f446a28 osmo-sgsn: add VTY parameter to toggle authentication
It may be useful to have 'remote' authorization policy, but do not
require authentication in GERAN at the same time, e.g. in combination
with 'subscriber-create-on-demand' feature of OsmoHLR.

This change introduces a new VTY parameter similar to the one
that we already have in OsmoMSC:

  authentication (optional|required)

Please note that 'required' only applies if 'auth-policy' is 'remote'.

Change-Id: I9909145e7e0af587c28827e16301a61b13eedaa9
2019-06-06 19:45:34 +00:00
Pau Espin f7afd20200 sgsn_libgtp: Use new per-GSN libgtp API instead of deprecated API
Depends: osmo-ggsn.git I653cbdc185165592d985e3efab6e3f1add97877b
Related: OS#2873
Change-Id: Iaaffe0ec4d9590309c62b62c446677c6f6732f2a
2019-06-06 15:30:47 +00:00
Vadim Yanitskiy 812a8bd18f doc/manuals/vty: regenerate sgsn_vty_reference.xml
Change-Id: I3dfe3598055457cc9724a371590e676f1920652b
2019-06-05 01:31:57 +07:00
Oliver Smith eb3a8556be debian: create -doc subpackage with pdf manuals
I have verified, that the resulting debian packages build in my own OBS
namespace (see the -doc packages):
https://download.opensuse.org/repositories/home:/osmith42/Debian_9.0/all/
https://build.opensuse.org/project/show/home:osmith42

Depends: Ib7251cca9116151e473798879375cd5eb48ff3ad (osmo-ci)
Related: OS#3899
Change-Id: I9c09a0cb5c65fa2e2cd9817edb4656b2a1a35bb9
2019-05-29 12:14:20 +02:00
Pau Espin 1825ab5bae sgsn: Fix echo timer not started upon first pdp ctx created
Commit 176a4d2f33 moved echo timer related
code to its own function but did some mistakes when moving the logic
from several places into its own function. As a result, echo timer was
only enabled after the 2nd pdp ctx was created, instead of the expected
1st.
First, let's be consistent and always call the function *after* changing
state, since that's what the function expects. This fixes the issue.

Finally make the logic in the function more intuitive by checking in the
if clause the only case where actually the echo timer should be enabled:
Only if policy specifies so and we have at least 1 pdp ctx against that ggsn.

Fixes: 176a4d2f33
Change-Id: I826030978edb61ea5a172c2b72f63758206a6246
2019-05-29 08:45:43 +00:00
Pau Espin 20795e3fda Document max retransmit times for T3395
Spec also states same value is used for T3390, which we don't yet
implement.

Change-Id: I1a2276bd42d1ea5706cf9cc26d3e44baa6fbf066
2019-05-28 21:27:56 +02:00
Pau Espin ba2e500395 sgsn: vty: Improve log warning content with spec section
Change-Id: I68e87f29711a282a97a43b175f13b3c70112ab60
2019-05-27 17:35:32 +02:00
Max ef38b4c55e Fix IMSI padding in imsi-acl
In I73fd54ad3a4ab8be5aff0fee5c722597ad766e9d incorrect fix was added
which only initialize first element of array. Fix this by using explicit
index to initialize entire array.

Change-Id: I26e4aa44f159d1b5b91dda4a586fd4e809711245
2019-05-12 10:35:40 +00:00
efistokl def0d941f9 gprs_gmm: send Service Reject when no PDP ctxs are available.
Look at PDP Context Status IE: if there are any PDP contexts which are
ACTIVE on MS side and there are no PDP contexts which are ACTIVE on the
network side, then send Service Reject with the cause "NO PDP
ACTIVATED". This forces MS to reactivate the PDP contexts.

3GPP TS 24.008 Section 4.7.13.4 Service request procedure not accepted
by the network. Cause # 40.

Fixes: OS#3937
Change-Id: If610cbef17c25ec44e65d4f1b2340d102c560437
2019-05-11 05:28:49 +00:00
Keith Whyte bfd67d2f69 Echo zero byte XID-Field of Type L3_PAR
After Activate PDP Context request, Motorola KRZR
sends a zero length XID-Field of Type L3 Parameters

If this is not echoed back, the phone will send
Deactivate PDP Context request with SM Cause:
LLC or SNDCP failure(A/Gb only) (25)

Closes: OS#3426

Change-Id: Ibd75f7b943c84ed7264481fa2e4bc3cb2f6745d4
2019-05-02 09:38:28 +00:00
Alexander Couzens 6c0586ac7b gbproxy: parse dtap GSM48_MT_GSM_DEACT_PDP_REQ|ACK
Fix a warning "Unhandled GSM 04.08 message type ...".

Fixes: OS#3466
Change-Id: I20bf4db8da746e0b994bfe3f8178188831b67ed3
2019-04-30 01:04:48 +00:00
Pau Espin b72141458c gprs_sndcp_comp_free: Replace ifelse with switch and better handling of error
gprs_sndcp_dcomp_term asserts if compclass is not
SNDCP_XID_DATA_COMPRESSION, so this way by checking in the caller too we
easily now if the unexpected value is in compclass or in algo.dcomp.

Change-Id: I4600e6a137f42f20fdf69637e4a9048b265c1748
2019-04-27 13:35:07 +02:00
Harald Welte aed46ec97d gb_proxy: cosmetic: Use 'bool' in data structures where applicable
If we ever only use 0/1 in an 'int', we should have used 'bool'.

Change-Id: I63876f52d5de87e4c99d92669270fd1f487e217c
2019-04-24 15:43:26 +02:00
Harald Welte d3dcaf0bf2 gb_proxy.h: Add missing comments; improve comments
When the patching and routing features were introduced, a lot of the
new structures were not documented at the same level as the pre-existing
code.  Let's fix that.

Change-Id: I61bdd3b1cec037bce825c234a8a274b70629adc8
2019-04-24 15:43:26 +02:00
Harald Welte af779d2ab2 LLC: Store the XID inside the LLC Entity, not LLC Mgmg Entity
For every logical session between a MS and the SGSN, there is one LLME
(LLC Management Entity) and a set of LLEs (Logical Link Entities): One
for each SAPI.

The XID procedure used to establish LLC configuration values such as
N201 (MTU) parameters happens on each LLE separately. The negotiated
parameters only affect that one LLE (SAPI) and are not global.

Still, the OsmoSGSN LLC code has the "struct llist_head *xid" member as
part of the gprs_llc_llme, and not as part of the gprs_llc_lle. This
list is a cache of the XID fields we have sent with the last XID
request, which is used in processing the response from the MS.

If two XID handshakes were to occur concurrently on two LLEs, the state
between them would get messed up. It must be maintained separately for
each LLE.

Closes: OS#3955
Change-Id: Iaeb54ca5ac58391be45e56c2e721f531969f3a9e
2019-04-24 15:42:36 +02:00
Harald Welte 1f60bbe8a2 gprs_llc: Correctly refuse any ABM command (SABM, DISC) with DM
According to Section 6.4.1.4 of 3GPP TS 04.64
	The DM unnumbered response shall be used by an LLE to report to
	its peer that the LLE is in a state such that ABM operation
	cannot be performed. An LLE shall transmit a DM response to any
	valid command received that it cannot action.

Closes: OS#3953
Change-Id: Ie8b8e16d5a68f19f21dc4fdb5703c8a794e0173c
2019-04-24 15:42:27 +02:00
Harald Welte 3a0b772d6c LLC: Avoid NOTICE message on LLC NULL
A MS sending LLC NULL frames on cell change is a perfectly normal event,
and we shouldn't log any cryptic NOTICE messages about it.

Change-Id: I6be0b9c8813dfb40a7955422fd8e7cebf94d189c
2019-04-23 23:22:54 +02:00
Harald Welte 37bd02121b LLC: Don't blindly assume all LLC frames have data payload
In reality, only UI, I, SABM, UA and XID frames carry payload.  All
other frames will have llhp.data == NULL.

Let's therefore not do any msgb adjustments unless we actually know
there is a user payload field.

Change-Id: I51bbd0f2c618d477a037af343ff41de1c8a5a3ae
Closes: OS#3952
2019-04-23 23:22:54 +02:00
Harald Welte 321eb8e8c9 LLC XID: Fix string representation of N201_U
Change-Id: I8799e3a3c47377aeeb9923d9d73f5d0b73cd8d0b
2019-04-23 20:51:37 +00:00
Alexander Couzens 932ccf87a0 gprs_gmm: reintroduce calling gsm48_gmm_authorize when not handling GMM Attach Requests
A security command is part of multiple procedures to ensure
integrity (optional also encryption) between MS and RNC.
It should be used for all Iu connections once.
With the rewrite of the GMM Attach FSM the use of the security command
procedure was broken for all procedures e.g. Service Request except GMM
Attach Request.

Relates: OS#3920
Change-Id: I50e8e316f06ae1a6171a6b07e4e2f0761322b779
2019-04-16 11:11:28 +02:00
efistokl c42e21e81c gsm0408_rcv_gmm: send Iu-ReleaseCommand upon receiving Attach Complete.
UE expects to receive Iu-ReleaseCommand after Attach Complete. If it
doesn't receive it, then it sends Iu-ReleaseRequest after a timeout
which makes the "PS Activation" process long.

Change-Id: Ib5053e3cd655d08ff3fd0fefa48325fabb1797c8
Related: OS#3908
2019-04-08 02:58:18 +00:00
Harald Welte 313cf35581 gbproxy_test: Fix test expectations of gprs_ns_rcvmsg()
gprs_ns_rcvmsg() in old libosmocore returns "number of bytes transmitted
by any response PDU we sent as a result of the received message", while
modern libosmocore simply retunrs '0' for any successfully received
message.  Let's make sure any non-negative responses lead to a
reproducible test output with both old and new libosmocore.

Change-Id: I7a48d14aed19825b87a02ccf9ee9cbfe0853342c
2019-02-26 22:37:57 +01:00
Max b6f8b74b07 GMM: permit VLR_ANSWERED event in attach FSM
This fixes following error:
DMM gprs_gmm.c:1126
    GMM_ATTACH_REQ_FSM(gb_gmm_req)[0x5589e78dded0]{WaitAttachComplete}:
	Event VLR answered not permitted

There seems to be a race condition in FSM when MS establishes MM context
which isn't immediately followed up by PDP context (for example when no
APN is configured in MS).

This does not affect actual functionality because in this case MS won't
be able to use GPRS anyway but it's still nice to get our FSM fixed even
in this corner case.

Change-Id: I14d234632224e20faf865d2273c83cfff31abf61
2019-02-14 11:07:48 +00:00
Max 34604c26b4 Improve 'show subscriber cache' vty command
* don't use spaces when printing hex data like RAND, SRES etc to
  increase the chance that it'll fit onto single line which will improve
  readability

* don't print non-existent QoS value

Change-Id: I0a09063f30c1116803994117f49df9d02bcc9181
2019-02-13 14:11:29 +01:00
Harald Welte 319a52b577 Bump version: 1.3.0.120-88220-dirty → 1.4.0
Change-Id: I9d37bb897d34ad973e93706003bdecc0cf6be816
2019-01-23 18:32:41 +01:00
Stefan Sperling 882200929f make gsup ipa name configurable in osmo-sgsn.cfg
Add a 'gsup ipa-name' VTY command which overrides the default
IPA name used by the SGSN on the GSUP link towards the HLR.
This is required for GSUP routing in multi-SGSN networks.

The 'gsup ipa-name' option can only be set via the config file
because changing the IPA name at run-time conflicts with active
GSUP connections and routes configured in the HLR. The osmo-sgsn
program must be restarted if its IPA name needs to change.

Related: OS#3356

Change-Id: Ib2f65fed9f56b9718e8a9647e3f01dce69870c1f
2018-12-20 16:13:00 +01:00
Stefan Sperling 2599644d81 remove pointless declaration of struct gsm_network
We were passing a NULL pointer of type struct gsm_network * to
ctrl_interface_setup_dynip(). Remove the pointless declaration
of this struct. Also, replace the sgsn_controlif_setup() helper
function with a direct call to ctrl_interface_setup_dynip().
The helper fnuction was just a thin wrapper around the latter.

Change-Id: Ib4151afa5bff01e63b462cca517fb60ac0503759
Related: OS#3356
2018-12-12 17:39:17 +01:00
Max 2e485767da Use explicit parameter for sgsn_auth_init()
This is necessary to properly test ACLs in follow-up patches.

Change-Id: Ibeba371234680f33ad35afbfffce9dca185228c1
2018-12-11 11:27:53 +01:00
Max ad2e18f0c4 Use explicit length check
Use OSMO_MIN macro to check for MSISDN length. This makes the code
cleaner and will, hopefully, aid static analysis tools.

Change-Id: Ic0fbeb8d248c74e54bfb51ba2cdea55c4f386ac7
Fixes: CID57879
2018-12-10 18:06:08 +00:00
Max 88d149c0b8 Drop unused osmo-sgsn.pc
We do not install any libraries so we don't need it: most likely it's a
forgotten leftover from pre-split repo time.

Change-Id: Ifabb26d1e6384659789061bc2abe23cb5ceca4cb
2018-12-10 18:05:58 +00:00
Max 40124c8624 Constify sgsn_acl_lookup() parameter
This requires I414e67a3de733fab407161b3264d3b89070ba537 in libosmocore
to avoid warning about discarded const.

Change-Id: Ie92637dd900b0f9eba891d5aad0b4ba0ee69c08c
2018-12-10 18:17:21 +01:00
Max 67c97849f8 Remove misleading comment
The code which has been used for 4 years is hardly temporary.

Change-Id: Ibe9c62e0beb89eecced941b8831d49ca266c7330
2018-12-10 17:07:05 +00:00
Oliver Smith 4786737cd7 contrib: fix makedistcheck with disabled systemd
EXTRA_DIST files need to be distributed, no matter if the systemd option
is configured or not.

Change-Id: I4b1973a4796ccddce930a130be00c15b09572c16
2018-12-06 13:54:53 +01:00
Oliver Smith b5ed023ffe contrib/jenkins.sh: build and publish manuals
Add new environment variables WITH_MANUALS and PUBLISH to control if
the manuals should be built and uploaded. Describe all environment vars
on top of the file.

When WITH_MANUALS is set, install osmo-gsm-manuals like any other
dependency and add --enable-manuals to the configure flags (for "make"
and "make distcheck"). Add the bin subdir of the installed files to
PATH, so osmo-gsm-manuals-check-depends can be used by ./configure.

Related: OS#3385
Change-Id: Ic45322c809f9f65d0fd24b828dab0cd929fa6267
2018-12-05 13:18:47 +01:00
Oliver Smith cc77954000 Fix DISTCHECK_CONFIGURE_FLAGS override
Set AM_DISTCHECK_CONFIGURE_FLAGS in Makefile.am instead of
DISTCHECK_CONFIGURE_FLAGS. This is the recommended way from the
automake manual, as otherwise the flag can't be changed by the user
anymore.

Related: OS#3718
Change-Id: I5bf96adcf06f1844ffc888d8690d2cc0df48e3f9
2018-12-04 15:34:16 +01:00
Oliver Smith f164d89549 build manuals moved here from osmo-gsm-manuals.git
Moved to doc/manuals/, with full commit history, in preceding merge commit.
Now incorporate in the build system.

Build with:

$ autoreconf -fi
$ ./configure --enable-manuals
$ make

Shared files from osmo-gsm-manuals.git are found automatically if
- the repository is checked out in ../osmo-gsm-manuals; or
- if it osmo-gsm-manuals was installed with "make install"; or
- OSMO_GSM_MANUALS_DIR is set.

Related: OS#3385
Change-Id: I0477d7c871413bd90b365d3064bac3cba23a0883
2018-11-27 18:10:43 +01:00
Neels Hofmeyr 1d2326d2cd Merge history from osmo-gsm-manuals.git
Change-Id: I284bfe2fc61167986cf784eabdd57151d4981e7a
2018-11-27 18:10:31 +01:00
Neels Hofmeyr 4ca244ab33 sgsn: update vty reference
Change-Id: I64d775efa6791aca025d116905e951e10ffa5d04
2018-11-27 18:10:00 +01:00
Harald Welte b8f9560658 vty-ref: Update URI of docbook 5.0 schema
... to match the /etc/xml/catalog file on debian (no "www" in hostname)

Change-Id: Id9f3579c7f2bc3af13fe30b5268f249b6f59ed0d
2018-11-27 18:10:00 +01:00
Neels Hofmeyr fb0ca14889 OsmoSGSN: update VTY reference
This is the first update since the libosmocore changes to the 'show
online-help' generated output. Hence the produced document now benefits from
the structural improvements:
- not repeating common commands for every node;
- using section names that match the VTY prompt.

Drop most of the sgsn_vty_additions.xml -- they merely repeat what the online
VTY doc already explains. Many of these more verbose explanations have been
absorbed into the VTY online doc in osmo-sgsn.git change-id
I35984014424412e91437b7ed71576aef3819cb1e.

Adjust remaining sgsn_vty_additions.xml to match the new node ID scheme.

Change-Id: I71863e5056ad369d2055e9882a52a00fa999ab04
2018-11-27 18:10:00 +01:00
Pau Espin 0b81a2f293 OsmoSGSN: overview: Fix typo and reference OpenGGSN->OsmoGGSN
Change-Id: I94cc362a4f52e6bd9f93299665e73dc4fd75a2c6
2018-11-27 18:10:00 +01:00
Harald Welte 2e0d1b0a08 share chapters/gsup.adoc from OsmoSGSN to OsmoMSC + OsmoHLR
Since the NITB split, GSUP is used in all three network elements, so
make the protocol a shared chapter

Change-Id: Id2d7c27ef16eb0ebe5f60d625a1fcf42f1603f4f
2018-11-27 18:10:00 +01:00
Alexander Couzens a6e189f639 OsmoSGSN: add rate counter documentation
Change-Id: I4c5d5744f961a92bc7c8888ca739d1e8a8a0be9c
2018-11-27 18:10:00 +01:00
Pau Espin 54828cdd79 OsmoSGSN: configuration: Document CDR CTRL interface
Change-Id: Ib729e2fc4898c20d27e95fc0f13abe9c0656dda5
2018-11-27 18:10:00 +01:00
Pau Espin 04da5fe0e6 OsmoSGSN: configuration: Add missing pdp-periodic event
Change-Id: I2d8b11496e75abd23a42efab8eabba2b5b0912e9
2018-11-27 18:10:00 +01:00
Pau Espin 817911f7c1 OsmoSGSN: configuration: Move pdp ctx specific CDR fields to its own table
Change-Id: I056f278b64ab426b9455b6a667abf2fe7fc94022
2018-11-27 18:10:00 +01:00
Neels Hofmeyr 471be2cd6f refactor Makefile build rules, don't use the FORCE
The initial goal was to make sure we don't have overall FORCE rules causing
unnecessary rebuilds -- annoying while writing documentation. As I looked
through possible dependencies, I finally understood what's going on here.

Remove code dup and nicely sort which belongs where in build/Makefile.*.inc. In
each, describe in a top comment how to use it, and also unify how they are
used:

- Rename Makefile.inc to Makefile.docbook.inc and refactor
- Add Makefile.vty-reference.inc
- Add Makefile.common.inc

Make sure that we accurately pick up all dependencies.

Drop use of the macro called 'command', that silenced the actual command lines
invoked and replaced them with short strings: it obscures what is actually
going on and makes the Makefiles hard to read and understand.

Each manual's makefile is greatly reduced to few definitions and a Makefile
include, e.g. one for asciidoc, one for VTY reference.

Move common/bsc_vty_additions.xml to OsmoBSC/vty/libbsc_vty_additions.xml, link
from OsmoNITB. It applies only to OsmoBSC and OsmoNITB.

Add a script that combines a VTY reference file with *all* additions files
found in a manual's vty/ dir. Call this from Makefile.vty-reference.inc.

Change-Id: I9758e04162a480e28c7dc83475b514cf7fd25ec0
2018-11-27 18:10:00 +01:00
Pau Espin 202a39e1d7 Allow easily disabling GFDL references
All parts referencing GFDL can be easily disabled by removing the
'gfdl-enabled' attribute from the document.

Change-Id: I2489726ad2e90301bceadfada926e31ae0f85986
2018-11-27 18:10:00 +01:00
Holger Hans Peter Freyther 19ee301b16 sgsn: Add charging characteristics to GSUP
Reserve a new IE for the charging characteristics. We need to handle
them as a GGSN might otherwise reject the PDP context creation. For
the SGSN it is enough to send the two octets as it.

Pick the 0x1X range for the IEs as it is used with the PDP contexts.

Change-Id: I1d7423582e154728a240cf15c32772a06822f4ad
2018-11-27 18:10:00 +01:00
Holger Hans Peter Freyther 29980b7ccb sgsn: Fix numbering of QoS and add basic description for APN
QoS was supposed to be 13 as 12 has been used for the APN. Fix that
and document the APN.

Change-Id: Ib6113aa7c59841aada424e2cafd94ed88c7badc7
2018-11-27 18:10:00 +01:00
Philipp Maier 0f63651adf osmo-sgsn: fix arrow tips in flow diagrams
The arrow style used to desribe the flowcharts in gsup.adoc does not match
the arrow style used in the protocol descriptions which are included from
the common directory (gb.adoc, control_if.adoc, oap.adoc). This patch changes
the arrow style to match the already existing common parts.

Change-Id: I7faa0c97ee3705a64289a47bc63f311d05f988b3
2018-11-27 18:10:00 +01:00
Philipp Maier e4e901186b osmo-sgsn: Explain TCP/IP header compression
The does not mention TCP/IP header compression yet. This
commit adds some info about it

Change-Id: I98408e72020a474d378e39263a933eb7567de146
2018-11-27 18:10:00 +01:00
Philipp Maier ed17106f01 osmo-sgsn: improve auth-policy explaination
The explaination of the access policy is a bit unclear. Users
that come from osmo-nitb might have trouble to grasp the functionality
of the access control list based approack correctly.

Change-Id: Iaae3035c4de3cb082f097441eff99289ee6dfc53
2018-11-27 18:10:00 +01:00
Philipp Maier 5783c0fc32 osmo-sgsn: Update VTY command reference
Change-Id: I6585144addd8501226572eda6f55db19d0e31c54
2018-11-27 18:10:00 +01:00
ikostov c520c3b2f4 GSUP, OAP: fix AUTS length to 14, not 16
https://gerrit.osmocom.org/1731

Change-Id: Id33d300c4985be5f2602703a6d4dc83032f0a926
2018-11-27 18:10:00 +01:00
ikostov aa6629f8a0 SGSN: add Auth. policy, NS Statistics and BSSGP state examples, tweaks
Add semicoli in fig-gprs-pcubts digraph.

Remove section from GMM Implementation about non-existence of HLR.
The SGSN can access osmo-hlr via GSUP (and will have to do so in the
libvlr future).

Change-Id: I0164f418e453672321eed00bbc454c1e223ea158
2018-11-27 18:10:00 +01:00
Neels Hofmeyr 8343572e2d fix 'make clean': shell glob, ignore failure
Unfortunately a glob like osmo-x__*.{svg,png} doesn't work, so have the
suffixes in separate globs.

Add dashes to indicate that failure should be ignored.

Change-Id: I6bc4d9ea72b43a573acbc860c23397f748de2c7b
2018-11-27 18:10:00 +01:00
Neels Hofmeyr 235b0db2eb add 'make check' target
Generate *.check files from asciidoc output and grep for WARNINGs.
Add *.check files to gitignore and to 'make clean'.

Change-Id: Ibccc83a3415930a528f2e8e4e4dda3b81c6d0b64
2018-11-27 18:10:00 +01:00
Harald Welte 779ba70905 GSUP: Add ladder diagrams for protocol transactions / procedures 2018-11-27 18:10:00 +01:00
Harald Welte ed9c53d575 Update GSUP chapter regarding UMTS AKA and other recent changes
The GSUP protocol has been enhanced with
* Support for UMTS AKA in 'Auth Tuple' / SAI operations
* Authentication Failure Report
* CN Domain indicator

Let's update the documentation accordingly.
2018-11-27 18:10:00 +01:00
Max 2b6d272549 Add OsmoSGSN control interface description 2018-11-27 18:10:00 +01:00
Jonathan Brielmaier 5530c91d3d fix various typos across all manuals 2018-11-27 18:10:00 +01:00
Harald Welte 36dea397ba OsmoSGSN: Fix formatting/cross reference in CDR section 2018-11-27 18:10:00 +01:00
Harald Welte aad1bf5207 Add link to Asciidoc source code of manual 2018-11-27 18:10:00 +01:00
Harald Welte 9f1331b103 initial checkin of manuals to public repo
The manuals existed in different form for several years in an internal
sysmocom repository.  However, since they had just recently been
converted from docboox-xml to asciidoc and all files have been
re-shuffled for enabling the public release, there's not much point in
keeping the history with git-filter-branch.
2018-11-27 18:10:00 +01:00
Neels Hofmeyr b2ee85da69 Importing history from osmo-gsm-manuals.git
Change-Id: I5dae23d0c9526aec3ee8f0b4b8baf2b6f919e43e
2018-11-27 18:09:36 +01:00
Pau Espin 926d54dc7e gbproxy: flush_stored_messages: Get rid of msg param
Log line actually makes more sense out of the function where IMSI acq is
resolved. We can then get rid of msg param which may cause confusion and
add complexitiy to code for no good reason.

Change-Id: I6716a260e12a3cf36af0501ce611c6c1e608f537
2018-11-26 10:49:15 +00:00
Pau Espin b540c3e983 gbproxy: flush_stored_messages: Log and route using stored_msg info
It makes no sense to print every stored_msg with BVCI from msg, same for
routing. This will allow getting rid of "msg" completelly in next
commit.

Change-Id: I95eafbf41012be3e02c68fc996773dd02b174fe6
2018-11-26 10:49:15 +00:00
Pau Espin e759f33ca5 gbproxy: flush_stored_messages: Move comment to func description
Change-Id: I14a90d1957a2cbd8fd53002b035fe481ab3abbbf
2018-11-26 10:49:15 +00:00
Pau Espin b0b1e3cbae gbproxy: Remove unneeded parse_ctx param
The only use inside the function is only to log information which should
actually be provided by tmp_parse_ctx of each stored msg.

Change-Id: Ic186b92fa9bd0a2b853a0cf525c6f6feb9493897
2018-11-26 10:49:15 +00:00
Pau Espin 8b67202ef6 gbproxy: Fix abort during APN patch
gbproxy process was aborted with following message during APN patching:
<000e> gb_proxy_patch.c:129 Patching ACT_PDP_REQ to SGSN: Replacing APN 'foo' -> 'bar'
msgb(0x5555558797d0): Sub area is not fully contained in the msg data

During osmo-sgsn 107fb59e84 old copy of
gprs_msgb_resize_area was replaced by more modern libosmocore version
called msgb_resize_area. They are mostly identical but the later has
some extra verification asserts. One of this asserts was triggering the
process abort, but the bug has always been there as far as I could see
in git history.

The assert triggers because the bssgp buffer and parse_ctx point to
"stored_msg", while the data buffer comes from a different msbg "msg",
which is clearly wrong behavior.

In the modified line, "msg" (the one which provided the imsi now already
stored in link_info through gbproxy_update_link_state_ul()->gbproxy_assign_imsi())
is really not needed anymore, and we want to patch the stored msg going
to be forwarded.

Related: SYS#4397
Change-Id: I7226fc5bcfbf58c349431d0a39cdb904fefd9e9c
2018-11-26 10:47:35 +00:00
Max 82f8846464 Revert "gbproxy: fix formatting in gbproxy-state command"
In case of multiple bts peers we use '\n' as individual entries
separator.

This reverts commit fffd6cb0d8.

Change-Id: I1ea17919ec3ed7e26044df8b5f8324717ee9e32c
2018-11-25 22:26:02 +00:00
Pau Espin d72f31bf17 gbproxy: flag gbproxy_assign_imsi as static
It's currently only used in the same file.

Change-Id: I08b51f36263e58f52ef9af2a63a7fcbf06a767c4
2018-11-22 18:10:53 +00:00
Max 655ef10975 gbproxy: add number-of-peers ctrl command
Return number of BTS peers. This is especially useful when no peers are
available because "gbproxy-state" command returns empty sstring in this
case.

Change-Id: I29b0664e60f7c81c3c7b495c1c8f2700e3f7e033
Related: SYS#2655
2018-11-22 18:13:28 +01:00
Max fffd6cb0d8 gbproxy: fix formatting in gbproxy-state command
In ctrl protocol we don't need any explicit formatting as it might
interfere with client processing our response. Let's drop trailing '\n'.

Change-Id: I3f32e01dd50a53991c292aeee57a78d81cdc5429
Related: SYS#2655
2018-11-22 18:05:53 +01:00
Stefan Sperling 81c97ff632 consistently check the result of osmo_shift_v_fixed()
Coverity points out we forgot to check the return value of
osmo_shift_v_fixed() in some places. Add checks which verify
the expected length of data which is skipped by the parser.

Change-Id: I20406f411810e966443d6fd5a4620b9a66cd9809
Related: CID#135160
2018-11-22 12:23:53 +01:00
Stefan Sperling eefb70df2c update gbproxy test expected output
libosmocore commit 797558ea1768e464f9559c5f7a4f3f4285c5de25
changed the order of NS_UNBLOCK_ACK transmission dispatching
of the NS_UNBLOCK signal. Update expected output of gbproxy
tests accordingly to make these tests pass again.

Change-Id: Ia3df811755b1c88cf7a27a466677b24a6c32fd8e
Related: OS#2388
2018-11-20 11:42:16 +01:00
Max f4fa695ca1 Use safer functions for IMSI ACL
Avoid explicit memset which confuses coverity, use strnlen() and
osmo_strlcpy() to handle strings.

Change-Id: I73fd54ad3a4ab8be5aff0fee5c722597ad766e9d
Fixes: CID163626
2018-11-19 05:46:24 +00:00
Stefan Sperling c5721545c6 use enums consistently instead of falling back to int
The two existing enums defined in gprs_sndcp_xid.h, for protocol
and data compression algorithm numbers respectively, were assigned
to 'int' variables when their values were copied to other structures.

This prevented the compiler from checking the enum value coverage
during switch statements and also tripped up Coverity scans looking
for enum value mismatch problems.

So instead of copying enums to ints, make use of the enums throughout.
Structures which can contain values from both enums now use a union
of both, forcing us to be very explicit about which set of values
we are dealing with.

Change-Id: I3771a5c59f4e6fee24083b3c914965baf192cbd7
Depends: If6f3598cd6da4643ff2214e21c0d21f6eff0eb67
Depends: I8444c1ed052707c76a979fb06cb018ac678defa7
Related: CID#149102
2018-11-15 15:57:59 +01:00
Stefan Sperling 6050968852 fix bogus error check in gprs_sndcp_comp_create()
The function gprs_sndcp_get_compression_class() returns -EINVAL
upon error, not -1, so an existing assertion would never trigger.

Instead, check for the values we want first (PROTOCOL_COMP or
DATA_COMP) and assert(false) in case the returned value doesn't
match either of these.

Found by: Neels

Change-Id: I8444c1ed052707c76a979fb06cb018ac678defa7
2018-11-12 13:03:04 +01:00
Stefan Sperling 6eeed7c4dc fix bogus assertion in encode_comp_field()
Fix an obvious logic bug in an assertion in encode_comp_field().

Found by: Neels

Change-Id: If6f3598cd6da4643ff2214e21c0d21f6eff0eb67
2018-11-12 12:52:34 +01:00
Max 68d1662347 Cleanup non-existent files from debian/copyright
Change-Id: I36a05b7c729cc1d050c8d07540ed1d867ca2d613
Related: OS#2534
2018-11-01 14:19:21 +01:00
Harald Welte f4b2c4ca42 Remove local libgsupclient; Use libosmo-gsup-client from osmo-hlr
osmo-hlr has recently (as of Change-Id
Iad227bb477d64da30dd6bfbbe1bd0c0a55be9474) a working shared library
implementation of libosmo-gsup-client.

We can remove the local implementation in osmo-sgsn and use the
system-installed shared library instead.

Change-Id: I6f542945403cf2e3ddac419186b09ec0e2d43b69
2018-10-30 18:30:36 +01:00
Pau Espin 73b2bf3215 Allocate sgsn_instance with talloc
Change-Id: I4a83c5799f0dbd5eb762039c6cfba671f6e465be
2018-10-30 18:25:47 +01:00
Pau Espin b1d1c240db Update wrong references to bsc in sgsn code
Change-Id: I93f0dc721c2eff8a87fb9248882f24768f708713
2018-10-30 17:35:31 +01:00
Oliver Smith e64f0ef1f6 gtphub: Add --version cmdline option
Related: OS#3576
Change-Id: Icdb2bd9ec90511b51428800d17f8ce81f6804670
2018-10-21 12:36:05 +00:00
Neels Hofmeyr e90b1977c8 fix build: remove unused variable
fix: "src/gprs/gprs_gmm_attach.c:240:6: error: unused variable ‘rc’"

introduced by

"gprs_gmm: Fix missing Security Command for 3G when attaching"
Change Id  I1e12b0a32e58c6f78dba7b548f7d7016567229db

Change-Id: I4837c10fed915c558a5374d448af813219087f36
2018-10-06 21:26:08 +02:00
Alexander Couzens 410bc9be9d gprs_llc: remove the FCS from the msgb by trim'ing the msgb
After checking the FCS, it's no use. The FCS should also not
appear on `hexdump(msgb_l3(MSG), msgb_l3len(MSG))`.

Change-Id: I27e061ead86395a336b67c7aead93d305a0f2ae8
2018-10-04 08:29:27 +00:00
Alexander Couzens 8e168605b2 sgsn_libgtp: fix a potential memleak when the GGSN is not reachable
When a MS does the following

- MS: GMM Attach
- MS: Activate PDP CTX
- SGSN: send PDP CTX Request to GGSN which GGSN does not answer
- GMM Detach (MM ctx get freed)
- libgtp retrans timeout of the first answer
- sgsn_libgtp.c: create_pdp_conf() which ignores this ctx because of emtpy MM ctx

Change-Id: I4575f7f80f785a62ae3b7f165d236a9dd818aabf
2018-10-04 08:29:04 +00:00
Alexander Couzens 545575695f gprs_gmm: Fix missing Security Command for 3G when attaching
Introduce a new FSM step in GMM Attach to send the
Security Command to the RNC after completing the
Authentication.

Fixes: f7198d7dbb ("gprs_gmm: introduce a GMM Attach Request FSM")
Change-Id: I1e12b0a32e58c6f78dba7b548f7d7016567229db
2018-10-02 20:19:35 +02:00
Alexander Couzens 47cf6bd001 gprs_gmm: dont answer unknown IMSI/TMSI on Service Requests NET_FAIL
NET_FAIL will result in asking again and again. Reject with IMPL_DETACHED to drop the
MS completely.

Change-Id: I195d533e330a4b577cad80c7e757d481f9c837df
2018-09-28 23:25:27 +00:00
Neels Hofmeyr 395c5580ec vty: add SCCP related vty commands
Depends: I214ea51fc6bfa2a9a4dd7c34b43add0c77ffe22e (libosmo-sccp)
Change-Id: Ie267aa014812b5c89f2268a65566d5427aa1ad7e
2018-09-27 03:34:48 +02:00
Harald Welte 1430b63e40 gbproxy-legacy: Ensure well-formed config file
Change-Id: I3495c8448459ba4f834744a1df6e7aa6a196d755
2018-09-25 20:39:22 +02:00
Neels Hofmeyr 1a9414b25b vty: fix doc str for 'reset sgsn state'
Document all keywords of the 'reset sgsn state' command: set the same doc
string for all three.

Also fixes the build after libosmocore
I1f18e0e41da4772d092d71261b9e489dc1598923, which resulted in HIDDEN commands
coming up in the VTY reference dumping. Note that libosmocore
I92c3c66ff69c186234276c64478d6342e061d25e will again remove this breakage by
omitting hidden commands.

Change-Id: I8b6e8615e409266910f2f76a10ced9ab33e4de91
2018-09-24 18:44:03 +02:00
Alexander Couzens 176a4d2f33 GTP: refactor the echo timer
Move the check of the echo timer into an own function.
The gtp echo timer must be re-check everytime the
echo-timer has been modified or deactivated via vty.

Fixes the TTCN3 SGSN_Tests.TC_attach_restart_ctr_echo

Change-Id: Ia33471a9a9cfc3887facb665c82094b99932052a
2018-09-19 13:31:42 +00:00
Alexander Couzens 9739067373 gprs_sgsn.h: fix wrong type of re-attempts
The GMM ctx->gmm_att_req.auth_reattempt is used to track
multiple UTMS re-sync attempt of a MS.

Change-Id: I708226cec9e131dcda4234f42ed3689f4f6750e8
Fixes: f7198d7dbb ("gprs_gmm: introduce a GMM Attach Request FSM")
Fixes: OS#3556
2018-09-19 10:31:02 +00:00
Alexander Couzens b62653a635 sgsn_ggsn_ctx_drop_pdp: protect against nullpointer when MM is gone
When the GGSN crashs, the SGSN will be notified after
it comes back. Because of the async operation,
the mm ctx could be already gone.

Change-Id: I507a8c2193c84f8dff7f5d669adcd3583331f289
2018-09-19 12:11:22 +02:00
Alexander Couzens a66f0f20f2 vty: restart sgsn state: improve output message
Change-Id: I20e91e196b9d64b6dac11ab47fcef85f8a9ee0b7
2018-09-18 16:09:18 +02:00
Alexander Couzens 35c3494d91 sgsn: use gtp_clear_queues() when reset sgsn state
Allow ttcn3 to flush the gtp queue between each test.
Fixes ttcn3 test SGSN_Tests.TC_attach_pdp_act_deact_mt_t3395_expire

Change-Id: I49d70cb7abe5cbe92ea68882fa68eccec0e79586
2018-09-17 04:39:14 +02:00
Alexander Couzens 5afef7c712 debian: add missing build dependencies
Change-Id: I0d552f938224e553187f0b4da06eac90fc025c95
2018-09-14 03:09:30 +02:00
Alexander Couzens f7198d7dbb gprs_gmm: introduce a GMM Attach Request FSM
The old GMM Attach Request handling used a recursive function
which can not handle certain states and is quite complex and hard to
extend.

The new FSM handles such request in a FSM and can be called multiple
times.

Change-Id: I58b9c17be9776a03bb2a5b21e99135cfefc8c912
2018-09-13 13:51:37 +00:00
Alexander Couzens 941ee147f9 tests: remove gmm unit tests
The test cases now implemented by TTCN3 which should not be as fragile
as the unit tests. Because the unit tests expect a quite strong internal
state to be happen.

Change-Id: Iac1c8854b5ea4aa03279990390ebc110c979aac2
2018-09-13 13:51:37 +00:00
Pau Espin 96696a87f4 Install sample cfg file to /etc/osmocom
Change-Id: Id898e920b934fbfb0b9abe1e3085ac817fa4634d
2018-09-13 11:52:32 +02:00
Pau Espin 97ba4062f8 Install systemd services with autotools
Change-Id: I103bf3468d53578045593eac31b61f7e0248495e
2018-09-13 11:52:30 +02:00
Pau Espin e17ae024fa debian: Fix typo in rules preventing build with IU support
It was discovered during OBS debian build that --enable-ui was not being
passed despite being defined. Comparing with other similar projects it
became clear that this override tag was not correct and it was being
omitted.

Change-Id: I0ad1009100fd7c2798bcf22aa84a0d90fbe41a55
2018-09-13 11:51:36 +02:00
Pau Espin 5262ceca72 Add osmo-gtphub systemd service file
Change-Id: I7ecfc9aa55611ae9975e5ef8c0716dae7598524c
2018-09-06 15:15:28 +02:00
Neels Hofmeyr 84c6ec6f17 use __FILE__, not __BASE_FILE__
The intention was to use the file's basename, but __BASE_FILE__ means "the root
file that is being parsed and contains #include statements".

If we had a function using __BASE_FILE__ and that was defined in an #included
file, __BASE_FILE__ would indicate the first file where the #include is, and
not the file where the function is defined. __BASE_FILE__ works for us because
we don't ever include function definitions that log something, so __BASE_FILE__
always coincides with __FILE__ for our logging; but still __BASE_FILE__ is
semantically the wrong constant.

Related: OS#2740
Change-Id: Icdf7af7a31fbba9197b3711eaf102fc0ae333bcc
2018-08-20 20:23:35 +00:00
Pau Espin c19817bce7 gbproxy: Replace '.' in counter names with ':'
The '.' is illegal character in counter names, as they are exported
via CTRL interface, where '.' has a special meaning that cannot be
used by strings comprising the variable name.

Change-Id: I66a7e044c027672adf77fbd6c0a111c43ee31b4f
2018-08-20 19:57:47 +02:00
Pau Espin 82f13612ce gbproxy: Add new VTY-managed timer: link-list clean-stale-timer
This timer allows periodically cleaning up stale links in link-list of
each gbproxy_peer. Previous to this patch, this kind of cleanup
(gbproxy_remove_stale_link_infos) was being done only as a consequence
of external events being triggered, such as a message from that peer
being received.
It was found in a production network agreggating several BSS that some
of them were offline for a longtime but gbproxy was still caching big
amounts of really old link_info for the NSEI assigned to those BSS,
because since they were probably turned off abruptely, no new messages
were received from it which would trigger the cleanup.
As a consequence, it has been observed that a timer to periodically
clean up old entries (link-list max-age) is requird in case w don't
receive messages from that NSEI periodically.

Related: SYS#4431
Change-Id: Ic777016f6d4f0e30fb736484774ca46878f17b7a
2018-08-17 14:13:47 +00:00
Pau Espin 67f1d1edf4 gbproxy: Add VTY parameter: link stored-msgs-max-length
It was discovered in some prod setups that some TLLIs can maintain quite
long queues of msgb in case its IMSI is not acquired and the tlli is not
pruned due to link-list max-{age,length} being set to 0. As a result,
the osmo-gpbroxy steadly increases the list size of maintained TLLIs, and
some TLLI was found without IMSI catching already 1211 msgb.

Let's allow setting a maxiumum length for the queue storing those msgb
in a per TLLI base. If the limit is reached, oldest msgb are removed
before adding a new one.

Depends: libosmocore Change-Id I33b501e89a8f29e4aa121696bcbb13d4b83db40f

Related: SYS#4297

Change-Id: I4473be8604f80302df03ffdd5a13280dc072f824
2018-08-17 14:13:24 +00:00
Pau Espin 36abeadc7b Use osmo_clock_gettime from libosmocore
Change-Id: Ic638849c6687c376c4c0c36cc286d499a073d6ca
2018-08-17 14:04:01 +00:00
Pau Espin 107fb59e84 Drop gprs_msgb_resize_area with libosmocore replacement
gprs_msgb_resize_area was introduced in libosmocore 0.94
(f78ec5ce0d0f6038147d9b9e14d81094309ba5d5) as msgb_resize_area. Let's use
that one to avoid code duplication.

Change-Id: Ib80f7b2b186d87f21d63d9b0bec58175170c905c
2018-08-15 14:11:30 +02:00
Pau Espin 816a67d59d Drop gprs_msgb_copy with libosmocore replacement
gprs_msgb_copy was introduced in libosmocore 0.94
(f78ec5ce0d0f6038147d9b9e14d81094309ba5d5) as bssgp_msgb_copy. Let's use
that one to avoid code duplication.

Change-Id: I42a65fd8e4045fafadf5694f2d8d0c5e7ab350a0
2018-08-15 13:53:50 +02:00
Alexander Couzens c503f0acd9 vty: add cmd "reset sgsn state"
Reset the SGSN internal state. Useful when testing the SGSN via TTCN3.
Depends on the libosmocore commit:
I29b6ad6742ddf9b0b58b4af37d9a1cf18e019325

Change-Id: I92096f3f6ea49e75676e30e9921d00210bac5382
2018-08-13 14:47:31 +00:00
Harald Welte d74fa3bf49 remove libcommon
This seems to b remaining from ancient days. The code
in there is either no longer needed, or has been moved to libosmocore.

Change-Id: I9307f9da7f48dd0a2e1cb213072068736e569722
2018-07-30 18:35:38 +02:00
Harald Welte 0b588be87e migrate to oap_client in libosmogsm
libosmogsm in libosmocore.git from Change-Id
Ie36729996abd30b84d1c30a09f62ebc6a9794950 onwards contains oap_client.c,
so we don't need our local copy here in this repo anymore.

Change-Id: I7b194f98ef3f925b6178d8a8dbd9fcf2f0c6e132
Requires: libosmocore.git Change-Id Ie36729996abd30b84d1c30a09f62ebc6a9794950
2018-07-30 18:35:34 +02:00
Daniel Willmann b920c4fefd git-version-gen: Don't check for .git directory
This check is not in all our repos that use git-version-gen. Indeed it
seems to be a leftover of openbsc where I think it wanted to ensure
being called in the openbsc subfolder or something? libosmocore e.g.
doesn't have it.

In any case .git being a directory is not always true (if using git
worktree) so remove this check.

Change-Id: I4385cc4fb87ca4354a3c608a18aa3d2eb03a744f
2018-07-25 07:03:14 +00:00
Pau Espin 437e209311 gbproxy: Replace '.' in counter names with ':'
The '.' is illegal character in counter names, as they are exported
via CTRL interface, where '.' has a special meaning that cannot be
used by strings comprising the variable name.

Change-Id: I93a2e5b6ec66c9edb6e93d95032e788f552af44b
2018-07-24 12:41:33 +02:00
Pau Espin ef6d78ff7f sgsn: Fix crash using new libgtp cb_recovery2 API
When PDP CTX CREATE ACK is received with an increased RestartCtr, cb_recovery2
is called first, which will dettach ggsn from al pdp ctx (free the
pdp_t). But when giving control back from the ctrl, libgtp still uses
that freed ctx and sends it back to osmo-sgsn through cb_conf().

As specs state in any case that we need to handle the message containing
the increased RestartCtr as valid, we then need to avoid freeing the pdp
ctx and leave handling for later in cb_conf.

Depends: osmo-ggsn (libgtp) Change-Id I53e92298f2f6b84d662a3300d922e8c2ccb178bc.
Change-Id: I0989c00e18ca95a099e1a312940eaac71957b444
2018-07-24 11:39:25 +02:00
Pau Espin 03dc773e08 sgsn: gtp: Use new API to send PDP DEL CTX REQ without freeing ctx locally
Previous API freed the ctx immediatelly after sending the packet, which
triggered a call to cb_delete_context() and dropped the entire
sgsn_pdp_ctx before the PDP DEL CTX ACCEPT was received. This new API
won't free the pdp ctx and we can tear down everything once we receive
the ACCEPT in cb_conf.

cb_conf is not automatically freed at cb_conf, user needs to free it, so
we need to remove setting pctx->lib to NULL in cb_conf to avoid leaking the
pdp ctx, as it needs to be freed inside sgsn_pdp_ctx_free().

Depends: osmo-ggsn (libgtp) Change-Id I29d366253bb98dcba328c7ce8aa3e4daf8f75e6c.
Change-Id: I304c59de5d137b81de3c6df0fdbe911ae3dbd1f3
2018-07-19 12:24:00 +02:00
Pau Espin c6cef69eef sgsn: cdr: Fix uninitialized string access if ggsn is detached
if pdp->ggsn==NULL, sgsn_addr was not initialized and caused asan report
during snprintf:

==19459==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffffffbe31 at pc 0x7ffff6e563fe bp 0x7fffffffb130 sp 0x7fffffffa8a8
READ of size 31 at 0x7fffffffbe31 thread T0
...
Address 0x7fffffffbe31 is located in stack of thread T0 at offset 337 in frame
    #0 0x55555573a7b0 in cdr_snprintf_pdp osmo-sgsn/src/gprs/sgsn_cdr.c:154
...
[320, 337) 'sgsn_addr' <== Memory access at offset 337 overflows this variable
...

Change-Id: I97bc56a4e3e76725eb2717b74b3ac125b68bbf0a
2018-07-19 10:09:11 +00:00
Pau Espin faeea348d6 sgsn: subscriber: Avoid calling memcpy with NULL src
Fixes: OS#3389

Change-Id: I2d1c01ed8b8d2233ced6d70972183ed4fc99007a
2018-07-17 18:26:49 +02:00
Pau Espin 9b5d7f6398 sgsn: Fix T3395 firing forever
field pdp->num_T_exp was being reset to 0 every time
pdpctx_timer_start() was called from gsm48_tx_gsm_deact_pdp_req().

Take the chance to test max amount of retrans to 4 as detailed in specs.

Change-Id: Iacce3c66f61578ebee37abaa287f7e183f985c1c
2018-07-16 17:26:32 +02:00
Pau Espin 2cf70e01d7 Forward GGSN originated DEACT PDP CTX REQ
This commit fixes TTCN3 sgsn test TC_attach_pdp_act_user_deact_mt.

Change-Id: I204209c017aac8a8402cbb8d0a0200540abcc954
2018-07-16 15:17:06 +02:00
Pau Espin a733a50931 sgsn: Don't attempt to delete GTP pdp ctx if GGSN was restarted
Scenario and behaviour before this commit:
- Received Echo Reply from GGSN has incremented RestartCounter
- func sgsn_ggsn_ctx_drop_all_pdp() is called to dettach all pdp ctx
from GGSN and request the MS to deact all related ctx.
- DEACT ACCEPT is received from MS, and then it tries to send DEL PDP CTX
to GGSN, expecting to receive a Confirmation and only then freeing the
pdp ctx.

The problem is that since the initial cause of triggering was a GGSN
restart, the GGSN doesn't know anything about that pdp ctx anymore, so
it's not useful sending it. We can instead dettach the GGSN and libgtp
ref at drop_all_pdp() time and then when we receive DEACT ACCEPT from MS
we can free the pdp ctx directly.

Change-Id: I1c74098e181552c218e152bf4ac5035cea770428
2018-07-16 15:17:06 +02:00
Pau Espin 89895b027d Add optional TearDownInd IE in PDP DEACT REQ towards PCU
According to 3GPP TS 24.008 Section 6.1.3.4, the tear down indicator IE
maybe included in the DEACTIVATE PDP CONTEXT REQUEST message in order
to indicate whether only the PDP context associated with this specific
TI or all active PDP contexts sharing the same PDP address and APN as
the PDP context associated with this specific TI shall be deactivated.

As we don't permit/support establishing multiple PDP contexts using
the same APN and PDP address, it shouldn't really make any difference.
Nevertheless, we want to clear everything, so let's include it.

Change-Id: Ia9bc2d0e93362a8473eac5cf4c7e8ffa41c79e5b
2018-07-16 15:16:53 +02:00
Pau Espin a83850c7fd vty: Add cmd to disable echo loop explictly
Change-Id: I0598427257533ce8ae9e9afa787293d7c98fed15
2018-07-13 11:51:52 +02:00
Pau Espin 2cc6c4ef26 examples: Enable by default echo req towards active GGSNs
60 seconds is used by default, which is the minimum accepted value for
this timer as per 3GPP TS 29.060 section "7.2.1 Echo Request".

Having it low by default is good for lab use in which a lot of stuff
changes over time.

Change-Id: Ia1898d172482bf6a25d829f8fc9a47824f49456f
2018-07-13 11:51:52 +02:00
Pau Espin 8c7d259061 Disarm T3395 when dettaching mmctx from pdpctx
In sgsn_pdp_ctx_terminate, a pdp ctx is terminated and the mm ctx is
detached. However, T3395 may still be armed and then pdpctx_timer_cb
will trigger, and attempt to use the pdp->mm ctx which was already
detached (set to NULL) when calling
gsm48_tx_gsm_deact_pdp_req()->mmctx2msgid().

Following list of log lines shows the scenario+crash, in which osmo-sgsn
is trying to deactivate the ctx all the time but the PCU doesn't ACK it,
and then at some point the PDP context is forced released.

osmo-sgsn/src/gprs/gprs_gmm.c:2294 MM(901700000015254/d7e9ab95) <- DEACTIVATE PDP CONTEXT REQ
osmo-sgsn/src/gprs/gprs_gmm.c:1464 MM(901700000015254/d7e9ab95) -> GMM DETACH REQUEST TLLI=0xd7e9ab95 type=GPRS detach Power-off
osmo-sgsn/src/gprs/gprs_gmm.c:313 MM(901700000015254/d7e9ab95) Cleaning MM context due to GPRS DETACH REQUEST
osmo-sgsn/src/gprs/gprs_sgsn.c:332 MM(901700000015254/d7e9ab95) Dropping PDP context for NSAPI=5
osmo-sgsn/src/gprs/gprs_sgsn.c:434 PDP(901700000015254/0) Forcing release of PDP context
osmo-sgsn/src/gprs/gprs_sndcp.c:508 SNSM-DEACTIVATE.ind (lle=0x62100001bca0, TLLI=d7e9ab95, SAPI=3, NSAPI=5)
osmo-sgsn/src/gprs/sgsn_libgtp.c:310 PDP(---/0) Delete PDP Context
osmo-sgsn/src/gprs/gprs_gmm.c:2294 MM(---/ffffffff) <- DEACTIVATE PDP CONTEXT REQ
osmo-sgsn/src/gprs/gprs_gmm.c:305:25: runtime error: member access within null pointer of type 'const struct sgsn_mm_ctx'

Program received signal SIGSEGV, Segmentation fault.
0x0000555555698c1b in mmctx2msgid (msg=0x61d0000172e0, mm=0x0)
    at /home/pespin/dev/sysmocom/git/osmo-sgsn/src/gprs/gprs_gmm.c:305
305             msgb_tlli(msg) = mm->gb.tlli;
(gdb) bt
 #0  0x0000555555698c1b in mmctx2msgid (msg=0x61d0000172e0, mm=0x0)
    at osmo-sgsn/src/gprs/gprs_gmm.c:305
 #1  0x00005555556b170a in _gsm48_tx_gsm_deact_pdp_req (mm=0x0, tid=0 '\000',
    sm_cause=38 '&')
    at osmo-sgsn/src/gprs/gprs_gmm.c:2297
 #2  0x00005555556b1a2e in gsm48_tx_gsm_deact_pdp_req (pdp=0x6140000008a0,
    sm_cause=38 '&')
    at osmo-sgsn/src/gprs/gprs_gmm.c:2311
 #3  0x00005555556b876c in pdpctx_timer_cb (_pdp=0x6140000008a0)
    at osmo-sgsn/src/gprs/gprs_gmm.c:2717
 #4  0x00007ffff355eb3e in osmo_timers_update ()
    at libosmocore/src/timer.c:257
 #5  0x00007ffff356255c in osmo_select_main (polling=0)
    at libosmocore/src/select.c:254
 #6  0x00005555556f17cb in main (argc=3, argv=0x7fffffffe298)
    at osmo-sgsn/src/gprs/sgsn_main.c:531

Change-Id: I2120e53ade6cabad37f9bd99e6680a453411821b
2018-07-13 11:51:52 +02:00
Pau Espin fa1201004f osmo-sgsn: ping GGSN periodically and check for restart counter
Before this commit, echo req/rsp logic was implemented in libgtp but
never used in osmo-sgsn.

This commit adds a timer which periodically sends a GTP ECHO Request to
every GGSN if there's at least one pdpd context associated with it. This
way by checking the restart counter in the ECHO Reply it can be known if
the GGSN was restarted. In this case, logic already present in osmo-sgsn
will terminate all pdp contexts associated with that GGSN.

Change-Id: I9d714726785407859f26bbef052cd0efc28e8dae
2018-07-13 11:51:50 +02:00
Pau Espin a98fead464 Maintain per ggsn pdp ctx list
This way we can easily track all pdp context associated to a specific
ggsn, which is useful to handle some scenarios, such as the one
implemented in next commit, in which specs references that GSNs should
ping only other GSNs with at least one pdp ctx in common. So the list
of pdp ctx per GGSN is really useful too (and cheap computationally)
to check if we should arm or disarm the echo procedure timer.

So this commit can be seen as a preparation for next commit.

Change-Id: I3bbcc0883df2bf1290ba8d4bd70db8baa494087a
2018-07-13 11:47:51 +02:00
Pau Espin 80d407fc3f sgsn_libgtp.c: Log pointer of deleted context
Change-Id: I8a4627b54090e72f86a9c5a781670be52522062b
2018-07-09 20:55:52 +02:00
Stefan Sperling 322643f921 finish gbproxy_parse_bssgp_unitdata test
The message this test is trying to parse is indeed invalid.
Add a comment showing the message in decoded form, and assert
that the parser rejects it.

Also, add a missing call to cleanup_test().

Change-Id: I2a86432d080c38d3c95626372a0129499d7146dd
Related: OS#3178
2018-06-23 16:51:30 +02:00
Pau Espin 92443a2533 Drop unused common_vty.c
Change-Id: I19f1ece5f2f62d1f8f40a9b9d0c6c41ad05e5c76
2018-06-21 00:05:22 +02:00
Pau Espin 94998fad7a Drop all references of unused MGCP
Change-Id: I1c023d773bf196d41b4251ca7011a82969acb613
2018-06-20 23:56:38 +02:00
Pau Espin 8216e2f215 Drop all references of unused SMPP
Change-Id: Iffae03fd855e6cbd99e71b9ba0d4157cb7791db2
2018-06-20 23:56:29 +02:00
Pau Espin c5ad8f8a96 jenkins.sh: Remove non-existent configure options
Change-Id: I331a187ae19125afa076e0a3d629ba7160d4b416
2018-06-20 23:49:36 +02:00
Pau Espin 917c987f81 jenkins.sh: Use --enable-werror only when iu support is disabled
The flag cannot be enabled in all cases because current osmo-iuh header
contain compilation warnings which are then propagated to this project
when building against them.

Change-Id: Ia4285a88af6d4adfba08c055c6734f9d82c1a5a4
2018-06-20 23:48:02 +02:00
Daniel Willmann c977afad6f gb_proxy: Add ctrl interface and nsvc-state, gbproxy-state commands
This patch adds a control interface to osmo-gbproxy as well as the first
two commands to query the state of each NSVC and gbproxy peer.

The "nsvc-state" command replies with
nsei, nsvci, local state, role, remote state of all NSVCs.

The "gbproxy-state" command replies with
nsei, bvci, mcc, mnc, lac, rac, and state of each peer.

Entries are separated by a newline '\n' character. If there are no
entries an empty list is returned. This behaviour is similar to that of
the subscriber-list-active-v1 command in osmo-sgsn.

$ ./osmo_ctrl.py -d 127.0.0.1 -p 4263 -g nsvc-state
Got message: b'GET_REPLY 23 nsvc-state 101,101,DEAD,BLOCKED,SGSN,DEAD,UNBLOCKED\n'
$ ./osmo_ctrl.py -d 127.0.0.1 -p 4263 -g gbproxy-state
Got message: b'GET_REPLY 4871085901306801158 gbproxy-state '

Change-Id: I82c74fd0bfcb9ba4ec3619d9fdaa0cae201b3177
Ticket: OS#3281, SYS#4235
Sponsored-by: On-Waves ehf
2018-06-15 07:33:46 +00:00
Stefan Sperling aaa3e2b9ae add a test for OS#3178 (invalid unitdata message)
Add a test which reproduces the parsing problem. Whether this problem
is due to an invalid message or a parser bug is yet to be determined.
Until then, this test helps with analyzing the problem further.

Change-Id: I39189701a57c785ffdacc3ae26d7aa93bb06cde6
Related: OS#3178
2018-06-07 19:12:25 +02:00
Alexander Couzens 13c13128fa gprs_gmm: Cancel Location: use detach type IMSI
The detach type network side is defined as
- Reattach required
- Reattach not required
- IMSI detach (after VLR failure)

IMSI detach seems to be more close. Howeever the standard
isn't clear about this.

Change-Id: I27da6dc5165819cccd1ae0a98b132b45a01f38bb
2018-06-05 13:06:14 +00:00
Daniel Willmann 3ab193ce73 gb_proxy: tallocate memory for gbproxy cfg so it can be a talloc ctx
Change-Id: Iad7cde5c08daacc3f5c4175d21d89fad25a5c3d7
2018-06-01 07:21:08 +02:00
Alexander Couzens 8007be41fe gprs_gmm: make extract_subscr_msisdn extract_subscr_hlr public
Change-Id: I54168e1a58dd36b38c53c13bbb5cdb4311f34410
2018-05-23 16:19:52 +00:00
Alexander Couzens d4788cdf65 gprs_gmm: make functions relating to GMM Attach Request public
GMM Attach Request will be handled in it's own file and will
use those functions.

Change-Id: Ic90d77f7b0bacd2a8e2e409e82d676772d352749
2018-05-23 16:19:52 +00:00
Alexander Couzens 1cec9c4c40 gprs_subscriber: gsup_auth_error: reject MS in all cases
There is no way to recover from "PROTOCOL_ERRORS".
As long the error_cause is not set, the
SGSN won't send out a GMM Request Reject.

Fixes: TTCN: SGGN_Tests.TC_attach_auth_sai_reject
Change-Id: Iefe8f05686ef4acac721f3c0672910704f3b0ff8
2018-05-22 20:54:35 +02:00
Pau Espin 39c67e2640 Bump version: 1.2.0.58-85ca87-dirty → 1.3.0
Change-Id: I466089b40fed02153e2850cb4a748ee6568b130b
2018-05-03 19:01:44 +02:00
Alexander Couzens 85ca87b8dd GMM: dont reply to GMM_DETACH_REQ with POWER OFF when MS is unknown
Change-Id: I1d1cf64500f1295ab58d157d4d4dab16fcddbbf3
2018-05-02 18:17:34 +02:00
Neels Hofmeyr aa4ed67164 GERAN: allow GSM SRES on UMTS AKA challenge
Store the established security context type (GSM or UMTS) instead of the
boolean flag is_authenticated. Provide the previous boolean query with thin
sgsn_mm_ctx_is_authenticated() function.

Knowing which security context was established will be necessary for OS#3224,
i.e. using the proper ciphering key, which is not yet tested properly, and
probably not correct at this stage.

This change will make new SGSN_Tests.TC_attach_umts_aka_gsm_sres pass.

Related: OS#3193 OS#3224
Change-Id: I36807bad3bc55c0030d4f09cb2c369714f24bec7
2018-05-01 01:32:13 +02:00
Neels Hofmeyr 7554fd1b5e log two RA Update Request failure causes
Change-Id: Ic9c8a492abf5a707b37d9c8888c59be6e51541b8
2018-04-30 22:09:13 +02:00
Neels Hofmeyr 918a47bdd8 auth+ciph: log is_r99 and auth types
Change-Id: I9679b7c174df186e05171a059a6b4d870a6f16e6
2018-04-30 22:09:13 +02:00
Neels Hofmeyr 5bd340eb5a use osmo_init_logging2(), fix regression test memleaks
Particularly gbproxy_test.c had various mem leaks, which (will) show up with
gcc (Debian 7.3.0-15) 7.3.0 address sanitizer. Fix those leaks to verify that
we don't have memleaks in the production code.

Change-Id: Ia4204c8b3d895b42c103edecb61b99d3d22bd36f
2018-04-16 01:03:48 +02:00
Neels Hofmeyr 69e356be93 compiler warnings: use enum ranap_nsap_addr_enc, constify local var
Use the proper enum ranap_nsap_addr_enc instead of int, and properly exclude
that member when we're building without Iu support:

sgsn_vty.c:1323:31: error: passing argument 2 of ‘ranap_iu_vty_init’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  ranap_iu_vty_init(SGSN_NODE, &g_cfg->iu.rab_assign_addr_enc);

Add const to a local var to silence compiler warning retrieving TLVP_VAL:

gprs_gmm.c:1657:18: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    uint8_t *mi = TLVP_VAL(&tp, GSM48_IE_GMM_ALLOC_PTMSI);
                  ^~~~~~~~

Change-Id: I1168ce6425c31db3f6c3bf1f3682ae96b028c59b
2018-03-16 09:16:19 +00:00
Neels Hofmeyr 5343a8c0d3 osmo-gbproxy: use 'osmo-gbproxy.cfg' as default config name
Like we did in osmo-sgsn in If804da17a7481e79e000fe40ae0d9c4be9722e61, move
from 'osmo_gbproxy.cfg' to 'osmo-gbproxy.cfg' as default config file name.
Still look for the legacy file name to not break old setups.

Change-Id: I9448908d94a23001f04b6334a78739a839b91313
2018-03-15 18:32:08 +00:00
Neels Hofmeyr 10719b74c3 implement support for 3-digit MNC with leading zeros
Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout
the code base to be able to handle an MNC < 100 that has three digits (leading
zeros).

Note that in gbproxy_test.ok, 0-0 changes to 000-000 instead of 000-00, because
the parsed ra buffer is 000000 which results in 000-000, while 00f000 would
result in 000-00. IOW this is expected.

Change-Id: I7437dfaa586689e2bef0d4be6537e5577a8f6c26
2018-03-15 19:18:14 +01:00
Neels Hofmeyr 5926e840cc configure: add --enable-werror
Provide a sane means of adding the -Werror compiler flag.

Currently, some of our jenkins.sh add -Werror by passing 'CFLAGS="-Werror"',
but that actually *overwrites* all the other CFLAGS we might want to have set.

Maintain these exceptions from -Werror:
a) deprecation (allow upstream to mark deprecation without breaking builds);
b) "#warning" pragmas (allow to remind ourselves of errors without breaking
   builds)

As a last configure step before generating the output files, print the complete
CFLAGS and CPPFLAGS by means of AC_MSG_RESULT.

Change-Id: Ifea235feb073a276302436936e908d9125c77a82
2018-03-13 00:03:52 +00:00
Neels Hofmeyr 24bb74732e vty: absorb command explanations from osmo-gsm-manuals
The osmo-gsm-manuals/vty/sgsn_vty_additions.xml contained many command
explanations that are redundant with the VTY online doc. Some however are more
verbose / easier to understand. Absorb these into the online VTY doc here.

This matches the removal in osmo-gsm-manuals change-id
I71863e5056ad369d2055e9882a52a00fa999ab04.

Change-Id: I35984014424412e91437b7ed71576aef3819cb1e
2018-03-06 16:16:34 +01:00
Neels Hofmeyr ee34de141c sgsn_test: guard against struct gprs_ra_id changing
sgsn_test initializes various struct gprs_ra_id without naming the actual
members, which is vulnerable to struct member re-ordering. Name the members
explicitly.

An upcoming ABI change in libosmocore would cause test failures here without
this patch.

Change-Id: I517ed9edf77fac37d9de7a39df24c419a8a65d96
2018-02-21 18:32:10 +01:00
Harald Welte 731930b672 Add talloc context introspection via VTY
This requires libosmocore with Change-Id
I43fc42880b22294d83c565ae600ac65e4f38b30d or later.

Change-Id: I50eb1c5a28efbe4542e177ce3d0a236e75eecdd0
2018-02-14 00:55:36 +00:00
Pau Espin e77ee12fd5 sgsn_libgtp.c: Fix typos and whitespace
Change-Id: Ic223cf378a83051603f58dacf087cc59d9f03890
2018-02-13 22:22:28 +01:00
Pau Espin 7202d7b56a .gitignore: Add m4 files
Existing m4/ax_check_compile_flag.m4 is skipped from the list of ignored
files.

Change-Id: I7ad810e720ee8a02a28c601aa966ddde04023819
2018-02-13 22:22:00 +01:00
Alexander Couzens d9a54af54e mandatory depend on libc-ares and libgtp
Both library are required to build osmo-sgsn.
The optional dependency was correct when osmo-sgsn
was part of openbsc.

Change-Id: Id608165ae490cb6c84aac1fe70412b2cb2b2587b
2018-02-08 09:42:39 +00:00
Max b643f56ebe gtphub: check for gsn_addr_from_sockaddr() error
Change-Id: I2d80b5a488e7daa0bc8f57ea304e0e1f10f6c1f5
Fixes: CID182472
2018-01-30 10:09:00 +01:00
Max 99f99535e5 gtphub: check for gsn_addr_from_sockaddr() errors
Previously the return value was ignored. Check it and log error message.

Change-Id: If6babdad650dc6a84e6a784fc8d3c5abe146ecc1
2018-01-27 17:05:27 +00:00
Pau Espin 54e4849877 configure.ac: Enable Wall in CFLAGS
Change-Id: I042b4918bc74955cc5162fad8c16d989402c29a1
2018-01-23 16:17:21 +01:00
Max 25c65c3d1f Use gsm48_encode_ra() for RAI encoding
It has stricter type signature which increase the chance of spotting
misuse either via compiler warning or with automated scan. This also
paves the way for gsm48_construct_ra() deprecation in libosmocore.

Change-Id: I2c0f082dc7214ed57a40dad0788e34b838dfac97
Related: OS#1640
2018-01-19 15:11:00 +00:00
Neels Hofmeyr 6789c84457 fix build: missing LIBGTP_CFLAGS in sgsn_test
Change-Id: I250cadecaf90238df1afa6997e5d165fb9eee8b6
2018-01-16 14:09:24 +01:00
Max c79ad73492 Remove unused bsc_version.c
Change-Id: Ib3f52c3e4cbd08b28f99d613aa18c6b00c71ead9
2018-01-12 16:48:22 +00:00
Max bb6b00a272 gtphub: make rate_ctr unique
* compute unique rate counter index when allocating new gtphub tunnel
* propagate rate counter allocation error to upper layers
* log and gracefully handle tunnel allocation error

Change-Id: I0e07f95c36de369bcd0691b8d0fd47c844abe5da
Related: OS#2757
2018-01-12 16:50:40 +01:00
Neels Hofmeyr 188a91c35a gprs_llc: tx dl ud: make mismatching LLE not crash osmo-sgsn
On 34c3, osmo-sgsn keeps restarting. At least once, it hits the assertion that
this patch replaces with an error message, to not disrupt operation.

Change-Id: I07a40960920dbc594192530c3a145f9a5d2a9c81
2018-01-11 11:05:32 +00:00
Max e0ed7d949f Fix RAI construction
The gsm48_construct_ra() expect 6-byte buffer while ra_id.digits is
3-byte buffer. The function fills in LAC and RAC as well so we should
pass entire struct, not just 'digits' part which only store MCC/MNC.

Related: OS#1640
Change-Id: I3bfda930012c792452f9fd695ed7acf46365f1df
Fixes: CID57877, CID57876
2018-01-08 13:01:38 +00:00
Pau Espin 8a5c17131d gprs_gmm: Convert warning message to pragma message
This way we can enable -Werror in builds to disallow new compilation
warnings being introduced.

Change-Id: If2b9a618f4219df9e013095beff52c20aacbc79e
2018-01-07 18:16:09 +01:00
Pau Espin d04e6693ca cosmetic: gprs_gmm: Remove trailing whitespace
Change-Id: Ie2466268fbc4699a366856d467660b17e3f7e307
2018-01-07 18:14:12 +01:00
Pau Espin db6f803eb0 gprs_gmm: Remove unused variable
Fixes following compilation warning:
osmo-sgsn/src/gprs/gprs_gmm.c: In function ‘gsm48_rx_gmm_service_req’:
osmo-sgsn/src/gprs/gprs_gmm.c:1786:10: warning: variable ‘ciph_seq_nr’ set but not used [-Wunused-but-set-variable]
  uint8_t ciph_seq_nr, service_type, mi_len, mi_type;
          ^~~~~~~~~~~

Change-Id: If0819026a99f45df96ee6de26a71c16128e79cb8
2018-01-07 18:13:12 +01:00
Pau Espin 76d2c8b268 cosmetic: tests: sgsn_test: Use proper formatting and remove uneeded semicolons
Change-Id: I144175b89f8058f6f8dedfa931c6768d9c43b70e
2018-01-07 18:07:17 +01:00
Pau Espin 0b05039f0d tests: sgsn_test: Define wrap APIs with correct parameters
Fixes following compilation warnings:

osmo-sgsn/tests/sgsn/sgsn_test.c: In function ‘test_gmm_attach_subscr’:
osmo-sgsn/tests/sgsn/sgsn_test.c:1110:30: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
  subscr_request_auth_info_cb = my_subscr_request_auth_info;
                              ^
osmo-sgsn/tests/sgsn/sgsn_test.c: In function ‘test_gmm_attach_subscr_fake_auth’:
osmo-sgsn/tests/sgsn/sgsn_test.c:1144:30: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
  subscr_request_auth_info_cb = my_subscr_request_auth_info_fake_auth;
                              ^
osmo-sgsn/tests/sgsn/sgsn_test.c: In function ‘test_gmm_attach_subscr_gsup_auth’:
osmo-sgsn/tests/sgsn/sgsn_test.c:1275:30: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
  subscr_request_auth_info_cb = my_subscr_request_auth_info_gsup_auth;
                              ^

Change-Id: I5fcb3d460d8becb4cc917fc8d27bfc7e49d50b90
2018-01-07 18:05:25 +01:00
Max c58de6237e Remove obsolete ./configure option
The '--enable-vty-tests' is just alias to '--enable-external-tests'
anyway.

Change-Id: I6230cfcf10247b601e16e7b872305499815520a9
2017-12-28 13:00:51 +01:00
Max 3b6332f6dc Migrate from OpenSSL to osmo_get_rand_id()
This avoids potential licensing incompatibility and makes integration of
Debian packaging patches easier.

The libosmocore version requirements are fine already but for jenkins
tests to pass we have to have Ic77866ce65acf524b768882c751a4f9c0635740b
merged into libosmocore master.

Related: OS#1694
Change-Id: I2b687b7f07ef05bbd861b8479cad5a958a3dde92
2017-12-27 11:10:42 +00:00
Max 794693c093 Use connection id when allocating rate counters
Due to recent libosmocore's change we can't allocate rate counters with
the same name and index which are already allocated. This causes
sgsn_mm_ctx_alloc_iu() failure for multiple subscribers.

Fix this by using conn_id parameter from ranap_ue_conn_ctx.

Change-Id: I1062ffdcac96c82269cab6f4e7ae50e28dc3aa44
Related: OS#2757
2017-12-26 22:22:10 +00:00
Max e9bcbe1545 cosmetic: use macro for gtphub plane iteration
Change-Id: If82fcd9f6509da60e6f0d916fe107de1b38bfd18
2017-12-26 21:27:55 +00:00
Max 68d08ad03f Enable sanitize for CI tests
While at it, also remove unsupported ./configure options remaining since
before repo split.

Change-Id: I77b3375fd680be269fd2df7db61ece6c5d1754ba
2017-12-21 17:15:07 +01:00
Max 367275e851 Remove dead code
Get rid of ifdefs around old unused code to improve readability.

Change-Id: Ia80cf845b624d520d67143b61c9de3d49074cb8c
2017-12-20 16:52:03 +00:00
Max 8a01a803a1 Replace '.' in counter names with ':'
The '.' is illegal character in counter names, as they are exported
via CTRL interface, where '.' has a special meaning that cannot be
used by strings comprising the variable name.

Change-Id: I4eb6851d3577f5942ae1a9ab28d3b3ca7ab8e208
2017-12-20 16:52:03 +00:00
Neels Hofmeyr ceccd4611f gsm48_rx_gmm_att_req: fix error handling: don't clean up NULL llme
Change-Id: I78903d0846568d4e98b6e43e62bbe3c329b5bc68
2017-12-20 16:01:54 +00:00
Alexander Couzens e221665415 .service: remove OpenBSC from service desription
Change-Id: I555939235437a0b3253a1236a918e1f491ed9d3a
2017-12-20 15:47:07 +00:00
Neels Hofmeyr aa7af4d029 gprs_gmm: segfault: gracefully handle failure to alloc context
This counter allocation error I hit uncovers a segfault when allocating an MM
context fails in the GSM_MI_TYPE_TMSI case:

  DRANAP <001a> ../../../src/osmo-iuh/src/iu_client.c:509 handle_co_initial(dir=1, proc=19)
  DRANAP <001a> ../../../src/osmo-iuh/src/iu_client.c:229 RNC 23: new LAC 24358 RAC 22
  DMM <0002> ../../../../src/osmo-sgsn/src/gprs/gprs_gmm.c:1271 MM(---/ffffffff) -> GMM ATTACH REQUEST MI(3427325924) type="GPRS attach"
  DLGLOBAL <001d> ../../../src/libosmocore/src/rate_ctr.c:195 counter group 'sgsn:mmctx' already exists for index 0
  DMM <0002> ../../../../src/osmo-sgsn/src/gprs/gprs_sgsn.c:272 MM(/00000000) Cannot allocate counter group

  Program received signal SIGSEGV, Segmentation fault.
  gsm48_rx_gmm_att_req (llme=0x0, msg=0x555555886950, ctx=0x0) at ../../../../src/osmo-sgsn/src/gprs/gprs_gmm.c:1375
  1375				ctx->p_tmsi = tmsi;

Fix it with a bit of code already present for the GSM_MI_TYPE_IMSI case just
above the segfault.

Change-Id: I49aa95b610f2faec52dede2e4816da47ca1dfb14
2017-12-20 00:41:29 +01:00
Max e882482db5 Remove unneeded .py scripts
The ipa.py has been moved to osmo-python-tests as osmo_ipa - use it for
vty and ctrl tests instead of local copy. The soap.py and twisted_ipa.py
are not SGSN-specific: leftovers from repository split which are now
available in osmo-python-tests as well.

Change-Id: I3ef4ca790878921a5846f64942a8de8a6ff9c11c
2017-12-19 18:21:13 +01:00
Alexander Couzens 41505ae1d3 configure.ac: remove unused libcdk check
libcdk isn't used

Change-Id: Iea2d61b34e9242bf59a1eb242c5cf1d82f625f2e
2017-12-16 20:31:17 +01:00
Alexander Couzens a801fba4d3 configure.ac: remove pcap check
libpcap isn't used in osmo-sgsn

Change-Id: I47880dba1f6855f31b5b6481eeb1027abc2a2671
2017-12-16 20:31:17 +01:00
Alexander Couzens 0c822a3a21 .gitignore: remove non-existent /src/utils exludes
Change-Id: I674da025df4b5d6bcf585a0c764ff186c9281121
2017-12-16 20:31:17 +01:00
Max b24af2bddf Show GTP version for PDP context in vty
Change-Id: Id1692e99ae0d2b78e9473f6139e6e430fcd6a607
2017-12-05 17:54:42 +01:00
Max 8492c2018c Fix display of GTP addresses
Previously we've tried to convert addresses manually which lead to
wrongly displayed GTP addresses (e. g. '4.0.0.0' instead of
'127.0.0.2'). Use libgtp function for conversion to fix it.

Change-Id: I695a9c9497d675564a088b002299096e0dcd267d
2017-12-05 17:49:17 +01:00
Pau Espin 2e9ea50f78 Add vty cmd 'cdr trap' to send CDR through CTRL iface
Default behavior is to have them disabled, and can be explicitly
disabled too by using 'no cdr trap' cmd.

Tested with osmo_ctrl.py that messages are send successfully:
TRAP 0 cdr-v1 20171129125950222,901700000015254,357737055592090,555,0,5,,pdp-periodic,2731,127.0.0.2,127.0.0.1,internet,176.16.222.3,20793,10045,1

Related: OS#2360

Change-Id: I1d144d87effd934d991257a65e19cf046a938907
2017-11-29 14:05:09 +01:00
Pau Espin 291efcb590 sgsn_cdr: Split log formatting into a snprintf function
This function is going to be re-used to send TRAP messages over CTRL
interface.

Related: OS#2360

Change-Id: I0d87df578db1d8c220fd63376e03866895d2aa0d
2017-11-29 12:50:13 +01:00
Pau Espin 2f89547fc9 tests: Fix selection of python version
According to documentation (and personal experience), AM_PATH_PYTHON
selects the highest version of python, no matter if major version is
different, which means if both python2 and 3 are available, 3 will be
chosen an PYTHON will point to "/.../python" which is python3. Apparently,
the macro cannot be easily used to pick highest python2 version.

As {vty,ctrl}_test_runner.py require python2 and are incompatible with
python3, let's instead rely on the system having a "python2" binary
available, which is the case in most distros.

Change-Id: If8e57924ed2c8da7ab7692f58a4bb5c5a970484f
2017-11-28 20:08:19 +01:00
Pau Espin dc730a3173 Replace '.' in counter names with ':'
'.' is an illegal character in counter names, as they are exported
via CTRL interface, where '.' has a special meaning that cannot be
used by strings comprising the variable name.

Change-Id: Ie7734cc42151581897d220b445984448ceb57aed
2017-11-28 19:40:37 +01:00
Neels Hofmeyr 1d047ed24f use default point-code as listed on Point_Codes wiki page
see https://osmocom.org/projects/cellular-infrastructure/wiki/Point_Codes

Change-Id: Ie11f1dfcdd5889d44fefe6cc10472ef1a794cc64
2017-11-24 04:33:08 +01:00
Harald Welte b68413b70c Replace '.' in counter names with ':'
'.' is an illegal character in counter names, as they are exported
via CTRL interface, where '.' has a special meaning that cannot be
used by strings comprising the variable name.

Change-Id: Iec382ec4ee54beb2937431f5a9d8d1171224eebb
2017-11-21 08:51:47 +01:00
Neels Hofmeyr d1c232e1c4 add --enable-sanitize config option
Change-Id: I3be01e0682b479a71c545f718b68c441a1011b0f
2017-11-18 10:16:52 +00:00
Alexander Couzens 77a3c17e1b debian: remove doublicated project name in example files
For example:
/usr/share/doc/osmo-sgsn/examples/osmo-sgsn/osmo-sgsn.cfg -> /usr/share/doc/osmo-sgsn/examples/osmo-sgsn.cfg

Change-Id: I77f9665e78e3e55910efb30cb50cefdb138e19f7
2017-11-15 23:32:02 +01:00
Alexander Couzens adf16966be tests/ctrl_test_runner.py: remove BSC/NAT TestRunner
SGSN was splitted out of OpenBSC.

Change-Id: Ie4e44e49e5c904929869b47fc4d608aab1aab75e
2017-11-15 22:03:15 +01:00
Alexander Couzens 57ad4e249c .gitignore: remove unneeded ignores of bsc/msc/nitb files
sgsn was splitted out of the openbsc repository

Change-Id: I66905432c411291630f66579fa4177936c8f2bcf
2017-11-15 22:02:20 +01:00
Neels Hofmeyr b10a2947d5 vty: skip installing cmds now always installed by default
vty_install_default() and install_default() will soon be deprecated.

Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: Iee1b582a62921cb3205de01ff87d94881e8d411b
2017-11-01 00:52:12 +01:00
Neels Hofmeyr fea0609f4b change default config filename to osmo-sgsn.cfg, not osmo_sgsn.cfg
All other Osmocom programs I know of have a default config file using a dash.
Comply.

Be backwards compatible: when a legacy osmo_sgsn.cfg exists but no
osmo-sgsn.cfg, use the old config file instead. (Verified to work by manual
tests.)

Change-Id: If804da17a7481e79e000fe40ae0d9c4be9722e61
2017-11-01 00:11:30 +01:00
Neels Hofmeyr 07e93ccee6 drop osmo_sgsn.cfg from src/gprs dir
There is a semantically identical config in doc/examples/osmo-sgsn.

Change-Id: I9b9c502afbddcfc02ea70aa8317e0d2f37276c38
2017-10-31 01:58:59 +01:00
Harald Welte 467cfebdae Tag/Release Version 1.2.0
Change-Id: I44bee346fd698bd51ef305813084afdce0099907
2017-10-28 19:08:27 +02:00
Harald Welte f1ad3882e5 Debian: fix dh_strip rules for creating one -dbg per program
Before this patch, all debug symbols end up in osmo-sgsn-dbg,
with osmo-{gbproxy,gtphub}-dbg being empty.

Change-Id: Ib2ceecb3527855350b69d7413efe42274dc6febd
2017-10-28 19:06:40 +02:00
Harald Welte 607f95f267 Debian: Add systemd service files for osmo-sgsn and osmo-gbproxy
Change-Id: I5a5a80bb19c521e8f20241ed8c02d65b4c937f23
2017-10-28 19:05:45 +02:00
Neels Hofmeyr 2fc999adef jenkins: use osmo-clean-workspace.sh before and after build
See osmo-ci change I2409b2928b4d7ebbd6c005097d4ad7337307dd93 for rationale.

Depends: I2409b2928b4d7ebbd6c005097d4ad7337307dd93
Change-Id: I7c3ecd83899f873bdc771ff7445740fea15900ef
2017-10-28 15:08:01 +00:00
Max f89be664dd Log address on GTP creation
Change-Id: Ic54a2ff835c9a0ceccf2f718f56371a881dd25b7
2017-10-27 19:00:12 +02:00
Max c005db7019 Log GTP-U endpoints update
* make gtp_ntoa() public after renaming it to sgsn_gtp_ntoa() to avoid
  confusion with libgtp functions
* use it to log GTP-U endpoints address updates

Change-Id: I96d0f3a63cce338471cc39cc33fd44c39cd2aa73
Related: SYS#3610
2017-10-27 18:49:52 +02:00
Max 869c3605e5 jenkins: check for IU properly
The bug fixed by Idb034bf2ae749204836ab7e02018d769bb242a9f was not
detected by jenkins because it installs libosmo-sccp unconditionally.

Let's be more strict and install it only when necessary for IU builds to
make sure we can catch such bugs in future.

Change-Id: I573c7fec687edb71d79815b38a3bcf96273c03b3
2017-10-26 15:57:55 +02:00
Max 095de01daa Fix libosmo-sigtran dependency
That's follow-up fix for I72819462db0b4656fabaa80731342d06ae91fcdf to
make sure IU builds are properly conditioned.

Change-Id: Idb034bf2ae749204836ab7e02018d769bb242a9f
2017-10-26 15:57:55 +02:00
Max 61940b3f5c gbproxy: don't link unnecessary
* remove sigtran include from common_vty.c because nothing uses it
* remove LIBOSMOSIGTRAN_LIBS from generic OSMO_LIBS
* remove LIBOSMOABIS_LIBS from generic OSMO_LIBS

Both LIBOSMOSIGTRAN and LIBOSMOABIS are linked explicitly when necessary
already anyway.

Change-Id: I015a9d858bc2a95f8c9a4aedd3e0a84eadcf84e1
2017-10-26 15:57:55 +02:00
Philipp Maier fdf509253b configure: fix libosmo-sigtran dependency
the configure script requires libosmo-sigtran even when IU is not
enabled.

move the line that checks for libosmo-sigtran into the conditional
branch for IU

Change-Id: I72819462db0b4656fabaa80731342d06ae91fcdf
2017-10-25 13:12:38 +00:00
Philipp Maier 4a547a1dcf non-iu-build: guard vty libosmo-sigtran function calls.
The function calls osmo_ss7_vty_go_parent() and gtphub_vty_is_config_node()
are not guarded by an ifdef. The functions are only needed for IU
support where libosmo-sigtran is used.

Guard the function calls with a BUILD_IU

Change-Id: I1c609ef0c344ce825c313335c7e084bf97159262
2017-10-25 13:05:21 +00:00
Philipp Maier 5614354be2 log: fix default loglevels
for some log categories the default loglevel is far to verbose.

downgrade all loglevels to LOGL_NOTICE

Change-Id: I3a427ce201c96338a00a84d737d090ac1a77a29f
2017-10-25 13:04:58 +00:00
Max 53ca657e4b Fix build after recent rate_ctr patches
It seems like recent changes expanded output of
dump_rate_ctr_group(). Adjust output accordingly to fix the build.

Change-Id: Icc9a53d35be2b0793d7ed25e6fec5bf6c8f84d92
2017-10-25 10:36:43 +02:00
Max 7933d96531 Fix APN printing
Previously first character of APN was omitted. Fix this by getting rid
of errorneous wrapper function and using osmo_apn_to_str() directly.

The breaking change was introduced in
I7315ffcbed8a54cca2056f313bb7783ad82d0ee9.

Change-Id: Ie13b6cd0066e0370e2adf48d12a363c2e405eaf2
Related: SYS#3610
2017-10-20 18:19:24 +00:00
Max 6f2440282c SGSN: check that GSN is created in proper mode
Change-Id: Ie15364fb3c099806ce8a456ef452200305c836f6
2017-10-20 14:28:04 +02:00
Max baabc681ae SGSN: print additional GTP-related info
* print libgtp version on startup
* print GSN addresses in 'sh sgsn'

Change-Id: I699a9eb56c4b362984ea8292a3d2b22b71f53c15
Related: SYS#3610
2017-10-20 13:39:57 +02:00
Max 72ad237d60 SGSN: uncomment BSSGP vty tests
Change-Id: I9181fc0ecd91e96bf6532aa89b811552009a1b7d
2017-10-20 13:38:45 +02:00
Max 4f979bf4ba Use new FSF address in license header
The issue was uncovered by lintian while checking .deb packaging.

Change-Id: Idfe0e3d61f2604521647e9ef5ffb984db96aabbe
2017-10-17 17:49:59 +02:00
Alexander Couzens 92d788bdac debian/rules: show testsuite.log when tests are failing
Change-Id: I4cc6589d4ce95538baf3f30079a3af53cc218268
2017-10-11 08:13:35 +00:00
Max 7ad8fa65e8 Check for correct P-TMSI allocation
Do not assign new P-TMSI if allocation failed.

Change-Id: Ifa71bbc8df726c74aceaf9ae3eb49e124a53910a
2017-10-09 16:26:43 +02:00
Max 86e04df862 Move P-TMSI alloc/update into separate function
Remove code duplication by allocating and assigning P-TMSI in a static
function.

Change-Id: Ie5466326a851867d55da389bf18b240acd3f0fc5
2017-10-09 16:21:31 +02:00
Max 6e59122ef9 deb: fix copyright file issues
* remove non-existent files
* fix ax_check_compile_flag.m4 license to match autoconf-archive
* fix various .py license to match OpenBSC description

Change-Id: I6881c0a16017d80d142a6cfa756a9c153bee94d3
Related: OS#2527
2017-10-04 12:04:47 +02:00
Max a3b73e917b Use extended logging for PDP contexts
Log additional details (IMSI, NSAPI etc) on PDP context
creation/deletion by using appropriate LOGP() wrappers.

Change-Id: I91a126952ae75ae9ba1f42aac4d26413384bba5d
Related: SYS#3610
2017-10-02 08:38:12 +00:00
Max 74ef149f06 Cleanup configure checks
* remove unused sqlite3 check
* remove unused NAT/SMPP/BSC/MGCP test checks

Change-Id: I83ae896f57cfb4cb139a42fbf3d77d4b11313f65
2017-10-02 08:37:57 +00:00
Neels Hofmeyr 7d913d80cd jenkins.sh: fix echo string to say osmo-sgsn, not msc
Change-Id: I3e9a1503de55e939179c032c17df53d27bdddd51
2017-09-28 19:07:28 +00:00
Max b73f265f75 jenkins: use osmo-ggsn for tests
Change-Id: I62b29b5531bfb9895318254c41a4e24ba1078fbf
2017-09-28 16:38:11 +02:00
Pau Espin 341d446b4d Remove unneeded dep libdbi
This dependency is not needed and it's most probably a left over from
openbsc git repository split.

Change-Id: I84b0e2851dc89dca39e87215c71e93457acb884f
2017-09-25 18:46:28 +02:00
Max 79605f6835 gbproxy: ensure peer allocation result
gbproxy_peer_alloc() could return NULL which wasn't checked and used
right away. Fix it by making this assumption explicit with
OSMO_ASSERT(); While at it, also format log messages consistently.

Change-Id: Ib10c954e17a479baef31ded54370b35938e00018
2017-09-23 13:57:42 +02:00
Max 3b3080b93d Remove rest_octets.h
This header is unused anyway.

Change-Id: Ic34f7d3e8f813e020d43be312df940c933bc52b7
2017-09-15 12:01:02 +02:00
Alexander Couzens f007755e8a debian: fix paths of examples
Change-Id: I054e500be9527b1dd0fc0c21cde2b7b2d2fdfbff
2017-09-14 05:29:17 +02:00
Neels Hofmeyr 396f2e69a0 move include/openbsc to include/osmocom/sgsn
Change-Id: I281ef585fffc2644682c8282224fb1c2da5ca795
2017-09-06 16:47:47 +02:00
Neels Hofmeyr 2c17747c1b move openbsc.pc to osmo-sgsn.pc
Change-Id: Iad28d85b2a6d175cbe5d506aa82e7e4d94111eff
2017-09-06 16:47:47 +02:00
Neels Hofmeyr 6ebf4a4e0a configure.ac: set name to osmo-sgsn, fix ML addr
Change-Id: I47e9f2307b42d171f2ceeda1e129e2311f611883
2017-09-06 16:47:47 +02:00
Neels Hofmeyr ac45b664b1 rewrite README
Change-Id: If78b74494a00ad230aec94e03b2fe4e905473897
2017-09-06 16:47:47 +02:00
Neels Hofmeyr 1e52928ad9 drop files unrelated to osmo-sgsn
These either remain from openbsc.git or slipped in while applying recent
patches from openbsc.git and do not belong in osmo-sgsn.

Change-Id: Ie9dc7514c3850010d0e9b3ab716b4f4e8d83594f
2017-09-06 16:47:47 +02:00
Neels Hofmeyr 075cac02b0 debian: fix osmo-sgsn.install, tweak VCS link and descriptions
Change-Id: I6493a7ca7d996fab00d99652a74a709c860a3de7
2017-09-06 16:47:47 +02:00
Neels Hofmeyr e269d181b0 jenkins: fix build: remove unused dependencies
Change-Id: Ice81f8541eda2cd5beeacbfd481f3e4283211331
2017-09-03 22:51:13 +02:00
Alexander Couzens 508c763e7f rework /debian support to match new osmo-sgsn
Remove old leftover from split of osmo-sgsn out of openbsc.

Change-Id: Ic0135a1118a115e8f053154e280f60674390f43a
2017-08-30 14:18:04 +02:00
Neels Hofmeyr 0010b7e59a sccp init: pass no local m3ua addr to use defaults
Remove the FIXMEs because these addresses are configurable via the cs7 /
{as,asp} vty commands.

Change-Id: Ibafda0a9097183c26b21f3380d24dbe293e132e2
2017-08-30 14:16:56 +02:00
Neels Hofmeyr ee6cfdc0d9 split off osmo-sgsn: remove files, apply build
Change-Id: I5d27ff93e56cd13e0e70edd15e2080201e35e91f
2017-08-30 14:14:58 +02:00
Neels Hofmeyr 6c809185ee add msg type to SMS rx logging
Change-Id: I73ea4eebe57b2d1008045a27f174072178b9f077
2017-08-30 14:12:37 +02:00
Neels Hofmeyr c7b761f303 msc_vlr tests: add IMEISV tests
Change-Id: I752afef2ae3ce04e813c7e9fea0e883e607c0e14
2017-08-30 14:12:37 +02:00
Neels Hofmeyr 94936254eb gsup client: move not-connected to error loglevel
Change-Id: I8290963aedb7237da89c9ff98adf4cd33beb5031
2017-08-30 14:12:37 +02:00
Neels Hofmeyr 34a313f2e2 move to osmo-mgw.git: osmo-bsc_mgcp and libmgcp as libosmo-legacy-mgcp
Rewire build and includes to libosmo-legacy-mgcp.

Drop osmo-bsc_mgcp and related python tests, now found in osmo-mgw.git.

libosmo-legacy-mgcp is installed from osmo-mgw, hence add the dependency to
jenkins.sh (so far using the pre_release branch).

Change-Id: Ic99d681759edce11564da62500c2aac5cf5fffe2
2017-08-30 14:12:37 +02:00
Neels Hofmeyr 7825a29722 .gitignore: cosmetic: use globs to ignore test binaries
Change-Id: I840e4333a4cad646d751ebafe7e0ef23e7a9c708
2017-08-30 14:12:37 +02:00
Neels Hofmeyr 413ecf6859 cosmetic: msc_vlr_tests: drop unused var
Change-Id: I584c0dfffe005597563dbd72fad8a087c554ba3d
2017-08-30 14:12:37 +02:00
Neels Hofmeyr a7a3947b9b move libiu to osmo-iuh/libosmo-ranap
Remove libiu here, use the functions from libosmo-ranap instead, by applying
the ranap_ / RANAP_ prefix.

Corresponding change-id in osmo-iuh.git is I6a3f7ad15be03fb94689b4af6ccfa828c25f45c0

To be able to run the msc_vlr tests for RAN_UTRAN_IU without Iu client headers
available, add iu_dummy.h, containing mere function signatures that match
iu_dummy.c and a mostly empty struct ranap_ue_conn_ctx.

Make sure we can build with and without --enable-iu: include osmo-iuh headers
only with --enable-iu.

Change-Id: Ib8c4fcdb4766c5e575618b95ce16dce51063206b
2017-08-30 14:12:37 +02:00
Neels Hofmeyr e0437166ff MSC,SGSN: use OSMO_GSUP_PORT == 4222 instead of 2222
In SGSN, actually place the port in the SGSN config by default, so that the
gsup port may now be omitted in the VTY config (the IP address suffices).

Adjust the osmo-sgsn.cfg example.

Depends: I4222e21686c823985be8ff1f16b1182be8ad6175 (libosmocore)
Change-Id: I50f2040e2eb0baacb43849e93cfed10cbc2fc156
2017-08-30 14:12:37 +02:00
Philipp Maier 4179ebdec1 mgcp: add VTY Option to force-realloc endpoints
Currently the force_realloc feature is turnd on and of in a
hardcoded way. This patch makes the option available via VTY.

Change-Id: Ic8740512c5ea0766ff6ceb1c28b9c2b3fe46e75f
2017-08-30 14:12:37 +02:00
Philipp Maier efe85d33d4 Implement AoIP, port to M3UA SIGTRAN (large addition and refactoring)
This was originally a long series of commits converging to the final result
seen in this patch. It does not make much sense to review the smaller steps'
trial and error, we need to review this entire change as a whole.

Implement AoIP in osmo-msc and osmo-bsc.

Change over to the new libosmo-sigtran API with support for proper
SCCP/M3UA/SCTP stacking, as mandated by 3GPP specifications for the IuCS and
IuPS interfaces.

From here on, a separate osmo-stp process is required for SCCP routing between
OsmoBSC / OsmoHNBGW <-> OsmoMSC / OsmoSGSN

jenkins.sh: build from libosmo-sccp and osmo-iuh master branches now for new
M3UA SIGTRAN.

Patch-by: pmaier, nhofmeyr, laforge
Change-Id: I5ae4e05ee7c57cad341ea5e86af37c1f6b0ffa77
2017-08-30 14:12:37 +02:00
Max 868dd5d8d3 Use release helper from libosmocore
See
https://osmocom.org/projects/cellular-infrastructure/wiki/Make_a_new_release
for details.

Change-Id: I869395d5c9ab5ec1a487aff15418d1517f47e831
Related: OS#1861
2017-08-30 14:12:37 +02:00
Harald Welte 6f750e63b0 Treat SIGTERM just like SIGINT in our programs
When somebody kills the process, it's best to handle the signal
and to use the opportunity for some cleanup.  We always did this
in the NITB on SIGINT, but never on SIGTERM. Let's change it.

Change-Id: Iea6804325a6575ceab5edfd28dd20249462f143b
2017-08-27 17:40:56 +02:00
Harald Welte b1c1a7676a NITB: remove 'help' output about '-a' option that is removed for ages
This option was present in very early versions of the NITB, but
at least since 2011 it is no longer supported.  It's still listed
in --help output, which is wrong.

Change-Id: I1d2cceb588ec5fb34ec5e2c05a7d8c93310bee88
2017-08-27 17:40:56 +02:00
Keith Whyte 5742ab8aab libmsc: Use actual delivery time in delivery reports.
Set the time on the status report to the time the message was delivered, as
this may not be the same as the time when we are delivering the report to the
originating MS.

Change-Id: I9056429d40bf02731f004b7833f1de45a0d1add8
2017-08-27 17:40:56 +02:00
Max a441e9d60b gbproxy: log signal value as text
Change-Id: I6ed923f5c60a8d64305f4b8e90d1362d6510e1c5
2017-08-27 17:40:56 +02:00
Max 537da6cb48 gbproxy: log unhandled BSSGP PDU as text
Change-Id: Ibe3c8bd353b3a178e26b0936f25b2e1959f9990c
2017-08-27 17:40:56 +02:00
Pau Espin 05a1213b29 libmsc: Fix wrong handling of user_message_reference parameter
libsmpp34 already converts received TLV integer values to native
endianess in libsmpp34_(un)pack.

Converting them again at receive time swaps the 2 bytes of
user_message_reference, then using a wrong value. As GSM03.40 spec
uses only 1 byte for the id, then only the high byte of the initial
value is used and eventually sent back to the ESME. Again, at that time,
htons() is not needed because libsmpp34 already handles that part.

See OS-#2429 for more details.

Change-Id: If748548a4a223e529a1110c89e483b599b406e8b
2017-08-27 17:40:56 +02:00
Pau Espin 12ebe7e042 smpp: Fix compilation warning
I already stumbled into 2 compilation environments which had Werror
enabled for -Wmaybe-uninitialized and the build failed, so let's
workaround this warning.

| smpp_openbsc.c: In function 'handle_smpp_submit':
| smpp_openbsc.c:216:9: error: 'sms_msg_len' may be used uninitialized in this function [-Werror=maybe-uninitialized]
|    memcpy(sms->user_data, sms_msg, sms_msg_len);
|          ^
| smpp_openbsc.c💯15: note: 'sms_msg_len' was declared here
|   unsigned int sms_msg_len;
|                ^
| cc1: some warnings being treated as errors

Change-Id: I0901ddadb5f72e1585cb1797ac22c8ab95e83146
2017-08-27 17:40:56 +02:00
Pau Espin 93fd462cd2 sgsn_test: Fix wrong definition of wrap func
Commit 058cd573d8 added 2 new pointer parameters to
gprs_subscr_request_auth_info, but forgot to update wraps of the
function in sgsn_test.

I catched this today because openbsc build test sgsn_test was failing.
Closed look up to the logs showed:
Assert failed (auts != NULL) == (auts_rand != NULL) openbsc/openbsc/src/gprs/gprs_subscriber.c:791

Change-Id: Ie9e4af6da0339536fb20ca0b7bbcf6f485bd522c
2017-08-27 17:40:56 +02:00
Keith Whyte a12df55ce7 LIBMSC: Use sms->text, not sms->user_data to construct report body
gsm_04_11.c sms_report_alloc()

Use the sms->text, not the sms->user_data to construct the report body.
This also prevents the potential output of non printable characters to
the log and or vty.

Change-Id: Id51bc9483ad6f52d6da74135605cfd12434c7c96
2017-08-27 17:40:55 +02:00
Keith Whyte c42b5f0861 LIBMSC: Place correct dst address in status report
gsm_04_11.c: gsm340_gen_sms_status_report_tpdu()

When we construct the status report PDU, use sms->src
instead of sms->dst as the destination address
This way we tell the MS that the message was delivered
to the destination and not to itself.
This is relevant for phones that display a textual
representation of the delivery report.

Change-Id: I2d4f87ac777465de9bfb5a775a789a2691755ee9
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso 042ffe322c libmsc: use SMPP34_DELIVERY_RECEIPT_* in libsmpp34
Use new definitions in libsmpp34 to set the registered_delivery field
accordingly, as provided by I5b3afff1b3b77cccd949e0606914c7ac3ba6114c.

Moreover, do not set this header field to zero if status reports are
off, the deliver_t structure has been already zeroed so this not
required.

Change-Id: Ie78e17323796120f576b9c0e1bc5ccc32da8ee12
2017-08-27 17:40:55 +02:00
Harald Welte 9b7f16317d increase libsmpp34 version requirement to 1.12
Only 1.12 contains some of the #defines that we're using with recent
commits.

Change-Id: I3743b10a1a5d2f1d42a61204273c1d00dc22b600
2017-08-27 17:40:55 +02:00
Harald Welte 7e82b74c75 Migrate from gprs_apn_to_str() to libosmocore osmo_apn_to_str()
In 2015, Jacob moved/copied related functions to libosmocore, but
for some reason didn't remove the copies here.  Let's follow-up on
that and remove duplicated code.

The libosmocore commit introducing osmo_apn_to_str() was
8114294bf29ac6e44822c0ae43d4b0819f11b022

Change-Id: I7315ffcbed8a54cca2056f313bb7783ad82d0ee9
2017-08-27 17:40:55 +02:00
Harald Welte dfbd2c88d2 sgsn_vty: Don't assume pdp->lib is always valid
We can only print libgtp pdp information if a library context is
attached to this pdp context.  This is not always the case,
particuarly during some teardown scenarios.

Change-Id: Ia3184877f9709db65f5f93a98403f2ef5b04a8ca
2017-08-27 17:40:55 +02:00
Harald Welte 619021da9a Fix gsm_pchan2chan_nr() to use RSL_CHAN_OSMO_PDCH
When converting from GSM_PCHAN_PDCH, we should generate
a RSL channel number IE with the osmocom extension
RSL_CHAN_OSMO_PDCH rather than claiming it is a regular
TCH/F channel.

This is important as this function is used by
osmo-bts, too - and it decides which channel number IE is
put in the GSMTAP header for both GSMTAP tracing as well
as the GSMTAP based osmo-bts-virtual.

In order to avoid any unintended effect on libbsc,
we make sure to modify rsl_ipacc_pdch_activate() to
always use GSM_PCHAN_TCH_F in related RSL message.

Change-Id: Ie34219e64a6d89da4a79f2db8ec73d1909fb8280
2017-08-27 17:40:55 +02:00
Harald Welte a4feac25d0 SGSN: Fix RAN information exposed on GTP during PDP CTX CREATE
In the PDP Context Create from SGSN to GGSN, we include information
about the RAN type (GERAN/UTRAN) and the Cell of the MS. This was
all hard-coded to GERAN, and wasn't updated when we added UTRAN
support to the SGSN.

Change-Id: I6c79e42c5e08b28fe8182555302a5505fbbaa313
2017-08-27 17:40:55 +02:00
Pau Espin ecee67d9e8 mgcp: Fix uplink activation of Osmux stream
Commit 5754206379 introduced
OSMUX_STATE_NEGOTIATING to fix a race condition present in osmo-bsc_nat.
However, after this change osmo-bsc_mgcp cannot switch to
OSMUX_STATE_ACTIVATING anymore, which means during osmux_send_dummy time
it won't call osmux_enable_endpoint(), which in turn won't set endp type
to MGCP_OSMUX_BSC.

If MGCP_OSMUX_BSC is not set, uplink streams are sent using regular RTP
instead of Osmux not matter it is enabled in config or not.

Change-Id: Ibcb59aa1ca25408f82cc88c2d5b81177b5f276dc
2017-08-27 17:40:55 +02:00
Ivan Kluchnikov c7decfe743 handover_logic: set correct link to bts for subscriber_connection in case of moving this connection to another bts
In case of successful completion of handover gsm_subscriber_connection could be moved from one bts to another,
so connection link to bts should be replaced by link to bts, which owns new_lchan.
This bug was detected, because conn->bts->nr is used in call control log messages
and wrong number of bts was observed in these messages after handover.

Change-Id: Idc7dd412b7580c451e716b73ef7549826c60b0d9
2017-08-27 17:40:55 +02:00
Pau Espin a34a419b6e mgcp_osmux: Remove unused parameter
Change-Id: Icb1e7cb15fe04642578f5292124ebc1eac9c9aa3
2017-08-27 17:40:55 +02:00
Alexander Chemeris 6e437b7523 libcommon: Fix log output for bts>0.
Fixes regression probably introduced in c696cc28.

For bts>0 logging doesn't show bts number correctly when printing lchan
identification string - it will always show it as "bts=0". The reason for
this is that the identification string is cached before bts->nr value is
set to a proper value.

This patch sets bts->nr as part of the first step of the bts structure
initialization, before caching happens thus making sure the cached
identification string is cached with the correct values.

Change-Id: I61c18a7f021fcb1ec00d34a745f4e3ab03416c2d
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso 57edda7fc5 libmsc: use new smpp34 esm_class definitions
Replace magic numbers by esm_class definitions, which
have been added to latest libsmpp34 in Change-Id
I91afd8b462b8fd3b2c4c5b54f4eeb7ec5b730b65

Change-Id: I6c458690da60c8f3637680efbd718f6e8c6feb4c
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso e6ad4c896d libmsc: use smpp34_tlv_for_each() to avoid suboptimal TLV handling
submit_to_sms() now handles two TLVs, so find_tlv() is suboptiomal and
it can be removed, since it would result in two passes on the TLV list.
Use new smpp34_tlv_for_each() helper to iterate over the list of TLVs
that is available since I446929feed049d0411e1629ca263e2bc41f714cc.

Change-Id: I53a65164a6cc4abc6bf57d9a8dc275cf21c90222
2017-08-27 17:40:55 +02:00
Pau Espin 78a0429a59 libmsc: Remove comment not applying anymore
The change-id I7276d356d805a83ebeec72b02c8563b7135ea0b6 added msg_ref to
the databse but forgot to remove the comment stating it's not being
stored.

Change-Id: I204f098c8f2a480405446113e2181b2c53700cf3
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso 0456d2bc32 libmsc: gsm340_gen_oa_sub() may return negative value
gsm340_gen_oa() returns a negative value if the output buffer that the
caller passes is too small, so we have to check the return value of this
function.

Fixes: CID 174178
Fixes: CID 174179
Change-Id: I47215d7d89771730a7f84efa8aeeb187a0911fdb
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso 170285d236 libmsc: support GSM 03.40 status report for nitb
This patch adds support for GSM 03.40 in nitb mode.

          MS         GSM 03.40          SMSC
           |                            |
           |         SMS-SUBMIT         |
           |--------------------------->|
           |     GSM 04.11 RP-ACK       |
           |<---------------------------|
           |         SMS-DELIVER        |
           |<---------------------------|
           |     GSM 04.11 RP-ACK       |
           |--------------------------->|
           |     SMS-STATUS-REPORT      |
           |<---------------------------|
           |     GSM 04.11 RP-ACK       |
           |--------------------------->|
           |                            |

Change-Id: I5cc7bb4ebadde0940f44d10c3df34707b0615160
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso 30743ab197 libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report
This patch adds gsm340_sms_send_status_report_tpdu() to build a
status-report. Moreover, set sms->report field if we see a SMPP
SUBMIT_SM with Delivery Acknowledgment esm_class, so this identifies
that this is a delivery report.

    MS        GSM 03.40           SMSC       SMPP 3.4               ESME
     |                             |                                |
     |                             |           SUBMIT-SM            |
     |                             |    esm_class = Delivery Ack    |
     |                             |<-------------------------------|
     |                             |         SUBMIT-SM-RESP         |
     |                             |------------------------------->|
     |                             |                                |
     |     SMS-STATUS-REPORT       |                                |
     |<----------------------------|                                |
     |     GSM 04.11 RP-ACK        |                                |
     |---------------------------->|                                |
     |                             |                                |

There is a FIXME message in this patch, that I just copied from
gsm340_gen_sms_deliver_tpdu() since TP-MMS is not supported by OpenBSC.

Change-Id: Ib70e534840308ed315f7add440351e649de3f907
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso 20366613c4 utils: smpp_mirror: bounce Delivery Receipts as Delivery Acknowledgments
Simple patch to test the new status-report support code, remove previous
code before Delivery Acknowledgement support was in place. Use
LOGL_DEBUG for logging messages here as suggested by Neels and Harald.

Change-Id: I877e228d8e174430f700631edbf9955972da7892
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso 423c0f8c44 libmsc: update database to accomodate SMS status-report fields
SMPP DELIVER_SM messages with esm_class = Delivery Receipt need to send
this message reference (that the mobile phone allocates) to the ESME.
Thus, the ESME propagates it via SUBMIT_SM with esm_class = Delivery
Acknoledgment so that the SMSC sends the GSM 03.40 status-report to the
origin including this. Given this field is useful for status-reports, we
need to store it in the HLR database.

Moreover, we need a new field that specifies if the entry represents a
SMS status-report, to do the right handling from the gsm411_send_sms() -
such new handling comes in a follow up patch entitled "libmsc: handle
delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report".

This patch includes the migration routines to the new database schema
revision 5, it's quite a bit of dbi boilerplate code - copied-pasted and
adapted.

Change-Id: I7276d356d805a83ebeec72b02c8563b7135ea0b6
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso 18659327a8 libmsc: add support for SMPP delivery receipts
If the mobile phone requests a status report via SMS, send a DELIVER_SM
with esm_class = Delivery Receipt to ESME to indicate that the SMS has
been already delivered to its destination.

    MS        GSM 03.40           SMSC       SMPP 3.4               ESME
     |                             |                                |
     |       SMS-DELIVER           |                                |
     |<----------------------------|                                |
     |     GSM 04.11 RP-ACK        |                                |
     |---------------------------->|                                |
     |                             |           DELIVER-SM           |
     |                             |  esm_class = Delivery Receipt  |
     |                             |------------------------------->|
     |                             |         DELIVER-SM-RESP        |
     |                             |<-------------------------------|
     |                             |                                |

This patch implements "Appendix B. Delivery Receipt Format" as specified
in the SMPP 3.4 specs. This string is conveyed in the SMS message as
data, and it is only meaningful to the ESME, for logging purposes. The
"submit date" and "done date" are not yet set, and other fields are just
sent with dummy values, so they are left to be finished as future work.

The new SMPP TLV tag TLVID_user_message_reference is added to the SMPP
messages inconditionally now since this information is required by
delivery-reports to associate the status-report with the original SMS.

Change-Id: Ic1a9023074bfa938099377980b6aff9b262fab2a
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso b35754d5cd utils: smpp_mirror: reflect message reference TLV
Useful to test the delivery receipt support. This TLV contains the
GSM03.40 message reference.

Change-Id: I1b0abaa7e06ffe1bd2242c70813d8b70e9fa954f
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso e16b1125f8 utils: smpp_mirror: temporarily munch SMPP delivery receipts
Just munch and log SMPP delivery receipts by now, don't mirror this, it
is going to break things in openbsc.

Follow up patch removes this and mirrors this SMPP message as a
SUBMIT_SM with esm_class = Delivery Acknowledgement.

Change-Id: I78e93bc4034679e238c8642ccf6a0e844b1d6d8b
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso be836ff805 utils: smpp_mirror: set registered_delivery field in SMPP SUBMIT_SM
To test delivery reports using this utility.

Change-Id: I0e477407531fdd4d906e53c9b5a48a79a239966f
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso be4e21d1d2 libmsc: missing bit shift in status report flag when stored in sms object
So we just store 0 or 1 depending on what the mobile phone requests.

Change-Id: Idb7d5594219c0e458ccb561383a59604bc1a4201
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso d3acbb29e5 libmsc: report status report request flag from SMPP SUBMIT_SM
Restore the sms status report request flag from SUBMIT_SM.

Change-Id: Iac05252253f8933a3875b4904599b7a225191a4b
2017-08-27 17:40:55 +02:00
Pablo Neira Ayuso 0df759f4d4 libmsc: set registered_delivery field in SMPP 3.4 DELIVER_SM messages
Propagate the status report request field to the SMPP message through
the registered_delivery field, so the ESME knows that the mobile phone
is asking for explicit delivery acknowledgment is required. See SMPP 3.4
specs section 5.2.17.

Change-Id: I59af60fa89cd10ae973c5e122789e3e03e3728ee
2017-08-27 17:40:55 +02:00
Neels Hofmeyr dfee042308 timer vty: also print the default value in cmd doc
Rationale: allows seeing all timer defaults at once by doing

  OsmoBSC(config-net)# timer ?

Before, defaults are visible only by doing on each timer:

  OsmoBSC(config-net)# timer t1234 <tab>

Change-Id: I8259234e5c62e058dde56d531071440bbab11462
2017-08-27 17:40:55 +02:00
Neels Hofmeyr 5b93630812 vty: add 'default' keyword to timer config
Change-Id: I4e837e8bedfad7ac4fd50048ecb016ddb37c2397
2017-08-27 17:40:55 +02:00
Neels Hofmeyr 7cd759edd0 cosmetic: vty for timers: remove obsolete range check
The VTY parsing already ensures the parameter range being 1..65535, no need to
check the range again.

Change-Id: I1cffa5b01cd5c589f1e42998e32135f1da8c960b
2017-08-27 17:40:54 +02:00
Pablo Neira Ayuso 36b8d83267 libmsc: move gsm340_rx_sms_submit() to sms_route_mt_sms()
Move the sms message-type-identifier (mti) handling away from the
routing logic. This patch allows us to reuse the sms_route_mt_sms()
function in a follow up patch for sms reports send through SMPP
DELIVER_SM with esm_class = Delivery Receipt whose Change-Id is
Ic1a9023074bfa938099377980b6aff9b262fab2a.

Change-Id: I3f3d30e0762b91e2099243b0be1a4b67cbb5e9c0
2017-08-27 17:40:54 +02:00
Pablo Neira Ayuso e754f8784f libmsc: remove 'deferred' parameter in sms_route_mt_sms()
No need to cache the sms object, just cache what we need into the
smpp_cmd structure. This simplifies what that I introduced in
93ffbd0029 ("libmsc: send RP-ACK to MS after ESME sends SMPP
DELIVER-SM-RESP").

Change-Id: Iba5f864f9bb963baff95969e306b1b7cff00c1e3
2017-08-27 17:40:54 +02:00
Pablo Neira Ayuso 40c690be6d libmsc: remove duplicate lines in deliver_to_esme()
This code is accidentally doing the same thing twice, remove it.

Change-Id: I68087a850399e22951d2407e4d8a09c671a775c9
2017-08-27 17:40:54 +02:00
Pablo Neira Ayuso a46ee7af37 libmsc: remove dead code in sms_route_mt_sms()
The following branch:

	if (!rc && !gsms->receiver)
		rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;

at the end of sms_route_mt_sms() always evaluates false.

Just a bit before, in such function, we have this:

        if (!gsms->receiver) {
                ...
 #ifdef BUILD_SMPP
                ...
 #else
                ...
 #endif
                return rc;
        }

So, if there is no receiver, we just stop running code and return the RP
cause via the rc variable. Same applies to the smpp_first check under
the BUILD_SMPP ifdef (that I have removed in this snippet to keep this
commit message small).

Change-Id: Ic3502b5b169bc7a73a67fd6ff53d8b6c0dc045c8
2017-08-27 17:40:54 +02:00
Pablo Neira Ayuso d0c470ca26 libmsc: do not leak pending SMPP command object on error path
Make sure the SMPP command object is released on errors.

Change-Id: I474584425d23fb379a9d71b33e29ac0e24f01e61
2017-08-27 17:40:54 +02:00
Pablo Neira Ayuso f15c891391 gsm_04_11: get rid of unused parameter in sms_route_mt_sms()
This parameter is unused, remove it.

Change-Id: I797abce3f91447e8f397c7cf726db7425479fe0e
2017-08-27 17:40:54 +02:00
Holger Hans Peter Freyther 9f30e402d5 sgsn: Convert cch_pdp to host order for libgtp
libgtp is calling gtpie_tv2 which will convert this uint16_t from host
to network order. So far libosmogsm and the sgsn treated the charging
characteristics as opaque data. So when moving from byte array to the
uint16_t do the swapping.

Change-Id: I977aec2e2f8d57802e45f591754e5733562d5c2a
2017-08-27 17:40:54 +02:00
Harald Welte cd8a252fb7 remove code disabling T3109 if configured to 0
We no longer permit timers with a 0 value, so this case can never
happen.  Also, if it should happen, I'd rather have a timter expiring
immediately (and breaking something) than not being started in the
first place.

Change-Id: Ibfcdd3ddc0155caee89c501498329bde247621a0
2017-08-27 17:40:54 +02:00
Harald Welte 3f263d4cb4 bsc_vty: Don't allow timers of zero (0)
It typically doesn't make sense to configure any of the GSM RR timer
to 0 (Seconds).  In fact, accidentially configuring any of the timers
to zero might have severe side effects, such as "stuck channels"
described in https://osmocom.org/issues/2380

Change-Id: I517828f2f0c80ec01cb63648db2626f17a67fe57
2017-08-27 17:40:54 +02:00
Harald Welte 72aaf4ce65 GSM timers: User reasonable defaults; don't save if equal default
A number of the GSM timers (including T3109) had no reasonable
default values if not specified in the VTY / config file.  Together
with unconditional writing to the config file, this created
config files with a persistent setting for important timers as '0'.

To make things worse, many of our example cofig files suffered from the
same problem.

Let's avoid this from happening by
* having reasonable defaults if nothing specified in the config file
* conditionally savingg timers only if they differ from default
* reject any timer values that state zero during start-up (see previous
  commit)

Change-Id: Iaac0bfca423852b61d8b9eb1438157ef00d0d8c8
Closes: OS#2380
2017-08-27 17:40:54 +02:00
Harald Welte 7103199331 bsc_vty: Add VTY command to test CTRL TRAP feature
Using this new command (introduced in OsmoBSC + OsmoNITB), you can
simulate the generation of TRAP events for testin purposes.

start the control interface monitor as an example client program:
	./openbsc/contrib/bsc_control.py -m -d localhost -p 4249

then start OsmoBSC or OsmoNITB, telnet to the VTY and enter 'enable'
mode and issue the following (example) command:
	ctrl-interface generate-trap my.foo.var 2342

As a result, on the bsc_control.py you will see:
	Got message: TRAP 0 my.foo.var 2342

Change-Id: Ib1d2ec38290dc94797c1b365d9b733e5215ab7d1
2017-08-27 17:40:54 +02:00
Harald Welte d939ac0cf4 gtphob: check for missing result of rate_ctr_group_alloc()
In case the counter group allocation fails, we must handle this
gracefully and fail the allocation of the parent object, too.

The recent change (Id I7dad4a4d52fe05f6b990359841b4408df5990e21) seems
to have missed one instance, so let's follow-up.

Change-Id: I1ee9e3d26dcc18e7f979fd9a786162cbcc50942c
Related: OS#2361
2017-08-27 17:40:54 +02:00
Harald Welte 23a6812a09 gsm_bts_trx_set_system_infos(): Disable non-existing SI
If we previously had a given SI present/active, we must send a
zero-length BCCH FILLING for that SI type to the BTS to stop it from
further transmitting this SI.

Change-Id: I33e356e2fa3a69efac9080813e3e9ef4e6438ed1
Closes: OS#2368
2017-08-27 17:40:54 +02:00
Harald Welte e7bd366a0e RSL: Allow disabling of BCCH/SACCH filling for given SI type
If we want to instruct the BTS to stop sending a given SI, we must be
able to send the respective BCCH INFO / SACCH FILLING with a header but
without any L3 data IE.  This patch enables the related functions to do
this whenever their data argument points to NULL.

Change-Id: I88b85614951a108574f05db3b706884afe7e87a9
2017-08-27 17:40:54 +02:00
Harald Welte 71cb4e6cfb Fix regression causing loss of static system-information messages
In commit 8b1a2f8cd7 we started to
initialize bts->si_valid to 0.  This means we are skipping the manually
configured static system information.

Instead, we have to initialize bts->si_valid to bts->si_mode_static,
i.e. start with those that are static and not to be auto-generated.

Found while developing
http://git.osmocom.org/osmo-ttcn3-hacks/tree/sysinfo

Change-Id: Iab9cc93cf6d54560a72cc393cc3721a8d10e04bf
Closes: #2367
2017-08-27 17:40:54 +02:00
Harald Welte 26c1465475 check for missing result of rate_ctr_group_alloc()
In case the counter group allocation fails, we must handle this
gracefully and fail the allocation of the parent object, too.

RelateD: OS#2361
Change-Id: I7dad4a4d52fe05f6b990359841b4408df5990e21
2017-08-27 17:40:54 +02:00
Harald Welte bf982e066d libbsc: Add VTY command to re-send the SYSTEM INFORMATION to BTS
This is useful if you are updating some configuration parameters which
affect the content of the SYSTEM INFORMATION messages.  Currently, we
only send them at the time the RSL connection is established (i.e. when
the BTS is initialized), so if you change something, you need to bring
down and re-start the BTS.

Using the newly-introduced "bts <0-255> resend-system-information"
command, you can re-generate + re-send SYSTEM INFORMATION without
bringing the BTS down, i.e. without any radio carrier downtime.

Change-Id: I326df47de98f6d36c9a4d2d5475225d1e62bafb5
2017-08-27 17:40:54 +02:00
Harald Welte 0db2f690ef bsc_api: Fix copy+paste error in printing name of RR STATUS PDU
Change-Id: I0ef78ef046e4850346569f750693e12938b50ab5
2017-08-27 17:40:54 +02:00
Benoit Bolsee 00f041c4b6 transaction: reject calls from unidentified subscribers
A valid subscriber is indespensible when allocating a new
transaction. Return NULL if no subscriber is supplied. This
will cause unidentified subscribers to be rejected.

Note: Under normal conditions, the problem does not occour,
but it is still possible that a misbehaving MS might trigger
the problem by sending a SETUP command before authenticating
the subscriber. (unencrypted networks)

Change-Id: Ia8739b6e329ab02c0064270d02ad1d6ee245520d
2017-08-27 17:40:54 +02:00
Max c02d72bf94 Fix BTS attribute requests
* fix BTS numbers: use 0 to indicate given BTS and 0xFF to indicate all
  BTS' as it's explained in 3GPP TS 52.021 §9.3.
* only request attributes from supported (OsmoBTS) types

Change-Id: I8f43055c38000248033a8ff9ddaf0910d68d794b
Related: OS#2317
2017-08-27 17:40:54 +02:00
Harald Welte ba2ad433b9 Add VTY commands for experimentation with TS 04.14 commands
TS 04.14 (TS 44.014) specifies a series of commands specific to
conformance testing.  Let's add some VTY commands to play (at least
initially) with closing and opening voice loops in the MS.

Change-Id: I38b1ee9dbf26f5689c38cb83b1b3c5e9eaad7678
2017-08-27 17:40:54 +02:00
Harald Welte e19faeea89 Support for TS 04.14 conformance test commands
Change-Id: Ib27edbfc8ccdedf00589ec715ced7bed435fa94c
2017-08-27 17:40:54 +02:00
Alexander Chemeris 8508ee5412 libmsc: Fix VTY output for handover counters.
Handover countrs belong to BSC, but we mistakenly take values from MSC counters.

Change-Id: I9512330f2e91d2f526751c5228e6e8e0fe17d579
2017-08-27 17:40:54 +02:00
Holger Hans Peter Freyther 5db6857204 sgsn: Fill the cch_pdp with a value coming from the tlv structure
For some GGSNs we need to insert the PDP Charging Characteristics
that were returned. We receive these values from GSUP and will
fill them into the tlv structure when finding the ggsn context.

Change-Id: I1725bfd2403d29ce3550bfcd6fcc1498426ef906
2017-08-27 17:40:54 +02:00
Benoit Bolsee b84c54eeee 04.08: find a portable way to obtain the timezone offset
Portable GMT offset calculation to display correct
time on GSM.

Change-Id: I673f17af2550c9708c4771e4ea4eafbbfafbb824
2017-08-27 17:40:54 +02:00
Harald Welte c3e0e4ed26 jenkins.sh: Proper error message if local environment isn't set up
Change-Id: I79c2302365824d9c8783dadfa378c8eaa07e2ee7
2017-08-27 17:40:54 +02:00
Benoit Bolsee 7535c0723c smpp: fix return cause
Return cause 38 when default SMPP route is unavailable. This
is better than cause 1.

Change-Id: If3241d50a78fa611981e55fef6ae4c72b0a2a167
2017-08-27 17:40:53 +02:00
Pau Espin 2c1e2b7f87 smpp_smsc.c: Log on sending deliver_sm message
Change-Id: Ie16294df6d5bc0065f8d2b49320ead61f535f271
2017-08-27 17:40:53 +02:00
Neels Hofmeyr 74146bc469 Use value string check from osmo-ci
Necessary since libosmocore I513835be2d931d0a931cdfc996f361a451bc1a15
removes the script from libosmocore/contrib.

Change-Id: I02d7e1c0151c687fd9341d21a09ca15cbf5a1938
2017-08-27 17:40:53 +02:00
Daniel Willmann c01bc00d35 examples/sgsn: Use osmo-hlr with auth-policy remote by default
For the vty tests, add osmo-sgsn-accept-all.cfg (that does not need an HLR) and
use in vty_test_runner.py, otherwise the 'show sgsn' command will reply that it
could not connect to the HLR, failing the vty test which expects empty.

Change-Id: Ie3b2013198d3e2b780a4e31c36b89b58129dcacd
2017-08-27 17:40:53 +02:00
Daniel Willmann c3bf304aed contrib: Change systemd requirements so the services connect properly
Change-Id: Ib1b3c640ddd81927a60ee307c4b0cb90fd83eebe
2017-08-27 17:40:53 +02:00
Daniel Willmann 806e127569 examples: Change IP address of config files
This helps in providing 3G software packages for the sysmoNITB hardware, which
uses 10.23.24.1 for SGSN and 10.23.24.2 for GGSN.

However, in order to not break the python tests, the osmo-sgsn.cfg example
still uses 127.0.0.1 as local address.

Change the GGSN address to 127.0.0.2, because SGSN and GGSN cannot co-exist on
the same address (the GTP port number is fixed by spec: no IE to communicate a
differing port, so it has to be the standard GTP port for both).

Change-Id: Ie3a25f6771ed6e620cb2b315638c622a9a24e530
2017-08-27 17:40:53 +02:00
Daniel Willmann 677d229fdb contrib: Add osmo-msc service file
Change-Id: Ifdaf4107167c84af8a616f4ee792d5a34495564b
2017-08-27 17:40:53 +02:00
Neels Hofmeyr dff0ec11f6 04.08: log protocol discriminators and message types by name
On incoming 04.08 messages, we log only the protocol discriminator in
decimal. Enhance: log pdisc and message type in hex, and also log the
protocol and message type as human readable string.

Also adjust the msc_vlr tests' log statements for wrapped rx/tx functions
of dtap from/to the MS.

Adjust the expected output of msc_vlr_tests.

Change-Id: Ida205d217e304337d816b14fd15e2ee435e7397d
Depends: libosmocore change-id I0fca8e95ed5c2148b1a7440eff3fc9c7583898df
2017-08-27 17:40:53 +02:00
Neels Hofmeyr 3e168c072d mgcp: hack RAB success from nano3G: patch first RTP payload
The ip.access nano3G needs the first RTP payload's first two bytes to read hex
'e400', or it will reject the RAB assignment. Add flag
patched_first_rtp_payload to mgcp_rtp_state to detect the first RTP payload on
a stream, and overwrite its first bytes with e400. This should probably be
configurable, but seems to not harm other femto cells (as long as we patch only
the first RTP payload in each stream). Only do this when sending to the BTS
side.

Related: OS#2459
Change-Id: I5eff04dcb0936e21690e427ae5e49228cd459bd4
2017-08-27 17:40:53 +02:00
Neels Hofmeyr 7b0c9687d7 fix msc_vlr tests after libosmocore uses localtime for SMS
libosmocore change-id I4efdb1eaae43aced33961b64d4f14b0040321c10 changes the
gsm340_gen_scts() from gmtime to localtime, meaning that by feeding a mere zero
as timestamp, we get different results depending on the local machine's
timezone setting. Instead of calling gsm340_gen_scts() with zero, simply write
a bunch of bytes as time so that the tests get identical SMS bytes every time.

Change-Id: I8a50e8963dce80609749571b61fc6ffe1c54660c
2017-08-27 17:40:53 +02:00
Neels Hofmeyr 2188a778b5 Implement IuCS (large refactoring and addition)
osmo-nitb becomes osmo-msc
add DIUCS debug log constant
add iucs.[hc]
add msc vty, remove nitb vty
add libiudummy, to avoid linking Iu deps in tests
Use new msc_tx_dtap() instead of gsm0808_submit_dtap()
libmgcp: add mgcpgw client API
bridge calls via mgcpgw

Enable MSC specific CTRL commands, bsc_base_ctrl_cmds_install() still needs to
be split up.

Change-Id: I5b5b6a9678b458affa86800afb1ec726e66eed88
2017-08-27 17:40:53 +02:00
Neels Hofmeyr c9a352f416 sgsn init: pass sgsn_config pointer to sgsn_vty_init(), not sgsn_parse_config
In an upcoming commit, sgsn_vty_init() will require access to the global sgsn
config struct to initialize a generic VTY command with the proper config
destination address, see Change-Id I5b5b6a9678b458affa86800afb1ec726e66eed88.

Change-Id: Ie6b6e5422987586531a898e0c5b867623dbecb0f
2017-08-27 17:40:53 +02:00
Neels Hofmeyr ce67be1910 mscsplit: various preparations to separate MSC from BSC
Disable large parts of the code that depend on BSC presence. The code sections
disabled by #if BEFORE_MSCSPLIT shall be modified or dropped in the course of
adding the A-interface.

Don't set msg->lchan nor msg->dst.
Don't use lchan in libmsc.
Decouple lac from bts.

Prepare entry/exit point for MSC -> BSC and MSC -> RNC communication:
Add msc_ifaces.[hc], a_iface.c, with a general msc_tx_dtap() to redirect to
different interfaces depending on the actual subscriber connection.
While iu_tx() is going to be functional fairly soon, the a_tx() is going to be
just a dummy for some time (see comment).
Add Iu specific fields in gsm_subscriber_connection: the UE connection pointer
and an indicator for the Integrity Protection status on Iu (to be fully
implemented in later commits).
Add lac member to gsm_subscriber_connection, to allow decoupling from
bts->location_area_code. The conn->lac will actually be set in iu.c in an
upcoming commit ("add iucs.[hc]").

move to libcommon-cs: gsm48_extract_mi(), gsm48_paging_extract_mi().

libmsc: duplicate gsm0808 / gsm48 functions (towards BSC).
In osmo-nitb, libmsc would directly call the functions on the BSC level, not
always via the bsc_api. When separating libmsc from libbsc, some functions are
missing from the linkage.
Hence duplicate these functions to libmsc, add an msc_ prefix for clarity, also
add a _tx to gsm0808_cipher_mode():
* add msc_gsm0808_tx_cipher_mode() (dummy/stub)
* add msc_gsm48_tx_mm_serv_ack()
* add msc_gsm48_tx_mm_serv_rej()
Call these from libmsc instead of
* gsm0808_cipher_mode()
* gsm48_tx_mm_serv_ack()
* gsm48_tx_mm_serv_rej()
Also add a comment related to msc_gsm0808_tx_cipher_mode() in two places.

Remove internal RTP streaming code; OsmoNITB supported that, but for OsmoMSC,
this will be done with an external MGCP gateway.

Remove LCHAN_MODIFY from internal MNCC state machine.

Temporarily disable all paging to be able to link libmsc without libbsc.
Skip the paging part of channel_test because the paging is now disabled.
Employ fake paging shims in order for msc_vlr_tests to still work.

msc_compl_l3(): publish in .h, tweak return value.  Use new libmsc enum values
for return val, to avoid dependency on libbsc headers.  Make callable from
other scopes: publish in osmo_msc.h and remove 'static' in osmo_msc.c

add gsm_encr to subscr_conn
move subscr_request to gsm_subscriber.h
subscr_request_channel() -> subscr_request_conn()
move to libmsc: osmo_stats_vty_add_cmds()
gsm_04_08: remove apply_codec_restrictions()
gsm0408_test: use NULL for root ctx
move to libbsc: gsm_bts_neighbor()
move to libbsc: lchan_next_meas_rep()
move vty config for t3212 to network level (periodic lu)
remove unneccessary linking from some tests
remove handle_abisip_signal()
abis_rsl.c: don't use libvlr from libbsc

gsm_subscriber_connection: put the LAC here, so that it is available without
accessing conn->bts. In bsc_api.c, place this lac in conn for the sake of
transition: Iu and A will use this new field to pass the LAC around, but in a
completely separate OsmoBSC this is not actually needed. It can be removed
again from osmo-bsc.git when the time has come.

Siemens MRPCI: completely drop sending the MRPCI messages for now, they shall
be added in osmo-bsc once the A-Interface code has settled. See OS#2389.

Related: OS#1845 OS#2257 OS#2389
Change-Id: Id3705236350d5f69e447046b0a764bbabc3d493c
2017-08-27 17:40:53 +02:00
Neels Hofmeyr fa68ccde69 vlr: LU FSM: enable Retrieve_IMEISV_If_Required
Change-Id: I121b95ad6d5ecb7603815eece2b43008de487a8a
2017-08-27 17:40:53 +02:00
Neels Hofmeyr 38885dbc96 vlr: place comments on if (0) cases
Change-Id: I56c1e61dedeac01a4e24452feee6616782783d8f
2017-08-27 17:40:53 +02:00
Harald Welte 42e8f216b3 SGSN: Don't indicate GERAN in Iu mode PDP CTX ACT REQ to GGSN
Change-Id: Ifd9ff4342de342475609bad0257a23c50290e23b
2017-08-27 17:40:53 +02:00
Neels Hofmeyr 158de361d3 IuPS: explicitly check RAN type; move comment
Change-Id: I054d72590dfb2012f6f8506d3a5f8fd2953194e1
2017-08-27 17:40:53 +02:00
Neels Hofmeyr d6649c3954 IuPS: don't require an MM context for Iu Release
Change-Id: I8b4d08b3ee8add1f1d54efb13985eabe0c9d31f3
2017-08-27 17:40:53 +02:00
Neels Hofmeyr bfa1895e8c SI3: indicate R99+ MSC to GSM MS to enable UMTS AKA
Change-Id: I796e1f4281628061f4522c43c549de9e751bc045
2017-08-27 17:40:53 +02:00
Neels Hofmeyr 7a921fc154 cosmetic: make osmo-python-tests dependency more accurate
Change-Id: I4f84a13b7fa6ec4173bdc155e6114d4d7328b619
2017-08-27 17:40:52 +02:00
Neels Hofmeyr fb9982e6c3 osmo-nitb: change default db name to sms.db
libvlr now delegates subscriber management to osmo-hlr, so the database no
longer represents a HLR. It basically only stores SMS, so reflect that fact in
the default database name.

Change-Id: I3289d68d3eb63aff940b48a25b584d5e83cd0197
2017-08-27 17:40:52 +02:00
Neels Hofmeyr 6bd5447c47 Add msc_vlr test suite for MSC+VLR end-to-end tests
Change-Id: If0e7cf20b9d1eac12126955b2f5f02bd8f1192cd
2017-08-27 17:40:52 +02:00
Harald Welte 9066b74c1f Use libvlr in libmsc (large refactoring)
Original libvlr code is by Harald Welte <laforge@gnumonks.org>,
polished and tweaked by Neels Hofmeyr <nhofmeyr@sysmocom.de>.

This is a long series of trial-and-error development collapsed in one patch.
This may be split in smaller commits if reviewers prefer that. If we can keep
it as one, we have saved ourselves the additional separation work.

SMS:

The SQL based lookup of SMS for attached subscribers no longer works since the
SQL database no longer has the subscriber data. Replace with a round-robin on
the SMS recipient MSISDNs paired with a VLR subscriber RAM lookup whether the
subscriber is currently attached.

If there are many SMS for not-attached subscribers in the SMS database, this
will become inefficient: a DB hit returns a pending SMS, the RAM lookup will
reveal that the subscriber is not attached, after which the DB is hit for the
next SMS. It would become more efficient e.g. by having an MSISDN based hash
list for the VLR subscribers and by marking non-attached SMS recipients in the
SMS database so that they can be excluded with the SQL query already.

There is a sanity limit to do at most 100 db hits per attempt to find a pending
SMS. So if there are more than 100 stored SMS waiting for their recipients to
actually attach to the MSC, it may take more than one SMS queue trigger to
deliver SMS for subscribers that are actually attached.

This is not very beautiful, but is merely intended to carry us over to a time
when we have a proper separate SMSC entity.

Introduce gsm_subscriber_connection ref-counting in libmsc.

Remove/Disable VTY and CTRL commands to create subscribers, which is now a task
of the OsmoHLR. Adjust the python tests accordingly.

Remove VTY cmd subscriber-keep-in-ram.

Use OSMO_GSUP_PORT = 4222 instead of 2222. See
I4222e21686c823985be8ff1f16b1182be8ad6175.

So far use the LAC from conn->bts, will be replaced by conn->lac in
Id3705236350d5f69e447046b0a764bbabc3d493c.

Related: OS#1592 OS#1974
Change-Id: I639544a6cdda77a3aafc4e3446a55393f60e4050
2017-08-27 17:40:52 +02:00
Harald Welte 9ccd6621fb Add libvlr implementation
Original libvlr code is by Harald Welte <laforge@gnumonks.org>,
polished and tweaked by Neels Hofmeyr <nhofmeyr@sysmocom.de>.

This is a long series of trial-and-error development collapsed in one patch.
This may be split in smaller commits if reviewers prefer that. If we can keep
it as one, we have saved ourselves the additional separation work.

Related: OS#1592
Change-Id: Ie303c98f8c18e40c87c1b68474b35de332033622
2017-08-27 17:40:52 +02:00
Neels Hofmeyr f2ff307ba1 jenkins: pass proper configure flags to make distcheck
Enable various components according to the build matrix during make distcheck.
Add python tests, osmo-bsc, nat, ...

Change-Id: Ic724cf61d44409337414dc58c8795896b4b97a8a
2017-08-27 17:40:52 +02:00
Neels Hofmeyr a4cd7f88ae fix make distcheck with python tests
- bscs.config needed by the vty tests was not picked up as a dist file, because
  its suffix is not 'cfg'. Rename to *.cfg. Apply this rename in
  vty_test_runner.py and osmo-bsc_nat.cfg.
- Remove restart counters after external tests, otherwise distcheck complains
  about uncleaned files.
- Add contrib/ipa.py to EXTRA_DIST, hence add a Makefile.am to contrib/.
  Otherwise the python tests cannot find that dependency.

Change-Id: I42b55cb1125099afc3a8e3f87c0e398426b2e2a9
2017-08-27 17:40:52 +02:00
Neels Hofmeyr d287114512 logging: auth request: use hexdump without spaces for RAND, AUTN
Change-Id: Ie16bb2c01e770914f411bfb34b523c56ea9fab81
2017-08-27 17:40:52 +02:00
Neels Hofmeyr 398851feff gsup_client: allow passing a unit id to identify with HLR
Before, each GSUP client would contact the HLR with an identical unit id, i.e.
"SGSN-00-00-00-00-00-00", with the result that some messages were sucked off by
the wrong client.

Pass explicit unit name from each gsup client user, so that OsmoMSC is "MSC"
and OsmoSGSN is "SGSN". Hence the HLR can properly route the messages.

Todo: also set some values instead of the zeros.

Unrelated cosmetic change while editing the arguments: gsup_client_create()'s
definition's oap client config arg name mismatched the one used in the
declaration. Use oapc_config in both.

Change-Id: I0a60681ab4a4d73e26fe8f0637447db4b6fe6eb2
2017-08-27 17:40:52 +02:00
Neels Hofmeyr 6d1e9a933b GPRS/IuPS: remove all 3G authentication dev hacks
UMTS auth works now with the external OsmoHLR.

Change-Id: Ie42945bb687b077fd0ee430c2711d19782151610
2017-08-27 17:40:52 +02:00
Neels Hofmeyr b6ccee113c git-version-gen: look for .git in ./, not ../
Change-Id: Ic71cfb8dde0a43325b50c75aae1e6ef3c3008501
2017-08-27 17:40:52 +02:00
Neels Hofmeyr b0fb72c2f9 join openbsc/.gitignore with .gitignore
Change-Id: Ib2120592749e85a4d13f6668e198857e3bddcf1e
2017-08-27 17:40:52 +02:00
Neels Hofmeyr bf28485b12 jenkins: apply rename to osmo-msc in log marker
Change-Id: I8ca9a1a8bdb5b9615df5f19f0c1017cb9383f6ee
2017-08-27 17:40:52 +02:00
Neels Hofmeyr ed3157ce46 move openbsc/* to repos root
This is the first step in creating this repository from the legacy openbsc.git.

Like all other Osmocom repositories, keep the autoconf and automake files in
the repository root. openbsc.git has been the sole exception, which ends now.

Change-Id: I9c6f2a448d9cb1cc088cf1cf6918b69d7e69b4e7
2017-08-27 17:40:52 +02:00
Neels Hofmeyr 2758330b6a jenkins: fix build of --enable-iu: use osmo-iuh tag 'old_sua'
We are building with libosmo-sccp tag 'old_sua' until the new sigtran has
been applied. Since osmo-iuh commit
  0f88c110093935305143987638e46dc6db304a3e
  "migrate osmo-hnbgw to libosmo-sigtran's SCCP/M3UA"
osmo-iuh requires libosmo-sccp master. A similar 'old_sua' tag is in place in
osmo-iuh.git, to match libosmo-sccp 'old_sua'. Do that to fix the jenkins
build of --enable-iu.

Change-Id: I70f731db0b74ed48ae6dd713ed4c3247222ef0de
2017-08-27 17:40:51 +02:00
Alexander Couzens 10ccddd694 .gitreview: update repo url to new location
Old files was a leftover from split out of openbsc.

Change-Id: Ifefb345df6c00aadee0ccc3c59796dba590a9f32
2017-08-08 17:28:24 +02:00
Max eab5f594b0 Enable optional static builds
* use LT_INIT instead of AC_PROG_RANLIB
* remove redundant libbsc entries

The default (for both manual and .deb builds) is to use shared build (as
before) - the static build is entirely optional.

Based on work by Sergey Kostanbaev <sergey.kostanbaev@gmail.com> and
Alexander Chemeris <Alexander.Chemeris@gmail.com>.

Change-Id: Ibcd1da98302413182c85e25c4cb7d69d9e38c35a
2017-06-22 10:51:46 +00:00
Max 5a44d25ad3 Fix BTS features length check
While fixing potentially incorrect memory access, the check for maximum
number of supported BTS features was incorrectly adjusted instead of
feature vectore length check next to it. Fix this by adjusting checks
properly and adding comments to avoid future confusion.

The error was introduced in a60bb3dd28.

Change-Id: I06d2498d730624d5da535f6add6fa98d004714ae
2017-06-22 10:50:30 +00:00
Harald Welte 2f8b9d25f8 Add vty command "radio-link-timeout infinite" for uplink rx testing
When we are performing Rx sensitivity testing on a BTS, we want to
deactivate the connection failure criterion / radio link timeout, i.e.
no matter how many SACCH frames in uplink are failed to decode, the BTS
should never close the channel.

OsmoBTS Change-Id I736f21f6528db5c16fa80cdb905af20673797be5 covers a way
how this behavior can be requested from the BTS via an OML attribute.
This patch adds support to the BSC to actually set that attribute.

Do not use this in production networks, as the BTS will keep open radio
channels indefinitely even if the phone is gone and no longer
transmitting anything.  This is a pure testing feature.

Change-Id: I6cb94e0f024934f7baeeb728ca9ed3042fbf16d2
2017-06-18 12:56:00 +03:00
Max 8b1a2f8cd7 bsc_init: Forget which SIs are valid for the trx
Previously the SI generation lead to setting the BCCH SIs for all TRX in
a multi-trx setup. This is because we create the SIs globally but
si_valid appears to be limited to the 'current' trx. Warn if we attempt
to set SIs for the BCCH on a trx that does not have a BCCH.

Change-Id: Ie0e288252a2e7709c4dae16b96a0b1512278847f
Tweaked-by: Max <msuraev@sysmocom.de>
2017-06-15 16:39:55 +02:00
Max 70fdd24d04 Update SI data structures and generation
To support segmented SI2quater as per 3GPP TS 44.018 we'll have to
support multiple SI messages (up to 16 for SI2q) for a given type in
contrast to existing 1:1 mapping:

* expand storage space to hold up to 16 SI messages (spec limit)
* add assertions for budget calculations
* generate multiple SI2q messages
* adjust SI2q-related tests
* use precise check for number of SIq messages instead of approximate
  estimation

Change-Id: Ic516ec9f0b821557d9461ae9f1c0afdd786f3b05
Related: OS#1660
2017-06-15 16:39:55 +02:00
Max 9b97b007df Move SI-related defines
* move SI2quater related defines to shared header
* add define from OsmoBTS which checks for presence of a given SI
  message in gsm_bts struct. Rename it to avoid conflicts with OsmoBTS
  code and to match naming conventions of similar macros.

Change-Id: I11432c93c772d1ead6d45a7bb0f1d13d492c82f1
Related: OS#1660
2017-06-15 11:43:10 +00:00
Max a60bb3dd28 OML: fix potential OOB memory access
Use sizeof target BTS feature storage to make sure we always fit into
pre-allocated memory. Also use it for log check.

Change-Id: Ib107daa6e8b9bc397a10756071849f8ff82455d5
Fixes: CID 170581
2017-06-12 13:45:03 +02:00
Max c51c1e7950 Request and parse BTS feature list via OML
Request features supported by BTS when getting attributes over OML.

Change-Id: Ic35b2865998bca3c2c0cb4b77e4e73d12e08bd7e
Related: OS#1614
2017-06-09 08:58:04 +00:00
Max 33e1357a90 Get TRX attributes
Request per-TRX attributes in addition to BTS attributes.

Change-Id: I2b61131b9930afd03357c0b66947ee856d58cc46
Related: OS#1614
2017-06-09 08:58:04 +00:00
Harald Welte 4a824ca8fc don't re-implement osmo_talloc_replace_string()
osmo_talloc_replace_string() was introducd into libosmocore in 2014, see
commit f3c7e85d05f7b2b7bf093162b776f71b2bc6420d

There's no reason for us to re-implement this as bsc_replace_string
here.

Change-Id: I6d2fcaabbc74730f6f491a2b2d5c784ccafc6602
2017-06-09 08:49:36 +00:00
Max aef68387ae Add remote BTS feature storage and helpers
In addition to compile-time defined BTS model features we also need
run-time BTS features reported by BTS via OML. This should be shared by
BSC and BTS. To accommodate for this, add following:

* features bitvec to gsm_bts struct
* features descriptions
* comments to avoid confusion between 2 feature sets
* helper functions to set/query particular feature
* upper boundary on number of supported features and assertion for it

Change-Id: I02bd317097ba66585c50ebd4e8fc348f6dc3dad9
Related: OS#1614
2017-05-31 12:15:54 +02:00
Max 71d082bec7 Adjust BTS model feature check
Rename gsm_bts_has_feature() -> gsm_btsmodel_has_feature() and adjust
type signature to match gsm_btsmodel_set_feature() function and avoid
confusion with upcoming functions to check/set BTS features reported
over OML.

Change-Id: I97abdedbef568e0c2fbd37c110f7d658cf20e100
Related: OS#1614
2017-05-31 12:14:17 +02:00
Harald Welte 8254cf75bf libbsc: Create pcu-socket only as specified in config file
Since commit b4999b60d4 we created PCU
sockets at hard-coded paths in the filesystem by default for all BTSs.
This is inflexible and prevents the use of multiple BSC instances on a
single filesystem, or the placement of the sockets in a more secure
location than /tmp.

The new approach with this patch is that
* no PCU sockets are created by default
* only for those BTSs where a 'pcu-socket' is configured via VTY,
  the socket will actually be created

Change-Id: Ie9079470584777dcc31f85f9bf0808f479156ccb
Closes: OS#2293
2017-05-29 13:45:04 +02:00
Harald Welte 3f86c523ee bsc_vty: Add command to manually issue IPAC MDCX
Using this command, one can modify the RTP stream associated with a
given logical channel and (re)direct it to a specified IP:Port.

Change-Id: I63e03b932038a4e2f6d51c5541b52e4a42df27bf
2017-05-28 22:51:47 +00:00
Harald Welte 2abd5e1663 bsc_vty.c: Add command for manual [de]actiovation of logical channels
Sometimes it is useful to manually activate (or decativate) a given
logical channel from the VTY.  Doing this on the BSC (rather than the
BTS) ensures that the BSC knows that this timeslot / channel is
allocated and there is no risk to have clashes between the BSC "owning"
the resources and the BTS allocating some by itself.

Change-Id: I44fc3904678eb48bd3ab1a3da8c0c265fa082e0d
2017-05-27 15:55:11 +02:00
Harald Welte 645eb62283 bsc_vty.c: Further simplify vty_get_ts()
We can also move the string-to-numeric conversion inside vty_get_ts() to
reduce the amount of work required in the caller.

Change-Id: I2a74ed06e90e39d39f53fff39bb96df172728c0e
2017-05-27 15:54:39 +02:00
Harald Welte 7fe00fb9be bsc_vty: Factor vty_get_ts() out of pdch_act_cmd()
Resolving a timeslot based on its numeric identities is a generally
useful function, so lets' factor that out.

Change-Id: Id2570232f82542487a1133be7efb1dc1eb3029a8
2017-05-27 14:09:50 +02:00
Harald Welte 0483f33820 bsc_api.c: Documentation for handle_mr_config()
Change-Id: I6edd442afc7c20f8f097198941bc592d429ba5da
2017-05-27 14:08:20 +02:00
Harald Welte 0de69a2501 costmetic: Document gsm48_multirate_config() + const-ify input
We generally use const pointers for input arguments.  Also, document
input/output arguments of function and add spec reference.

Change-Id: I2532cde69a18e3b021f7371e68f67a28a43d8b5f
2017-05-27 13:18:50 +02:00
Harald Welte 5f72f6fccc Use new e1inp_signal_names from libosmo-abis to print input signal names
Change-Id: I156027ecdd1456228c9f8776577edd48e70c19da
2017-05-25 19:16:40 +02:00
Alexander Couzens 271ceca862 abis_rsl: use msgb_pull to parse tlli from msg
Change-Id: I971bf6c8821689f9d8a1294a9b3bf1af9c4091f7
2017-05-25 14:04:08 +02:00
Alexander Couzens 2faeb1ac6c abis_rsl: fix off-by-one length check when parsing ericson tlli field
Change-Id: I658f6d82a67944345ddda5534fa996dca9e990ab
2017-05-25 14:04:08 +02:00
Philipp Maier 722bbb402f pcu_sock: Fix broken paging command
The pcu sends us an already made up MAC-Block that contains the
paging request. pcu_sock.c is parsing this paging request
wrongly and fails silently, which results into a dropping of the
request.

This commit fixes the parsing problems.

Change-Id: Iefef08123bdc351afd8287d3f27ebf0ae58a6e7d
2017-05-25 14:04:08 +02:00
Philipp Maier f8aeb2cccb pcu_sock: Forward imm.ass PCU originated messages
The PCU sends imm.ass messages in response to a rach request. Those
messages need to be forwarded to RSL in order to get them send. This
commit introduces the required functionality for that

Change-Id: Ice099c4ed7008200ed179e581aba1899c6c29455
2017-05-25 14:04:08 +02:00
Alexander Couzens f14cb3535c pcu_sock: implement direct tlli on AGCH
Ericsson allows to attach a reference to immediate assignments. A
confirmation of the transmission is then sent back, but only containing
the reference, not the whole RLC packet.

Change-Id: I945f49e62e2a74a7906e2d49940927773edd04a9
2017-05-25 14:04:08 +02:00
Alexander Couzens 872671e01b pcu_sock: pcu_tx_info_ind allow to use TRX not starting from 0
It would prevent using only e.g. TRX 1 when TRX 0 is disabled.

Change-Id: I68dc5e837bd2a3602f7875063c85da4082196274
2017-05-25 14:04:08 +02:00
Alexander Couzens a229756885 pcu_sock: set flag PCU_IF_FLAG_SYSMO by setting pcu_direct = 1
The use of PCU_IF_FLAG_SYSMO enable the PCU to use DIRECT_PHY code path.

Change-Id: I1f5407264fc4f209456ffcb73d7853ff315aab86
2017-05-25 14:04:08 +02:00
Harald Welte 54050a28ed pcu_sock: Send non-NULL hLayer1 to PCU
The BSC-located PCU case looks to the PCU like a BTS-located PCU with
"direct PHY" access, i.e. the data related primitives are communicated
from the PCU directly towards the TRAU Frames or whatever transport
method is used between CCU and PCU.

In order to make the PCU believe that, we need to pass in a 'layer 1
handle'.  As we don't use it, we can just pass any non-zero value and be
happy.

Change-Id: I8170bd4134904702b6b272e496100361ba473cbc
2017-05-25 14:04:08 +02:00
Harald Welte 854bcc2b7b pcu_sock: Forward paging request from PCU via RSL to BTS
Change-Id: I28bf0995699618f3f5fa15fc8e1733beddfc482f
2017-05-25 14:04:08 +02:00
Harald Welte e586f41692 pcu_sock: get rid of magic numbers and use ARRAY_SIZE() for array iteration
Change-Id: I602b581fab67b3a1c3c03c73a3a99e9afd564e29
2017-05-25 14:04:08 +02:00
Harald Welte 67798617b5 pcu_sock: Don't re-implement core functionality like gsm_bts_trx_num()
Change-Id: I5ea506c8240dac124ccf5522d02ba18e4f0cb90d
2017-05-25 14:04:08 +02:00
Philipp Maier b4999b60d4 pcu_sock: add basic pcu interface support
Adds a basic version of a pcu socket interface, similar
to the one that can be found in osmo-bts.

Change-Id: Ib13cb4099d12fa71e9e0b8727e19ab29e11909b2
2017-05-25 14:04:08 +02:00
Philipp Maier 94bbc73bce libbsc: add debug log message to S_L_INP_* callbacks
Improve debug log output of input callbacks by adding a line containing
the signal event name.

Change-Id: Ifca46dd8b356d0de31cccbd79e406079d3a0d7d2
2017-05-25 14:04:03 +02:00
Philipp Maier 6f483d3a05 gsm_data_shared: add value strings for gsm_chreq
Change-Id: I23d3be5610a5a46098d2b12feed4245828599aae
2017-05-25 14:01:50 +02:00
Neels Hofmeyr 1fe2647c5d ipaccess-config: properly create swload
Instead of 20, use the actual buffer sizes of struct sw_load, which are 255.
Previous code would truncate a longer string at 20 without(!) NUL termination.

In the _len members, store the actual length copied. In previous code, if the
source string were longer than 20, we would store only 20 (without NUL term)
but still reflect the longer length of the source string.

Fix both of these issues for sw_load.file_id / file_id_len and
sw_load.file_version / file_version_len.

Change-Id: I2e34a1348a290d3f58dd830d08da65b94b3270db
2017-05-22 13:28:31 +00:00
Alexander Huemer 5265bea76c Add missing _CFLAGS and _LIBS
These missing pieces go unnoticed if dependencies are not installed in
distinct directories.

Change-Id: If8d57b72f63d79cc0d8efba7466c6ec177207cbb
2017-05-20 11:42:37 +00:00
Keith Whyte 320960cf9d libmsc: Map SMPP command status to GSM 04.11 cause
Send SMS RP ERROR with a failure cause that relates to
the status returned by the ESME in the deliver_sm_resp.

Actual mapping array is limited as most phones I tested
don't seem to care about the failure cause anyway,
although some will display a different notification for
GSM411_RP_CAUSE_MO_NUM_UNASSIGNED

Change-Id: I61fb2d9ef4f2d2eabdc49b53d9966ad328d15e51
2017-05-20 08:18:50 +00:00
Neels Hofmeyr 9f77d7bd0e fix '/include/openbsc ' to have no trailing space
The newline and $NULL manage to append a trailing space to the 'openbsc' dir.

This was broken in commit 7b6673fa06
"Consistenly format variables in */Makefile.am files"
by Change-Id Ifa21513c007072314097b7bec188579972dc1694

Add a comment to prevent this in the future.

Reported-by: Andreas Mueller <andreas.mueller@criticallabs.org>
Change-Id: I218027459e3b2aaa817d91eb3f69d9c0b10dcd4e
2017-05-19 12:36:32 +00:00
Max 71124de33c Remove errorneous include
The gsm_data_shared.h header is installable and used by OsmoBTS so it
should not include any private (non-installable headers) to avoid
OsmoBTS' build failures.

Change-Id: Ic25031101fc01bd732fe691132c081ad05fa6a4b
2017-05-18 14:17:10 +02:00
Max defb6c95c1 Get basic BTS attributes
Request BTS attributes via OML on connection and parse the response:
request/parse incoming response as sw-config.

Note: only basic BTS-wide KV attributes wrapped in sw-config are
supported for now.

Change-Id: I589be51daca0cb9e1f3473b93e910e46b06e23ae
Related: OS#1614
2017-05-17 17:52:28 +00:00
Max 845a3a4c59 SI2quater: fix EARFCN inclusion check
Previously only the existance of bts->si_common.si2quater_neigh_list was
checked but not the actual number of EARFCNs in it. Fix it by using
si2q_earfcn_count() and adjust tests accordingly. While at it - reformat
tests to include extra information.

The correctness was checked manually by inspecting GSMTAP output.

Change-Id: Ic4fb2a9e870db66cac58b1e8d113587b30d64ce2
Related: RT#8792
2017-05-15 15:13:01 +02:00
Max f39d03ad21 Restructure SI2quater generation
In preparation for extended SI2q messages:

* add SI2q-specific accessor macro
* add *_offset variables to gsm_bts struct
* internalize memory check while generating rest octets - introduce
  budget concept (number of bits available in a given message)
* internalize *arfcn_size() functions as they are not needed outside of
  si2q_num() anymore
* change rest octets generation to work with gsm_bts struct directly
* do not generate rest octets if no SI2q is necessary
* adjust unit tests accordingly (cosmetic changes only to avoid
  regressions)

Requires: I92e12e91605bdab9916a3f665705287572434f74 in libosmocore

Change-Id: Ib554cf7ffc949a321571e1ae2ada1160e1b35fa6
Related: RT#8792
2017-05-15 13:11:48 +00:00
Max 1ebf23b7fe Prepare for BTS attribute reporting via OML
* use define for number of attributes instead of magic number
* add sub_model to gsm_bts struct
* expand number of BTS features
* mark attributes parameter to abis_nm_get_attr() as const

Change-Id: I7ecb0c4339530d3a8354a2f94b34063dda87e030
Related: OS#1614
2017-05-15 08:13:03 +00:00
Neels Hofmeyr 7590ff3fd6 fix subscriber random extension allocation range
The VTY config allows above 32bit range extensions, but
db_subscriber_alloc_exten() was unable to generate extensions outside of 32bit.

Add VTY regression test and fix the problem by using proper 64bit types.

Related: OS#2253
Change-Id: I9afe6a8833004ecd2f3f936b2d5aa4de8e7dbcb0
2017-05-12 15:43:49 +02:00
Neels Hofmeyr 34ce3d93c5 fix VTY parsing: subscriber-create-on-demand random
Fix parsing of the 'subscriber-create-on-demand random' VTY: atoi() is not
enough to include the specified range of 1-9999999999.

Use atoll() instead to ensure a large enough number space also on 32bit
systems.

(Note: for me, atoll() truncates at 32 bit when <stdlib.h> is not included.)

Add a VTY regression test for this.

Related: OS#2253
Change-Id: I353e04481ec567adca383d6b51ba8fb865eed73e
2017-05-12 15:43:18 +02:00
Pablo Neira Ayuso 5121576b0c src: use osmo_timer_setup()
Use new function available in libosmocore to set up timers. Compile
tested only.

Change-Id: Ibcfd915688e97d370a888888a83a7c95cbe16819
2017-05-10 11:21:24 +02:00
Max 7b62d54b52 Use define for limit on number of BTS features
Change-Id: Ief81db0b3653fec180e60776ff9bcb0ac1357217
Related: OS#1614
2017-05-10 07:49:43 +00:00
Max 2b6c5407b6 Add forgotten items to .gitignore
Change-Id: I04b2ec1115f6207bd238489db9317bfaee58f3bc
2017-05-09 11:37:36 +02:00
Max 7507aef92b Make BTS type and variant converters shareable
* move value_string definition and corresponding functions for BTS type
  to shared header to make it re-usable by OsmoBTS
* use consistent function naming
* add similar functions for BTS variant
* add enum to be used by OML Attribute Reporting to distinguish between
  type, variant and other info

Change-Id: Ida94725a6fce968443541e3526f48f13758031fd
Related: OS#1614
2017-05-09 09:09:55 +00:00
Pablo Neira Ayuso 93ffbd0029 libmsc: send RP-ACK to MS after ESME sends SMPP DELIVER-SM-RESP
Hold on with the GSM 04.11 RP-ACK/RP-ERROR that we send to the MS until
we get a confirmation from the ESME, via SMPP DELIVER-SM-RESP, that we
can route this sms somewhere we can reach indeed.

After this change, the conversation looks like this:

    MS    GSM 03.40      SMSC   SMPP 3.4   ESME
     |                    |                 |
     |   SMS-SUBMIT       |                 |
     |------------------->|                 |
     |                    |    DELIVER-SM   |
     |                    |---------------->|
     |                    |                 |
     |                    | DELIVER-SM-RESP |
     |                    |<----------------|
     |  GSM 04.11 RP-ACK  |                 |
     |<-------------------|                 |
     |                    |                 |

Before this patch, the RP-ACK was sent back straight forward to the MS,
no matter if the sms can be route by the ESME or not. Thus, the user
ends up getting a misleading "message delivered" in their phone screen,
when the message may just be unroutable by the ESME hence silently
dropped.

If we get no reply from the ESME, there is a hardcoded timer that will
expire to send back an RP-ERROR to the MS indicating that network is
out-of-order. Currently this timer is arbitrarily set to 5 seconds. I
found no specific good default value on the SMPP 3.4 specs, section 7.2,
where the response_timer is described. There must be a place that
describes a better default value for this. We could also expose this
timer through VTY for configurability reasons, to be done later.

Given all this needs to happen asyncronously, ie. block the SMSC, this
patch extends the gsm_sms structure with two new fields to annotate
useful information to send the RP-ACK/RP-ERROR back to the MS of origin.
These new fields are:

* the GSM 04.07 transaction id, to look up for the gsm_trans object.

* the GSM 04.11 message reference so the MS of origin can correlate this
  response to its original request.

Tested here using python-libsmpp script that replies with
DELIVER_SM_RESP and status code 0x0b (Invalid Destination). I can see
here on my motorola C155 that message cannot be delivered. I have tested
with the success status code in the SMPP DELIVER_SM_RESP too.

Change-Id: I0d5bd5693fed6d4f4bd2951711c7888712507bfd
2017-05-08 17:15:12 +02:00
Pablo Neira Ayuso 638ad068e8 libmsc: use GSM411_RP_CAUSE_MO_NUM_UNASSIGNED as return value
Instead of hardcoded value of 1 plus comment of the right hand side of
the statement.

Change-Id: I865bdbd6da17a0389044a8e749deeeebcb9cae06
2017-05-08 14:45:17 +00:00
Max fd2c1f90ba Use libosmocore for SW Description parsing
Requires libosmocore with Ib63b6b5e83b8914864fc7edd789f8958cdc993cd.

Change-Id: Ib94db414e94a2a1f234ac6f1cb346dca1c7a8be3
2017-05-08 11:49:40 +00:00
Max 310b730798 Use ipa.py for ctrl tests
Remove duplicated code and make sure that python code is actively used
as part of test harness

Change-Id: I676390abe2f179df6004cdd33d0eaaf60e18df03
2017-05-08 08:31:09 +00:00
Max 7b5dbc2805 Gb: use textual representation for parse log
Use textual representation for message type and protocol descriminator
in case of Gb parsing errors.

Change-Id: Ida925258be119619d8705361730c554a130b75bc
Related: SYS#3610
2017-05-05 11:31:07 +00:00
Max c6e8a01e70 deb: install python scripts from contrib/
Add .py scripts from contrib/ to osmo-nitb.deb package.

Change-Id: I852815f348ae330980b186e1ddbc78f18f4f42b5
Related: SYS#3028
2017-05-04 13:38:45 +00:00
Max 50eb66996d ctrl: remove boilerplate code
Define subscriber-list-active-v1 ctrl command as RO and remove
unnecessary functions.

Change-Id: I88fe905c22cf7563415d470b88cb43fca0d52a7f
2017-05-04 13:35:13 +00:00
Max 086067f0a1 Fix vty warnings for GEA0
Previously vty always used additional checks even for GEA0 (no
encryption) which resulted in misleading warnings. Fix this by
adding explicit check for GEA0.

Related: SYS#3610
Change-Id: I1ee468ab3298076d4cb5c7b1f6293c07e272417b
2017-05-02 13:43:13 +02:00
Max 7bb383a45c Make pcap dependency optional
Previously we required pcap.h unconditionally which causes embedded
build failure because it's not included in current version of out poky
toolchain. We can add it to toolchain but it's only necessary for
utils/osmo-meas-pcap2db which is not built for sysmobts anyway so it's
easier to just make this dependency optional and build osmo-meas-pcap2db
only if it's available - similar to the way we build osmo-meas-udp2db.

Related: SYS#3610
Change-Id: I77a5f7eafe0282abedacffad6a9bcb0a8f2b5caa
2017-05-02 13:43:06 +02:00
Max 6d8e5198ad Add gsm_bts_type_variant to gsm_bts struct
Previously it was only in gsm_bts_model which is not initialized on BTS
side. It's more convenient to have it in the struct which is available
to BTS as well.

Change-Id: I54fde8c4ccd5d994af08074f5864446e79a93a25
Related: OS#1614
2017-04-28 08:49:05 +00:00
Max 6f0e50c833 Prepare for extended SI2quater support
Supporting SI2quater as per 3GPP TS 44.018 will require chnages to the
way System Information is stored because it uses 1:n instead of 1:1
mapping between SI type and generated SI content. This should not affect
other SI types though. To facilitate this transition:

* convert the code to always use GSM_BTS_SI helper instead of accessing
  buffer directly
* make helper more robust by adding extra parenthesis
* add similar helper for gsm_lchan
* add function estimating number of SI2quater message to hold configured
  number of (U|E)ARFCNs
* add SI2q index/count fields and pass them to rest_octets generator
  explicitly
* internalize buffer access in generate_si* functions

Change-Id: I74e4e3cb86364cec869a1472a41b4a95af0d50dd
Related: RT#8792
2017-04-28 08:45:36 +00:00
Max a18001d506 Save PCU version reported by BTS
When BTS reports PCU disconnect - clear it.

Change-Id: Idb32c73036413ee912f633604150ee17b611cfa7
Related: OS#1615
2017-04-28 08:44:18 +00:00
Max 8b8fca757e deb: install openbsc.pc
Previously openbsc.pc was generated but not installed as part of
openbsc-dev.

Change-Id: I5472a8fe74a81b98598fbdb688db778cb7d09e62
2017-04-27 10:21:19 +00:00
Max 2b229ffaef gbproxy: add example .service
Change-Id: Ic8144777a77efce4bad44abf6c6abde12fc5149c
Related: SYS#3610
2017-04-26 16:21:43 +02:00
Max cb1e366094 Remove libs from openbsc.pc
OpenBSC does not produce any installable libraries, only header files so
this section is unnecessary.

Change-Id: I4c563d775a84f41f82404e0eaba1a25fdbaac1a5
2017-04-26 12:07:08 +02:00
Max 11e4e41ffc Fix MS TO measurement representation
* set proper flag when saving MS Timing Offset
* use gsm_subscriber's IMSI or lchan's name if bsc_subscriber is unknown
* add comments with spec reference
* store/display MS Timing Offset instead of raw Timing Offset field from
  RSL
* Compute MS Timing Offset [-63; 192] from Timing Offset field [0; 255],
  adjust structure gsm_meas_rep with proper type to store it

Change-Id: I7e003d23a6edb714c5f17688fd6a8edac131161d
Related: OS#1574
2017-04-26 08:25:22 +00:00
Pau Espin 7636c0833b nat: Fix initial buffer size parameter for getline
According to man, lineptr must be set to null AND n to 0.

Change-Id: I36683884106b97ef697264716de13813c00da9bc
2017-04-12 12:28:51 +00:00
Pau Espin dc9de23523 nat: Use equal func in bsc_sccp
It is defined in the file and used twice in there, so let's use it for
all of them which makes code smaller and more clear.

Change-Id: I9fac7cabedff74f8f6293ad8b54420229b80aa71
2017-04-12 12:24:49 +00:00
Neels Hofmeyr d75f11e6f2 build: iu: use libosmo-sccp tag 'old_sua'
libosmo-sccp master is moving ahead, openbsc --enable-iu needs an older
version.

Change-Id: Id74a802fd2ca65f4b6c2079550fbb6b0af3e8340
2017-04-10 20:57:09 +02:00
Max f9685c1461 gsm_bts: add version and variant details
* add version string to gsm_bts
* add PCU version string to gsm_bts
* rename GSM_BTS_TYPE_OSMO_SYSMO -> GSM_BTS_OSMOBTS to avoid confusion
  between BTS model and variant
* add variant enum to gsm_bts_model using enum with variants for each
  hw vendor of OsmoBTS
* show connected PCU version (if available) in vty via 'show bts'

This will come in handy when logging details regarding particular BTS
reported via OML, see:

Related: OS#1614

Change-Id: I6710d53115f34634a7b70969cc05fd5c72ff8ab2
2017-04-10 06:58:43 +00:00
Max 689e7e5562 abis: log known ACKs and unknown messages
Log expected ACK messages and unhandled messages to aid in
troubleshooting.

Change-Id: Id3afaaa76e24f63076ae0e6fd2322e4a7fa29b45
Related: OS#1614
2017-04-08 07:46:07 +00:00
Max 2d92162a6b python: fix Null logger
Change-Id: Ie120273eabbc670e9f19ba365508688a810a2773
Related: SYS#3028
2017-04-05 08:16:25 +00:00
Vadim Yanitskiy 7f3724e04d VTY: add the dyn_ts_allow_tch_f option
This option allows to enable or disable TCH/F allocation on the
TCH/F_TCH/H_PDCH timeslots. Until now, source code modification
was required to enable this feature.

Related: OS#1778

Change-Id: Id18cab25844dc854a66b4e2713e90c3f43afa712
2017-04-03 16:38:06 +00:00
Neels Hofmeyr 4aa75e74f4 jenkins.sh: Iu: use libosmo-sccp,-netif master
The iu specific branches of libosmo-sccp and libosmo-netif have recently
been merged to master.

Change-Id: I9465d7b956c3bd65d6e8a387e6710235672352e8
2017-03-31 20:03:43 +00:00
Neels Hofmeyr 36891a7d9d LU counters: count completion and failure, not messages sent
From a human admin viewpoint it doesn't make sense to count the messages sent:

When we use TMSIs, we first send a LU Accept with a new TMSI, and then expect
the MS to respond with a TMSI Realloc Complete message. When that fails to come
through, the LU actually ends in failure, even though a LU Accept was sent.

If a conn breaks/vanishes during LU, we cancel the LU without sending any reply
at all, so the failed LU would not be counted.

Instead, count Location Updating results, i.e. completion and failures.

(With the new VLR developments, LU counters need to be triggered in completely
different places, and this patch prepares for that by providing sensible
counters.)

Change-Id: I03f14c6a2f7ec5e1d3ba401e32082476fc7b0cc6
2017-03-31 12:05:29 +00:00
Max b1e6b37493 Handle PCU version received via OML alert
Explicitly check for and log PCU version received from BTS via OML alert
message.

Change-Id: I3c88663d4e2887a4038b4c3f1387128295b8934e
Related: OS#1614
2017-03-23 11:09:22 +00:00
Max 9311881bb1 Add simple CTRL2SOAP proxy
Add python client which converts TRAP messages into SOAP requests and
perform corresponding actions.

It can be used as follows

./soap.py -d -w http://example.com/soapservice/htdocs/wsdl/test.wsdl

See ./soap.py -h for additional options.

Change-Id: I82844ec7a302bac30d6daee9ebca2188fd48ca46
Related: SYS#3028
2017-03-23 09:41:00 +00:00
Alexander Couzens 16dcf2ae22 libbsc: add rsl_ericsson_imm_assign_cmd() which reply with a confirmation message
ericsson can handle a reference at the end of a imm assign command which is used in
the confirm response. The confirm response is only sent if the trailer is present.

Change-Id: I88560291b5a3a3d7a0bac4d3c089b45f1f6b297f
2017-03-23 02:10:21 +01:00
Harald Welte baaf3e242e RBS2000 RSL: Support for sending RSL PAGING CMD for GPRS
Change-Id: I66541f9b20e7fd67fbec329283fc3c821c970a56
2017-03-23 02:10:21 +01:00
Harald Welte f7e9a349ef RBS2000: Add the P-GSL Timer IE to RSL CHAN ACT for PDCH
This seems to be mandatory when an Ericsson RBS2000 uses a SuperChannel
as back-haul.

Change-Id: I793e7d62df1ca9f9c38d39e22d3868064d446c8d
2017-03-23 02:10:21 +01:00
Alexander Couzens 3521af7f3a abis_om2k: protect MO FSMs by NULL check
Also set MO FSMs to NULL after freeing them.

Change-Id: I30df0b9ab8bc47ba9756c8388e977deed0e40200
2017-03-23 02:10:21 +01:00
Harald Welte ce49258a12 OM2000: Send ALTCRQ for SuperChannel after receiving IS Enable Req Ack
When the BTS is configured to use a SuperChannel and it is using a
unix domain socket based transport towards the L2TP daemon, then
we must instruct the L2TP daemon to instruct the SIU to change the Abis
Lower Transport Mode using the ALTCRQ / ALTCRP L2TP signalling.

Change-Id: I672bfaa09c42fbeb0c8459f24b2222b952de954b
2017-03-23 02:10:21 +01:00
Max dd22a30d75 twisted_ipa.py: make debug logging more robust
Do not print anything to stdout directly - use proper logger object
instead: either the one supplied by IPAFactory user or default to NO-OP
NullHandler logger.

Change-Id: Ic3417095a6e8848f0acabb46a9e64c0197b736e2
Related: SYS#3028
2017-03-21 14:06:50 +01:00
Max ca2778cd22 twisted_ipa.py: bump version properly
Adjust version string to comply with PEP8 and PEP386.

Change-Id: I44c8521f12e6432038998bfb1ac1bb37a1137787
Related: SYS#3028
2017-03-21 12:55:54 +00:00
Neels Hofmeyr 476c4bb7d1 python tests: allow running from separate build dir
The VTY tests assume that $top_builddir == $top_srcdir. Use the script's
location from sys.path[0] to find the correct locations of example configs even
when building in another directory.

Change-Id: I2731f361e3b72d0980968e6cf83594ea450db7c2
2017-03-20 13:33:15 +00:00
Neels Hofmeyr ca06e040cc bsc_/gprs_subscriber: fix: use osmo_strlcpy() to safely copy IMSI
Fixes: coverity scan CID 163918
Change-Id: I4b2760b006a0707928530b4390c6997b79b02981
2017-03-20 00:21:01 +00:00
Neels Hofmeyr ac27a99021 jenkins: add value_string termination check
Depends: libosmocore change-id I2bc93ab4781487e7685cfb63091a489cd126b1a8
Change-Id: I4183415cd1ead9d46ae3a556e94243325ef5a844
2017-03-16 18:59:24 +00:00
Max 88d4fc70d5 Don't drop OML links for Get Attributes NACK
Previously any OML NACK message will result in BSC dropping OML link to
BTS which makes it impossible to use optional OML messages which might
be unsupported by BTS. Fix this for 3GPP TS 52.021 §8.11.1 Get
Attributes message. Also, log human-readable NACK name to see what
exactly causing OML link drop.

Change-Id: Ib8af2872c27abb793172ec59bdc145b8d54f83da
Related: OS#1614
2017-03-16 14:07:06 +01:00
Neels Hofmeyr 6dd0fc685b oap tests: fix after SQN scheme changes from libosmocore
In change-id Iadf43f21e0605e9e85f7e8026c40985f7ceff1a3, libosmocore changes
from incrementing SQN after tuple generation to incrementing SQN before tuple
generation. Thus we now need to pass desired_sqn - 1 to get the same tuples.

Change-Id: Ifeda71e713bb60dcd31ac651f461b714cfa39b5c
Related: OS#1968 OS#1969
2017-03-15 16:05:42 +01:00
Harald Welte c103c64e7d OM2000: Change the order of MO initialization
So far: CF-IS-CON-TF
Now: CF-TF-CON-IS

Change-Id: I8efd9bafdcf9504d2e5fc85c44c708fa53f4dff8
2017-03-15 13:36:31 +00:00
Philipp Maier 3d6cb338c6 gprs: fix T3186 encoding in Sysinfo 13
The timer T3186, which is described in 3GPP TS 44.060, is using 3
bits of the si13 mac block. This requires special encoding. In the
case of T3186, the value is encoded by the formula: bits = t/500-1.
Our implementation uses the formula bits=t/500, which is incorrect.

Change-Id: Ifd340c536cff2d1c4b1b3677a358ea95438801eb
2017-03-15 13:15:26 +00:00
Max e7379fe657 examples: remove logging level * everything
Option "logging level ... everything" is broken for quite some time and
might be deprecated in future. Replace it with "logging level ... debug"
in config examples.

Change-Id: I828ef7671b4fb38717526a18ff8e9a5428cd511e
Related: OS#71
2017-03-15 13:01:12 +00:00
Philipp Maier 99c9707d1c cosmetic: Add commandline option to display version
The -V option to display the Version and the copyright info
is missing.

Change-Id: I0c848fd42c13f473807caf3478d32c6ce5e43e31
2017-03-15 13:00:47 +00:00
Alexander Couzens 11368118c9 libbsc: add chreq type for CHREQ_T_PDCH_ONE_PHASE & CHREQ_T_PDCH_TWO_PHASE
When using a BSC located PCU the BSC must understand PDCH requests.

Change-Id: Ie7f4ed000cf1b40d269873cf0ddf5ff9f5bbc18a
2017-03-15 12:48:03 +00:00
Philipp Maier 2459f9fb5a cosmetic: add copyright header to bsc_control.py
bsc_control.py lacks a copyright header. This commit adds the
copyright header from ipa.py to bsc_control.py.

Change-Id: Ie70bf686ee9bb157198e02bf8d946abf56adc82a
2017-03-14 17:19:23 +00:00
Alexander Couzens 8a215c3d25 gprs_sgsn.c: initialize ptmsi with 0xdeadbeef
Fix uninitialized memory access warning.
"Conditional jump or move depends on uninitialised value"
Found by valgrind.

Change-Id: Ibc2d585c5db899e6af20104211e32faf3822633a
2017-03-14 12:00:03 +00:00
Neels Hofmeyr b3c7c79c04 python tests: vty and smpp: speed up >10 times
osmo-python-tests now includes code that retries connecting the VTY socket and
needs no external sleep()ing. This flies through most tests without any sleep()
at all.

See osmo-python-tests.git change-id Icc337f52a93d5fe31fc4ff235ccaf4e0fe75fa39

Change-Id: I42161d9716fe5bb0ef1c56e4bfb770bb99bbca7a
2017-03-14 03:18:26 +01:00
Alexander Couzens dfb138ff09 unixsocket: start sabm for UNIXSOCKET
openbsc only starts sabm messages for a subset of line drivers.
Add unixsocket to those subset.

Change-Id: If98c037119142cc33b46ab5c1bf02d4cda81c81e
2017-03-13 11:19:18 +00:00
Harald Welte 0722ffc743 OM2000: Add FIXME comments for missing resolving of RX/TX MO!
Change-Id: I45708df724c5fc3316eca6bd2ac2c0738b19a45b
2017-03-13 09:41:58 +01:00
Neels Hofmeyr 6d804b1a7e add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.

Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).

Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.

During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.

Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.

Add bsc_subscr unit test.

Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-03-08 01:01:43 +01:00
Max abf53d87b6 Add MS time. offset to gsm_lchan
Add MS TIMING OFFSET (3GPP TS 48.058 § 8.4.8) and P offset (3GPP TS
45.010 § 1.2) which can be used to compute MS TO from known TA.

This will be used by osmo-bts (see
I4dfe5c48834a083e757d5de3236a02e15a238b28) to provide MS TO as part of
RSL MEASUREMENT RESULT.

Change-Id: I8bda57c8d6c15bbb803eca708931556dae118a00
Related: OS#1574
2017-03-07 15:11:14 +01:00
Neels Hofmeyr 0b61932e7f vty tests: close msc socket after nat_msc_test
Change-Id: Ib64cf8690627803e1b4a8497ea63f1e766960478
2017-03-05 12:24:46 +00:00
Philipp Maier 6ee49d8416 sgsn: fix problem with leading-zero-IMSIs
When the IMSI ACL is maintained via the VTY, users may enter IMSIs
without leading zeros. Especially in test environments, where
MCC=001 and MNC=01 is common, it is likely that someone enters the
corresponding IMSI (001010000000001) without the two zeros at the
beginning.

This patch fixes the problem by sanitizing the IMSI, eventually
missing zeros in the beginning will be automatically added.

Change-Id: I56ba0da61978bbdce71d0e320166c52b20b42517
2017-03-05 12:24:25 +00:00
Neels Hofmeyr 3f8a8f7736 vty tests: allow picking specific tests to run by name
Depends: osmo-python-tests change-id I92f90c334169f31920c63dd5c5ac8dac215065e6
Change-Id: I849455e0423e1a63d6890aef7f9c6075ad53a920
2017-03-02 14:30:41 +00:00
Max 0436e42472 Fix potential segfault in sgsn_libgtp.c
* print pdp->address instead of mm->imsi if mm is NULL
* print mm->imsi in debug log (move it below NULL check)

Change-Id: I4fbf5a54019a46612fbc528d61120182738f9205
2017-03-02 13:28:52 +01:00
Neels Hofmeyr d3270a9c05 subscriber conn: add indicator for originating RAN
Add via_ran to gsm_subscriber_connection to indicate whether a conn is coming
in via 2G/GERAN/A-Interface or 3G/UTRAN/Iu-Interface. Prepares for Iu, but
also for libvlr to decide between GSM or UMTS Auth.

Until actual Iu support is merged to master, this indicator will aid VLR unit
testing.

At some point we may also add RAN_GERAN_IU; it's not on the agenda yet, but to
clearly distinguish the names if we want to add it, explicitly name the ones we
have RAN_GERAN_A and RAN_UTRAN_IU.

Change-Id: I93b870522f725170e4265a5543f6b680383d7465
2017-03-02 03:13:02 +01:00
Neels Hofmeyr 5616cdde3a fix: gprs_gmm, gprs_llc_vty: two unterminated value_string arrays
Change-Id: Icc4163ac4f962fe88bbebeb3310a557ba0834e84
2017-03-02 01:48:31 +00:00
Keith Whyte f01bd13ca1 meas_json: fix NEIGH: missing array braces
Make NEIGH an array of Javascript objects, otherwise the JSON is not parseable
when neighbours exist

Change-Id: I42029f40bf357adbb2f3c71cdcbafbc21090e348
2017-03-01 11:48:09 +00:00
Alexander Couzens f480b35893 libmsc/update_db_revision_3(): free memleaking db result
Found by ASAN

Change-Id: I2680c60e26b9876b428d4b75323f884f9ecd95b3
2017-02-28 18:36:35 +00:00
Philipp Maier e0d5caa916 silent_call: remove unfinished fuzzer interface
Remove the fuzzer interface that was partially implemented in
gsm_04_08.c and silent_call.c is causing problems when an
SMS is sent during an active silent call. The reason for this
is that gsm0408_dispatch() in gsm_04_08.c would decide to
rout all uplink traffic to silent_call_rx() in silent_call.c.
silent_call_rx() is a stub function that discards the data.

This patch removes the fuzzer interface code by placing ifdefs
around it, so that it can be re-activated by experimentators.

Change-Id: Id500197d58663b3f4b1756136343670388b0a4bc
2017-02-28 18:28:03 +00:00
Neels Hofmeyr acc6e8323a ctrl_test_runner: speed up more than 10 fold by sleeping less
Similar to a recent patch in osmo-python-tests for VTY based tests, but this is
for the Ctrl tests.

The TestCtrlBase tests gave a constant sleep(2) grace period for the process to
startup. This causes tests to take minutes for no reason at all.

Add code to TestCtrlBase to try and connect right away, retrying up to three
seconds in .1 second intervals. This flies through most tests without any
sleep() at all.

Change-Id: I06569767153838bd9cd3edac001df5f6c567874c
2017-02-28 18:26:49 +00:00
Neels Hofmeyr 534034580c vty test: nat_msc_test: setsockopt REUSE to avoid TIME_WAIT problems
When running the testBSCreload test in close succession, I get a "Connection
refused" error because the socket is still in TIME_WAIT state. Passing the
SO_REUSEADDR flag allows reusing the addr despite a TIME_WAIT socket.

Change-Id: I941851b062999ab4b962430f7b27c19935993e0a
2017-02-28 18:22:06 +00:00
Philipp Maier d015cbd65d XID: resend xid with pdp-ctx-ack messages
If a pdp context is created a xid request is sent right after
the pdp-context-ack message. The sending of the pdp-context-ack
and the xid message is triggered from the GGSN via the GTP
interface.

When the pdp-context-ack message is not received by the MS, it will
send the pdp-context-request again. A lost pdp-context-ack is resent
by the SGSN directly so that the mechanism described  above does
not work for pdp-context-ack resents.

This commit adds code to trigger the sending of xid messages also
for resent pdp-context-ack messages.

Change-Id: Ice66790803154310a61a70a54be76cec539c97a7
2017-02-27 18:07:29 +01:00
Neels Hofmeyr 27355c9c65 SGSN VTY: make missing GSUP server address+port fatal
On 'auth-policy remote', the SGSN requires GSUP server address and port. If it
was missing, the SGSN would print a VTY warning and run anyway. Make this error
more fatal: print an error (flattened a bit) to stderr and abort the program.

Move validation of the GSUP server data presence out of the VTY command itself
and into the config reading function. This way the GSUP server config can be
given anywhere, including below the auth-policy config (was required above).

Don't care about setting the auth-policy to remote with a telnet VTY, because
in that case the GSUP client won't be started anyway.

Change-Id: I4d8db910c32abd8579d3c9b9f0b2cb3a9a6dfe4c
2017-02-27 14:29:41 +00:00
Neels Hofmeyr 058cd573d8 SGSN: Integrate support for UMTS AKA
The general infrastructure for UMTS AKA is already in place:
* GSUP with capability to send us auth_vectors that contain
  either triplets or quintuples
* mm_context that holds such auth_vectors

Add:
* capability to send UMTS AUTN in GMM AUTH REQ
* parse extended UMTS RES
* on auth response, validate expected AKA with vector and received res/sres
* add Auth Failure message to receive resync AUTS token and
  * send to HLR
  * clear out-of-sync auth tuple
  * enter new state for when we're waiting for HLR to resync and send new
    tuples so that the next Auth Request will be handled

Original first half of this patch by: Harald Welte <laforge@gnumonks.org>

Full UMTS AKA procedure including AUTS resync tested to work against OsmoHLR
with R99 USIM and Milenage algorithm.

The sgsn_test.c needs adjustment because we're checking the vector's auth_types
now.

Depends: libosmocore change-ids
         I277fb3d407396dffa5c07a9c5454d87a415d393f
         If943731a78089f0aac3d55245de80596d01314a4
Related: OS#1956
Change-Id: Ie6a0cefba5e4e7f02cc2eaf6ec006ac07d5c1816
2017-02-27 14:29:41 +00:00
Neels Hofmeyr 44468ad531 smpp_test_runner.py: fix socket leak
Each running test would open up another socket without ever closing unused
ones. Close the sockets after each test is done.

Change-Id: I0a42caab3bb8c9c9d04b033e4de9efe0ca8fd2af
2017-02-25 17:04:45 +00:00
Neels Hofmeyr 577a125652 python tests: remove process 'Launch' message, now at osmoutil
Change-Id: Id8eb70ddfdc1d0d9f90aa5343a4ea522042c34ee
2017-02-25 17:04:08 +00:00
Neels Hofmeyr 8b24e9f203 vty_rest_runner.py: remove debug monitoring for TCP sockets
Change-Id: I7361bb0ce5302d00ccb18dc04eeb75ee1f6844a8
2017-02-25 17:04:08 +00:00
Alexander Chemeris c634063ea3 utils: 'meas_json' utility to convert measurement feed into a JSON feed.
Change-Id: I56631969384da245eed8ffc14845c76a5d4de8d4
2017-02-25 05:23:22 +00:00
Neels Hofmeyr 0e5d807297 add struct gprs_subscr, separating gprs from gsm_subscriber
Prepare for replacing gsm_subscriber with vlr_subscriber. vlr_subscriber will
not make sense to be used in gprs, so have a dedicated GPRS subscriber struct.
(Could change if the gprs code were to use libvlr; is currently independent).

Related: OS#1592
Change-Id: Ia8b391ee009c8545763cba04505be3947835120e
2017-02-25 01:25:22 +00:00
Neels Hofmeyr a369e24cb9 cosmetic: rename struct osmo_msc_data to bsc_msc_data
With the OsmoMSC program coming up, the name osmo_msc_data becomes even
more confusing than it already is. Clearly indicate it as libbsc's data of
a remote MSC by prefixing with bsc_.

Also, the Osmocom community has in the meantime agreed to have the osmo_
prefix only in libosmocore, to avoid naming conflicts in case things are
moved there. So while renaming anyway, also drop the osmo_ prefix.

Change-Id: I0dfbcb7d1a579211180f71319982820d8700afab
2017-02-24 21:01:55 +01:00
Neels Hofmeyr a42855f09f cosmetic: rename osmo_msc_data.h to bsc_msc_data.h
With the OsmoMSC program coming up, the name osmo_msc_data becomes even
more confusing than it already is. Clearly indicate it as libbsc's data of
a remote MSC by prefixing with bsc_.

Also, the Osmocom community has in the meantime agreed to have the osmo_
prefix only in libosmocore, to avoid naming conflicts in case things are
moved there. So while renaming anyway, also drop the osmo_ prefix.

Change-Id: I13554563ce9289de126ba0d4cf329bafcda35607
2017-02-24 21:01:55 +01:00
Neels Hofmeyr 9762b4c579 cosmetic: clarify BSC's remote MSC data vs. OsmoMSC
Change-Id: I74dd2b3f935d39b8caa718e2c8a51cc81bddf1b9
2017-02-24 21:01:55 +01:00
Neels Hofmeyr fe291de36b cosmetic: gsm_data.h, README: rename CSCN to MSC
We're discarding the name OsmoCSCN for the benefit of OsmoMSC. But "CSCN" has
already crept into the master branch in two places; apply the rename.

See OS#1958

Change-Id: Ib4274eb3c172ada1fe7f05746740b456370bc93d
2017-02-24 21:01:55 +01:00
Neels Hofmeyr d2b3399c04 vty: fix subscr ref count leak in 'subscriber name' cmd
Change-Id: I3d19518c94a7f302bf108f2ad945983cdc8db0b1
2017-02-24 19:58:07 +00:00
Neels Hofmeyr 40a91b38ec vty_test_runner.py: fix socket leak
Each running test would open up another socket without ever closing unused
ones. Close the sockets after each test is done.

Change-Id: Ie433c8560de54f9a9d05fa07c44bae3126d19b30
2017-02-24 17:54:24 +01:00
Neels Hofmeyr 7a250cc9d9 cosmetic: remove unused scall_signal_data.subscr
Doesn't make sense to switch this to struct vlr_subscr when it isn't used at
all. So let's remove it.

Change-Id: Ifa5901f8bf1aed3981841d24d4ec8d659f3de7a9
2017-02-23 23:44:05 +00:00
Neels Hofmeyr 89a8e722ed logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_*
In libosmocore, my patch was merged to master a bit too soon. To accomodate the
request for naming that matches the general "LOG" prefix instead of "LOGGING",
a fixup was committed to libosmocore. Adjust for that.

Original patch: change-id I5c343630020f4b108099696fd96c2111614c8067
The fixup: change-id I424fe3f12ea620338902b2bb8230544bde3f1a93

Change-Id: Ib2ec5e4884aa90f48051ee2f832af557aa525991
2017-02-23 18:11:57 +01:00
Neels Hofmeyr 94f49a4f08 debug.h/c: remove unused cruft / cosmetic tweaks
Change-Id: I9601d478763569933bcc46bf4eaaff70a9843be9
2017-02-22 17:28:49 +01:00
Neels Hofmeyr f13b3c968f logging: use central filter and ctx consts from libosmocore
The LCHAN and BTS filter contexts are actually never used, so drop them until
someone adds them properly.

For now use only LOGGING_{FILTER,CTX}_VLR_SUBSCR. Some of these will change to
_BSC_SUBSCR once struct bsc_subscriber is introduced, and later on, struct
gsm_subscriber will be replaced by vlr_subscriber so that the names will match.

Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067
Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b
2017-02-22 17:24:54 +01:00
Max a66d8cfcb5 Handle DSD from HLR
Handle Delete Subscriber Data GSUP message from HLR to disable Packet
Services for a given IMSI.

Change-Id: I6b9b494fa58bcb95bd550c49f8204f00f8fdf628
Related: OS#1645
2017-02-21 16:24:37 +00:00
Neels Hofmeyr a1613695d1 subscr_update_expire_lu(): fix (obscure) segfault
To be paranoid, catch a NULL subscriber and/or bts in
subscr_update_expire_lu(): print an error log and avoid segfault.
(I'm not sure this would really happen in a normal situation.)

During aggressive testing of Paging timeout, I came across this segfault in
msc_release_connection() when conn->expire_timer_stopped is set but
conn->subscr is NULL, at the subscr dereference after:

        if (conn->expire_timer_stopped)
                subscr_update_expire_lu(conn->subscr, conn->bts);

I brought this situation about by a fabricated Paging fault, i.e. in
gsm48_rx_rr_pag_resp() return 0 and don't call gsm48_handle_paging_resp() at
all. Thus conn->subscr is still NULL when expire_timer_stopped is 1.

When looking at CM Service Request handling, the conn->subscr is set before
setting expire_timer_stopped = 1, which is a saner thing to do. But without my
mad 'return 0', there is in fact no way to have a NULL subscriber there.

It looks like all other code paths already do the same, but it's not that
obvious (e.g. _gsm48_rx_mm_serv_req_sec_cb()). So rather catch this case of
NULL conn->subscr, and while at it catch NULL bts as well.

Change-Id: I430dd952b2b928bea7f8360f1e01bb3cccb0a395
2017-02-19 13:48:31 +00:00
Max 2c16beeb64 Add support for extended SI2q parameters
* add vty command to set E-UTRAN_PRIORITY, THRESH_E-UTRAN_low and
  E-UTRAN_QRXLEVMIN according to 3GPP TS 44.018 Table 10.5.2.33b.1
* remove old command which does not support those parameters

Change-Id: I36dcc79f7b7a02036e74720923d0df1a2a2db504
Fixes: RT#8792
2017-02-19 08:53:57 +00:00
Neels Hofmeyr 87bfed259d remove compiler warning: unused rc in vty_interface_layer3
Change-Id: I3dc94dc4bddc5a887ce196071327a6dddfe5b280
2017-02-18 23:11:04 +01:00
Max b726c2c72b Remove duplicating define
Use GSM_MACBLOCK_LEN consistently throughout abis_rsl.c

Change-Id: I96aec02748a0be0100dee2117f124ff32d5ee3f5
2017-02-09 19:23:38 +01:00
Max 8dc8f23c07 Expand chan allocation logging
Log more data related to channel allocation:
- channel type
- number of paging attempts
- timers fired

Change-Id: Ib417a9c942c17b902dd80ff555cd9da5f91bff48
2017-02-09 19:13:02 +01:00
Max db0e380558 vty: remove ignored logging parameters
Since ce9fec3e896571835ac5bfd2980d6836f2b29f0d libosmocore ignores
parameters to log_vty_command_* functions. Hence parameter of
logging_vty_add_cmds() is ignored too. As we depend on much later
libosmocore version anyway, we can simplify code somewhat by removing
parameters which will be ignored anyway.

Change-Id: I62f752fd88f1d8fefa563648f9864c7c31f87991
2017-02-08 09:37:38 +00:00
Neels Hofmeyr 50422016f0 vty tests: more attempts to resolve 'Broken Pipe' error (2)
Change-Id: I1c0a16d5b3094c25a908f0117d7656d57aac3fda
2017-02-08 08:33:10 +00:00
Alexander Couzens 5ba6fb3ef4 gprs/sgsn_vty: fix typo in comment
Change-Id: I63225b7ba6d666eddf00b1deb893e79dc9ec842b
2017-02-07 00:41:48 +00:00
Alexander Couzens 1013550218 gprs/sgsn_mm_ctx_alloc(): initialize MM state to IDLE
Previous the state was only set in Iu mode.

Change-Id: I99a6aec1090cad9b9d38d134cc9b34ef292062df
2017-02-07 00:41:32 +00:00
Alexander Couzens 17a29ef311 gprs/gprs_mm: add value_strings for PMM & MM states
Change-Id: I4e34dcd5e48c4dd73d63c6f865298ee7d9c864be
2017-02-07 00:41:32 +00:00
Alexander Couzens 2b5fb8ed66 gprs/sgsn: rename sgsn_mm_ctx_alloc() -> sgsn_mm_ctx_alloc_gb()
Postfix the ran type to clarify the purpose.
Because of the new support of the Iu ran type, there are 2 functions to allocate a mm ctx.
For Iu it's sgsn_mm_ctx_alloc_iu(). For gb it should be named in the same way.

Change-Id: Ic49009e8c20c12308855e1409c09004698c79b95
2017-02-07 00:41:32 +00:00
Alexander Couzens 4f8da6dfd5 gprs/sgsn: rename gprs->mm_state -> gmm_state
GMM is the right term. MM state is already occupied.

Change-Id: I9cfdcf921e4ebd14a5e7ce7489ec4ce5d1f5515f
2017-02-07 00:41:31 +00:00
Neels Hofmeyr 48324fed11 vty tests: more attempts to resolve 'Broken Pipe' error (3)
Change-Id: Iea5329b6b92afc4088520d7420953106f04f8e1c
2017-02-07 00:41:16 +00:00
Neels Hofmeyr bcfee2a0a6 vty tests: more attempts to resolve 'Broken Pipe' error
Change-Id: I4251a24eb7a57a354aa76de711547c3e76ebb846
2017-02-07 00:41:06 +00:00
Max d09b26d487 Attempt to fix nightly builds
The fix introduced in dac5867af5 did not
work because autotools in our OE are too old. Use alternative way to
include custom m4 macros to fix it.

Change-Id: I5fe6d1180c2624cfe1d3673314f6846527a43464
2017-02-07 00:40:02 +00:00
Harald Welte 89837d422e VTY: Print 3G auth tuples, not just 2G auth tuples
Change-Id: I277e4347ee1486a39e6dc4e2363a593f328f9e3b
Related: OS#1592
2017-02-06 15:08:11 +01:00
Neels Hofmeyr 22a735bfd4 gsm_04_08: implement parsing of UMTS Auth responses
Parse the longer UMTS res from the extended Auth Response Parameter IE.
Parse the R99 Authentication Failure and AUTS in case of cause
GSM_REJECT_SYNCH_FAILURE which indicates a SQN re-sync request.

Both still end in 'not implemented' error logs, which are the places where the
upcoming VLR that supports UMTS AKA will integrate.

Depends on recently added constants in libosmocore in
commit 55a43b801385e07a484217925ecf2379b9f54fcf
aka change-id I745061ce8eb88aa23080dadcdbfe2d703c362a30

Change-Id: I4868bbeedc32fa7b8d03b9e3c66db618543d38ec
2017-02-06 15:08:11 +01:00
Philipp Maier e1f8b9244a om2000: add VTY command to delete CON groups
The currently unused function abis_om2000_vty.c:con_group_del()
allows deleting OM 2000 connection groups. This commit adds a
matching VTY command to make use of it.

Change-Id: I39a90b06e19356c536cacd1c923e195dd305ab80
2017-02-03 17:05:14 +01:00
Neels Hofmeyr e02e1e782f Revert "vty tests: more attempts to resolve sporadic 'Broken Pipe' error"
'self' will not be accessible in that context, so this patch isn't
useful.

This reverts commit b39053ad6d.

Change-Id: Ic1a9ba5fdfd7bdc6c5cf0974e8c637ae23b81ece
2017-02-03 05:56:50 +01:00
Neels Hofmeyr d675515bd4 gsm48_tx_mm_auth_req(): support UMTS AUTN
To be able to do R99 UMTS authentication, we need to send along AUTN bytes in
the Authentication Request. Add autn parameter to gsm48_tx_mm_auth_req() and
conditionally append the R99 AUTN TLV to the Authentication Request message.

Change-Id: I0d644559088706aa06b42b9bfe1f8c21ca6fa4da
2017-02-03 05:35:25 +01:00
Neels Hofmeyr ba1468e4c6 vty tests: testBSCreload: ipa_handle_small: ensure rx of 4 bytes
Change-Id: I995b7aba9d0b51b0861a4281dbbca888f36e9e00
2017-02-03 04:48:27 +01:00
Neels Hofmeyr b39053ad6d vty tests: more attempts to resolve sporadic 'Broken Pipe' error
Change-Id: I3d833ddf8c62845fe68d1e5503332541a4a04a2d
2017-02-03 04:17:49 +01:00
Neels Hofmeyr 7d17c3ef61 vty tests: attempt to get at sporadic 'Broken Pipe' error
Add verbose logging as well as three retries around the place that often
fails on our build server with a 'Broken Pipe' error.

Change-Id: I8851b76b2d7b87dd500ae40f47e6bea716ef3fc4
2017-02-02 23:38:46 +00:00
Neels Hofmeyr 35706ddd80 gsm0408_rcv_cc: guard against NULL subscriber
Check conn->subscr against NULL.

gsm0408_rcv_cc() dereferences many conn members without checking presence: the
bts and lchan members may be expected to be NULL in the ongoing MSC split and
3G developments.

But the conn->subscr is initially NULL, so an MS sending a CC message before
something like a LU or CM Service Request will result in a segfault. Prevent
that.

Note: the upcoming VLR will be more restrictive on what messages are processed,
this is a "backport" to the situation on current master.

Change-Id: If067db7cc0dd3210d9eb1da15be6b637795a3ecf
2017-02-03 00:34:02 +01:00
Neels Hofmeyr 26adfd099b compiler warning: bsc_vty: remove two unused vars
Added in recent commit 42def7205b
"Implement VTY configuration to control Early Classmark Sending"

Change-Id: Iaf640fa6e1f234f594fb8dc06f716d3d3e95eb2a
2017-02-02 20:04:56 +00:00
Neels Hofmeyr a5c71bf39a paging.h: use '<>' include, not '""'
Also separate openbsc includes from osmocom/core includes.

Change-Id: I4da0cb32476202d06902531d07faed8004f689f9
2017-02-02 04:26:36 +01:00
Neels Hofmeyr 150abfffbf osmo_bsc_grace.h: use '<>' include, not '""'
Change-Id: I2f22be93d1a5fd6f229b85305a1d2a2cf6a43ce2
2017-02-02 04:26:36 +01:00
Harald Welte 2d02775b91 OM2000: use assoc_so *only* for TS objects
all other objects always use the MO instance.  The existing code
likely is due to copy+paste mistakes.

Change-Id: Ie0a31cd93993da10f31eecf530a5a05773c11eb1
2017-02-01 16:36:11 +00:00
Holger Hans Peter Freyther 725f3f1de0 sgsn: Fix deeply flawed copying logic for PDP context activation
It is one of these changes that should have never worked but did
for a long time. Only recently a corrupted GTP message was seen.
The code in ccd2312d10 tried to
solve the right problem but was deeply flawed.

* Make the code operate on the copied message and not the original
one that is deleted by the underlaying layers on return
* Add an out variable to determine if the msgb should be deleted
and assume that by default it will be deleted.

Change-Id: I564526e7cde2b8a2f0ce900492cd38fc23c176a7
2017-02-01 15:02:54 +00:00
Max dac5867af5 Remove dependency to autoconf-archive
It is generally not a good idea to add more and more external
dependencies unless absolutely needed.  autoconf-archive is a good
example of that, as we need to update all build machines, and older
OpenEmbedded versions do not appear to have (the right?)
autoconf-archive recipe. Provide local copy of necessary m4 files to fix
the build there.

The dependency to autoconf-archive was introduced in Change-Id
Ied9c950dafa65f324cf31298b13b590f56139700

Change-Id: Iacc1958b471ec3fc65307259039e1d496845f528
2017-01-31 19:54:58 +01:00
Holger Hans Peter Freyther 3f940fc9ee debian: Require libgtp-dev after the SO version bump
The ABI of libgtp changed and we require a new library now. Drop
the SO_VERSION from the library name and just depend on libgtp-dev.

Change-Id: Ib301b27e2c08fda827b55820389247e27e5e8fc7
2017-01-30 09:54:22 +00:00
Philipp Maier 6934a0fa9e gprs: Fix compiler warning about uninitalized cause code
in gprs_gmm.c:gsm48_rx_gmm_ra_upd_req the variable reject_cause
is not initalized, which is ok, since it gets initalized before
the jump into the "rejected" path. However, the compiler still
throws a warning. This commit fixes the problem by preinitalizing
the reject_cause to GMM_CAUSE_PROTO_ERR_UNSPEC

Change-Id: I84cffb631e4cad3d4748512b47e3876208f53727
2017-01-27 22:18:06 +00:00
Minh-Quang Nguyen f188623091 rsl: Fix dropping of LAPDm UA message.
In some cases, when successive mobile originated calls are made, the LAPDm UA
message gets lost because the channel is relased to early. Too overcome the
problem we do not send release indications immediately. Instead a flag will be
set and the message stored and sent on the next TCH-RTS-IND.

This commit adds the required flag and the msg-buffer to struct gsm_lchan.
See also coresponding change in osmo-bts.git:
Change-Id Ie4f70c75f0137b4bd72d579b3a32575bac2fca38

This patch is is a slightly improved/reformatted version of:
95d1f15ad1

Change-Id: I15fc1ef8e9e83f009bde96de9a8e95702cffbce6
2017-01-27 22:17:22 +00:00
Harald Welte 42def7205b Implement VTY configuration to control Early Classmark Sending
The SI3 rest octests contain a flag that indicates if early classmark
sending is allowed in this cell or not.  So far we always set this to
one, now it is configurable using the 'early-classmark-sending' command
at the VTY node.

Change-Id: Ia0b1cc5ab45673f3da70c59ae8917eba343f9862
2017-01-26 15:24:07 +01:00
Harald Welte 6c4382b998 remove unused struct members of 'struct sgsn_pdp_ctx'
There were some members that we neither set nor read, so let's
shrink the struct size and remove those unused members.

Change-Id: I02136e3aa91e58b2afc923c09c8693095497fdd7
2017-01-26 15:24:07 +01:00
Harald Welte 471ac7d99c sgsn: Add GTP information to "show pdp-context"
When displaying the PDP context, it is quite useful to also show IP
address and TEI information about the GTP side of that PDP context.

Change-Id: I56ea530240c15b26729e7a42e539020cb1e233e5
2017-01-26 15:24:07 +01:00
Neels Hofmeyr cc7db18e1a various comment / whitespace tweaks (libmsc, gprs, libcommon-cs)
cosmetic ws in common_cs_vty.c, osmo_msc.c

comment: tiny typo fix in gsm_04_08.c

In comments, drop some unbalanced braces, because simplistic C file harvesters
will break at a single opening brace even if it is in a comment. This is aimed
at the fsm-to-dot.py script in libosmocore/contrib.

Change-Id: I3c1fa53195a1e57d6fe0a6791c346d30ceff1251
2017-01-26 03:19:35 +01:00
Philipp Maier d0ef1ed78c compression: Fix nullpointer deref
When the creation of a new compression entity fails, an error
message is created, this error message contains printf with
a dereferentiation of the compression entity, that is clearly
NULL at that point. This commit corrects that.

Change-Id: I87371ade0ccd6a93b446f2013c1747f486739518
2017-01-25 19:44:54 +00:00
Max f6e51709fc CTRL: remove boilerplate
Use CTRL_CMD_DEFINE_RO(), CTRL_CMD_DEFINE_WO() and
CTRL_CMD_DEFINE_WO_NOVRF() where appropriate to get rid of boilerplate
code.

Change-Id: I5bcea0b4f4b8f535bef2b423f2013b8b4a218b5b
2017-01-25 11:52:45 +00:00
Holger Hans Peter Freyther 76f048a1fd debian: Install header and source file to different directory
osmo-bts consumes the gsm_data_shared.{h,c} files and assumes the
OpenBSC directory layout. Install the files into the specific
sub-directories to make the --with-openbsc=dir option work.

Change-Id: I3da21402dee3d6f1d812b232b0a3f13b8a462d5b
2017-01-24 13:16:10 +00:00
Keith Whyte d32b6d13ed Add VTY command to immediately expire user (set expire_lu to now)
Change-Id: I676c84350a7afc963bc6bb4c46c60e5ac3eee67e
2017-01-23 20:34:58 +00:00
Max e610e700da SI2q: add support for multiple UARFCNs
Support multiple UARFCNs with the same Scrambler Code.

Fixes: RT#7379
Change-Id: If1c32e8b547a28325180faaaddd21f80c37f7337
2017-01-23 12:32:09 +00:00
Max 881064e9b8 Prevent segfault in range encoding
* Explicitly check when ARFCN array split is impossible and return
  gracefully instead of using negative index.
* Separate range encoding into generic function and use it for all
  SI-related things.
* Propagate the error into that function and to its callers.
* Add separate test-case for the segfault previously triggered by this bug.

Change-Id: I3e049ab2d7c1c4d6c791b148f37e10636a8e43e0
Related: RT#7379
2017-01-23 12:32:00 +00:00
Max 47e1781907 bsc_control.py: fix blocking
Previously reading from socket would block if no data were sent by
the server. Use non-blocking read for set and get operations.

Change-Id: I706d54a4a7ceef62683bf9a2fe63fc9ab331c24e
2017-01-23 12:31:45 +00:00
Max a5e369300f Improve OML failure report
* clearly separate report parts
* use textual representation for failure cause if possible

Change-Id: I7a98a77011463021d0edd6ecfab1680e211f7e16
Related: OS#1615
2017-01-23 12:16:05 +00:00
Neels Hofmeyr 93bafb611a cosmetic: use osmo_strlcpy() everywhere
Shorten some code and make obvious to the reader that the string copy is done
in a safe way.

Change-Id: I900726cf06d34128db22a3d3d911ee0d1423b1bd
2017-01-23 11:59:01 +00:00
Neels Hofmeyr 59504dc80f fix strncpy() invocation in vty_interface_layer3.c and 3 tests
Use osmo_strlcpy() to fix unsafe invocation of strncpy(), which potentially
left the result unterminated.

Change-Id: I1a119b1760a3e3262538b4b012d476fdce505482
2017-01-23 11:59:01 +00:00
Max f5e74b5988 Print subcriber when skipping auth
Change-Id: I6ae6720afc04cc3c92ceff86e5b2a5a29494aeb1
2017-01-23 11:56:44 +00:00
Neels Hofmeyr b7f41d554b undup: gtphub_test: use libosmocore's llist_count()
Depends on libosmocore Change-Id Ic49adc7a346f5722bf624d7d3b4a735e4220ae15

Change-Id: I67bc1889c064596a2f3e93cc0354b11c720b0225
2017-01-23 11:53:27 +00:00
Max 34f012639d Turn some compiler warnings into errors
Re-apply the reverted commit 98bc7fa50d, this
time with a clear error message in case autoconf-archive is not installed.

Change-Id: I631bde22e79ec0318eb9c8114db5861a1d635816
Tweaked-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
2017-01-21 01:44:26 +01:00
Ruben Undheim c8fc41c2f6 deb: unbreak nightly builds
Add openbsc-dev with source and header files necessary for osmo-bts builds.

Max's note: extracted from Debian packaging work into separate commit.

Change-Id: I25f8c639d2dc525ca280a7cd09de3ca6358d2568
2017-01-19 13:35:18 +00:00
Neels Hofmeyr 04db87a89f gprs subscr: fix: intended strcmp(), but is strcpy()
The code checked 'if (strcpy(..) != 0)' which is always true and thus always
copied twice -- luckily we want to copy anyway and so this is not an actual
functional failure.

We could correct to strcmp, but instead of iterating to compare, we might as
well copy right away.

Change-Id: I0ea035bd478f7022ed65e9e84d8aaf5e423309b7
2017-01-15 18:10:47 +00:00
Max 3d07aef800 Log expected SRES on GPRS AUTH REJECT
Change-Id: I19b0001650979bf7f1832f04f9fd5a26beb577d0
2017-01-13 19:32:22 +01:00
Neels Hofmeyr 98bc7fa50d Revert "Turn some warnings into errors"
This introduces a failure with ./configure on my machine:

  ../configure: line 6612: syntax error near unexpected token `-Werror=implicit,'
  ../configure: line 6612: `AX_CHECK_COMPILE_FLAG(-Werror=implicit, CFLAGS="$CFLAGS -Werror=implicit")'
  Makefile:420: recipe for target 'config.status' failed
  make[1]: *** [config.status] Error 2

Installing autoconf-archive did not fix the error.
So even though jenkins seems to accept this, I cannot build with this patch.

Let's find out how to do this in a way that all systems can still build
and then re-apply this patch.

This reverts commit fd161ccce8.

Change-Id: I2b368500b07f233882ef854eca1fa21f6df39e29
2017-01-13 02:51:22 +00:00
Max fd161ccce8 Turn some warnings into errors
Make warnings (when available) related to common memory-related issues
into errors to harden the source and decrease chance of errors.

Change-Id: Ied9c950dafa65f324cf31298b13b590f56139700
2017-01-11 19:51:33 +01:00
Max 34be86b93c Cosmetic fixes around SI generation
* add missing spaces after comma and minus
* prevent useless recursion calls
* mark static functions as such
* name and explicitly use enum for ARFCN range

Change-Id: If5b717445c8b24668bad0e78fd5bb51f66c4d18e
2017-01-06 11:37:52 +00:00
Neels Hofmeyr fa9abaca26 fix 'osmo-nitb --version' segfault
Call vty_init() before handle_options() to make sure the host.app_info is
populated before --version potentially tries to print it.

The segfault was introduced by 2c05f75bbf in a
recent MSC-split merge.

Change-Id: Ice91256d72b9eabd52709352ba6cc6a42af2921b
2016-12-31 18:25:36 +01:00
Keith Whyte 80abe522e2 Pass actual smpp_avail_status through to smpp in alert_all_esme()
Change-Id: I4b00d8821c1688ca0c990b6042607f4ded0f80e3
2016-12-24 17:12:34 +00:00
Philipp Maier 532480a705 cosmetic: Rename phone to ms
The term "phone" is incorrect. Rename phone to "MS" (mobile station)
in the comments and log output of gprs_llc.c

Change-Id: I322d3d99452502da7555cc2af6bc8a192ca3c9c5
2016-12-23 11:19:15 +01:00
Philipp Maier db142dc59d sndcp: Allow empty SNDCP-XID indications
In some rare cases the modem might send a xid indication that does
not contain anything except the version number field. The sgsn
ignors such SNDCP-XID indications by stripping the entire field
from the response. We found a modem in the wild that started to
act problematic when the empty SNDCP-XID was missing in the
response. This patch changes the XID negotiation behaviour in
a way that if a modem should send empty SNDCP-XID indications,
the reply will also contain an empty SNDCP-XID indication. Apart
from that the SNDCP-XID version number is now parsed and echoed
in the response. This ensures that we always reply with the version
number that the modem expects. (The version was 0 in all cases we
observed so far)

Change-Id: I097a770cb4907418f53e620a051ebb8cd110c5f2
Related: OS#1794
2016-12-23 11:19:15 +01:00
Harald Welte a191dcd8f0 bsc_vty: Fix missing break statements in switch()
Change-Id: Ifd48e8d56c845603d320748144b4d7c3c24022a0
Fixes: Coverity CID 135188
Fixes: Coverity CID 135190
2016-12-22 14:07:43 +00:00
Neels Hofmeyr b42dc43e28 use new OSMO_VALUE_STRING
libosmocore change-id I857af45ae602bb9a647ba26cf8b0d1b23403b54c adds
OSMO_VALUE_STRING to compose value_string arrays with the exact enum names as
entries. Use instead of identical local macros in two places.

Change-Id: I1b44d2a3f293785a01d6a587c78f9e0cbeec70c3
2016-12-21 14:02:07 +00:00
Neels Hofmeyr 9fdb4e5f2f gitignore: gsup_test_client binary
gsup_test_client was added in 4f8e34b226 and
moved to libcommon in 2c1f8c8ceb, both of
which forgot to adjust the .gitignore.

Change-Id: Idd0d29a2f5c5b9b038103c955e0027d9ee9fee73
2016-12-21 14:30:30 +01:00
Max 5fa8b083cc Integrate Debian packaging changes
debian/control:
* restructure to make it easier to incorporate further changes
* update package descriptions
* update project URL

debian/rules:
* use proper hardening syntax
* restructure to make it easier to incorporate further changes
* remove useless comment

debian/compat: update compatibility version

debian/coryright: update to match Debian format

Change-Id: I49cc9239b15dc77d782914ca2547e601d049acdc
Related: OS#1694
2016-12-21 10:31:21 +00:00
Max 549ebc7d6c Improve GPRS logging
* log xid type as string instead of int
* log packet encryption status, algorithm and IOV-UI in debug mode
* print encryption parameters when dumping llme via vty
* log key propagation from MM to LLC

Related: OS#1794
Change-Id: I30c38fdeb0b88bb39bdb9928851300bc79e6aec6
2016-12-21 10:27:24 +00:00
Neels Hofmeyr 6903848029 build: remove obsolete $LIBCRYPT in two places
It should be $LIBCRYPTO_LIBS if at all.

Change-Id: I191dfe0901a10a25dffa3bbfdb9ea319fcebe254
2016-12-21 10:26:15 +00:00
Neels Hofmeyr b735390284 build: osmo-nitb: fix missing LIBCRYPTO_FLAGS
Change-Id: I6268d0b8782ee03b42ab8bbda7aa9650c26e11ad
2016-12-21 10:26:15 +00:00
Ruben Undheim 59d57da1e5 Fix some typos in stdout output
Change-Id: I0dbb438f3bfbaf9744717cbeec31ceefdd679ee9
Related: OS#1694
2016-12-20 17:39:55 +01:00
Max 0c32685898 bsc_control.py: remove unused -i option
This option only served to demonstrate possibility of manually selecting
<id> field in CTRL protocol. Since the transition to generic ipa module
this is no longer exposed so the option became a no-op. Correspondingly
there's no need to explicitly initialize the RNG - the Ctrl class
handles random <id> generation internally.

Change-Id: I10cc7c069354cced2bba84fe67c69c28b8596ded
2016-12-19 08:57:43 +00:00
Neels Hofmeyr ea619f1704 gtphub: fix possible NULL deref: don't print NULL tunnel
Fixes: coverity CID#158302
Change-Id: Ic500a3eb0c49393c7962a20e61eb57fd467208d3
2016-12-18 16:58:41 +00:00
Neels Hofmeyr ecdfd6d097 fix: missing terminator in two value_string arrays
iu_event_type_names[] and auth_action_names[] lacked a { 0, NULL }.

Change-Id: I2e3f271b887e711c8139fbaa32410c16e7fe9921
2016-12-16 14:19:19 +01:00
Neels Hofmeyr 37f9252361 oap_client: make use of OAP optional: disable for NULL config
When passing a NULL config to osmo_oap_client_init(), set OAP to disabled
state. Along with the previous fix that ensures message rejection in the
disabled state, this makes use of OAP in the GSUP client optional.

oap_client_test: expect null config to set state to disabled.

Related: OS#1592
Change-Id: Ie4d622fcfd24cb7d89d19f93e4b2571d8fadd1a3
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 2fa74faf92 oap_client: reject all messages in disabled/uninitialized state
Fixes the bug indicated in oap_client_test.c: adjust to actually expect the
proper behavior.

Also adjust for modified return value for message rejection. Instead of -1,
just expect < 0.

Adjust experr for new error messages.

Related: OS#1592
Change-Id: I16165d228653e8a2689f9df94b77b470c06480c6
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 3cbc052101 oap_client_test: show bug: disabled state does not reject message
There is a hole in OAP where a disabled OAP still accepts at least a
Registration Reject message, after which it will do things it shouldn't. Show
this by expecting the bugs, to be adjusted with the upcoming fix.

Related: OS#1592
Change-Id: I4a5fde308b876946fea2571ea1a550f0cc7ee136
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 73ed45599b oap_client: move logging to DLOAP logging category
Use libosmocore's DLOAP logging category for OAP.

oap_client_test.c: make sure DLOAP is in DEBUG level to not lose any logging
messages from experr.

Todo: we're using a "Library" logging category, which is not really what the
library category was intended for. Instead, the OAP client should probably be
given a logging category like DVLR or DGPRS in its initialization API.

Related: OS#1592
Change-Id: Ic765c19381b0d983da90a5d8aee9cd17e31cf34a
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 2e109f08c0 oap_client_test: print test descr to stderr, check stderr
Related: OS#1592
Change-Id: If1696c8e7bfa696b250f7eac24f08f85f8f492a2
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 28786bb209 oap_test.c: rename to avoid clash with libosmocore oap_test.c
Rename to oap_client_test.c, which is also a more accurate name.

Related: OS#1592
Change-Id: I3ca333141a15940df07a1ae77a30bc54885db41f
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 2c1f8c8ceb move grps_gsup_client.c to libcommon/gsup_client.c
This is in preparation for libvlr.

Related: OS#1592
Change-Id: I9ad7dc7f17f3b033c779de9ae8bc120655502fce
2016-12-13 14:54:02 +00:00
Neels Hofmeyr 3d6b9f4fe9 move gprs/oap.c to libcommon/oap_client.c
This is in preparation for libvlr.

Related: OS#1592
Change-Id: Ib526df6d9de55a1e59a379d5e2c8541ed0ef67e3
2016-12-13 14:54:01 +00:00
Neels Hofmeyr 11ecc9320c rename oap.h to oap_client.h
Related: OS#1592
Change-Id: I05bd65ff81b0f70f68217b2e0a9466e160bdbdec
2016-12-13 14:54:01 +00:00
Neels Hofmeyr 49012f14dd oap: rename public API from oap_ to oap_client_
Mainly to differentiate the OAP messaging API (osmo_oap_ in libosmocore) from
the OAP client.

This is in preparation for moving the oap client to libcommon, which is in turn
preparation for libvlr. Add the osmo_ prefix, as all public Osmocom API should
have. We also have OAP messages code in libosmocore, so clarify by naming this
osmo_oap_client, and by also renaming the oap_test to oap_client_test. This
reshuffling will allow an easy move of OAP to libosmocore if we should want to
do that. A number of patches will follow up on this.

Related: OS#1592
Change-Id: Id447d2bebc026a375567654adafa5f82439ea7e1
2016-12-13 14:54:01 +00:00
Harald Welte 736474ce45 move OAP messages implementations to libosmocore
This corresponds to change-id If5099e60681a215e798b6675f21813f26769c253 in
libosmocore, which is now required to build openbsc.

Related: OS#1592
Change-Id: I2f06aaa6eb54eafa860cfed8e72e41d82ff1c4cf
2016-12-13 14:54:01 +00:00
Neels Hofmeyr ef022783c3 gsup client, gsup_test_client: move logging to DLGSUP category
Use the DLGSUP logging category for GSUP.

Bump the required version of libosmocore to 0.9.5 to benefit from the DLGSUP
logging category fix in core/logging.[hc].
(Id974c7be158e4d60421a98110f5c807aefd31119)

Todo: we're using a "Library" logging category, which is not really what the
library category was intended for. Instead, the GSUP client should probably be
given a logging category like DVLR or DGPRS in its initialization API.

Related: OS#1592
Change-Id: Id3938267fa062e1a997d3704cd678874306f86ee
2016-12-13 14:54:01 +00:00
Neels Hofmeyr eaaee92db5 rename gprs_gsup_client.h to gsup_client.h
This is in preparation for moving gsup to libcommon, which is in turn
preparation for libvlr.

Related: OS#1592
Change-Id: I9c95d00f1a9420887a44c938b1d0ee3e20586f4c
2016-12-13 14:54:01 +00:00
Neels Hofmeyr 814fef04b0 gprs_gsup_client*: remove the gprs_ prefix
Make sure everything is named gsup_client_ / GSUP_CLIENT_.

Rename static gsup_client_send() to client_send() to avoid clash with public
gprs_gsup_client_send() being renamed to gsup_client_send().

This is in preparation for moving gsup to libcommon, which is in turn
preparation for libvlr. libvlr and osmo-sgsn will use the same GSUP client
code. A number of patches will follow up on this, also for the the OAP client.

Related: OS#1592
Change-Id: I57433973b1c4f6cc1e12e7b1c96b5f719f418b51
2016-12-13 14:54:01 +00:00
Neels Hofmeyr 3df5d53a04 comments: gsup client: rename to Generic, adjust copyright and authors
Related: OS#1592
Change-Id: I2c5d145e05aa4afd43ef1341d22563448f1c3577
2016-12-13 14:54:01 +00:00
Harald Welte 4f8e34b226 add gsup_test_client program
Related: OS#1592
Change-Id: Iafd844393dd90b899f84ed61c875c1eb533436d7
2016-12-13 14:54:01 +00:00
Neels Hofmeyr 08586c68db build: bump required libosmocore, libosmogsm to 0.9.4, for GSUP
GSUP was added to libosmocore in 0.9.4. We're using it here, so make up for a
previously missing bump.

(BTW: I'm pretty sure that other dependencies are also in dire need of a bump,
but leaving that for another patch)

Change-Id: I4f245a7d78d0889b37084c52478372bddb8289d6
2016-12-13 14:54:00 +00:00
Max bd33f54444 bsc_control.py: use ipa.py module
Simplify code by using Ctrl implementation from ipa.py

Change-Id: I25fd7cd4b42126354b72abd60a3837be5d13e159
2016-12-13 14:47:32 +01:00
Max 82caa3e9b7 bsc_control.py: style corrections
* replace some tabs indent with spaces
* add comment to make sure no new tabs are used for indentation by emacs
* remove unnecessary parenthesis

Change-Id: Ib79fd4317d40ee4fd87b090b9faf8ebaf4bfca64
2016-12-13 14:47:32 +01:00
Max 688231331b Add twisted-based IPA multiplex
Add sample applications using twisted framework for IPA and CTRL
multiplex.

Change-Id: I07559df420b7fe8418f3412f45acd9a375e43bc5
Related: SYS#3028
2016-12-13 14:47:32 +01:00
Max 3e6768937e Use IPA module for vty tests
Replace hackish ipa_send_* routines with proper implementation from IPA
module thus making it part of extended tests.

Change-Id: If13ed7fd243ce3aeef505d2e8468e221aa62f79e
2016-12-13 14:47:32 +01:00
Neels Hofmeyr d53e9b51b6 Revert "Support Deactivate PDP Context Request from network"
This reverts commit 1611df5226.

This is due to a segfault introduced to the asan build only. See:
http://lists.osmocom.org/pipermail/openbsc/2016-December/009966.html
 Subject: new sanitizer breakage: SIGSEGV in sgsn_create_pdp_ctx()
 Date: Tue Dec 13 12:08:32 UTC 2016

Change-Id: Ic926c0e6778947b516994822e3a21d4fde25bb02
2016-12-13 12:42:45 +00:00
Max c3b94f92c5 Add IPA multiplex
Add base class and derived Ctrl class implementing ctrl-specific
routines.

Change-Id: I41e37ec143183e422c0b31af95d183bd84f0c328
Related: SYS#3028
2016-12-13 10:52:23 +00:00
Pravin Kumarvel 1611df5226 Support Deactivate PDP Context Request from network
Enable Deactivate PDP context based on the IMSI of the subscriber.
When there are PDP contexts present for a MM context,
PDP context will be deactivated along with GMM Detach(MM context deletion).
If there are no PDP present, MM context will be deleted to avoid
further PDP context request from the MS.
Test cases is added to check this functionality.

Change-Id: Ia0a41aa2218ec2fda4ea17a37c8cc55cba63dd13
2016-12-12 17:20:39 +05:30
Harald Welte b8e8d0a402 channel_mode_from_lchan(): Add missing break statement
GSM48_CMODE_DATA_6k0 was not properly terminated and thus resulted in a
bug.

Change-Id: I4000f06d0b49c4afb0446beddd150521c4ba3cf0
Fixes: Coverity CID 148207
2016-12-09 16:26:23 +00:00
Harald Welte c59e28fa5e gsm0408_test.c: Don't pass negative value to strerror()
Change-Id: I4fcf24ec1bc974a3189486d2372b9713d7fdab70
Fixes: Coverity CID 135192
2016-12-09 15:36:58 +00:00
Harald Welte 1cd50585e9 cfg_bts_si2quater_neigh_add(): Don't call strerror() on negative value
Change-Id: I1300eede3f22df812b7e83902327ce4cde21aa35
Fixes: Coverity CID 135185
2016-12-09 15:35:31 +00:00
Harald Welte 4a7d0e79cc mgcp_protocol: Ensure we don't call strtok_r with NULL data
Change-Id: I1dce4df6a49fe95db592b0598194e3a8b8b1b994
Fixes: Coverity CID 135181
2016-12-09 15:35:31 +00:00
Harald Welte 2327cede9c bsc_ctrl: Ensure we don't pass NULL string into strtok_r()
Change-Id: I03bea132377c0136b55b6fdad99a5d92da12e692
Fixes: Coverity CID 135180
2016-12-09 15:35:31 +00:00
Harald Welte 8d35965f24 abisip-find: check bsc_fd_register() result
Change-Id: I72d713725d287d32ec90506099751aeb9b15ef15
Fixes: Coverity CID 70462
2016-12-09 15:35:30 +00:00
Harald Welte c346f87371 sgsn_test: Fix missing = in == type check
Change-Id: I696a7d25d2f4d19922e05a7e83c4aeec5c44fb07
Fixes: Coverity CID 135156
2016-12-09 15:35:30 +00:00
Neels Hofmeyr 8825c69409 Fix TCH/F_PDCH: no need to check ts subslots for PDCH
For TCH/F_PDCH in PDCH mode, directly return the lchan to use, in order to
switch it to TCH/F. To check the pchan type in chan_alloc.c, make ts_pchan()
public in gsm_data_shared.h.

Commit c3f72f63af broke TCH/F_PDCH, as a fallout
of setting the GSM_PCHAN_PDCH subslots number to 0. This is sane and correct,
but the chan_alloc code failed to see a ts as available if it has no subslots.

Explanation:

_lc_find_trx() checks each timeslot. For normal, static TCH timeslots we
determine the number of logical subslots contained and check whether one of
them is free. For dynamic TS, we can do the same when in TCH mode, but when in
PDCH mode, we already know that it is available for immediate switchover for
voice and hence can return it right away. TCH/F_TCH/H_PDCH already has a
special check for that. TCH/F_PDCH doesn't, but this worked for TCH/F_PDCH as
long as ts_subslots() returned 1 for PDCH: the for-loop at the bottom of
_lc_find_trx() checked one subslot, which succeeded on an lchan in PDCH mode,
since PDCH lchans are always marked type == NONE and state == NONE. Now we more
accurately acknowledge that a PDCH timeslot has zero subslots and that a
dynamic timeslot in PDCH mode can always be switched to voice immediately,
without checking lchan type or state.

So, above mentioned commit set PDCH to zero subslots, and the for-loop to check
the (zero) subslots never ran and hence never returned the lchan. This fix adds
a special condition for TCH/F_PDCH in PDCH mode, same as TCH/F_TCH/H_PDCH.

(Todo: ts_pchan() can probably be used in other places as well to remove some
code dup. Leaving that for another patch.)

Fixes: OS#1868
Change-Id: I5d555d018a5bcb8d948e54059d32ec4c9b3070d0
2016-12-09 12:13:03 +00:00
Neels Hofmeyr e14f4b93f2 cosmetic: chan_alloc: use switch instead of if-cascade
Preparing cosmetically for a subsequent commit which will add another pchan
kind to be checked, rather use a "switch (pchan) {}". Also reverse one if()
branch to "early-exit" style.

Change-Id: Ie5eb0fa859c4f225616095dc56d52ce0f2dc8bdc
2016-12-09 12:13:02 +00:00
Max 2440f49a72 Replace duplicated code with macro call
Use already defined GSM48_LEN2PLEN for computing SI length.

Change-Id: I2020417119c844b886f89e34dbfd75e716743dc4
2016-12-09 12:06:27 +00:00
Neels Hofmeyr ec16c16193 lchan release in error state: SACCH deact only for SACCH pchans
This is useful particularly in case where we deactivate PDCHs
which don't have a SACCH associated.  The existin code would
always attempt to deactivate a SACCH even in those cases, leading
to the BTS responsding with related error messages.

Change-Id: Iaf46782329b38ba8f3d438e6c75c2d467b852734
2016-12-09 11:35:41 +00:00
Philipp Maier f788d93382 LLC: Fixup element order in LLC-XID
When the LLC-XID request is constructed the order of the elements
in the TLV structure is reversed. This is in theory not a problem,
but differs from what we know from our practical experience. This
commit fixes the problem.

Change-Id: I1d71c947350d3c5a85ff36b71c1b8f036071d162
2016-12-05 18:56:51 +00:00
Neels Hofmeyr 2b9c53408f abis_om2k: fix typo that declared non-existent struct gsm_bts_trx_s
The typo was recently committed in 80ccb95267,
"OM2000: Fix missing dynamic TCH initialization"

Change-Id: I8e3eec8cf63494962fa31d85a0ec9db9a9e5df46
2016-12-02 12:09:41 +00:00
Neels Hofmeyr ce090f890b gsm_subscriber_connection: mark BSC specific items
This is intended to prepare for splitting gsm_subscriber_connection into BSC
and MSC specific structs, to make the splitting patch more readable.

Change-Id: Ib9666225fb9bfec2cf1e364343560571869fe6a7
2016-12-02 12:09:17 +00:00
Neels Hofmeyr 50669bebdb osmo-nitb: exit when MNCC socket init failed
Change-Id: Icef97bb5da9840b810fe6f4b4da6abd4baa66915
2016-12-02 12:09:17 +00:00
Neels Hofmeyr 42eb0141d7 split subscr_con_allocate()/_free() in bsc_ and msc_
Rename current subscr_con_allocate() and subscr_con_free to bsc_*,
and add two separate msc_subscr_con_allocate() and _free().
The msc_subscr_con_free() ignores all lchan members.

In libbsc use bsc_*, in libmsc use msc_*.

Change-Id: I3cf7c7cafdf4672ec7b26058bba8a77159855257
Future: there will be distinct subscr conns for libbsc and libmsc.
2016-12-02 12:09:17 +00:00
Neels Hofmeyr 640b794de0 move to libcommon-cs: net timezone VTY config
Leave the timezone VTY output in libbsc's config_write_net(), until the BSC/MSC
separation of struct gsm_network is completed.

Change-Id: I9712b2e07b4f1ab8d2e4ad40a8d771e98ed25b20
2016-12-02 12:09:17 +00:00
Neels Hofmeyr 7398395cc0 Move timezone settings up to network level
Time zone used to be configurable per-BTS. In the upcoming MSC-split, no BTS
structures will be available on the MSC level. To simplify, drop the ability to
manage several time zones in a core network and place the time zone config on
the network VTY level, i.e. in gsm_network. If we are going to re-add fine
grained time zone settings, it should probably be tied to the LAC.

Adjust time zone VTY config code (to be moved to libcommon-cs in subsequent commit).

Adjust time zone Ctrl Interface code.

Change-Id: I69848887d92990f3d6f969be80f6ef91f6bdbbe8
2016-12-02 12:09:17 +00:00
Neels Hofmeyr 1a60644eb2 reinvent connection_for_subscr() and move to libmsc
Implement connection_for_subscr() from a completely different angle: instead of
looking up lchans in bts structs, look up the subscriber in the global list of
gsm_subscriber_connection. static lchan_find() is thus obsoleted.

All callers of connection_for_subscr() live in libmsc, so move to libmsc.

The move and edit are done in a single commit since the old and new
implementation have nothing in common.

Future: osmo-cscn will use this, without bts being present.

Remove implementation of connection_for_subscr() from channel_test.c -- it is
possible that the abort() in there was intended for a regression test, but
actually it seems the implementation was merely added for linking reasons, and
the abort() added to guard against the NULL return value: no comment nor the
commit log indicate that the abort() is test critical; the addition was the
only change in channel_test.c for that commit; at the same time a
connection_for_subscr() call was added in libmsc.

Change-Id: I5e0ba0ecf1726ebd540800f4e98fdfc937c904ff
2016-12-02 12:09:17 +00:00
Neels Hofmeyr ea11bf8095 bsc vty: rename show_net_cmd to bsc_show_net_cmd
Future: there will be an MSC-land show-net-cmd, so rename to something with
bsc in its name.

Change-Id: Ifb86698cd57a09f03b935b6d3fcea87eff4cd397
2016-12-02 12:09:16 +00:00
Neels Hofmeyr 06d39fdb72 move to libcommon-cs: network VTY that isn't BSC-specific
Keep only BSC specific bits of the 'network' VTY node in bsc_vty.c, move more
general VTY commands to common_cs_vty.c.

Add arg to common_cs_vty_init() to pass a config_write_net() function. Pass a libbsc
specific config_write_net() function.

Future: upcoming omso-cscn will re-use the VTY bits moved to libcommon-cs and pass a
different config_write_net() function.

Change-Id: I871b7b32a0c56fdce983e409cf244ec487d24e71
2016-12-02 12:09:16 +00:00
Neels Hofmeyr b90eabfb46 move to libcommon-cs: global vty gsm_network pointer
Move gsmnet_from_vty() and the bsc_gsmnet global to common_cs_vty.c.

Rename bsc_gsmnet to vty_global_gsm_network and make it static to common_cs_vty.c, to
clearly mark the global variable for VTY use only.

Introduce common_cs_vty_init() to set vty_global_gsm_network.

Change-Id: I26c5c47de08f899b896813d09612d5cb2f8e42d6
2016-12-02 12:09:16 +00:00
Neels Hofmeyr 2c05f75bbf global gsm_network: move allocation further up
Now that bsc_network_alloc() is separate, move it to before the VTY init (a
subsequent patch will pass the gsm_network instance as a parameter to
vty_init()).

bsc_hack.c: drop the comment that says about the VTY init: "This needs to
precede handle_options()" -- it is not accurate. Actually move the
handle_options() above both vty_init() and the bsc_network_alloc() calls, to be
able to decide which mncc callback to pass to bsc_network_alloc. It would make
sense to set this later on, but that would require further refactoring of the
bsc_network_init() and gsm_network_init() signatures, so not in this patch.

Change-Id: Ie6a7037e703b5a2d08ceeb20d35f197aaddc9d1b
2016-12-02 12:09:15 +00:00
Neels Hofmeyr e235441f73 split bsc_bootstrap_network() in alloc and config
For patch clarity, keep some code dup to be removed in a subsequent patch. In
the same sense don't change the fact that mncc_sock_init()'s return value is
ignored.

The global gsm_network instance 'bsc_gsmnet' is basically only used by the VTY,
and a future patch will "hide" that global in a vty .c file. In a nutshell, I
want to

- first allocate a gsm_network,
- then initialize the VTY passing the gsm_network pointer,
- and then read the config file using the initialized VTY.

So far, bsc_bootstrap_network() allocates the gsm_network and reads the config
file right away, which only works by sharing the extern bsc_gsmnet pointer,
which I would like to uncouple.

Change-Id: I480a09a31a79766ad07b627dd5238b7e37f3be7a
2016-12-02 12:09:15 +00:00
Neels Hofmeyr 6a366055dd tests: drop unused libmsc, unneeded duplicate libbsc linking
Because of libcommon-cs, tests/gsm0408,subscr,trau no longer need libmsc.

Change-Id: I9073eba41a1cd3136ed7a9def6fe8aaf282eaa18
2016-12-02 12:09:15 +00:00
Neels Hofmeyr 05667a0aff sms_next_rp_msg_ref(): use direct pointer to next_rp_ref counter
libbsc and libmsc will have separate subscriber connection structs. Hence don't
rely on gsm_subscriber_connection, but work on a direct pointer to the counter
for the next RP reference.

The only very thin function in gsm_04_11_helper.c thus becomes obsolete: drop
the entire file.

Change-Id: I2a2e9ba6a981a385d1f8f07acbe03536ffed0072
2016-12-02 12:09:15 +00:00
Neels Hofmeyr ac1f1436e9 factor out & introduce struct gsm_encr, in common_cs.h
Factor out encryption info from struct gsm_lchan as struct gsm_encr, placed in
common_cs.h.

Change-Id: I94015fb9dd511c37c1e3058a0963c780b3f700ac
Future: this will be used by libmsc's subscriber connection, for osmo-cscn.
2016-12-02 12:09:15 +00:00
Neels Hofmeyr 43273c63de factor out gen of USSD notify and release complete to libosmocore
Both libmsc and libbsc will need distinct gsm0480_send_ussdNotify() and
gsm0480_send_releaseComplete() functions, since there will be distinct
subscriber connection structs.

Rename to msc_send_ussd_notify() and msc_send_ussd_release_complete(), and add
the same in libbsc with bsc_ prefix in new file gsm_04_80_utils.c.

In preparation of this patch, the message generation part of these functions
has been added to libosmocore as gsm0480_create_ussd_notify() and
gsm0480_create_ussd_release_complete(). Use these.

Adjust all libmsc and libbsc callers according to use the msc_* or bsc_*
implementation, respectively.

Change-Id: I33a84e3c28576ced91d2ea24103123431f551173
2016-12-02 12:09:15 +00:00
Neels Hofmeyr eb52aad198 IuPS: properly update ra_id on GMM Attach Request
For new MM contexts, the ra_id was correctly obtained from the ue_ctx, but in
case an MM ctx is re-used and the ra_id changed, the new ra_id was not copied
to the MM context; instead, the ra_id was overwritten with uninitialized data.

Always initialize the local ra_id variable from the ue_ctx->ra_id for Iu
connections; it is used further below to update the ctx->ra_id.

For the case of a brand new Iu MM ctx, the ctx->ra_id then gets initialized a
second time. We could technically drop the init in sgsn_mm_ctx_alloc_iu(), but
it doesn't hurt either way.

Fixes: CID#57936
Change-Id: Ia06458758362e76925690b1757d8ced95e9609e4
2016-11-28 12:09:06 +01:00
Philipp Maier 143a274051 sndcp: fixup for coverity scan defect CID 149097
Coverity scan detects a Null pointer deref (FORWARD_NULL) in
gprs_sndcp_comp.c: 67 in gprs_sndcp_comp_create().

The reason for this is that gprs_sndcp_dcomp_init() and also
gprs_sndcp_pcomp_init() rely on the comp_entity->algo algo
flag. If the program logic is correct a null pointer deref
should never occur.

This commit adds OSMO_ASSERT() statements to ensure a null
pointer deref is catched if if the ...comp_init() functions
are used with incorrect parameters.

Change-Id: I7748f06d1739a697edad5100a031e5aa1ef11ed1
2016-11-27 18:27:57 +00:00
Harald Welte 487436138e bsc_msc.c: Check setsockopt() return value
Change-Id: I79a8fe9c025772e51560503504f517485b0ace34
Fixes: Coverity CID 57644
2016-11-26 17:10:29 +01:00
Harald Welte be67050a36 abis_nm: ceck fseek() return code in is_last_line()
Change-Id: I8ed4e703625c9da959e0938cd1eb3f0c73a2d4d0
Fixes: Coverity CID 57643
2016-11-26 17:10:29 +01:00
Harald Welte 3c165d02bb ipaccess-proxy: Check setsockopt() return value
Change-Id: I34b082907b6f0b25fe2779f3a1f0a642a9002664
Fixes: Coverity CID 57642
2016-11-26 17:10:29 +01:00
Harald Welte 54f44ec585 ipaccess-config: Handle setsockopt return value
Change-Id: I8c2082f9a9c865cc663ad2abb63ee0f70914dabe
Fixes: Coverity CID 57640
2016-11-26 17:10:29 +01:00
Harald Welte 18712f0bd1 Fix possible non-null-terminated buffer
Change-Id: I22100c260856991b9a836135b3650e5b8c5449ca
Fixes: Coverity CID 57623
2016-11-26 17:10:29 +01:00
Harald Welte 96df077083 libmsc/db: avoid subscr->name without terminating NULL char
Change-Id: Ic8944ac4c5e940c9d835c52f1701461f274238db
Fixes: Coverity CID 57621
2016-11-26 16:08:38 +00:00
Harald Welte b0993e61d0 abis_nm: Fix non-null terminated buffer
Unrealistic case (filename of 4096 bytes)

Change-Id: Icf7b835f9edaf66976556fce1e9e0f66aa2010bc
Fixes: Coverity CID 57620
2016-11-26 16:08:38 +00:00
Harald Welte 7b6bae6584 abis_nm: Fix possible not-null-terminated buffer
Unrealistic case with file name of 4096 bytes length.

Change-Id: I503200b879b854cf2dc218d5fe3059a555732d92
Fixes: Coverity CID 57619
2016-11-26 16:08:37 +00:00
Neels Hofmeyr 28f637ec2c move to libcommon-cs: gsm48_create_mm_serv_rej(), gsm48_create_loc_upd_rej()
Used by libbsc, libmsc as well as osmo-bsc and osmo-bsc_nat.

Moving gsm48_create* to libcommon-cs affects linking of osmo-bsc_nat, resulting in
undefined references to gsm48_extract_mi() and gsm48_paging_extract_mi(); fix
that by placing libfilter.a left of libbsc.a upon linker invocation.

Change-Id: I212c2567b56191022b683674c1c4daf842839946
2016-11-24 16:58:31 +01:00
Neels Hofmeyr e78ae21ff4 move to libcommon-cs: net init 3: actual move
Reincarnate gsm_network_init() as the parts not specific to libbsc.
Move from bsc_network_init() those bits that are not BSC specific (and useful
for upcoming osmo-cscn).

Add libcommon-cs to all linkages that use gsm_network_init().

Note: the only requirement to allow linking gsm_network_init() without libbsc
is to keep the call to gsm_net_update_ctype() out of libcommon-cs. The other items
are kept out of libcommon-cs because it makes sense semantically. But the separation
is not strong in that the BSC specific data members are of course still
omnipresent in struct gsm_network. If bsc_network_init() is not called, these
are not initialized properly -- for now no users of uninitialized members
exist.

So this is just a first step towards a sensible split of the BSC and MSC
gsm_network structs. The long term aim should be to have entirely separate
structs with some common general items.

Change-Id: If06316b97002390dc9a434686750cb96193ea63b
2016-11-24 16:58:31 +01:00
Neels Hofmeyr 2d521a0296 move to libcommon-cs: net init 2: move bsc_network_init decl to new .h
bsc_network_init() is more fit to live in a BSC specific header, move it to new
common_bsc.h. It will probably also absorb the BSC-specific part of gsm_network
in the future.

Adjust header includes across the board. Particularly, fix abis_nm.h by
explicitly including gsm_data.h: it so far relied on other headers to do that,
which now is no longer always given.

Change-Id: I9edfb1e748bb1cb484fadd48b0406f5b3098e89b
2016-11-24 16:58:31 +01:00
Neels Hofmeyr 27681a3407 move to libcommon-cs: net init 1: rename to bsc_network_init
The gsm_network_init() function initializes a whole lot of BSC specific stuff.
Aiming to move some of it to libcommon-cs, first rename it to bsc_network_init().
This will retain the BSC specific stuff when the move is done.

Adjust all callers.

Future: osmo-cscn will call the more generic part and not the BSC specific
part.

Change-Id: I4816ae19374390fc5c64972f7cad2e9ec3d8bcc3
2016-11-24 16:58:31 +01:00
Neels Hofmeyr 402006dfdf define mncc_recv_cb_t to avoid code dup
Put mncc_recv_cb_t in common_cs.h to avoid header include complications: if placing
right above struct gsm_network, one must include gsm_data.h to use
mncc_recv_cb_t as function parameter in a header, which will include
gsm_data_shared.h, which will include common_cs.h (future knowledge). Since I will
need to use mncc_recv_cb_t in common_cs.h, including gsm_data.h from there would
introduce an #include loop. Avoid that and define mncc_recv_cb_t in common_cs.h to
begin with.

Change-Id: I2e64cffa563750ce9f3172ffba6f9cf5b9280e9c
2016-11-24 16:58:30 +01:00
Neels Hofmeyr c69ee8527c Add empty libcommon-cs
This will gradually soak up code shared by libbsc and libmsc.

Change-Id: If34e2bd38a099d0799238337468d56e0305ab8ae
2016-11-24 16:58:30 +01:00
Pravin Kumarvel 16606c9007 Add support for pdpctx_timer_stop
Timer T3395 starts  at the transmission of Deactivate PDP request using
pdpctx_timer_start  but there was no corresponding stop function.
The timer is stopped when Deactivate PDP Context Accept is received.
This according to 3gpp spec reference 24.008 section 6.1.3.4.2.

Change-Id: I825c0a47d39e784dd1b8251f564609262530a5c6
2016-11-23 12:23:41 +00:00
Holger Hans Peter Freyther 5085e0bf4c ussd: Add band-aid for interrogationSS
This is a speculative change for interrogateSS and by not answering
the request the radio connection would remain open long.

The SS/USSD code is from a time where none of knew much about GSM. We
do not support SS but should reject it. We have checked for an empty
string in the text field to guess if it is a result/release to not send
more information. The right way forward is to decode the ASN1 into the
fields REQUEST/RESULT(last).

Fix an issue and make the code worse. Assume ss_code > 0 to see if this
is a interrogate invoke. The issue is that code 0 is a well defined
value but unlikely to be used.

MAP ASN1 definition:

SS-Code ::= OCTET STRING (SIZE (1))
        -- This type is used to represent the code identifying a single
        -- supplementary service, a group of supplementary services, or
        -- all supplementary services. The services and abbreviations
        -- used are defined in TS 3GPP TS 22.004 [5]. The internal structure is
        -- defined as follows:
        --
        -- bits 87654321: group (bits 8765), and specific service
        -- (bits 4321)

allSS                   SS-Code ::= '00000000'B

Change-Id: Ib0dc4485388f030eb172fe21f5327b7ab94751f5
2016-11-18 19:04:37 +00:00
Pravin Kumarvel 26f6ced05c Correct Logging macro for pdpctx_timer_start
This commit corrects the Logging macro used in pdpctx_timer_start.

Change-Id: Id4e3a7fb934ed82af8096fda9ddd3f4550e05844
2016-11-17 12:19:01 +05:30
Harald Welte 80ccb95267 OM2000: Fix missing dynamic TCH initialization
When OM2000 has confirmed that a TS is started, call dyn_ts_init()
on the timeslot to start the processing for fully dynamic (osmocom
style) TCH/F_TCH/H_PDCH.  This should in turn trigger the activation of
idle timeslots as PDCH until we want to allocate any of them for TCH/F
or TCH/H.

Change-Id: I1a1fd61d6afd85449cacad4bacfb830252dab6b1
2016-11-16 18:20:22 +01:00
Harald Welte 96638d141e OM2000: Add three IEs to TCH activation about which we have no clue
Change-Id: Ie3067606033e894c558659ddf0025d01b8198cf9
2016-11-16 18:20:21 +01:00
Philipp Maier 309425e105 rsl: support for ericssons propritary SI13 format
Ericsson has introduced a propritary format to issue the S13 BCCH
information. Normally the system info type field for SI13 would
be encoded as 0x28. Ericsson encodes that field as 0x02 and ads
a bcch mapping parameter, (IEI=F2) This patch sets the BCCH mapping
to 0x00 (=BCCH Normal) statically (0xF200)

The new constands are added to libosmocore, see commit:
f0f9c8c29daaefbf9cff19177ade4a13ffb2e36c

Change-Id: Ie0900f9b810744172b3090ce1b0ef7b7a1132946
2016-11-16 16:36:17 +00:00
Philipp Maier 38cba5aa79 OM2000: Fixup based on Coverity Scan suggestion
This commit fixes Coverity Scan defect:

CID 151901:  Insecure data handling  (TAINTED_SCALAR)
Passing tainted variable "tag_len" to a tainted sink.

Change-Id: Ic71ed6a3bbb228bc03e95bfc4a6f5fe09cf5a021
2016-11-16 16:35:42 +00:00
Philipp Maier fb89b9b00b rbs2000: Add missing bts feature definitions
function bts_model_rbs2k_start() in bts_ericsson_rbs2000.c lacks
the feature definition for GPRS and EGPRS.

Change-Id: I777a67862084aa6cca39cfc43f5708e47608b0e6
2016-11-16 16:35:05 +00:00
Max c04c6ed4af abisip-find: use protocol constant
Use library define instead of directly using hardcoded value.

Change-Id: Ie9b8bc55bf40cf005434f27e205d47ffab959413
2016-11-15 22:35:38 +00:00
Philipp Maier 7d3093506a SNDCP: Fixup based on Coverity Scan suggestion
This commit fixes Coverity Scan defect:

CID 151900:  Null pointer dereferences  (FORWARD_NULL)
Passing null pointer "comp_field->v42bis_params->nsapi"
to "memcpy", which dereferences it.

Change-Id: Iff83e21168a267dd4b4c401ab7c603e029b3ac39
2016-11-15 22:32:20 +00:00
Daniel Willmann bb42eee113 test/gbproxy: Test for possible memory corruption when link_info is freed
This test is to trigger the use-after free issue in commit bff7b0d80972. If
compiled with address-sanitizer the test will abort without the fix.

Change-Id: I5e8c6626ba43342740f08d699383bdded739079f
Ticket: OW#3049
Sponsored-by: On-Waves ehf
2016-11-15 22:32:03 +00:00
Daniel Willmann beade314d0 gbproxy: Check whether gbproxy_update_link_state_after() deletes the link_info
In case the link_info is deleted we have to stop handling the stored messages
inside link_info. Not doing so can lead to invalid memory being accessed.

Change-Id: Ieb8503e9e94e7a5ac450ad8aa1713ec4f21cdea5
Ticket: OW#3049
Sponsored-by: On-Waves ehf
2016-11-15 22:32:02 +00:00
Harald Welte 58273f4b88 OM2000: CON MO: Allow larger range for CCP and CI values
it seesm more recent RBS2000 models have much larger CCP and CI value ranges
than those of older models.

Change-Id: Ib116c1fac901b293929fce34223d1fd0af15d2bc
2016-11-13 21:22:33 +01:00
Harald Welte eae68292bd Support configuration of CON MO Groups/Paths from VTY
The code for supporting the configuration of the OM2000 CON (LAPD
Concentrator) MO was so far incomplete and not used from the OM2000 FSM
initialization.  This patch adds
* VTY commands for configuration of CON Groups and Paths
* The FSM integration to actually configure the CON MO

Change-Id: I56dc1b5e35adef3a2078bcf9536537eb0f454192
2016-11-13 21:22:29 +01:00
Harald Welte fe7be8ddd0 RBS2000: Ensure the is-connection-list command is only used on RBS2000
... and not on other BTS models.

Change-Id: I8882ca9a9ab974b0bbdcbd5c3bab0eadf4bc0927
2016-11-11 21:20:49 +01:00
Harald Welte c1efa67c13 RBS2000: Avoid segfault if ts->lapd instance doesn't exist
This happens e.g. with DAHDI driver, when the DAHDI device cannot be
opened.  Let's not prematurely seg-fault early in the RBS2000 signal
handler, but take the proper error handlign for this.

Change-Id: I9223fb1568d3db7e278f07240c4be334c6602a13
2016-11-11 21:20:49 +01:00
Harald Welte dfe48fdecf bs11_config: remove compiler waring about unused variable
bs11_config.c:78:22: warning: ‘too_fast’ defined but not used [-Wunused-const-variable=]
 static const uint8_t too_fast[] = { 0x12, 0x80, 0x00, 0x00, 0x02, 0x02
};
                      ^~~~~~~~

Change-Id: I1fdb9645128c2dfeb489bf75e89ab0adea919d2b
2016-11-11 15:34:05 +00:00
Harald Welte af9a9b0b44 talloc_cxt: Fix compiler warning / missing #include
talloc_ctx.c: In function ‘talloc_ctx_init’:
talloc_ctx.c:40:2: warning: implicit declaration of function ‘msgb_talloc_ctx_init’ [-Wimplicit-function-declaration]
  msgb_talloc_ctx_init(ctx_root, 0);
  ^~~~~~~~~~~~~~~~~~~~

Change-Id: Ib8ebc02d5cf0d2b4019473d3750ae7c6f8a32896
2016-11-11 15:52:58 +01:00
Neels Hofmeyr 87ef68eb33 OM2000: disallow ip.access style TCH/F_PDCH pchan type
For TCH/F_PDCH, return an invalid chan comb (0) and print an error message
that hints at the proper pchan type to use instead: TCH/F_TCH/H_PDCH

Change-Id: Ibe0f944573f0a6d1be4bf7cf4986c4b2b3bd6d0d
2016-11-10 17:05:02 +00:00
Neels Hofmeyr f926f45c4b OM2000: for TS conf of dyn TS, always send TCH/F chan comb
When OM2K sets up the timeslots with the BTS, the dynamic channel state
is not yet resolved to any particular pchan type. Instead of using the
dyn state, always advertise dynamic timeslots as pchan2comb(TCH/F).

In the past, the Ericsson dynamic timeslots were handled as pchan type
TCH/F_PDCH. This is a mistake, as this pchan type is intended for
the ip.access dynamic PDCH way of dynamic channels. In any case, in the
initial state of this pchan type, the timeslot was initialized as
pchan2comb(TCH/F) because the ts->flags do not reflect an active PDCH
yet. In short, this patch does not change the behavior of TCH/F_PDCH
timeslots, only clarifies it.

It would in fact make sense to disallow use of TCH/F_PDCH for OM2K,
but that should probably be a separate patch.

The proper pchan to use for Ericsson dynamic timeslots is
TCH/F_TCH/H_PDCH. These do not use ts->flags, but ts->dyn.* as state,
which first reflects pchan_want == pchan_is == GSM_PCHAN_NONE. Hence
the timeslot was initialized by OM2K as pchan type zero, which is
unknown / invalid. So, instead of using pchan_is, which is not yet
reflecting anything meaningful, always initialize as TCH/F chan comb,
as Ericsson hardware apparently expects it.

Change-Id: If0693f7c5c85977b0e4acbc701ee5d635434d0d1
2016-11-10 17:05:02 +00:00
Neels Hofmeyr 194b4cb4fd fix use after free in bsc_config_free
talloc_free the cfg only after asserting num_bsc count sanity.
This caused a failure in the 'bsc-nat' test with -fsanitize build.

Should fix the Osmocom_Sanitizer build on jenkins.osmocom.org
https://jenkins.osmocom.org/jenkins/job/Osmocom_Sanitizer/

Change-Id: Ic20aacaccffcaa58ccec6d24c884727dc1bc50e6
2016-11-10 03:19:22 +01:00
Philipp Maier b4ecc1d43b OM2000: Throw error when MO can not be enabled
Throw warning message in case the MO state does not change
to enabled after sendeing an Enable-Request message.

Change-Id: Idfde8d6f71526e8acfea51835732515a4bee858e
2016-11-09 15:43:34 +00:00
Philipp Maier 6bbcfbb78c om2000: added support for ericssons sabm negotiation
This patch adds support for ericssons sambm negotiation.

This patch depends on libosmo-abis commit:
2788c7eacab91cd39d68e316fc8ee87763bbfeb4

Change-Id: I56b1c1cef07a61143fc0e8058480805cddfeff96
2016-11-09 15:43:34 +00:00
Philipp Maier 8136e4b9af OM2000: Add fault report parsing
This patch adds parsing for OM2000 MO fault report map parsing,
the bits in the fault maps are counted out and displayed.

Change-Id: I6e2928f39b09bc08e9ab78bc10bc81e07f7eb55d
2016-11-09 15:43:34 +00:00
Harald Welte 7975ddf0ec RBS2000: re-establish any lost signalling links
Contrary to standard A-bis, in the RBS2000 case the BSC connects
the signalling data links (LAPD) to the BTS.  In case one of them
drop, we need to attempt to re-establish them.

This requires libosmo-abis with Change-Id I07f0f79e0cda09766f357032ffb4e7ad643d448a

Change-Id: I710b5af5d0acbdd3febd314849340f2adb7abd80
2016-11-09 15:43:34 +00:00
root 4579978983 om2000: Add support for querying RBS capabilities
Change-Id: Id1fbaf41286f3651ce8f210eb8da05fb51179c96
2016-11-09 15:43:34 +00:00
Holger Hans Peter Freyther 46edbc4162 lchan: Release channel in case of late activation ack
In case of the sysmoBTS and receiving a channel activation ack on a channel
that was marked as broken, release it again.

Use a normal release without SACCH deactivation and release the rqd_ta data.

Also add a local variable 'ts' to shorten some lines.

The typical situation where this would occur is with high latency between BTS
and BSC (or NITB). If a channel activation ack does not arrive in time, a
channel is marked broken, and never recovers after that. This patch will
release the channel again, which will remove the BROKEN_UNUSABLE state and
makes lchan available again. Reported by Rhizomatica.

However, in case of packet loss, i.e. when the channel activation ack never
arrives at the BSC, this patch does not provide a resolution of the
BROKEN_UNUSABLE state.

On dynamic timeslots: clearing the dyn ts state could possibly happen in
lchan_free() instead of in rsl_rx_chan_act_ack(). That's to be done in a
separate patch, if at all.

Tweaked-By: nhofmeyr
Change-Id: I63dc0deaf15ba7c21e20b1e0c7b85f0437e183ed
2016-11-09 15:43:13 +00:00
Harald Welte 686f4d6a85 SGSN: Use dummy all-zero MSISDN value in PDP Context Act on GTP
The GTP protocol specification requires us to include the MSISDN IE in
all non-secondary PDP context activations. However, when no real HLR is
used (e.g. via GSUP), we do not have the MSISDN information available
and so far simply sent a zero-length MSISDN IE in GTP.  The latter is a
violation of the spec.

So to resolve this, we now send a 15-digit all-zero dummy MSISDN IE, as
described in TS 23.003.

Change-Id: I8d0a5d52d6cd2a00b5dda060bd41d45056dfa84d
2016-11-09 15:42:39 +00:00
Harald Welte 424656e527 OM2000: Fix state machien for CF/TRXC on START Result
When receiving the 'Start Result' message, for CF and TRXC MO
we directly transition to performing the Operational Info.  In that
case, we need to return after sending the Operational Info and skip
the usual processing for the default case below.

Change-Id: I99860d198b337ffe461b240bda20dc10e1b5b2cb
2016-11-09 15:11:36 +01:00
Harald Welte 591e1d7daa WIP: OM2000: Full state machine implementation using osmo_fsm
Our existing OM2000 code for initializing all Managed Objects of a BTS
at startup was never complete.  Rather than trying to fix the old-style
code, introudce a hierarchy of osmo_fsm's reflecting the full protocol
hand-shake and sequence of bringing up the individual MO's.

If this works out well, it mihgt make sense to convert the TS 12.21 OML
code for other BTS models, too.

Change-Id: I3e11b28ba22b8c227e0401e6207fdda5381dda8c
2016-11-08 19:57:50 +00:00
Neels Hofmeyr b748012d31 bsc_vty: include dyn TS info in vty show lchan
Extend both 'show lchan <bts> <trx> <lchan>' and 'show lchan summary' to
include information on dynamic timeslots.

Have one common function that prints " as foo" or " switching foo -> bar" to
the vty, use it in lchan_dump_full_vty() and lchan_dump_short_vty().

In lchan_dump_short_vty(), split the vty_out call in two in order to interleave
the dyn ts info right after the pchan.

The summary hence looks e.g. like this for osmocom style dyn ts:

    BTS 0, TRX 0, Timeslot 5 TCH/F_TCH/H_PDCH as PDCH, Lchan 0, Type NONE, State ACTIVE - L1 MS Power: 0 dBm RXL-FULL-dl: -110 dBm RXL-FULL-ul: -110 dBm

or

    BTS 0, TRX 0, Timeslot 4 TCH/F_TCH/H_PDCH switching NONE -> PDCH, Lchan 0, Type NONE, State BROKEN UNUSABLE - L1 MS Power: 0 dBm RXL-FULL-dl: -110 dBm RXL-FULL-ul: -110 dBm

Change-Id: I3eb72ac7f0a520a8eefe171b9fb357f149aa3fda
2016-11-03 12:37:03 +00:00
Neels Hofmeyr 350f93e1e4 log: count_codecs(): drop logging of non-TCH lchan types
count_codecs() is called on every chan act ack, also for channels other than
TCH/F and TCH/H. So this logging happens a lot during normal operation but adds
no real information.

Also, RSL would be the wrong logging category for this -- RSL is about the RSL
communications, not whether our internal code tries to count lchan codecs for
the wrong channel types.

Change-Id: Ibdac3bbe48745fe6a1c31d6f87369c9066c0374a
2016-11-02 14:33:48 +01:00
Harald Welte 0c566a444b mncc_builtin: Properly reject DTMF
As per TS 23.014, a GSM MSC must implement mobile-originated DTMF
generation.  We gate the DTMF signalling messages to MNCC, and expect
the external MNCC handler to deal with it.  However, the internal MNCC
handler simply ignored such singalling messages, rather than rejecting
DTMF altogether.

It turns out failure to respond to START DTMF will cause some phones to
behave in interesting ways, particularly with modem
firmware v6.01.00, see https://osmocom.org/issues/1817).  In this case
the phone is not able to release the call as the pending response to the
START DTMF is probably keping a reference or lock of some sort.

Change-Id: I336f0cd0a6396b522d228479a417fd4d606157ac
2016-11-02 09:20:54 +00:00
Philipp Maier 5e5d94cd1b Cosmetic: Add missing switch to usage help
Adds the -p --pcap option to the help text.

Change-Id: I3e763c30ca13bc51c8b72af8a94558c92439f109
2016-11-01 21:56:23 +00:00
Philipp Maier d37981e8f7 gsm0408: Adding log output for 3g specific RR messages
GSM 04.18, which is the successor of GSM 04.08, describes
additional RR 3g specific message types. This commit adds
log output for those messages. The behaviour is not changed
all affected message types are still forwared to the MSC
as they were before.

See also 3GPP TS 04.18, section 10.4, table 10.4.1

The change requires to update libosmocore as well, see
also commit f48fdb3a108da0dc23d7af4ac021e98e11f07152 in
libosmocore.git for details.

Change-Id: I41f2242fdf59c3eb4b3f8f7f003c17f7e0df01aa
2016-11-01 21:56:22 +00:00
Philipp Maier b4cb838092 OML: Improve OML attribute handling
the OML attribute tables are hardcoded. To set variable parameters,
the hardcoded data structure (tlv) is patched on byte level during
runtime. This patch replaces this mechanism.

- Replace hardcoded OML attribute tables with dynamically
  generated TLV structures.

- Add unit tests to check if the OML attribute tables are
  generated correctly

- Put OML attribute table generator code in a separate file:
  bts_ipaccess_nanobts_omlattr.c

Change-Id: Ibeb34a84912d6cf695f553a34c69320fca7d08fa
2016-11-01 21:56:22 +00:00
Max 05adbdcb2e Decrease count_codecs logging verbosity
Use channel type name instead of number and log it with DEBUG facility
otherwise it produces lots of irrelevant messages for SDCCH*

Change-Id: I11b04e0cb02bf6ed01f6076cb31a56d8921d735e
2016-11-01 11:51:51 +01:00
Neels Hofmeyr 87c0056480 info log: iu: add line break to and tweak rx RAB Ass Resp log
Change-Id: I50e701493f3951a43506cc37753a30d47f8d601f
2016-10-30 18:28:27 +00:00
Philipp Maier ae9beda150 sndcp: Fixups for sndcp layer based on coverity-scan suggestions
- missing break in gprs_sndcp_pcomp.c, line 143
- string overflow in slhc_test.c, line 211
- sizeof mismatch in gprs_sndcp_xid.c, line 1369 and 1378
- mismatching signedness in gprs_sndcp_xid.c, line 1377
- needless < 0 comparison in gprs_sndcp_xid.c, line 477
- needless < 0 comparison in gprs_sndcp_xid.c, line 209
- missing returncode check in v42bis_test.c, line 320
- wrong pointer dereferentialization in gprs_sndcp_comp.c, line 73

Change-Id: I4f9adf251f5119e67ffe76baad6f1f996ac8dbad
2016-10-28 13:43:10 +00:00
Max 1b76a03cdd DTX DL: Add FACCH cache
When DL DTX is active and silent period is in progress dtx.cache is
populated by SID UPDATE message which about to be scheduled next. If at
that moment FACCH message arrives (which have higher priority) we have
to send ONSET message to L1 but we can't invalidate cache with SID
UPDATE as it will be used for SID FIRST message to resume silent period
after FACCH transmission is over (provided there were no incoming voice
in between). Hence the necessity for separate buffer to store content of
FACCH message while we're sending ONSET to L1 while keeping SID UPDATE
cached.

Change-Id: I316e81af893b24766bf259baaed7a0be75a11694
Related: OS#1801
2016-10-28 09:25:47 +00:00
Alexander Couzens 8c53c59bfb bsc: count the usage of codec by setting the lchan active
We count the codec when the channel was successful setted up
Using sign_link->trx->bts instead of msg->trx to get the bts.
Add OSMO_ASSERT for bts within count_codecs()

Change-Id: Ib49c7c337980a7d6f189d7a0551ca2e4c3822f45
2016-10-27 10:17:58 +00:00
Max 582e4f6276 Replace magic number with define
Value 4 used as magic number by both OpenBSC and OsmoBTS so it make
sense to add it to shared header. See
ebb483b69a5319e522ba5f713e9cb6f68a814a6a in osmo-bts for details.

Change-Id: I9c6ad68f4c6aa72d39ec7e5a6968b36ec20e79f4
2016-10-18 16:19:33 +02:00
Alexander Couzens fbd96f55fd fix mistypes, spaces and tabs
Change-Id: I651473f638365bbd333c4c80d223cdd023dd2c51
2016-10-14 12:20:25 +00:00
Neels Hofmeyr 39ae17fb69 msgb ctx: use new msgb_talloc_ctx_init(), don't access talloc_msgb_ctx
Drop extern definitions of talloc_msgb_ctx and use msgb_talloc_ctx_init()
instead.

In sgsn_test.c, use a local variable msgb_ctx to do the talloc report
from the return value of msgb_talloc_ctx_init().

Change-Id: I2f9ace855f0ecbdc9adf5d75bcb1a3d666570de4
2016-10-13 13:14:41 +00:00
Neels Hofmeyr 4c2d4ab5db msgb talloc ctx: initialize in all main() scopes
Add msgb_talloc_ctx_init() call to many main() functions still lacking a
msgb talloc context.

Change-Id: Ib0d6751260659cabf18a7ce80680ba2fb4228ea1
2016-10-13 13:14:41 +00:00
Neels Hofmeyr e072da9d2e gtphub_test.c: remove unused include of msgb.h
Change-Id: I7a8003a0e0bff803941d7981ffc07cf78c3ae9a9
2016-10-13 13:14:41 +00:00
Neels Hofmeyr 20436c8506 meas_pcap2db.c: remove unused include of msgb.h
Change-Id: I2197432c9482537bd5cf06a6c4fc912607ffab53
2016-10-13 13:14:41 +00:00
Neels Hofmeyr 30f7310a62 bs11_config: initialize bs11 tall ctx, use instead of bsc ctx
Actually initialize tall_bs11cfg_ctx as named const.

Change-Id: I3b42b29cd1a688cb4c9d1d4e44208509d936e4ef
2016-10-13 13:14:41 +00:00
Neels Hofmeyr 3edd0b03d5 ipaccess-config: initialize root talloc ctx with name
tall_ctx_config is defined but remains NULL. Instead initialize as named
const.

Change-Id: Iec708eda2e4f8eb88b9e5bc5f82f6342709760b1
2016-10-13 13:14:41 +00:00
Max b6591072d8 Log use of incompatible BS-AG-BLKS-RES value
There's "channel-descrption bs-ag-blks-res" vty command which sets
BS-AG-BLKS-RES which might be too high if CCCH is combined with
SDCCHs. Previously proper value was silently enforced. Log this
situation explicitly and add spec reference to the comment.

Change-Id: I53e2b881fc28472d6709f063fb265a4e6a0fffcd
2016-10-13 08:35:24 +00:00
Neels Hofmeyr f1a56dea7b jenkins.sh: use osmo-build-dep.sh, log test failures
Like in libosmo-abis' jenkins.sh

Change-Id: I4d6ffd5b230dd095650cc2231678b66056a8e4b5
2016-10-12 11:29:22 +00:00
Max 1e646f02f4 DTX DL: use FSM for AMR
- consolidate all DTX-specific things in a separate struct
- rename struct fields to better reflect meaning
- add pointer to DL FSM for AMR
- remove unused flag
- expand buffer to hold cached payload alongside with CMR/CMI

Change-Id: Idac8609faf9b5ced818fde899ccfc6ed0c42e8fd
2016-10-12 11:22:22 +00:00
Neels Hofmeyr 756fb30c8a gsm_trx_name(): don't break if trx is NULL
Just as a general precaution deemed to fit such a convenience function that
lives in libcommon, no actual failure observed.

Change-Id: I8e77fe1abc402469fd037e2fde2f46e2c8114f59
2016-10-10 03:26:36 +02:00
Neels Hofmeyr a6ba6a370b abis_rsl_rx_dchan(): guard against lchan_lookup() returning NULL
Found this by coincidence, no actual failure case was observed.

lchan_lookup() does have a return NULL code path, so we should not blindly use
its returned pointer.

Change-Id: I34ce126d36420b8194c88c0faa865294334a6658
2016-10-10 03:24:09 +02:00
Neels Hofmeyr 5275c152e5 Revert "bsc: count the usage of codec by setting the lchan active"
This reverts commit 38e9ea3f7f.

Introduced a reproducable segfault, because msg->trx is not actually set/used
in the openbsc code paths.

 Program received signal SIGSEGV, Segmentation fault.
 count_codecs (lchan=0x1, bts=<optimized out>) at ../../../src/libbsc/abis_rsl.c:104
 104                             rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_CODEC_V1_FR]);
 (gdb) bt
 #0  count_codecs (lchan=0x1, bts=<optimized out>) at ../../../src/libbsc/abis_rsl.c:104
 #1  0x0000000000425661 in abis_rsl_rx_dchan (msg=<optimized out>) at ../../../src/libbsc/abis_rsl.c:1516
 #2  abis_rsl_rcvmsg (msg=0x8143f0) at ../../../src/libbsc/abis_rsl.c:2611
 #3  0x00007ffff71420d0 in handle_ts1_read (bfd=<optimized out>) at ../../src/input/ipaccess.c:271
 #4  ipaccess_fd_cb (bfd=0x815af8, what=1) at ../../src/input/ipaccess.c:386
 #5  0x00007ffff7779b62 in osmo_fd_disp_fds (_eset=0x7fffffffe590, _wset=0x7fffffffe510, _rset=0x7fffffffe490) at ../../src/select.c:149
 #6  osmo_select_main (polling=polling@entry=0) at ../../src/select.c:189
 #7  0x0000000000406fac in main (argc=<optimized out>, argv=0x7fffffffe738) at ../../../src/osmo-nitb/bsc_hack.c:385
2016-10-10 02:33:59 +02:00
Max 2d66bb2099 DTX: add flag for AMR HR P*
Add flag to explicitly track the state of DTX DL for AMR HR whe
SID_FIRST_P1 has been sent to L1 already but no next frame available
yet: this can be followed by SID_FIRST_P2 or SID_FIRST_INH depending on
arrival of voice frame within next 60 ms.

Change-Id: Id28b07b8e83cfe5e84de48a2f124084036580cd4
2016-10-05 05:48:16 +00:00
Max 63c18ca791 DTX: extend SID cache
In addition to RTP payload SID cache got to store CMR/CMI prefix. Extend
the buffer so it can fit in.

Change-Id: Ibd4a63604a82cad3ce65f0752bffefa4b083e1b3
Fixes: Coverity CID#149508
2016-10-05 05:48:11 +00:00
Alexander Couzens 3316397921 gprs/gprs_llc: count UI frames over SAPI in the statistics
Change-Id: I5f38d70e046ce9ca1342e6f862329dc3cded8995
2016-10-04 17:53:21 +02:00
Alexander Couzens 92f552f344 msc: add counters to track call attempts/active/success/failed
active_calls describe all calls in active state.
call.complete Call got terminated by disconnect requested either by MS or MSC.
call.incomplete Call got terminated by any other reason.
call.active Calls reached active state.
Change-Id: I49b93af2e6a0ba16c2fb00b7b83974e8a6a16df3
2016-10-04 01:08:12 +02:00
Alexander Couzens 38e9ea3f7f bsc: count the usage of codec by setting the lchan active
we count the codec when the channel was successful setted up

Change-Id: Ifc8a406a11dce16b9e7f3310841e470545550a2c
2016-10-04 00:55:05 +02:00
Neels Hofmeyr a8f91df851 configure: check for pkg-config presence
Change-Id: I1484fc8b870df6f0aeef0c13078c66d0cfa97e75
2016-10-01 01:01:53 +02:00
Neels Hofmeyr b81031292b build: be robust against install-sh files above the root dir
Explicitly set AC_CONFIG_AUX_DIR.

To reproduce the error avoided by this patch:

  rm install-sh        # in case it was already generated.
  touch ../install-sh  # yes, outside this source tree
  autoreconf -fi

This will produce an error like

  ...
  configure.ac:16: error: required file '../ltmain.sh' not found
  configure.ac:5: installing '../missing'
  src/Makefile.am: installing '../depcomp'
  autoreconf: automake failed with exit status: 1

See also automake (vim `which automake`) and look for 'sub locate_aux_dir'.

Change-Id: I3b6d9ad4e5af44c2bdf3844c7bf8e8517bd61d8e
2016-10-01 01:01:53 +02:00
Philipp Maier ea291e3004 SGSN: Fixing build config
Tests for V.42bis, slhc, llc-xid and sndcp-xid are built and
executed on all build configurations, but are only needed when
the sgsn (gprs) is built. This patch adds conditions check
if the tests mentioned abvove are needed or not.

Change-Id: I6921e6198ea7f99fe5276f91cbc522091853bc4e
2016-09-30 12:42:48 +00:00
Neels Hofmeyr 0867b72055 vty_test_runner.py: fix indents to use spaces, fix vim comment
Most of this file uses four spaces of indenting. Replace all tabs with spaces.

Remove the erratic 'set' from the recently added vim comment at the bottom.

Change-Id: I4273b3314defb1e5b31b509c2ac7d7c6cd6834cf
2016-09-30 12:42:20 +00:00
Neels Hofmeyr 0a45c1e77d vty_test_runner.py: make unittest print all output by default
Add option to TextTestRunner that shows print output on stdout.
It's better to see everything in our jenkins runs and not hide test output.

Change-Id: If4be1ad1c81c9ed4ab9b208b4c6d1e4b2cc8fdd5
2016-09-30 12:42:20 +00:00
Neels Hofmeyr aba82097b6 log CTRL bind only once
After libosmocore 38d232ee5d2ceb045d9ad6d3a23afcb4972523f7 which outputs
'CTRL at <ip> <port>' from ctrl_interface_setup_dynip(), there's no need to log
the CTRL bind here anymore.

Change-Id: I1a874efe365a1ecf8ec37b058215b95b9a635ec2
2016-09-30 03:12:46 +02:00
Neels Hofmeyr c6a44bbab9 fix: send SNDCP XID only on GERAN Gb contexts
Add a condition for GERAN Gb.

SNDCP and IuPS were developed on separate branches, and the merge results in
code trying to use an llme on a UTRAN Iu context where the llme is NULL,
leading to stack corruption upon PDP ctx act.

Change-Id: Ibb20d738c1b64d36630ce8eceb54c33ba4f1b003
2016-09-29 03:24:57 +02:00
Neels Hofmeyr caeb62d7ff vty_test_runner.py: fix nat_msc_test(): socket attach: reduce timeout, retry
In nat_msc_test(), upon socket timeout, retry up to six times. Reduce the
timeout between retries. This should get rid of sporadic test failures that
we've been seeing a lot on jenkins lately.

Raise an exception upon unexpected vty response.

Print more detail to stdout. Since we would actually want as much output as we
can get in a test suite, remove the 'if (verbose)' and just always print the
connection source. unittest is keeping all stdout silent by default anyway.

Change-Id: I2f83eef55592778e54164a90e1eabeb80fb918da
2016-09-28 23:53:24 +02:00
Harald Welte 7e5bb6283d COSMETIC: 'if' is not a function, so there is space before '('
Change-Id: Ic22623dffce998d70a3c67aa6e445de98f558ed7
2016-09-28 00:47:28 +00:00
Neels Hofmeyr 3ea9fece6d cosmetic: bs11: also use ts_is_tch()
Use the recently added ts_is_tch() function instead of an explicit switch to
determine TCH pchan types. This is a cosmetic change since the bs11 does not
support dynamic channels (which was the main motivator behind ts_is_tch()).

Change-Id: Idf8ce51c76a83210fe3d70e18c51bbaffebb8ad5
2016-09-28 00:28:01 +00:00
Neels Hofmeyr 255dbfe655 dyn TS: fix: e1_config.c: switch(pchan) for dyn TS
Add ts_is_tch() in gsm_data_shared.h/.c and use it to replace a switch on the
pchan in e1_config.c.

This patch is not due to an actual observed failure. A general grep for switch
on pchan turned up this instance that doesn't handle dyn TS properly. Hence
this patch is not actually tested with real equipment.

Change-Id: Ide4f156034bab77140d2d9a8c462d68ae6f0d6a6
2016-09-28 00:28:01 +00:00
Neels Hofmeyr 23c3aa37ac dyn TS: fix: abis_om2000: also handle dyn TS as TCH
Add ts2comb() to switch on dyn TS so that dyn TS in TCH mode are also treated
like normal TCH/H or TCH/F pchans. Use ts2comb() instead of pchan2comb().

Change-Id: Iddc51a4409488d91db59228ca66aaab73ce3f1df
2016-09-28 00:28:01 +00:00
Neels Hofmeyr c3f72f63af dyn TS: fix: ts_subslots() for TCH/F_PDCH in PDCH mode
In gsm_data_shared.c, add ts_pchan() to determine actual pchan type for dynamic
and non-dynamic TS.

Use in ts_subslots() to fix the value returned for TCH/F_PDCH in PDCH mode.
Adjust the assertion in channel_test.c accordingly.

Drop GSM_PCHAN_TCH_F_PDCH, which is now handled in ts_pchan().
Explicitly add GSM_PCHAN_PDCH as zero in subslots_per_pchan[] (cosmetic).
Adjust the comment in subslots_per_pchan[].

The fix for the number of subslots affects only one caller: bts_chan_load() in
chan_alloc.c. Before this, it would always include a TCH/F_PDCH in the
load_counter->total, now it is skipped when in PDCH mode. Whether this is the
way bts_chan_load() should handle dynamic TS is a separate discussion, so far
I'm only making sure that the two dyn TS kinds act in the same way:
TCH/F_TCH/H_PDCH is only counted when in TCH mode, and TCH/F_PDCH should match.

Change-Id: Icd6668667ad2be7ad20866ffd185bf3b8711ccd6
2016-09-28 00:28:01 +00:00
Neels Hofmeyr 2afffd5cf6 Revert "bts: extend bts_chan_load to allow counting tch only"
This reverts commit 308cb0719d.

Problems in this commit:

openbsc/src/libbsc/chan_alloc.c:523:   case GSM_PCHAN_TCH_F_PDCH:
This is actually wrong, GSM_PCHAN_TCH_F_PDCH use ts->flags, not ts->dyn below
(due to historical reasons and could be unified).

560:   if (only_count_tch && !chan_is_tch(ts))
This has exactly one effect: it excludes GSM_PCHAN_TCH_F_PDCH when in PDCH
mode, because for all other PDCH (plain PDCH and TCH/F_TCH/H_PDCH in PDCH mode)
below ts_subslots() returns 0 and skips the for() loop. I consider this a bug
in TCH/F_PDCH, to be fixed in an upcoming commit.

I don't see why we need the only_count_tch argument, because this should
normally only count TCH, weren't it for the TCH/F_PDCH bug.

If dyn TS should be counted differently, we should do this in a different way.

Change-Id: I34dbbaf53a800115e3d03bd44028cad675f3b525
2016-09-28 00:28:01 +00:00
Neels Hofmeyr e289a2a86a channel_test: test nr of subslots for dyn pchan, with error
Add test_dyn_ts_subslots() and call from main(). Update channel_test.ok.

This includes erratic assert to show a bug for TCH/F_PDCH in PDCH mode: the nr
of subslots should be the same as for a normal PDCH, i.e. zero. This will be
adjusted along with the fix in an upcoming commit.

Change-Id: I09685be3fb3ed1ead4577b772a9fbc31967980d1
2016-09-28 00:28:01 +00:00
Neels Hofmeyr 8d878e8a28 channel test: prepare to add another test function
Move the main() guts to test_request_chan(), so that I can add another test in
an upcoming commit.

Change-Id: I1349d0f416806416080d4667ad697f7db1ea252d
2016-09-28 00:28:01 +00:00
Neels Hofmeyr 57e8a1fee0 cosmetic: comment typo on e1_config.c
Change-Id: I894adf562670abf26665a1eb09592682ab8b31b5
2016-09-27 09:59:39 +00:00
Philipp Maier 3163f336f2 SLHC: Improving slhc (RFC1144) testcase
- Adding Testcases for  UNCOMPRESSED_TCP and TYPE_IP
- Minor cosmetic changes

Change-Id: I555fa3c9b9f78424102f359ef1c27b290fa9c9e9
2016-09-27 05:52:20 +00:00
Neels Hofmeyr dab3e34d0b 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: I97a730b28759df1d549a5049f47a3da1c16a3447
2016-09-27 05:00:18 +00:00
Neels Hofmeyr 89d20b60ef vty_test_runner.py: raise exception when MSC socket connection fails
Instead of below error, raise an exception to describe what's happening.

Seen in a jenkins run on https://gerrit.osmocom.org/#/c/945/2:

ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 787, in testBSCreload
    msc = nat_msc_test(self, ip, port)
  File "./vty_test_runner.py", line 1251, in nat_msc_test
    return conn
UnboundLocalError: local variable 'conn' referenced before assignment

Change-Id: Iae26e7345267a21aed0b108b089453832889c9fa
2016-09-26 13:00:35 +02:00
Neels Hofmeyr 23d37c91af cosmetic: vty_test_runner.py: add comment for vim auto settings
Change-Id: I61a0476a0317b011432bb4f6f593cfdcaf1c072b
2016-09-26 13:00:35 +02:00
Neels Hofmeyr a9f2bb5ab8 mscsplit: directly access gsm_network backpointer from gsm_subscriber_connection
The previous commit added a network backpointer to gsm_subscriber_connection.
Use it wherever it makes sense, to skip the step through the bts structure.

In some places, remove local variables that become unused.

Change-Id: I34537025986713291e14c8212a81539b497befd4
2016-09-26 02:25:46 +02:00
Neels Hofmeyr 5e0b0a658f mscsplit: add gsm_network backpointer to gsm_subscriber_connection
We want to be able to use a network backpointer without having to go through a
gsm_bts struct.

This commit adds the network pointer, the subsequent commit applies direct
access to the network structure from gsm_subscriber_connection.

Change-Id: If8870972f1b3e333c2a4cce97cdc95bdee0382a1
2016-09-26 02:25:46 +02:00
Neels Hofmeyr 663debcb90 mscsplit: abis vty: decouple from global bsc_gsmnet variable
Publish gsmnet_from_vty() in openbsc/vty.h and use in the abis VTY functions.

Change-Id: Ib65a18db06b8bc4fc7d56bf56dd64a52cc1cd253
2016-09-26 02:25:46 +02:00
Neels Hofmeyr 43d86bfc94 mscsplit: bsc_vty_init(): decouple from global bsc_gsmnet
Add an explicit gsm_network pointer instead of using the bsc_gsmnet global.
This allows passing a gsm_network struct from the main() scope, which helps to
decouple libmsc from libbsc.

Change-Id: I9e2c0d9c18d4cebb5efb71565ad84df2bc2e0251
2016-09-26 02:25:46 +02:00
Neels Hofmeyr c13e687742 mscsplit: talloc_ctx_init(): decouple from global tall_bsc_ctx
Decouple the talloc context allocations from global tall_bsc_ctx pointer.

It appears that talloc_ctx_init() was intended for general use, since it is
located in libcommon. It is currently used only by osmo-nitb; but the upcoming
osmo-cscn will use it as well.

Instead of defining in osmo-nitb main file, add definition in gsm_data.h.

Change-Id: I168106599b788f586be0ff0af4699b9746c1b103
2016-09-26 02:25:46 +02:00
Neels Hofmeyr 77c8d5ffb5 mscsplit: gsm_network_init(): add explicit root talloc ctx
Decouple the root talloc context from libbsc's global talloc_bsc_ctx.

This allows to define the root talloc ctx from a main() scope, which in turn
helps decouple libmsc from libbsc.

Change-Id: I92f6b47b1eeea2e8f3fba66f25d7e708e5659f8a
2016-09-26 02:25:46 +02:00
Neels Hofmeyr d90fa42dc9 mscsplit: move subscriber conns list into struct gsm_network
Replace the global sub_connections llist with gsm_network.subscr_conns.
Initialize and apply where applicable.

Remove bsc_api_sub_connections(), callers now access gsm_network->subscr_conns
directly.

This allows using the subscr_conns from libmsc without having to link libbsc.

Change-Id: Ice2a7ca04910bcfaaff22539abe68a6349e8631c
2016-09-26 02:25:46 +02:00
Neels Hofmeyr 0ce98c749a mscsplit: bsc_init: don't pass telnet dummy conn
We want to create the telnet for VTY only after reading the config file, and
the dummy_conn was a workaround to be able to do so, but is not needed:
gsmnet_from_vty() used to expect vty->priv to point to a gsm_network struct,
but that is not actually the case anymore. It is using a static pointer to
store the gsm_network struct instead.

Change-Id: I51e7224c5a4cd5baf564bee871cf2fa6e885cda7
2016-09-26 02:25:46 +02:00
Philipp Maier 73f83d533b SNDCP: add V.42bis data compression functionality
- Add compression control for V.42bis Add code to handle compression
   (gprs_sndcp_dcomp.c/h)
 - Add Adjustments in SNDCP
 - Add VTY commands

Change-Id: I6d36cbdf2f5c5f83ca9ba57c70452f02b8582e7e
2016-09-24 03:17:59 +00:00
Philipp Maier d8b45778de V.42bis: integration and unit test
- Edit previously committed V.42bis implementation to function
   outside IAXmodem.
 - Add unit test to verify the correct function of V.42bis

Change-Id: I689413f2541b6def0625ce6bd96f1f488f05f99d
2016-09-24 03:17:59 +00:00
Philipp Maier 0b11db7e9f V.42bis: add sourcecode from IAXmodem (SPANDSP)
V.42bis is a data compression method found in modems. It has also
been specified for GPRS as data compression algorithm.

The implementation has been taken from IAXmodem:

https://sourceforge.net/p/iaxmodem/code/HEAD/tree/
svn checkout svn://svn.code.sf.net/p/iaxmodem/code/ iaxmodem-code
Revision: r36

Change-Id: Iabedece9f97ca944a1e3f747bb073e532c4e9dca
2016-09-24 03:17:59 +00:00
Philipp Maier f1f34360fb SNDCP: add RFC1144 header compression functionality
- Add module to handle compression entities
- Add module to control header compression
- Introduce VTY commands for heade compression configuration
- Add changes in sndcp and llc to integrate header compression

Change-Id: Ia00260dc09978844c2865957b4d43000b78b5e43
2016-09-24 03:17:58 +00:00
Philipp Maier 2c7f83762a RFC1144: integration and unit-test
The previously pushed slhc implementation has been modified to compile
and function outside of the kernel. Also debug log messages were added
and datatypes ware matched. The implementation is now ready to be used

Change-Id: I7a638e88a43b3eb9d006751a03ef2570e36613f0
2016-09-24 03:17:58 +00:00
Philipp Maier b3e116c74d RFC1144: add slhc code from linux kernel
SLHC is an Implementation of RFC1144 TCP/IP header compression. We will need
RFC1144 compression to compress GPRS TCP/IP traffic. The implementation pushed
with this commit was taken from:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
commit 29b4817d4018df78086157ea3a55c1d9424a7cfc

Change-Id: Ied69c143678dc4a64cecc671f5c4dfebe19d8519
2016-09-24 03:17:58 +00:00
Philipp Maier 22611be3d9 SNDCP: add SNDCP-XID encoder/decoder and unit test
The SNDCP-XID (or layer-3 xid) is used to exchange layer-3 parameters
such as compression. The encoder encodes a bytestream that is then
sent as regular XID field from LLC.

We will need the SNDCP-XID to negotiate the parameters for our
upcomming GPRS data and header compression features

Change-Id: If2d63fe2550864cafef3156b1dc0629037c49c1e
2016-09-24 03:17:58 +00:00
Alexander Couzens 308cb0719d bts: extend bts_chan_load to allow counting tch only
Change-Id: I86f1d502649747b6b9aefcb39081b14110e8f494
2016-09-23 02:43:12 +00:00
Neels Hofmeyr 7c359eb4b4 cosmetic fixes in libcommon/talloc_ctx.c
Add copyright notice, remove obsolete include, remove unneeded line break.

Change-Id: I4d06a0323aee5a003b06edd179fc61e1936acae5
2016-09-22 21:11:42 +02:00
Neels Hofmeyr 8ce66fd19e cosmetic: transaction.h: 1 comment typo, 1 whitespace
Change-Id: Ia2629f9d9887b50b25c6996531b7ef518fb33335
2016-09-19 11:51:12 +00:00
Neels Hofmeyr 1e918c3d31 debug log for sms: fix/add
One logged the wrong function name. Add others.

Change-Id: Ied5d8e84d5d192c826bc131be8907eaa55190479
2016-09-18 23:40:06 +02:00
Neels Hofmeyr ffaed9eed2 Sanity fixes for gsm0408_dispatch(): rc, assertions
gsm0408_dispatch() is the main entry point for receiving data from the BSC/RNC
level, so make sure callers pass valid pointers before using them all the way
down the code path (related to CID#93769, a fix before this was refactored).

For unknown/unimplemented packet discriminators, make sure to return error
codes.

Change-Id: Ieec39c74a53ef4dfa971dd935c8c9aa60fef58c1
2016-09-18 23:40:06 +02:00
Neels Hofmeyr 378a492fd9 cosmetic: various comment, whitespace tweaks
Change-Id: I131939cfba4d67d7e2c935341deeb14d09523fee
2016-09-18 23:40:06 +02:00
Neels Hofmeyr 0b607297e6 utils/Makefile.am: remove unused LIBOSMOVTY_CFLAGS
Change-Id: Id1152b105bb7364a06d9720829d39f587242b707
2016-09-18 23:40:04 +02:00
Neels Hofmeyr d1fdefedf1 vty l3 help: fix typo 'comamnds'; fix english s/his//
Change-Id: I6be52bbb69de8aa0a6d57a3a320661ad85fc2cc4
2016-09-18 23:35:49 +02:00
Neels Hofmeyr 6d82c351b9 remove unused bsc_copyright from bsc_vty.c
Change-Id: I281791c0f57ca75ffe14431a3030811b2d224f0b
2016-09-18 23:35:49 +02:00
Neels Hofmeyr ab04fb2d50 properly #include <openbsc/gsm_data.h> from gsm_subscriber.h
Don't use quoted, local include, use <> style include.

Cosmetic: also move stdbool.h include to the top to keep osmocom and openbsc
includes grouped.

Change-Id: Iaa3dc36768f96f6b8c91010a2ba389fdc37f1503
2016-09-18 23:35:49 +02:00
Max 292ec58e67 Modify SI 13 field for control_ack_type
Add vty function to explicitly set use of 4xRACH type of ack message for
PACKET CONTROL ACKNOWLEDGMENT. Previous hardcoded value (use RLC/MAC
control block) is used as a default.

This is handy for debugging issues related to Timing Advance in context
of GPRS.

Change-Id: Ie869ac0a82055110f1e3b875e246750c4e113336
Related: OS#1526
2016-09-17 10:00:58 +00:00
Neels Hofmeyr 2867f883a1 log causing rx event for lchan_lookup errors
Add log_name to lchan_lookup() and pass such from the various RSL rx events
that call it to validate the RSL chan_nr.

Change-Id: Id81e7b8b9c27831923f050a78dfc7d650e687033
2016-09-17 09:58:54 +00:00
Neels Hofmeyr b3d8706bea log: abis_rsl: don't log 'error' when there is no error
The message 'RF Channel Release due error 0' keeps catching my eye because
it says 'error' even though the error code is zero, i.e. no error.
This shall end now.

Change-Id: Ie0b9d62e8ce85a096c963931e0ae5527b8dc490a
2016-09-17 09:58:53 +00:00
Alexander Couzens aa386d29fd sms: change rp err cause of smpp_try_deliver errors
smpp_try_deliver could fail with rc < 0. In such cases don't send the MS the rp
error sms rejected (cause 21). A rejected message should not be sent again. The
spec 04 11 recommends sending cause 41 Temporary failure in unknown cases.

Add also a log message and rate counter for such cases.

Tweaked-By: Neels Hofmeyr <nhofmeyr@sysmocom.de>
Change-Id: Ia03e50ce2bd9a7d1054cc5a6000fd73bd3497c03
2016-09-17 08:45:07 +00:00
Alexander Huemer c2f2ad8a5f Build fixes
Some fixes for build environments where dependencies are installed in
distinct directories.

Change-Id: I38808fd2911747b266ee6fde91187a88dd7ae355
2016-09-15 16:02:18 +02:00
Alexander Huemer 7b6673fa06 Consistenly format variables in */Makefile.am files
Change-Id: Ifa21513c007072314097b7bec188579972dc1694
2016-09-15 15:55:02 +02:00
Alexander Couzens 58f446ca08 gprs/gprs_llc: fix null pointer deref in gprs_llc_rcvmsg
Change-Id: I1f7e1d524042134c93a4f3de599c54d442447512
2016-09-05 13:36:01 +00:00
Alexander Couzens a173566b35 gprs/gsm0408_gprs_force_reattach_oldmsg: check llme before use
Change-Id: I9385655872c4dcf46aa1d18bcc47b84aba2f34f7
2016-09-05 13:36:01 +00:00
Daniel Willmann 21b269f814 IuPS: Change GTP-U endpoint to SGSN in PMM_IDLE and page UE when data arrives
Change-Id: I47b73a40cbdda6b7c31fb2767f74f9f93d84056b
2016-09-02 04:29:36 +02:00
Daniel Willmann c17cdb40b5 IuPS: Introduce function to change PMM state
This is where IuPS will redirect GTP-U endpoints in a subsequent commit.

Also add comprehensive logging of pmm_state transitions.

Change-Id: I7c2cd1abc1805659b01dffffff31c49fe5161086
2016-09-02 04:29:21 +02:00
Daniel Willmann fac9758820 IuPS: GMM Attach: reset MM ctx pending_req
Change-Id: I0df0f3d88085939eb617405e2013ad164eed477b
2016-09-02 04:29:15 +02:00
Daniel Willmann 5b2363ebb2 IuPS: sgsn_mm_ctx: add enum gprs_pmm_state field, track PMM state
Iu needs to page to transfer data in PMM-IDLE state.

Change-Id: Id37778cb9a0328a21c8e8246998ecdb43dd687d8
2016-09-02 04:29:01 +02:00
Daniel Willmann af241727a9 IuPS: RA UPD: make sure to authorize, for Iu Integrity Protection
Change-Id: I2ea2089895f8a8e125ef39d9bef70dafb2b1ce69
2016-09-02 04:28:49 +02:00
Daniel Willmann 1dee2b6e96 IuPS: add GMM Service Request rx and tx
Change-Id: Ib935de22d23a15f449927840d4d59497ce22abbd
2016-09-02 04:28:41 +02:00
Daniel Willmann 3ecfbbba6f IuPS: send Security Mode Command, track the new_key flag.
Change-Id: I0b2593c2df13b79eb36975b0d302e31cfdf8bb09
2016-09-02 04:28:31 +02:00
Daniel Willmann 770f3e32e0 IuPS: dev hack: init hardcoded Ki on ATT REQ
DEVELOPMENT HACK: Our current HLR does not support 3G authentication tokens.  A
new HLR/VLR implementation is being developed. Until it is ready and actual
milenage authentication is properly supported, we are hardcoding a fixed Ki and
use 2G auth.

Change-Id: Ieca45960fa941a3a706c6e479b04b9f2ef89d860
2016-09-02 04:28:16 +02:00
Daniel Willmann 7bc6986f6b IuPS: add Iu response to delete_pdp_conf()
Change-Id: I6d601586101c0a004b2243633fab48db82b44b7c
2016-09-01 23:44:45 +02:00
Daniel Willmann 6b7b319d54 IuPS: add Iu response to create_pdp_conf()
Change-Id: Iad65ca9b77c3166d4df9a58af527e6aef7e589ee
2016-09-01 23:44:45 +02:00
Daniel Willmann 61329d45b8 IuPS: redirect Iu in various places, link Iu in sgsn-test
In gsm48_gmm_sendmsg(), redirect to iu_tx() for both cases of MM context
present or not.

In gsm48_rx_gmm_att_req(), compose an MM context marked as Iu for messages
coming in from a ue_conn_ctx (passed in msg->dst). Also make sure cid is
initialized to avoid introducing a compiler warning.

In gsm48_rx_gmm_ra_upd_req(), look up an Iu MM context based on the presence of
the ue_conn_ctx in msg->dst.

In sgsn-test, add libiu and libasn1c, libosmo-sigtran, libosmo-ranap, which are
now needed for an --enable-iu build.

Change-Id: Ia47ffbfa6fa0f5a0cd76a379c57ef42faa0d80e3
2016-09-01 23:44:45 +02:00
Daniel Willmann 6292c8d44d IuPS: osmo-sgsn: add core IuPS impl, call iu_init()
Add main Iu entry points for IuPS:
* gsm0408_gprs_rcvmsg_iu()
* sgsn_ranap_iu_event()
* sgsn_ranap_rab_ass_resp()

Add main MM context management for IuPS:
* sgsn_mm_ctx_by_ue_ctx()
* sgsn_mm_ctx_alloc_iu()

Call iu_init() from sgsn_main.c.

Add asn_debug impl ("extern" from libasn1c).
Initialize asn_debug VTY command (iu_vty_init()).

osmo-sgsn build: add libiu and libasn1c, libosmo-sigtran, libosmo-ranap

Change-Id: I469ae6ca9ef254d04ee0d2d79bdd65aebcd027b5
2016-09-01 23:41:10 +02:00
Neels Hofmeyr 9bc42ec47b IuPS: add VTY config for asn_debug
Add file iu_vty.c in libiu, and iu_vty_init() to initialize the new VTY
command:

  log
   logging asn1-debug (1|0)

Change-Id: If4e7d0ab3fc2ed0cdf4fb0a3fa077a9e34890918
2016-08-31 11:11:07 +00:00
Harald Welte 7e82ad20fa osmo-nitb: generate backtrace on SIGABRT
As the NITB has an internal SIGABRT handler that prints a talloc report,
let's also print a stack backtrace at the same point.

Change-Id: Ia63aa5c39b26e27c3ee220d755c17d2c1ef636c5
2016-08-31 11:07:35 +00:00
Alexander Couzens 4b95b5401c bsc/netinit: correct mistyped rate counter
Introduced by b847a21fa4

Change-Id: I57c41f98e3826951a5071b005cb640c23d466477
2016-08-30 14:39:43 +02:00
Alexander Couzens b847a21fa4 libmsc/bsc: split rate counters into bsc and msc group
Tweaked-By: Neels Hofmeyr <nhofmeyr@sysmocom.de>
Change-Id: I7361033cd1eb919ec3c2ea2652f40ab8c75b2f99
2016-08-29 18:56:20 +02:00
Daniel Willmann d75864f6f5 IuPS: track msg->dst aka ue_conn_ctx, comment
For Iu connections, msg->dst will point to the ue_conn_ctx, and we need to make
sure to keep msg->dst intact when copying from/to msgb and from/to MM context.

Change-Id: I90c7ca6c3655d447aaca958e0086ae6ce6f6045a
2016-08-27 13:29:33 +02:00
Daniel Willmann 746c7896cb gprs_gmm: Fix bit mask when determining update/attach type
Bit 4 is reserved in 3GPP TS 04.08 so exclude it from the type.

In 3GPP TS 24.008 it indicates if a follow-on request is pending by the
MS, but only in Iu mode. According to the spec it is not required to
react to that request with a follow-on proceed so this field can be
ignored for now.

See 3GPP TS 24.008 Ch. 4.4:
"Unless it has specific permission from the network (follow-on proceed)
the mobile station side should await the release of the RR connection
used for a MM specific procedure before a new MM specific procedure or
MM connection establishment is started."

as well as Ch. 4.4.4.6:
"If the network wishes to prolong the RR connection to allow the mobile
station to initiate MM connection establishment (for example if the
mobile station has indicated in the LOCATION UPDATING REQUEST that it
has a follow-on request pending) the network shall send "follow on
proceed" in the LOCATION UPDATING ACCEPT and start timer T3255."

Change-Id: If1dff960c406060e257dafc54132687ffc42ad8f
2016-08-27 13:29:33 +02:00
Neels Hofmeyr f4daf16c8d cosmetic: gprs_sgsn.c: move pdp.h include to top
Change-Id: I9a9b34d714235462ba72cdb65b7c8c9824dfa9c6
2016-08-27 13:29:33 +02:00
Neels Hofmeyr bfa8878a07 add libiu
Co-Authored by dwillmann, laforge, nhofmeyr

Change-Id: Iffc26f9c73cb15463948f7435b72ac1747aabdb3
2016-08-27 13:29:30 +02:00
Philipp Maier 4ac3aee711 Adding LLC-XID related modifications in LLC
With this commit the already existing XID mechanism has been
modified to suit the needs for the upcomming SNDCP-XID patches.

This commit should not break anything since it does not alter
the current behaviour (incoming XID is still just echoed, on
GMM-Reset a basic XID message is still echoed)

Change-Id: I65b9d625e72d3d61c99abdc7041773701d694d52
2016-08-27 04:45:55 +00:00
Philipp Maier 3ec03d5048 Moving grs_sndcp.h header file to include
For some reason gprs_sndcp.h is located in src/gprs. This commit moves
gprs_sndcp.h to include/openbsc and fixes the include path in
gprs_sndcp.c and gprs_sndcp_vty.c

Change-Id: If4e4f1252c81d7907c1b4d738c982bb172b128c9
2016-08-27 04:45:55 +00:00
Philipp Maier a536fc644b Adding LLC-XID encoder / decoder and unit test
The lle-xid encoder/decoder is needed to encode and decode llc
xid parameter messages. We need this to exchange sndcp-parameters
(SNDCP-XID) and also simple parameters such as encryption IOVs

Change-Id: Ia06e4cb08bf9b48c2a4682606d1b1a91d19a9d37
2016-08-27 04:45:54 +00:00
Neels Hofmeyr d5d39ae2b6 log: rsl notice: tiny tweak for readability
Change-Id: I57c3b7d27d857c96e3fa3dacf7b766bc43100fc3
2016-08-27 02:23:47 +00:00
Neels Hofmeyr 423269f803 log: improve for rsl_lchan_mark_broken()
In rsl_lchan_mark_broken(), call rsl_lchan_set_state() so the state transition
gets logged in the debug log.

Remove logging for the broken channel at the callers, instead log the error
actually in rsl_lchan_mark_broken() itself, with the reason message passed by
the caller anyway. (Removes code dup and ensures it's always logged.)

Change-Id: I54ae9bbd3f193bae7b1bda1fef3e33e62b353bf5
2016-08-27 02:23:47 +00:00
Neels Hofmeyr baa6c5546e dyn TS: debug log: if still in use, also log lchan type and state
Change-Id: Ifbf31cde24b2d1022b7a472966c17959c96e6dda
2016-08-27 02:23:47 +00:00
Neels Hofmeyr a0a08d80b8 dyn TS: debug log 'switchover complete' only when there was a switchover
Change-Id: I7ddcb41edce1cd7b22fe91e33bdcaedb21856222
2016-08-27 02:23:47 +00:00
Neels Hofmeyr d35fc4408c dyn TS: fix OS#1798: on late RF CHAN REL ACK, activate PDCH
Tested by hacking a REL ACK delay of a couple of seconds into osmo-bts' rsl.c
for the first TCH_H lchan:

[[[
diff --git a/include/osmo-bts/rsl.h b/include/osmo-bts/rsl.h
index 093e9cb..b35c3bb 100644
--- a/include/osmo-bts/rsl.h
+++ b/include/osmo-bts/rsl.h
@@ -22,6 +22,7 @@ int rsl_tx_est_ind(struct gsm_lchan *lchan, uint8_t link_id, uint8_t *data, int
 int rsl_tx_chan_act_acknack(struct gsm_lchan *lchan, uint8_t cause);
 int rsl_tx_conn_fail(struct gsm_lchan *lchan, uint8_t cause);
 int rsl_tx_rf_rel_ack(struct gsm_lchan *lchan);
+int rsl_tx_rf_rel_ack_later(struct gsm_lchan *lchan);
 int rsl_tx_hando_det(struct gsm_lchan *lchan, uint8_t *ho_delay);

 /* call-back for LAPDm code, called when it wants to send msgs UP */
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 3802e25..1f92b0d 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -491,7 +491,16 @@ static int l1sap_info_rel_cnf(struct gsm_bts_trx *trx,

 	lchan = get_lchan_by_chan_nr(trx, info_act_cnf->chan_nr);

-	rsl_tx_rf_rel_ack(lchan);
+	static int yyy = 0;
+
+	DEBUGP(DRSL, "%s YYYYYYYYYYYYYYYYYYYYY %d %s\n",
+	       gsm_lchan_name(lchan), yyy, gsm_lchant_name(lchan->type));
+
+	if (lchan->type == GSM_LCHAN_TCH_H && !yyy) {
+		yyy ++;
+		rsl_tx_rf_rel_ack_later(lchan);
+	} else
+		rsl_tx_rf_rel_ack(lchan);

 	/* During PDCH DEACT, this marks the deactivation of the PDTCH as
 	 * requested by the PCU. Next up, we disconnect the TS completely and
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 3c97af9..7926f21 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -534,6 +534,22 @@ int rsl_tx_rf_rel_ack(struct gsm_lchan *lchan)
 	return abis_bts_rsl_sendmsg(msg);
 }

+struct osmo_timer_list yyy_timer;
+
+static void yyy_timer_cb(void *data)
+{
+	rsl_tx_rf_rel_ack(data);
+}
+
+int rsl_tx_rf_rel_ack_later(struct gsm_lchan *lchan)
+{
+	yyy_timer.cb = yyy_timer_cb;
+	yyy_timer.data = lchan;
+	osmo_timer_schedule(&yyy_timer, 10, 0);
+	return 0;
+}
+
+
 /* 8.4.2 sending CHANnel ACTIVation ACKnowledge */
 static int rsl_tx_chan_act_ack(struct gsm_lchan *lchan)
 {
]]]

Change-Id: I87e07e1d54882f8f3d667fa300c6e3679f5c920d
Fixes: OS#1798
2016-08-27 02:23:47 +00:00
Neels Hofmeyr a2ef7d6477 dyn TS: fix: properly run an lchan activation timeout
Actually schedule an activation timer for the activation part of a dyn TS
switchover. It needs to be restarted because the channel release procedure in
the first part of a switchover actually removes the activation timer.

Change-Id: Ibf50d13ba10298464a8b07e34716763161438990
2016-08-27 02:23:47 +00:00
Neels Hofmeyr b74a2c8e29 dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).

Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.

For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.

Adjust all callers to pass ts instead of lchan.

In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.

In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].

In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.

This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.

Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-27 02:23:47 +00:00
Neels Hofmeyr cd150a8f74 dyn TS: fix error recovery: switch to PDCH after lchan error state
Tested by hacking a CHAN ACT ACK delay of a couple of seconds into osmo-bts'
rsl.c for the first TCH_H lchan:

[[[
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 3c97af9..4bfd27a 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -559,6 +559,22 @@ static int rsl_tx_chan_act_ack(struct gsm_lchan *lchan)
 	return abis_bts_rsl_sendmsg(msg);
 }

+struct osmo_timer_list xxx_timer;
+
+static void xxx_timer_cb(void *data)
+{
+	rsl_tx_chan_act_ack(data);
+}
+
+static int rsl_tx_chan_act_ack_later(struct gsm_lchan *lchan)
+{
+	xxx_timer.cb = xxx_timer_cb;
+	xxx_timer.data = lchan;
+	osmo_timer_schedule(&xxx_timer, 10, 0);
+	return 0;
+}
+
+
 /* 8.4.7 sending HANDOver DETection */
 int rsl_tx_hando_det(struct gsm_lchan *lchan, uint8_t *ho_delay)
 {
@@ -614,6 +630,18 @@ int rsl_tx_chan_act_acknack(struct gsm_lchan *lchan, uint8_t cause)

 	if (cause)
 		return rsl_tx_chan_act_nack(lchan, cause);
+
+	static int xxx = 0;
+
+	DEBUGP(DRSL, "%s XXXXXXXXXXXXXXXXXXXXX %d %s\n",
+	      gsm_lchan_name(lchan), xxx, gsm_lchant_name(lchan->type));
+
+	if (lchan->type == GSM_LCHAN_TCH_H) {
+		if (!xxx) {
+			xxx ++;
+			return rsl_tx_chan_act_ack_later(lchan);
+		}
+	}
 	return rsl_tx_chan_act_ack(lchan);
 }

]]]

Change-Id: Ie82dec9c9fefc476fdf5b5afdad2246b9d6fe304
2016-08-27 02:23:47 +00:00
Neels Hofmeyr 2ae305de46 dyn TS: move check whether to switch to PDCH to separate function
Prepares for an upcoming commit using the same check in error_timeout_cb().

Change-Id: I8abfa964631040f798212cc3e360f67f9e09b7c5
2016-08-27 02:23:47 +00:00
Alexander Couzens 7130683ffe libmsc: add missing count of sms no receiver when using smpp_first
Change-Id: I20ecb3299d67dbaa7b016620685997db49970ffb
2016-08-27 01:58:19 +00:00
Alexander Couzens 20423ea6cf libbsc/libmsc: convert old osmo counter into rate_ctrgs
rate counters support the export to statsd and can have a delta value.

Change-Id: Ie749cebd53a0bb618d0e23d375885712078bf8dd
2016-08-27 01:58:19 +00:00
Alexander Couzens 4e699a9cbf sgsn: add statistics counter for LLC packets
new counters are:

llc.dl_bytes
llc.ul_bytes
llc.dl_packets
llc.ul_packets

The ip payload bytes are waiting for payload compression
because those data are known then.

Change-Id: I068376d35e84283cb98523cd3097a12c55cdb709
2016-08-27 01:27:43 +00:00
Neels Hofmeyr 76a0ad7fe9 move ts_sublots() to gsm_data_shared.c, it will be used by osmo-bts
Change-Id: I8ba06d7dd6e0ceab3d8d18bb565354d6ed461f7e
2016-08-27 01:23:49 +00:00
Neels Hofmeyr 5486025b18 chan_alloc.c: use ts_subslots() instead of subslots_per_pchan[]
The array will move to gsm_data_shared.c; to prepare, use the function
instead.

Change-Id: Icbea7dbd78abf6144e5291f531a97f96507d8cbf
2016-08-27 01:23:49 +00:00
Neels Hofmeyr 3673380cdb dyn TS: bts_chan_load: use correct nr of subslots for dyn ts
For TCH/F_TCH/H_PDCH dynamic timeslots, the ts->pchan does not lead to a
meaningful value from the subslots_per_pchan[] array. Use the ts_subslots()
function instead, which checks for dyn pchan.

Change-Id: I659acebca82dfb3e305433471be64e9d27439af8
2016-08-27 01:23:49 +00:00
Neels Hofmeyr 723f7c7db3 comment: gsm48_gmm_sendmsg(): add spec reference on encryptable
Change-Id: I54a3bc518bc38e38b78f6e9ea3705e4fbd5ffb98
2016-08-22 22:19:13 +00:00
Holger Hans Peter Freyther 91dfa86c18 ci: Attempt to disable doxygen warnings of dependencies
We do not want to see doxygen warnings when building the
libosmocore dependency.

Change-Id: I4640cb5b91d54641e8e5b2f096c3bca49bfff60e
2016-08-15 17:39:28 +00:00
Max 1f6a9ba7e5 Add web proxy for control interface
Add web application exposing Control Interface over web. All of SET, GET
and TRAP are fully supported.

Notice: TRAP is converted into 'Server-sent events' according to RFC
6202, see also https://www.w3.org/TR/eventsource/ - this requires
corresponding client.

Due to use of special prefix modified version of python
eventsource-client is necessary ATM.

Change-Id: I87d40c80061f8b3d02d656ab8cadabbfb871b461
Related: OS#1646
2016-08-11 06:05:39 +00:00
Max dbb6392368 Add python functions to get/set ctrl variables
Add get_var and set_var functions which handle requested variable while
checking for proper response and id. Split header handling into separate
function.

Change-Id: I08705963c277bd93a011193dd7451a626d606c21
Related: OS#1646
2016-08-11 06:05:39 +00:00
Max 2a63d01c1e Use random operation id
According to documentation for Control Interface Protocol <id> is "A
numeric identifier, uniquely identifying this particular operation",
hence it's best to be illustrated with random integer - use it as
default.

Fix override of id with previously used python-specific objects' id.

Change-Id: I32236c067360526f4e7ee4bbdba64c5137de696d
Related: OS#1646
2016-08-11 06:05:39 +00:00
Neels Hofmeyr b6f565c97d gsm_pchan2chan_nr(): fix uninitialized cbits
Commit ec1b5a0e9e introduced an unset cbits
value for the 'special hack for BCCH', where I break out of the switch
without setting cbits. Fix that.

Also remove the comment part that says 'return 0', because I don't return 0.

Change-Id: I54129d921807971eeafc23f80c57666c67b71377
2016-08-10 17:14:53 +02:00
Neels Hofmeyr 2f44693fad gsm_pchan2chan_nr: disable a chan_nr assert in BTS, to not break octphy
In https://gerrit.osmocom.org/589 , msuraev reports an assertion on octphy.
So disable this recently added assertion until we clarify the invocation in
question.

Change-Id: Ia0f7ae5b114e179ab56b98adbae9810e81b4b88f
2016-08-10 17:14:48 +02:00
Harald Welte 158b5d2bdb add .mailmap file for mapping git author name/mail in shortlog
Change-Id: I7ed97fb897895935f942e3eb4fd87a8c138417be
2016-08-08 17:40:28 +00:00
Harald Welte beca090586 add example config for sysmobts
Many years ago, there was no difference between the libbsc support for
nanobts and sysmobts.  However, this is not the case for a long time
anymore, and there are some specifics in OsmoNITB when it comes to
sysmobts.  Let's have an example config file

Change-Id: I94ae57c9a3cb497ca39d56270fa15ed65d7f147e
2016-08-08 11:29:49 +00:00
Max 3ed214c7b0 Improve code re-use
Introduce explicit __main__ function to facilitate re-use of defined
python functions for ctrl interface.

Change-Id: I9bad8f0dd1d69bd28816bf047d85840e3411bb9c
Related: OS#1646
2016-07-29 18:23:21 +02:00
Neels Hofmeyr 5f0c71b7d5 dyn TS: OS#1778 workaround: disable TCH/F on dyn TS for nitb
To avoid two phones picking mismatching TCH pchans, never pick TCH/F on dynamic
TS in osmo-nitb.

Add gsm_network flag dyn_ts_allow_tch_f, set to true by default in
gsm_network_init().

Set this flag to false in osmo-nitb's main().

See http://osmocom.org/issues/1778

Reasoning about ways to solve this:

* a compile time switch doesn't work because libbsc is first compiled and then
  linked to both osmo-nitb and osmo-bsc.

* we could test net->bsc_api == msc_bsc_api(), but I have the so-called MSC
  split waiting on branch sysmocom/cscn, which will result in msc_bsc_api() not
  being linked in the osmo-bsc binary.

* have a function am_i_nitb() with different implementations in osmo-nitb and
  osmo-bsc, but then we'd need to add implementations to all tests and other
  binaries linking lchan_alloc().

* have a flag in struct bsc_api, but so far there are only function pointers
  there.

Having a "global" flag in gsm_network allows to add a VTY command in case we
decide to keep this feature (#1781), has no linking implications and is nicely
explicit.

Tested that osmo-bsc still picks TCH/F on dyn TS indirectly, since I have no
standalone MSC available: when compiling osmo-nitb with the line that sets
dyn_ts_allow_tch_f = false commented out, TCH/F is picked as described in
OS#1778; and by printf-verifying that dyn_ts_allow_tch_f == true in osmo-bsc
main(), only osmo-nitb should have TCH/F disabled.

Related: OS#1778, OS#1781
Change-Id: If7e4797a72815fc6e2bbef27756ea5df69f4bde7
2016-07-28 17:40:59 +02:00
Neels Hofmeyr c5e75f3e6a dyn TS: Rename bsc_dyn_pdch.c to bsc_dyn_ts.c
It's no longer just for IPAC style TCH/F_PDCH, but also contains code for
TCH/F_TCH/H_PDCH, so pick a more general name.

Change-Id: Ic19db81eca03fd72738839ee3686b6b4c8b6b437
2016-07-28 11:56:51 +02:00
Neels Hofmeyr d3b7fa837d dyn TS: split dyn_pdch_init() for new dyn type and rename
Init both TCH/F_PDCH and TCH/F_TCH/H_PDCH via dyn_ts_init(), which
refactors dyn_pdch_init().

Make dyn_ts_switchover_start from abis_rsl.c public in abis_rsl.h, so we can
start the initial switchover to PDCH from dyn_ts_init(); in abis_rsl.h include
gsm_utils.h for enum gsm_phys_chan_config.

Change-Id: I5c0b257ba8ff0e9c9a2268681a84b0681a778368
2016-07-28 11:56:51 +02:00
Neels Hofmeyr b91e6002a6 dyn TS: implement pchan switchover logic
In struct gsm_lchan, add dyn.rqd_ref and dyn.rqd_ta. These save the Channel
Requested details across the PDCH deactivation dance.

abis_rsl.c: add static functions:

* dyn_ts_switchover*() for the various stages of switchover between pchans.

* pchan_for_lchant() to derive the desired pchan from the lchan type that was
  set during lchan_alloc().

* rsl_chan_activate_lchan_as_pdch() to compose the simpler RSL CHAN ACT message
  without introducing numerous special cases to the normal RSL CHAN ACT code.

In rsl_chan_activate_lchan(), detect and initiate required pchan switchovers if
requested pchan on a dyn TS differs.

In rsl_rx_rf_chan_rel_ack(), initiate or continue pchan switchovers after a
channel was released.

In rsl_rx_chan_act_ack(), notice that a switchover is complete.

In chan_alloc.c, add ts_subslots(): abis_rsl.c will need to know the number of
subslots per pchan, to verify that all lchans are free before dyn TS
switchover. The subslots_per_pchan[] array is static to lchan_alloc.c, and
since we need a non-trivial check for dyn TS anyway, add public ts_subslots()
to lchan_alloc.c, which also checks the current dyn pchan type.

Change-Id: I5c6bce13092a10204113d84678c587c65e35e4fd
2016-07-28 11:56:51 +02:00
Neels Hofmeyr 7af652c0b2 dyn TS: chan act: set chan_nr according to dyn pchan type
Change-Id: Ica5ef2197b3e97d5e895f3e3221295d5d0ef8908
2016-07-28 11:56:51 +02:00
Neels Hofmeyr fdd9ad7c40 dyn TS: enhance channel allocator for dynamic TS
Change _lc_find_bts() to _lc_dyn_find_bts() with added dyn_as_pchan arg to
pass exactly as which pchan we'd like to allocate on a dynamic TS. Add
_lc_find_bts() as wrapper so non-dynamic-TS callers remain unchanged.

Also add dyn_as_pchan arg to _lc_find_trx() (not renaming to dyn and wrapping
because there is only one caller).

Implement dynamic allocator logic in _lc_find_trx() and lchan_alloc().

A returned dynamic channel still needs to be switched to the proper mode, which
will follow in another commit.

Replace a fixme comment with a normal comment in subslots_per_pchan[], because
handling of dynamic TS is now defined.

Change-Id: I18da7679300c43220d9baa6a304e8df74d366249
2016-07-28 11:56:51 +02:00
Neels Hofmeyr f58852d117 dyn TS: rsl_lchan_lookup(): add dyn PCHAN
Accept GSM_PCHAN_TCH_F_TCH_H_PDCH for TCH/F and TCH/H if in matching pchan mode
or switching to matching pchan.

Accept RSL_CHAN_OSMO_PDCH chan_nr cbits for GSM_PCHAN_TCH_F_TCH_H_PDCH pchan.

Change-Id: If8f7c118f69e5a9f370bfe25f82f3d5a8de75b51
2016-07-28 11:56:51 +02:00
Neels Hofmeyr 9518ffc299 dyn TS: verify_chan_comb(): handle new dyn TS NM_CHANC_*
Change-Id: I7ce754a48c7f492e921a4450745383bb8dd7225c
2016-07-28 11:56:51 +02:00
Neels Hofmeyr 4673b86f3d dyn TS: rsl *2chan_nr(): handle TCH/F_TCH/H_PDCH
In gsm_lchan2chan_nr() use the current pchan type.

In gsm_lchan_as_pchan2chan_nr(), add the special case of non-standard cbits for
activating PDCH on a TCH/F_TCH/H_PDCH dyn TS. This way, gsm_pchan2chan_nr()
conforms to the standard and does not need access to a ts struct.

Change-Id: If248b9073b9f397110a2003d8e1a04afdc1c0e20
2016-07-28 11:56:51 +02:00
Neels Hofmeyr d384110d3d dyn TS: gsm_lchan2chan_nr(): decouple from ts->pchan
For upcoming dynamic TS, the pchan choice for RSL De-/Activation is not
trivial. So in order to pass the desired pchan to generate the RSL chan_nr,
introduce gsm_lchan_as_pchan2chan_nr().

To avoid code dup, this requires decoupling the gsm_ts2chan_nr() pchan from the
actual ts struct, so refactor gsm_ts2chan_nr() to gsm_pchan2chan_nr() with
explicit pchan, ts_nr and lchan_nr arguments.

Change-Id: I1a40e8452fe8120d350a27973e56be0b8c8c517f
2016-07-28 11:56:49 +02:00
Neels Hofmeyr 6e999b75fa dyn TS: rename lchan->dyn_pdch to lchan->dyn
This will also be used by the new dynamic TS type, so make the name more
general.

Change-Id: I2451b10519dff3e5cdf503b430574c0984d19000
2016-07-28 11:55:03 +02:00
Neels Hofmeyr cf7933892a prepare dyn TS: act lchan: fetch the channel mode a bit later
Dyn TS will add a new type of chan activation, which does not need a Channel
Mode IE. Incidentally, the dyn PDCH also doesn't need this IE if it opts for
sending a PDCH ACT instead. So it makes sense to compose the Channel Mode IE
only after the dynamic decisions are done.

Change-Id: I66d88ad6a4ae7bee1e552960fd4e92aff953125c
2016-07-28 11:55:03 +02:00
Neels Hofmeyr e2eb5cb6a1 error log: rsl_chan_activate_lchan: log channel mode error
Change-Id: I0f403b13ff9897770c0b855bf57a9440717b46e8
2016-07-28 11:55:03 +02:00
Neels Hofmeyr 2e84b60652 cosmetic: dyn_pdch_init(): debug log: use new gsm_ts_and_pchan_name()
Change-Id: I396c2696bdbedb41a1f1fe2183f8eada57dc3413
2016-07-28 11:55:03 +02:00
Neels Hofmeyr ec1b5a0e9e gsm_ts2chan_nr(): add assertions for lchan_nr
Change-Id: Ibfdef347c85d4a145645a7325cd193ea1b475a54
2016-07-28 11:55:00 +02:00
bhargava 350533cc32 Modify SI 13 field to support 11 bit RACH
System Information 13 field EGPRS PACKET CHANNEL REQUEST is
modified to support 11 bit RACH. Further VTY configuration is added
to enable/disable 11 bit RACH support in EGPRS. By default 11 bit
RACH support is disabled.

Change-Id: I51357bec936c28a26ab9ff5d59e0e30ca3363297
2016-07-28 06:49:03 +00:00
Neels Hofmeyr e3dc498e01 debug log: fix line endings for abis_rsl_rx_rll logging
This function outputs a debug log without line ending, which should be
completed by a subsequent DEBUGPC(), so complete the started log line where
missing in three of the switch cases.

The three cases do print another log message, but since these don't start on a
new line when RLL is in debug level, the log output for these is hard(er) to
read without this patch.

Change-Id: I355647e77e1b2d8e75ae1a167fe87a507a38d82d
2016-07-28 06:31:35 +00:00
Max e443145d3e Fix default subscriber regexp
Incorrect regular expression used by default to authorize all
subscribers to implement authorization policy 'accept-all' prevented MS
from camping on the open network.

Change-Id: I20284b3d40ecf4ca1e67d8cd25afb8d5e4ae3025
2016-07-27 14:52:14 +02:00
Neels Hofmeyr d1c0e3755f log lchan_alloc() result
It is particularly interesting to see whether a given lchan type is allocated
on a dynamic timeslot.

Change-Id: I8a0bca6d9cd583a0988e5ee8f4e6f74f218f4185
2016-07-25 17:35:47 +02:00
Neels Hofmeyr bbbcfe5b73 error log: abis_rsl.c: log errors in channel_mode_from_lchan()
Change-Id: Ifa416eab76e6c26dc83e979d815ae778d0d7133b
2016-07-25 17:35:47 +02:00
Neels Hofmeyr 745857277c code dup: join [rsl_]lchan_lookup() from libbsc and osmo-bts
lchan_lookup in abis_rsl.c and rsl_lchan_lookup() from osmo-bts rsl.c are the
same code, except for the log context, which is only set in abis_rsl.c.
Factor out the common code to rsl_lchan_lookup() in gsm_data_shared.c.

Openbsc and osmo-bts each define their own DRSL log constant, so add an int *rc
return code argument and keep the logging part in abis_rsl.c's thin lchan_lookup()
wrapper. Incidentally, this also removes code dup for logging.

To avoid duplicate symbols, the rsl_lchan_lookup() implementation needs to be
removed from osmo-bts, so older osmo-bts git revisions will not build with
this.

Change-Id: Ie89bc5bb9110a0e539d37991dedac6f913211b48
2016-07-25 17:35:47 +02:00
Neels Hofmeyr 34b8b5b29b gsm_data_shared: add gsm_ts_and_pchan_name() for dyn ts logging
Change-Id: I9b6be77c9e5fb9dffa2021a2da72293af15a03a0
2016-07-25 17:35:47 +02:00
Neels Hofmeyr c165876223 dyn TS: add ts->dyn state
Add state fields osmo_bts_trx_ts->dyn.* to record dynamic timeslot state.
Initialize in gsm_bts_trx_alloc().

Change-Id: I0a4049df8500b4f7c864f1355c4e9238932d1b8f
2016-07-25 17:35:47 +02:00
Neels Hofmeyr f29dd5f15b cosmetic: rsl_rx_chan_act_ack(): use local lchan var in 14 instances
In preparation for an upcoming change.

Change-Id: I9ce71fd7dde42ad7d20f806ac70c150d11450efa
2016-07-25 15:21:24 +00:00
Neels Hofmeyr 8151648ceb cosmetic: act lchan type: use constant instead of 0x00
Change-Id: Idc8afc4e52e189f474077899eef896381ce238f7
2016-07-25 15:21:24 +00:00
Neels Hofmeyr 4007468014 cosmetic: rsl_rx_rf_chan_rel_ack(): use local ts var for brevity
In preparation for an upcoming change.

Change-Id: I11bd59492fa8d5b9392d9f2b511c8fa9585afe6c
2016-07-25 15:21:24 +00:00
Neels Hofmeyr c6926d064d comments: clarify some dynamic TS comments
A new type of dynamic channel will be introduced soon, so prepare some comments
to name the dynamic TS kind more specifically.

Change-Id: I51fa8c2ebba507299e55a5cb7e67e48a6c8471f7
2016-07-25 15:21:24 +00:00
Neels Hofmeyr 67933a19d6 fix: create_pdp_conf(): unset reject_cause after unknown ran_type
f9f4387686 introduced a check for ran_type,
which potentially leaves reject_cause unset. Fix that.

Change-Id: I0220841ff796f949d00a1415d46b54a3eacc9493
2016-07-25 15:19:50 +00:00
Harald Welte 7c989e7ced remove old copy of documentation that now is in osmo-gsm-manuals.git
We keep some random snippets of documentation here, but manuals are now
generally kept in osmo-gsm-manuals.git.  Particularly the GSUP, OAP and
control interface are documented more extensively there.

To avoid having two sets of (diverging) documentation, let's remove it
from the openbsc.git repository.

Change-Id: I4a4c918587e236a7aa00cf2bb6aa05b090f7229b
2016-07-25 09:58:34 +00:00
Alexander Couzens 14314bd808 sgsn: add statistics counter for GPRS and PDP packets
Changing the test to allow still allocated block from the rate
counters.

Change-Id: Ie30e4c3084ee3a138d6b39bb5000234ac814e65f
2016-07-25 00:15:53 +00:00
Alexander Couzens b1c227e5ab bs11_config: add brackets to fix warning in argument parsing
Change-Id: I2f02e09a21ca622b03fd966445f533263a499c8d
2016-07-25 00:14:44 +00:00
Neels Hofmeyr 17a6bab150 fix ctrl test: dyn TS: use new GSM_PCHAN_TCH_F_TCH_H_PDCH
Add GSM_PCHAN_TCH_F_TCH_H_PDCH in gsm_pchant_names and gsm_pchant_descs: the
VTY and CTRL can now handle the new pchan type.

Adjust the CTRL iface test to expect the new PCHAN type in the output.

Fixes make check with --enable-external-tests after libosmocore commit
fd80f5a04239c2ab7b561401476dd89f2861748b that adds GSM_PCHAN_TCH_F_TCH_H_PDCH.

Change-Id: I4ad9c972d7f76f7e20cf74d6fc3d1928b644a4f8
2016-07-24 13:35:04 +02:00
Vadim Yanitskiy d091b8de21 mncc_sock: use osmo_sock_unix_init() from libosmocore
Since the osmo_unixsock_listen() was moved to libosmocore
it would be better to use the library's implementation
instead of reinventing the wheel again.

Change-Id: Iacfc39b6214c24084438f8fe04d03952cdc9ebc2
2016-07-23 19:21:17 +00:00
Alexander Couzens 15fcd10fde gprs_gmm: remove duplicated start of T3395
The timer is already scheduled by gsm48_tx_gsm_deact_pdp_req().

Change-Id: I8203b939d2196f87b11c0f3b2b0ff481e572835c
2016-07-23 15:26:13 +00:00
Dieter Spaar b572d7c45e SGSN: fix FCS calculation for encrypted frames
Change-Id: I352bc9db0c17fff773788831c4389ec0a5a30af8
Related: OS#1582
2016-07-17 08:44:38 +00:00
Neels Hofmeyr 9ddd8e6267 dyn pdch: don't PDCH ACT if gprs mode is none
Skip PDCH activation if the GPRS mode is 'none' at:

* TCH/F_PDCH init after OML Enable (dyn_pdch_init())
* after TCH/F_PDCH is released, in TCH/F mode
* in the T3111 error timer callback after a TCH/F_PDCH was released in error
  state

Assert the GPRS mode in rsl_ipacc_pdch_activate() to make sure all callers
check the GPRS mode.

Closes: OS#1765

Change-Id: I970e5f9dbcb1c625209e914a4c7696294ed34e62
2016-07-17 07:46:38 +00:00
Neels Hofmeyr 9331df16cf cosmetic: dyn_pdch_init(): flatten if-logic, add comments
Prepare for upcoming addition of heeding gprs mode == none.

Change-Id: Id0fe6f762ac863c4d4053841c7732d011aa8c561
2016-07-17 07:46:38 +00:00
Max 1de159168c SGSN: move cipher application to separate function
Split out generation and application of GEA gamma into separate function
which can be used for both encryption and decryption.

Change-Id: I442f2ead57e40d9bcd24e7f1b261041371595360
Related: OS#1582
2016-07-17 07:15:20 +00:00
Max 82040101eb SGSN: encrypt/decrypt only necessary frames
According to 3GPP TS 24.008 § 4.7.1.2 some GMM frames are not supposed
to be ciphered. Propagate information about the necessity for
encryption between MM <-> LLC to ensure only proper frames are
encrypted/decrypted/dropped.

Change-Id: I0358905e60d1b182f75caec81bfcc72bbbbb2aa1
Related: OS#1582
2016-07-16 23:17:58 +00:00
Max b997f84443 SGSN: add preliminary support for GPRS encryption
It is already functional enough to allow testing with real
phones. However, note - there are several limitations in the current
implementation:

* only default value for IOV-UI is supported at the moment
* AUTN-based key material is not supported

Related: OS#1582
Change-Id: I8900b906693496e4e6b35be5a86937c58039ed9e
2016-07-16 21:11:10 +00:00
Max 5aa5196fbf SGSN: split GEA key management from TLLI
Move GEA key from TLLI assignment into separate function.

Change-Id: I8a0bc907072dc19cd9535a28b5252dc0f05357cc
Related: OS#1582
2016-07-16 21:04:01 +00:00
Max 4011e728d2 SGSN: use unique AUTH REQ reference
The A&C reference number specified in 3GPP TS 24.008 § 10.5.5.19
identifies particular request sent by network with the related response
sent by MS. The value transparently copied from request to response by
MS: the spec do not specify what exactly should be in there so we use
rand() to decrease chance for collisions.

Note: variable named 'rand' clashes with standard function rand() so it
was renamed.

Change-Id: I3638821a9b4a0532b28dbbb50faa30c4082579f6
Related: OS#1582
2016-07-16 21:03:30 +00:00
Neels Hofmeyr 9759374adb jenkins.sh: add --enable-iu matrix build
Change-Id: Ida76f24d0b801fa609f3a128b3b912572cad4297
2016-07-13 17:50:12 +02:00
Neels Hofmeyr a3d93ed2f9 jenkins.sh: remove code dup
Have a bash function to build each dependency with the same commands.  There is
a tradeoff: having each dependency build with the same function means you can't
easily tweak one of the dependencies. OTOH having a unified function means a)
more readable script, b) that we're sure not to forget some steps and c) no
need to do the same edit n times.

Set the PKG_CONFIG_PATH globally. Also a tradeoff: if a future addition
wouldn't need the same PKG_CONFIG_PATH, this would make things ugly. But that
is actually quite unlikely, and the readability improvement is substantial.

Use env variables to remember local paths. That means we always are sure to cd
to the same absolute base path, which a 'cd ..' can't guarantee; also, we avoid
possible typos for e.g. "$deps/install".

Change-Id: Ib23f86c6cc1441d882de59bcdde5de87fa4e9fdf
2016-07-13 17:50:10 +02:00
Daniel Willmann 5754206379 osmux: Add negotiation state so race conditions can't disable osmux
Without this commit it is possible that osmux is disabled again on links with
high jitter. This happens when an MGCP response without X-Osmux header is
received before the NAT receives an Osmux dummy frame from the other side.

Ticket: SYS#2628, SYS#2627
Sponsored-by: On-Waves ehf
Change-Id: Id624b0279aee5e2412059a10296ce7896e2d4628
2016-07-11 19:19:05 +00:00
Max 176b62a80c SGSN: prevent starting with inconsistent config
Previously it was possible to start osmo-sgsn with "auth-policy remote"
but without "gsup remote-*" which resulted in broken setup: no MS could
perform GPRS ATTACH. Add consistency check to vty code to fix this.

Related: OS#1582
Change-Id: Ie4296e7d99d7833f7d828b0196435ea81097cf6e
2016-07-11 19:18:17 +00:00
Max e6052c4cc7 Make random MSISDN assignment optional
Previously if subscriber was automatically created it got assigned
random MSISDN number. Make it optional (defaulting to previous behavior)
by adding following:

* new optional no-extension argument for subscriber-create-on-demand vty
  command
* db unit tests
* vty test

Note: using the db made with new code might result in subscribers with
empty extension. Such subscribers cannot be deleted using old
code. Make sure not to mix db versions or manually fix it by editing
sqlite with external program.

Fixes: OS#1658
Change-Id: Ibbc2e88e4722b08854ebc631485f19ed56443cbb
2016-07-09 19:52:54 +00:00
Alexander Couzens 9f8f9b8021 libbsc: skip channel state LCHAN_S_INACTIVE while handover
The state is directly overwritten by the next function. Because
there isn't any state transition, remove this state.

Change-Id: I7f287692dbd559268fb5e61d81ac19e5dd4827eb
2016-07-09 08:53:16 +00:00
Max 3955025c2a SGSN: move TLLI unassignment into separate function
Change-Id: Ia4df145ab03ebcaad70a13601cff60c488a5de54
Related: OS#1582
2016-07-04 08:42:37 +00:00
Max 93408ae727 SGSN: add vty config for choosing GPRS encryption
Change-Id: I07d65205be1c75d59744426629ed04cf3cd99f79
Related: OS#1582
2016-07-04 08:42:07 +00:00
Max 896c6f8e9e SGSN: force GSUP CN domain to PS
Always set CN domain in outgoing GSUP packets to PS to make it
compatible with osmo-auc.

Change-Id: Ia6ee2e55a41a8ea9e465d7df1b2b3559b553fca8
Related: OS#1582
2016-07-01 15:24:44 +02:00
Max 488902db2a Fix vty tests with subscriber deletion
Use correct vty command for subscriber deletion, adjust assertions
accordingly. The error was cause by inconsistent syntax of vty commands
for subscriber creation and deletion.

Change-Id: I9b9376b4ac0ec066000545167de312ca4460493b
2016-06-29 16:45:14 +00:00
Neels Hofmeyr dd49beebb1 err log: tweak dyn pdch ack error logging
Rather use gsm_lchan_name().

Change-Id: I0334484eaa6a2c0f25925042c9c3c1a4e3e78ca4
2016-06-24 09:31:54 +00:00
Neels Hofmeyr 3f2212235c dyn PDCH: cosmetic: clarify lchan rel with assertion and comment
Change-Id: If3cc40022e8283daa991fffe4b6baa734303d8a5
2016-06-24 09:31:17 +00:00
Neels Hofmeyr b0cc64274a debug log: log all lchan state transitions
Change-Id: Ic70aca65b3796c90ba1a88ea67ac7a2ad9190b69
2016-06-23 20:57:44 +00:00
Neels Hofmeyr efedf80526 vty: show lchan summary: also show lchan->state
Change-Id: If7ae92b8d501b51bbe8a165c223734e169a8bb97
2016-06-23 20:01:25 +00:00
Neels Hofmeyr 82c8f75f71 dyn PDCH: enable PDCH only after release due to error
In rsl_rx_rf_chan_rel_ack(), only activate PDCH when in NONE state.

For the case of REL_ERR state, do the PDCH activation in the error timeout
callback after T3111 is done.

Change-Id: I4c55479b252a12039bb3d8c30a9cbf0199ca410e
2016-06-21 21:33:28 +02:00
Neels Hofmeyr 241bda03b4 typo in sgsn_test
(committing just to test gerrit, if it goes through it's still a valid change)

Change-Id: I3291ea2da99cd7f0e2f340b0e6fd6022d088beb8
2016-06-20 18:26:15 +02:00
Neels Hofmeyr 29048b2a80 rm dup: use channel type names from libosmocore
In gsm_lchant_name(enum gsm_chan_t), use the gsm_chan_t_names value strings
from libosmocore instead of redefining the same strings. The list from
libosmocore is also more complete, including CCCH and PDTCH.

Add a todo comment to move to libosmocore.

In consequence, libosmogsm linkage needs to be added to osmo-bsc_mgcp,
mgcp_test, mgcp_transcoding_test and smpp_mirror, smpp_test.

Change-Id: If65ee7c0619cbc0acb0a15045bd5a969442c93cc
2016-06-18 11:34:21 +00:00
Neels Hofmeyr f8e02aa4e3 configure: require libgsm for --enable-mgcp-transcoding
Fail in configure if libgsm is not found.

Before this, the --enable-mgcp-transcoding would gladly accept that libgsm is
missing and the build would fail later because of missing linking and undefined
references.

Change-Id: Ic23157cc5b75694f400a176c31f97d71e861ea02
2016-06-17 15:33:22 +00:00
Neels Hofmeyr 349108801f bsc_version.c: update copyright date, add contributor
Change-Id: Ib3f6763448457915d7473ec5039ab406fd4bdb48
2016-06-17 04:52:30 +02:00
Neels Hofmeyr 832afa3f4b dyn PDCH: set lchan->state after PDCH DEACT / before PDCH ACT
Do the PDCH DE/ACT before we set the lchan->state to De-/Activation Requested.
It makes more sense semantically to change PDCH mode while the lchan is still
in NONE status. Thus slightly move some invocations:

PDCH ACT: Free the lchan before PDCH activation. Hence remove the lchan_free()
call from the rsl_rx_pdch_act_ack() code path; it used to do the PDCH
activation first and call lchan_free() in the callback.

PDCH DEACT: Set the (TCH) Activation Requested state only within
rsl_chan_activate_lchan(), after the PDCH deact is complete.

Channel allocator: don't pick channels that have a PDCH PENDING flag set, to
avoid using channels that are still in PDCH switchover (despite their state
being NONE).

The lchan_may_change_pdch() sanity checks are becoming a lot simpler.

Change-Id: I4206dd4808e21c3e59393ea7f5ab4f438afff066
2016-06-16 04:29:40 +02:00
Neels Hofmeyr 285df2ec62 dyn PDCH: add lchan sanity checks in PDCH DE/ACT ACK
Change-Id: I0456cfb88860823c37c14688673e9cbc8d0085d8
2016-06-16 04:29:40 +02:00
Neels Hofmeyr 3201988f7b dyn PDCH: track pending PDCH de-/activation
Set and clear pending flags on the TS according to PDCH de-/activation.

This will allow changing the time we set the channel state to after PDCH
DEACT and before PDCH ACT, in a subsequent commit.

Also add a sanity check on whether we're sending conflicting or superfluous
PDCH de-/activations on the same TS.

Change-Id: Ieae73271df749ded3d90585116aae01f3ad4ee74
2016-06-16 04:29:40 +02:00
Neels Hofmeyr c1fbdedcd3 dyn PDCH: fix: clear PDCH flags on TS reconnect (e.g. BTS re-connect)
Change-Id: I89a0ef1794f343fdd06a62237f5732e73f4d2704
2016-06-16 04:29:40 +02:00
Neels Hofmeyr 2ebacce4fa dyn PDCH: TS flags: rename one, add three, as enum
Rename TS_F_PDCH_MODE to TS_F_PDCH_ACTIVE, to more accurately reflect the truth
value's meaning.

Add TS_F_PDCH_ACT_PENDING and TS_F_PDCH_DEACT_PENDING for sysmoBTS (and
possibly other BTS implementations) to remember what to do when the PCU replies
with a channel de/activation. Also add TS_F_PDCH_PENDING_MASK to test for both.

Change from #define to an enum.

Note: These flags are also used in the upcoming osmo-bts-sysmo dyn PDCH
commits, so osmo-bts submission depends on this commit.

Change-Id: I391a103ab599648b0c5d4f3ad613a6d7c48834b3
2016-06-16 04:26:33 +02:00
Max 0fcd2e2fec Make random extension range configurable
Previously if subscriber was automatically created it got assigned
random MSISDN number between 20000 and 49999. Make it configurable with
new vty command "subscriber-create-on-demand random" and expand vty
tests to check it.

Change-Id: I040a1d227b0c7a1601dc7c33eccb0007941408a6
Related: OS#1658
2016-06-14 22:20:40 +00:00
Max e152ffe14d Fix SIGABRT on wrong AMR payload
Previously length check have not considered AMR format which requires
extra byte for in-band length leading to SIGABRT on incorrect payload
from BTS.

Change-Id: I800f756fc803accace8c7e0b4a42b3744fe78bb6
Fixes: OS#1731
2016-06-14 10:20:05 +00:00
Neels Hofmeyr b8afb5fda2 dyn PDCH: send PDCH ACT for each TCH/F_PDCH on TS Enable
Add dyn_pdch_init() in new file bsc_dyn_pdch.c (new file to avoid linking
issues; bsc_init.c would create undefined references, and putting in a new file
is the easiest solution).

Call dyn_pdch_init() from nm_statechg_event() whenever a TS is enabled.

Revert the |= TS_F_PDCH_MODE chunk from previous commit, since this flag will
now be set after dyn_pdch_init() sent out the PDCH ACT and when subsequently
the PDCH ACT ACK messages are received in rsl_rx_pdch_act_ack().

Change-Id: I0cad93dec59d546b3f3b19e332e0833496031575
2016-06-14 10:18:19 +00:00
Andreas Eversberg 9df268e217 dyn PDCH: Automatically deactivate/activate PDCH on TCH/F+PDCH channel
Handle shared TCH/F+PDCH channels as regular TCH/F channels. Prior to
activation, deactivate PDCH mode.

After deactivation, restore PDCH mode.

Change-Id: I59712b8769cc3959ef114a6e12e77801816fe8b6
2016-06-14 10:18:19 +00:00
Daniel Willmann 3adb23cfc5 add DSUA debug constant
Change-Id: I4a3a8189564345700ea4825983ab39a8411227f4
2016-06-13 09:18:51 +00:00
Neels Hofmeyr a66852525a dyn PDCH: allow allocating TCH/F on TCH/F_PDCH slots
Remove check for dyn PDCH in _lc_find_trx(), instead call _lc_find_trx() via
_lc_find_bts() several times, so that pure TCH/F is preferred to TCH/F_PDCH.
Add this logic next to the other channel match decisions in chan_alloc().

BTW, the removed check in _lc_find_trx() whether PDCH is active is not
necessary, as described in the added comment for lchan_alloc().

Original patch idea by jolly, but split in two and implemented differently by
nhofmeyr.

Change-Id: I0c728b922656be03588b775638b610a93f8187d5
2016-06-12 15:48:38 +00:00
Andreas Eversberg 0434efa077 dyn PDCH: Fix free slot search for chan_alloc_reverse == true
For chan_alloc_reverse, _lc_find_trx() should return the last free slot instead
of the first.

Original patch by jolly, but split in two by nhofmeyr.

Change-Id: Iff980242b9b5cb39345aaad0350ee368537677cd
2016-06-12 15:48:38 +00:00
Max ec744655b4 Add talkspurt indicator for gsm_lchan
Add bit which can be set on BTS side to indicate that next RTP frame
should be marked as a beginning of speech.

Change-Id: I355a5ae275a2743b29071924c916c4f68c3b3e80
Related: OS#1562
2016-06-12 15:43:50 +00:00
Max f5fe31d513 DTX: add data necessary for scheduling
DTXd: to schedule SID repetition we have to know when previous SID was
sent (fn) and if it was UPDATE or FIRST SID (is_update).
DTXu: to properly set Marker bit in outgoing RTP we have to know the
beginning of talkspurt. For codecs without explicit ONSET event we can
do it by setting the flag (ul_sid) upon receiving SID and unsetting it
on speech frames.

Change-Id: I79cbec3b6c6fed5de385f8e202ceaf0b13234778
Related: OS#22, OS#1701
2016-06-10 14:09:07 +02:00
Max ae3f0718f1 Add DTXd indicator to gsm_lchan
It is necessary for proper reporting of DTXd status during the
measurement period.

Change-Id: I4a033b03fcd0deb4db7a38273b5407511dbf1d6c
Related: OS#1701
2016-06-10 11:34:41 +00:00
Daniel Willmann 35a65edd10 add DRANAP debug constant
Change-Id: I6132198ea86979e0ed84df32f2b7117feba497f2
2016-06-10 10:46:48 +00:00
Neels Hofmeyr f5713a5c63 lchan_alloc(): on alloc failure, report original type
In lchan_alloc(), there are several decisions to fall back to another type of
channel, followed by setting the channel type to the fall back type. So far,
this was set regardless of allocation success or failure.

If such fall back type is not available, do not modify the local type variable
and thus report an S_CHALLOC_ALLOC_FAIL on the type originally requested
(report is at the end of lchan_alloc()).

Change-Id: Ie3d4cb74f91db0b8c4f5e595a963099de339ad1a
2016-06-07 11:10:40 +00:00
Max 6079528b48 Add warning for unsupported DTX configurations
libosmo-abis do not consider DTX bits while processing TRAU frames. As I
do not have equipment to test it, I'm not sure if/how non-IP BTS will
work in case of DTX - warn users about it.

Change-Id: I94ee69cd309fc343a428ddc66942cd57f2a34c05
Related: OS#22
2016-06-06 11:36:48 +02:00
Neels Hofmeyr 9329e6fb49 gprs_gmm.c: don't transmit NOTEXIST when mmctx is NULL
Add missing mmctx NULL check in gsm0408_rcv_gmm(). gsm48_tx_gmm_status() would
dereference mmctx without checking, so we can't call it if mmctx == NULL.

Follows up on recent e98ba82d2b07c835:
"gprs_gmm.c: Don't try to de-reference NULL mmctx".

Change-Id: If59efbde86c76ffe91a0b33be87273783a2a4a02
2016-06-05 23:36:28 +00:00
Daniel Willmann 3af9660e51 configure.ac: add --enable-iu with deps asn1c, ranap, sigtran
For upcoming 3G support.

Change-Id: I6209423d71f94d5cd0ca9daf065d0a9df521ef02
2016-06-05 23:13:01 +00:00
Neels Hofmeyr 9f5d231f00 debug log: cosmetic fixes
Drop erroneous C from a DEBUGPC, should be on a new line.

Drop underscores from IPAC_PDCH_[DE]ACT: all other log messages for IPAC PDCH
are without underscores -- git grep "P(.*IPAC.PDCH.*ACT"

Change-Id: I8fb7a1c1beabb1f4388517383fd0bdc082d557ca
2016-06-05 23:02:09 +00:00
Neels Hofmeyr 3e62d415ac comment tweak for bsc_handover_start()
Have a comment only in the .c file to remove dup, tweak wording, use doxygen
style.

Change-Id: If054dad877a1ca750cd72be9c9d90bcf087bf741
2016-06-05 23:01:25 +00:00
Max ddee01fa8f Add regexp authorization policy for IMSI
* extend "auth policy" vty command with new option "regexp"
* add vty command "authorized-regexp" for setting arbitrary POSIX
  regular expression
* add basic vty test
* add optional "regexp" argument to subscriber-create-on-demand vty
  command

With those in place we can now set the regexp against which MS's IMSI
will be matched.

If IMSI match the regexp than MS is allowed to access the network. If
subscriber is already marked as authorized in HLR than it'll be allowed
regardless of IMSI matching.

The same way we can decide whether to create subscribers on-demand
basesd on IMSI regexp match. Similar to authorization this restriction
can be overridden by manually creating subscriber via vty, ctrl
interface or directly in HLR.

Change-Id: I525f4b80676de47d1d422686da2ca012301b0129
Fixes: OS#1647
2016-06-05 09:36:37 +00:00
Max d7df7ae392 Store last used FN for TCH
It's necessary to properly compute timestamp compensation for RTP
packets in case of DTX (or heavy packet loss).

Related: OS#22
Change-Id: Ib42c6a8614a4b73333a83181488dd4069cac14d7
2016-06-03 13:03:52 +02:00
Daniel Willmann f9f4387686 gprs: more conditionals for Gb specific actions
Change-Id: I213d21b9ddbf19e56269defcc6aa65aca4947140
2016-06-02 03:01:06 +02:00
Daniel Willmann 7ec8ca422c sgsn_mm_ctx_cleanup_free(): clean up LLME iff present (Gb, not Iu)
Assert that llme is unused for non-Gb (Iu) connections, and clean up otherwise.
Make sure the cleanup is left below the sgsn_mm_ctx_free() call, as the comment
states.

Change-Id: I891ae21afc1f4f60580b822273b5435e0e17d46f
2016-06-02 03:01:04 +02:00
Harald Welte 2b2429eb59 gprs_gmm.c: Perform LLME operations only if we have one
In case the GMM message did not arrive over a Gb interface, there is no
LLME (and thus the associated pointer is NULL).  Don't try to perform
operations on a NULL LLME.

Change-Id: If7f24161cd2826f8ee238d4bc1090adf555cea4e
2016-06-02 03:01:02 +02:00
Harald Welte dbc72b37ee gprs_gmm.c: Make TLLI handling specific to Gb interface
Soem of the operations we perform in the GMM layer are specific to the
GPRS/EDGE radio access network and its Gb interface.  Let's make them
conditional to that in preparation of supporting an Iu interface.

Change-Id: I3efb7c5087afe8e2331ec17bd9fac5029f4bee6c
2016-06-02 03:00:59 +02:00
Neels Hofmeyr e98ba82d2b gprs_gmm.c: Don't try to de-reference NULL mmctx
There was a comment in the code that certain GMM messages require a
valid mmctx pointer.  However, nothing actually checked if that pointer
was in fact non-NULL.  We plainly crashed if a MS would send us the
wrong message in the wrong state.

Original patch by Harald Welte, but it broke message validity checking,
resulting in sgsn_test failure. This re-implements the NULL check in a
different way, as explained by in-code comment.

Change-Id: I7908de65bec91599f7042549b832cbbd7ae5a9a8
2016-06-02 03:00:55 +02:00
Harald Welte 49393e128e rename gsm0408_gprs_rcvmsg() to gsm0408_gprs_rcvmsg_gb()
This is the entry point for GMM from Gb.  We will create a new one
for Iu, so let's be explicit rather than implicit.

Change-Id: I93c074bf99db041117c0dc03dc8255879845a875
2016-06-02 03:00:53 +02:00
Daniel Willmann 62ff38447c create_pdp_conf(): factor out PDP context accept dispatch as send_act_pdp_cont_acc()
Change-Id: Ibf60e18707ff4aa2e60291e5595386ddda8d8190
2016-06-01 12:09:51 +00:00
Harald Welte f97ee04563 prepare sgsn_mm_ctx for Gb and Iu mode (UMTS)
Explicitly mark those sgsn_mm_ctx members that apply for Gb mode and (upcoming)
Iu mode, respectively.

Add some comments in sgsn_mm_ctx.

Change-Id: Ife9b02549f284e2547f16117cf43d7a36948fc4b
Tweaked-By: Neels Hofmeyr <nhofmeyr@sysmocom.de>
2016-06-01 12:09:36 +00:00
Daniel Willmann 97165f386f rename enum gprs_mm_state to gprs_gmm_state
Change-Id: Ibba054d15c55c7ac570e64ff66ea57964be095e3
2016-06-01 11:07:21 +00:00
Harald Welte e1197481e5 Merge "rename enum gprs_mm_state to gprs_gmm_state" 2016-06-01 10:46:41 +00:00
Harald Welte a9ca72d907 Merge "add .gitreview" 2016-06-01 06:29:42 +00:00
Alexander Couzens 85f8fdabc3 gprs: use new uint8_t * for kv in gprs_cipher_run()
libosmocore changed in bf990bb8 Update internal GPRS cipher API
from uint_64 to uint8_t*.
Fix a warning.

Change-Id: Ib5bfe1fb05c693347b11ff4faadd3fc2205ebd76
2016-05-31 17:47:52 +02:00
Alexander Couzens 51fbc5f6e0 add .gitreview
A .gitreview file is required to use git review.
More information about git review
https://www.mediawiki.org/wiki/Gerrit/git-review

Change-Id: Ie7cdf16232181d4b8093e61f2d8a3faed9010d4f
2016-05-31 17:43:46 +02:00
Daniel Willmann 0f46f9ca5a rename enum gprs_mm_state to gprs_gmm_state
Change-Id: Ibba054d15c55c7ac570e64ff66ea57964be095e3
2016-05-31 13:53:15 +02:00
Max 69e9c0dfc6 Make si2q scheduling optional
Previously si2quater SI messages were always scheduled. Check for
neighbor configuration and only schedule si2q when necessary. Add
corresponding unit test.

Change-Id: Ibe997803ffb894133fd4d838410fe735791d414f
Fixes: OS#1727
Reviewed-on: https://gerrit.osmocom.org/81
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-31 09:32:12 +00:00
Holger Hans Peter Freyther 82dd983dd8 bsc: Create minimal SI6 rest octets
In GSM R99 SI6 has mandatory SI6 rest octets and so far we did
not include them. Add minimal support to generate the right band
indicator.

Target a slightly older version of the SI6 rest octets as we neither
support MBMS nor Random bit stream but should include the band
indicator.

Change-Id: I417a40eb91f42a3416b4e07bb9fb4d7a01aaa36b
Fixes: OS#1698
Related: OS#1725
Reviewed-on: https://gerrit.osmocom.org/71
Tested-by: Jenkins Builder
Reviewed-by: Max <msuraev@sysmocom.de>
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-30 21:28:40 +00:00
Neels Hofmeyr 307e40648e tweak db debug log: log TMSI as hex
Change-Id: I4564c99c145a35fb592c228c1fa84c61ec425fd3
Reviewed-on: https://gerrit.osmocom.org/94
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-05-27 10:48:04 +00:00
Holger Hans Peter Freyther 5b692d0a5c filter/nat: Fix the context for the imsi assignment
In c09f8a3b7f as part of a cleanup
I accidently changed the talloc context from "con" to "bsc". The
issue occurred at an earlier commit when assigning req.ctx to the
"wrong" context. The allocation needs to be scoped by the struct
nat_sccp_connection and not the connection from BSC to NAT.

Before we have a nat_sccp_connection we scope the copied imsi to
the bsc_connection and then steal it, but for the identity resp
we will always have a nat_sccp_connection and can already use the
right context.

Change-Id: I53789aad2809e19338ad3b2deb72c4757e7bd524
Related: OS#1733
Reviewed-on: https://gerrit.osmocom.org/102
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Reviewed-by: daniel <dwillmann@sysmocom.de>
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-25 19:43:38 +00:00
Holger Hans Peter Freyther ddf4e1e114 debian: Make upgrading from debian SID easier
Make sure the version number of this sourcepackage is higher than
the one found in Debian SID.

Change-Id: I838632e9e90378a03235c2aebd5bc9ed06627ec8
Reviewed-on: https://gerrit.osmocom.org/113
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-25 19:41:19 +00:00
Harald Welte ed04fcc179 rtp_proxy.c: Ensure msgb_alloc is large enough for largest AMR frame
In AMR 12.2 (mode 7), the actual RTP payload is 33 bytes.  Howeerver,
as we store the length of the (dynamically-sized) AMR payload in the
first byte, our buffer needs at least 33+1 byte in size.

Change-Id: If1ad5d2d68c85733306c75ea62f67fe8fbc143b3
Reviewed-on: https://gerrit.osmocom.org/91
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-05-25 12:33:47 +00:00
Neels Hofmeyr aea28ceb27 gsm04_08_clear_request(): release loc with arg release=0
In gsm04_08_clear_request(), in_release == 1 anyway and
msc_release_connection() would exit immediately without any effect. Don't
confuse the reader by passing release=1 arg.

Change-Id: I5bf9eb4889d32ad5e42ac7d096bf62fa3a493e20
Reviewed-on: https://gerrit.osmocom.org/93
Reviewed-by: Holger Freyther <holger@freyther.de>
Tested-by: Jenkins Builder
2016-05-23 20:20:37 +00:00
Max ea8e983514 Fix copy-paste error in SI6
Fix error which prevented enabling DTX for half-rate channels.

Change-Id: I7d41df0068783c8fb33ddeeab1d1dcf63c2c259f
Reviewed-on: https://gerrit.osmocom.org/101
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-23 16:24:40 +00:00
Harald Welte 7184bd088e subscr_name(): Handle case for subscr == NULL
subscr_name() was called from several places:
* either without a check for subscr being NULL, which for example
  was causing a segfault if we hand-over a channel before identifying the
  subscriber
* or with an explicit NULL check and the ternary operator (?).

We now simplify the code by checking for the NULL Subscriber in subscr_name()
itself.

Change-Id: Ide09f4a515222eb2ec6c25e7a6a8c5f6cc2ffd4b
Reviewed-on: https://gerrit.osmocom.org/92
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-22 11:51:18 +00:00
Neels Hofmeyr 8495e03588 drop unneccessary duplicate linking: tests/gsm0408
Change-Id: I8b6fb27d1db0157cb7d61f18b03f33c4f3168946
Reviewed-on: https://gerrit.osmocom.org/90
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-22 10:46:42 +00:00
Neels Hofmeyr 5493d87f95 drop unneccessary duplicate linking: osmo-nitb
Change-Id: I430adbb1e0c6382317da282bcf5ef73cf9496f80
Reviewed-on: https://gerrit.osmocom.org/89
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-21 15:54:36 +00:00
Neels Hofmeyr 2fa7d8464f drop unneccessary duplicate/unused linking: ipaccess
Drop unused linking of libmsc, and drop duplicate linking of libbsc.

Change-Id: If2d63adb832c72ff1a22c25a78e06b0c244628d2
Reviewed-on: https://gerrit.osmocom.org/88
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-21 15:20:47 +00:00
Neels Hofmeyr 63081fe34d drop unneccessary duplicate linking: osmo-bsc
Change-Id: Ia227abcaa7b1f808646aadb9f53ee2a669699c51
Reviewed-on: https://gerrit.osmocom.org/87
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-21 15:02:55 +00:00
Max e21cf38da4 Make extending subscriber creation easier
* rename variable controlling subscriber creation
* use enum for subscriber creation policy
* move check for subscriber creation policy into separate static
  function

Related: OS#1658, OS#1647
Change-Id: I3b10a9a764fd3a7bb96717a990e52caae16266da
Reviewed-on: https://gerrit.osmocom.org/42
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-20 16:32:37 +00:00
Max 8a4d2e756d Use proper measurement for handover
Previously *FULL measurements were always used for handover
decisions. Those are incorrect in case of DTX - check if it was enabled
and use *SUB instead.

Note: *SUB values have higher variance so there might be more "bad"
values compared to *FULL although real quality remains the same.

Change-Id: I95e8e544047a83a256e057a47458678f40a19a15
Related: OS#1701
Reviewed-on: https://gerrit.osmocom.org/66
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-05-20 16:26:33 +00:00
Max c08ee71bff Move DTX settings to BTS
* Add per-BTS DTX settings
* Configure Uplink and Downlink DTX separately
* Deprecate global DTX option (it was never tested/used anyway)
* Use libosmocore function for DTX indicator in System
  Information (previously it was incorrectly assigned for half-rate
  channels)

Related: OS#22
Change-Id: I3d55168475ad47044b6238b55846ea22bdd518a4
Reviewed-on: https://gerrit.osmocom.org/40
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-17 16:17:54 +00:00
Max 9a7e25b9c3 Cleanup db test
Move copy-pasted code into separate function to make writing more tests
easier.

Related: OS#1658
Change-Id: I9e39af85718514dd0f081d41c234c9dda77c4b27
Reviewed-on: https://gerrit.osmocom.org/43
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-17 16:14:06 +00:00
Vadim Yanitskiy a8d8e93086 db.c: implemented incremental migration
In the past, normal migration was possible only if the actual
schema version differed from the version used in DB by 1. For
example, if DB uses an old version 3 and you need to use it
with the code written for version 5, the check_db_revision()
will convert it to 4 and DB will still use incompatible schema
version during Osmo-NITB running time. After next run it will
be converted to version 5.

This patch replaces a set of 'else-if' checks by a 'switch'
without 'break' statements between 'case' labels (waterfall).
It makes you able to migrate from current version to the
latest despite any difference between them.

Change-Id: Ia9c2aa86f96b88ad8a710d0a23879ce219bc82dc
Reviewed-on: https://gerrit.osmocom.org/62
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-15 19:31:18 +00:00
Max 34e2b09278 Ignore extended test leftovers
Change-Id: If9e3522d934611f631cbfde6e6db52251babc37f
Reviewed-on: https://gerrit.osmocom.org/41
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Reviewed-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
Tested-by: Holger Freyther <holger@freyther.de>
Reviewed-on: https://gerrit.osmocom.org/56
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-12 12:24:23 +00:00
Harald Welte cd5e52605c sgsn_test: Adapt test case to now-existing InsertSubscriberData
We recently implementd InsertSubscriberData in the SGSN, adapt the test
to reflect that.
2016-05-06 13:49:20 +02:00
Harald Welte 7c55ede8b1 Add human-readable name of SGSN_AUTH_AUTHENTICATE
In commit 4adb136da6 we introduced
a new authentication state SGSN_AUTH_AUTHENTICATE, but we didn't
add that to auth_state_names[] resulting in log messages printing
it abut 'unknown 0x1' rather than something more useful.
2016-05-05 18:31:37 +02:00
Harald Welte 5f2524fe3d sgsn/GSUP: Support MAP-style nested LU/ISD
The existing GSUP code expected the subscriber data to be piggy-backed
onto the location update response, rather than a separate (and nested)
insert subscriber data request/response phase.

With this patch we should now support both the nested as well as the
piggy-backed version.
2016-05-05 18:25:12 +02:00
Harald Welte 5d547a4358 osmo_oap_decode(): Use common argument ordering
In general, if a function generates output data like a msgb (or in this
case filling an osmo_oap_message structure), the output argument
precedes the source.  This is what we use all over libosmo*, and it is
modelled after memcpy(), where dst is the first argument, before src.

Let's align osmo_oap_decode().  Intestingly, osmo_oap_encode was already
correct, so the encode/decode functions used different conventions
before.
2016-04-29 13:10:37 +02:00
Harald Welte d8aa412c46 OAP: Various coding style fixes
* we always declare stack variables at the top of the function / block
* 'switch' is not a function, so there's space ahead of the opening (
2016-04-29 13:10:37 +02:00
Harald Welte 564c06525b OAP: use osmo_oap_ prefix for OAP, rather than plain oap_
this is in preparation of moving related code to libosmocore.
2016-04-29 13:10:37 +02:00
Harald Welte 31760a1f60 oap_message.h: Remove dependency to openbsc include
This is a first step to moving oap_messages.h to libosmocore
2016-04-29 13:10:37 +02:00
Harald Welte 23d77d56ea Move osmo_gsup_messages.[ch] to libosmocore
This requires the corresponding commit in libosmocore.
2016-04-29 13:10:37 +02:00
Harald Welte 50f1c0af56 move utils.h functions to libosmocore
This needs the corresponding commit in libosmocore which imports
the related functions
2016-04-29 13:10:37 +02:00
Harald Welte eff215a8bb osmo_gsup_messge.[ch] documentation update (doxygen) 2016-04-29 13:10:37 +02:00
Harald Welte 7ca035deca gsup_messages: Add UMTS AKA related encoding/decoding support 2016-04-29 13:10:37 +02:00
Harald Welte 85234a32db move osmo_shift_* / osmo_match_shift_* to libosmogsm 2016-04-29 13:10:37 +02:00
Harald Welte 842674b8b3 rename gprs_shift_*() to osmo_shift_*()
This rename is the first step of moving the associated functions into
libosmocore.

Also, rename gprs_match_* to osmo_match_shift_* to indicate that it is
not just matching the TLV, but also shifting the data portion.
2016-04-29 13:10:37 +02:00
Harald Welte 28903a99ea Rename gprs_gsup_* to osmo_gsup_*
This is a preparation to move the related code to libosmocore, whilst
at the same time generalizing it from GPRS Subscriber Update Protocol
to the Osmocom Generic Subscriber Update Protoco.
2016-04-29 13:10:37 +02:00
Harald Welte d3fa84dbba use new libosmocore gsm_23_003.h for IMEI/IMSI length
... rather than our private definitions everwhere.  As an added benefit,
gprs_gsup_messages.h is now free of any header dependencies within
openbsc.
2016-04-29 13:10:37 +02:00
Harald Welte 53373bca8f move gsm_04_08_gprs.h to libosmocore
This requres the corresponding commit in libosmocore.
2016-04-29 13:10:37 +02:00
Harald Welte 121e9a4164 Start to use struct osmo_auth_vector from gsm_auth_tuple
Rather than having a 'private' structure for kc, sres and rand, we
now finally (with 4 years delay) use osmo_auth_vector from libosmogsm,
which encapsulates authentication vectors that can be either GSM
triplets or UMTS quintuples or a combination of both.

gsm_auth_tuple becomes a wrapper around osmo_auth_vector, adding
use_count and key_seq to it.

key_seq is no longer initialized inside gprs_gsup_messages.c, as there
is no CKSN / key_seq inside the message anyway.  If a usre of the code
needs key_seq, they need to manage it themselves.
2016-04-29 13:10:37 +02:00
Max 3ffce19cb4 Disconnect calls with incompatible channel types / modes
In case both TCH/H and TCH/F or different codecs are configured and
internal MNCC handler is used we might end up in a situation where call
legs with incompatible channel types or codecs would be connected
resulting in a broken audio.  Disconnect such calls with appropriate
error message.

Fixes: OS#1663
2016-04-29 13:10:00 +02:00
Max 35697b9a10 Adjust si2quater ranges
Change ranges of arguments for si2quater neighbor lists to proper values
according to 3GPP spec.
2016-04-29 12:57:53 +02:00
Max 299a999465 Fix comment typo 2016-04-29 12:57:53 +02:00
Max e01f5050ef Add missing include 2016-04-23 18:12:01 +02:00
Max 8db12e4263 Add extra debug output with channel mode and type
This provides helpful information for debugging internal MNCC handler.
2016-04-22 15:53:51 +02:00
Max aafff96c40 Add vty check for max si2quater size
Explicitly check if added (U|E)ARFCN will fit into available si2quater
message.
2016-04-22 14:56:06 +02:00
Max 26679e0475 Add basic UARFCN support
* add data structures, generation functions
* vty interface for neightbor UARFCNs specific to SI2quater
* vty test
* unit test

Fixes: OS#1666
2016-04-22 14:55:33 +02:00
Max 27c3e76aa7 Cleanup shared data structure
* remove unused variable.
* lower max number of (e|u)arfcns to more realistic value.
2016-04-22 14:54:39 +02:00
Max 0c1bc26b64 Fix earfcn deletion
* fix typo in arg index
* fix sign in error reporting
* add vty test
2016-04-22 14:50:42 +02:00
Max 36212f2850 Fix documentation for command parameters 2016-04-22 14:50:29 +02:00
Holger Hans Peter Freyther 3a434f8e8c nat/ussd: Add an example of the USSD gateway side-channel
This adds a very basic, use once example in python on how to connect
and deal with the app specific payload and messages. The code is not
complete as the invokeId should be patched according to the initial
invoke. This excercise is left to future readers of that code.
2016-04-16 15:56:13 -04:00
Holger Hans Peter Freyther e43f8e0400 nat/vty: Do not print token update statement
On start this would print one line per BSC and this doesn't add
a lot of value. Let's just remove this logging message.
2016-04-16 15:56:13 -04:00
Max 59a1bf3dae Add basic SI2quater support
* support for sending arbitrary static SI2quater.
* vty interface for neightbor EARFCNs specific to SI2quater.
* dynamic generation of SI2quater messages.
* unit test for SI2quater messages.

Fixes: OS#1630
2016-04-16 13:47:56 +02:00
Max 5fa7e36bbc Refactor SI-related code
Move define to header file.
Use inline functions where appropriate.
Change int variables which are used as boolean into actual bool to make
code easier to follow.
2016-04-16 13:47:56 +02:00
Max f3f3505f49 Add SI2quater support to SI3
Advertise SI2 quater presence and location (if available) using SI3
according to 3GPP TS 44.018 § 10.5.2.34
2016-04-16 13:47:52 +02:00
Neels Hofmeyr c9ac20ea43 gbproxy_test: assert msg allocation (CID #57873) 2016-04-16 13:33:22 +02:00
Neels Hofmeyr a6e81a0986 bsc_nat: forward_sccp_to_msc(): assert con presence (CID #57872) 2016-04-16 13:33:21 +02:00
Neels Hofmeyr 312bf6ce8b gtphub_unmap_header_tei(): don't dereference unmapped_tei arg if not present (CID #57687) 2016-04-16 13:33:14 +02:00
Holger Hans Peter Freyther 8bb6204d50 nat/vty: Fix construct not working with python 2.6
Use the simpler approach and just call encode('hex') on the str and
then convert it to lower case to keep the tests working.

reproduce:

Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> d = '\0\0'
>>> d
'\x00\x00'
>>> "".join("{:02x}".format(ord(c)) for c in d)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <genexpr>
ValueError: zero length field name in format

fixes:

======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 658, in testBSCreload
    b0 = nat_bsc_sock_test(0, "lol")
  File "./vty_test_runner.py", line 1150, in nat_bsc_sock_test
    ipa_handle_small(bsc, verbose)
  File "./vty_test_runner.py", line 1116, in ipa_handle_small
    s = data2str(x.recv(4))
  File "./vty_test_runner.py", line 1100, in data2str
    return "".join("{:02x}".format(ord(c)) for c in d)
  File "./vty_test_runner.py", line 1100, in <genexpr>
    return "".join("{:02x}".format(ord(c)) for c in d)
ValueError: zero length field name in format

----------------------------------------------------------------------
2016-04-14 21:40:04 -04:00
Holger Hans Peter Freyther 2abf2b072d nat/vty: Remove second assumption about lo and binding
If we want to separate the BSCs we should separate based on
the source port and not the source ip (at least in the current
test setup).

Fixes:
======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 658, in testBSCreload
    b0 = nat_bsc_sock_test(0, "lol")
  File "./vty_test_runner.py", line 1145, in nat_bsc_sock_test
    bsc.bind(('127.0.0.1' + str(nr), 0))
  File "<string>", line 1, in bind
error: [Errno 99] Cannot assign requested address

----------------------------------------------------------------------
2016-04-14 21:13:51 -04:00
Holger Hans Peter Freyther e98c9c7136 nat/vty: And move to a different port.. 2016-04-14 10:58:58 -04:00
Holger Hans Peter Freyther 84ae27e731 nat/vty: Convert into str for the VTY command
======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 656, in testBSCreload
    nat_msc_ip(self, ip, port)
  File "./vty_test_runner.py", line 1096, in nat_msc_ip
    x.vty.command("msc port " + port)
TypeError: cannot concatenate 'str' and 'int' objects

----------------------------------------------------------------------
2016-04-14 10:40:06 -04:00
Holger Hans Peter Freyther 44ed4979c9 nat/vty: Use different port for the mock MSC
Update the comment to reflect that the NAT itself will bind to port
5000 and then the mock MSC will fail to bind to it. Try to move the
mock MSC to another port.

Could fix:

======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 654, in testBSCreload
    msc = nat_msc_test(self, ip)
  File "./vty_test_runner.py", line 1101, in nat_msc_test
    msc.bind((ip, 5000))
  File "<string>", line 1, in bind
error: [Errno 98] Address already in use

----------------------------------------------------------------------
2016-04-14 10:05:13 -04:00
Holger Hans Peter Freyther f1a61bb99f nat/vty: Don't assume one can magically add IPv4 addresses to lo
Don't assume that one can just bind to a local address that has
not been configured. Remove the unspecific comment as I don't know
to which other tests it is referred to.

This should fix:
======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 655, in testBSCreload
    msc = nat_msc_test(self, ip)
  File "./vty_test_runner.py", line 1102, in nat_msc_test
    msc.bind((ip, 5000))
  File "<string>", line 1, in bind
error: [Errno 99] Cannot assign requested address

----------------------------------------------------------------------
2016-04-14 08:51:57 -04:00
Max 4936448761 NAT: reload BSCs config dynamically
Add vty tests for BSC configuration reloading.
Load BSCs configuration on bscs-config-file command:
* remove all runtime configured BSC not in the config file
* close connections to all BSC with updated token value

Fixes: OS#1670
Sponsored-by: On-Waves ehf
2016-04-14 08:37:34 -04:00
Max 82f5ecde6a NAT: move BSC config into separate file
Introduce new configuration option bscs-config-file which includes BSC
configuration from the given file. Both absolute and relative (to the
main config file) paths are supported.
Add 'show bscs-config' command to display current BSC configuration.
Note: it is still possible to have BSC configuration in the main
file (provided proper index number is used) and in runtime but BSC
configuration is no longer saved automatically. The management of
included configuration file is left to external tools.
Update configuration examples.

Fixes: OS#1669
Sponsored-by: On-Waves ehf
2016-04-14 08:34:49 -04:00
Max 70cf7290da vty_test_runner: update ipa sending code
Factor out 2, add 3 functions. Those functions are simple wrappers
around hex strings specific to IPA protocol. Not all of them are
utilized at the moment but they were checked with wireshark while
working on the tests. It might come in handy if we'd like to further
expand related test harness in future. The same goes for optional
verbosity argument which is not used right now but will be handy for
future debugging.
2016-04-14 08:33:47 -04:00
Holger Hans Peter Freyther a47b401990 jenkins: Add the build script from jenkins here
This can be used to replicate a build issue more easily.
2016-04-13 19:03:38 -04:00
Max 714b170f89 NAT: allow allocating BSC in arbitrary order
Check for existing BSC before allocating new one.
Track number of remaining BSCs on deallocation.
Explicitly use BSC number in allocation function.
2016-04-12 10:15:02 -04:00
Max 7a301d3576 Remove trivial wrapper function
Rename gsm48_tx_chan_mode_modify() to gsm48_lchan_modify() and remove
corresponding wrapper code.
2016-04-12 10:13:57 -04:00
Max f220b52df3 NAT: extend debug output for ipaccess errors 2016-04-12 10:13:07 -04:00
Max e5686f21d6 NAT: vty command to display number of BSCs
Add command 'show nat num-bscs-configured' to display number of configured BSCs.

Sponsored-by: On-Waves ehf
2016-04-12 10:12:36 -04:00
Max 687f048ab0 Fix segfault with broken config
Fixes OS#1691
2016-04-11 10:22:55 +02:00
Holger Hans Peter Freyther 9bcb1a56cb ctrl: Extend ctrl command to optionally handle alg+ki
Extend the existing ctrl command to be able to specify the
algorithm and Ki. In contrast to the VTY no size check is
done. Together with the VTY this code only supports a small
part of what is supported by libosmocore.

The algorithm and ki are considered optional but if a valid
algorithm other than "none" is passed, a KI must be passed as
well.

Extend the test coverage by passing the potential values. It
is not verified that the KI/algorithm is stored.
2016-04-07 09:27:07 +02:00
Holger Hans Peter Freyther adb86759da db: If creating a subscriber in the db fails, return NULL
We should not return a subscriber in case it was not written to
the database. Instead free the memory allocated and return NULL.
Callers in gsm_04_08.c are prepared to have the creation fail.

Related: OS Issue #1657
2016-04-06 21:21:24 +02:00
Holger Hans Peter Freyther 2826df56b2 subscr: Make db_create_subscriber fail on duplicates
The issue of db_create_subscriber updating an already existing subscr
is that the same subscriber will then have two entries in the active
subscribers list. In general this will break assumptions that a subscr
can be compared by comparing the pointer.

In the case of the VTY this was not an issue as the created subscr
was immediately destroyed again but it is better to avoid this problem.

Change the VTY command to find the subscriber and then call sync to
have the updated time set. The side-effect is we will now have two
queries for the subscriber. Once through subscr_get_by_imsi and once
through db_create_subscriber.

Change the db_create_subscriber to fail if a subscriber already exists,
and add a testcase for this behavior and do not updated the 'updated'
timestamp of an already existing subscriber.

Add a testcase for this behavior.

Related: OS Issue #1657
2016-04-06 21:19:53 +02:00
Holger Hans Peter Freyther de392254ff subscr: Add testcase creating an already created subscriber
Add testcase to issue the subscriber create twice. db_create_subscriber
in db.c will first try to find the subscriber and if it exists, it will
update the "updated" column in the database.

Related: OS Issue #1657
2016-04-06 21:18:36 +02:00
Max 7dd2eed6d3 Ignore vty test byproducts 2016-04-05 22:34:54 +02:00
Holger Hans Peter Freyther c6a65511f3 bsc: Add parameter to restart a bts
The ip.access nanoBTS seems to have severe issues with BSSGP when
changing the country code and/or network code. It is unlikely that
the proprietary code is getting fixed so we extend the parameter
for the apply-configuration command to carry the 'restart' param.
2016-04-01 19:34:42 +02:00
Holger Hans Peter Freyther 740e65fb7b bsc: Add code to send ip.access reboot command to nanoBTS
The nanoBTS continues to be buggy and seems to have broken BSSGP
when changing SIs across new OML connections. Add an easy command
to force the reboot of the system through OML.
2016-04-01 19:34:42 +02:00
Holger Hans Peter Freyther 3a38ee6c3d abis: Send the message without enforcing to wait for a response
The user might issue restarts while no BTS is connected and we
should not block the abis queue because of these messages.
2016-04-01 19:34:42 +02:00
Neels Hofmeyr cf1302e4cb Fix MM Auth: zero-initialize auth tuple before first use
Make sure a new auth tuple is initialized after
db_get_lastauthtuple_for_subscr() returns an error, i.e. if no tuple is present
for the subscriber yet.

Before this patch, the first key_seq depended on the typically uninitialized
value that was present in auth tuple's key_seq upon calling
auth_get_tuple_for_subscr().

The very first key_seq used for a new subscriber will now always be 0. Before,
it used to be mostly 1 ("(0 + 1) % 7"), but depended on whether the key_seq was
indeed initialized with 0, actually by random.
2016-03-31 11:56:49 +02:00
Neels Hofmeyr 0d929be826 Fix MM Auth: disallow key_seq mismatch
In auth_get_tuple_for_subscr(), add missing condition to match incoming
key_seq with stored key_seq, so that re-authentication is requested for
mismatching key_seqs.

Add test for this issue.
2016-03-31 11:56:48 +02:00
Neels Hofmeyr 4e875aec0f MM Auth: return AUTH_NOT_AVAIL instead of hardcoded zero
AUTH_NOT_AVAIL == 0, so this is no functional change.
2016-03-31 11:56:47 +02:00
Neels Hofmeyr f9b212fabd MM Auth: introduce AUTH_ERROR constant.
Instead of using hardcoded -1 for errors, include -1 in the enum auth_action
type; apply its use.

In the mm_auth test, the string output changes from '(internal error)' to
'AUTH_ERROR', since now the proper enum value is used in auth_action_names[].
2016-03-31 11:56:29 +02:00
Neels Hofmeyr d617c5d3ac MM Auth test: add test to re-use existing auth 2016-03-31 11:56:21 +02:00
Neels Hofmeyr 4554a62c4d MM Auth test: add two tests for AUTH_THEN_CIPH
Test two situations for AUTH_DO_AUTH_THEN_CIPH:
- when no auth tuple is available
- when the key sequence from LU is marked invalid

Add convenience auth tuple comparison function using stringification.
2016-03-31 11:56:14 +02:00
Neels Hofmeyr 37984bdb1b Add MM Auth test; add auth_action_str() function
Add basic MM Authentication test setup, with fake DB access and RAND_bytes().

So far implement simple tests for IO error during DB access and missing auth
entry.

To print the auth action during tests, add struct auth_action_names and
auth_action_str() inline function in auth.[hc].
2016-03-31 11:56:00 +02:00
Neels Hofmeyr 56ea30ff3f osmo-bsc: fix compiler warning: store struct in vty->index
Don't store an MSC index number in the vty->index void* value. Instead,
store the osmo_msc_data struct directly. Thus avoid warnings about
differences in int vs void* sizes, and save some index lookups.
2016-03-27 10:48:14 +02:00
Harald Welte 3ad0346f00 Revert "move to hex TMSI representation"
This reverts commit 044fbe6568.
2016-03-17 14:42:24 +01:00
Vadim Yanitskiy 044fbe6568 move to hex TMSI representation
In OpenBSC, we traditionally displayed a TMSI in its integer
representation, which is quite unusual in the telecom world.  A TMSI is
normally printed as a series of 8 hex digits.

This patch aligns OpenBSC with the telecom industry standard.

Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
2016-03-17 14:15:16 +01:00
Neels Hofmeyr d2fa7a509a fix confusing typo in constant (THAN -> THEN) 2016-03-17 14:15:16 +01:00
Holger Hans Peter Freyther f4afcf0b23 mgcp: Fix compiler warnings on size_t on AMD64
mgcp_transcode.c: In function 'decode_audio':
mgcp_transcode.c:332:4: warning: format '%d' expects argument of type 'int', but argument 7 has type 'size_t' [-Wformat=]
    LOGP(DMGCP, LOGL_ERROR,
    ^
mgcp_transcode.c:332:4: warning: format '%d' expects argument of type 'int', but argument 8 has type 'long unsigned int' [-Wformat=]
mgcp_transcode.c: In function 'encode_audio':
mgcp_transcode.c:390:4: warning: format '%d' expects argument of type 'int', but argument 7 has type 'size_t' [-Wformat=]
    LOGP(DMGCP, LOGL_INFO,
    ^
mgcp_transcode.c:390:4: warning: format '%d' expects argument of type 'int', but argument 8 has type 'size_t' [-Wformat=]
mgcp_transcode.c: In function 'mgcp_transcoding_process_rtp':
mgcp_transcode.c:542:5: warning: format '%d' expects argument of type 'int', but argument 9 has type 'size_t' [-Wformat=]
     LOGP(DMGCP, LOGL_NOTICE,
     ^
mgcp_transcode.c:571:4: warning: format '%d' expects argument of type 'int', but argument 7 has type 'size_t' [-Wformat=]
    LOGP(DMGCP, LOGL_NOTICE,
    ^
2016-03-16 11:16:06 +01:00
Neels Hofmeyr 10cd11345c bsc_scan_msc_msg: check protocol discriminator
The function assumed an MM protocol discriminator without verifying it.
2016-03-15 14:26:00 +01:00
Holger Hans Peter Freyther 8c515272c3 meas: Do not retry to close the database
There is no concurrency involved and if it failed the first time,
it will fail the second, third, ... time as well. Simply print that
we will leak the database instance.
2016-03-15 14:22:57 +01:00
Neels Hofmeyr 961bd0b121 04.08: apply new transaction id inline functions
libosmocore recently added inline functions to relieve callers from applying
bitmasks and bit shifts to access the transaction id of a GSM 04.08 header.
Apply these functions.
2016-03-15 14:18:52 +01:00
Neels Hofmeyr 531734a547 04.08: apply new bitmask functions, fix bitmask use
Replace hardcoded protocol discriminator and message type bitmasks with
function calls recently introduced in libosmocore.

Note that the release 98 bitmasks slightly differ from the release 99 bitmasks.
This patch uses the "default" gsm48_hdr_msg_type invocation, thus it depends on
libosmocore whether 98 or 99 bitmasks are used.

In some places, use of the bitmask was erratic. Fix these implicitly by
employing the bitmask functions:

 * silent_call.c: silent_call_reroute(): add missing bitmask for MM.
 * bsc_msg_filter.c: bsc_msg_filter_initial(): RR vs. MM messages.
 * osmo_bsc_filter.c: bsc_find_msc() and bsc_scan_bts_msg(): RR vs. MM
   messages.
 * bsc_nat_rewrite.c: bsc_nat_rewrite_msg(): SMS vs. CC messages.
 * bsc_ussd.c: no bitmask is applicable for the message types used here.
 * gb_proxy.c: gbproxy_imsi_acquisition(): missing bit mask for pdisc.

In gprs_gb_parse.c: gprs_gb_parse_dtap(), add a log notice for unexpected
message types.
2016-03-15 14:15:00 +01:00
Neels Hofmeyr 51273157fa channel_test: don't segfault if paging fails
Add due assertions of return value validity, otherwise leading to segfaults.
2016-03-03 16:12:04 +01:00
Neels Hofmeyr 6a1d172c95 db: evaluate return value of sqlite3_finalize(), tweak log output. 2016-03-01 13:05:27 +01:00
Neels Hofmeyr 45ee133d1d check return value of sqlite3_close(), retry up to three times. 2016-02-29 16:44:13 +01:00
Neels Hofmeyr 5b38312b92 use sqlite3_close() instead of sqlite3_close_v2()
This allows using sqlite3 v3.7.13, used by our current debian installation in
the test setup. _v2 was added in v3.7.14.
2016-02-29 16:42:00 +01:00
Neels Hofmeyr 49b83d8f67 minor comment 2016-02-29 10:31:07 +01:00
Neels Hofmeyr a7313dd886 osmo_bsc_filter.c: add fixme note 2016-02-29 10:31:07 +01:00
Neels Hofmeyr fea1df8587 bsc_test.c: fix tz.override val and note a FIXME 2016-02-27 23:38:28 +01:00
Neels Hofmeyr 1b0e5540db smpp: refactor initialization, add bind address
Make the SMPP bind address configurable (used to be harcoded as "0.0.0.0").

Add VTY command

    smpp
     local-tcp A.B.C.D <1-65535>

while keeping the old command 'local-tcp-port <1-65535>'. Both the old and the
new command immediately change the SMPP listening address and port.

Add a LOGL_NOTICE log when the SMPP listening address and/or port change.

However, to be useful, this patch has to go somewhat further: refactor the
initialization procedure, because it was impossible to run the VTY commands
without an already established connection.

The SMPP initialization procedure was weird. It would first open a connection
on the default port, and a subsequent VTY port reconfiguration while reading
the config file would try to re-establish a connection on a different port. If
that failed, smpp would switch back to the default port instead of failing the
program launch as the user would expect. If anything else ran on port 2775,
SMPP would thus refuse to launch despite the config file having a different
port: the first bind would always happen on 0.0.0.0:2775. Change that.

In the VTY commands, merely store address and port if no fd is established yet.

Introduce several SMPP initialization stages:

* allocate struct and initialize pointers,
* then read config file without immediately starting to listen,
* and once the main program is ready, start listening.

After that, the VTY command behaves as before: try to re-establish the old
connection if the newly supplied address and port don't work out. I'm not
actually sure why this switch-back behavior is needed, but fair enough.

In detail, replace the function
  smpp_smsc_init()
with the various steps
  smpp_smsc_alloc_init() -- prepare struct for VTY commands
  smpp_smsc_conf() -- set addr an port only, for reading the config file
  smpp_smsc_start() -- establish a first connection, for main()
  smpp_smsc_restart() -- switch running connection, for telnet VTY
  smpp_smsc_stop() -- tear down connection, used by _start() twice

And replace
  smpp_openbsc_init()
  smpp_openbsc_set_net()
with
  smpp_openbsc_alloc_init()
  smpp_openbsc_start()

I'd have picked function names like "_bind"/"_unbind", but in the SMPP protocol
there is also a bind/unbind process, so instead I chose the names "_start",
"_restart" and "_stop".

The smsc struct used to be talloc'd outside of smpp_smsc_init(). Since the smsc
code internally uses talloc anyway and employs the smsc struct as talloc
context, I decided to enforce talloc allocation within smpp_smsc_alloc_init().

Be stricter about osmo_signal_register_handler() return codes.
2016-02-25 12:18:04 +01:00
Neels Hofmeyr 73828152d9 enable ctrl bind config for various programs
Add ctrl_vty_init() calls and feed the ctrl_vty_get_bind_addr() return value to
ctrl_interface_setup() in the following programs:

  osmo-bsc
  osmo-bsc_nat
  osmo-nitb
  osmo-sgsn

For osmo-sgsn, move the control interface setup invocation below the config
parsing, so that the ctrl_vty_get_bind_addr() can return the configured
address.
2016-02-25 12:18:04 +01:00
Neels Hofmeyr fc7add20e1 osmo-nitb: be strict about cmdline args
Abort upon unknown options and missing option arguments. This came to my
attention while rewiring the -m and -M options: passing -M without argument
would launch nitb with wrong configuration. So, rather exit immediately.

If there are legacy options that should be ignored, they deserve an own 'case:'
in the option switch. There are none that I'm aware of though.
2016-02-25 12:18:04 +01:00
Neels Hofmeyr f4a3123145 osmo-nitb: cosmetic: rename to rf_ctrl_path, following mncc_sock_path
Strictly speaking, the unix domain socket location is not a name but a path.
The MNCC socket is called path, so it is confusing to call the ctrl socket
a 'name'.
2016-02-25 12:18:04 +01:00
Neels Hofmeyr 0ade63233b osmo-nitb: add -M to pass specific MNCC socket path
The old -m option without argument is still available and marked deprecated,
to not make users' lives more difficult than necessary.
2016-02-25 12:18:03 +01:00
Neels Hofmeyr fa0f71526c enable telnet VTY bind address config for various programs
Following the 'line vty'/'bind A.B.C.D' command added in libosmocore, use the
configured address to set the telnet bind for the VTY line. It is now possible
to publish the VTY on a specific local interface (including 0.0.0.0 aka "any").

Implement in all of:
  osmo-gbproxy
  osmo-gtphub
  osmo-sgsn
  osmo-bsc
  osmo-bsc_nat
  osmo-bsc_mgcp
  osmo-nitb

In some of these main programs, move the telnet initialization below the
configuration parsing.

Historically, this was not a good idea for programs using bsc_init.c (aka
bsc_bootstrap_network()), since they expected a gsm_network struct pointer in
((struct telnet_connection*)vty->priv)->priv, so that telnet had to be either
initialized or replaced by a dummy struct. In the meantime, the gsm_network
struct is not actually looked up in a priv pointer but in the static bsc_vty.c
scope (bsc_gsmnet), so this limitation is mere legacy (even though said legacy
is still there in an "#if 0" chunk).

In the other binaries I have briefly looked at the init sequence dependencies
and found no reason to initialize telnet above the config file parsing. In any
case, I have tested every single one of abovementioned binaries to verify that
they still parse the example config successfully and launch, allowing VTY
connections on the configured address(es). I hope this suffices.

In all of the above, log VTY address and port. LOGL_INFO is disabled by default
in some of the logging scopes, and since it is a single log message right at
program launch, I decided for the slightly more aggressive LOGL_NOTICE.
2016-02-25 12:18:03 +01:00
Neels Hofmeyr 58d5430dd5 gsm340_rx_tpdu: comment-out two unused vars
Kills two compiler warnings.
2016-02-25 12:18:03 +01:00
Neels Hofmeyr 127fc93a13 ipaccess_rcvmsg: fix returncode, add partial write warning
Kills a compiler warning.
2016-02-25 12:18:03 +01:00
Neels Hofmeyr 547f048c89 bsc_nat: fail if VTY telnet port cannot be bound, clarify comment 2016-02-25 12:17:07 +01:00
Neels Hofmeyr fd1187e2e9 minor fixes in bsc_vty.c and bsc_nat.c
Remove unused talloc.h from bsc_vty.c.

In bsc_nat.c, use OSMO_CTRL_PORT_BSC_NAT instead of hardcoding port number, and
include ctrl/ports.h for that.

Fix comment typo "COMAMND"
2016-02-24 00:43:41 +01:00
Neels Hofmeyr 1901b92f0c osmo-bsc: fix checking wrong pointer for ctrl setup success 2016-02-24 00:43:25 +01:00
Neels Hofmeyr 69da1d453c gtphub: tweak default logging level 2016-02-23 13:28:04 +01:00
Neels Hofmeyr 03933a49de gtphub: include ports.h instead of redefining OSMO_VTY_PORT_GTPHUB 2016-02-23 13:26:02 +01:00
Holger Hans Peter Freyther 389a62d752 Merge branch 'jerlbeck/fixes/sgsn'
Remove the assert in the llme by avoiding the usage of foreign to local
mappings of TLLIs. The asserts had been hit at 32C3 and the fixes were
created by Jacob and had been tested at the convention.
2016-02-22 11:02:36 +01:00
Jacob Erlbeck 5ac4aadd1a sgsn: Re-add searching for MM ctx based on TLLI / P-TMSI matches
If an MM context cannot be found based on BBSGP info and a RA UPDATE
REQUEST is received, try to find an MM context with an P-TMSI from
which the TLLI could have been derived. This also checks, whether the
routing area matches.

This is similar to the old behaviour removed by the commits
"sgsn: Only look at TLLIs in sgsn_mm_ctx_by_tlli" and
"sgsn: Remove tlli_foreign2local", except that this will only
be done for RA UPDATE REQUESTs now.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck 1330478aa5 sgsn/test: Add test case test_gmm_routing_areas
This test add different cases of routing area changes.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck d35957a7d9 sgsn: Change handling of missing mmctx in gsm48_rx_gmm_ra_upd_req
Currently the MM context is just overwritten by a call to
sgsn_mm_ctx_by_tlli(msgb_tlli(msg), &old_ra_id) even if it
has already been found by using the BSSGP info. With the changes
made to sgsn_mm_ctx_by_tlli this will never find a MM context if
the routing area has changed. If the routing area has not changed,
the mmctx has already been found if it exists.

This commit splits searching for an MM context (if it hasn't been
found already) from checking, whether a found one can really be
used. The actual search is removed, so that the MS will be forced to
restart the attach procedure, which is less efficient but safe.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck d58c033305 sgsn: Only look at TLLIs in sgsn_mm_ctx_by_tlli
Currently the code also matches the TLLI against LOCAL and FOREIGN
mappings of the P-TMSI, thus eventually finding MM contexts not
consistent with the TLLI (both tlli and tlli_new differ). On
the other hand, tlli_new is not checked at all.

This commit changes the function to only look at mmctx->tlli,
mmctx->tlli_new, and the routing area.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck e7bcdc3bda sgsn: Make ra_id_equals available as gprs_ra_id_equals
The function is moved to gprs_utils.c, renamed, and made non-static
to be usable in other modules, too.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck 9158089fa8 sgsn/test: Add bssgp_raid parameter to send_0408_message
The BSSGP cell identifier is used to get the RA for the TLLI lookup.
The send_0408_message function used in the tests does not set this,
so the RA identifier is always 0-0-0-0.

This commit adds a parameters to pass the RAID and adds missing
dummy RAIDs.

Note that the CI can still not be set and thus is always 0.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Jacob Erlbeck 3fbf0a3735 sgsn: Remove tlli_foreign2local
Currently foreign TLLI are sometimes mapped to local TLLI in the
hope that they will match. This seems to sometimes introduce
inconsisties, possibly leading to a failing assertion in
_bssgp_tx_dl_ud.

This mapping should probably reduce the allocation of additional
LLME during routing area changes.

This commit removes tlli_foreign2local.

Sponsored-by: On-Waves ehf
2016-02-22 10:52:08 +01:00
Ruben Undheim 2259c7528e Patch to make openbsc find libsmpp34
This patch lets the build script for openbsc find the libsmpp34 installation
with the help of pkg-config instead of assuming the header files are in
/usr/include.
2016-02-18 19:39:32 +01:00
Harald Welte 28e9f60404 rename ipaccess-find into abisip-find
The tool is not used only to find ip.access devices, but used to find
any Abis/IP implementing devices, including those supported by OsmoBTS.
2016-02-18 11:15:16 +01:00
Harald Welte bafc1e4cfe add DOT graph showing NITB data structures and their references 2016-02-14 17:38:26 +01:00
Holger Hans Peter Freyther e9f420d487 msc: Remove oversimplified todo entry and add a comment
Add a comment of why we want to accept this connection anyway.
2016-02-10 10:42:20 +01:00
Holger Hans Peter Freyther 8239e063b9 gsm0408: Provide unique strings for the gsm 04.08 message
At Rhizomatica we see that some GSM 04.08 messages are leaked and
have no other indication if that is Call Control, SMS or something
else.
2016-01-30 09:57:49 +01:00
Neels Hofmeyr 1da0a7e229 openbsc/README: some fixes, add CSCN and Iu*
OsmoNITB stated to include BTS, should be BSC. Reword some outdated
statements. Add OsmoCSCN and mention IuCS and IuPS interfaces.
2016-01-28 13:36:07 +01:00
Neels Hofmeyr 6d575cbe57 Add README.vty-tests 2016-01-28 13:36:07 +01:00
Neels Hofmeyr 34cf923704 remove src/libgb/Makefile.am
libgb has been obsolete for years, but the Makefile.am is still there.
src/Makefile.am does not list it as a subdir, so it's just dangling legacy.
2016-01-28 11:51:21 +01:00
Neels Hofmeyr 9c4f1d6fd0 fix bsc_vty out: timeslot indented too deeply.
In 'show running-config', timeslot appears as a sub-element of rsl, but it is a
direct child of trx. Fix the timeslot section in vty_out by removing one space
of idention.

Adjust various config examples.

Rationale: it's not relevant for function, but confuses human operators. Fixing
it will save the next hacker some time.
2016-01-28 11:45:51 +01:00
Alexander Huemer 1bf8617610 gprs: use libgtp cflags 2016-01-26 11:05:14 +01:00
Holger Hans Peter Freyther de76661cf3 gtphub: Fix use after free on failure
Even if fclose fails the stream is inaccessible and the second fclose
might cause memory violation.

Linux manpage says:
Upon  successful  completion 0 is returned.  Otherwise, EOF is returned
and errno is set to indicate the error.  In either case any further
access (including another call to fclose()) to the stream results in
undefined behavior.

Fixes: CID#57958
2016-01-23 10:28:09 +01:00
Holger Hans Peter Freyther f9f44901a2 db: Avoid undefined behavior when copying cm2/cm3 from the db
memcpy has both the source and destination marked as non-null and
we were still passing NULL (with a zero size) to it. While this
makes sense it violates the constraints of the function. Add the
check to see if these values are NULL or not.

+db.c:583:2: runtime error: null pointer passed as argument 2, which is declared to never be null
+    #0 0x40d7f7 in get_equipment_by_subscr (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40d7f7)
+    #1 0x40f6d2 in db_get_subscriber (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40f6d2)
+    #2 0x40bfaa in sms_from_result_v3 (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40bfaa)
+    #3 0x40c847 in update_db_revision_3 (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40c847)
+    #4 0x40cbc3 in check_db_revision (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40cbc3)
+    #5 0x40cf85 in db_prepare (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40cf85)
+    #6 0x406f18 in main /home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test.c:179
+    #7 0x7fd625638a3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
+    #8 0x405598 in _start (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x405598)
+
+db.c:590:2: runtime error: null pointer passed as argument 2, which is declared to never be null
+    #0 0x40da23 in get_equipment_by_subscr (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40da23)
+    #1 0x40f6d2 in db_get_subscriber (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40f6d2)
+    #2 0x40bfaa in sms_from_result_v3 (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40bfaa)
+    #3 0x40c847 in update_db_revision_3 (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40c847)
+    #4 0x40cbc3 in check_db_revision (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40cbc3)
+    #5 0x40cf85 in db_prepare (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x40cf85)
+    #6 0x406f18 in main /home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test.c:179
+    #7 0x7fd625638a3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
+    #8 0x405598 in _start (/home/builder/jenkins/workspace/Osmocom_Sanitizer/source/openbsc/openbsc/tests/db/db_test+0x405598)
2016-01-23 09:21:04 +01:00
Holger Hans Peter Freyther fec29ab4e9 gtphub: Make the two setter static as well
Same as with the previous gtphub commit. Make these static to deal
with the new semantic of inline in gcc5.
2016-01-22 23:36:22 +01:00
Holger Hans Peter Freyther 7ba088bdf0 dahdi: The driver has moved to libosmo-abis
We can remove this check from openbsc as the handling is done
in libosmo-abis.
2016-01-22 23:35:21 +01:00
Holger Hans Peter Freyther 91e0e1b038 gtphub: Fix compilation using gcc5
The semantic of inline has changed and we need to make it static
to not end up with undefined references.
2016-01-22 23:32:36 +01:00
Alexander Huemer 22a7142129 tests/abis: fix format specifiers 2016-01-15 15:41:19 +01:00
Alexander Huemer 6cacc56d8e tests/oap: depend on libgtp
exclude logic copied from src/gprs/Makefile.am
2016-01-15 15:06:03 +01:00
Holger Hans Peter Freyther 5cb480a4c0 bsc/vty: Provide a hint of available input 2016-01-15 15:05:42 +01:00
Neels Hofmeyr cdc548cb0a gtphub VTY: add newlines to some VTY docs' final lines 2015-12-14 16:11:47 +01:00
Neels Hofmeyr 69a720f3be gtphub VTY: fix doc strings for show cmds 2015-12-14 15:52:01 +01:00
Holger Hans Peter Freyther da5359f1b6 gtphub: Fix the VTY prompt to make the tests move forward 2015-12-14 15:24:50 +01:00
Neels Hofmeyr 720372e4e8 gtphub VTY test: use only 127.0.0.1.
Add a second example config file for gtphub so that the VTY test can use
nonstandard ports.
2015-12-14 11:29:55 +01:00
Neels Hofmeyr 4adca4e8af osmoappdesc.py: fix wrong index introduced by gtphub.
vty_app should reference osmo-nitb, but by adding gtphub, apps[-1] has
changed. Use index 5, which won't change when adding further items.
2015-12-13 15:22:01 +01:00
Harald Welte 0a8cf32a48 indicate the GSM 04.08 channel mode in 'show lchan' 2015-12-12 21:43:16 +01:00
Harald Welte 53d51f501c mncc: introduce 'struct gsm_mncc_bridge' for MNCC_BRIDGE
When a MNCC handler wants to issue the MNCC_BRIDGE primitive
overt the MNCC interface, this was not possible so far via the
MNCC socket.   This primitive was so far only available from the
internal MNCC handler, more or less by accident I suppose.  The reason
for this is in the way the array of two call references had been passed
into mncc_tx_to_cc().
2015-12-12 21:43:16 +01:00
Harald Welte da8a19fec0 mncc.c: Convert mncc_names[] to 'struct value_string' 2015-12-12 21:43:16 +01:00
Neels Hofmeyr 36948bf7c7 gtphub: log: limit length of hex dumps.
The debug log prints the received/sent bytes in hex. When this data surpasses
the buffer size available for the log string (4096), the log is truncated
and lacks a newline character. Limit the amount of dumped bytes to 1000.

Sponsored-by: On-Waves ehi
2015-12-08 12:21:15 +01:00
Neels Hofmeyr 4d2b3ff6a2 gtphub: add VTY show for peers and peer stats.
Sponsored-by: On-Waves ehi
2015-12-07 13:37:28 +01:00
Neels Hofmeyr d010c49407 gtphub: improve handling of restarted peer.
Handle peer restart earlier, so that all the tunnels are deleted by the restart
code path, instead of the first one being deleted due to reused TEI. That
caused confusing logging messages.

Also, when receiving Delete confirmations from the peer that didn't restart,
don't complain about unknown peer, but acknowledge and remove the half
invalidated tunnel. This means that the pending delete entry from the restart
code path is not needed / not used, so don't bother to add pending delete
entries upon peer restart.

The test test_peer_restarted_reusing_tei() hits the situation where a tunnel is
removed because of a reused TEI rather than the restart counter. Adjust the
test to expect the "out-of-band" delete request earlier on, and to still see
the half invalidated tunnel around. Enhance the test by adding the delete
response from the peer that didn't restart, and add a final tunnels_are()
verification.

Sponsored-by: On-Waves ehi
2015-12-07 13:37:15 +01:00
Neels Hofmeyr bee75969cc gtphub: log most common message type names.
Sponsored-by: On-Waves ehi
2015-12-07 13:37:13 +01:00
Neels Hofmeyr ee07e4f75d gtphub: simplify/fix: one TEI mapping per tunnel.
Because the sender is known, one unique TEI per tunnel suffices to map the TEIs
that the peers are sending to gtphub, instead of previously 4 (SGSN<->GGSN
interaction on User and Ctrl plane, where each had an own unique TEI).

Also, previously, a tunnel's endpoints should also have been checked against
each other for TEI reuse, not only against the endpoints of other tunnels. This
simplification fixes that problem for free.

Thus simplify TEI reuse detection and improve VTY show readability and
debugging.

Adjust log and VTY output for tunnels.
Adjust tests accordingly.

Suggested-by: Holger Hans Peter Freyther <holger@moiji-mobile.com>
Sponsored-by: On-Waves ehi
2015-12-07 13:37:11 +01:00
Neels Hofmeyr f6e4d08219 gtphub: fix: when checking TEIs, skip 0.
Sponsored-by: On-Waves ehi
2015-12-07 13:37:10 +01:00
Neels Hofmeyr 328d2f78c1 gtphub: log: add TEI reuse msg, fix another TEI msg.
Sponsored-by: On-Waves ehi
2015-12-07 13:37:09 +01:00
Neels Hofmeyr 23d09cc904 gtphub_test: add test_parallel_context_creation()
Sponsored-by: On-Waves ehi
2015-12-07 13:37:08 +01:00
Neels Hofmeyr ee1e5d758e gtphub: log: add side str to msg for reused TEI
Sponsored-by: On-Waves ehi
2015-12-07 13:37:06 +01:00
Neels Hofmeyr e38fb66f4b gtphub: add more detailed I/O rate counters.
Count bytes and packets per peer port, as well es per tunnel enpoint, which
adds two more levels of detail.

Sponsored-by: On-Waves ehi
2015-12-07 13:37:05 +01:00
Neels Hofmeyr 956d856b61 gtphub: be strict about unknown cmdline args
Sponsored-by: On-Waves ehi
2015-12-07 13:37:04 +01:00
Neels Hofmeyr ba0525e3d8 gtphub: tweak logging.
Less spaces in tunnel strings, adjust tests accordingly.

Use side_idx to remove code dup in rate counter output.

Sponsored-by: On-Waves ehi
2015-12-07 13:37:03 +01:00
Neels Hofmeyr 28a70f20cd gtphub: logging: have one newline per log.
Some logging was multiline to ease human reading of debug output. However,
in the VTY output, these newlines lack a CR motion. Split multiline logs into
separate lines.

Also add one missing space.

Sponsored-by: On-Waves ehi
2015-12-07 13:37:01 +01:00
Neels Hofmeyr 9d8f506f7f gtphub: fix missing newline in log output
Sponsored-by: On-Waves ehi
2015-12-07 13:36:57 +01:00
Neels Hofmeyr 5d5c31a367 gtphub: enhance gtphub-example.txt 2015-12-07 11:07:22 +01:00
Neels Hofmeyr 5c7dcf9665 gtphub: add gtphub-example.txt 2015-12-07 10:58:11 +01:00
Harald Welte 3f015f04b1 bring the README into the 21st century 2015-12-05 23:13:49 +01:00
Harald Welte c14574b567 AUTHORS: Add Jacob and Neels 2015-12-05 23:04:11 +01:00
Harald Welte d8352d75b6 remove old obsolete linux kernel and wireshark patches
Those were relevant in 2008/2009, but not today...

Also, move hlrsync to the contrib directory
2015-12-05 22:59:41 +01:00
Harald Welte c696cc28d8 gsm_data_shared: compute/sprintf the lchan name only once
We now store the pre-printed lchan name in lchan->name to avoid having
to call sprintf every time there is a debug statement somewhere,
particularly as most of those debug statements are going to be inactive
most of the time.
2015-12-05 16:19:21 +01:00
Neels Hofmeyr e1ba781f7b gtphub: tweak startup log for sgsn_use_sender 2015-12-03 14:48:27 +01:00
Neels Hofmeyr f8c701008b gtphub: add test for SGSN behind NAT 2015-12-03 14:29:48 +01:00
Neels Hofmeyr 1ae3ebd68b gtphub_test: tweak test_user_data(): no seq routing.
Don't route User message back by sequence number, rather test that a
completely unrelated User message is routed back properly.

Sponsored-by: On-Waves ehi
2015-12-03 14:19:10 +01:00
Neels Hofmeyr ca2361c237 gtphub: implement sgsn_use_sender for NAT.
If an SGSN is behind NAT, we cannot rely on the default ports. Specifically,
if a GGSN sends a message, the forwarding to the SGSN should go to whichever
port the SGSN last sent from (whether sequence nr is known or not).

Add sgsn_use_sender config and VTY command, and store the sender instead
of the GSN Address IE and default port if set.

Sponsored-by: On-Waves ehi
2015-12-03 14:14:43 +01:00
Neels Hofmeyr d53c6046bc gtphub: prepare: keep tunnel ref in gtp_packet_desc.
Rather than passing a tunnel pointer as function arguments, keep it in the
gtp_packet_desc struct passed around anyway.

Reason: in the next commit (will add sgsn_use_sender), I need the tunnel to be
passed back out to gtphub_handle_buf(), and besides simplifying existing code,
this also makes passing the tunnel back out trivial.

Sponsored-by: On-Waves ehi
2015-12-03 13:59:50 +01:00
Neels Hofmeyr e5a0798c9c gtphub: tweak an error log message 2015-12-03 13:47:05 +01:00
Neels Hofmeyr 8c5b073072 gtphub: Del PDP: replace unnecessary lookup with asserts. 2015-12-03 13:45:15 +01:00
Neels Hofmeyr 8defadbdd2 tests: fix condition to run sgsn, oap, gtphub tests
Sponsored-by: On-Waves ehi
2015-12-03 11:47:34 +01:00
Neels Hofmeyr 59c1b645e2 gtphub: check TEI presence in Create PDP Ctx Response
Sponsored-by: On-Waves ehi
2015-12-03 11:47:30 +01:00
Neels Hofmeyr 87c83d0b89 gtphub: improve logging for invalid packet
Sponsored-by: On-Waves ehi
2015-12-03 11:47:25 +01:00
Neels Hofmeyr d8660ef090 gtphub: cosmetic
During the peer review session with Holger, these things were deemed fixable.

No need to have a static gtp_packet_desc in gtphub_handle_buf.

No need to memcpy, direct assignment does the job.

Remove obsolete comments.

Fix a stray space.

Sponsored-by: On-Waves ehi
2015-12-03 11:47:19 +01:00
Neels Hofmeyr c6d51f5fb4 gtphub: fix restart cleanup peer matching.
Adjust test expectations accordingly.

Sponsored-by: On-Waves ehi
2015-12-03 11:47:16 +01:00
Neels Hofmeyr 996ec1d731 gtphub: wrap gtphub_write() for test suite.
Sponsored-by: On-Waves ehi
2015-12-03 11:47:12 +01:00
Neels Hofmeyr 18d3049612 gtphub: fix use after free.
A tunnel pointer was still being checked after deleting by a call to
expiring_item_del(). 'continue' to the next tun.

Sponsored-by: On-Waves ehi
2015-12-03 11:47:08 +01:00
Neels Hofmeyr 237fee649e gtphub: add restart counter test
Sponsored-by: On-Waves ehi
2015-12-03 11:46:57 +01:00
Neels Hofmeyr 936b890f71 gtphub: Add a debug log
Sponsored-by: On-Waves ehi
2015-12-03 11:46:29 +01:00
Neels Hofmeyr be4bebaad0 gtphub: add test for reused TEI.
Sponsored-by: On-Waves ehi
2015-12-03 11:46:25 +01:00
Neels Hofmeyr 4573ca8834 gtphub: fix: add a missing NULL check
Sponsored-by: On-Waves ehi
2015-12-03 11:46:19 +01:00
Neels Hofmeyr 52c0bd3025 gtphub: cosmetic: early continue for less indent
Sponsored-by: On-Waves ehi
2015-12-03 11:44:39 +01:00
Neels Hofmeyr bc44330671 gtphub: monitor GSNs' restart counters.
If a GSN indicates that it has reset, tear down each known tunnel for that GSN
individually (don't send the GSNs on the other side a different restart
counter, because they represent more than just this GSN).

Sponsored-by: On-Waves ehi
2015-12-03 11:44:37 +01:00
Neels Hofmeyr 3fdba2ed5a gtphub: cosmetic
Move the SGSN read callback next to the GGSN read callback.

Comments.

Tweak an initialization to NULL.

Sponsored-by: On-Waves ehi
2015-12-03 11:44:28 +01:00
Neels Hofmeyr 7559910e8c gtphub_test: add test for Del PDP from GGSN side.
Sponsored-by: On-Waves ehi
2015-12-03 11:44:25 +01:00
Neels Hofmeyr 99a50b3529 gtphub_test: add some cleanup asserts.
Sponsored-by: On-Waves ehi
2015-12-03 11:44:21 +01:00
Neels Hofmeyr 10fc024472 gtphub: handle Delete PDP Context.
During resolution of the header TEI, also return the tunnel struct that
resolved the TEI, so the Delete PDP Ctx code does not need to look it up
again.

Upon Delete PDP Ctx Request, remember the IEs and that a request was made.
Upon Delete PDP Ctx Response, find the pending delete and remove the
corresponding tunnel, iff the response indicates success.

Add a context deletion to regression tests, rename the test appropriately.

Sponsored-by: On-Waves ehi
2015-12-03 11:44:19 +01:00
Neels Hofmeyr 2f67125c32 gtphub: remove obsolete todo comment
Sponsored-by: On-Waves ehi
2015-12-03 11:44:13 +01:00
Neels Hofmeyr 800126b1f3 gtphub: fix segfault when empty config.
gsn_addr_from_str(): return error upon NULL string.
Add some debug logging.

With an empty config, no bind addresses were set, and the address parser
did not check for a NULL pointer, resulting in a segfault.

Sponsored-by: On-Waves ehi
2015-12-03 11:44:08 +01:00
Neels Hofmeyr cd865d62f0 gtphub: be more fatal about not finding an unused TEI.
Sponsored-by: On-Waves ehi
2015-12-03 11:44:03 +01:00
Neels Hofmeyr 085500807c gtphub: fix some style complaints from cppcheck
Sponsored-by: On-Waves ehi
2015-12-03 11:43:57 +01:00
Neels Hofmeyr ff4b630de9 gtphub: add two stubs for Delete PDP msgs
Sponsored-by: On-Waves ehi
2015-12-03 11:43:49 +01:00
Neels Hofmeyr 817bc32696 gtphub: vty: add missing SGSN-proxy output.
Sponsored-by: On-Waves ehi
2015-12-03 11:43:40 +01:00
Neels Hofmeyr a9905a51f9 gtphub: refactor: use side_idx everywhere.
This is a mostly cosmetic change. Instead of separate buffer handling
functions, reduce some code duplication by using a side_idx just like the
plane_idx, with arrays.

Sponsored-by: On-Waves ehi
2015-12-03 11:43:25 +01:00
Neels Hofmeyr 7174b169e0 gtphub: make sure mapped TEIs aren't occupied (incomplete).
This could be done way better, discussion is pending/ongoing. It is indeed
quite unlikely that any user will ever hit this situation, so there is no
strong drive to invest effort in a more comprehensive implementation.

Sponsored-by: On-Waves ehi
2015-12-03 11:40:24 +01:00
Neels Hofmeyr d121ea6124 gtphub: use a single TEI pool across planes.
There's no need to keep two separate number pools when both can be fed
from the same pool. User and Ctrl plane TEIs can technically overlap without
colliding, but it doesn't hurt if they don't overlap, either.

Sponsored-by: On-Waves ehi
2015-12-03 11:40:22 +01:00
Neels Hofmeyr f977320736 gtphub: cosmetic: for_each_side,_plane macros.
Simplify looping over sides and planes. I'm tired of typing the same for
loops all the time.

Sponsored-by: On-Waves ehi
2015-12-03 11:40:18 +01:00
Neels Hofmeyr ba9e9f63bc gtphub: implement restart counter properly.
Force passing a restart counter, by adding such arg to gtphub_start() (test
suite is not affected by this).

In gtphub_main.c, add -r,--restart-file <path> and next_restart_count() to
maintain the counter file. While at it, tweak the cmdline help to unify the
formatting (mostly commas and a missing line break).

Send gtphub's own restart counter. So far, the sender's restart counter was
copied through, which would break as soon as more than one GSN would talk to
the same peer with differing restart counters.

Also fix the in-mem restart counter data type (one octet, not two).

Sponsored-by: On-Waves ehi
2015-12-03 11:40:15 +01:00
Neels Hofmeyr 8d1ffbd3ba gtphub: complain about excess cmdline args.
Sponsored-by: On-Waves ehi
2015-12-03 11:40:12 +01:00
Neels Hofmeyr 005f175c3b gtphub: fix a conditional for log output
Sponsored-by: On-Waves ehi
2015-12-03 11:40:09 +01:00
Neels Hofmeyr fc1be3a0c1 gtphub: avoid segfault for incomplete tunnels.
Sponsored-by: On-Waves ehi
2015-12-03 11:40:05 +01:00
Neels Hofmeyr e54cd1555a gtphub: track tunnels explicitly.
So far, gtphub worked perfectly by only tracking single TEIs ... for probably
most uses. But a Ctrl plane tunnel may have expired despite a still active
corresponding User plane tunnel. The User plane would continue to work
indefinitely, but if any Ctrl messages followed after more than six hours of
Ctrl silence, they would have been dropped due to an expired TEI mapping.

We want to
- combine expiry of a user TEI with its ctrl TEI. (done in this patch)
- upon delete PDP context, remove both user and ctrl TEI mappings. (future)
- when a peer indicates a restart counter bump, invalidate its tunnels.
  (future)

To facilitate these, track tunnels, complete with both SGSN's and GGSN's
address, original and replaced TEIs, all for both user and ctrl plane, in a
single struct. A single expiry entry handles the entire tunnel, instead of
previously four separate expiries for each endpoint identifier.

Add the concept of a "side", being either GGSN or SGSN, to index tunnel
endpoint structs, and so on.

Track the originating side in the gtp_packet_desc.

Add header_tei_rx: set_tei() overwrites header_tei, but the originally received
header TEI is still needed to match a Create PDP Context Response up with its
Request (and for logging).

Adjust the test suite to expect tunnel listing strings instead of TEI mappings,
with a bonus of making it a lot easier to grok, and including the IP addresses.

Add regression test for refreshing tunnel expiry upon use.

Note: the current implementation is as slow as can possibly be, iterating all
the tunnels all the time. Optimizations are kept for a future commit, on
purpose.

BTW, the sequence number mapping/unmapping structures remain unchanged.

Sponsored-by: On-Waves ehi
2015-12-03 11:40:03 +01:00
Neels Hofmeyr 2c8b58139f gtphub: cosmetic/prepare: rename expiry queues.
The expiry queues are already used for resolved GGSN addresses, and will
soon enlist tunnel structs. Hence the naming should be more general.

Sponsored-by: On-Waves ehi
2015-12-03 11:39:57 +01:00
Neels Hofmeyr 1aa0e47104 gtphub: add assertion to ensure expiry ordering.
Make 100% sure the user adds expiring_items in chronological order by asserting
that a newly added expiry is >= the last expiry in the queue. Add llist_last()
to facilitate.

Sponsored-by: On-Waves ehi
2015-12-03 11:39:55 +01:00
Neels Hofmeyr 508514c7c5 gtphub: cosmetic/prepare: add nr_map_refresh().
Sponsored-by: On-Waves ehi
2015-12-03 11:39:49 +01:00
Neels Hofmeyr 29d926be12 gtphub: move timestamp into packet struct.
Instead of passing the current time around in function arguments ('now'),
rather store the current time once upon decoding a GTP packet in the
gtp_packet_desc passed around anyway ('p->timestamp').

Sponsored-by: On-Waves ehi
2015-12-03 11:39:47 +01:00
Neels Hofmeyr 231653a8d0 gtphub: cosmetic: fix an argument name.
Sponsored-by: On-Waves ehi
2015-12-03 11:39:42 +01:00
Neels Hofmeyr 4b2cbdab3e gtphub: first vty show commands.
Start adding VTY commands to show rate counters / statistics / cache dumps.

Sponsored-by: On-Waves ehi
2015-12-03 11:39:41 +01:00
Neels Hofmeyr 1ba50c6598 gtphub: add first rate counters
Sponsored-by: On-Waves ehi
2015-12-03 11:39:39 +01:00
Neels Hofmeyr dba6d1af69 gtphub: cosmetic: clarify bind pointer naming.
Some gtphub_bind pointers point to an array of binds, some point directly at
instances. Make the distinction between the two more obvious by adding an
'_arr' suffix to the array ones.

Partly in preparation for upcoming rate counters.

Sponsored-by: On-Waves ehi
2015-12-03 11:39:38 +01:00
Neels Hofmeyr 20bd6bfef5 gtphub: add explicit cleanup handles.
Clean up functionality is added for the test suite only, to be able to clean
out all allocations and test against memory leaks.

So far, it was sufficient to expire everything to free a gtphub. In preparation
for the upcoming rate counters, which will need to be freed explicitly, add
gtphub functions to clean up everything.

As added bonus, also close the sockets explicitly -- not really needed upon
program exit, neither by the test suite, but *if* we have a cleanup function,
it should clean up everything properly.

Closing the sockets is however kept separate, for the test suite.
gtphub_start() and gtphub_stop() are for normal use (published in gtphub.h),
and gtphub_init() and gtphub_free() are for the test suite, without sockets.
(gtphub_stop() will probably never be called by anyone, but its existence
completes the picture.)

In gtphub_test.c, have a function to clean up the testing gtphub struct. First,
expire everything by timeout, assert emptiness, then call the cleanup function.
Call from each test in the end.

Sponsored-by: On-Waves ehi
2015-12-03 11:39:36 +01:00
Neels Hofmeyr 1ed9a8673d gtphub: ensure cleanup of peer addresses.
Upon calling gtphub_peer_del(), all addresses and ports should already have
expired (by force). Make sure the code heeds that with a so far missing
assertion.

Sponsored-by: On-Waves ehi
2015-12-03 11:39:34 +01:00
Neels Hofmeyr b6c2db569f gtphub: ares vty and init
From sgsn_vty.c, copy the cfg_grx_ggsn_cmd to add an ares server to the static
sgsn_instance.

This is sort of preliminary. As described in comments, the sgsn_ares functions
should actually be separated from the static sgsn structure. gtphub keeps such
an sgsn structure just for the sgsn_ares functions.

Sponsored-by: On-Waves ehi
2015-12-03 11:39:33 +01:00
Neels Hofmeyr d9b1d49485 gtphub: review some logging.
Sponsored-by: On-Waves ehi
2015-12-03 11:39:31 +01:00
Neels Hofmeyr 4960fab767 gtphub: cosmetic: rename a file.
gtphub_ext.c's initial purpose was to wrap a specific function. The file
then turned into everything related to DNS, which fits pretty well. Rename
to gtphub_ares.c.

Tweak the header comment to reflect the new file name.

Sponsored-by: On-Waves ehi
2015-12-03 11:39:30 +01:00
Neels Hofmeyr e2ed8e6cc3 gtphub: nr_map: add min,max and wrap.
Implement min/max bounds for nr_pool, adjust nr_pool_init() and current tests,
and create unit tests for nr_map wrapping.

Sequence numbers range from 0 to 65535, while TEIs range from 1 to 0xffffffff.
Both cause problems when the nr_pool surpasses the range: seq exit their valid
range, causing unmappings to fail, and a TEI would be mapped as zero (invalid).

Add a comment about TEI wrapping, and lose the comment about random TEIs (not
really important).

Sponsored-by: On-Waves ehi
2015-12-03 11:39:28 +01:00
Neels Hofmeyr 334af5dd9d gtphub: fix number map range for TEIs.
Use unsigned int for nr_map, just large enough to fit the TEI space.
Adjust log output formats and casts accordingly.

Fixes: TEIs are uint32_t, but the nr_map so far used int. This would cause TEIs
from 0x80000000 on to be handled and printed as a negative value.

Sponsored-by: On-Waves ehi
2015-12-03 11:39:24 +01:00
Neels Hofmeyr 5e95a41194 gtphub: add to osmoappdesc.py
Sponsored-by: On-Waves ehi
2015-11-30 12:09:06 +01:00
Neels Hofmeyr e5e78c21bb gtphub: add to debian build
By the example of osmo-sgsn, package osmo-gtphub for debian.

Sponsored-by: On-Waves ehi
2015-11-30 11:30:36 +01:00
Neels Hofmeyr ff252bb801 gtphub_test: build only when c-ares and gtp are present. 2015-11-29 18:53:34 +01:00
Neels Hofmeyr 8fbfaa51bb gtphub: remove another obsolete comment. 2015-11-26 22:59:10 +01:00
Neels Hofmeyr 4ae165da61 gtphub: add enable_gtphub_test to atlocal.in.
This line was missing, I noticed only now.
2015-11-24 12:52:13 +01:00
Neels Hofmeyr a4370dd969 gtphub: fix ares segfault: add missing initialization.
The struct gtphub_resolved_ggsn was not initialized properly, so that adding
it to a list caused a segmentation fault.
2015-11-24 12:52:13 +01:00
Neels Hofmeyr 273f875c42 gtphub: lose obsolete comment.
The del_cb is now also used for ares (GGSN resolution) timeouts, and expiry is
anyway separated from nr_map, so this comment is void.

Sponsored-by: On-Waves ehi
2015-11-24 12:52:13 +01:00
Harald Welte 6a8cbe9718 tests/smpp: Fix linking order
At least when using system-wide libtalloc, the LIBOSMOCORE_LIBS
must come last, after the static libraries under libcommon.
2015-11-21 15:43:29 +01:00
Harald Welte 97b6bfa996 Fix compilation with no libc-ares present on the system
This build failure was introduced with the OAP and gtphub changes.
2015-11-21 13:16:08 +01:00
Holger Hans Peter Freyther 1b9c815024 gtp: Fix Makefile.am so maybe distcheck is now going to work 2015-11-20 21:35:01 +00:00
Harald Welte 557c84e9f7 vty: Print NCC/BCC and not just integer value of BSIC 2015-11-20 10:50:24 +01:00
Harald Welte a2bbc5ec0e Fix TSC/BSIC handling bug and remove bts->tsc
This fixes a bug in the following circumstances:
* BSIC is set to 0 in the config file
* No TSC is explicitly specified at the BST level in the config file

In this case, we ended up using BSIC=0 and TSC=7, as TSC=7 is our
default initialization value.

The TSC of the CCCH/BCCH must always be the BCC, which is the lower 3
bits of the BSIC.  Having configuration options for both the BSIC _and_
the TSC at the BTS level therefore makes no sense, as it only adds ways
in which users can configure non-oprational configurations.  So we
remove the bts->tsc member, and keep only the ts->tsc members that allow
us to configure a timeslot-specific TSC that's different from the BTS
TSC (= BCC).
2015-11-20 10:43:31 +01:00
Harald Welte ae2c18c57b oap and gtphub tests must only be compiled of LIBGTP is present! 2015-11-20 10:41:02 +01:00
Harald Welte 0d21ac8f5a Depend on libgtp >= 0.92, as previous versions don't have gtpie.h installed
this fixes compilation for people having older gtp libraries installed.
2015-11-20 10:40:07 +01:00
Harald Welte 24e3c3e136 meas_db.c: fix compiler warnings
s_db.c: In function ‘_insert_ud’:
meas_db.c:65:6: warning: implicit declaration of function ‘rxlev2dbm’ [-Wimplicit-function-declaration]
      rxlev2dbm(ud->full.rx_lev)));
      ^
2015-11-20 10:28:42 +01:00
Neels Hofmeyr 6187e010a8 gtphub: fix echo reply to SGSNs: wrong fd. Add test.
The actual fix is just one character, but also add a regression test against
this, on both CTRL and USER plane.
2015-11-20 01:15:03 +01:00
Neels Hofmeyr 3c820ee532 gtphub: fix three oversights (thanks to coverity).
- an unnecessary if-not-NULL check (1339764);
- a missing nul termination safety net (1339768);
- a typo resulting in the wrong proxy being logged (1339767).

Sponsored-by: On-Waves ehi
2015-11-18 17:34:43 +01:00
Neels Hofmeyr 3d3aa8fb88 gtphub: fix fatal log msg for SGSN proxy.
While reworking the logging, a stray comma found its way into the code.

Fixes coverity 1339765.

Sponsored-by: On-Waves ehi
2015-11-18 17:34:43 +01:00
Neels Hofmeyr 4034897038 gtphub: fix gtphub_read() semantics.
gtphub always wants to know the sender, hence make the from_addr pointer
mandatory.

Fixes two coverity complaints (1339766, 1339764).

Sponsored-by: On-Waves ehi
2015-11-18 17:34:43 +01:00
Neels Hofmeyr ad945b6aa7 fix build: remove obsolete gtphub EXTRA_DIST.
Sponsored-by: On-Waves ehi
2015-11-18 17:34:29 +01:00
Neels Hofmeyr 9cfe037559 gtphub: cosmetic: break long lines.
Fit most of the code in 80 chars width. Some instances still leak past 80
characters because of long function names, inline comments or the like, "the
exception proves the rule."

Sponsored-by: On-Waves ehi
2015-11-16 15:18:24 +01:00
Neels Hofmeyr 063a802d46 gtphub: review log levels, add level arg to LOG().
For maintenance, it is convenient to have the log level explicit at each
log statement.

Tweak some log levels / message formatting while at it.

Sponsored-by: On-Waves ehi
2015-11-16 15:17:20 +01:00
Neels Hofmeyr 390e910125 gtphub: add logging labels to bind struct.
Allow logging the plane (Ctrl/User) and side (SGSN/GGSN) in functions that only
have a gtphub_bind* to work with, by adding a constant label to each bind.

Sponsored-by: On-Waves ehi
2015-11-16 15:17:00 +01:00
Neels Hofmeyr a208c734a2 gtphub: don't always try to do GGSN resolution.
If a GGSN is already known from unmapping, don't invoke a host resolution.
In a live working environment, it wouldn't hurt, because the lookups would
mostly return from the cache. But in a testing environment without a name
server, it barfs on every packet.

Sponsored-by: On-Waves ehi
2015-11-16 15:16:52 +01:00
Neels Hofmeyr 16c3f57ed6 gtphub: fix numerous segfaults, and other stupidities.
Initialize llist_heads to empty (2 were missing). Move those for struct gtphub
instances to gtphub_zero() (one moved, one added).

In from_[gs]gsns_read_cb(), use a return type that can actually reflect
negative return values.

resolved_addr.buf: no need to take the address of a byte array var
(cosmetic).

Pass the proper user data address to sgsn_ares_query(), not the address of
the pointer holding the user data address.

Initialize ggsn_lookup->expiry_entry (was missing). Publish the function for that
in gtphub.h so gtphub_ext.c can use it.

Sponsored-by: On-Waves ehi
2015-11-16 15:16:47 +01:00
Neels Hofmeyr 3317c84c16 gtphub: Add logging for ares queries.
Looking for a segfault, I added a lot of logging. This may be useful for
live testing ares, leaving it in there for now.

Note: I still want to clean up the logging concerning log levels etc. once
we're out of alpha.

Sponsored-by: On-Waves ehi
2015-11-16 15:16:44 +01:00
Neels Hofmeyr c83cd898ef gtphub: fix handling of sender from nonstandard port.
Allow a peer sending from an unknown port but a known address, and just
create the port (and unmap the seq nr back to this port later to return
the response to the sender).

Only an SGSN on the Ctrl plane is allowed to make the very first contact
from an unknown address.

Sponsored-by: On-Waves ehi
2015-11-16 15:16:39 +01:00
Neels Hofmeyr e921e32c82 gtphub: fix User plane decoding, add unit test.
Split decoding return code GTP_RC_PDU in GTP_RC_PDU_C and GTP_RC_PDU_U.
Don't do IEs in GTP_RC_PDU_U.

Add a unit test for User plane data, expected to fail (nonstandard port case).

In gtphub_test.c, tweak logging so that it is easily visible which test
produced which output. Also add the global resolved_sgsn_addr and ggsn_sender,
symmetrically to resolved_ggsn_add and sgsn_sender.

Sponsored-by: On-Waves ehi
2015-11-16 15:16:37 +01:00
Neels Hofmeyr c227594394 gtphub: make test code reusable for future tests.
Generalize to make the PDP ctx message definitions and "sending" of messages
from SGSN->gtphub->GGSN and back reusable in future tests.

Publish gsn_addr_from_sockaddr() in gtphub.h for use in gtphub_test.c.

Use an osmo_sockaddr for resolved_ggsn_addr, because one is needed for
comparison in probably every future test.

Add LVL2_ASSERT() to print assertion message and return instead of abort,
so that functions can be called from several tests without losing the
info of which test caused it from which line.

Use globals for struct gtphub and time_t now, to reduce nr of args that need to
be passed around when writing tests. Add a default test setup function.

Sponsored-by: On-Waves ehi
2015-11-16 15:16:36 +01:00
Neels Hofmeyr 5b664f4b9b gtphub: add/fix IMSI and APN IE error handling
Sponsored-by: On-Waves ehi
2015-11-16 15:16:34 +01:00
Neels Hofmeyr bb3d6785e1 gtphub: fix Echo behavior: respond directly.
Up to now I used the Echo as a test for sequence nr mappings. But Echos
should be handled differently: they are scoped on the link and an Echo
response should be sent right back to the requester.

Sponsored-by: On-Waves ehi
2015-11-16 15:16:32 +01:00
Neels Hofmeyr 30f7bcbd79 gtphub: add first bits of GRX ares
For the resolving function, change the function signature to return a
gtphub_peer_port. In consequence, publish two functions concerned with
gtphub_peer_port instances for use in test and gtphub_ext.c.

Add GGSN resolution queue, callback and cache. Simple implementation: if an
SGSN asks for a GGSN, it will first get no answer, and I hope it will ask again
once the GGSN is in the cache.

Within gtphub_ext.c, have a dummy sgsn struct, as the sgsn_ares code currently
depends on it (half the functions pass an sgsn instance pointer around, but the
other half use the global one).

In the unit tests, wrap away the ares initialization so that they can work
without a DNS server around. The netcat test breaks because of this, will
remove it.

Using sgsn_ares, implement the gtphub_resolve_ggsn_addr() function, I hope:
untested.

Minor cosmetics just to see if you're paying attention... ;)

Sponsored-by: On-Waves ehi
2015-11-16 15:16:30 +01:00
Neels Hofmeyr c8a614d2e9 Add GTP hub initial code base.
First steps towards a new GTP hub. The aim is to mux GTP connections, so that
multiple SGSN <--> GGSN links can pass through a single point. Background:
allow having more than one SGSN, possibly in various remote locations.

The recent addition of OAP to GSUP is related to the same background idea.

(This is a collapsed patch of various changes that do not make sense to review
in chronological order anymore, since a lot of it has thorougly transmorphed
after it was first committed.)

Sponsored-by: On-Waves ehf
2015-11-16 15:16:26 +01:00
Neels Hofmeyr 65482c919f sgsn_vty.c: fix typo 2015-11-10 22:53:15 +01:00
Holger Hans Peter Freyther 98fa3dc1c6 gbproxy: Count more GSM 04.08 messages
Extend the ul/dl counting to count the usual messages on the
Gb interface. Add counters for the attach, routing area update,
pdp context activation and deactivation procedures. Update the
test result with the new counters.
2015-11-10 09:35:30 +01:00
Martin Hauke 9270dc8ca3 Fix Warning: openbsc implicit-pointer-decl meas_udp2db.c:50 2015-11-05 21:04:34 +01:00
Martin Hauke 4316cb2f25 Fix no-return-in-nonvoid-function meas_vis.c
RPM post-build-checks found some issue and marks these as error:

[   38s] I: Program returns random data in a function
[   38s] E: openbsc no-return-in-nonvoid-function meas_vis.c:118
2015-11-05 21:04:29 +01:00
Holger Hans Peter Freyther 292769e19e stats/mgcp: Initialize the statistics for MGCP as well
There are currently no reate counters but this will hopefully
change in the near future.
2015-11-02 16:20:32 +01:00
Jacob Erlbeck 46caed8fc4 stats: Set class_id in rate_ctr group descriptions
This commit adds the class_id initialiser to all rate_ctr_group_desc
definitions.

Sponsored-by: On-Waves ehf
2015-11-02 16:04:16 +01:00
Jacob Erlbeck 64630cccc7 stats: Enable stats for sgsn, gbproxy, nitb, bsc, nat
This commit initialises and enables the stats subsystem for the given
binaries.

Sponsored-by: On-Waves ehf
2015-11-02 16:01:27 +01:00
Pablo Neira Ayuso 11cb27ece6 mgcp_osmux: available circuit IDs from 0 to 255, not from 0 to 128
Holger reports that the bitmap that accounts for available Osmux circuit
IDs is limited to 128, when the maximum number of circuit IDs are
determined by the uint8_t field in the header (ie. 256 circuits).

[hfreyther: Update the testcase now that we have more ids to allocate]
2015-11-02 13:26:26 +01:00
Neels Hofmeyr 568a727550 oap: add OAP config to VTY
Sponsored-by: On-Waves ehf
2015-11-02 12:56:49 +01:00
Neels Hofmeyr 9c534fdbe8 gsup/oap: add OAP to GSUP client.
Trigger an OAP registration upon IPA connect. Feed incoming OAP messages to
oap_handle() and send replies returned by it.

Add oap_config to sgsn_config (todo: vty).

Sponsored-by: On-Waves ehf

[hfreyther: Fix coding style]
2015-11-02 12:56:47 +01:00
Neels Hofmeyr 89ef324eab oap: add OAP API test
Sponsored-by: On-Waves ehf
2015-11-02 12:56:45 +01:00
Neels Hofmeyr f06046b6af oap: add oap testsuite skeleton
Sponsored-by: On-Waves ehf
2015-11-02 12:56:43 +01:00
Neels Hofmeyr d739f092be oap: implement initial OAP API.
Add oap.[hc] and oap_messages.[hc].

Sponsored-by: On-Waves ehf
2015-11-02 12:56:41 +01:00
Neels Hofmeyr d48f057328 libcommon: soak up three static functions.
Add new kitchen sink openbsc/utils.h and libcommon/utils.c to make three so far
static functions public (so I can use them in the upcoming OAP code).

A place to put them could have been the gprs_utils.h, but all general functions
in there have a gprs_ prefix, and todo markings to move them away. All other
libcommon headers are too specific, so I opened up this kitchen sink header.

Replace the implementation of encode_big_endian() with a call to
osmo_store64be_ext(). See comments.

Apply the change in Makefiles and C files.
2015-11-02 12:56:40 +01:00
Holger Hans Peter Freyther fe60cfb1d6 sgsn: Fix up the VTY doc strings
The documentation needs to end with a \n and T3316
needs to have some text. I think it is the T3316
timer that has no action on the network side.

<command id='timer t3312 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3322 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3350 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3360 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3370 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3313 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3314 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3316 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3385 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3386 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3395 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='timer t3397 &lt;0-65535&gt;'>
        <param name='&lt;0-65535&gt;' doc='(null)' />
2015-11-02 12:56:37 +01:00
Harald Welte 69ca8f01ec SGSN: Fix typo in VTY license statement.
It mentioned AGPLv3+ and refers to the hyperlink of v3, but still
stated "Version 2 or later".  That was a typo at the time.
2015-10-29 10:36:28 +01:00
Daniel Willmann 537d480f39 gprs/gb_proxy: Use RAND_bytes for gbproxy TLLI/TMSI allocation
This change has some implications for the test case. It manipulated
bss_ptmsi_state and sgsn_tlli_state variables to make the output of
rand_r() and thus the TLLI/TMSI used predictable.
This possibility is gone when using RAND_bytes() so instead it is
overridden by a function that returns a deterministic sequence of values
(0x00dead00, 0x00dead01, ...). The test cases are adapted to expect
these values instead of the pseudo random values before.

The gbproxy_test stdout file changes as well, but only where the
TLLI/TMSI is displayed (in the hex dumps as well as the TLLI cache
entries).  All other output is the same.
2015-10-13 10:20:26 +02:00
Daniel Willmann d1554ecb78 gbproxy/test: Add and call cleanup_test function
This (currently empty) function is meant to contain code that cleans
up the left-overs of the test functions. This is needed by the next
commit to reset the RAND_bytes sequence.
2015-10-13 10:18:34 +02:00
Daniel Willmann 044ce5fb84 gprs: Use RAND_bytes for p-tmsi
[hfreyther: Link to libcrypto, include header, add uint8_t* cast]
2015-10-13 10:00:16 +02:00
Jacob Erlbeck 133e8624ef sgsn/test: Really parse received DL LLC messages
Currently just the number of intercepted downlink messages is counted
and eventually checked. The contents of the messages is lost. The
PTMSI contained in ATTACH/RAU Accept messages is just 'guessed' by
resetting the random number generator after reference PTMSIs have
been generated. While this works with rand_r, RAND_bytes cannot be
forced to recreate a certain number sequence this way (unless the
backend is replaced).

This commit changes that behaviour so that the last received msgb is
kept and decoded. The PTMSI that has been assigned by the SGSN is
then taken in the affected test cases and used instead of a 'guessed'
one. This is similar to how a real MS would react to the Accept
message.

Sponsored-by: On-Waves ehf
2015-10-13 09:59:34 +02:00
Jacob Erlbeck cf15187458 sgsn/test: Add and call cleanup_test function
This (currently empty) function is meant to contain code that cleans
up the left-overs of the test functions. This will be needed by the
next commit that will store the last received msgb for later inspection.

Sponsored-by: On-Waves ehf
2015-10-13 09:58:29 +02:00
Holger Hans Peter Freyther a777c9ee3d osmux: Allow to listen to a specific address
For a setup with multiple network interfaces be able to pick
the one that osmux should be used/visible.
2015-10-12 20:06:16 +02:00
Holger Hans Peter Freyther 9861c122dd sgsn: Fix pattern for too long msisdn
We don't care how many bytes the length has but the
destination we want to copy to.

Fixes: CID#1296813
2015-10-12 11:06:34 +02:00
Holger Hans Peter Freyther fa07b489dc Revert "gprs: Use RAND_bytes for p-tmsi"
The commit not compiling/linking should have been a strong
indicator that it has not been tested either.

This reverts commit 6cf0249dac.
2015-10-12 09:55:59 +02:00
Holger Hans Peter Freyther f3316e30d6 mgcp: Use the right bind addresses for NET and BTS
This API is a bit unfortunate as the caller will also
access the endpoint directly. E.g. like this:

        output = bsc_mgcp_rewrite(...,
                      mgcp_net_src_addr(endp),
                      endp->net_end.local_port, -1,

In terms of "terminology" the "net" was meant to be bad
internet and the "bts" is the local and trusted network
segment. With this terminology the "bts" would be the
call-agent/MGW and "net" where the BSCs will send data
to but that is not the case and terminology actuallys
refers to:

	* net: The addresses exposed to the entity that
	made the MGCP call
	* bts: The system where we get our data for the
	local audio flow.

Fix the method but leave the API as it is. Use the net_end
in the net_src method and the bts_end in the bts_src method.
2015-10-12 09:37:35 +02:00
Holger Hans Peter Freyther d74cce266b Merge branch 'zecke/features/osmux-reliability'
Not verified that the audio handling is working. I saw a circuit
set-up of the call though.
2015-10-12 09:11:32 +02:00
Holger Hans Peter Freyther 6962127982 osmux: Make sure that bigger Osmux ids actually fit
We put a signed integer into this string but did not account
for the newline and for the terminating NUL of the string. Add
the newline to the string and add one for NUL. Spotted while
accidently having a CID of 255.
2015-10-12 09:11:25 +02:00
Holger Hans Peter Freyther 1afe7c7fe5 osmux: Remember the allocated CID and make sure it is released
There appears to be a leak of CIDs:
 <000b> mgcp_osmux.c:544 All Osmux circuits are in use!

There are paths that a CID had been requested and never released
of the NAT. Remember the allocated CID inside the endpoint so it
can always be released. It is using a new variable as the behavior
for the NAT and MGCP MGW is different.

The allocated_cid must be signed so that we can assign outside
of the 0-255 range of it.

Fixes: OW#1493
2015-10-12 09:11:25 +02:00
Holger Hans Peter Freyther 20626dde8f osmux: Enforce Osmux only global and per BSC configuration
Extend the osmux only setting from the MGCP MGW to the NAT. This
is applied when an endpoint is allocated and/or when the allocation
is confirmed by the remote system.

Not tested. The impact should only be when the new option is
being used.

Fixes: OW#1492
2015-10-12 09:11:25 +02:00
Holger Hans Peter Freyther 6598ded5cd osmux: Allow to enforce using Osmux for the client
Some systems only want to use Osmux. In case only Osmux
should be used fail if it has not be offered/acked.

Client:

Verified On, Off and Only with X-Osmux: 3 and without this field.
<000b> mgcp_protocol.c:823 Osmux only and no osmux offered on 0x14
<000b> mgcp_protocol.c:884 Resource error on 0x14

NAT:

Not tested and implemented

Fixes: OW#1492
2015-10-12 09:11:25 +02:00
Holger Hans Peter Freyther 15a40db606 osmux: Add introspection for osmux.
* Print number of used CIDs for the system
* Hopefully this is just the beginning
2015-10-12 09:11:25 +02:00
Holger Hans Peter Freyther b45e4d80b6 osmux: Do not divide the number of bytes by eight.
sizeof(uint8_t) == 1 and there is no need to create an array
with 16 bytes and then only use the first two of them. This
means the CID range is from 0 to 127 and we should be able
to extend this to 256 by changing the array size to 32. Update
the testcase now that we can have more than 16 calls with Osmux.
2015-10-12 09:11:25 +02:00
Holger Hans Peter Freyther 641d387409 osmux: Test cid allocation and de-allocation
* Test that one can get an id
* That they are assigned predicatble right now
* That returning them will make the number of used ones go down
* That allocating more will fail
2015-10-12 09:11:25 +02:00
Daniel Willmann 2aedfbdfe1 libmsc: Use RAND_bytes to generate a token
[hfreyther: Add cast to uint8_t to fix compiler warning]
2015-10-12 09:07:45 +02:00
Daniel Willmann 62a63f54a6 libmsc: Use RAND_bytes to choose auth tuple
[hfreyther: Fix compiler warning about unused variable]
2015-10-12 09:06:59 +02:00
Daniel Willmann 6cf0249dac gprs: Use RAND_bytes for p-tmsi
[hfreyther: Link to libcrypto, include header, add uint8_t* cast]
2015-10-12 09:05:48 +02:00
Daniel Willmann cdeb815c78 libmsc: Use RAND_bytes when choosing a tmsi
Require openssl version to be >= 0.9.5 because we rely on the RAND_bytes
return value.

[hfreyther: Add cast to uint8_t*]
2015-10-12 09:03:15 +02:00
Holger Hans Peter Freyther b3cbd9aa3b mgcp: Indicate where the sending failed
The log message does not help and says where the data is
being sent to. This is because we have both a RTP and RTCP
port. Remember if we failed with RTCP or RTP and improve
the log message.

I was searching a case where the port was bound to a local
address (e.g. 127.0.0.1) and tried to send the data to a
public one (e.g. 8.8.8.8).
2015-10-08 19:15:41 +02:00
Neels Hofmeyr 0e62e595a6 Add OAP design document.
Sponsored-by: On-Waves ehf
2015-10-07 18:59:55 +02:00
Neels Hofmeyr 06cfe00c71 gsup: factor out header composition & sending.
Move IPA header composition and sending to new static gsup_client_send() (so I
can use it in the upcoming OAP code).

Sponsored-by: On-Waves ehf
2015-10-07 18:59:01 +02:00
Holger Hans Peter Freyther 8b4e584621 Merge branch 'zecke/features/amr'
Fix AMR support for the BSC, remove code duplication, make it
less prone to error.
2015-10-02 15:30:38 +02:00
Holger Hans Peter Freyther 7a77d0155f amr: Attempt to unbreak the AMR support in the BSC
The signature of mr_config and the BSC implementation didn't
match and the compiler was warning about it:

osmo_bsc_api.c:530:2: warning: initialization from incompatible pointer type
 .mr_config = bsc_mr_config,
 ^
osmo_bsc_api.c:530:2: warning: (near initialization for ‘bsc_handler.mr_config’)

Change the mr_config again and provide an implementation
that will set the ms and bts data structure. It would be
better to put the size outside of the IE but I am not going
to change it right now. It would also be nice to either move
the AMR setting into the "nitb" structure or have the msc
data be used _after_ the bts settings. This needs to be
cleaned up in the next step.

Manually verified by placing a MO call and checking that
both the channel mode modify and the mode modify request
contain the multi rate config with the rate mr config
(length two bytes, version 1, icmi==1, no start mode being
set).
2015-10-02 15:30:29 +02:00
Holger Hans Peter Freyther a174a47811 amr: Kill more duplication and let the code work one of the modes 2015-10-02 15:30:29 +02:00
Holger Hans Peter Freyther 615ed46a6a amr: Instead of putting ms/bts into the same struct.. use it twice
This way a lot of if/else can just be killed by the caller deciding
which of the two instances to use.

I have copied both branches to new files, replace bts for ms in one
of them and ran diff on it. There is no difference.
2015-10-02 15:30:29 +02:00
Holger Hans Peter Freyther 11cb7a9fd9 amr: Remove some code duplication in preparation
Merge two copies into a local static helper function. The format
of the message will change and then it is easier to modify it in
one place than in two.

Sadly the original patch was merged before this clean-up so do
the clean-up as second step.

Conflicts:
	openbsc/src/libbsc/abis_rsl.c
	openbsc/src/libbsc/gsm_04_08_utils.c
2015-10-02 15:30:28 +02:00
Neels Hofmeyr 130be40c3e sgsn_main: in -h, print default config file 2015-09-24 17:29:08 +02:00
Holger Hans Peter Freyther d3496aed69 debian: Attempt to fix packaging and point to a meaningful readme
The empty README file has been removed but the package still tries
to install it.
2015-09-24 16:45:21 +02:00
Holger Hans Peter Freyther 3e4e8cfb74 vty: Change the return type from enum to int
clang complained that different enums are mixed with the
return type and we actually want this to be an int now.
2015-09-24 15:39:30 +02:00
Holger Hans Peter Freyther 925504bfe0 gbproxy: Add quirk commands to allow upgrade from pre-release
The pre-release didn't add a newline after the apn and the patching
pattern command. Create a quirk command that combines both. The
pre-release didn't include a differentation between routing and
patching.

The TLLI handling has a different and more generic name now. Make
it handle the old one that is actively used.

Add a file with the broken format and the standard config file
test should pick it up.
2015-09-24 10:28:43 +02:00
Neels Hofmeyr e57e0fa701 bsc_nat: Fix 1 log error output of wrong variable. 2015-09-23 19:02:36 +02:00
Andreas Eversberg 732665269e Add full AMR multirate IE support with VTY config for MS and BTS side 2015-09-22 16:46:27 +02:00
Neels Hofmeyr 354d1f3084 osmo-nitb: obsess about --help formatting.
Make every line use same punctuation style ('.' at the end and start in caps).
Insert spaces to have all help texts in a column.
2015-09-15 19:36:19 +02:00
Neels Hofmeyr c6a8d09b78 Remove empty README.
This README's content has moved to openbsc/README. This is just an empty
file now.
2015-09-15 19:36:19 +02:00
Neels Hofmeyr 51cf69cdb4 openbsc/configure.ac: check for pcap/pcap.h.
The build process requires pcap/pcap.h in openbsc/src/utils/meas_pcap2db.c, but
the configure script did not check for that file.
2015-09-15 19:36:19 +02:00
Holger Hans Peter Freyther 4b4a187b4f Merge branch 'zecke/features/rtp-bridge'
* Implement the rtp-bridge mode for MNCC
* Audio doesn't flow through the NITB at all
* It only works with IPv4 BTSes right now
* We need to select an audio codec way too early
* No tandem free operation
* Early assignment always equals TCH/F
2015-09-14 10:53:35 +02:00
Holger Hans Peter Freyther 53122b09d0 mncc: Use the default codec from the built-in mncc mode
In case of the RTP bridge mode we need to select the codec
ourselves. Rely on the same (incomplete) codec selection that
can be done using the mncc-int configuration node. This might
gain bearer capabilities support.

In case of a SDCCH a TCH/F will be attempted to be assigned.
This is an open issue for both modes and there should be a
preference for full or half-rate channels somewhere.
2015-09-14 10:12:29 +02:00
Holger Hans Peter Freyther c21dcb20e5 mncc: Implement CRCX->MDCX for handover for direct rtp mode
Implement sending MDCX on the newly allocated channel and send
the data to the same destination as the currently connected one.
This way the receiver can implement RTP RFC Appendix A.1 and
deal with the new source.
2015-09-14 10:12:29 +02:00
Holger Hans Peter Freyther c8a6c13e4e mncc: Implement the direct RTP mode for ip based systems
For the LCR rtp-bridge audio should directly flow to the
remote system. In contrast to the original patch audio
will now flow directly from the BTS to the remote system.
This assumes that BTS and the remote system are in the
same network segment and can directly communicate.

There are various limitations in the first iteration of
the implementation:

We could (and in the future) should delay the assignment
but currently we are forced to pick the channel and move
it to the audio state. In case we are located on a SDCCH
we always need to change but if we are on a TCH we could
send the ipa.CRCX and change the audio state a lot later.
The net effect is that the audio codec selection needs to
be done in the NITB code and not in the system connected
to it.

This only works with ip based systems. For E1 systems one
could still use the RTP socket or even try to move this
out of the process.

There is no code for handover handling and it relies on
the remote system dealing with the SSRC change of the
system.
2015-09-14 10:12:29 +02:00
Holger Hans Peter Freyther ffbf45e09e mncc: Update the protocol to match LCR
This adds the protocol definition for the RTP bridge extension
of Andreas Eversberg and bumps the protocol version.

I added the missing mncc mappings from value to string.

[ 5cf8fb10ea3addcae74d37f4dbf1c1be664df53e protocol extension
  5dac90de38990b188f499c602bf18a4f232070e8 payload extension]
2015-09-14 10:12:29 +02:00
Alexander Chemeris 08c508f84a msc: Add channel information to the meas_feed, bump version to v1. 2015-09-14 10:08:41 +02:00
Pablo Neira Ayuso d721579a6a osmux: fix show online-help
Before:

    <command id='osmux dummy (on|off)'>
      <params>
        <param name='osmux' doc='RTP multiplexing' />
        <param name='dummy' doc='Enable dummy padding' />
        <param name='on' doc='Disable dummy padding' />
        <param name='off' doc='(null)' />
      </params>

After:

    <command id='osmux dummy (on|off)'>
      <params>
        <param name='osmux' doc='RTP multiplexing' />
        <param name='dummy' doc='Dummy padding' />
        <param name='on' doc='Enable dummy padding' />
        <param name='off' doc='Disable dummy padding' />
      </params>
    </command>

Note the 'null' string in 'off'. Reported by Holger.
2015-09-07 11:31:17 +02:00
Ciaby 92360b15e3 Add SMPP support in the debian build, include libsmpp34-dev as a dependency. 2015-09-04 16:28:34 +02:00
Holger Hans Peter Freyther 614aba391d mgcp: Fix grammar, clean-up return codes
Mike's patch included clean-ups I want to apply separately and
change them a bit. If we return from an else we don't need to
put the else.

* Try the E1 trunk first
* Then try a local virtual trunk
* Fail if none of the above returned
2015-09-04 16:05:30 +02:00
Michael McTernan 79135acbb8 mgcp: Remove use of hardwired @mgw from endpoint IDs.
Remove the host portion of the endpoint Id.  This requires less
configuration and we are probably fine to trust that MGCP only
received messages designated for it.
2015-09-04 16:05:30 +02:00
Harald Welte e5ba92e7be system_information.c: Distinguish two previously identical log msgs 2015-09-04 06:25:48 +02:00
Harald Welte e18f78e81d Fix neighbor channel list generation for 1900 MHz PCS band
In the 1900 MHz PCS band, we always generated neighbor cell lists
consisting of only a single neighbor cell, rather than al the
configured BTSs.
2015-09-04 06:25:48 +02:00
Holger Hans Peter Freyther 8fc568466c debian: Require ares for the SGSN and GGSN resolving 2015-08-23 18:06:09 +02:00
Holger Hans Peter Freyther 0190d790b6 debian: Add libssl-dev for the NAT 2015-08-23 18:05:14 +02:00
Holger Hans Peter Freyther c390ae8eaf mgcp: Allow to bind to different ports for net/bts ports
When using multiple interfaces on a system one can now configure
which will be served for the BTS ports and which will be served
for the network. The direct usage of source_addr is now only to
initialize the MGCP receiving port itself.
2015-08-20 17:24:03 +02:00
Holger Hans Peter Freyther e6ed009a36 mgcp: Begin to separate network and bts endpoints
Make it possible to bind the call-agent to a specific IP address
and the network and bts end to different ip addresses. Begin by
clarifying which source ip address we want to have.
2015-08-20 14:58:19 +02:00
Holger Hans Peter Freyther ceef936ea8 mgcp: Add transcoding from PCMU as well
Use the existing ulaw encode/decode to support PCMU as well.
The MERA VoIP switch has some severe issues with the GSM codec
and it appears easier to enable transcoding for it.

The mera switch doesn't appear to cope with codec change
between a SIP 180 trying and the 200 ok connection result.

Inserting the codec is touching too many places. Ideally we
should have the transcoding function as pointer in the struct
as well but the arguments differ.. so it is not a direct way
forward.
2015-08-19 15:44:44 +02:00
Pablo Neira Ayuso 57e95a22f0 osmux: add option to pad the circuit with dummy messages
Iridium is a satellite network which operates a GPRS-like that allows you to
get speeds up to 128kbit/s. However, it takes from 5 to 6 secs to get the
bandwidth allocated, so the conversation is garbled during the time.

This patch uses the new dummy padding support in libosmo-netif that is
controlled through the osmux osmux_xfrm_input_open_circuit().

This includes a new VTY option for osmux.
2015-08-19 00:17:31 +02:00
Harald Welte ecff2424e5 Use 'ROUTING AREA' consistently, not 'ROUTEING AREA'
The spec unfortuantely uses both terms and has no consistent spelling,
but in our logging output we can at least try to be consistent.
2015-08-18 19:35:02 +02:00
Harald Welte b9845f937e GSM/GPRS 04.08: Don't print numeric mobile identity types
I guess none of our users knows what a mi_type=0x02 is, but most would
know what an IMSI or a TMSI is.  So let's use the newly introduced
gsm48_mi_type_name() function to fix this.
2015-08-18 19:35:02 +02:00
Harald Welte 6b39feedc7 GMM: fix format string compiler warning 2015-08-18 19:35:02 +02:00
Harald Welte 601cf12f81 GMM: Don't use DGPRS logging category from GMM 2015-08-18 19:35:02 +02:00
Harald Welte eb98c74fb1 GMM: use MMCTXP whenever possible to include MS identity in log output 2015-08-18 19:35:01 +02:00
Harald Welte 22df4ac848 LLC: Don't dispatch XID frames into GMM
For some odd reasons the XID is not a separate SAPI but has been kludged into
the GMM SAPI.  This means we ahve to be careful not to dispatch XID frames into
GMM.  We do this by introducing an explicit check for UI frames before the
dispatch to GMM.

The previous code already was doing "the right thing" but printed occasional
messages like "gprs_gmm.c:2082 Unknown GSM 04.08 discriminator 0x01: 01 00 0e
00 32 11 03 16 01 90 63 28 0b".  Those should be gone after this patch.
2015-08-18 19:35:01 +02:00
Harald Welte 78fa99103d LLC: Don't feed length=0 frames to SNDCP / GMM 2015-08-18 19:35:01 +02:00
Harald Welte 6a19dd0d31 GMM: add hexdump in case of unknown pdisc/msgtype 2015-08-18 19:35:01 +02:00
Harald Welte 9450882901 sgsn: make all SGSN timers configurable via the VTY 2015-08-18 19:35:01 +02:00
Andreas Eversberg 39ba248608 Send RADIO LINK TIMEOUT value via OML attribute to BTS
The same radio link timeout value is used for BTS and MS side.
2015-08-17 16:43:14 +02:00
Andreas Eversberg 4d4944a07d Add option to set RADIO LINK TIMEOUT value via VTY 2015-08-17 16:31:35 +02:00
Andreas Eversberg 93e795c1fd Add check for non existing lchan at tch_frame_down()
Traffic cannot sent to BTS, if there is (currently) no logical channel
associated with the transaction.

This happens, if TCH traffic is received from upper layer, but there is
no lchan available before completing immediate assignment, handover or
assignment process.

[hfreyther: The code has not been moved to tch_frame_down
but the issue looks similiar]
2015-08-17 16:21:24 +02:00
Holger Hans Peter Freyther 4c97435b35 mgcp: Test we don't crash on the NAT dummy MGCP message
We want the port and IPv4 address to be extracted but don't
expect any change in audio codecs.
2015-08-17 15:50:01 +02:00
Holger Hans Peter Freyther d17bc7b3a8 mgcp: Avoid crashing when rtpmap is not complete
The NAT sends an incomplete SDP file for the purpose of informing
the BSC about the remote IP/PORT early. The case of an incomplete
SDP file was not considered. Check if there is a codec and if not
skip it.

TODO: We need to have a better end-point life cycle test.
2015-08-17 15:22:30 +02:00
Holger Hans Peter Freyther a334e90ddf Merge branch 'zecke/features/sdp-codec-handling'
Move forward while preserving the legacy handling. Beging to
extract SDP rtpmap information and select codecs atfer this.
It is a foundation we can now build further and better check
ons.
2015-08-14 15:48:54 +02:00
Holger Hans Peter Freyther aeadf261e5 mgcp: Allow to enforce that the codecs need to match
We have a lot of legacy that I am afraid to break. We have
everything in place to make a good codec selection (e.g. if
we can avoid transcoding, pick the one with best quality or
the lowest speed). Right now I have a specific case where
from all options I want to pick GSM. Guard the codec compat
check behind the disallow transcoding option to make sure
to not break legacy application.
2015-08-14 15:43:06 +02:00
Holger Hans Peter Freyther ca7d05bdb9 mgcp: Turn SDP file parsing in a two stage process
First collect everything we know and the mapping. E.g. a genuis
could remap "3" to "AMR" so we only know the codecs once we are
at the end of the SDP file. Once we have collected everything we
can select the audio codecs. The current code is compatible in
that two codecs will be selected regardless of if they make any
sense or not.

mgcp_set_audio_info could re-use some of our codec information
but then the caller in the MGCP protocol needs to be updated as
well as we use the "I: GSM" information to derive the codec from
there.
2015-08-14 11:13:48 +02:00
Holger Hans Peter Freyther a611da8407 mgcp: Move the SDP handling into a separate file/module
The SDP file handling will get more complicated in terms of
codec selection so let's remove it from the protocol handling
before we start blowing it up in size.
2015-08-14 09:24:11 +02:00
Holger Hans Peter Freyther 0eaad4f216 mgcp: Remove unused parsing data struct
This struct was removed when we switched to strtok_r for
parsing the data. Remove the left-over.
2015-08-14 08:54:58 +02:00
Holger Hans Peter Freyther e9f7c9925c nat: Forward SDP files with multiple payload types in it
The parsing code assumed that there will be a single payload
type and this assumption is clearly wrong. Forward all of the
payload types. The code is still only extracting the first
type from the list. The variable name has been renamed to
reflect this.
2015-08-13 18:53:10 +02:00
Holger Hans Peter Freyther 29d58b734d sms: Attempt to plug memory leaks seen at Rhizomatica
Using the talloc leak report we see that there are some msgb's
that are allocated for SMS but we don't have transactions or
SMS around. We need to improve the name of the messages to
uniquely dscribe where they are from but the obvious leak does
occur in this routine.

The no available transaction id is most likely the case where
we leak memory. This should not occur and shows another issue
with the smsqueue/smpp handling. It doesn't explain the subscr
reference count issue either.

Extract of the leak report:

  GSM 04.11                      contains   1160 bytes in   1 blocks (ref 0) 0x2517dc0
  GSM 04.11                      contains   1160 bytes in   1 blocks (ref 0) 0x24b56e0
  GSM 04.11                      contains   1160 bytes in   1 blocks (ref 0) 0x23e7930
2015-08-12 13:38:22 +02:00
Holger Hans Peter Freyther c9dbe3c7b1 paging: Provide information about pending requests
For debugging it is nice to know how many requests are
pending. Simply count it and print it besides the paging
part.
2015-08-08 20:49:04 +02:00
Holger Hans Peter Freyther 2f25764e51 Merge branch 'zecke/fixes/subscr-leak'
At the rhizomatica sites some unauthorized subscribers have a
last used from long time ago but a bigger reference count. This
means that we have an unbalanced subscr_get/subscr_put that we
need to investigate. These two fixes are genuine fixes but are
unlikely to fix the issue I am not understanding yet.
2015-08-08 20:47:02 +02:00
Holger Hans Peter Freyther 5425e5ea27 subscr: Fix subscr refcount issue in case of message error
In case the SMPP payload didn't include the right fields we
would leak the subscr reference count.
2015-08-08 20:46:50 +02:00
Holger Hans Peter Freyther 8159455506 subscr: Fix potential subscr ref count issue
In case the subscriber is currently busy we would omit the
subscr_put. This seems to be very hard to hit as the subscr
need to be active and at the same time be selected for the
purge operation.
2015-08-08 20:46:49 +02:00
Holger Hans Peter Freyther e019b564ec Merge branch 'zecke/changes/paging-order'
Various paging clean-ups. I couldn't re-produce the assert that
was hit by Rhizomatica in the subscriber code. Let's clean things
up a bit to avoid some of the potential issues this code had.

Always stop paging regardless of where the subscriber is at the
time of the cancellation.
2015-08-08 20:44:42 +02:00
Holger Hans Peter Freyther eb48cafac9 paging: Forget we were paging after the dispatch
So in case somebody is starting paging from within a paging
expired callback we would dispatch the paging request right
away with the same failure.
2015-08-03 12:02:14 +02:00
Holger Hans Peter Freyther 778c7d1544 paging: Stop paging everywhere before dispatching any signal 2015-08-03 12:02:14 +02:00
Holger Hans Peter Freyther ba43365e96 paging: Go through all BTS to stop paging
As the comment says we should not rely that the paging
occurs on the current LAC. We might page at more BTS.
Walk all the BTS to stop paging. No callbacks will be
issued by this stop operation.
2015-08-03 12:02:14 +02:00
Holger Hans Peter Freyther 469f992b2b paging: In case paging failed stop it everywhere
In case we can't page on a BTS then stop it everywhere. The
callers of paging_request assume that this is kind of an
atomic operation and we should help with that.
2015-08-03 12:02:14 +02:00
Holger Hans Peter Freyther b618c7ec9b paging: Move the silent_call code to use the subscriber request
Coordinate with the normal subscriber channel requests instead
of going to page ourselves. This might lead to getting a channel
that is of a different type though.
2015-08-03 12:02:14 +02:00
Holger Hans Peter Freyther daaea0c84f 64bit: Fix compiler warnings in regard to 64bit
vty_interface_layer3.c:584:4: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Wformat=]
    sizeof(subscr->extension)-1, VTY_NEWLINE);
2015-08-03 12:01:44 +02:00
Max 5c06e4045a use non-vararg functions if possible
Signed-off-by: Max <max.suraev@fairwaves.co>
2015-08-01 23:51:52 +00:00
Holger Hans Peter Freyther 145e2532f4 Merge branch 'zecke/features/no-tmsi'
When two phones use the same TMSI and no A3A8 is possible
we could end in a hard to detect issue. Assume that the IMSI
will not clash and we have issues for foreign simcards.
2015-08-01 23:49:34 +00:00
Holger Hans Peter Freyther 666e36aea9 nitb: Add a mode to not use TMSI for normal operation
In case foreign simcards are used we can not do authentication
and ciphering. In case a TMSI is re-used too early and we do
page using TMSI we can't know which of the two MS is responding
to us. We could change the "secure channel" routine to ask for
the IMSI and only then stop the paging.

As we don't have ciphering there is not much use in using the
TMSI. Add a mode "no assign-tmsi" that will not assign the TMSI
during LU. Now CM Service Request and Paging Response  will
work using the IMSI. There can't be a clash with that.

[ciaby fixed the vty write to use the right name]
2015-08-01 23:49:16 +00:00
Holger Hans Peter Freyther 5f8a0c5c70 nitb: Be less strict about the reject cause
When we can't find the TMSI then the subscriber is not in our
VLR. We have not consulted with the HLR and it is better to not
use such a severe error code.
2015-08-01 23:49:16 +00:00
Holger Hans Peter Freyther d15409876c build: Include sys/socket.h for AF_UNSPEC 2015-08-01 23:46:56 +00:00
Holger Hans Peter Freyther 4672059d94 mgcp: Include enough socket data structures to build on freebsd
in_address is not 'accidently' included by FreeBSD when we include
the osmocom/core/select.h header file. We need to include a bit
more.

In file included from mgcp_protocol.c:38:
../../include/openbsc/mgcp_internal.h:134:21: error: field has incomplete type 'struct sockaddr_in'
        struct sockaddr_in forward;
2015-08-01 23:36:39 +00:00
Holger Hans Peter Freyther a2c41c42b1 sms: Fix the non-SMPP mode of the test
List needs to be executed from within the right configuration
node to see if it is available or not. list on the toplevel
will uncoditionally show "smpp" as part of the logging config.
2015-07-13 11:30:13 +02:00
Holger Hans Peter Freyther 1e365477ee bsc: Rename core_ncc to core_mnc
Struct osmo_msc_data contains int core_ncc, which is actually the
MNC part of the PLMN, not to be confused with the Network Colour
Code.

The following patch renames this field for clarity and consistency
with the standards.
2015-07-13 11:06:10 +02:00
Holger Hans Peter Freyther 14a434b9d6 Merge branch 'zecke/features/smpp-route' 2015-07-13 10:42:17 +02:00
Holger Hans Peter Freyther 7c19c6b406 sms: Do not go through the routing a second time
If we have tried SMPP first and it was not routable, and then
tried the local delivery there is no point in trying SMPP with
the same parameters again. Leave early and return unknown sub
to the caller.
2015-07-13 10:39:51 +02:00
Holger Hans Peter Freyther 42cf2e03c9 sms: Add a way to always route SMS through SMPP systems
default-route would only be looked at after there has been
no subscriber in the local database. Depending on the setup
this is not what one wants. This has been discussed at the
OsmoDevCon and there have been hacks in some branches. Let's
introduce a VTY command to select if SMPP should be consulted
first and then fallback to the current behavior.
2015-07-06 16:50:19 +02:00
Holger Hans Peter Freyther dcbc83355e sms: Simplify the return handling for SMPP routes/unroutable 2015-07-06 16:40:51 +02:00
Holger Hans Peter Freyther e3c391e8d0 sms: Put the try_deliver into the header file
Even if it is using BSC/NITB types let's put it in the header
file than just declaring it at a place that could bitrot in a
way that doesn't lead a warning.
2015-07-06 16:40:01 +02:00
Holger Hans Peter Freyther af1b968b22 sms: Move the routing of the sms to a separate function
The "default-route" for SMPP will be used after a local
subscriber look-up. Sometimes we want to route everything
to SMPP. Make this possible by changing this routine.
2015-07-06 16:04:41 +02:00
Holger Hans Peter Freyther b69518f383 configure: Do not link all applications against libgsm
Use the same trick as done by the dlopen check to not
have everyone link against the library.
2015-07-02 09:51:31 +02:00
Holger Hans Peter Freyther 58ec15c4ed configure: No need to check for crypt here
We just link to libosmovty and if it requires crypt internally it
needs to link to that (and not us). This looks like a left-over
from when we moved the VTY code out of OpenBSC
2015-07-02 09:40:03 +02:00
Holger Hans Peter Freyther 9f95ae8885 nat: Use RAND_bytes instead of /dev/urandom
We don't need to consume all the entropy of the kernel but can
use libcrypto (OpenSSL) to generate random data. It is not clear
if we need to call RAND_load_file but I think we can assume that
our Unices have a /dev/urandom.

This takes less CPU time, provides good enough entropy (in theory)
and leaves some in the kernel entropy pool.
2015-07-01 08:34:16 +02:00
Holger Hans Peter Freyther 8ee53ed9ec Merge branch 'zecke/features/auth'
Introduce another authentication scheme using MILENAGE. In the
future reading from /dev/urandom will be replaced with libcrypto.
2015-07-01 08:19:51 +02:00
Holger Hans Peter Freyther 694d98042f nat: After we identified the bsc check the key
We are using the token to find the right bsc_config and
then we can use the last_rand of the bsc_connection to
calculate the expected result and try to compare it with
a time constant(???) memcmp.
2015-07-01 08:16:41 +02:00
Holger Hans Peter Freyther e2ac6b77fe bsc: Check for the rand and then generate a res
Check if the NAT has sent 16 bytes of RAND and if a key
has been configured in the system and then generate a
result using milenage. The milenage res will be sent and
noth the four byte GSM SRES derivation.
2015-07-01 08:16:41 +02:00
Holger Hans Peter Freyther 9705671025 nat: Send 16 bytes of rand to the BSC and remember it
Generate 16 byte of random data to be used for A3A8 by
the BSC in the response. We can't know which BSC it is
at this point and I don't want to send another message
once the token has been received so always send the data
with an undefined code. The old BSCs don't parse the
message and will happily ignore the RAND.

/dev/urandom can give short reads on Linux so loop
around it until the bytes have been read from the kernel.
2015-07-01 08:16:40 +02:00
Holger Hans Peter Freyther fce6971fe3 nat: Provide access to /dev/urandom for the code
Instead of doing open/read/close all the time, open the
FD in the beginning and keep it open. To scare me even
more I have seen /dev/urandom actually providing a short
read and then blocking but it seems to be the best way
to get the random byes we need for authentication.

So one should/could run the cheap random generator on
the system (e.g. haveged) or deal with the NAT process
to block.
2015-07-01 08:16:40 +02:00
Holger Hans Peter Freyther 8a8df80772 bsc/nat: Fix the structure of the identity request message
Unfortunately the basic structure of the response is broken.
There is a two byte length followed by data. The concept of
a 'tag' happens to be the first byte of the data.

This means we want to write strlen of the token, then we
want to write the NUL and then we need to account for the
tag in front.

Introduce a flag if the new or old format should be used.
This will allow to have new BSCs talk to old NATs without
an additional change. In the long run we can clean that up.
2015-07-01 08:16:40 +02:00
Holger Hans Peter Freyther 0363d1bb97 nat: Close the connection after we couldn't find the user
In case the token was not correct, just close the connection.
It is not clear that forcing a new TCP connection is going to
give us any extra security here. But with the upcoming auth
handling it does make sense to have both case look similar.
2015-07-01 08:16:40 +02:00
Holger Hans Peter Freyther aa0cecd9b7 nat: Factor out the config by token search
In the upcoming authentication improvements it is nice to
separate the finding of the config from the post-allow
handling of it.
2015-07-01 08:16:40 +02:00
Holger Hans Peter Freyther 2dd18bdd87 nat: Add size check for the payload
The msgb will always have these bytes but it is better practice
to verify that the message really has space for the two bytes.
2015-07-01 08:16:40 +02:00
Holger Hans Peter Freyther 57ee780789 bts: Arfcn can never be smaller than 0
Remove the condition because it can never be true.

Fixes: Coverity CID#1307793
2015-06-20 18:45:35 +02:00
Andreas Rottmann 797eb7b592 build: avoid spurious hard dependency on libosmo-sccp
In the libfilter source code, which is built regardless of --enable-nat,
headers from libosmo-sccp were used, thus causing a build failure (see
below) when building without --enable-nat, and libosmo-sccp not being
installed (or being installed in a prefix not otherwise included in the
build).

The build fails like this:

In file included from ../../../src/libfilter/bsc_msg_filter.c:27:0:
../../../include/openbsc/bsc_nat_sccp.h:27:37: fatal error: osmocom/sccp/sccp_types.h: No such file or directory

As the includes seem not to be actually needed, this change fixes the
issue by just omitting them.
2015-06-19 20:58:35 +02:00
Andreas Rottmann 4bb3fccb75 Fix "make distcheck"
Running "make distcheck" failed trying to generate ".version" into the
read-only unpacked source directory. Actually shipping ".version" in the
tarball fixes that.
2015-06-19 20:57:48 +02:00
Andreas Rottmann b25c8342cc Fix build wrt. missing CFLAGS constituents
When libosmo-netif and/or libosmo-abis are installed in distinct
prefixes, the build failed with non-found headers.
2015-06-19 20:56:53 +02:00
Michael McTernan c58a1e573b Fix GSM900 ARFCN range check
Allow ARFCN 0 to be used in GSM900 band.
2015-06-19 20:51:43 +02:00
Holger Hans Peter Freyther ce97a06fa3 bsc: Attempt to fix crash when sending a SCCP CREF message
There was no context for the SCCP CREF message and this means
that the msc_con was a plain NULL pointer that was dereferenced
and the application would crash.

Use the new API to pass the incoming MSC Connection which sould
be used for the SCCP CREF message as context. The code has not
been fed with an actual SCCP CR message.
2015-06-15 09:47:45 +02:00
Holger Hans Peter Freyther 0958938d4e sgsn: Simplify finding/using the first address of the result
The loop was used to print all returned addresses but we can
simply pick the first one. This is fixing a coverity issue that
the loop will be executed eaxactly once (and that was on
purpose).

Simplify the code and just take the first element (which might
be NULL).

Fixes: Coverity CID#1302852
2015-06-02 09:51:32 +02:00
Holger Hans Peter Freyther f2e114ac85 sgsn: seleted_apn_str might be NULL do not strcpy
The subscriber might simply not be allowed to use the APN
that was specified. So selected_apn_str might very well be
NULL.

Fixes: Coverity CID#1302853
2015-06-02 09:46:32 +02:00
Holger Hans Peter Freyther 65b0efe56e sgsn: Check the return value of osmo_fd_register
We can't do much in case the fd is failing to be registered.
There should be a timeout that is catching this and it might
be able to repair it self.

Fixes: Coverity CID#1302854
2015-06-02 09:46:11 +02:00
Alexander Chemeris c36a13b073 libbsc: Move SIs update/generation for a BTS into a separate function.
The code to do that doesn't belong to the control interface, so
abstract it out to a separate function gsm_bts_set_system_infos().

[hfreyther: Fix the coding style...]
2015-06-02 08:43:29 +02:00
Holger Hans Peter Freyther 9cb249bf84 sgsn: Do not search the name with the "domain" name attached to it
In case the query for "hostname" will fail c-ares will append the
domain name of /etc/resolv.conf and query again. We don't want that
so claim we provide a list of domain names and then don't provide
any.

I didn't intend to have pushed the c-ares code to master yet.
2015-06-01 18:46:12 +02:00
Ivan Kluchnikov 5fd0c64e0a gsm_04_08: Use osmo_assert for transt->conn and conn only in case of paging succeeded
setup_trig_pag_evt function can receive parameter conn = NULL, if T3113 expires.
2015-05-29 15:14:23 +02:00
Holger Hans Peter Freyther b7ae0b34f9 ggsn: The id is a uint32_t don't print it as signed
This was noticed as I started to use UINT32_MAX for
dynamically created GGSNs.
2015-05-29 15:11:55 +02:00
Holger Hans Peter Freyther a5a6da46a0 sgsn: Allow to specify the DNS servers that should be used
If no server is specified the default list will be used. This
allows to separate the servers for the local network and GRX
from each other.
2015-05-25 15:58:02 +08:00
Holger Hans Peter Freyther 39c430ee29 sgsn: Allow to resolve the IPv4 address of a GGSN through DNS
For real networks we need to check if the requested APN string
is allowed and then resolve the GGSN address through DNS. There
are countries with two or three digit MNCs and one could either
try to keep a list of countries that have two/three digits or
just try both of them. I have opted for the later for the ease
of the implementation.

C-Ares doesn't allow to cancel a request so we will need to
have the MMCTX and the Lookup have different lifetimes. We simply
set ->mmctx to NULL in case the MMCTX dies more early.

The selected and verified apn_str will be copied into the out
parameter. In case no static APN/GGSN config is present and the
dynamic mode is enabled a request will be made.
2015-05-25 15:57:57 +08:00
Holger Hans Peter Freyther 66e7106d39 sgsn: Integrate c-ares with the osmocom event loop
c-ares is an asynchronous DNS resolver and we need it to
resolve the GGSN address. This is integrating the library
into our infrastructure. We will create and maintain a list
of registered FDs (c-ares is currently only using one of
them) and (re-)schedule the timer after events occurred.
2015-05-25 15:39:59 +08:00
Holger Hans Peter Freyther ccd2312d10 sgsn: Create a copy of the msgb for later usage
When needing to do an asynchronous DNS query we need
to keep the TLV data around. So create a wrapper that
takes a copy of it and frees it after the call. I can
change the code to add an out parameter to decide if
the msgb should be freed or not.

Pick network failure in case the msgb could not be
cloned in the hope the MS will retry then.
2015-05-25 15:39:59 +08:00
Holger Hans Peter Freyther 7605bdc02c sgsn: Re-factor the activate PDP code for future changes
A real SGSN will dynamically resolve the APN name into the
GGSN IP Address. This means that after we have collected all
information we need to start to resolve the GGSN and then
can continue.
2015-05-25 14:38:02 +08:00
Holger Hans Peter Freyther 08bb84b04e sgsn: Deal with no static ggsn being configured at all
In case no static ggsn is configured the code would crash
with the assumption that there is always such a GGSN.
2015-05-25 14:38:01 +08:00
Holger Hans Peter Freyther 9270d99f3d sgsn: If there is a subscr don't allow an empty list
This is a left-over from the initial system where no PDP
was provided by the system. For now if there is a subscr
attached and no PDP context provisioned. He is not allowed
to have a data connection.

Update the testcase to create the pdp list entry more
early with a wildcard and then change it to a specific
match.
2015-05-25 14:38:01 +08:00
Holger Hans Peter Freyther 5e4b88cbb2 Merge branch 'zecke/features/sgsn-hlr-number'
Store the hlr-Number for purgeMS and CDR handling
2015-05-24 12:32:36 +08:00
Holger Hans Peter Freyther 8ee13e2937 sgsn: Extract the hlr Number into the mm context
Include the hlr-Number of the subscriber in the CDR. This is useful
for debugging and understanding which equipment was used during the
test. In contrast to the MSISDN the '+' is emitted as the number
must be in international format already.
2015-05-24 12:32:23 +08:00
Holger Hans Peter Freyther 10c0f56a0e gsup: Copy the hlr-Number and use it during purge
Copy the hlr-Number into the sgsn_data and use it during
the purgeMS. There is no unit test that looks at the data
we send so I manually verified this by looking at the output.
Below is the output of the test that purges the subscriber.

<000f> gprs_subscriber.c:170 SUBSCR(123456789012345) Sending GSUP, will send: 0c 01 08 21 43 65 87 09 21 43 f5 09 07 91 83 61 26 31 23 f3
2015-05-24 12:32:23 +08:00
Holger Hans Peter Freyther 0bb5674cde gsup: Decode/Encode the hlr-Number in the GSUP message
Implement it similar to the msisdn_enc/msisdn_enc_len and
extend the testcase to include it as well.
2015-05-24 12:32:23 +08:00
Holger Hans Peter Freyther e54a24d4e6 gsup: Add the HLR-Number as type and use it for UpdateLocation Res
The HLR-Number can be passed from the MAP Proxy to the SGSN and
can then be used for the CDR module or passed during the purgeMS
operation.
2015-05-24 12:32:22 +08:00
Holger Hans Peter Freyther 0f7a279a06 sgsn: Change the selection mode to verified
We have verified/selected the APN. Either based on the subscriber
data, a global APN match. But at least this SGSN has looked at
what the MS has asked for and then selected a matching GGSN.
2015-05-22 10:05:56 +08:00
Holger Hans Peter Freyther c1c6a28c8d sgsn: Reserved bits should be set to 1
Bits 3 to 8 are spare bits and should be set to 1 in etsi
specifications. Do that.
2015-05-22 10:05:49 +08:00
Max 4c6e667968 Replace ad-hoc function with generic one from libosmocore
Signed-off-by: Max <max.suraev@fairwaves.co>
2015-05-17 19:09:32 +02:00
Holger Hans Peter Freyther 072bee5c85 sgsn: Clear LAC/RAC value for the routing area identity
Clear LAC/RAC with pre-defined value in the RAI.

3GPP 29.060 v7.17.0 section 7.3.1 page 23:

"The SGSN may include the Routeing Area Identity (RAI) of the
SGSN where the MS is registered. The MCC and MNC components shall
be populated with the MCC and MNC, respectively, of the SGSN
where the MS is registered. The LAC and RAC components shall be
populated by the SGSN with the value of 'FFFE' and 'FF',
respectively.”
2015-05-17 17:36:23 +02:00
Holger Hans Peter Freyther 267fd0c7f7 Merge branch 'zecke/features/sgsn-gtp-cdr'
Extend GTP and CDR support in the SGSN.
2015-05-17 17:24:09 +02:00
Holger Hans Peter Freyther d6900dfba4 sgsn: Give the IMEI to the GGSN for analysis
Most SGSNs pass the IMEI(SV). We currently only enquire about
the IMEI and then pad the 'SV' with 1111b (thanks to the encoding
routine). Sadly it insists on always writing the length which
means we have to memmove the data around by a single octet.

Manually verified using the pcu-emu and looking at the trace
using wireshark.
2015-05-17 17:23:57 +02:00
Holger Hans Peter Freyther 6ddb6ac028 sgsn: Encode the ULI for the PDP context creation ack
Give the GGSN another opportunity to determine which tarif
to apply for the SGSN/subscriber. This code assumes tha the
RAN is a GERAN system but the assumption has been made in
other places as well.
2015-05-17 17:23:57 +02:00
Holger Hans Peter Freyther 22093ef964 sgsn: Always include the routing area identity
For PDP context creation we always want to include the RAI
for the current mmctx. This might help commercial GGSNs to
determine which charging to apply.
2015-05-17 17:23:57 +02:00
Holger Hans Peter Freyther 77ff1c40e2 cdr: Remember the charging id supplied by the GGSN
The charging_id is provided by the GGSN. Copy it into the CDR
part of the data structure so it will remain present until after
the pdp context has been deleted.
2015-05-17 17:23:57 +02:00
Holger Hans Peter Freyther 446f8403d1 debian: Fix dependencies pointed out by lintian
E: openbsc source: missing-separator-between-items in osmocom-nitb depends field between '${misc:Depends}' and 'libdbd-sqlite3'
2015-05-17 17:23:36 +02:00
Holger Hans Peter Freyther 7882d2751f Merge branch 'zecke/features/cdr'
Add an optional CDR module. This will create a rotatable log
file, detect rotation and try to write as many information as
possible.
2015-05-12 20:06:47 +02:00
Holger Hans Peter Freyther c15c61c401 sgsn: Add VTY configuration for the CDR module
Make it possible to set a filename to use for the CDR. By
default no CDR will be generated. Forbid to set the interval
of 0 seconds as this will cause a lot of work. Add a very
basic VTY test.
2015-05-06 17:46:08 +02:00
Holger Hans Peter Freyther 4f5b8237ec sgsn: Create an initial and limited CDR module
This is consuming the new signals and allows to install several
different CDR/observing/event/audit modules in the future. For
getting the bytes in/out the code would have had to undo what the
rate counter is doing and at the same time adding a "total" to
the ratecounter didn't look like a good idea, the same went for
making it a plain counter.

Begin writing the values one by one and open/closing a new FILE
for every log messages. This is not efficient but easily deals
with external truncation/rotation of the file (no fstat for and
checking the links and size). As usual we will wait and see if
this is an issue.

Add some new members to our PDP context structure to see what it
is about.
2015-05-06 17:43:15 +02:00
Holger Hans Peter Freyther b100895557 sgsn: Add various signals consumed by CDR or other client code 2015-05-06 17:14:51 +02:00
Holger Hans Peter Freyther 20de3ae17c sgsn: Extract the MSISDN from the subscr data structure
In case there is a subscr attached to the MM context and there
is an encoded MSISDN we will attempt to decode it and in case
of an international number prepend a '+'. Assume that the array
size of gsm_mmcc_called->number is as big as ctx->msisdn for the
strncpy.
2015-05-06 17:14:51 +02:00
Holger Hans Peter Freyther b448dd849a sgsn: Make the free function internal
All calls should and do go through the
sgsn_mm_ctx_cleanup_free function.
2015-05-06 17:14:51 +02:00
Holger Hans Peter Freyther 4c8e8f990a Merge branch 'zecke/features/gprs-gsup-fixes'
When communicating with a GGSN that is not the OpenGGSN
the PDP context activation does fail. This is because on
the activation of the first PDP context we need to supply
a MSISDN. Extend the protocol, parse the MSISDN and then
send it to the GGSN. The second item is that we have only
forwarded the requested QoS of the subscriber. In most
cases this is 0x0, 0x0, ... which means one requests a
rate 0 byte/sec which the GGSN will not allow. Make it
possible to receive, store and use the subscribed QoS of
the Subscriber.
2015-05-05 21:16:19 +02:00
Holger Hans Peter Freyther d05e06989d sgsn: Show the QoS that has been assigned 2015-05-05 21:15:55 +02:00
Holger Hans Peter Freyther f7b3826f03 sgsn: Dump the E164 (encoded) assigned to the subscriber 2015-05-05 21:15:44 +02:00
Holger Hans Peter Freyther 4bd931f96d sgsn: Handle different levels of QoS
If QoS is only three bytes it does not include the allocation/
retention policy. Otherwise it does. Copy it depending on that.
We should have a macro for the clamping to reduce code duplication.

The insanity does come from the MAP data and this seems to be
the easiest in terms of complexity. It is an array of bytes that
is transported from MAPProxy to the SGSN and then simply forwarded.

The case of more than three bytes is neither unit nor manually
tested so far.
2015-05-05 21:15:20 +02:00
Holger Hans Peter Freyther 8cedded88c sgsn: Store subscribed QoS and attempt to use it
sgsn_create_pdp_ctx should use the subscribed QoS. When selecting
the PDP context we inject the QoS to be used into the TLV structure
and use it during the request. Assume a "qos-Subscribed" structure
only with three bytes and prepend the Allocation/Retention policy
to the request.
2015-05-05 21:11:16 +02:00
Holger Hans Peter Freyther 9ba273d365 sgsn: Copy the msisdn to the sgsn_data and use it in PDP activation
The MSISDN should be present for "security" reasons in the first
activation of a PDP context. Take the encoded MSISDN, store it for
future use and then put it into the PDP activation request.

The MM Context contains a field for a decoded MSISDN already. As
we need to forward the data to the GGSN I want to avoid having to
store TON and NPI in another place. Simply store the data in the
encoded form.
2015-05-05 21:09:53 +02:00
Holger Hans Peter Freyther 49c1a7156c gsup: Extract the QoS field
Add roundtrip test for the new QoS IE. It will be consumed in
later commits.
2015-05-05 21:09:20 +02:00
Holger Hans Peter Freyther b927f1c319 gsup: Extract the new MSISDN string
Extract the new MSISDN IE from the GSUP message and verify that
it is read/written to the message.
2015-05-05 21:08:00 +02:00
Holger Hans Peter Freyther 02d8c472bd gsup: Specify the QoS service for the PDP info
QoS is a mess. In MAP there is qos-Subscribed which is then extended
using ext-QoS-Subscribed, ext2-QoS-Subscribed, ext3-QoS-Subscribed
and maybe even ext4-QoS-Subscribed by now. The MAP ASN1 files defined
how these need to be "linearized". Instead of copying this I have
decided to include the two semantics with/without the Allocation/Retention
policy using the size of the data.
2015-05-05 21:05:25 +02:00
Holger Hans Peter Freyther e448554568 gsup: Document passing MSISDN as part of the response
When asking the GGSN to create/open a PDP context one needs
to send a MSISDN. The MSISDN can only be provided through the
GSUP interface.
2015-05-05 20:57:32 +02:00
Holger Hans Peter Freyther 337343d159 Merge branch 'zecke/features/acc-list'
Integrate the change and see how it is going. The unit tests
for the NAT look good so we might not have regressions.
2015-05-03 22:34:16 +02:00
Holger Hans Peter Freyther d26b8fcbe2 bsc: Send a LU Reject in case it has been filtered
In case we filter the request and it was a Location Updating
Procedure we should reject it.
2015-05-03 22:33:35 +02:00
Holger Hans Peter Freyther ec0cb7c64d bsc: Add access list filtering to the BSC 2015-05-03 22:33:35 +02:00
Holger Hans Peter Freyther d6332809d8 bsc: Add access lists to the MSC and the BSC
It is a bit arbitary to decide which one is the global
and which one is the local one. We might change it around.
I don't think we want to introduce it based on BTS.
2015-05-03 22:32:43 +02:00
Holger Hans Peter Freyther c652913674 filter: Move the con_type into the filter_state 2015-05-03 22:09:02 +02:00
Holger Hans Peter Freyther 06a88fa0ae filter: Move from DNAT to DFILTER category 2015-05-03 22:03:39 +02:00
Holger Hans Peter Freyther 4e8176d0c9 filter: Remove bsc_connection from the filter API
Remove the last occurence of NAT datastructures in the filtering
module and add the ctx to the filter request structure.
2015-05-03 22:01:46 +02:00
Holger Hans Peter Freyther c09f8a3b7f filter: Remove nat_sccp_connection from public API 2015-05-03 21:59:29 +02:00
Holger Hans Peter Freyther 81dbfe412c filter: Remove the bsc_connection from the internal functions 2015-05-03 21:42:29 +02:00
Holger Hans Peter Freyther 71857d7242 filter: Put all the parameters in a struct to avoid order issues
With the "local" and "global" list name we might pick the
wrong argument. Avoid it by passing them as a struct.
2015-05-03 21:42:28 +02:00
Holger Hans Peter Freyther a0478814bc filter: Remove NAT knowledge from auth_imsi
Push back the parameters we need to pass. auth_imsi doesn't
know anything about the nat now.
2015-05-03 21:42:28 +02:00
Holger Hans Peter Freyther 4ba947bf4b filter: Separate SCCP/BSSAP extraction and gsm48 code
For the BSC we will have the gsm48_hdr and don't need to
find data within SCCP. For legacy reasons we need to
initialize con_type, imsi, reject causes early on and
need to do the same in the filter method.
2015-05-03 21:42:28 +02:00
Holger Hans Peter Freyther c36a6d5705 filter: More renaming and remove of "NAT" from it 2015-05-03 21:42:28 +02:00
Holger Hans Peter Freyther 14b2cd9f32 filter: Rename BSC to LOCAL and NAT to GLOBAL 2015-05-03 21:42:28 +02:00
Holger Hans Peter Freyther a1e6bd6768 filter: Remove nat from bsc_nat_acc_lst and replace with msg 2015-05-03 21:42:28 +02:00
Holger Hans Peter Freyther d7e04b9956 filter: Cease out "struct bsc_nat" from the API
This means we need to require a talloc context and
simply operate on the list. I had considered creating
a structure to hold the list head but I didn't find
any other members so omitted it for now.
2015-05-03 21:42:28 +02:00
Holger Hans Peter Freyther d04d009f47 filter: Move VTY code into the filter module 2015-05-03 21:42:28 +02:00
Holger Hans Peter Freyther 4579bb1ed7 filter: Move the access list management around 2015-05-03 21:42:27 +02:00
Holger Hans Peter Freyther 973dbaeebd filter: Move the method definition to the filter module
Move the filter methods to the filter module. This is
still only usable for the NAT and the _dt/_cr filter
routines need to move back to the bsc_nat in the long
run.
2015-05-03 21:42:27 +02:00
Holger Hans Peter Freyther 4247cead2b filter: Move the gsm 04.08 filter to a common place
For customer requirements we want to be able to do
filtering on the BSC as well. The same messages need
to be scanned and the same access-lists will be looked
at. In the future we might even split traffic based
on the IMSI. Begin with moving the code to a new top
level directory and then renaming and removing the
nat dependency.
2015-05-03 21:42:27 +02:00
Holger Hans Peter Freyther 38159428d2 mgcp: Fix compiler warning on 64bit builds
ENDPOINT_NUMBER takes the difference of two pointers. On 64bit
builds the difference is a long and the compiler then complains
about the usage of abs. We will never have thousands of endpoints
so silence the warning by casting the ENDPOINT_NUMBER to int.

mgcp_vty.c:1381:34: warning: absolute value function 'abs' given an argument of type 'long' but has parameter of
      type 'int' which may cause truncation of value [-Wabsolute-value]
                        rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp),
                                                      ^
../../include/openbsc/mgcp_internal.h:206:31: note: expanded from macro 'ENDPOINT_NUMBER'
 #define ENDPOINT_NUMBER(endp) abs(endp - endp->tcfg->endpoints)
                              ^
mgcp_vty.c:1381:34: note: use function 'labs' instead
2015-05-02 10:02:38 +02:00
Holger Hans Peter Freyther 4a8b938348 Merge branch 'zecke/features/no-queue'
Let's get bigger exposure of the new implementation
2015-04-29 18:53:40 +02:00
Holger Hans Peter Freyther d6d7affa6e sub: Remove the queue from the subscriber code
The idea of "subscriber_get_channel" was that different
requests would be coordinated. At the same time we have
seen that the "queue" can get stuck at both 31C3 and the
rhizomatica installations.

Voice calls and SMS do not need coordination. We should
be able to send SMS on a voice channel and switch the MS
from a SDCCH to a TCH in case we establish a voice call.
The SMS code itself needs to coordinate to obey the limit
of one SMS per direction but this should be enforced in
the sms layer and not on the subscriber.

Modify the code to have a simple paging coordination. The
subscriber code will schedule the paging and register who
would like to know about success/failure.

This allowed to greatly simplify the paging response
handling for the transaction code (and in fact we could
move the transaction list into the subscriber structure
now). The code gained to support to cancel the notification
of a request (but not the paging itself yet).

TODO: Cancel paging request in case no one cares about it
anymore.
2015-04-29 18:53:28 +02:00
Holger Hans Peter Freyther 0759b1b952 sub: Remove introspection of the "channel queue"
Over the next commits the queuing of commits will be
completely modified to remove the queue and move the
scheduling/limits to the outer callers.
2015-04-29 18:53:27 +02:00
Holger Hans Peter Freyther 0ae564d9b1 sub: Remove paging requests before dispatching
The dispatching might lead to the removal of more
paging requests and makes "request" invalid. Remove
it before calling the callback.
2015-04-29 18:53:27 +02:00
Holger Hans Peter Freyther 1e28eb83c0 mncc: Select the codec similar to the modify handling
In case the default TCH/F codec is "EFR" and we do an early
assignment from SDCCH to a TCH we would assign the TCH/H
codec. This is because the lchan_type will be neither a
TCH/H nor a TCH/F.

At the same time the _gsm48_lchan_modify code to check for
half vs. full-rate is the other way around. Align both.

It is full-rate if it is not a TCH_H. This will have some
other complications down the way (early assignment on
cells with only TCH/H). So the mode should not depend on
the _current_ channel but the kind of channel we want.
2015-04-29 18:53:27 +02:00
Holger Hans Peter Freyther b396b69cb2 debian: Do not depend on shared libraries directly
The debian shlibs:depends macro will add the depends
according to the needed libraries for us. We only need
this for the sqlite3 plugin of libdbi-drivers as there
is no direct linkage.
2015-04-29 18:53:08 +02:00
Jacob Erlbeck ddc0e05604 mgcp/test: Fix mgcp-transcoding assertion (Coverity)
In test_rtp_seq_state an assignment is accidently done within an
assertion.

This commit changes that into a comparison as it was intended.

Fixes: Coverity CID 1295457, 1295458
Sponsored-by: On-Waves ehf
2015-04-29 14:02:40 +02:00
Jacob Erlbeck 5a2484b10e mgcp: Move assignment of src_codec downwards
Currently the src_codec const variable is set to &src_end->codec
before src_end is checked against NULL. Since the assigment is just
an address operation and the memory where it points to is only
accessed after the NULL check, this does not harm technically.
Nevertheless this is potential source for errors if that code is
changed.

This commit moves the definition below the NULL check. This does not
comply with the coding style, but it cannot be split into definition
and a later assignment due to the const qualifier.

Sponsored-by: On-Waves ehf
2015-04-28 09:40:40 +02:00
Holger Hans Peter Freyther cb43a9ac44 mgcp: Allow to disable transcoding for trunks
We might have compiled transcoding into the MGW but
we don't want to enable it for a given user. Add a new
switch that should allow that.

I had manually tested the allow-transcoding/no allow
VTY interface for the primary interface and a new trunk
using show running-config.
2015-04-24 16:10:54 -04:00
Holger Hans Peter Freyther c57b5507b2 mgcp: Ignore the case for finding a codec
It is unlikely that GSM, gsm and GsM refer to different codecs.
The mera mvts does send the audio codecs in lower case even if
RFC 3551 has them in upper case (but copy and paste is sometimes
too hard).
2015-04-24 15:07:20 -04:00
Holger Hans Peter Freyther 7f100c9712 nat: Make mode-set patching optional 2015-04-23 20:27:30 -04:00
Holger Hans Peter Freyther d4b03187c6 sgsn/gtp: Fill out the optional RAT type
Assume we are always a GERAN network right now.
2015-04-23 17:01:17 -04:00
Holger Hans Peter Freyther 8e6ecc9667 misc: Fix warnings about size of size_t in printf
Fixes warnings like:

warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat]
2015-04-23 17:01:09 -04:00
Holger Hans Peter Freyther adc17268fc debian: meas2pcap requires libpcap-dev unconditionally 2015-04-23 17:01:03 -04:00
Jacob Erlbeck 7ffa7b095f nitb: Fix IMSI/IMEI buffer handling (Coverity)
Currently the handling of the buffers is not done consistently. Some
code assumes that the whole buffer may be used to store the string
while at other places, the last buffer byte is left untouched in the
assumption that it contains a terminating NUL-character. The latter
is the correct behaviour.

This commit changes to code to not touch the last byte in the buffers
and to rely on the last byte being NUL. So the maximum IMSI/IMEI
length is GSM_IMSI_LENGTH-1/GSM_IMEI_LENGTH-1.

For information: We assume that we allocate the structure with
talloc_zero. This means we have NULed the entire imsi array and then
only write sizeof - 1 characters to it. So the last byte remains NUL.

Fixes: Coverity CID 1206568, 1206567
Sponsored-by: On-Waves ehf
2015-04-10 08:47:00 +02:00
Jacob Erlbeck 322b1499cd nitb: Check source string length before calling strncpy (Coverity)
Currently some VTY command do neither check the length of the source
string before calling strncpy nor ensure NUL-termination afterwards.
This can to destination string buffers whose contents are not
NUL-teminated.

This commit adds checks and corresponding warnings to the VTY
commands 'subscriber TYPE ID name .NAME" and "subscriber TYPE ID
extension EXTENSION".

Fixes: Coverity CID 1206570, 1206569
Sponsored-by: On-Waves ehf
2015-04-07 20:13:53 +02:00
Jacob Erlbeck 5b51205187 gprs: Fix GSUP cancel_type handling (Coverity)
When handling an incoming GSUP cancellation request, the cancel_type
if effectively ignored, such that is always handled as
GPRS_GSUP_CANCEL_TYPE_UPDATE and never as WITHDRAW.

This commit fixes the expression used to set the variable
is_update_procedure.

Fixes: Coverity CID 1267739
Sponsored-by: On-Waves ehf
2015-04-07 20:13:43 +02:00
Jacob Erlbeck 9ed6fd25dd nat: Fix timeslot range in 'show bsc mgcp' VTY command
Currently the inner loop in show_bsc_mgcp iterates of the timeslot
interval [0, 31]. Timeslot 0 is not valid, which causes
mgcp_timeslot_to_endpoint to generate a corresponding warning and to
return an invalid endp value. That value causes an out-of-bound
read access, possibly hitting unallocated memory.

This patch fixes the loop range by starting with timeslot 1.

Note that this does not prevent mgcp_timeslot_to_endpoint from
returning an invalid endpoint index when called with arguments not
within its domain.

Addresses:
<000b> ../../include/openbsc/mgcp.h:250 Timeslot should not be 0
[...]
    vty=0xb4203db0, argc=1, argv=0xbfffebb0) at bsc_nat_vty.c:256
        max = 1
        con = 0xb4a004f0
        i = 0
        j = 0
[...]
==15700== ERROR: AddressSanitizer: heap-use-after-free on address
0xb520be4f at pc 0x8062a42 bp 0xbfffeb18 sp 0xbfffeb0c

Sponsored-by: On-Waves ehf
2015-04-07 20:13:28 +02:00
Holger Hans Peter Freyther 08ea4d87f6 nat: Check for the access list in set command as well
I omitted the check as this was already done by the verify
function for this command. Please Coverity and do the check
again even if it is not necessary. I begin to doubt the
usage of a "dedicated" verify method as well.

Silences: Coverity CID 1293150
2015-04-07 09:10:05 +02:00
Holger Hans Peter Freyther 0ac00c15b9 nat: Check the con->imsi for the tracked IMSI
On DT messages we directly write into the tracked SCCP
connection. This means "imsi" will always be NULL at
this check. Change the code to use con->imsi

Fixes: Coverity CID 1293151
2015-04-07 09:06:26 +02:00
Holger Hans Peter Freyther 8ccf06c58b nat: Add ctrl command to save the configuration
$ bsc_control.py -d localhost -p 4250 -s net.0.save-configuration 0
2015-04-05 15:42:32 +02:00
Holger Hans Peter Freyther ab94ca18f2 nat: Add a ctrl command to add to an existing ACC list
We want to have a program add entries to the allow list
this can be done using:

$ bsc_control.py -d localhost -p 4250 -s net.0.add.allow.access-list.NAME "^IMSI$"
2015-04-05 15:42:25 +02:00
Holger Hans Peter Freyther 7c00983275 nat: Inform others if an IMSI is rejected
In case one wants to monitor the access lists one
there is now a trap for the IMSI.
2015-04-05 14:06:16 +02:00
Holger Hans Peter Freyther fa1cba9e60 nat: The reject cause of "-1" has failure meaning, change it
bsc_stat_reject is treating -1 as parsing failure but for the
global barring. Change it to another return value so it is
not counted as parsing failure.
2015-04-05 11:44:47 +02:00
Holger Hans Peter Freyther 6f6cbf7c5d bts: "Repair" broken channels if we receive the release ack
We had issues with odd behavior on the nanoBTS which lead
to the introduction of the "broken" state. On busy multi
BTS cells (e.g. rhizomatica) with wifi backhaul the timeout
we set to wait for a RF Channe Release ACK is sometimes too
little and channels are marked broken that look to be okay
(besides the still to be determined delay).

In case of a sysmoBTS we now know that we can change the
state of a broken channel back to normal in case we do
receive the right response.

Manually verified using the Smalltalk BTS code

PackageLoader fileInPackage: 'FakeBTS'
bts := FakeBTS.BTS new.
bts btsId: '1903/0/0'.
bts connect: 'localhost'.
bts waitForBTSReady.
test := FakeBTS.OpenBSCTest new.
test bts: bts.

test requireAnyChannel

... wait for NITB output
<0004> abis_rsl.c:223 (bts=0,trx=0,ts=0,ss=0) Timeout during deactivation! Marked as broken.

... process pending messages
stdin next
<0004> abis_rsl.c:735 (bts=0,trx=0,ts=0,ss=0) CHAN REL ACK for broken channel. Releasing it.

So the channel went from broken to unallocated.
2015-04-04 19:58:50 +02:00
Holger Hans Peter Freyther 40407835b3 bsc: Change paging strategy based on override or not
Change the paging strategy based on on if a LAC override
is in place or not. In case we had changed the LAC we need
to page on all the BTS. Change the "grace" handling to
iterate over the BTS and filter out all non matching ones
LAC in case no LAC handling is active.

Manually verified all four cases with a single BTS:

* No LAC handling and grace period
* LAC handling and grace period
* No LAC handling and not lock
* LAC handling and lock.

Related: SYS#1398
2015-04-01 19:26:26 +02:00
Holger Hans Peter Freyther 067ce6dea5 bsc: In preparation to the MT lac/ci patching split the code
For MT we can't page per lac as we don't know which BTS was
the original one. Split the grace period and normal mode into
two methods so we can bloat both of them later.
2015-04-01 19:26:24 +02:00
Holger Hans Peter Freyther 32dd2f3f9b bsc: Allow to use different LAC/CI for the core-network
We need to use different LAC/CI towards the core network.
It is a bit problematic as LAC/CI is a per BTS attribute
so this feature only works if a BSC manages everything in
the same LAC.

Related: SYS#1398
2015-04-01 19:26:12 +02:00
Holger Hans Peter Freyther 7cce1d301a libmgcp: Fail if transcoding can't be configured
We want to fail theallocation of an endpoint in case the
transcoding can't be configured.

Manually verified with:

./src/osmo-bsc_mgcp/osmo-bsc_mgcp -c doc/examples/osmo-bsc_mgcp/mgcp.cfg

$ ./contrib/mgcp_server.py
0000   32 30 30 20 33 30 36 39    200 3069
0008   31 20 4F 4B 0D 0A          1 OK.. ('127.0.0.1', 2427)
0000   34 30 30 20 35 39 30 36    400 5906
0008   39 20 46 41 49 4C 0D 0A    9 FAIL.. ('127.0.0.1', 2427)
0000   34 30 30 20 33 35 34 36    400 3546
0008   33 20 46 41 49 4C 0D 0A    3 FAIL.. ('127.0.0.1', 2427)
0000   34 30 30 20 36 32 31 37    400 6217
0008   30 20 46 41 49 4C 0D 0A    0 FAIL.. ('127.0.0.1', 2427)

Verified by not sending L: in the CRCX and then failing on the
MDCX.
2015-03-29 11:46:45 +02:00
Holger Hans Peter Freyther fd603ed9e2 write_queue: Check the result of osmo_wqueue_enqueue and free
The write_queue is designed to have a maximum amount of pending
messages and will refuse to take new messages when it has been
reached. The caller can decide if it wants to flush the queue
and add the message again, create a log. But in all cases the
ownership of the msgb has not been transferred. Fix the potential
memory leak in the failure situation.
2015-03-28 18:13:37 +01:00
Andreas Eversberg cf7557a7e7 rtp: Fixed problem of mute audio on some calls
When reading from RTP socket, the first read() may fail right after
connecting to remote socket. Subsequent read() will work as it should.

If the remote socket does not open fast enough, the transmitted RTP
payload can cause an ICMP (connection refused) packet reply. This causes
the read to fail with errno=111. In all other error cases, the errno is
logged at debug level. In all error cases, reading is not disabled.

Conflicts:
	openbsc/src/libtrau/rtp_proxy.c

[hfreyther: Fix typo, stop reading in all cases but ECONNREFUSED]
2015-03-28 17:56:16 +01:00
Holger Hans Peter Freyther 37b5ce56a0 rtp: Fix memory leak fixed by Andreas without mentioning it
We allocate the msgb at entry of the method and we always need
to msgb_free it.
2015-03-28 17:56:16 +01:00
Andreas Eversberg 9967a57587 rtp: Add handling of BFI (Bad Frame Indicatior) of received TRAU frames
If a bad TRAU frame is received, it is forwarded to MNCC application
as GSM_BAD_FRAME. The application can now handle the GAP of missing
audio. (e.g. by extrapolation)

If TRAU frames are forwarded via RTP, bad frames are dropped, but frame
counter and timestamp of RTP sender state is incremented.

Conflicts:
	openbsc/src/libtrau/rtp_proxy.c

[hfreyther: Merge without testcase, fix typo]
2015-03-28 17:56:08 +01:00
Max cea35aecdc ignore debian build byproducts
Signed-off-by: Max <max.suraev@fairwaves.co>
2015-03-28 17:13:57 +01:00
Holger Hans Peter Freyther 7ce72c1be8 rtp: And really catch up and remove all occurences of openbsc/rtp.h 2015-03-22 14:43:19 +01:00
Holger Hans Peter Freyther 7c7358e91e rtp: Catch up with the removal of the rtp.h 2015-03-22 13:56:30 +01:00
Holger Hans Peter Freyther d0e171a9ff rtp: Use osmocom/netif/rtp.h for the rtp structure definition
We depend on libosmo-netif unconditionally. Let's use this
definition of rtp and have one portability issue less.
2015-03-22 09:51:43 +01:00
Holger Hans Peter Freyther 8deba01eda debian: We are at version 0.14 now 2015-03-14 20:33:43 +01:00
Holger Hans Peter Freyther 66105fd3dc ctrl: Implement a global result for rf_locked
Create a one stop command to give a statement for the
entire network. This can be used to check the policy
and the state of the entire network.
2015-02-10 23:03:25 +01:00
Holger Hans Peter Freyther ca4151984c ctrl: Add a command to check how many bts are configured
This can be used to query how many bts are configured to
check if all of them are locked or not.
2015-02-10 21:55:37 +01:00
Holger Hans Peter Freyther 349c40f47b nitb: Move the rf-lock commands from osmo-bsc to libbsc
The bts.0.rf-state and rf_locked command have been moved
from the osmo-bsc binary to libbsc. All tests continue to
pass.
2015-02-10 21:37:16 +01:00
Holger Hans Peter Freyther a0735ecab5 smpp: Fix potential crash in handling submitSM
In case:

* No message_payload and a 0 sm_length was used
* esm_class indicates UDH being present
* 7bit encoding was requested

The code would execute:

  ud_len = *sms_msg + 1;

Which is a NULL pointer dereference and would lead
to a crash of the NITB. Enforce the limits of the
sm_length parameter and reject the messae otherwise.

Fixes: Coverity CID 1042373
2015-02-08 09:56:31 +01:00
Holger Hans Peter Freyther 60e073e28d nat: getopt returns "static" data no need to copy it
I used strdup in case the data would not be valid from after
the call to getopt and this creates a potential leak if a user
is specifying multiple configuration files. If I depend on the
fact that the string is a pointer into the argv[] array I can
kill the strdup and fix the unlikely leak.

Fixes: Coverity CID 1206578
2015-02-08 09:25:38 +01:00
Holger Hans Peter Freyther 019851a523 smpp: Do not check conn for being null
We are deferencing conn earlier in this function without doing
a null check. At the time deliver_to_esme is called the conn
will always exist and even the lchan is likely to be present.
Remove the null check for conn right now.

Fixes: Coverity CID 1210594
2015-02-08 09:21:04 +01:00
Sipos Csaba 56e1766dba nokia: Allow to set the reset time for the nokia bts 2015-02-07 13:27:36 +01:00
Holger Hans Peter Freyther 9c20a5f45c sgsn: Add easy APN commands with just the name
For most configurations we don't address multiple GGSNs but
only want to enforce a list of APNs. In the future we might
add a special global GGSN context but not right now.

Fixes: SYS#593
2015-02-06 16:44:58 +01:00
Jacob Erlbeck ca69b0f68d Revert "gprs: Block other GSUP procedures during PURGE_MS"
This reverts commit f81cacc681.

Since the PURGE MS retry mechanism had been removed, this feature
is not used anymore. It just makes the code more complex.

Conflicts:
	openbsc/include/openbsc/gprs_sgsn.h
	openbsc/src/gprs/gprs_subscriber.c
	openbsc/tests/sgsn/sgsn_test.c
2015-02-06 13:22:24 +01:00
Jacob Erlbeck 277b71e0d8 sgsn: Select GGSN based on APN
Currently the APN IE in the Activate PDP Contex Request and the PDP
data that is stored with the subscriber is ignored completely.

This commit adds the sgsn_mm_ctx_find_ggsn_ctx that checks the APN IE
against the subscriber's PDP data entries if both are present. If
there is no match, the request is rejected.

If an APN IE has not been included but PDP data entries are present,
the function checks all of these entries against the static 'apn'
configuration to find a suitable entry.

If an APN has not been determined so far and any APN is allowed, the
configuration is checked with an empty APN string, to allow for
default configurations based on the IMSI prefix only.

If nothing of this succeeded but the request wasn't rejected either,
and there is no 'apn' configuration at all or if any APN is allowed
but a default configuration ist not present, the GGSN with id 0 is
used (if present).

Otherwise the request is rejected ('missing APN').

Ticket: OW#1334
Sponsored-by: On-Waves ehf
2015-02-06 13:00:29 +01:00
Jacob Erlbeck f345612654 sgsn: Add sgsn_ggsn_ctx_free function
This function will be needed for testing, since the leak check would
fail if the GGSN context are not cleaned up after use.

Sponsored-by: On-Waves ehf
2015-02-06 10:00:03 +01:00
Jacob Erlbeck cb1db8b6d5 sgsn: Add functions to handle APN contexts
This commit adds the exported functions apn_ctx_find_alloc,
apn_ctx_free, apn_ctx_by_name, and apn_ctx_match to manage and
retrieve APN to GGSN mappings.

The following VTY commands are added to 'config-sgsn':

 - apn APN ggsn <0-255>
 - apn APN imsi-prefix PREFIX ggsn <0-255>

which maps an APN gateway string to an SGSN id. The SGSN must be
configured in advance. When matching an APN string, entries with a
leading '*' are used for suffix matching, otherwise an exact match is
done.  When a prefix is given, it is matched against the IMSI. If
several entries match, a longer matching IMSI prefix has precedence.
If there are several matching entries with the same PREFIX, the entry
with longest matching APN is returned.

Ticket: OW#1334
Sponsored-by: On-Waves ehf
2015-02-06 09:56:17 +01:00
Jacob Erlbeck 0e8add601d sgsn: Add PDP info to subscriber data
Currently the PDP info that is transmitted via GSUP is just parsed
and then discarded.

This commit adds a new data structure sgsn_subscriber_pdp_data and
maintains a list of those in sgsn_subscriber_data. The PDP data is
copied from an incoming GSUP UpdateLocationResult message. If that
message contains the PDPInfoComplete flag, the list is cleared before
new entries are added.  The 'show subscriber cache' output now also
shows the PDP data entries.

Note that the InsertSubscriberData message is still not supported.

[hfreyther: Added talloc_free in gprs_subscr_pdp_data_clear]

Sponsored-by: On-Waves ehf
2015-02-06 09:55:39 +01:00
Holger Hans Peter Freyther f6f86b0eec osmo-bts: Introduce new struct for a power loop in the BTS code
Keep track if the power level has been "fixed" by the BSC,
otherwise keep track of the currently ordered one. The ms_power
is the initial value set by the BSC and continues to be used.
2015-02-05 22:25:03 +01:00
Holger Hans Peter Freyther 4e13a8f9f9 bsc/nitb: Allow to set the GPRS mode through the ctrl command
Create a control command to read and modify the gprs mode. Use
the get_string_value to indicate if the value was found or not.
This is useful for the ctrl interface where I didn't want to
replicate "none", "gprs" and "egprs". Share code to verify that
a BTS supports the mode.

Related: SYS#591
2015-01-31 22:38:48 +01:00
Holger Hans Peter Freyther b8c204cb92 ctrl/bsc: Fix copy and paste error and update text
30f1f37638 introduced new channel
combinations but had a copy and paste error in the description.
The jenkins system didn't run the external tests so this issue
and others were not noticed until now.

Fix the copy and paste and update the test result.
2015-01-31 19:42:42 +01:00
Holger Hans Peter Freyther 7af5f8130f rsl: Remove unused code for channel activation
The code has been unused for a long time. Let's remove it.
2015-01-31 12:49:41 +01:00
Holger Hans Peter Freyther 8657326093 meas: Install the scenario command and test it 2015-01-31 12:49:41 +01:00
Holger Hans Peter Freyther a07e38d4bf meas: Add VTY documentation for the measurement commands
Document the parameters that can be passed on.
2015-01-31 09:48:18 +01:00
Jacob Erlbeck 4b2d02d037 sgsn/test: Fix memory leak in test_subscriber_gsup
Currently the MM context is not deleted when a GSUP location
cancellation message is processed, because the real
sgsn_update_subscriber_data function has been wrapped to a dummy
implementation.

This commit adds an explicit call to sgsn_mm_ctx_cleanup_free which
also unassigns the LLME, so the call to gprs_llgmm_assign is removed.

It also adds an assertion to check that there are no talloc'ed blocks
left in tall_bsc_ctx.

Addresses:
== 372 bytes in 1 blocks are possibly lost in loss record 7 of 9
==    at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==    by 0x4059FB8: _talloc_zero (talloc.c:354)
==    by 0x8055B82: sgsn_mm_ctx_alloc (gprs_sgsn.c:167)
==    by 0x804A336: alloc_mm_ctx (sgsn_test.c:140)
==    by 0x804B24D: test_subscriber_gsup (sgsn_test.c:503)
==    by 0x804EC99: main (sgsn_test.c:1853)

Sponsored-by: On-Waves ehf
2015-01-30 21:33:29 +01:00
Jacob Erlbeck baf0f94a7d sgsn/test: Add checks for subscr->error_cause
This commits adds a few asserts that check the value of
subscr->error_cause after a GSUP message has been received.

Sponsored-by: On-Waves ehf
2015-01-30 21:32:47 +01:00
Jacob Erlbeck 9ff82892da gprs: Use 'Network failure' as default cause
This commit adds a check after a GSUP message has been decoded
whether it is an error message and does not contain a cause value.
If his is the case, the cause value is set to 'Network failure', so
that this cause if effectively the default value for error messages.

Sponsored-by: On-Waves ehf
2015-01-30 21:32:26 +01:00
Jacob Erlbeck 85ba655788 gprs/test: Fix GSUP Purge MS response messages
Currently the message types for these message types are wrong.

This patch inserts the correct message types.

Sponsored-by: On-Waves ehf
2015-01-30 21:29:58 +01:00
Jacob Erlbeck 466cedd052 sgsn/test: Add tests for PurgeMs responses
Currently there are not any test cases for PurgeMS GSUP messages in
test_subscriber_gsup.

This commit adds tests for incoming PurgeMSResult and -Error
messages.

Sponsored-by: On-Waves ehf
2015-01-30 21:28:17 +01:00
Jacob Erlbeck 07f6e36ab4 gprs: Send GSUP error reply for requests without IMSI
Currently gprs_subscr_rx_gsup_message returns immediately after it
detects that an IMSI has not been given in the received GSUP message.
While this is ok for responses (result or error), a request should
always be answered.

This commit adds code to reply with a corresponding error message
("Invalid mandatory information") when it receives a request without
an IMSI.

Note that the generated error message will not contain an IMSI either.

Sponsored-by: On-Waves ehf
2015-01-30 21:28:07 +01:00
Jacob Erlbeck 8000e0ea50 gprs: Support cancellation type
The cancellation type that is part of the UpdateCancellation message
is currently ignored.

This patch adds the missing glue between the existing GSUP and GMM
support. If the type is not present or has the value updateProcedure
the subcriber and MM context are siliently removed. Otherwise, a
message with cause 'implicitly detached' is sent to the MS. Since the
real cause is not known (the specification neither added a cause IE
nor defined a static cause value), the MS may get the real cause in
the following AttachRej.

Added VTY commands:

- update-subscriber imsi IMSI cancel update-procedure
- update-subscriber imsi IMSI cancel subscription-withdraw

the old form without the cause is no longer supported.

Sponsored-by: On-Waves ehf
2015-01-30 21:27:07 +01:00
Jacob Erlbeck 929acdf6bf gprs: Handle PURGE MS ERR/RES without subscr
Currently the subscr entry is no longer present, when PURGE MS
ERROR/RESULT arrives. In this case, an unspecific notice is logged
('unknown IMSI'). This clutters up the logfile with notices even in
perfectly normal operation.

This commit changes the code path that is used when a subscr cannot
be found for an incoming GSUP message. A check for PURGE MS RESULT
and ERROR is added and gprs_subscr_handle_gsup_purge_no_subscr is
called for these messages instead of gprs_subscr_handle_unknown_imsi.

Sponsored-by: On-Waves ehf
2015-01-28 20:44:40 +01:00
Jacob Erlbeck e988ae471d gprs: Don't use subscr->keep_in_ram in normal operation
Currently the keep_in_ram flag is explicitely reset in
gprs_subscr_cleanup to cover the case, that the VTY 'create'
sub-command has been used to create the subscriber entry.

This commit completely removes keep_in_ram handling from
gprs_subscriber.c and adds a VTY 'destroy' sub-command to reset the
flag and remove the entry. So 'create' and 'destroy' can be used to
manager sticky entries that are kept even when a location
cancellation is done.

Added VTY command:

- update-subscriber imsi IMSI destroy

Sponsored-by: On-Waves ehf
2015-01-28 20:42:58 +01:00
Jacob Erlbeck e671d254cb sgsn: Add sgsn_mm_ctx_cleanup_free for safe shutdown
Currently the MM context cleanup code is distributed over several
functions. sgsn_mm_ctx_free not only frees data structure but also
eventually stops the timer and does the subscriber clean-up.
mm_ctx_cleanup_free (gprs_gmm.c) cleans up the PDP contexts and
unassign the TLLI.

This commit moves the cleanup code from both functions into a new
unifying function sgsn_mm_ctx_cleanup_free that cares about the
clean-up of all related sub-systems.

Sponsored-by: On-Waves ehf
2015-01-28 20:42:52 +01:00
Jacob Erlbeck 555b2e5ac1 sgsn: Don't allow mmctx == NULL in sgsn_update_subscriber_data
Currently, sgsn_update_subscriber_data can be called with mmctx ==
NULL and will find and associate the right context (if present) based
on the subscriber's IMSI. This will not happen in regular use
any more, since sgsn_update_subscriber_data will only be called when
subscribers are used (auth mode 'remote') and in this case
gprs_subscr_get_or_create_by_mmctx will already be called by
sgsn_auth_request. Therefore, MM context and subscriber are always
associated except for some test cases and experimental VTY usage.
The current implementation of sgsn_update_subscriber_data also causes
additional complexity for the deletion on MM contexts to avoid a
ipossible double-free MM contexts.

This commit removes the MM context <-> subscriber association code
from sgsn_update_subscriber_data. That function must always be called
with mmctx != NULL, now. To avoid problems with VTY and test usage,
the calling subscriber function now only call
sgsn_update_subscriber_data when mmctx != NULL, since the purpose of
that function is to update that state of an existing MM context after
subscriber data has been changed.

Sponsored-by: On-Waves ehf
2015-01-28 20:42:52 +01:00
Holger Hans Peter Freyther 925c57fb54 nitb: Make the last change configurable
Introduce a NITB node and add the subscriber creation as
config name in there.
2015-01-27 10:58:29 +01:00
Holger Hans Peter Freyther 1ba0730a71 nitb: Allow the network to decide if a subscriber should be created 2015-01-27 10:44:17 +01:00
Jacob Erlbeck 120250ad6f gbproxy: Remove dummy definition of subscr_put
The definition of subscr_put in gb_proxy_main.c will break linking if
symbols from libcommon are used. Since subscr_put is in libcommon,
there is no need for this dummy definition anymore.

This patch removes the dummy definition.

Adresses:
../../src/libcommon/libcommon.a(gsm_subscriber_base.o): In function `subscr_put':
/home/jerlbeck/git/build/openbsc/openbsc/src/libcommon/gsm_subscriber_base.c:90: multiple definition of `subscr_put'
gb_proxy_main.o:/home/jerlbeck/git/build/openbsc/openbsc/src/gprs/gb_proxy_main.c:56: first defined here

Sponsored-by: On-Waves ehf
2015-01-27 08:35:18 +01:00
Jacob Erlbeck 306bb993aa sgsn: Don't reset mm->subscr manually in sgsn_mm_ctx_free
Currently the sgsn_mm_ctx_free contains code to reset the mm->subscr
field that is also present in gprs_subscr_cleanup, which is called
directly afterwards.

This commit modifies the code path, so that the cleanup is done by
the gprs_subscr_cleanup function. The additional reference counter
increment is needed, since mm->subscr->mm->subscr (which is the same
like mm->subscr) will be reset (and unref'd) within
gprs_subscr_cleanup. Because the local variable subscr in
sgsn_mm_ctx_free is an additional pointer to the subscriber object,
it is consequent to adjust the reference counter when the assignment
is done.

Sponsored-by: On-Waves ehf
2015-01-27 08:31:36 +01:00
Jacob Erlbeck 3e4e58f349 gprs: Rename gprs_subscr_delete to gprs_subscr_cleanup
The old name is somewhat misleading. The function is rather preparing
the subscriber for a subsequent subscr_free, that is possibly invoked
by a subscr_put. It detaches the subscriber from the MM context and
optionally invokes a PURGE_MS procedure. Therefore the _cleanup
suffix is chosen (see mm_ctx_cleanup_free).

Sponsored-by: On-Waves ehf
2015-01-27 08:31:03 +01:00
Jacob Erlbeck 3ee67ff5c2 gprs: Don't check for EINPROGRESS in gprs_gsup_client_create
Currently, the return value of gsup_client_connect is checked whether
it is < 0 and != -EINPROGESS. Since gsup_client_connect will only
return a negative value on a few permanent errors (not including
EINPROGRESS), rc is always != EINPROGRESS.

This patch removes the explicit check againt -EINPROGRESS and just
leaves the check rc < 0.

Sponsored-by: On-Waves ehf
2015-01-27 08:30:49 +01:00
Holger Hans Peter Freyther abb3478533 gb_proxy: No need to copy optarg
Fixes: Coverity CID 1206578
2015-01-27 08:30:37 +01:00
Jacob Erlbeck 496aee7cb8 sgsn: Ensure 0-terminated imsi strings (Coverity)
Currently the size argument of strncpy is set to sizeof(mm->imsi) in
some places. If the source IMSI string is too long, the terminating
NUL byte in the static mm->imsi field gets overwritten.

This patch limits the size to sizeof(mm->imsi)-1, so that the last
byte of the buffer (that has been initialized to 0) is not
overwritten.

Fixes: Coverity CID 12065751, 12065754, 1206575

Sponsored-by: On-Waves ehf
2015-01-26 10:59:49 +01:00
Jacob Erlbeck 37139e5933 gprs: Do not put the subscr in gprs_subscr_delete
Currently gprs_subscr_delete implicitely calls subscr_put, which
makes the code more complex than necessary (additional subscr_get) in
a few places. It also makes it more difficult to see, whether get/put
are balanced within a function. In addition, the functions are not
named consistently (gprs_subscr_delete vs.
gprs_subscr_put_and_cancel).

This commit changes the semantics of gprs_subscr_delete and
indirectly of gprs_subscr_put_and_cancel to not call subscr_put on
their argument, but to leave that for the caller to do it
explicitely.

It renames gprs_subscr_put_and_cancel to gprs_subscr_cancel to
reflect that change in the name, too.

Sponsored-by: On-Waves ehf
2015-01-26 09:10:06 +01:00
Holger Hans Peter Freyther 1d778fdce3 sgsn: Remove the "permanent" subscriber cache
The subscriber cache would help in case:

  * GPRS DETACH, GPRS ATTACH. In that case we might still
  have some cached authentication tuples we avoid another
  sendAuthenticationInfo request.

  * After a detach the cache expiry would make sure to
  eventually send a purgeMS to the HLR (which might be
  ignored).

At the same time to make the cache work we will need to
make sure to start and stop timers. In case we don't
start we might accumulate subscribers. I am afraid that
the above two benefits do not outweight the complexity
of this implementation.
2015-01-26 09:09:12 +01:00
Holger Hans Peter Freyther e47d4f6d11 sgsn: Remove MM from the list before gprs_subscr_delete is called
Modify sgsn_mm_ctx_free to remove the entry from the
list as otherwise we might double free the context from
within gprs_subscriber_delete.
2015-01-26 09:08:57 +01:00
Jacob Erlbeck 81ffb740f7 sgsn: Remove inactive LLME/MM after inactivity timeout
Currently old LLMEs and MM contexts that haven't been explicitly
detached or cancelled are not removed until another request with the
same IMSI is made. These stale entries may accumulate over time and
severely compromise the operation of the SGSN.

This patch implements age based LLME expiry, when the maximum age has
been reached, the corresponding MM context is cancelled. If such an MM
context doesn't exist, the LLME is unassigned directly.

The implementation works as follows.
 - llme->age_timestamp is reset on each received PTP LLC message
 - sgsn_llme_check_cb is invoked periodically (each 30s)
 - sgsn_llme_check_cb sets the age_timestamp to the current time if
   it has been reset
 - sgsn_llme_check_cb computes the age and expires the LLME if
   it exceeds gprs_max_time_to_idle()

Ticket: OW#1364
Sponsored-by: On-Waves ehf

[hfreyther: Fix typo in comment LMME -> LLME]
2015-01-26 08:51:50 +01:00
Jacob Erlbeck 841d95f867 gprs: Use a macro value to set the 'Periodic RA update timer'
Currently the T3312 timer is directly set as encoded value when
generating the Attach/RAU Accept messages.

This patch adds GSM0408_T3312_SECS and uses it to set the
information element's value.

Sponsored-by: On-Waves ehf
2015-01-26 08:44:27 +01:00
Jacob Erlbeck 8de9c48c99 gprs: Add 'Negotiated READY timer value' IE to Attach/RAU Accept
Currently this optional IE is omitted, so that the optional
'Requested READY timer value' of the corresponding Request message
is used by the MS (or the default value if this IE is not used).

This patch extends gsm48_tx_gmm_att_ack and gsm48_tx_gmm_ra_upd_ack
to always include the IE set to the default value of T3312 (44s,
see GSM 04.08, table 11.4a).

Ticket: OW#1364
Sponsored-by: On-Waves ehf
2015-01-26 08:42:43 +01:00
Jacob Erlbeck 79af67d7c0 gprs: Add GPRS timer conversion functions
Currently, all GPRS timer values are hard-coded. To make these values
configurable in seconds and to show them, conversion functions from
and to seconds are needed.

This patch adds gprs_tmr_to_secs and gprs_secs_to_tmr_floor. Due to
the limited number of bits used to encode GPRS timer values, only a
few durations can be represented. gprs_secs_to_tmr_floor therefore
always returns the timer value that represents either the exact
number (if an exact representation exists) or the next lower number
for that an exact representation exists.

Sponsored-by: On-Waves ehf
2015-01-26 08:41:52 +01:00
Jacob Erlbeck 37184900e7 gprs: Return 0 from gsup_client_connect if ok or retry timer enabled
Currently the gsup_client_connect return 0 if the call to
ipa_client_conn_open was successful and -errno otherwise. This makes
it difficult for the caller to determine, whether the the whole
operation has been cancelled (currently on EBADF, ENOTSOCK,
EAFNOSUPPORT, EINVAL) or whether the GSUP client will retry to
connect after a timeout. This will cause gprs_gsup_client_create to
destroy the GSUP client object, even if the error might be temporary.

This patch changes the function to return 0 if (and only if)
ipa_client_conn_open was successful or the retry timer has been
started. Since the return value 0 doesn't guarantee, that a
subsequent call to gprs_gsup_client_send will succeed, this shouldn't
break anything.

Sponsored-by: On-Waves ehf
2015-01-26 08:41:52 +01:00
Holger Hans Peter Freyther 9d1a17e15f osmux: Initialize the socket only once
The per BSC code didn't guard against the init already having
been executed. This lead to:

 Adding a osmo_fd that is already in the list.
 <000b> bsc_nat_vty.c:1200 Setting up OSMUX socket

So a new socket got created and the old one leaked. Luckily
Linux appears to allow to bind multiple times so we were able
to just read from the new one. Use the same guard that is used
on the MGCP MGW. Re-order the log message to say "Setting up"
before we actually do that. I manually verified that osmux_init
is called at most once.

The log message was spotted by Roch
2015-01-21 16:56:53 +01:00
Jacob Erlbeck b194862b62 debian: Fix dependencies
The dependecies do not match the current package names or are
missing:

Build-Depends:
  - renamed libgtp-dev -> libgtp0-dev
  - added   libosmo-netif-dev

Depends:
  - renamed libgtp     -> libgtp0

Other run time dependencies might still be missing and have to be
installed manually.

This is taken from Holger's e744ebd17c3761b5cad81d718d0349f2f820ec66.
In addition, the build-dependency on libgtp-dev is replaced by
libgtp0-dev.
2015-01-21 13:24:38 +01:00
Holger Hans Peter Freyther 9be675ea52 mgcp: Honor the rtp IP_TOS settings for Osmux
Honor the IP_TOS settings for Osmux as well. Re-use the RTP
setting as it makes sense to classify the audio packets the
same way.

Fixes: OW#1369
2015-01-21 11:43:03 +01:00
Jacob Erlbeck d91934357f sgsn: Restructure the 'update-subscriber' command
This patch drops the following commands:

 - update-subscriber imsi IMSI insert authorized <0-1>
 - update-subscriber imsi IMSI commit

since they are already covered by the 'update-location-result'
sub-command, except that this command doesn't create an new entry if
none is found with the given IMSI.

It adds the following command:

 - update-subscriber imsi IMSI create

which can be used to create a new entry.

Sponsored-by: On-Waves ehf
2015-01-20 16:14:01 +01:00
Jacob Erlbeck 15cc8c8125 sgsn: Fix vty_out newlines
Currently '\n' is used to end lines in the VTY output string
constants instead of inserting VTY_NEWLINE. This leads to incorrect
line starts in error messages.

This patch fixes that accordingly.

Sponsored-by: On-Waves ehf
2015-01-20 16:13:55 +01:00
Jacob Erlbeck d6267d12d8 sgsn: Add SGSN_ERROR_CAUSE_NONE and use it instead of 0
Currently an error_cause of 0 is being used to indicate normal
operation. Albeit this is not a defined GMM cause, the value is not
explicitly reserved.

This commit adds the macro SGSN_ERROR_CAUSE_NONE and uses it for
initialisation (instead of relying on talloc_zero) and comparisons.
The value is set to -1 to be on the safe side. The VTY code is
updated to set the error_cause when using the
'update-subscriber imsi IMSI update-location-result CAUSE' command.

Sponsored-by: On-Waves ehf
2015-01-20 16:13:48 +01:00
Jacob Erlbeck 2585620857 sgsn: Fix access to subscr in sgsn_auth_update (Coverity)
Currently the access to subscr->sgsn_data->error_cause is not
protected against subscr == NULL like it is done in other code paths
of sgsn_auth_update.

This commit adds a conditional to avoid a NULL-dereference.

Fixes: Coverity CID 1264589

Sponsored-by: On-Waves ehf
2015-01-20 16:13:17 +01:00
Jacob Erlbeck 6be9ffa3b8 sgsn/test: Make assert_substr safer (Coverity)
Currently, if assert_subscr were called with subscr == NULL, the
later call to subscr_put might fail, as Coverity has complained. In
addition, the call to subscr_put would free the subscr object if it
were in the cache with a refcount of 0 at the time assert_substr was
called.

This patch adds a check for the subscr being non-NULL and reorders
the checks, so that the subscr_put comes last.

Fixes: Coverity CID 1264590

Sponsored-by: On-Waves ehf
2015-01-20 16:13:09 +01:00
Jacob Erlbeck d8a65536ec sgsn: Fix P-TMSI generator's distance of equal values
Currently sgsn_alloc_ptmsi uses rand() to get a new P-TMSI and then
sets to upper 2 MSB. Therefore there is no lower limit of the
distance between 2 identical P-TMSI.

This patch changes the implementation to discard any random value
above 2^30 and to generate a new random number in that case until a
fitting number is found (or a repetition limit is reached). This way,
all number below 2^30 within the PRNG's period are used.

Ticket: OW#1362
Sponsored-by: On-Waves ehf
2015-01-20 16:13:01 +01:00
Jacob Erlbeck 87c7ffccea gprs: Support the full cancellation procedure
Currently no GSUP LocationCancellationResult message is sent back to
the peer (HLR), if the procedure succeeded at the SGSN's side.

This patch adds the missing message and put the whole request
handling of this procedure into a separate function.

Ticket: OW#1338
Sponsored-by: On-Waves ehf
2015-01-20 16:12:52 +01:00
Jacob Erlbeck 4dedb27d7e gprs: Don't create a subscr entry on InsertSubscriberData
Currently gprs_subscr_rx_gsup_message creates a subscriber entry if
such an entry doesn't exist for the IMSI within an
InsertSubscriberData GSUP message. This behaviour is not compliant to
GSM 09.02, 20.3.3.2 (Subscriber data management/SGSN) where it is
defined, that an error ("Unidentified subscriber") shall be returned.

This patch removes the case distinction, so that an existing
subscriber entry is required for all incoming GSUP messages.

Sponsored-by: On-Waves ehf
2015-01-20 16:12:45 +01:00
Jacob Erlbeck 9999fd9026 gprs: Add replies for all GSUP requests
Currently, an incoming GSUP request message isn't answered at all if
it is not handled due to an error or missing implementation.

This patch adds GSUP error replies for these requests (and only for
requests). It also adds tests for these cases.

Note that several of these tests check for
GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL, which will have to be changed, when
the features are implemented.

Sponsored-by: On-Waves ehf
2015-01-20 16:12:39 +01:00
Jacob Erlbeck f81cacc681 gprs: Block other GSUP procedures during PURGE_MS
GSM 09.02, 19.4.1.4 mandates that no other MAP procedures shall be
started until the PURGE_MS procedure has been completed.

This patch implements this by adding corresponding state and checks
to gprs_subscr_purge, gprs_subscr_location_update, and
gprs_subscr_update_auth_info. If an Update Location or a Send Auth
Info Req procedure is not started because of blocking, the retry
mechanism is aborted to shorten the blocking time. The outstanding
Purge MS procedure itself is not aborted.

Sponsored-by: On-Waves ehf
2015-01-20 16:12:33 +01:00
Jacob Erlbeck 743dec4c0c gprs: Retry PURGE_MS procedure after timeout
Currently, when the PURGE_MS_REQ to the HLR gets lost (e.g. by a
connection or peer failure), the expired subscriber entry will not get
deleted.

This commit adds a retry mechanism then restarts the procedure after
a timeout (currently 10s). The maximum number of retries is limited
(currently to 3 PURGE_MS messages). If none of these procedures is
completed (either with success or error), the subscriber data is
deleted.

Sponsored-by: On-Waves ehf
2015-01-18 18:37:36 +01:00
Jacob Erlbeck 65fa3f73a1 gprs: Use PURGE MS messages
When a subscriber entry is going to be deleted by SGSN and when the
subscriber info has been obtained from a remote peer via GSUP, the
peer should be informed before the entry is really deleted. For this
purpose, MAP defines the PURGE MS procedure (see GSM 09.02, 19.1.4).

This patch adds support for the PURGE_MS_REQ/_ERR/_RES messages and
invokes the procedure when the subscriber entry is going to be
removed. This only applies if GSUP is being used, the Update
Location procedure has been completed successfully, and the
subscriber has not been cancelled. The removal of the entry is
delayed until a PURGE_MS_RES or PURGE_MS_ERR message is received.

Note that GSM 09.02, 19.1.4.4 implies that the subscriber data is not
to be removed when the procedure fails which is not the way the
feature has been implemented.

Note that handling 'P-TMSI freezing' is not implemented.

Ticket: OW#1338
Sponsored-by: On-Waves ehf
2015-01-18 18:33:31 +01:00
Jacob Erlbeck 69d271376c gprs: Implement PURGE_MS GSUP messages
This commit implements the encoding and decoding of the messages

  - Purge MS Request
  - Purge MS Error
  - Purge MS Result

and adds corresponding tests.

Sponsored-by: On-Waves ehf
2015-01-18 18:33:13 +01:00
Jacob Erlbeck cde0bb27a1 sgsn/doc: Add message definitions for PURGE_MS responses
Currently the definitions of the message PURGE_MS_RES and
PURGE_MS_ERR are missing in the specification.

This patch adds those definitions.

Sponsored-by: On-Waves ehf
2015-01-18 18:29:47 +01:00
Jacob Erlbeck 058bc26e1b sgsn/test: Add checks and reports to detect subscr leakage
This commit adds talloc reports to log remaining NULL chunks after the
terminates. It also adds explicit checks for empty subscriber lists.

Sponsored-by: On-Waves ehf
2015-01-18 18:29:13 +01:00
Jacob Erlbeck c157ee7d2c sgsn/test: Add test that intercepts gprs_gsup_client_send
This test replaces gprs_gsup_client_send by a custom function, that
emulates a GSUP remote peer by calling gprs_subscr_rx_gsup_message
with responses for all requests. It then executes a full
Attach/Detach cycle.

Sponsored-by: On-Waves ehf
2015-01-18 18:28:20 +01:00
Jacob Erlbeck 0f47b8fae7 gprs: Add expiry timeout for subscriber entries
Set the expiry delay after the subscriber has been deleted (e.g. by
freeing the MM context). If cancelled, the subscriber will be deleted
immediately and no timeout will be set. If the expiry time is set to
SGSN_TIMEOUT_NEVER, no timer will be started and the subscriber entry
will be kept until it is cancelled.

The following VTY command is added to the sgsn node:

  - subscriber-expiry-time <0-999999>    set expiry time in seconds
  - no subscriber-expiry-time            set to SGSN_TIMEOUT_NEVER

The default is an expiry time of 0 seconds, which means that the
subscriber entries are wiped out immediately after an MM context is
destroyed.

Note that unused MM contexts are not expired yet. Therefore the
subscriber will only be expired after a successful MM detach.

Sponsored-by: On-Waves ehf
2015-01-18 18:27:19 +01:00
Jacob Erlbeck b8fb1409d1 sgsn/test: Refactor subscriber test
The code sequence that checks, whether a subscriber is still
reachable for a given IMSI, is repeated several times.

This patch puts this code sequence into a single function and adds a
check for the IMSI after the entry has been found. In addition,
some comments are extended.

Sponsored-by: On-Waves ehf
2015-01-18 18:26:35 +01:00
Jacob Erlbeck e1beb6f51d sgsn/test: Fix subscriber cleanup
Currently the subscribers are not really deleted by
cleanup_subscr_by_imsi, but kept in RAM instead.

This patch fixes this and adds a test to verify, that the subscriber
is really deleted afterwards.

Sponsored-by: On-Waves ehf
2015-01-18 18:26:14 +01:00
Jacob Erlbeck d3cde1ecf4 gprs/test: Move subscr cleanup code into a separate function
Refactor several occurences of the same subscriber cleanup code into
a seperate cleanup_subscr_by_imsi function.

Sponsored-by: On-Waves ehf
2015-01-18 18:26:03 +01:00
Jacob Erlbeck f06fe29f61 gprs: Pass GMM causes related to the MSC connection
Currently the error causes MSC_TEMP_NOTREACH, NET_FAIL, and
CONGESTION are silently dropped to force the MS to continue. On the
other hand, GSM 04.08/24.008, 4.7.3.1.4 in combination with 4.7.3.1.5,
require the MS to retry the attachment procedure for cause codes
above 15 instead of disabling GPRS. All of the mentioned GMM causes
have codes above 15, so using a REJECT message including the cause
code is a better choice. This way, the retry algorithm based on T3311
(15s, 5 times) and T3302 (default 12min) could be used.

This patch modifies gprs_subscr_handle_gsup_auth_err and
gprs_subscr_handle_gsup_upd_loc_err to proceed like when the access
has beed denied, except that the corresponding subscriber's
information fields are not cleared.

This has been successfully tested which an iphone which enters a
retry loop as it is being described in the specification.

Sponsored-by: On-Waves ehf
2015-01-18 18:23:51 +01:00
Jacob Erlbeck bf34c67f3f gprs: Use LOGGSUBSCRP and LOGMMCTX for logging in gprs_susbcriber.c
To unify the layout of the logging messages in gprs_subscriber.c,
this patch replaces each LOGP by LOGGSUBSCRP, unless a non-NULL
pointer to a subscr is not available. In those cases, it uses
LOGMMCTXP if a pointer to an MM context is available or LOGP
otherwise.

Sponsored-by: On-Waves ehf
2015-01-18 18:23:21 +01:00
Jacob Erlbeck 4275578570 gprs: Add LOGGSUBSCRP macro to log subscriber info
This patch adds a new logging macro, that logs to DGPRS and provides
a uniform prefix containing the IMSI without using the mm reference.
This is an improvement over using LOGMMCTXP, since the new macro also
provides an IMSI if no MM context is attached.

Sponsored-by: On-Waves ehf
2015-01-18 18:23:04 +01:00
Jacob Erlbeck bce2061b43 gprs: Let GSUP parser functions return GMM causes on errors
Currently the GSUP message handling function in gprs_subscriber.c and
the functions in gprs_gsup_messages.c are not consistent with respect
to the return codes if an error happens. Albeit all error return
codes are negative, the semantics of the absolute value are not
clearly defined. In addition, some return codes are not passed to the
calling function.

This path changes these functions to always return a negated GMM
cause value in case of errors. Return values of called parser
functions are not longer ignored.

Sponsored-by: On-Waves ehf
2015-01-18 18:22:47 +01:00
Jacob Erlbeck 9aa9991efe gprs: Use the cause value in GSUP error messages
Currently always a cause with the meaning of 'access denied' is
assumed. gprs_subscr_handle_gsup_auth_err just clears the auth
triplets and the authorized flag before calling the update function.
gprs_subscr_handle_gsup_upd_loc_err only clears the authorized flag
and calls the update function. This means, that an MS will not retry
to attach even on temporary network errors.

This patch changes these functions to use the GSUP error cause value
to decide, whether to clear the corresponding subscriber fields, to
just continue with the corresponding update function, or to log,
ignore and not pass the cause to the MS in case the error is directly
related to the GSUP protocol. The subscriber's error_cause field is
updated, if the update function is going to be called. The
error_cause fielt is reset on non-error GSUP messages.

Sponsored-by: On-Waves ehf
2015-01-18 18:20:41 +01:00
Jacob Erlbeck af3d5c508c sgsn: Pass subscriber error causes to the GMM layer
This patch extends gsm0408_gprs_access_denied and
gsm0408_gprs_access_cancelled to accept GMM cause codes. These are
then passed to the MS, unless gsm0408_gprs_access_cancelled is called
with cause 0 (no error -> updateProcedure).

Since gsm0408_gprs_access_denied uses GMM_CAUSE_GPRS_NOTALLOWED if
the cause is not set, and the subscriber's error_cause is never set
(and thus always 0), the SGSN's behaviour does not change with this
patch.

Sponsored-by: On-Waves ehf

Conflicts:
	openbsc/include/openbsc/gprs_sgsn.h

[hfreyther: Conflict due the removal of the unused
authenticate flag]
2015-01-18 18:14:49 +01:00
Jacob Erlbeck afcf23001e gprs: Move protocol value_strings to gsm_04_08_gprs.c
Currently the mapping between GSM 04.08 (GPRS) protocol specific
numbers and their textual description was put into gprs_gmm.c and not
exported.

This commit moves the mappings to a new file gsm_04_08_gprs.c,
renames some of them, and exports them via gsm_04_08_gprs.h.

The following identifiers are renamed to match the corresponding type
names:

  - gmm_cause_names -> gsm48_gmm_cause_names
  - gsm_cause_names -> gsm48_gsm_cause_names

Sponsored-by: On-Waves ehf
2015-01-18 18:13:06 +01:00
Jacob Erlbeck 8054799963 sgsn: Show GSUP client info on 'show sgsn'
This commit adds a line to the output of 'show sgsn' if the GSUP
client has been initialized:

  - Remote authorization: [not] connected to HOST:PORT via GSUP

Sponsored-by: On-Waves ehf
2015-01-18 18:12:06 +01:00
Jacob Erlbeck 03b4630348 gprs: Send PING and eventually reconnect
Currently, the reconnect mechanism relies on gsup_client_updown_cb
which in turn gets called based on the OS' view of connection state.

This patch adds a timer based PING mechanism that regularly sends
PING messages and forces a reconnect if a PONG message won't be
received until the next PING message is scheduled. The current ping
interval is 20s.

Sponsored-by: On-Waves ehf

Conflicts:
	openbsc/src/gprs/gprs_gsup_client.c

[hfreyther: Conflicts due the potential memleak fix by me. Removed
another TODO from the code as we stop the ping/pong timer]
2015-01-18 18:11:08 +01:00
Jacob Erlbeck e154d8bdd4 gprs: Handle incoming IPA CCM message in gsup_client_read_cb
Currently the IPA CCM messages are not handled by the GSUP client.
This means, that the client doesn't answer to PING and ID_GET and
logs notices when receiving PONG or ID_ACK. At least the PING
functionality (remotely originated PING) shall be supported.

This patch extends gsup_client_read_cb by a call to
ipaccess_bts_handle_ccm. Only when the return code is 0, the message
is processed further and checked for an OSMO/GSUP message. ID_GET
messages are answered by a dummy description, where only the
unit_name is set to 'SGSN'.

Sponsored-by: On-Waves ehf
2015-01-18 18:02:09 +01:00
Jacob Erlbeck 69e16b9ea5 gprs: Handle return code of ipa_client_conn_open correctly
The ipa_client_conn_open function does not distinguish between a
connection being already established or waiting for establishment.
In either case, the application gets informed about the connection
state via the updown_cb. The 'up' parameter is only set, if
poll/select consider the socket as writable.

This patch handles both cases equally and fully relies on the
updown_cb to adjust the gsupc obejct state.

Sponsored-by: On-Waves ehf
2015-01-18 17:59:18 +01:00
Jacob Erlbeck 4188c30c4a gprs: Avoid sending stale GSUP requests after reconnect
Currently, messages are added to the tx queue even if the connection
is down for some reason and all of these messages are eventually sent
after a re-connect.  The MS has probably sent several Attach Requests
while the connection was down and will continue doing so. Therefore
these stored messages could be dropped.

This patch clears the queue before re-connecting and also extends
gprs_gsup_client_send to return immediately, when the connection is
not established instead of calling ipa_client_conn_send.

Sponsored-by: On-Waves ehf

[hfreyther: Replaced
	while (!llist_empty(&gsupc->link->tx_queue))
		llist_del(gsupc->link->tx_queue.next);
with new libosmo-abis API]
2015-01-18 17:58:56 +01:00
Jacob Erlbeck 849d0a83e8 gprs: Add automatic re-connect if the GSUP connection is down
Currently the GSUP connection to a server is not restarted if the
connection cannot be established or is terminated during operation.

This commit adds a timer based connection mechanism, basically
consisting of a timer callback that calls gsup_client_connect. The
timer is eventually triggered (up == 0) or cleared (up != 0) by
gsup_client_updown_cb. It adds calls to osmo_timer_del() to
gsup_client_connect and gprs_gsup_client_destroy. The latter is now
called instead of talloc_free in gprs_gsup_client_create on error to
be on the safe side.

Sponsored-by: On-Waves ehf
2015-01-18 17:24:37 +01:00
Jacob Erlbeck 7660ffa29f sgsn/test: Extend tests to simulate lost GSUP requests
This patch extends test_gmm_attach to optionally resend Attach
Requests until the SGSN responds to it instead of calling
OSMO_ASSERT at a few places. The test_gmm_attach_subscr_gsup_auth
test optionally uses this feature. It is called once in either mode.

Sponsored-by: On-Waves ehf
2015-01-18 17:23:59 +01:00
Jacob Erlbeck 3d722450de sgsn/test: Add GMM test for a GSUP based attach procedure
This test calls test_gmm_attach() where the mocked subscriber
functions insert GSUP messages instead of manipulating the
subscriber structure directly.

Sponsored-by: On-Waves ehf
2015-01-18 13:27:02 +01:00
Jacob Erlbeck e21e184d84 sgsn/test: Add wrapper for gprs_subscr_rx_gsup_message
Currently, several lines of boiler plate are needed around a call to
gprs_subscr_rx_gsup_message.

This patch puts all of this (including the call to
gprs_subscr_rx_gsup_message) into a separate function.

Sponsored-by: On-Waves ehf
2015-01-18 13:25:24 +01:00
Jacob Erlbeck 771573c535 sgsn: Add global require_update_location flag
This flag is used to determine, whether the Update Location procedure
shall be invoked. This is currently only set, when the 'remote'
authorization policy is set. When the flag is set, sgsn_auth_update
will not never be called directly by sgsn_auth_request, if an Attach
Request procedure is pending, even if the remote connection fails for
some reason.

Sponsored-by: On-Waves ehf
2015-01-18 13:23:13 +01:00
Holger Hans Peter Freyther a071c1ccc0 gprs: Remove now unused authenticate flag
This has been obsoleted by the previous commit. Remove it.
2015-01-18 13:22:37 +01:00
Jacob Erlbeck 9d4f46c975 sgsn: Replace subscr.authenticate by global require_authentication flag
Currently the flag 'authenticate' is managed per subscriber.

This patch replaces that flag by a global cfg.require_authentication
flag that enables/disables the use of the Auth & Ciph procedure for
every subscriber. The flag is set by the VTY, if and only if the
authorization policy is 'remote'.

The VTY command

  - update-subscriber imsi IMSI insert authenticate <0-1>

is removed.

Sponsored-by: On-Waves ehf
2015-01-18 13:18:35 +01:00
Jacob Erlbeck 39f040d62b sgsn: Integrate the GSUP client into the SGSN
This commit adds GSUP client configuration (via VTY), connection set
up, and real message sending.

The following configuration commands are added:

 - gsup remote-ip A.B.C.D            set server IP address
 - gsup remote-port PORT             set server TCP port

Ticket: OW#1338
Sponsored-by: On-Waves ehf
2015-01-18 13:17:50 +01:00
Jacob Erlbeck bb23dc17f8 gprs: Add GSUP client
This commit adds the client code to get subscriber information from a
remote server. It provides an IPA over TCP connection to transmit and
receive GSUP messages.

Sponsored-by: On-Waves ehf
2015-01-18 13:17:11 +01:00
Jacob Erlbeck 1610626fe9 gprs: Clear GSUP message structures before decoding
Currently the message structure is not cleared before the message is
parsed which can cause information leaking between messages if the
same gprs_gsup_message object is used. Especially list elements (auth
tuples and pdp info) are not replaced by an IE, but the IE is
appended.

This patch uses the assignment operator to clear gprs_gsup_message,
gsm_auth_tuple, and gprs_gsup_pdp_info before using them. This also
replaces the use of memcpy of the latter.

Sponsored-by: On-Waves ehf
2015-01-18 13:17:09 +01:00
Jacob Erlbeck a2315eebf9 gprs: Always reset auth tuples/pdp infos in gprs_gsup_decode
Currently auth tuples are always appended to the lists when
gprs_gsup_decode is called with a gsup_msg structure. This makes a
test case fail, where the same gsup_msg is used again and again
without clearing it after each use.
Sponsored-by: On-Waves ehf
2015-01-18 13:17:09 +01:00
Jacob Erlbeck 424ffa4806 gprs: Handle empty GSUP messages correctly
Currently, the gprs_gsup_decode function doesn't check the return
value of gprs_shift_v_fixed before using the value pointer. The
function fails, if the GSUP message length (not including IPA
headers) is 0. In this case, a segfault can happen, depending on the
value of the uninitialized 'value' pointer. The test case doesn't
trigger a segfault, but valgrind complains about reading
uninitialized data.

This patch adds a check for the return value that would return with
an error code if the shift function failed.

Sponsored-by: On-Waves ehf
2015-01-18 13:17:09 +01:00
Jacob Erlbeck 0572ee045d gprs/test: Add tests for invalid GSUP messages
Currently, the tests only use valid GSUP messages. This does not
check the robustness of the parser.

This commit adds a test for truncated messages and another for
modified messages.

Thanks to Holger for the basic truncation test.

Sponsored-by: On-Waves ehf
2015-01-18 13:17:09 +01:00
Jacob Erlbeck f0b06d82cd sgsn/test: Fix msgb freeing in mocked bssgp_tx_dl_ud
Currently the mocked bssgp_tx_dl_ud function used for testing in
sgsn_test.c does not free the msg as it is done by the original
function. This leads to a msgb leak in the test.

This patch fixes the test code accordingly and uncomments the
assertion that checks for left-over msgbs.

Sponsored-by: On-Waves ehf
2015-01-18 13:17:09 +01:00
Jacob Erlbeck 07de92e2c0 sgsn/test: Add checks and reports to detect msgb leakage
This commit adds talloc reports to log remaining chunks after the
testing has been finished. It also adds a (currently disabled) check,
that no msgbs are allocated after running the tests.

Sponsored-by: On-Waves ehf
2015-01-18 13:17:08 +01:00
Jacob Erlbeck a6ddc2d99f gprs: Add subscriber functions to create/handle GSUP messages
This patch extends gprs_subscr_query_auth_info and
gprs_subscr_location_update to create GSUP messages with the help of
a static gprs_subscr_tx_gsup_message function. A corresponding
gprs_subscr_rx_gsup_message is added which takes a messages, gets the
subscr, and updates it accordingly.

Sponsored-by: On-Waves ehf

[hfreyther: Added a msgb_free gprs_subscr_tx_gsup_message]
2015-01-10 21:26:18 +01:00
Jacob Erlbeck f3a271fa73 gprs: Add encoder/decoder for the Subscriber Update Protocol
This patch adds functions to encode and decode GSUP messages. This
does not include the layer 1 framing (IPA). The messages so far
supported are: send_auth_info_*, update_location_*,
location_cancellation_*.

Sponsored-by: On-Waves ehf
2015-01-10 21:26:18 +01:00
Jacob Erlbeck 46684dcfd2 sgsn/doc: Add IPA default parameters
This commit adds the default protocol identifiers that should be used
for GSUP by the IPA protocol.

Sponsored-by: On-Waves ehf
2015-01-10 21:26:18 +01:00
Jacob Erlbeck 0024cee9f8 sgsn/doc: Add protocol specification for remote subscriber update
This is the first version of the specification for the GPRS
Subscriber Update Protocol.

Sponsored-by: On-Waves ehf
2015-01-10 20:55:46 +01:00
Jacob Erlbeck 17fb3d46ff sgsn: Fix VTY command error handling (Coverity)
Currently the result of the osmo_hexparse function in
update_subscr_insert_auth_triplet is not handled correctly. There is
a misplaced leading exclamation mark in a few conditional
expressions. This effectively disables the error checks, as it is
noticed by Coverity ("Missing parentheses" followed by "Logically
dead code").

This patch removes the exclamation marks.

Fixes: Coverity CID 1260435 and CID 1260434
Sponsored-by: On-Waves ehf
2015-01-10 20:55:04 +01:00
Holger Hans Peter Freyther bb06eb9d7c meas: Unbreak the build once more
The code assumes that sqlite3.h is in the standard include
path. Maybe sqlite3 wasn't installed or resides in a non
standard (/usr/local) location? Fix the build as it has been
broken since 1st of January.
2015-01-10 09:54:30 +01:00
Harald Welte a67704753a Revert "debug.c: use new libosmocore features to print and save log filter"
This reverts commit c598e6e0a6.

It introduced a dependency from libcommon to libosmovty, which we don't
want
2015-01-05 14:15:16 +01:00
Harald Welte 0c4e400d2f meas_pcap2db.c: Fix build without CDK
Spotted by Jacob Erlbeck.
2015-01-05 14:13:16 +01:00
Harald Welte c598e6e0a6 debug.c: use new libosmocore features to print and save log filter 2015-01-05 14:05:32 +01:00
Harald Welte a9e420e93d RSL: Change "... is back in operation" to an INFO level message 2015-01-05 14:05:32 +01:00
Harald Welte 1dcc2603e9 Don't return an error to caller if we are out of lchan on CHAN RQD
This is a normal situation under high load: The BTS is out of resources
and the BSC cannot allocate any dedicated channel.  We may send an IMM
ASS REJECT back to the MS.  All well within normal parameters, not an
error that needs to be reported back to the caller, who propagates it
all the way up to libosmo-abis.
2015-01-05 14:05:32 +01:00
Harald Welte e5d2c60ae6 SMS: Attempting to send SMS is not a NOTICEable event 2015-01-05 14:05:32 +01:00
Holger Hans Peter Freyther 6995f24831 logging: Only compare the subscr address
Move the "logging filter imsi IMSI" into the BTS/NITB code to
allow to set the gsm_subscriber and only compare it. This way
we simply compare the subscriber address and don't have to care
if the subscriber data is still valid.
2015-01-02 11:43:06 +01:00
Holger Hans Peter Freyther b7ccac4d62 logging: Set the context for paging requests as well. 2015-01-02 11:43:06 +01:00
Holger Hans Peter Freyther 454140e7fc lchan: Remember why a channel is broken using static strings
Remember why a channel is being marked as broken. So we can
maybe understand what happend.
2015-01-02 11:43:06 +01:00
Holger Hans Peter Freyther 52fa7bd2da misc: Ignore new binaries 2015-01-02 11:43:06 +01:00
Holger Hans Peter Freyther c6e32ad0b8 Partial revert "Fix most compiler warnings with gcc-4.9.2"
Most of the "fixes" have nothing to do with gcc-4.9.2 but are a
question of ABI/Architecture (e.g. x86 vs. AMD64). Revert these
for now.

This partially reverts commit 7b1d25a11e.

abis_test.c: In function ‘test_simple_sw_config’:
abis_test.c:68:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
  printf("Start: %ld len: %zu\n", descr[0].start - simple_config, descr[0].len);
  ^
abis_test.c: In function ‘test_dual_sw_config’:
abis_test.c:111:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
  printf("Start: %ld len: %zu\n", descr[0].start - dual_config, descr[0].len);
  ^
abis_test.c:115:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
  printf("Start: %ld len: %zu\n", descr[1].start - dual_config, descr[1].len);
  ^
abis_test.c: In function ‘test_sw_selection’:
abis_test.c:132:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
  printf("Start: %ld len: %zu\n", descr[0].start - load_config, descr[0].len);
  ^
abis_test.c:136:2: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
  printf("Start: %ld len: %zu\n", descr[1].start - load_config, descr[1].len);
2015-01-02 11:42:38 +01:00
Harald Welte c83f0276b3 Merge branch 'laforge/meas_vis'
I'm merging this code, as it is proven to be very useful.  The only
reason to keep it out of master was the fact that the UDP data
structures it sends are non-portable, so you can only run it reliably on
localhost or between identical systems (hardware/compiler/os).

As this hasn't been fixed in the past >= 2 years, I am merging the code
now anyway.  We can still introduce a portable protocol by increasing
the protocol  version at a later point.

There are two options:
a) we make 'struct gsm_meas_rep' portable.  This requires an ABI
   change with libosmocore, as it contains struct gsm_meas_rep_unidir :(

b) we introduce a completely separate wire format with corresponding
   encoding and decoding functions.
2015-01-01 13:23:49 +01:00
Harald Welte 8db0788896 meas_feed.c: Fix compiler warning 2015-01-01 13:06:48 +01:00
Harald Welte dfbc42c261 meas_feed: add osmo-meas-udp2db for realtime feed into database
This tool can save the meas_feed messages from UDP port 8888 directly to
a sqlite3 database for further analysis.
2015-01-01 13:03:03 +01:00
Harald Welte dc9b4e9ebf meas_feed: Add tool to read meas_feed PCAP and write it to sqlite3
In fact, the DB write code has been split out so we could later also
have a binary that would listen to realtime meas_feed packets and stuff
them into a database without any intermediate PCAP step.

The database schema contains a couple of convenience wrapper views, most
notably the "overview" view.
2015-01-01 13:03:03 +01:00
Harald Welte 7465e4c2e1 build meas_vis only if libcdk is available 2015-01-01 13:03:03 +01:00
Harald Welte 61c9156a74 meas_vis: Add header and print TA + TO values 2015-01-01 13:03:03 +01:00
Harald Welte 98ba6359a1 meas_vis: assign bar colors depending on level, display RxQual 2015-01-01 13:03:03 +01:00
Harald Welte b4771a6871 Initial support for export + curses-visualization of measurements
This extends osmo_nitb to offer a UDP feed of real-time measurement
reports, which can be used by (a variety of) external tools for
visualization or other processing.

We also add a small ncurses based tool (meas_vis) which shows a
baragraph display of the last few mobile stations that were active,
indicating their uplink/downlink receive level and quality.

<WARNING>
This sends non-portable structures like gsm_meas_rep over UDP
and assumes the receiver has identical alignment and endianness!  Before
this feature is merged, it either needs to be converted to a unix domain
socket (but they don't do multicast, which would be nice) or the wire
format needs to change into something portable with defined alignment
and encoding
</WARNING>
2015-01-01 13:03:03 +01:00
Holger Hans Peter Freyther 7ff77ec713 smscb: Prepare to fill in the info for CBCH in SI4
Pass the number of bytes the rest octet for si4 should
fill.
2015-01-01 12:57:35 +01:00
Harald Welte f86852ce0b chan_alloc: remove ts_alloc() and ts_free()
The idea of ts_alloc()/ts_free() dates back to the very early days of
OpenBSC, where we didn't yet have a fixed PCHAN type assigned for every
lchan in a BTS.  However, ever since, PCHAN types (channel combinations)
are configured by OML in a certain way, and we only allocate LCHANs
inside PCHANs of a matching type.  There should be no PCHANs with
type GSM_PCHAN_NONE, unless those that you don't want to use for
administraive reasons or the like.
2015-01-01 12:46:26 +01:00
Harald Welte 5468f76861 convert away from deprecated gsm_7bit_{encode,decode}() functions
which removes yet another bunch of compiler warnings.
2015-01-01 12:41:39 +01:00
Harald Welte 7b1d25a11e Fix most compiler warnings with gcc-4.9.2 2015-01-01 12:32:03 +01:00
Harald Welte 7b129e76ce rtp_proxy: Remove dead code
commit 65be6de155 removed the RTP
timesetamp mangling and thus the only caller to tv_difference(),
which can now be removed, too.
2015-01-01 12:20:21 +01:00
Harald Welte c3e66ff5c3 chan_alloc: Fix missing break statement
Fixes: Coverity CID 1261354
2015-01-01 12:15:33 +01:00
Harald Welte c3f0cb38cf chan_alloc.c: Don't remove SDCCH/8 without CBCH
In commit 30f1f37638 we wanted to add
support for SDCCH/8+CBCH, not replace the existing SDCCH/8 with the new
CBCH-enabled configuration.
2015-01-01 12:13:42 +01:00
Daniel Willmann 979ac86095 libbsc/chan_alloc: Fix size of pchan to hold the +CBCH channels as well
show net with an CCCH+SDCCH/4+CBCH channel active caused bts_chan_load to read
from invalid memory. Fix this by making sure the pchan array is large enough.

==30346==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff9bdc5dc8 at pc 0x5aeece bp 0x7fff9bdc5350 sp 0x7fff9bdc5348
READ of size 4 at 0x7fff9bdc5dc8 thread T0
    #0 0x5aeecd in bts_chan_load /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/chan_alloc.c:490
    #1 0x5af706 in network_chan_load /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/chan_alloc.c:511
    #2 0x4b7410 in net_dump_vty /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/bsc_vty.c:208
    #3 0x4b5f23 in show_net /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/bsc_vty.c:227
    #4 0x7fdabaa425bd in cmd_execute_command_real /home/alphaone/scm/osmo/libosmocore/src/vty/command.c:2042
    #5 0x7fdabaa3f124 in cmd_execute_command /home/alphaone/scm/osmo/libosmocore/src/vty/command.c:2077
    #6 0x7fdabaa850e9 in vty_command /home/alphaone/scm/osmo/libosmocore/src/vty/vty.c:402
    #7 0x7fdabaa75962 in vty_execute /home/alphaone/scm/osmo/libosmocore/src/vty/vty.c:666
    #8 0x7fdabaa6d947 in vty_read /home/alphaone/scm/osmo/libosmocore/src/vty/vty.c:1408
    #9 0x7fdabaa9165f in client_data /home/alphaone/scm/osmo/libosmocore/src/vty/telnet_interface.c:119
    #10 0x7fdaba7860b6 in osmo_select_main /home/alphaone/scm/osmo/libosmocore/src/select.c:160
    #11 0x43c656 in main /home/alphaone/scm/osmo/openbsc/openbsc/src/osmo-nitb/bsc_hack.c:355
    #12 0x7fdab92604bc (/lib64/libc.so.6+0x224bc)
    #13 0x43b6cc (/home/alphaone/local/osmo-asan/bin/osmo-nitb+0x43b6cc)
Address 0x7fff9bdc5dc8 is located in stack of thread T0 at offset 232 in frame
    #0 0x4b5faf in net_dump_vty /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/bsc_vty.c:182
  This frame has 3 object(s):
    [32, 40) ''
    [96, 104) ''
    [160, 224) 'pl'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/chan_alloc.c:490 bts_chan_load
2014-12-30 12:15:08 +01:00
Daniel Willmann 695675f539 libbsc/system_information.c: Fix off-by-one error in si4 generation with CBCH enabled
==25637==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff3f587c43 at pc 0x5bf591 bp 0x7fff3f587630 sp 0x7fff3f587628
READ of size 4 at 0x7fff3f587c43 thread T0
    #0 0x5bf590 in tv_fixed_put /home/alphaone/local/osmo-asan/include/osmocom/gsm/tlv.h:237
    #1 0x5b7e14 in generate_si4 /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/system_information.c:607
    #2 0x5b488b in gsm_generate_si /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/system_information.c:882
    #3 0x4cb247 in gsm_bts_trx_set_system_infos /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/bsc_init.c:166
    #4 0x4d3c26 in bootstrap_rsl /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/bsc_init.c:272
    #5 0x4ced44 in inp_sig_cb /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/bsc_init.c:316
    #6 0x7f4f15b563d7 in osmo_signal_dispatch /home/alphaone/scm/osmo/libosmocore/src/signal.c:105
    #7 0x7f4f156c0e3f in e1inp_int_snd_event (/home/alphaone/local/osmo-asan/lib/libosmoabis.so.4+0x17e3f)
    #8 0x7f4f156be7e5 in e1inp_event (/home/alphaone/local/osmo-asan/lib/libosmoabis.so.4+0x157e5)
    #9 0x583a6a in ipaccess_sign_link /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/bts_ipaccess_nanobts.c:675
    #10 0x7f4f156e63b0 in handle_ts1_read (/home/alphaone/local/osmo-asan/lib/libosmoabis.so.4+0x3d3b0)
    #11 0x7f4f156e4f4e in ipaccess_fd_cb (/home/alphaone/local/osmo-asan/lib/libosmoabis.so.4+0x3bf4e)
    #12 0x7f4f15b540b6 in osmo_select_main /home/alphaone/scm/osmo/libosmocore/src/select.c:160
    #13 0x43c656 in main /home/alphaone/scm/osmo/openbsc/openbsc/src/osmo-nitb/bsc_hack.c:355
    #14 0x7f4f1462e4bc (/lib64/libc.so.6+0x224bc)
    #15 0x43b6cc (/home/alphaone/local/osmo-asan/bin/osmo-nitb+0x43b6cc)
Address 0x7fff3f587c43 is located in stack of thread T0 at offset 483 in frame
    #0 0x5b712f in generate_si4 /home/alphaone/scm/osmo/openbsc/openbsc/src/libbsc/system_information.c:580
  This frame has 8 object(s):
    [32, 40) ''
    [96, 104) ''
    [160, 164) 'rc'
    [224, 232) 'si4'
    [288, 296) 'cbch_lchan'
    [352, 360) 'restoct'
    [416, 420) 'l2_plen'
    [480, 483) 'cd'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /home/alphaone/local/osmo-asan/include/osmocom/gsm/tlv.h:237 tv_fixed_put
2014-12-30 12:14:25 +01:00
Harald Welte 142d12d829 move gsm_bts_get_cbch() to gsm_data_shared() as its needed in osmo-bts 2014-12-30 00:35:44 +01:00
Harald Welte 30f1f37638 Add basic support for CBCH / SMS-CB (Cell Brroadcast)
We can now configure the pyisical channel types for CBCH either in the
CCCH+SDCCH4 or in the SDCCH8 chanel combination.

Depending on whether a CBCH exists on the BTS, we also generate the SI4
with matching CBCH channel description to notify the phones of the
existance of the CBCH.

There is now a VTY command how a SMS-CB message can be sent to a given
BTS.

We do not yet have any logic at all for actual scheduling of multiple
CBCH RSL messages towards one or multiple BTSs yet, though.
2014-12-30 00:35:28 +01:00
Holger Hans Peter Freyther 65be6de155 rtp: Remove the "correction" of timestamps
We tend to comment out this code every XXC3, let's just get rid
off it. The nanoBTS has a rather odd timing behavior. Jacob has
spent hours this summer to trial/document/fix it in the MGCP code
and this code is not getting close to working around the ip.access
audio issues.

If someobody still wants to use the nanoBTS then he should help
to have the MGCP MGW use/share code with the rtp_proxy.c
2014-12-25 18:47:27 +01:00
Holger Hans Peter Freyther be8e775776 db: Extend the test to mark a SMS as delivered and verify it
Mark the SMS as delivered, then free it and try to get an
undelivered SMS to that subscriber again and make sure it
is failing.
2014-12-25 17:33:30 +01:00
Jacob Erlbeck 98a95ac17f sgsn: Add a subscriber based authentication phase
This implements the MAP way of subscriber validation when the MS
tries to perform an Attach Request:

  1. perform authentication (optionally invoke the sendAuthInfo
     procedure), starts the Auth & Ciph procedure
  2. perform update location
  3. insert subscriber data
  4. finish the update location
  5. Attach Accept / Attach Reject

The authentication triplets are used and eventually updated if all of
them have been used.

This is currently accessible via the VTY interface by the following
commands:

  - update-subscriber imsi IMSI update-auth-info
  - update-subscriber imsi IMSI update-location-result (ok|ERR-CAUSE)

Sponsored-by: On-Waves ehf
2014-12-24 16:50:30 +01:00
Jacob Erlbeck 7921ab1593 sgsn: Add support for authentication triplets
This commit add data structures, functions, initialization, and VTY
commands for per subscriber authentication triplets.

The following VTY command is added:

  - update-subscriber imsi IMSI \
    insert auth-triplet <1-5> sres SRES rand RAND kc KC

Note that the triplets are not really used by the SGSN yet.

Sponsored-by: On-Waves ehf
2014-12-24 16:50:16 +01:00
Jacob Erlbeck 7dba11fe32 sgsn: Be more tolerant with state and SUSPEND/RESUME
Currently, when a BSSGP SUSPEND is received and the corresponding MM
context is already in the state GMM_REGISTERED_SUSPENDED, a
SUSPEND_NACK is returned which is not covered by GSM 08.18, 7.4.1.
The same goes for RESUME in the state GMM_REGISTERED_NORMAL.

This commit changes gprs_gmm_rx_suspend and gprs_gmm_rx_resume to not
complain (and thus answer a NACK) when the MM context is either in
GMM_REGISTERED_SUSPENDED or GMM_REGISTERED_NORMAL.

Note that GSM 08.18, 7.4.1 and 7.5.1 only mention to send an NACK if
the MS is not known. Even with this patch, the SGSN returns a NACK if
either the MS is unknown _or_ the MM context ist not in one of the
state GMM_REGISTERED_SUSPENDED and GMM_REGISTERED_NORMAL.

Sponsored-by: On-Waves ehf
2014-12-23 15:15:13 +01:00
Jacob Erlbeck 3ea2260d00 sgsn: Log requested state change in sgsn_auth_update
Sponsored-by: On-Waves ehf
2014-12-23 15:14:36 +01:00
Jacob Erlbeck 4b59d24f4f openbsc: Ignore generated coverage analysis files
This patch adds *.gcda and *.gcno to .gitignore to skip files that
are generated by gcc --coverage and related tools.

Sponsored-by: On-Waves ehf
2014-12-23 15:12:42 +01:00
Jacob Erlbeck 697a534ed6 gprs: Add gprs_shift_tlv function
This function is similar to gprs_match_tlv with the exception, that
the tag is not compared but returned in *tag instead.

Sponsored-by: On-Waves ehf
2014-12-23 15:10:24 +01:00
Jacob Erlbeck dcfd456640 gprs: Move TLV parser functions to gprs_utils.c and rename them
Currently the parser functions for single information elements are
defined within gprs_gb_parse.c and not exported explicitely. In
addition they are named like libosmocore's TLV parser functions and
do not have a proper name prefix. Since it is planned to use them for
other protocols, they need to be globally accessible.

This patch moves them to gprs_utils.c and renames them.

The new names are:
    lv_shift             -> gprs_shift_lv
    v_fixed_shift        -> gprs_shift_v_fixed
    lv_shift             -> gprs_shift_lv
    v_fixed_shift        -> gprs_shift_v_fixed

In the long term, these functions should be moved to libosmocore (and
renamed again).

Sponsored-by: On-Waves ehf
2014-12-23 15:08:52 +01:00
Jacob Erlbeck c939196557 sgsn: Add missing LF in log message
Sponsored-by: On-Waves ehf
2014-12-23 15:07:54 +01:00
Holger Hans Peter Freyther 22fd3cd0de ho: Copy the multirate config to the new lchan
The new lchan will be in speech mode already but for AMR we will
need to provide a working multirate config in the channel activation,
otherwise the channel act might be nacked.

Copy the config from the current lchan into the new lchan. The
abis code simply added the mrconf if the speech mode was amr.
Before this commit the invalidate mrconf with all zeroes was
copied/sent.
2014-12-18 18:33:11 +01:00
Holger Hans Peter Freyther d30ed6b6f2 ho: Make sure the timer is always stopped
In case of a ho_chan_activ_nack (sent due another bug inside
both sysmobts and openbsc) the code would not stop the timer
but free the datastructure. This can lead to a clear segfault
when the timer has expired. Create a "free" function which is
responsible to detach the handover structure, stop the timer
(which is idempotent) and free the structure.
2014-12-17 21:21:36 +01:00
Holger Hans Peter Freyther f7e23c5ff7 bts: When one link drops.. check what needs to be dropped
In case a BTS is dropped, iterate over the list of BTS and check
if a dependency is now missing and then drop the BTS. This check
could lead to check of 256*256 checks (e.g. all BTS on each other
in the chain and the master is being dropped). The performance
aspect of it doesn't matter for our usecase. We expect to have
pairs of BTS right now.
2014-12-17 15:50:11 +01:00
Holger Hans Peter Freyther c22930e24b bts: Add some simple dependency between different BTS
E.g. for the sysmoBTS2050 we have the requirement that the first
board connects before the second due clocking. The easiest point
to enforce this is the BSC. Add a simple bitmask based system to
allow to express dependencies for IP based systems.
2014-12-17 14:46:17 +01:00
Holger Hans Peter Freyther 27ca0436ac bts: Remove unused fields from the trx structure
These have either never been used or were replaced with a
more generic approach.
2014-12-10 14:38:43 +01:00
Jacob Erlbeck 2e5e94c328 sgsn: Support subscriber based authentication
This commit mainly extends sgsn_auth.c to use and support the
auth_state SGSN_AUTH_AUTHENTICATE. It will be activated when IMSI and
IMEI are available, authentication is required
(subscr->sgsn_data->authenticate is set), but the MM context is not
marked as authenticated. If the state has been set to
SGSN_AUTH_AUTHENTICATE and sgsn_auth_update() is called, the GMM
layer will be informed by invoking gsm0408_gprs_authenticate().

Sponsored-by: On-Waves ehf
2014-12-10 12:45:22 +01:00
Jacob Erlbeck 4adb136da6 sgsn: Integrate Auth & Ciph into gsm48_gmm_authorize
Currently the Authentication and Ciphering procedure is not yet
invoked by the GMM layer.

This patch starts this procedure from within gsm48_gmm_authorize when
the mm->auth_state has been set to SGSN_AUTH_AUTHENTICATE and a call
to gsm0408_gprs_authenticate has been issued directly or indirectly
by the call to sgsn_auth_request.

Sponsored-by: On-Waves ehf
2014-12-10 12:44:05 +01:00
Jacob Erlbeck 665acd1dbd sgsn: Do not 'commit' implicitely when executing 'insert'
Currently the gprs_subscr_update function is called when the
'update-subscriber ... insert ...' command is executed. This will
eventually notify the GMM layer which is rather the purpose of the
'commit' command.

This patch removes the call from update_subscr_insert.

Sponsored-by: On-Waves ehf
2014-12-10 12:42:36 +01:00
Holger Hans Peter Freyther 416c08f9ed nat: Fix copy and paste in the test code
The test didn't test that the access-list has been properly
removed. Fix the test to only remove the list once and verify
that it is gone.
2014-12-09 19:13:00 +01:00
Jacob Erlbeck a1e0373224 sgsn: Put SGSN related subscriber data into separate struct
There will be an increasing number of SGSN related fields per
subscriber. Instead of extending gsm_subscriber accordingly, a single
struct sgsn_subscriber_data object is assigned to it. The talloc
context used to allocated that object is the subscr object itself.
Therefore it will be freed automatically along with the subscr
object.

Sponsored-by: On-Waves ehf
2014-12-09 10:01:08 +01:00
Jacob Erlbeck 207f4a5deb sgsn: Add VTY commands to manage subscriber cache
This adds the following commands to the ENABLE node:
  - show subscriber cache
  - update-subscriber imsi IMSI insert authorized (0|1)
  - update-subscriber imsi IMSI cancel
  - update-subscriber imsi IMSI commit

These commands are mainly testing tools and maintenance helpers. The
update commands work asynchronously and can be used to complete a
pending update request or to terminate an existing connection. The
'insert' command just update the subscriber records but does not
notify the GMM layer. Invoke the 'commit' command to continue with
pending procedures.

Note that the subscriber cache is not stored persistently and will
always be empty after an SGSN restart.

Sponsored-by: On-Waves ehf
2014-12-09 10:00:41 +01:00
Jacob Erlbeck 98647ca0ef sgsn: Add gsm0408_gprs_access_cancelled
This function is called to delete an established MM context
silently without invoking a detach procedure.

It is called when a subscriber is cancelled by the HLR. This
generally happens, when an MS has moved to another routing area and
has to use another SGSN.

Sponsored-by: On-Waves ehf
2014-12-09 09:48:25 +01:00
Jacob Erlbeck be2c8d9358 sgsn: Integrate subscriber handling into the SGSN
This commit adds a new authorization policy 'remote' and uses
the subscriber cache for authorization when this policy is being used.

Note that there is no remote backend implemented yet. After the
IMSI/IMEI have been acquired, a request would be sent to the remote
peer. The attach/auth-ciph procedure continues when authorization
info has been received from the peer. This means, that
gprs_subscr_update() must be called then to tell the GMM layer
that it can proceed. A later commit will add VTY commands to do this
manually.

Sponsored-by: On-Waves ehf
2014-12-09 09:27:20 +01:00
Jacob Erlbeck 33b6dadc88 sgsn: Add gprs_subscriber.c
This patch adds GPRS specific functions for gsm_subscriber objects
(allocation, retrieval, deletion) and subscriber data
requests/updates. The sgsn_update_subscriber_data callback is used to
notify the sgsn about updates and is extended by a parameter that
passes a reference to a gsm_subscriber.

Sponsored-by: On-Waves ehf
2014-12-09 09:23:11 +01:00
Jacob Erlbeck 70d8e31a74 msc: Add per subscriber keep_in_ram flag
Currently the keep_subscr flag in gsm_subscriber_group refers to a
whole group of subscribers which makes it difficult to really delete
single entries if the flag is set.

This patch adds a keep_in_ram field to gsm_subscriber which allows for
keeping subscriber objects in RAM while deleting others.

Note that really deleting an entry requires that both flags
(subscr_group->keep_subscr and subscr->keep_in_ram) are set to 0. So
only the latter should be used if a specification requires the
deletion of a subscriber entry.

Sponsored-by: On-Waves ehf
2014-12-09 09:08:28 +01:00
Jacob Erlbeck 901c40f550 sgsn: Remove warnings
Remove warnings related to the SGSN specific code.

Sponsored-by: On-Waves ehf
2014-12-09 08:59:36 +01:00
Jacob Erlbeck af792d6bb2 msc: Add net parameter to trans_alloc
The trans_alloc function still uses the subscr object to access the
network object.

This patch adds an explicit net parameter to this function and
removes the access to subscr to obtain it.

Sponsored-by: On-Waves ehf
2014-12-09 08:59:29 +01:00
Jacob Erlbeck 8ff3fb04f2 sgsn: Do authentication based on SRES values
Currently the SRES value in the Auth & Ciph Response is ignored.

This patch checks the SRES value in response against the value stored
in mm->auth_triplet.sres. If they don't match, an Auth & Ciph Reject
message is sent to the MS. If they match, the mm->is_authenticated
flag is set.

Note that the procedure will not be started yet.

Sponsored-by: On-Waves ehf
2014-12-08 10:51:38 +01:00
Jacob Erlbeck bd0cf1190a sgsn: Change Auth&Ciph timer handling
Currently mmctx_timer_start is called from within
gsm48_tx_gmm_auth_ciph_req which differs from the way e.g. the
identification procedure is implemented. It also makes it more
difficult to restart the procedure after timeout, which is not
implemented yet. In addition, the timer is not properly stopped when
an AUTH & CIPH response is received.

This patch removes this timer start from gsm48_tx_gmm_auth_ciph_req,
adds the retransmission of Auth & Ciph requests to the timer callback
function, and properly stops the timer in
gsm48_rx_gmm_auth_ciph_resp.

Sponsored-by: On-Waves ehf
2014-12-08 10:50:52 +01:00
Jacob Erlbeck 65d8273bf3 sgsn: Fix and enable auth/ciph message generation
Currently gsm48_tx_gmm_auth_ciph_req/_rej are commented out. In
addition, gsm48_tx_gmm_auth_ciph_req uses a wrong encoding (two byte TV instead of two nibbles TV) of the CKSN information element.

This patch fixes the encoding of the CKSN IE and enables the
functions mentioned above.

Sponsored-by: On-Waves ehf
2014-12-08 10:49:17 +01:00
Jacob Erlbeck 0acc0018d9 bsc/test: Add tests for gsm_subscriber base
This commit adds test for the generic part of gsm_subscriber like
reference counting and flag usage.

Sponsored-by: On-Waves ehf
2014-12-05 15:16:59 +01:00
Jacob Erlbeck 1e30a28e51 msc: Add and use gsm_subscriber_group
Currently every subcriber object directly refers to the gsm_network
which contains a flag shared by every related subscriber
(keep_subscr). This adds a dependency on gsm_network even if only the
function defined in gsm_subscriber_base.c are used.

This patch adds a new struct gsm_subscriber_group which contains the
keep_subscr flag and a back reference to the network object. The
latter is not dereferenced in gsm_subscriber_base.c, so it can safely
be set to NULL when only that part of the gsm_subscriber API is being
used. It also changes that API to use gsm_subscriber_group instead of
gsm_network parameters.

Since there are some places where a pointer to the gsm_network is
needed but where only a gsm_subscriber is available, a 'net' back
pointer is added to the group struct, too. Nevertheless subscr group
and network could be separated completely, but this is not the topic
of this commit.

Sponsored-by: On-Waves ehf
2014-12-05 14:59:02 +01:00
Jacob Erlbeck dae1f64ba6 msc: Don't use the subscriber to access the net object
Sponsored-by: On-Waves ehf
2014-12-05 14:58:41 +01:00
Jacob Erlbeck f07c605361 msc: Add net back pointer to gsm_trans
Currently the net pointer is obtained from trans->subscr->net. On the
other hand, the list gsm_trans object is managed by the net object.

This patch adds the back pointer to the structure and replaces all
trans->subscr->net by trans->net expressions. In trans_alloc() the
trans->net pointer is obtained from the subscr object.

Sponsored-by: On-Waves ehf
2014-12-05 14:56:35 +01:00
Holger Hans Peter Freyther 1f6cce772e ctrl: Allow to query if the OML link is connected or not
Related: SYS#798
2014-12-05 14:52:57 +01:00
Holger Hans Peter Freyther 5eebb7a814 ctrl: Add command to get the current load of a BTS
Add a command and test to see the current channel load and
available channels per BTS.

Related: SYS#798
2014-12-05 14:52:57 +01:00
Jacob Erlbeck de4bbc7146 sgsn/test: Add test case for unexpected Detach Accepts
The commit "sgsn: Don't send XID reset after Detach Accept" fixed the
SGSN to not respond to a Detach Accept message when there is no MM
context.

This patch adds a test case to verify, that there is really no
message sent in that case.

The test fails when the commit mentioned aboved is reverted.

Sponsored-by: On-Waves ehf
2014-12-02 09:18:45 +01:00
Jacob Erlbeck aec03a1f13 sgsn/test: Don't rely on the actual PRNG sequence
Currently the expected P-TMSI generated by the SGSN is hard-coded
into the test. This adds a dependency on the implementation of rand()
and thus the libc used. This breaks the test e.g. on FreeBSD.

This patch modifies test_gmm_attach() to srand(1) first, generate the
P-TMSI, and finally srand(1) again before starting the test.

Sponsored-by: On-Waves ehf
2014-12-02 09:18:19 +01:00
Jacob Erlbeck 59ac49dc1f gbproxy: Reset TLLIs when the link_info is found by IMSI/P-TMSI
Currently when the MS does a re-attach without doing a proper detach
first, the gbproxy uses the old local TLLI if patching and the keep
mode are enabled. This leads to a failing attachment procedure when
TLLI patching is also enabled.

This patch changes gbproxy_update_link_state_ul to reset all TLLIs
within the link_info if the message contains an unknown TLLI and an
MI. This is generally the case with Attach Request messages.

The gbproxy_get_link_info_ul gets an additional tlli_is_valid
output parameter that is set, when a TLLI was present and found.
This flag is then used instead of checking tlli.current == 0 to
set TLLI/P-TMSI e.g. Attach Requests when a link_info was already
present for the P-TMSI/IMSI used in such a request.

Ticket: OW#1324
Sponsored-by: On-Waves ehf
2014-12-02 09:00:09 +01:00
Holger Hans Peter Freyther 175a240285 bsc: Add ctrl command to set the TRX ARFCN 2014-11-21 11:40:32 +01:00
Holger Hans Peter Freyther a49b2c010e bsc: Allow to generate new system information online
Increase the bcch_change_mark and generate a new copy of the
system information. Make the method public, add a small test
case. Manually verified using the FakeBTS. I don't know if
the MS will re-read these SIs.

Related: SYS#739
2014-11-21 11:23:47 +01:00
Holger Hans Peter Freyther b92a538d23 bts: Store the bcch_change_mark in the bts structure
Store the BCCH change mark inside the BTS structure. This will
allow us increment the number and re-generate the SIs.

Related: SYS#739
2014-11-21 11:23:47 +01:00
Holger Hans Peter Freyther 8a64141a53 bsc: Allow to set the call-identity
Allow to set the cell-identity through the control interface
and add a small test for it.

Related: SYS#739
2014-11-21 11:23:47 +01:00
Holger Hans Peter Freyther b1461152e6 bsc: Allow to apply configuration for an individual BTS
This will drop a specific IP based BTS. It will lead to a
re-connect of the BTS and the new settings will be applied
then.

Fixes: SYS#737
2014-11-21 10:24:18 +01:00
Holger Hans Peter Freyther b1edf7b64f mgcp/sdp: Session name must not be empty pick an empty one
The session name must be present in a SDP file. The RFC proposes
to use a space for it but the other equipment is using the dash
so I have picked that as well.

RFC 4566:
The "s=" field is the textual session name.  There MUST be one and
only one "s=" field per session description.  The "s=" field MUST NOT
be empty and SHOULD contain ISO 10646 characters (but see also the
"a=charset" attribute).  If a session has no meaningful name, the
alue "s= " SHOULD be used (i.e., a single space as the session
name).

Fixes: RT#2196
2014-11-20 23:17:32 +01:00
Holger Hans Peter Freyther 619b014d3a mgcp: Allow to omit sending the audio name at all
Equipment like AudioCode appears to get upset when we use a
builtin type and then assign a name to it. Allow to completely
omit the name.
2014-11-19 16:18:56 +01:00
Jacob Erlbeck 02ab91e6a7 sgsn: Cross-link gsm_subscriber and sgsn_mm_ctx
To implement subscriber based authorization a data structure is
needed that keeps the subscriber data. The MSC already uses a similar
struct named gsm_subscriber whose implementation is split into a
generic part (allocation, retrieval, reference counting, list
maintenance) and MSC related parts. For GPRS, only the generic part
will be used and specific fields may be added when needed.

This patch adds a field mm to struct gsm_subscriber that will be used
by the SGSN to store a reference to the current MM context (or NULL
if there is none). This also adds a field subscr to struct
sgsn_mm_ctx that reversely points to a gsm_subscriber (or NULL if
there is none).  Either both fields are NULL or both fields are
non-NULL. Note that subscr is being reference counted.

Sponsored-by: On-Waves ehf
2014-11-14 10:26:49 +01:00
Jacob Erlbeck a0b6efb368 sgsn: Remove explicit sgsn_instance parameters
Currently the function in sgsn_auth.c either have an sgsn_config or
an sgsn_instance parameter. Since then global sgsn variable is
already being used in that file and since other parts of the SGSN
related code also rely on a global sgsn singleton, these parameters
pretend to provide a flexibility that is not really supported.

Therefore this patch removes these parameters except for the ACL
related functions, which do not call code that uses the sgsn
variable.

Sponsored-by: On-Waves ehf
2014-11-14 10:26:06 +01:00
Jacob Erlbeck f951a01bb2 sgsn: Refactor sgsn_auth to separate request and authorization
Currently the authorization is done in sgsn_auth_request for ACL
based authorization. This doesn't match the way remote authorization
would work, so that there is a second call to sgsn_auth_state already
present in sgsn_auth_update.

This patch removes the autorization check completely from
sgsn_auth_request which in turn calls sgsn_auth_update directly now.

Sponsored-by: On-Waves ehf
2014-11-14 10:23:54 +01:00
Jacob Erlbeck f6e7d99d54 sgsn: Don't assign a new P-TMSI if one is pending
Currently every time an RA Update Req or an Attach Req is processed, a
new P-TMSI is allocated. When an MS issues another of these messages
before it has completed the first procedure, old_ptmsi is replaced by
ptmsi (and thus lost) and ptmsi is replaced by the newly allocated
P-TMSI. This can confuse the gbproxy, which can loose track of the
logical link then. At least a Blackberry emits a double set of RA Upd
Req messages from time to time which may be just 20ms apart.

This patch adds a check whether mm->ptmsi or mm->old_ptmsi are set.
If both are set, the P-TMSI is not re-allocated. This is only the
case, when the Complete message has not been received yet, since that
message will reset old_ptmsi.

Sponsored-by: On-Waves ehf
2014-11-14 10:19:29 +01:00
Jacob Erlbeck c4f9bf3142 sgsn: Don't send XID reset after Detach Accept
Currently when a Detach Accept is received for an unknown TLLI (which
is in general the case afer the SGSN has requested the detachment),
an XID reset is sent to the BSS, causing a BSSGP Status message. This
happens in gsm0408_rcv_gmm.

This patch moves the corresponding call to gprs_llgmm_reset downwards
so that it is not being called in that case.

Addresses:
SGSN->BSS TLLI: 0xd75b91d9 SAPI: LLGMM, UI (DTAP) (GMM) Detach Request
BSS->SGSN TLLI: 0xd75b91d9 SAPI: LLGMM, UI (DTAP) (GMM) Detach Accept
SGSN->BSS TLLI: 0xd75b91d9 SAPI: LLGMM, U, XID (Reset, IOV-UI)
BSS->SGSN TLLI: ---        BSSGP STATUS (Unknown MS)

Sponsored-by: On-Waves ehf
2014-11-14 10:12:32 +01:00
Jacob Erlbeck 80d07e30c7 sgsn: Cleanup after RA Update Reject / Attach Reject
Currently, the LLME is not cleaned up after sending an RA Update
Reject. This happens after entering a routing area from outside,
since in that case the SGSN sends an RA Update Reject (implicitly
detached) which causes the MS to restart the attach procedure.
The LLME is also not updated if an Attach Request with message errors
(encoding, invalid MI type) is received or if an MM context cannot be
allocated.

This patch changes gsm48_rx_gmm_ra_upd_req and gsm48_rx_gmm_att_req
to unassign the LLME or free the MM context (if available) after a
Reject message has been sent.

Ticket: OW#1324
Sponsored-by: On-Waves ehf
2014-11-14 10:07:42 +01:00
Jacob Erlbeck 106f547733 sgsn: Add 'acl-only' authentication policy
Currently the VTY 'auth-policy' command results in setting or clearing
the acl_enabled flag. This also enables the matching of the MCC/MNC
prefix of the IMSI.

This patch adds an additional policy 'acl-only' which disables the
MCC/MNC matching and relies on the ACL only.

Sponsored-by: On-Waves ehf
2014-11-14 10:07:28 +01:00
Jacob Erlbeck 144b8b1ca7 sgsn/test: Add VTY tests for the SGSN
This patch adds some basic SGSN tests to vty_test_runner.py:
- check for config tree nodes
- check specific show commands

Sponsored-by: On-Waves ehf
2014-11-14 10:06:53 +01:00
Jacob Erlbeck 423f8bfa02 sgsn: Make authorization asynchronous
Currently the authorization of an IMSI is done by checking ACLs
synchronously which is not feasible when the subscriber data has to
be retrieved from an external source.

This patch changes this by using a callback when the information is
available. This is also done when only ACL are checked, in this case
the callback is invoked from within sgsn_auth_request(). The callback
function sgsn_update_subscriber_data calls sgsn_auth_update which
in turn calls either gsm0408_gprs_access_granted or
gsm0408_gprs_access_denied. gsm48_gmm_authorize is extended by a call
to sgsn_auth_request when IMSI and IMEI are available but the
auth_state is unknown.

The change has been successfully tested with single phones (E71 and
IPhone 5c).

Sponsored-by: On-Waves ehf
2014-11-14 09:58:28 +01:00
Jacob Erlbeck 0c06f98ced sgsn: Move IMSI authorization to gsm48_gmm_authorize
Currently the IMSI is only checked immediately when an Attach Request
is received that contains an IMSI IE. If it contains a P-TMSI
instead, access is always granted.

This commit moves the IMSI check to gsm48_gmm_authorize where it is
applied when IMSI and IMEI have been acquired. This fixes the
authorization when the Attach Accept doesn't contain an IMSI.

Sponsored-by: On-Waves ehf
2014-11-14 09:27:23 +01:00
Jacob Erlbeck b1c074f62c sgsn: Fix LLME leak when forcing a reattach
Currently when forceing a reattach by sending a Detach
Request (reattach), the SGSN waits for the Detach Accept until it
frees the MM context (if present) and the LLME. If that message gets
lost or isn't sent by the MS, the LLME is never freed if it isn't
bound to an MM context.

This patch adds code to free the MM context/LLME when forcing a
reattachment.

Sponsored-by: On-Waves ehf
2014-11-14 09:26:27 +01:00
Jacob Erlbeck abdf02b9b9 sgsn: Split gsm0408_gprs_force_reattach into 2 functions
This patch replaces gsm0408_gprs_force_reattach(msg, mmctx) by two
functions
  - gsm0408_gprs_force_reattach(mmctx)
  - gsm0408_gprs_force_reattach_oldmsg(msg)

The old function basically consists of the code of the two new
functions, where the code path selected depends on mmctx == NULL,
which is harder to maintain, less obvious to use, and not consistent
with many other SGSN functions.

Sponsored-by: On-Waves ehf
2014-11-14 09:23:38 +01:00
Jacob Erlbeck a790456f1b sgsn: Call mm_ctx_cleanup_free to deregister MM context
Currently the MM context isn't always removed when it is
de-registered (mmctx_timer_cb), mm_state is set to GMM_DEREGISTERED
instead. This can lead to left-over MM contexts which are only
cleaned up if the MS reattaches.

This patch replaces all of these assignments by a call to
mm_ctx_cleanup_free.

Ticket: OW#1324
Sponsored-by: On-Waves ehf
2014-11-14 09:16:58 +01:00
Jacob Erlbeck 0074a77424 sgsn: Cleanup GMM state transitions
Currently the GMM state is set to GMM-REGISTERED when an Attach
Accept or a RA Update Accept message is sent, even if a new P-TMSI is
included. In this case 04.08 requires (see 4.7.3.1.3 and 4.7.5.1.3),
that the state is set to GMM-COMMON-PROCEDURE-INITIATED when the
Accept is sent. When the Complete is received, the SGSN shall set
the state to GMM-REGISTERED.

This patch modifies the state updates accordingly.

Sponsored-by: On-Waves ehf
2014-11-14 09:12:10 +01:00
Jacob Erlbeck 93eae8ec78 sgsn: Reorganize and fix gsm48_gmm_authorize
Currently the order of the 'if' clauses in gsm48_gmm_authorize
doesn't match the order in which the conditional parts are entered.
This makes it difficult to maintain. In addition the t3350_mode is
not stored in every path, so that this information is lost when the
identification procedure is started. Since the default value
coincidentally is GMM_T3350_MODE_ATT, this doesn't hurt for Attach
Requests which are the only messages that initially trigger the
authentication yet.

This patch changes the order of the 'if' clause to match the
processing order, it removes the t3350_mode parameter entirely and
introduces a mm->pending_req field. The latter must be set when the
request that causes the authorization before calling
gsm48_gmm_authorize. The gprs_t3350_mode enum is extended by
GMM_T3350_MODE_NONE (value 0, which is the default) to make it
possible to detect related initialisation errors or race conditions.

Sponsored-by: On-Waves ehf
2014-11-14 08:57:50 +01:00
Jacob Erlbeck 3911880b68 bsc: Move gsm_subscriber_base.c to libcommon
Since it is planned to use struct gsm_subscriber to manage subscriber
data in the SGSN, this file which contains the generic subscriber
related methods is moved to libcommon.

Sponsored-by: On-Waves ehf
2014-11-11 22:52:21 +01:00
Jacob Erlbeck cdd4302c6d bsc: Move gsm_network_init function to libbsc
Currently libcommon depends on libbsc, because gsm_network_init
(libcommon/gsm_data.c) directly calls gsm_net_update_ctype
(libbsc/gsm_04_08_utils.c).

This patch moves gsm_network_init to a new file libbsc/net_init.c.

Sponsored-by: On-Waves ehf
2014-11-11 22:52:04 +01:00
Jacob Erlbeck 27cb4d57e0 sgsn/test: Add test_gmm_attach
This test checks the attach procedure until the Attach Complete is
received.

Note that authorization and GMM state updates are not working
properly yet.

Sponsored-by: On-Waves ehf
2014-11-11 22:47:59 +01:00
Jacob Erlbeck 94ef1c0da9 sgsn/test: Move message sending to send_0408_message
This replaces serveral occurences of duplicated code for message
creation and sending (passing to gsm0408_gprs_rcvmsg) into a single
function. In addition, the sgsn_tx_counter is always reset within
send_0408_message to simplify the code that checks for the number of
messages sent.

Sponsored-by: On-Waves ehf
2014-11-11 22:47:40 +01:00
Jacob Erlbeck 4110868029 gbproxy: Honour the BSS TLLI type when creating an SGSN TLLI
Currently gbproxy_make_sgsn_tlli always returns a foreign TLLI when
it uses the (SGSN) P-TMSI to generate one.

This patch changes the implementation to return a SGSN TLLI of the
same type like the BSS TLLI in that case.

Sponsored-by: On-Waves ehf
2014-11-11 22:44:32 +01:00
Henning Heinold 0d8ac0eac0 systemd: use Wants for the dependency btw. osmo-bsc-mgcp and osmo-bsc
* osmo-bsc and osmo-bsc-mgcp are needed to run
* with Wants, both are started but can be indepently
  controlled via systemctl

Fixes: SYS#738
2014-11-11 17:59:49 +01:00
Holger Hans Peter Freyther 054bc24e6d bts: Allow to set the LAC through the CTRL interface
Allow to set the LAC of the BTS through the CTRL interface.
The change will not be effective immediately.

Fixes: SYS#738
2014-11-10 11:41:03 +01:00
Jacob Erlbeck 74b2028167 bsc: Fix use-after-free on OML NM messages from the BTS
Currently the sign_link pointer is dereferenced after a call to
osmo_signal_dispatch, which can indirectly call
e1inp_sign_link_destroy. If that happens, accessing *sign_link is
illegal and can lead to a segmentation violation.

Since only the bts pointer is needed from sign_link after the call to
osmo_signal_dispatch, this patch changes abis_nm_rcvmsg_fom to save
that pointer to a local variable earlier.

Addresses:
<0019> input/ipa.c:250 accept()ed new link from 192.168.1.101 to port 3002
SET ATTR NACK  CAUSE=Message cannot be performed
<0005> bsc_init.c:52 Got a NACK going to drop the OML links.
<001b> bsc_init.c:319 Lost some E1 TEI link: 1 0xb351a830
=================================================================
==13198== ERROR: AddressSanitizer: heap-use-after-free on address 0xb5d1bc70 at pc 0x80a6e3d bp 0xbfbb33d8 sp 0xbfbb33cc

Sponsored-by: On-Waves ehf
2014-11-10 08:47:14 +01:00
Holger Hans Peter Freyther 33f2c4d898 bts: Fail OML in case the channel combination is wrong
In case a BTS is being bootstrapped and one TS can not be
activated prevent the whole BTS from coming up.

When the OML activation is not being done the rest of the BSC
code still assumes these logical channel(s) to be available
and one will see channel activation issues that might be hard
to debug.

Instead of having a half-configured system up and running,
keep the BTS offline.
2014-11-07 09:54:57 +01:00
Holger Hans Peter Freyther 1464a121c0 ipa: Correct the prototype of these functions
They return nothing and not int.
2014-11-06 16:32:57 +01:00
Jacob Erlbeck 9d0fb1e97a gbproxy/test: Extend test_gbproxy_keep_info
Add new test message sequences:
  - Normal attach (with IMSI) after detach (ok)
  - Normal attach (with local TLLI) after detach (ok)
  - Unexpected attach (with IMSI) after successful TLLI validation (fails)
  - Unexpected attach (with P-TMSI) after successful TLLI validation (fails)

Ticket: OW#1324
Sponsored-by: On-Waves ehf
2014-11-05 00:26:34 +01:00
Jacob Erlbeck de74e721b2 gbproxy: Fixed VTY doc for delete-gbproxy-link
The command definition delete_gb_link_by_id_cmd lacks a description
for the sgsn-nsei token.

This patch adds the missing description.

Addresses:
Verifying src/gprs/osmo-gbproxy -c doc/examples/osmo-gbproxy/osmo-gbproxy.cfg, test verify_doc
Documentation error (missing docs):
<command id='delete-gbproxy-link &lt;0-65534&gt; (tlli|imsi|sgsn-nsei) IDENT'>
        <param name='IDENT' doc='(null)' />

Sponsored-by: On-Waves ehf
2014-11-05 00:24:13 +01:00
Jacob Erlbeck 14ae582064 sgsn: Unassign the LLME after GMM Status without mmctx
Currently the LLME is not deleted when a GMM Status message is
received for which a mmctx cannot be found. This can fill the LLME
list with unneeded entries.

This patch adds code to unassign the LLME in that case.

Ticket: OW#1324
Sponsored-by: On-Waves ehf
2014-11-05 00:24:02 +01:00
Jacob Erlbeck 7067142100 sgsn: Remove unused static functions from gprs_gmm.c
The following functions are not being used:
 - gsm48_tx_gmm_status_oldmsg
 - gsm48_tx_sm_status_oldmsg

This patch removes the function definitions.

Sponsored-by: On-Waves ehf
2014-11-05 00:23:44 +01:00
Holger Hans Peter Freyther db64f2e45a bsc: Allow to disable sending ping/pong to the MSC
Some switches do not like to receive the IPA PING/PONG messages.
Allow to disable the handling with "no timeout-ping" and create
test cases that verify the switching between the modes. Change the
code to trat <= 0 as an invalid timeout.

Fixes: SYS#713
2014-10-29 10:11:21 +01:00
Jacob Erlbeck 76606d3473 nitb/ctrl: Fix access to freed memory in verify_subscriber_modify
Currently the temporary string 'tmp' is freed before parts of it are
referenced. This lets address sanitizer complain when evaluating
strlen(imsi), where imsi points into the 'tmp' data block.

This patch moves the talloc_free to the end of the function and uses
a rc variable instead of using early returns.

Addresses:
testSubscriberAddRemove (__main__.TestCtrlNITB) ... Launch:
./src/osmo-nitb/osmo-nitb -c
  ./doc/examples/osmo-nitb/nanobts/openbsc.cfg -l test_hlr.sqlite3
Connecting to host 127.0.0.1:4249
Sending "SET 1000 subscriber-modify-v1 2620345,445566"
Decoded replies:  {}
ERROR

Sponsored-by: On-Waves ehf
2014-10-28 15:17:02 +01:00
Jacob Erlbeck 5a38f6470e sgsn: Handle Detach Requests even when there is no mmctx
Currently, when a Detach Request is received with an unknown TLLI,
it is answered by another Detach Request (!), even when a power_off
Type is used.

This patch uses gsm48_rx_gmm_det_req to handle the message instead.
So this function is changed to cope with a NULL mmctx. In that case
it doesn't unassign the llme, so this must be done manually
afterwards.

Sponsored-by: On-Waves ehf
2014-10-27 15:34:14 +01:00
Jacob Erlbeck b9ab0d4f39 sgsn: Only send Detach Accept (MO) if power_off isn't set
Currently, every time the SGSN received a Detach Request from the MS
via an established logical link, it is answered by a Detach Accept.
This violates the specification (GSM 04.08, 4.7.4.1.2 and .3), which
states, that it should only be sent, if "the detach type IE value
indicates that the detach request has not been sent due to switching
off".

This patch adds a conditional to limit the sending of Detach Accept
accordingly.

Sponsored-by: On-Waves ehf
2014-10-27 15:21:31 +01:00
Jacob Erlbeck 189999d654 sgsn/test: Add test case for Detach Request (MO, power-off = 1)
Currently only a Detach Request (MO) message with power_off = 0 is
checked.

This commit adds a new test case with power_off set to 1. It also
adds checks for the number of messages generated by the SGSN to
verify that these messages are handled differently.

Note that the handling of power_off isn't implemented yet. Therefore
the corresponding assertion is being disabled yet.

Sponsored-by: On-Waves ehf
2014-10-27 15:21:11 +01:00
Jacob Erlbeck abc16a55b2 sgsn/test: Move MM context allocation into separate function
This refactores serveral code lines needed for the allocation of MM
contexts into the new function alloc_mm_ctx.

Sponsored-by: On-Waves ehf
2014-10-27 15:20:07 +01:00
Jacob Erlbeck 3b5d407203 sgsn: Moved IMSI ACL management to sgsn_auth.c
Currently the ACL code is located in sgsn_vty.c.

This commit moves this to a new file sgsn_auth.c as a first step to
make authorization more flexible in order to implement remote
acquisition on subsciber data.

Sponsored-by: On-Waves ehf
2014-10-27 13:06:55 +01:00
Jacob Erlbeck fb26c60a2f sgsn: Avoid duplicated Attach Accept messages
Currently each received Ident Resp triggers an Attach Accept/Reject
if IMSI and IMEI are known. This has led to duplicated Attach Accept
messages when used with the gbproxy (IMSI acquisition active) and
with certain mobile equipment (iOS).

This patch modifies gsm48_rx_gmm_id_resp to discard Ident Resp messages
if all required information (IMEI and IMSI) has been gathered.

Ticket: OW#1322
Sponsored-by: On-Waves ehf
2014-10-27 13:06:55 +01:00
Jacob Erlbeck c37ef6cd0e gbproxy: Patch BSSGP P-TMSI in PAGING PS messages
Currently the P-TMSI IE in PAGING_PS is not patched.

This commit adds code to patch BSSGP P-TMSI IE in
gbproxy_patch_bssgp independently from the P-TMSI patching at the LLC
layer. It also extends gbproxy_update_link_state_dl to use the IMSI
to find the link_info if the TLLI is not present in the message.

Note that the spec (GSM 08.18, 7.2) requires to use of the P-TMSI
instead of the IMSI to select the MS if that IE is available.
Nevertheless as long as the IMSI is always present in downlink BSSGP
messages and as long as the optional P-TMSI refers to the same MS
(which is the case currently), this is not an issue.

Sponsored-by: On-Waves ehf
2014-10-27 11:59:28 +01:00
Jacob Erlbeck 91e9f555b6 gbproxy: Fix P-TMSI generation for repeated Attach Accept messages
Currently, when P-TMSI patching is enabled, a new BSS P-TMSI is
generated for each Attach Accept. So two duplicated, subsequent
Attach Accept messages will be mapped to different BSS side P-TMSI.
Because the last one will replace former ones in the link_info
struct, the MS will fail to access the SGSN if it uses the former
P-TMSI to derive the new TLLI.

This patch checks the SGSN P-TMSI already assigned to the link_info
and only generates a new BSS P-TMSI on mismatch (or if the BSS P-TMSI
hasn't been set yet).

Ticket: OW#1322
Sponsored-by: On-Waves ehf
2014-10-27 11:17:11 +01:00
Jacob Erlbeck e99c333d61 gbproxy/test: Add test case for repeated and otherwise bad messages
This adds a test case to check gbproxy's behaviour when processing
two subsequent but identical Attach Accept messages.

Ticket: OW#1322
Sponsored-by: On-Waves ehf
2014-10-27 11:12:22 +01:00
Jacob Erlbeck fb83ed32d2 gbproxy/test: Add expect_msg checks to test_gbproxy_keep_info
This patch adds assertions to check the LLC/GMM message received from
the gbproxy by the test framework within the function
test_gbproxy_keep_info.

It also fixes the source address of the DETACH ACC messages.

Sponsored-by: On-Waves ehf
2014-10-27 10:51:40 +01:00
Jacob Erlbeck 78ecaf0561 sgsn: Send detach(re-attach) instead of gmm status if TLLI unknown
The osmo-sgsn sends Status messages (or nothing in case of non
GMM/GSM) when the TLLI is unknown. This prevents the MS from
reconnecting.

This patch adds the initiation of an MT detach procedure to force a
re-attach to set up a valid LLE context if an LLE or an MM context
cannot be found. Since this can also be triggered by non-GMM SAPI
messages, a GPRS application callback sgsn_force_reattach_oldmsg is
added which in turn calls the GMM layer to generate the GSM 04.08
specific messages.

Note that the MS can be left in REGISTERED state after initially
wanting to detach itself, since it will receive a Detach Req
(re-attach) when sending a DEACT PDP CTX REQ after the SGSN or
gbproxy (P-TMSI patching enabled) has been restarted. This same
behaviour has been observed with another SGSN.

Sponsored-by: On-Waves ehf
2014-10-27 10:50:36 +01:00
Jacob Erlbeck 99985b5ea8 sgsn: Delete PDP contexts properly
Currently the PDP contexts are hard freed (via sgsn_pdp_ctx_free)
at some places in gprs_gmm.c on the reception of a Detach Req and on
re-use of an IMSI that is already associated with an MM context. This
can lead to segfaults when there is a pending request or a data
indication at libgtp.

This patch add a new function sgsn_pdp_ctx_terminate that de-associates
the PTP context from the MM context, deactivates SNDCP, sets pdp->mm
to NULL and then calls sgsn_delete_pdp_ctx. sgsn_libgtp is updated to
check for pdp->mm being non-NULL before dereferencing it. The
sgsn_pdp_ctx_terminate function will be called for each PDP context of
an MM context before this context is going to be deleted via
sgsn_mm_ctx_free. To ensure, that the ctx->llme (which is accessed
during the deactivation of SNDCP) remains valid, the call to
gprs_llgmm_assign is moved after the call to sgsn_mm_ctx_free. The
handling of re-used IMSIs is changed to mimic the processing of a
Detach Req.

Addresses:
<0002> gprs_gmm.c:654 MM(/f6b31ab0) Deleting old MM Context for same
    IMSI p_tmsi_old=0xc6f19134
<000f> gprs_sgsn.c:259 PDP freeing PDP context that still has a
    libgtp handle attached to it, this shouldn't happen!
[...]
SEGFAULT

Ticket: OW#1311
Sponsored-by: On-Waves ehf
2014-10-27 10:25:13 +01:00
Jacob Erlbeck ae20b4b31b sgsn: Cancel pending timer in sgsn_mm_ctx_free
Currently the timer is not stopped before the MM context is freed
which can lead to failure if sgsn_mm_ctx_free is called while timer
protected procedures are active.

This patch add code to cancel the timer if necessary from within
sgsn_mm_ctx_free.

Ticket: OW#1322
Sponsored-by: On-Waves ehf
2014-10-27 10:25:03 +01:00
Holger Hans Peter Freyther 19e990d6a7 gprs: Fix typo in the comment 2014-10-27 10:25:03 +01:00
Jacob Erlbeck 6a1d428f56 gbproxy: Fix segfault for VTY delete-gbproxy-link
Currently the code segfaults when the link shall be deleted by IMSI
when the IMSI has not been set yet.

This patch adds a NULL check to skip the entry before calling
gsm48_mi_to_string,

Adresses:
Program received signal SIGSEGV, Segmentation fault.
0xb693af77 in gsm48_mi_to_string (string=0xbfffe020 "", str_len=200,
mi=0x0, mi_len=0) at gsm48.c:360
    360         mi_type = mi[0] & GSM_MI_TYPE_MASK;
    str_len=200, mi=0x0, mi_len=0) at gsm48.c:360
    self=0x807c9a0 <delete_gb_link_by_id_cmd>, vty=0xb4303c70,
     argc=3, argv=0xbfffe1c0) at gb_proxy_vty.c:670
...

Sponsored-by: On-Waves ehf
2014-10-27 09:47:00 +01:00
Jacob Erlbeck c79beec8f6 gbproxy/test: Don't assign a variable within OSMO_ASSERT (Coverity)
Coverity complains about having side effects in OSMO_ASSERT argument
expressions. This would be an issue in this case, because that
variable is only reference in other OSMO_ASSERT expressions.

Nevertheless this patch changes this to assign the variable outside
of OSMO_ASSERT.

Fixes: Coverity CID 1244239
Sponsored-by: On-Waves ehf
2014-10-27 09:45:28 +01:00
Jacob Erlbeck 058ae12135 gbproxy: Discard UL PTP messages with an unknown BVCI
Currently all PTP messages are in general forwarded to the SGSN even
when the BVCI is not known to the gbproxy. Only if message patching
is active and the peer cannot be determined, a log message is
generated, a STATUS message returned, and the message discarded.
The intention for this was to keep the old gbproxy's behaviour if
patching is disabled. But the code gets much more complex this way.
Another drawback is that when the SGSN returns a corresponding STATUS
message, it cannot be routed to the BSS where the original message
came from.

This patch therefore changes the behaviour to reject BSSGP PTP uplink
messages immediately if the BVCI is not known.

Fixes: Coverity CID 1244240
Ticket: OW#1317
Sponsored-by: On-Waves ehf
2014-10-27 09:44:29 +01:00
Holger Hans Peter Freyther f9ffd1fa18 sgsn: Prevent memory leak and double free
This has been re-produced using the "osmo-pcu emulator" code
and a ping to force segmented SNDCP messages. When the NS link
enters the DEAD/BLOCKED state the msgb would be freed twice.
Once inside gprs_ns_sendmsg and once by the caller. Based on the
return one can not see if the parameter has been deleted.

I changed libosmocore/libosmogb to always free the msgb in case
of an error on the way to gprs_ns_sendmsg. Catch up, avoid the
double free and fix some memory leaks. In case the sending fails
assume the entire segmented message is at end and free the
original input data.

This has been tested by posix suspending/resuming the emulator
process to have the GPRS-NS link go to dead/blocked to alive
and unblocked. The ping recovers and "SIGUSR1" to the SGSN does
not show active memory allocations.

The SGSN calls bssgp_tx_dl_ud at the lowest level and has the
following callchains. Most of them allocate the msgb and have
no early return and transfer ownership already:

<- gprs_llc_tx_u
<- gprs_llc_tx_ui
	<- gsm48_gmm_sendmsg (all callers sane)
		<- _tx_status
		<- _tx_detach_req
	<- gprs_llc_tx_xid (all callers sane)
	<- sndcp_unitdata_req
		<- sndcp_send_ud_frag
2014-10-10 17:43:40 +02:00
Jacob Erlbeck b4f0e8089d gbproxy: Log more information on parse errors
To get a clue which message caused the error without having to enable
LOGL_DEBUG, information about how far the parser came (message name,
parsed fields) is logged with LOGL_NOTICE along with a full hexdump
of the message.

Ticket: OW#1307
Sponsored-by: On-Waves ehf
2014-10-09 18:17:06 +02:00
Jacob Erlbeck 1c407aa993 gbproxy: Pass the log level as argument to gprs_gb_log_parse_context
Currently, the log level is always LOGL_DEBUG. In case of errors it
would be helpful to use a higher log level.

This patch adds a log_level parameter to gprs_gb_log_parse_context to
let the caller decide about the level.

Ticket: OW#1307
Sponsored-by: On-Waves ehf
2014-10-09 18:16:22 +02:00
Jacob Erlbeck 9b07135b92 gbproxy: Add gprs_gb_message_name function
This function tries to get an accurate name for the message even if
the parsing has been aborted due to message errors.

The patch also moves the settings of the BSSGP related fields in
parse_ctx from behind to the front of bssgp_tlv_parse, to get more
information in the case of failure. This is now consistent with the
handling of the llc and g48_hdr fields.

Id addition, gprs_gb_log_parse_context now uses the new function to
derive a more accurate message name.

Ticket: OW#1307
Sponsored-by: On-Waves ehf
2014-10-09 18:15:31 +02:00
Jacob Erlbeck cc8856f9d3 gbproxy: Refuse to configure conflicting NSEIs
Currently it is possible to set the secondary SGSN NSEI to the same
value like the (primary) SGSN NSEI. This leads to undefined behaviour
and is hard to recognize.

This patch adds checks to either NSEI configuration command to refuse
conflicting values.

Ticket: OW#1306
Sponsored-by: On-Waves ehf
2014-10-09 18:14:09 +02:00
Jacob Erlbeck 49389178cc gbproxy: Use pointer to PTMSI value instead of MI
Currently, ptmsi_enc and new_ptmsi_enc point to the beginning of the
mobile identity. Since all P-TMSI in 04.08 (MM) are encoded this way (1
byte header + 4 byte P-TMSI value). This is different to the P-TMSI
encoding in 08.18 (BSSGP), where the P-TMSI is encoded into 4 byte
without MI header.

This patch changes the code to use pointers to the P-TMSI value,
which is encoded in the same way in both specifications.

Sponsored-by: On-Waves ehf
2014-10-09 18:12:27 +02:00
Jacob Erlbeck 43b8f9f8a1 gbproxy: Send STATUS(BVCI unknown) to BSS on unknown PTP BVCI
Currently BSSGP PTP messages are silently dropped when the BVCI is
not known and patching is enabled. The nanoBTS will not recognize
this and continue to send messages on the BVCI. If it receives a
STATUS(BVCI unknown) instead, it will start a BVC reset procedure
instead.

This patch modifies gbprox_rx_ptp_from_bss() to return a
STATUS(BVCI unknown) to the BSS instead of dropping the message.

Sponsored-by: On-Waves ehf
2014-10-09 18:09:54 +02:00
Jacob Erlbeck f349baeec8 gbproxy: Replace ';;' by ';'
This patch removes some superfluous ';' from the code.

Sponsored-by: On-Waves ehf
2014-10-09 18:09:27 +02:00
Jacob Erlbeck c9cd15fbc9 gbproxy: Fix parser to accept GSM 24.008 Attach Req messages
Currently the parse expects a 'MS network capability' IE with
2 <= length <= 3 which is compliant to GSM 04.08, 9.4.1  but not to
GSM 24.008, 9.4.1 which specifies 3 <= length <= 9. Thus the parser
rejects messages with a length >= 4 (including length field).

This patch relaxes the length check to accept either range by
requiring 2 <= length <= 9.

Ticket: OW#1258
Sponsored-by: On-Waves ehf
2014-10-09 18:07:10 +02:00
Jacob Erlbeck b36032cb27 gbproxy: Use a separate regexp for routing
Currently one regexp ('patching') is used for all matching.

This patch adds a second category 'routing' which is exclusively used
for SGSN selection. It also adds a corresponding VTY command:

  - match-imsi patching RE : MS related patching (currently APN)
  - match-imsi routing RE  : Select secondary SGSN on match only
  - no match-imsi          : Clear all filter expressions

Ticket: OW#1258
Sponsored-by: On-Waves ehf
2014-10-09 18:06:30 +02:00
Jacob Erlbeck 6c3fdc1091 gbproxy: Extend the match-imsi VTY command to support categories
This patch modifies the match-imsi command to allow for different
match categories (currently only 'patching' is provided).

  - match-imsi patching RE : Filter APN patching and routing
  - no match-imsi          : Clear all filter expressions

Sponsored-by: On-Waves ehf
2014-10-09 18:05:17 +02:00
Jacob Erlbeck 9ccc41ea05 gbproxy: Cleanup match config after tests
Currently, patch filter configurations are leaking between tests.

This adds a call to gbproxy_clear_patch_filter() to the end of each
test that calls gbproxy_set_patch_filter().

Sponsored-by: On-Waves ehf
2014-10-09 18:04:14 +02:00
Jacob Erlbeck 9a83d7af55 gbproxy: Refactor IMSI matching
The current implementation makes it difficult to add further match
expressions.

This patch adds a new struct gbproxy_match that contains the fields
needed for each match expression. The matches (config) and the
results (link_info) are stored in arrays. All related functions are
updated to use them. The old fields in the config structure are
removed.

Sponsored-by: On-Waves ehf
2014-10-09 18:02:33 +02:00
Jacob Erlbeck 55ec2bf97f gbproxy/test: Add expect_msg checks to test_gbproxy_ra_patching
This patch adds assertions to check the LLC/GMM message received from
the gbproxy by the test framework within the function
test_gbproxy_ra_patching.

Sponsored-by: On-Waves ehf
2014-10-09 18:01:48 +02:00
Jacob Erlbeck acfaff38db gbproxy/test: Save and check received messages
Currently the only way to check, whether the right message have been
generated is to look into the generated text output. This is
error-prone if there are many messages.

This patch adds a way to optionally store all received messages into
a FIFO. They can then be checked by calling expect_msg() which
removes the first message from the FIFO and returns a pointer to it
or NULL if there is none. The pointer is only valid until the next
call to this function.

A few convenience functions are added to check for common message
types:

  - expect_gmm_msg checks for certain GSM 04.08 messages in LLC/GMM
  - expect_llc_msg checks for arbitrary LLC messages in BSSGP/UD
  - expect_bssgp_msg checks for arbitrary BSSG messages

Each of their arguments can be set by MATCH_ANY to ignore it while
matching. On success, they return a pointer to a statically
allocated struct containing the pointer to the msg and the full parse
context.

Recording is enabled by setting the global variable received_messages
to a pointer to a struct llist_head. It can be disabled again by
setting it to NULL.

Sponsored-by: On-Waves ehf
2014-10-09 18:01:15 +02:00
Jacob Erlbeck 7e31f847af gprs: Fix gprs_msgb_copy pointer computation
Currently the pointers are computed by adding an offset to the new
message's _data pointer even when the original pointer is NULL.
This leads to invalid pointers in the copied msgb.

This patch adds a NULL check to each computation such that NULL
pointers are not adjusted.

Sponsored-by: On-Waves ehf
2014-10-09 18:00:55 +02:00
Jacob Erlbeck 657502812b gbproxy: Refactor local message generation
This patch adds und uses the function gbproxy_gsm48_to_peer() which
takes a GSM 04.08 message, encapsulates it in BSSGP and LLC, and
sends it to the BSS peer. This function increments vu_gen_tx_bss
which is now used instead of imsi_acq_retries to set the N(U) of the
outgoing message.

Since imsi_acq_retries isn't currently incremented before a Detach
Accept is generated, this patch also fixes the N(U) of such messages.

Sponsored-by: On-Waves ehf
2014-10-09 17:57:28 +02:00
Jacob Erlbeck d211d1d999 gbproxy: Reset IMSI acquisition within gbproxy_unregister_link_info
Currently then link_info is not cleaned up completely, when
gbproxy_unregister_link_info is called.

This patch adds a function gbproxy_reset_link that must be defined
externally. This is done in gb_proxy.c, where it resets the IMSI
acquisition.

Sponsored-by: On-Waves ehf
2014-10-09 17:56:16 +02:00
Jacob Erlbeck 9c65c8116f gbproxy: Parse Attach Reject messages
That message is currently ignored but should invalidate the TLLI and
de-register the logical link instead.

This patch extends the parser to recognize such messages and to set
the invalidate_tlli flag.

Sponsored-by: On-Waves ehf
2014-10-09 17:48:37 +02:00
Jacob Erlbeck 2bf326186a gbproxy/test: Add invalidation tests to test_gbproxy_keep_info()
The TLLI should also be invalidated:
 - when an Attach Reject info is received from the SGSN
 - when an Attach Req is immediately followed by a Detach Req
 - when an Attach Req is immediately followed by an MT detach
   procedure

To verify that, this patch adds corresponding message sequences to
the test.

Sponsored-by: On-Waves ehf
2014-10-09 17:48:29 +02:00
Jacob Erlbeck ea71b4880c gbproxy/test: Fix IMSI length check (Coverity)
This fixes the IMSI length assertion, which currently uses a
greater-or-equal than zero comparison which always yields true. It is
replaced by a greater than zero check.

Fixes: Coverity CID 1239442

Sponsored-by: On-Waves ehf
2014-10-09 17:47:58 +02:00
Jacob Erlbeck 51fde08b07 gbproxy/test: Fix time calculation in test_gbproxy_tlli_expire()
A single test case still uses time() to obtain the reference time.

This commit fixes this by using the 'now' variable instead, that
contains a fixed time value and does therefore not depend on when the
test is executed.

Sponsored-by: On-Waves ehf
2014-10-09 17:47:30 +02:00
Jacob Erlbeck c6807c4405 gbproxy: Use monotonic system time instead of time-of-day
Currently time() is used for age calculations. This time source
may jump either forwards or backwards in time (NTP update, leap
seconds).

This patch replaces the use of time() by using
clock_gettime(CLOCK_MONOTONIC) instead.

Sponsored-by: On-Waves ehf
2014-10-09 17:46:34 +02:00
Jacob Erlbeck ba6267f05a gbproxy: Only search by valid identifiers
Don't return a link_info if TLLI is 0 resp. P-TMSI is 0xffff. These
values are used for uninitialised or cleared fields and can possibly
match several entries.

Sponsored-by: On-Waves ehf
2014-10-09 17:46:06 +02:00
Jacob Erlbeck d4c79a458b gbproxy: Replace 'tlli' by 'link' in VTY commands
Since the (former) TLLI list has developed into a logical link list,
related commands are renamed accordingly.

 - tlli-list * -> link-list *
 - delete-gbproxy-tlli * -> delete-gbproxy-link *
 - show gbproxy tllis -> show gbproxy links

Sponsored-by: On-Waves ehf
2014-10-09 17:45:27 +02:00
Jacob Erlbeck f8562e362b gbproxy: Rename the field 'enabled_tllis' to 'logical_links'
This field in struct gbproxy_patch_state has involved and holds a
list of all tracked logical links now. Thus the name is modified
accordingly.

Sponsored-by: On-Waves ehf
2014-10-09 17:45:14 +02:00
Jacob Erlbeck 91d2f8a704 gbproxy: Use the term 'link' instead of 'tlli'
Currently in many places where 'tlli' (Temporary Logical Link
Identifier) within identifiers is used, the logical link itself is
meant instead. For instance, the tlli_info contain information about
an LLC logical link including up to four individual TLLI.

To avoid confusion between these concepts, this patch replaces all
'tlli_info' by 'link_info' and a few 'tlli' by 'link'.

Sponsored-by: On-Waves ehf
2014-10-09 17:44:57 +02:00
Jacob Erlbeck 9a7b0d5641 gbproxy: Rename functions related to tlli_info
This patch replaces 'tlli' by 'tlli_info' within the following
function identifiers:
  - gbproxy_delete_tlli
  - gbproxy_delete_tllis
  - gbproxy_remove_stale_tllis
  - gbproxy_touch_tlli
  - gbproxy_unregister_tlli
  - gbproxy_remove_matching_tllis
  - gbproxy_find_tlli -> gbproxy_tlli_info_by_tlli
  - gbproxy_find_tlli_by_* -> gbproxy_tlli_info_by_*

These functions refer to the whole logical link info rather than to a
certain TLLI. So they are renamed to be named consistently with
gbproxy_attach_tlli_info and others.

Sponsored-by: On-Waves ehf
2014-10-09 17:43:53 +02:00
Jacob Erlbeck 9a6b763507 gbproxy: Remove sgsn_nsei parameter
The function gbproxy_imsi_acquisition() has a parameter sgsn_nsei
that is alyways equal to tlli_info->sgsn_nsei (if tlli_info is not
NULL).

This patch removes this parameter from gbproxy_imsi_acquisition() and
gbproxy_flush_stored_messages() and accesses tlli_info->sgsn_nsei
instead within these functions.

Sponsored-by: On-Waves ehf
2014-10-09 17:43:34 +02:00
Jacob Erlbeck 8992f30866 gbproxy: Rename identifiers related to IMSI matching
This patch renames gbproxy_check_tlli() to
gbproxy_imsi_matches() and struct tlli_info's
enable_patching to imsi_matches.

It's meant to be more obvious and consistent this way.

Sponsored-by: On-Waves ehf
2014-10-09 17:43:12 +02:00
Jacob Erlbeck 08fbeb8fa4 gbproxy/sgsn: Enforce termination when creating a P-TMSI/TLLI
Currently the number of iterations when creating a P-TMSI/TLLI is not
limited. It is nevertheless very unlikely that the loop will not
terminate. On the other hand, the number of iterations of every loop
should have an upper bound (loop variant) which wouldn't be the case
here if an arbitrary random generator was used.

This patch limits the number of iterations to 23 and logs an error if
the creation of the indentifier was aborted due to this limit.

Sponsored-by: On-Waves ehf
2014-10-09 17:42:23 +02:00
Jacob Erlbeck e27ab916d6 gbproxy: Restart IMSI acquisition on RA UDP REQ
Currently the IMSI acquisition is not restarted when a RA Update
Request is received. This leads to repeated N(U) in the generated
Ident Request message, which in turn causes the MS to drop the
second of these message. This is bad, when the first Ident Response
has been lost between MS and gbproxy.

This patch changes gbproxy_imsi_acquisition() to handle RA Update
Request messages like Attach Requests.

Sponsored-by: On-Waves ehf
2014-10-09 17:41:41 +02:00
Jacob Erlbeck 2ec2757def gbproxy/test: Test IMSI acquisition for RA UDP REQ
When a MS is state GMM_REGISTERED enters a new RA, it sends a RA
Update Request which is then handled by a gbproxy that possibly
doesn't have a matching tlli_info. In this case, depending on the
configuration an identification procedure to acquire the IMSI must be
started.

This adds tests to test_gbproxy_imsi_acquisition():
 - IMSI acquisition triggered by a RA Update Request message
 - Reaction to repeated RA Update Request messages, like it could be
   caused by packet loss between PCU and gbproxy.

Sponsored-by: On-Waves ehf
2014-10-09 17:41:06 +02:00
Jacob Erlbeck 258ce3ded5 sgsn: Free MM context after receiving a Detach Request
On a Detach/Re-attach cycle the Address Sanitizer detected a
use-after-free kind of problem. That is because we tried to
destroy the LLME twice. The first time it is destroyed as part
of the Detach handling ans the second time it is destroyed as
part of destroying the old MM context.

In case the GPRS GMM detach message is lost the SGSN needs
to reply besides not having a MM entry.

The alternative would have been to add NULL checks for all
usages of ctx->llme which would not have helped with the
readability.

Sponsored-by: On-Waves ehf
2014-10-09 17:22:34 +02:00
Holger Hans Peter Freyther fe92133132 sgsn: Add test that exposes a dangling pointer to the LLME
On detach the LLME get's unassigned (and hence destroyed) but the
GMM context will still point to that dead structure.
2014-10-09 17:22:34 +02:00
Holger Hans Peter Freyther 4299c0560f sgsn: Create testcase that verifies that llmes get deleted
On an "unassignment" this code verifies that the LLME will vanish
from the list of LLMEs. We assume that this doesn't create a
memory leak.
2014-10-09 17:22:34 +02:00
Holger Hans Peter Freyther 68c6f887c2 sgsn: Add boilerplate code for a SGSN test 2014-10-09 17:22:34 +02:00
Holger Hans Peter Freyther 7b76f82b6e mgcp: Count the incoming data instead of the modified one
For jitter, transit and packet loss we should count the data
that arrived and not the data we send towards the remote. This
is changing the jitter timings to what they were before the
re-factoring.

For forced timing we might willingly add jumps in the sequence
number but for jitter and packet loss we are more interested
in the data that traveled through the wire/air.
2014-10-09 17:22:33 +02:00
Holger Hans Peter Freyther 05d481a42c mgcp: Do not detect the initial package as a wrap around
The Annex A code has a probation period but we don't have it. When
starting with seq_no==0 do not assume that the sequence numbers
have wrapped. Do it by moving the entire checking code into the
else.
2014-10-09 17:22:33 +02:00
Holger Hans Peter Freyther a5a59c9a05 mgcp: Move Annex A counting out of patch/count method
mgcp_patch_and_count has grown due supporting linearizing timestamps,
ssrc and other things for equipment like the ip.access nanoBTS. Fight
back and move the Annex A code into a dedicated method.

The result is updated as we now count after all the patching and for
the Annex A code no change in SSRC can be detected.
2014-10-09 17:22:33 +02:00
Holger Hans Peter Freyther 2a7ab868e3 mgcp: We only look at the RTP header use that in the comment 2014-10-09 17:22:33 +02:00
Ruben Pollan ed04a0d060 nitb: Add subscriber delete command 2014-10-03 09:15:28 +02:00
Holger Hans Peter Freyther 47c624b561 bsc: Let the VTY verify that the timeout is a number
Before the old code allowed to specify "timeout-ping bla" which
would be parsed as '0' which would trigger a flood of pings. Use
the VTY code to parse it as a number.
2014-10-02 12:08:29 +02:00
Daniel Willmann f8070f4793 gprs: Move log message about mm context after NULL check
Fixes: CID#1240205
2014-09-25 14:24:55 +02:00
Daniel Willmann 465531403c gprs: Improve loglevels and log messages for SGSN
Many log levels were DEBUG without any good reason. Also where possible
the details of the MM or PDP context are now logged with LOGMM/PDPCTXP.
2014-09-22 10:47:11 +02:00
Daniel Willmann b15ceec33f gprs_sgsn.h: Add two macros to log details of MM/PDP contexts 2014-09-22 10:47:11 +02:00
Jacob Erlbeck 25ad52cf6a sgsn: Reset local LLC parameters when sending XID reset
Currently when gprs_llgmm_reset() is invoked an XID reset is sent but
the local LLC parameters (e.g. V(U)) are not cleared (see GSM 04.64,
8.5.3.1). This can lead to discarded messages on the SGSN side.

This patch modifies gprs_llgmm_reset to clear vu_send, vu_recv,
oc_ui_send, oc_ui_recv.

Sponsored-by: On-Waves ehf
2014-09-19 11:55:21 +02:00
Jacob Erlbeck 91a0e8639a gbproxy: Separate SGSN numeric namespaces
Currently the SGSN side message's TLLI are searched without checking
the originating SGSN. This leads to collisions if both SGSN use the
same P-TMSI for different MS.

With this patch, the SGSN NSEI is stored within the tlli_info and is
used in comparisons to separate the namespaces.

Note that this type of collision cannot happen with BSS numbers,
since the tlli_info are already separated and stored per (BSS) peer.

Sponsored-by: On-Waves ehf
2014-09-19 11:21:35 +02:00
Jacob Erlbeck af952baffc gbproxy/test: Add a test with a P-TMSI collision between two SGSNs
This patch extends test_gbproxy_secondary_sgsn() by the establishment
of a third MS connection using a P-TMSI that has been assigned by the
other SGSN already. It is expected that the entries do not
interfere and are properly retrieved.

Note that these collisions are not handled properly yet.

Sponsored-by: On-Waves ehf
2014-09-19 11:21:24 +02:00
Jacob Erlbeck 2bb4543809 gbproxy/test: Fix Identification Response
At one place, the reply to the second Ident Req contains the wrong
IMSI. That is fixed by this patch.

Sponsored-by: On-Waves ehf
2014-09-19 11:21:13 +02:00
Jacob Erlbeck 1a02442f66 gbproxy: Check other tlli_infos for matching TLLI/P-TMSI
Currently it is possible to create serveral entries referring to the
same P-TMSI/TLLI by using P-TMSI assigment via Attach Accept or
RA Update Accept messages. This can lead to the use of the wrong
tlli_info.

This patch adds gbproxy_remove_matching_tllis() that removes all
conflicting entries. This function is called after the P-TMSIs and
the resulting TLLIs has been set up.

Sponsored-by: On-Waves ehf
2014-09-19 11:21:01 +02:00
Jacob Erlbeck 04f679be73 gbproxy/test: Add test case for P-TMSI assigment
This tests P-TMSI assignment when P-TMSI patching is disabled. A test
with colliding P-TMSI in Attach Accept messages is included.

Note that P-TMSI collisions are not handled properly yet.

Sponsored-by: On-Waves ehf
2014-09-19 11:20:50 +02:00
Jacob Erlbeck 85e5c8f905 gbproxy: Parse RA_UPD_REJ and invalidate TLLI
Since this message puts the MS into DEREGISTERED state (like a detach
procedure), this message is parsed and the invalidate_tlli field is
set accordingly.

Sponsored-by: On-Waves ehf
2014-09-19 11:20:31 +02:00
Jacob Erlbeck cdd37837b3 gbproxy: Delete and show detached entries via VTY
This commit adds/modifies the following VTY commands:

  - delete-gbproxy-tlli <NSEI> de-registered : Delete all
    de-registered entries
  - show gbproxy tllis : Display 'DE-REGISTERED' when appropriate

In addition, the implementation of the delete-gbproxy-tlli command
has been split into two functions (with and without TLLI/IMSI
value).

Sponsored-by: On-Waves ehf
2014-09-19 10:54:21 +02:00
Jacob Erlbeck d3bde96b36 gbproxy: Replace LOGP by LOGPC for continued lines
gprs_gb_log_parse_context() uses a sequence of LOGP calls to compose
a single message line. This leads to cluttered log output.

This patch replaces all but the first LOGP applications in this
function by applications of LOGPC.

Sponsored-by: On-Waves ehf
2014-09-19 10:49:17 +02:00
Jacob Erlbeck 16a3cd3847 gbproxy: Avoid multiple tlli_info entries with the same IMSI
Currently it is possible to create several tlli_info entries with the
same IMSI.

This patch disables this by adding a check before the imsi field
is updated.

Sponsored-by: On-Waves ehf
2014-09-19 10:49:12 +02:00
Jacob Erlbeck 7430da621a gbproxy: Keep tlli_info after detach
Currently a tlli_info entry is deleted when the TLLI gets invalidated
by a Detach message.

This patch introduces the possibility to keep tlli_info entries in
the list. Those entries then have cleared TLLI fields, are marked as
de-registered, and can only be retrieved by a message containing an
IMSI or a P-TMSI.

The following VTY configuration commands are added to the gbproxy
node:
  - tlli-list keep-mode never : Don't keep the entries (default)
  - tlli-list keep-mode re-attach : Only keep them, when a Detach
    message with re-attach required has been received
  - tlli-list keep-mode identified : Only keep entries which are
    associated with an IMSI
  - tlli-list keep-mode always : Keep all entries

Note that at least one of max-length or max-age should be set when
this feature is used to limit the number of entries.

Sponsored-by: On-Waves ehf
2014-09-19 10:46:23 +02:00
Jacob Erlbeck cba4c0cc60 gbproxy: Only patch what has been configured
Currently when patching is basically enabled P-TMSI and TLLI gets
patched even when P-TMSI patching is not enabled. Albeit the result
is correct in this case (the same value is re-written), the counter
shows unexpected results.

This patch adds configuration checks for P-TMSI and TLLI patching. It
also reorders the code of gbproxy_patch_raid to return early if there
is nothing to patch.

Sponsored-by: On-Waves ehf
2014-09-18 13:46:09 +02:00
Jacob Erlbeck 772a22b529 gbproxy/test: Add test case for tlli_info persistence
This test case consists of a sequence of several attach and detach
procedures. The kind of detach varies (mobile originated, mobile
terminated re-attach required, mobile terminated re-attach not
required, routing area update reject). To main focus is to check that
the tlli_info is de-registered correctly (not accessible via the
TLLI) and that can be re-used afterwards (which is not implemented
yet).

Sponsored-by: On-Waves ehf
2014-09-18 13:40:03 +02:00
Jacob Erlbeck a42fe9f61e gbproxy: Remove gbproxy_register_tlli
This function is a remainder of the initial implemenation that was
not meant for TLLI patching and can be used for the BSS side only.
The SGSN side is already using a composition of more flexible
single purpose functions.

This patch changes the implementation to use a similar approach. The
function is moved to gbproxy_test.c and renamed to register_tlli to
keep the tests intact.

Sponsored-by: On-Waves ehf
2014-09-18 13:21:17 +02:00
Jacob Erlbeck 2a5096dfc6 gbproxy: Send DETACH_ACC if the IMSI has not been acquired
If IMSI acquisition is enabled and the gbproxy receives a Detach
request from the MS, it cannot pass it to the SGSN since the
acquisition has not yet been completed.

This patch implements the generation of a Detach Accept message and
for this case and updates the TLLI state accordingly.

Sponsored-by: On-Waves ehf
2014-09-18 13:21:16 +02:00
Jacob Erlbeck 948c07f490 gbproxy: Fixed RAI patching in Attach Request messages
Currently the RAI in the LLC part of the message is not updated if
the message has been taken from the list of stored messages. The
reason is, that old_raid_matches is update in
gbprox_process_bssgp_ul() but not in gbproxy_flush_stored_messages().

This patch moves the check to gprs_gb_parse_bssgp() which is called
at both places and where other fields like parse_ctx->tlli are set,
too.

In addition, old_raid_matches is replaced by old_raid_is_foreign
since this is clearer in the case when there is no old RAI at all.

Several RAI patch counter assertions are also added to
test_gbproxy_ra_patching().

Sponsored-by: On-Waves ehf
2014-09-18 13:20:58 +02:00
Jacob Erlbeck 991606b57a gbproxy/test: Add/modify test cases
Add a Attach Request message to test_gbproxy_ra_patching, where the
BSSGP RAI differs from the old RAI signalled in the LLC part. This
case had not been tested explicitely yet.

Change the RAI in the first Attach Request in
test_gbproxy_imsi_acquisition from rai_unknown to rai_bss.

Add Detach Requests to test_gbproxy_imsi_acquisition, one for a
incomplete attach procedure and one for an unknown (fresh) TLLI.
In these cases, the acquisition of a IMSI is not necessary and also
doesn't work properly with an E71.

Sponsored-by: On-Waves ehf
2014-09-18 11:26:07 +02:00
Jacob Erlbeck 2fd1ba4c6d gbproxy: Replace 'mi_data' by 'imsi'
Since at all places where mi_data/mi_data_len is used it will always
contain an IMSI. Thus the names of the identifiers have been updated
accordingly for clarity.

Sponsored-by: On-Waves ehf
2014-09-18 11:22:15 +02:00
Jacob Erlbeck 6bafa4ce0d gbproxy: Rework gbproxy_imsi_acquisition
This commit changes gbproxy_imsi_acquisition as follows:

tlli_info->mi_data_len is used instead of parse_ctx->imsi to check,
whether the IMSI is known already. Since the function is always
called after gbproxy_update_tlli_ul(), the two values are already
synchronized.

Messages are always flushed when the IMSI gets known, if the current
message is IDENT RESP discard it, otherwise continue processing as
usual.

The 'if' clauses are simplified for better readability.

Sponsored-by: On-Waves ehf
2014-09-18 11:21:57 +02:00
Jacob Erlbeck 0b243a106a gbproxy: Refactor gbprox_process_bssgp_ul into smaller functions
gbprox_process_bssgp_ul has grown quite large mainly by the addition
of IMSI acquisition.

This patch moves that code into several smaller functions. In
addition, the peer resolution which is similar to that in
gbprox_process_bssgp_dl is moved into a separate function, too.

Sponsored-by: On-Waves ehf
2014-09-18 08:49:21 +02:00
Pablo Neira Ayuso ee11bc0f5c osmux: send osmux stats in MGCP DLCX responses
This allows us to know what number of messages and bytes has been
received per active osmux endpoint.

Note that an Osmux message is composed of several chunks. Each chunk
contains an osmux header plus several voice data frames.

 P: PS=385, OS=11188, PR=195, OR=5655, PL=0, JI=49
 X-Osmo-CP: EC TIS=0, TOS=0, TIR=0, TOR=0
 X-Osmux-ST: CR=51, BR=3129

The new 'X-Osmux-ST:' notifies the received chunks and bytes.
2014-09-17 19:34:25 +02:00
Holger Hans Peter Freyther 8d2fe43c7f nitb: Don't mention the broken PCAP generation option
The PCAP option doesn't seem to work for TCP/IP based BTS. Don't
mention it to not confuse people that search for a way.
2014-09-16 18:13:44 +02:00
Pablo Neira Ayuso 115e81ee19 osmux: account extracted traffic from the osmux batch
Use struct mgcp_rtp_end statistics to account the RTP messages
that has been extracted from the osmux batch and transmitted.
2014-09-16 14:32:37 +02:00
Jacob Erlbeck 1abfdc218e gbproxy: Remove patch_mode, update initial checks
This patch removes the patch_mode feature including the related VTY
command patch-mode. Where sensible, the other configuration flags are
queried instead.

In addition, this initial checks in gbprox_process_bssgp_dl() and
gbprox_process_bssgp_ul() have been updated.

The patch mode feature has not been used and was increasingly
difficult to maintain.

Sponsored-by: On-Waves ehf
2014-09-09 10:10:25 +02:00
Jacob Erlbeck 7fb26c2943 gbproxy/test: Add assertions, improve test coverage
This patch add explicit tests for
  - gbproxy_peer_by_bvci
  - gbproxy_peer_by_nsei
  - gbproxy_cleanup_peers
  - gbproxy_peer_by_rai
  - gbproxy_peer_by_lai
  - gbproxy_peer_by_lac
and for messages with an unknown TLLI sent by the SGSN.

Sponsored-by: On-Waves ehf
2014-09-09 10:10:12 +02:00
Jacob Erlbeck 31591142e9 gbproxy: Reset IMSI acquisition and free stored messages in tlli_info
Currently the stored messages are only removed, when IMSI acquisition
has succeeded. In addition, receiving two ATTACH_REQ messages in
sequence (e.g. due to loss of a Identity Req/Resp message) will not
restart the IMSI acquisition procedure.

This patch adds gbproxy_tlli_info_discard_messages() to clean up the
message list and calls it from gbproxy_delete_tlli() fixing a
potential memory leak. It is also called when an Attach Request
message has been received. In that case the imsi_acq_pending flag is
cleared, too. This would (re-)trigger the IMSI acquisition procedure
at each of these messages. If an Ident Response has been lost,
resending the Ident Request with the same N(U) will not work.
Therefore the N(U) gets incremented on each Ident Request generated
by the gbproxy. The first N(U) used is 256 which shouldn't collide
with the V(UT) used by the SGSN given that P-TMSI patching is enabled
(since a new random TLLI is used initially on every new (no
tlli_info) connection and V(U) starts with zero then).

Ticket: OW#1261
Sponsored-by: On-Waves ehf
2014-09-09 10:10:00 +02:00
Jacob Erlbeck ea1698e322 gbproxy/test: Add test cases for IMSI acquisition
If the Attach Request procedure gets restarted e.g. because of a lost
message, all of these messages are stored if IMSI acquisition is in
progress.

This patch adds a test for this case and modifies the dump_peers
function to output the number of stored messages.

Note that the number of stored messages currently increases with each
(repeatedly) received Attach Request which is not the desired behaviour.

Sponsored-by: On-Waves ehf
2014-09-09 10:09:50 +02:00
Jacob Erlbeck b1ee5cd3b6 gbproxy: Fix P-TMSI reassignment
Currently, a new P-TMSI within an Attach Accept or within an RA
Update Request is applied to the TLLI mapping (gbproxy_reassign_tlli)
_before_ patching is done. This can lead to inconsistent behaviour
when the TLLI validation has not been completed, which is the case
when subsequent RA UDP REQ are received. The new TLLI must not be
applied to the message itself yet, it should only be considered for
following messages.

This patch moves the TLLI reassignment to
gbproxy_update_tlli_state_after() to fix that.

It also separates the implementation of the feature that a new
tlli_info can be created when such a message is received from the
SGSN. This makes sense, when P-TMSI patching is not active and the
tlli_info entry has expired.

Sponsored-by: On-Waves ehf
2014-09-09 10:05:56 +02:00
Jacob Erlbeck 37fda77814 gbproxy: Change creation of tlli_info for SGSN originated messages
Currently tlli_info are created for SGSN originated messages when
the SGSN TLLI cannot be found and P-TMSI patching is active. This
doesn't make much sense, since the BSS side TLLI is not known in this
case. Given that the SGSN is working properly, that can only happen
if either the tlli_info has expired or the gbproxy has been
restarted.

This patch disables the creation of a tlli_info in this case.

Note that these messages are passed unmodified to the MS so far.

Sponsored-by: On-Waves ehf
2014-09-09 09:47:03 +02:00
Jacob Erlbeck 52f070a099 gbproxy/test: Extend P-TMSI patch test by a sequence of RA UDP REQ
This adds a sequence of two RA update procedures to
test_gbproxy_ptmsi_patching(). Each of them assigns a new P-TMSI.

Note that the implementation fails to patch the RAI within the
message labelled 'RA UDP ACC (P-TMSI 3)' and logs 'TLLI sent by the
SGSN is unknown'.

Sponsored-by: On-Waves ehf
2014-09-08 13:34:13 +02:00
Jacob Erlbeck cd9e1c94e5 gbproxy: Reorganize VTY commands
Since the secondary SGSN selection and APN patching can both be
enable/disabled by IMSI matching, this patch introduces a separate
match-imsi command and removes the corresponding variant of the
core-access-point-name command.

P-TMSI patching and IMSI acquisition are enabled/disabled by
match-imsi resp. secondary-sgsn. The patch-ptmsi and acquire-imsi
commands are still available for internal testing but are subject to
being removed.

Sponsored-by: On-Waves ehf
2014-09-08 10:54:20 +02:00
Jacob Erlbeck 146e30736d gbproxy: Show number of stored messages in VTY show
This patch extends the 'show gbproxy tllis' command to display the
number of stored messages per tlli_info if there are any.

Sponsored-by: On-Waves ehf
2014-09-08 10:20:18 +02:00
Jacob Erlbeck 1e65b0e7a1 gbproxy: Forward SGSN originated STATUS messages with BVCI
Currently all STATUS messages coming from the SGSN are just logged
and dropped. This prevents the PCU from recognising that the
(secondary) SGSN doesn't know about a certain BVCI and might require
a reset procedure.

This patch changes gbprox_rx_sig_from_bss() to forward STATUS
messages with cause "Invalid BVCI" containing a BVCI to the BSS.

Note that this will not forward broken "Invalid BVCI"
messages which do not include a BVCI IE.

Sponsored-by: On-Waves ehf
2014-09-08 10:20:18 +02:00
Jacob Erlbeck 17b42b81f0 gbproxy: Make STATUS messages spec compliant
Currently the gbproxy sends STATUS messages that are not compliant to
GSM 08.18, 10.4.14.1: The BVCI must be included if (and only if) the
cause is either "BVCI blocked" or "BVCI unknown".

This patch adds a missing BVCI to UNKNOWN_BVCI and BVCI_BLOCKED
status messages if the BVCI is available. Otherwise, INV_MAND_INF is
used instead.

Sponsored-by: On-Waves ehf
2014-09-08 10:20:18 +02:00
Jacob Erlbeck 18a3787296 gbproxy: Check tlli_info when patching, fix APN patching
Currently the numeric TLLI or tlli_info's enable_patching flag is
used to decide, whether a APN shall be patched or the secondary SGSN
shall be used. Using the numeric TLLI imposes a problem, when
TLLI/P-TMSI patching is used, since gbproxy_check_tlli uses the BSS
side TLLI namespace when trying to get the tlli_info.

This patch modifies the gbproxy_check_tlli() function to accept a
tlli_info pointer instead of a numeric TLLI. The tlli_info is already
available when the function is called. Since this a similar approach
has been used by accessing the enable_patching flag directly, this
commit unifies checking by always using this function instead of the
flag outside of gb_proxy_tlli.c.

This fixes the APN patching that doesn't work currently when P-TMSI
patching is enabled.

Sponsored-by: On-Waves ehf
2014-09-08 10:20:16 +02:00
Jacob Erlbeck 82add78f89 gbproxy/test: Check APN patching while P-TMSI patching is enabled
This commit adds a single ACT PDP CTX REQ message to
test_gbproxy_ptmsi_patching() to check whether APN patching works in
this case, too.

Note that this doesn't work currently, the APN patch count is not
incremented.

Sponsored-by: On-Waves ehf
2014-09-08 09:27:41 +02:00
Jacob Erlbeck 25f98e618a gbproxy: Add missing commands to VTY write
Currently the new command acquire-imsi and secondary-sgsn are not
included into the write command's output.

This is fixed by this commit.

Sponsored-by: On-Waves ehf
2014-09-08 09:27:41 +02:00
Jacob Erlbeck c1c57d3a26 gbproxy: Copy uplink messages to SGSN 2
Some messages that are related to the BVC itself must be forwarded to
the secondary SGSN, too.

This patch implements this for BVC-RESET (BVCI != 0) and FLOW-CONTROL-BVC
messages. The resulting acknowledgement messages from the secondary
SGSN are silently dropped. The idea behind this is that the primary
SGSN is responsible for setting up and maintaining the BVC whereas
the secondary SGSN is rather passive and just has to accept it.

Ticket: OW#1258
Sponsored-by: On-Waves ehf
2014-09-08 09:27:41 +02:00
Jacob Erlbeck cabd24b33f gbproxy: Use secondary SGSN if IMSI matches
This patch modifies gbprox_process_bssgp_ul() to send the message to
the secondary SGSN if the IMSI has matched and routing to the
secondary SGSN is enabled. The destination for stored messages is
modified accordingly.

Ticket: OW#1261
Sponsored-by: On-Waves ehf
2014-09-08 09:27:36 +02:00
Jacob Erlbeck f181f9ec2a gbproxy/test: Add test case for secondary SGSN
This patch adds a case to test the establishment (and shutdown) of
connection between 2 MS and 2 SGSN, where the assignment is based
on each IMSI. Since BVC-RESET and FLOW-CONTROL-BVC will have to be
sent to both SGSN, an ACK is simulated for both.

New functions to generate FLOW-CONTROL-BVC(-ACK) messages are
provided.

It modifies dump_peers to add the string "IMSI matches" to a TLLI dump
line if appropriate.

Note that there is no real support to use a secondary SGSN in the
gbproxy yet, but the test code reflects the expected behaviour when
the feature is implemented.

Sponsored-by: On-Waves ehf
2014-09-08 09:12:02 +02:00
Jacob Erlbeck f4d60c8788 gbproxy: Support a secondary SGSN
This patch refactors SGSN NSEI handling to support a secondary SGSN.

It adds the following VTY commands:
  - secondary-sgsn nsei <0-65534>
  - no secondary-sgsn

Sending messages to the secondary SGSN is not yet implemented, but
received messages from such a SGSN would be forwarded to the BSS
peers.

Sponsored-by: On-Waves ehf
2014-09-08 09:11:59 +02:00
Jacob Erlbeck 5930064700 gbproxy: Add missing gbprox_process_bssgp_ul() return check
This should have been part of the 'Implement IMSI acquisition'
commit, where a similar change has been made for BSS originated PTP
messages.

Sponsored-by: On-Waves ehf
2014-09-08 09:04:01 +02:00
Jacob Erlbeck 1a8dbc4fc9 gbproxy: Fix warnings
This patch fixes the remaining 'unused' warnings.

Sponsored-by: On-Waves ehf
2014-09-07 10:46:10 +02:00
Holger Hans Peter Freyther 56cb729907 bsc: Add a "IPA PING" to the SCCP CR messages
We want to reduce the background traffic and might set the ping
interval to be in the range of minutes. But this means that if
the TCP connection is frozen several "SCCP CR CM Service Requests"
will be stuck in the send queue without ever being answered. I
could have used the logic of not receiving the "SCCP CC" to close
the connection but instead I am introducing an overload to schedule
the ping as part of the normal SCCP connection establishment.

The VTY write case has been manually verified, I have also looked
at a single trace to see that the SCCP CR and the IPA PING is
transfered in the same ethernet frame.
2014-09-05 12:25:32 +02:00
Holger Hans Peter Freyther 0169971a59 mgcp: Re-load the state after the transcoding change
Jacob ran the tests with ASAN and noticed that the state is
dead. This is on purpose as we have forced a change in the
transcoding. Re-load the state and verify that it has not
changed in the other cases.
2014-09-05 12:25:32 +02:00
Holger Hans Peter Freyther 0454e32861 mgcp: Use l16 in the test
G729 might not be available, so execute the test with codecs that
are always available.
2014-09-02 12:16:22 +02:00
Jacob Erlbeck 5f4ef321a6 gbproxy: Implement IMSI acquisition
To modify or route messages based on the IMSI the latter must be known
when the action shall take place.

This patch modifies the gbproxy to optionally retain and enqueue
messages from the MS while initiating an identification procedure.
Further message processing of the LLC PTP link towards the SGSN will
be done, when the identity of the MS has been acquired.

Note that the N(U) of the LLC GMM SAPI are not adjusted, so it is
possible that adjacent messages of a single LLC link arriving either
at the BSS or the SGSN have the same N(U) and might get discarded,
leading to retransmissions and additional delay.

Note also that retransmissions and packet loss are not yet handled
explicitely. If for instance the generated IDENT REQ gets lost, the
gbproxy will not act on its own. In this case, the MS will time out
and eventually resend the Attach Request on which the gbproxy will
act exactly like before (thus having two Attach Req messages in its
queue, which will both be sent after the Ident Resp arrives).

This has been tested successfully with an E71, needing one
retransmission by the SGSN due to an N(U) collision.

Ticket: OW#1261
Sponsored-by: On-Waves ehf
2014-09-02 09:53:47 +02:00
Jacob Erlbeck 28fe98891f gbproxy/test: Add a test for IMSI acquisition
This patch copies test_gbproxy_ptmsi_patching to
test_gbproxy_imsi_acquisition as a base for a later test for IMSI
acquisition (which is not yet implemented). The idea behind this is
to make the different behaviour visible in the ok file without
compromising the P-TMSI test.

Sponsored-by: On-Waves ehf
2014-09-02 09:53:42 +02:00
Jacob Erlbeck 4b663ac34a gbproxy: Create STATUS message with original PDU
Currently when patching is enabled and an error happens when
receiving a message from the SGSN, the patched message is sent back
with the PDU_IN_ERROR IE.

This patch modifies gbprox_rx_sig_from_sgsn() to copy the message
before it is patched, so that the original message can be used with
the STATUS message. gbprox_rx_ptp_from_sgsn() does all checks before
the message is patched, so copying is not necessary.

Since gbprox_rx_sig_from_sgsn() is not called for BSSGP UNITDATA
messages and the msgb is already been copied in the gbprox_relay2peer
function, the relative performance impact is expected to be low.

Note that the PDU IE of STATUS messages received from an MS and
forwarded to the SGSN will not be patched. STATUS messages from the
SGSN are only logged and not forwarded to the MS.

Sponsored-by: On-Waves ehf
2014-09-02 09:53:38 +02:00
Jacob Erlbeck 299389a99f gbproxy/test: Test patching BSSGP SUSPEND/LLC-DISCARDED
Currently messages like these with a TLLI IE (BSSGP) are not
tested (properly) with TLLI patching.

This patch extends the send_bssgp_suspend* functions to accept a
TLLI as argument and adds the send_bssgp_llc_discarded function.
These are then used in test_gbproxy_ptmsi_patching() with a valid
TLLI.

Note that the TLLI IE patching doesn't work currently.

Sponsored-by: On-Waves ehf
2014-09-02 09:53:34 +02:00
Jacob Erlbeck 46f1d6fddb gbproxy: Move PTP message handling into separate functions
This patch adds gbprox_rx_data_from_sgsn() and
gbprox_rx_ptp_from_bss() which contain the PTP message processing
of gbprox_rcvmsg(). The calls to gbprox_process_bssgp_ul() are moved
from gbprox_relay2sgsn() to gbprox_rx_ptp_from_bss() and
gbprox_rx_sig_from_bss().

The goal is, to do all patching (and calls to gbprox_process_bssgp_*)
from within the gbprox_rx_* functions. Doing the patching from within
gbprox_relay2sgsn has the drawback, that the patching code cannot
call gbprox_relay2sgsn() which is needed if a single message shall
trigger a sequence of messages.

Sponsored-by: On-Waves ehf
2014-09-02 09:53:30 +02:00
Jacob Erlbeck 48bb3a37da gbproxy: Remove nonnull attributes
The compiler also uses this attribute for code elimination. If the
nonnull attribute has been given erroneously for an parameter, that
is later been checked against NULL, this check is removed silently
by the gcc if optimization is enabled. This can lead to hard-to-find
segmentation violation faults.

To be on the safe side, this patch removes all uses of the nonnull
attribute in openbsc.

Compiler:
  - gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1): no warning, segfault
  - clang 3.4 (3.4-1ubuntu3): no warning, no segfault, asm ok

Example:
  /* foo.c */
  int f(int* p) __attribute((nonnull));
  int f(int *p) {
      if (!p)
          return 0;

      return *p;
  }

  /* main.c */
  int f(int* p) __attribute((nonnull));
  int g () {
      return f(arg);
  }

  int main() {
      return g(NULL);
  }

When these files are compiled into an executable, no warnungs are
issued but it will fail with a segfault when -O2 is used (unless LTO
is active).

Compiler output (gcc -O2):
  int f(int *p) {
    0:  8b 44 24 04             mov    0x4(%esp),%eax
    4:  8b 00                   mov    (%eax),%eax
    6:  c3                      ret
  }

Sponsored-by: On-Waves ehf
2014-09-02 09:53:18 +02:00
Holger Hans Peter Freyther e3283ec3eb Merge branch 'zecke/features/dynamic-codec-switch' 2014-09-02 09:28:44 +02:00
Holger Hans Peter Freyther 4680121fe6 mgcp: Deal with receiving another payload type
In case we get offered G729 and G711 we might have selected
G729 as the audio codec. The first packet we receive might be
G711 though. In that case we will need to change. But only if
we have a matching alternate codec payload_type. E.g. in the
case of comfort noise we will receive the PT=11 and we don't
want to change.
2014-09-02 09:27:45 +02:00
Holger Hans Peter Freyther e46bc2714d mgcp: Store one more codec/payload type if it is present
In case of some RTP proxy from time to time we are offered both
G729 and G711 but only one of them will work. I intend to adjust
the codec at runtime in case we receive the wrong codec.
2014-09-02 09:22:19 +02:00
Holger Hans Peter Freyther fa80d07de0 mgcp: Group codec reset and put it to a separate method. 2014-09-02 08:25:49 +02:00
Holger Hans Peter Freyther cac2438b0c mgcp: Move the "codec" params to a struct
We might be offered multiple codecs by the remote and need to
switch between them once we receive data. Do this by moving it
to a struct so we can separate between proposed and current
codec. In SDP we can have multiple codecs but a global ptime.
The current code doesn't separate that clearly instead we write
it to the main codec.
2014-09-02 08:25:49 +02:00
Holger Hans Peter Freyther 3713f78ac2 mgcp: Use the rtp_hdr structure and extract ts/seq from there
Use the rtp_hdr structure. The basic alignment issue remains
and I need to merge/cherry-pick Jacob's getters for the ts,
sequence number and other attributes.
2014-09-02 08:25:49 +02:00
Pablo Neira Ayuso c20a661272 osmux: osmux batch-factor can't be higher than 8
The osmux header uses a counter of 3 bits, so you can put up to
8 message in it.
2014-09-01 20:07:27 +02:00
Pablo Neira Ayuso fcec6d85d0 osmux: save specific osmux configuration options if osmux is enabled
Just like other options do, to avoid polluting the configuration file
with unused options if osmux is disabled.
2014-09-01 20:06:43 +02:00
Pablo Neira Ayuso 9224010859 configure: fix unrecognized option --enable-external-tests
./configure --help indicates:

  --enable-external-tests Include the VTY/CTRL tests in make check
                          [default=no]
but

./configure ... --enable-external-tests
configure: WARNING: unrecognized options: --enable-external-tests

the name of the option seems to be --enable-ext-tests.
2014-09-01 18:35:15 +02:00
Pablo Neira Ayuso 08726e2837 osmux: initialize osmux_batch_size in mgcp config
The library allows to indicate zero as batch size if you want to use
the default size, however openbsc saves 'osmux batch-size 0' which is
not good as input.

Use OSMUX_BATCH_DEFAULT_MAX to explicitly initialize the batch size
from mgcp_parse_config().
2014-08-30 07:59:41 +02:00
Pablo Neira Ayuso 03ab79abac osmux: add 'osmux batch-size NUM' option to mgcp vty
This allows you to specify the osmux batch frame size. If zero, the
library uses the default value.
2014-08-29 12:30:38 +02:00
Pablo Neira Ayuso 308d5f8912 osmux: set default port from mgcp_parse_config() 2014-08-29 12:21:58 +02:00
Holger Hans Peter Freyther 73ec6980d5 nat: Introduce a config free for the test and fix valgrind issues
The talloc_free on the nat lead to the freeing of the bsc_config
which lead to freeing of the rate_ctr_group. The rate_ctr_group
remained in a global list and the next creation of a bsc_config
would access dead memory. Fix it.

The free routine is only meant to be used by the test, for the
real nat we would need to make sure that all connections and
other state that refers to the cfg is removed/closed first.

Fix various memleaks in the test while we are at it. There are
still some to fix.

==7195== Invalid write of size 4
==7195==    at 0x4043171: rate_ctr_group_alloc (linuxlist.h:65)
==7195==    by 0x804D893: bsc_config_alloc (bsc_nat_utils.c:174)
==7195==    by 0x804B5D2: main (bsc_nat_test.c:954)
==7195==  Address 0x4311cbc is 52 bytes inside a block of size 208 free'd
==7195==    at 0x4029D28: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==7195==    by 0x4048D98: _talloc_free (talloc.c:609)
==7195==    by 0x4052806: talloc_free (talloc.c:578)
==7195==    by 0x804B58A: main (bsc_nat_test.c:940)
2014-08-29 11:42:34 +02:00
Holger Hans Peter Freyther dc16bdd369 nat: Remove the entry from the list before we destroy it 2014-08-29 11:42:26 +02:00
Holger Hans Peter Freyther cd48525ecb nat: Fix compiler warning about unknown prototype
bsc_nat_ctrl.c: In function ‘set_net_cfg_cmd’:
bsc_nat_ctrl.c:360:3: warning: implicit declaration of function ‘bsc_replace_string’ [-Wimplicit-function-declaration]
   bsc_replace_string(bsc_cfg, &bsc_cfg->acc_lst_name, cmd->value);
   ^
2014-08-29 11:42:26 +02:00
Holger Hans Peter Freyther fcc30a3df7 gprs: Document the stale option in delete-gbproxy-tlli 2014-08-29 10:51:44 +02:00
Pablo Neira Ayuso dfa91df289 tests: bsc-nat: fix bsc_mgcp_rewrite() with osmux
Pass -1 to indicate no osmux, before ("b769f3c osmux: add osmux
circuit ID management and resolve NAT problems"), 0 was indicating
no osmux.
2014-08-29 09:14:37 +02:00
Jacob Erlbeck ecbd56c625 gbproxy: Fix issues found by Coverity
gbproxy_patch_bssgp: Move a check for tlli_info in front of the first
conditional that depends on it, and return immediately if it is NULL.

gbproxy_register_tlli: Initialize tlli_already_known to 0.

Fixes: Coverity CID 1232691
Fixes: Coverity CID 1232692
Sponsored-by: On-Waves ehf
2014-08-29 08:50:40 +02:00
Pablo Neira Ayuso 3ba3cf85e1 osmux: fix unchecked return value in mgcp_parse_osmux_cid()
** CID 1232804:  Unchecked return value  (CHECKED_RETURN)
/src/libmgcp/mgcp_protocol.c: 888 in mgcp_parse_osmux_cid()
2014-08-29 08:46:54 +02:00
Pablo Neira Ayuso 4ef66b1c5f osmux: fix leak in osmux_deliver()
The callback is responsible for releasing the batch message that
libosmo-netif builds.
2014-08-28 20:14:12 +02:00
Pablo Neira Ayuso caa0aace21 osmux: fix access to uninitialized memory area in scheduled_tx_*_cb
mgcp_send() needs some initialized address when printing a log message.
Nothing really serious but let's calm down valgrind.
2014-08-28 19:50:41 +02:00
Pablo Neira Ayuso 7a83f4d264 osmux: rename osmux.c to mgcp_osmux.c
So we can easily identify in the log message what refers to
libosmo-netif and what to libmgcp.
2014-08-28 19:40:51 +02:00
Pablo Neira Ayuso 91ca4a77b7 osmux: remove spamming debug log messages
It may print a debug line every 20ms, so disable this. We can still
compile this extra spamming debug from the libosmo-netif library.
2014-08-28 17:25:28 +02:00
Pablo Neira Ayuso f892763b0f osmux: use osmux port when specified from vty from engine
Instead of the hardcoded OSMUX_PORT.
2014-08-28 16:51:30 +02:00
Pablo Neira Ayuso eb7aeb19a2 osmux: print out 'osmux port' when saving configuration 2014-08-28 16:48:55 +02:00
Pablo Neira Ayuso 0fe78d39bd osmux: allow to specify the Osmux port
via mgcp section from the configuration file.
2014-08-28 16:43:38 +02:00
Pablo Neira Ayuso 36a03bdfcb osmux: display statistics once osmux input handle is released 2014-08-28 16:34:40 +02:00
Pablo Neira Ayuso 1c81045521 osmux: fix error path in osmux_handle_dummy()
This patch adds a missing goto err. While at it, reword log message.
2014-08-28 15:37:04 +02:00
Pablo Neira Ayuso 1e1558f548 osmux: remove spamming log message
Not very useful:

<000b> osmux.c:163 Osmux uses CID 1 from endpoint=7 (active=1)

Get rid of it.
2014-08-28 15:07:56 +02:00
Pablo Neira Ayuso a1efcc26cb osmux: remove redundant log message when bsc doesn't want to use Osmux
Remove redundant information log message:

<000b> bsc_mgcp_utils.c:647 BSC doesn't want to use Osmux, failing back to RTP
<000b> bsc_mgcp_utils.c:669 bsc didn't accept to use Osmux (cid=0)

One single log message is just fine. The error path already indicates
the precise reason not to accept the request to use Osmux.
2014-08-28 14:50:48 +02:00
Pablo Neira Ayuso 72b187be6d osmux: cleanup osmux input handle on release
Use osmux_xfrm_input_fini() to release the internal state of the osmux
input handle.
2014-08-28 12:47:21 +02:00
Pablo Neira Ayuso b769f3ce0b osmux: add osmux circuit ID management and resolve NAT problems
This patch includes several osmux fixes that are interdependent:

1) This adds Osmux circuit ID, this is allocated from the bsc-nat. This
   announces the circuit ID in the CRCX MGCP message. This aims to resolve
   the lack of uniqueness due to the use of endp->ci, which is local to
   the bsc. This ID is notified via X-Osmux: NUM where NUM is the osmux
   circuit ID.

2) The dummy load routines are now used to setup osmux both in bsc and
   bsc-nat to resolve source port NAT issues as suggested by Holger. The
   source port that is used from the bsc is not known until the first
   voice message is sent to the bsc-nat, therefore enabling osmux from
   the MGCP plane breaks when a different source port is used.

3) Add refcnt to struct osmux_handle, several endpoints can be using the
   same input RTP osmux handle to perform the batching. Remove it from the
   osmux handle list once nobody is using it anymore to clean it up.

4) Add a simple Osmux state-machine with three states. The initial state
   is disabled, then if the bsc-nat requests Osmux, both sides enters
   activating. The final enabled state is reached once the bsc-nat sees
   the dummy load message that tells what source port is used by the bsc.

5) The osmux input handle (which transforms RTP messages to one Osmux batch)
   is now permanently attached to the endpoint when Osmux is set up from the
   dummy load path, so we skip a lookup for each message. This simplifies
   osmux_xfrm_to_osmux().

After this patch, the workflow to setup Osmux is the following:

                    bsc                   bsc-nat
                     |                       |
                     |<------ CRCX ----------|
                     |      X-Osmux: 3       | (where 3 is the Osmux circuit ID
                     |                       |  that the bsc-nat has allocated)
                     |------- resp --------->|
                     |      X-Osmux: 3       | (the bsc confirm that it can
                     |                       |  use Osmux).
                     .                       .
                     |                       |
         setup osmux |----- dummy load ----->| setup osmux
                     |      Osmux CID: 3     |

In two steps:

1st) Allocate the Osmux Circuit ID (CID): The bsc-nat allocates an unique
     Osmux CID that is notified to the bsc through the 'X-Osmux:' extension.
     The bsc-nat annotates this circuit ID in the endpoint object. The bsc
     replies back with the 'X-Osmux:' to confirm that it agrees to use Osmux.
     If the bsc doesn't want to use Osmux, it doesn't include the extension
     so the bsc-nat knows that it has to use to RTP.

2nd) The dummy load is used to convey the Osmux CID. This needs to happen
     at this stage since the bsc-nat needs to know what source port the bsc
     uses to get this working since the bsc may use a different source
     port due to NAT. Unfortunately, this can't be done from the MGCP signal
     plane since the real source port is not known that the bsc uses is not
     known.

This patch also reverts the MDCX handling until it is clear that we need
this special handling for this case.
2014-08-28 12:08:29 +02:00
Pablo Neira Ayuso 8be171e88f osmux: move osmux socket initialization out of osmux_enable_endpoint()
In the bsc-nat side, the osmux socket initialization can be done from
the vty. This ensure that the osmux socket is available by the time the
bsc-nt receives the dummy load that confirms that the osmux flow has
been set up.

This change is required by the follow up patch. This change ensures that
the Osmux socket in the bsc-nat is already in place by the time this
receives the dummy load.
2014-08-27 16:56:08 +02:00
Pablo Neira Ayuso fd1d961af5 osmux: split osmux_handle_lookup() in several functions
This is a cleanup to allow the reuse of the new functions
osmux_handle_find_get() and osmux_handle_alloc().
2014-08-27 16:31:40 +02:00
Pablo Neira Ayuso 63650bbc5d osmux: encapsulate for osmux state information in struct mgcp_endpoint
Just a cleanup, wrap around the osmux state information in a struct.
2014-08-27 14:37:57 +02:00
Holger Hans Peter Freyther a4faeb1a79 gprs: Attempt to fix distcheck by adding the header file
Due libdbi 0.9.x being broken I didn't run make distcheck and
apparently Jacob has a similar issue and didn't run it either.
2014-08-25 16:15:04 +02:00
Harald Welte 7ff4f0e0fc port over to libosmocore include/osmocom/gsm/meas_rep.h
Back in March 2013, some structures and defines related to decoded
measurement reports have been moved from openbsc to libosmocore
(libosmocore e128f4663104ed64e33e362cff2566f36d65e658) so that they can
be used also from osmo-bts.  This finally makes gsm_lchan follow suit
for osmo-bts.
2014-08-25 09:20:33 +02:00
Holger Hans Peter Freyther 5160996d4a gprs: Link gbproxy to -lrt for clock_gettime
On older GNU libc systems we need to link to this library to
use the clock_gettime symbol.
2014-08-25 07:29:15 +02:00
Harald Welte 55dc31e781 Use port number #defines for VTY and CTRL ports
.. as defined in libosmocore
2014-08-24 17:54:49 +02:00
Harald Welte 6e68808247 move GSM_RESERVED_TMSI to libosmocore
The gb_proxy shouldn't start to open the box of pandora by including the
gsm_data_shared.h file, particularly not without defining the BSC role.

In any case, as the reserved TMSI is something that's part of the GSM
specs, and not specific to the OpenBSC implementation, it should be part
of libosmocore.
2014-08-24 17:38:18 +02:00
Harald Welte 101c5c2a3a gsm_data_shared: Add new trx_power_params for osmo-bts 2014-08-24 16:44:43 +02:00
Holger Hans Peter Freyther ddbbe695b3 Merge Jacob's GPRS GB Proxy related configs
All review feedback will be addressed _after_ the split of the
files. This is the only reasonable approach to get the split of
files merged. I didn't have the time to review all of the code
before the point of splitting.
2014-08-24 16:18:26 +02:00
Jacob Erlbeck 5f1faa3cd2 gbproxy: Move peer definitions to gb_proxy_peer.c
This patch moves the peer related definitions from gb_proxy.c to
gb_proxy_peer.c and adjusts the prefix of each global symbol to
gbproxy_:

Peer definitions (prefix adjusted to gbproxy_):
  peer_ctr_description -> gprs/gb_proxy_peer.c (static)
  peer_ctrg_desc -> gprs/gb_proxy_peer.c (static)
  *peer_by_* -> gprs/gb_proxy_peer.c
  gbproxy_peer_alloc -> gprs/gb_proxy_peer.c
  gbproxy_peer_free -> gprs/gb_proxy_peer.c
  gbprox_cleanup_peers -> gprs/gb_proxy_peer.c

Sponsored-by: On-Waves ehf
2014-08-24 16:16:40 +02:00
Jacob Erlbeck 9114bee242 gbproxy: Refactor gb_proxy.c into several files
This patch moves several functions and declarations out of gb_proxy.c
to make them reusable by other components and to separate them by
context and task.

Counter enums (prefix is changed to gbproxy_):
  enum gbprox_global_ctr -> gprs/gb_proxy.h
  enum gbprox_peer_ctr -> gprs/gb_proxy.h

Generic Gb parsing (prefix is changed to gprs_gb_):
  struct gbproxy_parse_context -> openbsc/gprs_gb_parse.h
  gbprox_parse_dtap() -> gprs/gprs_gb_parse.c
  gbprox_parse_llc() -> gprs/gprs_gb_parse.c
  gbprox_parse_bssgp() -> gprs/gprs_gb_parse.c
  gbprox_log_parse_context() -> gprs/gprs_gb_parse.c
  *_shift(), *_match() -> gprs/gprs_gb_parse.c (no prefix)
  gbprox_parse_gmm_* -> gprs/gprs_gb_parse.c (static)
  gbprox_parse_gsm_* -> gprs/gprs_gb_parse.c (static)

MI testing/parsing (prefix gprs_ added):
  is_mi_tmsi() -> gprs/gprs_utils.c
  is_mi_imsi() -> gprs/gprs_utils.c
  parse_mi_tmsi() -> gprs/gprs_utils.c

TLLI state handling (prefix is changed to gbproxy_):
  gbprox_*tlli* -> gprs/gb_proxy_tlli.c
  (except gbprox_patch_tlli, gbproxy_make_sgsn_tlli)

Message patching (prefix is changed to gbproxy_):
  gbprox_*patch* -> gprs/gb_proxy_patch.c
  gbprox_check_imsi -> gprs/gb_proxy_patch.c

Sponsored-by: On-Waves ehf
2014-08-24 16:16:40 +02:00
Jacob Erlbeck 6bd7ded71e gbproxy/test: Add test for TLLI patching
Add LLC test messages containing XID (SAPI LLGMM, U frame) and IP traffic
(SAPI LL11, UI frame).

Add a test case containing a complete SGSN session with TLLI/PTMSI
patching enabled.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:40 +02:00
Jacob Erlbeck 0d37671824 gbproxy: Use different TLLI/P-TMSI for BSS and SGSN
This patch modifies gbprox_make_bss_ptmsi() to generate a new P-TMSI
when patch_ptmsi is set in the configuration instead of using the
P-TMSI assigned by the SGSN. It modifies gbprox_make_sgsn_tlli() to
either use a foreign TLLI based on the SGSN side P-TMSI or (if there
is none) generate a random TLLI if patch_ptmsi is set. Otherwise, the
TLLI used by the BSS is used.

The seeds for the pseudo-random sequences sre set based on time
initially. Note that these are neither cryptographically safe nor
protected against collisions.

Ticket: OW#1259
Sponsored-by: On-Waves ehf
2014-08-24 16:16:40 +02:00
Jacob Erlbeck 643d5228ed gbproxy: Add context info to log messages
This mainly adds the NSEI to the messages, similar to log messages
ogf the existing gbproxy code.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:40 +02:00
Jacob Erlbeck 03ca10e863 gbproxy: Patch TLLI/P-TMSI
This patch adds code to modify TLLIs and P-TMSIs. Related counters
are also added.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck e37487e083 gbproxy: Fix TLLI state handling
This patch contains fixes for the TLLI tracking and handling.
It adds and uses gbprox_map_tlli() the map the source TLLI to the
destination TLLI while respecting whether it is current or assigned.
It removes gbprox_register_tlli() from the downlink path. It fixes
TLLI validation and disables the use of the BSSGP TLLI IE.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 3b23d639ab gbproxy: Also handle LLC non UI and LL11 messages
Currently, these messages lead to a parsing error which prevents them
from being processed any further.

This patch sets the return value of gbprox_parse_llc to 1 in these
cases and fixes a segfault which is triggered by any non-04.08
message.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 12496dd7db gbproxy: Refactor gbprox_patch_raid(), use different RAI types properly
Currently gbprox_patch_raid() updates the local MCC/MNC with every
BSS originated message, even if the RAI is an 'old' one.

This patch separates state updating and patching into 2 functions
gbprox_update_current_raid and gbprox_patch_raid. In addition, a
field named old_raid_enc is added to gbproxy_parse_context, which is
used for 'old RAI' IEs in Attach Requests and RA Update Requests.
Only the bssg_raid_enc in BSS originated message is used to update
the BSS side 'local' MCC/MNC.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 311592fc39 gbproxy: Refactor gbprox_get_detached_tlli_info
This patch splits the functionality of gbprox_get_detached_tlli_info
into 2 new functions:
  - gbprox_tlli_info_alloc to allocate an intialized and detached
    tlli_info
  - gbprox_detach_tlli_info to detach an already attached tlli_info

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 0d4236be54 gbproxy: Add 'patch-ptmsi' command to enable TLLI/P-TMSI patching
This VTY command add the following commands to the gbproxy node:
  - patch-ptmsi: Enables P-TMSI/TLLI patching
  - no patch-ptmsi: Disables P-TMSI/TLLI patching

Note that using these commands interactively can load to undefined
behavior of existing LLC connections.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 9057bc3c72 gbproxy: Track SGSN and BSS TLLI/PTMSI separately
This patch separates BSS side from SGSN side TLLI/PTMSI tracking. When
TLLI/PTMSI patching is not enabled, the corresponding states shall be
identical. The TLLI/PTMSI state has been moved into the struct
gbproxy_tlli_state and is used twice in gbproxy_tlli_info.

Since the state handling for uplink and downlink messages is
diverging, gbprox_update_state() is replaced by two functions
gbprox_update_state_dl/gbprox_update_state_ul and
gbprox_process_bssgp_message() is replaced by
gbprox_process_bssgp_dl/gbprox_process_bssgp_ul.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck c53f2a6961 gbproxy/test: Generate BSSGP and LLC layer for DTAP messages
This patch adds the functions send_bssgp_ul_unitdata(),
send_bssgp_dl_unitdata(), send_llc_ul_ui(), and send_llc_dl_ui().
They are used instead of send_ns_unitdata() in
test_gbproxy_ra_patching(). This make it easier to modify TLLI, N(U),
and other parameters.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 425afaca2f gbproxy/test: Fix BSSGP/LLC test messages
The following parts of the messages have been fixed
  - Attach Accept: checksum
  - Attach Complete: checksum
  - RA Update Accept: Use the same MS Radio Access Capabilities and
    DRX Parameters like the other messages

The N(U) of most messages have not been fixed.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 59748e653b gbproxy: Handle old and new P-TMSI/TLLI
Don't replace the current TLLI immediately, store it in an additional
'assigned_tlli' field and discard the old TLLI when both sides have
used the new one (see GSM 04.08, 4.7.1.5).

Add an Attach Complete message to test and check, whether the related
field of the corresponding tlli_info struct are set as expected
during the local TLLI validation cycle.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 3c5b40fb75 gbproxy: Update enable_patching flag on existing tlli_info
Currently the enable_patching field in tlli_info is not updated,
when an IMSI is assigned to a TLLI that is already known.

This patch fixes this in gbprox_update_state() after the call to
gbprox_update_tlli_info().

The number of APN increases and the test output file is updated
accordingly.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Jacob Erlbeck 3e23ddf88b gbproxy: Parse Detach Request messages
GSM 24.008 also allows a P-TMSI field in Detach request messages.

This patch adds gbprox_parse_gmm_detach_req() to parse Detach Request
messages which sets the ptmsi field if the IE is present.

In addition, when power_off is set to 1 (MO only), the
invalidate_tlli field is set, since Detach Request message is
expected in this case.

The second detach test (see 'RA update') is modified to use
power_off instead of relying on a Detach Accept from the network.
To make this work, the PTMSI of the RA Update Accept is fixed to
match the TLLI of the Detach Request.

Sponsored-by: On-Waves ehf
2014-08-24 16:16:39 +02:00
Harald Welte 1449c9f06f move gsm_bts_num() to gsm_data_shared.[ch]
this way we can drop a copy of this function from osmo-bts.
2014-08-24 12:47:12 +02:00
Holger Hans Peter Freyther dd588ae2ce misc: Introduce a more neutral configure option for CTRL/VTY
We started with only testing the VTY but now test VTY and CTRL
interface with this python framework and might even extend this
to SMPP. So add and "--enable-external-tests" directive which
enables the external interface tests.
2014-08-22 00:29:04 +02:00
Jacob Erlbeck 29805da6d1 gbproxy: Add gbprox_clear_patch_filter() (Coverity)
Add a separate function to clear the IMSI filter to be used instead of
gbprox_set_patch_filter(cfg, NULL, ...). Albeit it fixes a Coverity
issue (Unchecked return value), it is a false positive, since the
return value is always 0 in these cases. Nevertheless it is more
obvious what happens when an explicit clear function is called. Using
NULL as filter argument of gbprox_set_patch_filter still clears the
filter.

Fixes: Coverity CID 1231255
Sponsored-by: On-Waves ehf
2014-08-22 00:21:56 +02:00
Harald Welte d2eb5e911e fix missing '\' at end of line in Makefile.am
... causing header files to be missing from 'make dist'.

this was introduced in ba874b82be
2014-08-21 18:50:25 +02:00
Harald Welte e263187a36 Fix bsc_ctrl_node_lookup after libctrl changes
As bsc_ctrl_node_lookup() is called for each iteration,
the variables 'bts' and 'trx' are no longer static accross multiple
calls, which means we need a different way to determine if we are in the
right node while matching for a trx or a ts.
2014-08-21 18:26:36 +02:00
Harald Welte 0ad2382131 configure.ac: Depend on libosmocore 0.7.0 2014-08-21 15:56:00 +02:00
Harald Welte 74d4adcbba libctrl: Follow rename of controlif_setup -> ctrl_interface_setup 2014-08-21 15:34:28 +02:00
Harald Welte 02cc2b668a libctrl: Move bulk of node lookup code into libosmocore
Now that the bulk of the control interface node lookup has
no reference to the BSC specific data structures, we are
moving it into libosmocore.

A control interface user now only registers an optional small
node lookup function like bsc_ctrl_node_lookup()
2014-08-21 15:34:28 +02:00
Harald Welte a67455f8d8 ctrl_if: Split bsc_ctrl_cmd_handle() in two parts
The idea here is that bsc_ctrl_cmd_handle now has no dependency
at all to the BSC related data structures and thus can actually become
part of libctrl.

The new function bsc_ctrl_node_lookup however will remain bsc-specific.
2014-08-21 15:34:28 +02:00
Harald Welte ba874b82be move libctrl from openbsc to libosmoctrl (libosmocore.git) 2014-08-21 15:34:28 +02:00
Daniel Willmann 0e167fc974 systemd: Add Install section to service files
That way the services can be enabled with
> systemctl enable <service>
2014-08-21 10:19:50 +02:00
Harald Welte 248b38539d Fix control interface build after IPA rename/migration 2014-08-21 00:28:55 +02:00
Harald Welte 4a88a49c03 adopt recent IPA related symbol rename
... which happened during recent migration of IPA functionality from
libosmo-abis into libosmocore.
2014-08-20 23:47:56 +02:00
Harald Welte eb62301938 ipaccess-proxy: avoid namespace collision with libosmo-abis 2014-08-18 22:49:50 +02:00
Jacob Erlbeck 948b730fea gbproxy: Fix warnings (signed/unsigned)
Adresses:
gbproxy_test.c:1288:17: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]

Sponsored-by: On-Waves ehf
2014-08-13 11:22:03 +02:00
Jacob Erlbeck 5e68ecf3b2 gbproxy: Pass tlli_info around
This patch modifies the code to pass a pointer to the tlli_info
around once it has been acquired. To achieve this,
gbprox_register_tlli() and gbprox_update_state() are modified to
return it (if it has been found or created), and gbprox_patch_llc(),
gbprox_patch_bssgp(), and gbprox_update_state_after() are modified to
take it as parameter.

Add a new function gbprox_touch_tlli() to update timestamp and list
ordering for existing tlli_infos.

The motivation behind this patch is to make the tlli_info available to
the patching code and to avoid repeated searches for the same TLLI.

Sponsored-by: On-Waves ehf
2014-08-13 11:14:08 +02:00
Jacob Erlbeck 2dec9851bd gbproxy: Optimize gbprox_remove_stale_tllis
The current implementation of this function is O(N), where N is the
number of entries.

The new implementation is O(D), where D is the number of entries that
are going to be deleted.

Sponsored-by: On-Waves ehf
2014-08-13 10:42:27 +02:00
Jacob Erlbeck f494620c55 gbproxy/test: More TLLI expiry testing
This patch adds a combined expiry test to remove one entry by list
length and another by age.

This patch also modifies the existing age based test to register both
TLLI with a different timestamp and to remove only one of the TLLI
entries by age based expiration.

Sponsored-by: On-Waves ehf
2014-08-13 10:42:27 +02:00
Jacob Erlbeck 7b821d031a gbproxy: Don't call time() in TLLI related functions
Currently time() is called at several places to control TLLI aging.
Beside calling time() more often than necessary, the decision which
timesource is to be used is coded into the TLLI handling, and testing
complex aging scenarios is cumbersome.

This patch passes the current time as a parameter instead. The call
to time() is moved to gbprox_process_bssgp_message().

Sponsored-by: On-Waves ehf
2014-08-13 10:42:27 +02:00
Jacob Erlbeck aad32bccc0 gbproxy: Don't remove stale TLLI automatically
This patches removes the call to gbprox_remove_stale_tllis()
from gbprox_register_tlli(), so it must be called explicitly now.
The call is now done from within gbprox_update_state_after().

In addition, the TLLI cache size counter is also kept in sync when
gbprox_remove_stale_tllis is called manually. The call to
gbproxy_peer_free() in gbproxy_peer_free() is moved behind the TLLI
to allow for counter updates in gbprox_delete_tlli().

Sponsored-by: On-Waves ehf
2014-08-13 10:42:26 +02:00
Jacob Erlbeck 12828c1b30 gbproxy: Move parse_ctx logging into separate function
Sponsored-by: On-Waves ehf
2014-08-13 10:42:26 +02:00
Jacob Erlbeck c812882dbf gbproxy: Refactor gbproxy_patch_bssgp_message
This patch refactors that function by separating the actual patch
code into a new function gbproxy_patch_bssgp(), similar to
gbproxy_patch_llc(). The remaining function is renamed to
gbproxy_process_bssgp_message. The existing function
gbproxy_parse_bssgp_message() is renamed to
gbproxy_process_bssgp_message to match gbproxy_parse_llc.

Sponsored-by: On-Waves ehf
2014-08-13 10:42:26 +02:00
Jacob Erlbeck 291f0508c5 gbproxy: Test and fix IMSI/TMSI matching
This adds a test for gbprox_set_patch_filter() and
gbprox_check_imsi().

It also fixes the masking of the type field when IMSIs are checked by
using GSM_MI_TYPE_MASK (0x07) instead of 0x0f.

Sponsored-by: On-Waves ehf
2014-08-13 10:41:23 +02:00
Jacob Erlbeck 89d3d343d1 gbproxy: Track TLLI even when the IMSI is not known
Currently only TLLIs for which it is known that they may be patched
are put into the TLLI list.

This patch changes this to add TLLIs even when the IMSI is not yet
known. A enable_patching flag is added to the gbproxy_tlli_info
structure to control patching.

Note that this puts every active TLLI into the list where accesses
are O(N) currently.

Sponsored-by: On-Waves ehf
2014-08-13 10:29:09 +02:00
Jacob Erlbeck 58da91d5d0 gbproxy: Make pointers to MI const in parse/check functions
The encoded mobile identity will never be modified in
is_mi_tmsi/is_mi_imsi/parse_mi_tmsi, thus the pointer is made const.

Sponsored-by: On-Waves ehf
2014-08-13 09:57:26 +02:00
Jacob Erlbeck fb22ac52b0 gbproxy: Explicitly convert PTMSI to TLLI
This patch modifies the new_ptmsi handling by setting its two most
significant bits before using it as TLLI.

Sponsored-by: On-Waves ehf
2014-08-13 09:57:25 +02:00
Jacob Erlbeck 690768a171 gbproxy: Parse additional IMSI/PTMSI/TLLI fields
This adds parsing support for the following messages:
  - Attach Request: IMSI/PTMSI
  - Identity Response: IMSI/PTMSI
  - BSSGP: Optional TLLI IE
  - BSSGP/PAGING_PS: PTMSI

A new new_ptmsi_enc field is added for newly assigned PTMSI in
SGSN->BSS messages (instead of ptmsi_enc). The ptmsi_enc field is now
used for informational PTMSI IE in messages.

Sponsored-by: On-Waves ehf
2014-08-13 09:55:27 +02:00
Jacob Erlbeck 2db2512f4d gbproxy: Separate BSSGP parsing from patching
This adds a gbprox_parse_bssgp_message() function that contains the
parsing part of the former gbprox_patch_bssgp_message(). This
includes a call to gbprox_parse_llc().

The calls to gbprox_patch_llc(), gbprox_update_state() and
gbprox_update_state_after() have therefore been moved to
gbprox_patch_bssgp_message().

Sponsored-by: On-Waves ehf
2014-08-12 19:32:26 +02:00
Jacob Erlbeck 2bdd253d54 gbproxy: Unify TLLI tracking
This patch unifies the TLLI tracking for all LLC messages. The TLLI
state handling is moved into separate functions.

Only Detach Accept messages are taken into account to release a TLLI,
which is safe but not optimal.

Sponsored-by: On-Waves ehf
2014-08-12 19:30:48 +02:00
Jacob Erlbeck 0cee7ad2bf gbproxy: Move patching code out of the 04.08 specific functions
Currently, parsing and optionally patching is done in the same
functions (e.g. gbprox_patch_gmm_attach_req()).

This patch moves the patching code out of these functions into
gbprox_patch_llc() and just stores pointers to the relevant data
areas into parse_ctx. Consequently the len_change parameter is
removed and the _patch_ in the function's names is renamed to
_parse_. In addition, the patching_is_enabled checks and counter
increments are moved out of these functions, too.

Sponsored-by: On-Waves ehf
2014-08-12 19:29:12 +02:00
Holger Hans Peter Freyther 2c6b59ca6a sysmobts: Add variable for N(S) + 1 needed for the sysmobts
We could use the upper three bits of the ciph_state to store the
sequence number but make the code understandable first.
2014-08-09 09:43:53 +02:00
Holger Hans Peter Freyther 93dfa24f42 bsc: Add a ctrl command to send a ussdNotify for a call
Send a non-call related SS message for an active call indentified
by the CIC of that call. As an ugly hack the order of the SS
release and the invocation are changed. That was necessary for the
E71 on a TCH. The time between notify and release was just too short.
The right would be to wait for the returnResultLast but this would
involve keeping more local state. Let's see how far we get here. It
might be necessary to change the order in the other call sites as
well.
2014-08-08 21:17:36 +02:00
Holger Hans Peter Freyther 350de9fe80 ctrl: Allow the value to contain spaces. No need to split the string 2014-08-08 21:17:35 +02:00
Jacob Erlbeck da4b492f56 gbproxy/test: Fix BSSGP RESET message size
The given msg array size doesn't match the initializer's size.

Sponsored-by: On-Waves ehf
2014-08-08 09:21:45 +02:00
Jacob Erlbeck 477c69a9c5 gbproxy: Track all TLLIs (not only LOCAL)
This patch removes all checks for the TLLI type.

Sponsored-by: On-Waves ehf
2014-08-08 08:50:14 +02:00
Holger Hans Peter Freyther b773fbf335 sgsn: Make P-TMSI a local TLLI to avoid clash
Some broken equipment does not convert the P-TMSI to a Local TLLI.
This leads to the SGSN ignoring the GPRS Attach Complete message
from the phone. Proprietary SGSNs and some documentation we found
state that one should always set the two highest bits of a P-TMSI
to one. This will help broken equipment and will avoid a potential
P-TMSI/TLLI clash. The P-TMSI/Local TLLI mapping is now bijective.
2014-08-05 15:20:23 +02:00
Jacob Erlbeck 58cf664d28 gprs: Refactor gbprox_register_tlli()
Currently gbprox_register_tlli() is a rather complex function.

This patch splits it into several smaller functions to ease reviewing
and maintaining it.

Sponsored-by: On-Waves ehf
2014-08-05 15:11:11 +02:00
Holger Hans Peter Freyther 0196c9936c gbproxy/test: Test TLLI expiry
This adds a unit test for gbprox_register_tlli() and
gbprox_remove_stale_tllis().

The dump_peers() function is extended by a cfg parameter to support
a non-global gbproxy_config.

Done with Jacob
2014-08-05 15:02:06 +02:00
Jacob Erlbeck d8a7e22709 gbproxy: Remove broken TLLI comparison
This comparison bit-ored the TLLI with 0xc000 instead of 0xc000000.

Since this has never worked properly yet and since normalizing to
local TLLIs doesn't seem sensible here, the comparison is removed
entirely.

Sponsored-by: On-Waves ehf
2014-08-04 17:13:17 +02:00
Holger Hans Peter Freyther 3fa26448d1 gbproxy: Kill the global gbprox_global_patch_state struct
Move this patching state into the gbproxy_config as well.

Done by Jacob
2014-08-04 16:27:11 +02:00
Holger Hans Peter Freyther 3748ada073 gbproxy: Add a hint to the compiler that all parameters are not NULL
In these functions we assume that peer is not NULL. Add a compiler
attribute in the hope that either coverity or GCC/Clang will help
us to find a misusage.

Done with Jacob
2014-08-04 16:06:20 +02:00
Holger Hans Peter Freyther eece627799 gbproxy: Remove global state from the gbproxy
Global state prevents us from writing simple units tests for
single routines. Go through the code and add pointers to the
gbproxy configuration. Only the vty and the test code remain
using the global gbproxy instance.
2014-08-04 16:01:12 +02:00
Holger Hans Peter Freyther fa7a8bc6eb gprs: The methods moved to gprs_utils.h remove them here
Stop declaring the apn routines in here.

Done with Jacob
2014-08-04 15:44:21 +02:00
Holger Hans Peter Freyther ce1b22e817 gprs: Add testcases for the APN string/octet conversion and fix it
Create a testcase for the gprs_str_to_apn and gprs_apn_to_str
routines. While writing the testcase we noticed it is possible to
write more bytes than should have been allowed. This is fixed by
checking that the max_len is at least 1 (needed to write the first
length octet) and to do the size check before writing to the output.

Modify the signature of gprs_str_to_apn to put the length/size next
to the parameter that requires a size.

Done with Jacob
2014-08-04 15:00:54 +02:00
Holger Hans Peter Freyther 4d9fc422d2 gbproxy: Use gbprox_delete_tlli if possible
Make use of the delete routine in more places and get test coverage
for it.

Done with Jacob
2014-08-04 12:18:07 +02:00
Holger Hans Peter Freyther 7127b0295e gprs: Create a gprs_utils file and move to be shared code in there
We intend to move some of these routines to libosmocore but to avoid
a feature symbol clash we are prefixing these routines with gprs_.

Done with Jacob
2014-08-04 11:52:52 +02:00
Holger Hans Peter Freyther 1ddd9e518e gbproxy: Use gbproxy_ for all structures
The application is called gbproxy but the structures and functions
were inconsistently named as either gbprox or gbproxy. Rename all
structures to use gbproxy.

Done with Jacob
2014-08-04 11:37:50 +02:00
Holger Hans Peter Freyther b900459e96 gbproxy: The dump routines are only used by the test, move it there
Done with Jacob
2014-08-04 11:37:47 +02:00
Holger Hans Peter Freyther 16f30b5373 gbproxy: Have a clear namespace for the public functions
Done with Jacob
2014-08-04 11:37:45 +02:00
Holger Hans Peter Freyther a7027a04dd gbproxy: Remove the global rate counter and place it in the config
Move the global data into the struct and use it. gbprox_reset will
first free data and then re-initialize the structure. This code is
used by the unit test.

Done with Jacob
2014-08-04 11:37:40 +02:00
Holger Hans Peter Freyther d4d36f22ee gbproxy: Correct the method name. We work on TLLIs
Done with Jacob
2014-08-04 11:37:33 +02:00
Holger Hans Peter Freyther 18739ea32d gbproxy: Move the VTY code into the vty file and create public API
Create public accessors to the core of the peer to allow to
simplify the test and separate concerns.

Done with Jacob.
2014-08-04 11:37:28 +02:00
Andreas Eversberg 035b874fdf MNCC: Add IMSI to CALL CONFIRM message
LCR requires IMSI to correlate calls for MPTY (multi party conference)
and ECT (call transfer).
2014-08-04 08:59:16 +02:00
Andreas Eversberg 723a751e5f dyn PDCH: Cleanup of rsl_chan_activate_lchan() and users
Timing advance is stored inside lchan structure, so it is removed from
arguments. This is useful, if other actions are required prior calling
rsl_chan_activate_lchan. (like deactivating PDCH first)

The "shifted TA value" that is required by BS11 is now calculated inside
rsl_chan_activate_lchan and not by each user.

[Rebased by Holger. So some hunks were skipped as the patch
depended on Jolly's HO code]
2014-08-04 08:59:16 +02:00
Harald Welte 1011d5b505 vty: Fix interactive VTY help for silent-sms transmission 2014-08-02 09:58:52 +02:00
Harald Welte c7548a116c DB: produce a backtrace in case of a DB error
This helps us to identify where exactly in our code the DB error
originates from.
2014-08-02 09:58:52 +02:00
Holger Hans Peter Freyther 9b62580595 openbsc: Add new fields for the osmo-bts software
For the osmo-bts software we want to be able to slowly change the
output power. The state is kept inside the trx structure.
2014-07-30 18:20:51 +02:00
Max a5cae441e2 Fix some packaging mistakes detected by lintian.
Signed-off-by: Max Suraev <max.suraev@fairwaves.co>
2014-07-30 08:46:47 +02:00
Holger Hans Peter Freyther 652cdb4699 trau: Cast to remove compiler warning
rtp_proxy.c: In function ‘rtp_decode’:
rtp_proxy.c:199:8: warning: assignment from incompatible pointer type
  frame = msgb_put(new_msg, sizeof(struct gsm_data_frame));
2014-07-24 21:09:31 +02:00
Holger Hans Peter Freyther 922ef5dc86 bts: Remember the last AMR mode that we received
Not every air message contains the AMR mode so we need to remember
it to not confuse receiving equipment like AudioCodes Media Gateways.
2014-07-24 21:05:32 +02:00
Jacob Erlbeck 03551e5f3c gprs: Move LLC IE length fix to BSSGP level
This commit moves the fixing code of the length field of the LLC
information element to the BSSGP patching level since that is not a
part of LLC itself.

Sponsored-by: On-Waves ehf
2014-07-22 17:13:32 +02:00
Jacob Erlbeck 2e2650f8f3 gprs: Parse PTMSI and update TLLI accordingly
This commit adds code to parse the PTMSI in network originated
messages

  - Attach Accept,
  - Routing Area Update Accept, and
  - P-TMSI Reallocation Command (see below)

to keep track of the TLLI identifying the LLC connection.

The P_TMSI Realloc Command specific code is not being tested yet, so
a corresponding notice is logged when such a message will be
received.

NOTE:
  The gbproxy will lose the TLLI when the MS doesn't receive/use
  the message (normally the SGSN remembers the old TLLI for some time
  to avoid this kind of problem). If this happens the MS will
  probably restart the procedure and the network will have to answer
  again eventually using one of the above messages which will
  re-associate the IMSI with the TLLI before the MS can send a
  PDP Context Request message.

Ticket: OW#1192
Sponsored-by: On-Waves ehf
2014-07-22 17:11:57 +02:00
Jacob Erlbeck 35cc03f97d gprs: Use struct to pass context information
Add a struct containing context information from the parts of the
message that have been parsed already. A pointer to this (temporary)
struct is passed to parse/patch functions.

Sponsored-by: On-Waves ehf
2014-07-22 17:10:51 +02:00
Jacob Erlbeck aefaf92d1a gprs: Use shift functions instead of manual parsing
Currently the patching code directly accesses the single bytes to
parse the LLC/DTAP messages.

This patch uses the shift functions instead to parse tlv and similar
structures.

Sponsored-by: On-Waves ehf
2014-07-22 17:08:28 +02:00
Jacob Erlbeck b138106423 gprs: Add TLV parse functions
This adds a set of function that parse a single tlv, lv, tv, or v
encoded information element. They are complementary to the *_put
functions defined in libosmocore's tlv.h file. The functions update
the data and data_len fields unless they are a 'match' function and
the tag field doesn't match.

Sponsored-by: On-Waves ehf
2014-07-22 17:08:10 +02:00
Jacob Erlbeck 040b4012a7 gprs: Fix TLLI cache size computation
Currently the enabled_tllis_count field isn't always decremented when
an element is removed from the TLLI cache list.

This patch adds the missing update and also adjusts the counter
accordingly.

Sponsored-by: On-Waves ehf
2014-07-22 17:05:16 +02:00
Jacob Erlbeck aa3e334608 gprs/test: Rearrange for PTMSI parsing
Add TLLI cache output to gbprox_dump_peers() to include this info
into the test output.

Separate RA Update Req message handling from Attach Request handling.

Note: There is no test case for the P-TMSI Reallocation Command yet.

Sponsored-by: On-Waves ehf
2014-07-22 17:03:23 +02:00
Jacob Erlbeck 25049b93b1 gprs: Add counters related to LLC layer patching
This commit adds the following counters:

  - attach-reqs:   Number of Attach Request messages
  - attach-rejs:   Number of Attach Reject messages
  - tlli-cache:    Size of the TLLI cache

Sponsored-by: On-Waves ehf
2014-07-22 17:02:43 +02:00
Jacob Erlbeck 7dd498de64 gprs/vty: Add commands to manage the TLLI list
These commands manage the TLLI list used to decide whether an APN
shall be patched or not. Note that this list is (currently) only
maintained if IMSI matching is used.

VTY commands (enable node):
  show gbproxy tllis                   show all TLLI entries
  delete-gbproxy-tlli NSEI stale       purge all stale entries
  delete-gbproxy-tlli NSEI imsi IMSI   purge entry with the IMSI given
  delete-gbproxy-tlli NSEI tlli TLLI   purge entry with the TLLI given

Sponsored-by: On-Waves ehf
2014-07-22 17:02:34 +02:00
Jacob Erlbeck 7c101d922e gprs: Track IMSI/TLLI to control APN patching
This patch adds IMSI/TLLI connection tracking and uses it to control
APN patching based on the IMSI. TLLI entries can expire based on age
and/or by limiting the TLLI list size.

VTY config-gbproxy:
  no core-access-point-name                   disable APN patching
  core-access-point-name none                 remove APN if present
  core-access-point-name APN                  replace APN if present
  core-access-point-name none match-imsi RE   remove if IMSI matches
  core-access-point-name APN match-imsi RE    replace if IMSI matches
  tlli-list max-age SECONDS                   expire after SECONDS
  no tlli-list max-age                        don't expire by age
  tlli-list max-length N                      keep N entries only
  no tlli-list max-length                     don't limit list length

RE is an extended regular expression, e.g. ^12345|^23456

Ticket: OW#1192
Sponsored-by: On-Waves ehf
2014-07-22 16:56:33 +02:00
Jacob Erlbeck 006c038212 gprs: Store gbproxy patching state per peer
Currently, all patching state is stored globally in the gbproxy. Thus
the feature cannot be used safely with a concentrating gbproxy (NAT).

This patch moves the state and relevant counters to the gbprox_peer
structure. It adds code to resolve the corresponding peer when
packets are received by looking at BVCI, NSEI, and BSSGP IEs (BVCI,
RAI/LAI/LAC) when the peer is not passed to the
gbprox_patch_bssgp_message() function.

Test cases are also added for the SGSN->BSS case including test cases
with invalid identifiers.

Note that this patch should make it possible to use RAI patching at a
NAT gbproxy as long as the messages are not encrypted.

Ticket: OW#1185
Sponsored-by: On-Waves ehf
2014-07-22 16:53:41 +02:00
Jacob Erlbeck cf02eb1b20 gprs/test: Add Detach messages to test
This patch adds a Detach Request (MO) / Detach Accept sequence to the
test, followed by another (here invalid) Act PDP Context Req which
should be APN patched.

Sponsored-by: On-Waves ehf
2014-07-22 16:19:57 +02:00
Jacob Erlbeck 1166974bca gprs/test: Added GMM Info and fixed TLLI
Add a DTAP GMM Information message with an IMSI in the BSSGP header
to enable the association between IMSI and TLLI.

The TLLI of the Routing Area Update messages is set to foreign.

Sponsored-by: On-Waves ehf
2014-07-22 16:18:40 +02:00
Jacob Erlbeck 736852825a gprs: Add APN patch support for LLC/GSM messages
Patch the APN in every 'Activate PDP Context Request' message to the
value given by the 'core-access-point-name' command. If the command is
given without an APN, the whole APN IE will be removed. If the
command is being prefixed by a 'no', the APN IE remains unmodified.

The patch mode 'llc-gsm' is added to selectively enable the patching
of LLC session management messages. This is enabled implicitely by
the patch mode 'llc'.

Note that the patch mode should not be set to a value not enabling
the patching of LLC GSM messages ('llc-gsm', 'llc', and 'default' are
sufficient to patch 'Activate PDP Context Request' messages).

Ticket: OW#1192
Sponsored-by: On-Waves ehf
2014-07-22 16:07:01 +02:00
Jacob Erlbeck 91fb680236 gprs: Add MCC/MNC patch support for LLC/GMM messages
This patch extends the BSSGP patch code to also patch LLC information
elements along with MCC/MNC patching support for the following messages:

- Attach Request
- Attach Accept
- Routing Area Update Request
- Routing Area Update Accept
- P-TMSI reallocation command

Note that encrypted packets will not be patched.

Ticket: OW#1185
Sponsored-by: On-Waves ehf
2014-07-22 16:05:59 +02:00
Jacob Erlbeck 67a4445675 gprs: Implement BSSGP MCC/MNC patching
This adds a feature to patch the BSSGP MNC/MCC fields of messages going
to and coming from the SGSN. To enable this feature, the gbproxy's
VTY commands 'core-mobile-country-code' and/or
'core-mobile-network-code' must be used. All packets to the SGSN are
patched to match the configured values. Packets received from the
SGSN are patched to the corresponding values as last seen from the BSS
side.

Note that this will probably not work with a gbproxy used for several
BSS simultaneously.

Note also, that MCC/MNC contained in a LLC IE will not be patched.

Ticket: OW#1185
Sponsored-by: On-Waves ehf
2014-07-22 16:04:54 +02:00
Jacob Erlbeck fd636aed1e gprs: Use imsi field instead of imei
The wrong field has been use for the field length computation. This
hadn't any impact so far, since
  sizeof(ctx->imei) == sizeof(ctx->imsi)

This patch fixes the computation to use the right field.

Sponsored-by: On-Waves ehf
2014-07-22 15:51:55 +02:00
Jacob Erlbeck ff0d65aaf6 gprs/test: Make test output more readable
This patch makes a few changes to improve readability:

- change the sendto() hexdump to start with NS instead of BSSGP
- use more specific message descriptions instead of 'UNITDATA'
- add a title line per test

Sponsored-by: On-Waves ehf
2014-07-22 15:48:53 +02:00
Holger Hans Peter Freyther 524edccb61 Merge branch 'zecke/fixes/osmux-nat'
The osmux code doesn't work if the MGCP MGW is behind a NAT (which
is likely to be the case). The usage of endp->ci is troublesome too
not only because of the uint8_t vs. uint32_t mismatch but because
this identity is generated by the MGCP MGW and can clash. This means
that with two clients the wrong call might be connected.

The next bigger thing is that old handles are never cleared. This
code is clearly not ready for deployment.
2014-07-22 15:21:57 +02:00
Holger Hans Peter Freyther a563641d25 osmux: Drop the message in case we don't know the remote yet.
Avoid creating a bogus state that will never go away.
2014-07-22 15:15:13 +02:00
Holger Hans Peter Freyther ea7ef38734 osmux: Qualify the handle by IPv4 address _and_ port
For our usecase several different systems might be behind the
same firewall so we need to distinguish the remote by more than
the IPv4 address.
2014-07-22 15:15:13 +02:00
Holger Hans Peter Freyther 48a071e366 osmux: Extract the dummy message, find the endpoint and set rtp port
Set the remote port for the endpoint. Somehow this needs to propagate
all the way to the handle.
2014-07-22 15:15:13 +02:00
Holger Hans Peter Freyther 07ec8eebe0 osmux: Send the CI as part of the dummy to help to identify a client
We need to discover the remote port as we are likely behind a NAT.
Right now the NAT code will just send to port 1984 on the BSC but
this might not arrive at the BSC. Include the CI (in the future we
need to include the endpoint address or send the dummy to the net
port). This is just an interim solution.
2014-07-22 15:15:06 +02:00
Holger Hans Peter Freyther 25a2db018e osmux: Using the "CI" and calling it "CID" is plain wrong
The CI is a MGCP value that is counted from 0 upwards. The code
is comparing a uint8_t with a uint32_t. This will only work for
up to UINT8_MAX calls and then will silently break. The code should
probably work with the endpoint number and not the CI. For now
truncate things and hope things work.
2014-07-22 15:11:07 +02:00
Holger Hans Peter Freyther cb6ad70994 mgcp: Change API to remove memory management from the name
Jacob pointed out that "free_endp" refers to the memory of
the endpoint being freed. What we want is actually a way to
release an endpoint (and the resource it allocated) or in
the case of the testcase/testapp initialize the data structure
correctly. Introduce two names for that.
2014-07-22 15:00:52 +02:00
Holger Hans Peter Freyther 34a1976d5d Merge commit 'zecke/fixes/mgcp-transcoding'
Include the last bits of fixes for the transcoding code. These fixes
and the appropriate mgcp config are known to work.
2014-07-22 14:48:25 +02:00
Holger Hans Peter Freyther b936278b2e mgcp: Fix/test the case of a time jump and the resync
In case the sender didn't send a couple of frames we will have
a time gap that is bigger than the accepted delta. Add a new
testcase for this and update the next_time.
2014-07-22 14:48:07 +02:00
Holger Hans Peter Freyther 4c18d79475 mgcp: Add a testcase for 160->80 ptime handling 2014-07-22 14:48:07 +02:00
Holger Hans Peter Freyther c8b29083d2 mgcp: Initialise next_time in case the initial timestamp is not 0. 2014-07-22 14:48:07 +02:00
Holger Hans Peter Freyther bd4109babc mgcp: Document transcoding semantic and follow it
Transcoding from GSM to PCMA can lead to the MGCP MGW sending
two PCMA packages with the same sequence number and timestamp.
Once with the encoded audio and once completely empty.

This is because "state->dst_packet_duration" is 0 in most cases
(unless a ptime is forced) and we attempt to encode audio even
if there are not enough samples. The encode_audio return will
return 0 in that case which is not trated as an error by the
mgcp network code.

Handle rc == 0 specially and document the semantic.
2014-07-22 14:42:53 +02:00
Holger Hans Peter Freyther 91eeeae312 mgcp: Fix/test reading/writing the sequence number
The sequence number was read from the wrong place and then
the wrong byte order conversion routine was used so we ended
up wirting 0x00, 0x00 into the patched sequence number. Add
a testcase for that.
2014-07-22 14:31:35 +02:00
Holger Hans Peter Freyther 1fc1ed23b2 mgcp: Patch and Count _after_ the transcoding
When going from a ptime of 10 to 20 a lot of alignment errors
are reported. In fact the alignment check should be done before
and after the transcoding. As this is not possible right now
only do it _after_ the patching.
2014-07-22 14:31:28 +02:00
Holger Hans Peter Freyther 77ceaaf7f5 mgcp: Add a comment about the return of the function 2014-07-22 13:51:39 +02:00
Holger Hans Peter Freyther 7bcbe2a9cc Merge branch 'zecke/fixes/mgcp-transociding-tests'
Various clean-ups and extensions to the tests. Share one test
set-up routine, capture more of the API inside the output files.
2014-07-22 13:13:12 +02:00
Holger Hans Peter Freyther dd1f81512d mgcp: Make the internal state of the transcoder accessible
For the unit tests we need to look at the internal state.
2014-07-22 13:12:19 +02:00
Holger Hans Peter Freyther 4fb7e64da2 mgcp: Capture the return value of the of the transcode function 2014-07-22 13:12:12 +02:00
Holger Hans Peter Freyther 6041c8db27 mgcp: Do not use errx as finding a test failure is too hard
It took me a long time to figure out that errx just exits and
the test output didn't indicate that the application was exited
early. Use a printf and good old abort in case of a failure.
2014-07-22 13:12:05 +02:00
Holger Hans Peter Freyther 83cbac2ac0 mgcp: Re-factor testcase to separate test and setup
Separate the test from the code necessary for the setup. This is
somehow inspired by the PhExample framework of Pharo.
2014-07-22 13:11:59 +02:00
Holger Hans Peter Freyther e52ca9aad1 mgcp: Warn when the buffer is being reset due a wrong seq number
When the sample buffer is being dropped write a warning so we can
see how often this event occurs.
2014-07-22 12:41:48 +02:00
Holger Hans Peter Freyther a7992e0389 mgcp: Mention the packet duration in the error message 2014-07-22 12:41:32 +02:00
Holger Hans Peter Freyther 3d93d35a93 mgcp: Provide more information about configured endpoints 2014-07-22 12:41:25 +02:00
Holger Hans Peter Freyther c5c239f361 mgcp: Fix memory leak in the transcoding code
The GSM handle was never released. This was found using valgrind
and the leak check.

==14933== 752 bytes in 1 blocks are definitely lost in loss record 15 of 19
==14933==    at 0x4028B4C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==14933==    by 0x4130201: gsm_create (in /usr/lib/i386-linux-gnu/libgsm.so.1.0.12)
==14933==    by 0x80517AE: mgcp_transcoding_setup (mgcp_transcode.c:199)
==14933==    by 0x8049691: given_configured_endpoint.isra.1 (mgcp_transcoding_test.c:198)
==14933==    by 0x8049C11: test_transcode_result (mgcp_transcoding_test.c:328)
==14933==    by 0x8049418: main (mgcp_transcoding_test.c:582)
2014-07-22 12:40:59 +02:00
Holger Hans Peter Freyther 24fc435dad trau_mux.c: Prevent out-of-bounds read in trau_decode_fr()
Haralds patch in 9f109dfb99 only fixed
the trau_encode_fr part but the issue seems to exist in the decode
function as well. Apply the same fix.
2014-07-22 12:23:03 +02:00
Holger Hans Peter Freyther 94f83e1787 smpp: Fix small typo in the comment 2014-07-19 19:02:46 +02:00
Holger Hans Peter Freyther 0d7efef394 gbproxy: Fix the NAME in the start script...
NAME is used by start-stop-daemon to stop the process.
2014-07-17 07:31:42 +02:00
Holger Hans Peter Freyther d29b8a4745 bsc: Implement a way to relay a message to the remote MSC
This is analogue to the notification that is relayed locally and
now we have a way to relay a message back to the network.
2014-07-09 15:22:21 +02:00
Holger Hans Peter Freyther c6e9049f9c osmux: Now that we have IPv4/port we might want to consider to expire handles 2014-07-09 13:51:29 +02:00
Holger Hans Peter Freyther 9d43cee88c osmux: Mention where the data was coming from 2014-07-09 13:51:04 +02:00
Holger Hans Peter Freyther 7239f574aa osmux: Be accurate. The label has been already created 2014-07-09 13:50:56 +02:00
Holger Hans Peter Freyther 6b0ba01bf3 osmux: Make sure to always use the right dummy sending method
Make sure to re-use the right method for nat traversal. Found
by Roch while looking at traces.
2014-07-08 13:08:00 +02:00
Holger Hans Peter Freyther 768580b3ec bsc: Use the word core network and not backbone. 2014-07-08 12:48:49 +02:00
Holger Hans Peter Freyther 891b0a857d osmux: Remove extra newline from the osmux log message
<000b> osmux.c:177 Cannot find endpoint with cid=7
!
<000b> osmux.c:253 Cannot find an endpoint for circuit_id=7

The extra newline and '!' do not provide any extra value and
make reading the output more difficult. Just remove it.
2014-07-08 09:08:34 +02:00
Jacob Erlbeck 627e7d9bfe gprs/test: Increase stderr log level
Enable the generation of more log messages.

Sponsored-by: On-Waves ehf
2014-07-07 20:07:34 +02:00
Holger Hans Peter Freyther 2840b3f6c3 gbproxy_test: Provide enough disabled categories to please valgrind
An empty log_info is not enough. We need to make sure that at least
DLGLOBAL is present. Instead of doing that make sure that we have
enough entries.

==26163== Conditional jump or move depends on uninitialised value(s)
==26163==    at 0x403B289: osmo_vlogp (logging.c:290)
==26163==    by 0x403B3DA: logp2 (logging.c:339)
==26163==    by 0x804D027: gbprox_relay2bvci (gb_proxy.c:347)
==26163==    by 0x804D3CF: gbprox_rx_sig_from_sgsn (gb_proxy.c:589)
==26163==    by 0x804DBFC: gbprox_rcvmsg (gb_proxy.c:685)
==26163==    by 0x4052CB0: gprs_ns_process_msg (gprs_ns.c:669)
==26163==    by 0x4052F70: gprs_ns_rcvmsg (gprs_ns.c:1053)
==26163==    by 0x804BB49: gprs_process_message (gbproxy_test.c:488)
==26163==    by 0x804BC4C: send_ns_unitdata (gbproxy_test.c:210)
==26163==    by 0x804BDE8: send_bssgp_reset_ack (gbproxy_test.c:243)
==26163==    by 0x804B54F: main (gbproxy_test.c:863)
==26163==
2014-07-07 19:48:14 +02:00
Holger Hans Peter Freyther 461966b8ef mgcp: Ignore the transcoding test 2014-07-07 19:24:43 +02:00
Holger Hans Peter Freyther 8d998a713e mgcp: Verify that the force-ptime is written back to the file
When the command was added it was not verified that. Add a very
basic MGCP VTY test and test that the string appears in the config.
2014-07-07 19:24:34 +02:00
Holger Hans Peter Freyther 2947411383 mgcp: Fix documentation issue in the force-ptime command
<command id='rtp force-ptime (10|20|40)'>
        <param name='10' doc='(null)' />
        <param name='20' doc='(null)' />
        <param name='40' doc='(null)' />
2014-07-07 19:24:28 +02:00
Holger Hans Peter Freyther 983c99113d rtp: Share the rtp header between the proxy and the mgcp code 2014-07-07 19:24:21 +02:00
Holger Hans Peter Freyther 6019b5a508 nat: Fix the documentation issue with the osmux command
Documentation error (missing docs):
<command id='osmux (on|off)'>
        <param name='off' doc='(null)' />
2014-07-07 19:24:14 +02:00
Holger Hans Peter Freyther 84db98fdbe gbproxy_test: Reset the gbproxy before we reset GPRS NS
The peers are (talloc) children of the GPRS NS. This means the
peers (and the rate counters) are currently being deleted twice.

==23446== Invalid write of size 4
==23446==    at 0x403C243: rate_ctr_group_alloc (linuxlist.h:66)
==23446==    by 0x4050974: gprs_nsvc_create (gprs_ns.c:209)
==23446==    by 0x405320D: gprs_ns_instantiate (gprs_ns.c:1330)
==23446==    by 0x804ABEB: main (gbproxy_test.c:666)
==23446==  Address 0x4300694 is 52 bytes inside a block of size 784 free'd
==23446==    at 0x4029DA8: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==23446==    by 0x4041B9D: _talloc_free (talloc.c:609)
==23446==    by 0x4043292: talloc_free (talloc.c:578)
==23446==    by 0x40532D3: gprs_ns_destroy (gprs_ns.c:1363)
==23446==    by 0x804ABD7: main (gbproxy_test.c:660)
2014-07-07 19:22:02 +02:00
Daniel Willmann 46d13268b8 gprs_llc: Prevent llme_alloc/lle_init from reading invalid memory
Make the llc_default_params structure from which data is initialized
large enough. Otherwise address sanitizer complains with out-of-bounds
reads.

Only SAPIs 1, 2, 3, 5, 7, 8, 9, 11 are defined for GPRS but the
struct gprs_llc_llme includes NUM_SAPIS lle's and they are populated
from the llc_default_params structure.
2014-07-07 19:17:54 +02:00
Daniel Willmann 8a485f0bec libbsc, osmo-bsc{, _nat}: Prevent unaligned access when casting TLVP_VAL
foo = *((uintXX_t *) TLVP_VAL(...) can lead to unaligned access. To
prevent that use tlvp_valXX_unal() to get the values.
2014-07-07 19:04:32 +02:00
Holger Hans Peter Freyther 99a20d6be1 gbproxy_test: Simplify the test setup by sharing code 2014-07-07 15:06:21 +02:00
Jacob Erlbeck 7fb42dbd27 gprs/test: Add additional gbproxy tests
This adds a test case with several messages to test BSSGP patching.
New messages:

- BSSGP/DTAP Attach Request
- BSSGP/DTAP Attach Accept
- BSSGP/DTAP Routing Area Update Request
- BSSGP/DTAP Routing Area Update Accept
- BSSGP/DTAP Activate PDP Context Request
- BSSGP SUSPEND
- BSSGP SUSPEND ACK

Sponsored-by: On-Waves ehf
2014-07-07 15:06:12 +02:00
Jacob Erlbeck 2e038f7336 gprs/test: Add connect_sgsn() function
This function abstracts identical code sequences that are used at
multiple places.

Sponsored-by: On-Waves ehf
2014-07-07 15:06:06 +02:00
Jacob Erlbeck b32d3c041b gprs/test: Remove verbose parameter of gbprox_dump_* functions
This parameter is not used (the methods are always called with an
argument of 1 in the third position). Thus the parameter is removed
completely.

Sponsored-by: On-Waves ehf
2014-07-07 15:05:59 +02:00
Holger Hans Peter Freyther b115cb6655 db: Use ulonglong to access the database for sqlite3
The type in the schema is integer but we need to use ulonglong to
read it as otherwise the read will fail.

DBI: -7: The requested variable type does not match what libdbi thinks it should be
2014-07-03 14:12:24 +02:00
Harald Welte 9f109dfb99 trau_mux.c: Prevent out-of-bounds read in trau_encode_fr()
found by -fsanitize=address the last iteration of the loop, where i ==
259 and o == 260.  It is read out-of-bounds but the content is never
used.
2014-06-23 09:49:29 +02:00
Holger Hans Peter Freyther db0caf239e nitb: Only print channel activations once in show statistics
openbsc_vty_print_statistics will already print these counters
for us. No need to print them again.
2014-06-18 08:34:54 +02:00
Holger Hans Peter Freyther 421365eeaa mgcp: Allow to batch more than four messages 2014-06-16 14:12:02 +02:00
Jacob Erlbeck 8f50359ebf gprs: Use area terms LAI/RAI as defined in GSM 03.03
Currently the terms 'Routing area code' (RAC) and 'Location area
code' (LAC) are used in several places where 'Routing area
identification' (RAI) or 'Location area identification' (LAI) are
meant in fact.

This patch replaces RAC/LAC by RAI/LAI and 'code' by 'identification'
at these places.

Note that RAI := MCC MNC LAC RAC, and LAI := MCC MNC LAC (see GSM
03.03, sections 4.1 and 4.2).

Sponsored-by: On-Waves ehf
2014-06-15 19:23:38 +02:00
Jacob Erlbeck cb04ca2fc3 mgcp: Fix SDP formatting of fmtp_extra (Coverity)
Currently when ftmp_extra is set, a doubled a=rtpmap line is emitted
instead of the fmtp_extra info.

This patch fixes replaces the formerly copied and pasted but not
modified snprintf parameters by the correct ones.

Fixes: Coverity CID 1220873
Sponsored-by: On-Waves ehf
2014-06-15 19:15:32 +02:00
Jacob Erlbeck bebf92d7f0 mgcp/test: Add test case using the fmtp_extra info
Add tests setting the fmtp_extra field to check the response
generation. This triggers a bug found by Coverity.

Addresses: Coverity CID 1220873
Sponsored-by: On-Waves ehf
2014-06-15 19:15:09 +02:00
Holger Hans Peter Freyther 4e5f93ccdc proxy: Annotate the switch/case/fall through
Use the same comment as some lines earlier in that file.

Fixes: Coverity CID 1040737
2014-06-12 11:32:25 +02:00
Holger Hans Peter Freyther b07df2bfd4 bsc: Do not use strdup on argv parameter
Fixes: Coverity CID 1206578
2014-06-12 11:19:38 +02:00
Jacob Erlbeck efd266ae12 Merge remote-tracking branch 'origin/jerlbeck/features/mgcp-transcoding' 2014-06-05 14:45:07 +02:00
Jacob Erlbeck 452c183c5e mgcp: Set net_end audio params in recvonly mode
Currently, if there is no SDP data in the MGCP message received from
the net, the fields containing audio encoding information are not set
in net_end. So in recvonly mode transcoding would not be set up
correctly.

This patch changes the implementation of the code handling CRCX and
MDCX to use the codec signalled in the MGCP local connection options
(field 'a:') if there isn't any SDP data. This is only halfway
negotiation, because the codec is used blindly and not matched
against the supported ones.

Sponsored-by: On-Waves ehf
2014-06-05 14:09:52 +02:00
Jacob Erlbeck 909fac6689 mgcp: Move transcoding to libmgcp
This patch moves the files relevant to transcoding from
src/osmo-bsc_mgcp to src/libmgcp and src/include/openbsc. Makefiles
and include directives are being updated accordingly.

Sponsored-by: On-Waves ehf
2014-06-05 14:08:53 +02:00
Jacob Erlbeck 84a45cbf83 mgcp/test: Add test cases for transcoding and repacking
This patch adds test cases for transcoding and repacking.

Sponsored-by: On-Waves ehf
2014-06-05 14:08:53 +02:00
Jacob Erlbeck 07886d9b0a mgcp: Extend the CLI transcoding tool by ptime conversion
This modification allows it to set the number of samples per packet
that is written to the output.

Sponsored-by: On-Waves ehf
2014-06-05 14:08:53 +02:00
Jacob Erlbeck 42a833e89f mgcp: Add packet size (ptime) conversion
The current transcoder implemenation always does a 1:1 recoding
concerning the duration of a packet. So RTP timestamps and sequence
numbers are not modified.

This is not sufficient in some cases, e.g. when the BTS does only
allow for a single fixed ptime.

This patch decouples encoding from decoding and moves the decoded
samples to the state structure so that samples can be combined or
drain according to the packaging of incoming and outgoing packets.

This patch incorporates parts of Holger's experimental fixes in
0e669e05^..9eba68f9.

Ticket: OW#1111
Sponsored-by: On-Waves ehf
2014-06-05 14:08:45 +02:00
Jacob Erlbeck 136a319e91 mgcp: Add CLI tool to test audio conversion
This tool uses mgcp_transcode.c to convert audio data from stdin to
stdout.

Sponsored-by: On-Waves ehf
2014-06-05 14:00:47 +02:00
Jacob Erlbeck 239a853f40 mgcp: Add RTP audio transcoding
This patch implements audio transcoding between the formats GSM,
PCMA, L16, and optionally G.729.

The feature needs to be enabled by using the autoconf option
'--enable-mgcp-transcoding'. In this case mgcp_transcode.c will
be compiled and linked to osmo-bsc_mgcp, and the transcoding
functions provided will be registered as processing callbacks.

If G.729 support is required, libcg729 needs to be installed and
'--with-g729' must be passed to ./configure.

Ticket: OW#1111
Sponsored-by: On-Waves ehf
2014-06-05 14:00:47 +02:00
Jacob Erlbeck 997e1e8e9d mgcp: Only include SDP lines with valid content
Don't show media related lines if the payload type has not been set.
Don't show a 'a=rtpmap' line if the audio_name has not been set.

This patch unifies the SDP generation of create_response_with_sdp()
and send_msg().

Sponsored-by: On-Waves ehf
2014-06-05 14:00:46 +02:00
Jacob Erlbeck 168ca00b02 mgcp: Add a function to get media info for MGCP responses
This patch adds the get_net_downlink_format_cb() callback to provide
payload_type, subtype_name, and fmtp_extra suitable for use in a MGCP
response sent to the network. Per default, the BTS side values are
returned since these must be honoured by the net peer when sending
audio to the media gateway (unless transcoding is done).

Sponsored-by: On-Waves ehf
2014-06-05 14:00:46 +02:00
Jacob Erlbeck 845d0054b4 mgcp: Add audio info fields to struct mgcp_rtp_end
This patch adds the fields channels, subtype_name, and audio_name to
the struct. The field audio_name contains the full string that has
been used for the last part of a SDP a=rtpmap line. The others contain
decoded parts of that string. If no a=rtpmap line has been given
(e.g. because dynamic payload types are not used), values are
assigned when the payload type matches one of the predefined ones
(GSM, G729, PCMA).

The patch also moves the audio_name parsing code to a dedicated
set_audio_info() function.

Sponsored-by: On-Waves ehf
2014-06-05 14:00:41 +02:00
Jacob Erlbeck a0d64ce063 mgcp: Add callbacks for payload processing
This patch adds the callbacks rtp_processing_cb and
setup_rtp_processing_cb to mgcp_config to support arbitrary RTP
payload processing.

Sponsored-by: On-Waves ehf
2014-06-05 12:19:46 +02:00
Jacob Erlbeck b492d39177 gprs: Separate LLC parsing from LLC state handling
Currently LLC parsing is part of gprs_llc.c which needs large parts
of the SGSN code parsing to fulfill its link dependencies.

This patch moves the functions that just do plain parsing, dumping,
and FCS computation to a different file to avoid these dependencies
if LLC stateful processing is not needed. It also exposes
struct gprs_llc_hdr_parsed and enum gprs_llc_cmd publically.

Sponsored-by: On-Waves ehf
2014-06-04 16:29:30 +02:00
Jacob Erlbeck def0391ec5 gprs/test: Use valid MCC/MNC for BVC RESET
The code currently uses an encoded sequence of (hex) 10 20 30 40 50
60 as RAI, for which no bijective mapping to the set of
representations MCC-MNC-LAC-RAC exists.

This patch changes the hard-coded RAI to 11 22 33 40 50 60 which maps
to 112-332-16464-96 (and vice-versa).

Sponsored-by: On-Waves ehf
2014-06-04 16:20:46 +02:00
Holger Hans Peter Freyther cc84c9535c osmux: Fix the VTY online help in the osmux command
This should fix most of:

Documentation error (missing docs):
<command id='osmux (on|off)'>
        <param name='off' doc='(null)' />

Documentation error (missing docs):
<command id='osmux batch-factor &lt;1-4&gt;'>
        <param name='&lt;1-4&gt;' doc='(null)' />

Documentation error (missing docs):
<command id='osmux (on|off)'>
        <param name='off' doc='(null)' />

Documentation error (missing docs):
<command id='osmux (on|off)'>
        <param name='off' doc='(null)' />

Documentation error (missing docs):
<command id='osmux batch-factor &lt;1-4&gt;'>
        <param name='&lt;1-4&gt;' doc='(null)' />
2014-06-03 13:36:42 +02:00
Holger Hans Peter Freyther 889710c890 Merge branch 'hfreyther/fixes/channel-release-handling'
The patches were posted to the ML but didn't receive review
there. At the time I merge the change I did a Location Updating
Request and the channel was released in a successful way.
2014-06-03 13:25:02 +02:00
Holger Hans Peter Freyther 0e4e73a891 rsl: Check if the channel is active and then start the channel release
In case we receive ERROR INDICATION and CONNECTION FAILURE we only
want to RF Channel Release the lchan once. This code is more simple
and should work as reliable as the previous commit.
2014-06-03 12:51:16 +02:00
Holger Hans Peter Freyther 1e93b79cce rsl: Avoid double channel release procedure in error conditions
When we receive an ERROR INDICATION and CONNECTION FAILURE we
might call rsl_rf_chan_release multiple times. The channel release
handling is still a bit messy and there too many paths that lead
to the call.

1.) In case we receive an ERROR INDICATION for SAPI=3. A RLL
error signal will be emitted that leads to the release of the
channel through the SMS code in case of the NITB.  The call to
rsl_rf_chan_release might be a double release.

2.) In case a CONNECTION FAILURE is received when the release
process has already been started we would unconditionally
call rsl_rf_chan_release as well.

Because the lchan state is changed by the callers of the
rsl_rf_chan_release we can not move the state checking into this
code but need to do it in the caller. The issue was seen in a trace
from Rhizomatica and I created the DoubleRelease.st to re-produce
the issue and verified that we have no duplicate RF Channel Releses.

The other option would be to introduce a new state to track
the release process and see if we have already released SAPIs
deactivated the SACCH or such. We can not simply look at these
as for a channel that fails to activate they will be null already.
2014-06-03 12:51:16 +02:00
Holger Hans Peter Freyther f0405068d8 lchan: Speculative "fix" for error and late reply
Looking at the code it seemed possible that a channel would
transition from BROKEN to NONE. Or worse from NONE to BROKEN.
Start the timer _after_ the channel has been released.
2014-06-03 12:51:16 +02:00
Holger Hans Peter Freyther 5308fffc53 bsc: Introduce a local notification scheme for the CTRL interface
Make it possible to inform local CTRL connections about some state.
The TRAP will be only sent to local connections. The notification
text may not contain spaces.
2014-05-31 08:42:29 +02:00
Holger Hans Peter Freyther 4f0381b1c3 mgcp: Address scanf issue already found by cppcheck and now ASAN
Use the right size for scanf.

=================================================================
==6106== ERROR: AddressSanitizer: unknown-crash on address 0xbffff4b0 at pc 0xb69d87fd bp 0xbffff248 sp 0xbffff21c
WRITE of size 65 at 0xbffff4b0 thread T0
    #0 0xb69d87fc (/usr/lib/i386-linux-gnu/libasan.so.0.0.0+0xa7fc)
    #1 0xb69d9239 (/usr/lib/i386-linux-gnu/libasan.so.0.0.0+0xb239)
    #2 0xb69d92d6 (/usr/lib/i386-linux-gnu/libasan.so.0.0.0+0xb2d6)
    #3 0x804f151 (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x804f151)
    #4 0x80531e8 (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x80531e8)
    #5 0x8051e6f (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x8051e6f)
    #6 0x8049b0a (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x8049b0a)
    #7 0x804bd9e (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x804bd9e)
    #8 0xb6778a62 (/lib/i386-linux-gnu/i686/cmov/libc-2.18.so+0x19a62)
    #9 0x8049330 (/home/ich/source/gsm/openbsc/openbsc/tests/mgcp/mgcp_test+0x8049330)
Address 0xbffff4b0 is located at offset 416 in frame <parse_sdp_data> of T0's stack:
  This frame has 8 object(s):
    [32, 36) 'audio_payload'
    [96, 100) 'payload'
    [160, 164) 'channels'
    [224, 228) 'ptime'
    [288, 292) 'port'
    [352, 368) 'ipv4'
    [416, 480) 'audio_name'
    [512, 576) 'audio_codec'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are*
2014-05-28 17:00:56 +02:00
Holger Hans Peter Freyther b691bf1d54 channel_test: Return a positive number to claim it was paged
This addresses an ASAN issue where the request was already deleted
by our callback function.

(gdb) where
 #0  0xb69e7810 in __asan_report_error () from /usr/lib/i386-linux-gnu/libasan.so.0
 #1  0xb69e0aff in __asan_report_store4 () from /usr/lib/i386-linux-gnu/libasan.so.0
 #2  0x0804ea64 in subscr_send_paging_request (subscr=subscr@entry=0xb5103cb0)
     at gsm_subscriber.c:212
 #3  0x0804edac in subscr_get_channel (subscr=subscr@entry=0xb5103cb0, type=type@entry=2,
     cbfn=cbfn@entry=0x804969d <subscr_cb>, param=param@entry=0x2342) at gsm_subscriber.c:246
 #4  0x080498f7 in main (argc=1, argv=0xbffff804) at channel_test.c:77

Breakpoint 3, subscr_paging_dispatch (hooknum=hooknum@entry=101, event=event@entry=200,
    msg=msg@entry=0x1323, data=<optimized out>, data@entry=0x8063900 <s_conn>,
    param=<optimized out>, param@entry=0xb5103cb0) at gsm_subscriber.c:126
126		llist_del(&request->entry);

 (gdb) b llist_del
 (gdb) bt
 #0  subscr_paging_dispatch (hooknum=hooknum@entry=101, event=event@entry=200,
     msg=msg@entry=0x1323, data=<optimized out>, data@entry=0x8063900 <s_conn>,
     param=<optimized out>, param@entry=0xb5103cb0) at gsm_subscriber.c:126
 #1  0x0804e8a9 in subscr_paging_cb (hooknum=101, event=200, msg=0x1323,
     data=0x8063900 <s_conn>, param=0xb5103cb0) at gsm_subscriber.c:187
 #2  0x080497e9 in paging_request (bts=0xb5b03e70, subscriber=subscriber@entry=0xb5103cb0,
     type=2, cbfn=cbfn@entry=0x804e881 <subscr_paging_cb>, data=data@entry=0xb5103cb0)
     at channel_test.c:51
 #3  0x0804ea39 in subscr_send_paging_request (subscr=subscr@entry=0xb5103cb0)
     at gsm_subscriber.c:207
 #4  0x0804edac in subscr_get_channel (subscr=subscr@entry=0xb5103cb0, type=type@entry=2,
     cbfn=cbfn@entry=0x804969d <subscr_cb>, param=param@entry=0x2342) at gsm_subscriber.c:246
 #5  0x080498f7 in main (argc=1, argv=0xbffff804) at channel_test.c:77
(gdb) q
2014-05-28 17:00:48 +02:00
Holger Hans Peter Freyther f6b61e6154 mgcp: Use #pragma once instead of a possible clashing #ifdef
The filename is mgcp_internal.h but the define refers to MGCP_DATA.
Avoid having a potential clash by using the #pragma once option.
2014-05-26 08:17:45 +02:00
Holger Hans Peter Freyther ee41ecff98 rsl: Remove obsolete FIXME comment.
The lchan state is set to none either on RF Channel Release ACK
or in case of an error after the error timer has expired.
2014-05-26 08:17:35 +02:00
Holger Hans Peter Freyther 4f200491ff osmux: Fix potential memory leak in the msgb handling 2014-05-22 16:46:11 +02:00
Holger Hans Peter Freyther 1cc5ff8e19 mgcp: Add proper length checking for line handling
In ae1997248c the handwritten tokenizer
was replaced with strtok_r. As part of this change the structural
checking of MGCP parameters was stopped. This means that a code like
"line + 3" might access beyond the first NUL and be possibly behind
the msgb. Manually add size checking again. Manually jumping to the
error label is not possible anymore as it has been removed. The result
is that invalid lines will be skipped. This is matching the general
approach by the IETF RFCs to be permissive in data being received.
2014-05-22 16:46:11 +02:00
Holger Hans Peter Freyther f259bd8359 mgcp: Remove excessive logging for each frame 2014-05-22 14:42:09 +02:00
Pablo Neira Ayuso cab6e7528c mgcp: add voice muxer support
This patch adds the voice muxer. You can use this to batch RTP
traffic to reduce bandwidth comsuption. Basically, osmux transforms
RTP flows to a compact batch format, that is later on decompacted
to its original form. Port UDP/1984 is used for the muxer traffic
between osmo-bsc_nat and osmo-bsc_mgcp (in the BSC side). This
feature depends on libosmo-netif, which contains the osmux core
support.

Osmux is requested on-demand via the MGCP CRCX/MDCX messages (using
the vendor-specific extension X-Osmux: on) coming from the BSC-NAT,
so you can selectively enable osmux per BSC from one the bsc-nat.cfg
file, so we have a centralized point to enable/disable osmux.

First thing you need to do is to accept requests to use Osmux,
this can be done from VTY interface of osmo-bsc_nat and
osmo-bsc_mgcp by adding the following line:

mgcp
  ...
  osmux on
  osmux batch-factor 4

This just initializes the osmux engine. You still have to specify
what BSC uses osmux from osmo-bsc_nat configuration file:

...
 bsc 1
  osmux on
 bsc 2
  ...
 bsc 3
  osmux on

In this case, bsc 1 and 3 should use osmux if possible, bsc 2 does
not have osmux enabled.

Thus, you can selectively enable osmux depending on the BSC, and
we have a centralized point for configuration from the bsc-nat to
enable osmux on demand, as suggested by Holger.

At this moment, this patch contains heavy debug logging for each
RTP packet that can be removed later to save cycles.

The RTP ssrc/seqnum/timestamp is randomly allocated for each MDCX that
is received to configure an endpoint.
2014-05-22 14:39:16 +02:00
Daniel Willmann 038f97a69f bsc_hack: Don't strdup the string arguments
Fixes CIDs #1206577, #1206578
2014-05-22 14:34:24 +02:00
Daniel Willmann 45fcb85236 rtp_proxy: Prevent out-of-bounds read in rtcp_sdes_cname_mangle
In rtcp_sdes_cname_mangle when skipping over additional zeroes at the
end of a chunk we should not read past the actual message (rtcp_end).

Fixes CID #1206579
2014-05-22 14:31:09 +02:00
Harald Welte a4c63b0cdb chan_alloc: Fall-back to TCH/H, if we cannot find a TCH/F
I'm not entirely sure if this is the best approach.  However,
there are phones that send a RACH request for TCH/F on MO calls, even
though they actually do support TCH/H channels.
2014-05-19 08:31:39 +02:00
Harald Welte ec75798644 rtp_proxy.c: Correctly set msg_type to GSM_TCH_FRAME_AMR on AMR
When forwarding AMR from RTP towards the MNCC interface, we need to set
the apropriate msg_type.  Before this patch it was unitialized,
resulting in improper/unknown msg_types of messages on the MNCC
interface.
2014-05-18 22:23:15 +02:00
Harald Welte a87f8f9891 rtp_proxy: Simplify AMR handling
AMR frames on the MNCC interface are slightly different as they
include a single-byte payload_length indicator prior to the actual
payload.  Commit 3f201ac89952b68d05c0bb6cb41932b9cd898b19 introduced
more special-case handling than required, so I'm trying to simplify
things again.

We now also use msgb_put() more consistently, i.e. always put
before actually using the data, and use the return value of msgb_put()
rather than first making assumptions about the pointer, writing to it
and then calling msgb_put().
2014-05-18 22:23:15 +02:00
Andreas Eversberg d8967f76a5 Add support for AMR frames to MNCC/RTP interface
AMR rate is currently fixed to 5.9k.
2014-05-18 22:23:15 +02:00
Andreas Eversberg 72c0dbd753 bsc_api/NITB: If TCH/H channel is used, indicate it to bsc_api
If we don't do this, OsmoNITB will send an assignment command from
a TCH/H to another TCH/H without any need.
2014-05-18 22:23:15 +02:00
Andreas Eversberg a4d0e3cc6b Add check to tch_map(), if RTP sockets exist 2014-05-18 22:23:15 +02:00
Holger Hans Peter Freyther 20f6e946e1 ctrl: Use CTRL_CMD_DEFINE_STRUCT in CTRL_CMD_DEFINE_RANGE
Jacob pointed out that I didn't convert CTRL_CMD_DEFINE_RANGE.
This patch is doing it now.
2014-05-15 17:28:03 +02:00
Holger Hans Peter Freyther b66f158b05 ctrl: Reduce code duplication and add a define to create the struct
This has been pointed out by Jacob and removes two more duplicates
of the struct. For the unused CTRL_CMD_DEFINE_STRING macro there
will be no verify command.
2014-05-15 15:50:55 +02:00
Holger Hans Peter Freyther 6e36255221 ctrl: Remove the param parameter as it was never used/implemented 2014-05-15 15:50:55 +02:00
Holger Hans Peter Freyther 1159005ae0 ctrl: Introduce a macro for read-only attributes and use it
Certain attributes are read-only. Add a macro to make it more
easy to define those.
2014-05-15 15:30:52 +02:00
Jacob Erlbeck 268b2e6544 ctrl: Fix handling of missing replies
Currently, if a CTRL method does not set the reply, an error is
logged ("cmd->reply has not been set"). It even complains when the
function implementing the command returns CTRL_CMD_HANDLED, where
a reply text is not needed.

This patch changes the logging level from ERROR to NOTICE. The logging
is now only done, when the retry has not been set and the
implementation returns either CTRL_CMD_ERROR or CTRL_CMD_REPLY. So
in these cases the reply field must be set.

This fixes the generation of log messages when doing NAT ctrl command
forwarding.

Ticket: OW#1177
Sponsored-by: On-Waves ehf
2014-05-15 14:22:56 +02:00
Holger Hans Peter Freyther 47d8f02c06 misc: Use the right mailinglist address for OpenBSC 2014-05-15 12:26:54 +02:00
Jacob Erlbeck 543e11496e contrib/rtp: Use payload data files directly by gen_rtp_header
This adds a --frame-size option to read payload binary files with a
fixed frame size directly. The file must not contain RTP headers.
In addition '--rate' and '--duration' can be used to configure the
timing.

Sponsored-by: On-Waves ehf
2014-05-09 16:38:28 +02:00
Nikola Kolev 10bad1031e ipa: Fix the compilation of ipaccess-find on FreeBSD
FreeBSD does not offer the SO_BINDTODEVICE option. The closest
thing is the IP_RECVIF option and this is used here now.
2014-05-09 04:40:23 +02:00
Nikola Kolev b9f45987b3 bsc: Fix compilation on FreeBSD
FreeBSD uses POSIX netinet/in.h for representing socket addresses
data types.

[Holger removed the #ifdef and changed the order of includes to
have specific ones first and system includes later]
2014-05-09 04:38:58 +02:00
Holger Hans Peter Freyther abddd6aa44 nat/bsc: Check proto before calling ipaccess_rcvmsg_base
The code in the BSC/NAT called ipaccess_rcvmsg_base without
checking if the protocol is IPA. This lead the BSC to respond
to SCCP messages with an "ID ACK". From a quick look neither
the code of ipaccess_rcvmsg_base in OpenBSC nor the copy of
libosmo-abis ever checked the protocol header. So this code
has been wrong since initially being created in 2010.
2014-05-06 06:50:39 +02:00
Holger Hans Peter Freyther 3c9068f185 db: Fix next fall-out with make distcheck 2014-05-01 07:53:42 +02:00
Holger Hans Peter Freyther f242e7afef db: Fix fall-out with the subscriber removal in the subscriber deletion code
The sender_id is gone so the code that attempted to delete SMS
didn't work anymore. Delete the SMS based on src_addr or the
dest_addr.

Fixes:
======================================================================
ERROR: testSubscriberAddRemove (__main__.TestCtrlNITB)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/ctrl_test_runner.py", line 379, in testSubscriberAddRemove
    r = self.do_set('subscriber-delete-v1', '2620345')
  File "tests/ctrl_test_runner.py", line 114, in do_set
    return self.recv_msgs()[id]
KeyError: 1002
2014-04-30 20:51:28 +02:00
Holger Hans Peter Freyther edfdc9829c Merge branch 'zecke/features/sms-db-changes'
This branch allows a SMPP user to fully specify the sender id. It
requires a change in schema, database migration code and exposed
some issues in the libdbi and the sqlite3 driver.
2014-04-30 15:32:41 +02:00
Holger Hans Peter Freyther 6114401b9b db: Add testcase for the db migration. 2014-04-30 15:31:57 +02:00
Holger Hans Peter Freyther e7cc9aa447 sms: Add code to migrate the database to the new schema
This is mostly based on Alexander's migration code. The code
adds transaction handling and some sanity checks and cleanups
to the code. We made the decision to fork the sms_from_result
method and freeze it to that version. This way sms_from_result
can move forward without having to deal with legacy.
2014-04-30 15:31:57 +02:00
Alexander Chemeris ca7ed2d2df sms: Do not store received id in the SMS database.
That was a bad idea from the very beginning. A visible result of this is a wrong
SMS routing when you change subscriber extensions, while having queued SMS. It's
also a very wrong thing from the code layering perspective.

I think the next logical step should be to remove "receiver" pointer from
the gsm_sms structure into a structure, special for the internal SMS queue.
2014-04-30 15:31:57 +02:00
Holger Hans Peter Freyther 73bc51deea db: Add testcase for storing/loading/comparing a sms
Use the already created subscriber, create a sms and read it
back from the subscriber.
2014-04-30 15:31:57 +02:00
Holger Hans Peter Freyther ca3c256579 sms: Kill the sms->sender and use addr/ton/npi throughout the code
This is an incompatible database schema change. Store the type of
the address in the database for both the sender and the receiver.

Currently it is possible to use SMPP to store a SMS and the NPI
and TON will be lost on the delivery of the SMS. The schema is
changed to make the delivery always use the right NPI/TON. This
patch is not ready for the master branch as there is no upgrade
path for the HLR yet.
2014-04-30 15:31:57 +02:00
Álvaro Neira Ayuso 1b148ec100 openbsc/gsm_data_shared.h: Added the attribute reduce_power in TRX
Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-04-29 11:59:40 +02:00
Holger Hans Peter Freyther e9faa6f3a4 ctrl: Extend the testcase for using '09' as numbers on the interface
Verify that '0X' numbers are parsed correctly from the wire
interface.
2014-04-24 10:30:05 +02:00
Holger Hans Peter Freyther 86decfb53c gbproxy: Fix the start script for gbproxy
* Use the right name
* Refer to the right config file
2014-04-24 10:09:08 +02:00
Holger Hans Peter Freyther 5dd295ff44 bsc: Timers are in seconds, clarify that in the online help 2014-04-11 19:30:53 +02:00
Holger Hans Peter Freyther 444d7d8e65 ipa: Fix compiler warnings about aliasing
Use memcpy to copy from the OML message into the stack and then
convert the network byte order.

network_listen.c: In function ‘test_rep’:
network_listen.c:145:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  test_rep_len = ntohs(*(uint16_t *) &foh->data[3]);
  ^
network_listen.c:153:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   ferr_list_len = ntohs(*(uint16_t *) &foh->data[7]);
   ^
network_listen.c:164:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   ferr_list_len = ntohs(*(uint16_t *) &foh->data[7]);
   ^
network_listen.c:130:11: warning: variable ‘test_rep_len’ set but not used [-Wunused-but-set-variable]
  uint16_t test_rep_len, ferr_list_len;
2014-04-04 13:01:28 +02:00
Holger Hans Peter Freyther 686191a1c9 oml: Fix compiler warning about aliasing
Make the fill_fom_hdr return the header and use it throughout.

  CC       abis_nm.o
In file included from ../../include/openbsc/debug.h:8:0,
                 from abis_nm.c:38:
abis_nm.c: In function ‘abis_nm_opstart’:
abis_nm.c:1763:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
                                  ^
/home/ich/install/openbsc/include/osmocom/core/logging.h:23:74: note: in definition of macro ‘DEBUGP’
 #define DEBUGP(ss, fmt, args...) logp(ss, __FILE__, __LINE__, 0, fmt, ## args)
                                                                          ^
abis_nm.c:1763:2: note: in expansion of macro ‘abis_nm_debugp_foh’
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
  ^
abis_nm.c:1763:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
                                  ^
/home/ich/install/openbsc/include/osmocom/core/logging.h:23:74: note: in definition of macro ‘DEBUGP’
 #define DEBUGP(ss, fmt, args...) logp(ss, __FILE__, __LINE__, 0, fmt, ## args)
                                                                          ^
abis_nm.c:1763:2: note: in expansion of macro ‘abis_nm_debugp_foh’
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
  ^
abis_nm.c:1763:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
                                  ^
/home/ich/install/openbsc/include/osmocom/core/logging.h:23:74: note: in definition of macro ‘DEBUGP’
 #define DEBUGP(ss, fmt, args...) logp(ss, __FILE__, __LINE__, 0, fmt, ## args)
                                                                          ^
abis_nm.c:1763:2: note: in expansion of macro ‘abis_nm_debugp_foh’
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
  ^
abis_nm.c:1763:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
                                  ^
/home/ich/install/openbsc/include/osmocom/core/logging.h:23:74: note: in definition of macro ‘DEBUGP’
 #define DEBUGP(ss, fmt, args...) logp(ss, __FILE__, __LINE__, 0, fmt, ## args)
                                                                          ^
abis_nm.c:1763:2: note: in expansion of macro ‘abis_nm_debugp_foh’
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
  ^
abis_nm.c:1763:34: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
                                  ^
/home/ich/install/openbsc/include/osmocom/core/logging.h:23:74: note: in definition of macro ‘DEBUGP’
 #define DEBUGP(ss, fmt, args...) logp(ss, __FILE__, __LINE__, 0, fmt, ## args)
                                                                          ^
abis_nm.c:1763:2: note: in expansion of macro ‘abis_nm_debugp_foh’
  abis_nm_debugp_foh(DNM, (struct abis_om_fom_hdr *) oh->data);
2014-04-04 12:56:34 +02:00
Holger Hans Peter Freyther 90e9a445c8 gprs: Fix compiler warnings in sgsn_main.c
sgsn_main.c: In function ‘main’:
sgsn_main.c:345:2: warning: implicit declaration of function ‘gprs_sndcp_vty_init’ [-Wimplicit-function-declaration]
  gprs_sndcp_vty_init();
  ^
sgsn_main.c:354:2: warning: implicit declaration of function ‘sgsn_gtp_init’ [-Wimplicit-function-declaration]
  rc = sgsn_gtp_init(&sgsn_inst);
  ^
2014-04-04 12:51:28 +02:00
Holger Hans Peter Freyther 5a1b329a9e gprs: Fix compiler warnings ini gprs_sndcp_vty.c
CC       gprs_sndcp_vty.o
gprs_sndcp_vty.c: In function ‘vty_dump_sne’:
gprs_sndcp_vty.c:46:15: warning: unused variable ‘i’ [-Wunused-variable]
  unsigned int i;
2014-04-04 12:49:38 +02:00
Holger Hans Peter Freyther 65762e0455 gprs: Fix compiler warnings in sgsn_libgtp.c
CC       sgsn_libgtp.o
sgsn_libgtp.c: In function ‘create_pdp_conf’:
sgsn_libgtp.c:262:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
      ^
sgsn_libgtp.c: In function ‘cb_data_ind’:
sgsn_libgtp.c:432:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
2014-04-04 12:49:00 +02:00
Holger Hans Peter Freyther 744568b569 gprs: Fix compiler warnings in the gprs_llc.c code
CC       gprs_llc.o
gprs_llc.c: In function ‘t200_expired’:
gprs_llc.c:322:2: warning: enumeration value ‘GPRS_LLES_UNASSIGNED’ not handled in switch [-Wswitch]
  switch (lle->state) {
  ^
gprs_llc.c:322:2: warning: enumeration value ‘GPRS_LLES_ASSIGNED_ADM’ not handled in switch [-Wswitch]
gprs_llc.c:322:2: warning: enumeration value ‘GPRS_LLES_REMOTE_EST’ not handled in switch [-Wswitch]
gprs_llc.c:322:2: warning: enumeration value ‘GPRS_LLES_ABM’ not handled in switch [-Wswitch]
gprs_llc.c:322:2: warning: enumeration value ‘GPRS_LLES_TIMER_REC’ not handled in switch [-Wswitch]
gprs_llc.c: In function ‘gprs_llc_hdr_rx’:
gprs_llc.c:564:2: warning: enumeration value ‘GPRS_LLC_NULL’ not handled in switch [-Wswitch]
  switch (gph->cmd) {
  ^
gprs_llc.c:564:2: warning: enumeration value ‘GPRS_LLC_RR’ not handled in switch [-Wswitch]
gprs_llc.c:564:2: warning: enumeration value ‘GPRS_LLC_ACK’ not handled in switch [-Wswitch]
gprs_llc.c:564:2: warning: enumeration value ‘GPRS_LLC_RNR’ not handled in switch [-Wswitch]
gprs_llc.c:564:2: warning: enumeration value ‘GPRS_LLC_SACK’ not handled in switch [-Wswitch]
gprs_llc.c: In function ‘gprs_llc_rcvmsg’:
gprs_llc.c:791:23: warning: unused variable ‘udh’ [-Wunused-variable]
  struct bssgp_ud_hdr *udh = (struct bssgp_ud_hdr *) msgb_bssgph(msg);
                       ^
gprs_llc.c: At top level:
gprs_llc.c:311:13: warning: ‘t200_expired’ defined but not used [-Wunused-function]
 static void t200_expired(void *data)
             ^
gprs_llc.c:337:13: warning: ‘t201_expired’ defined but not used [-Wunused-function]
 static void t201_expired(void *data)
2014-04-04 12:47:32 +02:00
Holger Hans Peter Freyther cfee952e23 gprs: Fix compiler warnings in gprs_sndcp.c
CC       gprs_sndcp.o
gprs_sndcp.c: In function ‘defrag_input’:
gprs_sndcp.c:188:25: warning: variable ‘scomph’ set but not used [-Wunused-but-set-variable]
  struct sndcp_comp_hdr *scomph = NULL;
                         ^
gprs_sndcp.c: In function ‘sndcp_llunitdata_ind’:
gprs_sndcp.c:512:11: warning: variable ‘npdu_num’ set but not used [-Wunused-but-set-variable]
  uint16_t npdu_num;
           ^
gprs_sndcp.c: At top level:
gprs_sndcp.c:565:12: warning: ‘sndcp_ll_reset_ind’ defined but not used [-Wunused-function]
 static int sndcp_ll_reset_ind(struct gprs_sndcp_entity *se)
            ^
gprs_sndcp.c:573:12: warning: ‘sndcp_ll_status_ind’ defined but not used [-Wunused-function]
 static int sndcp_ll_status_ind()
            ^
2014-04-04 12:43:08 +02:00
Holger Hans Peter Freyther 1768a5765d gprs: Reduce the number of compiler warnings in gprs_gmm.c
CC       gprs_gmm.o
gprs_gmm.c: In function ‘gsm48_tx_gmm_att_ack’:
gprs_gmm.c:350:11: warning: unused variable ‘ptsig’ [-Wunused-variable]
  uint8_t *ptsig, *mid;
           ^
gprs_gmm.c: In function ‘gsm48_rx_gmm_auth_ciph_resp’:
gprs_gmm.c:524:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
      ^
gprs_gmm.c: In function ‘gsm48_rx_gmm_att_req’:
gprs_gmm.c:703:9: warning: implicit declaration of function ‘sgsn_acl_lookup’ [-Wimplicit-function-declaration]
         !sgsn_acl_lookup(mi_string))) {
         ^
gprs_gmm.c:632:40: warning: variable ‘old_ra_info’ set but not used [-Wunused-but-set-variable]
  uint8_t *cur = gh->data, *msnc, *mi, *old_ra_info, *ms_ra_acc_cap;
                                        ^
gprs_gmm.c: In function ‘gsm48_rx_gmm_ra_upd_req’:
gprs_gmm.c:915:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
      ^
gprs_gmm.c:910:11: warning: variable ‘ms_ra_acc_cap’ set but not used [-Wunused-but-set-variable]
  uint8_t *ms_ra_acc_cap;
           ^
gprs_gmm.c: At top level:
gprs_gmm.c:458:12: warning: ‘gsm48_tx_gmm_auth_ciph_req’ defined but not used [-Wunused-function]
 static int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm, uint8_t *rand,
            ^
gprs_gmm.c:501:12: warning: ‘gsm48_tx_gmm_auth_ciph_rej’ defined but not used [-Wunused-function]
 static int gsm48_tx_gmm_auth_ciph_rej(struct sgsn_mm_ctx *mm)
            ^
gprs_gmm.c:1169:13: warning: ‘msgb_put_pdp_addr_ipv4’ defined but not used [-Wunused-function]
 static void msgb_put_pdp_addr_ipv4(struct msgb *msg, uint32_t ipaddr)
             ^
gprs_gmm.c:1180:13: warning: ‘msgb_put_pdp_addr_ppp’ defined but not used [-Wunused-function]
 static void msgb_put_pdp_addr_ppp(struct msgb *msg)
2014-04-04 12:41:03 +02:00
Holger Hans Peter Freyther 4766524d17 rsl: Add missing breaks in the code
Given that the method is only called for a traffic channels the
missing breaks didn't hurt.

Fixes: Coverity CID 1040731, CID 1040732, CID 1040733,
       CID 1040734
2014-04-04 12:17:28 +02:00
Holger Hans Peter Freyther d219507d63 sgsn: Comparing array to NULL is not useful
.v is a unsigned char array with up-to 255 elements. We do not
need to add a null check here.

Fixes: Coverity CID 1040719
2014-04-04 11:55:21 +02:00
Holger Hans Peter Freyther bd30cd3e1f bsc/msc: Extension can never be NULL use strlen instead
Fixes: Coverity CID 1040717
2014-04-04 11:53:18 +02:00
Holger Hans Peter Freyther cb4567f117 msc: Name is never NULL use strlen to check if it is empty
Fixes: Coverity CID 1040716
2014-04-04 11:50:41 +02:00
Holger Hans Peter Freyther 8a080be4ad abis: Check for failure of ftell
In case ftell -1 will be returned. Coverity complained that the
pos we pass to fseek might be negative. In case the ftell fails
we are at the last line for sure.

Fixes: Coverity CID 1040721
2014-04-04 11:49:45 +02:00
Jacob Erlbeck 4ace424fa7 ipa: Be consistent in checking conn->cfg (Coverity)
Coverity complains about checking connection->cfg in
bsc_close_connection() at one place but not at the second.

This patch fixes this by adding a check before accessing cfg when
generating the 'partial message' log message.

Fixes: Coverity CID 1195180
Sponsored-by: On-Waves ehf
2014-04-03 12:42:04 +02:00
Holger Hans Peter Freyther c8b2c2f10e nat: Mention the the BSC the SCCP connection was on
The log message lacked a lot of context. A SCCP connection is
created on behalf of a configured BSC. This way we should be
able to always list this information.
2014-04-03 12:30:34 +02:00
Holger Hans Peter Freyther 27aab2e1c5 gbproxy/debian: Add a start script for the GBproxy
Fixes: OW#1164
2014-04-03 12:20:15 +02:00
Holger Hans Peter Freyther bb8d68196c nat/debian: Create an init script for the nat application 2014-04-03 12:20:15 +02:00
Jacob Erlbeck e827812051 ipa: Use enhanced ipa_msg_recv_buffered() to cope with partioned IPA messages
The old ipa_msg_recv() implementation didn't support partial receive,
so IPA connections got disconnected when this happened.

This patch adds the handling of the temporary message buffers and uses
ipa_msg_recv_buffered().

It has been successfully tested by jerlbeck with osmo-nitb and
osmo-bsc.

Ticket: OW#768
Sponsored-by: On-Waves ehf
2014-04-01 13:40:59 +02:00
Holger Hans Peter Freyther 8a158bb1ea ctrl/abis: When the max_power_reduction changes, send it to the BTS
In case the max_power_reduction changes, issue a new Set Radio
Carrier Attributes command. OML 12.21 allows to not include the
ARFCN list and the semantic I picked/understand is that a partial
update is possible.

Fixes: SYS#267
2014-03-26 18:08:22 +01:00
Holger Hans Peter Freyther a27303094a sgsn/ctrl: Add ctrl interface, implement listing subscribers
Add the control interface with no hierachy right now and implement
the first command to list IMSI + Context Address of active sessions.
sgsn_cmd_handle could share more code with bsc variant.

Fixes: SYS#264, SYS#265
2014-03-23 18:34:58 +01:00
Holger Hans Peter Freyther 49f9e5b6b4 ctrl: Move the lookup into a separate file in preparation for GPRS
For GPRS the look-up via bts/trx does not make any sense and would
introduce bad depdencies for the SGSN. Move the look-up code to a
new file and introduce new setup methods.
2014-03-23 16:25:16 +01:00
Holger Hans Peter Freyther d883db027b nitb/ctrl: Implement a command to list all active subscribers
This is only useful for small networks. List the IMSI and MSISDN
of all active subscribers.

Fixes: SYS#266
2014-03-23 16:22:55 +01:00
Holger Hans Peter Freyther 2d99eeb7f2 nitb/ctrl: Implement creating and deleting subscribers
Sadly there is no proper foreign key relationship on the tables
that related to the Subscriber. This means we can't use a DELETE
with Cascade and need to delete everything by hand. To make things
worse maybe the SMS/Paging code is still using the subscriber
making the operation more dangerous. I had added NULL checks for
sender_id/receiver_id at 30C3 so we should not crash in this
situation.

Fixes: SYS#274
2014-03-23 14:05:49 +01:00
Holger Hans Peter Freyther 9dbc3f8db7 nitb/ctrl: Add command to add/modify a subscriber to the database
The test has been manually verified. Executing the select for
the subscribers showed:

sqlite> select * from Subscriber;
1|2014-03-23 12:12:46|2014-03-23 12:19:09|2620345||445567|1||0|

This created a subscriber with the right IMSI, MSISDN and has
it authorized.

Fixes: SYS#275
2014-03-23 14:05:49 +01:00
Holger Hans Peter Freyther d092f48648 nitb/ctrl: Add ctrl command to set the TRX max_power_reduction
In case the BTS is connected the new attribute should be set
through OML. This is left as a todo item.

Addresses: SYS#267
2014-03-23 14:05:22 +01:00
Holger Hans Peter Freyther ebe55aa95a systemd: Add service for the osmo-sgsn
Fixes: SYS#175
2014-03-21 17:43:19 +01:00
Holger Hans Peter Freyther 2826cb58bb systemd: Saying these services restart once should be enough 2014-03-21 17:41:45 +01:00
Holger Hans Peter Freyther 870cc0fdac Merge branch 'jolly/mncc'
Merge the interface changes to the MNCC protocol
2014-03-20 22:36:27 +01:00
Andreas Eversberg 63bfdd83ea mncc: Add support for half rate V1 frames to MNCC/RTP interface 2014-03-20 22:36:16 +01:00
Andreas Eversberg 9acbe4cefe mncc: Use helper function to check if an MNCC frame is data (speech/traffic)
Rename method mncc_rcv_tchf() to mncc_rcv_data(), because the check applies
to all types of data frames, not only TCH/F data.
2014-03-20 22:36:16 +01:00
Andreas Eversberg f78fc4e76e mncc: Complete definitions for all speech traffic frames at MNCC interface
The new definitions are: half rate and AMR

Change of definition name for bad frame, because it applies to all types of
traffic, not only TCH/F.

Increase MNCC interface version to 4. Version 3 is skipped, because it was
used by older version of Linux-Call-Router which is incompatible with the
current version of the MNCC interface.
2014-03-20 22:36:16 +01:00
Holger Hans Peter Freyther f50f70452f mgcp: The valid payload types start at 0. Fix the VTY 2014-03-20 22:34:37 +01:00
Holger Hans Peter Freyther 162a0becc5 systemd: Remove the second occurance of Restart=always 2014-03-13 18:37:19 +01:00
Nikola 9e55636fe0 trau: Fix linking on FreeBSD by using LIBRAY_DL 2014-03-11 15:41:50 +01:00
Alexander Chemeris 9e15e187cc sms: Rename gsm340_gen_tpdu() to gsm340_gen_sms_deliver_tpdu()
Rename gsm340_gen_tpdu() to gsm340_gen_sms_deliver_tpdu() to
show that it generates SMS-DELIVER TPDU and is not a generic function.
2014-03-09 19:27:46 +01:00
Alexander Chemeris 1e77e3dc5b db,sms: Rename db_sms_mark_sent() to db_sms_mark_delivered()
In MT-SMS the message is being delivered. Make the naming follow
that. The schema still refers to "sent" while it should be "delivered"
too.
2014-03-09 10:26:11 +01:00
Alexander Chemeris 82a1858eb0 db: Add more tests for retrieving subscribers from a DB. 2014-03-09 10:24:11 +01:00
Alexander Chemeris 7e20f64f27 db: Remove the german from the log message 2014-03-07 17:05:23 +01:00
Holger Hans Peter Freyther e0bd8efcc0 Merge branch 'daniel/smpp-fixes' 2014-03-06 23:48:49 +01:00
Holger Hans Peter Freyther ed0d4f6222 nitb/smpp: Add simple test runner for the issues found by daniel
Send the two strings that caused the read handling to misbehave.
Verify that we handle this correctly by still being able to issue
a VTY command. The CPU load issue could not be verified like this.
2014-03-06 23:48:17 +01:00
Daniel Willmann 1fc8ec66a3 smpp_smsc: Fix integer overflow in read return value and msgb_alloc()
The size parameter of msgb_alloc is uint16_t so any length value above
65535 will allocate a msgb with incorrect size.

This patch changes the type of rdlen and rc to ssize_t (the return value
of read) and guards against the read length being larger than
UINT16_MAX.

To reproduce the issue run:
echo -en "\x00\x01\x00\x01\x01" |socat stdin tcp:localhost:2775
2014-03-06 23:20:30 +01:00
Daniel Willmann b6f01e77b1 smpp_smsc: Check that the size is large enough to hold actual data
The first 4 bytes are the length including the length field. For
length < 4 the subsequent msgb_put(msg, sizeof(uint32_t)) will fail,
resulting in an abort. The code also expects (in smpp_msgb_cmdid()) the
existence of 4 more bytes for the SMPP command ID.

This patch checks that the length received is large enough to hold all
8 bytes in the msgb and drops the connection if that's not the case.

The issue is reproducible with:
echo -e "\x00\x00\x00\x02\x00" |socat stdin tcp:localhost:2775
2014-03-06 23:20:30 +01:00
Daniel Willmann a4540b2c3b smpp_smsc: Fix socket read() error handling
Read returning -1 is an error here so make sure to print the actual
reason and close the socket. Before this patch we just looped over the
fd with read returning -1 every time.

EINTR is handled to not cause an error and we don't need to check
EAGAIN/EWOULDBLOCK since the callback is only called in case there is
something to read.

To avoid copy&paste issues the check is implemented as a macro and the
log message moved into a separate if.
2014-03-06 23:20:30 +01:00
Ciaby ec6e4f8b3d nitb: Add a test for "show network" in the python testsuite.
Make sure that bsc_gsmnet->bsc_data->rf_ctrl is initialized for
NITB. In commit a9fae1ae66 the
conditions for the rf_ctrl was removed but it was still needed
for the NITB.

Fixes regression from:
a9fae1ae66
bsc: rf_ctrl will always be created, remove the NULL checks
2014-03-06 17:31:23 +01:00
Holger Hans Peter Freyther 1a1463725b Merge branch 'zecke/features/extended-control' 2014-03-06 11:10:30 +01:00
Holger Hans Peter Freyther 4ecc6877a2 nat: Add CTRL command test case for the new control commands 2014-03-06 11:04:56 +01:00
Holger Hans Peter Freyther 472f3bd198 nat: Introduce command to remove an access-list-name 2014-03-04 20:39:38 +01:00
Holger Hans Peter Freyther bc3780a73f nat: Implement setting the access-control-name through CTRL interface
For operation we want to switch the access-list of a BSC at runtime
in a programatic way.

Sponsored-by: On-Waves ehf
2014-03-04 20:39:27 +01:00
Holger Hans Peter Freyther ecdf912ffb bsc: Include the MCC/MNC in the location trap
It is of interest to know the MCC/MNC that is broadcasted at the
specific position.

Sponsored-by: On-Waves ehf
2014-03-04 20:39:16 +01:00
Holger Hans Peter Freyther 3adb772853 libbsc: Add command to set MNC/MCC and apply it if something changed
Change the splitting of the ctrl_test_runner.py. Make sure that
we get one element and all the rest.
2014-03-04 20:38:49 +01:00
Holger Hans Peter Freyther 6ca9f4f5c3 libbsc: Add ctrl command to apply the configuration
Right now this only works for IP based BTS like the sysmoBTS and
by dropping the OML link.
2014-03-04 14:45:48 +01:00
Holger Hans Peter Freyther f8c42191de libbsc: Add ctrl command for MNC, MCC, short-name and long-name
Add the framework for adding more setting commands.
2014-03-04 14:45:48 +01:00
Holger Hans Peter Freyther 93de8b2591 sms: Address the TODO and schedule the next SMS for an active subscriber
When one SMS has been delivered check if a second SMS can be scheduled
to that subscriber. If nothing can be scheduled kick the normal SMS queue
as one slot has become free now. Otherwise send the SMS and create a
pending entry.
2014-02-24 16:13:04 +01:00
Holger Hans Peter Freyther 024dc77de2 sms: Do not interfere with the SMS queue from within gsm_04_11
It was possible that two SMS would be delivered at the same time
which violates GSM 04.11. We should solely rely on the sms queue
to schedule more SMS to the subscriber.
2014-02-24 14:31:39 +01:00
Holger Hans Peter Freyther 98258dbbc6 bsc: Add vty command to send location trap through VTY
I have manually tested this by entering the VTY command and
observing the CTRL interface using wireshark.

Ticket: OW#1129
2014-02-22 10:36:14 +01:00
Harald Welte 7e40be3949 SMPP: UCS2 data_coding is 0x08, not 0x80!
As can clearly be seen from SMPP Spec v3.4 Chapter 5.2.19,
a SUBMIT-SM with data_coding == 0x08 is UCS2, not with 0x80.

Thanks to ciaby@rhizomatica.org for reporting the bug.
2014-02-21 13:21:03 +01:00
Holger Hans Peter Freyther ca114432be sms: Increment the RP Message Reference for each transaction
Each RP-DATA should have a unique msg reference. Currently 42 is
used for all of these. Remember the last reference we used and
increment it on the next SMS. Do not track if the reference is
still in use a clash is a lot less likely now. First unless SMPP
is used only one SMS is delivered at a time, second the transaction
space is a lot smaller than the one for the reference.
2014-02-20 11:35:56 +01:00
Holger Hans Peter Freyther 6ab5d4f861 trau: Fix compiler warning about decoded_trau_frame
In file included from bsc_api.c:34:0:
../../include/openbsc/trau_mux.h:62:15: warning: ‘struct decoded_trau_frame’ declared inside parameter list [enabled by default]
  const struct decoded_trau_frame *tf);
               ^
../../include/openbsc/trau_mux.h:62:15: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
../../include/openbsc/trau_mux.h:64:15: warning: ‘struct decoded_trau_frame’ declared inside parameter list [enabled by default]
  const struct decoded_trau_frame *tf);
               ^
../../include/openbsc/trau_mux.h:66:2: warning: ‘struct decoded_trau_frame’ declared inside parameter list [enabled by default]
  const unsigned char *data);
  ^
../../include/openbsc/trau_mux.h:68:2: warning: ‘struct decoded_trau_frame’ declared inside parameter list [enabled by default]
  const unsigned char *data);
2014-02-20 11:19:32 +01:00
Holger Hans Peter Freyther 34235294d7 tests: Remove unused file 2014-02-20 11:19:32 +01:00
Holger Hans Peter Freyther a9fae1ae66 bsc: rf_ctrl will always be created, remove the NULL checks 2014-02-08 12:47:39 +01:00
Holger Hans Peter Freyther 362d10f20a libbsc: Create the RF interface all the time
The interface can be accessed through CTRL and a socket. But currently
it is only available when the socket interface has been configured.
Create the interface all the time but only listen on the socket when
a path has been specified.
2014-02-08 12:47:32 +01:00
Holger Hans Peter Freyther 8cedb11350 ctrl: Make it possible to re-use the string get and set routine
This can be used for the description field that requires some
special handling for newlines.
2014-02-04 19:35:32 +01:00
Holger Hans Peter Freyther 2c7032e4eb ctrl: Make the int range set, get and verify methods available
For the max power reduction we will need to have a different range
method. It will need to check if the value is even. Make the set,
get and verify methods available through a macro.
2014-02-04 19:35:16 +01:00
Holger Hans Peter Freyther cdfc2061bb mgcp: Round the frame time otherwise we have porting issues
With the current multiplication we might end up with 19999 as
time on i386. When we round it ends up as 20000 on i386 and
should work the same on AMD64.
2014-02-03 13:32:34 +01:00
Holger Hans Peter Freyther ba41978b97 mgcp: transit is a signed variable and should be printed like this
On AMD64 we had a difference in the test result most likely due
the bigger size of integers.
2014-02-03 09:20:06 +01:00
Holger Hans Peter Freyther 757971ade8 mgcp: Use the length modifier for the size_t in the printf
Should fix on AMD64:
mgcp_test.c: In function ‘sendto’:
mgcp_test.c:318:10: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ [-Wformat]
2014-02-03 09:18:51 +01:00
Jacob Erlbeck b281e4e6f4 mgcp/rtp: Base jitter calculation on input timestamps
So far, the jitter computation has been based on output timestamps.

This patch uses the input timestamps instead and resets jitter
computation on SSRC changes.

Sponsored-by: On-Waves ehf
2014-01-31 11:45:25 +01:00
Jacob Erlbeck eacc9b92a1 mgcp/rtp: Compute delta timestamp based on wallclock
Currently, when the SSRC changes within a stream and SSRC fixing is
enabled, the RTP timestamp between the last packet that has been
received with the old SSRC and the first packet of the new SSRC
is always incremented by one packet duration.
This can lead to audio muting (at least with the nanoBTS) when the
wallclock interval between these packets is too large (> 1s).

This patch changes the implementation to base the RTP timestamp offset
on the wallclock interval that has passed between these two packets.

Ticket: OW#466
Sponsored-by: On-Waves ehf
2014-01-31 11:44:16 +01:00
Jacob Erlbeck 303b54a2a4 mgcp/rtp: Fix transit computation units
Currently micro-secs and RTP rate get mixed when the transit value is
computed in mgcp_patch_and_count().

This patch changes get_current_ts() to accept the desired rate as
argument and to use it for the time conversion instead of always
converting to microseconds. If microseconds are needed,
get_current_ts(1000) can be used.
The arrival_time is now measured in 1/rtp_end->rate seconds so that
it can be directly compared to RTP timestamps as required by RFC3550
(section 6.4.1, see definition of 'interarrival jitter').

Sponsored-by: On-Waves ehf
2014-01-31 11:18:25 +01:00
Jacob Erlbeck e763f3e73e mgcp/test: Fake wallclock for RTP timing/stats tests
Currently the stats (jitter, transit) cannot be checked properly,
since they depend on the wallclock time.

This patch fakes clock_gettime (CLOCK_MONOTONIC) to reflect the
scheduling time of the RTP packets. In addition, the RTP statistical
value are written to stdout.
A RTP test case with a SSRC change along with a reference time delay
has been added.

Sponsored-by: On-Waves ehf
2014-01-31 11:18:25 +01:00
Jacob Erlbeck cf577c3492 mgcp/test: Only include conn_mode into test output
Currently the conn_mode and the output_enabled flags are printed to
stdout.

This patch modifies this to print the output_enabled flags to stderr
instead. The bits in conn_mode are shown as RECV, SEND, and LOOP.
This does not reduce the significance of the test, since there is an
assertion already that verifies the values of the output_enabled
flags with respect to the conn_mode.

Sponsored-by: On-Waves ehf
2014-01-31 11:18:25 +01:00
Jacob Erlbeck 8e68b56fe5 sms/dtap: Add log messages to analyse SMS message loss
Incoming DTAP messages from MS are discarded during silent calls,
which leads to the repeated delivery of SMS since the ACKs are not
being processed.

This patch adds some log messages that have been helpful to track
this down.

Sponsored-by: On-Waves ehf
2014-01-31 11:17:44 +01:00
Andreas Eversberg dcf38e1c96 Add function to update TRAU muxer after assignment or handover
E1 based BTS use TRAU muxer to decode TRAU frames. After changing
channel from one timeslot to another (due to handover or assignment),
the TRAU muxer must be updated. The call reference of the call is
disconnected from the old channel and connected to the new channel.
2014-01-27 14:39:06 +01:00
Andreas Eversberg 88012b6e87 Use 'defines' for length and duration of RTP payload 2014-01-26 08:49:35 +01:00
Holger Hans Peter Freyther 6419018e68 nat: Make the access-list deny cause configurable
Add two optional arguments to the imsi-deny rule
for the reject cause and verify that it is saved
out.
2014-01-20 10:14:05 +01:00
Holger Hans Peter Freyther 415cd2eebb nat: Introduce reject cause to bsc_nat_acc_lst_entry
The filtering architecture already allowed to specify a reject
reason but this has not been used for the access-lists. Extend
the access-list to include a reject reason and extend the test
case to honor it.
2014-01-20 10:13:36 +01:00
Jacob Erlbeck ead0529e07 mgcp/test: Don't reset conn_mode between messages
Currently, the conn_mode field is reset after it has been checked.

This patch disables this behaviour and only adds a mark (bit) to
detect modifications.

Sponsored-by: On-Waves ehf
2014-01-20 08:27:03 +01:00
Jacob Erlbeck e35fd13697 mgcp: Synchronize conn mode bits and output enabled flags
This patch changes implementation and the mgcp_connection_mode enum
in a way that net_end.output_enabled (bts_end.output_enabled) flag
always matches the MGCP_CONN_SEND_ONLY (MGCP_CONN_RECV_ONLY) bit of
conn_mode.

Based on this, the conn_mode bits are then used instead of the
output_enabled fields within mgcp_protocol.c.

Sponsored-by: On-Waves ehf
2014-01-20 08:27:03 +01:00
Jacob Erlbeck 8857c90e36 mgcp: Disable output enabled on initialisation
Currently RTP output_enabled is set to 1 on initialisation, which
does not semantically match the initial value of conn_mode
(MGCP_CONN_NONE).

This patch changes this initial value to 0.

Sponsored-by: On-Waves ehf
2014-01-20 08:27:03 +01:00
Harald Welte 94bc1e0b5e Fix more hidden TSC bugs for Ericsson BTS
It seems that also the Ericsson RBS2000 code was assuming that
we always use the bts-global TSC, rather than the possibly different
TS-specific TSC.
2014-01-19 17:32:59 +01:00
Harald Welte 1fe2412949 TSC: Add new gsm_ts_tsc() function to resolve TSC of TS
We don't want every caller to check for ts->tsc == -1 and then
using ts->trx->bts->tsc instead.  Rather, introduce a new inline
function to retrieve the correct value.
2014-01-19 17:32:59 +01:00
Harald Welte 903aaea668 Do not expect all BTSs support TSC != BCC
We introduce a new feature indicating if the given BTS model
supports a TSC that is different from the BCC (lower 3 bits of BSIC).
2014-01-19 17:32:56 +01:00
Harald Welte cd4e74df95 Make gsm48_lchan2chan_desc() reflect a ts-specific TSC
If the TS has a specific, different TSC than the BTS (beacon),
we should use that with preference over the TSC of the BTS.
2014-01-19 16:55:16 +01:00
Jacob Erlbeck 1dc022cb62 openbsc: Fix coverity issues
This patch (hopefully) fixes the new defects reported by coverity.

Addresses:
** CID 1156986:  Negative array index read  (NEGATIVE_RETURNS)
/tests/gsm0408/gsm0408_test.c: 419 in test_si_range_helpers()
/tests/gsm0408/gsm0408_test.c: 423 in test_si_range_helpers()
/tests/gsm0408/gsm0408_test.c: 427 in test_si_range_helpers()

** CID 1156987:  Unchecked return value from library
(CHECKED_RETURN)
/src/libmgcp/mgcp_protocol.c: 1150 in mgcp_keepalive_timer_cb()

** CID 1156988:  Unchecked return value from library
(CHECKED_RETURN)
/src/libmgcp/mgcp_protocol.c: 983 in handle_modify_con()

Sponsored-by: On-Waves ehf
2014-01-17 14:36:51 +01:00
Andreas Eversberg caae10b71f Remove obsolete check of conn and lchan pointers not beeing NULL
The check is removed from gsm48_cc_rx_setup() and gsm48_cc_rx_call_conf().
Receiving a layer 3 message implies that the transaction has a subscriber
connection and a logical channel.

This patch fixes the Coverity issues with CID 115311 and CID 1155312.
2014-01-16 20:49:07 +01:00
Holger Hans Peter Freyther fbb1c8f6fe Merge branch 'jerlbeck/features/mgcp-rtp-keep-alive' 2014-01-16 14:08:16 +01:00
Jacob Erlbeck 075a9ebdcc mgcp: Send RTP keepalive dummy packets to net
So far, a single dummy packet has been sent immediately after the
reception of a MDCX message. There is no dedicated keep alive
mechanism (it just worked because the audio from the MS has always
been forwarded to the NAT until the 'mgcp: Set output_enabled flags
based on the MGCP mode' patch).

This patch adds explicit, timer based keep alive handling that can be
enable per trunk. A VTY command 'rtp keep-alive' command is added for
configuration which can be used to set the interval in seconds, to
send a single packet after the reception of a CRCX/MDCX when RTP data
from the net is expected ('once'), or to disable the feature
completely ('no rtp keep-alive'). In 'send-recv' connections, only
the initial packet is sent if enabled (even when an interval has been
configured). The default is 'once'.

Note that this removes the mgcp_change_cb() from mgcp_main.c.

Sponsored-by: On-Waves ehf
2014-01-16 13:20:51 +01:00
Jacob Erlbeck 34bdc9f8fe mgcp/rtp: Send dummy packet to the RTCP destination, too
Currently a dummy packet is only sent to the RTP port. This is not
enough if RTCP must also cross the SNAT.

This patch sends an additional dummy packet to the RTCP net
destination if omit_rtcp is not set.

Sponsored-by: On-Waves ehf
2014-01-16 13:20:49 +01:00
Jacob Erlbeck 785e3c95d7 mgcp/rtp: Make offset computation understandable
Rename the timestamp variable to make in clear, that the input
timestamp is meant. Add a helper variable to illustrate the offset
computation.

Sponsored-by: On-Waves ehf
2014-01-16 13:20:47 +01:00
Jacob Erlbeck 2645c9e7fc mgcp: Set output_enabled flags based on the MGCP mode
This patch enhances parse_conn_mode() to set the output_enabled flags
of each end based on the MGCP mode.

Ticket: OW#1044
Sponsored-by: On-Waves ehf
2014-01-16 13:20:44 +01:00
Jacob Erlbeck 84dfba1579 mgcp/test: Show the number of dummy packets sent
This patch extends the test_messages test to show the number of dummy
packets that has been passed to sendto(). This way, dummy packets are
even being counted when sendto() itself failes (e.g. due to the fd
being -1).

Sponsored-by: On-Waves ehf
2014-01-16 13:20:37 +01:00
Jacob Erlbeck 68c74f59a4 mgcp/test: Reset pkt_period_* after each test
Currently these value may leak into the next test.

This patch will reset them after each message has been processed.

Sponsored-by: On-Waves ehf
2014-01-16 12:17:24 +01:00
Jacob Erlbeck 1b653af283 mgcp/test: Test the connection mode parser
This modifies the test MGCP messages to include M:recvonly (CRCX),
M:sendrecv (MDCX) and M:sendonly (MDCX) outputs the resulting
output_enabled flags and the conn_mode after processing the message.

Sponsored-by: On-Waves ehf
2014-01-16 12:17:24 +01:00
Jacob Erlbeck 0970bab2a3 mgcp/rtp: Add flag to disable RTP output
This patch make it possible to have a valid endpoint that drops all
outgoing RTP packets. The number of dropped packets is shown by the
VTY 'show mgcp' command. By default, this feature is disabled. To
enable packet dropping, the corresponding output_enabled field must
be set to 0.

Ticket: OW#1044
Sponsored-by: On-Waves ehf
2014-01-16 12:17:24 +01:00
Jacob Erlbeck b830008020 mgcp/rtp: Refactor mgcp_send to avoid code duplication
Currently there are two symmetric code paths which are selected by
the packet destination (NET or BTS).

This patch introduces 3 variables that take the different values
and unifies both code paths into one.

Sponsored-by: On-Waves ehf
2014-01-16 12:17:24 +01:00
Holger Hans Peter Freyther d9c1d31a6a Merge remote-tracking branch 'origin/jerlbeck/features/range-encode' 2014-01-16 12:06:41 +01:00
Jacob Erlbeck 64277e6514 si: Implement range 128, 256, 1024 encoding
This commit adds the implementation of these range formats to the
encoder. In addition, the work-around that tried range 512 first is
removed, so that the selection is primarily based on the max distance
between frequencies.

Ticket: OW#1061
Sponsored-by: On-Waves ehf
2014-01-16 12:04:30 +01:00
Jacob Erlbeck f8f72e23ca si: Add generic range w(k) encoder
Currently the encoding of the chan_list is done by a hard-coded
sequence of macros that closely resembles figure 10.5.16 in
3GPP TS 04.08.

This patch replaces this by an algorithmic solution that can be used
for all range encodings and is based on the property

    W(2^i) to W(2^(i+1)-1) are on w1_len-i bits when present

(see section 10.5.2.13 in TS 04.08).

Ticket: OW#1061
Sponsored-by: On-Waves ehf
2014-01-16 12:04:30 +01:00
Jacob Erlbeck 45014a0cad si: Fix range1024 encoding
f0 is currently set to arfcns[0] in range_enc_determine_range(),
while GSM 04.08 requires f0 to be ARFCN 0 in range1024 encoding.

This patch modifies range_enc_determine_range() to force f0 to be 0
if this encoding is used. This way the case distinction in
range_enc_filter_arfcns() is not longer necessary.

Sponsored-by: On-Waves ehf
2014-01-16 12:04:30 +01:00
Jacob Erlbeck 131406c86d si: Fix range512 encoding
This patch fixes a bug in the range encoder that leads to wrong
encoding when 17 or more ARFCNs are encoded.

Sponsored-by: On-Waves ehf
2014-01-16 12:04:30 +01:00
Jacob Erlbeck 9444d4f8e2 si/test: Merge si tests into gsm48 tests
Currently tests covering features of the GSM 04.08 specification are
spread over the si and gsm0408 subdirs in tests.

This commit merges all tests from 'si' into 'gsm0408' and removes the
'si' test sub-directory.

Sponsored-by: On-Waves ehf
2014-01-16 12:04:30 +01:00
Jacob Erlbeck 4b903b4afb si/test: Add tests for range encoding/decoding
This commit adds test range encoding tests. They check the property
decoding(encoding(L)) = L and optionally dump the results and
encoded sequences to stdout.

There a 2 test modes:

 - A list of fixed tests
 - A random number based test loop per ARFCN list size (only dumps
   the first failing test)

Sponsored-by: On-Waves ehf
2014-01-16 12:04:29 +01:00
Jacob Erlbeck 65d114fe43 si: Add a config option to disable SI2ter/SI2bis/SI5ter/SI5bis messages
The iPhone5 (US) appears to have some issues with the SIs generated,
or the nanoBTS is not sending them correctly.

Add a configurable hack to put all bands into the SI2/SI5 message.
It is enabled by the bts VTY command 'force-combined-si'.

This is a quick change without much reflection and watching for side
effects. I have verfied that a network with ARFCN 134 and neighbors
ARFCN 130 and 512 do not get generate the SI2ter and announce everything
inside the SI2.

This patch is conceptually based on 'si: Add a hack to disable
SI2ter/SI2bis/SI5ter/SI5bis messages' (692daaf2d2).

Ticket: OW#1062
Sponsored-by: On-Waves ehf
2014-01-16 12:04:22 +01:00
Andreas Eversberg a83d511b61 Each BTS can be configured for speech support (other than GSM full rate)
Speech codings which are not supported by BTS will be removed from the
bearer capability information element after parsing. This way it is not
required for the MNCC application to consider support of each BTS.

Only GSM full rate is supported by default.
2014-01-14 17:37:02 +01:00
Andreas Eversberg 7d8fa3418f Add VTY option for Nokia BTS that does not send RELease CONFirm message
This option is a workarround for a bug found in Nokia InSite BTS firmware
version 3.0.0. There is no RELease CONFirm message for local end release.
Nokia MetroSite with firmware version 4.178.16 is not affected.

TS 04.06 Chapter 5.4.4.4 "Local end release procedure" states that a
confirm must be sent by layer 2 when receiving a local end release
request.

In order to correctly switch a channel (handover or assignment), local
end release is required.
2014-01-09 08:12:14 +01:00
Jacob Erlbeck f46e226428 nitb: Set the DST field in generated MM info messages
Currently the NET_DST information element (see GSM 24.008) is not
included in generated MM info messages even when the DST field in the
timezone info has been set via the VTY or the control interface.

This patch modifies gsm48_tx_mm_info() to append this information
element if (and only if) a non-zero DST has been configured. The
DST IE is not part of GSM 4.8. Therefore it will only be sent, if the
DST offset is configured to a value != 0.

The DST functionality has been verified with wireshark by Jacob.

Sponsored-by: On-Waves ehf
2014-01-08 10:49:26 +01:00
Holger Hans Peter Freyther 095bd36627 smpp: In case we know the receiver set the context for logging 2013-12-29 20:30:02 +01:00
Holger Hans Peter Freyther 249b3f38c5 mncc: Add the context we get from the MNCC interface
Currently we only set the SUBSCR on RSL messages. Extend it to
messages that go through MNCC. For call control/bridging it is
difficult to pick the right subscriber. We should support a list
or at least two legs in the imsi filter context.
2013-12-29 20:24:37 +01:00
Tobias Engel ea730327d1 ussd: Reject and release unhandled SS requests/interrogation
In case the unpack of a USSD request is failing the channel would
remain open and the phone would not receive a response. Simply
reject the interrogation.

Example interrogation:
0000   1b 7b 1c 0d a1 0b 02 01 01 02 01 0e 30 03 04 01
0010   11 7f 01 00
2013-12-28 17:52:23 +01:00
Holger Hans Peter Freyther f76ed2d089 sms: Fix crash on RLL Establish Request timeouts with active call
Sylvain pointed out that in the current crash log the transaction
we try to read the SMS from is actually a transaction for Call
Control. On AMD64 the struct layout is different and that leads to
a crash when the CC transaction is in front of the SMS transaction.

Look at the trans->protocol to fix the crash. The issue got
introduced in 6a3d765bf9 (2010)
when I added the SAPI N Reject handling.

 #0  smpp_sms_cb (subsys=1, signal=4, handler_data=0xbb8270, signal_data=0x7fff33574ea0)
     at smpp_openbsc.c:284
 284		if (sms->source != SMS_SOURCE_SMPP)
 (gdb) bt
 #0  smpp_sms_cb (subsys=1, signal=4, handler_data=0xbb8270, signal_data=0x7fff33574ea0)
     at smpp_openbsc.c:284
 #1  0x00007f424e4a094c in osmo_signal_dispatch (subsys=1, signal=4,
     signal_data=0x7fff33574ea0) at signal.c:105
 #2  0x000000000042b070 in send_signal (sig_no=<optimized out>, trans=<optimized out>,
     sms=<optimized out>, paging_result=<optimized out>) at gsm_04_11.c:125
 #3  0x000000000042ccd2 in gsm411_sapi_n_reject (conn=0xec6790) at gsm_04_11.c:1000
 #4  0x0000000000408983 in send_sapi_reject (link_id=<optimized out>, conn=<optimized out>)
     at bsc_api.c:733
 #5  rll_ind_cb (_data=<optimized out>, lchan=<optimized out>, link_id=<optimized out>,
     rllr_ind=<optimized out>) at bsc_api.c:755
 #6  rll_ind_cb (lchan=<optimized out>, link_id=<optimized out>, _data=<optimized out>,
     rllr_ind=<optimized out>) at bsc_api.c:736
 #7  0x000000000041f8d2 in complete_rllr (rllr=<optimized out>, type=<optimized out>)
     at bsc_rll.c:55
 #8  0x00007f424e4a03bc in osmo_timers_update () at timer.c:243
 #9  0x00007f424e4a069b in osmo_select_main (polling=0) at select.c:133
 #10 0x0000000000407394 in main (argc=<optimized out>, argv=0x7fff33575238) at bsc_hack.c:346
 (gdb) frame 3
 #3  0x000000000042ccd2 in gsm411_sapi_n_reject (conn=0xec6790) at gsm_04_11.c:1000
 1000				send_signal(S_SMS_UNKNOWN_ERROR, trans, sms, 0);
 (gdb) p trans
 $1 = (struct gsm_trans *) 0xedba80
 (gdb) p *trans
  ....
          data = 0x1}}, sms = 0x3439323400000003}}}
 (gdb) p trans->protocol
 $4 = 3 '\003'
2013-12-27 22:57:56 +01:00
Holger Hans Peter Freyther 900394acf3 db: Avoid crash we have seen with the dbi code when reading a SMS
Avoid a crash when reading a SMS and a Subscriber could not be resolved.
It is not clear why the read was failing. The sender_id and the receiver_id
was valid for the given sms. I assume that the database has been locked
due external access to it.

The side-effect is that in case of such a failure the sms_queue will start
to deliver starting from subscriber id = 0 again.

 #1  0x0000000000428bec in sms_from_result (net=0x156a270, result=0x15eda30) at db.c:1146
 #2  0x000000000042a8e0 in db_sms_get_unsent_by_subscr (net=0x156a270,
     min_subscr_id=<optimized out>, failed=<optimized out>) at db.c:1255
 #3  0x000000000042e900 in take_next_sms (smsq=<optimized out>) at sms_queue.c:193
 #4  sms_submit_pending (_data=0x158e300) at sms_queue.c:227
 #5  0x00007f3fd30de3bc in osmo_timers_update () at timer.c:243
 #6  0x00007f3fd30de69b in osmo_select_main (polling=0) at select.c:133
 #7  0x0000000000406fbc in main (argc=9, argv=<optimized out>) at bsc_hack.c:346
 (gdb) frame 1
 #1  0x0000000000428bec in sms_from_result (net=0x156a270, result=0x15eda30) at db.c:1146
 1146		strncpy(sms->src.addr, sms->sender->extension, sizeof(sms->src.addr)-1);
 (gdb) p *sms
 (gdb) p sms->sender
 $1 = (struct gsm_subscriber *) 0x0
 (gdb) p sender_id
 $2 = <optimized out>
2013-12-27 20:20:55 +01:00
Holger Hans Peter Freyther b1d71d4267 bsc: Reduce the RLL timeout to be smaller than TC1/max_retr+1
Sylvain pointed out that the RLL and the SMC timeout is the same.
This can lead to have a SMC re-transmission before the first RLL
Establish Request has timed out. Reduce the RLL timeout. GSM 08.58
does not specify a timeout so right now I just reduce it to seven
seconds.
2013-12-27 19:21:58 +01:00
Holger Hans Peter Freyther 8effcb747d libmsc: Set the "trans->conn" to NULL to catch invalid usage
Make finding use-after-free more easy and set it to NULL.
2013-12-27 18:07:23 +01:00
Holger Hans Peter Freyther 1a345ca48f lu crash: Fix a crash that likely occurred during the LU procedure
conn->loc_operation is already NULL (e.g. due a five second timeout but
we are still processing a RSL message after we initiated the release
procedure). Do not attempt to authorize a subcriber without knowing the
key_sequence.

This can cause more problems but we will need to test this in the field.

(gdb) bt
 #0  gsm0408_authorize (conn=0x19fc2f0, msg=<optimized out>) at gsm_04_08.c:323
 #1  gsm0408_authorize (conn=0x19fc2f0, msg=<optimized out>) at gsm_04_08.c:319
 #2  0x000000000043a99a in mm_rx_id_resp (conn=0x19fc2f0, msg=<optimized out>)
     at gsm_04_08.c:495
 #3  gsm0408_rcv_mm (msg=<optimized out>, conn=0x19fc2f0) at gsm_04_08.c:1041
 #4  gsm0408_dispatch (conn=0x19fc2f0, msg=<optimized out>) at gsm_04_08.c:3232

(gdb) p *conn
 $5 = {entry = {next = 0x1746930, prev = 0x1a14270}, subscr = 0x1745eb0,
  expire_timer_stopped = 1 '\001', loc_operation = 0x0, sec_operation = 0x0,
  anch_operation = 0x0, silent_call = 0, put_channel = 0, sccp_con = 0x0, in_release = 0,
  lchan = 0x7f8c79007218, ho_lchan = 0x0, bts = 0x1719f90, T10 = {node = {
      rb_parent_color = 0, rb_right = 0x0, rb_left = 0x0}, list = {next = 0x0, prev = 0x0},
    timeout = {tv_sec = 0, tv_usec = 0}, active = 0, cb = 0, data = 0x0},
  secondary_lchan = 0x0}
2013-12-27 17:37:27 +01:00
Holger Hans Peter Freyther 2147bc4cc9 periodic/lu: Attempt to implicitly attach a subscriber instead of rejecting
When modern Smartphones receive "Not in VLR". The baseband firmware
apparently does not try to do an IMSI ATTACH but just remains un-happy
and will not connect to the network anymore.
2013-12-27 17:22:32 +01:00
Holger Hans Peter Freyther defb10fa62 Revert "gsm_04_11: Speculative fix for MT SMS and SAPI 'n Reject"
Let's revert it and see if we can find the real issue about the
sms being invalid. Sylvain has pointed out that we get invoked
from a timer and might not have stopped it properly.

This reverts commit 80ba9b5dd6.
2013-12-27 16:32:59 +01:00
Holger Hans Peter Freyther 80ba9b5dd6 gsm_04_11: Speculative fix for MT SMS and SAPI 'n Reject
I am not sure why it is crashing so this is a speculative fix based on
something we already did in 3e9b2ec257.

 #0  sms_find_pending (smsq=0x2706300, sms=<optimized out>) at sms_queue.c:77
 #1  sms_sms_cb (subsys=<optimized out>, signal=4, handler_data=0x26e2270,
     signal_data=0x7fffdac256c0) at sms_queue.c:396
 #2  0x00007fcdea94394c in osmo_signal_dispatch (subsys=1, signal=4,
     signal_data=0x7fffdac256c0) at signal.c:105
 #3  0x000000000042acc0 in send_signal (sig_no=<optimized out>, trans=<optimized out>,
     sms=<optimized out>, paging_result=<optimized out>) at gsm_04_11.c:124
 #4  0x000000000042c8e2 in gsm411_sapi_n_reject (conn=0x2722d30) at gsm_04_11.c:999
 #5  0x00000000004085d3 in send_sapi_reject (link_id=<optimized out>, conn=<optimized out>)
     at bsc_api.c:733
 #6  rll_ind_cb (_data=<optimized out>, lchan=<optimized out>, link_id=<optimized out>,
     rllr_ind=<optimized out>) at bsc_api.c:755
 #7  rll_ind_cb (lchan=<optimized out>, link_id=<optimized out>, _data=<optimized out>,
     rllr_ind=<optimized out>) at bsc_api.c:736
 #8  0x000000000041f522 in complete_rllr (rllr=<optimized out>, type=<optimized out>)
     at bsc_rll.c:55
 #9  0x00007fcdea9433bc in osmo_timers_update () at timer.c:243
 #10 0x00007fcdea94369b in osmo_select_main (polling=0) at select.c:133
 #11 0x0000000000406fbc in main (argc=9, argv=<optimized out>) at bsc_hack.c:346
2013-12-27 15:26:42 +01:00
Holger Hans Peter Freyther 91acfa0720 sms: Move to gsm_7bit_encode_n in the sms sending code
Do not rely on the potential wrong gsm_7bit_encode result but
use gsm_7bit_encode_n with maximum available space.
2013-12-26 22:33:02 +01:00
Holger Hans Peter Freyther 1f229b344e ussd: Move to use gsm_7bit_encode_n_ussd for USSD encoding
The legacy functions have a bad/wrong return value for the number
of septets in the string. Change the code to use the new functions
which will fix encoding issues as well.
2013-12-26 22:17:45 +01:00
Kevin Redon c9763a3de4 db: Fetch the authorized key using ulonglong
Location Update Requests time out and get rejected because the
subscriber is not authorized. Authorizing the subscriber through
openBSC or sqlite3 doesn't help the subscriber is still seen and
shown as not authorized

The value is read as uint, this is the wrong type it's a (u)longlong
in libdbi 0.9.0 and later.
2013-12-26 16:02:03 +01:00
Jacob Erlbeck 4bbddc6de9 mgcp/rtp: Only patch timestamp alignment errors
Currently, all timestamps are force to SeqNo*d + C which is more than
required by the nanoBTS which seems to be sensitive to alignment
errors only (dTS != k*d, d = ptime * rate = 160).

This patch replaces the force_constant_timing feature by a
force_aligned_timing feature. The timestamp offset will only be
changed (and timestamp errors counted) when the alignment does not
match to the raster based on ptime (default 20ms).

The VTY interface does not change.

Sponsored-by: On-Waves ehf
2013-12-19 11:56:11 +01:00
Jacob Erlbeck 65c7a4551a mgcp/test: Use differential output for counters and timestamp
Currently the counter and output timestamp values are written out for
each packet. This makes it difficult to see in the diffs what has
been changed significantly.

This patch changes this by showing differences for those
values. The absolute input values are also shown now. In addition,
the sequence numbers (the difference for the output value) are
written, too.

Sponsored-by: On-Waves ehf
2013-12-19 11:56:11 +01:00
Jacob Erlbeck 93c9da3b37 mgcp/test: Add test cases for constant RTP sequence number
This adds two test cases:
  1. Packet repetition (dSeq=0, dTS=0)
  2. Broken seqNo (dSeq=0, dTS=160)

The second had been already present in the test cases, but it was a
mere copy&paste mistake which turned out to be rather helpful. This
patch therefore turns it into a documented test case.

Sponsored-by: On-Waves ehf
2013-12-19 11:56:11 +01:00
Andreas Eversberg d074f8f396 Add EFR support to TRAU muxer + test case
Decoding and encoding of FR and EFR TRAU frames are put into seperate
functions. CRC check is done to detect bad EFR TRAU frames.

The test case includes FR and EFR transcoding.

EFR support was tested with Nokia InSite BTS and Siemens BS11.
2013-12-19 10:12:28 +01:00
Andreas Eversberg b6f9516193 Fix: Nokia requires VTY's "oml e1" parameters also
When writing config file, OML configuration must be written for all
E1 based BTS, which includes Nokia *Site BTS.
2013-12-18 16:23:39 +01:00
Jacob Erlbeck eddaa9f19e contrib/rtp: Fix default payload case
There is the wrong record field selection being used to extract the
default value. It returns the tuple offset instead of the value.

This patch fixes this.

Sponsored-by: On-Waves ehf
2013-12-18 16:16:42 +01:00
Holger Hans Peter Freyther daf2a38eb6 Merge branch 'jerlbeck/features/mgcp-get-info-from-sdp' 2013-12-13 13:51:50 +01:00
Jacob Erlbeck 0a1bc56e5a mgcp: Optionally send ptime in SDP
Currently the SDP 'ptime' media attribute is never set in generated
MGCP responses.

This patch optionally includes the 'ptime' attribute if
packet_duration_ms is != 0. This behaviour can be enabled/disabled
by using the VTY command "sdp audio-payload send-ptime" (enabled by
default).

Sponsored-by: On-Waves ehf
2013-12-13 13:51:29 +01:00
Jacob Erlbeck 24754f0490 mgcp: Parse SDP to get rate and packet duration
This patch parses the 'ptime' and 'maxptime' SDP attributes, and the
SDP rate information and sets up packet_duration_ms accordingly. If
the packet duration is unknown or allows for different values (e.g.
because 'ptime' uses a range or 'maxptime' allows for more than one
frame) the duration is set to 0.

Sponsored-by: On-Waves ehf
2013-12-13 13:49:32 +01:00
Jacob Erlbeck 2c2ca4df38 mgcp: Put local connection options into a struct
Currently the local connection options have been stored as a string.

This patch replaces this string by a struct (that still contains a
string) along with the parsed fields (only the packetization period
at the moment).

It also re-adds the calls to set_local_cx_options() to the
handle_create_con() and handle_modify_con() functions. Except for
the test program this has no side effects, since the LCO values
aren't used yet.
2013-12-13 13:48:04 +01:00
Jacob Erlbeck ba477d2ba3 mgcp/test: Output the packet duration after MGCP parsing
This also adds additional MDCX tests (based on MDCX4) to test the
analysis of different combinations of 'p' and 'ptime' fields.

Sponsored-by: On-Waves ehf
2013-12-13 13:45:19 +01:00
Jacob Erlbeck 33f300915a mgcp/rtp: Refactor timestamp offset calculation into own function
Currently the timestamp offset calculation is done in two different
places.

This patch moves and unifies both code parts into a separate function.

Sponsored-by: On-Waves ehf
2013-12-13 13:45:19 +01:00
Jacob Erlbeck e8ae1ac76a contrib/rtp: Add tool to create RTP state files
This tool provides the following features:
  - Output formats: state, C arrays
  - Optionally take RTP payload from existing state files
  - Generate streams with RTP timestamp jumps and/or delays
  - Set/change SSRC or payload type

Requires erlang to be installed.

Example:
  Generate 300 packets, set playout time offset to 1s, set
  RTP timestamp offset to 8000 (1s), generate another 100
  packets, the RTP payload is copied from rtp.state:

  ./gen_rtp_header.erl --type=98 --file=rtp.state  --
      0 300 0 --delay=1.0 100 8000

Sponsored-by: On-Waves ehf
2013-12-13 13:40:11 +01:00
Jacob Erlbeck 8b66649883 contrib/rtp: Enhance RTP replay tool
This patch adds optional parameters to pass the state file, the
destination address (default 127.0.0.1), the destination port
(default 4000), the source port (default 0). So it is called as
follows:

    gst rtp_replay.st -a [FILE [HOST [SOURCEPORT [DESTPORT]]]]

In addition, nonexistant FILEs are no longer created but opened
read-only instead.

Sponsored-by: On-Waves ehf
2013-12-13 13:40:09 +01:00
Holger Hans Peter Freyther e828b661a7 build: db_test does not use dlopen/dlsym.. remove LIBRARY_DL from deps 2013-12-13 10:18:33 +01:00
Holger Hans Peter Freyther a066d38fbf build: channel_test does not use dlopen/dlsym remove LIBRARY_DL dep 2013-12-13 10:18:32 +01:00
Holger Hans Peter Freyther fd465bcdf1 build: osmo-nitb does not use dlopen/dlsym remove LIBRARY_DL
osmo-nitb does not use dlopen/dlsym so we can remove the depedency
to LIBRARY_DL.
2013-12-13 10:18:32 +01:00
Holger Hans Peter Freyther 5b0e8706e8 build: Remove bogus depends from ipaccess-config
The code does not use libmsc and doesn't use dlsym/dlopen etc. So
let us remove LIBRARY_DL as dependency.
2013-12-13 10:18:32 +01:00
Nikola 876b55af33 freebsd: dlopen/dlsym/dlerror is part of libc, use LIBRARY_DL for linking
In FreeBSD there is no spearate library for dlopen, dlsym and dlerror.
Use LIBRARY_DL to check for this condition.
2013-12-13 10:18:19 +01:00
Holger Hans Peter Freyther 27a788ddb9 si: Make sure to not overwrite orig_arfcn_hi in the range encoding
Andreas highlighted that the doubel assignment is not needed and
wrong. Change the code to assign chan_list[0] before writing the
base frequency to the header. Update the testcase to make the highest
bit set and update the test result.
2013-12-12 17:00:57 +01:00
Holger Hans Peter Freyther e18209c975 ipa-proxy: Socket creation can fail, address coverity issue
Fixes: Coverity CID 1040722
2013-12-12 16:20:19 +01:00
Holger Hans Peter Freyther 7f180e83c3 vty: Address coverity issue with subscr->name never being NULL
Coverity points out that subscr->name is an array and never NULL.
Use strlen instead in this check.

Fixes: Coverity CID 1040717
2013-12-12 16:20:12 +01:00
Holger Hans Peter Freyther a5ddf489e1 subscriber: Address coverity warning and truncate the IMSI
The IMSI can only be 15 characters in length, our define gives
us a length of 17. This means we have place for two NULs. Use
strncpy and make sure it is null-terminated.

Fixes: Coverity CID 1040707
2013-12-12 16:20:07 +01:00
Holger Hans Peter Freyther 7672db33bd smpp_mirror: Initialize rc when cmd_id is not DELIVER_SM
Fixes: Coverity CID 1042369
2013-12-12 16:20:01 +01:00
Holger Hans Peter Freyther 109583dacb build: Ignore file generated by automake 2013-12-12 13:08:48 +01:00
Holger Hans Peter Freyther a80100644c mgcp: Address compiler error for sprintf misusage...
The hardening flags of debian have highlighted this sprintf mis-usage
in the testcase. Address it.
2013-12-12 13:08:26 +01:00
Holger Hans Peter Freyther 12355ae658 debian: Enable hardening for the OpenBSC packages 2013-12-12 13:08:26 +01:00
Holger Hans Peter Freyther 65f7427e02 debian: Build debug packages for each of the target packages 2013-12-12 13:08:26 +01:00
Holger Hans Peter Freyther 9f4f4e6c29 Merge remote-tracking branch 'jerlbeck/features/rtp-header-patching' 2013-12-10 12:50:38 +01:00
Jacob Erlbeck f6ec0e9fc4 mgcp/rtp: Refactored packet_duration computation
Since the packet duration is given in ms with the 'ptime' RTP media
attribute and also with the 'p' MGCP local connection option, the
computation is changed to use this value (if present). The
computation assumes, that there are N complete frames in a packet and
takes into account, that the ptime value possibly had been rounded
towards the next ms value (which is never the case with a frame length
of exact 20ms).

Sponsored-by: On-Waves ehf
2013-12-10 11:17:44 +01:00
Jacob Erlbeck 58340e5b5b mgcp/rtp: Fix RTP timestamps if enabled
This forces the output timing to fulfill
   dTS = dSegNo * fixedPacketDuration
where dSegNo = seqNo - lastSeqNo.

If timestamp patching is enabled, the output timestamp will be set
to lastTimestamp + dTS. This kind of relative updating is used to
handle seqNo- and timestamp-wraparounds properly.

The updating of timestamp and SSRC has been separated and the patch
field of mgcp_rtp_state has been renamed to patch_ssrc to reflect
it's semantics more closely. The offset fields are now used always
and will change the corresponding header field if they are != 0.

Ticket: OW#1065
Sponsored-by: On-Waves ehf
2013-12-10 11:17:44 +01:00
Jacob Erlbeck e2292f3aa1 mgcp/rtp: Only patch SSRC once after MDCX if enabled
Currently the output SSRC is always forced to be the same if SSRC
patching is enabled.

This patch modifies this to optionally restrict the number of SSRC
changes that will be corrected.

Note that the configuration only allows for the 'once' mode and 'off'.

Sponsored-by: On-Waves ehf
2013-12-10 11:17:42 +01:00
Jacob Erlbeck 3da9e4e441 mgcp/rtp: Use SSRC in proper byte ordering
The ssrc has been used without respect to proper byte ordering in
mgcp_patch_and_count(). This only affected log messages.

This patch introduces a new variable 'ssrc' that takes the value of
the SSRC in proper byte order.

Sponsored-by: On-Waves ehf
2013-12-10 11:13:22 +01:00
Jacob Erlbeck 30ce42250f mgcp/rtp: Compute default packet duration at state initialisiation
This patch adds a packet_duration field to mgcp_rtp_state which
contains the RTP packet's duration in RTP timestamp units or 0, when
the duration is unknown or not fixed.

Sponsored-by: On-Waves ehf
2013-12-10 11:13:22 +01:00
Jacob Erlbeck b35a77751b mgcp/rtp: Only update RTP header field offsets if enabled
Currently seq_offset and timestamp_offset are updated on each SSRC
change even when SSRC patching is not allowed.

This patch fixes this by changing mgcp_patch_and_count() to only
update these fields when SSRC patching is allowed.

Sponsored-by: On-Waves ehf
2013-12-10 11:13:22 +01:00
Jacob Erlbeck 5e9549e6a9 mgcp/rtp: Change the log message shown when the SSRC changes
Show old and new SSRC. Move logging command upward to show the values
immediately after the change has been detected and before any fixing
attempt is made.

Sponsored-by: On-Waves ehf
2013-12-10 11:13:22 +01:00
Jacob Erlbeck db2d431697 mgcp/rtp: Add RTP header patch mode configuration
This adds datastructures and a VTY frontend to configure the
different type of RTP header patching: SSRC and timestamp.

Note that timestamp patching is not yet implemented.

Sponsored-by: On-Waves ehf
2013-12-10 11:11:42 +01:00
Jacob Erlbeck 55ba140da1 mgcp/rtp: Fix output timing error counter
The tsdelta computation and error detection didn't handle the
intialisation phase properly.

This patches fixes this by skipping the output timing validation
when the SSRCs don't match.

Sponsored-by: On-Waves ehf
2013-12-05 16:55:39 +01:00
Jacob Erlbeck 83c0523739 mgcp/rtp: Add more test cases for RTP header patching
This patch extends the existing RTP error check test by adding a
check for timestamp errors after SSRC changes and a check for a
segno delta of 2 (with a timestamp delta of 320).

To test SSRC patching too, a corresponding line will be written on
each SSRC change that has been detected in the output stream.

In addition there is now support for selectively enabling/disabling
SSRC and timestamp patching. The RTP test sequence is repeated for
all combinations thereof.

Sponsored-by: On-Waves ehf
2013-12-05 16:54:25 +01:00
Holger Hans Peter Freyther 598b1c7231 Merge branch 'jerlbeck/mgcp-cleanups' 2013-12-05 10:32:06 +01:00
Jacob Erlbeck 78a9501cfd mgcp: Handle SDP in CRCX received by the MGW
So far the SDP part of the CRCX message has been ignored by the MGW.

This patch adds SDP parsing for this case, eventually updating the
net end's payload type and connection parameters.

Sponsored-by: On-Waves ehf
2013-12-05 10:28:51 +01:00
Jacob Erlbeck 3dff27d38d mgcp/nat: Take payload type from SDP data
So far the payload type used in RTP streams has been taken from the
trunk configuration in NAT mode.

This patch changes the implementation to use the payload type
announced in the SDP part of MGCP messages and responses. SDP
descriptions more than one m=audio line are not yet supported
properly (always the last one is taken).

Ticket: OW#466
Sponsored-by: On-Waves ehf
2013-12-05 10:28:48 +01:00
Jacob Erlbeck 9107e2da13 mgcp: NUL-terminate MGCP message
The MGCP message isn't always NUL-terminated when arriving at
mgcp_handle_message(). This may lead to undefined results.

This patch ensures that the message text is NUL-terminated by
setting *msg->tail to '\0' in mgcp_handle_message().

Addresses:
<000b> mgcp_protocol.c:642 Unhandled option: 'r'/114 on 0x3
<000b> mgcp_protocol.c:593 Unhandled SDP option: '='/61 on 0x3
<000b> mgcp_protocol.c:871 Unhandled option: '.'/46 on 0x2

Sponsored-by: On-Waves ehf
2013-12-05 10:28:23 +01:00
Jacob Erlbeck 1771171e05 mgcp: Refactor MGCP/SDP parsing
This patch separates the SDP parsing from the (message specific) MGCP
parsing.

Sponsored-by: On-Waves ehf
2013-12-05 10:27:33 +01:00
Jacob Erlbeck a52ac66e52 mgcp: Add tests for payload types in MGCP messages
These tests mainly check whether the SDP parsing works properly by
looking at the payload type detected.

Sponsored-by: On-Waves ehf
2013-12-05 10:27:32 +01:00
Jacob Erlbeck 2bee7f96ff mgcp: Add new for_each_line macro that also returns empty lines
This patch add the for_each_line macro based on a strline_r()
function (similar to strtok_r()), that is also part of this patch.
This strline_r() function is tolerant with respect to line endings,
it supports CR-only, CRLF, and LF-only and any combinations thereof
(note that a CRLF is always detected as a single line break).

Similar to for_each_non_empty_line (the former for_each_line) where
the 'save' pointer needed to be initialised by a call to strtok_r(),
the new for_each_line macro expects, that the 'save' pointer has been
initialised by a call to strline_r(). Also note, that
for_each_line/strline_r and for_each_non_empty_line/strtok_r may use
the 'save' pointer differently, so calls to them can not be mixed.

Sponsored-by: On-Waves ehf
2013-12-05 10:27:32 +01:00
Jacob Erlbeck a01bd60851 mgcp: Rename for_each_line to for_each_non_empty_line
The implementation of for_each_line is based on strtok() and skips
any sequence of CR and LF. Thus empty lines are never detected. There
exists code which tests for an empty line to detect the beginning of
the SDP part which is dead code currently (the parser works
nevertheless due to other reasons). So the semantics of this macro
have been misunderstood at least once.

This patch renames the macro to reflect the semantics more precisely.

Sponsored-by: On-Waves ehf
2013-12-05 10:27:32 +01:00
Harald Welte 19d8742820 osmo-nitb: don't print 'bac_hack' in usage/help output 2013-11-27 01:28:21 +01:00
Jacob Erlbeck 72c309021a mgcp/rtp: Fix timestamp offset when patching RTP packets
The current implementation increments the seqno but does not increment
the RTP timestamp, leading to two identical timestamps following one
after the other.

This patch fixes this by adding the computed tsdelta when the offset
is calulated. In the unlikely case, that a tsdelta hasn't been
computed yet when the SSRC changes, a tsdelta is computed based on
the RTP rate and a RTP packet duration of 20ms (one speech frame per
channel and packet). If the RTP rate is not known, a rate of 8000 is
assumed.

Note that this approach presumes, that the per RTP packet duration
(in samples) is the same for the last two packets of the stream being
replaced (the first one).

Sponsored-by: On-Waves ehf
2013-11-25 18:30:50 +01:00
Jacob Erlbeck d62419b574 mgcp/rtp: Add test case for RTP timestamp patching and stats
This patch adds a test case to check, whether RTP timestamps are
generated properly after SSRC changes and whether the error counters
work properly.

Sponsored-by: On-Waves ehf
2013-11-25 18:13:35 +01:00
Jacob Erlbeck 50079a1843 mgcp/rtp: Add counter for invalid RTP timestamp deltas
This patch modifies the patch_and_count() function to check for RTP
timestamp inconsistencies. It basically checks, whether dTS/dSeqNo
remains constant. If this fails, the corresponding counter is
incremented. There are four counter for this: Incoming and outgoing,
each for streams from the BTS and the net.

Note that this approach presumes, that the per RTP packet duration
(in samples) remains the same throughout the entire stream. Changing
the number of speech frames per channel and packet will be detected
as error.

In addition, the VTY command 'show mgcp' is extended by an optional
'stats' to show the counter values, too.

Ticket: OW#964
Sponsored-by: On-Waves ehf
2013-11-25 18:07:21 +01:00
Holger Hans Peter Freyther ec37bb2956 bsc: Add a VTY command to show the paging group for a BSC/IMSI 2013-11-22 16:00:00 +01:00
Jacob Erlbeck d9e4039516 rtp: Fixed size check in padded RTP packets
This patch fixes a corner case (padding 1, payload size incl padding
0) which is not being detected correctly.

Sponsored-by: On-Waves ehf
2013-11-21 20:00:55 +01:00
Holger Hans Peter Freyther 33b9641025 bsc: Use the right string for the notification 2013-11-15 16:47:59 +01:00
Holger Hans Peter Freyther 92ce02e644 rtp: Take the parameter from the arguments
$ gst rtp_replay.st -a FILE
2013-11-14 09:45:51 +01:00
Holger Hans Peter Freyther 558bdb4330 ipa: Explain that one needs to get the IP address of the BTS as argument 2013-11-11 14:30:09 +01:00
Holger Hans Peter Freyther 49976f4c1e shared: Introduce/Add procedure pending to the MO
GSM 12.21 specifies that "No elementary procedure shall be
initiated to an object instance which has not yet replied to
a previously initiated elementary procedure with a response,
an ACK or a NACK within a layer 3 time-out. The layer 3
timeout for ACK, NACK and responses shall have a default value
of 10 seconds."

We are using this flag in the BTS to enforce/safe-guard
this situation.
2013-11-05 16:06:17 +01:00
Holger Hans Peter Freyther 82e644b572 gbproxy: The "[stats]" option was not documented, document it
Documentation error (missing docs):
<command id='show gbproxy [stats]'>
        <param name='[stats]' doc='(null)' />
2013-11-03 17:34:17 +01:00
Jacob Erlbeck aff2d62b8c bsc/ussd: Rename bsc_send_ussd_notification()
Rename this function to bsc_send_ussd_no_srv() since it's a rather
specialised function and not a generic USSD notification function.

Sponsored-by: On-Waves ehf
2013-11-01 17:12:41 +01:00
Jacob Erlbeck b1250312ba bsc/ussd: Send faked CM Service Accept before sending USSD
The MS do not show the USSD messages yet. This patch modifies the
implementation to insert a CM Service Accept to finish the
establishment of the MM connection according to 3GPP TS 04.10/3.2.1
before the USSD notification is sent.

This fix has been tested with a Blackberry phone that has shown
an ussd_grace_txt after rf_locked has been set to '1'. Without this
patch, that message wasn't shown. The phone has sent a CC Setup
and other messages before processing the channel release message sent
by the BSC, but these messages have not been forwarded to the MSC (as
expected).

Ticket: OW#957
Sponsored-by: On-Waves ehf
2013-11-01 17:12:39 +01:00
Jacob Erlbeck 24d3b91d46 bsc: Move gsm48_tx_mm_serv_ack/rej to gsm_04_08_utils.c
These functions are currently located in libmsc/gsm_04_08.c together
with other symbols that (transitively) depend on many external
symbols (and thus libraries) that aren't otherwise needed by e.g.
osmo-bsc.

Since gsm48_tx_mm_serv_ack() will be needed by osmo-bsc, these
functions are moved to avoid the dependency on gsm_04_08.o.

Sponsored-by: On-Waves ehf
2013-11-01 17:12:37 +01:00
Holger Hans Peter Freyther 28e183f385 Revert "bsc/ussd: Send faked CM Service Accept before sending USSD"
This reverts commit 61bd965b04.

No, we should not link to dbi.. and these libraries..
2013-10-31 13:35:28 +01:00
Jacob Erlbeck 61bd965b04 bsc/ussd: Send faked CM Service Accept before sending USSD
The MS do not show the USSD messages yet. This patch modifies the
implementation to insert a CM Service Accept before the ussdNotify
to finish the establishment of the MM connection according to
3GPP TS 04.10/3.2.1.

This fix has been tested with a Blackberry phone that has shown
an ussd_grace_txt after rf_locked has been set to '1'. Without this
patch, that message wasn't shown. The phone has sent a CC Setup
and other messages before processing the channel release message sent
by the BSC, but these messages have not been forwarded to the MSC (as
expected).

Ticket: OW#957
Sponsored-by: On-Waves ehf
2013-10-31 13:29:51 +01:00
Jacob Erlbeck 6e919dbb65 vty: Enable the end/exit test for libosmocore nodes
This patch replaces the calls to ignoredCheckForEndAndExit by calls
to checkForEndAndExit to test the libosmocore nodes, too. The former
method is removed.

Sponsored-by: On-Waves ehf
2013-10-30 15:19:02 +01:00
Jacob Erlbeck 36722e13da vty: Use vty_install_default() instead of bsc_install_default()
Remove ournode_exit_cmd, ournode_end_cmd, and bsc_install_default()
since this functionality is provided by the current libosmocore.

Replace calls to bsc_install_default() by call to
vty_install_default() with the following semantic patch:

    @rule1@
    expression N;
    @@
    - bsc_install_default(N);
    + vty_install_default(N);

Ticket: OW#952
Sponsored-by: On-Waves ehf
2013-10-30 15:19:00 +01:00
Holger Hans Peter Freyther fc7a75f5df bts: Add a flag to remember the kind of activation/release
When the PCU is activating a channel we don't want to tell the
BSC using RSL. Add a flag so we can keep track of who asked for
the activation/release of the channel.
2013-10-25 18:58:30 +02:00
Jacob Erlbeck 64cb924634 gbproxy: Fix handling of NSEI changes
The gbproxy looses NSEI changes on BVC_RESET and then tries to send
later messages to the wrong (not longer existing) destination.

This patch fixes this by updating the peer's nsei field on BVC_RESET.

Ticket: OW#874
Sponsored-by: On-Waves ehf
2013-10-24 18:02:38 +02:00
Jacob Erlbeck 72b401f33d gbproxy: Add test for NSEI and NSVCI changes
This checks the behavior of the gbproxy when the BSS peer changes the
NSEI and the NSVCI. It also tests BVC_RESET and other UNITDATA
messages after these changes between BSS and SGSN and vice versa (via
the gbproxy).

Ticket: OW#874
Sponsored-by: On-Waves ehf
2013-10-24 18:02:36 +02:00
Jacob Erlbeck 4211d79cd1 gbproxy/vty: Enhance delete-gbproxy-peer command
This adds the option to delete all BVC peers and/or NS_VC with a
given NSEI with a single command. Static (configured) NS-VC are not
affected. In addition, all connections for this NSEI that can be
deleted by this command can be listed without deleting them by
appending 'dry-run' to the command.

Sponsored-by: On-Waves ehf
2013-10-24 18:02:33 +02:00
Holger Hans Peter Freyther 90267a961c gbproxy: Add a command to delete peers from the GBProxy
This just deletes the peer entry based on NSEI and BVCI. The NS-VC
are not touched.
2013-10-24 08:22:45 +02:00
Jacob Erlbeck 02ca7783ab gbproxy: Fix rate counter group leak in peer_free()
This also frees the counter group pointed to by peer->ctrg when the
peer gets freed.

Sponsored-by: On-Waves ehf
2013-10-24 08:22:45 +02:00
Jacob Erlbeck 6d23371805 gbproxy: Add basic VTY tests
This checks for the ns and gbproxy config nodes and show commands.

Sponsored-by: On-Waves ehf
2013-10-24 08:21:29 +02:00
Jacob Erlbeck 7587727445 vty: Fix whitespace in test script
Expands leading tabs and removes trailing whitespace.

Sponsored-by: On-Waves ehf
2013-10-24 08:21:22 +02:00
Jacob Erlbeck f0f63a4113 gbproxy: Reject SGSN UNITDATA messages with an invalid BVCI
Currently such messages lead to a creation of a new peer with the
SGSN's NSEI, which results in echoing the message back to the SGSN.

This patch modifies this by sending a STATUS response (invalid BVCI)
instead back to the SGSN.

Sponsored-by: On-Waves ehf
2013-10-19 12:10:24 +02:00
Jacob Erlbeck da890c7733 gbproxy: Test invalid BVCI from SGSN
This adds a test with a UNITDATA SGSN message that is addressed to an
invalid (unknown) BVCI. The test shows, that the message is echoed to
the SGSN.

Sponsored-by: On-Waves ehf
2013-10-19 12:10:21 +02:00
Jacob Erlbeck bc555742aa gbproxy: Add global and per peer counters
This adds counters that are incremented when errors are detected.
It also modifies the VTY command 'show gbproxy' so that
'show gbproxy stats' shows the counters.

Sponsored-by: On-Waves ehf
2013-10-19 12:10:19 +02:00
Jacob Erlbeck c5085f9d3d gbproxy: Fix warning and log message
Add the unused attribute to peer_free() that isn't used currently.
Change 'RAC' to 'NSEI' in the log message, since the latter has been
examined before the log message is generated.

Sponsored-by: On-Waves ehf
2013-10-19 12:10:16 +02:00
Jacob Erlbeck 2082afa76e gbproxy: Extended test program to simulate SGSN, too
This adds a simulation of the SGSN side of the Gbproxy. The VC is set
up correctly and several combinations of BSSGP messages are sent.

Sponsored-by: On-Waves ehf
2013-10-19 12:10:13 +02:00
Jacob Erlbeck e75fec60d0 gbproxy: Replace NS-VC references by NSEI
Currently in most places in gb_proxy.c a reference to a NS-VC object
is used where the peer is meant instead. The patch changes this by
using the NSEI instead in these cases.

Sponsored-by: On-Waves ehf
2013-10-15 15:19:29 +02:00
Jacob Erlbeck 51a869c80c gbproxy: Add test program to test gbproxy message handling
This program tests the gbproxy implementation by passing NS messages
to a modified gbproxy that dumps the resulting messages, signals, and
state.

It focusses on testing abnormal situations like port changes.

Ticket: OW#874
Sponsored-by: On-Waves ehf
2013-10-15 15:10:22 +02:00
Alexander Huemer 475f513aea ussd: Fix test for RELEASE COMPLETE
A correcsponding change in libosmocore sets text[0] to '\0'.
The test for 0xFF could never have been true.
2013-10-15 13:29:25 +02:00
Holger Hans Peter Freyther 8c90f47b09 misc: Require libosmocore 0.6.4 and libosmogb 0.6.4 2013-10-15 13:29:25 +02:00
Holger Hans Peter Freyther 7634ec1de1 db: Remove the struct gsm_network from the database layer
The database code should not know about the network. Move the
setting of the network pointer into the subscriber layer.
2013-10-13 13:44:54 +02:00
Alexander Chemeris 0c48fc7c62 abis: Consistent usage of LOGP/DEBUGP for "RSL CONNECT NACK" 2013-10-08 11:29:44 +02:00
Holger Hans Peter Freyther caa98d51b6 osmo-bts: Kill the different ROLE_BSC as e1inp_sign_link is used now 2013-10-06 15:52:14 +02:00
Alexander Chemeris bd6d40f1fb nitb: Add "subscriber create" VTY command.
It may be useful in production, but it's really required for
VTY testing of subscriber related commands.
2013-10-05 10:27:47 +02:00
Alexander Chemeris 4ad593c8f6 sms: Possiqble meamleak fix gsm340_rx_tpdu()
Slight clean up of the code in gsm340_rx_tpdu() and a fix for
an unlikely, but possible memory leak there.
2013-10-04 08:18:32 +02:00
Alexander Chemeris a3d41c9124 Fix typo in console output: "PEROIDOC" -> "PERIODIC". 2013-10-04 08:18:14 +02:00
Alexander Chemeris 8c16928beb Fix typo ',' -> ';' at the end of a line.
Funny, this is a correct C expression and doesn't change execution, thus it
stayed unnoticed for quite a while.
2013-10-04 08:18:01 +02:00
Alexander Chemeris 86d46c5c7a Fix copy-paste error in console output in db_test. 2013-10-04 08:17:52 +02:00
Jacob Erlbeck cc391b8880 bsc: Add control command to set timezone
This adds a per BTS control command 'timezone' which expects a value
of the format '<hours>,<mins>,<dst>' or 'off' to set the value of
bts->tz. It has the same functionality like the existing VTY command
'timezone' in network/bts.

Sponsored-by: On-Waves ehf
Ticket: OW#978
2013-10-01 17:25:44 +02:00
Holger Hans Peter Freyther 55e34a3325 smpp: Fix the make distcheck for smpp
DISTCHECK_CONFIGURE_FLAGS="--enable-smpp" make distcheck
2013-09-19 11:08:43 +02:00
Holger Hans Peter Freyther cb78612689 nat: Fix make distcheck for the nat
The jenkins runs make distcheck in the default configuration and
not with the nat enabled.

DISTCHECK_CONFIGURE_FLAGS="--enable-nat" make distcheck
2013-09-19 11:01:14 +02:00
Jacob Erlbeck 946d1415c2 bsc/mminfo: Patch timezone and DST in MM Info messages
This adds in-place patching of the time information in the
MM INFORMATION message. The timezone in the 'Local time zone' and
the 'Universal time and local time zone' information elements
and the offset in the 'Network Daylight Saving Time' information
element are optionally set.

The new values are determined by the 'timezone' vty command in the
config_net_bts node. That command is extended by an optional
DST offset parameter.

Tests are provided for the vty part and for the plain
bsc_scan_msc_msg() function.

Sponsored-by: On-Waves ehf
Ticket: OW#978
2013-09-19 10:57:13 +02:00
Ivan Kluchnikov 6792059d50 bsc: Add vty command for setting Access control classes. 2013-09-18 16:14:44 +02:00
Jacob Erlbeck 4f13d03213 ctrl: Set a generic reply when it hasn'n been set
When verification failed and the reply string was not updated, the
message "Someone forgot to fill in the reply." was shown instead
of the default "Value failed verification." message.

This patch changes the default reply handling in ctrl_cmd_handle()
by setting the reply to NULL initially and then checking it at the
end. If it hasn't been set, a generic message is assigned and an
error is logged.
2013-09-16 14:07:20 +02:00
Jacob Erlbeck 0760a83910 ctrl: Add test script for the BSC control interface
This script is similar to vty_test_runner.py but tests the control
interface instead.

It currently tests some error cases, BTS status queries, and
setting/clearing rf_locked.
2013-09-16 14:03:43 +02:00
Holger Hans Peter Freyther cd40fb4dea vty: Cosmetic change to the writing of the bts->model
Based on the feedback of Peter from the mailinglist, move the
writing code to a new method and return early if there is no
bts->model.
2013-09-16 14:03:43 +02:00
Jacob Erlbeck 779a72819d ctrl: Remember last 'rf_locked' control command
This stores the last SET rf_locked control command along with a
timestamp. The 'show network' vty command is extended to show
this information.

Ticket: OW#659
2013-09-11 20:27:08 +02:00
Jacob Erlbeck 733bec8626 vty: Hide unconfigured BTS on 'write'
This prevents the application from crashing when there is a half
configured BTS (e.g. by using the command 'bts 1' when there isn't
a BTS 1) and the 'write' command is used.
2013-09-11 20:20:33 +02:00
Jacob Erlbeck 56595f8647 ussd: Send USSD on call setup on MSC errors
Send an USSD message to the mobile station requesting a connection
for a call or a SMS when the link to the MSC is down or in the
grace period.

The messages can be set (and this feature activated) by setting
bsc/missing-msc-text resp. msc/bsc-grace-text via the vty.

The generation of both messages has been tested manually.

Ticket: OW#957
2013-09-11 20:18:42 +02:00
Holger Hans Peter Freyther 3ffd9bc0a4 bsc_msc: Fix possible null pointer dereference
In case the allocation of con is failing, do not attempt to
print con->name as this will be a null pointer dereference.

Fixes: Coverity CID 1076318
2013-09-04 08:45:48 +02:00
Holger Hans Peter Freyther 1b9902c128 nat: Remember the original dest local reference in the parsed struct
In case of the RLSD coming from the MSC we are patching the address
in-situ but for local calls set con = NULL. We then answered the RLSD
with the wrong reference and the MSC kept on trying.
2013-09-03 15:04:43 +02:00
Holger Hans Peter Freyther ff98b3cffa nat: Fix the log message of the code in case of an allocation failure
This wrong log message appears to be the result of copy and paste
2013-09-03 15:04:31 +02:00
Holger Hans Peter Freyther 33eb5873d9 bsc_msc: Stop the re-connect timer in case the msc is lost
It was possible to cause a crash by enabling and disabling the
MSC connection. The enabling lead to scheduling a connection
and the second call was not stopping the timer.
2013-09-03 15:04:17 +02:00
Holger Hans Peter Freyther c1a8687cb8 bsc_msc: Add a name field to the MSC Connection to differentiate links
Assign a static name to a MSC Connection and use it. In case there
are multiple connections we can now more easily identify them.

This is only used for the NAT right now, the BSC could start to
name the various MSC connections too.
2013-09-03 15:02:46 +02:00
Holger Hans Peter Freyther 0df1ab97a2 vty: Attempt to fix the build when SMPP is not enabled 2013-09-02 21:55:56 +02:00
Jacob Erlbeck 4c9dff5d8e vty: Rename 'mgcp-through-msc-ipa' command to 'use-msc-ipa-for-mgcp'
Currently the 'mgcp' command fails in the 'config-nat' node, because
it get confused with 'mgcp-through-msc-ipa' which is executed
instead because of the prefix based command selection. Thus the
latter command is renamed by this patch to avoid the common prefix.

The workaround in the test suite is removed.
2013-09-02 20:25:51 +02:00
Jacob Erlbeck 0ae92a950a vty: Use generic 'end' and 'exit' commands
Add bsc_install_default() and replace all install_default()

This patch adds bsc_install_default() which calls install_default()
and add 'exit' and 'end'. All other calls to install_default() are
replaced by calls to bsc_install_default().

Since 'exit' and 'end' are now added automatically to each node, the
explicit registrations of these commands are removed by this patch,
too.

The related tests succeed now without work-arounds (except for the
'config' node itself which is part of libosmocore).
2013-09-02 20:25:35 +02:00
Jacob Erlbeck 190acf6fd0 vty: Generalize ournode_exit() and ournode_end()
ournode_exit() duplicates most of bsc_vty_go_parent(). This patch
fixes the inconsistencies of both functions within
bsc_vty_go_parent() and replaces the implementation of
ournode_exit() by a call to it. This makes 'exit' behave exactly
like ^D in all openbsc nodes.

ournode_end() has been changed to walk through the intermediate
nodes until one of the top nodes is reached. This allows for
cleanups to be done on the way.

Note that in config mode if the tree is searched along the nodes
toward the config node and a command is not found this way, a
rollback is done by just replacing the vty's node and index member
variable by the saved old values which might break the whole thing, when
there has been a free() on the way.
2013-09-02 20:20:05 +02:00
Jacob Erlbeck 96903c4b2d vty: Add test to check vty node hierarchy and related commands
These tests check for the availability of 'exit' and 'end' in each
configuration node and for the node specific commands to traverse
the tree.
In addition, using these commands from within inner contexts is
checked. This will detect problems, when an outer command word is
a prefix of an inner command, like with 'mgcp' and
'mgcp-through-msc-ipa'.

Several assertions are disabled due to inconsistencies and missing
commands (see above).
2013-09-02 20:12:00 +02:00
Harald Welte 6a399efb72 SMPP: add missing VTY parameter 'deliver-src-imsi' for ESME
the parameter was already used in the code and saved from VTY code,
but somehow the functions for parsing it didn't make it into master.
2013-09-02 16:41:00 +02:00
Holger Hans Peter Freyther 6fcc3a9e8a nat: Attempt to follow the MODULE_METHOD pattern for methods
Rename methods to be like bsc_ussd_ACTION.
2013-09-02 11:11:16 +02:00
Holger Hans Peter Freyther 5741256703 nat: Use bsc_nat_msc_is_connected instead of accessing it directly 2013-09-02 11:00:09 +02:00
Holger Hans Peter Freyther c85ed4e8db bsc: Fix compiler warning about undeclare functions
Addresses:
osmo_bsc_sccp.c:280:2: warning: implicit declaration of function ‘gsm0480_send_ussdNotify’ [-Wimplicit-function-declaration]
osmo_bsc_sccp.c:281:2: warning: implicit declaration of function ‘gsm0480_send_releaseComplete’ [-Wimplicit-function-declaration]
2013-09-02 10:58:35 +02:00
Holger Hans Peter Freyther 9303df22bd nanobts: Fix initialization of two concurrent BTS.
It was possible that the wrong NSEI information was sent to the
BTS. This is because patch_nm_tables is not called before sending
the data to the BTS. This will break when two BTS connect more or
less at the same time.

Stop using the arrays directly and instead introduce a method
that will patch the table and return the data and length. This
makes sure that all users patch the table before we send the
data to the BTS.

I bootstrapped a sysmoBTS and I can bring up rsl. The device is
running with a dummy load so I couldn't do more verification.
2013-09-02 10:20:14 +02:00
Jacob Erlbeck 0b4f1b9e75 vty: Fix BSC_NODE prompt string
Change '%s(bsc)#' to '%s(config-bsc)# '. The missing trailing blank
breaks osmopy's VTYInteract.command() because the blank is contained
in the end patterns which are checked to decide whether to leave the
select loop. Thus trying to execute the 'bsc' command there blocks
the test script forever.
2013-08-31 15:55:16 +02:00
Jacob Erlbeck 97e139f267 bsc/vty: Add 'no bsc-welcome-text' command
There was no command to reset a bsc-welcome-text string, so it has
been added.
2013-08-28 11:10:44 +02:00
Jacob Erlbeck 1b894022fd bsc/ussd: Optionally send USSD message on MSC disconnection
Send an USSD message on each MS connection if the connection to
the MSC has been lost.
Add a vty config command 'bsc-msc-loss-txt' in 'config-msc' to set
the notification string and to enable the feature.

Ticket: OW#957
2013-08-28 11:10:44 +02:00
Holger Hans Peter Freyther 0c0e1c308f nat: Add example bsc entry for pablo 2013-08-27 21:32:29 +02:00
Pablo Neira Ayuso 326b5d80b3 libmgcp: add enum mgcp_role
This enum indicates if the mgcp is running on the BSC or the BSC-NAT.
2013-08-27 12:21:43 +02:00
Pablo Neira Ayuso d81fec021e libmgcp: attach mgcp_ prefix to udp_send
This patch is a cleanup.
2013-08-27 12:21:24 +02:00
Andreas Eversberg a874b8d396 Fix: Handle CM service request on already secured channel correctly
Second part of the previous patch. Log an error message in case
we receive a location updating request on an already authenticated
channel.
2013-08-18 10:32:45 +02:00
Pablo Neira Ayuso 66b52c1df8 libmgcp: add mgcp prefix to functions and constants
Functions and constants that belong to the libmgcp scope are prefixed
with mgcp_ and MGCP_. This patch is a cleanup.
2013-08-14 16:20:37 +02:00
Jacob Erlbeck 6cb2cccc8d nat/ussd: Add 'show ussd-connection' vty command
This command returns the current state of the connection to the USSD
side channel provider. It shows whether a provider has been connected
and authorized or not.

Fixes: OW#953
2013-08-14 12:07:07 +02:00
Holger Hans Peter Freyther 27876a2df0 nat: Fix potential memory leak when reading a message
Spotted while going through the code with Jacob. We could have
leaked the msgb in case of error.
2013-08-13 14:48:44 +02:00
Holger Hans Peter Freyther 9962151230 nat: Misc changes spotted while going through the file with Jacob
* Spell Configure correctly
* Use %s and VTY_NEWLINE instead of \n
2013-08-13 11:36:33 +02:00
Holger Hans Peter Freyther 3db24b5fe4 Merge branch 'laforge/smpp-fixes'
These commits have been deployed by sysmocom and it should qualify
as some form of smoke testing. Let's see how things go from here.
The by IMSI alertion has not been used, the rest should have been
executed by the system.
2013-08-03 19:22:38 +02:00
Harald Welte 045f402298 SMPP: use VTY setting for E212/E164 in ALERT NOTIFICATION
There's a VTY option by which for every ESME the user can specify if the
E.212 or E.164 number should be used in DELIVER-SM.  The ALERT
notifications generate by subscriber LU have so far always contained the
E.212 (IMSI) rather than E.164 (MSISDN) which is a bit inconsistent.

Rather than copying code, we create a new function that implements
ALERTing all ESMEs.
2013-08-03 19:20:37 +02:00
Harald Welte 99e273db00 SMPP: convert a SMMA to a SMPP ALERT NOTIFICATION 2013-08-03 19:20:36 +02:00
Harald Welte 1aeb2af75d SMPP: don't get stuck in case of SMS memory exceeded
If the MS memory for SMS is exceeded and we get an RP-layer error, we
need to report that back to the (transaction-mode) ESME.  Otherwise the
ESME will wait forever after sending a SUBMIT-SM without ever receiving
a response to it.

Thanks to Holger for catching this.
2013-08-03 19:20:36 +02:00
Holger Hans Peter Freyther 14d1177735 Merge branch 'zecke/features/big-rewrite' 2013-07-31 16:41:22 +02:00
Holger Hans Peter Freyther 52f705eaab nat: Use the DCC region for number rewriting and increase debug output 2013-07-31 16:36:40 +02:00
Holger Hans Peter Freyther 67e423c256 nat: Implement a post-routing for the NAT software
* The post-routing is applied after the first re-writing. To do this
  the new number is copied back into the called data structure.

* Add a testcase that goes from 0172 to 0049 and then back to 0049
  using the post rule with a table lookup.
2013-07-31 16:36:40 +02:00
Holger Hans Peter Freyther 3615a30d3d nat: Fix some memory leaks in the testcases.
The test cases did not free some of the resources it allocated.
Improve the situation a bit. There is still data allocated that
is not freed at exit.
2013-07-31 16:36:40 +02:00
Holger Hans Peter Freyther ddf191eafc nat: Allow to use the prefix lookup to rewrite numbers
* Increase the rewritten rule to five digits (this is the easiest
  for the unit test). This will add another 40kb to the runtime size.

* Create a unit test that tests adding and removing the prefix rules.

* Use the regexp match to replace from one package
2013-07-31 16:36:40 +02:00
Holger Hans Peter Freyther 85d3b34ed2 nat: Introduce a prefix lookup tree (trie) for number rewriting
* It is a trie. The max depth of the trie is the length of the
longest prefix. The lookup is O(lookuped_prefix), but as the prefix
length is limited, the lookup time is constant.

* Each node can hold the entire prefix, has place for the rewrite
  rule with up to three digits.

* A trie with 20k entries will take about 3MB ram.

* Filling the trie 100 times takes ~800ms on my i7 laptop

* 10.000.000 lookups take 315ms.. (for the same prefix).

* 93/99 lines are tested, 6/6 functions are tested, 49 of 54 branches
  are tested. Only memory allocation failures are not covered

* A late addition is to handle the '+' sign and to increase the number
  of chars in the rewrite prefix. The timing/line coverage has not
  been updated after this change.
2013-07-31 16:36:40 +02:00
Holger Hans Peter Freyther b718ad397e nat: Add a no number-rewrite command and call it through a VTY test
The test is just testing the invocation but does not verify that
the side effect of this call. It is good enought for now.
2013-07-31 16:36:13 +02:00
Holger Hans Peter Freyther aa93bac34b gprs_gmm: Avoid assertion in the sending code during routing area update
Use old and new tlli as specified by the caller.

WIP

<000f> sgsn_libgtp.c:321 Received DELETE PDP CTX CONF, cause=128(Request accepted)
<0013> gprs_sndcp.c:320 SNSM-DEACTIVATE.ind (lle=0x8095d08, TLLI=e3ddd574, SAPI=11, NSAPI=5)
<0011> gprs_bssgp.c:376 BSSGP TLLI=0xe3ddd574 Rx UPLINK-UNITDATA
<0012> gprs_llc.c:551 LLC SAPI=1 C   FCS=0xb85a96CMD=UI DATA
<0011> gprs_bssgp.c:376 BSSGP TLLI=0xe3ddd574 Rx UPLINK-UNITDATA
<0012> gprs_llc.c:551 LLC SAPI=1 C   FCS=0xbe5a96CMD=UI DATA
<0002> gprs_gmm.c:214 Starting MM timer 3350 while old timer 3350 pending
<0012> gprs_llc.c:417 LLC TX: unknown TLLI 0xe3ddd574, creating LLME on the fly
Assert failed msgb_tlli(msg) == mmctx->llme->tlli || msgb_tlli(msg) == mmctx->llme->old_tlli || tlli_foreign2local(msgb_tlli(msg)) == mmctx->llme->tlli || tlli_foreign2local(msgb_tlli(msg)) == mmctx->llme->old_tlli gprs_llc.c:123
backtrace() returned 18 addresses
/home/ich/install/openbsc/lib/libosmocore.so.4(osmo_generate_backtrace+0x16) [0xb7bb6a36]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x805224a]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804a2f6]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804b687]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804bc35]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804bd4e]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804d20c]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x8052be4]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn(bssgp_prim_cb+0x55) [0x804f5a4]
/home/ich/install/openbsc/lib/libosmogb.so.2(bssgp_rcvmsg+0x3b8) [0xb7b626b8]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804f4f1]
/home/ich/install/openbsc/lib/libosmogb.so.2(gprs_ns_rcvmsg+0x8c7) [0xb7b5ecf7]
/home/ich/install/openbsc/lib/libosmogb.so.2(+0x4311) [0xb7b5f311]
/home/ich/install/openbsc/lib/libosmocore.so.4(osmo_select_main+0x192) [0xb7bb2ed2]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x804fbcd]
/lib/i386-linux-gnu/i686/cmov/libc.so.6(__libc_start_main+0xf5) [0xb796a8f5]
/home/ich/source/gsm/openbsc/openbsc/src/gprs/osmo-sgsn() [0x8049db1]

Program received signal SIGABRT, Aborted.
0xb7fde424 in __kernel_vsyscall ()
(gdb) bt
 #0  0xb7fde424 in __kernel_vsyscall ()
 #1  0xb797f83f in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 #2  0xb7982cf3 in __GI_abort () at abort.c:90
 #3  0x0805224f in _bssgp_tx_dl_ud (mmctx=0x80932d0, msg=0x80963a8) at gprs_llc.c:120
 #4  gprs_llc_tx_ui (msg=0x80963a8, sapi=1 '\001', command=0, mmctx=0x80932d0)
    at gprs_llc.c:496
 #5  0x0804a2f6 in gsm48_gmm_sendmsg (msg=0x80963a8, command=0, mm=0x80932d0) at gprs_gmm.c:241
 #6  0x0804b687 in gsm48_tx_gmm_ra_upd_ack (mm=0x80932d0) at gprs_gmm.c:851
 #7  0x0804bc35 in gsm48_rx_gmm_ra_upd_req (mmctx=0x80932d0, msg=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1004
 #8  0x0804bd4e in gsm0408_rcv_gmm (mmctx=0x80932d0, msg=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1036
 #9  0x0804d20c in gsm0408_gprs_rcvmsg (msg=msg@entry=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1566
 #10 0x08052be4 in gprs_llc_rcvmsg (msg=0x8091ce8, tv=0xbfffdcb0) at gprs_llc.c:882
 #11 0x0804f5a4 in bssgp_prim_cb (oph=oph@entry=0xbfffdc8c, ctx=ctx@entry=0x0)
    at sgsn_main.c:114
 #12 0xb7b626b8 in bssgp_rx_ul_ud (tp=0xbfffdcb0, msg=0x8091ce8, ctx=<optimized out>)
    at gprs_bssgp.c:398
 #13 bssgp_rx_ptp (bctx=0x8091a08, tp=0xbfffdcb0, msg=0x8091ce8) at gprs_bssgp.c:820
 #14 bssgp_rcvmsg (msg=0x8091ce8) at gprs_bssgp.c:1016
 #15 0x0804f4f1 in sgsn_ns_cb (event=GPRS_NS_EVT_UNIT_DATA, nsvc=0x8090740, msg=0x8091ce8,
    bvci=1801) at sgsn_main.c:92
 #16 0xb7b5ecf7 in gprs_ns_rx_unitdata (msg=0x8091ce8, nsvc=0x8090740) at gprs_ns.c:616
 #17 gprs_ns_rcvmsg (nsi=nsi@entry=0x807fd38, msg=msg@entry=0x8091ce8,
    saddr=saddr@entry=0xbfffedc0, ll=ll@entry=GPRS_NS_LL_UDP) at gprs_ns.c:841
 #18 0xb7b5f311 in handle_nsip_read (bfd=0x807fd58) at gprs_ns.c:991
 #19 nsip_fd_cb (bfd=0x807fd58, what=1) at gprs_ns.c:1024
 #20 0xb7bb2ed2 in osmo_select_main (polling=0) at select.c:158
 #21 0x0804fbcd in main (argc=3, argv=0xbffff234) at sgsn_main.c:369
(gdb) frame 5
 #5  0x0804a2f6 in gsm48_gmm_sendmsg (msg=0x80963a8, command=0, mm=0x80932d0) at gprs_gmm.c:241
241		return gprs_llc_tx_ui(msg, GPRS_SAPI_GMM, command, mm);
(gdb) p msgb_tlli(msg)
$1 = 3822966132
(gdb) frame 4
 #4  gprs_llc_tx_ui (msg=0x80963a8, sapi=1 '\001', command=0, mmctx=0x80932d0)
    at gprs_llc.c:496
496		return _bssgp_tx_dl_ud(msg, mmctx);
(gdb) p mmctx
$2 = (void *) 0x80932d0
(gdb) frame 3
 #3  0x0805224f in _bssgp_tx_dl_ud (mmctx=0x80932d0, msg=0x80963a8) at gprs_llc.c:120
120			OSMO_ASSERT(msgb_tlli(msg) == mmctx->llme->tlli
(gdb) p mmctx
$3 = (struct sgsn_mm_ctx *) 0x80932d0
(gdb) p *mmctx
$4 = {list = {next = 0x8092e28, prev = 0x805c318 <sgsn_mm_ctxts>},
  imsi = "901700000003094\000", mm_state = GMM_REGISTERED_NORMAL, p_tmsi = 296043751,
  p_tmsi_old = 2075232571, p_tmsi_sig = 0, imei = "353943044782210\000",
  msisdn = '\000' <repeats 14 times>, ra = {mnc = 70, mcc = 901, lac = 1, rac = 0 '\000'},
  cell_id = 0, cell_id_age = 0, sac = 0, sac_age = 0, new_sgsn_addr = 0,
  ciph_algo = GPRS_ALGO_GEA0, ms_radio_access_capa = {len = 11 '\v',
    buf = "4\307\003*\240B|\255\341\030\v", '\000' <repeats 38 times>}, ms_network_capa = {
    len = 2 '\002', buf = "\345\200\000\000\000\000\000"}, drx_parms = 3329, mnrg = 0,
  ngaf = 0, ppf = 0, recovery = 0, radio_prio_sms = 0 '\000', pdp_list = {next = 0x8093390,
    prev = 0x8093390}, llme = 0x8095630, tlli = 3822966132, tlli_new = 3517269223,
  nsei = 1801, bvci = 1801, ctrg = 0x8096048, timer = {node = {rb_parent_color = 3082574944,
      rb_right = 0x0, rb_left = 0x0}, list = {next = 0x80933b8, prev = 0x80933b8}, timeout = {
      tv_sec = 1375260414, tv_usec = 864196}, active = 1, cb = 0x804bfd0 <mmctx_timer_cb>,
    data = 0x80932d0}, T = 3350, num_T_exp = 0, t3350_mode = GMM_T3350_MODE_RAU,
  t3370_id_type = 1 '\001'}
(gdb) p msgb_tlli(msg)
No symbol "msgb_tlli" in current context.
(gdb) frame 5
 #5  0x0804a2f6 in gsm48_gmm_sendmsg (msg=0x80963a8, command=0, mm=0x80932d0) at gprs_gmm.c:241
241		return gprs_llc_tx_ui(msg, GPRS_SAPI_GMM, command, mm);
(gdb) frame 6
 #6  0x0804b687 in gsm48_tx_gmm_ra_upd_ack (mm=0x80932d0) at gprs_gmm.c:851
851		return gsm48_gmm_sendmsg(msg, 0, mm);
(gdb) p msgb_tlli(msg)
$5 = 3822966132
(gdb) p mmctx->tlli
No symbol "mmctx" in current context.
(gdb) p mm->tlli
$6 = 3822966132
(gdb) p mm->tlli_new
$7 = 3517269223
(gdb) p mm->llme->tlli
$8 = 3517269223
(gdb) p mm->llme->tlli_old
There is no member named tlli_old.
(gdb) p mm->llme->old_tlli
$9 = 4222716219
(gdb) bt
 #0  0xb7fde424 in __kernel_vsyscall ()
 #1  0xb797f83f in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 #2  0xb7982cf3 in __GI_abort () at abort.c:90
 #3  0x0805224f in _bssgp_tx_dl_ud (mmctx=0x80932d0, msg=0x80963a8) at gprs_llc.c:120
 #4  gprs_llc_tx_ui (msg=0x80963a8, sapi=1 '\001', command=0, mmctx=0x80932d0)
    at gprs_llc.c:496
 #5  0x0804a2f6 in gsm48_gmm_sendmsg (msg=0x80963a8, command=0, mm=0x80932d0) at gprs_gmm.c:241
 #6  0x0804b687 in gsm48_tx_gmm_ra_upd_ack (mm=0x80932d0) at gprs_gmm.c:851
 #7  0x0804bc35 in gsm48_rx_gmm_ra_upd_req (mmctx=0x80932d0, msg=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1004
 #8  0x0804bd4e in gsm0408_rcv_gmm (mmctx=0x80932d0, msg=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1036
 #9  0x0804d20c in gsm0408_gprs_rcvmsg (msg=msg@entry=0x8091ce8, llme=0x8095630)
    at gprs_gmm.c:1566
 #10 0x08052be4 in gprs_llc_rcvmsg (msg=0x8091ce8, tv=0xbfffdcb0) at gprs_llc.c:882
 #11 0x0804f5a4 in bssgp_prim_cb (oph=oph@entry=0xbfffdc8c, ctx=ctx@entry=0x0)
    at sgsn_main.c:114
 #12 0xb7b626b8 in bssgp_rx_ul_ud (tp=0xbfffdcb0, msg=0x8091ce8, ctx=<optimized out>)
    at gprs_bssgp.c:398
 #13 bssgp_rx_ptp (bctx=0x8091a08, tp=0xbfffdcb0, msg=0x8091ce8) at gprs_bssgp.c:820
 #14 bssgp_rcvmsg (msg=0x8091ce8) at gprs_bssgp.c:1016
 #15 0x0804f4f1 in sgsn_ns_cb (event=GPRS_NS_EVT_UNIT_DATA, nsvc=0x8090740, msg=0x8091ce8,
    bvci=1801) at sgsn_main.c:92
 #16 0xb7b5ecf7 in gprs_ns_rx_unitdata (msg=0x8091ce8, nsvc=0x8090740) at gprs_ns.c:616
 #17 gprs_ns_rcvmsg (nsi=nsi@entry=0x807fd38, msg=msg@entry=0x8091ce8,
    saddr=saddr@entry=0xbfffedc0, ll=ll@entry=GPRS_NS_LL_UDP) at gprs_ns.c:841
 #18 0xb7b5f311 in handle_nsip_read (bfd=0x807fd58) at gprs_ns.c:991
 #19 nsip_fd_cb (bfd=0x807fd58, what=1) at gprs_ns.c:1024
 #20 0xb7bb2ed2 in osmo_select_main (polling=0) at select.c:158
 #21 0x0804fbcd in main (argc=3, argv=0xbffff234) at sgsn_main.c:369
(gdb) frame 3
 #3  0x0805224f in _bssgp_tx_dl_ud (mmctx=0x80932d0, msg=0x80963a8) at gprs_llc.c:120
120			OSMO_ASSERT(msgb_tlli(msg) == mmctx->llme->tlli
(gdb) p msgb_tlli(msg)
No symbol "msgb_tlli" in current context.
(gdb) frame 4
 #4  gprs_llc_tx_ui (msg=0x80963a8, sapi=1 '\001', command=0, mmctx=0x80932d0)
    at gprs_llc.c:496
496		return _bssgp_tx_dl_ud(msg, mmctx);
(gdb) p msgb_tlli(msg)
No symbol "msgb_tlli" in current context.
(gdb) frame 5
 #5  0x0804a2f6 in gsm48_gmm_sendmsg (msg=0x80963a8, command=0, mm=0x80932d0) at gprs_gmm.c:241
241		return gprs_llc_tx_ui(msg, GPRS_SAPI_GMM, command, mm);
(gdb) p msgb_tlli(msg)
$10 = 3822966132
(gdb) p mm->tlli
$11 = 3822966132
(gdb) p mm->tlli_new
$12 = 3517269223
(gdb) p mm->tlli_new
$13 = 3517269223
(gdb) p mm->llme->tlli
$14 = 3517269223
(gdb) p mm->llme->tlli_old
There is no member named tlli_old.
(gdb) p mm->llme->old_tlli
$15 = 4222716219
(gdb) p mm->llme->state
$16 = GPRS_LLMS_ASSIGNED
(gdb) q
2013-07-31 16:12:02 +02:00
Holger Hans Peter Freyther 7e0fec17ce gprs_llc: Assert that we send frames with either tlli or old_tlli
In case we have access to the context verify that the selected
msgb_tlli is either the old_tlli or the tlli in either local or
foreign format. It is wrong to use any other TLLI.
2013-07-31 14:57:21 +02:00
Holger Hans Peter Freyther 964a9b3e20 gprs_llc: Work on finding the right LLE/LLME in case of routing area update
Attempt to solve what f0901f0067 tried to
solve without breaking the case of someone with a foreign TLLI from a
different network.

Lookup with the foreign TLLI converted to a local one in case we did
not find the TLLI and only then create a LLE/LLME on the fly for the
RX path.
2013-07-31 14:57:21 +02:00
Holger Hans Peter Freyther 012a7eec29 gprs_llc: Lookup lle based on the real TLLI
During the GPRS Attach procedure we might have a foreign tlli and
in the RX create a LLME on the fly for this tlli. The GMM GPRS
Attach handling code will then assign a new TLLI and keep the
foreign tlli as the llme->old_tlli.

When the GMM is sending the identity request the msgb_tlli will
point to the foreign tlli. The GPRS LLC code will then try to find
that foreign tlli but due the conversion this will not be found.
Instead a new ad-hoc LLE/LLME will be created on the fly for
each message (this means there are duplicate LLE/LLMEs in the
list).

Make the code more strict and remove the tlli_foreign2local change
from the look-up routine. This will make the GPRS LLC code find
the right LLE/LLME and the N(U) will be handled correctly.

This partially reverts:
  f0901f0067

Addresses:
  <0012> gprs_llc.c:773 LLC RX: unknown TLLI 0xadf11820, creating LLME on the fly
  ...
  <0012> gprs_llc.c:357 LLC TX: unknown TLLI 0xedf11820, creating LLME on the fly

Reproducable:
  Use pcu_emu (gprs attach) and observe with wireshark.
2013-07-31 14:57:21 +02:00
Holger Hans Peter Freyther 598e7b3cdf gprs_sgsn: In case of a Activate PDP Context timeout we should free pdp
In case of a failure this method didn't set the pctx->lib back to
NULL. In case of a timeout the callback will be made with pdp=NULL
and this would lead to leaking the PDP context. Check for the case
of having a pctx->lib != pdp and free it.

This resolves:
<000f> gprs_sgsn.c:259 freeing PDP context that still has a libgtp handle attached to it, this shouldn't happen!
2013-07-31 14:57:21 +02:00
Holger Hans Peter Freyther 92aa6bb9dc gprs: Fix a typo in the comment 2013-07-28 20:13:01 +02:00
Holger Hans Peter Freyther c0438e3587 tests: TestCase.assertGreater is not available on Python 2.5
The jenkins build node has Python 2.5.X installed and the
assertGreater method is not available. Use assert_ until
we can use newer versions of Python.
2013-07-27 22:23:25 +02:00
Holger Hans Peter Freyther c63f6f1f32 expiration: Allow to disable the periodic location updating procedure
Disable the periodic LU using "no periodic location update" VTY
command. In that case set the expire_lu to 0 which will then be
translated to a NULL in the database layer. This leads to a bit of
copy and paste in the db_sync_subscriber method but I don't see
how we could easily use 'datetime(%i, 'unixepoch')' and 'NULL'
at the same time.

Change the query to find expired queries to check for NOT NULL
and the time being in the past. This means if there are still
old subscribers in the database they might not be expired. One
would need to execute a query like "UPATE Subscriber SET expire_lu
= 0 WHERE expire_lu is null". The same applies when disabling the
periodic LU. One would need to update the database by hand.

Manual tests executed/passed:

1.) periodic LU enabled:

  * use gst LUTest.st to do a LU
  * UPDATE Subscriber SET expire_lu=datetime('now');
  * observe the subscriber being expired (it was)

2.) periodic LU disabled:

  * use gst LUTest.st to do a LU
  * verify that the expire_lu is NULL in the database
2013-07-27 22:02:24 +02:00
Holger Hans Peter Freyther e7bd863f76 expiration: Speculative fixes for the periodic expiring handling
We were expiring subscribers during active calls. This is because
the T3212 is stopped under certain conditions but we didn't stop
that timer at all.

Remember if T3212 timer was stopped due something done by NITB and
update the expiration time at the end of the radio connection, as
the phone should restart it when returning to MM Idle.

It is a bit difficult to decide when we should set the flag. E.g.
in a CM Service Request we don't know if we accept the service and
during a LU we already send MM messages before we accept or reject
the subscriber.

The easiest is to set the flag when receiving a paging response
on known subscribers and at the end of the authentication process.

Do not expire a subscriber that has an active connection that is
marked with the flag, e.g. we would still expire a subscriber that
is being paged.

Manual tests executed/passed:

 * gst LUTest.st verified that a expiration date was set
 * gst SMSTest.st (doing another LU but forcing a timeout on the
   SMS sending). Verified that the expire_lu was updated.
2013-07-27 21:39:13 +02:00
Holger Hans Peter Freyther b97089432f expiration: Print the "expire_lu" time in show subscriber
This can help with debugging subscriber expiration issues.
2013-07-27 20:03:11 +02:00
Holger Hans Peter Freyther a7328a5642 smpp: Move the coding/mode detection into a utils file
Make sure to not ever have issues with this code again, move the
utility code to a new file and create a basic testcase. The method
currently has 100% line and branch coverage. My initial patched
missed the smpp_utils.c file and I re-did the copying (and verifying
the branch coverage)
2013-07-27 20:03:10 +02:00
Holger Hans Peter Freyther 5ecbc93656 misc: Fix compilation warnings
bsc_api.c:417:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘unsigned int’ [-Wformat]
bsc_api.c: In function ‘handle_ass_fail’:
bsc_api.c:458:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘unsigned int’ [-Wformat]

db.c: In function ‘db_sync_subscriber’:
db.c:785:3: warning: format ‘%i’ expects argument of type ‘int’, but argument 8 has type ‘time_t’ [-Wformat]

osmo_msc.c: In function ‘msc_release_connection’:
osmo_msc.c:145:20: warning: unused variable ‘trans’ [-Wunused-variable]

smpp_smsc.c: In function ‘link_accept_cb’:
smpp_smsc.c:891:24: warning: assignment from incompatible pointer type [enabled by default]

smpp_smsc.c:271:1: warning: ‘esme_by_system_id’ defined but not used [-Wunused-function]

smpp_openbsc.c: In function ‘smpp_openbsc_init’:
smpp_openbsc.c:545:2: warning: implicit declaration of function ‘smpp_vty_init’ [-Wimplicit-function-declaration]

osmo_bsc_ctrl.c: In function ‘verify_bts_loc’:
osmo_bsc_ctrl.c:340:19: warning: variable ‘height’ set but not used [-Wunused-but-set-variable

smpp_mirror.c: In function ‘main’:
smpp_mirror.c:297:2: warning: implicit declaration of function ‘osmo_init_logging’ [-Wimplicit-function-declaration]
2013-07-27 20:03:08 +02:00
Harald Welte 649e1ff4b3 sgsn: spelling fixes inside comments 2013-07-21 17:41:46 +08:00
Harald Welte b4b21f59f6 SMPP: complete the VTY help/documentation
As discovered by osmotestconfig.py, a number of SMPP related VTY
commands were missing their help/documentation text.
2013-07-21 16:00:28 +08:00
Harald Welte badb12f6a6 remove 'bind early' from osmo-bsc_mgcp example config
(discovered by osmotestconfig.py)
2013-07-21 15:52:40 +08:00
Harald Welte 3dfb549a6f sgsn: Add "auth-policy" VTY command to enable/disable ACL 2013-07-21 15:44:28 +08:00
Harald Welte 7f6da485f5 sgsn: add a minimalistic ACL
This adds a minimalistic ACL by which certain, individual roaming IMSIs
can be authorized to use the SGSN.  So you can selectively bypass the
'MCC+MNC == first 5 digits of IMSI' checking for a couple of IMSIs
2013-07-21 15:44:24 +08:00
Holger Hans Peter Freyther cb5353d851 oml: Add a missing break switch for NM_OC_BS11
It appears to me that for NM_OC_BS11 mo was either NULL or the
one mo value from NM_OC_BS11_RACK. The break inside the nested
switch case didn't break from the outer one.

Fixes Coverity: CID 1040728
2013-07-18 12:03:31 +02:00
Holger Hans Peter Freyther 1b624ba1f6 smpp: Close the file descriptor when we can't accept the SMSC conn
When we failed to allocate the memory or failed to register the
fd we would have leaked the file descriptor. Close the fd and
avoid the leak.
2013-07-14 09:04:51 +02:00
Holger Hans Peter Freyther c962d45669 smpp: Add the classic check for osmo_fd_register
In case the osmo_fd_register will fail we will need to free the
memory we have allocated.

Fixes: Coverity CID 1042375
2013-07-14 09:04:51 +02:00
Holger Hans Peter Freyther 921b2278df smpp: Fix possible NULL dereference of the emse->acl
The esme->acl is treated like it can be NULL in other places
of the code. Assume it can be NULL during this check as well.

Dereference after null check (FORWARD_NULL)
9. var_deref_op: Dereferencing null pointer "esme->acl".

Fixes: Coverity CID 1042374
2013-07-14 09:04:51 +02:00
Holger Hans Peter Freyther ae9d8d3131 smpp: Checking an array for NULL will always be false
The if (submit->short_message) and if (smsc->system_id) will
always be true.

Fixes: Coverity CID 1042371, CID 1042372
2013-07-14 09:04:50 +02:00
Holger Hans Peter Freyther c9251fa8c9 ipaccess: The proxy code checked the array but not the element
Array compared against 0 (NO_EFFECT)
array_null: Comparing an array to null is not useful: "ipbc->bsc_rsl_conn".

Fixes: Coverity CID 1040718
2013-07-14 09:04:50 +02:00
Holger Hans Peter Freyther 3aedba66bd ipaccess: Fix a resource leak in case the stat is failing
Close the file when the stat is failing.

Fixes: Coverity CID 1040711
2013-07-14 09:04:50 +02:00
Holger Hans Peter Freyther 5ccd015371 nitb: The subscr->imsi is an array will never be NULL
Array compared against 0 (NO_EFFECT)
array_null: Comparing an array to null is not useful: "subscr->imsi"

Fixes: Coverity CID 1040716
2013-07-14 09:04:50 +02:00
Harald Welte 995ff35f39 Fix license header at smpp_openbsc.c and smpp_smsc.c
As Holger pointed out, they contained a GPLv2+ disclaimer rather than
the AGPLv3+ which we use for OpenBSC.  This is not an incompaibility,
but was done unintentionally.  The code was always mean to be under
AGPLv3+.

Nevertheless, anyone using those two files in a version up to this
commit have the right to use it under GPLv2+ as well.  This is not
applicable for any versions after this commit.
2013-07-13 16:35:32 +02:00
Harald Welte 4c5babc06c smpp_openbsc: Fix parsing of 03.38 data coding scheme in MO case 2013-07-11 14:29:31 +02:00
Andreas Eversberg 641475cb81 Fix: Handle CM service request on already secured channel correctly
A CM service request must be acknowledged also, when encryption is already
enabled.

Without encryption enabled, the security status is GSM_SECURITY_NOTAVAIL,
which causes a CM service acknowledge. On initial CM service request, the
security status is GSM_SECURITY_SUCCEED, if encryption is enabled. This
will not lead to an acknowledge, because the cyphering command implies an
acknowlege. An additional CM service request requires an acknowledge, so
I added a new security status: GSM_SECURITY_ALREADY
2013-07-11 08:27:26 +02:00
Pablo Neira Ayuso 46bd4244a1 libmgcp: add enum mgcp_type and use it
This patch replaces the field 'is_transcoded' in the mgcp_endpoint
structure by the enum mgcp_type, that can be further extended with
new types.
2013-07-08 16:46:06 +02:00
Holger Hans Peter Freyther 1e61b25661 mncc: Remove what we believe to be a tautology from the MNCC code
Coverity pointed out that we use trans->subscr after a NULL check,
it is our believe that every transaction will have a subscriber.
Remove the check and add an assert before we are dispatching things.

Fixes: Coverity CID 1040740, CID 1040739
2013-07-06 11:45:38 +02:00
Holger Hans Peter Freyther 096dc3a466 nat: The con variable is not assigned at this point
Coverity pointed out that this code is logically dead. Quickly
judging the code we will forward the RSLD message anyway. Remove
the code for now and next time I work on the NAT/USSD bridge I
will have a look at the flow of the RLSD messages.

Fixes: Coverity CID 1042327
2013-07-05 08:22:03 +02:00
Holger Hans Peter Freyther 7346081ba3 nat: number could point to an address on the stack that can be reused
The number = int_number assignment will make the number point to
the stack and as the int_number goes out of scope at the end of
the if statement other code could re-use this stack for other memory.

Fixes: Coverity CID 1042325
2013-07-05 07:50:30 +02:00
Holger Hans Peter Freyther 9bec10ecd3 nat: Address coverity warning about uninitialized addr
Use memset on the addr to initialize the entire structure.

Fixes: Coverity CID 1042324
2013-07-05 07:48:04 +02:00
Holger Hans Peter Freyther b0b8a34dd5 nat: Please coverity and initialize the saveptr to NULL
Coverity complains about the saveptr used in the strtok_r. This
is not a bug because we pass a string as part of the first call
to strtok_r but it is easier to just initialize it.

Addresses: Coverity CID 1042323
2013-07-05 07:45:08 +02:00
Holger Hans Peter Freyther 9feef48eaf nitb: Add a missing NULL check for searching the subscriber
"subscriber " SUBSCR_TYPES " ID sms pending-send

could fail with an invalid ID/IMSI for the subscriber.

Fixes: Coverity CID 1040715
2013-07-04 20:34:46 +02:00
Holger Hans Peter Freyther e885951f27 db: Fix an issue with the memset
We want to memset the entire area of the atuple and not just the
first four/eight bytes of the data.

Fixes: Coverity CID 1040708
2013-07-04 20:24:02 +02:00
Holger Hans Peter Freyther 81cff91ec0 gsm_subscriber: Fix compiler warning of the printf string
This fixes both a GCC and a Coverity warning:

GCC:
gsm_subscriber.c: In function ‘subscr_expire_callback’:
gsm_subscriber.c:389:2: warning: format ‘%i’ expects argument of type ‘int’, but argument 8 has type ‘long long unsigned int’ [-Wformat]

Coverity:
CID 1040712
2013-07-04 20:22:27 +02:00
Holger Hans Peter Freyther 7b76934f03 nat: The second call didn't really add anything to the test.
Avoid: Coverity CID 1042323
2013-07-04 20:19:44 +02:00
Holger Hans Peter Freyther b18c7456cb ipaccess-config: Add missing break to parsing the -L option
Fixes: Coverity CID 1040738
2013-07-04 18:51:07 +02:00
Holger Hans Peter Freyther 7d8139a42e ipaccess-config: Fix a resource leak in an error path
Fixes: Coverity CID 1040710, CID 1040711
2013-07-04 18:49:04 +02:00
Holger Hans Peter Freyther aa63d70f39 sgsn: Fix the unimplemented/uninstalled show ggsn command
This is fixing a GCC and Coverity warning.

GCC:
sgsn_vty.c: At top level:
sgsn_vty.c:308:1: warning: ‘show_ggsn_cmd’ defined but not used [-Wunused-variable]

Coverity: CID 1040727
2013-07-04 18:45:31 +02:00
Holger Hans Peter Freyther 80e036560d sgsn_vty: Fix uninitialized variable in the gprs_apn2str method
This is fixing a GCC and Coverity warning:

GCC:
sgsn_vty.c: In function ‘vty_dump_pdp’:
sgsn_vty.c:64:5: warning: ‘i’ may be used uninitialized in this function [-Wmaybe-uninitialized]
sgsn_vty.c:49:15: note: ‘i’ was declared here

Coverity: CID 1040706
2013-07-04 18:44:16 +02:00
Holger Hans Peter Freyther 3a708afe63 sgsn: Fix logically dead code in regard to the osmo_fd_register
The code was written like checking the return value of the
osmo_fd_register but the rc variable was not assigned for the
subsequent calls.

Fixes: Coverity CID 1040741
2013-07-04 18:39:52 +02:00
Alexander Chemeris 84402c0c82 sgsn: Fix lengths of MS Network Capability and MS Radio Access Capability elements.
Original code was inconsistent about lengths and could lead to out
of bounds write. Lengths were also inconsistent with the TS 24.008.

Fixes: Coverity CID 1040714.
2013-07-04 18:34:49 +02:00
Holger Hans Peter Freyther f0167ddfc2 hsl: Remove the support for the HSL bts from OpenBSC
The support has been implemented for an old model, we were told that
newer versions would be made incompatible with OpenBSC. Ther are
various warnings in the code and coverity has found some new ones.

Just remove the code as we don't know of anyone using this code.
2013-07-03 16:19:41 +02:00
Holger Hans Peter Freyther a164d5291e nat: Fix compiler warning and cast uint16_t to uint8_t 2013-07-03 16:18:37 +02:00
Holger Hans Peter Freyther 1eba7de0c2 mgcp: Make sure the save pointer is initialized with NULL.
Coverity is not happy about it but it doesn't appear to be a real
issue as the data will not be NULL on the first call.

Addresses: Coverity CID 1040704
2013-07-03 10:23:35 +02:00
Holger Hans Peter Freyther d5c270e71c ipaccess-find: Address a warning by coverity of unitialized memory
Use a memset on the sockaddr_in to make coverity happy.

Fixes: CID 1040705
2013-07-03 10:19:37 +02:00
Holger Hans Peter Freyther 8690b98e7c isdnsync: Remove a double close of the isdn device
The fd is already closed above the if statement and Coverity
detected this as a double close.

Fixes: Coverity CID 1040703
2013-07-03 10:17:37 +02:00
Holger Hans Peter Freyther 8bb0720ebb nanobts: Do not crash on an invalid TRX number
In case the specified trx number is not configured, do not crash
but return NULL from the function. The libosmo-abis library should
close the connection for us then.
2013-06-30 20:11:46 +02:00
Holger Hans Peter Freyther eb0acb6e02 tests: Add a custom test runner to test the VTY functionality.
Begin with the NAT code. It is not clear yet if we will have one
file with all the tests or will have a sub directory with *.py files.
In the long run the base class will move to the osmo-python-tests
module.
2013-06-24 16:13:55 +02:00
Holger Hans Peter Freyther 9e22e69266 misc: Ignore compiled python code and another test case 2013-06-24 14:04:55 +02:00
Katerina Barone-Adesi e0aee7aaa9 Introduced support for external python tests
The test scripts warn about missing documentation, untested configs,
check common errors, and stub out testing individual VTY commands.
The scripts have been moved to the another osmocom repository,
python/osmo-python-tests

The features were requested by zecke.
2013-06-24 13:22:34 +02:00
Harald Welte cc6b2d2fa3 ctrlif: Flush/Clear write_queue when closing the control socket 2013-06-24 10:59:40 +02:00
Harald Welte 1304b35a64 bsc_vty: Print human-readable string version of NM ADM STATE 2013-06-24 10:59:33 +02:00
Harald Welte abadd54346 GPRS LLC: Add non-standard method of sequence number recovery
In some situations (like MS reboot without prior DETACH or SGSN reboot
without prior MS detach), the LLC sequence numbers for UI mode could
be different on both sides.

The LLC spec unfortunately doesn't permit us to send something like a
FRMR in this case, but instructs us to silently discard the frame.  At
that time the remote LLC entity will re-transmit the frame with the same
seqeunce number over and over again, which we will drop again and again.

The mthod used now will keep track of the last received UI sequence
number.  If that number is retransmitted for three times in a row, then
we accept this sequence number and recover from that point on.
2013-06-21 14:06:18 +02:00
Harald Welte 22ce59826a osmo-bsc VTY: fix saving of codec-list
the codec-list parser expects only spaces between the elements of the
list, while the 'save' code is putting ", " between the elements
2013-06-19 15:42:44 +02:00
Holger Hans Peter Freyther b0bf1da4c8 smpp: Only write the systemd-id if it is not empty
system_id is a char array, which makes the NULL check a tautology,
so we should check with strlen if the string is empty or not.

This is fixing the "write" command of VTY that would otherwise
create a config file that can not be parsed.
2013-06-12 09:35:43 +02:00
Alexander Huemer a1c09a401d Makefile.am: Use AM_CPPFLAGS
Since automake 1.13 INCLUDES is depricates and causes a warning
2013-06-12 09:16:27 +02:00
Holger Hans Peter Freyther 846d8dca9f vty: Print the state of all GPRS OML objects in show bts
For debugging GB-proxy/IPA issues it is nice to see the state of
the OML objects.
2013-05-29 16:37:27 +02:00
Harald Welte c75ed6d593 SMPP: Add new 'dcs_transparent' ESME setting
If an ESME has the dcs_transparent config flag, then the TP-DCS
of MO-SMS is transparently passed to SMPP and not converted to SMPP
specific data_coding values.

This is needed in cases where ESMEs actually care about the exact
TP-DCS, as the conversion from TP-DCS to SMPP data_coding is not
bijective.
2013-05-28 20:59:25 +02:00
Harald Welte 27d5e65640 SMPP: Pass on 0xFx style DCS from SMPP to GSM
There are multiple ways how the TS 03.38 TP-DCS can indicate 8bit or
7bit messages.  SMPP has it's own data coding specification, which is
different from TS 03.38.

However, some SMPP ESMEs want to be able to have fine-grained control
over the TP-DCS indicated in the TPDU header.  If such values like 0xF6
are used in SMPP, we now transparently pass them on to the GSM side.
2013-05-28 20:37:07 +02:00
Harald Welte 61e1935a5f SMPP: Respond with BIND_TRX_RESP to BIND_TRX, not BIND_TX_RESP 2013-05-26 14:40:14 +02:00
Holger Hans Peter Freyther 9f3835b988 mgcp: Initialize the tone to CHAR_MAX as this might not be a request
The RQNT message might not contain a 'S:' line with the actual tone
to play. Instead of calling the callback with the 0 as tone just leave
early.

Example:
X: 6B9519B88F0
R: D/[0-9#*](N), G/ft, fxr/t38
2013-05-21 17:04:35 +02:00
Pablo Neira Ayuso 0a244b40c9 nat: fix use after free in forward_sccp_to_bts
valgrind detected an use after free in the path of forward_sccp_to_bts.
The 'parsed' object is referenced from update_con_authorize.
2013-05-13 01:13:27 +02:00
Holger Hans Peter Freyther 2177624ca9 channels: Mark channels as broken that time out on activation/release
A channel that fails to send an ACK/NACK/REL within the four second
timeout is now marked as broken. In case the release comes in late
it will be ignored. The lchan should already been freed and for now
we don't want to trust the channel.

In the future we might want to send a "release" for a channel that
got activated ack late and just set the state to none on a channel
that is released acked late.

The late ACK and REL has been tested with two manual tests using the
fakebts. The channels remained blocked even after having received
the ACK message here. The NACK case has not been manually tested.
2013-05-02 19:36:29 +02:00
Holger Hans Peter Freyther e152a46f6e Merge branch 'zecke/features/sysmobts'
* This branch make the type sysmobts work.
* Asssume a bsc_gsmnet variable to be defined.
* This allows to use channel configurations not supported by the
  nanoBTS.
* Manually tested with the FakeBTS and tested by users.
2013-04-29 20:47:52 +02:00
Holger Hans Peter Freyther e48c1871af ipaccess: Remove the ipaccess_gsmnet and assume there is a bsc_gsmnet
Assume that there is a bsc_gsmnet and modify the ipaccess-config to
provide this symbol. If a bsc_gsmmnet is not available when linked
the linker will complain and fail.

E.g. give an error like this:
../../src/libbsc/libbsc.a(bts_ipaccess_nanobts.o): In function `ipaccess_sign_link_up':
src/libbsc/bts_ipaccess_nanobts.c:550: undefined reference to `bsc_gsmnet'
2013-04-29 20:44:42 +02:00
Holger Hans Peter Freyther 4b0e36ae7f sysmobts: Make the nanoBTS NM code work for the sysmobts
Use the is_ipaccess_bts method to check if this is either is
nanoBTS or sysmoBTS. The sysmobts type can now be used to bootstrap
a bts.
2013-04-29 20:44:42 +02:00
Holger Hans Peter Freyther 84b033f8c7 sysmobts: Initialize the NM signal handler only once in a mixed network
Make sure that the bts_ipa_nm_sig_cb is only installed once. In
a nanoBTS + sysmoBTS network the _start method will be called
for each mode leading to the handler being registered twice.

Make sure that there is only one handler registered by unregistering
a previously installed handler. The osmo_signal_unregister_handler
will remove 0 or 1 handlers per invocation and we only add one
handler in this file so it is always balanced.
2013-04-29 20:44:42 +02:00
Holger Hans Peter Freyther e84dd98d26 sysmobts: Avoid a crash when trying to look-up a BTS
The nanoBTS code is trying to find a struct gsm_bts based on
the ipaccess_gsmnet and the ipaccess_unit data. The pointer is
not initialized in the case of a sysmoBTS leading to a classic
NULL pointer dereference.

Move the feature init into the _init method. This way we can
re-use the start code of the nanoBTS. This ensures that the
ipaccess_gsmnet pointer is properly initialized and that the
signal handlers are installed.
2013-04-29 20:44:42 +02:00
Holger Hans Peter Freyther 7a0010bdd4 nat: Include LAC/CI as TV values at the end of the 'status' message
Extend the status message and send LAC/CI as part of the status
message. It is using TV to allow sending more fields in the feature.
We only need to encode the data and this is why there is no tlv
description yet.
2013-04-29 20:40:44 +02:00
Holger Hans Peter Freyther d7b22c624b smpp: Attempt to fix a memory leak of the msgb
The smpp_pdu_rx method does not free the msgb. Introduce an
annotation (currently defined to nothing) to indicate what
will happen to a msgb.
2013-04-29 14:00:59 +02:00
Holger Hans Peter Freyther 2bc90c274d nat: Use memcmp for the token on the USSD interface as well
This is similar to the token on the A-interface. There are no more
token based authentication in the NAT.
2013-04-22 10:54:32 +02:00
Holger Hans Peter Freyther ab22335378 nat: Move the callstats to a new header file due sccp usage
The bsc_nat.h is included by common_vty.c so we may not used
sccp_types.h in the bsc_nat.h header file. Move the callstats
to a new file and include it where it is needed.
2013-04-22 09:07:39 +02:00
Holger Hans Peter Freyther 7e9b039a94 nat: Add an example for a black list 2013-04-18 15:11:49 +02:00
Holger Hans Peter Freyther 70c58ef03b ctrl: Provide a reply in case the range check failed 2013-04-17 14:34:36 +02:00
Holger Hans Peter Freyther d38cf50d0a ctrl: Make the commands static to not pollute the namespace
We do not need to access these commands from another compilation
unit and can just make it static.
2013-04-17 14:34:26 +02:00
Holger Hans Peter Freyther b2b291d3ef nat: Extract the LAC/CI from the Complete Layer3 Information
Find the Cell Identifier from the Complete Layer3 Information and
store it for future reference. We could begin to verify that the
LAC/CI used really belongs to the BSC.
2013-04-16 14:14:17 +02:00
Holger Hans Peter Freyther c279e39c12 nat: Rename "struct sccp_connections" to "struct nat_sccp_connection"
The name sccp_connection is used in the osmo-sccp code, sccp_connections
was used in the NAT for tracking a sccp_connection. Rename it so it is
obvious that the struct belongs to the nat.

The rename was done with sed:
$ sed -i s,"struct sccp_connections","struct nat_sccp_connection",g \
		include/openbsc/*.h src/osmo-bsc_nat/* tests/*/*
2013-04-16 09:53:13 +02:00
Holger Hans Peter Freyther 0e5f5aeaad debian: Begin the 0.13.0 series with a new changelog entry 2013-04-16 09:23:33 +02:00
Holger Hans Peter Freyther dbd9449a16 nat: Allow to re-write international numbers in the CC Setup messages
Prepend the international number with a '+' and then do the normal
re-writing on it. There are a couple of ways to handle this:

	\+([0-9]), \+[0-9][0-9]([0-9]), \+49([0-9])

Add a test case for the international re-write based on an already
internationalized number.
2013-04-16 09:20:06 +02:00
Holger Hans Peter Freyther 27b6184225 nat: Allow to daemonize the NAT process
Add handling for the 'D' option
2013-04-16 09:20:00 +02:00
Holger Hans Peter Freyther dc3a78f0c4 Merge commit 'zecke/mgcp-statistics' 2013-04-16 09:18:29 +02:00
Holger Hans Peter Freyther ac04d8d55e nat: Name the variable more properly and begin with net.1.bsc.%d
We can identify the NAT and BSC given the types of the variable,
no need to put them into the value itself.
2013-04-16 09:17:21 +02:00
Holger Hans Peter Freyther 7d7054eafa nat: Include the sccp_src_ref and sccp_dst_ref for this call
This can help with some post analysis for failed calls and helps
finding the connection in the pcap trace.
2013-04-16 09:17:21 +02:00
Holger Hans Peter Freyther 7c831ecd19 nat: Do not allow the amount of pending responses to grow infinitely
Limit the amount of pending DLCX responses to three times the amount
of available endpoints. Currently all MGCP messages are sent and handled
in sequence.
2013-04-16 09:17:21 +02:00
Holger Hans Peter Freyther 931ad6ac33 nat: Reword the log messages as this is normal operation
The bsc_mgcp_dlcx method is called from the mgcp policy callback
but also from inside the nat core when the SCCP connection is going
away.
2013-04-16 09:17:21 +02:00
Holger Hans Peter Freyther 462b7d7158 nat: We want the remote to respond to our DLCX request
We want to send a TRAP with the MGCP statistics from the NAT and
the connected BSC. The BSC endpoint can be either released because
of a DLCX from the MGCP CallAgent or the SCCP Connection release on
the A-link.

This is why we need to queue the statistics when the deleting the
endpoint on the BSC. The processing is continued once the response
arrives. This code assumes that the response of the DLCX will be sent
by the remote side. The current amount of outstanding responses can be
seen on the VTY. This assumption is based on the fact that the BSC has
already responded to the CRCX and maybe to the MDCX.

The MGCP RFC is bended to prefix the transaction identifier with "nat-"
to easily detect the response and hand it to the handler. This will
then parse the response and generate the TRAP. The current version is
v1. We assume that the transaction space is big enough and we will
not re-assign the transaction identifier too early.
2013-04-16 09:17:21 +02:00
Holger Hans Peter Freyther c327187259 nat: Make it possible to send MGCP messages through the IPA multiplex
Instead of handling MGCP through the UDP socket, read and write messages
through the ipa connection to the MSC.
2013-04-16 09:17:21 +02:00
Holger Hans Peter Freyther 77956aa034 nat: Move all methods sending a response to the callagent to a single place
For testing it can be nice to handle MGCP messages through the IPA
protocol. Prepare the code to send the messages through other means.
2013-04-16 09:17:21 +02:00
Holger Hans Peter Freyther 6de9d0ba35 nat: Address the FIXME and send the MDCX down to the BSC 2013-04-16 09:17:21 +02:00
Holger Hans Peter Freyther 1c0c317094 debian: Fix the installation of the sgsn example data
Creating the sgsn package failed because the debian directory has
been moved and the .examples file was not updated. This was reported
by plotr.
2013-04-05 18:43:25 +02:00
Holger Hans Peter Freyther 30156e1eea sysmobts: Add the necessary data structure and init for the SAPI queue
The sysmobts is now having a SAPI queue with all pending SAPI operations
on the BTS. Add the llist_head to the lchan and make sure it is initialized
by the shared code.
2013-04-05 18:41:45 +02:00
Holger Hans Peter Freyther d34adb2f9f nat: Fix authentication by-pass using shorter tokens
The token was compared with the configured one but only up to a
user supplied length. Compare the token sizes and then use memcmp
for the actual comparison to make sure to compare the right ammount
of characters.

There is no unit-test but there should be one.
2013-04-02 10:10:21 +02:00
Holger Hans Peter Freyther 8ae35c1606 bsc-ctrl: Fix a potential memory leak on failed verification
It was possible that the tmp was strduped but not freed, e.g. when
the number of commas was not right. It would evenutally be freed at
the time the cmd is freed thanks to the talloc hierachy.
2013-03-28 17:13:01 +01:00
Holger Hans Peter Freyther 0c908b6e72 db: Link to the VTY library for the vty_config_unlock symbol
Linking started to fail for me due the symbol coming from the
vty library and the db code not linking to it.
2013-03-21 11:12:56 +01:00
Andreas Eversberg 0c8f9ca30b Add VTY option to set GPRS network-control-order to enable MS measurements
In order to enable GPRS downlink measurements at mobile, the
network-control-order must be set to nc1.
2013-03-17 14:37:16 +01:00
Harald Welte 7159e8bea3 Fix osmo-nitb build without libsmpp 2013-03-13 15:40:14 +01:00
Harald Welte 3f78600346 SMPP: Implement SMPP Osmocom Estensions on MO-SMS
An ESME can now be configured in the VTY to enable osmocom-extensions,
which will add vendor-specific SMPP TLVs for RxLev/RxQual/ARFCN/IMEI and
transmit power to the SMPP DELIVER-SM message type.
2013-03-13 15:30:48 +01:00
Harald Welte 76afa16d04 SMPP: Fix crash on delivery of incoming SUBMIT-SM
As bsc_gsmnet is NULL at the time we call smpp_openbsc_init(),
we later run into segfaults with subscribers that don't have a
subscr->net set.

However, we cannot delay smpp_openbsc_init() until after
bsc_bootstrap_network(), as we then fail to parse the SMPP specific
VTY/config file options...
2013-03-13 15:30:48 +01:00
Harald Welte 8b29180cad IPA: Allow RSL connection to different IP address as OML
This patch adds a new VTY command "ip.access rsl-ip A.B.C.D" at the
BTS level.  If you set this IP address, the BTS will be instructed to
establish the RSL link to the indiciated IP address, rather than using
the same as for the OML link (default).

Use "ip.access rsl-ip 0" to disable the feature.
2013-03-12 13:58:30 +01:00
Andreas Eversberg 1af682adb9 BTS: Add S counter for link loss criterion to lchan structure 2013-03-11 11:50:50 +01:00
Holger Hans Peter Freyther f876c39887 si: Another round of PCS related fixes
Inside the SI1 rest_octets we will need to indicate if the ARFCN
is band 1800 or 1900. If the BTS is either 850 or 1900 we assume
we are running a PCS network, otherwise it is a DCS network.

The band indicator is not documented in GSM 04.08 but it is in the
GSM 05.14 version 6.1.0 Release 1997.
2013-03-10 17:39:50 +01:00
Holger Hans Peter Freyther e1145cf0f9 rsl: Properly initialize the cm structure with memset
abis_rsl.c:332:23: warning: 'memset' call operates on objects of type 'struct rsl_ie_chan_mode'
      while the size is based on a different type 'struct rsl_ie_chan_mode *'
      [-Wsizeof-pointer-memaccess]
        memset(cm, 0, sizeof(cm));
               ~~            ^~
abis_rsl.c:332:23: note: did you mean to dereference the argument to 'sizeof' (and multiply it
      by the number of elements)?
        memset(cm, 0, sizeof(cm));
                             ^~
1 warning generated.
2013-03-09 17:53:50 +01:00
Harald Welte e972dba8dd bsc_vty: Prevent printing -1 as unsigned integer for timeslot TSC 2013-03-08 07:45:29 +00:00
Holger Hans Peter Freyther 9b5192b153 bsc: Stop "show paging" from crashing before the first paging
The paging structure is still initialized lazily and we attempt
to traverse it before it is ready. The crash was discovered by
Katerina. Removing the lazy initialization will take a bit of work
as the gsm_data_shared is used by the osmo-bts and the OpenBSC but
paging is different.
2013-03-03 11:08:22 +01:00
Holger Hans Peter Freyther f4be327b4c doc: Do not have examples with accept-all in our repository
We do not want to tell random users to run a network with the
accept-all. This was pointed out by Katerina.
2013-03-03 09:56:25 +01:00
Holger Hans Peter Freyther 63b0e44f65 vty: Document some previously undocumented parameters
Katerina pointed out that some nodes are not fully documented and
proposed some messages. The token/timeout messages were correct, I
have modified the other messages. I removed the full-stop from the
PING/PONG documentation as we are normally not using a full sentence.
2013-03-03 09:48:20 +01:00
Holger Hans Peter Freyther 456fccf697 doc: Create a documentation on the SCCP/lite implementation we have
Describe how we handle/dispatch SCCP messages in the osmo-bsc.
2013-02-26 11:51:25 +01:00
Harald Welte b02fc1e9bb VTY: backwards compatibility for 'logging level sms'
when the SMS code was moved into libosmocore, its logging prefix was
changed from 'sms' to 'lsms', which breaks existing config files.

This introduces a deprecated/hidden vty command to make sure those
config files are still parsed OK, and will simply print a warning
message about the config needing some update.
2013-02-12 11:15:49 +01:00
Andreas Eversberg 75e13a41dc Fix of IMMIDIATE ASSIGNMENT REJECT message
The message was corrupt at several points. They are fixed now and
successfully tested.

A default T3122 timer value of 10 is defined by default now. If set to 0,
the reject message will not be sent. Note that when using existing configs
with T3122 value set to 0.
2013-02-08 08:25:17 +01:00
Harald Welte 647db848e3 add some more docbook snippets 2013-02-07 15:03:08 +01:00
Harald Welte ce1d742f27 dump_all_docs.py: Also extract documentation for SGSN 2013-02-07 15:00:31 +01:00
Harald Welte af33e1d3a1 fix osmo-bsc example configuration file 2013-02-07 15:00:18 +01:00
Holger Hans Peter Freyther 0a7c6a3549 doc: Add some documentation on how the paging system is working 2013-02-06 12:04:32 +01:00
Holger Hans Peter Freyther 883fbc9d04 Merge branch 'zecke/feature/rf-lock-exclude'
Exclude a BTS from the RF Lock and allow MO and MT operations on
this BTS. The paging modification has been verified using the FakeBTS
and the handover test. Paging continues to work for the normal case.
2013-01-28 16:00:46 +01:00
Holger Hans Peter Freyther dc030960fc bsc: Allow to page a BTS that is excluded from the RF lock
The RF lock excluded BTS was not paged at all. Now forward the
paging message to the handler and call a function that will check
if this LAC can be paged right now. Introduce a new paging method
that allows to page on a dedicated bts, refactor the code to use
this method for paging.
2013-01-28 15:41:27 +01:00
Holger Hans Peter Freyther 3d119f1de4 bsc: A BTS excluded from the RF lock should be allowed to make a connection
When introducing the exclude for the BTS lock the RF stayed up but
all connections were immediately released. Optionally pass the BTS
as second parameter and check the exclude bit.

Tested-with: rf-lock-exclude/RFLockExcludeTest.st
2013-01-28 15:41:27 +01:00
Holger Hans Peter Freyther e30d40de0e bts: Allow to exclude a BTS from the global RF lock handling
Some BTS might be in locations where they can run all the time,
allow to exclude them from the global lock handling.
2013-01-28 15:41:26 +01:00
Andreas Eversberg e7ea08379e CC: gsm48_cc_tx_release() must not remove callref
If after release has been sent, the call control layer waits for:
- reception of release complete
- or timeout
- or release of transaction (due to radio link failure)
In this case, an MNCC_REL_CNF is sent to upper layer. The callref must
still exist, so the upper layer can handle this confirm.
2013-01-25 08:43:01 +01:00
Andreas Eversberg 1590727b64 CC: mncc_release_ind() must send MNCC_REL_CNF in state N19
If transaction is destroyed, but callref still exists, the
mncc_release_ind function is called. If the upper layer already sent an
MNCC_REL_REQ, the state N19 was entered. In this case it expects an
MNCC_REL_CNF.
2013-01-25 08:38:29 +01:00
Andreas Eversberg c5e0851054 CC: Be sure to allocate call instance with talloc_zero() 2013-01-25 08:36:32 +01:00
Harald Welte b862cef60d smpp_vty: Ensure to not print 'system-id' in openbsc.cfg if its empty
... as an empty system-id would render the openbsc.cfg unparseable on
next openbsc start.
2013-01-24 09:54:04 +01:00
Holger Hans Peter Freyther 6a85c15eea smpp: Fix a memleak of the SMS on the submit path 2013-01-20 19:21:48 +01:00
Holger Hans Peter Freyther b5a4edd09b SMPP: Inform the SMS Queue that a SMS was submitted to kick the queue
Work on the 'forward' part.. tell the sms queue that something has been
submitted for it..

Conflicts:
	openbsc/src/libmsc/smpp_openbsc.c
2013-01-20 19:21:34 +01:00
Holger Hans Peter Freyther d4d1d5e751 si: Deal with DCS1800 and PCS1900 have overlapping ARFCN ranges
For PCS1900 the SI1 does not contain the ARFCN of the serving cell.
This is because the arfcn2band method will return GSM_BAND_1800 and
not GSM_BAND_1900. The academic fix would be to set the ARFCN_PCS bit
but this would require increasing the bitvector sizes from 1024/8 to
(0x8000 + 1024) / 8. This would increase the storage size for each
bitvector by three.

It is not possible to have DCS1800 and PCS1900 in one network so we
can avoid increasing the memory usage and check if the ARFCN resolved
to 1800 and then check if the BTS is a 1900 BTS and then claim that
this is compatible.
2013-01-17 19:31:49 +01:00
Holger Hans Peter Freyther 9e1952a901 si: Share the ARFCN selection condition between the two statements
This makes reading the condition more easy and allows me to fix it
for GSM1900 more easily and I can remove one level of indention.
2013-01-17 19:30:05 +01:00
Holger Hans Peter Freyther 164ee307b2 rsl: Properly parse the RLM cause from the error indication
The code predates the TLV parser and we were parsing the RLM from the
wrong offset. In general we were using the length of the TLV which
happened to be equal to the T200 indication.

After consulting the RLM cuases not every of them should generate a
BSC_RLLR_IND_ERR_IND as these are forwarded to the MSC as a SAPI reject
right now.

TLV parsing now generates this due a bug in the osmo-bts code:
abis_rsl.c:1605 (bts=0,trx=0,ts=2,ss=0) SAPI=0 <0000> abis_rsl.c:1547 (bts=0,trx=0,ts=2,ss=0) ERROR INDICATION cause=Fraeme not implemented
2013-01-16 21:07:43 +01:00
Daniel Willmann 69665f8722 osmo-bsc: Add ctrl cmd bts RF state
Returns opearional, administrational state and RF policy
2013-01-15 22:19:44 +01:00
Daniel Willmann 7d10983865 osmo-bsc: Add VTY command show position 2013-01-15 16:53:51 +01:00
Holger Hans Peter Freyther 2a896070a7 bsc: Auto RF Off in case of missing MSC connection
For short IP failures we want the RF to stay up and wait for
the re-connect but in case the A-link is gone too long it is
good to switch off the RF and wait for commands to enable it
again.
2013-01-15 13:52:00 +01:00
Holger Hans Peter Freyther 036b25fb7f nat: Fail if the control interface can not be initialized 2013-01-15 13:48:18 +01:00
Holger Hans Peter Freyther c7de8ef014 Merge branch 'zecke/feature/location-control'
Merge the code from the On-Waves branch. Use the internal RF control
interface to switch the TRXs on/off. This code has the necessary delays
to not crash the nanoBTS. Introduce signals for re-connection of the
BSC on the A-link.
2013-01-15 11:33:00 +01:00
Holger Hans Peter Freyther 431ceada36 bsc: Create a better error message for when RF commands are rejected
Provide an error message that makes it more clear that the command
is rejected because RF handling is not enabled in the BSC.
2013-01-15 11:27:28 +01:00
Holger Hans Peter Freyther 25eca0bfdc bsc: Simplify the trap sending by using the location state method 2013-01-15 11:27:28 +01:00
Holger Hans Peter Freyther 23446844a8 bsc: Send a TRAP with the locations on a MSC connection
Send the current position when the MSC connection is established.
2013-01-15 11:27:28 +01:00
Holger Hans Peter Freyther 7b6ea56f41 bsc: Use the BSC RF CTRL to change the RF state of the TRXs
Use the delayed scheduling feature of the osmo_bsc_rf class to
avoid crashing the site controller of the nanoBTS.
2013-01-15 11:27:28 +01:00
Holger Hans Peter Freyther baa1a2df20 bsc: Do not re-start the grace timer when we are in the grace period 2013-01-15 11:27:28 +01:00
Holger Hans Peter Freyther ed0374ffeb bsc: Introduce an authenticated signal for the MSC connection
Send the signal whenever a MSC appears to be authenticated.
2013-01-15 11:27:28 +01:00
Holger Hans Peter Freyther ba36bf4c5d sms: Avoid infinite CP-ERROR/CP-ACK loop with sms.
The issue can be reproduced by typing the following 9 or more times.
 OpenBSC> subscriber id 2 sms sender id 2 send bla

For some unknown reason the phone sends us a CP-ERROR for a transaction
identifier we have allocated and used but don't remember. Due the way
we use the SMC/SMR we 'establish' the machine and this results in a CP-ACK
being sent out. But the CP-ERROR is not having the content we want for
an establish so we send out a RP-ERROR. This will result in a CP-ERROR
because the phone does not know the transaction...

Avoid the issue by checking the direction of the transaction. If we do
not know the transaction and it is supposed to be allocated by us then
just ignore it and do not create a new transaction.
2013-01-13 17:30:00 +01:00
Holger Hans Peter Freyther 30a3d2f0fe debug: Fix typo in the debug category 2013-01-11 18:11:21 +01:00
Holger Hans Peter Freyther 4babba62b8 ctrl: Work on the cmd->node instead of the data pointer passed
Make the macros use the cmd->node instead of the data pointer. The
naming of the variable inside the macro already indicates that it
should use the nodes data structure.
2013-01-11 18:11:13 +01:00
Holger Hans Peter Freyther 3749dc93a3 ctrl: Fix the signature of the string control commands
Like with all type unsafe callbacks we will need to cast from
void to the dtype. This addresses some compiler warnings.

Make it possible to only include the control_cmd.h to use the
macros defined in this file.
2013-01-11 18:11:05 +01:00
Andreas Eversberg f2621e506d si: Do not schedule SI1 to SI4 on the second TRX 2013-01-08 19:34:24 +01:00
Holger Hans Peter Freyther 608ac2a8a4 abis: Fix the verification of BCCH/SDCCH8 on TRX != 0 for the BS11
The SDCCH8 is only allowed on trx 0 if there is no BCCH/SDCCH4 on it.
2013-01-08 19:30:14 +01:00
Holger Hans Peter Freyther bac7dcc367 Merge branch 'zecke/feature/improve-audio-codec-selection'
Allow to select the AMR multirate config using the VTY.
2013-01-07 16:22:00 +01:00
Holger Hans Peter Freyther 75077955e9 audio: Make AMR multirate configurable for the osmo-bsc
Provide VTY options to allow/forbid the usage of a
specific multirate option.
2013-01-07 16:14:08 +01:00
Holger Hans Peter Freyther 25aa749f10 audio: Make the BSC handle the new mr_config request of the BSC API
Handle the mr_config request and set the AMR multirate config for
the given MSC. Initialize the mr_config with the AMR5.9 default we
have been using until now.
2013-01-07 16:10:31 +01:00
Holger Hans Peter Freyther ff799f0912 Merge branch 'zecke/feature/move-calls'
Be able to move a call from one MSC to another MSC based on a regexp
for the phone number and pre-defined dial plan.
2013-01-07 15:50:38 +01:00
Holger Hans Peter Freyther 0b19d55dd6 bsc: Blind fix to deal with phones sending a dialplan of 0 2013-01-07 15:50:14 +01:00
Holger Hans Peter Freyther c7db4dce4a bsc: Fix crash when the new route is not available
When we are asked to route calls on a local link and
the link is not available we would crash when trying
to send a packet over a deadline. When we have decided
to move a connection it is guranteed that the current
SCCP connection will vanish, we either migrate to another
MSC or the RSL/subscriber connection will be closed.
2013-01-07 15:50:14 +01:00
Holger Hans Peter Freyther d5edc4f84d bsc: Add VTY code for the local area prefix 2013-01-07 15:50:14 +01:00
Holger Hans Peter Freyther 83d2d38a3c bsc: Inspect a CC Setup message and attempt to reroute the traffic
Inspect the CC Setup messages and if the dialed number is matching
the regexp of the local MSC the connection will be rerouted. The
original MSC will get a GSM0808 CLEAR REQUEST, a new connection with
a CC Setup message will be opened.
2013-01-07 15:47:32 +01:00
Holger Hans Peter Freyther ea46b77f3e Merge remote-tracking branch 'origin/zecke/barr-subscribers'
Allow to merge barr certain subscribers with a given error code
2013-01-07 15:03:29 +01:00
Holger Hans Peter Freyther aa191adce6 nat: Send a CM Service Reject for NAT_CON_TYPE_SSA as well
For USSD we remember that it is a supplementary service but this
means we sent no CM Service Reject down to the subscriber. Treat
NAT_CON_TYPE_CM_SERV_REQ and NAT_CON_TYPE_SSA the same and send
a cm service reject.
2013-01-07 15:02:34 +01:00
Holger Hans Peter Freyther 1f8276e588 nat: Introduce a global IMSI barr list using red-black trees 2013-01-07 15:02:34 +01:00
Holger Hans Peter Freyther 0434faedc9 nat: Simplify the code and call auth_imsi from the main method
Do the auth check in bsc_nat_filter_sccp_cr, remove the cause from
the signature again. For the bsc_nat_filter_dt restructure the flow
but leave the auth inside the id response message.

Return 1 when the IMSI has been extracted as indicator for running
the auth check. 1 has not been used before and is safe to be used
as this indicator.
2013-01-07 15:02:34 +01:00
Holger Hans Peter Freyther 184950e298 nat: Get the cause into the imsi_auth method in preparation
For the new barr feature get the cause struct down to the imsi_auth
code so we can add the blacklist there.
2013-01-07 15:02:34 +01:00
Holger Hans Peter Freyther bdf764a025 nat: Allow the filter to select the reject cause
In preparation for another kind of black-list allow the filter code
to decide how the connection should be rejected. Introduce a new struct
that will carry the reject causes for certain operations.
2013-01-07 15:02:34 +01:00
Holger Hans Peter Freyther adc2e87372 nat: Move the IMSI/TMSI filtering to a new and dedicated file
Move all routines related to filtering to a separate file.
2013-01-07 15:02:34 +01:00
Holger Hans Peter Freyther 6fbd864a65 nat: Fix a typo in the log message for out of memory 2013-01-07 15:02:34 +01:00
Holger Hans Peter Freyther 6ecb3cb599 nat: Extract the message re-writing from the utils to a dedicated file
Move the code around to make it more clear what the routines should do.
2013-01-07 15:02:34 +01:00
Holger Hans Peter Freyther b9b828b1e5 Revert "libbsc: With the new SAPI states we don't need sacch_deact anymore"
For now we need to keep the sacch_deact in OpenBSC as we couldn't get
the new activation/de-activation code working.

This reverts commit 0c282f5268.
2013-01-01 19:20:51 +01:00
Holger Hans Peter Freyther b5ae7288a9 Merge branch 'daniel/t3212-work'
This implements exipiry of subscribers, requires a schema change. A permanent
attachment (time set to 0) is not supported any more and would require some
more work. This code was used at the 29C3.
2013-01-01 17:31:07 +01:00
Jan Luebbe 1c201c6055 osmo-nitb: Add a timer to regularly expire 2013-01-01 17:19:47 +01:00
Jan Luebbe bfbdeec714 libmsc: Track and update the location update expiry
Set the subscriber expiry timeout to twice the duration of the location
update period and provide functions subscr_expire() and
db_subscriber_expire() to mark subscribers offline that have missed two
location update periods.

This patch increases the DB revision to 3, so the hlr will be
incompatible with prior versions.

We should allow 0 for T3212 as well to disable the location update
period. In that case we will need a way to indicate that in the
database.
2013-01-01 17:19:47 +01:00
Daniel Willmann 4d62d63151 Stricter limits for T3212 (location update period)
libcommon: Default to 30min location update period
libbsc: Limit VTY value for periodic update and disallow the value 0

According to GSM 04.08 Table 10.5.33 "The value 0 is used for infinite
timeout value i.e. periodic updating shall not be used within the cell."

This was the default value until now, but the code that deals with
expiring inactive subscribers in the next commit can't handle that case
so this remains a TODO for now.
2013-01-01 17:19:46 +01:00
Holger Hans Peter Freyther 4d2a68cf11 misc: Do not use else when using return in the previous branch 2013-01-01 17:18:27 +01:00
Sylvain Munaut 39c31dea2e libbsc: Make argument optional in some 'show' commands
The actual command implementation was already for this, but some
bad vty parsing prevented optional range arguments from working
properly.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-01-01 17:04:52 +01:00
Sylvain Munaut 01c13a3a45 libmsc: Allow to set sender id when sending SMS from the VTY
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-01-01 17:04:38 +01:00
Sylvain Munaut 11c1b6e014 libmsc: Refuse service to anyone not attached
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2013-01-01 17:03:15 +01:00
Daniel Willmann 977cd13741 gsm_04_08: Display debug message correctly on DETACH INDICATION
Log messages would get mangled before if we receive detach by TMSI or
IMSI.
2012-12-29 12:47:31 +01:00
Daniel Willmann 0c282f5268 libbsc: With the new SAPI states we don't need sacch_deact anymore 2012-12-29 12:42:29 +01:00
Daniel Willmann 324c8052ae gsm_data_shared.h: Keep a list of SAPI states per lchan 2012-12-29 12:42:16 +01:00
Holger Hans Peter Freyther 4173b174eb libmsc: One of assign_compl and assign_fail will always be called
Remove the log messages and comments as they are wrong for now. Even
for the mode modify we will get the assign complete call.
2012-12-26 21:44:12 +01:00
Daniel Willmann 56260b648c tests: Don't delete atconfig in clean
This file is created in ./configure so we shouldn't remove it with make.
Otherwise ./configure && make clean && make check fails with:

make[3]: *** No rule to make target `atconfig', needed by `check-local'.
Stop.
2012-12-26 12:26:09 +01:00
Holger Hans Peter Freyther cf77b3a2cf abis_test: Fix the test case and calculate the right offset
We parse the load_config, take the ptrdiff_t from start and load_config
and from the previous array as the alignment can differ on different ABIs.

This was found by Daniel when executing the tests on a 64 bit userspace.
2012-12-26 12:19:53 +01:00
Holger Hans Peter Freyther c121bb3188 handover: Fix the handover signalling for IP based BTSes
This was reported by Kevin when he was testing handover. The problem
is the order of the signal handlers for S_ABISIP_CRCX_ACK. Right now
the handover signal handler is called before the one inside the libmsc
gsm_04_08.c. This means S_HANDOVER_ACK is signalled _before_ there is a
rtp socket created for the channel. The result is that the MDCX will
never be sent and the called will not be properly switched _after_ the
handover detection.

I do not want to play with the order of signal handlers, remove the
CRCX ack handling from the handover_logic.c and force the NITB (and
later the BSC) to check if the lchan is involved with a handover and
do the switching in there. This means right now we do what two signal
handlers did in one.

Reproduced and tested with the FakeBTS Handover test.

Log message:
<0004> abis_rsl.c:1954 (bts=1,trx=0,ts=3,ss=0) IPAC_CRCX_ACK ...
<000c> gsm_04_08.c:1400 no RTP socket for new_lchan
<001a> rtp_proxy.c:533 rtp_socket_create(): success
<001a> rtp_proxy.c:615 rtp_socket_bind(rs=0x48703c8, IP=0.0.0.0): ...
2012-12-26 10:32:02 +01:00
Holger Hans Peter Freyther 006e3d87e0 gsm: Do not attempt to release SAPI=0 if it was never allocated
In case of handover (but probably on RACH) we would send a RLL for
SAPI=0 even if this SAPI was never established. After we have released
all SAPI>0 locally check that SAPI=0 is established and if not release
the rf channel directly.
2012-12-26 00:20:18 +01:00
Sylvain Munaut 48ea4e8aec libbsc: Fix DL QUAL decoding from measurement reports
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2012-12-26 00:13:51 +01:00
Jan Luebbe 6e300682df gsm_subscriber: change subscr_bsc_active_subscriber to plural
This was requested by Holger Freyther <zecke@selfish.org>.
2012-12-25 19:08:46 +01:00
Holger Hans Peter Freyther 4485321219 nitb: Add a VTY command to initiate a handover to another BTS 2012-12-25 08:37:36 +01:00
Holger Hans Peter Freyther 7d0f60dce6 Merge branch 'zecke/channel-release'
Merge the channel release re-work. The most notable change is that
SAPI > 0 will now be released on the local end and that the release
process should be both more fast and more standard conform. With SMS
spamming/mass sending the nanoBTS is crashing but this does not appear
to originate from any of these changes. I used git rebase to go through
each of the change to see where the nanoBTS is crashing but couldn't
reproduce it. It might be a general overload or something generated by
the modems of the sysmocom modem bank. Merge it before the 29C3 so we
can test this code some more.
2012-12-23 20:21:15 +01:00
Holger Hans Peter Freyther b348939d86 lchan: Introduce T3109 handling for the release procedure
T3109 is started when the SACCH is deactivated. It is stopped when
the phones sends the DISC/UA/UM on LAPDm for the main signalling
link. In case of timeout the abnormal release procedure will be
initiated. Make sure to not issue the SACCH Deactivate twice to
avoid confusing the equipment.

This is still not fully spec compliant. In case of a timeout the
abnormal release handling will be started which involves starting
T3111+2. The error handling should be split out of the rf channel
release method, e.g. lchan_release should be called and check if
the channel release was already initiated.
2012-12-23 20:20:38 +01:00
Holger Hans Peter Freyther 638da51a78 lchan: Introduce a BROKEN state for the lchan
If the CHAN ACTIV is NACKED we set the state backto NONE. This is
problematic as our channel allocator will allocate from the front
or from the back and if the channel is early in the list it might
cause permanent failures. Introduce a BROKEN state and use it when
the channel activation is failing for an unknown reason. Copy the
cause so it can be inspected later.
2012-12-23 20:18:18 +01:00
Holger Hans Peter Freyther 9d50a27695 lchan: Document the behavior/quirks for abnormal channel release
Deactivate the SACCH and release all SAPIs locally as of GSM 04.08. Add
documentation to the code and explain what will happen as part of the
release process.
2012-12-23 20:18:18 +01:00
Holger Hans Peter Freyther 8582535c82 lchan: Release the lchan more quickly, align with GSM 04.08
* Release all channels with SAPI > 0 with the "local end release"
  (as of NOTE 1 of GSM 04.08).
* No need to wait for all SAPIs to be torn down and the normal
  REL_IND/REL_CONF will call rsl_handle_release and the channel
  should be released.
* Update the documentation
2012-12-23 20:18:18 +01:00
Holger Hans Peter Freyther 960c4044e6 lchan: Release all higher sapis on the local end.
According to GSM 04.08 3.4.13.1.1 RR connection release in NOTE 1
one should release all non main signaling links using the local end
link release.
2012-12-23 20:18:18 +01:00
Holger Hans Peter Freyther 93599a2c2c rsl: Cosmetic changes to the release code
Put the idiom that sets the lchan state to none and respecting the
error state into a shared method. This way the special handling for
the abnormal case is just in one place.
2012-12-23 20:18:18 +01:00
Holger Hans Peter Freyther d66777f9cf rsl: Call the release function with the enum name and not the number
Done with the semantic patch:
@rule1@
expression E;
expression F;
@@
- lchan_release(E, F, 1);
+ lchan_release(E, F, RSL_REL_LOCAL_END);

@rule2@
expression E;
expression F;
@@
- lchan_release(E, F, 0);
+ lchan_release(E, F, RSL_REL_NORMAL);
2012-12-23 20:18:18 +01:00
Holger Hans Peter Freyther 5ca825e431 rsl: Rename the reason to release_mode and use the enum value
The API with 0 and 1 as legal values is hard to understand. Use the
recently introduced enum values instead.
2012-12-23 20:18:18 +01:00
Holger Hans Peter Freyther 1411c066cc rsl: Use LOGL_ERROR instead of LOGL_NOTICE act/deact timeouts
It is a grave error when the BTS does not respond to the ACT/DEACT
requests, use LOGL_ERROR for such conditions.
2012-12-23 20:18:17 +01:00
Holger Hans Peter Freyther 10049bc3b7 paging: Do not page when there is no OML link
Avoid printing error messages when paging while the BTS is down. In
case a BTS is going down it is best to just let the timers expire
normally. We can not expire them right away as multiple BTS could be
paged and we do not want to interfere with that. There is no need to
stop the queue right now.
2012-12-22 19:27:27 +01:00
Holger Hans Peter Freyther 3e9b2ec257 libmsc: Avoid a crash on lchan release during call control
If subscriber A is calling B and has sent a CC Setup message we will
allocate the MO and MT transaction and link them together. When the
BTS or the lchan is failing the BSC API will send a clear request,
as part of the clear request all pending transactions will be released.

As part of taking down the transaction, the remote leg will be informed
and will send a MNCC_REL_REQ. This results in a call to trans_free. The
llist_for_each_entry_safe does not handle removing other elements from
the list and we would segfault.

One way to fix this is to move the transaction list into the subscriber
connection. This might require to create the subscriber connection for
MT handling earlier. Otherwise one could have one transaction list inside
the subscriber connection and a global list for MT- transactions.
2012-12-22 18:45:27 +01:00
Holger Hans Peter Freyther 405824c057 libmsc: Set trans->subscr = NULL after we release it
This is a cosmetic change and should happen to find use after free
of the subscriber.
2012-12-22 18:16:47 +01:00
Holger Hans Peter Freyther 25b70cea9d autoconf: Fix the --disable-* case for the AC_ARG_ENABLE macros
--disable-smpp would actually not disable SMPP but enable it. Correct
it for all usages of AC_ARG_ENABLE.

Move the unconditional invocation of PKG_CHECK_MODULES before the
conditional one to make it work as the pkg-config m4 macro appears
to expand the first usage differently and searches for the pkg-config
exuable.

Use "$enableval" to see if the feature should be enabled or disabled
and then search for the module afterwards.
2012-12-21 00:04:57 +01:00
Holger Hans Peter Freyther 0e0a09c610 osmo-bts: Include lapdm.h to fix autoconf usability test
Include the LAPDm header file so the size of struct lapdm_channel
is known and gsm_data_shared.h can be included by itself.
2012-12-20 19:03:18 +01:00
Holger Hans Peter Freyther 3a41b80bd7 Merge branch 'zecke/abis-sw-selection' 2012-12-20 18:56:47 +01:00
Holger Hans Peter Freyther 2f25747e3f abis: Activate the newest available installed on the BTS
Select thew newest software from all available file versions.
2012-12-19 16:37:55 +01:00
Holger Hans Peter Freyther bce5675e5f abis: Create a routine that can parse all SW Descriptions of a SW Config
Be able to parse the entire SW Config IE. Parse the SW Descruption
into a struct provided by the caller.
2012-12-19 16:37:55 +01:00
Holger Hans Peter Freyther c751cf92cb misc: Fix compilation now that the method is located in libosmocore
These TLV helper functions are now located in libosmocore.
2012-12-19 16:18:44 +01:00
Holger Hans Peter Freyther 408208d887 nitb: Do not crash on IMSI Detach messages from a phone
This has been reported and analyzed by Tobias Engel. The IMSI Detach
is dispatched as part of the complete layer3 message. I had patched
the code to release the anchor and call msc_release_connection to
release the connection as fast as possible (otherwise the anchor would
trigger in a couple of seconds).

With commit 70ae5d3000 I made this more
generic to release the connection immediately if there are no operations,
no transaction and no silent call. This leads to the subscriber connection
being released twice and eventually causing a segfault. Remove the
msc_release_connection invocation from the IMSI Detach code as the connection
will be taken down by the BSC API.

This has been tested using the FakeBTS and an IMSI Detach message. The
channel is released immediately and the nitb does not crash.
2012-12-16 14:12:38 +01:00
Holger Hans Peter Freyther 5ea1bc77a3 mgcp: Allow to freely control the a=fmtp line for experiments
In case of AMR one can specify the available codecs out-of-band. Allow
to configure this line statically in the configuration file.
2012-12-16 13:18:08 +01:00
Holger Hans Peter Freyther 7e7ee5f8c6 mgcp: Fix the vary large jump detection in the code
GCC 3.x on PowerPC correctly highlights that the code is fishy.
Re-reading the RFC 3550 shows that we should subtract it and then
we are in the 16bit range. The probation and re-sync code is still
missing.

GCC:
mgcp/mgcp_network.c:200: warning: comparison is always true due to limited range of data type
2012-12-16 13:11:50 +01:00
Holger Hans Peter Freyther 1bf6610ce7 Merge branch 'zecke/mgcp-transactions' 2012-12-10 14:53:00 +01:00
Holger Hans Peter Freyther ce55361e93 mgcp: Test and implement re-transmission handling
MGCP is used over UDP and a response might be lost. The MGCP RFC
asks for keeping a list of responses and then using the previous
response to answer a duplicate request. I tried to conserve memory
and just wanted to remember the last transaction identifier and
result-code and re-generate the result from that. This made the
code look bad and this is why the entire response will now be stored.
It sadly increases the memory usage but can not be avoided at this
time.

Remove the msg->l3h pointer for the RQNT callback as strtok has
modified the content of it.
2012-12-10 14:46:00 +01:00
Holger Hans Peter Freyther 29de346b32 mgcp: Change the flow of the code when handling a MGCP response
Attempt to detect a response and return only then. Remove one level
of tabls in preparation for the re-transmission handling.
2012-12-10 13:36:00 +01:00
Holger Hans Peter Freyther a769dcb889 mgcp: Methods generating a response now include the endpoint pointer
This is required for remembering the last result in a central place
and is required to properly implement detection of re-transmissions.
2012-12-10 13:36:00 +01:00
Holger Hans Peter Freyther cf2f158caa mgcp: Add testdata for MDCX handling 2012-12-10 13:35:53 +01:00
Holger Hans Peter Freyther d267f4d685 mgcp: Test the second CRCX as a CRCX and not as a re-transmission
The second CRCX would be mostly ignored and be handled by the
retransmission layer of MGCP.
2012-12-10 12:16:23 +01:00
Holger Hans Peter Freyther 0d904e004a mgcp: Fix a typo.. it is msg and not mgs 2012-12-10 12:16:23 +01:00
Holger Hans Peter Freyther 01d315f19c mgcp: We do not need to check for talloc_free
Simplify the code and remove null check for the two strings.
2012-12-10 12:16:23 +01:00
Holger Hans Peter Freyther 3d4d79d890 bsc: Fix compiler warning and return from the method with a value. 2012-12-10 12:09:22 +01:00
Holger Hans Peter Freyther d2361d970a bsc: Send the USSD message after the location updating accept.
Make sure to accept the phone first before sending the USSD message.
2012-12-03 15:32:54 +01:00
Holger Hans Peter Freyther f589221ed0 msc: Add debug messages when not sending a USSD welcome message 2012-12-03 14:39:19 +01:00
Holger Hans Peter Freyther b3089e437d bsc: Fix a brown paper bug and most likely fix the USSD welcome issue 2012-12-03 14:39:11 +01:00
Holger Hans Peter Freyther 383d3c33e6 bsc: Call the variable with a more appropriate name. 2012-12-03 14:38:59 +01:00
Holger Hans Peter Freyther c5903a2b01 Merge branch 'zecke/jolly-sms'
MT-SMS:
Manual test with VTY to phone. Also multiple SMS deliveries on
the same lchan. Manual test with phone to phone.

MO-SMS:
Manual test with phone to phone but only a single SMS at a time,
not testing the special 'CP-ACK' case.

Forced CP timeout using the fakebts SMSTest, not causing a crash.
2012-12-01 12:03:46 +01:00
Holger Hans Peter Freyther 536a10b63b sms: Kill the linkid as we are using SAPI=3 all the time
For GSM (not GPRS) we will never use a SAPI!=3. Simplify the code
and remove the link_id=0.
2012-12-01 11:49:33 +01:00
Andreas Eversberg bc6c43f759 sms: Replaced the SMR process by new implementation in libosmocore
Rebased, tested and fixed by Holger Freyther. Release the transaction
only once the SMC is asking for the release and set the cb's to NULL
to catch a use after free early.
2012-12-01 11:49:33 +01:00
Andreas Eversberg f7396eac2f sms: Replaced the SMC process by new implementation in libosmocore
This has been rebased and fixed by Holger Freyther. The change of
the debug area was split out in a previous commit and the is_mt was
put back into the transaction code.

The transaction is now freed from the RELEASE_REQ sent by the SMC
layer and not inside the error path. When clearing the SMC instance
we also clear the callbacks.
2012-12-01 11:49:15 +01:00
Holger Hans Peter Freyther 07dec137de sms: Remove the susbcr_put_lchan logic from the SMS code
This should and does happen as part of the trans_free/msc_release_connection
code. There is no easy way to determine that the lchan is now 'free' for other
things.. Let the transaction code sort this out. This code just needs to make
sure that transactions are always freed.
2012-12-01 11:33:00 +01:00
Holger Hans Peter Freyther 70ae5d3000 nitb: Release the channel if there is nothing on it
This is more a work around and one still needs to implement a
proper dispatch on the opening of the connection. If there is no
operation left, no transaction and no silent call, close down the
channel.
2012-12-01 11:32:47 +01:00
Holger Hans Peter Freyther 6d818839a9 Merge branch 'zecke/mgcp-dtmf' 2012-12-01 10:53:15 +01:00
Holger Hans Peter Freyther 8d0be259cb mgcp: Begin handling of the RQNT message as needed for DTMF
Introduce a callback for the request and forward the signalrequest
to the callback. This is not a full implementation of MGCP RQNT.
2012-11-29 19:56:22 +01:00
Harald Welte 0d0c9ec5c5 use DLSMS and not DSMS in SMPP related code (merge with master) 2012-11-24 11:13:19 +01:00
Harald Welte c6483683eb tests: Fix build of 'db' test after smpp merge 2012-11-24 11:11:59 +01:00
Harald Welte b8a1f967c5 SMPP: fix handling of UDH / multi-part for 7-bit messages
... I would have never believed it is such a broken mindfuck.
2012-11-24 11:09:21 +01:00
Harald Welte c0de14da8f SMPP: add small utility program 'smpp_mirror'
This program binds as ESME transceiver to a SMSC and simply mirrors back
all SMS that it receives.
2012-11-24 11:09:21 +01:00
Harald Welte e07b6a77e5 SMPP: Implement support for MO SMS
Each ESME can have a number of prefix-matching routes, or it can
be a 'default route' to whcih all otherwise unknown SMS destinations
are routed.
2012-11-24 11:07:30 +01:00
Harald Welte 338e3b3b4b SMPP: VTY configuration of SMPP code, authentication support 2012-11-24 11:07:29 +01:00
Holger Hans Peter Freyther eff4094950 sms: Use the DLSMS instead of the DSMS category throughout our code 2012-11-21 21:33:03 +01:00
Holger Hans Peter Freyther 366c33185b sms: Use the definitions from the libosmogsm
Use the code that is shipped inside the libosmogsm library. Right now
the signature (besides the static) and the implementation is the same.
This makes using the libosmogsm SMC code more easy in the near future.

For the gsm340_gen_oa we are now using a small wrapper to generate the
proper type and numbering plan.
2012-11-21 21:31:47 +01:00
Harald Welte 0a1a312311 Merge branch 'laforge/smpp' 2012-11-16 22:17:49 +01:00
Harald Welte 6c7680d726 SMPP: build the smpp interface only in case of ./configure --enable-smpp 2012-11-16 22:16:46 +01:00
Harald Welte 1a2993adb7 SMPP: fix subscriber reference leak.
subscr_get_by_* is already increasing the refcount, we shouldn't
do that a second time (thanks, Holger).
2012-11-16 22:00:10 +01:00
Harald Welte 9122c13933 SMPP: More logging in error cases, fix UDH in 7bit ASCII 2012-11-16 22:00:10 +01:00
Harald Welte 874f9f1aa7 SMPP: More consistent logging / error reporting 2012-11-16 22:00:10 +01:00
Harald Welte 8a1b056bff SMPP: Implement ALERT NOTIFICATION on attach/detach of subscribers 2012-11-16 22:00:10 +01:00
Harald Welte 9ad0362429 SMPP: Deal with DCS according to 03.38 and respect TP-PID 2012-11-16 22:00:09 +01:00
Harald Welte 4dbcdad903 SMPP: Introduce wrapper macro to memset all structures to zero
For some reason, libsmpp34 is too smart to zero out the entire structure
to which it is unpacking.  This introduces an ugly wrapper macro to
work around.  This needs discussion with the libsmpp34 maintainer.
2012-11-16 22:00:09 +01:00
Harald Welte e94db49698 SMPP: Introduce ESME reference coounting
In case a ESME disappears after SUBMIT-SM but before the MT-SMS
is delivered (transaction mode), we have to make sure the esme
structure still exists.
2012-11-16 22:00:09 +01:00
Harald Welte d4bdee79e9 SMPP: Implement transaction mode for SUBMIT-SM
WARNING: if the ESME disconnects, osmo_esme gets freed, and
sms->smpp.esme might point to invalid/unallocated memory!
2012-11-16 22:00:09 +01:00
Harald Welte f1033cc752 Initial support of SMPP interface for MT-SMS 2012-11-16 22:00:09 +01:00
Harald Welte 90d7f26f67 Makefile: just a slight re-order / breaking of a line 2012-11-16 22:00:09 +01:00
Holger Hans Peter Freyther eedb45362d mgcp: Print both receivd and expected address in the error statement
The log statement is split into two because inet_ntoa works on an
internal buffer and would print the last address twice.
2012-11-12 10:55:29 +01:00
Holger Hans Peter Freyther 98da544992 nat: Move the ctrl handling code into a separate file
Move to the control command handling out of the main file into
a dedicated module. There are still some calls embedded into the
main code but it will be moved soon.
2012-11-12 10:49:10 +01:00
Holger Hans Peter Freyther 88c06bcd64 Merge branch 'zecke/mgcp-rtp-statistics' 2012-11-12 10:46:11 +01:00
Holger Hans Peter Freyther cb306a689e mgcp: Send the jitter statistics at the end of the call 2012-11-12 10:45:09 +01:00
Holger Hans Peter Freyther 30690adbc8 mgcp: Calculate the jitter with the formula/code from the appendix
Use a usec timestamp for the local time. The seconds to usec will
swap over to the lower bits but this appears to be correct. The
CLOCK_MONOTONIC is used to fulfill the RFC 3550 requirement even
if it is a bit slower than the gettimeofday.

Make sure to initialize transit in a way that the first transit
time will be 0. Otherwise the jitter will contain the difference
of the localtime and the remote time.
2012-11-12 10:45:03 +01:00
Holger Hans Peter Freyther 38e02c5125 mgcp: Calculate the packet loss as of Appendix A of RFC 3550
Calculate the expected packages and packet loss as of RFC 3550.
The values should be clamped but our packet loss counter is 32
bits and not 24 and we should clamp at other values but I am
waiting for some issues first before dealing with that.
2012-11-12 10:44:58 +01:00
Holger Hans Peter Freyther 769912c9e9 mgcp: Calculate the wrap around as of Appendix A in RFC 3550
This is missing the probation and the dealing with a remote
restart. For the remote restart we will simply write a log
statement as this is unlikely to happen during a call or if
it does happen the call will be taken down by the BSC anyway.
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther 1e85af661c mgcp: Document a difference between RFC 3550 and this code
Explain why this code deals with only one source and that this is
a limit of some equipment (e.g. the nanoBTS).
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther ed3a661d0b mgcp: Align the variable naming with Appendix A of RFC 3550
Align the naming inside the mgcp_rtp_state with the naming inside
the 'source' struct of the appendix. Make first_seq_no/base_seq
a uint16_t. This is removing rules for alignments and reduces the
struct from 40 bytes to 36.
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther 0bf15a8187 mgcp: Include statistics at the end of a connection
Follow the MGCP specification and send the collected statistics
at the end of a call. Right now this does not include jitter, packet
loss and delay.
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther 2e8e659586 mgcp: Remember the initial sequence number of the stream
This information is required for calculating the packet loss at the
end of a phone call.
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther 952f752ffa mgcp: Count the received octets as of the MGCP specification
Count the received octets. This is encouraged by the MGCP specification.
Use a 32bit counter that is good enough for more than 12 hours of a EFR
call. This limit is good enough for the current configuration.
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther 2a60a11c48 mgcp: Remove the lost_no from the mgcp statistics
The RFC 3435 specifies a different formula for calculating the lost
packages. It involves the number of received packages and the delta
of the sequence number.
2012-11-12 10:42:05 +01:00
Holger Hans Peter Freyther de1674ab02 bts: Really drop the BTS in case of an OML NACK
The previous code didn't work as expected. The trx and dst pointer
are located in an union and in the case of the Abis code the dst
is used to point to the signalling link timeslot and not the TRX.

The is_ipaccess_bts always returned false because the dst was casted
to a trx while it was no trx.

This fix was tested with the nack_test/NACKTest.st of the test repo.
2012-11-11 18:33:17 +01:00
Holger Hans Peter Freyther 75172124e7 sms: Re-order the include files after the separationf OpenBSC and osmocore 2012-11-11 18:33:09 +01:00
Holger Hans Peter Freyther 3dfe8a1705 nat: sizeof char * != sizeof char[], make the code work on 64bit systems
The test cases were failing on 64bit systems because the sizeof
code operated on the pointer size which is 8 and longer than the
size that was intended to be used for comparing it.
2012-11-07 13:35:14 +01:00
Holger Hans Peter Freyther e2f34d588c nat: Inject a a=fmtp:%d to force the right AMR code
This assumes that AMR is used and/or the mode-set is ignored for other
codecs by the remote end.
2012-11-07 13:34:43 +01:00
Holger Hans Peter Freyther 93fda87cf8 debian: Make the package creation work on debian squeeze (stable)
the dh_autoreconf application did not honor the sourcedirectory
option back then. Override the target and call autoreconf from
the right directory.
The libdbi development package is called libdbi0-dev. Use this name
for Debian stable but it should work for Ubuntu as well.
2012-11-06 23:12:02 +01:00
Holger Hans Peter Freyther e0b5972d30 debian: We require libdbi-sqlite3 for running the tests
The tests are not broken but the db test fails when the dbi driver
is not installed. Make it a build time depedency.
2012-11-06 23:12:00 +01:00
Holger Hans Peter Freyther f3a317ceed debian: Update the rules to work from the toplevel directory 2012-11-06 23:11:43 +01:00
Holger Hans Peter Freyther e600eed7fa debian: Move debian directory to ease building packages
This is required to have git-buildpackage be able to create tarballs
from the git repository and was done by Jan in the debian branch as
well.
2012-11-06 23:01:43 +01:00
Holger Hans Peter Freyther 6b55f603e3 sms_queue: It is a bad idea to detach a subscriber on failed delivery
It is a bad idea to detach a subscriber. The subscriber will not
be reachable until the next periodic updating cycle. In case we have
too many failed deliveries we will need to reduce the period for the
LU and implement a subscriber purging task.

This is a preparation for the 29C3 and a problem Jolly experience with
his type writer system.
2012-11-02 17:23:05 +01:00
Holger Hans Peter Freyther 7456891439 mgcp: Fix the log message. This is inside the MDCX printing routine 2012-10-30 11:22:21 +01:00
Holger Hans Peter Freyther cb3c2c95bf nat: Make MGCP helper routine static as it is internal to the MGCP code 2012-10-29 19:41:51 +01:00
Holger Hans Peter Freyther 07fc097fc4 nat: Document the high level goal of the MGCP/NAT routines
Provide some high level documentation that might help to understand
what this code is supposed to be doing.
2012-10-29 19:41:37 +01:00
Tobias Engel aff20717e4 Set byte order defines when compiled on OSX
Byte order defines have a DARWIN prefix on OSX so the values openbsc
expects are set from their Darwin counterparts when compiled on OSX.
2012-10-27 10:09:21 +02:00
Holger Hans Peter Freyther 511f9c3e4a si: Partially implement the range encoding for the SI.
I saw the old copy of the "Appendix J" code too late and I have
discovered some quirks and I am more familar with my implementation.
Most noticable 'w' only needs to be as big as the input arfcn but
requires the 'w' to be initialized. The power_of_2 implementation
differs as well (mine matches the output of wirehsark).

The f0 could be chosen in a better way but right now picking
the lower bound is the easiest. It is not clear if to use
modulo if the range is chosen in the middle. This can be improved
in the future. Right now I have no bit fiddling for range128, 256
and 1024 as I was running out of time.
2012-10-22 15:23:58 +02:00
Pablo Neira Ayuso d49eb74732 libbsc: fix message leaks on several error paths
This patch fixes several leak of msgbs in uncommon error paths.

Add break at the end of default to make Holger and Peter happy ;-)
2012-10-18 19:04:40 +02:00
Andreas Eversberg 2ee7ecddeb Allow setting of Control Channel Description parameters via VTY 2012-10-18 12:01:32 +02:00
Holger Hans Peter Freyther 94c2b0578b bsc: Do not print "SI 18" but SI2ter when the SI generation fails 2012-10-09 11:54:00 +02:00
Harald Welte c15d0ac8dd SI13: Set alpha value to a safer default of 0 instead of 10
alpha=0 (the new value) doesn't reduce MS transmission power during GPRS
as much as we did with alpha=10.  This is to optimize for coverage and
to keep GPRS working at all cost, and not care about MS battery life
time or uplink interference in surrounding cells.

FIXME: This should be made configurable via the VTY and the normal
default (unless configured otherwise by vty/config file) should be '6'.
2012-10-08 21:22:08 +02:00
Harald Welte d9173c3fce bsc_init: Don't drop all BTSs because a single BTS had an error 2012-10-08 21:17:51 +02:00
Holger Hans Peter Freyther 8936d00587 tests: Remove the debug/logging test as it is in libosmocore now 2012-10-04 10:55:58 +02:00
Andreas Eversberg becc89a98e Fix: T3192 and T3193 must be similar
In order to keep mobile at PACCH as long as possible the timer T3192 is
set to 1500ms. This reduces the probablity of long lasting assignment
process on CCCH for subsequent downlink TBFs.
2012-09-29 20:29:16 +02:00
Holger Hans Peter Freyther 778695d0b4 mgcp: Add the disable color option to the mgcp binary 2012-09-20 16:06:56 +02:00
Holger Hans Peter Freyther 221ff66327 systemd: Add service units for the BSC, NITB and MGCP
Add simple systemd service units.
2012-09-20 16:06:56 +02:00
Harald Welte bf0a7c97be nncc_builtin: send CHAN MODE MODIFY after CALL PROCEEDING
This is specified in fifugre 7.10c of 3GPP TS 04.08.
2012-09-19 11:47:49 +02:00
Holger Hans Peter Freyther 34203bd487 abis_nm: Provide a reason when an invalid channel configuration is used
Provide a human readable reason the channel combination is not allowed.
2012-09-17 17:24:49 +02:00
Holger Hans Peter Freyther 9ceea68ba9 abis_nm: Log an error when the channel combination can not be set. 2012-09-17 14:21:53 +02:00
Holger Hans Peter Freyther ca5d211113 Merge branch 'feature/local-mscs' 2012-09-11 18:02:46 +02:00
Holger Hans Peter Freyther 31b245b91a bsc: Add vty code for allowing emergency 2012-09-11 18:01:52 +02:00
Holger Hans Peter Freyther cbaa880ae8 bsc: Add vty function for the MSC type 2012-09-11 18:01:52 +02:00
Holger Hans Peter Freyther 18fa70aa3a bsc: Look for CM Service Requests with emergency cause
Look for emergency calls and send them to a MSC that can
handle them properly.
2012-09-11 18:01:52 +02:00
Holger Hans Peter Freyther 210565ed8c bsc: Introduce a local MSC type and forbid it from being selected 2012-09-11 18:01:52 +02:00
Holger Hans Peter Freyther c11889f3dd Merge branch 'feature/multiple-msc-connections' 2012-09-11 18:00:59 +02:00
Holger Hans Peter Freyther f67d9a9bed bsc: Attempt to respond to paging to the MSC that paged
Inspect the message and see if it is a paging response,
then try to find the MSC that has paged this subscriber
and select this as the target MSC, also move the MSC to
the back of the list for 'load balancing'.
2012-09-11 17:48:01 +02:00
Holger Hans Peter Freyther 644b0bf3da bsc: Hand the msc_connection to the UDT handling, pass it to paging
Pass the osmo_msc_data to the paging sub system, change the code
to pass the osmo_msc_data instead of network + bsc_msc_conn.
2012-09-11 17:47:42 +02:00
Holger Hans Peter Freyther 076af1c54b bsc: Move the finding of a MSC into the filter code
For responding to paging on the right link we will need to
figure out if the msg is a paging response.
2012-09-11 17:47:30 +02:00
Holger Hans Peter Freyther 354c87cdfc bsc: Select a MSC in a round-robin fashion
Select a MSC, add it to the back of the list after we have
selected it.
2012-09-11 17:47:08 +02:00
Holger Hans Peter Freyther 8b902d74cf bsc: Allow to configure more than one MSC in the VTY 2012-09-11 17:47:01 +02:00
Holger Hans Peter Freyther 8c176cc6ab msc: Only kill connections belonging to the given MSC
When a MSC connection drops, only kill the connections that
belong to the given MSC and not all other connections.
2012-09-11 17:46:54 +02:00
Holger Hans Peter Freyther ffd6856249 gbproxy: Address two unaligned memory access warnings
The lines 461 and 303 were producing unaligned memory access as
the BVCI was not aligned properly. Introduce a tlvp_val16_unal to
read 16bit from the data, use memcpy to the stack to make sure
that it is working in the aligned and unaligned case.
2012-09-11 16:23:31 +02:00
Daniel Willmann 7a7c2f8567 osmo-bsc: Command bts_connection_status with TRAPS 2012-09-11 16:20:46 +02:00
Daniel Willmann 806d6549f8 osmo-bsc: Introduce command msc_connection_status and send TRAPs for it 2012-09-11 16:20:46 +02:00
Daniel Willmann 6dc6910b79 nat: Change the ctrl command path
The commands net.<netid>.bsc.<bscid>.* are now forwarded to the
appropriate osmo-bsc. <netid> for now is just 0. <bscid> is not the LAC
anymore (since that could be ambiguous), but instead the number as
configured in bsc-nat.cfg
2012-09-11 16:20:46 +02:00
Daniel Willmann 6088f149b5 libctrl, osmo-bsc: Get rid of net prefix
net is now implicit in the root node
2012-09-11 16:20:46 +02:00
Daniel Willmann 65924a5fe8 osmo-bsc: Include rf statistics in the location-state TRAP as well
The first fields are still the location up to the height.
The next field is "operational" if any of the trx are operational,
otherwise "inoperational"
The second to last field contains "locked" if all of the trx are in the
admin state, otherwise "unlocked".
The last field represents the rf policy currently in effect. It is one
of (on|off|grace|unknown).

<tstamp>,<valid>,<lat>,<lon>,<height>,<oper>,<admin>,<policy>
2012-09-11 16:20:45 +02:00
Daniel Willmann 11620111f4 osmo-bsc: Prepare to send more than just the location in the TRAP 2012-09-11 16:20:45 +02:00
Daniel Willmann d08ad7d6d9 ctrl: Use strtol instead of atoi to detect conversion errors 2012-09-11 16:20:45 +02:00
Daniel Willmann ebe22375a6 ctrl: Improve error messages in ctrl_cmd_handle 2012-09-11 16:20:45 +02:00
Daniel Willmann 7aa4f0a263 ctrl: Change the paths to bts.%i. instead of bts%i 2012-09-11 16:20:45 +02:00
Holger Hans Peter Freyther fa0ec157af ctrl: Do not allow to set the RF Lock for a single trx
The ip.access nanoBTS has issues if the admin changes are called
too often in too little time. This will lead to a situation where
the site manager will fail to start properly. Remove the TRX code
as the RF Control class does not support setting this per TRX.
2012-09-11 16:20:45 +02:00
Daniel Willmann a5352a0174 osmo-bsc: Change variable name to better reflect current/last location 2012-09-11 16:20:37 +02:00
Daniel Willmann 47b5b3eeb2 gsm_data: Include a structure for the geographical location in gsm_bts 2012-09-11 15:22:00 +02:00
Daniel Willmann 5e95f45af0 ctrl: Improve error handling if controlif setup fails 2012-09-11 15:20:55 +02:00
Daniel Willmann 5ff06af6f5 osmo-bsc: Put the control commands in osmo_bsc_ctrl.c 2012-09-11 14:53:51 +02:00
Daniel Willmann d5eb431c47 osmo-bsc: Only send a TRAP if the location changes 2012-09-11 14:46:48 +02:00
Daniel Willmann adcde9f8f5 osmo-bsc: Add support for traps to the location command 2012-09-11 14:43:27 +02:00
Daniel Willmann 47824541f0 osmo-bsc: Allow location tstamp to be zero if fix is invalid 2012-09-11 13:10:38 +02:00
Daniel Willmann ad2946ce03 osmo-nitb: Update control interface API in osmo-nitb 2012-09-11 13:10:18 +02:00
Daniel Willmann d79da3baac nat: Add support for traps to the nat 2012-09-11 13:09:03 +02:00
Daniel Willmann 721f0325b5 libctrl: Add function ctrl_cmd_send_to_all
Sends a command to all ctrl connections except the one it originated
from.
2012-09-11 13:08:48 +02:00
Daniel Willmann 114a010c33 libctrl: Add trap helper function 2012-09-11 13:05:30 +02:00
Daniel Willmann 6fc4a98fc5 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
2012-09-11 12:52:23 +02:00
Daniel Willmann f3b31eb349 libctrl: Keep track of connections in struct ctrl_handle 2012-09-11 12:43:40 +02:00
Holger Hans Peter Freyther 4dd84ff7c2 bts_hsl_femtocell.c: Use PRIx64 to printf the uint64_t
bts_hsl_femtocell.c: In function ‘hsl_sign_link_up’:
bts_hsl_femtocell.c:206:3: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘uint64_t’ [-Wformat]
bts_hsl_femtocell.c:210:2: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘uint64_t’ [-Wformat]
2012-09-11 12:41:23 +02:00
Holger Hans Peter Freyther 8c3d0695e4 mgcp_network.c: Address compiler warning on return
When adding the "omit RTCP" the method started to return with
a proper return statement.

mgcp_network.c: In function ‘send_to’:
mgcp_network.c:233:1: warning: control reaches end of non-void function [-Wreturn-type]
2012-09-11 12:41:23 +02:00
Holger Hans Peter Freyther d98136d25c bsc_init: Initialize rc on all paths to address a compiler warning
bsc_init.c:203:6: warning: ‘rc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
bsc_init.c:101:6: note: ‘rc’ was declared here
2012-09-11 12:41:23 +02:00
Holger Hans Peter Freyther a5050b14c9 misc: Address compiler warning on unused variables
abis_nm.c: In function ‘abis_nm_get_attr’:
abis_nm.c:1380:11: warning: unused variable ‘cur’ [-Wunused-variable]

abis_nm.c: In function ‘ipac_parse_bcch_info’:
abis_nm.c:2588:11: warning: variable ‘len’ set but not used [-Wunused-but-set-variable]

bts_nokia_site.c:1310:6: warning: variable ‘constructed’ set but not used [-Wunused-but-set-variable]
bts_nokia_site.c: At top level:
bts_nokia_site.c:1364:12: warning: ‘dump_elements’ defined but not used [-Wunused-function]

gsm_04_08.c: In function ‘mm_rx_loc_upd_req’:
gsm_04_08.c:521:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]

osmo_msc.c: In function ‘msc_ciph_m_compl’:
osmo_msc.c:122:7: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]

bts_hsl_femtocell.c: In function ‘hslfemto_bootstrap_om’:
bts_hsl_femtocell.c:101:11: warning: variable ‘cur’ set but not used [-Wunused-but-set-variable]

bts_hsl_femtocell.c: In function ‘hsl_drop_oml’:
bts_hsl_femtocell.c:232:21: warning: variable ‘line’ set but not used [-Wunused-but-set-variable]

handover_logic.c: In function ‘ho_chan_activ_ack’:
handover_logic.c:197:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
2012-09-11 12:41:23 +02:00
Holger Hans Peter Freyther 86f240aded gsm_data: Address compiler warning of unhandled switch
gcc does not really know the _NR_OF_ELEMENTS_IN_ENUM approach, add
the _NUM_GSM_BTS_TYPE to the handled cases.

gsm_data.c: In function ‘gsm_set_bts_type’:
gsm_data.c:349:2: warning: enumeration value ‘_NUM_GSM_BTS_TYPE’ not handled in switch [-Wswitch]
2012-09-11 12:41:22 +02:00
Harald Welte 79c34ffb4f OM2000: don't silently send CON/IS/TF configuration request 2012-09-07 20:15:50 +02:00
Harald Welte 4c889a5c49 RBS2000: Don't sent IS configuration if we want to config TF 2012-09-07 20:14:47 +02:00
Harald Welte 0818f31144 OM2000: make sure to route messages to IXU/DXU over BTS oml link
Messages to CF and other core objects need to go to the BTS (IXU/DXU)
OML link, not to the OML link of the primary TRX!
2012-09-07 19:10:47 +02:00
Harald Welte 240a828ffd OM2000: don't signal operational state for a unknown MO
This case happens if the BTS signals operational state for a TRXC which
is not configured as TRX in the openbsc.cfg
2012-09-07 19:10:47 +02:00
Holger Hans Peter Freyther 037065deee contrib: Add some SQL statements to remove old subscribers 2012-09-07 19:09:10 +02:00
Harald Welte e422798866 RSL: Add basic support for CSD transparent mode
We now have a lchan->csd_mode member that determines if RSL should
activate the channel in CSD transparent services or not.  The previous
code always assumed CSD is non-transparent.

(This requires libosmocore >= eed26116c96f03c6128fac3dead9054714af6cab)
2012-08-29 16:33:54 +02:00
Harald Welte bb53e3577a reimplement chan_compat_with_mode() to take care of CSD 2012-08-29 16:33:54 +02:00
Harald Welte 9fc70f365a bsc_api: Invert logic of chan_compat_with_mode()
A function called this  way should return 1 if it is compatible, so
something like "if (!chan_compat_with_mode())" will check if it is not
compatible.
2012-08-29 16:33:53 +02:00
Eric Butler 6fcac63cc0 Add init script to osmocom-sgsn package. 2012-08-26 20:09:55 +02:00
Eric Butler b561459dd6 osmocom-nitb debian package improvements.
* Don't enable MNCC sock by default.
* Create important directories.
* Fix init script 'stop' command.
2012-08-26 20:09:55 +02:00
Eric Butler 6e7d137e79 Start osmocom-nitb with HLR path and RTP proxy enabled (debian package). 2012-08-26 20:09:55 +02:00
Eric Butler 3d610e63cc Fix init script. 2012-08-26 20:09:55 +02:00
Eric Butler dd68fcaeee Fix libdbi package dependency 2012-08-26 20:09:55 +02:00
Eric Butler 010c9551ff Use package version since git info won't be available. 2012-08-26 20:09:54 +02:00
Eric Butler a73ca05db6 Update debian package. 2012-08-26 20:09:54 +02:00
Harald Welte 570ce24deb VTY: improve VTY prompt and make sure exit/end works everywhere
Some nodes below 'config' didn't have ournode_exit / ournode_end,
and thus were not able to properly perform this function.  exit should
always only go back one level, while end drops us back to ENABLE_NODE.

The prompt now represents the nesting level, and there's one consistent
space after the final prompt character (typically #).
2012-08-17 13:16:10 +02:00
Harald Welte e555c2b545 VTY: dynamically create BTS "type" command syntax 2012-08-17 13:02:12 +02:00
Harald Welte 57e0724ed4 BSC VTY: use numeric ranges for bts/trx/timeslot numbers
This effectively limits the number of BTSs to 256, but I think that's
acceptable for now.  Unfortuantely there's no decent way to dynamically
update the valid number range depending on how many BTSs are actually
configured in the system :/
2012-08-17 12:50:14 +02:00
Harald Welte 4ab9d7c012 dynamically generate a proper VTY reference for phys_chan_config
this uses vty_cmd_string_from_valstr() from _very_ recent libosmocore,
so you have to update the library, sorry.
2012-08-17 12:42:06 +02:00
Harald Welte 13fe21939c ... and more VTY help fixes 2012-08-17 09:57:25 +02:00
Harald Welte d13e0cd6db Some more VTY documentation / help fixes 2012-08-17 09:52:03 +02:00
Harald Welte cfaabbb21e complete the VTY help messages so we don't get "null" in the manual 2012-08-16 23:23:50 +02:00
Harald Welte fe568f235f abis_nm: Add function abis_nm_get_attr() to get attributes from BTS 2012-08-14 19:15:57 +02:00
Holger Hans Peter Freyther df49a983e2 docs: Do not remove too much from of the dumped online help
Use the len of the end and not the filename.
2012-08-14 00:14:36 +02:00
Holger Hans Peter Freyther b7b6cf5695 doc: Document a shortcoming of the current OML code
The BTS has 10s to respond to a command but we do not run any
timer. So it is possible that the BTS gets stuck in the process
of the bring up.
2012-08-06 12:41:45 +02:00
Holger Hans Peter Freyther f42e908cea contrib: Create a script that opens a SIP session before
Use the Smalltalk SIP implementation to create a call
and once the call has been established start the replay
using the commoncode. No patching of RTP occurs yet.
2012-08-05 16:10:32 +02:00
Holger Hans Peter Freyther 602559fd9f contrib: Move the shared code into a new file 2012-08-05 09:27:20 +02:00
Holger Hans Peter Freyther 4552d8061a contrib: Make the RTPReplay a a class so it can be shared 2012-08-05 09:25:25 +02:00
Holger Hans Peter Freyther 59043d8c94 typo: Mandantory -> Mandatory.. a common typo of mine 2012-08-03 11:05:29 +02:00
Holger Hans Peter Freyther 9b5db287c6 gb: suspend_ref was changed to a plain uint8_t, update the code
Require a 0.5.2+ libosmogb due the change of the suspend_ref type.
2012-08-03 10:08:32 +02:00
Holger Hans Peter Freyther 1a6b83c919 nat: Document all parameters of the VTY commands 2012-07-28 16:14:04 +02:00
Holger Hans Peter Freyther bc6a54dadc mgcp: Make sure "no rtcp-omit" is fully documented
One command missed the NO_STR in the documentation, share the
main text across all commands.
2012-07-28 15:46:45 +02:00
Holger Hans Peter Freyther d028807658 misc: Introduce a script tha generates the VTY reference
Update/Move/Create example configuration files for NiTB, BSC,
MGCP, NAT and the GbProxy. Create a script that starts, generates
the vty reference and terminates the application.
2012-07-28 15:30:09 +02:00
Holger Hans Peter Freyther 64c17fa598 libbsc: Add documentation to MM INFO, LAC, TSC, CI 2012-07-21 00:28:05 +02:00
Holger Hans Peter Freyther 3217fa2412 nitb: Document missing parameters, reword documentation, combine param
Change "pending send" to "pending-send" as there is no other pending
command right now, add missing documentation for parameters.
2012-07-21 00:01:01 +02:00
Harald Welte 70f9205cd9 MSC 04.08: RRLP messages are DRR, not DNM ! 2012-07-16 13:22:19 +02:00
Harald Welte ae1d010220 BSC API: Don't treat a RRLP message as NOTICE event
While generally we should log troly unknown RR messages, we can simply
pass along RRLP messages (which aren't unknown!)

In real networks, the RRLP would probably not end up at the MSC, but
well, sometimes we don't care what real/classic networks do.
2012-07-16 13:20:53 +02:00
Harald Welte fdf453c0a9 SGSN: Code to help debug / fix sgsn crash in cb_data_ind()
A crash was obsserved in cb_data_ind() when mm is dereferenced.

This patch adds some safeguards that try to prevent the library handle
back-pointer to the pdp_ctx to be NULL, and print a stack backtrace in
case we are free() ing the sgsn-side pdp_ctx while there's still a
library handle attached.
2012-07-14 12:18:28 +02:00
Harald Welte 7b022eed2d add some comments regarding the free() / release of pdp contextx
It might be that we're deleting structures instead of properly cleaning
up the attached libgtp handles...
2012-07-14 12:17:42 +02:00
Harald Welte 45f9171175 move BTS-specific timezone override into sub-structure
Group all three structure members involved in bts-specific timezone
handling into a sub-structure.
2012-07-12 01:14:28 +02:00
Harald Welte 25cf824edc handover: Not finding a HO record on CHAN ACT NACK is not an error
... it might well a completely non-ho-related establishment
2012-07-12 01:14:28 +02:00
Holger Hans Peter Freyther 153b13b02e msc: Attempt to release the lchan immediately on IMSI Detach
The Nokia E71 sends a "IMSI Detach" this msc code does not immediately
send the "RR Channel Release", the E71 is impatient and sends a DISC,
the "RELEASE INDICATION" is handled by starting the channel release
procedure. OpenBSC sends a "RR Channel Release" which will never be
answered, during the early release there is no timer and the lchan will
be in "RELEASE REQUESTED" forever.

This commit removes the anchor operation and checks if the channel can
be released immediately. Regarding the channel release handling there
is already a branch that needs to be tested.
2012-07-10 08:57:41 +02:00
Harald Welte 8c00496e42 GPRS LLC: fix segfault when transmitting downlink unit-data without mmctx 2012-07-04 21:53:12 +02:00
Harald Welte ad66a2d150 BSC VTY: Allow encryption to be set to A5/3
We are currently not checking if the BTS actually suports that cipher,
and we particularly don't have any hack for ip.access which apparently
seems to re-use the RSL algorithm identifier for A5/2.
2012-07-04 21:39:27 +02:00
Harald Welte f383aa11a5 BSC: introduce new "sysmobts" BTS model
so far, osmo-bts/sysmobts used to be entered as "sysmobts" type in the
configuration file.  However, there are some differences in the
protocol/behaviour and we should reflect that by a new BTS plugin (with
lots of code reuse from the nanobts driver).
2012-07-02 20:13:08 +02:00
Harald Welte 0c1bd61bb3 pre-fix measurement reports with subscriber identity
... otherwise it's impossible to distinguish them from each other.
2012-07-02 20:13:02 +02:00
Harald Welte 019f913ca3 gsm_data_shared: add structure for decoded parameters of RLC config
this is primarily needed on the BTS side, but we should also use it on
the BSC side and make the parameters VTY-configurable.
2012-06-28 09:03:07 +02:00
Harald Welte c95175fb88 ipaccess: some more comments on timer values 2012-06-28 09:03:00 +02:00
Harald Welte edcba4e307 use new external libosmogb (part of libosmocore.git)
This removes the libgb (GPRS NS/BSSGP) code from the openbsc.git
repository and uses the new version from libosmocore.git instead.
2012-06-17 23:34:34 +08:00
Harald Welte b46d566559 index on master: d24566a libgb: separate header files related to spec and implementation 2012-06-17 13:13:52 +08:00
Harald Welte d24566ac6e libgb: separate header files related to spec and implementation
like in libosmogsm, we separate between header files that are just
reflecting information in the respective specs, and header files that
related to our specific implementation.
2012-06-17 13:12:51 +08:00
Harald Welte ce95b27b68 libgb: make sure all BSSGP functions have bssgp_ prefix
We change the minority of functions employing the gprs_bssgp_ prefix to
match with the majority without gprs_ in front.
2012-06-17 13:05:48 +08:00
Harald Welte 11461a6457 libgb/gprs: don't use log_info from libcommon anymore 2012-06-17 12:58:46 +08:00
Harald Welte e6599ee180 libgb: prefix all NS related functions with gprs_ 2012-06-17 12:38:07 +08:00
Harald Welte b1fd9022eb libgb: don't call directly into GMM / LLC layer
Instead of direct function calls to individual functions, we now
generate primitives (osmo_prim) and send them to one
application-provided function "bssgp_prim_cb()"
2012-06-17 12:17:22 +08:00
Harald Welte faa70ff2c6 libgb: remove dependency of BSSGP to include sgsn/gmm internal structs 2012-06-17 09:31:16 +08:00
Harald Welte 0d5e8e0b56 update .gitignore 2012-06-17 09:05:43 +08:00
Harald Welte 68d85d5610 libgb: Remove dependency to openbsc/debug.h 2012-06-16 17:53:38 +08:00
Harald Welte fdd8b3b40d libgb: remove dependencies to openbsc/vty.h and openbsc/gsm_data.h
Rather than using openbsc internal data/functions, we now use only
internal and libosmocore-provided ones.
2012-06-16 16:59:50 +08:00
Harald Welte a6a20b4ff6 libgb: Use library SS_L_NS instead lf local SS_NS
which removes some further dependencies of libgb to openbsc internal
code and data.
2012-06-16 16:40:42 +08:00
Harald Welte 8645e101da libgb: move GPRS specific msgb CB definitions to separate header 2012-06-16 16:09:52 +08:00
Harald Welte ea34a4e3a7 split libgb into a separate library for outside use
This also removes the dependency to osmo_sock() inside libcommon and
replaces it with osmo_sock_* from libosmocore
2012-06-16 15:14:00 +08:00
Harald Welte 704cb8680b gsm_data_shared: add handover related bits for osmo-bts 2012-06-16 15:02:13 +08:00
Harald Welte 67161f27d1 Allow VTY-based configuration of T3105
This timer will only be forwarded to BS11 and Ericsson Abis so far,
not to Nokia and ip.access BTS yet.
2012-06-03 16:58:18 +02:00
Harald Welte 66d360661a update year in copyright string 2012-06-03 16:58:09 +02:00
Harald Welte f25b55ec71 abis_rsl_rcvmsg(): Fix msgb memory leak in error path
Thanks to Andreas Eversberg for spotting this one.
2012-05-31 20:22:34 +02:00
Harald Welte c513ded578 vty / cfg_bts_tsc: TSC range is 0..7, not 0..255 2012-05-31 10:57:40 +02:00
Holger Hans Peter Freyther 3fab3fdd24 rtp: Add a smalltalk script that can replay the state file. 2012-05-18 18:54:11 +02:00
Holger Hans Peter Freyther bea9a1206b rtp: Add lua script to split a trace by SSRC/streams
This can be used to replay RTP streams with more or less the
same timing as the original one.
2012-05-18 10:48:02 +02:00
Holger Hans Peter Freyther 2c9ea91317 nitb: Enable the external RF Control interface for the nitb application
Add argument handling for the nitb application and create the RF
ctrl interface for being able to control the TRX using an external
socket.
2012-05-17 09:38:24 +02:00
Holger Hans Peter Freyther 41a93dc2f0 bsc: Move the osmo_bsc_rf file into the libbsc code and rename
The nitb will provide the RF interface as well.
2012-05-17 09:37:22 +02:00
Holger Hans Peter Freyther a8090d54d6 mgcp: Make it possible to drop RTCP packets coming from the BTS/Net
The ip.access nanoBTS appears to send quite broken NTP timestamps in
the RTCP messages might confuse equipment that uses the sender report
of the BTS. Make it easy to experiment by adding an option to drop RTCP.
2012-05-11 13:09:30 +02:00
Holger Hans Peter Freyther c50e04a409 bsc vty: Provide a show mscs command to show the state of each MSC 2012-05-11 12:41:13 +02:00
Sylvain Munaut 5e80cc4adc libmsc/db: Fix max value of ainfo->a3a8_ki_len in db_get_authinfo_for_subscr
Thanks to Robert Ingr for pointing this out

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2012-05-07 22:09:15 +02:00
Harald Welte fda74ee055 RSL add debug statements when sending RSL EST REQ and RSL REL REQ. 2012-04-26 19:43:36 +02:00
Harald Welte 6e8dcf304c bsc_api: Fix wrong order of log category and level arguments 2012-04-26 19:35:58 +02:00
Harald Welte 0e9311df40 bsc_api: log RR STATUS from MS as NOTICE, not DEBUG level 2012-04-26 19:35:27 +02:00
Harald Welte 46cb8514a5 add loopback flag to lchan (for osmo-bts) 2012-04-19 23:14:28 +02:00
Holger Hans Peter Freyther afa0ad1723 lchan: Fix the name of the SACCH in the variable names
Call the channel by the right name.
2012-04-18 18:58:36 +02:00
Holger Hans Peter Freyther cc7b22a53b bsc_api: Send RR Release and de-activate the SACCH on error
In case the connection should not be created/accepted release
the channel by sending a RR Release and de-activating the
SACCH. Phones should deal better with that behavior.
2012-04-17 21:54:24 +02:00
Holger Hans Peter Freyther ec2542627e mgcp: Catch up with the renaming of the MGCP GW binary 2012-04-13 18:06:26 +02:00
Holger Hans Peter Freyther a5dcdd9a9a bsc: Allow to run a mixed TCH/H, TCH/F configuration
In case the call handling starts on a TCH/H switch to a TCH/F
if fullrate is requested. Add a method that is used to determine
if the mode and current channel are compatible with each other.
2012-04-11 20:15:54 +02:00
Harald Welte 5d52c97cff add 'ciph_state' member to BTS-side lchan definition 2012-04-08 20:23:28 +02:00
Harald Welte 9c3dc90d16 introduce HAVE_TM_GMTOFF_IN_TM
Not all architectures have the tm.tm_gmtoff member.  This fixes cygwin
builds.
2012-04-08 16:59:24 +02:00
Harald Welte a334c296e0 make sure we still build on systems that don't have IPPROTO_GRE 2012-04-08 15:56:00 +02:00
Holger Hans Peter Freyther 09db1a44bc nat: Add another test case for TP-SRR clearing and number rewrite 2012-03-26 16:22:08 +02:00
Holger Hans Peter Freyther 2f2be578cb 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]
2012-03-16 12:18:39 +01:00
Holger Hans Peter Freyther 20fea24515 bsc: Prepare to have multiple MSC connections
We now have a list of MSCs but in the code we will
try to access the MSC with the nr 0.
2012-03-16 11:56:21 +01:00
Holger Hans Peter Freyther 44e5dad3e2 bsc: Use the right connection for outgoing packets
This is needed for simple UDT messages where we do not have
a SCCP connection.
2012-03-16 11:56:10 +01:00
Holger Hans Peter Freyther abd668a68d bsc: Move more things to use osmo_msc_data* directly 2012-03-16 11:56:10 +01:00
Holger Hans Peter Freyther f936fb4086 bsc: Move the bsc_filter to use the osmo_bsc_sccp_con 2012-03-16 11:56:10 +01:00
Holger Hans Peter Freyther 4cdb050d13 bsc: Move away from ->bsc.msc to use the selected MSC
For multiple MSCs we should only have one place where the MSC
is selected and the rest will extract it from somewhere.
2012-03-16 11:56:10 +01:00
Holger Hans Peter Freyther f31a4a4810 bsc: Stop using net->bsc->msc and get the right msc from somewhere else 2012-03-16 11:56:10 +01:00
Holger Hans Peter Freyther 8ec4952557 bsc: Create a osmo_bsc_data and embed osmo_msc_data
We want to have multiple MSCs but we also have some data
that is only present on a per BSC basis. Right now the
MSC data is not allocated with talloc, so we have some
change in the talloc contexts.
2012-03-16 11:56:10 +01:00
Holger Hans Peter Freyther 4d31900e2d bsc: Address warnings about implicit declarations
osmo_bsc_main.c: In function ‘main’:
osmo_bsc_main.c:398:2: warning: implicit declaration of function ‘bts_init’ [-Wimplicit-function-declaration]
osmo_bsc_main.c:399:2: warning: implicit declaration of function ‘libosmo_abis_init’ [-Wimplicit-function-declaration]
osmo_bsc_main.c:418:2: warning: implicit declaration of function ‘bsc_bootstrap_network’ [-Wimplicit-function-declaration]
2012-03-16 11:56:10 +01:00
Holger Hans Peter Freyther dc3389f9c8 bsc: Fix compiler warning about wrong return and unused variable
osmo_bsc_api.c: In function ‘bsc_cm_update’:
osmo_bsc_api.c:195:2: warning: ‘return’ with a value, in function returning void [enabled by default]
osmo_bsc_api.c:193:28: warning: unused variable ‘sccp’ [-Wunused-variable]
2012-03-16 11:56:10 +01:00
Harald Welte ae1997248c mgcp: implement a more tolerant parser based on strtok_r()
Instead of building complex manual byte-wise parsers, we simply use two
strtok_r loops:  one iterating over all the lines, the next one
iterating over the invididual space-separated elements in the first line.

The benefit is that we now accept \r, \n or \r\n, or any multiple of
them as line ending.  This works around incompliant MGCP implementations
like that of Zynetix MSC.

Addition: mgcp_analyze_header returns 0 when all out parameters have
been set.

Signed-off-by: Holger Hans Peter Freyther <zecke@selfish.org>
2012-03-16 10:24:18 +01:00
Harald Welte 6b36b90f75 mgcp: make sure all command line options are documented
Signed-off-by: Holger Hans Peter Freyther <zecke@selfish.org>
2012-03-16 10:21:34 +01:00
Harald Welte ec7683f3b0 mgcp: consistently name bsc_mgcp osmo-bsc_mgcp
Signed-off-by: Holger Hans Peter Freyther <zecke@selfish.org>
2012-03-16 10:21:34 +01:00
Holger Hans Peter Freyther d77023b1c2 mgcp_test: Add wrong messages as input and check what happens
Test parsing some invalid messages and see if we start to crash.
2012-03-16 10:21:29 +01:00
Holger Hans Peter Freyther 5563e6c268 mgcp_test: Rename method as it now operates on an array of messages
This code was cleaned up, catch up and rename the method.
2012-03-16 10:06:39 +01:00
Holger Hans Peter Freyther 3e60348b3b misc: Deal with smatch warnings about the bitfields
Use unsigned ints for the bitfield.
2012-03-02 14:14:33 +01:00
Holger Hans Peter Freyther a8ddb08e05 misc: Use msgb_free for freeing the messages 2012-03-01 20:30:32 +01:00
Andreas Eversberg c50543b18a Improved generation of SYSTEM INFORMATIONs 2* and 5* for neighbour bands
In addition to SI 2 and SI 5, the SI 2ter and 2bis is generated, if
neighbour cells in other bands exist. Also it is indicated in the rest
octets of SI3, that SI 2ter is used. If no neighbour cell in a different
band exists, the SI 2ter and SI 5ter is omitted.

A special case is P-GSM range (channels 1-124). To be compatible with
older phones, SI 2bis and SI 5bis is used. If the BCCH lays inside the
P-GSM band, only neighbour cells of the P-GSM range are included in
SI 2 and SI 5. If neighbour cells exist in the same band (900), but lay
outside the P-GSM range, the SI 2bis and SI 5bis is used to extend the
list of neighbour cells. The extension is also indicated in SI 2 and
SI 5. If the BCCH lays inside the P-GSM range, but no neighbour cell
exists in the same band outside the P-GSM range, the SI 2bis ans SI 5bis
are omitted.
2012-03-01 08:29:56 +01:00
Tobias Engel c33d7d71cb Make sure USSD code only responds *#100# for retrieving own number
strstr() was used with wrong argument order, causing it to always match,
and causing an invalid response to a variety of different SS and USSD
requests.

This has apparently caused havoc among a number of HTC phones which
issue SS requests without user interaction upon boot, and then trip over
our inappropriate response.
2012-02-24 22:23:17 +01:00
Harald Welte 2935034b5e fix generation of frequency list (E-GSM vs. P-GSM 900) 2012-02-17 15:59:25 +01:00
Holger Hans Peter Freyther c8ddf73c8f bts_ipaccess_nanobts.c: Remove unused variable.
This must have been obsoleted by the move to libosmo-abis.

GCC warning:
bts_ipaccess_nanobts.c: In function ‘ipaccess_drop_oml’:
bts_ipaccess_nanobts.c:509:21: warning: variable ‘line’ set but not used [-Wunused-but-set-variable]
2012-02-03 20:31:05 +01:00
Holger Hans Peter Freyther 863dc9bc84 abis_rsl.c: Remove unused variable net.
The old BSC code had code to override the payload type, this has
been removed, remove the variable accessing it.

GCC warning:
abis_rsl.c: In function ‘ipa_rtp_pt_for_lchan’:
abis_rsl.c:1590:22: warning: unused variable ‘net’ [-Wunused-variable]
2012-02-03 20:29:00 +01:00
Holger Hans Peter Freyther 54fa2c7eab abis_rsl: The rach information was not used, introduce a signal
Introduce a SS_CCCH for the paging and the rach load. The paging
code could now start using the signal.

GCC warning:
abis_rsl.c: In function ‘rsl_rx_ccch_load’:
abis_rsl.c:1371:11: warning: variable ‘rach_access_count’ set but not used [-Wunused-but-set-variable]
abis_rsl.c:1370:11: warning: variable ‘rach_busy_count’ set but not used [-Wunused-but-set-variable]
abis_rsl.c:1369:11: warning: variable ‘rach_slot_count’ set but not used [-Wunused-but-set-variable]
2012-02-03 20:26:25 +01:00
Holger Hans Peter Freyther c6d0a17100 abis_rsl.c: Remove unused variable ts_number
GCC warning:
abis_rsl.c: In function ‘rsl_rx_chan_rqd’:
abis_rsl.c:1245:10: warning: variable ‘ts_number’ set but not used [-Wunused-but-set-variable]
2012-02-03 20:10:13 +01:00
Holger Hans Peter Freyther 06b04f851b abis_om2000.c: Remove unused variable to_trx_oml.
GCC warning:
abis_om2000.c: In function ‘abis_om2k_sendmsg’:
abis_om2000.c:804:6: warning: unused variable ‘to_trx_oml’ [-Wunused-variable]
2012-02-03 20:03:06 +01:00
Holger Hans Peter Freyther 37e6523c0f vty: Remove two unimplemented OML functions
attribute get|set <0-255> (.HEX) was never implemented and the
output about the unused attributes clutter the build output, remove
them.

GCC warning:
abis_nm_vty.c: In function ‘oml_attrib_get’:
abis_nm_vty.c:141:25: warning: unused variable ‘oms’ [-Wunused-variable]
abis_nm_vty.c: In function ‘oml_attrib_set’:
abis_nm_vty.c:152:25: warning: unused variable ‘oms’ [-Wunused-variable]
2012-02-03 20:03:02 +01:00
Holger Hans Peter Freyther dae5307a57 misc: abis_nm.c Use the result of ret.
Use LOGP(DNM, LOGL_ERROR, ...); for errors in the
abis_nm_rx_sw_act_req method.

GCC warning:
abis_nm.c: In function ‘abis_nm_rx_sw_act_req’:
abis_nm.c:412:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
2012-02-03 20:03:00 +01:00
Holger Hans Peter Freyther f02bb200c5 misc: gsm_data.c address compiler warning
Assume nothing special needs to be done for the Nokia
*site hardware.

GCC warning:
gsm_data.c: In function ‘gsm_set_bts_type’:
gsm_data.c:342:2: warning: enumeration value ‘GSM_BTS_TYPE_NOKIA_SITE’ not handled in switch [-Wswitch]
2012-02-03 20:02:54 +01:00
Harald Welte 1fe73a19cd ARFCNs are in the range of 0..1023, not 0..1024
I'm sure I read somewhere that it actually was 0..1024, as I kept
wondering how stupid it was to use 10bit+1.  However, that source
was incorrect, as GSM TS 05.05 quite clearly states 0..1023
2012-01-29 13:24:12 +01:00
Harald Welte 94b499c9bd mgcp: add missing prototypes for send_mgcp_reset_* 2012-01-27 00:46:49 +01:00
Harald Welte 78b5586e25 osmo-bsc: Remove hard-coded check for codec preferecne in ASS CMD
When we get an assignment command from the MSC, we no longer have to
check statically for certain codecs, as we have a vty-configured list of
codecs that is checked just below.
2012-01-27 00:43:06 +01:00
Harald Welte 6a85705d51 MGCP: Add VTY commands to reset (RSIP) one or all endpoints 2012-01-27 00:41:39 +01:00
Harald Welte 50f93a4acd bsc_mgcp: optionally connect the MGCP socket to the MGW
This allows the use of the existing "call-agent ip A.B.C.D" command in
libmgcp in order to set a default destination address of the call agent.

This is required as a pre-condition for certain call agents (like the
zynetix MSC) that require a RSIP from the BSC to the MSC as the initial
MGCP message.
2012-01-27 00:38:59 +01:00
Harald Welte 27fa7901bb MGCP: Add CRCX test cases
The second test case (CRCX_ZYN) fails as the message is not compliant
with the spec.  However, our parer should be more tolerant, just in
case...
2012-01-27 00:37:23 +01:00
Harald Welte f74da14c01 further generalize mgcp testing code
use a data-structure driven approach
2012-01-27 00:36:56 +01:00
Harald Welte 8819d8289d mgcp_test: remove duplicate code 2012-01-27 00:00:44 +01:00
Harald Welte cf149eebb6 Move the bulk of RR processing from MSC into BSC
RR Messages like STATUS, GPRS SUSPEND, HANDOVER COMPLETE/FAIL, ...
should be processed on the BSC side of things, not on the MSC side.

This is among other things required in preparation of intra-BSC
hand-over support in osmo-bsc.
2012-01-23 16:40:24 +01:00
Harald Welte 95e862cab4 Move processing of CLASSMARK CHANGE behind bsc_api
This prevents osmo-bsc from sending RR messages to the MSC and rather
process them inside the BSC and turn them into BSSAP CM UPDATE.
2012-01-23 10:28:35 +01:00
Harald Welte d55cef9b07 osmo-bsc: correctly parse the TMSI in BSSAP paging from MSC
the TMSI is a uint32_t big-endian value and not a gsm 04.08 mobile
identity like the IMSI.
2012-01-20 17:21:36 +01:00
Holger Hans Peter Freyther 7d60bdb2c2 nat: Add VTY command for the TP-DA rewriting. 2012-01-18 20:40:01 +01:00
Holger Hans Peter Freyther 2718845967 nat: Fix the no sms-clear-tp-srr command 2012-01-18 20:34:08 +01:00
Holger Hans Peter Freyther 47b144b002 nat: Internationalize the TP-DA if it starts with a 00
Internationalize the number like we do it for Call Control. Update
the test result to match this new behavior.
2012-01-18 20:15:29 +01:00
Holger Hans Peter Freyther 8e60f629e2 nat: Prepare to rewrite the TP-DA number of a SMS submit.
Introduce number rewriting of SMS-SUBMIT. Introduce a new list,
move code around to help with finding a new number, somehow the
number encoding for TP-DA is borked, 03.40 references 04.11 but
the length appears to be strlen(number) without taken the type
field into account.
2012-01-18 20:14:58 +01:00
Holger Hans Peter Freyther be53012f9c nat: Print the sizes and the offending data in case of a failure 2012-01-18 17:20:23 +01:00
Holger Hans Peter Freyther 0354a80357 rsl: This is provided by libosmo-abis, remove it here 2012-01-17 16:14:23 +01:00
Holger Hans Peter Freyther 445d00543a mgcp: Fix warning about unused variable
mgcp_network.c:335:22: warning: variable ‘cfg’ set but not used [-Wunused-but-set-variable]
2012-01-17 16:00:08 +01:00
Holger Hans Peter Freyther 9592c45e34 mgcp: Provide documentation for the method, check sscanf return 2012-01-17 15:58:48 +01:00
Holger Hans Peter Freyther 523a99d3a6 bts: Convert the rsl_link to be a struct ipabis_link 2012-01-17 15:52:45 +01:00
Holger Hans Peter Freyther f95f2733e6 lchan: Close a possible still open RTP Socket
In case of a reset (loss of the BTS) close down all remaining
RTP Proxy sockets. In case of a lchan_free shout if the rtp
proxy is still open. I would prefer if the proxy code sits inside
the gsm subscriber connection.
2012-01-17 15:30:24 +01:00
Holger Hans Peter Freyther 1d7f7c8ca8 ho: Remove rtp_proxy.h include, no proxy code in here 2012-01-17 15:27:13 +01:00
Holger Hans Peter Freyther aa433d2d84 nat: Add the bsc_data.c file to the EXTRA_DIST 2012-01-15 17:55:50 +01:00
Holger Hans Peter Freyther 794e8f2649 abis: gsm_data_shared.h includes libosmo-abis header, add abis to cflags
gsm_data_shared.h includes e1_input.h of libosmo-abis, add the
LIBOSMOABIS_CFLAGS to Makefile.am, remove AM_LDFLAGS at the same
time as we only build .a archives.
2012-01-15 17:52:02 +01:00
Holger Hans Peter Freyther 9e7837a14d mncc: Include size and offsets of struct gsm_mncc in the hello
Increase the version number and send the sizeof of the gsm_mncc
and the gsm_data_frame structure. Include the offsets of some
members as well to maybe identify ABI problems.

The reason we go through this is that we want to benefit from
the native ABI and don't want to force packed structs.
2012-01-15 00:40:42 +01:00
Holger Hans Peter Freyther c0a6674614 channel: Review lchan_free calls and the state the channel is in
In case of a memory allocation failure in rsl_rx_chan_rqd we would
have left the channel in the LCHAN_S_ACT_REQ state. Move the state
change below the allocation.
2012-01-15 00:28:15 +01:00
Holger Hans Peter Freyther dfcfe65f24 lchan: Rename release_reason to release_mode
Use the name of GSM 08.58 for the release mode.
2012-01-15 00:03:19 +01:00
Holger Hans Peter Freyther ded0268a8d channel: Fix a typo in the lchan state documentation 2012-01-15 00:02:54 +01:00
Holger Hans Peter Freyther bbf2139fdc channel: The error timer and the lchan_deact_tmr are both running
In case a BTS does not send the RF Channel Release ACK and we are
closing the channel because of an error two timers are running to
set the state back to none.

Make lchan_deact_tmr_cb and rsl_rx_rf_chan_rel_ack behave the same
in regard to changing the state of the lchan. For the other direction
we are save, the error path will set the state to NONE and the timeout
will call lchan_free to set the channel type back to NONE, only then
the lchan may be allocated again.

The channel release procedure requires some more tweaking, some part
was started in the zecke/28c3 branch and needs to be tested/integrated
with the goal of having one common release path.
2012-01-15 00:02:54 +01:00
Holger Hans Peter Freyther c55f0a5415 Revert "libbsc: Log if a channel is freed with lchan->state != LCHAN_S_NONE"
In case of a failed channel we still want the channel to not be
re-allocated right away but keep it closed/unused for (T3109 + T311).

rsl_rx_rf_chan_rel_ack has a check to not set the channel to S_NONE in
case the channel is in the error state. Add the camp Harald added a timer
to set the channel back to the none state in case the RF Channel Release
is not acked.

This reverts commit fc462dd59e.
2012-01-15 00:02:54 +01:00
Holger Hans Peter Freyther 7173f63eed bsc: Fix "show lchan" for partially provided information
show lchan should be capable of showing all allocated lchans,
all of a given bts, a given trx, a given ts. This feature was
broken when I added the ability to show a more simple summary.

Restore the initial behavior by splitting out the for loops
for the bts/trx/ts and check if we have parsed all parameters
and then call and return the subroutine.
2012-01-15 00:02:54 +01:00
Holger Hans Peter Freyther 0977e0c4b8 nat: Add the line break after the '. 2012-01-11 11:23:25 +01:00
Holger Hans Peter Freyther 68368dd99a nat: Implement clearing of TP-SRR flags from TPDUs
Match IMSI and destination address against a set of entries, if it
is matching the header will be modified and no sender report will be
requested. Change the test case to request the sender report and then
verify that this bit is reset to 0.
2012-01-10 22:45:24 +01:00
Holger Hans Peter Freyther 50be1a9d7f nat: Reduce copy and paste in the test, create a verify_msg 2012-01-10 22:31:39 +01:00
Holger Hans Peter Freyther 951f34b885 nat: Use the link_id from the original message in the new DTAP message
SMS went from SAPI=3 to SAPI=0 and nobody notices on the NAT->MSC direction.
2012-01-10 22:29:35 +01:00
Holger Hans Peter Freyther c2c0ea700b nat: Compare the DTAP L3 size with the size of the msgb - dtap header 2012-01-10 22:27:43 +01:00
Holger Hans Peter Freyther 8c36fdb1d8 nat: Fix comment and mask for looking at TP-MTI 2012-01-10 14:33:27 +01:00
Holger Hans Peter Freyther 55466197f0 nat: SMS rewrite matching, empty list means match everything 2012-01-10 14:22:55 +01:00
Holger Hans Peter Freyther dec7387a22 nat: SMS comment updates 2012-01-10 14:13:43 +01:00
Holger Hans Peter Freyther 998a98185f nat: Move SMS creation into a new method, no functional change 2012-01-10 13:44:05 +01:00
Holger Hans Peter Freyther 5d2a30a83c nat: Access data_ptr after we have checked the length 2012-01-10 13:04:40 +01:00
Holger Hans Peter Freyther c5df08b388 nat: Move the finding of the number to a new method 2012-01-10 12:05:52 +01:00
Holger Hans Peter Freyther 93ef33edb6 tests: Use atlocal/atlocal.in to enable/disable the NAT test
Kill the hacking, use atlocal to remember if the NAT test should
be enabled and then skip the test (exit with 77).
2012-01-09 22:53:04 +01:00
Holger Hans Peter Freyther 03ff1c8477 Revert "tests: Make the test setup more abusive to fix the build"
This reverts commit 41b42c7229.
2012-01-09 21:49:47 +01:00
Holger Hans Peter Freyther 41b42c7229 tests: Make the test setup more abusive to fix the build
Paolo says I will need to use atconfig/atlocal, need to read up on
it first though.
2012-01-09 21:13:15 +01:00
Holger Hans Peter Freyther faf1f64a2d gprs: Honor GSM 04.64 8.4.2 Receipt of unacknowledged information
GSM 04.64 8.4.2 asks to ignore UI frames if the DLCI is not known,
or if the "(V(UR)- 32) <= N(U) < V(UR)". E.g. if we want to have
V(UR) == 511 and this frame is dropped, we would ignore N(U)'s
0 to 510. Calculate the delta.

The code is based on Jonathan Santos's "LLC UI window" fix but the
issue was discovered independly.
2012-01-06 18:52:05 +01:00
Holger Hans Peter Freyther 26d0fe3c89 gprs_sgsn.h: Include timer.h for the timer struct 2012-01-06 18:52:05 +01:00
Holger Hans Peter Freyther 6c88217c19 tests: Introduce running tests with GNU autotest in OpenBSC
The quality of the tests is of different value but it is good to
get started and improve from here.
2012-01-06 18:52:05 +01:00
Holger Hans Peter Freyther d5b3ca621b mgcp: Print message when the test is finished 2012-01-06 17:23:19 +01:00
Holger Hans Peter Freyther 300457b7d2 gsm0408: Print message when the test is done 2012-01-06 17:23:19 +01:00
Holger Hans Peter Freyther 45222a79e2 db: Fix the test code
* Initialize logging
* use a dummy net before calling subcr_put as the keep in ram
  option is going to be set.
2012-01-06 17:23:19 +01:00
Holger Hans Peter Freyther 08e324fda7 channel: Make the test not crash again.
* Initialize logging
* The callback expects NULL or a subscriber connection
2012-01-06 17:23:19 +01:00
Holger Hans Peter Freyther f5ede52a22 nat: Log test output stdout using printf in prep for GNU autotest 2012-01-06 17:23:19 +01:00
Holger Hans Peter Freyther 40aac3f7f6 bsc: Assume assignment_complete/assignment_fail is set
The osmo-nitb application sometimes crashes because the BSC API
is doing an assignment underneath which is not handled by the code,
add dumy handlers to not crash, the right thing to do is to change
MNCC to have an assignment that can succeed/fail.

The keyword to look for is MNCC_LCHAN_MODIFY and mncc_sock should
wait for an ack/nack but right now the call just continues.
2011-12-27 12:55:44 +01:00
Andreas Eversberg 3365cd1cfe RSL: Nokia BTS reports TA in quarter-bits, not full bits.
We need to compensate accordingly...
2011-12-24 11:49:05 +01:00
Andreas Eversberg 2957de9228 RSL: BS-11 reports TA in quarter-bits, not full bits.
We need to compensate accordingly...
2011-12-16 17:45:37 +01:00
Gus Bourg 1c5dd2c9bb Add NITZ (timezone) support as part of MM INFO
The UTC offset from the operating system will be used by default to
calculate the NITZ in MM INFO.  However,  a "timezone" vty command is
added at the BTS level, allowing BTS-specific overrides, e.g. in case
BTSs are distributed accross multiple timezones.
2011-12-02 10:18:17 +01:00
Alexander Huemer 6b8a56c365 fix two mistakes in AM_LDFLAGS 2011-11-25 09:43:45 +01:00
Harald Welte 511bd8e98c BSSGP: Add functions required for true BSS-side BSSGP implementation
The BSS-side of BSSGP requires quite a number of additional functions
for sending unidirectional messages that a SGSN never sends.

This is a first step into completing the BSSGP implementation and making
it ready to be used from osmo-bts and other BTS-side GPRS
implementations.
2011-11-25 08:58:40 +01:00
Harald Welte b52b4cfc48 BSSGP: add more doxygen comments 2011-11-25 08:15:42 +01:00
Harald Welte 8cbc4a406d GPRS: add new bssgp_create_cell_id(), opposite of bssgp_parse_cell_id() 2011-11-24 21:33:16 +01:00
Harald Welte 914660d6f6 GPRS NS: Add some doxygen API documentation 2011-11-24 21:33:16 +01:00
Sylvain Munaut 63ef215e15 bsc_vty: Fix usage of deprecated osmo_osmo_hexdump_nospc
The typo was fixed upstream

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-13 23:05:48 +01:00
Harald Welte f7e94106bb osmo_nitb: introduce --no-dbcounter command line option
this allows us to disable writing the current rate counters to the
sqlite database every 60 seconds.
2011-11-13 19:03:34 +01:00
Holger Hans Peter Freyther 2692e3bcff gsm0408: Print a message when the LU is timing out. 2011-11-07 12:26:29 +01:00
Holger Hans Peter Freyther 347e7ba377 mncc: Introduce a hello packet that is sent to the client.
Send a hello packet down to the client with the version number
of the MNCC interface. The hello structure might be extended to
include the endianes, size of each structure, etc.
2011-11-06 21:49:18 +01:00
Holger Hans Peter Freyther 1491f2e7a9 sgsn: Make sure each parameter has some sort of documentation 2011-11-06 21:41:51 +01:00
Holger Hans Peter Freyther 2eb6e2c0ad gb_proxy: Make sure each parameter has some sort of documentation 2011-11-06 21:41:51 +01:00
Holger Hans Peter Freyther 3ffcf2045c mgcp: Make sure each command has some kind of online help
In this iteration I just want to make sure that each VTY command has
online help. Replace "a b" with "a-b" if there is no "a c" with b!=c.

This config should gain some more sanity and consistency, this will
happen in another iteration.
2011-11-06 21:41:51 +01:00
Holger Hans Peter Freyther da6597ea29 mncc: Remove FIXME about queuing messages
mncc_sock_from_cc will discard the messages when the
fd has been set to -1.
2011-11-06 21:41:51 +01:00
Holger Hans Peter Freyther 694c82d8e3 mncc: Address the fixme and put the mncc_sock_state in gsm_network
Remove the unused mncc_sock_write_pending, switch over from the
static s_state to net->mncc_state.
2011-11-06 21:41:51 +01:00
Holger Hans Peter Freyther 2a260ee9bc misc: Fix typo...'teh' -> 'the' 2011-11-06 21:41:51 +01:00
Andreas.Eversberg bb5c594e15 nokia: Use a longer T200 because RSL link can be pretty slow after a reset
Written-by: Andreas Eversberg <jolly@eversberg.eu>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-02 23:11:19 +01:00
Sylvain Munaut 86aaefe17b build: Update configure.ac to use libgtp.pc rather than manual detection
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-18 21:51:42 +02:00
Sylvain Munaut 2192ed8d61 libbsc/nokia_site: Increase reset timer to 15 seconds
Also make sure to specify seconds in the 'seconds' field. Doing
otherwise is an abuse that non longer works with the new timer infra.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-18 21:51:03 +02:00
Sylvain Munaut c951946691 libbsc/nokia_site: Fix reset procedure and add option to skip it.
do_reset was not initialized anywhere anymore, so the reset was never
triggered. It's now fixed and we add an option to skip it in the
config so that when in production, you can restart without config
changes quickly.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-18 21:51:02 +02:00
Sylvain Munaut 67c0c7f8aa libbsc/nanobts: Fix NSVC OML init sequence for some rugby models
The NVC never goes to OFF LINE but only to DEPENDENCY (because of
missing attributes).

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-17 13:57:58 +02:00
Sylvain Munaut 851f1206a8 libbsc: Don't include ext_info in SI13 if not in EGPRS mode
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-17 13:56:02 +02:00
Harald Welte d4c6f8b343 GPRS GMM: When we receive a RA UPD REQ, we are NORMAL even after SUSPEND
There is no explicit BSSGP RESUME in case the MS sends a RA UPD REQ
after being in SUSPEND previously.
2011-10-16 21:35:21 +02:00
Harald Welte 066a0f5c0b GPRS LLC: fix compiler warning 2011-10-16 18:59:20 +02:00
Harald Welte 2b697a6671 GPRS GMM: Send LLGMM-RESET.req when talking to unknown MS
In case a MS (of which we have no MM context) sends us anything but a
GMM ATTACH REQUEST, we need to send it a LLC XID RESET (by means of
issuing LLGMM-RESET.req).  Otherwise the phone will expect us to send a
specific unacknowledged sequence number that we don't know.

Thanks to Holger for pointing this bug out to me.

It seems to commonly occur when a MS is doing network re-selection and
(erroneously) sends a RA UPD REQ instead of an ATTACH REQ.  The RA UPD
REJ that we sent was never seen by the GMM entity in the MS, as the LLC
entity discarded it due to sequence number mis-match.
2011-10-16 18:58:30 +02:00
Harald Welte 0c1a30312d LLC: Add minimal LLGMM-RESET.req implementation
Using LLGMM-RESET.req, the GMM can request the LLC of the MS to reset
all its parameters, particularly the sequence numbers.  We don't yet do
XID RESET retransmissions, and we don't yet generate a LLGMM-RESET.conf
primitive back to GMM.
2011-10-16 18:58:30 +02:00
Holger Hans Peter Freyther 37a63ca34a misc: Linking fixes for Ubuntu 11.10 Compiler
Ubuntu 11.10 has changed some linker/compiler flags. Some fixes for this
can be seen here[1]. In general the to be linked libs need to be moved into
the LDADD section of parameters. This is with the old BFD linker (not gold).

This is likely to end in some ping-pong with other versions of the linker.

[1] https://bugs.launchpad.net/ubuntu/+source/nis/+bug/771034

Errors:
/usr/bin/ld.bfd.real: bsc_hack.o: undefined reference to symbol 'osmo_init_ignore_signals'
/usr/bin/ld.bfd.real: note: 'osmo_init_ignore_signals' is defined in DSO /home/ich/install/openbsc/lib/libosmocore.so so try adding it to the linker command line
/home/ich/install/openbsc/lib/libosmocore.so: could not read symbols: Invalid operation

...
../../src/libbsc/libbsc.a(rest_octets.o):/home/ich/source/gsm/openbsc/openbsc/src/libbsc/rest_octets.c:381: more undefined references to `bitvec_set_bit' follow
../../src/libbsc/libbsc.a(rest_octets.o): In function `rest_octets_si13':
/home/ich/source/gsm/openbsc/openbsc/src/libbsc/rest_octets.c:382: undefined reference to `bitvec_set_uint'
/home/ich/source/gsm/openbsc/openbsc/src/libbsc/rest_octets.c:383: undefined reference to `bitvec_set_uint'
/home/ich/source/gsm/openbsc/openbsc/src/libbsc/rest_octets.c:385: undefined reference to `bitvec_set_bit'
/home/ich/source/gsm/openbsc/openbsc/src/libbsc/rest_octets.c:402: undefined reference to `bitvec_set_bit'
/home/ich/source/gsm/openbsc/openbsc/src/libbsc/rest_octets.c:403: undefined reference to `bitvec_set_uint'
2011-10-16 17:08:51 +02:00
Holger Hans Peter Freyther 3dccda5ef0 gprs: Fix various compiler warnings 2011-10-14 23:42:13 +02:00
Holger Hans Peter Freyther 6142dc407a gprs: Fix compiler warnings in the code 2011-10-14 23:37:27 +02:00
Holger Hans Peter Freyther 2b17454f4a gprs_gmm: Fix various compiler warnings
gprs_gmm.c:240:2: warning: passing argument 4 of ‘gprs_llc_tx_ui’ discards qualifiers from pointer target type
../../include/openbsc/gprs_llc.h:151:5: note: expected ‘void *’ but argument is of type ‘const struct sgsn_mm_ctx *’
gprs_gmm.c:349:11: warning: unused variable ‘ptsig’
gprs_gmm.c:601:5: warning: too many arguments for format
gprs_gmm.c:987:25: warning: initialization discards qualifiers from pointer target type
gprs_gmm.c:1010:6: warning: ‘rc’ may be used uninitialized in this function
2011-10-14 23:31:34 +02:00
Holger Hans Peter Freyther 42b9195023 gprs: This comes from libosmocore, remove it here 2011-10-14 23:28:07 +02:00
Holger Hans Peter Freyther 30ebcf71d0 osmo-sgsn: Install the osmo-sgsn configuration for debian 2011-10-13 23:54:33 +02:00
Holger Hans Peter Freyther 00a8ab9d3b sgsn: Add a configuration that is accepted by osmo-sgsn
Provide an exmaple that is accepted by osmo-sgsn.
2011-10-13 23:53:18 +02:00
Alexander Huemer 670ffe3290 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
2011-10-12 08:30:44 +02:00
Holger Hans Peter Freyther 74c7dc36b6 bsc: Put the full stop before the \n in the log message 2011-10-12 08:30:36 +02:00
Holger Hans Peter Freyther cc98d188eb bsc: Add new SCCP connections to the tail 2011-10-12 08:30:29 +02:00
Holger Hans Peter Freyther df82b72375 bsc: Drop the BTS instead of exiting the application
When the BTS reboots it might not want to accept our BTS Attr,
do not leave the bsc_msc_ip/bsc_nitb but simply drop the BTS
connection.

Manually cherry-picked from: 54e6c8b3400b376ed36fe84f28f7930d2d9ff24b
2011-10-12 08:30:22 +02:00
Holger Hans Peter Freyther 08542564fe vty: Document more VTY parameters of a command
The below is used to identify commands that need proper documentation

diff --git a/src/vty/command.c b/src/vty/command.c
index ab1eaca..bcf72d0 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -426,6 +426,20 @@ void install_element(enum node_type ntype, struct cmd_element *cmd)

        cmd->strvec = cmd_make_descvec(cmd->string, cmd->doc);
        cmd->cmdsize = cmd_cmdsize(cmd->strvec);
+
+       printf("NODE: %d\n", ntype);
+
+       int j;
+       for (j = 0; j < vector_count(cmd->strvec); ++j) {
+               vector descvec = vector_slot(cmd->strvec, j);
+               int i;
+               for (i = 0; i < vector_active(descvec); i++) {
+                       struct desc *desc = vector_slot(descvec, i);
+                       if (desc == NULL)
+                               continue;
+                       printf(" %s %s\n", desc->cmd, desc->str);
+               }
+       }
 }
2011-10-12 08:30:14 +02:00
448 changed files with 37092 additions and 74491 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1 @@
open_collective: osmocom

73
.gitignore vendored Normal file
View File

@ -0,0 +1,73 @@
debian/*.log
*.o
*.lo
*.a
*.la
.deps
Makefile
Makefile.in
config.h
config.h.in
*.*~
*.sw?
.libs
*.pyc
*.gcda
*.gcno
*~
#configure
aclocal.m4
autom4te.cache/
m4/*.m4
!m4/ax_*.m4
config.log
config.status
config.guess
config.sub
configure
compile
depcomp
install-sh
missing
stamp-h1
libtool
ltmain.sh
# git-version-gen magic
.tarball-version
.version
# apps and app data
src/sgsn/osmo-sgsn
src/gtphub/osmo-gtphub
src/libcommon/gsup_test_client
#tests
tests/testsuite.dir
tests/*/*_test
tests/atconfig
tests/atlocal
tests/package.m4
tests/testsuite
tests/testsuite.log
gsn_restart
writtenconfig/
gtphub_restart_count
# manuals
doc/manuals/*.html
doc/manuals/*.svg
doc/manuals/*.pdf
doc/manuals/*__*.png
doc/manuals/*.check
doc/manuals/generated/
doc/manuals/osmomsc-usermanual.xml
doc/manuals/common
doc/manuals/build
contrib/osmo-sgsn.spec

3
.gitreview Normal file
View File

@ -0,0 +1,3 @@
[gerrit]
host=gerrit.osmocom.org
project=osmo-sgsn

12
.mailmap Normal file
View File

@ -0,0 +1,12 @@
Harald Welte <laforge@gnumonks.org>
Harald Welte <laforge@gnumonks.org> <laflocal@hanuman.gnumonks.org>
Harald Welte <laforge@gnumonks.org> <laflocal@goeller.de.gnumonks.org>
Holger Hans Peter Freyther <holger@moiji-mobile.com> <zecke@selfish.org>
Holger Hans Peter Freyther <holger@moiji-mobile.com> <ich@tamarin.(none)>
Holger Hans Peter Freyther <holgre@moiji-mobile.com> <holger@freyther.de>
Andreas Eversberg <jolly@eversberg.eu>
Andreas Eversberg <jolly@eversberg.eu> <Andreas.Eversberg@versatel.de>
Andreas Eversberg <jolly@eversberg.eu> <root@nuedel.(none)>
Pablo Neira Ayuso <pablo@soleta.eu> <pablo@gnumonks.org>
Max Suraev <msuraev@sysmocom.de>
Tom Tsou <tom.tsou@ettus.com> <tom@tsou.cc>

View File

@ -5,3 +5,5 @@ Stefan Schmidt <stefan@datenfreihafen.org>
Daniel Willmann <daniel@totalueberwachung.de>
Andreas Eversberg <Andreas.Eversberg@versatel.de>
Sylvain Munaut <246tnt@gmail.com>
Jacob Erlbeck <jerlbeck@sysmocom.de>
Neels Hofmeyr <nhofmeyr@sysmocom.de>

36
Makefile.am Normal file
View File

@ -0,0 +1,36 @@
AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6
## FIXME: automake >= 1.13 or autoconf >= 2.70 provide better suited AC_CONFIG_MACRO_DIRS for configure.ac
## remove line below when OE toolchain is updated to version which include those
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = \
$(all_includes) \
-I$(top_srcdir)/include \
$(NULL)
SUBDIRS = \
include \
src \
contrib \
tests \
doc \
$(NULL)
BUILT_SOURCES = $(top_srcdir)/.version
EXTRA_DIST = \
.version \
README.md \
debian \
git-version-gen \
osmoappdesc.py \
$(NULL)
AM_DISTCHECK_CONFIGURE_FLAGS = \
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
@RELMAKE@
$(top_srcdir)/.version:
echo $(VERSION) > $@-t && mv $@-t $@
dist-hook:
echo $(VERSION) > $(distdir)/.tarball-version

0
README
View File

100
README.md Normal file
View File

@ -0,0 +1,100 @@
osmo-sgsn - Osmocom SGSN Implementation
=======================================
This repository contains a C-language implementation of a *Serving GPRS
Support Node (SGSN)* for 2.5/2.75G (GPRS/EDGE) and 3G (UMTS). It is part of the
[Osmocom](https://osmocom.org/) Open Source Mobile Communications
project.
OsmoSGSN exposes
* *Gb* towards PCUs (e.g. [OsmoPCU](https://osmocom.org/projects/osmopcu/wiki/OsmoPCU)): Various GbIP flavors + Gb/FR/E1
* *GTP* towards a GGSN (e.g. [OsmoGGSN](https://osmocom.org/projects/openggsn/wiki))
* IuPS over IP towards RNCs / HNBGW (e.g. [osmo-hnbgw](https://osmocom.org/projects/osmohnbgw/wiki))
* The Osmocom typical telnet *VTY* and *CTRL* interfaces.
* The Osmocom typical *statsd* exporter.
* GSUP (custom MAP-like protocol) towards [osmo-hlr](https://osmocom.org/projects/osmo-hlr/wiki/OsmoHLR)
OsmoSGSN implements
* GPRS mobility management
* GPRS session management
Homepage
--------
You can find the OsmoSGSN homepage online at <https://osmocom.org/projects/osmosgsn/wiki>.
GIT Repository
--------------
You can clone from the official osmo-sgsn.git repository using
git clone https://gitea.osmocom.org/cellular-infrastructure/osmo-sgsn
There is a web interface at <https://gitea.osmocom.org/cellular-infrastructure/osmo-sgsn>
Documentation
-------------
User Manuals and VTY reference manuals are [optionally] built in PDF form
as part of the build process.
Pre-rendered PDF version of the current "master" can be found at
[User Manual](https://ftp.osmocom.org/docs/latest/osmosgsn-usermanual.pdf)
as well as the [VTY Reference Manual](https://ftp.osmocom.org/docs/latest/osmosgsn-vty-reference.pdf)
Forum
-----
We welcome any osmo-sgsn related discussions in the
[Cellular Network Infratructure -> 2G/3G Core Network](https://discourse.osmocom.org/c/cni/2g-3g-cn).
section of the osmocom discourse (web based Forum).
Mailing List
------------
Discussions related to osmo-sgsn are happening on the
osmocom-net-gprs@lists.osmocom.org mailing list, please see
<https://lists.osmocom.org/postorius/lists/osmocom-net-gprs.lists.osmocom.org/> for subscription
options and the list archive.
Please observe the [Osmocom Mailing List
Rules](https://osmocom.org/projects/cellular-infrastructure/wiki/Mailing_List_Rules)
when posting.
Issue Tracker
-------------
We use the [issue tracker of the osmo-sgsn project on osmocom.org](https://osmocom.org/projects/osmosgsn/issues) for
tracking the state of bug reports and feature requests. Feel free to submit any issues you may find, or help
us out by resolving existing issues.
Contributing
------------
Our coding standards are described at
<https://osmocom.org/projects/cellular-infrastructure/wiki/Coding_standards>
We us a gerrit based patch submission/review process for managing
contributions. Please see
<https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit> for
more details
The current patch queue for osmo-sgsn can be seen at
<https://gerrit.osmocom.org/#/q/project:osmo-sgsn+status:open>
History
-------
OsmoSGSN originated from the OpenBSC project, as a separate program within
openbsc.git. In 2017, OpenBSC was split in separate repositories, and hence
OsmoSGSN was given its own separate git repository.

11
README.vty-tests Normal file
View File

@ -0,0 +1,11 @@
To run the configuration parsing and output (VTY) test suite, first install
https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests
and pass the following configure options here:
./configure --enable-external-tests
The VTY tests are then included in the standard check target:
make check

2
TODO-RELEASE Normal file
View File

@ -0,0 +1,2 @@
#component what description / commit summary line
libosmocore > 1.9.0 gsup.h: Using new fields in struct osmo_gsup_pdp_info (ABI break)

258
configure.ac Normal file
View File

@ -0,0 +1,258 @@
dnl Process this file with autoconf to produce a configure script
AC_INIT([osmo-sgsn],
m4_esyscmd([./git-version-gen .tarball-version]),
[osmocom-net-gprs@lists.osmocom.org])
dnl *This* is the root dir, even if an install-sh exists in ../ or ../../
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([dist-bzip2])
AC_CONFIG_TESTDIR(tests)
dnl kernel style compile messages
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
dnl include release helper
RELMAKE='-include osmo-release.mk'
AC_SUBST([RELMAKE])
dnl checks for programs
AC_PROG_MAKE_SET
AC_PROG_CC
AC_PROG_INSTALL
LT_INIT
dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
AS_CASE(["$LD"],[*clang*],
[AS_CASE(["${host_os}"],
[*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
AC_MSG_WARN([You need to install pkg-config])
fi
PKG_PROG_PKG_CONFIG([0.20])
dnl use a defined standard across all builds and don't depend on compiler default
CFLAGS="$CFLAGS -std=gnu11"
dnl checks for libraries
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 1.9.0)
PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 1.5.0)
PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 1.4.0)
PKG_CHECK_MODULES(LIBOSMOGSUPCLIENT, libosmo-gsup-client >= 1.7.0)
PKG_CHECK_MODULES(LIBGTP, libgtp >= 1.11.0)
# Enable/disable 3G aka IuPS + IuCS support?
AC_ARG_ENABLE([iu], [AS_HELP_STRING([--enable-iu], [Build 3G support, aka IuPS and IuCS interfaces])],
[osmo_ac_iu="$enableval"],[osmo_ac_iu="no"])
if test "x$osmo_ac_iu" = "xyes" ; then
PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 1.8.0)
PKG_CHECK_MODULES(LIBASN1C, libasn1c >= 0.9.30)
PKG_CHECK_MODULES(LIBOSMORANAP, libosmo-ranap >= 1.5.0)
AC_DEFINE(BUILD_IU, 1, [Define if we want to build IuPS and IuCS interfaces support])
fi
AM_CONDITIONAL(BUILD_IU, test "x$osmo_ac_iu" = "xyes")
AC_SUBST(osmo_ac_iu)
PKG_CHECK_MODULES(LIBCARES, libcares)
dnl checks for header files
AC_HEADER_STDC
dnl Checks for typedefs, structures and compiler characteristics
AC_ARG_ENABLE(sanitize,
[AS_HELP_STRING(
[--enable-sanitize],
[Compile with address sanitizer enabled],
)],
[sanitize=$enableval], [sanitize="no"])
if test x"$sanitize" = x"yes"
then
CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
fi
AC_ARG_ENABLE(werror,
[AS_HELP_STRING(
[--enable-werror],
[Turn all compiler warnings into errors, with exceptions:
a) deprecation (allow upstream to mark deprecation without breaking builds);
b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
]
)],
[werror=$enableval], [werror="no"])
if test x"$werror" = x"yes"
then
WERROR_FLAGS="-Werror"
WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
CFLAGS="$CFLAGS $WERROR_FLAGS"
CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
fi
# The following test is taken from WebKit's webkit.m4
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fvisibility=hidden "
AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
[ AC_MSG_RESULT([yes])
SYMBOL_VISIBILITY="-fvisibility=hidden"],
AC_MSG_RESULT([no]))
CFLAGS="$saved_CFLAGS"
AC_SUBST(SYMBOL_VISIBILITY)
CPPFLAGS="$CPPFLAGS -Wall -Wno-trigraphs"
CFLAGS="$CFLAGS -Wall -Wno-trigraphs"
# Coverage build taken from WebKit's configure.in
AC_MSG_CHECKING([whether to enable code coverage support])
AC_ARG_ENABLE(coverage,
AC_HELP_STRING([--enable-coverage],
[enable code coverage support [default=no]]),
[],[enable_coverage="no"])
AC_MSG_RESULT([$enable_coverage])
if test "$enable_coverage" = "yes"; then
COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
AC_SUBST([COVERAGE_CFLAGS])
AC_SUBST([COVERAGE_LDFLAGS])
fi
AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
AC_CACHE_CHECK(
[whether struct tm has tm_gmtoff member],
osmo_cv_tm_includes_tm_gmtoff,
[AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include <time.h>
], [
time_t t = time(NULL);
struct tm* lt = localtime(&t);
int off = lt->tm_gmtoff;
])
],
osmo_cv_tm_includes_tm_gmtoff=yes,
osmo_cv_tm_includes_tm_gmtoff=no
)]
)
if test "x$osmo_cv_tm_includes_tm_gmtoff" = xyes; then
AC_DEFINE(HAVE_TM_GMTOFF_IN_TM, 1,
[Define if struct tm has tm_gmtoff member.])
fi
])
CHECK_TM_INCLUDES_TM_GMTOFF
AC_ARG_ENABLE([external_tests],
AC_HELP_STRING([--enable-external-tests],
[Include the VTY/CTRL tests in make check [default=no]]),
[enable_ext_tests="$enableval"],[enable_ext_tests="no"])
if test "x$enable_ext_tests" = "xyes" ; then
AC_CHECK_PROG(PYTHON3_AVAIL,python3,yes)
if test "x$PYTHON3_AVAIL" != "xyes" ; then
AC_MSG_ERROR([Please install python3 to run the VTY/CTRL tests.])
fi
AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
AC_MSG_ERROR([Please install https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests to run the VTY/CTRL tests.])
fi
fi
AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
AC_MSG_RESULT([$enable_ext_tests])
AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
# Generate manuals
AC_ARG_ENABLE(manuals,
[AS_HELP_STRING(
[--enable-manuals],
[Generate manual PDFs [default=no]],
)],
[osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
fallback])
if test x"$osmo_ac_build_manuals" = x"yes"
then
# Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
if test -n "$OSMO_GSM_MANUALS_DIR"; then
echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
else
OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
if test -n "$OSMO_GSM_MANUALS_DIR"; then
echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
else
OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
fi
fi
if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
fi
# Find and run check-depends
CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
if ! test -x "$CHECK_DEPENDS"; then
CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
fi
if ! $CHECK_DEPENDS; then
AC_MSG_ERROR("missing dependencies for --enable-manuals")
fi
# Put in Makefile with absolute path
OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
AC_SUBST([OSMO_GSM_MANUALS_DIR])
fi
# https://www.freedesktop.org/software/systemd/man/daemon.html
AC_ARG_WITH([systemdsystemunitdir],
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
[with_systemdsystemunitdir=auto])
AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
AS_IF([test "x$def_systemdsystemunitdir" = "x"],
[AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemdsystemunitdir=no],
[with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
[AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
AC_MSG_RESULT([CFLAGS="$CFLAGS"])
AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
dnl Generate the output
AM_CONFIG_HEADER(config.h)
AC_OUTPUT(
include/Makefile
include/osmocom/Makefile
include/osmocom/gtphub/Makefile
include/osmocom/sgsn/Makefile
src/Makefile
src/gprs/Makefile
src/sgsn/Makefile
src/gtphub/Makefile
tests/Makefile
tests/atlocal
tests/gprs/Makefile
tests/sgsn/Makefile
tests/gtphub/Makefile
tests/xid/Makefile
tests/sndcp_xid/Makefile
tests/slhc/Makefile
tests/v42bis/Makefile
doc/Makefile
doc/examples/Makefile
doc/manuals/Makefile
contrib/Makefile
contrib/systemd/Makefile
Makefile)

1
contrib/Makefile.am Normal file
View File

@ -0,0 +1 @@
SUBDIRS = systemd

77
contrib/jenkins.sh Executable file
View File

@ -0,0 +1,77 @@
#!/usr/bin/env bash
# jenkins build helper script for openbsc. This is how we build on jenkins.osmocom.org
#
# environment variables:
# * IU: configure 3G support (values: "--enable-iu", "--disable-iu")
# * WITH_MANUALS: build manual PDFs if set to "1"
# * PUBLISH: upload manuals after building if set to "1" (ignored without WITH_MANUALS = "1")
#
if ! [ -x "$(command -v osmo-build-dep.sh)" ]; then
echo "Error: We need to have scripts/osmo-deps.sh from http://git.osmocom.org/osmo-ci/ in PATH !"
exit 2
fi
set -ex
base="$PWD"
deps="$base/deps"
inst="$deps/install"
export deps inst
osmo-clean-workspace.sh
mkdir "$deps" || true
osmo-build-dep.sh libosmocore "" ac_cv_path_DOXYGEN=false
verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$inst/lib"
export PATH="$inst/bin:$PATH"
osmo-build-dep.sh libosmo-abis
osmo-build-dep.sh libosmo-netif
osmo-build-dep.sh osmo-ggsn
osmo-build-dep.sh osmo-hlr
if [ "x$IU" = "x--enable-iu" ]; then
osmo-build-dep.sh libosmo-sccp
osmo-build-dep.sh libasn1c
#osmo-build-dep.sh asn1c aper-prefix # only needed for make regen in osmo-iuh
osmo-build-dep.sh osmo-iuh
fi
# Additional configure options and depends
CONFIG=""
if [ "$WITH_MANUALS" = "1" ]; then
CONFIG="--enable-manuals"
fi
set +x
echo
echo
echo
echo " =============================== osmo-sgsn ==============================="
echo
set -x
cd "$base"
autoreconf --install --force
./configure --enable-sanitize --enable-werror $IU --enable-external-tests $CONFIG
$MAKE $PARALLEL_MAKE
LD_LIBRARY_PATH="$inst/lib" $MAKE check \
|| cat-testlogs.sh
LD_LIBRARY_PATH="$inst/lib" \
DISTCHECK_CONFIGURE_FLAGS="--enable-werror $IU --enable-external-tests $CONFIG" \
$MAKE $PARALLEL_MAKE distcheck \
|| cat-testlogs.sh
if [ "$WITH_MANUALS" = "1" ] && [ "$PUBLISH" = "1" ]; then
make -C "$base/doc/manuals" publish
fi
$MAKE $PARALLEL_MAKE maintainer-clean
osmo-clean-workspace.sh

View File

@ -0,0 +1,11 @@
EXTRA_DIST = \
osmo-gtphub.service \
osmo-sgsn.service
if HAVE_SYSTEMD
SYSTEMD_SERVICES = \
osmo-gtphub.service \
osmo-sgsn.service
systemdsystemunit_DATA = $(SYSTEMD_SERVICES)
endif

View File

@ -0,0 +1,18 @@
[Unit]
Description=Osmocom GTP Hub
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=osmocom
Group=osmocom
ExecStart=/usr/bin/osmo-gtphub -c /etc/osmocom/osmo-gtphub.cfg
StateDirectory=osmocom
WorkingDirectory=%S/osmocom
Restart=always
RestartSec=2
RestartPreventExitStatus=1
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,20 @@
[Unit]
Description=Osmocom SGSN (Serving GPRS Support Node)
Wants=osmo-hlr.service
After=osmo-hlr.service
After=osmo-hnbgw.service
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
StateDirectory=osmocom
WorkingDirectory=%S/osmocom
Restart=always
User=osmocom
Group=osmocom
ExecStart=/usr/bin/osmo-sgsn -c /etc/osmocom/osmo-sgsn.cfg
RestartSec=2
[Install]
WantedBy=multi-user.target

810
debian/changelog vendored Normal file
View File

@ -0,0 +1,810 @@
osmo-sgsn (1.11.1) unstable; urgency=medium
[ Philipp Maier ]
* sgsn_rim: forward message based on RIM ROUTING ADDRESS
[ Daniel Willmann ]
* sgsn_vty: Fix output in config_write_sgsn
* sgsn_vty: Correctly indent encryption cipher-plugin-path
* vty-tests: Test encryption options
* libgtp: Check for all successful create_pdp_conf causes
-- Oliver Smith <osmith@sysmocom.de> Tue, 28 Nov 2023 13:32:46 +0100
osmo-sgsn (1.11.0) unstable; urgency=medium
[ Oliver Smith ]
* Run struct_endianness.py
* debian: set compat level to 10
* systemd: depend on networking-online.target
[ arehbein ]
* Transition to use of 'telnet_init_default'
[ Vadim Yanitskiy ]
* tests: use -no-install libtool flag to avoid ./lt-* scripts
* tests: $(BUILT_SOURCES) is not defined, depend on osmo-sgsn
* copyright: fix typo: sysmocom s/s.m.f.c./s.f.m.c./ GmbH
[ Pau Espin Pedrol ]
* gmm: Ciphering Key Sequence Number IE has half octet tag
* gprs_sm.c: Fix load of misaligned ptr address
* Write explicit role & sctp-role fields in ASP configurations
* gmm: Update DRX params during rx RAU REQ
* gmm: Add missing GSM48_IE_GMM_RX_NPDU_NUM_LIST IE in gsm48_gmm_att_tlvdef
[ Philipp Maier ]
* sgsn_rim: fix typo
* sgsn_rim: cosmetic: improve comment
* sgsn_rim: get rid of MME check in sgsn_rim_rx_from_gtp:
* sgsn_rim: do not check the origin of a RIM message
-- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 12 Sep 2023 16:57:02 +0200
osmo-sgsn (1.10.0) unstable; urgency=medium
[ Vadim Yanitskiy ]
* configure.ac: do not require unused dlsym/dlopen
* gprs_llc: fix misleading spacing in gprs_llc_rcvmsg()
* gprs_llc.h: use '#pragma once'
* llc: gprs_llc_fcs(): make the input data pointer const
[ Max ]
* Set working directory in systemd service file
* SNDCP: log more details on failure
* GTP: migrate from deprecated function
* Constify LLC/SNDCP parameters
* GMM: permit E_GMM_COMMON_PROC_SUCCESS in normal state
* ctrl: take both address and port from vty config
[ Pau Espin Pedrol ]
* vty: Make new libgtp tdefs configurable through VTY
* sndcp: Put decompress handling code into helper function
* Move gprs_gb_parse.[c,h] to tests/sgsn/
* Create new specific file for BSSGP code
* Move some functions gprs_gb.[c,h] -> gprs_gmm.[c,h]
* Rename gprs_gb.[c,h] -> gprs_ns.[c,h]
* Move gprs_tmr_to_secs() to tests/gprs/gprs_test.c
* cosmetic: gprs_llc_vty.c: Fix trailing whitespace
* vty: Fix wrong value_string used to print llme state
* Standarize lle and llme state enum & value_string
* Remove unused function gprs_parse_mi_tmsi()
* Replace gprs_str_to_apn() with libosmocore API osmo_apn_from_str()
* Move struct sgsn_ggsn_ctx to its own file gtp_ggsn.{c,h}
* gprs_subscriber: Move API declarations to correct header
* Move gprs_sndcp_vty_init() declaration to gprs_sndcp.h
* Introduce new header file sgsn/gtp.h
* Fix -Werror=old-style-definition
* Move related structs to gprs_subscriber.h
* Remove unneeded extern declaration from libosmocotrl
* Keep sgsn subsystems under struct sgsn_instance lifecycle
* Move global ggsn_list into struct sgsn_instance
* Move struct apn_ctx and APN related definitions to its own file
* Move struct sgsn_subscriber_pdp_data to gprs_subscriber.h
* sgsn.h: Drop declaration of non existing function
* Properly split llc->sndcp->gtp unitdata pathi through extra func call
* Move func defintions of funcs implemented in gprs_sndcp.c to gprs_sndcp.h
* sndcp: Standarize unitdata function naming
* Move gtp related functions to gtp.h
* Move global apn_list inside struct sgsn_instance
* gtp_{ggsn,mme}: Allocate contexts under struct sgsn_instance
* Move extern declarations of tall_sgsn_ctx to sgsn.h
* Drop extern declarations of global sgsn_instance in source files
* Move sgsn_pdp_ctx to its own file pdpctx.{c,h}
* Move global pdp_list inside struct sgsn_instance
* Move gtphub header to include/osmocom/gtphub/
* Move sgsn_ctrl_cmds_install() declaration to sgsn.h
* Move LOGGSUBSCRP to gprs_subscriber.h
* Rename bscconfig.h -> config.h
* gtphub.h: Remove dependency on sgsn/gprs_sgsn.h
* Split gprs_sgsn.{c,h} -> {auth,mmctx,sgsn}.{c,h}
* Move global mmctx list into struct sgsn_instance
* vty: Introduce encryption cipher-plugin-path command
* Fix extra whitespace in pdpctx_ctr_description
[ Oliver Smith ]
* contrib/jenkins.sh: use enable-werror with IU too
* sgsn_libgtp: cb_data_ind: remove mm_idle assert
* osmo-gtphub.cfg: fix conflict with osmo-ggsn.cfg
-- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 07 Feb 2023 17:34:26 +0100
osmo-sgsn (1.9.0) unstable; urgency=medium
[ Oliver Smith ]
* llme_free: clean up related sndcp
* treewide: remove FSF address
[ Pau Espin Pedrol ]
* Drop unneeded ax_check_compile_flag.m4
* Revert "sgsn: Handle different levels of QoS"
[ Neels Hofmeyr ]
* s/cipher_support_mask/gea_encryption_mask
* Iu: add UEA encryption
[ Vadim Yanitskiy ]
* tests: use 'check_PROGRAMS' instead of 'noinst_PROGRAMS'
[ Harald Welte ]
* update git URLs (git -> https; gitea)
* README: Major update
-- Pau Espin Pedrol <pespin@sysmocom.de> Wed, 29 Jun 2022 11:45:08 +0200
osmo-sgsn (1.8.0) unstable; urgency=medium
[ Harald Welte ]
* Remove bogus DNS log category
[ Daniel Willmann ]
* manuals: Regenerate counters/VTY through docker
[ Vadim Yanitskiy ]
* main: resurrect removed 'ns' logging category as deprecated
* doc/manuals: update configuration.adoc to use new command syntax
* tests/Makefile.am: do not try removing non-existing files
[ Pau Espin Pedrol ]
* ranap: log ranap iu event type name instead of number
* gmm: log GMM msg type name instead of number
* gmm: Expect E_VLR_ANSWERED when in ST_IU_SECURITY_CMD
* gmm_fsm: Expect E_GMM_COMMON_PROC_INIT_REQ when in ST_GMM_COMMON_PROC_INIT
* mm_iu: Send event E_PMM_PS_CONN_ESTABLISH upon rx GMM SERVICE REQUEST
* mm_iu: Expect E_PMM_PS_ATTACH when in ST_PMM_IDLE
* gprs_gmm.c: State proper GMM prefix logging rx/tx of GMM messages
* mm_state_iu_fsm: T3314 expiry must lead to PMM IDLE, not PMM DETACHED
* Iu: Drop timer X3314
* gprs_ranap.c: Clean up code path releasing IU conn
* mm_state_{gb,iu}_fsm: Add missing license block, improve spec references
* mm_state_{gb,iu}_fsm: Improve naming for detach event
* Drop unused GBRPOXY enum field
* gtp: Delete ctx upon receive UpdateCtxResp with cause Non-existent
* Support forwarding RIM messages over GTPCv1 EUTRAN<->GERAN
* Use new stat item/ctr getter APIs
[ Keith ]
* vty: Fix optional display of pdp with mm-context
* VTY: Don't display 'PDP Address: invalid' for IPv4v6
[ Eric ]
* add support for multiple encryption algorithms and a5/4
[ Oliver Smith ]
* gtphub: remove llist_first, llist_last macros
* vty: add "page imsi"
* debian/control: remove dh-systemd build-depend
* Revert "Turn some compiler warnings into errors"
-- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 16 Nov 2021 17:57:50 +0100
osmo-sgsn (1.7.0) unstable; urgency=medium
[ Daniel Willmann ]
* gprs_gmm: Check for RAT change and ensure this only happens for RAU/ATT
* gbproxy-usermanual: Explain BSSGP/BVC handling
* gbproxy: Whitespace fixes
* gbproxy: Add todo for BVC RESET logic
* gbproxy: Get the peer if paging by BVCI on SIG_BVC
* Let libosmocore handle VTY parent node tracking
* osmo-gbproxy: Free msgb in ns2 prim callback
* configure.ac: Require python3 for ext_tests
* osmo-gbproxy: Implement nsvc-state ctrl command
* gbproxy: Remove test testing NSVCI change
* gbproxy: Add NSE peer that can have multiple gbproxy_peers
* gbproxy: Ensure BVC0 is reset before handling PtP BVCs
* gbproxy: Only send paging to each matching NSE once
* gbproxy: Separate function to move gbproxy_peer to different nse
* gbproxy: Add logging macros for NSE and BVC
* gbproxy: Use LOG macros for NSE/BVC
* gbproxy: Change generic LOG messages so BVCI/NSEI fmt is consistent
* gbproxy: Add todos encountered while going through the code
* gbproxy: Add BVC log filters
* gbproxy: Add newline to log message
* gbproxy: Allow gbproxy_nse_free(NULL)
* gbproxy: Delete gbproxy_nse in delete-gbproxy-peer VTY command
* mm_state_gb_fsm: Handle implicit detach from mm_standby
* gbproxy: Fix bvci check in gbprox_rx_ptp_from_*
* osmo-gbproxy: Initialize all hash_maps
* gbproxy: Fix confusing log message in gbprox_relay2nse
* gbproxy: Add SGSN NRI configuration
* gbproxy: Add SGSN pooling support
* gbproxy: Add comments to sgsn functions
* gbproxy: Add config option to name an SGSN
* gbproxy: Add VTY command to override the node selection function
* Fix gbproxy_sgsn_by_tlli wraparound
* gbproxy: Implement TLLI cache and use it for SUSPEND/RESUME
* gbproxy: Increase TLLI cache timeout to 10s
* gbproxy: Implement IMSI cache
* gbproxy: Use IMSI cache to handle PAGING_PS_REJECT
* gbproxy: Use C-style comments
* gbproxy: Move helper function to a more logical place
* gbproxy: Remove unused variable assignment
* gbproxy: Fix VTY cmd name
* gbproxy: Define and use help string for gbproxy
* gbproxy: Add VTY commands to query the TLLI/IMSI cache
* gbproxy: Use IMSI cache for PTP paging and implement DUMMY_PAGING_PS
* gbproxy: Print the correct message type for dummy paging/paging reject
* gbproxy: Improve log messages in gbproxy_select_sgsn
* gbproxy: Fix radio status routing by TMSI
* manual/gbproxy: Update overview chapter
* Rename OsmoGbPROXY -> *Proxy
* manuals/gbproxy: Update configuration chapter
* manuals/gbproxy: Add osmo-bsc MSC pooling chapter from Neels as a base
* manuals/gbproxy: MSC -> SGSN for pooling chapter
* manuals/gbproxy: Move pooling to separate chapter
[ Alexander Couzens ]
* gprs_gmm_fsm.c: Implement RAT change between 2g and 3g
* gtphub: rename sgsn's oww osmo_sockaddr into sgsn_sockaddr
* gprs_llc: _bssgp_tx_dl_ud: ensure the LLME is valid before using it
* gmm: on invalid RA id reject the MS with an implicit detach
* gtphub_test: fix compilation error on gcc 10.2.0
* gtphub: fix compilation with gcc 10.2.0
* Port gbproxy to NS2
* sgsn: check for NULL of gprs_subscr_get_or_create()
* sgsn: Use the new NS2 api
* gbproxy: use ns2 vty2
* configure.ac: define a c standard instead of using the compilers default
* follow libosmocore/gprs_ns2 API changes of GPRS enums
* gbproxy: follow gprs_ns2 API vty changes
* sgsn: migrate to the new gprs_ns2_vty configuration
* follow libosmocore/gprs_ns2 API changes (gprs_ns2_dynamic_create_nse)
[ Neels Hofmeyr ]
* manual: explain IuPS, add SCCP/M3UA section from common chapters
* fix nullpointer: in gsm48_rx_gmm_ra_upd_req()
* gsup: send RAT type on LU
* gbproxy_test.c: fix mobile identity test data
* use new osmo_mobile_identity API everywhere
[ Eric ]
* tests: dlopen does not imply availability of dlsym..
* configure.ac: fix libtool issue with clang and sanitizer
[ Harald Welte ]
* gtphub_test: Fix compilation with gcc-10
* Fix memory leak when SNDCP de-fragmentation is used
* Treat RAU as implicit RESUME if GMM is suspended
* *.spec.in: Use %config(noreplace) to retain current config file
* Send a BVC-RESET to all persistent Gb interfaces at start-up
* Use osmo_fd_setup() whenever applicable
* Use osmo_fd_*_{disable,enable}
* gbproxy: Properly implement paging to LAC/RAC
* gbproxy: Implement paging to entire BSS area
* gprs_gb_parse: Add function to determine TLLI from encoded BSSGP
* gbproxy: Pass TLLI as LSP towards NS to facilitate load sharing
* gb_proxy_peer: Add some FIXMEs regarding invalid assumptions
* gb_proxy: More precise + readable log messages
* gb_proxy: Broadcast SGSN-INVOKE-TRACE and OVERLOAD
* gbproxy: Move BSS-side BVC-RESET processing to its own function
* gb_proxy: Slightly restructure processing of BSS-originated BVC-RESET
* gbproxy: Cosmetics: use longer lines
* gbproxy: Send BVC-STATUS if BSS sends us BVC-RESET without mandatory IEs
* gb_proxy: Use TLVP_PRES_LEN instead of TLVP_PRESENT
* gb_proxy: Rename gbproxy_peer to gbproxy_bvc
* gbproxy: Rename gbproxy_cfg.nses to gbproxy_cfg.bss_nses
* gbproxy: convert bss_nses from llist_head to hashtable
* gbproxy: convert nse->bvcs from llist_head to hashtable
* gbproxy: Remove patching, TLLI-tracking and SGSN2 support
* gb_proxy: cosmetic: Use function rather than open-coding is_sgsn
* gbproxy: Delete gbproxy_test
* gb_proxy: Introduce more validation / constraint checks
* gbproxy: use gbprox_relay2peer() whenever possible
* gb_proxy: Use osmo_tlv_prot_parse() to validate mandatory IEs
* gbproxy: Log FSM timeouts
* migrate to DLBSSGP as log sub-system for BSSGP
* gbproxy major rewrite for SGSN pool support
* gbproxy: Use "(nsei << 16) | bvci" as rate_ctr_group index
* gbproxy: Introduce new DOBJ log category; log object allocation/release
* gbproxy: Don't create an extra msgb copy for SGSN DL SIG
* gbproxy: Implement handling of BVC Flow Control
* gbproxy: Copy RA-ID from BSS side BVC to CELL and SGSN-side BVC
* gbproxy: (Re)allocate SGSN-side PTP BVC even if CELL already exists
* gbproxy: Fix segfault when receiving PAGING for unknown destination
* gbproxy: Add FSM related VTY commands
* gbproxy: Implement scaling of BVC flow control in SGSN pool
* gbproxy: Improve VTY state introspection
* gbproxy: rename vty command "show gbproxy ..." to "show gbproxy bvc ..."
* gbproxy: Add "show gbproxy cell ..." VTY command
* gbproxy: Fix build on Deiban 8
* gb_proxy: Don't use orphan log subsystem DPCU
* gbproxy: Avoid depending on any of the SGSN code
* main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
* manuals: generate vty reference xml at build time
[ Pau Espin Pedrol ]
* Use OSMO_FD_* instead of deprecated BSC_FD_*
* sgsn_libgtp: Improve ps-paging logging
* gprs_gmm_fsm.c: Add missing license header
* sgsn_libgtp: Avoid ps-paging MS on GMM Suspended state
* configure.ac: Fix trailing whitespace
* doc: Update VTY reference xml file
* Support setting rt-prio and cpu-affinity mask through VTY
* Change default SCTP conn NULL->127.0.0.1 to localhost->localhost
* contrib/jenkins: Enable parallel make in make distcheck
* Log error if pdp ctx is freed while holding an active timer
* Fix crash rx DeactPdpReq while waiting for DeactPdpAck after gtp side is freed
* sgsn_delete_pdp_ctx: Add documentation and assert assumptions
* process_ms_ctx_status: refactor to avoid code duplication
* process_ms_ctx_status: Fix crash deleting PDP Ctx if GTP side was already released
* gbproxy: generate coredump and exit upon SIGABRT received
* gtphub: generate coredump and exit upon SIGABRT received
* sgsn: generate coredump and exit upon SIGABRT received
* gmm: fix build without define PTMSI_ALLOC
* gmm: Introduce comment to ease addition of Network feature support IE later
* .gitignore: Ignore new autofoo tmp files
* sndcp: Fix struct bit fields on big endian
* Fix nsei+bvci not updated on rx UL SNDCP data
[ Oliver Smith ]
* contrib: import RPM spec
* contrib: integrate RPM spec
* Makefile.am: EXTRA_DIST: debian, contrib/*.spec.in
* contrib/jenkins: don't build osmo-gsm-manuals
* gbproxy: remove (moved to own repository)
[ Vadim Yanitskiy ]
* debian/control: change maintainer to the Osmocom team / mailing list
* gb_proxy_peer: sgsn can never be NULL in gbproxy_sgsn_by_nri()
* gb_proxy_peer: fix NULL pointer dereference in gbproxy_sgsn_alloc()
[ Keith ]
* Fix Radio Priority in MM Attach and PDP Context Activation
* VTY: Add gtp state-dir command
[ Philipp Maier ]
* gprs_sndcp: fix use after free
* sgsn_rim: Add routing for (GERAN) BSSGP RIM messages
-- Pau Espin Pedrol <pespin@sysmocom.de> Tue, 23 Feb 2021 20:29:33 +0100
osmo-sgsn (1.6.0) unstable; urgency=medium
[ Pau Espin Pedrol ]
* gprs_gmm: Introduce macros to access msgb's associated IU UE ctx
* gprs_llc.h: Improve documentation of some structs
* gprs_gmm.c: Improve doc on nullable parameters
* gprs_gmm.c: Drop unneeded brackets
* Introduce define TLLI_UNASSIGNED
* gprs_sgsn.c: Warn upon llme free unexpected scenarios
* gprs_gmm: Clarify comment during TLLI assignment
* gprs_sgsn.c: Remove recently introduced assert
* gprs_gmm: Introduce assert to guard against unexpected condition
* gprs_gmm.c: Use correct function to set MM_IDLE state during cleanup
* gprs_sgsn.h: Flag MM_CTX_T_GERAN_Iu as not supported
* gprs_gmm.c: Flag mmctx_set_(p)mm_state() functions static
* sgsn: use sccp_simple_client API to setup ss7 id 0 instead of 1
* gprs_gmm.c: Fix typo in log message
* gprs_gmm.c: Call mmctx_set_(p)mm_state only on related ran_type
* Introduce and use log macros when no mm ctx available
* gprs_gmm: Avoid spaces in fsm events and enum strings
* tests: Verify that timers can be set over VTY
* Replace own timer infra with libosmocore osmo_tdef
* tests: Introduce vty-transcript-test tests
* gprs_gmm.c: Use osmo_rai_name() in log line
* examples: Add osmo-sgsn_custom-sccp.cfg
* vty: Introduce cs7-instance-iu
* gprs_gmm.c: Print value_string of reject cause
* gprs_gmm.c: Add spec document to function documentation
* gtp: make echo_interval unsigned
* gtp: cb_delete_context(): Clarify why pdp->lib is set to NULL
* Introduce log helper LOGGGSN and log category DGTP
* sgsn: gtp: Drop related pdp contexts on echo timeout against GGSN
* Move lots of Iu/ranap specific code into its own file
* Move llc->MM/SM Gb specific glue code to its own file
* Split enum gprs_pmm_state into Iu and Gb counterparts
* Merge common allocation steps for Gb and Iu ctx
* gprs_gmm.c: Replace inet_ntoa with inet_ntop
* sgsn_cdr.c: Fix ip addr string buffer size
* sgsn_vty: Fix mmctx rate_ctr output indentation
* sgsn_vty: Print correct Iu mmctx id in 'show mm-context'
* Introduce FSM mm_state_gb_fsm
* Introduce FSM mm_state_iu_fsm
* vty: Print MM state and RAN type in show mm-context
* src/gprs/Makefile.am: Move build of shared .c files to an internal lib
* Move out gbproxy to its own subdir
* Move out gtphub to its own subdir
* Move out sgsn to its own subdir
* gmm: Move code handling GMM Attach Complete to its own function
* gmm: Move code handling GMM Routing Area Update Complete to its own function
* gmm: Move code handling GMM PTMSI Realloc Complete to its own function
* enum gprs_gmm_state: Fix spec reference
* Implement GMM State using osmocom FSM
* Split out GPRS SM layer into its own file
* sgsn: Reject PdpActReq if no GTP pdp ctx exists
* Introduce TODO-RELEASE file
* sgsn_libgtp.c: Drop use of deprecated libgtp APIs gtp_retrans*()
* gmm: Fix assertion hit during RA UPD REQ before completting gmm attach
* Improve logging in gprs_llc.c code
* gprs_llc.c: Use enum instead of hardcoded value
* gprs_gmm.c: Send XID reset with received TLLI
[ Alexander Couzens ]
* gprs/gprs_gmm: implement T3314. Timeout to reset MM state READY->STANDBY
* gprs_gmm: only update gb/iu cell information when Iu/Gb present
* gprs_gmm: clarify comment of Iu follow-on request
* gprs_gmm: gsm48_rx_gmm_att_req(): refactor duplicated code
* sgsn_pdp_ctx_terminate: check llme before accessing
* gprs_ranap: send CommonId after receiving Security Mode Complete
* mm_gb_fsm: unassign the llme when entering MM_IDLE
* gprs_ranap: refactor REQUIRE_MM define
* sgsn: when receiving data PDU notify the Gb GMM fsm
* Avoid compiling unneeded files when building without Iu
* gprs_ranap: release Iu UE Context when exiting PMM Connected
* Iu: implement a user inactivity timer
* gprs_ranap: on Iu release, stop the attach fsm if running
* gprs_mm_state_gb_fsm: ensure T3350 is not running when entering IDLE
* gprs_ranap: add missing rc = 0
* gprs_sgsn: always allocate Gb/Iu mm fsm
* sgsn: MM Gb Fsm: fix event handling for implicit detach
* ranap: add non-spec X1001
* gprs_gmm: release Iu connection on RAU failures
* sgsn_mm_ctx_alloc(): check for unallocated fsms
* sgsn_libgtp: refactor ps paging into gprs_gb
* sgsn: Gb: implementing PS Paging when MS is MM_STANDBY
[ Vadim Yanitskiy ]
* gprs_mm_state_iu_fsm.c: fix: assign timer_cb to mm_state_iu_fsm
[ Max ]
* Use libosmocore constant for IMSI length in ACL entry
[ Harald Welte ]
* LLC: Don't use hard-coded N201-U / N201-I values in XID
* Initial OsmoGbPROXY user manual
* check for osmo_fsm_register() error return values
* check for osmo_ss7_init() error return value
* manual: Fix copy+paste error
* exit(2) on unsupported positional arguments on command line
[ Oliver Smith ]
* gitignore: fix paths to binaries
* doc: add OsmoGbProxy VTY reference
* regen_doc.sh: support gbproxy, run without docker
* osmoappdesc.py, tests: switch to python 3
-- Pau Espin Pedrol <pespin@sysmocom.de> Fri, 03 Jan 2020 19:17:56 +0100
osmo-sgsn (1.5.0) unstable; urgency=medium
[ Max ]
* Improve 'show subscriber cache' vty command
* GMM: permit VLR_ANSWERED event in attach FSM
* Fix IMSI padding in imsi-acl
[ Harald Welte ]
* gbproxy_test: Fix test expectations of gprs_ns_rcvmsg()
* LLC XID: Fix string representation of N201_U
* LLC: Don't blindly assume all LLC frames have data payload
* LLC: Avoid NOTICE message on LLC NULL
* gprs_llc: Correctly refuse any ABM command (SABM, DISC) with DM
* LLC: Store the XID inside the LLC Entity, not LLC Mgmg Entity
* gb_proxy.h: Add missing comments; improve comments
* gb_proxy: cosmetic: Use 'bool' in data structures where applicable
[ efistokl ]
* gsm0408_rcv_gmm: send Iu-ReleaseCommand upon receiving Attach Complete.
* gprs_gmm: send Service Reject when no PDP ctxs are available.
[ Alexander Couzens ]
* gprs_gmm: reintroduce calling gsm48_gmm_authorize when not handling GMM Attach Requests
* gbproxy: parse dtap GSM48_MT_GSM_DEACT_PDP_REQ|ACK
[ Pau Espin Pedrol ]
* gprs_sndcp_comp_free: Replace ifelse with switch and better handling of error
* sgsn: vty: Improve log warning content with spec section
* Document max retransmit times for T3395
* sgsn: Fix echo timer not started upon first pdp ctx created
* sgsn_libgtp: Use new per-GSN libgtp API instead of deprecated API
* sgsn: Have authentication required on by default
* Remove undefined param passed to {logging,osmo_stats}_vty_add_cmds
* Require newer versions of dependencies
[ Keith ]
* Echo zero byte XID-Field of Type L3_PAR
[ Oliver Smith ]
* debian: create -doc subpackage with pdf manuals
* contrib/jenkins.sh: run "make maintainer-clean"
* osmo-gtphub.cfg: fix conflict with osmo-sgsn.cfg
* osmo-gbproxy.cfg: fix conflict with osmo-sgsn.cfg
[ Vadim Yanitskiy ]
* doc/manuals/vty: regenerate sgsn_vty_reference.xml
* osmo-sgsn: add VTY parameter to toggle authentication
* sgsn_mm_ctx_find_ggsn_ctx(): fix: always set gsm_cause
[ Eric Wild ]
* replace magic tmsi constant with define
* turn -Werror=null-dereference into a warning
[ Daniel Willmann ]
* manuals: Add script to regenerate vty/counter documentation
* manuals: Update vty/counter documentation
* Add/fix help string for version option
* osmo-sgsn: Fix outdated information in usermanual
* configuration.adoc: Small fixes
* configuration.adoc: Add a section about encryption
[ Ruben Undheim ]
* Spelling fixes
-- Pau Espin Pedrol <pespin@sysmocom.de> Thu, 08 Aug 2019 16:46:31 +0200
osmo-sgsn (1.4.0) unstable; urgency=medium
[ Alexander Couzens ]
* gprs_subscriber: gsup_auth_error: reject MS in all cases
* gprs_gmm: make functions relating to GMM Attach Request public
* gprs_gmm: make extract_subscr_msisdn extract_subscr_hlr public
* gprs_gmm: Cancel Location: use detach type IMSI
* vty: add cmd "reset sgsn state"
* tests: remove gmm unit tests
* gprs_gmm: introduce a GMM Attach Request FSM
* debian: add missing build dependencies
* sgsn: use gtp_clear_queues() when reset sgsn state
* vty: restart sgsn state: improve output message
* sgsn_ggsn_ctx_drop_pdp: protect against nullpointer when MM is gone
* gprs_sgsn.h: fix wrong type of re-attempts
* GTP: refactor the echo timer
* gprs_gmm: dont answer unknown IMSI/TMSI on Service Requests NET_FAIL
* gprs_gmm: Fix missing Security Command for 3G when attaching
* sgsn_libgtp: fix a potential memleak when the GGSN is not reachable
* gprs_llc: remove the FCS from the msgb by trim'ing the msgb
* OsmoSGSN: add rate counter documentation
[ Daniel Willmann ]
* gb_proxy: tallocate memory for gbproxy cfg so it can be a talloc ctx
* gb_proxy: Add ctrl interface and nsvc-state, gbproxy-state commands
* git-version-gen: Don't check for .git directory
[ Stefan Sperling ]
* add a test for OS#3178 (invalid unitdata message)
* finish gbproxy_parse_bssgp_unitdata test
* fix bogus assertion in encode_comp_field()
* fix bogus error check in gprs_sndcp_comp_create()
* use enums consistently instead of falling back to int
* update gbproxy test expected output
* consistently check the result of osmo_shift_v_fixed()
* remove pointless declaration of struct gsm_network
* make gsup ipa name configurable in osmo-sgsn.cfg
[ Pau Espin Pedrol ]
* jenkins.sh: Use --enable-werror only when iu support is disabled
* jenkins.sh: Remove non-existent configure options
* Drop all references of unused SMPP
* Drop all references of unused MGCP
* Drop unused common_vty.c
* sgsn_libgtp.c: Log pointer of deleted context
* Maintain per ggsn pdp ctx list
* osmo-sgsn: ping GGSN periodically and check for restart counter
* Disarm T3395 when dettaching mmctx from pdpctx
* examples: Enable by default echo req towards active GGSNs
* vty: Add cmd to disable echo loop explictly
* Add optional TearDownInd IE in PDP DEACT REQ towards PCU
* sgsn: Don't attempt to delete GTP pdp ctx if GGSN was restarted
* Forward GGSN originated DEACT PDP CTX REQ
* sgsn: Fix T3395 firing forever
* sgsn: subscriber: Avoid calling memcpy with NULL src
* sgsn: cdr: Fix uninitialized string access if ggsn is detached
* sgsn: gtp: Use new API to send PDP DEL CTX REQ without freeing ctx locally
* sgsn: Fix crash using new libgtp cb_recovery2 API
* gbproxy: Replace '.' in counter names with ':'
* Drop gprs_msgb_copy with libosmocore replacement
* Drop gprs_msgb_resize_area with libosmocore replacement
* Use osmo_clock_gettime from libosmocore
* gbproxy: Add VTY parameter: link stored-msgs-max-length
* gbproxy: Add new VTY-managed timer: link-list clean-stale-timer
* gbproxy: Replace '.' in counter names with ':'
* Add osmo-gtphub systemd service file
* debian: Fix typo in rules preventing build with IU support
* Install systemd services with autotools
* Install sample cfg file to /etc/osmocom
* Update wrong references to bsc in sgsn code
* Allocate sgsn_instance with talloc
* gbproxy: flag gbproxy_assign_imsi as static
* gbproxy: Fix abort during APN patch
* gbproxy: Remove unneeded parse_ctx param
* gbproxy: flush_stored_messages: Move comment to func description
* gbproxy: flush_stored_messages: Log and route using stored_msg info
* gbproxy: flush_stored_messages: Get rid of msg param
* Allow easily disabling GFDL references
* OsmoSGSN: configuration: Move pdp ctx specific CDR fields to its own table
* OsmoSGSN: configuration: Add missing pdp-periodic event
* OsmoSGSN: configuration: Document CDR CTRL interface
* OsmoSGSN: overview: Fix typo and reference OpenGGSN->OsmoGGSN
[ Harald Welte ]
* migrate to oap_client in libosmogsm
* remove libcommon
* gbproxy-legacy: Ensure well-formed config file
* Remove local libgsupclient; Use libosmo-gsup-client from osmo-hlr
* initial checkin of manuals to public repo
* Add link to Asciidoc source code of manual
* OsmoSGSN: Fix formatting/cross reference in CDR section
* Update GSUP chapter regarding UMTS AKA and other recent changes
* GSUP: Add ladder diagrams for protocol transactions / procedures
* share chapters/gsup.adoc from OsmoSGSN to OsmoMSC + OsmoHLR
* vty-ref: Update URI of docbook 5.0 schema
[ Neels Hofmeyr ]
* use __FILE__, not __BASE_FILE__
* vty: fix doc str for 'reset sgsn state'
* vty: add SCCP related vty commands
* fix build: remove unused variable
* Importing history from osmo-gsm-manuals.git
* add 'make check' target
* fix 'make clean': shell glob, ignore failure
* refactor Makefile build rules, don't use the FORCE
* OsmoSGSN: update VTY reference
* sgsn: update vty reference
[ Oliver Smith ]
* gtphub: Add --version cmdline option
* build manuals moved here from osmo-gsm-manuals.git
* Fix DISTCHECK_CONFIGURE_FLAGS override
* contrib/jenkins.sh: build and publish manuals
* contrib: fix makedistcheck with disabled systemd
[ Max ]
* Cleanup non-existent files from debian/copyright
* Use safer functions for IMSI ACL
* gbproxy: fix formatting in gbproxy-state command
* gbproxy: add number-of-peers ctrl command
* Revert "gbproxy: fix formatting in gbproxy-state command"
* Add OsmoSGSN control interface description
* Remove misleading comment
* Constify sgsn_acl_lookup() parameter
* Drop unused osmo-sgsn.pc
* Use explicit length check
* Use explicit parameter for sgsn_auth_init()
[ Jonathan Brielmaier ]
* fix various typos across all manuals
[ ikostov ]
* SGSN: add Auth. policy, NS Statistics and BSSGP state examples, tweaks
* GSUP, OAP: fix AUTS length to 14, not 16
[ Philipp Maier ]
* osmo-sgsn: Update VTY command reference
* osmo-sgsn: improve auth-policy explaination
* osmo-sgsn: Explain TCP/IP header compression
* osmo-sgsn: fix arrow tips in flow diagrams
[ Holger Hans Peter Freyther ]
* sgsn: Fix numbering of QoS and add basic description for APN
* sgsn: Add charging characteristics to GSUP
-- Harald Welte <laforge@gnumonks.org> Wed, 23 Jan 2019 18:32:41 +0100
osmo-sgsn (1.3.0) unstable; urgency=medium
[ Neels Hofmeyr ]
* drop osmo_sgsn.cfg from src/gprs dir
* change default config filename to osmo-sgsn.cfg, not osmo_sgsn.cfg
* vty: skip installing cmds now always installed by default
* add --enable-sanitize config option
* use default point-code as listed on Point_Codes wiki page
* gprs_gmm: segfault: gracefully handle failure to alloc context
* gsm48_rx_gmm_att_req: fix error handling: don't clean up NULL llme
* gprs_llc: tx dl ud: make mismatching LLE not crash osmo-sgsn
* fix build: missing LIBGTP_CFLAGS in sgsn_test
* sgsn_test: guard against struct gprs_ra_id changing
* vty: absorb command explanations from osmo-gsm-manuals
* configure: add --enable-werror
* implement support for 3-digit MNC with leading zeros
* osmo-gbproxy: use 'osmo-gbproxy.cfg' as default config name
* compiler warnings: use enum ranap_nsap_addr_enc, constify local var
* use osmo_init_logging2(), fix regression test memleaks
* auth+ciph: log is_r99 and auth types
* log two RA Update Request failure causes
* GERAN: allow GSM SRES on UMTS AKA challenge
[ Alexander Couzens ]
* .gitignore: remove unneeded ignores of bsc/msc/nitb files
* tests/ctrl_test_runner.py: remove BSC/NAT TestRunner
* debian: remove doublicated project name in example files
* .gitignore: remove non-existent /src/utils exludes
* configure.ac: remove pcap check
* configure.ac: remove unused libcdk check
* .service: remove OpenBSC from service desription
* mandatory depend on libc-ares and libgtp
* GMM: dont reply to GMM_DETACH_REQ with POWER OFF when MS is unknown
[ Harald Welte ]
* Replace '.' in counter names with ':'
* Add talloc context introspection via VTY
[ Pau Espin Pedrol ]
* Replace '.' in counter names with ':'
* tests: Fix selection of python version
* sgsn_cdr: Split log formatting into a snprintf function
* Add vty cmd 'cdr trap' to send CDR through CTRL iface
* tests: sgsn_test: Define wrap APIs with correct parameters
* cosmetic: tests: sgsn_test: Use proper formatting and remove uneeded semicolons
* gprs_gmm: Remove unused variable
* cosmetic: gprs_gmm: Remove trailing whitespace
* gprs_gmm: Convert warning message to pragma message
* configure.ac: Enable Wall in CFLAGS
* .gitignore: Add m4 files
* sgsn_libgtp.c: Fix typos and whitespace
[ Max ]
* Fix display of GTP addresses
* Show GTP version for PDP context in vty
* Remove unneeded .py scripts
* Replace '.' in counter names with ':'
* Remove dead code
* Enable sanitize for CI tests
* cosmetic: use macro for gtphub plane iteration
* Use connection id when allocating rate counters
* Migrate from OpenSSL to osmo_get_rand_id()
* Remove obsolete ./configure option
* Fix RAI construction
* gtphub: make rate_ctr unique
* Remove unused bsc_version.c
* Use gsm48_encode_ra() for RAI encoding
* gtphub: check for gsn_addr_from_sockaddr() errors
* gtphub: check for gsn_addr_from_sockaddr() error
-- Pau Espin Pedrol <pespin@sysmocom.de> Thu, 03 May 2018 19:01:44 +0200
osmo-sgsn (1.2.0) unstable; urgency=medium
[ Neels Hofmeyr ]
* jenkins: fix build: remove unused dependencies
* debian: fix osmo-sgsn.install, tweak VCS link and descriptions
* drop files unrelated to osmo-sgsn
* rewrite README
* configure.ac: set name to osmo-sgsn, fix ML addr
* move openbsc.pc to osmo-sgsn.pc
* move include/openbsc to include/osmocom/sgsn
* jenkins.sh: fix echo string to say osmo-sgsn, not msc
* jenkins: use osmo-clean-workspace.sh before and after build
[ Alexander Couzens ]
* debian: fix paths of examples
* debian/rules: show testsuite.log when tests are failing
[ Max ]
* Remove rest_octets.h
* gbproxy: ensure peer allocation result
* jenkins: use osmo-ggsn for tests
* Cleanup configure checks
* Use extended logging for PDP contexts
* deb: fix copyright file issues
* Move P-TMSI alloc/update into separate function
* Check for correct P-TMSI allocation
* Use new FSF address in license header
* SGSN: uncomment BSSGP vty tests
* SGSN: print additional GTP-related info
* SGSN: check that GSN is created in proper mode
* Fix APN printing
* Fix build after recent rate_ctr patches
* gbproxy: don't link unnecessary
* Fix libosmo-sigtran dependency
* jenkins: check for IU properly
* Log GTP-U endpoints update
* Log address on GTP creation
[ Pau Espin Pedrol ]
* Remove unneeded dep libdbi
[ Philipp Maier ]
* log: fix default loglevels
* non-iu-build: guard vty libosmo-sigtran function calls.
* configure: fix libosmo-sigtran dependency
[ Harald Welte ]
* Debian: Add systemd service files for osmo-sgsn and osmo-gbproxy
* Debian: fix dh_strip rules for creating one -dbg per program
-- Harald Welte <laforge@gnumonks.org> Sat, 28 Oct 2017 19:07:48 +0200
osmo-sgsn (0.1.0) unstable; urgency=low
* Initial release.
-- Alexander Couzens <lynxis@fe80.eu> Tue, 08 Aug 2017 01:13:05 +0000

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
10

62
debian/control vendored Normal file
View File

@ -0,0 +1,62 @@
Source: osmo-sgsn
Section: net
Priority: extra
Maintainer: Osmocom team <openbsc@lists.osmocom.org>
Build-Depends: debhelper (>= 10),
dh-autoreconf,
autotools-dev,
autoconf,
automake,
libtool,
pkg-config,
libtalloc-dev,
libc-ares-dev,
libgtp-dev (>= 1.11.0),
libosmocore-dev (>= 1.9.0),
libosmo-abis-dev (>= 1.5.0),
libosmo-netif-dev (>= 1.4.0),
libosmo-gsup-client-dev (>= 1.7.0),
libasn1c-dev (>= 0.9.30),
libosmo-ranap-dev (>= 1.5.0),
libosmo-sigtran-dev (>= 1.8.0),
libosmo-sccp-dev (>= 1.8.0),
osmo-gsm-manuals-dev (>= 1.5.0)
Standards-Version: 3.9.8
Vcs-Git: https://gitea.osmocom.org/cellular-infrastructure/osmo-sgsn
Vcs-Browser: https://gitea.osmocom.org/cellular-infrastructure/osmo-sgsn
Homepage: https://projects.osmocom.org/projects/osmo-sgsn
Package: osmo-sgsn
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: OsmoSGSN: Osmocom's Serving GPRS Support Node for 2G and 3G packet-switched mobile networks
Package: osmo-sgsn-dbg
Section: debug
Architecture: any
Multi-Arch: same
Depends: osmo-sgsn (= ${binary:Version}), ${misc:Depends}
Description: OsmoSGSN: Osmocom's Serving GPRS Support Node for 2G and 3G packet-switched mobile networks
Package: osmo-gtphub
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Osmocom GTP Hub: Proxy for GTP traffic between multiple SGSNs and GGSNs
Package: osmo-gtphub-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmo-gtphub (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for Osmocom GTP Hub
Package: osmo-sgsn-doc
Architecture: all
Section: doc
Priority: optional
Depends: ${misc:Depends}
Description: ${misc:Package} PDF documentation
Various manuals: user manual, VTY reference manual and/or
protocol/interface manuals.

334
debian/copyright vendored Normal file
View File

@ -0,0 +1,334 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: osmo-sgsn
Source: https://gitea.osmocom.org/cellular-infrastructure/osmo-sgsn
Files: .gitignore
.gitreview
.mailmap
AUTHORS
Makefile.am
README
README.vty-tests
configure.ac
contrib/Makefile.am
contrib/gprs/gb-proxy-unblock-bug.py
contrib/gprs/gprs-bssgp-histogram.lua
contrib/gprs/gprs-buffer-count.lua
contrib/gprs/gprs-split-trace-by-tlli.lua
contrib/gprs/gprs-verify-nu.lua
contrib/ipa.py
contrib/jenkins.sh
contrib/soap.py
contrib/systemd/osmo-sgsn.service
contrib/twisted_ipa.py
doc/Makefile.am
doc/examples/Makefile.am
doc/examples/osmo-gtphub/gtphub-example.txt
doc/examples/osmo-gtphub/osmo-gtphub-1iface.cfg
doc/examples/osmo-gtphub/osmo-gtphub.cfg
doc/examples/osmo-sgsn/osmo-sgsn.cfg
include/Makefile.am
include/osmocom/sgsn/Makefile.am
include/osmocom/sgsn/common.h
include/osmocom/sgsn/crc24.h
include/osmocom/sgsn/debug.h
include/osmocom/sgsn/gb_proxy.h
include/osmocom/sgsn/gprs_gmm.h
include/osmocom/sgsn/gprs_llc.h
include/osmocom/sgsn/gprs_sgsn.h
include/osmocom/sgsn/gprs_sndcp.h
include/osmocom/sgsn/gprs_subscriber.h
include/osmocom/sgsn/sgsn.h
include/osmocom/sgsn/vty.h
m4/README
src/Makefile.am
src/gprs/.gitignore
src/gprs/Makefile.am
src/gprs/osmo_sgsn.cfg
tests/Makefile.am
tests/atlocal.in
tests/gprs/Makefile.am
tests/gprs/gprs_test.c
tests/gprs/gprs_test.ok
tests/gtphub/Makefile.am
tests/gtphub/gtphub_test.ok
tests/sgsn/gprs_gb_parse.h
tests/sgsn/Makefile.am
tests/sgsn/sgsn_test.ok
tests/slhc/Makefile.am
tests/slhc/slhc_test.ok
tests/sndcp_xid/Makefile.am
tests/sndcp_xid/sndcp_xid_test.ok
tests/testsuite.at
tests/v42bis/Makefile.am
tests/v42bis/v42bis_test.ok
tests/xid/Makefile.am
tests/xid/xid_test.ok
Copyright: __NO_COPYRIGHT_NOR_LICENSE__
License: __NO_COPYRIGHT_NOR_LICENSE__
Files: include/osmocom/sgsn/a_reset.h
include/osmocom/sgsn/gprs_llc_xid.h
include/osmocom/sgsn/gprs_sndcp_comp.h
include/osmocom/sgsn/gprs_sndcp_dcomp.h
include/osmocom/sgsn/gprs_sndcp_pcomp.h
include/osmocom/sgsn/gprs_sndcp_xid.h
include/osmocom/sgsn/gprs_utils.h
include/osmocom/gtphub/gtphub.h
include/osmocom/sgsn/signal.h
src/gprs/gprs_llc_parse.c
src/gprs/crc24.c
src/gprs/gprs_utils.c
src/gprs/sgsn_ares.c
src/gtphub/gtphub.c
src/gtphub/gtphub_main.c
src/gtphub/gtphub_vty.c
src/sgsn/gprs_gmm.c
src/sgsn/gprs_llc.c
src/sgsn/gprs_llc_vty.c
src/sgsn/gprs_llc_xid.c
src/sgsn/gprs_sgsn.c
src/sgsn/gprs_sndcp.c
src/sgsn/gprs_sndcp_comp.c
src/sgsn/gprs_sndcp_dcomp.c
src/sgsn/gprs_sndcp_pcomp.c
src/sgsn/gprs_sndcp_vty.c
src/sgsn/gprs_sndcp_xid.c
src/sgsn/gprs_subscriber.c
src/sgsn/sgsn_auth.c
src/sgsn/sgsn_cdr.c
src/sgsn/sgsn_ctrl.c
src/sgsn/sgsn_libgtp.c
src/sgsn/sgsn_main.c
src/sgsn/sgsn_vty.c
tests/gtphub/gtphub_test.c
tests/sgsn/gprs_gb_parse.c
tests/sgsn/sgsn_test.c
tests/slhc/slhc_test.c
tests/sndcp_xid/sndcp_xid_test.c
tests/v42bis/v42bis_test.c
tests/xid/xid_test.c
Copyright: 2008-2015 Holger Hans Peter Freyther <zecke@selfish.org>
2008-2016 Harald Welte <laforge@gnumonks.org>
2009-2015 Holger Hans Peter Freyther
2010-2014 On-Waves
2011-2016 sysmocom s.f.m.c. GmbH <info@sysmocom.de>
2014-2016 Sysmocom s.f.m.c. GmbH
2014-2017 sysmocom s.f.m.c. GmbH
License: AGPL-3.0+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Files: src/gtphub/gtphub_ares.c
src/gtphub/gtphub_sock.c
Copyright: 2013 Jacob Erlbeck <jerlbeck@sysmocom.de>
2013 sysmocom s.f.m.c. GmbH
2014 Holger Hans Peter Freyther
2015 sysmocom s.f.m.c. GmbH <info@sysmocom.de>
License: __NO_LICENSE__
Files: include/osmocom/sgsn/v42bis.h
include/osmocom/sgsn/v42bis_private.h
Copyright: 2005-2011 Steve Underwood
License: LGPL-2.1
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1,
as published by the Free Software Foundation.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.
The FSF address in the above text is the old one.
.
On Debian systems, the complete text of the GNU Lesser General Public License
Version 2.1 can be found in `/usr/share/common-licenses/LGPL-2.1'.
Files: osmoappdesc.py
tests/ctrl_test_runner.py
tests/vty_test_runner.py
Copyright: 2013 Katerina Barone-Adesi <kat.obsc@gmail.com>
2013 Jacob Erlbeck <jerlbeck@sysmocom.de>
2013-2014 Holger Hans Peter Freyther <zecke@selfish.org>
License: GPL-3+
Files: git-version-gen
Copyright: 2007-2010 Free Software Foundation, Inc.
License: GPL-3.0+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.
It may be run two ways:
- from a git repository in which the "git describe" command below
produces useful output (thus requiring at least one signed tag)
- from a non-git-repo directory containing a .tarball-version file, which
presumes this script is invoked like "./git-version-gen .tarball-version".
.
In order to use intra-version strings in your project, you will need two
separate generated version string files:
.
.tarball-version - present only in a distribution tarball, and not in
a checked-out repository. Created with contents that were learned at
the last time autoconf was run, and used by git-version-gen. Must not
be present in either $(srcdir) or $(builddir) for git-version-gen to
give accurate answers during normal development with a checked out tree,
but must be present in a tarball when there is no version control system.
Therefore, it cannot be used in any dependencies. GNUmakefile has
hooks to force a reconfigure at distribution time to get the value
correct, without penalizing normal development with extra reconfigures.
.
.version - present in a checked-out repository and in a distribution
tarball. Usable in dependencies, particularly for files that don't
want to depend on config.h but do want to track version changes.
Delete this file prior to any autoconf run where you want to rebuild
files to pick up a version string change; and leave it stale to
minimize rebuild time after unrelated changes to configure sources.
.
It is probably wise to add these two files to .gitignore, so that you
don't accidentally commit either generated file.
.
Use the following line in your configure.ac, so that $(VERSION) will
automatically be up-to-date each time configure is run (and note that
since configure.ac no longer includes a version string, Makefile rules
should not depend on configure.ac for version updates).
.
On Debian systems, the complete text of the GNU General Public License
Version 3 can be found in `/usr/share/common-licenses/GPL-3'.
Files: src/gprs/v42bis.c
Copyright: 2005-2011 Steve Underwood
License: LGPL-2.1
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1,
as published by the Free Software Foundation.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
.
THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED.
Currently it performs the core compression and decompression functions OK.
However, a number of the bells and whistles in V.42bis are incomplete.
.
! \file
.
The FSF address in the above text is the old one.
.
On Debian systems, the complete text of the GNU Lesser General Public License
Version 2.1 can be found in `/usr/share/common-licenses/LGPL-2.1'.
Files: include/osmocom/sgsn/slhc.h
Copyright: 1989 Regents of the University of California.
License: __UNKNOWN__
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by the University of California, Berkeley. The name of the
University may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.
Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- Initial distribution.
.
modified for KA9Q Internet Software Package by
Katie Stevens (dkstevens@ucdavis.edu)
University of California, Davis
Computing Services
- 01-31-90 initial adaptation
Files: src/gprs/slhc.c
Copyright: 1989 Regents of the University of California.
License: __UNKNOWN__
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by the University of California, Berkeley. The name of the
University may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.
Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
- Initial distribution.
.
modified for KA9Q Internet Software Package by
Katie Stevens (dkstevens@ucdavis.edu)
University of California, Davis
Computing Services
- 01-31-90 initial adaptation (from 1.19)
PPP.05 02-15-90 [ks]
PPP.08 05-02-90 [ks] use PPP protocol field to signal compression
PPP.15 09-90 [ks] improve mbuf handling
PPP.16 11-02 [karn] substantially rewritten to use NOS facilities
Files: m4/ax_check_compile_flag.m4
Copyright: 2008 Guido U. Draheim <guidod@gmx.de>
2011 Maarten Bosmans <mkbosmans@gmail.com>
License: GNU-All-Permissive-License
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
.
As a special exception, the respective Autoconf Macro's copyright owner
gives unlimited permission to copy, distribute and modify the configure
scripts that are the output of Autoconf when processing the Macro. You
need not follow the terms of the GNU General Public License when using
or distributing such scripts, even though portions of the text of the
Macro appear in them. The GNU General Public License (GPL) does govern
all other use of the material that constitutes the Autoconf Macro.
.
This special exception to the GPL applies to versions of the Autoconf
Macro released by the Autoconf Archive. When you make and distribute a
modified version of the Autoconf Macro, you may extend this special
exception to the GPL to apply to your modified version as well.
.
On Debian systems, the complete text of the GNU General Public License
Version 3 can be found in `/usr/share/common-licenses/GPL-3'.

2
debian/osmo-gtphub.default vendored Normal file
View File

@ -0,0 +1,2 @@
CONFIG_FILE="/etc/osmocom/osmo-gtphub.cfg"

5
debian/osmo-gtphub.install vendored Normal file
View File

@ -0,0 +1,5 @@
etc/osmocom/osmo-gtphub.cfg
lib/systemd/system/osmo-gtphub.service
usr/bin/osmo-gtphub
usr/share/doc/osmo-sgsn/examples/osmo-gtphub/osmo-gtphub-1iface.cfg usr/share/doc/osmo-gtphub/examples
usr/share/doc/osmo-sgsn/examples/osmo-gtphub/osmo-gtphub.cfg usr/share/doc/osmo-gtphub/examples

1
debian/osmo-sgsn-doc.install vendored Normal file
View File

@ -0,0 +1 @@
usr/share/doc/osmo-sgsn-doc/*.pdf

5
debian/osmo-sgsn.install vendored Normal file
View File

@ -0,0 +1,5 @@
/etc/osmocom/osmo-sgsn.cfg
lib/systemd/system/osmo-sgsn.service
usr/bin/osmo-sgsn
usr/share/doc/osmo-sgsn/examples/osmo-sgsn/osmo-sgsn.cfg usr/share/doc/osmo-sgsn/examples
usr/share/doc/osmo-sgsn/examples/osmo-sgsn/osmo-sgsn-accept-all.cfg usr/share/doc/osmo-sgsn/examples

38
debian/postinst vendored Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh -e
case "$1" in
configure)
# Create the osmocom group and user (if it doesn't exist yet)
if ! getent group osmocom >/dev/null; then
groupadd --system osmocom
fi
if ! getent passwd osmocom >/dev/null; then
useradd \
--system \
--gid osmocom \
--home-dir /var/lib/osmocom \
--shell /sbin/nologin \
--comment "Open Source Mobile Communications" \
osmocom
fi
# Fix permissions of previous (root-owned) install (OS#4107)
if dpkg --compare-versions "$2" le "1.12.0"; then
if [ -e /etc/osmocom/osmo-sgsn.cfg ]; then
chown -v osmocom:osmocom /etc/osmocom/osmo-sgsn.cfg
chmod -v 0660 /etc/osmocom/osmo-sgsn.cfg
fi
if [ -d /etc/osmocom ]; then
chown -v root:osmocom /etc/osmocom
chmod -v 2775 /etc/osmocom
fi
mkdir -p /var/lib/osmocom
chown -R -v osmocom:osmocom /var/lib/osmocom
fi
;;
esac
# dh_installdeb(1) will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#

68
debian/rules vendored Executable file
View File

@ -0,0 +1,68 @@
#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
# See debhelper(7) (uncomment to enable)
# This is an autogenerated template for debian/rules.
#
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1
#
# Copy some variable definitions from pkg-info.mk and vendor.mk
# under /usr/share/dpkg/ to here if they are useful.
#
# See FEATURE AREAS/ENVIRONMENT in dpkg-buildflags(1)
# Apply all hardening options
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# Package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# Package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
#
# With debhelper version 9 or newer, the dh command exports
# all buildflags. So there is no need to include the
# /usr/share/dpkg/buildflags.mk file here if compat is 9 or newer.
#
# These are rarely used code. (START)
#
# The following include for *.mk magically sets miscellaneous
# variables while honoring existing values of pertinent
# environment variables:
#
# Architecture-related variables such as DEB_TARGET_MULTIARCH:
#include /usr/share/dpkg/architecture.mk
# Vendor-related variables such as DEB_VENDOR:
#include /usr/share/dpkg/vendor.mk
# Package-related variables such as DEB_DISTRIBUTION
#include /usr/share/dpkg/pkg-info.mk
#
# You may alternatively set them susing a simple script such as:
# DEB_VENDOR ?= $(shell dpkg-vendor --query Vendor)
#
# These are rarely used code. (END)
#
# main packaging script based on dh7 syntax
%:
dh $@ --with autoreconf
# debmake generated override targets
# Set options for ./configure
CONFIGURE_FLAGS += --enable-iu --with-systemdsystemunitdir=/lib/systemd/system --enable-manuals
override_dh_auto_configure:
dh_auto_configure -- $(CONFIGURE_FLAGS)
#
# Do not install libtool archive, python .pyc .pyo
#override_dh_install:
# dh_install --list-missing -X.la -X.pyc -X.pyo
# See https://www.debian.org/doc/manuals/developers-reference/best-pkging-practices.html#bpp-dbg
override_dh_strip:
dh_strip -posmo-sgsn --dbg-package=osmo-sgsn-dbg
dh_strip -posmo-gtphub --dbg-package=osmo-gtphub-dbg
# Print test results in case of a failure
override_dh_auto_test:
dh_auto_test || (find . -name testsuite.log -exec cat {} \; ; false)
# Don't create .pdf.gz files (barely saves space and they can't be opened directly by most pdf readers)
override_dh_compress:
dh_compress -X.pdf

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (native)

4
doc/Makefile.am Normal file
View File

@ -0,0 +1,4 @@
SUBDIRS = \
examples \
manuals \
$(NULL)

View File

@ -1,3 +1,12 @@
OSMOCONF_FILES = \
osmo-gtphub/osmo-gtphub.cfg \
osmo-sgsn/osmo-sgsn.cfg \
$(NULL)
osmoconfdir = $(sysconfdir)/osmocom
osmoconf_DATA = $(OSMOCONF_FILES)
EXTRA_DIST = $(OSMOCONF_FILES)
CFG_FILES = find $(srcdir) -name '*.cfg*' | sed -e 's,^$(srcdir),,'

View File

@ -0,0 +1,90 @@
Here is a simple setup to test GTPHub operations. The IP addresses picked will
work well only on a system that creates local addresses (127.0.0.123) on the
fly (like linux) -- you may pick of course different IP addresses.
Overview of the example setup:
sgsnemu gtphub ggsn
127.0.0.1 <--> 127.0.0.3 127.0.0.4 <--> 127.0.0.2
Prerequisites: openggsn.
Have a local directory where you store config files and from which you launch
the GSNs and the hub (they will store restart counter files in that dir).
In it, have these config files:
ggsn.conf:
# GGSN local address
listen 127.0.0.2
# End User Addresses are picked from this range
net 10.23.42.0/24
pcodns1 8.8.8.8
logfile /tmp/foo
gtphub.conf:
gtphub
bind-to-sgsns 127.0.0.3
bind-to-ggsns 127.0.0.4
ggsn-proxy 127.0.0.2
end
(
You may omit the ggsn-proxy if GRX ares is working, or if you add the GRX
address and GGSN IP address to /etc/hosts something like:
127.0.0.2 internet.mnc070.mcc901.gprs
)
Once the config files are in place, start the programs, in separate terminals.
GGSN and SGSN need to be started with root priviliges to be able to create tun
interfaces. GTPHub may run as unprivileged user.
The LD_LIBRARY_PATH below may be needed if OpenGGSN installed to /usr/local.
1. GGSN:
sudo -s
cd <your-test-dir>
LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/ggsn -f -c ./ggsn.conf
2. GTPHub:
cd <your-test-dir>
path/to/openbsc/openbsc/src/gtphub/osmo-gtphub -c gtphub.conf #-e 1 #for DEBUG level
3. SGSN tests:
sudo -s
cd <your-test-dir>
/usr/local/bin/sgsnemu --createif -l 127.0.0.1 -r 127.0.0.3 --imsi 420001214365100 --contexts=3
Add more SGSNs using different IMSIs and local ports (if the same IMSI is used,
the GGSN will reuse TEIs and tunnels will be discarded automatically):
/usr/local/bin/sgsnemu --createif -l 127.0.0.11 -r 127.0.0.3 --imsi 420001214365300 --contexts=3
This shows the basic setup of GTPHub. Testing internet traffic via sgsnemu
still needs some effort to announce a mobile subscriber or the like (I have
used a real BTS, osmo-sgsn and a testing SIM in a web phone, instead).
The core capability of GTPHub is to manage more than two GSNs, e.g. an SGSN
contacting various GGSNs over the single GTPHub link. You would configure the
SGSN to use one fixed GGSN (sending to gtphub) and gtphub will resolve the
GGSNs once it has received the messages. So the SGSN may be behind NAT (add
"sgsn-use-sender" to gtphub.conf) and communicate to various GGSNs over a
single link to gtphub.
I hope this helps to get you going.
Any suggestions/patches are welcome!
~Neels

View File

@ -0,0 +1,33 @@
!
! Osmocom gtphub configuration
!
! This file is used for VTY tests, referenced by openbsc/osmoappdesc.py
! For the test, try to use most config commands.
!
log stderr
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
line vty
no login
gtphub
! Local addresses to listen on and send from, both on one interface.
! The side towards SGSN uses nonstandard ports.
bind-to-sgsns ctrl 127.0.0.1 12123 user 127.0.0.1 12153
! The GGSN side with standard ports.
bind-to-ggsns 127.0.0.1
! Proxy: unconditionally direct all traffic to...
sgsn-proxy 127.0.0.4
! Proxy with nonstandard ports or separate IPs:
ggsn-proxy ctrl 127.0.0.3 2123 user 127.0.0.5 2152
! Add a name server for GGSN resolution
grx-dns-add 192.168.0.1

View File

@ -0,0 +1,33 @@
!
! Osmocom gtphub configuration
!
log stderr
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
line vty
no login
gtphub
! Local addresses to listen on and send from, each on standard ports
! 2123 and 2152. Setting these addresses is mandatory.
bind-to-sgsns 127.0.0.10
bind-to-ggsns 127.0.0.20
! Local nonstandard ports or separate IPs:
!bind-to-sgsns ctrl 127.0.0.1 2342 user 127.0.0.1 4223
! Proxy: unconditionally direct all traffic to...
!ggsn-proxy 127.0.0.3
!sgsn-proxy 127.0.0.4
! Proxy with nonstandard ports or separate IPs:
!ggsn-proxy ctrl 127.0.0.3 2123 user 127.0.0.5 2152
! Add a name server for GGSN resolution
!grx-dns-add 192.168.0.1

View File

@ -0,0 +1,38 @@
!
! Osmocom SGSN configuration
!
!
log stderr
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
line vty
no login
!
sgsn
gtp state-dir /var/lib/osmocom/osmo-sgsn
gtp local-ip 127.0.0.1
ggsn 0 remote-ip 127.0.0.2
ggsn 0 gtp-version 1
ggsn 0 echo-interval 60
authentication optional
auth-policy accept-all
!
ns
timer tns-block 3
timer tns-block-retries 3
timer tns-reset 3
timer tns-reset-retries 3
timer tns-test 30
timer tns-alive 3
timer tns-alive-retries 10
bind udp local
listen 127.0.0.1 23000
accept-ipaccess
!
bssgp
!

View File

@ -0,0 +1,40 @@
!
! Osmocom SGSN configuration
!
!
log stderr
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
line vty
no login
!
sgsn
gtp state-dir /var/lib/osmocom/osmo-sgsn
gtp local-ip 127.0.0.1
ggsn 0 remote-ip 127.0.0.2
ggsn 0 gtp-version 1
ggsn 0 echo-interval 60
authentication required
auth-policy remote
gsup remote-ip 127.0.0.1
gsup remote-port 4222
!
ns
timer tns-block 3
timer tns-block-retries 3
timer tns-reset 3
timer tns-reset-retries 3
timer tns-test 30
timer tns-alive 3
timer tns-alive-retries 10
bind udp local
listen 127.0.0.1 23000
accept-ipaccess
!
bssgp
!

View File

@ -0,0 +1,50 @@
!
! Osmocom SGSN configuration
!
!
log stderr
logging color 1
logging print category-hex 0
logging print category 1
logging timestamp 0
logging print file basename last
logging print level 1
line vty
no login
!
cs7 instance 0
point-code 0.23.4
asp asp-clnt-OsmoSGSN-A 2905 0 m3ua
remote-ip 172.18.8.200 ! where to reach the STP
role asp
sctp-role client
as as-clnt-OsmoSGSN-A m3ua
asp asp-clnt-OsmoSGSN-A
routing-key 3 0.23.4
sgsn
gtp state-dir /var/lib/osmocom/osmo-sgsn
gtp local-ip 127.0.0.1
ggsn 0 remote-ip 127.0.0.2
ggsn 0 gtp-version 1
ggsn 0 echo-interval 60
authentication required
auth-policy remote
gsup remote-ip 127.0.0.1
gsup remote-port 4222
cs7-instance-iu 0
!
ns
timer tns-block 3
timer tns-block-retries 3
timer tns-reset 3
timer tns-reset-retries 3
timer tns-test 30
timer tns-alive 3
timer tns-alive-retries 10
bind udp local
listen 127.0.0.1 23000
accept-ipaccess
!
bssgp
!

25
doc/manuals/Makefile.am Normal file
View File

@ -0,0 +1,25 @@
EXTRA_DIST = osmosgsn-usermanual.adoc \
osmosgsn-usermanual-docinfo.xml \
osmosgsn-vty-reference.xml \
regen_doc.sh \
chapters \
vty \
$(NULL)
if BUILD_MANUALS
ASCIIDOC = osmosgsn-usermanual.adoc
ASCIIDOC_DEPS = $(srcdir)/chapters/*.adoc
include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.asciidoc.inc
VTY_REFERENCE = osmosgsn-vty-reference.xml
BUILT_REFERENCE_XML = $(builddir)/vty/sgsn_vty_reference.xml
$(builddir)/vty/sgsn_vty_reference.xml: $(top_builddir)/src/sgsn/osmo-sgsn
mkdir -p $(builddir)/vty
$(top_builddir)/src/sgsn/osmo-sgsn --vty-ref-xml > $@
include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.vty-reference.inc
OSMO_REPOSITORY = osmo-sgsn
include $(OSMO_GSM_MANUALS_DIR)/build/Makefile.common.inc
endif

View File

@ -0,0 +1,432 @@
== Configuring OsmoSGSN
Contrary to other network elements (like OsmoBSC, OsmoNITB), the
OsmoSGSN has a relatively simple configuration.
On the one hand, this is primary because the PCU configuration happens
from the BSC side.
On the other hand, it is because the Gb interface does not need an
explicit configuration of each PCU connecting to the SGSN. The
administrator only has to ensure that the NS and BSSGP layer identities
(NSEI, NSVCI, BVCI) are unique for each PCU connecting to the SGSN.
[[gp-if-ggsn]]
=== Configuring the Gp interface (towards GGSN)
The Gp interface is the GTP-C and GTP-U based interface between the SGSN
and the GGSNs. It is implemented via UDP on well-known source and
destination ports.
When an MS requests establishment of a PDP context, it specifies the APN
(Access Point Name) to which the context shall be established. This APN
determines which GGSN shall be used, and that in turn determines which
external IP network the MS will be connected to.
There are two modes in which GGSNs can be configured:
. static GGSN/APN configuration
. dynamic GGSN/APN configuration
==== Static GGSN/APN configuration
In this mode, there is a static list of GGSNs and APNs configured in
OsmoSGSN via the VTY / config file.
This is a non-standard method outside of the 3GPP specifications for the
SGSN, and is typically only used in private/small GPRS networks without
any access to a GRX.
.Example: Static GGSN/APN configuration (single catch-all GGSN)
----
OsmoSGSN(config-sgsn)# gtp local-ip 172.0.0.1 <1>
OsmoSGSN(config-sgsn)# ggsn 0 remote-ip 127.0.0.2 <2>
OsmoSGSN(config-sgsn)# ggsn 0 gtp-version 1 <3>
OsmoSGSN(config-sgsn)# apn * ggsn 0 <4>
----
<1> Configure the local IP address at the SGSN used for Gp/GTP
<2> Specify the remote IP address of the GGSN (for GGSN 0)
<3> Specify the GTP protocol version used for GGSN 0
<4> Route all APN names to GGSN 0
==== Dynamic GGSN/APN configuration
In this mode, the SGSN will use a DNS-based method to perform the lookup
from the APN (as specified by the MS) towards the GGSN IP address.
This is the official method as per the 3GPP specifications for the SGSN,
and what is used on GRX.
.Example: Dynamic GGSN/APN configuration
----
OsmoSGSN(config-sgsn)# gtp local-ip 192.168.0.11 <1>
OsmoSGSN(config-sgsn)# ggsn dynamic <2>
OsmoSGSN(config-sgsn)# grx-dns-add 1.2.3.4 <3>
----
<1> Configure the local IP address at the SGSN used for Gp/GTP
<2> Enable the dynamic GGSN resolving mode
<3> Specify the IP address of a DNS server for APN resolution
[[gp-if-mme]]
=== Configuring the Gp interface (towards MME)
The Gp interface also contains the GTP-C v1 based interface between the SGSN
and the MMEs. This interface between SGSN and MMEs is used to transfer _RAN
Information Relay_ GTP-C messages between them, which are used as containers to
allow PCUs under the SGSN and eNodeBs under MMEs to exchange cell information
(RIM).
In the SGSN, this interface re-uses the same socket local configuration as per
the GGSN connections (see _gtp local-ip_ VTY command in <<gp-if-ggsn>>).
Similarly as with GGSNs, (again see <<gp-if-ggsn>>), selection of destination
peers for the _RAN Information Relay_ message can be configured statically or
dynamically over GRX.
==== Static MME/TAI configuration
In this mode, there is a static list of MMEs and TAIs configured in
OsmoSGSN via the VTY / config file. One MME in the list can be configured as the
_default route_, where all unspecified TAIs are routed too.
This is a non-standard method outside of the 3GPP specifications for the
SGSN, and is typically only used in private/small GPRS networks without
any access to a GRX.
.Example: Static MME/TAI configuration (single catch-all GGSN)
----
sgsn
...
gtp local-ip 192.168.0.10 <1>
mme test-mme0 <2>
gtp remote-ip 192.168.0.20 <3>
gtp ran-info-relay 262 42 3 <4>
gtp ran-info-relay 262 42 4
mme test-mme1 <5>
gtp remote-ip 192.168.0.30
gtp ran-info-relay default <6>
----
<1> Configure the local IP address at the SGSN used for Gp/GTP
<2> Configure an MME named "test-mme0"
<3> Specify the remote IP address of the MME (for MME "test-mme0")
<4> Route specified TAIs towards this MME
<5> Configure an MME named "test-mme1"
<6> Route all TAIs with an unspecified MME towards MM "test-mme1"
==== Dynamic MME/TAI configuration
Dynamic MME/TAI peer look up over GRX is not yet supported by OsmoSGSN.
[[auth-pol]]
=== Authorization Policy
The authorization policy controls by which rules a subscriber is accepted or
rejected. The possible options range from accepting just all subscribers without
further checking, to a fine grained access-control, handled by an external HLR.
accept-all:: All subscribers that attempt to attach to the GPRS network are
accepted without further checking. This option is intended to be used for
testing in a controlled environment only. A wide-open network may attract
subscribers from foreign networks and disrupt their service. It is highly
recommended to pick one of the options below.
remote:: This option allows to connect OsmoSGSN to an external HLR via the
GSUP protocol. This will be the preferred option in larger networks.
acl-only:: If no external HLR is available, the network operator has the
option to control the access using an access control list. The access control
list contains the IMSI numbers of the allowed subscribers. This method offers
fine grained access control and is ideal for small networks and lab test
environments.
closed:: This policy mode softens the strict *acl-only* only mode by also
implicitly accepting home network subscribers. The decision is made by the MCC
and MNC part of the IMSI number. The combination of MCC and MNC fully identifies
a subscribers home network, also known as a Home Network Identity (HNI, i.e.
MCC and MNC found at the start of the IMSI, e.g. MCC 901 and MNC 700 with
IMSI 901700000003080).
NOTE: The policy mode *closed* must not be confused with the equally named
policy that is defined for osmo-nitb!
.Example: Assign or change authorization policy
----
OsmoSGSN> enable
OsmoSGSN# configure terminal
OsmoSGSN(config)# sgsn
OsmoSGSN(config-sgsn)# auth-policy acl-only <1>
OsmoSGSN(config-sgsn)# write <2>
Configuration saved to sgsn.cfg
OsmoSGSN(config-sgsn)# end
OsmoSGSN# disable
OsmoSGSN>
----
<1> 'acl-only' is selected as authorization policy
<2> Saves current changes to cofiguration to make this policy
persistent
.Example: Access control list
----
sgsn
auth-policy acl-only <1>
imsi-acl add 001010000000003
imsi-acl add 001010000000002
imsi-acl add 001010000000001
imsi-acl add 901700000000068 <2>
----
<1> Set the authorization policy
<2> Add as many subscribers as required
=== Subscriber Configuration
As opposed to OsmoNITB, OsmoSGSN does not feature a built-in HLR.
It can thus operate only in the following two modes:
. Accessing an external HLR (or HLR gateway) via the GSUP protocol
. Accepting subscribers based on internal ACL (access control list),
see also <<auth-pol>>
==== Accessing an external HLR via GSUP
The non-standard GSUP protocol was created to provide OsmoSGSN with
access to an external HLR while avoiding the complexities of the
TCAP/MAP protocol stack commonly used by HLRs.
A custom HLR could either directly implement GSUP, or an external gateway
can be used to convert GSUP to the respective MAP operations.
The primitives/operations of GSUP are modelled to have a 1:1
correspondence to their MAP counterparts. However, the encoding is much
simplified by use of a binary TLV encoding similar to Layer 3 of
GSM/GPRS.
GSUP performs a challenge-response authentication protocol called OAP,
which uses the standard MILENAGE algorithm for mutual authentication
between OsmoSGSN and the HLR/HLR-GW.
[[sgsn-ex-gsup]]
.Example: Using an external HLR via GSUP
----
OsmoSGSN(config-sgsn)# gsup remote-ip 2.3.4.5 <1>
OsmoSGSN(config-sgsn)# gsup remote-port 10000 <2>
OsmoSGSN(config-sgsn)# gsup oap-k 000102030405060708090a0b0c0d0e0f <3>
OsmoSGSN(config-sgsn)# gsup oap-opc 101112131415161718191a1b1c1d1e1f <4>
----
<1> Configure the IP address of the (remote) HLR or HLR-GW
<2> Configure the TCP port of the (remote) HLR or HLR-GW
<3> Specify the OAP shared key
<4> Specify the OAP shared OPC
=== CDR configuration
OsmoSGSN can write a text log file containing CDR (call data records),
which are commonly used for accounting/billing purpose.
.Example: CDR log file configuration
----
OsmoSGSN(config-sgsn)# cdr filename /var/log/osmosgsn.cdr
OsmoSGSN(config-sgsn)# cdr interval 600 <1>
----
<1> Periodically log existing PDP contexts every 600 seconds (10 min)
The CDR file is a simple CSV file including a header line naming the
individual fields of each CSV line.
==== CDR CTRL interface
Independently of whether logging CDR to a file is enabled or not, OsmoSGSN can
also provide delivery of CDR through the CTRL interface. CDR are sent by means
of TRAP messages with variable name _cdr-v1_, and its value is filled using the
same CSV line format as in the log file, but without CSV header line.
.Example: CDR delivery through CTRL TRAP messages
----
OsmoSGSN(config-sgsn)# cdr trap
----
==== CDR Format
[[sgsn-cdr]]
.Description of CSV fields in OsmoSGSN CDR file
[options="header",cols="15%,85%"]
|===
|Field Name|Description
|timestamp|Timestamp in YYYYMMDDhhmmssXXX where XXX are milli-seconds
|imsi|IMSI causing this CDR
|imei|IMEI causing this CDR
|msisdn|MSISDN causing this CDR (if known)
|cell_id|Cell ID in which the MS was registered last
|lac|Location Area Code in which the MS was registered last
|hlr|HLR of the subscriber
|event|Possible events are explained below in <<sgsn-cdr-event>>
|===
If the _event_ field describes a pdp context related action (starts with
_pdp-_), then the following extra CSV fields are appended to the line:
[[sgsn-cdr-pdp]]
.Description of extra CSV fields for pdp context related events
[options="header",cols="15%,85%"]
|===
|Field Name|Description
|pdp_duration|duration of the PDP context so far
|ggsn_addr|GGSN related to the PDP context
|sgsn_addr|SGSN related to the PDP context
|apni|APN identifier of the PDP context
|eua_addr|IP address allocated to the PDP context
|vol_in|Number of bytes in MO direction
|vol_out|Number of bytes in MT direction
|charging_id|Related charging ID
|===
[[sgsn-cdr-event]]
.Description of OsmoSGSN CDR Events
[options="header",cols="15%,85%"]
|===
|Event|Description
|attach|GMM ATTACH COMPLETE about to be sent to MS
|update|GMM ROUTING AREA UPDATE COMPLETE about to be sent to MS
|detach|GMM DETACH REQUEST received from MS
|free|Release of the MM context memory
|pdp-act|GTP CREATE PDP CONTEXT CONFIRM received from GGSN
|pdp-deact|GTP DELETE PDP CONTEXT CONFIRM received from GGSN
|pdp-terminate|Forced PDP context termination during MM context release
|pdp-free|Release of the PDP context memory
|pdp-periodic|Triggered by periodic timer, see VTY cmd _cdr interval_
|===
=== User traffic compression
In order to save GPRS bandwith, OsmoSGSN implements header and data
compression schemes which will reduce the packet length.
==== Header compression
On TCP/IP connections, each packet is prepended with a fairly long TCP/IP
header. The header contains a lot of static information that never changes
throughout the connection. (source and destination address, port numbers etc.)
OsmoSGSN implements a TCP/IP header compression scheme called RFC1144, also
known as SLHC. This type of header compression removes the TCP/IP header
entirely and replaces it with a shorter version, that only contains the
information that is absolutely necessary to identify and check the packet.
The receiving part then restores the original header and forwards it to higher
layers.
*compression rfc1144 passive*::
TCP/IP header compression has to be actively requested by the modem. The
network will not promote compression by itself. This is the recommended mode
of operation.
*compression rfc1144 active slots <1-256>*::
TCP/IP header compression is actively promoted by the network. Modems may still
actively request different compression parameters or reject the offered
compression parameters entirely. The number of slots is the maximum number
of packet headers per subscriber that can be stored in the codebook.
.Example: Accept compression if requested
----
sgsn
compression rfc1144 passive
----
.Example: Actively promote compression
----
sgsn
compression rfc1144 active slots 8
----
.Example: Turn off compression
----
sgsn
no compression rfc1144
----
NOTE: The usage of TCP/IP options may disturb the RFC1144 header compression
scheme. TCP/IP options may render RFC1144 ineffective if variable data is
encoded into the option section of the TCP/IP packet. (e.g. TCP option 8,
Timestamp)
==== Data compression
Data compression works on the raw packet data, including the header part of the
packet. If enabled, header compression is applied first before data compression
is applied. OsmoSGSN implements the V.42bis data compression scheme.
*compression v42bis passive*::
V42bis data compression has to be actively requested by the modem. The network
will not promote compression by itself. This is the recommended mode of
operation.
*compression v42bis active direction (ms|sgsn|both) codewords <512-65535> strlen <6-250>*::
V42bis data compression is actively promoted by the network. Modems may still
actively request different compression parameters or reject the offered
compression parameters entirely. The direction configures which sides are
allowed to send compressed packets. For most cases, compressing 'both'
directions will be the preferred option. The following to parameters configure
the codebook size by the maxium number ('codewords') and size ('strlen') of
entries.
.Example: Accept compression if requested
----
sgsn
compression v42bis passive
----
.Example: Actively promote compression
----
sgsn
compression v42bis active direction both codewords 512 strlen 20
----
.Example: Turn off compression
----
sgsn
no compression v42bis
----
=== Encryption
Encryption can be enabled if the auth-policy is set to remote and the
HLR subscriber entries contain the keys of the SIM card. See
<<sgsn-ex-gsup>> on how to connect to an external HLR.
.Example: Turn on encryption (GEA3 and GEA4)
----
sgsn
encryption gea 3 4
----
.Example: Turn off encryption (GEA0)
----
sgsn
encryption gea 0
----
=== Configure SCCP/M3UA to accept _IuPS_ links
OsmoSGSN acts as client to contact an STP instance and establish an SCCP/M3UA
link.
An example configuration of OsmoSGSN's SCCP link:
----
cs7 instance 0
point-code 0.23.4
asp asp-clnt-OsmoSGSN 2905 0 m3ua
remote-ip 127.0.0.1
role asp
sctp-role client
as as-clnt-OsmoSGSN m3ua
asp asp-clnt-OsmoSGSN
routing-key 0 0.23.4
----
This configuration is explained in detail in <<cs7_config>>.

View File

@ -0,0 +1,23 @@
[[control]]
== Control interface
The actual protocol is described in <<common-control-if>>, the variables
common to all programs using it are described in <<ctrl_common_vars>>. Here we
describe variables specific to OsmoSGSN.
.Variables available over control interface
[options="header",width="100%",cols="20%,5%,5%,50%,20%"]
|===
|Name|Access|Trap|Value|Comment
|subscriber-list-active-v1|RO|No|"<imsi>,<addr>"|See <<subs>> for details.
|===
[[subs]]
=== subscriber-list-active-v1
Return the list of active subscribers as a concatenated set of pairs "<imsi>",
"addr" where first element of the pair is subscriber's IMSI and the second
element (which might be empty) is the subscriber's address. The address value
might be "none", "invalid" and "PPP" in addition to actual IP address. In case
of IP address it will be prefixed with "IPv4" or "IPv6" string depending on the
version of IP protocol.

View File

@ -0,0 +1,4 @@
[[counters]]
== Counters
include::./counters_generated.adoc[]

View File

@ -0,0 +1,82 @@
// autogenerated by show asciidoc counters
These counters and their description based on OsmoSGSN 1.4.0.31-05fe (OsmoSGSN).
=== Rate Counters
// generating tables for rate_ctr_group
// rate_ctr_group table BSSGP Peer Statistics
.bssgp:bss_ctx - BSSGP Peer Statistics
[options="header"]
|===
| Name | Reference | Description
| packets:in | <<bssgp:bss_ctx_packets:in>> | Packets at BSSGP Level ( In)
| packets:out | <<bssgp:bss_ctx_packets:out>> | Packets at BSSGP Level (Out)
| bytes:in | <<bssgp:bss_ctx_bytes:in>> | Bytes at BSSGP Level ( In)
| bytes:out | <<bssgp:bss_ctx_bytes:out>> | Bytes at BSSGP Level (Out)
| blocked | <<bssgp:bss_ctx_blocked>> | BVC Blocking count
| discarded | <<bssgp:bss_ctx_discarded>> | BVC LLC Discarded count
| status | <<bssgp:bss_ctx_status>> | BVC Status count
|===
// rate_ctr_group table SGSN Overall Statistics
.sgsn - SGSN Overall Statistics
[options="header"]
|===
| Name | Reference | Description
| llc:dl_bytes | <<sgsn_llc:dl_bytes>> | Count sent LLC bytes before giving it to the bssgp layer
| llc:ul_bytes | <<sgsn_llc:ul_bytes>> | Count successful received LLC bytes (encrypt & fcs correct)
| llc:dl_packets | <<sgsn_llc:dl_packets>> | Count successful sent LLC packets before giving it to the bssgp layer
| llc:ul_packets | <<sgsn_llc:ul_packets>> | Count successful received LLC packets (encrypt & fcs correct)
| gprs:attach_requested | <<sgsn_gprs:attach_requested>> | Received attach requests
| gprs:attach_accepted | <<sgsn_gprs:attach_accepted>> | Sent attach accepts
| gprs:attach_rejected | <<sgsn_gprs:attach_rejected>> | Sent attach rejects
| gprs:detach_requested | <<sgsn_gprs:detach_requested>> | Received detach requests
| gprs:detach_acked | <<sgsn_gprs:detach_acked>> | Sent detach acks
| gprs:routing_area_requested | <<sgsn_gprs:routing_area_requested>> | Received routing area requests
| gprs:routing_area_requested | <<sgsn_gprs:routing_area_requested>> | Sent routing area acks
| gprs:routing_area_requested | <<sgsn_gprs:routing_area_requested>> | Sent routing area rejects
| pdp:activate_requested | <<sgsn_pdp:activate_requested>> | Received activate requests
| pdp:activate_rejected | <<sgsn_pdp:activate_rejected>> | Sent activate rejects
| pdp:activate_accepted | <<sgsn_pdp:activate_accepted>> | Sent activate accepts
| pdp:request_activated | <<sgsn_pdp:request_activated>> | unused
| pdp:request_activate_rejected | <<sgsn_pdp:request_activate_rejected>> | unused
| pdp:modify_requested | <<sgsn_pdp:modify_requested>> | unused
| pdp:modify_accepted | <<sgsn_pdp:modify_accepted>> | unused
| pdp:dl_deactivate_requested | <<sgsn_pdp:dl_deactivate_requested>> | Sent deactivate requests
| pdp:dl_deactivate_accepted | <<sgsn_pdp:dl_deactivate_accepted>> | Sent deactivate accepted
| pdp:ul_deactivate_requested | <<sgsn_pdp:ul_deactivate_requested>> | Received deactivate requests
| pdp:ul_deactivate_accepted | <<sgsn_pdp:ul_deactivate_accepted>> | Received deactivate accepts
|===
// rate_ctr_group table NSVC Peer Statistics
.ns:nsvc - NSVC Peer Statistics
[options="header"]
|===
| Name | Reference | Description
| packets:in | <<ns:nsvc_packets:in>> | Packets at NS Level ( In)
| packets:out | <<ns:nsvc_packets:out>> | Packets at NS Level (Out)
| bytes:in | <<ns:nsvc_bytes:in>> | Bytes at NS Level ( In)
| bytes:out | <<ns:nsvc_bytes:out>> | Bytes at NS Level (Out)
| blocked | <<ns:nsvc_blocked>> | NS-VC Block count
| dead | <<ns:nsvc_dead>> | NS-VC gone dead count
| replaced | <<ns:nsvc_replaced>> | NS-VC replaced other count
| nsei-chg | <<ns:nsvc_nsei-chg>> | NS-VC changed NSEI count
| inv-nsvci | <<ns:nsvc_inv-nsvci>> | NS-VCI was invalid count
| inv-nsei | <<ns:nsvc_inv-nsei>> | NSEI was invalid count
| lost:alive | <<ns:nsvc_lost:alive>> | ALIVE ACK missing count
| lost:reset | <<ns:nsvc_lost:reset>> | RESET ACK missing count
|===
== Osmo Stat Items
// generating tables for osmo_stat_items
NSVC Peer Statistics
// osmo_stat_item_group table NSVC Peer Statistics
.ns.nsvc - NSVC Peer Statistics
[options="header"]
|===
| Name | Reference | Description | Unit
| alive.delay | <<ns.nsvc_alive.delay>> | ALIVE response time | ms
|===
== Osmo Counters
// generating tables for osmo_counters
// there are no ungrouped osmo_counters

View File

@ -0,0 +1,109 @@
[[chapter_introduction]]
== Overview
[[intro_overview]]
=== About OsmoSGSN
OsmoSGSN is the Osmocom implementation of the GPRS SGSN (Serving Gprs
Support Node) element inside the GPRS network. The SGSN plays a similar
central function to the GPRS network as the MSC plays in the GSM
network.
The SGSN is connected on the downlink side to Gb interfaces of the BSS,
specifically the PCU inside the BSS. The SGSN is further connected by
the GTP protocol to the GGSN which terminates the tunnels towards the
external packet data network (e.g. IPv4).
OsmoSGSN supports both a PCU that is co-located with(in) the BTS, as
well as a PCU that is co-located with(in) the BSC. In combination with
OsmoNITB/OsmoBSC/OsmoBTS, the PCU is co-located within the BTS.
[[fig-gprs-pcubts]]
.GPRS network architecture with PCU in BTS
[graphviz]
----
digraph G {
rankdir=LR;
MS0 [label="MS"];
MS1 [label="MS"];
MS0->BTS [label="Um"];
MS1->BTS [label="Um"];
BTS->BSC [label="Abis"];
BSC->MSC [label="A"];
BTS->PCU [label="pcu_sock"];
PCU->SGSN [label="Gb"];
SGSN->GGSN [label="GTP"];
}
----
=== Software Components
OsmoSGSN contains a variety of different software components, which
we'll quickly describe in this section.
==== Gb Implementation
OsmoSGSN implements the ETSI/3GPP specified Gb interface, including TS
08.16 (NS), TS 08.18 (BSSGP) and TS 08.64 (LLC) protocols. As transport
layers for NS, it supports NS/IP (NS encapsulated in UDP/IP), as well as
NS/FR/GRE/IP. The latter is provided in order to use a Router with
Ethernet and Frame Relay interface to convert to actual physical Frame
Relay medium, which is not directly supported by OsmoSGSN.
The actual Gb Implementation is part of the libosmogb library, which is
in turn part of the libosmocore software package. This allows the same
Gb implementation to be used from osmo-pcu, osmo-gbproxy as well as
OsmoSGSN.
==== GTP Implementation
OsmoSGSN uses the libgtp implementation originating from OsmoGGSN. It
supports both GTPv0 and GTPv1.
==== GMM Implementation
The GPRS Mobility Management implementation is quite simplistic at this
point. It supports the GPRS ATTACH and GPRS ROUTING AREA UPDATE
procedures, as well as GPRS ATTACH and GPRS DETACH.
==== LLC Implementation
The LLC (Logical Link Control) implementation of OsmoSGSN only supports
non-acknowledged mode, as this is the most common use case in real-world
GPRS networks.
It does support both TCP/IP header compression according to RFC1144 and
payload compression according to V.42bis
The LLC implementation does support LLC encryption with ciphers GEA3 and GEA4.
For encryption to work the auth policy needs to be set to remote and the SGSN
connected to an HLR containing the subscriber data including key material.
Other auth policys will not work with encryption.
==== Session Management Implementation
The session management procedures ACTIVATE PDP CONTEXT and DEACTIVATE
PDP CONTEXT are supported. However, no MODIFY PDP CONTEXT and no
Network-initiated PDP context activation is possible. This is again
covering the predominant use cases and configurations in GPRS real-world
networks while skipping the more esoteric features.
Multiple PDP contexts can be attached by a single MS.
Multiple GGSNs can be configured and routing to a GGSN can be configured based
on APN. Dynamic lookup of GGSNs though DNS-based APN resolving is also possible.
=== Limitations
At the time of writing, OsmoSGSN still has a number of limitations,
which are a result of the demand-driven Open Source development model.
If you require any of those features, please consider implementing and
contributing them, or contracting the existing OsmoSGSN developers for
performing that work.
Known Limitations include:
* No paging coordination between SGSN and MSC
* No SMS over Ps support

View File

@ -0,0 +1,35 @@
== Running OsmoSGSN
The OsmoSGSN executable (`osmo-sgsn`) offers the following command-line
options:
=== SYNOPSIS
*osmo-sgsn* [-h|-V] [-d 'DBGMASK'] [-D] [-c 'CONFIGFILE'] [-s] [-e 'LOGLEVEL']
=== OPTIONS
*-h, --help*::
Print a short help message about the supported options
*-V, --version*::
Print the compile-time version number of the OsmoSGSN program
*-d, --debug 'DBGMASK','DBGLEVELS'*::
Set the log subsystems and levels for logging to stderr. This
has mostly been superseded by VTY-based logging configuration,
see <<logging>> for further information.
*-D, --daemonize*::
Fork the process as a daemon into background.
*-c, --config-file 'CONFIGFILE'*::
Specify the file and path name of the configuration file to be
used. If none is specified, use `osmo_sgsn.cfg` in the current
working directory.
*-s, --disable-color*::
Disable colors for logging to stderr. This has mostly been
deprecated by VTY based logging configuration, see <<logging>>
for more information.
*-e, --log-level 'LOGLEVEL'*::
Set the global log level for logging to stderr. This has mostly
been deprecated by VTY based logging configuration, see
<<logging>> for more information.

View File

@ -0,0 +1,73 @@
<revhistory>
<revision>
<revnumber>1</revnumber>
<date>January 13, 2013</date>
<authorinitials>HW</authorinitials>
<revremark>
Initial version.
</revremark>
</revision>
<revision>
<revnumber>2</revnumber>
<date>February 2016</date>
<authorinitials>HW</authorinitials>
<revremark>
Conversion to asciidoc, removal of sysmoBTS specific parts.
</revremark>
</revision>
<revision>
<revnumber>3</revnumber>
<date>April 2024</date>
<authorinitials>AC</authorinitials>
<revremark>
Replace NS chapter with new NS2 chapter to match the code.
</revremark>
</revision>
</revhistory>
<authorgroup>
<author>
<firstname>Harald</firstname>
<surname>Welte</surname>
<email>hwelte@sysmocom.de</email>
<authorinitials>HW</authorinitials>
<affiliation>
<shortaffil>sysmocom</shortaffil>
<orgname>sysmocom - s.f.m.c. GmbH</orgname>
<jobtitle>Managing Director</jobtitle>
</affiliation>
</author>
<author>
<firstname>Alexander</firstname>
<surname>Couzens</surname>
<email>acouzens@sysmocom.de</email>
<authorinitials>AC</authorinitials>
<affiliation>
<shortaffil>sysmocom</shortaffil>
<orgname>sysmocom - s.f.m.c. GmbH</orgname>
<jobtitle>Developer</jobtitle>
</affiliation>
</author>
</authorgroup>
<copyright>
<year>2013-2024</year>
<holder>sysmocom - s.f.m.c. GmbH</holder>
</copyright>
<legalnotice>
<para>
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, no Front-Cover Texts,
and no Back-Cover Texts. A copy of the license is included in
the section entitled "GNU Free Documentation License".
</para>
<para>
The Asciidoc source code of this manual can be found at
<ulink url="https://git.osmocom.org/osmo-gsm-manuals/">
https://git.osmocom.org/osmo-gsm-manuals/
</ulink>
</para>
</legalnotice>

View File

@ -0,0 +1,40 @@
:gfdl-enabled:
OsmoSGSN User Manual
====================
Harald Welte <hwelte@sysmocom.de>
include::./common/chapters/preface.adoc[]
include::{srcdir}/chapters/overview.adoc[]
include::{srcdir}/chapters/running.adoc[]
include::{srcdir}/chapters/control.adoc[]
include::./common/chapters/vty.adoc[]
include::./common/chapters/logging.adoc[]
include::{srcdir}/chapters/configuration.adoc[]
include::./common/chapters/cs7-config.adoc[]
include::./common/chapters/gb-ns2.adoc[]
include::./common/chapters/control_if.adoc[]
include::./common/chapters/oap.adoc[]
include::./common/chapters/gsup.adoc[]
include::{srcdir}/chapters/counters.adoc[]
include::./common/chapters/port_numbers.adoc[]
include::./common/chapters/bibliography.adoc[]
include::./common/chapters/glossary.adoc[]
include::./common/chapters/gfdl.adoc[]

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
ex:ts=2:sw=42sts=2:et
-*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML 5.0//EN"
"http://docbook.org/xml/5.0/dtd/docbook.dtd" [
<!ENTITY chapter-vty SYSTEM "./common/chapters/vty.xml" >
<!ENTITY sections-vty SYSTEM "generated/docbook_vty.xml" >
]>
<book>
<info>
<revhistory>
<revision>
<revnumber>v1</revnumber>
<date>13th January 2013</date>
<authorinitials>hw</authorinitials>
<revremark>Initial</revremark>
</revision>
<revision>
<revnumber>v2</revnumber>
<date>5th March 2014</date>
<authorinitials>hf</authorinitials>
<revremark>Update to match osmo-bsc version 0.13.0-305</revremark>
</revision>
</revhistory>
<title>OsmoSGSN VTY Reference</title>
<copyright>
<year>2013-2014</year>
</copyright>
<legalnotice>
<para>This work is copyright by <orgname>sysmocom - s.f.m.c. GmbH</orgname>. All rights reserved.
</para>
</legalnotice>
</info>
<!-- Main chapters-->
&chapter-vty;
</book>

17
doc/manuals/regen_doc.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh -x
if [ -z "$DOCKER_PLAYGROUND" ]; then
echo "You need to set DOCKER_PLAYGROUND"
exit 1
fi
SCRIPT=$(realpath "$0")
MANUAL_DIR=$(dirname "$SCRIPT")
COMMIT=${COMMIT:-$(git log -1 --format=format:%H)}
cd "$DOCKER_PLAYGROUND/scripts" || exit 1
OSMO_BSC_BRANCH=$COMMIT ./regen_doc.sh osmo-sgsn 4245 \
"$MANUAL_DIR/chapters/counters_generated.adoc" \
"$MANUAL_DIR/vty/sgsn_vty_reference.xml"

View File

@ -0,0 +1,6 @@
<vtydoc xmlns='urn:osmocom:xml:libosmocore:vty:doc:1.0'>
<node id='config-sgsn'>
<description>Configure the remote GGSN, access-control and other
attributes of the SGSN</description>
</node>
</vtydoc>

View File

@ -92,8 +92,8 @@ fi
if test -n "$v"
then
: # use $v
elif test -d ./../.git \
&& v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \
elif
v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \
|| git describe --abbrev=4 HEAD 2>/dev/null` \
&& case $v in
[0-9]*) ;;

View File

@ -1,125 +0,0 @@
#!/usr/bin/python2.5
from __future__ import with_statement
from pysqlite2 import dbapi2 as sqlite3
import sys
hlr = sqlite3.connect(sys.argv[1])
web = sqlite3.connect(sys.argv[2])
# switch to autocommit
hlr.isolation_level = None
web.isolation_level = None
hlr.row_factory = sqlite3.Row
web.row_factory = sqlite3.Row
with hlr:
hlr_subscrs = hlr.execute("""
SELECT * FROM Subscriber
""").fetchall()
hlr_tokens = hlr.execute("""
SELECT * FROM AuthToken
""").fetchall()
with web:
web_tokens = web.execute("""
SELECT * FROM reg_tokens
""").fetchall()
web_sms = web.execute("""
SELECT * FROM sms_queue
""").fetchall()
# index by subscr id
hlr_subscrs_by_id = {}
hlr_subscrs_by_ext = {}
hlr_tokens_by_subscr_id = {}
for x in hlr_subscrs:
hlr_subscrs_by_id[x['id']] = x
hlr_subscrs_by_ext[x['extension']] = x
del hlr_subscrs
for x in hlr_tokens:
hlr_tokens_by_subscr_id[x['subscriber_id']] = x
del hlr_tokens
web_tokens_by_subscr_id = {}
for x in web_tokens:
web_tokens_by_subscr_id[x['subscriber_id']] = x
del web_tokens
# remove leftover web_tokens and correct inconsistent fields
with web:
for x in web_tokens_by_subscr_id.values():
subscr = hlr_subscrs_by_id.get(x['subscriber_id'], None)
if subscr is None:
web.execute("""
DELETE FROM reg_tokens WHERE subscriber_id = ?
""", (x['subscriber_id'],))
del web_tokens_by_subscr_id[x['subscriber_id']]
continue
if str(x['imsi']) != str(subscr['imsi']) or \
x['extension'] != subscr['extension'] or \
x['tmsi'] != subscr['tmsi'] or \
x['lac'] != subscr['lac']:
web.execute("""
UPDATE reg_tokens
SET imsi = ?, extension = ?, tmsi = ?, lac = ?
WHERE subscriber_id = ?
""", (str(subscr['imsi']), subscr['extension'],
subscr['tmsi'], subscr['lac'], x['subscriber_id']))
# add missing web_tokens
with web:
for x in hlr_tokens_by_subscr_id.values():
subscr = hlr_subscrs_by_id.get(x['subscriber_id'], None)
if subscr is None:
hlr.execute("""
DELETE FROM AuthToken WHERE subscriber_id = ?
""", (x['subscriber_id'],))
del hlr_tokens_by_subscr_id[x['subscriber_id']]
continue
webtoken = web_tokens_by_subscr_id.get(x['subscriber_id'], None)
if webtoken is None:
web.execute("""
INSERT INTO reg_tokens
(subscriber_id, extension, reg_completed, name, email, lac, imsi, token, tmsi)
VALUES
(?, ?, 0, ?, '', ?, ?, ?, ?)
""", (x['subscriber_id'], subscr['extension'], subscr['name'],
subscr['lac'], str(subscr['imsi']), x['token'], subscr['tmsi']))
# authorize subscribers
with hlr:
for x in web_tokens_by_subscr_id.values():
subscr = hlr_subscrs_by_id.get(x['subscriber_id'], None)
if x['reg_completed'] and not subscr['authorized']:
hlr.execute("""
UPDATE Subscriber
SET authorized = 1
WHERE id = ?
""", (x['subscriber_id'],))
# Sync SMS from web to hlr
with hlr:
for sms in web_sms:
subscr = hlr_subscrs_by_ext.get(sms['receiver_ext'])
if subscr is None:
print '%s not found' % sms['receiver_ext']
continue
hlr.execute("""
INSERT INTO SMS
(created, sender_id, receiver_id, reply_path_req, status_rep_req, protocol_id, data_coding_scheme, ud_hdr_ind, text)
VALUES
(?, 1, ?, 0, 0, 0, 0, 0, ?)
""", (sms['created'], subscr['id'], sms['text']))
with web:
for sms in web_sms:
web.execute("""
DELETE FROM sms_queue WHERE id = ?
""", (sms['id'],))
hlr.close()
web.close()

3
include/Makefile.am Normal file
View File

@ -0,0 +1,3 @@
SUBDIRS = \
osmocom \
$(NULL)

View File

@ -0,0 +1,4 @@
SUBDIRS = \
gtphub \
sgsn \
$(NULL)

View File

@ -0,0 +1,3 @@
noinst_HEADERS = \
gtphub.h \
$(NULL)

View File

@ -0,0 +1,521 @@
/* GTP Hub Implementation */
/* (C) 2015 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Neels Hofmeyr
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include <sys/socket.h>
#include <osmocom/core/select.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gsm/apn.h>
/* support */
/* TODO move to osmocom/core/socket.c ? */
#include <netdb.h> /* for IPPROTO_* etc */
struct sgsn_sockaddr {
struct sockaddr_storage a;
socklen_t l;
};
/* TODO move to osmocom/core/socket.c ? */
/*! \brief Initialize a sockaddr
* \param[out] addr Valid sgsn_sockaddr pointer to write result to
* \param[in] family Address Family like AF_INET, AF_INET6, AF_UNSPEC
* \param[in] type Socket type like SOCK_DGRAM, SOCK_STREAM
* \param[in] proto Protocol like IPPROTO_TCP, IPPROTO_UDP
* \param[in] host Remote host name or IP address in string form
* \param[in] port Remote port number in host byte order
* \returns 0 on success, otherwise an error code (from getaddrinfo()).
*
* Copy the first result from a getaddrinfo() call with the given parameters to
* *addr and *addr_len. On error, do not change *addr and return nonzero.
*/
int sgsn_sockaddr_init(struct sgsn_sockaddr *addr,
uint16_t family, uint16_t type, uint8_t proto,
const char *host, uint16_t port);
/* Conveniently pass AF_UNSPEC, SOCK_DGRAM and IPPROTO_UDP to
* sgsn_sockaddr_init(). */
static inline int sgsn_sockaddr_init_udp(struct sgsn_sockaddr *addr,
const char *host, uint16_t port)
{
return sgsn_sockaddr_init(addr, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP,
host, port);
}
/*! \brief convert sockaddr to human readable string.
* \param[out] addr_str Valid pointer to a buffer of length addr_str_len.
* \param[in] addr_str_len Size of buffer addr_str points at.
* \param[out] port_str Valid pointer to a buffer of length port_str_len.
* \param[in] port_str_len Size of buffer port_str points at.
* \param[in] addr Binary representation as returned by sgsn_sockaddr_init().
* \param[in] flags flags as passed to getnameinfo().
* \returns 0 on success, an error code on error.
*
* Return the IPv4 or IPv6 address string and the port (a.k.a. service) string
* representations of the given struct sgsn_sockaddr in two caller provided
* char buffers. Flags of (NI_NUMERICHOST | NI_NUMERICSERV) return numeric
* address and port. Either one of addr_str or port_str may be NULL, in which
* case nothing is returned there.
*
* See also sgsn_sockaddr_to_str() (less flexible, but much more convenient). */
int sgsn_sockaddr_to_strs(char *addr_str, size_t addr_str_len,
char *port_str, size_t port_str_len,
const struct sgsn_sockaddr *addr,
int flags);
/*! \brief concatenate the parts returned by sgsn_sockaddr_to_strs().
* \param[in] addr Binary representation as returned by sgsn_sockaddr_init().
* \param[in] buf A buffer to use for string operations.
* \param[in] buf_len Length of the buffer.
* \returns Address string (in buffer).
*
* Compose a string of the numeric IP-address and port represented by *addr of
* the form "<ip-addr> port <port>". The returned string is valid until the
* next invocation of this function.
*/
const char *sgsn_sockaddr_to_strb(const struct sgsn_sockaddr *addr,
char *buf, size_t buf_len);
/*! \brief conveniently return sgsn_sockaddr_to_strb() in a static buffer.
* \param[in] addr Binary representation as returned by sgsn_sockaddr_init().
* \returns Address string in static buffer.
*
* See sgsn_sockaddr_to_strb().
*
* Note: only one sgsn_sockaddr_to_str() call will work per print/log
* statement. For two or more, use sgsn_sockaddr_to_strb() with a separate
* buffer each.
*/
const char *sgsn_sockaddr_to_str(const struct sgsn_sockaddr *addr);
/*! \brief compare two sgsn_sockaddr.
* \param[in] a The first address to compare.
* \param[in] b The other address to compare.
* \returns 0 if equal, otherwise -1 or 1.
*/
int sgsn_sockaddr_cmp(const struct sgsn_sockaddr *a,
const struct sgsn_sockaddr *b);
/*! \brief Overwrite *dst with *src.
* Like memcpy(), but copy only the valid bytes. */
void sgsn_sockaddr_copy(struct sgsn_sockaddr *dst,
const struct sgsn_sockaddr *src);
/* general */
enum gtphub_plane_idx {
GTPH_PLANE_CTRL = 0,
GTPH_PLANE_USER = 1,
GTPH_PLANE_N
};
enum gtphub_side_idx {
GTPH_SIDE_SGSN = 0,
GTPH_SIDE_GGSN = 1,
GTPH_SIDE_N
};
#define for_each_side(I) for (I = 0; I < GTPH_SIDE_N; I++)
#define for_each_plane(I) for (I = 0; I < GTPH_PLANE_N; I++)
#define for_each_side_and_plane(I,J) for_each_side(I) for_each_plane(J)
static inline int other_side_idx(int side_idx)
{
return (side_idx + 1) & 1;
}
extern const char* const gtphub_plane_idx_names[GTPH_PLANE_N];
extern const uint16_t gtphub_plane_idx_default_port[GTPH_PLANE_N];
extern const char* const gtphub_side_idx_names[GTPH_SIDE_N];
/* A host address in the form that is expected in the 7.7.32 GSN Address IE.
* len is either 4 (IPv4) or 16 (IPv6), any other value is invalid. If no
* address is set, len shall be 0. */
struct gsn_addr {
uint16_t len;
uint8_t buf[16];
};
void gsn_addr_copy(struct gsn_addr *gsna, const struct gsn_addr *src);
int gsn_addr_from_str(struct gsn_addr *gsna, const char *numeric_addr_str);
/* Return gsna in numeric string form, in a static buffer. */
const char *gsn_addr_to_str(const struct gsn_addr *gsna);
/* note: strbuf_len doesn't need to be larger than INET6_ADDRSTRLEN + 1. */
const char *gsn_addr_to_strb(const struct gsn_addr *gsna,
char *strbuf, int strbuf_len);
/* Return 1 on match, zero otherwise. */
int gsn_addr_same(const struct gsn_addr *a, const struct gsn_addr *b);
/* Decode sa to gsna. Return 0 on success. If port is non-NULL, the port number
* from sa is also returned. */
int gsn_addr_from_sockaddr(struct gsn_addr *gsna, uint16_t *port,
const struct sgsn_sockaddr *sa);
/* expiry */
struct expiring_item;
typedef void (*del_cb_t)(struct expiring_item *);
struct expiring_item {
struct llist_head entry;
time_t expiry;
del_cb_t del_cb;
};
struct expiry {
int expiry_in_seconds;
struct llist_head items;
};
/* Initialize an expiry queue. */
void expiry_init(struct expiry *exq, int expiry_in_seconds);
/* Add a new mapping, or restart the expiry timeout for an already listed
* mapping. */
void expiry_add(struct expiry *exq, struct expiring_item *item, time_t now);
/* Initialize to all-empty; must be called before using the item in any way. */
void expiring_item_init(struct expiring_item *item);
/* Remove the given item from its expiry queue, and call item->del_cb, if set.
* This sets item->del_cb to NULL and is harmless when run a second time on the
* same item, so the del_cb may choose to call this function, too, to allow
* deleting items from several code paths. */
void expiring_item_del(struct expiring_item *item);
/* Carry out due expiry of mappings. Must be invoked regularly.
* 'now' is the current clock count in seconds and must correspond to the clock
* count passed to nr_map_add(). A monotonous clock counter should be used. */
int expiry_tick(struct expiry *exq, time_t now);
/* Expire all items. */
void expiry_clear(struct expiry *exq);
/* number map */
/* A number map assigns a "random" mapped number to each user provided number.
* If the same number is requested multiple times, the same mapped number is
* returned.
*
* Number maps plug into possibly shared pools and expiry queues, for example:
*
* mapA -----------+-> pool1 <-+-- mapB
* {10->1, 11->5} | {1, 2, 3, ...} | {10->2, 11->3}
* | |
* | |
* /-> \-> expiry1 <-/
* | (30 seconds)
* |
* mapC -------+-----> pool2 <-+-- mapD
* {10->1, 11->3} {1, 2, 3, ...} | {10->2, 11->5}
* |
* expiry2 <-/
* (60 seconds)
*
* A map contains mappings ("10->1"). Each map needs a number pool, which can
* be shared with other maps. Each new mapping receives a number from the pool,
* which is then unavailable to any other map using the same pool.
*
* A map may point at an expiry queue, in which case all mappings added to it
* are also appended to the expiry queue (using a separate llist entry in the
* mapping). Any number of maps may submit to the same expiry queue, if they
* desire the same expiry timeout. An expiry queue stores the mappings in
* chronological order, so that expiry checking is needed only from the start
* of the queue; hence only mappings with identical expiry timeout can be added
* to the same expiry queue. Upon expiry, a mapping is dropped from the map it
* was submitted at. expiry_tick() needs to be called regularly for each expiry
* queue.
*
* A nr_mapping can be embedded in a larger struct: each mapping can have a
* distinct destructor (del_cb), and each del_cb can figure out the container
* struct's address and free that upon expiry or manual deletion. So in expiry
* queues (and even maps), mappings of different container types can be mixed.
* This can help to drastically reduce the amount of unnecessary visits during
* expiry checking, for the case that no expiry is pending. An expiry queue
* always knows which mappings to expire next, because they are right at the
* start of its list.
*
* Mapping allocation and a del_cb are provided by the caller. If del_cb is
* NULL, no deallocation will be done (allowing statically allocated entries).
*/
typedef unsigned int nr_t;
/* Generator for unused numbers. So far this counts upwards from zero, but the
* implementation may change in the future. Treat this like an opaque struct.
* If this becomes random, the tests need to be fixed. */
struct nr_pool {
nr_t last_nr;
nr_t nr_min;
nr_t nr_max;
};
struct nr_mapping {
struct llist_head entry;
struct expiring_item expiry_entry;
void *origin;
nr_t orig;
nr_t repl;
};
struct nr_map {
struct nr_pool *pool; /* multiple nr_maps can share a nr_pool. */
struct expiry *add_items_to_expiry;
struct llist_head mappings;
};
void nr_pool_init(struct nr_pool *pool, nr_t nr_min, nr_t nr_max);
/* Return the next unused number from the nr_pool. */
nr_t nr_pool_next(struct nr_pool *pool);
/* Initialize the nr_mapping to zero/empty values. */
void nr_mapping_init(struct nr_mapping *mapping);
/* Remove the given mapping from its parent map and expiry queue, and call
* mapping->del_cb, if set. */
void nr_mapping_del(struct nr_mapping *mapping);
/* Initialize an (already allocated) nr_map, and set the map's number pool.
* Multiple nr_map instances may use the same nr_pool. Set the nr_map's expiry
* queue to exq, so that all added mappings are automatically expired after the
* time configured in exq. exq may be NULL to disable automatic expiry. */
void nr_map_init(struct nr_map *map, struct nr_pool *pool,
struct expiry *exq);
/* Add a new entry to the map. mapping->orig, mapping->origin and
* mapping->del_cb must be set before calling this function. The remaining
* fields of *mapping will be overwritten. mapping->repl is set to the next
* available mapped number from map->pool. 'now' is the current clock count in
* seconds; if no map->expiry is used, just pass 0 for 'now'. */
void nr_map_add(struct nr_map *map, struct nr_mapping *mapping,
time_t now);
/* Restart the timeout for the given mapping. mapping must be a member of map.
*/
void nr_map_refresh(struct nr_map *map, struct nr_mapping *mapping,
time_t now);
/* Return a known mapping from nr_orig and the given origin. If nr_orig is
* unknown, return NULL. */
struct nr_mapping *nr_map_get(const struct nr_map *map,
void *origin, nr_t nr_orig);
/* Return a known mapping to nr_repl. If nr_repl is unknown, return NULL. */
struct nr_mapping *nr_map_get_inv(const struct nr_map *map, nr_t nr_repl);
/* Remove all mappings from map. */
void nr_map_clear(struct nr_map *map);
/* Return 1 if map has no entries, 0 otherwise. */
int nr_map_empty(const struct nr_map *map);
/* config */
static const int GTPH_EXPIRE_QUICKLY_SECS = 30; /* TODO is there a spec for this? */
static const int GTPH_EXPIRE_SLOWLY_MINUTES = 6 * 60; /* TODO is there a spec for this? */
struct gtphub_cfg_addr {
const char *addr_str;
uint16_t port;
};
struct gtphub_cfg_bind {
struct gtphub_cfg_addr bind;
};
struct gtphub_cfg {
struct gtphub_cfg_bind to_gsns[GTPH_SIDE_N][GTPH_PLANE_N];
struct gtphub_cfg_addr proxy[GTPH_SIDE_N][GTPH_PLANE_N];
int sgsn_use_sender; /* Use sender, not GSN addr IE with std ports */
};
/* state */
struct gtphub_peer {
struct llist_head entry;
struct llist_head addresses; /* Alternatives, not load balancing. */
struct nr_pool seq_pool;
struct nr_map seq_map;
};
struct gtphub_peer_addr {
struct llist_head entry;
struct gtphub_peer *peer;
struct gsn_addr addr;
struct llist_head ports;
};
struct gtphub_peer_port {
struct llist_head entry;
struct gtphub_peer_addr *peer_addr;
uint16_t port;
unsigned int ref_count; /* references from other peers' seq_maps */
struct sgsn_sockaddr sa; /* a "cache" for (peer_addr->addr, port) */
int last_restart_count; /* 0..255 = valid, all else means unknown */
struct rate_ctr_group *counters_io;
};
struct gtphub_tunnel_endpoint {
struct gtphub_peer_port *peer;
uint32_t tei_orig; /* from/to peer */
struct rate_ctr_group *counters_io;
};
struct gtphub_tunnel {
struct llist_head entry;
struct expiring_item expiry_entry;
uint32_t tei_repl; /* unique TEI to replace peers' TEIs */
struct gtphub_tunnel_endpoint endpoint[GTPH_SIDE_N][GTPH_PLANE_N];
};
struct gtphub_bind {
struct gsn_addr local_addr;
uint16_t local_port;
struct osmo_fd ofd;
/* list of struct gtphub_peer */
struct llist_head peers;
const char *label; /* For logging */
struct rate_ctr_group *counters_io;
};
struct gtphub_resolved_ggsn {
struct llist_head entry;
struct expiring_item expiry_entry;
/* The APN OI, the Operator Identifier, is the combined address,
* including parts of the IMSI and APN NI, and ending with ".gprs". */
char apn_oi_str[APN_MAXLEN+1];
/* Which address and port we resolved that to. */
struct gtphub_peer_port *peer;
};
struct gtphub {
struct gtphub_bind to_gsns[GTPH_SIDE_N][GTPH_PLANE_N];
/* pointers to an entry of to_gsns[s][p].peers */
struct gtphub_peer_port *proxy[GTPH_SIDE_N][GTPH_PLANE_N];
/* The TEI numbers will simply wrap and be reused, which will work out
* in practice. Problems would arise if one given peer maintained the
* same TEI for a time long enough for the TEI nr map to wrap an entire
* uint32_t; if a new TEI were mapped every second, this would take
* more than 100 years (in which a single given TEI must not time out)
* to cause a problem. */
struct nr_pool tei_pool;
struct llist_head tunnels; /* struct gtphub_tunnel */
struct llist_head pending_deletes; /* opaque (gtphub.c) */
struct llist_head ggsn_lookups; /* opaque (gtphub_ares.c) */
struct llist_head resolved_ggsns; /* struct gtphub_resolved_ggsn */
struct osmo_timer_list gc_timer;
struct expiry expire_quickly;
struct expiry expire_slowly;
uint8_t restart_counter;
int sgsn_use_sender;
};
struct gtp_packet_desc;
/* api */
int gtphub_vty_init(struct gtphub *global_hub, struct gtphub_cfg *global_cfg);
int gtphub_cfg_read(struct gtphub_cfg *cfg, const char *config_file);
/* Initialize and start gtphub: bind to ports, run expiry timers. */
int gtphub_start(struct gtphub *hub, struct gtphub_cfg *cfg,
uint8_t restart_counter);
/* Close all sockets, expire all maps and peers and free all allocations. The
* struct is then unusable, unless gtphub_start() is run on it again. */
void gtphub_stop(struct gtphub *hub);
time_t gtphub_now(void);
/* Remove expired items, empty peers, ... */
void gtphub_gc(struct gtphub *hub, time_t now);
/* Return the string of the first address for this peer. */
const char *gtphub_peer_str(struct gtphub_peer *peer);
/* Return a human readable description of tun in a static buffer. */
const char *gtphub_tunnel_str(struct gtphub_tunnel *tun);
/* Return 1 if all of tun's endpoints are fully established, 0 otherwise. */
int gtphub_tunnel_complete(struct gtphub_tunnel *tun);
int gtphub_handle_buf(struct gtphub *hub,
unsigned int side_idx,
unsigned int port_idx,
const struct sgsn_sockaddr *from_addr,
uint8_t *buf,
size_t received,
time_t now,
uint8_t **reply_buf,
struct osmo_fd **to_ofd,
struct sgsn_sockaddr *to_addr);
struct gtphub_peer_port *gtphub_port_have(struct gtphub *hub,
struct gtphub_bind *bind,
const struct gsn_addr *addr,
uint16_t port);
struct gtphub_peer_port *gtphub_port_find_sa(const struct gtphub_bind *bind,
const struct sgsn_sockaddr *addr);
void gtphub_resolved_ggsn(struct gtphub *hub, const char *apn_oi_str,
struct gsn_addr *resolved_addr,
time_t now);
const char *gtphub_port_str(struct gtphub_peer_port *port);
int gtphub_write(const struct osmo_fd *to,
const struct sgsn_sockaddr *to_addr,
const uint8_t *buf, size_t buf_len);

View File

@ -0,0 +1,37 @@
noinst_HEADERS = \
apn.h \
auth.h \
common.h \
crc24.h \
debug.h \
gprs_bssgp.h \
gprs_gmm.h \
gprs_gmm_fsm.h \
gprs_gmm_attach.h \
gprs_mm_state_gb_fsm.h \
gprs_mm_state_iu_fsm.h \
gprs_ns.h \
gprs_llc.h \
gprs_llc_xid.h \
gprs_ranap.h \
gprs_sm.h \
gprs_sndcp_comp.h \
gprs_sndcp_dcomp.h \
gprs_sndcp.h \
gprs_sndcp_pcomp.h \
gprs_sndcp_xid.h \
gprs_subscriber.h \
gprs_utils.h \
gtp.h \
gtp_ggsn.h \
gtp_mme.h \
mmctx.h \
pdpctx.h \
sgsn.h \
sgsn_rim.h \
signal.h \
slhc.h \
v42bis.h \
v42bis_private.h \
vty.h \
$(NULL)

View File

@ -0,0 +1,20 @@
#pragma once
#include <osmocom/core/linuxlist.h>
struct sgsn_ggsn_ctx;
#define GSM_APN_LENGTH 102
struct apn_ctx {
struct llist_head list;
struct sgsn_ggsn_ctx *ggsn;
char *name;
char *imsi_prefix;
char *description;
};
struct apn_ctx *sgsn_apn_ctx_find_alloc(const char *name, const char *imsi_prefix);
void sgsn_apn_ctx_free(struct apn_ctx *actx);
struct apn_ctx *sgsn_apn_ctx_by_name(const char *name, const char *imsi_prefix);
struct apn_ctx *sgsn_apn_ctx_match(const char *name, const char *imsi_prefix);

View File

@ -0,0 +1,39 @@
/* MS authorization and subscriber data handling */
#pragma once
#include <osmocom/core/linuxlist.h>
struct sgsn_config;
struct sgsn_instance;
struct sgsn_mm_ctx;
struct gsm_auth_tuple;
/* Authorization/ACL handling */
enum sgsn_auth_state {
SGSN_AUTH_UNKNOWN,
SGSN_AUTH_AUTHENTICATE,
SGSN_AUTH_UMTS_RESYNC,
SGSN_AUTH_ACCEPTED,
SGSN_AUTH_REJECTED
};
extern const struct value_string *sgsn_auth_state_names;
void sgsn_auth_init(struct sgsn_instance *sgsn);
/* Request authorization */
enum sgsn_auth_state sgsn_auth_state(struct sgsn_mm_ctx *mm);
int sgsn_auth_request(struct sgsn_mm_ctx *mm);
void sgsn_auth_update(struct sgsn_mm_ctx *mm);
struct gsm_auth_tuple *sgsn_auth_get_tuple(struct sgsn_mm_ctx *mmctx,
unsigned key_seq);
/*
* Authorization/ACL handling
*/
struct imsi_acl_entry {
struct llist_head list;
char imsi[OSMO_IMSI_BUF_SIZE];
};
struct imsi_acl_entry *sgsn_acl_lookup(const char *imsi, const struct sgsn_config *cfg);
int sgsn_acl_add(const char *imsi, struct sgsn_config *cfg);
int sgsn_acl_del(const char *imsi, struct sgsn_config *cfg);

View File

@ -0,0 +1,6 @@
#pragma once
enum nsap_addr_enc {
NSAP_ADDR_ENC_X213,
NSAP_ADDR_ENC_V4RAW,
};

View File

@ -5,6 +5,6 @@
#define INIT_CRC24 0xffffff
uint32_t crc24_calc(uint32_t fcs, uint8_t *cp, unsigned int len);
uint32_t crc24_calc(uint32_t fcs, const uint8_t *cp, unsigned int len);
#endif

View File

@ -0,0 +1,33 @@
#pragma once
#include <stdio.h>
#include <osmocom/core/linuxlist.h>
#define DEBUG
#include <osmocom/core/logging.h>
/* Debug Areas of the code */
enum {
DMM,
DPAG,
DMEAS,
DREF,
DGPRS,
DLLC,
DSNDCP,
DSLHC,
DCTRL,
DFILTER,
DGTPHUB,
DRANAP,
DSUA,
DV42BIS,
DIUCS,
DSIGTRAN,
DGTP,
DOBJ,
DRIM,
Debug_LastEntry,
};
extern const struct log_info log_info;

View File

@ -0,0 +1,12 @@
#pragma once
#include <osmocom/core/msgb.h>
/* Called by bssgp layer when a prim is received from lower layers. */
int sgsn_bssgp_rx_prim(struct osmo_prim_hdr *oph);
/* called by the bssgp layer to send NS PDUs */
int sgsn_bssgp_dispatch_ns_unitdata_req_cb(void *ctx, struct msgb *msg);
/* page a MS in its routing area */
int sgsn_bssgp_page_ps_ra(struct sgsn_mm_ctx *mmctx);

View File

@ -0,0 +1,56 @@
#ifndef _GPRS_GMM_H
#define _GPRS_GMM_H
#include <stdbool.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/crypt/auth.h>
struct sgsn_mm_ctx;
struct gprs_llc_llme;
int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm,
const struct osmo_auth_vector *vec,
uint8_t key_seq, bool force_standby);
int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme,
bool drop_cipherable);
int gsm0408_rcv_gmm(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
struct gprs_llc_llme *llme, bool drop_cipherable);
int gsm48_gmm_sendmsg(struct msgb *msg, int command,
struct sgsn_mm_ctx *mm, bool encryptable);
int gsm0408_gprs_force_reattach(struct sgsn_mm_ctx *mmctx);
int gsm0408_gprs_force_reattach_oldmsg(struct msgb *msg,
struct gprs_llc_llme *llme);
void gsm0408_gprs_access_granted(struct sgsn_mm_ctx *mmctx);
void gsm0408_gprs_access_denied(struct sgsn_mm_ctx *mmctx, int gmm_cause);
void gsm0408_gprs_access_cancelled(struct sgsn_mm_ctx *mmctx, int gmm_cause);
void gsm0408_gprs_authenticate(struct sgsn_mm_ctx *mmctx);
int gprs_gmm_rx_suspend(struct gprs_ra_id *raid, uint32_t tlli);
int gprs_gmm_rx_resume(struct gprs_ra_id *raid, uint32_t tlli,
uint8_t suspend_ref);
int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme,
bool drop_cipherable);
/* Has to be called whenever any PDU (signaling, data, ...) has been received */
void gprs_gb_recv_pdu(struct sgsn_mm_ctx *mmctx, const struct msgb *msg);
time_t gprs_max_time_to_idle(void);
int gsm48_tx_gmm_id_req(struct sgsn_mm_ctx *mm, uint8_t id_type);
int gsm48_tx_gmm_att_rej(struct sgsn_mm_ctx *mm,
uint8_t gmm_cause);
int gsm48_tx_gmm_att_ack(struct sgsn_mm_ctx *mm);
int gprs_gmm_attach_req_ies(struct msgb *a, struct msgb *b);
int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx);
/* TODO: move extract_subscr_* when gsm48_gmm_authorize() got removed */
void extract_subscr_msisdn(struct sgsn_mm_ctx *ctx);
void extract_subscr_hlr(struct sgsn_mm_ctx *ctx);
void msgid2mmctx(struct sgsn_mm_ctx *mm, const struct msgb *msg);
void mmctx2msgid(struct msgb *msg, const struct sgsn_mm_ctx *mm);
#endif /* _GPRS_GMM_H */

View File

@ -0,0 +1,39 @@
#ifndef GPRS_GMM_ATTACH_H
#define GPRS_GMM_ATTACH_H
#include <osmocom/core/fsm.h>
struct sgsn_mm_ctx;
enum gmm_attach_req_fsm_states {
ST_INIT,
ST_IDENTIY,
ST_RETRIEVE_AUTH,
ST_AUTH,
ST_ASK_VLR,
ST_IU_SECURITY_CMD,
ST_ACCEPT,
ST_REJECT
};
enum gmm_attach_req_fsm_events {
E_ATTACH_REQ_RECV,
E_IDEN_RESP_RECV,
E_AUTH_RESP_RECV_SUCCESS,
E_AUTH_RESP_RECV_RESYNC,
E_IU_SECURITY_CMD_COMPLETE,
E_ATTACH_ACCEPTED,
E_ATTACH_ACCEPT_SENT,
E_ATTACH_COMPLETE_RECV,
E_REJECT,
E_VLR_ANSWERED,
};
#define GMM_DISCARD_MS_WITHOUT_REJECT -1
extern const struct value_string gmm_attach_req_fsm_event_names[];
extern struct osmo_fsm gmm_attach_req_fsm;
void gmm_att_req_free(struct sgsn_mm_ctx *mm);
#endif // GPRS_GMM_ATTACH_H

View File

@ -0,0 +1,44 @@
#pragma once
#include <osmocom/core/fsm.h>
#include <osmocom/sgsn/mmctx.h>
struct gprs_llc_llme;
/* 3GPP TS 24.008 § 4.1.3.3 GMM mobility management states on the network side */
enum gmm_fsm_states {
ST_GMM_DEREGISTERED, /* 4.1.3.3.1.1 */
ST_GMM_COMMON_PROC_INIT, /* 4.1.3.3.1.2 */
ST_GMM_REGISTERED_NORMAL, /* 4.1.3.3.2.1 */
ST_GMM_REGISTERED_SUSPENDED, /* 4.1.3.3.2.2 */
ST_GMM_DEREGISTERED_INIT, /* 4.1.3.3.1.4 */
};
enum gmm_fsm_events {
E_GMM_COMMON_PROC_INIT_REQ,
/* E_GMM_COMMON_PROC_FAILED, NOT USED */
/* E_GMM_LOWER_LAYER_FAILED, NOT USED */
E_GMM_COMMON_PROC_SUCCESS,
E_GMM_ATTACH_SUCCESS,
/* E_GMM_NET_INIT_DETACH_REQ, NOT USED */
/* E_GMM_MS_INIT_DETACH_REQ, NOT USED */
/* E_GMM_DETACH_ACCEPTED, */
E_GMM_SUSPEND,
E_GMM_RESUME,
E_GMM_CLEANUP,
E_GMM_RAT_CHANGE,
};
struct gmm_rat_change_data {
enum sgsn_ran_type new_ran_type;
struct gprs_llc_llme *llme;
};
static inline bool gmm_fsm_is_registered(struct osmo_fsm_inst *fi)
{
return fi->state == ST_GMM_REGISTERED_NORMAL ||
fi->state == ST_GMM_REGISTERED_SUSPENDED;
}
extern struct osmo_fsm gmm_fsm;

View File

@ -1,8 +1,15 @@
#ifndef _GPRS_LLC_H
#define _GPRS_LLC_H
#pragma once
#include <stdint.h>
#include <openbsc/gprs_sgsn.h>
#include <stdbool.h>
#include <osmocom/core/timer.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/crypt/gprs_cipher.h>
#include <osmocom/sgsn/gprs_llc_xid.h>
struct sgsn_mm_ctx;
/* Section 4.7 LLC Layer Structure */
enum gprs_llc_sapi {
@ -27,6 +34,25 @@ enum gprs_llc_u_cmd {
GPRS_LLC_U_NULL_CMD = 0x00,
};
/* Section 6.4.1.6 / Table 6 */
enum gprs_llc_xid_type {
GPRS_LLC_XID_T_VERSION = 0,
GPRS_LLC_XID_T_IOV_UI = 1,
GPRS_LLC_XID_T_IOV_I = 2,
GPRS_LLC_XID_T_T200 = 3,
GPRS_LLC_XID_T_N200 = 4,
GPRS_LLC_XID_T_N201_U = 5,
GPRS_LLC_XID_T_N201_I = 6,
GPRS_LLC_XID_T_mD = 7,
GPRS_LLC_XID_T_mU = 8,
GPRS_LLC_XID_T_kD = 9,
GPRS_LLC_XID_T_kU = 10,
GPRS_LLC_XID_T_L3_PAR = 11,
GPRS_LLC_XID_T_RESET = 12,
};
extern const struct value_string gprs_llc_xid_type_names[];
/* TS 04.64 Section 7.1.2 Table 7: LLC layer primitives (GMM/SNDCP/SMS/TOM) */
/* TS 04.65 Section 5.1.2 Table 2: Service primitives used by SNDCP */
enum gprs_llc_primitive {
@ -70,11 +96,13 @@ enum gprs_llc_lle_state {
GPRS_LLES_LOCAL_REL = 6, /* Local Release */
GPRS_LLES_TIMER_REC = 7, /* Timer Recovery */
};
extern const struct value_string gprs_llc_lle_state_names[];
enum gprs_llc_llme_state {
GPRS_LLMS_UNASSIGNED = 1, /* No TLLI yet */
GPRS_LLMS_ASSIGNED = 2, /* TLLI assigned */
};
extern const struct value_string gprs_llc_llme_state_names[];
/* Section 8.9.9 LLC layer parameter default values */
struct gprs_llc_params {
@ -89,13 +117,13 @@ struct gprs_llc_params {
uint16_t kU;
};
/* Section 4.7.1: Logical Link Entity: One per DLCI (TLLI + SAPI) */
/* 3GPP TS 44.064 § 4.7.1: Logical Link Entity: One per DLCI (TLLI + SAPI) */
struct gprs_llc_lle {
struct llist_head list;
uint32_t sapi;
struct gprs_llc_llme *llme;
struct gprs_llc_llme *llme; /* backpointer to the Logical Link Management Entity */
enum gprs_llc_lle_state state;
@ -109,6 +137,10 @@ struct gprs_llc_lle {
uint16_t vu_send;
uint16_t vu_recv;
/* non-standard LLC state */
uint16_t vu_recv_last;
uint16_t vu_recv_duplicates;
/* Overflow Counter for ABM */
uint32_t oc_i_send;
uint32_t oc_i_recv;
@ -120,10 +152,18 @@ struct gprs_llc_lle {
unsigned int retrans_ctr;
struct gprs_llc_params params;
/* Copy of the XID fields we have sent with the last
* network originated XID-Request. Since the phone
* may strip the optional fields in the confirmation
* we need to remeber those fields in order to be
* able to create the compression entity. */
struct llist_head *xid;
};
#define NUM_SAPIS 16
/* 3GPP TS 44.064 § 4.7.3: Logical Link Management Entity: One per TLLI */
struct gprs_llc_llme {
struct llist_head list;
@ -134,29 +174,119 @@ struct gprs_llc_llme {
/* Crypto parameters */
enum gprs_ciph_algo algo;
uint8_t kc[8];
uint8_t kc[16];
uint8_t cksn;
/* 3GPP TS 44.064 § 8.9.2: */
uint32_t iov_ui;
/* over which BSSGP BTS ctx do we need to transmit */
uint16_t bvci;
uint16_t nsei;
struct gprs_llc_lle lle[NUM_SAPIS];
/* Compression entities */
struct {
/* In these two list_heads we will store the
* data and protocol compression entities,
* together with their compression states */
struct llist_head *proto;
struct llist_head *data;
} comp;
/* Internal management */
uint32_t age_timestamp;
};
#define GPRS_LLME_RESET_AGE (0)
/* 3GPP TS 44.064 § 8.3 TLLI assignment procedures */
#define TLLI_UNASSIGNED (0xffffffff)
extern struct llist_head gprs_llc_llmes;
/* LLC low level types */
enum gprs_llc_cmd {
GPRS_LLC_NULL,
GPRS_LLC_RR,
GPRS_LLC_ACK,
GPRS_LLC_RNR,
GPRS_LLC_SACK,
GPRS_LLC_DM,
GPRS_LLC_DISC,
GPRS_LLC_UA,
GPRS_LLC_SABM,
GPRS_LLC_FRMR,
GPRS_LLC_XID,
GPRS_LLC_UI,
};
struct gprs_llc_hdr_parsed {
uint8_t sapi;
uint8_t is_cmd:1,
ack_req:1,
is_encrypted:1;
uint32_t seq_rx;
uint32_t seq_tx;
uint32_t fcs;
uint32_t fcs_calc;
uint8_t *data;
uint16_t data_len;
uint16_t crc_length;
enum gprs_llc_cmd cmd;
};
/* BSSGP-UL-UNITDATA.ind */
int gprs_llc_rcvmsg(struct msgb *msg, struct tlv_parsed *tv);
/* LL-UNITDATA.req */
int gprs_llc_tx_ui(struct msgb *msg, uint8_t sapi, int command,
void *mmctx);
struct sgsn_mm_ctx *mmctx, bool encryptable);
/* Chapter 7.2.1.2 LLGMM-RESET.req */
int gprs_llgmm_reset(struct gprs_llc_llme *llme);
int gprs_llgmm_reset_oldmsg(struct msgb* oldmsg, uint8_t sapi,
struct gprs_llc_llme *llme);
/* Set of LL-XID negotiation (See also: TS 101 351, Section 7.2.2.4) */
int gprs_ll_xid_req(struct gprs_llc_lle *lle,
struct gprs_llc_xid_field *l3_xid_field);
/* 04.64 Chapter 7.2.1.1 LLGMM-ASSIGN */
int gprs_llgmm_assign(struct gprs_llc_llme *llme,
uint32_t old_tlli, uint32_t new_tlli,
enum gprs_ciph_algo alg, const uint8_t *kc);
uint32_t old_tlli, uint32_t new_tlli);
int gprs_llgmm_unassign(struct gprs_llc_llme *llme);
int gprs_llc_init(const char *cipher_plugin_path);
int gprs_llc_vty_init(void);
#endif
/**
* \short Check if N(U) should be considered a retransmit
*
* Implements the range check as of GSM 04.64 8.4.2
* Receipt of unacknowledged information.
*
* @returns Returns 1 if (V(UR)-32) <= N(U) < V(UR)
* @param nu N(U) unconfirmed sequence number of the UI frame
* @param vur V(UR) unconfirmend received state variable
*/
static inline int gprs_llc_is_retransmit(uint16_t nu, uint16_t vur)
{
int delta = (vur - nu) & 0x1ff;
return 0 < delta && delta < 32;
}
/* LLC low level functions */
void gprs_llme_copy_key(const struct sgsn_mm_ctx *mm, struct gprs_llc_llme *llme);
/* parse a GPRS LLC header, also check for invalid frames */
int gprs_llc_hdr_parse(struct gprs_llc_hdr_parsed *ghp,
uint8_t *llc_hdr, int len);
void gprs_llc_hdr_dump(struct gprs_llc_hdr_parsed *gph, struct gprs_llc_lle *lle);
int gprs_llc_fcs(const uint8_t *data, unsigned int len);
/* LLME handling routines */
struct llist_head *gprs_llme_list(void);
struct gprs_llc_lle *gprs_lle_get_or_create(const uint32_t tlli, uint8_t sapi);

View File

@ -0,0 +1,57 @@
/* GPRS LLC XID field encoding/decoding as per 3GPP TS 44.064 */
/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
/* 3GPP TS 44.064 6.4.1.6 Exchange Identification (XID)
command/response parameter field */
struct gprs_llc_xid_field {
struct llist_head list;
uint8_t type; /* See also Table 6: LLC layer parameter
negotiation */
uint8_t *data; /* Payload data (memory is owned by the
* creator of the struct) */
unsigned int data_len; /* Payload length */
};
/* Transform a list with XID fields into a XID message (dst) */
int gprs_llc_compile_xid(uint8_t *dst, int dst_maxlen,
const struct llist_head *xid_fields);
/* Transform a XID message (dst) into a list of XID fields */
struct llist_head *gprs_llc_parse_xid(const void *ctx, const uint8_t *src,
int src_len);
/* Create a duplicate of an XID-Field */
struct gprs_llc_xid_field *gprs_llc_dup_xid_field(const void *ctx,
const struct gprs_llc_xid_field *xid_field);
/* Copy an llist with xid fields */
struct llist_head *gprs_llc_copy_xid(const void *ctx,
const struct llist_head *xid_fields);
/* Dump a list with XID fields (Debug) */
void gprs_llc_dump_xid_fields(const struct llist_head *xid_fields,
unsigned int logl);

View File

@ -0,0 +1,25 @@
#pragma once
#include <osmocom/core/fsm.h>
struct sgsn_mm_ctx;
/* TS 23.060 § 6.1.1 Mobility Management States (A/Gb mode) */
enum mm_state_gb_fsm_states {
ST_MM_IDLE,
ST_MM_READY,
ST_MM_STANDBY
};
enum mm_state_gb_fsm_events {
E_MM_GPRS_ATTACH,
E_MM_GPRS_DETACH, /* MS becomes detached: due to Detach Req, RAU reject, implicit detach, etc. */
E_MM_PDU_RECEPTION,
E_MM_READY_TIMER_EXPIRY,
/* E_FORCE_TO_STANDBY, TODO: not used */
/* E_ABNSORMAL_RLC_CONDITION, TODO: not used */
E_MM_RA_UPDATE,
};
extern struct osmo_fsm mm_state_gb_fsm;

View File

@ -0,0 +1,22 @@
#pragma once
#include <osmocom/core/fsm.h>
struct sgsn_mm_ctx;
/* TS 23.060 § 6.1.2 Mobility Management States (Iu mode) */
enum mm_state_iu_fsm_states {
ST_PMM_DETACHED,
ST_PMM_CONNECTED,
ST_PMM_IDLE
};
enum mm_state_iu_fsm_events {
E_PMM_PS_ATTACH,
E_PMM_PS_DETACH, /* UE becomes detached: due to Detach Req, RAU reject, implicit detach, etc. */
E_PMM_PS_CONN_RELEASE,
E_PMM_PS_CONN_ESTABLISH,
E_PMM_RA_UPDATE, /* = Serving RNC relocation */
};
extern struct osmo_fsm mm_state_iu_fsm;

View File

@ -0,0 +1,9 @@
#pragma once
#include <stdbool.h>
#include <osmocom/core/msgb.h>
#include <osmocom/sgsn/gprs_llc.h>
/* called by the ns layer */
int gprs_ns_prim_cb(struct osmo_prim_hdr *oph, void *ctx);

View File

@ -0,0 +1,36 @@
#pragma once
#include <osmocom/core/msgb.h>
#ifdef BUILD_IU
#include <osmocom/ranap/ranap_ies_defs.h>
#include <osmocom/ranap/ranap_msg_factory.h>
#include <osmocom/ranap/iu_client.h>
struct sgsn_mm_ctx;
struct sgsn_pdp_ctx;
void activate_pdp_rabs(struct sgsn_mm_ctx *ctx);
int sgsn_ranap_iu_event(struct ranap_ue_conn_ctx *ctx, enum ranap_iu_event_type type, void *data);
int iu_rab_act_ps(uint8_t rab_id, struct sgsn_pdp_ctx *pdp);
/* free the Iu UE context */
void sgsn_ranap_iu_free(struct sgsn_mm_ctx *ctx);
/* send a Iu Release Command and free afterwards the UE context */
void sgsn_ranap_iu_release_free(struct sgsn_mm_ctx *ctx,
const struct RANAP_Cause *cause);
int gsm0408_gprs_rcvmsg_iu(struct msgb *msg, struct gprs_ra_id *ra_id, uint16_t *sai);
#else /* ifndef BUILD_IU */
inline static void sgsn_ranap_iu_free(void *ctx) {};
inline static void sgsn_ranap_iu_release_free(void *ctx, void *cause) {};
#endif /* BUILD_IU*/
struct ranap_ue_conn_ctx;
/* On RANAP, Returns pointer to he associated ranap_ue_conn_ctx in msg, filled
* in by osmo-iuh's iu_recv_cb().
* On Gb, returns NULL */
#define MSG_IU_UE_CTX(msg) ((struct ranap_ue_conn_ctx *)(msg)->dst)
#define MSG_IU_UE_CTX_SET(msg, val) (msg)->dst = (val)

View File

@ -1,19 +1,18 @@
#ifndef _GPRS_GMM_H
#define _GPRS_GMM_H
#pragma once
#include <osmocom/core/msgb.h>
#include <openbsc/gprs_sgsn.h>
int gsm48_tx_gsm_deact_pdp_req(struct sgsn_pdp_ctx *pdp, uint8_t sm_cause);
struct sgsn_mm_ctx;
struct sgsn_pdp_ctx;
struct gprs_llc_llme;
int gsm48_tx_gsm_deact_pdp_req(struct sgsn_pdp_ctx *pdp, uint8_t sm_cause, bool teardown);
int gsm48_tx_gsm_act_pdp_rej(struct sgsn_mm_ctx *mm, uint8_t tid,
uint8_t cause, uint8_t pco_len, uint8_t *pco_v);
int gsm48_tx_gsm_act_pdp_acc(struct sgsn_pdp_ctx *pdp);
int gsm48_tx_gsm_deact_pdp_acc(struct sgsn_pdp_ctx *pdp);
int gsm0408_gprs_rcvmsg(struct msgb *msg, struct gprs_llc_llme *llme);
void pdp_ctx_detach_mm_ctx(struct sgsn_pdp_ctx *pdp);
int gprs_gmm_rx_suspend(struct gprs_ra_id *raid, uint32_t tlli);
int gprs_gmm_rx_resume(struct gprs_ra_id *raid, uint32_t tlli,
uint8_t suspend_ref);
#endif /* _GPRS_GMM_H */
int gsm0408_rcv_gsm(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
struct gprs_llc_llme *llme);

View File

@ -0,0 +1,101 @@
#ifndef _INT_SNDCP_H
#define _INT_SNDCP_H
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/gsm48.h>
struct gprs_llc_lle;
/* A fragment queue header, maintaining list of fragments for one N-PDU */
struct defrag_state {
/* PDU number for which the defragmentation state applies */
uint16_t npdu;
/* highest segment number we have received so far */
uint8_t highest_seg;
/* bitmask of the segments we already have */
uint32_t seg_have;
/* do we still expect more segments? */
unsigned int no_more;
/* total length of all segments together */
unsigned int tot_len;
/* linked list of defrag_queue_entry: one for each fragment */
struct llist_head frag_list;
struct osmo_timer_list timer;
/* Holds state to know which compression mode is used
* when the packet is re-assembled */
uint8_t pcomp;
uint8_t dcomp;
/* Holds the pointers to the compression entity list
* that is used when the re-assembled packet is decompressed */
struct llist_head *proto;
struct llist_head *data;
};
/* See 6.7.1.2 Reassembly */
enum sndcp_rx_state {
SNDCP_RX_S_FIRST,
SNDCP_RX_S_SUBSEQ,
SNDCP_RX_S_DISCARD,
};
struct gprs_sndcp_entity {
struct llist_head list;
/* FIXME: move this RA_ID up to the LLME or even higher */
struct gprs_ra_id ra_id;
/* reference to the LLC Entity below this SNDCP entity */
struct gprs_llc_lle *lle;
/* The NSAPI we shall use on top of LLC */
uint8_t nsapi;
/* NPDU number for the GTP->SNDCP side */
uint16_t tx_npdu_nr;
/* SNDCP eeceiver state */
enum sndcp_rx_state rx_state;
/* The defragmentation queue */
struct defrag_state defrag;
};
extern struct llist_head gprs_sndcp_entities;
int gprs_sndcp_vty_init(void);
/* Set of SNDCP-XID negotiation (See also: TS 144 065,
* Section 6.8 XID parameter negotiation) */
int sndcp_sn_xid_req(struct gprs_llc_lle *lle, uint8_t nsapi);
/* Process SNDCP-XID indication (See also: TS 144 065,
* Section 6.8 XID parameter negotiation) */
int sndcp_sn_xid_ind(struct gprs_llc_xid_field *xid_field_indication,
struct gprs_llc_xid_field *xid_field_response,
const struct gprs_llc_lle *lle);
/* Process SNDCP-XID indication
* (See also: TS 144 065, Section 6.8 XID parameter negotiation) */
int sndcp_sn_xid_conf(struct gprs_llc_xid_field *xid_field_conf,
struct gprs_llc_xid_field *xid_field_request,
struct gprs_llc_lle *lle);
/* Clean up all gprs_sndcp_entities related to llme (OS#4824) */
void gprs_sndcp_sm_deactivate_ind_by_llme(const struct gprs_llc_llme *llme);
/* Called by SNDCP when it has received/re-assembled a N-PDU */
int sndcp_sn_unitdata_ind(struct gprs_sndcp_entity *sne, struct msgb *msg,
uint32_t npdu_len, uint8_t *npdu);
int sndcp_sn_unitdata_req(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t nsapi,
void *mmcontext);
/* Entry point for the SNSM-ACTIVATE.indication */
int sndcp_sm_activate_ind(struct gprs_llc_lle *lle, uint8_t nsapi);
/* Entry point for the SNSM-DEACTIVATE.indication */
int sndcp_sm_deactivate_ind(const struct gprs_llc_lle *lle, uint8_t nsapi);
int sndcp_ll_unitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle,
uint8_t *hdr, uint16_t len);
#endif /* INT_SNDCP_H */

View File

@ -0,0 +1,82 @@
/* GPRS SNDCP header compression entity management tools */
/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/sgsn/gprs_sndcp_xid.h>
/* Header / Data compression entity */
struct gprs_sndcp_comp {
struct llist_head list;
/* Serves as an ID in case we want to delete this entity later */
unsigned int entity; /* see also: 6.5.1.1.3 and 6.6.1.1.3 */
/* Specifies to which NSAPIs the compression entity is assigned */
uint8_t nsapi_len; /* Number of applicable NSAPIs (default 0) */
uint8_t nsapi[MAX_NSAPI]; /* Applicable NSAPIs (default 0) */
/* Assigned pcomp values */
uint8_t comp_len; /* Number of contained PCOMP / DCOMP values */
uint8_t comp[MAX_COMP]; /* see also: 6.5.1.1.5 and 6.6.1.1.5 */
/* Algorithm parameters */
union gprs_sndcp_comp_algo algo;
enum gprs_sndcp_xid_param_types compclass; /* See gprs_sndcp_xid.h/c */
void *state; /* Algorithm status and parameters */
};
#define MAX_COMP 16 /* Maximum number of possible pcomp/dcomp values */
#define MAX_NSAPI 11 /* Maximum number usable NSAPIs */
/* Allocate a compression enitiy list */
struct llist_head *gprs_sndcp_comp_alloc(const void *ctx);
/* Free a compression entitiy list */
void gprs_sndcp_comp_free(struct llist_head *comp_entities);
/* Delete a compression entity */
void gprs_sndcp_comp_delete(struct llist_head *comp_entities, unsigned int entity);
/* Create and Add a new compression entity
* (returns a pointer to the compression entity that has just been created) */
struct gprs_sndcp_comp *gprs_sndcp_comp_add(const void *ctx,
struct llist_head *comp_entities,
const struct gprs_sndcp_comp_field
*comp_field);
/* Find which compression entity handles the specified pcomp/dcomp */
struct gprs_sndcp_comp *gprs_sndcp_comp_by_comp(const struct llist_head
*comp_entities, uint8_t comp);
/* Find which compression entity handles the specified nsapi */
struct gprs_sndcp_comp *gprs_sndcp_comp_by_nsapi(const struct llist_head
*comp_entities, uint8_t nsapi);
/* Find a comp_index for a given pcomp/dcomp value */
uint8_t gprs_sndcp_comp_get_idx(const struct gprs_sndcp_comp *comp_entity,
uint8_t comp);
/* Find a pcomp/dcomp value for a given comp_index */
uint8_t gprs_sndcp_comp_get_comp(const struct gprs_sndcp_comp *comp_entity,
uint8_t comp_index);

View File

@ -0,0 +1,53 @@
/* GPRS SNDCP data compression handler */
/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/sgsn/gprs_sndcp_comp.h>
/* Note: The decompressed packet may have a maximum size of:
* Return value * MAX_DATADECOMPR_FAC */
#define MAX_DATADECOMPR_FAC 10
/* Note: In unacknowledged mode (SN_UNITDATA), the comression state is reset
* for every NPDU. The compressor needs a reasonably large payload to operate
* effectively (yield positive compression gain). For packets shorter than 100
* byte, no positive compression gain can be expected so we will skip the
* compression for short packets. */
#define MIN_COMPR_PAYLOAD 100
/* Initalize data compression */
int gprs_sndcp_dcomp_init(const void *ctx, struct gprs_sndcp_comp *comp_entity,
const struct gprs_sndcp_comp_field *comp_field);
/* Terminate data compression */
void gprs_sndcp_dcomp_term(struct gprs_sndcp_comp *comp_entity);
/* Expand packet */
int gprs_sndcp_dcomp_expand(uint8_t *data, unsigned int len, uint8_t pcomp,
const struct llist_head *comp_entities);
/* Compress packet */
int gprs_sndcp_dcomp_compress(uint8_t *data, unsigned int len, uint8_t *pcomp,
const struct llist_head *comp_entities,
uint8_t nsapi);

View File

@ -0,0 +1,46 @@
/* GPRS SNDCP header compression handler */
/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/sgsn/gprs_sndcp_comp.h>
/* Note: The decompressed packet may have a maximum size of:
* Return value + MAX_DECOMPR_INCR */
#define MAX_HDRDECOMPR_INCR 64
/* Initalize header compression */
int gprs_sndcp_pcomp_init(const void *ctx, struct gprs_sndcp_comp *comp_entity,
const struct gprs_sndcp_comp_field *comp_field);
/* Terminate header compression */
void gprs_sndcp_pcomp_term(struct gprs_sndcp_comp *comp_entity);
/* Expand packet header */
int gprs_sndcp_pcomp_expand(uint8_t *data, unsigned int len, uint8_t pcomp,
const struct llist_head *comp_entities);
/* Compress packet header */
int gprs_sndcp_pcomp_compress(uint8_t *data, unsigned int len, uint8_t *pcomp,
const struct llist_head *comp_entities,
uint8_t nsapi);

View File

@ -0,0 +1,224 @@
/* GPRS SNDCP XID field encoding/decoding as per 3GPP TS 44.065 */
/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* Author: Philipp Maier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#define DEFAULT_SNDCP_VERSION 0 /* See 3GPP TS 44.065, clause 8 */
#define MAX_ENTITIES 32 /* 3GPP TS 44.065 reserves 5 bit
* for compression enitity number */
#define MAX_COMP 16 /* Maximum number of possible pcomp/dcomp values */
#define MAX_NSAPI 11 /* Maximum number usable NSAPIs */
#define MAX_ROHC 16 /* Maximum number of ROHC compression profiles */
/* According to: 3GPP TS 44.065, 6.5.1.1.4 Algorithm identifier */
enum gprs_sndcp_hdr_comp_algo {
RFC_1144, /* TCP/IP header compression, see also 6.5.2 */
RFC_2507, /* TCP/UDP/IP header compression, see also: 6.5.3 */
ROHC /* Robust Header Compression, see also 6.5.4 */
};
/* According to: 3GPP TS 44.065, 6.5.1.1.4 Algorithm identifier */
enum gprs_sndcp_data_comp_algo {
V42BIS, /* V.42bis data compression, see also 6.6.2 */
V44 /* V44 data compression, see also: 6.6.3 */
};
union gprs_sndcp_comp_algo {
enum gprs_sndcp_hdr_comp_algo pcomp;
enum gprs_sndcp_data_comp_algo dcomp;
};
/* According to: 3GPP TS 44.065, 6.5.1.1 Format of the protocol control
* information compression field (Figure 7) and 3GPP TS 44.065,
* 6.6.1.1 Format of the data compression field (Figure 9) */
struct gprs_sndcp_comp_field {
struct llist_head list;
/* Propose bit (P), see also: 6.5.1.1.2 and 6.6.1.1.2 */
unsigned int p;
/* Entity number, see also: 6.5.1.1.3 and 6.6.1.1.3 */
unsigned int entity;
/* Algorithm identifier, see also: 6.5.1.1.4 and 6.6.1.1.4 */
union gprs_sndcp_comp_algo algo;
/* Number of contained PCOMP / DCOMP values */
uint8_t comp_len;
/* PCOMP / DCOMP values, see also: 6.5.1.1.5 and 6.6.1.1.5 */
uint8_t comp[MAX_COMP];
/* Note: Only one of the following struct pointers may,
be used. Unused pointers must be set to NULL! */
struct gprs_sndcp_pcomp_rfc1144_params *rfc1144_params;
struct gprs_sndcp_pcomp_rfc2507_params *rfc2507_params;
struct gprs_sndcp_pcomp_rohc_params *rohc_params;
struct gprs_sndcp_dcomp_v42bis_params *v42bis_params;
struct gprs_sndcp_dcomp_v44_params *v44_params;
};
/* According to: 3GPP TS 44.065, 8 SNDCP XID parameters */
enum gprs_sndcp_xid_param_types {
SNDCP_XID_VERSION_NUMBER,
SNDCP_XID_DATA_COMPRESSION, /* See also: subclause 6.6.1 */
SNDCP_XID_PROTOCOL_COMPRESSION, /* See also: subclause 6.5.1 */
SNDCP_XID_INVALID_COMPRESSION /* Not part of the spec; this means we found an invalid value */
};
/* According to: 3GPP TS 44.065, 6.5.2.1 Parameters (Table 5) */
struct gprs_sndcp_pcomp_rfc1144_params {
uint8_t nsapi_len; /* Number of applicable NSAPIs
* (default 0) */
uint8_t nsapi[MAX_NSAPI]; /* Applicable NSAPIs (default 0) */
int s01; /* (default 15) */
};
/* According to: 3GPP TS 44.065, 6.5.2.2 Assignment of PCOMP values */
enum gprs_sndcp_pcomp_rfc1144_pcomp {
RFC1144_PCOMP1, /* Uncompressed TCP */
RFC1144_PCOMP2, /* Compressed TCP */
RFC1144_PCOMP_NUM /* Number of pcomp values */
};
/* According to: 3GPP TS 44.065, 6.5.3.1 Parameters (Table 6) */
struct gprs_sndcp_pcomp_rfc2507_params {
uint8_t nsapi_len; /* Number of applicable NSAPIs
* (default 0) */
uint8_t nsapi[MAX_NSAPI]; /* Applicable NSAPIs (default 0) */
int f_max_period; /* (default 256) */
int f_max_time; /* (default 5) */
int max_header; /* (default 168) */
int tcp_space; /* (default 15) */
int non_tcp_space; /* (default 15) */
};
/* According to: 3GPP TS 44.065, 6.5.3.2 Assignment of PCOMP values for RFC2507 */
enum gprs_sndcp_pcomp_rfc2507_pcomp {
RFC2507_PCOMP1, /* Full Header */
RFC2507_PCOMP2, /* Compressed TCP */
RFC2507_PCOMP3, /* Compressed TCP non delta */
RFC2507_PCOMP4, /* Compressed non TCP */
RFC2507_PCOMP5, /* Context state */
RFC2507_PCOMP_NUM /* Number of pcomp values */
};
/* According to: 3GPP TS 44.065, 6.5.4.1 Parameter (Table 10) */
struct gprs_sndcp_pcomp_rohc_params {
uint8_t nsapi_len; /* Number of applicable NSAPIs
* (default 0) */
uint8_t nsapi[MAX_NSAPI]; /* Applicable NSAPIs (default 0) */
int max_cid; /* (default 15) */
int max_header; /* (default 168) */
uint8_t profile_len; /* (default 1) */
uint16_t profile[MAX_ROHC]; /* (default 0, ROHC uncompressed) */
};
/* According to: 3GPP TS 44.065, 6.5.4.2 Assignment of PCOMP values for ROHC */
enum gprs_sndcp_pcomp_rohc_pcomp {
ROHC_PCOMP1, /* ROHC small CIDs */
ROHC_PCOMP2, /* ROHC large CIDs */
ROHC_PCOMP_NUM /* Number of pcomp values */
};
/* ROHC compression profiles, see also:
http://www.iana.org/assignments/rohc-pro-ids/rohc-pro-ids.xhtml */
enum gprs_sndcp_xid_rohc_profiles {
ROHC_UNCOMPRESSED = 0x0000, /* ROHC uncompressed [RFC5795] */
ROHC_RTP = 0x0001, /* ROHC RTP [RFC3095] */
ROHCV2_RTP = 0x0101, /* ROHCv2 RTP [RFC5225] */
ROHC_UDP = 0x0002, /* ROHC UDP [RFC3095] */
ROHCv2_UDP = 0x0102, /* ROHCv2 UDP [RFC5225] */
ROHC_ESP = 0x0003, /* ROHC ESP [RFC3095] */
ROHCV2_ESP = 0x0103, /* ROHCv2 ESP [RFC5225] */
ROHC_IP = 0x0004, /* ROHC IP [RFC3843] */
ROHCV2_IP = 0x0104, /* ROHCv2 IP [RFC5225] */
ROHC_LLA = 0x0005, /* ROHC LLA [RFC4362] */
ROHC_LLA_WITH_R_MODE = 0x0105, /* ROHC LLA with R-mode [RFC3408] */
ROHC_TCP = 0x0006, /* ROHC TCP [RFC6846] */
ROHC_RTP_UDP_LITE = 0x0007, /* ROHC RTP/UDP-Lite [RFC4019] */
ROHCV2_RTP_UDP_LITE = 0x0107, /* ROHCv2 RTP/UDP-Lite [RFC5225] */
ROHC_UDP_LITE = 0x0008, /* ROHC UDP-Lite [RFC4019] */
ROHCV2_UDP_LITE = 0x0108, /* ROHCv2 UDP-Lite [RFC5225] */
};
/* According to: 3GPP TS 44.065, 6.6.2.1 Parameters (Table 7a) */
struct gprs_sndcp_dcomp_v42bis_params {
uint8_t nsapi_len; /* Number of applicable NSAPIs
* (default 0) */
uint8_t nsapi[MAX_NSAPI]; /* Applicable NSAPIs (default 0) */
int p0; /* (default 3) */
int p1; /* (default 2048) */
int p2; /* (default 20) */
};
/* According to: 3GPP TS 44.065, 6.6.2.2 Assignment of DCOMP values */
enum gprs_sndcp_dcomp_v42bis_dcomp {
V42BIS_DCOMP1, /* V.42bis enabled */
V42BIS_DCOMP_NUM /* Number of dcomp values */
};
/* According to: 3GPP TS 44.065, 6.6.3.1 Parameters (Table 7c) */
struct gprs_sndcp_dcomp_v44_params {
uint8_t nsapi_len; /* Number of applicable NSAPIs
* (default 0) */
uint8_t nsapi[MAX_NSAPI]; /* Applicable NSAPIs (default 0) */
int c0; /* (default 10000000) */
int p0; /* (default 3) */
int p1t; /* Refer to subclause 6.6.3.1.4 */
int p1r; /* Refer to subclause 6.6.3.1.5 */
int p3t; /* (default 3 x p1t) */
int p3r; /* (default 3 x p1r) */
};
/* According to: 3GPP TS 44.065, 6.6.3.2 Assignment of DCOMP values */
enum gprs_sndcp_dcomp_v44_dcomp {
V44_DCOMP1, /* Packet method compressed */
V44_DCOMP2, /* Multi packet method compressed */
V44_DCOMP_NUM /* Number of dcomp values */
};
/* Transform a list with compression fields into an SNDCP-XID message (dst) */
int gprs_sndcp_compile_xid(uint8_t *dst, unsigned int dst_maxlen,
const struct llist_head *comp_fields, int version);
/* Transform an SNDCP-XID message (src) into a list of SNDCP-XID fields */
struct llist_head *gprs_sndcp_parse_xid(int *version,
const void *ctx,
const uint8_t *src,
unsigned int src_len,
const struct llist_head
*comp_fields_req);
/* Find out to which compression class the specified comp-field belongs
* (header compression or data compression?) */
enum gprs_sndcp_xid_param_types gprs_sndcp_get_compression_class(
const struct gprs_sndcp_comp_field *comp_field);
/* Dump a list with SNDCP-XID fields (Debug) */
void gprs_sndcp_dump_comp_fields(const struct llist_head *comp_fields,
unsigned int logl);

View File

@ -0,0 +1,110 @@
/* GPRS subscriber details for use in SGSN land */
#pragma once
#include <stdint.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/socket.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <osmocom/sgsn/apn.h>
struct sgsn_instance;
struct sgsn_mm_ctx;
extern struct llist_head * const gprs_subscribers;
#define GPRS_SUBSCRIBER_FIRST_CONTACT 0x00000001
#define GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING (1 << 16)
#define GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING (1 << 17)
#define GPRS_SUBSCRIBER_CANCELLED (1 << 18)
#define GPRS_SUBSCRIBER_ENABLE_PURGE (1 << 19)
#define GPRS_SUBSCRIBER_UPDATE_PENDING_MASK ( \
GPRS_SUBSCRIBER_UPDATE_LOCATION_PENDING | \
GPRS_SUBSCRIBER_UPDATE_AUTH_INFO_PENDING \
)
struct gsm_auth_tuple {
int use_count;
int key_seq;
struct osmo_auth_vector vec;
};
#define GSM_KEY_SEQ_INVAL 7 /* GSM 04.08 - 10.5.1.2 */
struct sgsn_subscriber_data {
struct sgsn_mm_ctx *mm;
struct gsm_auth_tuple auth_triplets[5];
int auth_triplets_updated;
struct llist_head pdp_list;
int error_cause;
uint8_t msisdn[9];
size_t msisdn_len;
uint8_t hlr[9];
size_t hlr_len;
uint8_t pdp_charg[2];
bool has_pdp_charg;
};
/* see GSM 09.02, 17.7.1, PDP-Context and GPRSSubscriptionData */
/* see GSM 09.02, B.1, gprsSubscriptionData */
struct sgsn_subscriber_pdp_data {
struct llist_head list;
unsigned int context_id;
enum gsm48_pdp_type_org pdp_type_org;
enum gsm48_pdp_type_nr pdp_type_nr;
struct osmo_sockaddr pdp_address[2];
char apn_str[GSM_APN_LENGTH];
uint8_t qos_subscribed[20];
size_t qos_subscribed_len;
uint8_t pdp_charg[2];
bool has_pdp_charg;
};
struct sgsn_subscriber_pdp_data *sgsn_subscriber_pdp_data_alloc(struct sgsn_subscriber_data *sdata);
struct gprs_subscr {
struct llist_head entry;
int use_count;
char imsi[GSM23003_IMSI_MAX_DIGITS+1];
uint32_t tmsi;
char imei[GSM23003_IMEISV_NUM_DIGITS+1];
bool authorized;
bool keep_in_ram;
uint32_t flags;
uint16_t lac;
struct sgsn_subscriber_data *sgsn_data;
};
struct gprs_subscr *_gprs_subscr_get(struct gprs_subscr *gsub,
const char *file, int line);
struct gprs_subscr *_gprs_subscr_put(struct gprs_subscr *gsub,
const char *file, int line);
#define gprs_subscr_get(gsub) _gprs_subscr_get(gsub, __FILE__, __LINE__)
#define gprs_subscr_put(gsub) _gprs_subscr_put(gsub, __FILE__, __LINE__)
int gprs_subscr_init(struct sgsn_instance *sgi);
int gprs_subscr_request_update_location(struct sgsn_mm_ctx *mmctx);
int gprs_subscr_request_auth_info(struct sgsn_mm_ctx *mmctx,
const uint8_t *auts,
const uint8_t *auts_rand);
void gprs_subscr_cleanup(struct gprs_subscr *subscr);
struct gprs_subscr *gprs_subscr_get_or_create(const char *imsi);
struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx);
struct gprs_subscr *gprs_subscr_get_by_imsi(const char *imsi);
void gprs_subscr_cancel(struct gprs_subscr *subscr);
void gprs_subscr_update(struct gprs_subscr *subscr);
void gprs_subscr_update_auth_info(struct gprs_subscr *subscr);
int gprs_subscr_rx_gsup_message(struct msgb *msg);
#define LOGGSUBSCRP(level, subscr, fmt, args...) \
LOGP(DGPRS, level, "SUBSCR(%s) " fmt, \
(subscr) ? (subscr)->imsi : "---", \
## args)

View File

@ -0,0 +1,48 @@
/* GPRS utility functions */
/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
* (C) 2010-2014 by On-Waves
* (C) 2013 by Holger Hans Peter Freyther
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <stdint.h>
#include <sys/types.h>
#include <osmocom/core/msgb.h>
struct msgb;
struct gprs_ra_id;
/* GSM 04.08, 10.5.7.3 GPRS Timer */
uint8_t gprs_secs_to_tmr_floor(int secs);
int gprs_is_mi_tmsi(const uint8_t *value, size_t value_len);
int gprs_is_mi_imsi(const uint8_t *value, size_t value_len);
void gprs_parse_tmsi(const uint8_t *value, uint32_t *tmsi);
int gprs_ra_id_equals(const struct gprs_ra_id *id1, const struct gprs_ra_id *id2);
#define GSM48_ALLOC_SIZE 2048
#define GSM48_ALLOC_HEADROOM 256
static inline struct msgb *gsm48_msgb_alloc_name(const char *name)
{
return msgb_alloc_headroom(GSM48_ALLOC_SIZE, GSM48_ALLOC_HEADROOM,
name);
}

View File

@ -0,0 +1,30 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gprs/gprs_bssgp_rim.h>
struct gprs_ra_id;
struct sgsn_instance;
struct sgsn_ggsn_ctx;
struct sgsn_pdp_ctx;
struct sgsn_mm_ctx;
struct sgsn_mme_ctx;
int sgsn_gtp_init(struct sgsn_instance *sgi);
int sgsn_mme_ran_info_req(struct sgsn_mme_ctx *mme, const struct bssgp_ran_information_pdu *pdu);
void sgsn_ggsn_echo_req(struct sgsn_ggsn_ctx *ggc);
struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn,
struct sgsn_mm_ctx *mmctx,
uint16_t nsapi,
struct tlv_parsed *tp);
int sgsn_gtp_data_req(struct gprs_ra_id *ra_id, int32_t tlli, uint8_t nsapi,
struct msgb *msg, uint32_t npdu_len, uint8_t *npdu);
int sgsn_delete_pdp_ctx(struct sgsn_pdp_ctx *pctx);
void sgsn_pdp_upd_gtp_u(struct sgsn_pdp_ctx *pdp, void *addr, size_t alen);
int send_act_pdp_cont_acc(struct sgsn_pdp_ctx *pctx);

View File

@ -0,0 +1,41 @@
#pragma once
#include <stdint.h>
#include <netinet/in.h>
#include <inttypes.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/timer.h>
#include <osmocom/gprs/protocol/gsm_24_301.h>
struct gsn_t;
struct sgsn_pdp_ctx;
struct sgsn_instance;
struct sgsn_ggsn_ctx {
struct llist_head list;
uint32_t id;
unsigned int gtp_version;
struct in_addr remote_addr;
int remote_restart_ctr;
struct gsn_t *gsn;
struct llist_head pdp_list; /* list of associated pdp ctx (struct sgsn_pdp_ctx*) */
struct osmo_timer_list echo_timer;
unsigned int echo_interval;
};
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_alloc(struct sgsn_instance *sgsn, uint32_t id);
void sgsn_ggsn_ctx_free(struct sgsn_ggsn_ctx *ggc);
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_by_id(struct sgsn_instance *sgsn, uint32_t id);
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_by_addr(struct sgsn_instance *sgsn, struct in_addr *addr);
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_find_alloc(struct sgsn_instance *sgsn, uint32_t id);
void sgsn_ggsn_ctx_drop_pdp(struct sgsn_pdp_ctx *pctx);
int sgsn_ggsn_ctx_drop_all_pdp_except(struct sgsn_ggsn_ctx *ggsn, struct sgsn_pdp_ctx *except);
int sgsn_ggsn_ctx_drop_all_pdp(struct sgsn_ggsn_ctx *ggsn);
void sgsn_ggsn_ctx_add_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp);
void sgsn_ggsn_ctx_remove_pdp(struct sgsn_ggsn_ctx *ggc, struct sgsn_pdp_ctx *pdp);
void sgsn_ggsn_ctx_check_echo_timer(struct sgsn_ggsn_ctx *ggc);
#define LOGGGSN(ggc, level, fmt, args...) { \
char _buf[INET_ADDRSTRLEN]; \
LOGP(DGTP, level, "GGSN(%" PRIu32 ":%s): " fmt, (ggc)->id, inet_ntop(AF_INET, &(ggc)->remote_addr, _buf, sizeof(_buf)), ## args); \
} while (0)

View File

@ -0,0 +1,41 @@
#pragma once
#include <netinet/in.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/timer.h>
#include <osmocom/gprs/protocol/gsm_24_301.h>
struct gsn_t;
struct mme_rim_route {
struct llist_head list; /* item in struct sgsn_mme_ctx */
struct osmo_eutran_tai tai;
};
struct sgsn_mme_ctx {
struct llist_head list; /* item in sgsn_mme_ctxts */
struct llist_head routes; /* list of struct mme_rim_route */
struct sgsn_instance *sgsn; /* backpointer */
char *name;
struct in_addr remote_addr;
/* is it the default route for outgoing message? are all incoming messages accepted? */
bool default_route;
};
struct sgsn_mme_ctx *sgsn_mme_ctx_alloc(struct sgsn_instance *sgsn, const char *name);
struct sgsn_mme_ctx *sgsn_mme_ctx_find_alloc(struct sgsn_instance *sgsn, const char *name);
void sgsn_mme_ctx_free(struct sgsn_mme_ctx *mme);
struct sgsn_mme_ctx *sgsn_mme_ctx_by_name(const struct sgsn_instance *sgsn, const char *name);
struct sgsn_mme_ctx *sgsn_mme_ctx_by_addr(const struct sgsn_instance *sgsn, const struct in_addr *addr);
struct sgsn_mme_ctx *sgsn_mme_ctx_by_route(const struct sgsn_instance *sgsn, const struct osmo_eutran_tai *tai);
struct sgsn_mme_ctx *sgsn_mme_ctx_by_default_route(const struct sgsn_instance *sgsn);
void sgsn_mme_ctx_route_add(struct sgsn_mme_ctx *mme, const struct osmo_eutran_tai *tai);
void sgsn_mme_ctx_route_del(struct sgsn_mme_ctx *mme, const struct osmo_eutran_tai *tai);
#define LOGMME(mme, cat, level, fmt, args...) { \
char _buf[INET_ADDRSTRLEN]; \
LOGP(cat, level, "MME(%s:%s): " fmt, (mme)->name, inet_ntop(AF_INET, &(mme)->remote_addr, _buf, sizeof(_buf)), ## args); \
} while (0)

View File

@ -0,0 +1,287 @@
#pragma once
#include <stdint.h>
#include <netinet/in.h>
#include <inttypes.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/timer.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/crypt/gprs_cipher.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
#include <osmocom/crypt/auth.h>
#include <osmocom/sgsn/apn.h>
#include <osmocom/sgsn/auth.h>
#include <osmocom/sgsn/gprs_subscriber.h>
#define GSM_EXTENSION_LENGTH 15
struct gprs_llc_lle;
struct ctrl_handle;
struct gprs_subscr;
struct sgsn_ggsn_ctx;
struct sgsn_pdp_ctx;
enum gsm48_gsm_cause;
enum gprs_mm_ctr {
GMM_CTR_PKTS_SIG_IN,
GMM_CTR_PKTS_SIG_OUT,
GMM_CTR_PKTS_UDATA_IN,
GMM_CTR_PKTS_UDATA_OUT,
GMM_CTR_BYTES_UDATA_IN,
GMM_CTR_BYTES_UDATA_OUT,
GMM_CTR_PDP_CTX_ACT,
GMM_CTR_SUSPEND,
GMM_CTR_PAGING_PS,
GMM_CTR_PAGING_CS,
GMM_CTR_RA_UPDATE,
};
enum gprs_t3350_mode {
GMM_T3350_MODE_NONE,
GMM_T3350_MODE_ATT,
GMM_T3350_MODE_RAU,
GMM_T3350_MODE_PTMSI_REALL,
};
enum sgsn_ggsn_lookup_state {
SGSN_GGSN_2DIGIT,
SGSN_GGSN_3DIGIT,
};
struct sgsn_ggsn_lookup {
int state;
struct sgsn_mm_ctx *mmctx;
/* APN string */
char apn_str[GSM_APN_LENGTH];
/* the original data */
struct msgb *orig_msg;
struct tlv_parsed tp;
/* for dealing with re-transmissions */
uint8_t nsapi;
uint8_t sapi;
uint8_t ti;
};
enum sgsn_ran_type {
/* GPRS/EDGE via Gb */
MM_CTX_T_GERAN_Gb,
/* UMTS via Iu */
MM_CTX_T_UTRAN_Iu,
#if 0
/* GPRS/EDGE via Iu, not supported */
MM_CTX_T_GERAN_Iu,
#endif
};
extern const struct value_string sgsn_ran_type_names[];
struct service_info {
uint8_t type;
uint16_t pdp_status;
};
struct ranap_ue_conn_ctx;
/* According to TS 03.60, Table 5: SGSN MM and PDP Contexts */
/* Extended by 3GPP TS 23.060, Table 6: SGSN MM and PDP Contexts */
struct sgsn_mm_ctx {
struct llist_head list;
enum sgsn_ran_type ran_type;
char imsi[GSM23003_IMSI_MAX_DIGITS+1];
struct osmo_fsm_inst *gmm_fsm;
uint32_t p_tmsi;
uint32_t p_tmsi_old; /* old P-TMSI before new is confirmed */
uint32_t p_tmsi_sig;
char imei[GSM23003_IMEISV_NUM_DIGITS+1];
/* Opt: Software Version Numbber / TS 23.195 */
char msisdn[GSM_EXTENSION_LENGTH];
struct gprs_ra_id ra;
struct {
uint16_t cell_id; /* Gb only */
uint32_t cell_id_age; /* Gb only */
uint8_t radio_prio_sms;
/* Additional bits not present in the GSM TS */
uint16_t nsei;
uint16_t bvci;
struct gprs_llc_llme *llme;
uint32_t tlli;
uint32_t tlli_new;
/* TS 23.060 6.1.1 Mobility Management States (A/Gb mode) */
struct osmo_fsm_inst *mm_state_fsm;
} gb;
struct {
int new_key;
uint16_t sac; /* Iu: Service Area Code */
uint32_t sac_age; /* Iu: Service Area Code age */
/* CSG ID */
/* CSG Membership */
/* Access Mode */
/* Seelected CN Operator ID (TS 23.251) */
/* CSG Subscription Data */
/* LIPA Allowed */
/* Voice Support Match Indicator */
struct ranap_ue_conn_ctx *ue_ctx;
struct service_info service;
/* TS 23.060 6.1.2 Mobility Management States (Iu mode) */
struct osmo_fsm_inst *mm_state_fsm;
} iu;
struct {
struct osmo_fsm_inst *fsm;
/* when a second attach req arrives while in this procedure,
* the fsm needs to compare it against old to decide what to do */
struct msgb *attach_req;
uint32_t id_type;
unsigned int auth_reattempt; /* tracking UMTS resync auth attempts */
} gmm_att_req;
/* VLR number */
uint32_t new_sgsn_addr;
/* Authentication Triplet */
struct gsm_auth_tuple auth_triplet;
/* Kc */
/* Iu: CK, IK, KSI */
/* CKSN */
enum gprs_ciph_algo ciph_algo;
uint8_t ue_cipher_mask;
/* Auth & Ciphering Request reference from 3GPP TS 24.008 § 10.5.5.19: */
uint8_t ac_ref_nr_used;
struct {
uint8_t len;
uint8_t buf[50]; /* GSM 04.08 10.5.5.12a, extended in TS 24.008 */
} ms_radio_access_capa;
/* Supported Codecs (SRVCC) */
struct {
uint8_t len;
uint8_t buf[8]; /* GSM 04.08 10.5.5.12, extended in TS 24.008 */
} ms_network_capa;
/* UE Netowrk Capability (E-UTRAN) */
uint16_t drx_parms;
/* Active Time value for PSM */
int mnrg; /* MS reported to HLR? */
int ngaf; /* MS reported to MSC/VLR? */
int ppf; /* paging for GPRS + non-GPRS? */
/* Subscribed Charging Characteristics */
/* Trace Reference */
/* Trace Type */
/* Trigger ID */
/* OMC Identity */
/* SMS Parameters */
int recovery;
/* Access Restriction */
/* GPRS CSI (CAMEL) */
/* MG-CSI (CAMEL) */
/* Subscribed UE-AMBR */
/* UE-AMBR */
/* APN Subscribed */
struct llist_head pdp_list;
struct rate_ctr_group *ctrg;
struct osmo_timer_list timer;
unsigned int T; /* Txxxx number */
unsigned int num_T_exp; /* number of consecutive T expirations */
enum gprs_t3350_mode t3350_mode;
uint8_t t3370_id_type;
uint8_t pending_req; /* the request's message type */
/* TODO: There isn't much semantic difference between t3350_mode
* (refers to the timer) and pending_req (refers to the procedure),
* where mm->T == 3350 => mm->t3350_mode == f(mm->pending_req). Check
* whether one of them can be dropped. */
enum sgsn_auth_state auth_state;
enum osmo_sub_auth_type sec_ctx;
/* the string representation of the current hlr */
char hlr[GSM_EXTENSION_LENGTH];
/* the current GGSN look-up operation */
struct sgsn_ggsn_lookup *ggsn_lookup;
struct gprs_subscr *subscr;
};
static inline bool sgsn_mm_ctx_is_authenticated(struct sgsn_mm_ctx *ctx)
{
switch (ctx->sec_ctx) {
case OSMO_AUTH_TYPE_GSM:
case OSMO_AUTH_TYPE_UMTS:
return true;
default:
return false;
}
}
#define LOGMMCTXP(level, mm, fmt, args...) \
LOGP(DMM, level, "MM(%s/%08x) " fmt, (mm) ? (mm)->imsi : "---", \
(mm) ? (mm)->p_tmsi : GSM_RESERVED_TMSI, ## args)
#ifdef BUILD_IU
#define LOGIUP(ue, level, fmt, args...) \
LOGP(DMM, level, "UE(0x%x){%s} " fmt, ue->conn_id, osmo_rai_name(&(ue)->ra_id), ## args)
#else
#define LOGIUP(ue, level, fmt, args...) \
LOGP(DMM, level, "UE(%p){NOTSUPPORTED} " fmt, ue, ## args)
#endif
#define LOGGBP(llme, category, level, fmt, args...) \
LOGP(category, level, "LLME(%08x/%08x){%s} " fmt, (llme)->old_tlli, \
(llme)->tlli, get_value_string_or_null(gprs_llc_llme_state_names, (llme)->state), ## args);
#define LOGGBIUP(llme, msg, level, fmt, args...) \
do { \
struct ranap_ue_conn_ctx * _ue; \
if (llme) { \
LOGGBP(llme, DMM, level, fmt, ## args); \
} else if ((msg) && (_ue = MSG_IU_UE_CTX(msg))) { \
LOGIUP(_ue, level, fmt, ## args); \
} else { OSMO_ASSERT(0); } \
} while (0)
/* look-up a SGSN MM context based on TLLI + RAI */
struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(uint32_t tlli,
const struct gprs_ra_id *raid);
struct sgsn_mm_ctx *sgsn_mm_ctx_by_ptmsi(uint32_t tmsi);
struct sgsn_mm_ctx *sgsn_mm_ctx_by_imsi(const char *imsi);
struct sgsn_mm_ctx *sgsn_mm_ctx_by_ue_ctx(const void *uectx);
/* look-up by matching TLLI and P-TMSI (think twice before using this) */
struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli_and_ptmsi(uint32_t tlli,
const struct gprs_ra_id *raid);
/* Allocate a new SGSN MM context */
struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
const struct gprs_ra_id *raid);
struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx);
void sgsn_mm_ctx_cleanup_free(struct sgsn_mm_ctx *ctx);
struct sgsn_ggsn_ctx *sgsn_mm_ctx_find_ggsn_ctx(struct sgsn_mm_ctx *mmctx,
struct tlv_parsed *tp,
enum gsm48_gsm_cause *gsm_cause,
char *apn_str);
/* look up PDP context by MM context and NSAPI */
struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_nsapi(const struct sgsn_mm_ctx *mm,
uint8_t nsapi);
/* look up PDP context by MM context and transaction ID */
struct sgsn_pdp_ctx *sgsn_pdp_ctx_by_tid(const struct sgsn_mm_ctx *mm,
uint8_t tid);
uint32_t sgsn_alloc_ptmsi(void);
/* Called on subscriber data updates */
void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx);

View File

@ -0,0 +1,94 @@
#pragma once
#include <stdint.h>
#include <netinet/in.h>
#include <inttypes.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/crypt/gprs_cipher.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
#include <osmocom/crypt/auth.h>
#include <osmocom/sgsn/apn.h>
#include <osmocom/sgsn/gprs_subscriber.h>
struct sgsn_mm_ctx;
struct sgsn_ggsn_ctx;
enum gprs_pdp_ctx {
PDP_CTR_PKTS_UDATA_IN,
PDP_CTR_PKTS_UDATA_OUT,
PDP_CTR_BYTES_UDATA_IN,
PDP_CTR_BYTES_UDATA_OUT,
};
enum pdp_ctx_state {
PDP_STATE_NONE,
PDP_STATE_CR_REQ,
PDP_STATE_CR_CONF,
/* 04.08 / Figure 6.2 / 6.1.2.2 */
PDP_STATE_INACT_PEND,
PDP_STATE_INACTIVE = PDP_STATE_NONE,
};
enum pdp_type {
PDP_TYPE_NONE,
PDP_TYPE_ETSI_PPP,
PDP_TYPE_IANA_IPv4,
PDP_TYPE_IANA_IPv6,
};
struct sgsn_pdp_ctx {
struct llist_head list; /* list_head for mmctx->pdp_list */
struct llist_head g_list; /* list_head for global list */
struct sgsn_mm_ctx *mm; /* back pointer to MM CTX */
int destroy_ggsn; /* destroy it on destruction */
struct sgsn_ggsn_ctx *ggsn; /* which GGSN serves this PDP */
struct llist_head ggsn_list; /* list_head for ggsn->pdp_list */
struct rate_ctr_group *ctrg;
//unsigned int id;
struct pdp_t *lib; /* pointer to libgtp PDP ctx */
enum pdp_ctx_state state;
enum pdp_type type;
uint32_t address;
char *apn_subscribed;
//char *apn_used;
uint16_t nsapi; /* SNDCP */
uint16_t sapi; /* LLC */
uint8_t ti; /* transaction identifier */
int vplmn_allowed;
uint32_t qos_profile_subscr;
//uint32_t qos_profile_req;
//uint32_t qos_profile_neg;
uint8_t radio_prio;
//uint32_t charging_id;
struct osmo_timer_list timer;
unsigned int T; /* Txxxx number */
unsigned int num_T_exp; /* number of consecutive T expirations */
struct osmo_timer_list cdr_timer; /* CDR record wird timer */
struct timespec cdr_start; /* The start of the CDR */
uint64_t cdr_bytes_in;
uint64_t cdr_bytes_out;
uint32_t cdr_charging_id;
};
#define LOGPDPCTXP(level, pdp, fmt, args...) \
LOGP(DGPRS, level, "PDP(%s/%u) " \
fmt, (pdp)->mm ? (pdp)->mm->imsi : "---", (pdp)->ti, ## args)
struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm,
struct sgsn_ggsn_ctx *ggsn,
uint8_t nsapi);
void sgsn_pdp_ctx_terminate(struct sgsn_pdp_ctx *pdp);
void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp);
char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len, bool return_ipv6);

196
include/osmocom/sgsn/sgsn.h Normal file
View File

@ -0,0 +1,196 @@
#ifndef _SGSN_H
#define _SGSN_H
#include <osmocom/core/msgb.h>
#include <osmocom/core/select.h>
#include <osmocom/crypt/gprs_cipher.h>
#include <osmocom/gprs/gprs_ns2.h>
#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/sgsn/auth.h>
#include <osmocom/sgsn/gtp_mme.h>
#include <osmocom/gsm/oap_client.h>
#include <osmocom/gsupclient/gsup_client.h>
#include <osmocom/sgsn/common.h>
#include "../../config.h"
#if BUILD_IU
#include <osmocom/ranap/iu_client.h>
#endif
#include <ares.h>
#include <gtp.h>
struct hostent;
#define SGSN_ERROR_CAUSE_NONE (-1)
enum sgsn_auth_policy {
SGSN_AUTH_POLICY_OPEN,
SGSN_AUTH_POLICY_CLOSED,
SGSN_AUTH_POLICY_ACL_ONLY,
SGSN_AUTH_POLICY_REMOTE
};
enum sgsn_rate_ctr_keys {
CTR_LLC_DL_BYTES,
CTR_LLC_UL_BYTES,
CTR_LLC_DL_PACKETS,
CTR_LLC_UL_PACKETS,
CTR_GPRS_ATTACH_REQUEST,
CTR_GPRS_ATTACH_ACKED,
CTR_GPRS_ATTACH_REJECTED,
CTR_GPRS_DETACH_REQUEST,
CTR_GPRS_DETACH_ACKED,
CTR_GPRS_ROUTING_AREA_REQUEST,
CTR_GPRS_ROUTING_AREA_ACKED,
CTR_GPRS_ROUTING_AREA_REJECT,
/* PDP single packet counter / GSM 04.08 9.5.1 - 9.5.9 */
CTR_PDP_ACTIVATE_REQUEST,
CTR_PDP_ACTIVATE_REJECT,
CTR_PDP_ACTIVATE_ACCEPT,
CTR_PDP_REQUEST_ACTIVATE, /* unused */
CTR_PDP_REQUEST_ACTIVATE_REJ, /* unused */
CTR_PDP_MODIFY_REQUEST, /* unsued */
CTR_PDP_MODIFY_ACCEPT, /* unused */
CTR_PDP_DL_DEACTIVATE_REQUEST,
CTR_PDP_DL_DEACTIVATE_ACCEPT,
CTR_PDP_UL_DEACTIVATE_REQUEST,
CTR_PDP_UL_DEACTIVATE_ACCEPT,
};
struct sgsn_cdr {
char *filename;
bool trap;
int interval;
};
struct sgsn_config {
/* parsed from config file */
char *gtp_statedir;
struct sockaddr_in gtp_listenaddr;
/* misc */
struct gprs_ns2_inst *nsi;
char *crypt_cipher_plugin_path;
enum sgsn_auth_policy auth_policy;
uint8_t gea_encryption_mask;
uint8_t uea_encryption_mask;
struct llist_head imsi_acl;
struct sockaddr_in gsup_server_addr;
int gsup_server_port;
/* Only meaningful if auth_policy is SGSN_AUTH_POLICY_REMOTE */
int require_authentication;
int require_update_location;
/* CDR configuration */
struct sgsn_cdr cdr;
/* Timer defintions */
struct osmo_tdef *T_defs;
struct osmo_tdef *T_defs_gtp;
int dynamic_lookup;
struct osmo_oap_client_config oap;
/* RFC1144 TCP/IP header compression */
struct {
int active;
int passive;
int s01;
} pcomp_rfc1144;
/* V.42vis data compression */
struct {
int active;
int passive;
int p0;
int p1;
int p2;
} dcomp_v42bis;
#if BUILD_IU
struct {
enum ranap_nsap_addr_enc rab_assign_addr_enc;
uint32_t cs7_instance;
} iu;
#endif
/* This is transmitted as IPA Serial Number tag, which is used for GSUP routing (e.g. in OsmoHLR).
* This name must be set in a multi-SGSN network, and it must be unique to each SGSN.
* If no name is set, the IPA Serial Number will be the same as the Unit Name,
* and will be of the form 'SGSN-00-00-00-00-00-00' */
char *sgsn_ipa_name;
};
struct sgsn_instance {
char *config_file;
struct sgsn_config cfg;
/* File descriptor wrappers for LibGTP */
struct osmo_fd gtp_fd0;
struct osmo_fd gtp_fd1c;
struct osmo_fd gtp_fd1u;
/* GSN instance for libgtp */
struct gsn_t *gsn;
/* Subscriber */
struct osmo_gsup_client *gsup_client;
/* LLME inactivity timer */
struct osmo_timer_list llme_timer;
/* c-ares event loop integration */
struct osmo_timer_list ares_timer;
struct llist_head ares_fds;
ares_channel ares_channel;
struct ares_addr_node *ares_servers;
struct rate_ctr_group *rate_ctrs;
struct llist_head apn_list; /* list of struct sgsn_apn_ctx */
struct llist_head ggsn_list; /* list of struct sgsn_ggsn_ctx */
struct llist_head mme_list; /* list of struct sgsn_mme_ctx */
struct llist_head mm_list; /* list of struct sgsn_mm_ctx */
struct llist_head pdp_list; /* list of struct sgsn_pdp_ctx */
struct ctrl_handle *ctrlh;
};
extern struct sgsn_instance *sgsn;
extern void *tall_sgsn_ctx;
/*
* ctrl interface related work (sgsn_ctrl.c)
*/
int sgsn_ctrl_cmds_install(void);
/* sgsn_vty.c */
int sgsn_vty_init(struct sgsn_config *cfg);
int sgsn_parse_config(const char *config_file);
char *sgsn_gtp_ntoa(struct ul16_t *ul);
/* sgsn.c */
struct sgsn_instance *sgsn_instance_alloc(void *talloc_ctx);
int sgsn_inst_init(struct sgsn_instance *sgsn);
/*
* CDR related functionality
*/
int sgsn_cdr_init(struct sgsn_instance *sgsn);
void sgsn_cdr_release(struct sgsn_instance *sgsn);
/*
* C-ARES related functionality
*/
int sgsn_ares_init(struct sgsn_instance *sgsn);
int sgsn_ares_query(struct sgsn_instance *sgsm, const char *name, ares_host_callback cb, void *data);
#endif

View File

@ -0,0 +1,6 @@
#pragma once
struct sgsn_mme_ctx;
int sgsn_rim_rx_from_gb(struct osmo_bssgp_prim *bp, struct msgb *msg);
int sgsn_rim_rx_from_gtp(struct msgb *msg, struct bssgp_rim_routing_info *rim_routing_address);

View File

@ -1,5 +1,6 @@
/*
* (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
/* Generic signalling/notification infrastructure */
/* (C) 2009-2010, 2015 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2009 by Harald Welte <laforge@gnumonks.org>
* (C) 2010 by On-Waves
* All Rights Reserved
*
@ -18,11 +19,34 @@
*
*/
#ifndef OSMO_BSC_GRACE_H
#define OSMO_BSC_GRACE_H
#ifndef OPENBSC_SIGNAL_H
#define OPENBSC_SIGNAL_H
#include "gsm_data.h"
#include <stdlib.h>
#include <errno.h>
int bsc_grace_allow_new_connection(struct gsm_network *network);
#include <osmocom/core/signal.h>
enum signal_subsystems {
SS_SGSN,
};
/* GPRS SGSN signals SS_SGSN */
enum signal_sgsn {
S_SGSN_ATTACH,
S_SGSN_DETACH,
S_SGSN_UPDATE,
S_SGSN_PDP_ACT,
S_SGSN_PDP_DEACT,
S_SGSN_PDP_TERMINATE,
S_SGSN_PDP_FREE,
S_SGSN_MM_FREE,
};
struct sgsn_mm_ctx;
struct sgsn_signal_data {
struct sgsn_mm_ctx *mm;
struct sgsn_pdp_ctx *pdp; /* non-NULL for PDP_ACT, PDP_DEACT, PDP_FREE */
};
#endif

187
include/osmocom/sgsn/slhc.h Normal file
View File

@ -0,0 +1,187 @@
#ifndef _SLHC_H
#define _SLHC_H
/*
* Definitions for tcp compression routines.
*
* $Header: slcompress.h,v 1.10 89/12/31 08:53:02 van Exp $
*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
*
*
* modified for KA9Q Internet Software Package by
* Katie Stevens (dkstevens@ucdavis.edu)
* University of California, Davis
* Computing Services
* - 01-31-90 initial adaptation
*
* - Feb 1991 Bill_Simpson@um.cc.umich.edu
* variable number of conversation slots
* allow zero or one slots
* separate routines
* status display
*/
/*
* Compressed packet format:
*
* The first octet contains the packet type (top 3 bits), TCP
* 'push' bit, and flags that indicate which of the 4 TCP sequence
* numbers have changed (bottom 5 bits). The next octet is a
* conversation number that associates a saved IP/TCP header with
* the compressed packet. The next two octets are the TCP checksum
* from the original datagram. The next 0 to 15 octets are
* sequence number changes, one change per bit set in the header
* (there may be no changes and there are two special cases where
* the receiver implicitly knows what changed -- see below).
*
* There are 5 numbers which can change (they are always inserted
* in the following order): TCP urgent pointer, window,
* acknowledgment, sequence number and IP ID. (The urgent pointer
* is different from the others in that its value is sent, not the
* change in value.) Since typical use of SLIP links is biased
* toward small packets (see comments on MTU/MSS below), changes
* use a variable length coding with one octet for numbers in the
* range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
* range 256 - 65535 or 0. (If the change in sequence number or
* ack is more than 65535, an uncompressed packet is sent.)
*/
/*
* Packet types (must not conflict with IP protocol version)
*
* The top nibble of the first octet is the packet type. There are
* three possible types: IP (not proto TCP or tcp with one of the
* control flags set); uncompressed TCP (a normal IP/TCP packet but
* with the 8-bit protocol field replaced by an 8-bit connection id --
* this type of packet syncs the sender & receiver); and compressed
* TCP (described above).
*
* LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
* is logically part of the 4-bit "changes" field that follows. Top
* three bits are actual packet type. For backward compatibility
* and in the interest of conserving bits, numbers are chosen so the
* IP protocol version number (4) which normally appears in this nibble
* means "IP packet".
*/
#include <linux/ip.h>
#include <linux/tcp.h>
/* SLIP compression masks for len/vers byte */
#define SL_TYPE_IP 0x40
#define SL_TYPE_UNCOMPRESSED_TCP 0x70
#define SL_TYPE_COMPRESSED_TCP 0x80
#define SL_TYPE_ERROR 0x00
/* Bits in first octet of compressed packet */
#define NEW_C 0x40 /* flag bits for what changed in a packet */
#define NEW_I 0x20
#define NEW_S 0x08
#define NEW_A 0x04
#define NEW_W 0x02
#define NEW_U 0x01
/* reserved, special-case values of above */
#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
#define TCP_PUSH_BIT 0x10
/*
* data type and sizes conversion assumptions:
*
* VJ code KA9Q style generic
* u_char byte_t unsigned char 8 bits
* u_short int16 unsigned short 16 bits
* u_int int16 unsigned short 16 bits
* u_long unsigned long unsigned long 32 bits
* int int32 long 32 bits
*/
typedef __u8 byte_t;
typedef __u32 int32;
/*
* "state" data for each active tcp conversation on the wire. This is
* basically a copy of the entire IP/TCP header from the last packet
* we saw from the conversation together with a small identifier
* the transmit & receive ends of the line use to locate saved header.
*/
struct cstate {
byte_t cs_this; /* connection id number (xmit) */
struct cstate *next; /* next in ring (xmit) */
struct iphdr cs_ip; /* ip/tcp hdr from most recent packet */
struct tcphdr cs_tcp;
unsigned char cs_ipopt[64];
unsigned char cs_tcpopt[64];
int cs_hsize;
};
#define NULLSLSTATE (struct cstate *)0
/*
* all the state data for one serial line (we need one of these per line).
*/
struct slcompress {
struct cstate *tstate; /* transmit connection states (array)*/
struct cstate *rstate; /* receive connection states (array)*/
byte_t tslot_limit; /* highest transmit slot id (0-l)*/
byte_t rslot_limit; /* highest receive slot id (0-l)*/
byte_t xmit_oldest; /* oldest xmit in ring */
byte_t xmit_current; /* most recent xmit id */
byte_t recv_current; /* most recent rcvd id */
byte_t flags;
#define SLF_TOSS 0x01 /* tossing rcvd frames until id received */
int32 sls_o_nontcp; /* outbound non-TCP packets */
int32 sls_o_tcp; /* outbound TCP packets */
int32 sls_o_uncompressed; /* outbound uncompressed packets */
int32 sls_o_compressed; /* outbound compressed packets */
int32 sls_o_searches; /* searches for connection state */
int32 sls_o_misses; /* times couldn't find conn. state */
int32 sls_i_uncompressed; /* inbound uncompressed packets */
int32 sls_i_compressed; /* inbound compressed packets */
int32 sls_i_error; /* inbound error packets */
int32 sls_i_tossed; /* inbound packets tossed because of error */
int32 sls_i_runt;
int32 sls_i_badcheck;
};
#define NULLSLCOMPR (struct slcompress *)0
/* In slhc.c: */
struct slcompress *slhc_init(const void *ctx, int rslots, int tslots);
void slhc_free(struct slcompress *comp);
int slhc_compress(struct slcompress *comp, unsigned char *icp, int isize,
unsigned char *ocp, unsigned char **cpp, int compress_cid);
int slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize);
int slhc_remember(struct slcompress *comp, unsigned char *icp, int isize);
int slhc_toss(struct slcompress *comp);
void slhc_i_status(struct slcompress *comp);
void slhc_o_status(struct slcompress *comp);
#endif /* _SLHC_H */

View File

@ -0,0 +1,143 @@
/*
* SpanDSP - a series of DSP components for telephony
*
* v42bis.h
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2005, 2011 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
/*! \page v42bis_page V.42bis modem data compression
\section v42bis_page_sec_1 What does it do?
The v.42bis specification defines a data compression scheme, to work in
conjunction with the error correction scheme defined in V.42.
\section v42bis_page_sec_2 How does it work?
*/
#include <stdint.h>
#if !defined(_SPANDSP_V42BIS_H_)
#define _SPANDSP_V42BIS_H_
#define SPAN_DECLARE(x) x
#define V42BIS_MIN_STRING_SIZE 6
#define V42BIS_MAX_STRING_SIZE 250
#define V42BIS_MIN_DICTIONARY_SIZE 512
#define V42BIS_MAX_BITS 12
#define V42BIS_MAX_CODEWORDS 4096 /* 2^V42BIS_MAX_BITS */
#define V42BIS_MAX_OUTPUT_LENGTH 1024
enum
{
V42BIS_P0_NEITHER_DIRECTION = 0,
V42BIS_P0_INITIATOR_RESPONDER,
V42BIS_P0_RESPONDER_INITIATOR,
V42BIS_P0_BOTH_DIRECTIONS
};
enum
{
V42BIS_COMPRESSION_MODE_DYNAMIC = 0,
V42BIS_COMPRESSION_MODE_ALWAYS,
V42BIS_COMPRESSION_MODE_NEVER
};
typedef void (*put_msg_func_t)(void *user_data, const uint8_t *msg, int len);
/*!
V.42bis compression/decompression descriptor. This defines the working state for a
single instance of V.42bis compress/decompression.
*/
typedef struct v42bis_state_s v42bis_state_t;
#if defined(__cplusplus)
extern "C"
{
#endif
/*! Compress a block of octets.
\param s The V.42bis context.
\param buf The data to be compressed.
\param len The length of the data buffer.
\return 0 */
SPAN_DECLARE(int) v42bis_compress(v42bis_state_t *s, const uint8_t buf[], int len);
/*! Flush out any data remaining in a compression buffer.
\param s The V.42bis context.
\return 0 */
SPAN_DECLARE(int) v42bis_compress_flush(v42bis_state_t *s);
/*! Decompress a block of octets.
\param s The V.42bis context.
\param buf The data to be decompressed.
\param len The length of the data buffer.
\return 0 */
SPAN_DECLARE(int) v42bis_decompress(v42bis_state_t *s, const uint8_t buf[], int len);
/*! Flush out any data remaining in the decompression buffer.
\param s The V.42bis context.
\return 0 */
SPAN_DECLARE(int) v42bis_decompress_flush(v42bis_state_t *s);
/*! Set the compression mode.
\param s The V.42bis context.
\param mode One of the V.42bis compression modes -
V42BIS_COMPRESSION_MODE_DYNAMIC,
V42BIS_COMPRESSION_MODE_ALWAYS,
V42BIS_COMPRESSION_MODE_NEVER */
SPAN_DECLARE(void) v42bis_compression_control(v42bis_state_t *s, int mode);
/*! Initialise a V.42bis context.
\param s The V.42bis context.
\param negotiated_p0 The negotiated P0 parameter, from the V.42bis spec.
\param negotiated_p1 The negotiated P1 parameter, from the V.42bis spec.
\param negotiated_p2 The negotiated P2 parameter, from the V.42bis spec.
\param encode_handler Encode callback handler.
\param encode_user_data An opaque pointer passed to the encode callback handler.
\param max_encode_len The maximum length that should be passed to the encode handler.
\param decode_handler Decode callback handler.
\param decode_user_data An opaque pointer passed to the decode callback handler.
\param max_decode_len The maximum length that should be passed to the decode handler.
\return The V.42bis context. */
SPAN_DECLARE(v42bis_state_t *) v42bis_init(const void *ctx,
v42bis_state_t *s,
int negotiated_p0,
int negotiated_p1,
int negotiated_p2,
put_msg_func_t encode_handler,
void *encode_user_data,
int max_encode_len,
put_msg_func_t decode_handler,
void *decode_user_data,
int max_decode_len);
/*! Release a V.42bis context.
\param s The V.42bis context.
\return 0 if OK */
SPAN_DECLARE(int) v42bis_release(v42bis_state_t *s);
/*! Free a V.42bis context.
\param s The V.42bis context.
\return 0 if OK */
SPAN_DECLARE(int) v42bis_free(v42bis_state_t *s);
#if defined(__cplusplus)
}
#endif
#endif
/*- End of file ------------------------------------------------------------*/

View File

@ -0,0 +1,122 @@
/*
* SpanDSP - a series of DSP components for telephony
*
* private/v42bis.h
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2005 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
#if !defined(_SPANDSP_PRIVATE_V42BIS_H_)
#define _SPANDSP_PRIVATE_V42BIS_H_
/*!
V.42bis dictionary node.
Note that 0 is not a valid node to point to (0 is always a control code), so 0 is used
as a "no such value" marker in this structure.
*/
typedef struct
{
/*! \brief The value of the octet represented by the current dictionary node */
uint8_t node_octet;
/*! \brief The parent of this node */
uint16_t parent;
/*! \brief The first child of this node */
uint16_t child;
/*! \brief The next node at the same depth */
uint16_t next;
} v42bis_dict_node_t;
/*!
V.42bis compression or decompression. This defines the working state for a single instance
of V.42bis compression or decompression.
*/
typedef struct
{
/*! \brief Compression enabled. */
int v42bis_parm_p0;
/*! \brief Compression mode. */
int compression_mode;
/*! \brief Callback function to handle output data. */
put_msg_func_t handler;
/*! \brief An opaque pointer passed in calls to the data handler. */
void *user_data;
/*! \brief The maximum amount to be passed to the data handler. */
int max_output_len;
/*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */
int transparent;
/*! \brief Next empty dictionary entry */
uint16_t v42bis_parm_c1;
/*! \brief Current codeword size */
uint16_t v42bis_parm_c2;
/*! \brief Threshold for codeword size change */
uint16_t v42bis_parm_c3;
/*! \brief The current update point in the dictionary */
uint16_t update_at;
/*! \brief The last entry matched in the dictionary */
uint16_t last_matched;
/*! \brief The last entry added to the dictionary */
uint16_t last_added;
/*! \brief Total number of codewords in the dictionary */
int v42bis_parm_n2;
/*! \brief Maximum permitted string length */
int v42bis_parm_n7;
/*! \brief The dictionary */
v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS];
/*! \brief The octet string in progress */
uint8_t string[V42BIS_MAX_STRING_SIZE];
/*! \brief The current length of the octet string in progress */
int string_length;
/*! \brief The amount of the octet string in progress which has already
been flushed out of the buffer */
int flushed_length;
/*! \brief Compression performance metric */
uint16_t compression_performance;
/*! \brief Outgoing bit buffer (compression), or incoming bit buffer (decompression) */
uint32_t bit_buffer;
/*! \brief Outgoing bit count (compression), or incoming bit count (decompression) */
int bit_count;
/*! \brief The output composition buffer */
uint8_t output_buf[V42BIS_MAX_OUTPUT_LENGTH];
/*! \brief The length of the contents of the output composition buffer */
int output_octet_count;
/*! \brief The current value of the escape code */
uint8_t escape_code;
/*! \brief TRUE if we just hit an escape code, and are waiting for the following octet */
int escaped;
} v42bis_comp_state_t;
/*!
V.42bis compression/decompression descriptor. This defines the working state for a
single instance of V.42bis compress/decompression.
*/
struct v42bis_state_s
{
/*! \brief Compression state. */
v42bis_comp_state_t compress;
/*! \brief Decompression state. */
v42bis_comp_state_t decompress;
/*! \brief Error and flow logging control */
};
#endif
/*- End of file ------------------------------------------------------------*/

View File

@ -0,0 +1,9 @@
#pragma once
#include <osmocom/vty/command.h>
enum bsc_vty_node {
SGSN_NODE = _LAST_OSMOVTY_NODE + 1,
GTPHUB_NODE,
MME_NODE,
};

View File

@ -1,144 +0,0 @@
diff -Nru --exclude-from /sunbeam/home/laforge/scripts/dontdiff linux-2.6.27.4-clean/drivers/isdn/mISDN/layer2.c linux-2.6.27.4/drivers/isdn/mISDN/layer2.c
--- linux-2.6.27.4-clean/drivers/isdn/mISDN/layer2.c 2008-10-26 00:05:07.000000000 +0200
+++ linux-2.6.27.4/drivers/isdn/mISDN/layer2.c 2008-12-23 16:16:29.000000000 +0100
@@ -94,8 +94,10 @@
struct layer2 *l2 = fi->userdata;
va_list va;
+#if 0
if (!(*debug & DEBUG_L2_FSM))
return;
+#endif
va_start(va, fmt);
printk(KERN_DEBUG "l2 (tei %d): ", l2->tei);
vprintk(fmt, va);
@@ -882,6 +884,8 @@
l2->va = 0;
l2->vr = 0;
l2->sow = 0;
+ l2->sapi = skb->data[0] >> 2;
+ set_channel_address(&l2->ch, l2->sapi, l2->tei);
clear_exception(l2);
send_uframe(l2, NULL, UA | get_PollFlag(l2, skb), RSP);
mISDN_FsmChangeState(fi, ST_L2_7);
@@ -898,6 +902,7 @@
struct layer2 *l2 = fi->userdata;
struct sk_buff *skb = arg;
+ printk(KERN_DEBUG "l2_send_UA()\n");
send_uframe(l2, skb, UA | get_PollFlag(l2, skb), RSP);
}
@@ -931,6 +936,8 @@
l2->va = 0;
l2->vr = 0;
l2->sow = 0;
+ l2->sapi = skb->data[0] >> 2;
+ set_channel_address(&l2->ch, l2->sapi, l2->tei);
mISDN_FsmChangeState(fi, ST_L2_7);
stop_t200(l2, 3);
mISDN_FsmRestartTimer(&l2->t203, l2->T203, EV_L2_T203, NULL, 3);
@@ -982,6 +989,8 @@
} else if (l2->vs != l2->va) {
skb_queue_purge(&l2->i_queue);
pr = DL_ESTABLISH_IND;
+ //l2->sapi = skb->data[0] >> 2;
+ //set_channel_address(&l2->ch, l2->sapi, l2->tei);
}
stop_t200(l2, 5);
l2->vr = 0;
@@ -1841,11 +1850,14 @@
u_int l;
int c = 0;
+ printk(KERN_DEBUG "ph_data_indication 0x%x 0x%x 0x%x\n", datap[0], datap[1], datap[2]);
+
l = l2addrsize(l2);
if (skb->len <= l) {
mISDN_FsmEvent(&l2->l2m, EV_L2_FRAME_ERROR, (void *) 'N');
return ret;
}
+#if 0
if (test_bit(FLG_LAPD, &l2->flag)) { /* Maybe not needed */
psapi = *datap++;
ptei = *datap++;
@@ -1875,6 +1887,7 @@
return 0;
}
} else
+#endif
datap += l;
if (!(*datap & 1)) { /* I-Frame */
c = iframe_error(l2, skb);
@@ -1890,6 +1903,7 @@
ret = mISDN_FsmEvent(&l2->l2m, EV_L2_UI, skb);
} else if (IsSABME(datap, l2)) {
c = unnum_error(l2, skb, CMD);
+ printk(KERN_DEBUG "IsSABME() returned true, unnum_error=%d\n", c);
if (!c)
ret = mISDN_FsmEvent(&l2->l2m, EV_L2_SABME, skb);
} else if (IsUA(datap)) {
@@ -2087,7 +2101,7 @@
test_and_set_bit(FLG_LAPD, &l2->flag);
test_and_set_bit(FLG_LAPD_NET, &l2->flag);
test_and_set_bit(FLG_MOD128, &l2->flag);
- l2->sapi = 0;
+ l2->sapi = 62;
l2->maxlen = MAX_DFRAME_LEN;
if (test_bit(OPTION_L2_PMX, &options))
l2->window = 7;
diff -Nru --exclude-from /sunbeam/home/laforge/scripts/dontdiff linux-2.6.27.4-clean/drivers/isdn/mISDN/tei.c linux-2.6.27.4/drivers/isdn/mISDN/tei.c
--- linux-2.6.27.4-clean/drivers/isdn/mISDN/tei.c 2008-10-26 00:05:07.000000000 +0200
+++ linux-2.6.27.4/drivers/isdn/mISDN/tei.c 2008-12-23 16:32:59.000000000 +0100
@@ -830,18 +830,29 @@
int tei, ri;
struct layer2 *l2;
+ printk(KERN_DEBUG "new tei request: tei=%d\n", dp[3] >> 1);
+
ri = dp[0] << 8;
ri += dp[1];
- if (!mgr->up)
- goto denied;
- tei = get_free_tei(mgr);
- if (tei < 0) {
- printk(KERN_WARNING "%s:No free tei\n", __func__);
+ if (!mgr->up) {
+ printk(KERN_DEBUG "mgr->up == NULL\n");
goto denied;
}
+ if (dp[3] != 0xff) {
+ /* This is a TEI request according to 3GPP TS 08.56 6.1.11.2 */
+ tei = dp[3] >> 1;
+ } else {
+ tei = get_free_tei(mgr);
+ if (tei < 0) {
+ printk(KERN_WARNING "%s:No free tei\n", __func__);
+ goto denied;
+ }
+ }
l2 = create_new_tei(mgr, tei);
- if (!l2)
+ if (!l2) {
+ printk(KERN_DEBUG "create_new_tei == NULL\n");
goto denied;
+ }
else
mISDN_FsmEvent(&l2->tm->tei_m, EV_ASSIGN_REQ, dp);
return;
@@ -1159,12 +1170,14 @@
return -ENOTCONN;
if (skb->len != 3)
return -ENOTCONN;
+#if 0
if (skb->data[0] != 0)
/* only SAPI 0 command */
return -ENOTCONN;
+#endif
if (!(skb->data[1] & 1)) /* invalid EA1 */
return -EINVAL;
- tei = skb->data[1] >> 0;
+ tei = skb->data[1] >> 1;
if (tei > 63) /* not a fixed tei */
return -ENOTCONN;
if ((skb->data[2] & ~0x10) != SABME)

View File

@ -1,486 +0,0 @@
This experimental patch splits one E1 card into three virtual cards,
TS 1,2,3,4,5 is card 0
TS 6,7,8,9,10 is card 1
TS 11,12,13,14 is card 2
This allows you to run one L2 TEI handler on each of the virtual cards,
which is required if you want to run multiple BTS on a single E1 link.
Thanks to Andreas Eversberg for this patch.
diff --git a/drivers/isdn/hardware/mISDN/hfc_multi.h b/drivers/isdn/hardware/mISDN/hfc_multi.h
index 0c77386..02dd4a1 100644
--- a/drivers/isdn/hardware/mISDN/hfc_multi.h
+++ b/drivers/isdn/hardware/mISDN/hfc_multi.h
@@ -209,14 +209,17 @@ struct hfc_multi {
u_long ledstate; /* save last state of leds */
int opticalsupport; /* has the e1 board */
/* an optical Interface */
- int dslot; /* channel # of d-channel (E1) default 16 */
+
+ u_int bmask[32]; /* bitmask of bchannels for port */
+ u_char dnum[32]; /* array of used dchannel numbers for port */
+ u_char created[32]; /* what port is created */
+ u_int activity[32]; /* if there is any action on this */
+ /* port (will be cleared after */
+ /* showing led-states) */
u_long wdcount; /* every 500 ms we need to */
/* send the watchdog a signal */
u_char wdbyte; /* watchdog toggle byte */
- u_int activity[8]; /* if there is any action on this */
- /* port (will be cleared after */
- /* showing led-states) */
int e1_state; /* keep track of last state */
int e1_getclock; /* if sync is retrieved from interface */
int syncronized; /* keep track of existing sync interface */
@@ -233,7 +236,6 @@ struct hfc_multi {
* the bch->channel is equvalent to the hfc-channel
*/
struct hfc_chan chan[32];
- u_char created[8]; /* what port is created */
signed char slot_owner[256]; /* owner channel of slot */
};
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index e1dab30..4fe2d27 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -1619,8 +1619,8 @@ hfcmulti_leds(struct hfc_multi *hc)
* left red: frame sync, but no L1
* right green: L2 active
*/
- if (hc->chan[hc->dslot].sync != 2) { /* no frame sync */
- if (hc->chan[hc->dslot].dch->dev.D.protocol
+ if (hc->chan[hc->dnum[0]].sync != 2) { /* no frame sync */
+ if (hc->chan[hc->dnum[0]].dch->dev.D.protocol
!= ISDN_P_NT_E1) {
led[0] = 1;
led[1] = 1;
@@ -2428,55 +2428,56 @@ handle_timer_irq(struct hfc_multi *hc)
}
}
if (hc->ctype == HFC_TYPE_E1 && hc->created[0]) {
- dch = hc->chan[hc->dslot].dch;
- if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dslot].cfg)) {
+#warning todo: put interface parameters to hc
+ dch = hc->chan[hc->dnum[0]].dch;
+ if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dnum[0]].cfg)) {
/* LOS */
temp = HFC_inb_nodebug(hc, R_SYNC_STA) & V_SIG_LOS;
- if (!temp && hc->chan[hc->dslot].los)
+ if (!temp && hc->chan[hc->dnum[0]].los)
signal_state_up(dch, L1_SIGNAL_LOS_ON,
"LOS detected");
- if (temp && !hc->chan[hc->dslot].los)
+ if (temp && !hc->chan[hc->dnum[0]].los)
signal_state_up(dch, L1_SIGNAL_LOS_OFF,
"LOS gone");
- hc->chan[hc->dslot].los = temp;
+ hc->chan[hc->dnum[0]].los = temp;
}
- if (test_bit(HFC_CFG_REPORT_AIS, &hc->chan[hc->dslot].cfg)) {
+ if (test_bit(HFC_CFG_REPORT_AIS, &hc->chan[hc->dnum[0]].cfg)) {
/* AIS */
temp = HFC_inb_nodebug(hc, R_SYNC_STA) & V_AIS;
- if (!temp && hc->chan[hc->dslot].ais)
+ if (!temp && hc->chan[hc->dnum[0]].ais)
signal_state_up(dch, L1_SIGNAL_AIS_ON,
"AIS detected");
- if (temp && !hc->chan[hc->dslot].ais)
+ if (temp && !hc->chan[hc->dnum[0]].ais)
signal_state_up(dch, L1_SIGNAL_AIS_OFF,
"AIS gone");
- hc->chan[hc->dslot].ais = temp;
+ hc->chan[hc->dnum[0]].ais = temp;
}
- if (test_bit(HFC_CFG_REPORT_SLIP, &hc->chan[hc->dslot].cfg)) {
+ if (test_bit(HFC_CFG_REPORT_SLIP, &hc->chan[hc->dnum[0]].cfg)) {
/* SLIP */
temp = HFC_inb_nodebug(hc, R_SLIP) & V_FOSLIP_RX;
- if (!temp && hc->chan[hc->dslot].slip_rx)
+ if (!temp && hc->chan[hc->dnum[0]].slip_rx)
signal_state_up(dch, L1_SIGNAL_SLIP_RX,
" bit SLIP detected RX");
- hc->chan[hc->dslot].slip_rx = temp;
+ hc->chan[hc->dnum[0]].slip_rx = temp;
temp = HFC_inb_nodebug(hc, R_SLIP) & V_FOSLIP_TX;
- if (!temp && hc->chan[hc->dslot].slip_tx)
+ if (!temp && hc->chan[hc->dnum[0]].slip_tx)
signal_state_up(dch, L1_SIGNAL_SLIP_TX,
" bit SLIP detected TX");
- hc->chan[hc->dslot].slip_tx = temp;
+ hc->chan[hc->dnum[0]].slip_tx = temp;
}
- if (test_bit(HFC_CFG_REPORT_RDI, &hc->chan[hc->dslot].cfg)) {
+ if (test_bit(HFC_CFG_REPORT_RDI, &hc->chan[hc->dnum[0]].cfg)) {
/* RDI */
temp = HFC_inb_nodebug(hc, R_RX_SL0_0) & V_A;
- if (!temp && hc->chan[hc->dslot].rdi)
+ if (!temp && hc->chan[hc->dnum[0]].rdi)
signal_state_up(dch, L1_SIGNAL_RDI_ON,
"RDI detected");
- if (temp && !hc->chan[hc->dslot].rdi)
+ if (temp && !hc->chan[hc->dnum[0]].rdi)
signal_state_up(dch, L1_SIGNAL_RDI_OFF,
"RDI gone");
- hc->chan[hc->dslot].rdi = temp;
+ hc->chan[hc->dnum[0]].rdi = temp;
}
temp = HFC_inb_nodebug(hc, R_JATT_DIR);
- switch (hc->chan[hc->dslot].sync) {
+ switch (hc->chan[hc->dnum[0]].sync) {
case 0:
if ((temp & 0x60) == 0x60) {
if (debug & DEBUG_HFCMULTI_SYNC)
@@ -2485,10 +2486,10 @@ handle_timer_irq(struct hfc_multi *hc)
"in clock sync\n",
__func__, hc->id);
HFC_outb(hc, R_RX_OFF,
- hc->chan[hc->dslot].jitter | V_RX_INIT);
+ hc->chan[hc->dnum[0]].jitter | V_RX_INIT);
HFC_outb(hc, R_TX_OFF,
- hc->chan[hc->dslot].jitter | V_RX_INIT);
- hc->chan[hc->dslot].sync = 1;
+ hc->chan[hc->dnum[0]].jitter | V_RX_INIT);
+ hc->chan[hc->dnum[0]].sync = 1;
goto check_framesync;
}
break;
@@ -2499,7 +2500,7 @@ handle_timer_irq(struct hfc_multi *hc)
"%s: (id=%d) E1 "
"lost clock sync\n",
__func__, hc->id);
- hc->chan[hc->dslot].sync = 0;
+ hc->chan[hc->dnum[0]].sync = 0;
break;
}
check_framesync:
@@ -2510,7 +2511,7 @@ check_framesync:
"%s: (id=%d) E1 "
"now in frame sync\n",
__func__, hc->id);
- hc->chan[hc->dslot].sync = 2;
+ hc->chan[hc->dnum[0]].sync = 2;
}
break;
case 2:
@@ -2520,7 +2521,7 @@ check_framesync:
"%s: (id=%d) E1 lost "
"clock & frame sync\n",
__func__, hc->id);
- hc->chan[hc->dslot].sync = 0;
+ hc->chan[hc->dnum[0]].sync = 0;
break;
}
temp = HFC_inb_nodebug(hc, R_SYNC_STA);
@@ -2530,7 +2531,7 @@ check_framesync:
"%s: (id=%d) E1 "
"lost frame sync\n",
__func__, hc->id);
- hc->chan[hc->dslot].sync = 1;
+ hc->chan[hc->dnum[0]].sync = 1;
}
break;
}
@@ -2746,7 +2747,8 @@ hfcmulti_interrupt(int intno, void *dev_id)
if (r_irq_misc & V_STA_IRQ) {
if (hc->ctype == HFC_TYPE_E1) {
/* state machine */
- dch = hc->chan[hc->dslot].dch;
+#warning todo
+ dch = hc->chan[hc->dnum[0]].dch;
e1_syncsta = HFC_inb_nodebug(hc, R_SYNC_STA);
if (test_bit(HFC_CHIP_PLXSD, &hc->chip)
&& hc->e1_getclock) {
@@ -2768,7 +2770,15 @@ hfcmulti_interrupt(int intno, void *dev_id)
}
dch->state = HFC_inb_nodebug(hc, R_E1_RD_STA)
& 0x7;
+#warning todo hack!!! broadcast state change!!!
+ dch = hc->chan[hc->dnum[0]].dch;
schedule_event(dch, FLG_PHCHANGE);
+ dch = hc->chan[hc->dnum[1]].dch;
+ dch->state = HFC_inb_nodebug(hc, R_E1_RD_STA)
+ & 0x7;
+ schedule_event(dch, FLG_PHCHANGE);
+
+
if (debug & DEBUG_HFCMULTI_STATE)
printk(KERN_DEBUG
"%s: E1 (id=%d) newstate %x\n",
@@ -3851,31 +3861,35 @@ hfcmulti_initmode(struct dchannel *dch)
if (debug & DEBUG_HFCMULTI_INIT)
printk(KERN_DEBUG "%s: entered\n", __func__);
+ i = dch->slot;
+ pt = hc->chan[i].port;
if (hc->ctype == HFC_TYPE_E1) {
- hc->chan[hc->dslot].slot_tx = -1;
- hc->chan[hc->dslot].slot_rx = -1;
- hc->chan[hc->dslot].conf = -1;
- if (hc->dslot) {
- mode_hfcmulti(hc, hc->dslot, dch->dev.D.protocol,
+ /* E1 */
+#warning todo: don''t do it if dnum == 0
+ hc->chan[hc->dnum[pt]].slot_tx = -1;
+ hc->chan[hc->dnum[pt]].slot_rx = -1;
+ hc->chan[hc->dnum[pt]].conf = -1;
+ if (hc->dnum[pt]) {
+ mode_hfcmulti(hc, dch->slot, dch->dev.D.protocol,
-1, 0, -1, 0);
dch->timer.function = (void *) hfcmulti_dbusy_timer;
dch->timer.data = (long) dch;
init_timer(&dch->timer);
}
for (i = 1; i <= 31; i++) {
- if (i == hc->dslot)
+ if (!((1 << i) & hc->bmask[pt])) /* skip unused channel */
continue;
hc->chan[i].slot_tx = -1;
hc->chan[i].slot_rx = -1;
hc->chan[i].conf = -1;
mode_hfcmulti(hc, i, ISDN_P_NONE, -1, 0, -1, 0);
}
- /* E1 */
- if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dslot].cfg)) {
+#warning todo (global)
+ if (test_bit(HFC_CFG_REPORT_LOS, &hc->chan[hc->dnum[pt]].cfg)) {
HFC_outb(hc, R_LOS0, 255); /* 2 ms */
HFC_outb(hc, R_LOS1, 255); /* 512 ms */
}
- if (test_bit(HFC_CFG_OPTICAL, &hc->chan[hc->dslot].cfg)) {
+ if (test_bit(HFC_CFG_OPTICAL, &hc->chan[hc->dnum[pt]].cfg)) {
HFC_outb(hc, R_RX0, 0);
hc->hw.r_tx0 = 0 | V_OUT_EN;
} else {
@@ -3888,12 +3902,12 @@ hfcmulti_initmode(struct dchannel *dch)
HFC_outb(hc, R_TX_FR0, 0x00);
HFC_outb(hc, R_TX_FR1, 0xf8);
- if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dslot].cfg))
+ if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dnum[pt]].cfg))
HFC_outb(hc, R_TX_FR2, V_TX_MF | V_TX_E | V_NEG_E);
HFC_outb(hc, R_RX_FR0, V_AUTO_RESYNC | V_AUTO_RECO | 0);
- if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dslot].cfg))
+ if (test_bit(HFC_CFG_CRC4, &hc->chan[hc->dnum[pt]].cfg))
HFC_outb(hc, R_RX_FR1, V_RX_MF | V_RX_MF_SYNC);
if (dch->dev.D.protocol == ISDN_P_NT_E1) {
@@ -3957,7 +3971,7 @@ hfcmulti_initmode(struct dchannel *dch)
plxsd_checksync(hc, 0);
}
} else {
- i = dch->slot;
+ /* ST */
hc->chan[i].slot_tx = -1;
hc->chan[i].slot_rx = -1;
hc->chan[i].conf = -1;
@@ -3973,8 +3987,6 @@ hfcmulti_initmode(struct dchannel *dch)
hc->chan[i - 1].slot_rx = -1;
hc->chan[i - 1].conf = -1;
mode_hfcmulti(hc, i - 1, ISDN_P_NONE, -1, 0, -1, 0);
- /* ST */
- pt = hc->chan[i].port;
/* select interface */
HFC_outb(hc, R_ST_SEL, pt);
/* undocumented: delay after R_ST_SEL */
@@ -4557,6 +4569,8 @@ release_port(struct hfc_multi *hc, struct dchannel *dch)
}
/* free channels */
for (i = 0; i <= 31; i++) {
+ if (!((1 << i) & hc->bmask[pt])) /* skip unused channel */
+ continue;
if (hc->chan[i].bch) {
if (debug & DEBUG_HFCMULTI_INIT)
printk(KERN_DEBUG
@@ -4680,12 +4694,13 @@ release_card(struct hfc_multi *hc)
}
static int
-init_e1_port(struct hfc_multi *hc, struct hm_map *m)
+init_e1_port(struct hfc_multi *hc, struct hm_map *m, int pt)
{
struct dchannel *dch;
struct bchannel *bch;
int ch, ret = 0;
char name[MISDN_MAX_IDLEN];
+ int bcount = 0;
dch = kzalloc(sizeof(struct dchannel), GFP_KERNEL);
if (!dch)
@@ -4698,13 +4713,12 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
(1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
dch->dev.D.send = handle_dmsg;
dch->dev.D.ctrl = hfcm_dctrl;
- dch->dev.nrbchan = (hc->dslot) ? 30 : 31;
- dch->slot = hc->dslot;
- hc->chan[hc->dslot].dch = dch;
- hc->chan[hc->dslot].port = 0;
- hc->chan[hc->dslot].nt_timer = -1;
+ dch->slot = hc->dnum[pt];
+ hc->chan[hc->dnum[pt]].dch = dch;
+ hc->chan[hc->dnum[pt]].port = pt;
+ hc->chan[hc->dnum[pt]].nt_timer = -1;
for (ch = 1; ch <= 31; ch++) {
- if (ch == hc->dslot) /* skip dchannel */
+ if (!((1 << ch) & hc->bmask[pt])) /* skip unused channel */
continue;
bch = kzalloc(sizeof(struct bchannel), GFP_KERNEL);
if (!bch) {
@@ -4733,7 +4747,10 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
hc->chan[ch].bch = bch;
hc->chan[ch].port = 0;
set_channelmap(bch->nr, dch->dev.channelmap);
+ bcount++;
}
+ dch->dev.nrbchan = bcount;
+#warning todo: must be set globally, and must be a seperate function
/* set optical line type */
if (port[Port_cnt] & 0x001) {
if (!m->opticalsupport) {
@@ -4749,7 +4766,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
__func__,
HFC_cnt + 1, 1);
test_and_set_bit(HFC_CFG_OPTICAL,
- &hc->chan[hc->dslot].cfg);
+ &hc->chan[hc->dnum[pt]].cfg);
}
}
/* set LOS report */
@@ -4759,7 +4776,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
"LOS report: card(%d) port(%d)\n",
__func__, HFC_cnt + 1, 1);
test_and_set_bit(HFC_CFG_REPORT_LOS,
- &hc->chan[hc->dslot].cfg);
+ &hc->chan[hc->dnum[pt]].cfg);
}
/* set AIS report */
if (port[Port_cnt] & 0x008) {
@@ -4768,7 +4785,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
"AIS report: card(%d) port(%d)\n",
__func__, HFC_cnt + 1, 1);
test_and_set_bit(HFC_CFG_REPORT_AIS,
- &hc->chan[hc->dslot].cfg);
+ &hc->chan[hc->dnum[pt]].cfg);
}
/* set SLIP report */
if (port[Port_cnt] & 0x010) {
@@ -4778,7 +4795,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
"card(%d) port(%d)\n",
__func__, HFC_cnt + 1, 1);
test_and_set_bit(HFC_CFG_REPORT_SLIP,
- &hc->chan[hc->dslot].cfg);
+ &hc->chan[hc->dnum[pt]].cfg);
}
/* set RDI report */
if (port[Port_cnt] & 0x020) {
@@ -4788,7 +4805,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
"card(%d) port(%d)\n",
__func__, HFC_cnt + 1, 1);
test_and_set_bit(HFC_CFG_REPORT_RDI,
- &hc->chan[hc->dslot].cfg);
+ &hc->chan[hc->dnum[pt]].cfg);
}
/* set CRC-4 Mode */
if (!(port[Port_cnt] & 0x100)) {
@@ -4797,7 +4814,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
" card(%d) port(%d)\n",
__func__, HFC_cnt + 1, 1);
test_and_set_bit(HFC_CFG_CRC4,
- &hc->chan[hc->dslot].cfg);
+ &hc->chan[hc->dnum[pt]].cfg);
} else {
if (debug & DEBUG_HFCMULTI_INIT)
printk(KERN_DEBUG "%s: PORT turn off CRC4"
@@ -4829,20 +4846,23 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
}
/* set elastic jitter buffer */
if (port[Port_cnt] & 0x3000) {
- hc->chan[hc->dslot].jitter = (port[Port_cnt]>>12) & 0x3;
+ hc->chan[hc->dnum[pt]].jitter = (port[Port_cnt]>>12) & 0x3;
if (debug & DEBUG_HFCMULTI_INIT)
printk(KERN_DEBUG
"%s: PORT set elastic "
"buffer to %d: card(%d) port(%d)\n",
- __func__, hc->chan[hc->dslot].jitter,
+ __func__, hc->chan[hc->dnum[pt]].jitter,
HFC_cnt + 1, 1);
} else
- hc->chan[hc->dslot].jitter = 2; /* default */
- snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d", HFC_cnt + 1);
+ hc->chan[hc->dnum[pt]].jitter = 2; /* default */
+ if (hc->ports > 1)
+ snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d-%d", HFC_cnt + 1, pt+1);
+ else
+ snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d", HFC_cnt + 1);
ret = mISDN_register_device(&dch->dev, &hc->pci_dev->dev, name);
if (ret)
goto free_chan;
- hc->created[0] = 1;
+ hc->created[pt] = 1;
return ret;
free_chan:
release_port(hc, dch);
@@ -5009,18 +5029,30 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev,
hc->id = HFC_cnt;
hc->pcm = pcm[HFC_cnt];
hc->io_mode = iomode[HFC_cnt];
+#warning todo: rework module parameters for customizing e1 fragments.... yea, let''s call it: fragments
if (dslot[HFC_cnt] < 0 && hc->ctype == HFC_TYPE_E1) {
- hc->dslot = 0;
+ hc->dnum[0] = 0;
printk(KERN_INFO "HFC-E1 card has disabled D-channel, but "
"31 B-channels\n");
}
if (dslot[HFC_cnt] > 0 && dslot[HFC_cnt] < 32
&& hc->ctype == HFC_TYPE_E1) {
- hc->dslot = dslot[HFC_cnt];
+ hc->dnum[0] = dslot[HFC_cnt];
printk(KERN_INFO "HFC-E1 card has alternating D-channel on "
"time slot %d\n", dslot[HFC_cnt]);
} else
- hc->dslot = 16;
+ hc->dnum[0] = 16;
+
+#warning todo HACK!!! just a small map of two "fragments"
+ if (hc->ctype == HFC_TYPE_E1) {
+ hc->dnum[0] = 1;
+ hc->bmask[0] = 0x0000003c;
+ hc->dnum[1] = 6;
+ hc->bmask[1] = 0x00000780;
+ hc->dnum[2] = 11;
+ hc->bmask[2] = 0x00007800;
+ hc->ports = 3;
+ }
/* set chip specific features */
hc->masterclk = -1;
@@ -5103,7 +5135,7 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev,
goto free_card;
}
if (hc->ctype == HFC_TYPE_E1)
- ret_err = init_e1_port(hc, m);
+ ret_err = init_e1_port(hc, m, pt);
else
ret_err = init_multi_port(hc, pt);
if (debug & DEBUG_HFCMULTI_INIT)
@@ -5115,10 +5147,14 @@ hfcmulti_init(struct hm_map *m, struct pci_dev *pdev,
if (ret_err) {
while (pt) { /* release already registered ports */
pt--;
- release_port(hc, hc->chan[(pt << 2) + 2].dch);
+ if (hc->ctype == HFC_TYPE_E1)
+ release_port(hc, hc->chan[hc->dnum[pt]].dch);
+ else
+ release_port(hc, hc->chan[(pt << 2) + 2].dch);
}
goto free_card;
}
+#warning todo: count it right, add additional "fragment" counter...
Port_cnt++;
}

3
m4/README Normal file
View File

@ -0,0 +1,3 @@
We want to avoid creating too many external build-time dependencies
like this one to autoconf-archive. This directory provides a local
copy of required m4 rules.

55
openbsc/.gitignore vendored
View File

@ -1,55 +0,0 @@
*.o
*.a
.deps
Makefile
Makefile.in
bscconfig.h
bscconfig.h.in
openbsc.pc
src/osmo-nitb/osmo-nitb
bsc_mgcp
src/osmo-bsc/osmo-bsc
*.*~
*.sw?
#configure
aclocal.m4
autom4te.cache/
config.log
config.status
configure
depcomp
install-sh
missing
stamp-h1
# git-version-gen magic
.tarball-version
.version
# apps and app data
hlr.sqlite3
src/utils/bs11_config
src/ipaccess/ipaccess-config
src/ipaccess/ipaccess-find
src/ipaccess/ipaccess-firmware
src/ipaccess/ipaccess-proxy
src/utils/isdnsync
src/nat/bsc_nat
src/gprs/osmo-sgsn
src/gprs/osmo-gbproxy
src/osmo-bsc_nat/osmo-bsc_nat
#tests
tests/bsc-nat/bsc_nat_test
tests/channel/channel_test
tests/db/db_test
tests/debug/debug_test
tests/gsm0408/gsm0408_test
tests/mgcp/mgcp_test
tests/sccp/sccp_test
tests/sms/sms_test
tests/timer/timer_test
src/openbsc.cfg*

View File

@ -1,14 +0,0 @@
AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6
INCLUDES = $(all_includes) -I$(top_srcdir)/include
SUBDIRS = doc include src tests
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = openbsc.pc
BUILT_SOURCES = $(top_srcdir)/.version
EXTRA_DIST = git-version-gen
$(top_srcdir)/.version:
echo $(VERSION) > $@-t && mv $@-t $@
dist-hook:
echo $(VERSION) > $(distdir)/.tarball-version

View File

@ -1,32 +0,0 @@
About OpenBSC
=============
OpenBSC is a minimalistic implementation of the GSM Network, with
particular emphasis on the functionality typically provided by the BSC,
MSC, HLR, VLR and SMSC.
Its currently supported interfaces towards the BTS are:
* Classic A-bis over E1 using a mISDN based E1 interface. In other
words, you can connect existing GSM Base Transceiver Station (BTS)
through E1 to OpenBSC. So far, we have only tested the Siemens BS-11
Test reports with other BTS are much appreciated!
* A-bis over IP as used by the ip.access nanoBTS product family
You can find the project documentation at http://openbsc.gnumonks.org/
This project is still in its early days, and there are lots of areas where it
doesn't behave as per GSM spec.
Harald Welte <laforge@gnumonks.org>
libosmocore
===========
Please note that as of March 2010, OpenBSC has a dependency to a library
called "libosmocore". You can obtain that library from
git://git.osmocom.org/libosmocore.git

Some files were not shown because too many files have changed in this diff Show More