Compare commits

...

613 Commits

Author SHA1 Message Date
Vadim Yanitskiy bea6a0ffb5 README.md: cosmetic: fix a typo
Change-Id: Ia23fdbde29691c7af3834effee3d03ab866ca809
2024-06-05 18:34:07 +07:00
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
195 changed files with 10506 additions and 28234 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1 @@
open_collective: osmocom

52
.gitignore vendored
View File

@ -2,30 +2,25 @@ debian/*.log
*.o
*.lo
*.a
*.la
.deps
Makefile
Makefile.in
bscconfig.h
bscconfig.h.in
openbsc.pc
src/osmo-nitb/osmo-nitb
src/osmo-bsc_mgcp/osmo-bsc_mgcp
src/osmo-bsc/osmo-bsc
src/utils/meas_vis
src/utils/meas_json
src/utils/osmo-meas-pcap2db
src/utils/osmo-meas-udp2db
src/utils/smpp_mirror
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
@ -45,30 +40,13 @@ ltmain.sh
# apps and app data
hlr.sqlite3
src/utils/bs11_config
src/ipaccess/ipaccess-config
src/ipaccess/abisip-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/gprs/osmo-gtphub
src/osmo-bsc_nat/osmo-bsc_nat
src/sgsn/osmo-sgsn
src/gtphub/osmo-gtphub
src/libcommon/gsup_test_client
src/osmo-msc/osmo-msc
#tests
tests/testsuite.dir
tests/*/*_test
# ignore compiled binaries like msc_vlr_test_foo; do not ignore
# msc_vlr_test_foo.{c,ok,err}, but do still ignore the corresponding .o object
# files:
tests/msc_vlr/msc_vlr_test_*
!tests/msc_vlr/msc_vlr_test_*.*
tests/msc_vlr/msc_vlr_test_*.o
tests/atconfig
@ -78,6 +56,18 @@ tests/testsuite
tests/testsuite.log
gsn_restart
src/openbsc.cfg*
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

View File

@ -9,18 +9,24 @@ AM_CPPFLAGS = \
$(NULL)
SUBDIRS = \
doc \
include \
src \
tests \
contrib \
tests \
doc \
$(NULL)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = osmo-sgsn.pc
BUILT_SOURCES = $(top_srcdir)/.version
EXTRA_DIST = git-version-gen osmoappdesc.py .version
EXTRA_DIST = \
.version \
README.md \
debian \
git-version-gen \
osmoappdesc.py \
$(NULL)
AM_DISTCHECK_CONFIGURE_FLAGS = \
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
@RELMAKE@

17
README
View File

@ -1,17 +0,0 @@
About OsmoSGSN
==============
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.
OsmoSGSN exposes
- GSUP towards OsmoHLR (or a MAP proxy);
- GTP towards a GGSN (e.g. OsmoGGSN);
- Gb towards a BSS (e.g. OsmoPCU);
- IuPS towards an RNC or HNB-GW (e.g. OsmoHNBGW) for 3G data;
- The Osmocom typical telnet VTY and CTRL interfaces.
Find OsmoSGSN issue tracker and wiki online at
https://osmocom.org/projects/osmosgsn
https://osmocom.org/projects/osmosgsn/wiki

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 use 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.

View File

@ -1,10 +1,10 @@
To run the configuration parsing and output (VTY) test suite, first install
git://git.osmocom.org/python/osmo-python-tests
https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests
and pass the following configure options here:
./configure --enable-vty-tests --enable-external-tests
./configure --enable-external-tests
The VTY tests are then included in the standard check target:

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)

View File

