Commit Graph

4951 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther 8deba01eda debian: We are at version 0.14 now 2015-03-14 20:33:43 +01:00
Holger Hans Peter Freyther 66105fd3dc ctrl: Implement a global result for rf_locked
Create a one stop command to give a statement for the
entire network. This can be used to check the policy
and the state of the entire network.
2015-02-10 23:03:25 +01:00
Holger Hans Peter Freyther ca4151984c ctrl: Add a command to check how many bts are configured
This can be used to query how many bts are configured to
check if all of them are locked or not.
2015-02-10 21:55:37 +01:00
Holger Hans Peter Freyther 349c40f47b nitb: Move the rf-lock commands from osmo-bsc to libbsc
The bts.0.rf-state and rf_locked command have been moved
from the osmo-bsc binary to libbsc. All tests continue to
pass.
2015-02-10 21:37:16 +01:00
Holger Hans Peter Freyther a0735ecab5 smpp: Fix potential crash in handling submitSM
In case:

* No message_payload and a 0 sm_length was used
* esm_class indicates UDH being present
* 7bit encoding was requested

The code would execute:

  ud_len = *sms_msg + 1;

Which is a NULL pointer dereference and would lead
to a crash of the NITB. Enforce the limits of the
sm_length parameter and reject the messae otherwise.

Fixes: Coverity CID 1042373
2015-02-08 09:56:31 +01:00
Holger Hans Peter Freyther 60e073e28d nat: getopt returns "static" data no need to copy it
I used strdup in case the data would not be valid from after
the call to getopt and this creates a potential leak if a user
is specifying multiple configuration files. If I depend on the
fact that the string is a pointer into the argv[] array I can
kill the strdup and fix the unlikely leak.

Fixes: Coverity CID 1206578
2015-02-08 09:25:38 +01:00
Holger Hans Peter Freyther 019851a523 smpp: Do not check conn for being null
We are deferencing conn earlier in this function without doing
a null check. At the time deliver_to_esme is called the conn
will always exist and even the lchan is likely to be present.
Remove the null check for conn right now.

Fixes: Coverity CID 1210594
2015-02-08 09:21:04 +01:00
Sipos Csaba 56e1766dba nokia: Allow to set the reset time for the nokia bts 2015-02-07 13:27:36 +01:00
Holger Hans Peter Freyther 9c20a5f45c sgsn: Add easy APN commands with just the name
For most configurations we don't address multiple GGSNs but
only want to enforce a list of APNs. In the future we might
add a special global GGSN context but not right now.

Fixes: SYS#593
2015-02-06 16:44:58 +01:00
Jacob Erlbeck ca69b0f68d Revert "gprs: Block other GSUP procedures during PURGE_MS"
This reverts commit f81cacc681.

Since the PURGE MS retry mechanism had been removed, this feature
is not used anymore. It just makes the code more complex.

Conflicts:
	openbsc/include/openbsc/gprs_sgsn.h
	openbsc/src/gprs/gprs_subscriber.c
	openbsc/tests/sgsn/sgsn_test.c
2015-02-06 13:22:24 +01:00
Jacob Erlbeck 277b71e0d8 sgsn: Select GGSN based on APN
Currently the APN IE in the Activate PDP Contex Request and the PDP
data that is stored with the subscriber is ignored completely.

This commit adds the sgsn_mm_ctx_find_ggsn_ctx that checks the APN IE
against the subscriber's PDP data entries if both are present. If
there is no match, the request is rejected.

If an APN IE has not been included but PDP data entries are present,
the function checks all of these entries against the static 'apn'
configuration to find a suitable entry.

If an APN has not been determined so far and any APN is allowed, the
configuration is checked with an empty APN string, to allow for
default configurations based on the IMSI prefix only.

If nothing of this succeeded but the request wasn't rejected either,
and there is no 'apn' configuration at all or if any APN is allowed
but a default configuration ist not present, the GGSN with id 0 is
used (if present).

