Commit Graph

64 Commits

Author SHA1 Message Date
Max 176b62a80c SGSN: prevent starting with inconsistent config
Previously it was possible to start osmo-sgsn with "auth-policy remote"
but without "gsup remote-*" which resulted in broken setup: no MS could
perform GPRS ATTACH. Add consistency check to vty code to fix this.

Related: OS#1582
Change-Id: Ie4296e7d99d7833f7d828b0196435ea81097cf6e
2016-07-11 19:18:17 +00:00
Max e6052c4cc7 Make random MSISDN assignment optional
Previously if subscriber was automatically created it got assigned
random MSISDN number. Make it optional (defaulting to previous behavior)
by adding following:

* new optional no-extension argument for subscriber-create-on-demand vty
  command
* db unit tests
* vty test

Note: using the db made with new code might result in subscribers with
empty extension. Such subscribers cannot be deleted using old
code. Make sure not to mix db versions or manually fix it by editing
sqlite with external program.

Fixes: OS#1658
Change-Id: Ibbc2e88e4722b08854ebc631485f19ed56443cbb
2016-07-09 19:52:54 +00:00
Max 488902db2a Fix vty tests with subscriber deletion
Use correct vty command for subscriber deletion, adjust assertions
accordingly. The error was cause by inconsistent syntax of vty commands
for subscriber creation and deletion.

Change-Id: I9b9376b4ac0ec066000545167de312ca4460493b
2016-06-29 16:45:14 +00:00
Max 0fcd2e2fec Make random extension range configurable
Previously if subscriber was automatically created it got assigned
random MSISDN number between 20000 and 49999. Make it configurable with
new vty command "subscriber-create-on-demand random" and expand vty
tests to check it.

Change-Id: I040a1d227b0c7a1601dc7c33eccb0007941408a6
Related: OS#1658
2016-06-14 22:20:40 +00:00
Max ddee01fa8f Add regexp authorization policy for IMSI
* extend "auth policy" vty command with new option "regexp"
* add vty command "authorized-regexp" for setting arbitrary POSIX
  regular expression
* add basic vty test
* add optional "regexp" argument to subscriber-create-on-demand vty
  command

With those in place we can now set the regexp against which MS's IMSI
will be matched.

If IMSI match the regexp than MS is allowed to access the network. If
subscriber is already marked as authorized in HLR than it'll be allowed
regardless of IMSI matching.

The same way we can decide whether to create subscribers on-demand
basesd on IMSI regexp match. Similar to authorization this restriction
can be overridden by manually creating subscriber via vty, ctrl
interface or directly in HLR.

Change-Id: I525f4b80676de47d1d422686da2ca012301b0129
Fixes: OS#1647
2016-06-05 09:36:37 +00:00
Max 26679e0475 Add basic UARFCN support
* add data structures, generation functions
* vty interface for neightbor UARFCNs specific to SI2quater
* vty test
* unit test

Fixes: OS#1666
2016-04-22 14:55:33 +02:00
Max 0c1bc26b64 Fix earfcn deletion
* fix typo in arg index
* fix sign in error reporting
* add vty test
2016-04-22 14:50:42 +02:00
Holger Hans Peter Freyther 8bb6204d50 nat/vty: Fix construct not working with python 2.6
Use the simpler approach and just call encode('hex') on the str and
then convert it to lower case to keep the tests working.

reproduce:

Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> d = '\0\0'
>>> d
'\x00\x00'
>>> "".join("{:02x}".format(ord(c)) for c in d)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in <genexpr>
ValueError: zero length field name in format

fixes:

======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 658, in testBSCreload
    b0 = nat_bsc_sock_test(0, "lol")
  File "./vty_test_runner.py", line 1150, in nat_bsc_sock_test
    ipa_handle_small(bsc, verbose)
  File "./vty_test_runner.py", line 1116, in ipa_handle_small
    s = data2str(x.recv(4))
  File "./vty_test_runner.py", line 1100, in data2str
    return "".join("{:02x}".format(ord(c)) for c in d)
  File "./vty_test_runner.py", line 1100, in <genexpr>
    return "".join("{:02x}".format(ord(c)) for c in d)
ValueError: zero length field name in format