@ -22,6 +22,11 @@ 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
@ -29,68 +34,69 @@ if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
fi
PKG_PROG_PKG_CONFIG([0.20])
dnl check for AX_CHECK_COMPILE_FLAG
m4_ifdef([AX_CHECK_COMPILE_FLAG], [], [
AC_MSG_ERROR([Please install autoconf-archive; re-run 'autoreconf -fi' for it to take effect.])
])
dnl use a defined standard across all builds and don't depend on compiler default
CFLAGS="$CFLAGS -std=gnu11"
dnl checks for libraries
AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
AC_SUBST(LIBRARY_DL)
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5)
PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.3.0)
PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl)
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.5)
PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.2.0)
PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 0.6.4)
PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.0.1)
PKG_CHECK_MODULES(LIBCRYPTO, libcrypto >= 0.9.5)
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) # TODO version?
PKG_CHECK_MODULES(LIBASN1C, libasn1c) # TODO version?
PKG_CHECK_MODULES(LIBOSMORANAP, libosmo-ranap) # TODO version?
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)
found_libgtp=yes
PKG_CHECK_MODULES(LIBGTP, libgtp >= 1.0.0, , found_libgtp=no)
AM_CONDITIONAL(HAVE_LIBGTP, test "$found_libgtp" = yes)
AC_SUBST(found_libgtp)
found_libcares=yes
PKG_CHECK_MODULES([LIBCARES], [libcares], [], [found_libcares=no])
AM_CONDITIONAL(HAVE_LIBCARES, test "$found_libcares" = yes)
AC_SUBST(found_libcares)
found_libgtp_and_libcares=no
if test "$found_libgtp" = "yes" -a "$found_libcares" = "yes"; then
found_libgtp_and_libcares=yes
fi
AC_SUBST(found_libgtp_and_libcares)
PKG_CHECK_MODULES(LIBCARES, libcares)
dnl checks for header files
AC_HEADER_STDC
found_pcap=yes
AC_CHECK_HEADERS(pcap/pcap.h,,found_pcap=no)
AM_CONDITIONAL(HAVE_PCAP, test "$found_pcap" = yes)
found_cdk=yes
AC_CHECK_HEADERS(cdk/cdk.h,,found_cdk=no)
AM_CONDITIONAL(HAVE_LIBCDK, test "$found_cdk" = yes)
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 "
@ -102,12 +108,8 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
CFLAGS="$saved_CFLAGS"
AC_SUBST(SYMBOL_VISIBILITY)
AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
AX_CHECK_COMPILE_FLAG([-Werror=null-dereference], [CFLAGS="$CFLAGS -Werror=null-dereference"])
AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
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])
@ -148,42 +150,101 @@ AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
CHECK_TM_INCLUDES_TM_GMTOFF
AC_ARG_ENABLE([vty_tests],
AC_HELP_STRING([--enable-vty-tests],
[Include the VTY/CTRL tests in make check (deprecated)
[default=no]]),
[enable_ext_tests="$enableval"],[enable_ext_tests="no"])
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
AM_PATH_PYTHON
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 git://osmocom.org/python/osmo-python-tests to run the VTY/CTRL tests.])
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(bscconfig.h)
AM_CONFIG_HEADER(config.h)
AC_OUTPUT(
osmo-sgsn.pc
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/gbproxy/Makefile
tests/sgsn/Makefile
tests/oap/Makefile
tests/gtphub/Makefile
tests/xid/Makefile
tests/sndcp_xid/Makefile
@ -191,5 +252,7 @@ AC_OUTPUT(
tests/v42bis/Makefile
doc/Makefile
doc/examples/Makefile
doc/manuals/Makefile
contrib/Makefile
contrib/systemd/Makefile
Makefile)

View File

@ -1 +1 @@
EXTRA_DIST = ipa.py
SUBDIRS = systemd

View File

@ -1,58 +0,0 @@
#!/usr/bin/env python
"""
demonstrate a unblock bug on the GB Proxy..
"""
bts_ns_reset = "\x02\x00\x81\x01\x01\x82\x1f\xe7\x04\x82\x1f\xe7"
ns_reset_ack = "\x03\x01\x82\x1f\xe7\x04\x82\x1f\xe7"
bts_ns_unblock = "\x06"
ns_unblock_ack = "\x07"
bts_bvc_reset_0 = "\x00\x00\x00\x00\x22\x04\x82\x00\x00\x07\x81\x03\x3b\x81\x02"
ns_bvc_reset_0_ack = "\x00\x00\x00\x00\x23\x04\x82\x00\x00"
bts_bvc_reset_8167 = "\x00\x00\x00\x00\x22\x04\x82\x1f\xe7\x07\x81\x08\x08\x88\x72\xf4\x80\x10\x1c\x00\x9c\x40"
import socket
socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
socket.bind(("0.0.0.0", 0))
socket.setblocking(1)
import sys
port = int(sys.argv[1])
print "Sending data to port: %d" % port
def send_and_receive(packet):
socket.sendto(packet, ("127.0.0.1", port))
try:
data, addr = socket.recvfrom(4096)
except socket.error, e:
print "ERROR", e
import sys
sys.exit(0)
return data
#send stuff once
to_send = [
(bts_ns_reset, ns_reset_ack, "reset ack"),
(bts_ns_unblock, ns_unblock_ack, "unblock ack"),
(bts_bvc_reset_0, ns_bvc_reset_0_ack, "BVCI=0 reset ack"),
]
for (out, inp, type) in to_send:
res = send_and_receive(out)
if res != inp:
print "Failed to get the %s" % type
sys.exit(-1)
import time
time.sleep(3)
res = send_and_receive(bts_bvc_reset_8167)
print "Sent all messages... check wireshark for the last response"

View File

@ -1,278 +0,0 @@
#!/usr/bin/python3
# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
"""
/*
* Copyright (C) 2016 sysmocom s.f.m.c. GmbH
*
* All Rights Reserved
*
* 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
"""
import struct, random, sys
class IPA(object):
"""
Stateless IPA protocol multiplexer: add/remove/parse (extended) header
"""
version = "0.0.5"
TCP_PORT_OML = 3002
TCP_PORT_RSL = 3003
# OpenBSC extensions: OSMO, MGCP_OLD
PROTO = dict(RSL=0x00, CCM=0xFE, SCCP=0xFD, OML=0xFF, OSMO=0xEE, MGCP_OLD=0xFC)
# ...OML Router Control, GSUP GPRS extension, Osmocom Authn Protocol
EXT = dict(CTRL=0, MGCP=1, LAC=2, SMSC=3, ORC=4, GSUP=5, OAP=6)
# OpenBSC extension: SCCP_OLD
MSGT = dict(PING=0x00, PONG=0x01, ID_GET=0x04, ID_RESP=0x05, ID_ACK=0x06, SCCP_OLD=0xFF)
_IDTAG = dict(SERNR=0, UNITNAME=1, LOCATION=2, TYPE=3, EQUIPVERS=4, SWVERSION=5, IPADDR=6, MACADDR=7, UNIT=8)
CTRL_GET = 'GET'
CTRL_SET = 'SET'
CTRL_REP = 'REPLY'
CTRL_ERR = 'ERR'
CTRL_TRAP = 'TRAP'
def _l(self, d, p):
"""
Reverse dictionary lookup: return key for a given value
"""
if p is None:
return 'UNKNOWN'
return list(d.keys())[list(d.values()).index(p)]
def _tag(self, t, v):
"""
Create TAG as TLV data
"""
return struct.pack(">HB", len(v) + 1, t) + v
def proto(self, p):
"""
Lookup protocol name
"""
return self._l(self.PROTO, p)
def ext(self, p):
"""
Lookup protocol extension name
"""
return self._l(self.EXT, p)
def msgt(self, p):
"""
Lookup message type name
"""
return self._l(self.MSGT, p)
def idtag(self, p):
"""
Lookup ID tag name
"""
return self._l(self._IDTAG, p)
def ext_name(self, proto, exten):
"""
Return proper extension byte name depending on the protocol used
"""
if self.PROTO['CCM'] == proto:
return self.msgt(exten)
if self.PROTO['OSMO'] == proto:
return self.ext(exten)
return None
def add_header(self, data, proto, ext=None):
"""
Add IPA header (with extension if necessary), data must be represented as bytes
"""
if ext is None:
return struct.pack(">HB", len(data) + 1, proto) + data
return struct.pack(">HBB", len(data) + 1, proto, ext) + data
def del_header(self, data):
"""
Strip IPA protocol header correctly removing extension if present
Returns data length, IPA protocol, extension (or None if not defined for a give protocol) and the data without header
"""
if not len(data):
return None, None, None, None
(dlen, proto) = struct.unpack('>HB', data[:3])
if self.PROTO['OSMO'] == proto or self.PROTO['CCM'] == proto: # there's extension which we have to unpack
return struct.unpack('>HBB', data[:4]) + (data[4:], ) # length, protocol, extension, data
return dlen, proto, None, data[3:] # length, protocol, _, data
def split_combined(self, data):
"""
Split the data which contains multiple concatenated IPA messages into tuple (first, rest) where rest contains remaining messages, first is the single IPA message
"""
(length, _, _, _) = self.del_header(data)
return data[:(length + 3)], data[(length + 3):]
def tag_serial(self, data):
"""
Make TAG for serial number
"""
return self._tag(self._IDTAG['SERNR'], data)
def tag_name(self, data):
"""
Make TAG for unit name
"""
return self._tag(self._IDTAG['UNITNAME'], data)
def tag_loc(self, data):
"""
Make TAG for location
"""
return self._tag(self._IDTAG['LOCATION'], data)
def tag_type(self, data):
"""
Make TAG for unit type
"""
return self._tag(self._IDTAG['TYPE'], data)
def tag_equip(self, data):
"""
Make TAG for equipment version
"""
return self._tag(self._IDTAG['EQUIPVERS'], data)
def tag_sw(self, data):
"""
Make TAG for software version
"""
return self._tag(self._IDTAG['SWVERSION'], data)
def tag_ip(self, data):
"""
Make TAG for IP address
"""
return self._tag(self._IDTAG['IPADDR'], data)
def tag_mac(self, data):
"""
Make TAG for MAC address
"""
return self._tag(self._IDTAG['MACADDR'], data)
def tag_unit(self, data):
"""
Make TAG for unit ID
"""
return self._tag(self._IDTAG['UNIT'], data)
def identity(self, unit=b'', mac=b'', location=b'', utype=b'', equip=b'', sw=b'', name=b'', serial=b''):
"""
Make IPA IDENTITY tag list, by default returns empty concatenated bytes of tag list
"""
return self.tag_unit(unit) + self.tag_mac(mac) + self.tag_loc(location) + self.tag_type(utype) + self.tag_equip(equip) + self.tag_sw(sw) + self.tag_name(name) + self.tag_serial(serial)
def ping(self):
"""
Make PING message
"""
return self.add_header(b'', self.PROTO['CCM'], self.MSGT['PING'])
def pong(self):
"""
Make PONG message
"""
return self.add_header(b'', self.PROTO['CCM'], self.MSGT['PONG'])
def id_ack(self):
"""
Make ID_ACK CCM message
"""
return self.add_header(b'', self.PROTO['CCM'], self.MSGT['ID_ACK'])
def id_get(self):
"""
Make ID_GET CCM message
"""
return self.add_header(self.identity(), self.PROTO['CCM'], self.MSGT['ID_GET'])
def id_resp(self, data):
"""
Make ID_RESP CCM message
"""
return self.add_header(data, self.PROTO['CCM'], self.MSGT['ID_RESP'])
class Ctrl(IPA):
"""
Osmocom CTRL protocol implemented on top of IPA multiplexer
"""
def __init__(self):
random.seed()
def add_header(self, data):
"""
Add CTRL header
"""
return super(Ctrl, self).add_header(data.encode('utf-8'), IPA.PROTO['OSMO'], IPA.EXT['CTRL'])
def rem_header(self, data):
"""
Remove CTRL header, check for appropriate protocol and extension
"""
(_, proto, ext, d) = super(Ctrl, self).del_header(data)
if self.PROTO['OSMO'] != proto or self.EXT['CTRL'] != ext:
return None
return d
def parse(self, data, op=None):
"""
Parse Ctrl string returning (var, value) pair
var could be None in case of ERROR message
value could be None in case of GET message
"""
(s, i, v) = data.split(' ', 2)
if s == self.CTRL_ERR:
return None, v
if s == self.CTRL_GET:
return v, None
(s, i, var, val) = data.split(' ', 3)
if s == self.CTRL_TRAP and i != '0':
return None, '%s with non-zero id %s' % (s, i)
if op is not None and i != op:
if s == self.CTRL_GET + '_' + self.CTRL_REP or s == self.CTRL_SET + '_' + self.CTRL_REP:
return None, '%s with unexpected id %s' % (s, i)
return var, val
def trap(self, var, val):
"""
Make TRAP message with given (vak, val) pair
"""
return self.add_header("%s 0 %s %s" % (self.CTRL_TRAP, var, val))
def cmd(self, var, val=None):
"""
Make SET/GET command message: returns (r, m) tuple where r is random operation id and m is assembled message
"""
r = random.randint(1, sys.maxsize)
if val is not None:
return r, self.add_header("%s %s %s %s" % (self.CTRL_SET, r, var, val))
return r, self.add_header("%s %s %s" % (self.CTRL_GET, r, var))
def verify(self, reply, r, var, val=None):
"""
Verify reply to SET/GET command: returns (b, v) tuple where v is True/False verification result and v is the variable value
"""
(k, v) = self.parse(reply)
if k != var or (val is not None and v != val):
return False, v
return True, v
if __name__ == '__main__':
print("IPA multiplexer v%s loaded." % IPA.version)

View File

@ -1,5 +1,11 @@
#!/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 !"
@ -24,10 +30,12 @@ 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
@ -36,6 +44,12 @@ if [ "x$IU" = "x--enable-iu" ]; then
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
@ -46,13 +60,18 @@ set -x
cd "$base"
autoreconf --install --force
./configure --enable-osmo-bsc --enable-nat $SMPP $MGCP $IU --enable-vty-tests --enable-external-tests
./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-osmo-bsc --enable-nat $SMPP $MGCP $IU --enable-vty-tests --enable-external-tests" \
$MAKE distcheck \
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

@ -1,188 +0,0 @@
#!/usr/bin/python3
# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
"""
/*
* Copyright (C) 2016 sysmocom s.f.m.c. GmbH
*
* All Rights Reserved
*
* 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
"""
__version__ = "v0.7" # bump this on every non-trivial change
from twisted.internet import defer, reactor
from twisted_ipa import CTRL, IPAFactory, __version__ as twisted_ipa_version
from ipa import Ctrl
from treq import post, collect
from suds.client import Client
from functools import partial
from distutils.version import StrictVersion as V # FIXME: use NormalizedVersion from PEP-386 when available
import argparse, datetime, signal, sys, os, logging, logging.handlers
# we don't support older versions of TwistedIPA module
assert V(twisted_ipa_version) > V('0.4')
# keys from OpenBSC openbsc/src/libbsc/bsc_rf_ctrl.c, values SOAP-specific
oper = { 'inoperational' : 0, 'operational' : 1 }
admin = { 'locked' : 0, 'unlocked' : 1 }
policy = { 'off' : 0, 'on' : 1, 'grace' : 2, 'unknown' : 3 }
# keys from OpenBSC openbsc/src/libbsc/bsc_vty.c
fix = { 'invalid' : 0, 'fix2d' : 1, 'fix3d' : 1 } # SOAP server treats it as boolean but expects int
def handle_reply(p, f, log, r):
"""
Reply handler: takes function p to process raw SOAP server reply r, function f to run for each command and verbosity flag v
"""
repl = p(r) # result is expected to have both commands[] array and error string (could be None)
bsc_id = repl.commands[0].split()[0].split('.')[3] # we expect 1st command to have net.0.bsc.666.bts.2.trx.1 location prefix format
log.info("Received SOAP response for BSC %s with %d commands, error status: %s" % (bsc_id, len(repl.commands), repl.error))
log.debug("BSC %s commands: %s" % (bsc_id, repl.commands))
for t in repl.commands: # Process OpenBscCommands format from .wsdl
(_, m) = Ctrl().cmd(*t.split())
f(m)
class Trap(CTRL):
"""
TRAP handler (agnostic to factory's client object)
"""
def ctrl_TRAP(self, data, op_id, v):
"""
Parse CTRL TRAP and dispatch to appropriate handler after normalization
"""
(l, r) = v.split()
loc = l.split('.')
t_type = loc[-1]
p = partial(lambda a, i: a[i] if len(a) > i else None, loc) # parse helper
method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda: "Unhandled %s trap" % t_type)
method(p(1), p(3), p(5), p(7), r) # we expect net.0.bsc.666.bts.2.trx.1 format for trap prefix
def ctrl_SET_REPLY(self, data, _, v):
"""
Debug log for replies to our commands
"""
self.factory.log.debug('SET REPLY %s' % v)
def ctrl_ERROR(self, data, op_id, v):
"""
We want to know if smth went wrong
"""
self.factory.log.debug('CTRL ERROR [%s] %s' % (op_id, v))
def connectionMade(self):
"""
Logging wrapper, calling super() is necessary not to break reconnection logic
"""
self.factory.log.info("Connected to CTRL@%s:%d" % (self.factory.host, self.factory.port))
super(CTRL, self).connectionMade()
@defer.inlineCallbacks
def handle_locationstate(self, net, bsc, bts, trx, data):
"""
Handle location-state TRAP: parse trap content, build SOAP context and use treq's routines to post it while setting up async handlers
"""
(ts, fx, lat, lon, height, opr, adm, pol, mcc, mnc) = data.split(',')
tstamp = datetime.datetime.fromtimestamp(float(ts)).isoformat()
self.factory.log.debug('location-state@%s.%s.%s.%s (%s) [%s/%s] => %s' % (net, bsc, bts, trx, tstamp, mcc, mnc, data))
ctx = self.factory.client.registerSiteLocation(bsc, float(lon), float(lat), fix.get(fx, 0), tstamp, oper.get(opr, 2), admin.get(adm, 2), policy.get(pol, 3))
d = post(self.factory.location, ctx.envelope)
d.addCallback(collect, partial(handle_reply, ctx.process_reply, self.transport.write, self.factory.log)) # treq's collect helper is handy to get all reply content at once using closure on ctx
d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error %s while trying to register BSC %s" % (e, bsc)), bsc) # handle HTTP errors
# Ensure that we run only limited number of requests in parallel:
yield self.factory.semaphore.acquire()
yield d # we end up here only if semaphore is available which means it's ok to fire the request without exceeding the limit
self.factory.semaphore.release()
def handle_notificationrejectionv1(self, net, bsc, bts, trx, data):
"""
Handle notification-rejection-v1 TRAP: just an example to show how more message types can be handled
"""
self.factory.log.debug('notification-rejection-v1@bsc-id %s => %s' % (bsc, data))
class TrapFactory(IPAFactory):
"""
Store SOAP client object so TRAP handler can use it for requests
"""
location = None
log = None
semaphore = None
client = None
host = None
port = None
def __init__(self, host, port, proto, semaphore, log, wsdl=None, location=None):
self.host = host # for logging only,
self.port = port # seems to be no way to get it from ReconnectingClientFactory
self.log = log
self.semaphore = semaphore
soap = Client(wsdl, location=location, nosend=True) # make async SOAP client
self.location = location.encode() if location else soap.wsdl.services[0].ports[0].location # necessary for dispatching HTTP POST via treq
self.client = soap.service
level = self.log.getEffectiveLevel()
self.log.setLevel(logging.WARNING) # we do not need excessive debug from lower levels
super(TrapFactory, self).__init__(proto, self.log)
self.log.setLevel(level)
self.log.debug("Using IPA %s, SUDS client: %s" % (Ctrl.version, soap))
def reloader(path, script, log, dbg1, dbg2, signum, _):
"""
Signal handler: we have to use execl() because twisted's reactor is not restartable due to some bug in twisted implementation
"""
log.info("Received Signal %d - restarting..." % signum)
if signum == signal.SIGUSR1 and dbg1 not in sys.argv and dbg2 not in sys.argv:
sys.argv.append(dbg1) # enforce debug
if signum == signal.SIGUSR2 and (dbg1 in sys.argv or dbg2 in sys.argv): # disable debug
if dbg1 in sys.argv:
sys.argv.remove(dbg1)
if dbg2 in sys.argv:
sys.argv.remove(dbg2)
os.execl(path, script, *sys.argv[1:])
if __name__ == '__main__':
p = argparse.ArgumentParser(description='Proxy between given SOAP service and Osmocom CTRL protocol.')
p.add_argument('-v', '--version', action='version', version=("%(prog)s " + __version__))
p.add_argument('-p', '--port', type=int, default=4250, help="Port to use for CTRL interface, defaults to 4250")
p.add_argument('-c', '--ctrl', default='localhost', help="Adress to use for CTRL interface, defaults to localhost")
p.add_argument('-w', '--wsdl', required=True, help="WSDL URL for SOAP")
p.add_argument('-n', '--num', type=int, default=5, help="Max number of concurrent HTTP requests to SOAP server")
p.add_argument('-d', '--debug', action='store_true', help="Enable debug log")
p.add_argument('-o', '--output', action='store_true', help="Log to STDOUT in addition to SYSLOG")
p.add_argument('-l', '--location', help="Override location found in WSDL file (don't use unless you know what you're doing)")
args = p.parse_args()
log = logging.getLogger('CTRL2SOAP')
if args.debug:
log.setLevel(logging.DEBUG)
else:
log.setLevel(logging.INFO)
log.addHandler(logging.handlers.SysLogHandler('/dev/log'))
if args.output:
log.addHandler(logging.StreamHandler(sys.stdout))
reboot = partial(reloader, os.path.abspath(__file__), os.path.basename(__file__), log, '-d', '--debug') # keep in sync with add_argument() call above
signal.signal(signal.SIGHUP, reboot)
signal.signal(signal.SIGQUIT, reboot)
signal.signal(signal.SIGUSR1, reboot) # restart and enabled debug output
signal.signal(signal.SIGUSR2, reboot) # restart and disable debug output
log.info("SOAP proxy %s starting with PID %d ..." % (__version__, os.getpid()))
reactor.connectTCP(args.ctrl, args.port, TrapFactory(args.ctrl, args.port, Trap, defer.DeferredSemaphore(args.num), log, args.wsdl, args.location))
reactor.run()

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

