9
0
Fork 0
Commit Graph

196 Commits

Author SHA1 Message Date
Pablo Neira Ayuso 3f58223436 ggsn: add support for GTP kernel data encapsulation
This patch adds the -g, --gtpnl=device option that allows you to
enable the GTP kernel tunneling mode in openggsn. You have to specify
the real downlink device that will be used to tunnel traffic, eg.

	-g=eth0

This means that the gtp0 device will be created and it will use eth0
as the real device to encapsulate packet coming from the Internet that
are addressed to the MS (so the tunnel devuce encapsulates these IP
packets in GTP packets when traveling to the SGSN).

Alternatively, you can also add this to the ggsn.conf configuration file:

	gtpnl eth0

The device has to be the real device that can route packets to the SGSN,
if you select the wrong device, the kernel routing code may not find a
way to reach the SSGN, you've been warned.

Therefore, if this option is set, the operational becomes the following:

1) A gtp0 device is created via rtnetlink and configure the socket
   encapsulation infrastructure in the kernel.
2) Whenever a PDP context is created, this adds the necessary tunnel
   configuration via genetlink GTP interface.
3) Whenever a PDP context is destroyed, this deletes the tunnel via
   genetlink GTP interface.
4) Destroy the gtp0 device if ggsn is stopped, including all of the
   existing tunnels.

You require the osmo-ggsn.git tree, which contains the kernel module
gtp.ko and the libgtpnl library that you have to compile and install.
Make sure you have loaded the gtp.ko kernel module before launching
the ggsn daemon using the kernel driver mode, otherwise you will get
a nice "operation not supported" error message ;-).

This patch also adds supports for "ipup" configuration option to invoke
an external script after the gtp0 device has been brought up. Typical
command to add the route to reach the MS behind the GGSN is required,
eg. ip route add 10.0.0.0/8 dev gtp0.

The (horrible) ggsn parser has been manually extended to support the
new configuration option. That code doesn't look nice, but it just
mimics what we already have there for consistency, please don't blame
me for that.

If you want to run in debugging mode, I suggest you to use:

	sudo ggsn -c ggsn.conf -f -d

Note that you do have to run openggsn as root to bring up the gtp0
device. You have to see this message that announce that the GTP kernel
mode is enabled.

openggsn[1106]: ggsn.c: 656: Using the GTP kernel mode (genl ID is 25)

This patch also automagically sets up route to reach MS from Internet
just like tun mode does. This is fundamental to get this working,
better don't leave to the admin, he may forget to add this route.

In this patch, I tried to encapsulate this new feature as much as
possible as Harald initially suggested.

To compile this feature, you have to pass --enable-gtp-kernel, ie.

./configire --enable-gtp-kernel

Otherwise, the code to interact with the gtp kernel part is not compiled.
2014-03-24 19:20:26 +01:00
Pablo Neira Ayuso 746b944ad6 gtp: add pdp_set_imsi_nsapi
Encapsulate code to handle the teid with GTPv0.
2014-03-24 17:59:19 +01:00
Holger Hans Peter Freyther 9c0ff4fafe cli: Introduce a logfile command to log errors to a file
The evolution would be to introduce libosmocore and start using
the logging framework. But even then we can map this option to
the file target.

Fixes: SYS#263
2014-03-23 10:29:17 +01:00
Holger Hans Peter Freyther 1c4d9e6d87 cli: Manually patch the generated code to fix compiler warning
cmdline.c: In function ‘cmdline_parser_internal’:
cmdline.c:588:7: warning: variable ‘check_required’ set but not used [-Wunused-but-set-variable]
   int check_required;
       ^
2014-03-23 10:27:21 +01:00
Holger Hans Peter Freyther 6c0b9c2c42 cli: Re-generate the cmdline.c/cmdline.h with newer gengetopt 2014-03-23 10:27:19 +01:00
Holger Hans Peter Freyther 4afb44a25e systemd: Do not restart when the application exits with 1
This is the case of a wrong config or failure to create a tunnel
2014-03-21 18:01:07 +01:00
Holger Hans Peter Freyther 29567ed125 systemd: Add a simple ggsn service file 2014-03-21 18:01:01 +01:00
Pablo Neira Ayuso 1a1ba02292 gtp: fix endianness in teid field of GTPv0 header
This field needs to be in network byte order as well.
2014-03-20 14:11:25 +01:00
Pablo Neira Ayuso 0674f0b56c gtp: fix wrong binary layout for struct gtp0_header in x86_64
struct gtp0_header needs __attribute__((packed)) to make sure that
gcc doesn't add a hole of 4 bytes to align the 64-bits teid, resulting
in 24 bytes instead of 20 bytes. This was breaking gtpv0 in my gprs
testbed with my x86_64 laptop.

