9
0
Fork 0
Commit Graph

35 Commits

Author SHA1 Message Date
Harald Welte 2778ae2b8f lib/tun: Mark internal helper functions 'static'
Change-Id: I53a8a89abb0080a39a153e9d3864c17b29aa193c
2017-09-05 23:13:14 +02:00
Harald Welte 1b6e8e7b5e Remove __sun__ code that is unmaintained
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-09-05 23:13:14 +02:00
Harald Welte 9e6dfa0558 lib/tun.c: Proper cleanup during tun_new() error paths
Change-Id: I285be20df76774ac7258b6edb3d4f2d28703757d
2017-09-05 22:42:18 +02:00
Harald Welte 4857f3c2f3 lib/ippool: Move ippool_aton() out of ippool_new()
we rather pass the in46_prefix directly into ippool_new()

Change-Id: Iadf6274e881a9bfc75eb41f9380f5ae2d8c92a0f
2017-09-05 22:42:18 +02:00
Harald Welte b513b951bd lib/ippool: Add back-pointer from pool member to pool
This allows us to remove pool members without having to keep
a pointer to the pool around.

Change-Id: I9042eb85989c5451d7894678eca110dd19e78002
2017-09-05 22:42:17 +02:00
Harald Welte 33520b43ec lib/in46_addr: Avoid ASSERT() when in46a_ntop() is called on uninitialized address
Change-Id: I42d41ec1370b9cc15d372b649d8e1bc78e76af9b
2017-09-05 22:42:17 +02:00
Harald Welte 7fc8694b97 lib/in46_addr: Add 'struct in46_prefix' to represent addr + prefix
Change-Id: I797d105117e81951732bcfc2cc26a8d00fd69443
2017-09-05 22:42:17 +02:00
Harald Welte b62983d3c3 lib/in46_addr: Add in46a_ntoa() function, similar to inet_ntoa()
Change-Id: I752b7033a106a74dc219047da5c3a7ad3cd3602e
2017-09-05 22:42:17 +02:00
Harald Welte 881e97ed00 lib/tun: Add 'void *priv' pointer to tun_t
This allows the application to attach some private state to the tun
device, such as the context from which it was created/allocated

Change-Id: Ief43b9b5fab5830fa8e28362c795f88f0b4d353b
2017-09-05 22:42:17 +02:00
Harald Welte c55ece8d91 lib/tun: Add missing #include to net/if.h for IFNAMSIZ
Change-Id: I979867d643c9fa912884fe55105333dbad39ab97
2017-09-05 22:42:17 +02:00
Harald Welte 81bc2aea53 tun_new(): Fix array overflow in FreeBSD related code
Change-Id: I096e3b614e82e402886163274cfcf9355bd57580
2017-08-11 13:12:09 +02:00
Harald Welte ab6d189f8f replace hand-coded tun_gifindex() with standard POSIX if_nametoindex()
Change-Id: I738472765ab09f530dcf071455e1bb4e6fb3f6e5
2017-08-11 13:12:09 +02:00
Harald Welte 2e48a44952 Support setting TUN device IPv6 address + prefix
As we can now have PDP contexts with IPv6 user IP payload,
it is useful to extend the TUN related code to be able to
configure the tun device IPv6 address + prefix length

Change-Id: I899d21e52d02e0b8384af29ddd489ff19c8f2cf6
2017-08-11 13:12:04 +02:00
Harald Welte 72a38b55e3 IPv6: in46_addr: OSMO_ASSERT() in case of unsupported calls
There's a bit of trickery with the ip_pool and it's "lengty=8" IPv6
prefix handling, let's make sure we don't accidentially call any
support functions with addresses of wrong length.

Change-Id: I444c190bdcd18780344e1f0dad4faf3bcf9da5a5
2017-08-11 10:46:00 +02:00
Harald Welte d46bcd236e IPv6: Implement IPv6 prefix assignment via ICMPv6 router advertisement
The 3GPP specs are quite strange when it comes to how an IPv6 address
or rather prefix is assigned to an IPv6 PDP context.  The designated
method for allocating the IPv6 address via the PDP EUA (End User
Address) Information Element in the GTP signalling plane is *not*
used to allocate the address/prefix.  Instead, the EUA is used to
allocate an "interface identifier" to the MS, which it the uses
to derive its link-local source address to send a router solicitation.

The GGSN subsequently answers witha router advertisement, advertising
a single/64 prefix, whihcthe MS then uses to generate it's real IPv6
source address for subsequent communication.

Change-Id: Icddf7d30e01d76a4784bcef5787b36f52f703a9f
2017-08-11 10:45:56 +02:00
Harald Welte d4d6e09fd2 ippool: Extend pool to work with /64 prefixes
In IPv6 GPRS, we actually don't want to allocate an individual v6
address (like in IPv4), but we want to allocate a prefix.  The
standard prefix lengh is 8 bytes, i.e. a /64 prefix.  This patch
extends the pool to be able to work with such v6 prefixes.

Change-Id: I0cf700b6baf195a2e5fbea000531f801acaaa443
2017-08-09 22:37:57 +02:00
Harald Welte 365f8fa462 in46_addr: Add new function in46a_prefix_equal()
This function is used to compare an IPv6 address against another,
using the smaller of the two prefix lengths.

Change-Id: Ic993d8abdc90897cb55276f01ae3b8a5eadf5a0d
2017-08-09 22:09:34 +02:00
Harald Welte d1bf1e11ba ggsn: Send proper errors in create_context_ind()
When we receive PDP context requests for unknown PDP types or if
we run out of dynamic addresses, we need to inform the SGSN that
PDP context creation failed.

Change-Id: Ibf199c1726130d27c8f80230b30ee51101c93b06
2017-08-09 22:09:34 +02:00
Harald Welte a0d281db1c IPv6 support for user IP
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-09 22:09:34 +02:00
Harald Welte 53165ede24 ippool_new(): const-ify input arguments
Change-Id: If3e53584e8c9c1f06bba4c183c9fd65fae913904
2017-08-09 22:09:34 +02:00
Harald Welte 63ebccdfe3 lib/tun.h: Remove non-endian-safe redefinition of IP header
We can simply use 'struct iphdr' from netinet/ip.h to achieve
the same goal (and be portable).

Change-Id: Ieece22e127dc14a7ffdc3b05656628989ad00b32
2017-08-09 22:09:34 +02:00
Harald Welte d12eab9c4e ippool: Add IPv6 support to IP pool implementation
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-08-09 22:08:57 +02:00
Pablo Neira Ayuso 0eaa5b8e6c gtp: fix several compilation warnings
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-05-12 17:02:34 +02:00
Michael McTernan b07d07072e openggsn: Check return codes and take error paths on failure.
Return early when socket() returns -1, and check return codes
where indicated by some TODOs. This removes 2 TODOs and fixes
a compiler warning about assignment to a variable which then
isn't used.

Signed-off-by: Michael McTernan <mike.mcternan@wavemobile.com>
2015-05-02 07:53:34 +02:00
Holger Hans Peter Freyther 91d0ee5c14 lib: Speculatively add libosmocore cflags to the lib 2014-12-23 19:52:54 +01:00
Holger Hans Peter Freyther 9c7fd8edc4 logging: Switch to using libosmocore logging for all the code 2014-12-04 16:51:15 +01:00
Holger Hans Peter Freyther e527ef105f syserr: Remove unused error packet logging code 2014-12-04 16:49:38 +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
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 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
Harald Welte 6fc42401b9 properly build a library for the content of the lib directory 2011-05-10 17:44:39 +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 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