@ -1,12 +0,0 @@
[Unit]
Description=Osmocom Gb proxy
[Service]
Type=simple
ExecStart=/usr/bin/osmo-gbproxy -c /etc/osmocom/osmo-gbproxy.cfg
Restart=always
RestartSec=2
RestartPreventExitStatus=1
[Install]
WantedBy=multi-user.target

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

@ -1,12 +1,18 @@
[Unit]
Description=OpenBSC SGSN
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

View File

@ -1,384 +0,0 @@
#!/usr/bin/python3
# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
"""
/*
* Copyright (C) 2016 sysmocom s.f.m.c. GmbH
*
* All Rights Reserved
*
* 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
"""
__version__ = "0.6" # bump this on every non-trivial change
from ipa import Ctrl, IPA
from twisted.internet.protocol import ReconnectingClientFactory
from twisted.internet import reactor
from twisted.protocols import basic
import argparse, logging
class IPACommon(basic.Int16StringReceiver):
"""
Generic IPA protocol handler: include some routines for simpler subprotocols.
It's not intended as full implementation of all subprotocols, rather common ground and example code.
"""
def dbg(self, line):
"""
Debug print helper
"""
self.factory.log.debug(line)
def osmo_CTRL(self, data):
"""
OSMO CTRL protocol
Placeholder, see corresponding derived class
"""
pass
def osmo_MGCP(self, data):
"""
OSMO MGCP extension
"""
self.dbg('OSMO MGCP received %s' % data)
def osmo_LAC(self, data):
"""
OSMO LAC extension
"""
self.dbg('OSMO LAC received %s' % data)
def osmo_SMSC(self, data):
"""
OSMO SMSC extension
"""
self.dbg('OSMO SMSC received %s' % data)
def osmo_ORC(self, data):
"""
OSMO ORC extension
"""
self.dbg('OSMO ORC received %s' % data)
def osmo_GSUP(self, data):
"""
OSMO GSUP extension
"""
self.dbg('OSMO GSUP received %s' % data)
def osmo_OAP(self, data):
"""
OSMO OAP extension
"""
self.dbg('OSMO OAP received %s' % data)
def osmo_UNKNOWN(self, data):
"""
OSMO defaul extension handler
"""
self.dbg('OSMO unknown extension received %s' % data)
def handle_RSL(self, data, proto, extension):
"""
RSL protocol handler
"""
self.dbg('IPA RSL received message with extension %s' % extension)
def handle_CCM(self, data, proto, msgt):
"""
CCM (IPA Connection Management)
Placeholder, see corresponding derived class
"""
pass
def handle_SCCP(self, data, proto, extension):
"""
SCCP protocol handler
"""
self.dbg('IPA SCCP received message with extension %s' % extension)
def handle_OML(self, data, proto, extension):
"""
OML protocol handler
"""
self.dbg('IPA OML received message with extension %s' % extension)
def handle_OSMO(self, data, proto, extension):
"""
Dispatcher point for OSMO subprotocols based on extension name, lambda default should never happen
"""
method = getattr(self, 'osmo_' + IPA().ext(extension), lambda: "extension dispatch failure")
method(data)
def handle_MGCP(self, data, proto, extension):
"""
MGCP protocol handler
"""
self.dbg('IPA MGCP received message with attribute %s' % extension)
def handle_UNKNOWN(self, data, proto, extension):
"""
Default protocol handler
"""
self.dbg('IPA received message for %s (%s) protocol with attribute %s' % (IPA().proto(proto), proto, extension))
def process_chunk(self, data):
"""
Generic message dispatcher for IPA (sub)protocols based on protocol name, lambda default should never happen
"""
(_, proto, extension, content) = IPA().del_header(data)
if content is not None:
self.dbg('IPA received %s::%s [%d/%d] %s' % (IPA().proto(proto), IPA().ext_name(proto, extension), len(data), len(content), content))
method = getattr(self, 'handle_' + IPA().proto(proto), lambda: "protocol dispatch failure")
method(content, proto, extension)
def dataReceived(self, data):
"""
Override for dataReceived from Int16StringReceiver because of inherently incompatible interpretation of length
If default handler is used than we would always get off-by-1 error (Int16StringReceiver use equivalent of l + 2)
"""
if len(data):
(head, tail) = IPA().split_combined(data)
self.process_chunk(head)
self.dataReceived(tail)
def connectionMade(self):
"""
We have to resetDelay() here to drop internal state to default values to make reconnection logic work
Make sure to call this via super() if overriding to keep reconnection logic intact
"""
addr = self.transport.getPeer()
self.dbg('IPA connected to %s:%d peer' % (addr.host, addr.port))
self.factory.resetDelay()
class CCM(IPACommon):
"""
Implementation of CCM protocol for IPA multiplex
"""
def ack(self):
self.transport.write(IPA().id_ack())
def ping(self):
self.transport.write(IPA().ping())
def pong(self):
self.transport.write(IPA().pong())
def handle_CCM(self, data, proto, msgt):
"""
CCM (IPA Connection Management)
Only basic logic necessary for tests is implemented (ping-pong, id ack etc)
"""
if msgt == IPA.MSGT['ID_GET']:
self.transport.getHandle().sendall(IPA().id_resp(self.factory.ccm_id))
# if we call
# self.transport.write(IPA().id_resp(self.factory.test_id))
# instead, than we would have to also call
# reactor.callLater(1, self.ack)
# instead of self.ack()
# otherwise the writes will be glued together - hence the necessity for ugly hack with 1s timeout
# Note: this still might work depending on the IPA implementation details on the other side
self.ack()
# schedule PING in 4s
reactor.callLater(4, self.ping)
if msgt == IPA.MSGT['PING']:
self.pong()
class CTRL(IPACommon):
"""
Implementation of Osmocom control protocol for IPA multiplex
"""
def ctrl_SET(self, data, op_id, v):
"""
Handle CTRL SET command
"""
self.dbg('CTRL SET [%s] %s' % (op_id, v))
def ctrl_SET_REPLY(self, data, op_id, v):
"""
Handle CTRL SET reply
"""
self.dbg('CTRL SET REPLY [%s] %s' % (op_id, v))
def ctrl_GET(self, data, op_id, v):
"""
Handle CTRL GET command
"""
self.dbg('CTRL GET [%s] %s' % (op_id, v))
def ctrl_GET_REPLY(self, data, op_id, v):
"""
Handle CTRL GET reply
"""
self.dbg('CTRL GET REPLY [%s] %s' % (op_id, v))
def ctrl_TRAP(self, data, op_id, v):
"""
Handle CTRL TRAP command
"""
self.dbg('CTRL TRAP [%s] %s' % (op_id, v))
def ctrl_ERROR(self, data, op_id, v):
"""
Handle CTRL ERROR reply
"""
self.dbg('CTRL ERROR [%s] %s' % (op_id, v))
def osmo_CTRL(self, data):
"""
OSMO CTRL message dispatcher, lambda default should never happen
For basic tests only, appropriate handling routines should be replaced: see CtrlServer for example
"""
self.dbg('OSMO CTRL received %s::%s' % Ctrl().parse(data.decode('utf-8')))
(cmd, op_id, v) = data.decode('utf-8').split(' ', 2)
method = getattr(self, 'ctrl_' + cmd, lambda: "CTRL unknown command")
method(data, op_id, v)
class IPAServer(CCM):
"""
Test implementation of IPA server
Demonstrate CCM opearation by overriding necessary bits from CCM
"""
def connectionMade(self):
"""
Keep reconnection logic working by calling routine from CCM
Initiate CCM upon connection
"""
addr = self.transport.getPeer()
self.factory.log.info('IPA server: connection from %s:%d client' % (addr.host, addr.port))
super(IPAServer, self).connectionMade()
self.transport.write(IPA().id_get())
class CtrlServer(CTRL):
"""
Test implementation of CTRL server
Demonstarte CTRL handling by overriding simpler routines from CTRL
"""
def connectionMade(self):
"""
Keep reconnection logic working by calling routine from CTRL
Send TRAP upon connection
Note: we can't use sendString() because of it's incompatibility with IPA interpretation of length prefix
"""
addr = self.transport.getPeer()
self.factory.log.info('CTRL server: connection from %s:%d client' % (addr.host, addr.port))
super(CtrlServer, self).connectionMade()
self.transport.write(Ctrl().trap('LOL', 'what'))
self.transport.write(Ctrl().trap('rulez', 'XXX'))
def reply(self, r):
self.transport.write(Ctrl().add_header(r))
def ctrl_SET(self, data, op_id, v):
"""
CTRL SET command: always succeed
"""
self.dbg('SET [%s] %s' % (op_id, v))
self.reply('SET_REPLY %s %s' % (op_id, v))
def ctrl_GET(self, data, op_id, v):
"""
CTRL GET command: always fail
"""
self.dbg('GET [%s] %s' % (op_id, v))
self.reply('ERROR %s No variable found' % op_id)
class IPAFactory(ReconnectingClientFactory):
"""
Generic IPA Client Factory which can be used to store state for various subprotocols and manage connections
Note: so far we do not really need separate Factory for acting as a server due to protocol simplicity
"""
protocol = IPACommon
log = None
ccm_id = IPA().identity(unit=b'1515/0/1', mac=b'b0:0b:fa:ce:de:ad:be:ef', utype=b'sysmoBTS', name=b'StingRay', location=b'hell', sw=IPA.version.encode('utf-8'))
def __init__(self, proto=None, log=None, ccm_id=None):
if proto:
self.protocol = proto
if ccm_id:
self.ccm_id = ccm_id
if log:
self.log = log
else:
self.log = logging.getLogger('IPAFactory')
self.log.setLevel(logging.CRITICAL)
self.log.addHandler(logging.NullHandler)
def clientConnectionFailed(self, connector, reason):
"""
Only necessary for as debugging aid - if we can somehow set parent's class noisy attribute then we can omit this method
"""
self.log.warning('IPAFactory connection failed: %s' % reason.getErrorMessage())
ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
def clientConnectionLost(self, connector, reason):
"""
Only necessary for as debugging aid - if we can somehow set parent's class noisy attribute then we can omit this method
"""
self.log.warning('IPAFactory connection lost: %s' % reason.getErrorMessage())
ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
if __name__ == '__main__':
p = argparse.ArgumentParser("Twisted IPA (module v%s) app" % IPA.version)
p.add_argument('-v', '--version', action='version', version="%(prog)s v" + __version__)
p.add_argument('-p', '--port', type=int, default=4250, help="Port to use for CTRL interface")
p.add_argument('-d', '--host', default='localhost', help="Adress to use for CTRL interface")
cs = p.add_mutually_exclusive_group()
cs.add_argument("-c", "--client", action='store_true', help="asume client role")
cs.add_argument("-s", "--server", action='store_true', help="asume server role")
ic = p.add_mutually_exclusive_group()
ic.add_argument("--ipa", action='store_true', help="use IPA protocol")
ic.add_argument("--ctrl", action='store_true', help="use CTRL protocol")
args = p.parse_args()
test = False
log = logging.getLogger('TwistedIPA')
log.setLevel(logging.DEBUG)
log.addHandler(logging.StreamHandler(sys.stdout))
if args.ctrl:
if args.client:
# Start osmo-bsc to receive TRAP messages when osmo-bts-* connects to it
print('CTRL client, connecting to %s:%d' % (args.host, args.port))
reactor.connectTCP(args.host, args.port, IPAFactory(CTRL, log))
test = True
if args.server:
# Use bsc_control.py to issue set/get commands
print('CTRL server, listening on port %d' % args.port)
reactor.listenTCP(args.port, IPAFactory(CtrlServer, log))
test = True
if args.ipa:
if args.client:
# Start osmo-nitb which would initiate A-bis/IP session
print('IPA client, connecting to %s ports %d and %d' % (args.host, IPA.TCP_PORT_OML, IPA.TCP_PORT_RSL))
reactor.connectTCP(args.host, IPA.TCP_PORT_OML, IPAFactory(CCM, log))
reactor.connectTCP(args.host, IPA.TCP_PORT_RSL, IPAFactory(CCM, log))
test = True
if args.server:
# Start osmo-bts-* which would attempt to connect to us
print('IPA server, listening on ports %d and %d' % (IPA.TCP_PORT_OML, IPA.TCP_PORT_RSL))
reactor.listenTCP(IPA.TCP_PORT_RSL, IPAFactory(IPAServer, log))
reactor.listenTCP(IPA.TCP_PORT_OML, IPAFactory(IPAServer, log))
test = True
if test:
reactor.run()
else:
print("Please specify which protocol in which role you'd like to test.")