----------------------------------------------------------------------
2016-04-14 21:40:04 -04:00
Holger Hans Peter Freyther 2abf2b072d nat/vty: Remove second assumption about lo and binding
If we want to separate the BSCs we should separate based on
the source port and not the source ip (at least in the current
test setup).

Fixes:
======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 658, in testBSCreload
    b0 = nat_bsc_sock_test(0, "lol")
  File "./vty_test_runner.py", line 1145, in nat_bsc_sock_test
    bsc.bind(('127.0.0.1' + str(nr), 0))
  File "<string>", line 1, in bind
error: [Errno 99] Cannot assign requested address

----------------------------------------------------------------------
2016-04-14 21:13:51 -04:00
Holger Hans Peter Freyther e98c9c7136 nat/vty: And move to a different port.. 2016-04-14 10:58:58 -04:00
Holger Hans Peter Freyther 84ae27e731 nat/vty: Convert into str for the VTY command
======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 656, in testBSCreload
    nat_msc_ip(self, ip, port)
  File "./vty_test_runner.py", line 1096, in nat_msc_ip
    x.vty.command("msc port " + port)
TypeError: cannot concatenate 'str' and 'int' objects

----------------------------------------------------------------------
2016-04-14 10:40:06 -04:00
Holger Hans Peter Freyther 44ed4979c9 nat/vty: Use different port for the mock MSC
Update the comment to reflect that the NAT itself will bind to port
5000 and then the mock MSC will fail to bind to it. Try to move the
mock MSC to another port.

Could fix:

======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 654, in testBSCreload
    msc = nat_msc_test(self, ip)
  File "./vty_test_runner.py", line 1101, in nat_msc_test
    msc.bind((ip, 5000))
  File "<string>", line 1, in bind
error: [Errno 98] Address already in use

----------------------------------------------------------------------
2016-04-14 10:05:13 -04:00
Holger Hans Peter Freyther f1a61bb99f nat/vty: Don't assume one can magically add IPv4 addresses to lo
Don't assume that one can just bind to a local address that has
not been configured. Remove the unspecific comment as I don't know
to which other tests it is referred to.