Otherwise the request is rejected ('missing APN').

Ticket: OW#1334
Sponsored-by: On-Waves ehf
2015-02-06 13:00:29 +01:00
Jacob Erlbeck f345612654 sgsn: Add sgsn_ggsn_ctx_free function
This function will be needed for testing, since the leak check would
fail if the GGSN context are not cleaned up after use.

Sponsored-by: On-Waves ehf
2015-02-06 10:00:03 +01:00
Jacob Erlbeck cb1db8b6d5 sgsn: Add functions to handle APN contexts
This commit adds the exported functions apn_ctx_find_alloc,
apn_ctx_free, apn_ctx_by_name, and apn_ctx_match to manage and
retrieve APN to GGSN mappings.

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

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

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

Ticket: OW#1334
Sponsored-by: On-Waves ehf
2015-02-06 09:56:17 +01:00
Jacob Erlbeck 0e8add601d sgsn: Add PDP info to subscriber data
Currently the PDP info that is transmitted via GSUP is just parsed
and then discarded.

This commit adds a new data structure sgsn_subscriber_pdp_data and
maintains a list of those in sgsn_subscriber_data. The PDP data is
copied from an incoming GSUP UpdateLocationResult message. If that
message contains the PDPInfoComplete flag, the list is cleared before
new entries are added.  The 'show subscriber cache' output now also
shows the PDP data entries.

Note that the InsertSubscriberData message is still not supported.

[hfreyther: Added talloc_free in gprs_subscr_pdp_data_clear]

Sponsored-by: On-Waves ehf
2015-02-06 09:55:39 +01:00
Holger Hans Peter Freyther f6f86b0eec osmo-bts: Introduce new struct for a power loop in the BTS code
Keep track if the power level has been "fixed" by the BSC,
otherwise keep track of the currently ordered one. The ms_power
is the initial value set by the BSC and continues to be used.
2015-02-05 22:25:03 +01:00
Holger Hans Peter Freyther 4e13a8f9f9 bsc/nitb: Allow to set the GPRS mode through the ctrl command
Create a control command to read and modify the gprs mode. Use
the get_string_value to indicate if the value was found or not.
This is useful for the ctrl interface where I didn't want to
replicate "none", "gprs" and "egprs". Share code to verify that
a BTS supports the mode.

Related: SYS#591
2015-01-31 22:38:48 +01:00
Holger Hans Peter Freyther b8c204cb92 ctrl/bsc: Fix copy and paste error and update text
30f1f37638 introduced new channel
combinations but had a copy and paste error in the description.
The jenkins system didn't run the external tests so this issue
and others were not noticed until now.

Fix the copy and paste and update the test result.
2015-01-31 19:42:42 +01:00
Holger Hans Peter Freyther 7af5f8130f rsl: Remove unused code for channel activation
The code has been unused for a long time. Let's remove it.
2015-01-31 12:49:41 +01:00
Holger Hans Peter Freyther 8657326093 meas: Install the scenario command and test it 2015-01-31 12:49:41 +01:00
Holger Hans Peter Freyther a07e38d4bf meas: Add VTY documentation for the measurement commands
Document the parameters that can be passed on.
2015-01-31 09:48:18 +01:00
Jacob Erlbeck 4b2d02d037 sgsn/test: Fix memory leak in test_subscriber_gsup
Currently the MM context is not deleted when a GSUP location
cancellation message is processed, because the real
sgsn_update_subscriber_data function has been wrapped to a dummy
implementation.

This commit adds an explicit call to sgsn_mm_ctx_cleanup_free which
also unassigns the LLME, so the call to gprs_llgmm_assign is removed.

It also adds an assertion to check that there are no talloc'ed blocks
left in tall_bsc_ctx.