753
debian/changelog vendored
View File

@ -1,3 +1,756 @@
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 ]

2
debian/compat vendored
View File

@ -1 +1 @@
9
10

52
debian/control vendored
View File

@ -1,26 +1,29 @@
Source: osmo-sgsn
Section: net
Priority: extra
Maintainer: Alexander Couzens <lynxis@fe80.eu>
Build-Depends: debhelper (>=9),
Maintainer: Osmocom team <openbsc@lists.osmocom.org>
Build-Depends: debhelper (>= 10),
dh-autoreconf,
autotools-dev,
autoconf,
automake,
libtool,
pkg-config,
libssl-dev,
libtalloc-dev,
libc-ares-dev,
libgtp-dev,
libosmocore-dev,
libosmo-abis-dev,
libosmo-ranap-dev,
libosmo-sccp-dev,
libosmo-netif-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: git://git.osmocom.org/osmo-sgsn.git
Vcs-Browser: https://git.osmocom.org/osmo-sgsn
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
@ -28,14 +31,14 @@ 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
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
Description: OsmoSGSN: Osmocom's Serving GPRS Support Node for 2G and 3G packet-switched mobile networks
Package: osmo-gtphub
Architecture: any
@ -49,18 +52,11 @@ Priority: extra
Depends: osmo-gtphub (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for Osmocom GTP Hub
Package: osmo-gbproxy
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends}
Recommends: osmo-sgsn
Description: Osmocom GPRS Gb Interface Proxy
The purpose of the Gb proxy is to aggregate the Gb links of multiple
BSS's and present them in one Gb link to the SGSN.
Package: osmo-gbproxy-dbg
Architecture: any
Section: debug
Priority: extra
Depends: osmo-gbproxy (= ${binary:Version}), ${misc:Depends}
Description: Debug symbols for Osmocom GPRS Gb Interface Proxy
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.

89
debian/copyright vendored
View File

@ -1,6 +1,6 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: osmo-sgsn
Source: git://git.osmocom.org/osmo-sgsn
Source: https://gitea.osmocom.org/cellular-infrastructure/osmo-sgsn
Files: .gitignore
.gitreview
@ -19,13 +19,10 @@ Files: .gitignore
contrib/ipa.py
contrib/jenkins.sh
contrib/soap.py
contrib/systemd/osmo-gbproxy.service
contrib/systemd/osmo-sgsn.service
contrib/twisted_ipa.py
doc/Makefile.am
doc/examples/Makefile.am
doc/examples/osmo-gbproxy/osmo-gbproxy-legacy.cfg
doc/examples/osmo-gbproxy/osmo-gbproxy.cfg
doc/examples/osmo-gtphub/gtphub-example.txt
doc/examples/osmo-gtphub/osmo-gtphub-1iface.cfg
doc/examples/osmo-gtphub/osmo-gtphub.cfg
@ -36,7 +33,6 @@ Files: .gitignore
include/osmocom/sgsn/crc24.h
include/osmocom/sgsn/debug.h
include/osmocom/sgsn/gb_proxy.h
include/osmocom/sgsn/gprs_gb_parse.h
include/osmocom/sgsn/gprs_gmm.h
include/osmocom/sgsn/gprs_llc.h
include/osmocom/sgsn/gprs_sgsn.h
@ -45,25 +41,18 @@ Files: .gitignore
include/osmocom/sgsn/sgsn.h
include/osmocom/sgsn/vty.h
m4/README
osmo-sgsn.pc.in
src/Makefile.am
src/gprs/.gitignore
src/gprs/Makefile.am
src/gprs/osmo_sgsn.cfg
src/libcommon/Makefile.am
src/libcommon/gsup_test_client.c
tests/Makefile.am
tests/atlocal.in
tests/gbproxy/Makefile.am
tests/gbproxy/gbproxy_test.ok
tests/gprs/Makefile.am
tests/gprs/gprs_test.c
tests/gprs/gprs_test.ok
tests/gtphub/Makefile.am
tests/gtphub/gtphub_test.ok
tests/oap/Makefile.am
tests/oap/oap_client_test.err
tests/oap/oap_client_test.ok
tests/sgsn/gprs_gb_parse.h
tests/sgsn/Makefile.am
tests/sgsn/sgsn_test.ok
tests/slhc/Makefile.am
@ -85,56 +74,35 @@ Files: include/osmocom/sgsn/a_reset.h
include/osmocom/sgsn/gprs_sndcp_pcomp.h
include/osmocom/sgsn/gprs_sndcp_xid.h
include/osmocom/sgsn/gprs_utils.h
include/osmocom/sgsn/gsup_client.h
include/osmocom/sgsn/gtphub.h
include/osmocom/sgsn/oap_client.h
include/osmocom/gtphub/gtphub.h
include/osmocom/sgsn/signal.h
src/gprs/crc24.c
src/gprs/gb_proxy.c
src/gprs/gb_proxy_main.c
src/gprs/gb_proxy_patch.c
src/gprs/gb_proxy_peer.c
src/gprs/gb_proxy_tlli.c
src/gprs/gb_proxy_vty.c
src/gprs/gprs_gb_parse.c
src/gprs/gprs_gmm.c
src/gprs/gprs_llc.c
src/gprs/gprs_llc_parse.c
src/gprs/gprs_llc_vty.c
src/gprs/gprs_llc_xid.c
src/gprs/gprs_sgsn.c
src/gprs/gprs_sndcp.c
src/gprs/gprs_sndcp_comp.c
src/gprs/gprs_sndcp_dcomp.c
src/gprs/gprs_sndcp_pcomp.c
src/gprs/gprs_sndcp_vty.c
src/gprs/gprs_sndcp_xid.c
src/gprs/gprs_subscriber.c
src/gprs/crc24.c
src/gprs/gprs_utils.c
src/gprs/gsup_client.c
src/gprs/gtphub.c
src/gprs/gtphub_main.c
src/gprs/gtphub_vty.c
src/gprs/oap_client.c
src/gprs/sgsn_ares.c
src/gprs/sgsn_auth.c
src/gprs/sgsn_cdr.c
src/gprs/sgsn_ctrl.c
src/gprs/sgsn_libgtp.c
src/gprs/sgsn_main.c
src/gprs/sgsn_vty.c
src/libcommon/bsc_version.c
src/libcommon/common_vty.c
src/libcommon/debug.c
src/libcommon/gsm_data.c
src/libcommon/gsm_data_shared.c
src/libcommon/gsm_subscriber_base.c
src/libcommon/gsup_client.c
src/libcommon/oap_client.c
src/libcommon/socket.c
src/libcommon/talloc_ctx.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/oap/oap_client_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
@ -161,9 +129,8 @@ License: AGPL-3.0+
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/gprs/gtphub_ares.c
src/gprs/gtphub_sock.c
tests/gbproxy/gbproxy_test.c
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

View File

@ -1,151 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: osmo-gbproxy
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Osmocom GBproxy
# Description: A tool to proxy the GPRS Gb interface.
### END INIT INFO
# Author: Harald Welte <laforge@gnumonks.org>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=osmo-gbproxy # Introduce the short server's name here
DESC="Osmocom GBProxy" # Introduce a short description here
DAEMON=/usr/bin/osmo-gbproxy # Introduce the server's location here
SCRIPTNAME=/etc/init.d/osmocom-gbproxy
CONFIG_FILE=/etc/osmocom/osmocom-gbproxy.cfg
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/osmocom-gbproxy ] && . /etc/default/osmocom-gbproxy
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
DAEMON_ARGS="-D -c $CONFIG_FILE"
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -1,2 +0,0 @@
usr/bin/osmo-gbproxy
usr/share/doc/osmo-sgsn/examples/osmo-gbproxy

View File

@ -1 +0,0 @@
../contrib/systemd/osmo-gbproxy.service

View File

@ -1,150 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: osmo-gtphub
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Osmocom GTP hub
# Description: Osmocom GTP hub
### END INIT INFO
# Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=osmo-gtphub # Introduce the short server's name here
DESC="Osmocom GTP hub" # Introduce a short description here
DAEMON=/usr/bin/osmo-gtphub # Introduce the server's location here
SCRIPTNAME=/etc/init.d/osmo-gtphub
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/osmo-gtphub ] && . /etc/default/osmo-gtphub
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
DAEMON_ARGS="$DAEMON_ARGS -D -c $CONFIG_FILE"
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
# and leave 'force-reload' as an alias for 'restart'.
#
#log_daemon_msg "Reloading $DESC" "$NAME"
#do_reload
#log_end_msg $?
#;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -1,2 +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
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

View File

@ -1,2 +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
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

View File

@ -1 +0,0 @@
../contrib/systemd/osmo-sgsn.service

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#

9
debian/rules vendored
View File

@ -46,8 +46,8 @@
# debmake generated override targets
# Set options for ./configure
CONFIGURE_FLAGS += --enable-iu
override_dh_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
@ -58,8 +58,11 @@ override_dh_configure:
override_dh_strip:
dh_strip -posmo-sgsn --dbg-package=osmo-sgsn-dbg
dh_strip -posmo-gtphub --dbg-package=osmo-gtphub-dbg
dh_strip -posmo-gbproxy --dbg-package=osmo-gbproxy-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

View File

@ -1,3 +1,4 @@
SUBDIRS = \
examples \
manuals \
$(NULL)

View File

@ -1,3 +1,13 @@
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),,'
dist-hook:

View File

@ -1,44 +0,0 @@
!
! OsmoGbProxy (UNKNOWN) configuration saved from vty
!!
!
log stderr
logging filter all 1
logging color 1
logging timestamp 0
logging level all debug
logging level gprs debug
logging level ns info
logging level bssgp debug
logging level lglobal notice
logging level llapd notice
logging level linp notice
logging level lmux notice
logging level lmi notice
logging level lmib notice
logging level lsms notice
!
line vty
no login
!
ns
nse 666 nsvci 666
nse 666 remote-role sgsn
! nse 666 encapsulation framerelay-gre
! nse 666 remote-ip 172.16.1.70
! nse 666 fr-dlci 666
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
encapsulation udp local-port 23000
! encapsulation framerelay-gre enabled 1
gbproxy
sgsn nsei 666
core-mobile-country-code 666
core-mobile-network-code 6
core-access-point-name none match-imsi ^666066|^66607
tlli-list max-length 200

View File

@ -1,25 +0,0 @@
!
! Osmocom Gb Proxy (0.9.0.404-6463) configuration saved from vty
!!
!
line vty
no login
!
gbproxy
sgsn nsei 101
ns
nse 101 nsvci 101
nse 101 remote-role sgsn
nse 101 encapsulation udp
nse 101 remote-ip 192.168.100.239
nse 101 remote-port 7777
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
encapsulation framerelay-gre enabled 0
encapsulation framerelay-gre local-ip 0.0.0.0
encapsulation udp local-port 23000

View File

@ -59,7 +59,7 @@ The LD_LIBRARY_PATH below may be needed if OpenGGSN installed to /usr/local.
2. GTPHub:
cd <your-test-dir>
path/to/openbsc/openbsc/src/gprs/osmo-gtphub -c gtphub.conf #-e 1 #for DEBUG level
path/to/openbsc/openbsc/src/gtphub/osmo-gtphub -c gtphub.conf #-e 1 #for DEBUG level
3. SGSN tests:

View File

@ -5,6 +5,14 @@
! 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

View File

@ -2,14 +2,22 @@
! 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.1
bind-to-ggsns 127.0.0.2
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

View File

@ -2,13 +2,24 @@
! 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
@ -19,9 +30,9 @@ ns
timer tns-test 30
timer tns-alive 3
timer tns-alive-retries 10
encapsulation udp local-ip 127.0.0.1
encapsulation udp local-port 23000
encapsulation framerelay-gre enabled 0
bind udp local
listen 127.0.0.1 23000
accept-ipaccess
!
bssgp
!

