path: root/gtp
AgeCommit message (Collapse)AuthorFilesLines
2017-10-14gtpie_{encaps,encaps2}(): RAI is a fixe 6-byte length field, not 8 bytesHarald Welte1-2/+6
gtpie_decaps() always had this right, but the encapsulation functions treated it as 8-byte fixed length IE. I hope we had a chance to convert all of this to the normal libosmogsm tlv_parser one day. This would have one description table for all TLV types which then is used from encoder and decoder. Change-Id: I48471f2735511806ac424b5ffc1929e85bb156f3
2017-10-14gtpie.h: Add IE identifier definitions up to 29.60 v11.8.0 Release 11Harald Welte2-9/+275
Change-Id: I6ab7bfb31f93f52f9f6b1b5880dcb2c232bba794
2017-10-14Allow Common flags 0x94 and ignore them in PDP activationHarald Welte2-0/+4
extended from https://github.com/osmocom/openggsn/pull/2 Change-Id: I31b3e4b378e74bb5a0a2f54af6d2a15b629876cf
2017-10-13gtpie: Add missing #include of <arpa/inet.h> for htonl() and friendsHarald Welte1-0/+2
Change-Id: Id69d957d0860ee49e7f0db5c64ab8ba976f8c8d6
2017-10-13gtpie_decaps: const-ify pointer to input packet dataHarald Welte2-4/+4
Change-Id: Ia048abcd80f29581c6ac02cd7f534f2617005671
2017-10-13gtpie: Add doxygen API documentationHarald Welte1-0/+110
libgtp should have proper API documentation, let's start with the gtpie.[ch] parts. Change-Id: I97df5bd3c8dcc5c97a114c8c6abadabf33147b05
2017-10-13gtpie_tlv() gtpie_tv0(): const-ify read-only input argumentHarald Welte2-4/+4
Change-Id: Ide487e34884c8356694246f43c3f1f562357304c
2017-10-01Replace EUA magic numbers for IETF, IPv4 and IPv6 with #definesHarald Welte3-6/+10
Change-Id: I33f65e404217e717bd795e5229c8d9456a7b3739
2017-09-25Move extended PDP logging macro to headerMax1-0/+3
It might be useful for any user of libgtp who uses libosmocore so let's make generalized version of it available as part of installable header. Change-Id: I79aba10ef989384a28f059c30899e65c771ae5e1 Related: SYS#3610
2017-09-24libgtp: Allow each PDP context to specify if it transmits G-PDU sequence numbersHarald Welte3-6/+22
GTP sequence numbers on GTP-U are optional for G-PDU type messages (i.e. user-ip messages). Let's allow the user to specify this behavior by a new pdu_t.tx_gpdu_seq flag. The flag is enabled by default to stay compatible with the prior behaviour. Related: OS#2519 Change-Id: Icf22a2ddd5c4a968ef5bda7c202b921d93fb49e6
2017-09-24gtp: Avoid magic numbers when operating on GTP header flagsHarald Welte2-26/+40
Let's introduce a couple of #defines that make the code much more readable. Change-Id: I3635d679fd54507274b46e99a02bdbbe41d7684e
2017-09-24libgtp: Avoid extra memcpy() in gtp_data_req() by using sendmsg()Harald Welte1-29/+20
Adresses two "TODO Should be avoided" comments about an extra memcpy() before sendto() that can be replaced by a single sendmsg() call with an iovec array: 1 record for the GTP header + 1 record for the user payload. Change-Id: Ie332a6b15972330fcf540753898eb84ecb84fe24
2017-09-06libgtp: Bump major LIBVERSION for recent API/ABI breakageHarald Welte1-1/+1
in Change-Id I68ae49a765828fa681054c68bf7f5e74dbe48ad2 we introduced a new struct member that breks ABI and API. Change-Id: Ie631880155513b1b78d1e9dd473dc5dc50e05943
2017-09-06Rename OpenGGSN to OsmoGGSNHarald Welte8-8/+13
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-05libgtp: Add back-reference to gsn from pdp contextHarald Welte2-1/+11
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-09-05libgtp: Remove ctrl_handle from gsn_t, replace with private contextHarald Welte1-3/+1
The control interface handle never belonged into libgtp in the first place. Commit 727417dd28813c697b4820aef9f54f249e30c4b8 should not have added this to the shared library (used by sgsnemu, osmo-sgsn, ...), but to some private state of the GGSN. Introducing a private context pointer at the same location will keep ABI compatibilty. Change-Id: I4f17516dae3e04114564828a3e5f6e2ea54212a5
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 Welte3-6/+53
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 Welte2-0/+29
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
2017-01-26abi/debian: Bump ABI version of libgtp after struct size changeHolger Hans Peter Freyther1-0/+5
The gsn_t changed the size with the addition of the ctrl pointer. Bump the SO version to not break osmo-sgsn/ggsn on upgrade. Call the -dev package libgtp-dev to follow the rest of Osmocom and to ease making releases here. Change-Id: Iac4d6d2effde1a6b2f60b1e1b49c91513d5ca8c3
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-10-12Add control interfaceMax1-1/+3
Only generation of TRAP messages over Control Interface is supported so far. Note: requires corresponding version of libosmoctrl. Change-Id: Ia76f841d2c9cd14394e9316fcd39f4060e23c898 Related: OS#1646
2016-10-11Remove unused functionMax2-12/+0
Change-Id: Iff0f1499660b12a47277b16a435efecb42fab038
2016-09-15Add 'Bearer Control Mode' IEBJovke2-0/+4
This IE is known to be sent by a Cisco GGSN, and was added in ETSI TS 129 060 V7.17.0 (2011-10) / 3GPP TS 29.060 version 7.17.0 Release 7 See https://lists.osmocom.org/pipermail/osmocom-net-gprs/2016-September/000711.html Subject "sgsnemu failing to create PDP context with Cisco GGSN" Tue Sep 13 08:00:37 UTC 2016 Tweaked-by: Neels Hofmeyr <nhofmeyr@sysmocom.de>
2016-06-06gtp/queue/queue_seqdel(): fix element check which was always trueAlexander Couzens1-2/+1
Fix an apparent typo that prevented queue iteration to find the correct item to be removed. Instead, the first item was always returned. Calling code has been analyzed to find that mostly this fault is not visible, since usually, the first item is indeed the correct item to be returned. See mail thread http://lists.osmocom.org/pipermail/osmocom-net-gprs/2016-June/000618.html Date: Wed Jun 1 11:51:38 UTC 2016 Subject: "[PATCH] gtp/queue/queue_seqdel(): fix element check which always was true"
2016-05-12gtp: fix several compilation warningsPablo Neira Ayuso1-4/+0
CC gtpie.lo gtpie.c: In function 'gtpie_encaps': gtpie.c:437:22: warning: variable 'm' set but not used [-Wunused-but-set-variable] union gtpie_member *m; ^ gtpie.c: In function 'gtpie_encaps2': gtpie.c:537:22: warning: variable 'm' set but not used [-Wunused-but-set-variable] union gtpie_member *m; ^ lookup.c: In function ‘lookup’: lookup.c:40:24: warning: typedef ‘ub1’ locally defined but not used [-Wunused-local-typedefs] typedef unsigned char ub1; /* unsigned 1-byte quantities */ ^ Still one compilation warning left in cmdline.c, but that code is autogenerated.
2016-04-29queue_new(): fix NULL dereference on allocation failureNeels Hofmeyr1-4/+3
Coverity complains about a 'Dereference before null check' on *queue. So, push the NULL check further up. Though I doubt that 'return EOF' is the proper way to handle allocation failure, this patch is only about the NULL dereference. Fixes: CID#57918
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
2016-01-23gtp: Fix a bunch of compiler warnings when just including gtp.hHolger Hans Peter Freyther1-0/+1
Attempt to fix a bunch of compiler warnings in OpenBSC. ‘struct pdp_t’ declared inside parameter list
2015-11-07fix some format specifiersAlexander Huemer2-8/+10
2015-11-02Dump dead code and never look at it againHolger Hans Peter Freyther1-20/+0
This seems to be a wrong search. It seems to assume that there are no buckets. Let's just remove it before looking at it too much.
2015-11-02add todo commentsNeels Hofmeyr1-0/+6
2015-10-27make install: also install gtpie.hNeels Hofmeyr1-1/+1
2015-10-12gtp.c: fix an error log.Neels Hofmeyr1-2/+2
Fix: the code handles fd1u but prints fd1c.
2015-10-12gtp.h: rename gsn_t.dublicate to duplicate.Neels Hofmeyr1-1/+1
Fix spelling dublicate -> duplicate. This is potentially breaking API compat, but currently, no users of gsn_t.dublicate are known.
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 Freyther4-62/+43
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 Freyther2-307/+272
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 Ayuso3-9/+12
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.