Commit Graph

33 Commits

Author SHA1 Message Date
Philipp Maier 3ec03d5048 Moving grs_sndcp.h header file to include
For some reason gprs_sndcp.h is located in src/gprs. This commit moves
gprs_sndcp.h to include/openbsc and fixes the include path in
gprs_sndcp.c and gprs_sndcp_vty.c

Change-Id: If4e4f1252c81d7907c1b4d738c982bb172b128c9
2016-08-27 04:45:55 +00:00
Max 82040101eb SGSN: encrypt/decrypt only necessary frames
According to 3GPP TS 24.008 § 4.7.1.2 some GMM frames are not supposed
to be ciphered. Propagate information about the necessity for
encryption between MM <-> LLC to ensure only proper frames are
encrypted/decrypted/dropped.

Change-Id: I0358905e60d1b182f75caec81bfcc72bbbbb2aa1
Related: OS#1582
2016-07-16 23:17:58 +00:00
Holger Hans Peter Freyther f9ffd1fa18 sgsn: Prevent memory leak and double free
This has been re-produced using the "osmo-pcu emulator" code
and a ping to force segmented SNDCP messages. When the NS link
enters the DEAD/BLOCKED state the msgb would be freed twice.
Once inside gprs_ns_sendmsg and once by the caller. Based on the
return one can not see if the parameter has been deleted.

I changed libosmocore/libosmogb to always free the msgb in case
of an error on the way to gprs_ns_sendmsg. Catch up, avoid the
double free and fix some memory leaks. In case the sending fails
assume the entire segmented message is at end and free the
original input data.

This has been tested by posix suspending/resuming the emulator
process to have the GPRS-NS link go to dead/blocked to alive
and unblocked. The ping recovers and "SIGUSR1" to the SGSN does
not show active memory allocations.

The SGSN calls bssgp_tx_dl_ud at the lowest level and has the
following callchains. Most of them allocate the msgb and have
no early return and transfer ownership already:

<- gprs_llc_tx_u
<- gprs_llc_tx_ui
	<- gsm48_gmm_sendmsg (all callers sane)
		<- _tx_status
		<- _tx_detach_req
	<- gprs_llc_tx_xid (all callers sane)
	<- sndcp_unitdata_req
		<- sndcp_send_ud_frag
2014-10-10 17:43:40 +02:00
Holger Hans Peter Freyther cfee952e23 gprs: Fix compiler warnings in gprs_sndcp.c
CC       gprs_sndcp.o
gprs_sndcp.c: In function ‘defrag_input’:
gprs_sndcp.c:188:25: warning: variable ‘scomph’ set but not used [-Wunused-but-set-variable]
  struct sndcp_comp_hdr *scomph = NULL;
                         ^
gprs_sndcp.c: In function ‘sndcp_llunitdata_ind’:
gprs_sndcp.c:512:11: warning: variable ‘npdu_num’ set but not used [-Wunused-but-set-variable]
  uint16_t npdu_num;
           ^
gprs_sndcp.c: At top level:
gprs_sndcp.c:565:12: warning: ‘sndcp_ll_reset_ind’ defined but not used [-Wunused-function]
 static int sndcp_ll_reset_ind(struct gprs_sndcp_entity *se)
            ^
gprs_sndcp.c:573:12: warning: ‘sndcp_ll_status_ind’ defined but not used [-Wunused-function]
 static int sndcp_ll_status_ind()
            ^
