From abef6ce152a768b2f939e70387605410f00840fd Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 18 Jun 2019 15:21:37 +0200 Subject: [PATCH] move own ipv6 header definition into own header file and use it in tft filter --- lib/include/srslte/upper/ipv6.h | 60 ++++++++++++++++++++++ srsue/src/stack/upper/gw.cc | 35 +------------ srsue/src/stack/upper/tft_packet_filter.cc | 2 +- 3 files changed, 62 insertions(+), 35 deletions(-) create mode 100644 lib/include/srslte/upper/ipv6.h diff --git a/lib/include/srslte/upper/ipv6.h b/lib/include/srslte/upper/ipv6.h new file mode 100644 index 000000000..a1b70952c --- /dev/null +++ b/lib/include/srslte/upper/ipv6.h @@ -0,0 +1,60 @@ +/* + * Copyright 2013-2019 Software Radio Systems Limited + * + * This file is part of srsLTE. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#ifndef SRSLTE_IPV6_H +#define SRSLTE_IPV6_H + +#ifdef USE_GLIBC_IPV6 +#include +#else +// Some versions of glibc yield to a compile error with gcc +// complaining about a redefinition of struct in6_pktinfo. See [1]. +// Since we only need two structs from that header we define them here and +// just don't include the entire file. See [1] for more information. +// +// [1] https://patchwork.ozlabs.org/patch/425881/ +#include +struct ipv6hdr { +#if defined(__LITTLE_ENDIAN_BITFIELD) + __u8 priority : 4, version : 4; +#elif defined(__BIG_ENDIAN_BITFIELD) + __u8 version : 4, priority : 4; +#else +#error "Please fix " +#endif + __u8 flow_lbl[3]; + + __be16 payload_len; + __u8 nexthdr; + __u8 hop_limit; + + struct in6_addr saddr; + struct in6_addr daddr; +}; + +struct in6_ifreq { + struct in6_addr ifr6_addr; + __u32 ifr6_prefixlen; + int ifr6_ifindex; +}; +#endif + +#endif // SRSLTE_IPV6_H diff --git a/srsue/src/stack/upper/gw.cc b/srsue/src/stack/upper/gw.cc index 3602cae09..a87c4ae33 100644 --- a/srsue/src/stack/upper/gw.cc +++ b/srsue/src/stack/upper/gw.cc @@ -20,6 +20,7 @@ */ #include "srsue/hdr/stack/upper/gw.h" +#include "srslte/upper/ipv6.h" #include #include @@ -31,40 +32,6 @@ #include #include -#ifdef USE_GLIBC_IPV6 -#include -#else -// Some versions of glibc yield to a compile error with gcc -// complaining about a redefinition of struct in6_pktinfo. See [1]. -// Since we only need two structs from that header we define them here and -// just don't include the entire file. See [1] for more information. -// -// [1] https://patchwork.ozlabs.org/patch/425881/ -struct ipv6hdr { -#if defined(__LITTLE_ENDIAN_BITFIELD) - __u8 priority : 4, version : 4; -#elif defined(__BIG_ENDIAN_BITFIELD) - __u8 version : 4, priority : 4; -#else -#error "Please fix " -#endif - __u8 flow_lbl[3]; - - __be16 payload_len; - __u8 nexthdr; - __u8 hop_limit; - - struct in6_addr saddr; - struct in6_addr daddr; -}; - -struct in6_ifreq { - struct in6_addr ifr6_addr; - __u32 ifr6_prefixlen; - int ifr6_ifindex; -}; -#endif - namespace srsue { gw::gw() : if_up(false), default_lcid(0), thread("GW") diff --git a/srsue/src/stack/upper/tft_packet_filter.cc b/srsue/src/stack/upper/tft_packet_filter.cc index 1fdb50df8..488e68232 100644 --- a/srsue/src/stack/upper/tft_packet_filter.cc +++ b/srsue/src/stack/upper/tft_packet_filter.cc @@ -20,8 +20,8 @@ */ #include "srsue/hdr/stack/upper/tft_packet_filter.h" +#include "srslte/upper/ipv6.h" #include -#include #include namespace srsue {