While at it, add also attribute packed to other headers just to
make sure that gcc doesn't pad the structures with holes.
2014-03-20 14:11:25 +01:00
Holger Hans Peter Freyther 0382996e10 gtp: Use struct ul16_t/struct ul66_t to avoid compiler warnings in OsmoSGSN
This is fixing various compiler warnings:
In file included from sgsn_libgtp.c:49:0:
include/gtp.h:397:48: warning: ‘struct ul66_t’ declared inside parameter list [enabled by default]
include/gtp.h:397:48: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
include/gtp.h:398:49: warning: ‘struct ul66_t’ declared inside parameter list [enabled by default]
include/gtp.h:399:53: warning: ‘struct ul16_t’ declared inside parameter list [enabled by default]
include/gtp.h:400:53: warning: ‘struct ul16_t’ declared inside parameter list [enabled by default]

include/gtp.h:397:48: warning: ‘struct ul66_t’ declared inside parameter list [enabled by default]
include/gtp.h:397:48: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
include/gtp.h:398:49: warning: ‘struct ul66_t’ declared inside parameter list [enabled by default]
include/gtp.h:399:53: warning: ‘struct ul16_t’ declared inside parameter list [enabled by default]
include/gtp.h:400:53: warning: ‘struct ul16_t’ declared inside parameter list [enabled by default]
2013-07-27 20:02:19 +02:00
Holger Hans Peter Freyther 0527289c2b build: Do not generate a Makefile in the empty src/ directory 2012-11-06 14:32:55 +01:00
Holger Hans Peter Freyther d7566b8280 pdp: Mark the data as static as only pdp.c should access this data 2012-11-06 14:17:45 +01:00
Holger Hans Peter Freyther 0aa17870bc build: Let the system decide where libraries are searched 2012-11-06 14:10:17 +01:00
Holger Hans Peter Freyther e071e30937 build: Remove subdir-objects as it breaks make distclean
We are not using this option in any of our projects and it is breaking
make distclean. Remove the option for now.

make[2]: Entering directory `/openggsn-0.91/_build/ggsn'
Makefile:307: ../lib/.deps/getopt.Po: No such file or directory
Makefile:308: ../lib/.deps/getopt1.Po: No such file or directory
make[2]: *** No rule to make target `../lib/.deps/getopt1.Po'.  Stop.
2012-11-06 13:59:59 +01:00
Tobias Engel 3d7500e686 Remove out-of-bounds write
This removes an out-of-bounds write. The whole statement can simply be
removed since snprintf already adds the trailing 0 byte.
2012-11-05 13:31:25 +01:00
Harald Welte f4594e236b Fix dpkg-buildpackage build for OpenGGSN
Attached is a trivial patch to make
	"dpkg-buildpackage -rfakeroot -uc -us"
work out of the box.

Tested on ubuntu 12.04 x86_64 but should work on any debian-based
distro.
2012-10-27 11:06:17 +02:00
Eric Butler ab9ff093cb Fix init script in debian package. 2012-08-24 21:16:01 -07:00
Eric Butler 235a095d08 Debian package updates.
* Split out a new libgtp-dev package.
* Updated dependencies.
2012-08-14 18:08:41 -07:00
Harald Welte 95848bafce GTP: don't use magic numbers for T3-REQUESTS and N3-REQUEST 2011-11-02 18:17:50 +01:00
Harald Welte ef71162a74 queue: fix copy+paste mistake in debug statements 2011-11-02 18:07:02 +01:00
Harald Welte b841e57f0b queue: Add some more comments throughout the code (doxygen style) 2011-11-02 13:45:50 +01:00
Harald Welte bb47c354b6 queue: mark non-public functions as static
This makes it a bit more explicit about what is the 'user API' of the
code and what is just used internally.
2011-11-02 13:30:37 +01:00
Harald Welte e65c7390ca queue: use %p format string when printing a pointer 2011-11-02 13:12:53 +01:00
Harald Welte bdca4b7886 configure: use AM_SILENT_RULES when available
this makes the compile process a bit easier to read/follow
2011-11-02 13:11:56 +01:00
Harald Welte d88e11d819 GTP: use socklen_t where appropriate
this fixes some compiler warnings
2011-11-02 13:09:43 +01:00
Harald Welte bed35df298 Convert all code to Linux coding style
After so many years of silence, we don't expect the original author to
return to the project.  To make things a bit simpler for us, we convert
the coding style to what we are used to (Linux style).