View File

@ -2,13 +2,24 @@
! 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
@ -21,9 +32,9 @@ ns
timer tns-test 30
timer tns-alive 3
timer tns-alive-retries 10
encapsulation udp local-ip 127.0.0.1
encapsulation udp local-port 23000
encapsulation framerelay-gre enabled 0
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,3 +1,4 @@
SUBDIRS = \
gtphub \
sgsn \
$(NULL)

View File

@ -0,0 +1,3 @@
noinst_HEADERS = \
gtphub.h \
$(NULL)

View File

@ -27,22 +27,20 @@
#include <osmocom/core/select.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/sgsn/gprs_sgsn.h>
#include <osmocom/gsm/apn.h>
/* support */
/* TODO move to osmocom/core/socket.c ? */
#include <netdb.h> /* for IPPROTO_* etc */
struct osmo_sockaddr {
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 osmo_sockaddr pointer to write result to
* \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
@ -53,16 +51,16 @@ struct osmo_sockaddr {
* 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 osmo_sockaddr_init(struct osmo_sockaddr *addr,
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
* osmo_sockaddr_init(). */
static inline int osmo_sockaddr_init_udp(struct osmo_sockaddr *addr,
* sgsn_sockaddr_init(). */
static inline int sgsn_sockaddr_init_udp(struct sgsn_sockaddr *addr,
const char *host, uint16_t port)
{
return osmo_sockaddr_init(addr, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP,
return sgsn_sockaddr_init(addr, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP,
host, port);
}
@ -71,25 +69,25 @@ static inline int osmo_sockaddr_init_udp(struct osmo_sockaddr *addr,
* \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 osmo_sockaddr_init().
* \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 osmo_sockaddr in two caller provided
* 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 osmo_sockaddr_to_str() (less flexible, but much more convenient). */
int osmo_sockaddr_to_strs(char *addr_str, size_t addr_str_len,
* 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 osmo_sockaddr *addr,
const struct sgsn_sockaddr *addr,
int flags);
/*! \brief concatenate the parts returned by osmo_sockaddr_to_strs().
* \param[in] addr Binary representation as returned by osmo_sockaddr_init().
/*! \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).
@ -98,33 +96,33 @@ int osmo_sockaddr_to_strs(char *addr_str, size_t addr_str_len,
* the form "<ip-addr> port <port>". The returned string is valid until the
* next invocation of this function.
*/
const char *osmo_sockaddr_to_strb(const struct osmo_sockaddr *addr,
const char *sgsn_sockaddr_to_strb(const struct sgsn_sockaddr *addr,
char *buf, size_t buf_len);
/*! \brief conveniently return osmo_sockaddr_to_strb() in a static buffer.
* \param[in] addr Binary representation as returned by osmo_sockaddr_init().
/*! \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 osmo_sockaddr_to_strb().
* See sgsn_sockaddr_to_strb().
*
* Note: only one osmo_sockaddr_to_str() call will work per print/log
* statement. For two or more, use osmo_sockaddr_to_strb() with a separate
* 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 *osmo_sockaddr_to_str(const struct osmo_sockaddr *addr);
const char *sgsn_sockaddr_to_str(const struct sgsn_sockaddr *addr);
/*! \brief compare two osmo_sockaddr.
/*! \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 osmo_sockaddr_cmp(const struct osmo_sockaddr *a,
const struct osmo_sockaddr *b);
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 osmo_sockaddr_copy(struct osmo_sockaddr *dst,
const struct osmo_sockaddr *src);
void sgsn_sockaddr_copy(struct sgsn_sockaddr *dst,
const struct sgsn_sockaddr *src);
/* general */
@ -179,7 +177,7 @@ 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 osmo_sockaddr *sa);
const struct sgsn_sockaddr *sa);
/* expiry */
@ -389,7 +387,7 @@ struct gtphub_peer_port {
struct gtphub_peer_addr *peer_addr;
uint16_t port;
unsigned int ref_count; /* references from other peers' seq_maps */
struct osmo_sockaddr sa; /* a "cache" for (peer_addr->addr, port) */
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;
@ -428,7 +426,7 @@ struct gtphub_resolved_ggsn {
/* 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[GSM_APN_LENGTH];
char apn_oi_str[APN_MAXLEN+1];
/* Which address and port we resolved that to. */
struct gtphub_peer_port *peer;
@ -496,13 +494,13 @@ 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 osmo_sockaddr *from_addr,
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 osmo_sockaddr *to_addr);
struct sgsn_sockaddr *to_addr);
struct gtphub_peer_port *gtphub_port_have(struct gtphub *hub,
struct gtphub_bind *bind,
@ -510,7 +508,7 @@ struct gtphub_peer_port *gtphub_port_have(struct gtphub *hub,
uint16_t port);
struct gtphub_peer_port *gtphub_port_find_sa(const struct gtphub_bind *bind,
const struct osmo_sockaddr *addr);
const struct sgsn_sockaddr *addr);
void gtphub_resolved_ggsn(struct gtphub *hub, const char *apn_oi_str,
struct gsn_addr *resolved_addr,
@ -519,5 +517,5 @@ void gtphub_resolved_ggsn(struct gtphub *hub, const char *apn_oi_str,
const char *gtphub_port_str(struct gtphub_peer_port *port);
int gtphub_write(const struct osmo_fd *to,
const struct osmo_sockaddr *to_addr,
const struct sgsn_sockaddr *to_addr,
const uint8_t *buf, size_t buf_len);

View File

@ -1,13 +1,20 @@
noinst_HEADERS = \
apn.h \
auth.h \
common.h \
crc24.h \
debug.h \
gb_proxy.h \
gprs_gb_parse.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_sgsn.h \
gprs_ranap.h \
gprs_sm.h \
gprs_sndcp_comp.h \
gprs_sndcp_dcomp.h \
gprs_sndcp.h \
@ -15,10 +22,13 @@ noinst_HEADERS = \
gprs_sndcp_xid.h \
gprs_subscriber.h \
gprs_utils.h \
gsup_client.h \
gtphub.h \
oap_client.h \
gtp.h \
gtp_ggsn.h \
gtp_mme.h \
mmctx.h \
pdpctx.h \
sgsn.h \
sgsn_rim.h \
signal.h \
slhc.h \
v42bis.h \

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

@ -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

@ -8,39 +8,25 @@
/* Debug Areas of the code */
enum {
DRLL,
DCC,
DMM,
DRR,
DRSL,
DNM,
DMNCC,
DPAG,
DMEAS,
DSCCP,
DMSC,
DMGCP,
DHO,
DDB,
DREF,
DGPRS,
DNS,
DBSSGP,
DLLC,
DSNDCP,
DSLHC,
DNAT,
DCTRL,
DSMPP,
DFILTER,
DGTPHUB,
DRANAP,
DSUA,
DV42BIS,
DPCU,
DVLR,
DIUCS,
DSIGTRAN,
DGTP,
DOBJ,
DRIM,
Debug_LastEntry,
};

View File

@ -1,288 +0,0 @@
#ifndef _GB_PROXY_H
#define _GB_PROXY_H
#include <osmocom/core/msgb.h>
#include <osmocom/gprs/gprs_ns.h>
#include <osmocom/vty/command.h>
#include <sys/types.h>
#include <regex.h>
#define GBPROXY_INIT_VU_GEN_TX 256
struct rate_ctr_group;
struct gprs_gb_parse_context;
struct tlv_parsed;
enum gbproxy_global_ctr {
GBPROX_GLOB_CTR_INV_BVCI,
GBPROX_GLOB_CTR_INV_LAI,
GBPROX_GLOB_CTR_INV_RAI,
GBPROX_GLOB_CTR_INV_NSEI,
GBPROX_GLOB_CTR_PROTO_ERR_BSS,
GBPROX_GLOB_CTR_PROTO_ERR_SGSN,
GBPROX_GLOB_CTR_NOT_SUPPORTED_BSS,
GBPROX_GLOB_CTR_NOT_SUPPORTED_SGSN,
GBPROX_GLOB_CTR_RESTART_RESET_SGSN,
GBPROX_GLOB_CTR_TX_ERR_SGSN,
GBPROX_GLOB_CTR_OTHER_ERR,
GBPROX_GLOB_CTR_PATCH_PEER_ERR,
};
enum gbproxy_peer_ctr {
GBPROX_PEER_CTR_BLOCKED,
GBPROX_PEER_CTR_UNBLOCKED,
GBPROX_PEER_CTR_DROPPED,
GBPROX_PEER_CTR_INV_NSEI,
GBPROX_PEER_CTR_TX_ERR,
GBPROX_PEER_CTR_RAID_PATCHED_BSS,
GBPROX_PEER_CTR_RAID_PATCHED_SGSN,
GBPROX_PEER_CTR_APN_PATCHED,
GBPROX_PEER_CTR_TLLI_PATCHED_BSS,
GBPROX_PEER_CTR_TLLI_PATCHED_SGSN,
GBPROX_PEER_CTR_PTMSI_PATCHED_BSS,
GBPROX_PEER_CTR_PTMSI_PATCHED_SGSN,
GBPROX_PEER_CTR_PATCH_CRYPT_ERR,
GBPROX_PEER_CTR_PATCH_ERR,
GBPROX_PEER_CTR_ATTACH_REQS,
GBPROX_PEER_CTR_ATTACH_REJS,
GBPROX_PEER_CTR_ATTACH_ACKS,
GBPROX_PEER_CTR_ATTACH_COMPLS,
GBPROX_PEER_CTR_RA_UPD_REQS,
GBPROX_PEER_CTR_RA_UPD_REJS,
GBPROX_PEER_CTR_RA_UPD_ACKS,
GBPROX_PEER_CTR_RA_UPD_COMPLS,
GBPROX_PEER_CTR_GMM_STATUS_BSS,
GBPROX_PEER_CTR_GMM_STATUS_SGSN,
GBPROX_PEER_CTR_DETACH_REQS,
GBPROX_PEER_CTR_DETACH_ACKS,
GBPROX_PEER_CTR_PDP_ACT_REQS,
GBPROX_PEER_CTR_PDP_ACT_REJS,
GBPROX_PEER_CTR_PDP_ACT_ACKS,
GBPROX_PEER_CTR_PDP_DEACT_REQS,
GBPROX_PEER_CTR_PDP_DEACT_ACKS,
GBPROX_PEER_CTR_TLLI_UNKNOWN,
GBPROX_PEER_CTR_TLLI_CACHE_SIZE,
GBPROX_PEER_CTR_LAST,
};
enum gbproxy_keep_mode {
GBPROX_KEEP_NEVER,
GBPROX_KEEP_REATTACH,
GBPROX_KEEP_IDENTIFIED,
GBPROX_KEEP_ALWAYS,
};
enum gbproxy_match_id {
GBPROX_MATCH_PATCHING,
GBPROX_MATCH_ROUTING,
GBPROX_MATCH_LAST
};
struct gbproxy_match {
int enable;
char *re_str;
regex_t re_comp;
};
struct gbproxy_config {
/* parsed from config file */
uint16_t nsip_sgsn_nsei;
/* misc */
struct gprs_ns_inst *nsi;
/* Linked list of all Gb peers (except SGSN) */
struct llist_head bts_peers;
/* Counter */
struct rate_ctr_group *ctrg;
/* force mcc/mnc */
int core_mnc;
int core_mcc;
uint8_t* core_apn;
size_t core_apn_size;
int tlli_max_age;
int tlli_max_len;
/* Experimental config */
int patch_ptmsi;
int acquire_imsi;
int route_to_sgsn2;
uint16_t nsip_sgsn2_nsei;
enum gbproxy_keep_mode keep_link_infos;
/* IMSI checking/matching */
struct gbproxy_match matches[GBPROX_MATCH_LAST];
};
struct gbproxy_patch_state {
int local_mnc;
int local_mcc;
/* List of TLLIs for which patching is enabled */
struct llist_head logical_links;
int logical_link_count;
};
struct gbproxy_peer {
struct llist_head list;
/* point back to the config */
struct gbproxy_config *cfg;
/* NSEI of the peer entity */
uint16_t nsei;
/* BVCI used for Point-to-Point to this peer */
uint16_t bvci;
int blocked;
/* Routeing Area that this peer is part of (raw 04.08 encoding) */
uint8_t ra[6];
/* Counter */
struct rate_ctr_group *ctrg;
struct gbproxy_patch_state patch_state;
};
struct gbproxy_tlli_state {
uint32_t current;
uint32_t assigned;
int bss_validated;
int net_validated;
uint32_t ptmsi;
};
struct gbproxy_link_info {
struct llist_head list;
struct gbproxy_tlli_state tlli;
struct gbproxy_tlli_state sgsn_tlli;
uint32_t sgsn_nsei;
time_t timestamp;
uint8_t *imsi;
size_t imsi_len;
int imsi_acq_pending;
struct llist_head stored_msgs;
unsigned vu_gen_tx_bss;
int is_deregistered;
int is_matching[GBPROX_MATCH_LAST];
};
/* gb_proxy_vty .c */
int gbproxy_vty_init(void);
int gbproxy_parse_config(const char *config_file, struct gbproxy_config *cfg);
/* gb_proxy.c */
int gbproxy_init_config(struct gbproxy_config *cfg);
/* Main input function for Gb proxy */
int gbprox_rcvmsg(struct gbproxy_config *cfg, struct msgb *msg, uint16_t nsei, uint16_t ns_bvci, uint16_t nsvci);
int gbprox_signal(unsigned int subsys, unsigned int signal,
void *handler_data, void *signal_data);
/* Reset all persistent NS-VC's */
int gbprox_reset_persistent_nsvcs(struct gprs_ns_inst *nsi);
void gbprox_reset(struct gbproxy_config *cfg);
/* TLLI info handling */
void gbproxy_delete_link_infos(struct gbproxy_peer *peer);
struct gbproxy_link_info *gbproxy_update_link_state_ul(
struct gbproxy_peer *peer, time_t now,
struct gprs_gb_parse_context *parse_ctx);
struct gbproxy_link_info *gbproxy_update_link_state_dl(
struct gbproxy_peer *peer, time_t now,
struct gprs_gb_parse_context *parse_ctx);
int gbproxy_update_link_state_after(
struct gbproxy_peer *peer, struct gbproxy_link_info *link_info,
time_t now, struct gprs_gb_parse_context *parse_ctx);
int gbproxy_remove_stale_link_infos(struct gbproxy_peer *peer, time_t now);
void gbproxy_delete_link_info(struct gbproxy_peer *peer,
struct gbproxy_link_info *link_info);
void gbproxy_link_info_discard_messages(struct gbproxy_link_info *link_info);
void gbproxy_attach_link_info(struct gbproxy_peer *peer, time_t now,
struct gbproxy_link_info *link_info);
void gbproxy_update_link_info(struct gbproxy_link_info *link_info,
const uint8_t *imsi, size_t imsi_len);
void gbproxy_detach_link_info(struct gbproxy_peer *peer,
struct gbproxy_link_info *link_info);
struct gbproxy_link_info *gbproxy_link_info_alloc( struct gbproxy_peer *peer);
struct gbproxy_link_info *gbproxy_link_info_by_tlli(
struct gbproxy_peer *peer, uint32_t tlli);
struct gbproxy_link_info *gbproxy_link_info_by_imsi(
struct gbproxy_peer *peer, const uint8_t *imsi, size_t imsi_len);
struct gbproxy_link_info *gbproxy_link_info_by_any_sgsn_tlli(
struct gbproxy_peer *peer, uint32_t tlli);
struct gbproxy_link_info *gbproxy_link_info_by_sgsn_tlli(
struct gbproxy_peer *peer,
uint32_t tlli, uint32_t sgsn_nsei);
struct gbproxy_link_info *gbproxy_link_info_by_ptmsi(
struct gbproxy_peer *peer,
uint32_t ptmsi);
int gbproxy_imsi_matches(
struct gbproxy_config *cfg,
enum gbproxy_match_id match_id,
struct gbproxy_link_info *link_info);
uint32_t gbproxy_map_tlli(
uint32_t other_tlli, struct gbproxy_link_info *link_info, int to_bss);
/* needed by gb_proxy_tlli.h */
uint32_t gbproxy_make_bss_ptmsi(struct gbproxy_peer *peer, uint32_t sgsn_ptmsi);
uint32_t gbproxy_make_sgsn_tlli(
struct gbproxy_peer *peer, struct gbproxy_link_info *link_info,
uint32_t bss_tlli);
void gbproxy_reset_link(struct gbproxy_link_info *link_info);
int gbproxy_check_imsi(
struct gbproxy_match *match, const uint8_t *imsi, size_t imsi_len);
/* Message patching */
void gbproxy_patch_bssgp(
struct msgb *msg, uint8_t *bssgp, size_t bssgp_len,
struct gbproxy_peer *peer, struct gbproxy_link_info *link_info,
int *len_change, struct gprs_gb_parse_context *parse_ctx);
int gbproxy_patch_llc(
struct msgb *msg, uint8_t *llc, size_t llc_len,
struct gbproxy_peer *peer, struct gbproxy_link_info *link_info,
int *len_change, struct gprs_gb_parse_context *parse_ctx);
int gbproxy_set_patch_filter(
struct gbproxy_match *match, const char *filter, const char **err_msg);
void gbproxy_clear_patch_filter(struct gbproxy_match *match);
/* Peer handling */
struct gbproxy_peer *gbproxy_peer_by_bvci(
struct gbproxy_config *cfg, uint16_t bvci);
struct gbproxy_peer *gbproxy_peer_by_nsei(
struct gbproxy_config *cfg, uint16_t nsei);
struct gbproxy_peer *gbproxy_peer_by_rai(
struct gbproxy_config *cfg, const uint8_t *ra);
struct gbproxy_peer *gbproxy_peer_by_lai(
struct gbproxy_config *cfg, const uint8_t *la);
struct gbproxy_peer *gbproxy_peer_by_lac(
struct gbproxy_config *cfg, const uint8_t *la);
struct gbproxy_peer *gbproxy_peer_by_bssgp_tlv(
struct gbproxy_config *cfg, struct tlv_parsed *tp);
struct gbproxy_peer *gbproxy_peer_alloc(struct gbproxy_config *cfg, uint16_t bvci);
void gbproxy_peer_free(struct gbproxy_peer *peer);
int gbproxy_cleanup_peers(struct gbproxy_config *cfg, uint16_t nsei, uint16_t bvci);
#endif

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

@ -1,21 +1,25 @@
#ifndef _GPRS_GMM_H
#define _GPRS_GMM_H
#include <osmocom/core/msgb.h>
#include <osmocom/sgsn/gprs_sgsn.h>
#include <stdbool.h>
int gsm48_tx_gsm_deact_pdp_req(struct sgsn_pdp_ctx *pdp, uint8_t sm_cause);
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);
#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_gprs_rcvmsg_iu(struct msgb *msg, struct gprs_ra_id *ra_id,
uint16_t *sai);
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);
@ -28,8 +32,25 @@ 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 iu_rab_act_ps(uint8_t rab_id, struct sgsn_pdp_ctx *pdp);
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,11 +1,16 @@
#ifndef _GPRS_LLC_H
#define _GPRS_LLC_H
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/sgsn/gprs_sgsn.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 {
GPRS_SAPI_GMM = 1,
@ -91,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 {
@ -110,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;
@ -145,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;
@ -169,13 +184,6 @@ struct gprs_llc_llme {
uint16_t nsei;
struct gprs_llc_lle lle[NUM_SAPIS];
/* 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;
/* Compression entities */
struct {
/* In these two list_heads we will store the
@ -191,6 +199,9 @@ struct gprs_llc_llme {
#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 */
@ -267,18 +278,15 @@ static inline int gprs_llc_is_retransmit(uint16_t nu, uint16_t vur)
}
/* LLC low level functions */
void gprs_llme_copy_key(struct sgsn_mm_ctx *mm, struct gprs_llc_llme *llme);
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(uint8_t *data, unsigned int len);
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);
#endif

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,484 +0,0 @@
#ifndef _GPRS_SGSN_H
#define _GPRS_SGSN_H
#include <stdint.h>
#include <netinet/in.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>
#define GSM_EXTENSION_LENGTH 15
#define GSM_APN_LENGTH 102
struct gprs_llc_lle;
struct ctrl_handle;
struct gprs_subscr;
enum gsm48_gsm_cause;
/* TS 04.08 4.1.3.3 GMM mobility management states on the network side */
enum gprs_gmm_state {
GMM_DEREGISTERED, /* 4.1.3.3.1.1 */
GMM_COMMON_PROC_INIT, /* 4.1.3.3.1.2 */
GMM_REGISTERED_NORMAL, /* 4.1.3.3.2.1 */
GMM_REGISTERED_SUSPENDED, /* 4.1.3.3.2.2 */
GMM_DEREGISTERED_INIT, /* 4.1.3.3.1.4 */
};
/* TS 23.060 6.1.1 and 6.1.2 Mobility management states A/Gb and Iu mode */
enum gprs_pmm_state {
PMM_DETACHED,
PMM_CONNECTED,
PMM_IDLE,
MM_IDLE,
MM_READY,
MM_STANDBY,
};
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_pdp_ctx {
PDP_CTR_PKTS_UDATA_IN,
PDP_CTR_PKTS_UDATA_OUT,
PDP_CTR_BYTES_UDATA_IN,
PDP_CTR_BYTES_UDATA_OUT,
};
enum gprs_t3350_mode {
GMM_T3350_MODE_NONE,
GMM_T3350_MODE_ATT,
GMM_T3350_MODE_RAU,
GMM_T3350_MODE_PTMSI_REALL,
};
/* Authorization/ACL handling */
enum sgsn_auth_state {
SGSN_AUTH_UNKNOWN,
SGSN_AUTH_AUTHENTICATE,
SGSN_AUTH_UMTS_RESYNC,
SGSN_AUTH_ACCEPTED,
SGSN_AUTH_REJECTED
};
#define MS_RADIO_ACCESS_CAPA
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,
/* GPRS/EDGE via Iu */
MM_CTX_T_GERAN_Iu,
};
struct service_info {
uint8_t type;
uint16_t pdp_status;
};
struct ranap_ue_conn_ctx;
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 */
/* 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];
enum gprs_gmm_state gmm_state;
enum gprs_pmm_state pmm_state; /* Iu: page when in PMM-IDLE mode */
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;
} 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;
} iu;
/* 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;
/* 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;
int is_authenticated;
/* 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;
};
#define LOGMMCTXP(level, mm, fmt, args...) \
LOGP(DMM, level, "MM(%s/%08x) " fmt, (mm) ? (mm)->imsi : "---", \
(mm) ? (mm)->p_tmsi : GSM_RESERVED_TMSI, ## args)
/* 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);
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 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)
/* 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);
struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm,
uint8_t nsapi);
void sgsn_pdp_ctx_terminate(struct sgsn_pdp_ctx *pdp);
void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp);
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 sgsn_ggsn_ctx *sgsn_ggsn_ctx_alloc(uint32_t id);
void sgsn_ggsn_ctx_free(struct sgsn_ggsn_ctx *ggc);
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_by_id(uint32_t id);
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_by_addr(struct in_addr *addr);
struct sgsn_ggsn_ctx *sgsn_ggsn_ctx_find_alloc(uint32_t id);
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);
extern struct llist_head sgsn_mm_ctxts;
extern struct llist_head sgsn_ggsn_ctxts;
extern struct llist_head sgsn_apn_ctxts;
extern struct llist_head sgsn_pdp_ctxts;
uint32_t sgsn_alloc_ptmsi(void);
void sgsn_inst_init(void);
/* High-level function to be called in case a GGSN has disappeared or
* ottherwise lost state (recovery procedure) */
int drop_all_pdp_for_ggsn(struct sgsn_ggsn_ctx *ggsn);
char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len);
/*
* ctrl interface related work
*/
struct gsm_network;
struct ctrl_handle *sgsn_controlif_setup(struct gsm_network *,
const char *bind_addr, uint16_t port);
int sgsn_ctrl_cmds_install(void);
/*
* Authorization/ACL handling
*/
struct imsi_acl_entry {
struct llist_head list;
char imsi[16+1];
};
/* 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;
uint16_t pdp_type;
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_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;
};
#define SGSN_ERROR_CAUSE_NONE (-1)
#define LOGGSUBSCRP(level, subscr, fmt, args...) \
LOGP(DGPRS, level, "SUBSCR(%s) " fmt, \
(subscr) ? (subscr)->imsi : "---", \
## args)
struct sgsn_config;
struct sgsn_instance;
extern const struct value_string *sgsn_auth_state_names;
void sgsn_auth_init(void);
struct imsi_acl_entry *sgsn_acl_lookup(const char *imsi, 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);
/* Request authorization */
int sgsn_auth_request(struct sgsn_mm_ctx *mm);
enum sgsn_auth_state sgsn_auth_state(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);
/*
* GPRS subscriber data
*/
#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 \
)
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);
int gprs_subscr_auth_sync(struct gprs_subscr *subscr,
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);
/* Called on subscriber data updates */
void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx);
int gprs_sndcp_vty_init(void);
struct sgsn_instance;
int sgsn_gtp_init(struct sgsn_instance *sgi);
void sgsn_rate_ctr_init();
#endif /* _GPRS_SGSN_H */

