diff --git a/src/Makefile.am b/src/Makefile.am index eb1e3894..54c6f1b1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,7 +41,7 @@ noinst_LTLIBRARIES = libgprs.la libgprs_la_SOURCES = \ gprs_debug.cpp \ csn1.c \ - gsm_rlcmac.cpp \ + gsm_rlcmac.c \ gprs_bssgp_pcu.cpp \ gprs_rlcmac.cpp \ gprs_rlcmac_sched.cpp \ @@ -106,7 +106,8 @@ noinst_HEADERS = \ gprs_codel.h \ gprs_coding_scheme.h \ coding_scheme.h \ - egprs_rlc_compression.h + egprs_rlc_compression.h \ + wireshark_compat.h osmo_pcu_SOURCES = pcu_main.cpp diff --git a/src/bts.h b/src/bts.h index 823138bb..4fddc0bb 100644 --- a/src/bts.h +++ b/src/bts.h @@ -29,10 +29,10 @@ extern "C" { #include #include #include - #include +#include "mslot_class.h" +#include "gsm_rlcmac.h" } -#include #include "poll_controller.h" #include "sba.h" #include "tbf.h" diff --git a/src/csn1.h b/src/csn1.h index 50cd9ef6..a637d575 100644 --- a/src/csn1.h +++ b/src/csn1.h @@ -29,9 +29,7 @@ #define _PACKET_CSN1_H_ #include - -#define MIN(a,b) (((a)<(b))?(a):(b)) -//#define max(a,b) (((a)>(b))?(a):(b)) +#include "wireshark_compat.h" /* Error codes */ #define CSN_OK 0 @@ -46,17 +44,6 @@ #define CSN_ERROR_MESSAGE_TOO_LONG -9 #define CSN_ERROR_ -10 -#define FALSE (0) -#define TRUE (1) -typedef signed int gint32; -typedef signed short gint16; -typedef int gint; -typedef unsigned int guint; -typedef gint gboolean; -typedef unsigned char guint8; -typedef unsigned short guint16; -typedef unsigned int guint32; -typedef unsigned long guint64; /* CallBack return status */ typedef gint16 CSN_CallBackStatus_t; diff --git a/src/decoding.h b/src/decoding.h index d1371d53..cadb80ce 100644 --- a/src/decoding.h +++ b/src/decoding.h @@ -19,7 +19,10 @@ */ #pragma once -#include +extern "C" { +#include "gsm_rlcmac.h" +} + #include "rlc.h" #include diff --git a/src/encoding.h b/src/encoding.h index 31f74d13..2365f078 100644 --- a/src/encoding.h +++ b/src/encoding.h @@ -21,10 +21,10 @@ #pragma once #include -#include #include extern "C" { #include +#include "gsm_rlcmac.h" } struct gprs_rlcmac_tbf; diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h index 6d871078..789b8dbd 100644 --- a/src/gprs_rlcmac.h +++ b/src/gprs_rlcmac.h @@ -24,7 +24,6 @@ #include #ifdef __cplusplus -#include #include #include @@ -33,6 +32,7 @@ extern "C" { #include #include #include +#include "gsm_rlcmac.h" } #endif diff --git a/src/gsm_rlcmac.cpp b/src/gsm_rlcmac.c similarity index 99% rename from src/gsm_rlcmac.cpp rename to src/gsm_rlcmac.c index 5db8bbd2..5a6634c6 100644 --- a/src/gsm_rlcmac.cpp +++ b/src/gsm_rlcmac.c @@ -29,18 +29,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -extern "C" { #include -} +#include #include "gsm_rlcmac.h" +#include "csn1.h" /* Initialize the protocol and registered fields */ -#include -#include #include #include -using namespace std; /* Payload type as defined in TS 44.060 / 10.4.7 */ #define PAYLOAD_TYPE_DATA 0 diff --git a/src/gsm_rlcmac.h b/src/gsm_rlcmac.h index 1a448e48..48abac09 100644 --- a/src/gsm_rlcmac.h +++ b/src/gsm_rlcmac.h @@ -32,12 +32,8 @@ #ifndef __PACKET_GSM_RLCMAC_H__ #define __PACKET_GSM_RLCMAC_H__ -extern "C" { -#include "csn1.h" -} - -#include -#include +#include +#include "wireshark_compat.h" #ifndef PRE_PACKED #define PRE_PACKED diff --git a/src/pdch.cpp b/src/pdch.cpp index 9b4d89ba..f46acc87 100644 --- a/src/pdch.cpp +++ b/src/pdch.cpp @@ -34,7 +34,6 @@ #include #include #include -#include extern "C" { #include @@ -45,7 +44,9 @@ extern "C" { #include #include #include + #include "coding_scheme.h" +#include "gsm_rlcmac.h" } #include diff --git a/src/pdch.h b/src/pdch.h index 821fb901..97b4b236 100644 --- a/src/pdch.h +++ b/src/pdch.h @@ -24,9 +24,9 @@ #ifdef __cplusplus extern "C" { #include +#include "gsm_rlcmac.h" } -#include #include #include #endif diff --git a/src/tbf.cpp b/src/tbf.cpp index 9cba354a..73d7ea92 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -48,6 +47,8 @@ extern "C" { #include #include #include + +#include "gsm_rlcmac.h" } #include diff --git a/src/wireshark_compat.h b/src/wireshark_compat.h new file mode 100644 index 00000000..13b165a0 --- /dev/null +++ b/src/wireshark_compat.h @@ -0,0 +1,38 @@ +/* wireshark_compat.h + * Copyright (C) 2020 by sysmocom - s.f.m.c. GmbH + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* This header contains a few definitions required by rlcmac and csn1 files + * originally imported from wireshark packet-gsm_rlcmac.* and package-csn1.*, + * in order to keep code as similar as possible to ease maintainability and port + * of patches. +*/ +#pragma once + +#define MIN(a,b) (((a)<(b))?(a):(b)) + +#define FALSE (0) +#define TRUE (1) +typedef signed int gint32; +typedef signed short gint16; +typedef int gint; +typedef unsigned int guint; +typedef gint gboolean; +typedef unsigned char guint8; +typedef unsigned short guint16; +typedef unsigned int guint32; +typedef unsigned long guint64; diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp index a21c22de..0215cc8d 100644 --- a/tests/rlcmac/RLCMACTest.cpp +++ b/tests/rlcmac/RLCMACTest.cpp @@ -24,7 +24,6 @@ #include #include #include -#include "gsm_rlcmac.h" #include "gprs_rlcmac.h" #include "decoding.h" @@ -38,6 +37,7 @@ extern const struct log_info gprs_log_info; #include #include "csn1.h" +#include "gsm_rlcmac.h" } using namespace std; @@ -215,7 +215,9 @@ void testCsnLeftAlignedVarBmpBounds(void *test_ctx) msgb_free(m); } +extern "C" { int encode_gsm_ra_cap(struct bitvec *vector, MS_Radio_Access_capability_t * data); +} void testRAcap(void *test_ctx) {