2014-04-04 12:43:08 +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
Holger Hans Peter Freyther a8ddb08e05 misc: Use msgb_free for freeing the messages 2012-03-01 20:30:32 +01:00
Holger Hans Peter Freyther 6142dc407a gprs: Fix compiler warnings in the code 2011-10-14 23:37:27 +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
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 3d6815abd1 [SGSN] SNDCP: Subtract SNDCP header from fragment length
We don't want to store too many bytes as we would otherwise create
too large re-assembled packets..
2010-07-02 17:16:07 +02:00
Harald Welte 36f1217f32 [SGSN] SNDCP: SN-PDUs need a 16bit length field
The BSSGP LLC-PDU IE can have up ot 16bit length, so subtracting
the LLC header the SN-PDU can still have almost a length field
close to 0xffff
2010-07-02 16:44:24 +02:00
Harald Welte 8b705f2533 [SGSN] SNDCP: re-set total number of fragment length 2010-07-02 16:18:59 +02:00
Harald Welte ab4094ca6b [SNDCP] some more defragmentation debug statements 2010-07-02 16:01:47 +02:00
Harald Welte 60da7d4f88 [SGSN] SNDCP defrag: use correct length, don't include LLC FCS
The LLC layer tells us the PDU length, and we have to use it
in SNDCP rather than to re-calculate it if we want to avoid copying
the CRC24 into the defrag elements.
2010-07-02 15:45:12 +02:00
Harald Welte 8f0c0a3a3c [SGSN] SNDCP: Actually copy the payload data in the defrag queue entry
Prior to this patch our defragmented messages always consisted of 00-bytes
2010-07-02 10:29:06 +02:00
Harald Welte 993697c8d2 [SGSN] SNDCP: Fix off-by-one error missing last segment in defrag
When we defragment the segments from the defrage queue, we have
to iterate all the way up to (and including) the last segment number
that we have received.
2010-07-02 10:11:42 +02:00
Harald Welte b87bc86006 [SGSN] SNDCP: more verbose defragmentation debugging 2010-07-01 20:29:20 +02:00
Harald Welte 8911cef81d [SGSN] Fix segfault when passing re-assembled SN-PDU to GMM
sgsn_rx_sndcp_ud_ind() can no longer make the assumption that msgb_bcid() is
valid, as this is only true for an un-fragmented SN-PDU.  So instead,
we now store the RAID in the SNDCP Entity and pass it as an explicit
argument to sgsn_rx_sndcp_ud_ind().
2010-07-01 19:56:19 +02:00
Harald Welte 951a12cf4e [SGSN] SNDCP: fix off-by-one error during defragmentation 2010-07-01 15:09:45 +02:00
Harald Welte 362aea0f4d [SGSN] SNDCP: Initialize defrag list header 2010-07-01 12:31:10 +02:00
Harald Welte 65d96783df [SGSN] SNDCP: use llist_for_each_entry_safe() when cleaning frag queue 2010-07-01 12:19:02 +02:00
Harald Welte f78a3b2a22 [SGSN] Add VTY interface for SNDCP 2010-07-01 10:57:44 +02:00
Sylvain Munaut eda125ca51 [gprs] sndcp: Fix call to msgb_alloc_headroom to have both head&tail room
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-06-10 15:15:42 +02:00
Harald Welte ce22f92b6c [GPRS] SNDCP: Implement fragmentation of N-PDUs to SN-PDUs in downlink
Using the code of this commit, it was possible to provision GPRS
services and access a website from a G1 phone (Qualcomm MSM7k baseband chipset)
using a nanoBTS, Osmo-SGSN and OpenGGSN.

There is still no fragment re-assembly in the uplink path yet,
despite the (untested) code present in the gprs_sndcp.c file
2010-06-03 21:21:21 +02:00
Harald Welte db2c39f888 [GPRS] SNDCP: Check if SN-PDU is too large and reject it
... since we don't do fragmentation yet
2010-06-03 07:16:04 +02:00
Harald Welte bb1c805718 [GPRS] implement GTP->SNDCP->LLC downlink user-data path
This only works for packets that are small enough to not need
fragmentation at the SNDCP layer (dns queries, ntp and the like).

It requires libgtp built from OpenGGSN dc3744fda045f9fca83de6881176987335a309a8
or later.  Plain 0.90 will NOT work.

Using this version, I could see bi-directional traffic from various
phones going all the way through BTS, OsmoSGSN, OpenGGSN and being routed
to and from the real internet.  Time to celebrate...
2010-06-03 06:38:38 +02:00
Harald Welte 5cc2bc37a7 [GPRS] SNDCP: Fix PCOMP and DCOMP header field length
They're both just one 4bit nibble, not 1 byte each.
2010-06-02 23:17:05 +02:00
Harald Welte 6144452068 [GPRS] SNDCP: Add new SNDCP Entity to global list of entities
Also, don't reject SN-PDUs with positive packet length.
2010-06-02 12:40:48 +02:00
Harald Welte 69996cb534 [GPRS] SNDCP use DSNDCP instead of DGPRS 2010-06-02 10:26:19 +02:00
Harald Welte 16836a37aa [GPRS] SNDCP: Fix header length (pcomp is part of common_hdr)
Also add some more debug statements
2010-06-02 10:25:40 +02:00
Harald Welte ebabdea0a6 [GPRS] hand SNDCP N-PDUs to the GTP to the GGSN
This so far only works for UNIT-DATA and only if the N-PDU is not fragmented at
the SNDCP layer.
2010-06-01 18:28:10 +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 e236596bf4 [gprs] Move all GPRS related code to src/gprs subdirectory 2010-05-04 07:41:59 +02:00