View File

@ -0,0 +1,18 @@
#pragma once
#include <osmocom/core/msgb.h>
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);
void pdp_ctx_detach_mm_ctx(struct sgsn_pdp_ctx *pdp);
int gsm0408_rcv_gsm(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
struct gprs_llc_llme *llme);

View File

@ -3,6 +3,9 @@
#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 {
@ -60,6 +63,8 @@ struct gprs_sndcp_entity {
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);
@ -68,7 +73,7 @@ int sndcp_sn_xid_req(struct gprs_llc_lle *lle, uint8_t nsapi);
* 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,
struct gprs_llc_lle *lle);
const struct gprs_llc_lle *lle);
/* Process SNDCP-XID indication
* (See also: TS 144 065, Section 6.8 XID parameter negotiation) */
@ -76,4 +81,21 @@ 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

@ -41,9 +41,9 @@ struct gprs_sndcp_comp {
uint8_t comp[MAX_COMP]; /* see also: 6.5.1.1.5 and 6.6.1.1.5 */
/* Algorithm parameters */
int algo; /* Algorithm type (see gprs_sndcp_xid.h) */
int compclass; /* See gprs_sndcp_xid.h/c */
void *state; /* Algorithm status and 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 */

View File

@ -32,6 +32,24 @@
#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) */
@ -45,7 +63,7 @@ struct gprs_sndcp_comp_field {
unsigned int entity;
/* Algorithm identifier, see also: 6.5.1.1.4 and 6.6.1.1.4 */
int algo;
union gprs_sndcp_comp_algo algo;
/* Number of contained PCOMP / DCOMP values */
uint8_t comp_len;
@ -62,24 +80,12 @@ struct gprs_sndcp_comp_field {
struct gprs_sndcp_dcomp_v44_params *v44_params;
};
/* 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 */
};
/* 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) */
@ -209,7 +215,7 @@ struct llist_head *gprs_sndcp_parse_xid(int *version,
/* Find out to which compression class the specified comp-field belongs
* (header compression or data compression?) */
int gprs_sndcp_get_compression_class(
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) */

View File

@ -4,10 +4,70 @@
#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;
@ -27,5 +87,24 @@ 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, __BASE_FILE__, __LINE__)
#define gprs_subscr_put(gsub) _gprs_subscr_put(gsub, __BASE_FILE__, __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

@ -29,18 +29,11 @@
struct msgb;
struct gprs_ra_id;
struct msgb *gprs_msgb_copy(const struct msgb *msg, const char *name);
int gprs_msgb_resize_area(struct msgb *msg, uint8_t *area,
size_t old_size, size_t new_size);
int gprs_str_to_apn(uint8_t *apn_enc, size_t max_len, const char *str);
/* GSM 04.08, 10.5.7.3 GPRS Timer */
int gprs_tmr_to_secs(uint8_t tmr);
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);
int gprs_parse_mi_tmsi(const uint8_t *value, size_t value_len, uint32_t *tmsi);
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);

