Commit Graph

154 Commits

Author SHA1 Message Date
Harald Welte 7f6da485f5 sgsn: add a minimalistic ACL
This adds a minimalistic ACL by which certain, individual roaming IMSIs
can be authorized to use the SGSN.  So you can selectively bypass the
'MCC+MNC == first 5 digits of IMSI' checking for a couple of IMSIs
2013-07-21 15:44:24 +08:00
Alexander Chemeris 84402c0c82 sgsn: Fix lengths of MS Network Capability and MS Radio Access Capability elements.
Original code was inconsistent about lengths and could lead to out
of bounds write. Lengths were also inconsistent with the TS 24.008.

Fixes: Coverity CID 1040714.
2013-07-04 18:34:49 +02:00
Harald Welte 7b022eed2d add some comments regarding the free() / release of pdp contextx
It might be that we're deleting structures instead of properly cleaning
up the attached libgtp handles...
2012-07-14 12:17:42 +02:00
Harald Welte ea34a4e3a7 split libgb into a separate library for outside use
This also removes the dependency to osmo_sock() inside libcommon and
replaces it with osmo_sock_* from libosmocore
2012-06-16 15:14:00 +08:00
Harald Welte d4c6f8b343 GPRS GMM: When we receive a RA UPD REQ, we are NORMAL even after SUSPEND
There is no explicit BSSGP RESUME in case the MS sends a RA UPD REQ
after being in SUSPEND previously.
2011-10-16 21:35:21 +02:00
Harald Welte 2b697a6671 GPRS GMM: Send LLGMM-RESET.req when talking to unknown MS
In case a MS (of which we have no MM context) sends us anything but a
GMM ATTACH REQUEST, we need to send it a LLC XID RESET (by means of
issuing LLGMM-RESET.req).  Otherwise the phone will expect us to send a
specific unacknowledged sequence number that we don't know.

Thanks to Holger for pointing this bug out to me.

It seems to commonly occur when a MS is doing network re-selection and
(erroneously) sends a RA UPD REQ instead of an ATTACH REQ.  The RA UPD
REJ that we sent was never seen by the GMM entity in the MS, as the LLC
entity discarded it due to sequence number mis-match.
2011-10-16 18:58:30 +02:00
Holger Hans Peter Freyther 2b17454f4a gprs_gmm: Fix various compiler warnings
gprs_gmm.c:240:2: warning: passing argument 4 of ‘gprs_llc_tx_ui’ discards qualifiers from pointer target type
../../include/openbsc/gprs_llc.h:151:5: note: expected ‘void *’ but argument is of type ‘const struct sgsn_mm_ctx *’
gprs_gmm.c:349:11: warning: unused variable ‘ptsig’
gprs_gmm.c:601:5: warning: too many arguments for format
gprs_gmm.c:987:25: warning: initialization discards qualifiers from pointer target type
gprs_gmm.c:1010:6: warning: ‘rc’ may be used uninitialized in this function
2011-10-14 23:31:34 +02:00
Harald Welte cdf76cff9f GPRS: Fix the parsing/interpretation of the PDP CTX status IE
The byte ordering is a bit odd:  The least significant byte is ahead of
the most significant byte, different from everything else in GSM that
seems to be big-endian.

Thanks to Seungju Kim <admin@manateeshome.com> for repoerting the bug.
2011-08-05 21:23:46 +02:00
Harald Welte 4b2ed35b8f GPRS: Fix buffer overflow in case of very long MS RA CAP IE
The MS Radio Access Capability IE can be _very_ long in some recent
high-end mobile phones, way beyond the old 14-byte limit.  We increase
our array to 52 bytes, and make sure not to overflow that buffer.
2011-07-27 23:35:38 +02:00
Harald Welte f6b606f422 gprs_gmm: ctx cannot be null, so remove check
Detected by Smatch:
/home/laforge/projects/git/openbsc/openbsc/src/gprs/gprs_gmm.c +757 gsm48_rx_gmm_att_req(133) warn: variable dereferenced before check 'ctx'
2011-07-16 13:45:57 +02:00
Pablo Neira Ayuso c0d17f2266 src: use namespace prefix osmo_* for misc utils
Summary of changes:

s/bcd2char/osmo_bcd2char/g
s/char2bcd/osmo_char2bcd/g
s/hexparse/osmo_hexparse/g
s/hexdump/osmo_hexdump/g
s/hexdump_nospc/osmo_hexdump_nospc/g
s/ubit_dump/osmo_ubit_dump/g
s/static_assert/osmo_static_assert/g
2011-05-07 12:58:59 +02:00
Pablo Neira Ayuso bf540cb7c3 src: use namespace prefix osmo_timer* for timer functions
Summary of changes:

s/struct timer_list/struct osmo_timer_list/g
s/bsc_add_timer/osmo_timer_add/g
s/bsc_schedule_timer/osmo_timer_schedule/g
s/bsc_del_timer/osmo_timer_del/g
s/bsc_timer_pending/osmo_timer_pending/g
s/bsc_nearest_timer/osmo_timers_nearest/g
s/bsc_prepare_timers/osmo_timers_prepare/g
s/bsc_update_timers/osmo_timers_update/g
s/bsc_timer_check/osmo_timers_check/g
2011-05-06 12:11:06 +02:00
Harald Welte d36ff76f9d Fix build of bsc-nat and GPRS code after include path change
The last patch changed the osmocore include paths, this fixes some build
problems caused by it
2011-03-23 18:33:26 +01: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
Harald Welte f0901f0067 [SGSN] Fix processing of RA Update Request regarding TLLI
In case we get a RA UPD REQ on a new cell (both served by the same
SGSN), the LLC stack should not allocate a ne LLE/LLME, as the latter
would reset the V(u)sent / V(u)recv to zero and make the MS discard
our responses.

Instead, whenever the LLC stack sees a foreign TLLI, it should always
convert it to the local TLLI before doing any lookup for a LLE/LLME.
2011-01-01 17:28:29 +01:00
Harald Welte 9af6ddfcec License change: We are now AGPLv3+ instead of GPLv2+
The reason for this is quite simple: We want to make sure anyone
running a customized version of OpenBSC to operate a network will
have to release all custom modifiations to the source code.
2011-01-01 15:39:34 +01:00
Harald Welte c728eeaf9b SGSN: Avoid duplicate MM contexts in case MS and SGSN disagree on P-TMSI 2010-12-26 19:20:07 +01:00
Harald Welte a9b473a3c2 SGSN: Implement network-initiated PDP CTX DEACT when GGSN restarts
If the GGSN restarts, its restart counter will increase.  We can
detect that and accordingly release/delete all PDP contexts for
that GGSN.
2010-12-26 19:20:03 +01:00
Harald Welte eafe22ca72 SGSN / GMM: Only allow non-roaming IMSIs
As we do not yet use the HLR from the SGSN, we allow all MS to
attach to our GPRS network.  However, if this is running in a public
environment, it could cause service interruption to users of commercial
GPRS networks.

Thus, we now check if the first 5 digits of the IMSI match the MCC/MNC
of the cell that they want to register to.  Thus, any subscribers with
SIM cards from real operators will no longer be accepted.
2010-12-24 15:42:26 +01:00
Harald Welte f6bd340df6 GPRS/GMM: Correctly look up MM Context in RA Update
If a MS changes RA, the RA will arrive in the new cell using the old
TLLI (masked as foreign TLLI).  So we need to look-up the TLLI
in a special way, using the old RA as indicated in the 04.08 GMM
message.