Addresses:
== 372 bytes in 1 blocks are possibly lost in loss record 7 of 9
==    at 0x402A17C: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==    by 0x4059FB8: _talloc_zero (talloc.c:354)
==    by 0x8055B82: sgsn_mm_ctx_alloc (gprs_sgsn.c:167)
==    by 0x804A336: alloc_mm_ctx (sgsn_test.c:140)
==    by 0x804B24D: test_subscriber_gsup (sgsn_test.c:503)
==    by 0x804EC99: main (sgsn_test.c:1853)

Sponsored-by: On-Waves ehf
2015-01-30 21:33:29 +01:00
Jacob Erlbeck baf0f94a7d sgsn/test: Add checks for subscr->error_cause
This commits adds a few asserts that check the value of
subscr->error_cause after a GSUP message has been received.

Sponsored-by: On-Waves ehf
2015-01-30 21:32:47 +01:00
Jacob Erlbeck 9ff82892da gprs: Use 'Network failure' as default cause
This commit adds a check after a GSUP message has been decoded
whether it is an error message and does not contain a cause value.
If his is the case, the cause value is set to 'Network failure', so
that this cause if effectively the default value for error messages.

Sponsored-by: On-Waves ehf
2015-01-30 21:32:26 +01:00
Jacob Erlbeck 85ba655788 gprs/test: Fix GSUP Purge MS response messages
Currently the message types for these message types are wrong.

This patch inserts the correct message types.

Sponsored-by: On-Waves ehf
2015-01-30 21:29:58 +01:00
Jacob Erlbeck 466cedd052 sgsn/test: Add tests for PurgeMs responses
Currently there are not any test cases for PurgeMS GSUP messages in
test_subscriber_gsup.

This commit adds tests for incoming PurgeMSResult and -Error
messages.

Sponsored-by: On-Waves ehf
2015-01-30 21:28:17 +01:00
Jacob Erlbeck 07f6e36ab4 gprs: Send GSUP error reply for requests without IMSI
Currently gprs_subscr_rx_gsup_message returns immediately after it
detects that an IMSI has not been given in the received GSUP message.
While this is ok for responses (result or error), a request should
always be answered.

This commit adds code to reply with a corresponding error message
("Invalid mandatory information") when it receives a request without
an IMSI.

Note that the generated error message will not contain an IMSI either.

Sponsored-by: On-Waves ehf
2015-01-30 21:28:07 +01:00
Jacob Erlbeck 8000e0ea50 gprs: Support cancellation type
The cancellation type that is part of the UpdateCancellation message
is currently ignored.

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

Added VTY commands:

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

the old form without the cause is no longer supported.

Sponsored-by: On-Waves ehf
2015-01-30 21:27:07 +01:00
Jacob Erlbeck 929acdf6bf gprs: Handle PURGE MS ERR/RES without subscr
Currently the subscr entry is no longer present, when PURGE MS
ERROR/RESULT arrives. In this case, an unspecific notice is logged
('unknown IMSI'). This clutters up the logfile with notices even in
perfectly normal operation.

This commit changes the code path that is used when a subscr cannot
be found for an incoming GSUP message. A check for PURGE MS RESULT
and ERROR is added and gprs_subscr_handle_gsup_purge_no_subscr is
called for these messages instead of gprs_subscr_handle_unknown_imsi.

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

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

Added VTY command:

- update-subscriber imsi IMSI destroy

Sponsored-by: On-Waves ehf
2015-01-28 20:42:58 +01:00
Jacob Erlbeck e671d254cb sgsn: Add sgsn_mm_ctx_cleanup_free for safe shutdown
Currently the MM context cleanup code is distributed over several
functions. sgsn_mm_ctx_free not only frees data structure but also
eventually stops the timer and does the subscriber clean-up.
mm_ctx_cleanup_free (gprs_gmm.c) cleans up the PDP contexts and
unassign the TLLI.

This commit moves the cleanup code from both functions into a new
unifying function sgsn_mm_ctx_cleanup_free that cares about the
clean-up of all related sub-systems.