This should fix:
======================================================================
ERROR: testBSCreload (__main__.TestVTYNAT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./vty_test_runner.py", line 655, in testBSCreload
    msc = nat_msc_test(self, ip)
  File "./vty_test_runner.py", line 1102, in nat_msc_test
    msc.bind((ip, 5000))
  File "<string>", line 1, in bind
error: [Errno 99] Cannot assign requested address

----------------------------------------------------------------------
2016-04-14 08:51:57 -04:00
Max 4936448761 NAT: reload BSCs config dynamically
Add vty tests for BSC configuration reloading.
Load BSCs configuration on bscs-config-file command:
* remove all runtime configured BSC not in the config file
* close connections to all BSC with updated token value

Fixes: OS#1670
Sponsored-by: On-Waves ehf
2016-04-14 08:37:34 -04:00
Max 70cf7290da vty_test_runner: update ipa sending code
Factor out 2, add 3 functions. Those functions are simple wrappers
around hex strings specific to IPA protocol. Not all of them are
utilized at the moment but they were checked with wireshark while
working on the tests. It might come in handy if we'd like to further
expand related test harness in future. The same goes for optional
verbosity argument which is not used right now but will be handy for
future debugging.
2016-04-14 08:33:47 -04:00
Holger Hans Peter Freyther de392254ff subscr: Add testcase creating an already created subscriber
Add testcase to issue the subscriber create twice. db_create_subscriber
in db.c will first try to find the subscriber and if it exists, it will
update the "updated" column in the database.

Related: OS Issue #1657
2016-04-06 21:18:36 +02:00
Holger Hans Peter Freyther c390ae8eaf mgcp: Allow to bind to different ports for net/bts ports
When using multiple interfaces on a system one can now configure
which will be served for the BTS ports and which will be served
for the network. The direct usage of source_addr is now only to
initialize the MGCP receiving port itself.
2015-08-20 17:24:03 +02:00
Holger Hans Peter Freyther a2c41c42b1 sms: Fix the non-SMPP mode of the test
List needs to be executed from within the right configuration
node to see if it is available or not. list on the toplevel
will uncoditionally show "smpp" as part of the logging config.
2015-07-13 11:30:13 +02:00
Holger Hans Peter Freyther 42cf2e03c9 sms: Add a way to always route SMS through SMPP systems
default-route would only be looked at after there has been
no subscriber in the local database. Depending on the setup
this is not what one wants. This has been discussed at the
OsmoDevCon and there have been hacks in some branches. Let's
introduce a VTY command to select if SMPP should be consulted
first and then fallback to the current behavior.
2015-07-06 16:50:19 +02:00
Holger Hans Peter Freyther c15c61c401 sgsn: Add VTY configuration for the CDR module
Make it possible to set a filename to use for the CDR. By
default no CDR will be generated. Forbid to set the interval
of 0 seconds as this will cause a lot of work. Add a very
basic VTY test.
2015-05-06 17:46:08 +02:00
Holger Hans Peter Freyther 7f100c9712 nat: Make mode-set patching optional 2015-04-23 20:27:30 -04:00
Jacob Erlbeck 322b1499cd nitb: Check source string length before calling strncpy (Coverity)
Currently some VTY command do neither check the length of the source
string before calling strncpy nor ensure NUL-termination afterwards.
This can to destination string buffers whose contents are not
NUL-teminated.

This commit adds checks and corresponding warnings to the VTY
commands 'subscriber TYPE ID name .NAME" and "subscriber TYPE ID
extension EXTENSION".

Fixes: Coverity CID 1206570, 1206569
Sponsored-by: On-Waves ehf
2015-04-07 20:13:53 +02:00
Holger Hans Peter Freyther 32dd2f3f9b bsc: Allow to use different LAC/CI for the core-network
We need to use different LAC/CI towards the core network.
It is a bit problematic as LAC/CI is a per BTS attribute
so this feature only works if a BSC manages everything in
the same LAC.

Related: SYS#1398
2015-04-01 19:26:12 +02:00
Holger Hans Peter Freyther 9c20a5f45c sgsn: Add easy APN commands with just the name
For most configurations we don't address multiple GGSNs but
only want to enforce a list of APNs. In the future we might
add a special global GGSN context but not right now.

Fixes: SYS#593
2015-02-06 16:44:58 +01:00
Jacob Erlbeck cb1db8b6d5 sgsn: Add functions to handle APN contexts
This commit adds the exported functions apn_ctx_find_alloc,
apn_ctx_free, apn_ctx_by_name, and apn_ctx_match to manage and
retrieve APN to GGSN mappings.

The following VTY commands are added to 'config-sgsn':

 - apn APN ggsn <0-255>
 - apn APN imsi-prefix PREFIX ggsn <0-255>

which maps an APN gateway string to an SGSN id. The SGSN must be
configured in advance. When matching an APN string, entries with a
leading '*' are used for suffix matching, otherwise an exact match is
done.  When a prefix is given, it is matched against the IMSI. If
several entries match, a longer matching IMSI prefix has precedence.
If there are several matching entries with the same PREFIX, the entry
with longest matching APN is returned.

Ticket: OW#1334
Sponsored-by: On-Waves ehf
2015-02-06 09:56:17 +01:00
Holger Hans Peter Freyther 8657326093 meas: Install the scenario command and test it 2015-01-31 12:49:41 +01:00
Jacob Erlbeck 8000e0ea50 gprs: Support cancellation type
The cancellation type that is part of the UpdateCancellation message
is currently ignored.

This patch adds the missing glue between the existing GSUP and GMM
support. If the type is not present or has the value updateProcedure
the subcriber and MM context are siliently removed. Otherwise, a
message with cause 'implicitly detached' is sent to the MS. Since the
real cause is not known (the specification neither added a cause IE
nor defined a static cause value), the MS may get the real cause in
the following AttachRej.

Added VTY commands:

- update-subscriber imsi IMSI cancel update-procedure
- update-subscriber imsi IMSI cancel subscription-withdraw

the old form without the cause is no longer supported.

Sponsored-by: On-Waves ehf
2015-01-30 21:27:07 +01:00
Jacob Erlbeck e988ae471d gprs: Don't use subscr->keep_in_ram in normal operation
Currently the keep_in_ram flag is explicitely reset in
gprs_subscr_cleanup to cover the case, that the VTY 'create'
sub-command has been used to create the subscriber entry.

This commit completely removes keep_in_ram handling from
gprs_subscriber.c and adds a VTY 'destroy' sub-command to reset the
flag and remove the entry. So 'create' and 'destroy' can be used to
manager sticky entries that are kept even when a location
cancellation is done.

Added VTY command:

- update-subscriber imsi IMSI destroy

Sponsored-by: On-Waves ehf
2015-01-28 20:42:58 +01:00
Jacob Erlbeck d91934357f sgsn: Restructure the 'update-subscriber' command
This patch drops the following commands:

 - update-subscriber imsi IMSI insert authorized <0-1>
 - update-subscriber imsi IMSI commit

since they are already covered by the 'update-location-result'
sub-command, except that this command doesn't create an new entry if
none is found with the given IMSI.

It adds the following command:

 - update-subscriber imsi IMSI create

which can be used to create a new entry.

Sponsored-by: On-Waves ehf
2015-01-20 16:14:01 +01:00
Jacob Erlbeck 207f4a5deb sgsn: Add VTY commands to manage subscriber cache
This adds the following commands to the ENABLE node:
  - show subscriber cache
  - update-subscriber imsi IMSI insert authorized (0|1)
  - update-subscriber imsi IMSI cancel
  - update-subscriber imsi IMSI commit

These commands are mainly testing tools and maintenance helpers. The
update commands work asynchronously and can be used to complete a
pending update request or to terminate an existing connection. The
'insert' command just update the subscriber records but does not
notify the GMM layer. Invoke the 'commit' command to continue with
pending procedures.

Note that the subscriber cache is not stored persistently and will
always be empty after an SGSN restart.

Sponsored-by: On-Waves ehf
2014-12-09 10:00:41 +01:00
Jacob Erlbeck be2c8d9358 sgsn: Integrate subscriber handling into the SGSN
This commit adds a new authorization policy 'remote' and uses
the subscriber cache for authorization when this policy is being used.

Note that there is no remote backend implemented yet. After the
IMSI/IMEI have been acquired, a request would be sent to the remote
peer. The attach/auth-ciph procedure continues when authorization
info has been received from the peer. This means, that
gprs_subscr_update() must be called then to tell the GMM layer
that it can proceed. A later commit will add VTY commands to do this
manually.

Sponsored-by: On-Waves ehf
2014-12-09 09:27:20 +01:00
Holger Hans Peter Freyther 619b014d3a mgcp: Allow to omit sending the audio name at all
Equipment like AudioCode appears to get upset when we use a
builtin type and then assign a name to it. Allow to completely
omit the name.
2014-11-19 16:18:56 +01:00
Jacob Erlbeck 106f547733 sgsn: Add 'acl-only' authentication policy
Currently the VTY 'auth-policy' command results in setting or clearing
the acl_enabled flag. This also enables the matching of the MCC/MNC
prefix of the IMSI.

This patch adds an additional policy 'acl-only' which disables the
MCC/MNC matching and relies on the ACL only.

Sponsored-by: On-Waves ehf
2014-11-14 10:07:28 +01:00
Jacob Erlbeck 144b8b1ca7 sgsn/test: Add VTY tests for the SGSN
This patch adds some basic SGSN tests to vty_test_runner.py:
- check for config tree nodes
- check specific show commands

Sponsored-by: On-Waves ehf
2014-11-14 10:06:53 +01:00
Holger Hans Peter Freyther db64f2e45a bsc: Allow to disable sending ping/pong to the MSC
Some switches do not like to receive the IPA PING/PONG messages.
Allow to disable the handling with "no timeout-ping" and create
test cases that verify the switching between the modes. Change the
code to trat <= 0 as an invalid timeout.

Fixes: SYS#713
2014-10-29 10:11:21 +01:00
Ruben Pollan ed04a0d060 nitb: Add subscriber delete command 2014-10-03 09:15:28 +02:00
Holger Hans Peter Freyther 8d998a713e mgcp: Verify that the force-ptime is written back to the file
When the command was added it was not verified that. Add a very
basic MGCP VTY test and test that the string appears in the config.
2014-07-07 19:24:34 +02:00
Ciaby ec6e4f8b3d nitb: Add a test for "show network" in the python testsuite.
Make sure that bsc_gsmnet->bsc_data->rf_ctrl is initialized for
NITB. In commit a9fae1ae66 the
conditions for the rf_ctrl was removed but it was still needed
for the NITB.

Fixes regression from:
a9fae1ae66
bsc: rf_ctrl will always be created, remove the NULL checks
2014-03-06 17:31:23 +01:00
Holger Hans Peter Freyther 4ecc6877a2 nat: Add CTRL command test case for the new control commands 2014-03-06 11:04:56 +01:00
Holger Hans Peter Freyther 6419018e68 nat: Make the access-list deny cause configurable
Add two optional arguments to the imsi-deny rule
for the reject cause and verify that it is saved
out.
2014-01-20 10:14:05 +01:00
Jacob Erlbeck 65d114fe43 si: Add a config option to disable SI2ter/SI2bis/SI5ter/SI5bis messages
The iPhone5 (US) appears to have some issues with the SIs generated,
or the nanoBTS is not sending them correctly.

Add a configurable hack to put all bands into the SI2/SI5 message.
It is enabled by the bts VTY command 'force-combined-si'.

This is a quick change without much reflection and watching for side
effects. I have verfied that a network with ARFCN 134 and neighbors
ARFCN 130 and 512 do not get generate the SI2ter and announce everything
inside the SI2.

This patch is conceptually based on 'si: Add a hack to disable
SI2ter/SI2bis/SI5ter/SI5bis messages' (692daaf2d2).

Ticket: OW#1062
Sponsored-by: On-Waves ehf
2014-01-16 12:04:22 +01:00
Holger Hans Peter Freyther ec37bb2956 bsc: Add a VTY command to show the paging group for a BSC/IMSI 2013-11-22 16:00:00 +01:00
Jacob Erlbeck 6e919dbb65 vty: Enable the end/exit test for libosmocore nodes
This patch replaces the calls to ignoredCheckForEndAndExit by calls
to checkForEndAndExit to test the libosmocore nodes, too. The former
method is removed.

Sponsored-by: On-Waves ehf
2013-10-30 15:19:02 +01:00
Jacob Erlbeck 4211d79cd1 gbproxy/vty: Enhance delete-gbproxy-peer command
This adds the option to delete all BVC peers and/or NS_VC with a
given NSEI with a single command. Static (configured) NS-VC are not
affected. In addition, all connections for this NSEI that can be
deleted by this command can be listed without deleting them by
appending 'dry-run' to the command.

Sponsored-by: On-Waves ehf
2013-10-24 18:02:33 +02:00
Jacob Erlbeck 6d23371805 gbproxy: Add basic VTY tests
This checks for the ns and gbproxy config nodes and show commands.

Sponsored-by: On-Waves ehf
2013-10-24 08:21:29 +02:00
Jacob Erlbeck 7587727445 vty: Fix whitespace in test script
Expands leading tabs and removes trailing whitespace.

Sponsored-by: On-Waves ehf
2013-10-24 08:21:22 +02:00
Alexander Chemeris bd6d40f1fb nitb: Add "subscriber create" VTY command.
It may be useful in production, but it's really required for
VTY testing of subscriber related commands.
2013-10-05 10:27:47 +02:00
Jacob Erlbeck 946d1415c2 bsc/mminfo: Patch timezone and DST in MM Info messages
This adds in-place patching of the time information in the
MM INFORMATION message. The timezone in the 'Local time zone' and
the 'Universal time and local time zone' information elements
and the offset in the 'Network Daylight Saving Time' information
element are optionally set.

The new values are determined by the 'timezone' vty command in the
config_net_bts node. That command is extended by an optional
DST offset parameter.

Tests are provided for the vty part and for the plain
bsc_scan_msc_msg() function.

Sponsored-by: On-Waves ehf
Ticket: OW#978
2013-09-19 10:57:13 +02:00
Ivan Kluchnikov 6792059d50 bsc: Add vty command for setting Access control classes. 2013-09-18 16:14:44 +02:00
Jacob Erlbeck 733bec8626 vty: Hide unconfigured BTS on 'write'
This prevents the application from crashing when there is a half
configured BTS (e.g. by using the command 'bts 1' when there isn't
a BTS 1) and the 'write' command is used.
2013-09-11 20:20:33 +02:00