The conversion was made using the 'Lindent' script which is part of the
Linux kernel.
2011-11-02 13:06:18 +01:00
Sylvain Munaut ca36f29364 build: Add a proper pkgconfig libgtp.pc for the GTP library
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-10-18 13:15:29 +02:00
Harald Welte 3a4c67b4bf optionally do not send recovery with sgsnemu
According to 3GPP TS 29.060 recovery is optional, add command line option --norecovery to remove this field in sgsnemu

Signed-off-by: Yann BONNAMY <yann_bonnamy@yahoo.fr>
Signed-off-by: Harald Welte <laforge@gnumonks.org>
2011-10-07 18:45:54 +02:00
Harald Welte 41af5691ef Add optional RAI Field
Routing Area Information is an optional Field described in 3GPP TS 29.060 7.7.3
it can be added with command line option rai, in the dot separated format MCC.MNC.LAC.RAC
example :  --rai 208.10.65535.255

Signed-off-by: Yann BONNAMY <yann_bonnamy@yahoo.fr>
Signed-off-by: Harald Welte <laforge@gnumonks.org>
2011-10-07 18:42:34 +02:00
Yann BONNAMY 11a398fbc3 sgsnemu support for QoS as defined in 3GPP TS 24.008
this patch allows to tweak any bit of the QoS field of the Create PDP context generated by sgsnemu , aligned with 10.5.6.5 of 3GPP TS 24.008 V10.0.0 (2010-09)

QoS field can be extended to "lenght 12" with option --qose1, as seen in real life on UMTS networks.
extension to lenght 13, 15 and 17 can be done with option --qose2, --qose3, --qose4, never seen IRL but allows to test 3GPP compliance of GGSN.

Signed-off-by: Yann BONNAMY <yann_bonnamy@yahoo.fr>
2011-10-07 18:34:56 +02:00
Yann BONNAMY ad18ccb9df RAI fix
fix ggsn handling of create pdp context when RAI is included and Recovery field is absent

Signed-off-by: Yann BONNAMY <yann_bonnamy@yahoo.fr>
2011-10-07 18:34:02 +02:00
Isabelle Kraemer fe50409675 GTP: Fix bug in update PDP context procedure
I use OpenGGSN to create/update/delete PDP context and I found a bug
in the implementation: when the sgsnemu sends an "update PDP context"
request, it receives back a "create PDP context" response. Below is
the correction I made, I hope it helps.
2011-07-29 16:41:38 +02:00
Harald Welte f5cbbc9558 debian: add openggsn example config files 2011-05-13 21:14:40 +02:00
Harald Welte 142af72b13 debian packaging: add missing openggsn.install file 2011-05-13 21:10:52 +02:00
Harald Welte 38c8f6da35 remove autotools-generated INSTALL file 2011-05-10 17:45:07 +02:00
Harald Welte 6fc42401b9 properly build a library for the content of the lib directory 2011-05-10 17:44:39 +02:00
Harald Welte b502255b8f debian: update to source format git 2011-05-10 17:44:20 +02:00
Harald Welte 629e986ea4 libgtp: introduce cb_recovery() callback
The cb_recovery() callback enables the user application to detect
a change in the restart counter and thus start the appropriate
recovery procedures.
2010-12-24 20:58:09 +01:00
Yann BONNAMY 944dce3e66 Add support for GTP IE's from 3GPP R7
This adds support for the followng new GTP Information Elements:
	RAT_TYPE, USER_LOC, MS_TZ, IMEI_SV

Furthermore, it allows to specify those fields as sgsnemu command line
arguments.
2010-10-29 17:07:44 +02:00
Emmanuel Bretelle 87490d7fa9 IFNAMSIZ includes terminating 0
http://www.delorie.com/gnu/docs/glibc/libc_308.html
thus reverting devname to IFNAMSIZ
and making sure (*tun)->devname[IFNAMSIZ-1] = 0;

Signed-off-by: Emmanuel Bretelle <chantra@debuntu.org>
2010-10-20 11:04:51 +02:00
Emmanuel Bretelle 4e56c83be2 fixed compilation warning against gcc-4.4
* Change arguments of tun_gifindex from:
int tun_gifindex(struct tun_t *this, int *index)
to
int tun_gifindex(struct tun_t *this, __u32 *index)
solves:
../lib/tun.c: In function ‘tun_addaddr’:
../lib/tun.c:265: warning: pointer targets in passing argument 2 of
‘tun_gifindex’ differ in signedness
../lib/tun.c:88: note: expected ‘int *’ but argument is of type ‘__u32
*’

