Commit Graph

48 Commits

Author SHA1 Message Date
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 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
Harald Welte d3fa84dbba use new libosmocore gsm_23_003.h for IMEI/IMSI length
... rather than our private definitions everwhere.  As an added benefit,
gprs_gsup_messages.h is now free of any header dependencies within
openbsc.
2016-04-29 13:10:37 +02:00
Harald Welte 3ad0346f00 Revert "move to hex TMSI representation"
This reverts commit 044fbe6568.
2016-03-17 14:42:24 +01:00
Vadim Yanitskiy 044fbe6568 move to hex TMSI representation
In OpenBSC, we traditionally displayed a TMSI in its integer
representation, which is quite unusual in the telecom world.  A TMSI is
normally printed as a series of 8 hex digits.

This patch aligns OpenBSC with the telecom industry standard.

Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
2016-03-17 14:15:16 +01:00
Holger Hans Peter Freyther d6d7affa6e sub: Remove the queue from the subscriber code
The idea of "subscriber_get_channel" was that different
requests would be coordinated. At the same time we have
seen that the "queue" can get stuck at both 31C3 and the
rhizomatica installations.

Voice calls and SMS do not need coordination. We should
be able to send SMS on a voice channel and switch the MS
from a SDCCH to a TCH in case we establish a voice call.
The SMS code itself needs to coordinate to obey the limit
of one SMS per direction but this should be enforced in
the sms layer and not on the subscriber.

Modify the code to have a simple paging coordination. The
subscriber code will schedule the paging and register who
would like to know about success/failure.

This allowed to greatly simplify the paging response
handling for the transaction code (and in fact we could
move the transaction list into the subscriber structure
now). The code gained to support to cancel the notification
of a request (but not the paging itself yet).

TODO: Cancel paging request in case no one cares about it
anymore.
2015-04-29 18:53:28 +02:00
Holger Hans Peter Freyther 0759b1b952 sub: Remove introspection of the "channel queue"
Over the next commits the queuing of commits will be
completely modified to remove the queue and move the
scheduling/limits to the outer callers.
2015-04-29 18:53:27 +02:00
Jacob Erlbeck a1e0373224 sgsn: Put SGSN related subscriber data into separate struct
There will be an increasing number of SGSN related fields per
subscriber. Instead of extending gsm_subscriber accordingly, a single
struct sgsn_subscriber_data object is assigned to it. The talloc
context used to allocated that object is the subscr object itself.
Therefore it will be freed automatically along with the subscr
object.

Sponsored-by: On-Waves ehf
2014-12-09 10:01:08 +01:00
Jacob Erlbeck 33b6dadc88 sgsn: Add gprs_subscriber.c
This patch adds GPRS specific functions for gsm_subscriber objects
(allocation, retrieval, deletion) and subscriber data
requests/updates. The sgsn_update_subscriber_data callback is used to
notify the sgsn about updates and is extended by a parameter that
passes a reference to a gsm_subscriber.

Sponsored-by: On-Waves ehf
2014-12-09 09:23:11 +01:00
Jacob Erlbeck 70d8e31a74 msc: Add per subscriber keep_in_ram flag
Currently the keep_subscr flag in gsm_subscriber_group refers to a
whole group of subscribers which makes it difficult to really delete
single entries if the flag is set.

This patch adds a keep_in_ram field to gsm_subscriber which allows for
keeping subscriber objects in RAM while deleting others.

Note that really deleting an entry requires that both flags
(subscr_group->keep_subscr and subscr->keep_in_ram) are set to 0. So
only the latter should be used if a specification requires the
deletion of a subscriber entry.

Sponsored-by: On-Waves ehf
2014-12-09 09:08:28 +01:00
Jacob Erlbeck 1e30a28e51 msc: Add and use gsm_subscriber_group
Currently every subcriber object directly refers to the gsm_network
which contains a flag shared by every related subscriber
(keep_subscr). This adds a dependency on gsm_network even if only the
function defined in gsm_subscriber_base.c are used.

