path: root/gtp/gtp.c
AgeCommit message (Collapse)AuthorFilesLines
2017-09-05libgtp: Add back-reference to gsn from pdp contextHarald Welte1-1/+7
This is required once one wants to support multiple GSNs in a single application. WARNING: This breaks ABI compatibility, LIBVERSION must be adjusted Change-Id: I68ae49a765828fa681054c68bf7f5e74dbe48ad2
2017-08-22libgtp: expand loggingMax1-10/+7
* print destination address on sendto error * print address length on conversion error * log listening address * log GTP version on PDP context errors * fix incorrect logging message for unknown GSN peer Related: SYS#3610 Change-Id: I0f8ad8687acb7f6f0eeeb962f007e87cca0c4c27
2017-08-13libgtp: Delete PDP context on receiving GTPv1 Error IndicationHarald Welte1-6/+33
When a peer GSN receives a GPDU for an unknown PDP context, it sends a GTP Error Indication. This Error Indication should be used to delete the offending PDP context locally. In GTPv1, the Error Indication contains some mandatory IEs using which we can look up the PDP context and delete it. The existing code only dealt with GTPv0 Error Indications which lack those IEs and use the TEI in the header instead. Change-Id: I3e843f9ef1d6fd7868cc992e083c0891d16b6da9 Closes: OS#2426
2017-08-12libgtp: Add missing mandatory IEs in GTP Error IndicationHarald Welte1-1/+11
Change-Id: Iadd1fe3de7c476576a4409f22f5e84e9eade6b6e
2017-08-12Properly format IMSI before using it in trapHarald Welte1-0/+28
For some reason Max' commits introducing the CTRL/trap interface about one year ago didn't convert the IMSI to its actual textual representation before usign it in the CTRL interface. Let's clean that up by properly interpreting the IMSI. Change-Id: I8b20d2e47a29de266d93a7ddd5e6877f7e346a63
2017-06-09libgtp: improve error logging and propagationMax1-13/+13
* propagate error code from gtp_new() to caller instead of always returning -1 * on socket-related failures log explicitly which kind of socket caused error * log expected GTP version for unexpected packets Change-Id: Ie07f1e4246eb178838b7df21946a08a1f60f2084 related: SYS#3610
2017-02-23gtp.c: Don't print ""Unknown packet flags" error message in get_seq()Harald Welte1-1/+0
get_seq() is called also from contexts where GTP-U is used, and GTP-U doesn't have sequence numbers. Thus, it is perfectly normal if no sequence number and/or no S flag in the header is present. Change-Id: Ie19b95bbb4427e547843a019f5213a231a9f83da
2016-12-15gtp.c: Improve debug statements about GTP header flagsHarald Welte1-8/+8
* as there are muptiple flags in the field, use plural * print the flags as hex value, not decimal. Hex is customary for bitfields. Change-Id: Ib23d80fae32b4e9fa146d82d8f5a1dada1a3cb2b
2016-10-14gsn_restart file: wrap umask change tightly around file creationNeels Hofmeyr1-4/+6
An fopen("w") error used to omit the umask() call to reinstate the previous umask. Also an fopen("r") at the top will never create a file and hence does not need a umask set. Instead, wrap the umask change and change-back tightly around the single fopen("w") call. Change-Id: If7d948e2f2ba47ecebba5614f18235a53b273d14
2016-10-14fix gsn_restart file buffer overflow and missing path sepNeels Hofmeyr1-9/+7
Fix errors during gsn_restart file path composition: - possible buffer overflow because the wrong remaining length was fed to strncat(). - missing path separator: put restart file in dir/gsn_restart instead of ../dirgsn_restart. This assumes that the path separator is '/'. Use talloc_asprintf() to fix all filename length problems and shorten the code. In order to free the allocated path, add a free_filename label, and jump there instead of returning from the fopen("w") failure branch. Also don't return from "fclose failed" branch in order to free the path, remove the if {} braces. Change-Id: Idf0a64ff45720aa818f2f9de1e8ba2fe2c82631b
2016-02-05gtp: Handle gtpv1 in gtp_update_pdp_conf() correctlyDaniel Willmann1-57/+63
libgtp cannot understand its own update pdp request (in gtp v1) Only require the conditional and mandatory fields for gtpv1 and not others. Refer to 3GPP TS 29.060 Ch. 7.3.4
2016-02-04gtp: Make gtp_update_pdp_conf() work for gtp0 and gtp1 connectionsDaniel Willmann1-11/+5
pdp_getgtp1(&pdp, get_tei(pack)) works like pdp_getgtp0 for gtp0 connections. Using get_hlen() for gtpie_decaps is used in other places to decode ies for both version 0 and 1.
2016-02-04gtp: Pass pdp along when calling gtp_req() in gtp_update_context()Daniel Willmann1-1/+1
With no pdp parameter gtp_req() will send the packet to TEID 0 which is not what we want. When trying to modify an established pdp context the correct TEID of that context must be used.
2016-01-23gtp: Do not leak the restart counter file handle in case of errorHolger Hans Peter Freyther1-1/+2
If the file exists but can not be read the file would not be closed. Jump to a label that will close f. Fixes: CID#57917
2015-11-07fix some format specifiersAlexander Huemer1-5/+6
2015-11-02add todo commentsNeels Hofmeyr1-0/+6
2015-10-12gtp.c: fix an error log.Neels Hofmeyr1-2/+2
Fix: the code handles fd1u but prints fd1c.
2015-10-12gtp.c: improve 3 error logs.Neels Hofmeyr1-12/+14
It would print the memory location of the address buffer. Instead, print the human readable host address and port. The current code base supports only IPv4, and thread safety is apparently not required, hence just use inet_ntoa(). (The IPv6 and thread capable version is 4 times longer and harder to read.)
2014-12-04gtp: Make these regions runtime debuggableHolger Hans Peter Freyther1-42/+33
2014-12-04gtp: Kill unused and non public methodHolger Hans Peter Freyther1-33/+0
2014-12-04gtp: Move to using LOGP for logging GTP packagesHolger Hans Peter Freyther1-306/+270
Make libgtp depend on libosmocore and use the generic logging infrastructure for it.
2014-04-04gtp: Speculative FreeBSD compile fix for htobe64Holger Hans Peter Freyther1-0/+4
2014-03-24gtp: add pdp_set_imsi_nsapiPablo Neira Ayuso1-9/+4
Encapsulate code to handle the teid with GTPv0.
2014-03-20gtp: fix endianness in teid field of GTPv0 headerPablo Neira Ayuso1-20/+17
This field needs to be in network byte order as well.
2011-11-02GTP: don't use magic numbers for T3-REQUESTS and N3-REQUESTHarald Welte1-3/+10
2011-11-02GTP: use socklen_t where appropriateHarald Welte1-3/+3
this fixes some compiler warnings
2011-11-02Convert all code to Linux coding styleHarald Welte1-2621/+2804
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-1/+2
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/+6
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-07-29GTP: Fix bug in update PDP context procedureIsabelle Kraemer1-1/+1
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.
2010-12-24libgtp: introduce cb_recovery() callbackHarald Welte1-4/+13
The cb_recovery() callback enables the user application to detect a change in the restart counter and thus start the appropriate recovery procedures.
2010-10-29Add support for GTP IE's from 3GPP R7Yann BONNAMY1-0/+17
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-20Fix warning on unused fscanf return codeEmmanuel Bretelle1-2/+6
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-05-15[libgtp] add comments with references to the GTP specification sectionsHarald Welte1-2/+19
2010-05-04sgsnemu: delete pdp context - teardown must be before NSAPIHarald Welte1-3/+3
in front of Cisco and Alcatel GGSN's, we meet the following error : 5 packets transmitted Disconnecting PDP context #0 openggsn[24940]: gtp.c: 2417: Unexpected cause value received: 193. Packet from, length: 14, content: 32 15 00 06 00 00 00 01 04 02 00 00 01 c1 it is because in the sgsnemu requests packet, the teardown field is after the NSAPI field : No. Time Source Destination Protocol Info 24 10.940094 GTP Delete PDP context request Frame 24 (58 bytes on wire, 58 bytes captured) Ethernet II, Src: HewlettP_55:23:8d (00:11:0a:55:23:8d), Dst: Alcatel-_f6:8e:32 (00:d0:95:f6:8e:32) Internet Protocol, Src: (, Dst: ( User Datagram Protocol, Src Port: gtp-control (2123), Dst Port: gtp-control (2123) GPRS Tunneling Protocol Flags: 0x32 Message Type: Delete PDP context request (0x14) Length: 8 TEID: 0x00000739 Sequence number: 0xbc02 N-PDU Number: 0x00 Next extension header type: No more extension headers (0x00) [--- end of GTP header, beginning of extension headers ---] NSAPI: 0 Teardown Indicator: True [Response In: 25] Taken from http://sourceforge.net/tracker/index.php?func=detail&aid=2865662&group_id=68956&atid=522957
2010-05-04Fix various compiler warnings throughout the codeHarald Welte1-18/+18
Mostly signed/unsigned and typecasting issues Taken from http://sourceforge.net/tracker/index.php?func=detail&aid=1811517&group_id=68956&atid=522957
2004-09-17qos length bugfix and apple support plus header cleanupjjako1-12/+10
2004-05-27Charging characteristics made optionaljjako1-4/+4
2004-02-05Added IP address alias capability for FreeBSDjjako1-7/+9
2004-01-28Added FreeBSD route capabilityjjako1-1/+1
2004-01-26 Fixed long constant warning on FreeBSDjjako1-5/+5
2004-01-19FreeBSD porting and IMSI bugfixjjako1-0/+16
2004-01-09Fix NSAPI bug in create pdp contextjjako1-8/+8
2004-01-09Removed NSAPI from version 0 create pdp context requestjjako1-5/+3
2004-01-09Removed stdint.h includejjako1-1/+1
2004-01-09Rename u_int to uintjjako1-1/+1
2003-11-10Added --net, --nsapi, --gtpversion optionsjjako1-2/+3
2003-10-25Fixed sgsnemu freepdp on failed create context.jjako1-34/+34
2003-10-25Fixed deallocation of pdp context on failed create context.jjako1-1/+27
2003-10-22sgsnemu timelimit bug fix. Readme updatejjako1-1/+2