* handle system return code and returns -1 if system failed
solves:
../lib/tun.c: In function ‘tun_runscript’:
../lib/tun.c:895: warning: ignoring return value of ‘system’, declared
with attribute warn_unused_result

* do not dereference a pointer cast and use it as an lvalue
see
http://www.mail-archive.com/svn-commits@lists.digium.com/msg50931.html
solves:
../lib/tun.c: In function ‘tun_route’:
../lib/tun.c:533: warning: dereferencing pointer ‘({anonymous})’ does
break strict-aliasing rules
../lib/tun.c:533: note: initialized from here
../lib/tun.c:534: warning: dereferencing pointer ‘({anonymous})’ does
break strict-aliasing rules
../lib/tun.c:534: note: initialized from here
../lib/tun.c:535: warning: dereferencing pointer ‘({anonymous})’ does
break strict-aliasing rules
../lib/tun.c:535: note: initialized from here
../lib/tun.c: In function ‘tun_setaddr’:
../lib/tun.c:435: warning: dereferencing pointer ‘({anonymous})’ does
break strict-aliasing rules
../lib/tun.c:435: note: initialized from here
../lib/tun.c:452: warning: dereferencing pointer ‘({anonymous})’ does
break strict-aliasing rules
../lib/tun.c:452: note: initialized from here
../lib/tun.c:465: warning: dereferencing pointer ‘({anonymous})’ does
break strict-aliasing rules
../lib/tun.c:465: note: initialized from here

Signed-off-by: Emmanuel Bretelle <chantra@debuntu.org>
2010-10-20 11:04:51 +02:00
Emmanuel Bretelle 91384a4cb0 Do not exceed 80 characters per line
Signed-off-by: Emmanuel Bretelle <chantra@debuntu.org>
2010-10-20 11:04:51 +02:00
Emmanuel Bretelle eaaf50095b Set tun devname to IFNAMESIZ+1 to avoid warning
Relevant output from make:

../lib/tun.c: In function ‘tun_new’:
../lib/tun.c:688: warning: array subscript is above array bounds

Caused by assignement:
(*tun)->devname[IFNAMSIZ] = 0;
while devname defined as:
char devname[IFNAMSIZ];

Signed-off-by: Emmanuel Bretelle <chantra@debuntu.org>
2010-10-20 11:04:51 +02:00
Emmanuel Bretelle 2a103687b6 Move common sgsnemu/ggsn files to directory "lib"
Some files like in sgsnemu and ggsn directory where exactly the same.
They are now moved to the same directory for easier maintenance

Signed-off-by: Emmanuel Bretelle <chantra@debuntu.org>
2010-10-20 11:04:51 +02:00
Emmanuel Bretelle 2a7cad57ef Fixe compilation warning
Relevant output of make:

sgsnemu.c: In function ‘process_options’:
sgsnemu.c:443: warning: pointer targets in passing argument 1 of
‘strncpy’ differ in signedness
/usr/include/bits/string3.h:120: note: expected ‘char * __restrict__’
but argument is of type ‘unsigned char *’

Signed-off-by: Emmanuel Bretelle <chantra@debuntu.org>
2010-10-20 11:04:51 +02:00
Emmanuel Bretelle 68521860e0 Fixed compile warning,exit if cant daemonize
Relevant output of make:

ggsn.c: In function ‘main’:
ggsn.c:436: warning: ignoring return value of ‘freopen’, declared with
attribute warn_unused_result
ggsn.c:437: warning: ignoring return value of ‘freopen’, declared with
attribute warn_unused_result
ggsn.c:438: warning: ignoring return value of ‘freopen’, declared with
attribute warn_unused_result
ggsn.c:439: warning: ignoring return value of ‘daemon’, declared with
attribute warn_unused_result

Signed-off-by: Emmanuel Bretelle <chantra@debuntu.org>
2010-10-20 11:04:51 +02:00
Emmanuel Bretelle 111e054543 Fix warning on unused fscanf return code
Relevant output of make:

gtp.c: In function ‘log_restart’:
gtp.c:697: warning: ignoring return value of ‘fscanf’, declared with
attribute warn_unused_result

Signed-off-by: Emmanuel Bretelle <chantra@debuntu.org>
2010-10-20 11:04:51 +02:00
Harald Welte 1e9b27b70e debian: add init script for OpenGGSN 2010-08-26 13:26:07 +02:00
Harald Welte a3f42e0738 debian: libgtp has architecture 'any' not 'all' 2010-08-25 12:56:25 +02:00
Harald Welte e916809a32 import debian packaging info 2010-08-24 15:23:33 +02:00