View File

@ -1,63 +0,0 @@
/* GPRS Subscriber Update Protocol client */
/* (C) 2014 by Sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Jacob Erlbeck
*
* 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 <osmocom/core/timer.h>
#include <osmocom/sgsn/oap_client.h>
#define GSUP_CLIENT_RECONNECT_INTERVAL 10
#define GSUP_CLIENT_PING_INTERVAL 20
struct msgb;
struct ipa_client_conn;
struct gsup_client;
/* Expects message in msg->l2h */
typedef int (*gsup_client_read_cb_t)(struct gsup_client *gsupc,
struct msgb *msg);
struct gsup_client {
const char *unit_name;
struct ipa_client_conn *link;
gsup_client_read_cb_t read_cb;
void *data;
struct oap_client_state oap_state;
struct osmo_timer_list ping_timer;
struct osmo_timer_list connect_timer;
int is_connected;
int got_ipa_pong;
};
struct gsup_client *gsup_client_create(const char *unit_name,
const char *ip_addr,
unsigned int tcp_port,
gsup_client_read_cb_t read_cb,
struct oap_client_config *oapc_config);
void gsup_client_destroy(struct gsup_client *gsupc);
int gsup_client_send(struct gsup_client *gsupc, struct msgb *msg);
struct msgb *gsup_client_msgb_alloc(void);

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

@ -1,82 +0,0 @@
/* Osmocom Authentication Protocol API */
/* (C) 2015 by Sysmocom s.f.m.c. GmbH
* 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>
struct msgb;
struct osmo_oap_message;
/* This is the config part for vty. It is essentially copied in
* oap_client_state, where values are copied over once the config is
* considered valid. */
struct oap_client_config {
uint16_t client_id;
int secret_k_present;
uint8_t secret_k[16];
int secret_opc_present;
uint8_t secret_opc[16];
};
/* The runtime state of the OAP client. client_id and the secrets are in fact
* duplicated from oap_client_config, so that a separate validation of the
* config data is possible, and so that only a struct oap_client_state* is
* passed around. */
struct oap_client_state {
enum {
OAP_UNINITIALIZED = 0, /* just allocated. */
OAP_DISABLED, /* disabled by config. */
OAP_INITIALIZED, /* enabled, config is valid. */
OAP_REQUESTED_CHALLENGE,
OAP_SENT_CHALLENGE_RESULT,
OAP_REGISTERED
} state;
uint16_t client_id;
uint8_t secret_k[16];
uint8_t secret_opc[16];
int registration_failures;
};
/* From config, initialize state. Return 0 on success. */
int oap_client_init(struct oap_client_config *config,
struct oap_client_state *state);
/* Construct an OAP registration message and return in *msg_tx. Use
* state->client_id and update state->state.
* Return 0 on success, or a negative value on error.
* If an error is returned, *msg_tx is guaranteed to be NULL. */
int oap_client_register(struct oap_client_state *state, struct msgb **msg_tx);
/* Decode and act on a received OAP message msg_rx. Update state->state. If a
* non-NULL pointer is returned in *msg_tx, that msgb should be sent to the OAP
* server (and freed) by the caller. The received msg_rx is not freed.
* Return 0 on success, or a negative value on error.
* If an error is returned, *msg_tx is guaranteed to be NULL. */
int oap_client_handle(struct oap_client_state *state,
const struct msgb *msg_rx, struct msgb **msg_tx);
/* Allocate a msgb and in it, return the encoded oap_client_msg. Return
* NULL on error. (Like oap_client_encode(), but also allocates a msgb.)
* About the name: the idea is do_something(oap_client_encoded(my_struct))
*/
struct msgb *oap_client_encoded(const struct osmo_oap_message *oap_client_msg);

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);

View File