Sponsored-by: On-Waves ehf
2015-01-28 20:42:52 +01:00
Jacob Erlbeck 555b2e5ac1 sgsn: Don't allow mmctx == NULL in sgsn_update_subscriber_data
Currently, sgsn_update_subscriber_data can be called with mmctx ==
NULL and will find and associate the right context (if present) based
on the subscriber's IMSI. This will not happen in regular use
any more, since sgsn_update_subscriber_data will only be called when
subscribers are used (auth mode 'remote') and in this case
gprs_subscr_get_or_create_by_mmctx will already be called by
sgsn_auth_request. Therefore, MM context and subscriber are always
associated except for some test cases and experimental VTY usage.
The current implementation of sgsn_update_subscriber_data also causes
additional complexity for the deletion on MM contexts to avoid a
ipossible double-free MM contexts.

This commit removes the MM context <-> subscriber association code
from sgsn_update_subscriber_data. That function must always be called
with mmctx != NULL, now. To avoid problems with VTY and test usage,
the calling subscriber function now only call
sgsn_update_subscriber_data when mmctx != NULL, since the purpose of
that function is to update that state of an existing MM context after
subscriber data has been changed.

Sponsored-by: On-Waves ehf
2015-01-28 20:42:52 +01:00
Holger Hans Peter Freyther 925c57fb54 nitb: Make the last change configurable
Introduce a NITB node and add the subscriber creation as
config name in there.
2015-01-27 10:58:29 +01:00
Holger Hans Peter Freyther 1ba0730a71 nitb: Allow the network to decide if a subscriber should be created 2015-01-27 10:44:17 +01:00
Jacob Erlbeck 120250ad6f gbproxy: Remove dummy definition of subscr_put
The definition of subscr_put in gb_proxy_main.c will break linking if
symbols from libcommon are used. Since subscr_put is in libcommon,
there is no need for this dummy definition anymore.

This patch removes the dummy definition.

Adresses:
../../src/libcommon/libcommon.a(gsm_subscriber_base.o): In function `subscr_put':
/home/jerlbeck/git/build/openbsc/openbsc/src/libcommon/gsm_subscriber_base.c:90: multiple definition of `subscr_put'
gb_proxy_main.o:/home/jerlbeck/git/build/openbsc/openbsc/src/gprs/gb_proxy_main.c:56: first defined here

Sponsored-by: On-Waves ehf
2015-01-27 08:35:18 +01:00
Jacob Erlbeck 306bb993aa sgsn: Don't reset mm->subscr manually in sgsn_mm_ctx_free
Currently the sgsn_mm_ctx_free contains code to reset the mm->subscr
field that is also present in gprs_subscr_cleanup, which is called
directly afterwards.