There is still another bug remaining: As we somehow create a new LLC,
the sequence numbers of our responses start from 0 again, which is not
what the MS expects.  This needs to be fixed in a follow-up patch.
2010-12-23 23:38:02 +01:00
Harald Welte c48ac4750d [SGSN] Some IEs in ATTACH REQUEST can be longer in 24.008
The original length checks were based on 04.08, but 24.008 allows
longer IEs.
2010-07-03 21:20:06 +02:00
Harald Welte 4b6ac1edb9 [SGSN] Initial work on GMM authentication and ciphering 2010-07-03 11:09:06 +02:00
Harald Welte d6f582b352 [SGSN] use GPRS_ALGO_GEA0 instead of '0' 2010-07-02 22:56:55 +02:00
Harald Welte 23c13760ca [SGSN] SM: Properly parse APN and PCO Optional IE in PDP CTX ACT REQ 2010-07-02 22:52:04 +02:00
Harald Welte 18d1452a92 [SGSN] Send poper SM and GMM STATUS in case we have no MM CTX 2010-07-02 16:18:18 +02:00
Harald Welte 11ff3e8ec2 [SGSN] Remove old dead code 2010-07-02 10:17:24 +02:00
Harald Welte 19f9e30eb9 [SGSN] Only increment PDP CTX ACT count after check for retransmission 2010-07-02 10:15:49 +02:00
Harald Welte b37515e86b [SGSN] Account for re-transmitted PDP CTX ACT REQ
In case our PDP CTX ACT ACK gets lost on the Gb or Um link,
the MS re-transmits the PDP CTX ACT REQ.  We have to ACK it
again instead of REJecting it..
2010-07-02 10:12:58 +02:00
Harald Welte fd29a1f6cc [SGSN] GMM: Complete value_string for GMM cause values 2010-07-01 12:26:59 +02:00
Harald Welte 875840c603 [SGSN] Fix TLLI (re)assignments
Once The TLLI (or P-TMSI of which it is derived) change has been
confirmed by the MS, we need to unassign the old TLLI but keep
the new TLLI  _without_ re-setting the LLC entity structure such
as VUsend /VUrecv counters.
2010-07-01 11:54:31 +02:00
Harald Welte bd5c91276b [SGSN] MM: Properly communicate TLLI changes / unassignment to LLC 2010-06-28 22:18:53 +02:00
Harald Welte c0d59504b4 [SGSN] Deactivate all PDP contexts on GPRS DETACH 2010-06-28 19:11:41 +02:00
Harald Welte 5bfe499366 [GPRS] SGSN: Pass BSSGP SUSPEND/RESUME up to GMM and alter MMCTX state 2010-06-09 21:40:45 +08:00
Harald Welte f54e7e2102 [GPRS] GMM/SM: Improve error handling by sending STATUS messages 2010-06-09 21:40:45 +08:00
Harald Welte 588d44ee65 [GPRS] Drop all PDP contexts not present in PDP CTX STATUS IE at RA UPD 2010-06-09 21:40:45 +08:00
Harald Welte 60ebc02ba8 [GPRS] SM: Acknowledge PDP CTX DEACT for non-existing PDP CTX
Some phones (notably a Ericsson Mobile Platform based E-TEN M800)
insist on sending PDP CTX DEACT messages for contexts that have already
been deactivated.  The spec doesn't really say what we should do in
this case. But since there is no "reject", we simply acknowledge it.
2010-06-09 21:40:45 +08:00
Harald Welte 807a5d8264 [GPRS] Major LLC / TLLI handling fixes
* separate the LLME and LLE state in the LLC layer
* introduce gprs_llgmm_assign() function for LLGMM-ASSIGN.req primitive
* change QoS profile to match 'real' SGSN
* Update the new TLLI when assigning a P-TMSI

The result now is that the LLC layer is notified of TLLI changes, which in turn
means it doesn't allocate a new LLE structure every TLLI change, which again
in turn means that the UI frame sequence number does not reset to zero.