This patch adds a new struct gsm_subscriber_group which contains the
keep_subscr flag and a back reference to the network object. The
latter is not dereferenced in gsm_subscriber_base.c, so it can safely
be set to NULL when only that part of the gsm_subscriber API is being
used. It also changes that API to use gsm_subscriber_group instead of
gsm_network parameters.

Since there are some places where a pointer to the gsm_network is
needed but where only a gsm_subscriber is available, a 'net' back
pointer is added to the group struct, too. Nevertheless subscr group
and network could be separated completely, but this is not the topic
of this commit.

Sponsored-by: On-Waves ehf
2014-12-05 14:59:02 +01:00
Jacob Erlbeck 02ab91e6a7 sgsn: Cross-link gsm_subscriber and sgsn_mm_ctx
To implement subscriber based authorization a data structure is
needed that keeps the subscriber data. The MSC already uses a similar
struct named gsm_subscriber whose implementation is split into a
generic part (allocation, retrieval, reference counting, list
maintenance) and MSC related parts. For GPRS, only the generic part
will be used and specific fields may be added when needed.

This patch adds a field mm to struct gsm_subscriber that will be used
by the SGSN to store a reference to the current MM context (or NULL
if there is none). This also adds a field subscr to struct
sgsn_mm_ctx that reversely points to a gsm_subscriber (or NULL if
there is none).  Either both fields are NULL or both fields are
non-NULL. Note that subscr is being reference counted.

Sponsored-by: On-Waves ehf
2014-11-14 10:26:49 +01:00
Holger Hans Peter Freyther 7634ec1de1 db: Remove the struct gsm_network from the database layer
The database code should not know about the network. Move the
setting of the network pointer into the subscriber layer.
2013-10-13 13:44:54 +02:00
Holger Hans Peter Freyther c63f6f1f32 expiration: Allow to disable the periodic location updating procedure
Disable the periodic LU using "no periodic location update" VTY
command. In that case set the expire_lu to 0 which will then be
translated to a NULL in the database layer. This leads to a bit of
copy and paste in the db_sync_subscriber method but I don't see
how we could easily use 'datetime(%i, 'unixepoch')' and 'NULL'
at the same time.

Change the query to find expired queries to check for NOT NULL
and the time being in the past. This means if there are still
old subscribers in the database they might not be expired. One
would need to execute a query like "UPATE Subscriber SET expire_lu
= 0 WHERE expire_lu is null". The same applies when disabling the
periodic LU. One would need to update the database by hand.

Manual tests executed/passed:

1.) periodic LU enabled:

  * use gst LUTest.st to do a LU
  * UPDATE Subscriber SET expire_lu=datetime('now');
  * observe the subscriber being expired (it was)

2.) periodic LU disabled:

  * use gst LUTest.st to do a LU
  * verify that the expire_lu is NULL in the database
2013-07-27 22:02:24 +02:00
Holger Hans Peter Freyther e7bd863f76 expiration: Speculative fixes for the periodic expiring handling
We were expiring subscribers during active calls. This is because
the T3212 is stopped under certain conditions but we didn't stop
that timer at all.

Remember if T3212 timer was stopped due something done by NITB and
update the expiration time at the end of the radio connection, as
the phone should restart it when returning to MM Idle.

It is a bit difficult to decide when we should set the flag. E.g.
in a CM Service Request we don't know if we accept the service and
during a LU we already send MM messages before we accept or reject
the subscriber.

The easiest is to set the flag when receiving a paging response
on known subscribers and at the end of the authentication process.

Do not expire a subscriber that has an active connection that is
marked with the flag, e.g. we would still expire a subscriber that
is being paged.

Manual tests executed/passed:

 * gst LUTest.st verified that a expiration date was set
 * gst SMSTest.st (doing another LU but forcing a timeout on the
   SMS sending). Verified that the expire_lu was updated.
2013-07-27 21:39:13 +02:00
Jan Luebbe bfbdeec714 libmsc: Track and update the location update expiry
Set the subscriber expiry timeout to twice the duration of the location
update period and provide functions subscr_expire() and
db_subscriber_expire() to mark subscribers offline that have missed two
location update periods.

This patch increases the DB revision to 3, so the hlr will be
incompatible with prior versions.

