aboutsummaryrefslogtreecommitdiffstats
path: root/sgsnemu/sgsnemu.c
AgeCommit message (Collapse)AuthorFilesLines
2018-04-25Move kernel GTP support from ggsn/ to lib/Harald Welte1-1/+1
This way, the IP address / route handling between TUN devices and kernel GTP can be shared, which will provide not only a unified codebase but also a more consistent behavior. This also paves the road for to use kernel GTP from sgsnemu in the future. Related: OS#3214 Change-Id: Ic53a971136edd0d8871fbd6746d7b0090ce3a188
2018-04-25sgsnemu: Convert from tun_setaddr() to tun_addaddr()Harald Welte1-2/+1
This converts the last caller of tun_setaddr() outside of lib/tun.c to use tun_addaddr(). Change-Id: Ia301d6a4ee3d02c1af1c85f2fe1041d3013268b0
2018-04-25lib/tun.c: generalize tun_*route() to netdev_*route()Harald Welte1-2/+2
There's nothing specific to tun devices in adding a route to the kernel. Change-Id: Ib077934aa5f3c9bed06e2cf16a980c965a7a046d
2018-04-17use osmo_init_logging2Pau Espin Pedrol1-1/+5
Change-Id: Ic38fff17cc985238b91999c8acdd92d22fd28c72
2018-02-12sgsnemu: Fix bad ptr during context deallocationPau Espin Pedrol1-2/+2
Older commit switched pdp_t to have an array of 2 peers instead of only one in order to accomodate for ipv4v6 contexts, which can have 2 addresses assigned. The usage of peer field was not updated in sgsnemu accordingly, which means the wrong memory portion was being accessed. Fixes: 2d6a69e69a4b4cb2b8cc63c4810dae44e5a4d8f6 ("Add support for IPv4v6 End User Addresses") Change-Id: I9e563522173a82b265e93b1ef9dc93ced40fefa2
2018-02-12sgsnemu: fix: no outgoing GTP-U in "createif" modeViktor Tsymbalyuk1-1/+1
in "createif" mode uplink traffic not forwarding from tun interface into Gn, inside GTP-U. create_pdp_conf get iphash (ipm) with pdp == 0x0 Fix - in create_pdp_conf - instead of casting using already definned iphash in ipset function. Change-Id: Icd58450548b3a47cb933d70a2e3166c067552b2c
2018-01-26sgsnemu: sgsnemu stopped after recieving "Request accepted" from ggsnViktor Tsymbalyuk1-1/+1
"sgsnemu" stopped with the message "Received create PDP context response. Cause value: 128", but normaly at that poit it should continue working and create "user plane". Reason: Funtion "create_pdp_conf" checking result of "in46a_from_eua" and mistakenly returned EOF when more than 1 IP address provided by GGSN. Now function "create_pdp_conf" stopped with error when 0 IP provided or error code comes from "in46a_from_eua". Fixes: 2d6a69e69a4b4cb2b8cc63c4810dae44e5a4d8f6 ("Add support for IPv4v6 End User Addresses") Change-Id: I7881b8e1f27c432007cb6e5ff665a2ce55f103b5
2017-12-14Set tun_addaddr ipv agnostic and add support for ipv6Pau Espin Pedrol1-15/+11
sgsnemu (the only user of this API so far) has been modified to use the new API with in46_addr. FreeBSD code for IPv6 has not been tested. Change-Id: Ie36afe6eaf393855a4a708000ef4ad0192bf4767
2017-12-14cosmetic: sgsnemu.c: Fix trailing whitespacePau Espin Pedrol1-6/+6
Change-Id: Ic392ed35946e076a39aa5f7bf80a8c2ffe73562c
2017-12-11Add support for IPv4v6 End User AddressesPau Espin Pedrol1-1/+1
Before this commit, when an MS requested an ipv4v6 context osmo-ggsn returned an error stating the type was unknown, and this text was printed in the log: Processing create PDP context request for APN 'ims' Cannot decode EUA from MS/SGSN: f1 8d This patch has been tested with an MS running the 3 types of addresses: - IPv4 and IPv6: no regressions observed, the context is activated and packets are sent to the ggsn. - IPv4v6: Wireshark correctly parses request and reponse, and then ICMPv6 traffic from both sides. Finally I see the MS using the IPv4 and IPv6 DNS addresses advertised and TCP traffic over IPv4 (because probably my IPv6 network setup is not correct). I also checked I can disable/enable data (pdp ctx delete and activate) several times without any issue. Change-Id: Ic820759167fd3bdf329cb11d4b942e903fe50af5
2017-11-06sgsnemu: Free strings in error pathHarald Welte1-2/+2
In create_pdp_conf(), we have to free() any strings both in the success and in the error case. Change-Id: If59cc8d6d151c123f46c1d029091209fd82b3c8e Fixes: Coverity CID#187636, CID#187633
2017-11-06sgsnemu: Make sure buffer has space for terminating-NULHarald Welte1-1/+1
In proc_ipv6_conf_read() we allocatea buffer on the stack but forgot the terminating NUL byte. Change-Id: I54126d8bc08c137859f2de4b47ef23fc0714fdd7 Fixes: Coverity CID#178641
2017-11-06sgsnemu: Fix format string in printing tun-device nameHarald Welte1-1/+1
Change-Id: Ie05050a78a135a1a76473337a341fd723bbe4976 Fixes: Coverity CID#178654
2017-11-06sgsnemu: Don't leak FILE handle in proc_read()Harald Welte1-1/+0
Change-Id: Ie22e6a9bc172427e867e7a4001b6c710477a232b Fixes: Coverity CID#178660
2017-10-14sgsnemu: Use getprotobynumber() in print_ipprot()Harald Welte1-9/+5
There's no point in sgsnemu doing a poor mans reimplementation of what the C library provides already by means of getprotobynumber() Change-Id: I8cdc460e4fa5d86d80addf6e5f341d2d80093a35
2017-10-14sgsnemu: Remove dead code: encaps_printf()Harald Welte1-13/+0
This function is never used/called, remove it. Change-Id: I37a447e4d5387e3fc5f4433ab20ceba7c446684b
2017-10-14sgsnemu: Mark local functions 'static'Harald Welte1-23/+23
We don't need to export those to the global name space as they're not called from code in other files. Change-Id: I454249335ba46abdb3afbc669c4a06a06f39ae72
2017-10-14sgsnemu: Print warnings on broken IPv6 configuration (acept_ra)Harald Welte1-0/+57
When sgsnemu is used for an IPv6 pdp context, we rely on the router discovery procedure and SLAAC to set the correct IPv6 address/prefix on the tun device. This requires the system to be configure to accept router-advertisements on the tun device. Let's print a warning if accept_ra for the specific tun device is set to a wrong value. We're leaving it up to the user to either set a system-wide /proc/sys/net/ipv6/conf/default/accept_ra or to configure this in an ip-up script used together with sgsnemu. Change-Id: I563092ca35bc74f035a5023e11256779aac46e11
2017-10-14sgsnemu: Add '--tun-device' option to specify TUN device nameHarald Welte1-1/+7
This way, multiple sgsnemu instances can be runnig in parallel, each of them creating a different tun device for their respective PDP context Change-Id: Id12fbadf924a60db255b6d51b9f647aa51dd2e16
2017-10-10sgsnemu: Add IPv6 support via tun device and "-t v6 --createif"Harald Welte1-12/+61
The idea is to only implement the GTP-C plane and configure the right link-local source address on the tun-device and let the regular (Linux) kernel take care of sending router solicitations and accepting/processing the related router advertisement. This avoids a lot of complexity in sgsnemu. For this to work, you must have /proc/sys/net/ipv6/conf/$tun/accept_ra set to either 1 (works only if no IPv6 forwarding/routing configured on your sgsnemu-running system) or 2 (works even if forwarding/routing is configured). Change-Id: I57e4c53ee648e1efecfba3eea592d1129849557c Closes: OS#2518
2017-10-01sgsnemu: Allow specification of PDP (EUA) Type IPv4 or IPv6Harald Welte1-1/+11
This just adds the capability to sgsnemu to request a certain PDP EUA type. It doesn't mean it actually handles anything beyond the existing IPv4 yet. Change-Id: I157f9157a7ff2ea56c37a4a902d4706de4c7d35d
2017-09-24sgsnemu: Add --no-tx-gpdu-seq option to suppress transmission of G-PDU ↵Harald Welte1-0/+10
sequence numbers Related: OS#2519 Change-Id: Idc650d896f0f72329090b56a37d9c16359294860
2017-09-24sgsnemu: Re-generate cmdline.[ch] using gengetoptHarald Welte1-3/+3
This will replace the manual additions to cmdline.[ch] with auto-generated code from gengetopt. We need to fix-up the RAT Type in sgsnemu.c as the manually-added code diverged from what gengetopt generates. Change-Id: Ia687e13d5cec1655a57078a767d2123aa022842c
2017-09-06Rename OpenGGSN to OsmoGGSNHarald Welte1-1/+1
Osmocom has maintained this program since about 7 years now, while the original author / copyright holder has completely disappeared. With the introduction of Osmocom-style CTRL and VTY interfaces, the way how the program is used and configured has substantially changed. In order to avoid confusion in terms of configuration file format etc, let's rename it to OsmoGGSN. Change-Id: I2da30f7d4828e185bfac1a4e2d8414b01cbe4f9d
2017-09-06Introduce a VTY, factually turning OpenGGSN into an Osmocom programHarald Welte1-1/+1
Change-Id: I9613ca3436e77ea132c47f0096df7c5050d7e826
2017-09-05Remove __sun__ code that is unmaintainedHarald Welte1-5/+0
We haven nobody maintaining this platform, let's remove it. In fact, only Linux and FreeBSD are part of the jenkins build tests, so even Apple/MacOS is up for disposal. However, as it's more popular, let's keep the code. Change-Id: Id6b8179259bacade52c39f96e688f828eff164ac
2017-08-09IPv6 support for user IPHarald Welte1-1/+1
This patch enables the use of IPv6 PDP contexts. The phone will have to request an IPv6 End-user-Address, and the GGSN will have to be configured for an IPv6 pool. The outer transport-layer IP between SGSN and GGSN must still be IPv4, it is not modified by this patch Change-Id: I22c3bf32a98e5daf99d6eaeac8c9f95cc7574774
2017-08-09lib/tun.h: Remove non-endian-safe redefinition of IP headerHarald Welte1-2/+3
We can simply use 'struct iphdr' from netinet/ip.h to achieve the same goal (and be portable). Change-Id: Ieece22e127dc14a7ffdc3b05656628989ad00b32
2017-08-09ippool: Add IPv6 support to IP pool implementationHarald Welte1-22/+27
Extend the IP pool implementation to be able to manage both pools of 32bit addresses (IPv4) as well as pools of 128bit addresses (IPv6) Change-Id: Ib98cc4bf634d6be9a7bf8c03a24e629455fcafc8
2017-02-27Code formatted to be in line with formatting rules.bjovan1-13/+32
Change-Id: I546dc0a8d814527b9a96943a52f2f6b700285167
2016-05-24Description: Fix some typos in the man pages and in the binaryRuben Undheim1-4/+4
2015-11-13convert literal APN name to protocol encoded version before useAndreas Schultz1-4/+14
The definition of the APN field format in GTPv1 is hidden in a chain of documents. 3GPP TS 29.060 (the GTPv1-C specification) Section 7.7.30: > The Access Point Name contains a logical name (see 3GPP TS 23.060 [4]). > It is coded as in the value part defined in 3GPP TS 24.008 3GPP TS 24.008 Section 10.5.6.1: > The value part is defined in 3GPP TS 23.003. 3GPP TS 23.003 Section 9.1: > The APN consists of one or more labels. Each label is coded as a one > octet length field followed by that number of octets coded as 8 bit > ASCII characters This converts a literal APN (e.g. Label1.Label2.Label3) to a structured field (e.g. \006Label1\006Label2\006Label3) Signed-off-by: Andreas Schultz <aschultz@tpip.net>
2015-11-02sgsnemu: improve an error messageNeels Hofmeyr1-1/+2
2014-12-04logging: Switch to using libosmocore logging for all the codeHolger Hans Peter Freyther1-26/+19
2011-11-02Convert all code to Linux coding styleHarald Welte1-1468/+1538
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-10-07optionally do not send recovery with sgsnemuHarald Welte1-0/+8
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-07Add optional RAI FieldHarald Welte1-0/+83
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-07sgsnemu support for QoS as defined in 3GPP TS 24.008Yann BONNAMY1-15/+50
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>
2010-10-29Add support for GTP IE's from 3GPP R7Yann BONNAMY1-0/+209
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-20Move common sgsnemu/ggsn files to directory "lib"Emmanuel Bretelle1-3/+3
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-20Fixe compilation warningEmmanuel Bretelle1-1/+1
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-05-04Use newer gengetopt which also frees memoryHarald Welte1-1/+1
Taken from http://sourceforge.net/tracker/index.php?func=detail&aid=1811521&group_id=68956&atid=522957
2010-05-04Fix various compiler warnings throughout the codeHarald Welte1-6/+6
Mostly signed/unsigned and typecasting issues Taken from http://sourceforge.net/tracker/index.php?func=detail&aid=1811517&group_id=68956&atid=522957
2005-03-14Fixed APN bugjjako1-3/+3
2004-09-17qos length bugfix and apple support plus header cleanupjjako1-6/+1
2004-07-20Added selmodejjako1-1/+8
2004-05-27Charging optionjjako1-6/+8
2004-05-27Fix on PPP PCO length and charging characteristics required flag.jjako1-1/+8
2004-04-28Solaris tun interfacejjako1-31/+42
2004-01-26 Fixed long constant warning on FreeBSDjjako1-2/+2