This commit modifies the code path, so that the cleanup is done by
the gprs_subscr_cleanup function. The additional reference counter
increment is needed, since mm->subscr->mm->subscr (which is the same
like mm->subscr) will be reset (and unref'd) within
gprs_subscr_cleanup. Because the local variable subscr in
sgsn_mm_ctx_free is an additional pointer to the subscriber object,
it is consequent to adjust the reference counter when the assignment
is done.

Sponsored-by: On-Waves ehf
2015-01-27 08:31:36 +01:00
Jacob Erlbeck 3e4e58f349 gprs: Rename gprs_subscr_delete to gprs_subscr_cleanup
The old name is somewhat misleading. The function is rather preparing
the subscriber for a subsequent subscr_free, that is possibly invoked
by a subscr_put. It detaches the subscriber from the MM context and
optionally invokes a PURGE_MS procedure. Therefore the _cleanup
suffix is chosen (see mm_ctx_cleanup_free).

Sponsored-by: On-Waves ehf
2015-01-27 08:31:03 +01:00
Jacob Erlbeck 3ee67ff5c2 gprs: Don't check for EINPROGRESS in gprs_gsup_client_create
Currently, the return value of gsup_client_connect is checked whether
it is < 0 and != -EINPROGESS. Since gsup_client_connect will only
return a negative value on a few permanent errors (not including
EINPROGRESS), rc is always != EINPROGRESS.

This patch removes the explicit check againt -EINPROGRESS and just
leaves the check rc < 0.

Sponsored-by: On-Waves ehf
2015-01-27 08:30:49 +01:00
Holger Hans Peter Freyther abb3478533 gb_proxy: No need to copy optarg
Fixes: Coverity CID 1206578
2015-01-27 08:30:37 +01:00
Jacob Erlbeck 496aee7cb8 sgsn: Ensure 0-terminated imsi strings (Coverity)
Currently the size argument of strncpy is set to sizeof(mm->imsi) in
some places. If the source IMSI string is too long, the terminating
NUL byte in the static mm->imsi field gets overwritten.

This patch limits the size to sizeof(mm->imsi)-1, so that the last
byte of the buffer (that has been initialized to 0) is not
overwritten.

Fixes: Coverity CID 12065751, 12065754, 1206575

Sponsored-by: On-Waves ehf
2015-01-26 10:59:49 +01:00
Jacob Erlbeck 37139e5933 gprs: Do not put the subscr in gprs_subscr_delete
Currently gprs_subscr_delete implicitely calls subscr_put, which
makes the code more complex than necessary (additional subscr_get) in
a few places. It also makes it more difficult to see, whether get/put
are balanced within a function. In addition, the functions are not
named consistently (gprs_subscr_delete vs.
gprs_subscr_put_and_cancel).

This commit changes the semantics of gprs_subscr_delete and
indirectly of gprs_subscr_put_and_cancel to not call subscr_put on
their argument, but to leave that for the caller to do it
explicitely.

It renames gprs_subscr_put_and_cancel to gprs_subscr_cancel to
reflect that change in the name, too.

Sponsored-by: On-Waves ehf
2015-01-26 09:10:06 +01:00
Holger Hans Peter Freyther 1d778fdce3 sgsn: Remove the "permanent" subscriber cache
The subscriber cache would help in case:

  * GPRS DETACH, GPRS ATTACH. In that case we might still
  have some cached authentication tuples we avoid another
  sendAuthenticationInfo request.

  * After a detach the cache expiry would make sure to
  eventually send a purgeMS to the HLR (which might be
  ignored).

At the same time to make the cache work we will need to
make sure to start and stop timers. In case we don't
start we might accumulate subscribers. I am afraid that
the above two benefits do not outweight the complexity
of this implementation.
2015-01-26 09:09:12 +01:00
Holger Hans Peter Freyther e47d4f6d11 sgsn: Remove MM from the list before gprs_subscr_delete is called
Modify sgsn_mm_ctx_free to remove the entry from the
list as otherwise we might double free the context from
within gprs_subscriber_delete.
2015-01-26 09:08:57 +01:00
Jacob Erlbeck 81ffb740f7 sgsn: Remove inactive LLME/MM after inactivity timeout
Currently old LLMEs and MM contexts that haven't been explicitly
detached or cancelled are not removed until another request with the
same IMSI is made. These stale entries may accumulate over time and
severely compromise the operation of the SGSN.

This patch implements age based LLME expiry, when the maximum age has
been reached, the corresponding MM context is cancelled. If such an MM
context doesn't exist, the LLME is unassigned directly.

The implementation works as follows.
 - llme->age_timestamp is reset on each received PTP LLC message
 - sgsn_llme_check_cb is invoked periodically (each 30s)
 - sgsn_llme_check_cb sets the age_timestamp to the current time if
   it has been reset
 - sgsn_llme_check_cb computes the age and expires the LLME if
   it exceeds gprs_max_time_to_idle()

Ticket: OW#1364
Sponsored-by: On-Waves ehf

[hfreyther: Fix typo in comment LMME -> LLME]
2015-01-26 08:51:50 +01:00
Jacob Erlbeck 841d95f867 gprs: Use a macro value to set the 'Periodic RA update timer'
Currently the T3312 timer is directly set as encoded value when
generating the Attach/RAU Accept messages.

This patch adds GSM0408_T3312_SECS and uses it to set the
information element's value.

Sponsored-by: On-Waves ehf
2015-01-26 08:44:27 +01:00
Jacob Erlbeck 8de9c48c99 gprs: Add 'Negotiated READY timer value' IE to Attach/RAU Accept
Currently this optional IE is omitted, so that the optional
'Requested READY timer value' of the corresponding Request message
is used by the MS (or the default value if this IE is not used).

This patch extends gsm48_tx_gmm_att_ack and gsm48_tx_gmm_ra_upd_ack
to always include the IE set to the default value of T3312 (44s,
see GSM 04.08, table 11.4a).

Ticket: OW#1364
Sponsored-by: On-Waves ehf
2015-01-26 08:42:43 +01:00
Jacob Erlbeck 79af67d7c0 gprs: Add GPRS timer conversion functions
Currently, all GPRS timer values are hard-coded. To make these values
configurable in seconds and to show them, conversion functions from
and to seconds are needed.

This patch adds gprs_tmr_to_secs and gprs_secs_to_tmr_floor. Due to
the limited number of bits used to encode GPRS timer values, only a
few durations can be represented. gprs_secs_to_tmr_floor therefore
always returns the timer value that represents either the exact
number (if an exact representation exists) or the next lower number
for that an exact representation exists.

Sponsored-by: On-Waves ehf
2015-01-26 08:41:52 +01:00
Jacob Erlbeck 37184900e7 gprs: Return 0 from gsup_client_connect if ok or retry timer enabled
Currently the gsup_client_connect return 0 if the call to
ipa_client_conn_open was successful and -errno otherwise. This makes
it difficult for the caller to determine, whether the the whole
operation has been cancelled (currently on EBADF, ENOTSOCK,
EAFNOSUPPORT, EINVAL) or whether the GSUP client will retry to
connect after a timeout. This will cause gprs_gsup_client_create to
destroy the GSUP client object, even if the error might be temporary.

This patch changes the function to return 0 if (and only if)
ipa_client_conn_open was successful or the retry timer has been
started. Since the return value 0 doesn't guarantee, that a
subsequent call to gprs_gsup_client_send will succeed, this shouldn't
break anything.

Sponsored-by: On-Waves ehf
2015-01-26 08:41:52 +01:00
Holger Hans Peter Freyther 9d1a17e15f osmux: Initialize the socket only once
The per BSC code didn't guard against the init already having
been executed. This lead to:

 Adding a osmo_fd that is already in the list.
 <000b> bsc_nat_vty.c:1200 Setting up OSMUX socket

So a new socket got created and the old one leaked. Luckily
Linux appears to allow to bind multiple times so we were able
to just read from the new one. Use the same guard that is used
on the MGCP MGW. Re-order the log message to say "Setting up"
before we actually do that. I manually verified that osmux_init
is called at most once.

The log message was spotted by Roch
2015-01-21 16:56:53 +01:00
Jacob Erlbeck b194862b62 debian: Fix dependencies
The dependecies do not match the current package names or are
missing:

Build-Depends:
  - renamed libgtp-dev -> libgtp0-dev
  - added   libosmo-netif-dev

Depends:
  - renamed libgtp     -> libgtp0

Other run time dependencies might still be missing and have to be
installed manually.

This is taken from Holger's e744ebd17c3761b5cad81d718d0349f2f820ec66.
In addition, the build-dependency on libgtp-dev is replaced by
libgtp0-dev.
2015-01-21 13:24:38 +01:00
Holger Hans Peter Freyther 9be675ea52 mgcp: Honor the rtp IP_TOS settings for Osmux
Honor the IP_TOS settings for Osmux as well. Re-use the RTP
setting as it makes sense to classify the audio packets the
same way.

Fixes: OW#1369
2015-01-21 11:43:03 +01:00