We should allow 0 for T3212 as well to disable the location update
period. In that case we will need a way to indicate that in the
database.
2013-01-01 17:19:47 +01:00
Holger Hans Peter Freyther a8a09df6a6 misc: Remove sys/types.h includes from the files
These are not needed any more. We used them for u_int
types but we now use uint which comes from stdint.h
2011-04-18 17:31:39 +02:00
Holger Hans Peter Freyther c42ad8b686 misc: Move from u_int to uint types of stdint.h
This was done with sed on the files.
2011-04-18 17:31:39 +02:00
Pablo Neira Ayuso 136f453dd2 src: use new library libosmogsm and new path to headers in libosmocore
libosmogsm is a new library that is distributed in the libosmocore.
Now, openbsc depends on it. This patch gets openbsc with this
change.

This patch also rewrites all include path to the new
osmocom/[gsm|core]

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-03-23 18:17:56 +01:00
Holger Hans Peter Freyther 451eb29e37 subscr: Add a vty option to kick the queue. 2011-01-06 14:52:52 +01:00
Holger Hans Peter Freyther 763b42a92a subscr: Dump the pending requests to help with debugging state. 2011-01-06 14:52:52 +01:00
Holger Hans Peter Freyther fc857414ae subscr: Make it possible to clear pending requests for a subscriber 2011-01-06 14:52:52 +01:00
Holger Hans Peter Freyther ebdd3cbd89 subscr: Show the number of pending requests on this subscriber. 2011-01-06 14:52:52 +01:00
Holger Hans Peter Freyther 725966d9b4 subscr: Make the subscr_put_channel work with the subscr
The active channel might or might not be gone when the transaction
has been released. Instead of passing an invalid subscriber conn
we will pass the subscr that is ref-counted and guranteed to be
valid at this point. subscr_put_channel could search the connections
for an active connection if that is ever needed.
2011-01-06 14:52:51 +01:00
Holger Hans Peter Freyther abd0cac0c5 subscr: Add a VTY command to update the subscriber from the database. 2010-12-24 21:40:48 +01:00
Holger Hans Peter Freyther f694d5f47a subscr: Introduce subscr_purge_inactive to free unused subscribers
Introduce a method that will remove all subscribers that have a
zero use count. This is useful if someone wants to purge subscribers
from memory or wants to disable the everything in RAM feature.
2010-12-24 21:40:47 +01:00
Holger Hans Peter Freyther 8dfd241bc6 subscr: Add method to find an active subscriber
This is used by the paging code of the osmo_bsc. When we get
a paging response there should be an active subscriber with
the TMSI or IMSI and we can stop paging. There is no need to
allocate a new subscriber.
2010-11-15 20:06:45 +01:00
Holger Hans Peter Freyther d740b688dc subscr: Add the subscr_get_or_create from the on-waves/bsc-master branch
Create a subscriber based on a known IMSI, search the list of
active subscribers if there is already someone like this.
2010-11-15 20:06:45 +01:00
Holger Hans Peter Freyther 928ca743db subscr: Move the TMSI reserved into the gsm_data
Put it into the gsm_data.h to avoid requiring MSC code
in the BSC code paths.
2010-11-15 20:06:45 +01:00
Holger Hans Peter Freyther fa530cd6d8 gsm_subscriber: Increase the name to 160 charachters
160 charachters is the limit of the subscriber name inside
the notifySS nameIndicator/callingName.
2010-07-26 03:55:56 +08:00
Holger Hans Peter Freyther bddd152049 bsc_api: Operate on the subscriber connection for subscriber management 2010-06-16 15:42:40 +08:00
Harald Welte dfe6c7d910 split 'libosmocore' from openbsc codebase
This library is intended to collect all generic/common funcitionality
of all Osmocom.org projects, including OpenBSC but also OsmocomBB

The library currently includes the following modules:

bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer,
tlv_parse, linuxlist