As a result, MS should no longer ignore frames based on wrong UI sequence number.
2010-06-01 11:57:13 +02:00
Harald Welte dce1255d8f [GPRS] GMM: Set LLC 'C/R' bit when sending IDENTITY REQUEST
Commands initiatied by the SGSN have to set C/R = 1
2010-05-31 22:31:04 +02:00
Harald Welte 56a0145dd8 [GPRS] Include IMSI and DRX params in BSSGP DL-UD
When we send a downlink unit-data request via BSSGP, there is a lot
of information that needs to be copied from the mm context, such as
the IMSI, DRX parametes, MS radio access parameters, ...

This is a quite strange layering violation, since we now need to pass
a pointer to the MM ctx from GMM through LLC into BSSGP :(
2010-05-31 22:12:30 +02:00
Harald Welte c2e8cc4a10 [GPRS] Implement TMSI reallocation and timers 3350 + 3370
Our state transitions and timers now reflect 04.08 for GMM much
better than before.  Also, we allocate a new P-TMSI on every ATTACH
and RA UPDATE, as some phones seem to get confused if they don't
get a P-TMSI.
2010-05-31 20:23:38 +02:00
Harald Welte b12aa4b1ee [GPRS] GMM: Add some FIXME's to the code 2010-05-30 20:28:22 +02:00
Harald Welte ab1d5626ac [GPRS] SGSN: use GGSN IP address from config file, disable TMSI allocation 2010-05-18 19:58:38 +02:00
Harald Welte cd4dd4d7ff [GPRS] fix numerous compiler warnings 2010-05-18 17:20:49 +02:00
Harald Welte 6463c0799c [GPRS] SGSN: TMSI allocation 2010-05-18 17:04:55 +02:00
Harald Welte 4e38ac7a8a [GPRS] SGSN: Correctly set upper 4 bits of PDP address to 0
It's really strange.  In GTP those 4 bits are 1, in 04.08 they are
zero.  Otherwise the IE is exactly the same :/
2010-05-18 14:51:18 +02:00
Harald Welte 3c0b9b9c2a [GPRS] SGSN: Make sure the PCO from GGSN are passed to the MS 2010-05-18 14:36:11 +02:00
Harald Welte 77289c202f [GPRS] SGSN: properly delete a PDP context after receiving PDP CTX DEACT REQ 2010-05-18 14:32:29 +02:00
Harald Welte 55e0df7c43 [GPRS] SGSN: Don't use GGSN-provided QoS as the MS doesn't like it 2010-05-18 13:20:08 +02:00
Harald Welte 68b99a4a08 [GPRS] fix null pointer dereference in GMM 2010-05-18 12:05:42 +02:00
Harald Welte 8acd88f369 [GPRS] SGSN: Include rate counters in MM Context 2010-05-18 10:57:45 +02:00
Harald Welte 6abf94e420 [GPRS] Properly connect GPRS SM with LIBGTP for PDP context activation
* store LLC SAPI as part of PDP ctx
* store NSEI + BVCI as part of MM ctx
* export gsm48_tx_gsm_act_pdp_acc() and call it from sgsn_libgtp.c
* create and use gsm48_tx_gsm_act_pdp_rej for error cases
* print SAPI as part of VTY show pdp
2010-05-18 10:35:06 +02:00
Harald Welte d193cb327a [GPRS] More work on a real SGSN 2010-05-17 22:58:03 +02:00
Harald Welte 2720e7310d [GPRS] Initial untested support for libgtp
libgtp of the OpenGGSN project will allow us to speak the GTPv0/v1
protocol of the interface between SGSN and GGSN.

This commit includes code for the main libgtp integration (file
descriptor, select loop, timer) as well as code to encode/send
a CREATE PDP CONTEXT request.
2010-05-17 00:44:57 +02:00
Harald Welte 24c9fc1700 [GPRS] Rename gsm_04_08_gprs.c to gprs_gmm.c
GMM refers to GPRS Mobility Management.
2010-05-13 21:29:11 +02:00