@ -3,18 +3,30 @@
#include <osmocom/core/msgb.h>
#include <osmocom/core/select.h>
#include <osmocom/crypt/gprs_cipher.h>
#include <osmocom/gprs/gprs_ns.h>
#include <osmocom/sgsn/gprs_sgsn.h>
#include <osmocom/sgsn/oap_client.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 gprs_gsup_client;
struct hostent;
#define SGSN_ERROR_CAUSE_NONE (-1)
enum sgsn_auth_policy {
SGSN_AUTH_POLICY_OPEN,
SGSN_AUTH_POLICY_CLOSED,
@ -52,6 +64,7 @@ enum sgsn_rate_ctr_keys {
struct sgsn_cdr {
char *filename;
bool trap;
int interval;
};
@ -62,39 +75,32 @@ struct sgsn_config {
struct sockaddr_in gtp_listenaddr;
/* misc */
struct gprs_ns_inst *nsi;
struct gprs_ns2_inst *nsi;
char *crypt_cipher_plugin_path;
enum sgsn_auth_policy auth_policy;
enum gprs_ciph_algo cipher;
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;
struct {
int T3312;
int T3322;
int T3350;
int T3360;
int T3370;
int T3313;
int T3314;
int T3316;
int T3385;
int T3386;
int T3395;
int T3397;
} timers;
/* Timer defintions */
struct osmo_tdef *T_defs;
struct osmo_tdef *T_defs_gtp;
int dynamic_lookup;
struct oap_client_config oap;
struct osmo_oap_client_config oap;
/* RFC1144 TCP/IP header compression */
struct {
@ -112,9 +118,18 @@ struct sgsn_config {
int p2;
} dcomp_v42bis;
#if BUILD_IU
struct {
int rab_assign_addr_enc;
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 {
@ -124,12 +139,10 @@ struct sgsn_instance {
struct osmo_fd gtp_fd0;
struct osmo_fd gtp_fd1c;
struct osmo_fd gtp_fd1u;
/* Timer for libGTP */
struct osmo_timer_list gtp_timer;
/* GSN instance for libgtp */
struct gsn_t *gsn;
/* Subscriber */
struct gsup_client *gsup_client;
struct osmo_gsup_client *gsup_client;
/* LLME inactivity timer */
struct osmo_timer_list llme_timer;
@ -140,9 +153,23 @@ struct sgsn_instance {
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 */
@ -151,37 +178,13 @@ int sgsn_parse_config(const char *config_file);
char *sgsn_gtp_ntoa(struct ul16_t *ul);
/* sgsn.c */
/* Main input function for Gb proxy */
int sgsn_rcvmsg(struct msgb *msg, struct gprs_nsvc *nsvc, uint16_t ns_bvci);
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_delete_pdp_ctx(struct sgsn_pdp_ctx *pctx);
void sgsn_pdp_upd_gtp_u(struct sgsn_pdp_ctx *pdp, void *addr, size_t alen);
/* gprs_sndcp.c */
/* 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(struct gprs_llc_lle *lle, uint8_t nsapi);
/* Called by SNDCP when it has received/re-assembled a N-PDU */
int sgsn_rx_sndcp_ud_ind(struct gprs_ra_id *ra_id, int32_t tlli, uint8_t nsapi,
struct msgb *msg, uint32_t npdu_len, uint8_t *npdu);
int sndcp_unitdata_req(struct msgb *msg, struct gprs_llc_lle *lle, uint8_t nsapi,
void *mmcontext);
int sndcp_llunitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle,
uint8_t *hdr, uint16_t len);
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);
/*

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

@ -17,10 +17,6 @@
* 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.
*/
/*! \page v42bis_page V.42bis modem data compression

View File

@ -17,10 +17,6 @@
* 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.
*/
#if !defined(_SPANDSP_PRIVATE_V42BIS_H_)

View File

@ -3,7 +3,7 @@
#include <osmocom/vty/command.h>
enum bsc_vty_node {
GBPROXY_NODE = _LAST_OSMOVTY_NODE + 1,
SGSN_NODE,
SGSN_NODE = _LAST_OSMOVTY_NODE + 1,
GTPHUB_NODE,
MME_NODE,
};

View File

@ -1,74 +0,0 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# 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.
#serial 4
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_VAR_IF(CACHEVAR,yes,
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS

View File

@ -1,10 +0,0 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/
Name: OsmoSGSN
Description: Osmocom's Serving GPRS Support Node for 2G and 3G packet-switched mobile networks
Requires:
Version: @VERSION@
Cflags: -I${includedir}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
# This program is free software: you can redistribute it and/or modify
@ -16,19 +16,15 @@
app_configs = {
"gbproxy": ["doc/examples/osmo-gbproxy/osmo-gbproxy.cfg",
"doc/examples/osmo-gbproxy/osmo-gbproxy-legacy.cfg"],
"sgsn": ["doc/examples/osmo-sgsn/osmo-sgsn.cfg"],
"sgsn": ["tests/osmo-sgsn.cfg"],
"gtphub": ["doc/examples/osmo-gtphub/osmo-gtphub-1iface.cfg"]
}
apps = [(4246, "src/gprs/osmo-gbproxy", "OsmoGbProxy", "gbproxy"),
(4245, "src/gprs/osmo-sgsn", "OsmoSGSN", "sgsn"),
(4253, "src/gprs/osmo-gtphub", "OsmoGTPhub", "gtphub")
apps = [(4245, "src/sgsn/osmo-sgsn", "OsmoSGSN", "sgsn"),
(4253, "src/gtphub/osmo-gtphub", "OsmoGTPhub", "gtphub")
]
vty_command = ["./src/gprs/osmo-sgsn", "-c",
"doc/examples/osmo-sgsn/osmo-sgsn.cfg"]
vty_command = ["./src/sgsn/osmo-sgsn", "-c", "tests/osmo-sgsn.cfg"]
vty_app = apps[1]
vty_app = apps[0]

View File

@ -1,3 +1,5 @@
SUBDIRS = \
gprs \
sgsn \
gtphub \
$(NULL)

View File

@ -13,9 +13,9 @@ AM_CFLAGS = \
$(LIBOSMOCTRL_CFLAGS) \
$(LIBOSMOABIS_CFLAGS) \
$(LIBOSMOGB_CFLAGS) \
$(LIBOSMOGSUPCLIENT_CFLAGS) \
$(COVERAGE_CFLAGS) \
$(LIBCARES_CFLAGS) \
$(LIBCRYPTO_CFLAGS) \
$(LIBGTP_CFLAGS) \
$(NULL)
if BUILD_IU
@ -26,105 +26,20 @@ AM_CFLAGS += \
$(NULL)
endif
OSMO_LIBS = \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOVTY_LIBS) \
$(LIBOSMOCTRL_LIBS) \
$(LIBOSMOGB_LIBS) \
$(LIBGTP_LIBS) \
$(NULL)
noinst_LTLIBRARIES = libcommon.la
bin_PROGRAMS = \
osmo-gbproxy \
$(NULL)
if HAVE_LIBGTP
if HAVE_LIBCARES
bin_PROGRAMS += \
osmo-sgsn \
osmo-gtphub \
$(NULL)
endif
endif
osmo_gbproxy_SOURCES = \
gb_proxy.c \
gb_proxy_main.c \
gb_proxy_vty.c \
gb_proxy_patch.c \
gb_proxy_tlli.c \
gb_proxy_peer.c \
gprs_gb_parse.c \
libcommon_la_SOURCES = \
gprs_llc_parse.c \
crc24.c \
gprs_utils.c \
$(NULL)
osmo_gbproxy_LDADD = \
$(OSMO_LIBS) \
$(LIBCRYPTO_LIBS) \
-lrt \
sgsn_ares.c \
$(NULL)
osmo_sgsn_SOURCES = \
gprs_gmm.c \
gprs_sgsn.c \
gprs_sndcp.c \
gprs_sndcp_comp.c \
gprs_sndcp_dcomp.c \
gprs_sndcp_pcomp.c \
gprs_sndcp_vty.c \
gprs_sndcp_xid.c \
sgsn_main.c \
sgsn_vty.c \
sgsn_libgtp.c \
gprs_llc.c \
gprs_llc_parse.c \
gprs_llc_vty.c \
crc24.c \
sgsn_ctrl.c \
sgsn_auth.c \
gprs_subscriber.c \
gprs_utils.c \
sgsn_cdr.c \
sgsn_ares.c \
slhc.c \
gprs_llc_xid.c \
v42bis.c \
gsup_client.c \
oap_client.c \
$(NULL)
osmo_sgsn_LDADD = \
$(OSMO_LIBS) \
$(LIBOSMOABIS_LIBS) \
$(LIBCARES_LIBS) \
$(LIBCRYPTO_LIBS) \
$(LIBGTP_LIBS) \
-lrt \
-lm \
$(NULL)
if BUILD_IU
osmo_sgsn_LDADD += \
$(LIBOSMOSIGTRAN_LIBS) \
$(LIBOSMORANAP_LIBS) \
$(LIBASN1C_LIBS) \
$(NULL)
endif
osmo_gtphub_SOURCES = \
gtphub_main.c \
gtphub.c \
gtphub_sock.c \
gtphub_ares.c \
gtphub_vty.c \
sgsn_ares.c \
gprs_utils.c \
$(NULL)
osmo_gtphub_LDADD = \
libcommon_la_LIBADD = \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOVTY_LIBS) \
$(LIBCARES_LIBS) \
$(LIBGTP_LIBS) \
$(LIBOSMOSIGTRAN_LIBS) \
-lrt \
$(LIBCARES_LIBS) \
$(NULL)

View File

@ -59,7 +59,7 @@ static const uint32_t tbl_crc24[256] = {
#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)
{
while (len--)
fcs = (fcs >> 8) ^ tbl_crc24[(fcs ^ *cp++) & 0xff];

File diff suppressed because it is too large Load Diff

View File

@ -1,342 +0,0 @@
/* NS-over-IP proxy */
/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
* (C) 2010 by On-Waves
* 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/>.
*
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
#include <signal.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <osmocom/core/application.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/stats.h>
#include <osmocom/gprs/gprs_ns.h>
#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/sgsn/signal.h>
#include <osmocom/sgsn/debug.h>
#include <osmocom/sgsn/vty.h>
#include <osmocom/sgsn/gb_proxy.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/logging.h>
#include <osmocom/vty/stats.h>
#include <osmocom/vty/ports.h>
#include "../../bscconfig.h"
#define _GNU_SOURCE
#include <getopt.h>
void *tall_bsc_ctx;
const char *openbsc_copyright =
"Copyright (C) 2010 Harald Welte and On-Waves\r\n"
"License AGPLv3+: GNU AGPL version 3 or later <http://gnu.org/licenses/agpl-3.0.html>\r\n"
"This is free software: you are free to change and redistribute it.\r\n"
"There is NO WARRANTY, to the extent permitted by law.\r\n";
static char *config_file = "osmo_gbproxy.cfg";
struct gbproxy_config gbcfg = {0};
static int daemonize = 0;
/* Pointer to the SGSN peer */
extern struct gbprox_peer *gbprox_peer_sgsn;
/* call-back function for the NS protocol */
static int proxy_ns_cb(enum gprs_ns_evt event, struct gprs_nsvc *nsvc,
struct msgb *msg, uint16_t bvci)
{
int rc = 0;
switch (event) {
case GPRS_NS_EVT_UNIT_DATA:
rc = gbprox_rcvmsg(&gbcfg, msg, nsvc->nsei, bvci, nsvc->nsvci);
break;
default:
LOGP(DGPRS, LOGL_ERROR, "SGSN: Unknown event %u from NS\n", event);
if (msg)
msgb_free(msg);
rc = -EIO;
break;
}
return rc;
}
static void signal_handler(int signal)
{
fprintf(stdout, "signal %u received\n", signal);
switch (signal) {
case SIGINT:
case SIGTERM:
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(1);
exit(0);
break;
case SIGABRT:
/* in case of abort, we want to obtain a talloc report
* and then return to the caller, who will abort the process */
case SIGUSR1:
talloc_report(tall_vty_ctx, stderr);
talloc_report_full(tall_bsc_ctx, stderr);
break;
case SIGUSR2:
talloc_report_full(tall_vty_ctx, stderr);
break;
default:
break;
}
}
static void print_usage()
{
printf("Usage: bsc_hack\n");
}
static void print_help()
{
printf(" Some useful help...\n");
printf(" -h --help this text\n");
printf(" -d option --debug=DNS:DGPRS,0:0 enable debugging\n");
printf(" -D --daemonize Fork the process into a background daemon\n");
printf(" -c --config-file filename The config file to use.\n");
printf(" -s --disable-color\n");
printf(" -T --timestamp Prefix every log line with a timestamp\n");
printf(" -V --version. Print the version of OpenBSC.\n");
printf(" -e --log-level number. Set a global loglevel.\n");
}
static void handle_options(int argc, char **argv)
{
while (1) {
int option_index = 0, c;
static struct option long_options[] = {
{ "help", 0, 0, 'h' },
{ "debug", 1, 0, 'd' },
{ "daemonize", 0, 0, 'D' },
{ "config-file", 1, 0, 'c' },
{ "disable-color", 0, 0, 's' },
{ "timestamp", 0, 0, 'T' },
{ "version", 0, 0, 'V' },
{ "log-level", 1, 0, 'e' },
{ 0, 0, 0, 0 }
};
c = getopt_long(argc, argv, "hd:Dc:sTVe:",
long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 'h':
print_usage();
print_help();
exit(0);
case 's':
log_set_use_color(osmo_stderr_target, 0);
break;
case 'd':
log_parse_category_mask(osmo_stderr_target, optarg);
break;
case 'D':
daemonize = 1;
break;
case 'c':
config_file = optarg;
break;
case 'T':
log_set_print_timestamp(osmo_stderr_target, 1);
break;
case 'e':
log_set_log_level(osmo_stderr_target, atoi(optarg));
break;
case 'V':
print_version(1);
exit(0);
break;
default:
break;
}
}
}
int gbproxy_vty_is_config_node(struct vty *vty, int node)
{
switch (node) {
/* add items that are not config */
case CONFIG_NODE:
return 0;
default:
return 1;
}
}
int gbproxy_vty_go_parent(struct vty *vty)
{
switch (vty->node) {
case GBPROXY_NODE:
default:
if (gbproxy_vty_is_config_node(vty, vty->node))
vty->node = CONFIG_NODE;
else
vty->node = ENABLE_NODE;
vty->index = NULL;
}
return vty->node;
}
static struct vty_app_info vty_info = {
.name = "OsmoGbProxy",
.version = PACKAGE_VERSION,
.go_parent_cb = gbproxy_vty_go_parent,
.is_config_node = gbproxy_vty_is_config_node,
};
/* default categories */
static struct log_info_cat gprs_categories[] = {
[DGPRS] = {
.name = "DGPRS",
.description = "GPRS Packet Service",
.enabled = 1, .loglevel = LOGL_DEBUG,
},
[DNS] = {
.name = "DNS",
.description = "GPRS Network Service (NS)",
.enabled = 1, .loglevel = LOGL_INFO,
},
[DBSSGP] = {
.name = "DBSSGP",
.description = "GPRS BSS Gateway Protocol (BSSGP)",
.enabled = 1, .loglevel = LOGL_DEBUG,
},
};
static const struct log_info gprs_log_info = {
.filter_fn = gprs_log_filter_fn,
.cat = gprs_categories,
.num_cat = ARRAY_SIZE(gprs_categories),
};
int main(int argc, char **argv)
{
int rc;
tall_bsc_ctx = talloc_named_const(NULL, 0, "nsip_proxy");
msgb_talloc_ctx_init(tall_bsc_ctx, 0);
signal(SIGINT, &signal_handler);
signal(SIGTERM, &signal_handler);
signal(SIGABRT, &signal_handler);
signal(SIGUSR1, &signal_handler);
signal(SIGUSR2, &signal_handler);
osmo_init_ignore_signals();
osmo_init_logging(&gprs_log_info);
vty_info.copyright = openbsc_copyright;
vty_init(&vty_info);
logging_vty_add_cmds(NULL);
osmo_stats_vty_add_cmds(&gprs_log_info);
gbproxy_vty_init();
handle_options(argc, argv);
rate_ctr_init(tall_bsc_ctx);
osmo_stats_init(tall_bsc_ctx);
bssgp_nsi = gprs_ns_instantiate(&proxy_ns_cb, tall_bsc_ctx);
if (!bssgp_nsi) {
LOGP(DGPRS, LOGL_ERROR, "Unable to instantiate NS\n");
exit(1);
}
gbproxy_init_config(&gbcfg);
gbcfg.nsi = bssgp_nsi;
gprs_ns_vty_init(bssgp_nsi);
gprs_ns_set_log_ss(DNS);
bssgp_set_log_ss(DBSSGP);
osmo_signal_register_handler(SS_L_NS, &gbprox_signal, &gbcfg);
rc = gbproxy_parse_config(config_file, &gbcfg);
if (rc < 0) {
LOGP(DGPRS, LOGL_FATAL, "Cannot parse config file\n");
exit(2);
}
/* start telnet after reading config for vty_get_bind_addr() */
rc = telnet_init_dynif(tall_bsc_ctx, NULL,
vty_get_bind_addr(), OSMO_VTY_PORT_GBPROXY);
if (rc < 0)
exit(1);
if (!gprs_nsvc_by_nsei(gbcfg.nsi, gbcfg.nsip_sgsn_nsei)) {
LOGP(DGPRS, LOGL_FATAL, "You cannot proxy to NSEI %u "
"without creating that NSEI before\n",
gbcfg.nsip_sgsn_nsei);
exit(2);
}
rc = gprs_ns_nsip_listen(bssgp_nsi);
if (rc < 0) {
LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on NSIP socket\n");
exit(2);
}
rc = gprs_ns_frgre_listen(bssgp_nsi);
if (rc < 0) {
LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen GRE "
"socket. Do you have CAP_NET_RAW?\n");
exit(2);
}
if (daemonize) {
rc = osmo_daemonize();
if (rc < 0) {
perror("Error during daemonize");
exit(1);
}
}
/* Reset all the persistent NS-VCs that we've read from the config */
gbprox_reset_persistent_nsvcs(bssgp_nsi);
while (1) {
rc = osmo_select_main(0);
if (rc < 0)
exit(3);
}
exit(0);
}

Some files were not shown because too many files have changed in this diff Show More