msgb allocation error debugging had to be temporarily disabled as it depends on
'debug.c' functionality which at the moment remains in OpenBSC
2010-02-20 16:27:23 +01:00
Harald Welte 2e6d4684ff add (and use) new subscr_name() function to get name or IMSI 2009-12-24 14:50:24 +01:00
Mike Haben 2449b37dfe [USSD] various USSD improvements
- Improved handling of extension-number string (as per review)
- Guard against a buffer-overflow if mobile sends a too-long USSD
- declare some function-parameters const
- fix gsm_ts_name function to display the right BTS number (bts->nr rather than bts->bts_nr)
2009-10-26 20:39:26 +01:00
Holger Hans Peter Freyther 2223025e21 [tmsi] Make the tmsi a 4 octet number
tmsi is four octets long, there is no need to make it a string
and then jump through hoops to convert it to a number. Keep the database
using it as a string to benefit from the NULL handling of the db.

Introduce the reserved tmsi which has all bits set to 1 according
to GSM 03.03 §2.4 and start checking for it and make sure the db
code will never allocate such a tmsi.
2009-09-28 05:14:25 +02:00
Holger Hans Peter Freyther e4e8bf4dd0 [subscr] Change the signature... the gsm_network is in the subscr
Remove the extra parameter from the method, the network can be
taken from the subscriber.
2009-08-20 13:56:45 +02:00
Harald Welte (local) 15920de8ce add 'show subscriber cache' vty command to debug subscriber refcount leaks 2009-08-14 20:27:16 +02:00
Jan Luebbe ebcce2aae1 allocate an extension when creating the subscriber 2009-08-12 22:22:20 +02:00
Jan Luebbe b0dfc31d7d flag new subscriber structs in memory and send a signal 2009-08-12 21:03:00 +02:00
Harald Welte 76042188e0 first 'working' SMS implementation
we now have the full path from the MS into the database (SUBMIT), as well as
back from the database to the MS (DELIVER).  The database gets correctly
updated once a SMS has been successfully delivered.

What's still missing is the periodic scan over all undelivered messages,
trying to deliver them to the respective MS.  So far, you have to manually
trigger this on the telnet interface with 'sms send pending 1'
2009-08-08 16:03:15 +02:00
Harald Welte 9176bd46e3 make sure subscr->net is always set
since a subscriber is an element of the gsm_network, we have to ensure
subscr->net is always set correctly.  We do this by using gsm_network
as an argument to all functions that resolve or create a subscriber.
2009-07-23 18:46:00 +02:00
Harald Welte f0465bd6cb Merge branch 'master' into sms 2009-07-05 14:10:01 +02:00
Harald Welte c2e302dc84 Store classmark1/2/3 in equipment SQL table
For further evaluation/analysis, this patch stores the classmark 1, 2 and 3
values of every equipment in the SQL database.  We can use this non-volatile
data to determine the supported features for each handset that we've ever
seen on our network.
2009-07-05 14:08:13 +02:00
Harald Welte be3e3784dc further SMS work
* implement ID based lookup of gsm_subscriber from database
* look-up recipient and sender subscribers from database
2009-07-05 14:06:41 +02:00
Harald Welte 4bfdfe7f70 reworked MNCC codebase
This is Harald's reworked MNCC base, slowly heading towards integration
into master.  The key changes are:
* provide much more structure to the data in gsm_mncc
* encode_* and decode_* functions now take a structure rather than tons
  of individual arguments (whose order nobody can remember)
* make sure we don't have copies of the same code everywhere by introducing
  mncc_set_cause() and mncc_release_ind()
* save horizontal screen space if possible
* make sure we break lines > 80 characters
2009-06-10 23:25:50 +08:00
Holger Freyther 85a7b363d9 Handle and dispatch paging requests in gsm_subscriber
Implement subscr_get_channel and subscr_put_channel to
a degree that SMS Submit and phone call scheduled at the
same time will deliver both (one after the other).
2009-06-10 13:38:20 +02:00
Holger Freyther 04866d4279 Proposal for a "channel request" interface...
Reuqests for a subscriber a stored within the gsm_subscriber
datastructure and it will keep track how many channels are
allocated for this user and of which type to decide on policy...

e.g. attempt to submit SMS during a phone call and not doing
paging but a simple (immediate) assignment of the channel...
2009-06-10 13:20:39 +02:00
Harald Welte 13e10daa33 move openbsc into its own subdirectory 2009-06-10 05:40:52 +08:00