Change in osmo-pcu[master]: Move gsm_rlcmac.cpp -> .c

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Thu Mar 26 15:16:45 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/17627 )


Change subject: Move gsm_rlcmac.cpp -> .c
......................................................................

Move gsm_rlcmac.cpp -> .c

Original file from wireshark.git (packet-gsm_csn1.c) is being built and
maintained as a C file. There's no real need for us to maintain it as a
C++, and doing so will make both files derive over time (as already
happened). Let's keep it as a C compiler (which btw seems to be more
strict) to make it easier to port patches back and forth wireshark.git.

Take the chance to move some declarations we added to csn1.h to be able
to build it out of wireshark. Let's keep those in a separate header file
to ease looking for differences.

Change-Id: I818a8ae947f002d35142f9f5473454cfd80e1830
---
M src/Makefile.am
M src/bts.h
M src/csn1.h
M src/decoding.h
M src/encoding.h
M src/gprs_rlcmac.h
R src/gsm_rlcmac.c
M src/gsm_rlcmac.h
M src/pdch.cpp
M src/pdch.h
M src/tbf.cpp
A src/wireshark_compat.h
M tests/rlcmac/RLCMACTest.cpp
13 files changed, 62 insertions(+), 37 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/27/17627/1

diff --git a/src/Makefile.am b/src/Makefile.am
index eb1e389..54c6f1b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,7 +41,7 @@
 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 @@
 	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 823138b..4fddc0b 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -29,10 +29,10 @@
 #include <osmocom/core/tdef.h>
 #include <osmocom/gsm/l1sap.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
-	#include <mslot_class.h>
+#include "mslot_class.h"
+#include "gsm_rlcmac.h"
 }
 
-#include <gsm_rlcmac.h>
 #include "poll_controller.h"
 #include "sba.h"
 #include "tbf.h"
diff --git a/src/csn1.h b/src/csn1.h
index 50cd9ef..a637d57 100644
--- a/src/csn1.h
+++ b/src/csn1.h
@@ -29,9 +29,7 @@
 #define _PACKET_CSN1_H_
 
 #include <osmocom/core/bitvec.h>
-
-#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 d1371d5..4df2080 100644
--- a/src/decoding.h
+++ b/src/decoding.h
@@ -18,8 +18,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 #pragma once
-
-#include <gsm_rlcmac.h>
+extern "C" {
+#include "gsm_rlcmac.h"
+}
 #include "rlc.h"
 
 #include <stdint.h>
diff --git a/src/encoding.h b/src/encoding.h
index 31f74d1..2365f07 100644
--- a/src/encoding.h
+++ b/src/encoding.h
@@ -21,10 +21,10 @@
 #pragma once
 
 #include <stdint.h>
-#include <gsm_rlcmac.h>
 #include <gprs_coding_scheme.h>
 extern "C" {
 #include <osmocom/gsm/l1sap.h>
+#include "gsm_rlcmac.h"
 }
 
 struct gprs_rlcmac_tbf;
diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 6d87107..789b8db 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -24,7 +24,6 @@
 #include <stdbool.h>
 
 #ifdef __cplusplus
-#include <gsm_rlcmac.h>
 #include <gsm_timer.h>
 #include <pcu_l1_if.h>
 
@@ -33,6 +32,7 @@
 #include <osmocom/core/timer.h>
 #include <osmocom/core/bitvec.h>
 #include <osmocom/pcu/pcuif_proto.h>
+#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 5db8bbd..5a6634c 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 <osmocom/core/utils.h>
-}
+#include <osmocom/core/bitvec.h>
 
 #include "gsm_rlcmac.h"
+#include "csn1.h"
 /* Initialize the protocol and registered fields
 */
-#include <iostream>
-#include <cstdlib>
 #include <assert.h>
 #include <gprs_debug.h>
-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 1a448e4..48abac0 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 <iostream>
-#include <cstdlib>
+#include <osmocom/core/bitvec.h>
+#include "wireshark_compat.h"
 
 #ifndef PRE_PACKED
 #define PRE_PACKED
diff --git a/src/pdch.cpp b/src/pdch.cpp
index 1505068..92f5728 100644
--- a/src/pdch.cpp
+++ b/src/pdch.cpp
@@ -34,7 +34,6 @@
 #include <tbf.h>
 #include <tbf_ul.h>
 #include <cxx_linuxlist.h>
-#include <gsm_rlcmac.h>
 
 extern "C" {
 #include <osmocom/core/talloc.h>
@@ -44,7 +43,9 @@
 #include <osmocom/core/gsmtap.h>
 #include <osmocom/core/logging.h>
 #include <osmocom/core/utils.h>
+
 #include "coding_scheme.h"
+#include "gsm_rlcmac.h"
 }
 
 #include <errno.h>
diff --git a/src/pdch.h b/src/pdch.h
index 821fb90..97b4b23 100644
--- a/src/pdch.h
+++ b/src/pdch.h
@@ -24,9 +24,9 @@
 #ifdef __cplusplus
 extern "C" {
 #include <osmocom/core/linuxlist.h>
+#include "gsm_rlcmac.h"
 }
 
-#include <gsm_rlcmac.h>
 #include <gprs_coding_scheme.h>
 #include <bts.h>
 #endif
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 9cba354..73d7ea9 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -32,7 +32,6 @@
 #include <gprs_ms.h>
 #include <pcu_utils.h>
 #include <gprs_ms_storage.h>
-#include <gsm_rlcmac.h>
 #include <sba.h>
 #include <gprs_coding_scheme.h>
 #include <gsm_timer.h>
@@ -48,6 +47,8 @@
 #include <osmocom/core/bitvec.h>
 #include <osmocom/core/rate_ctr.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
+
+#include "gsm_rlcmac.h"
 }
 
 #include <errno.h>
diff --git a/src/wireshark_compat.h b/src/wireshark_compat.h
new file mode 100644
index 0000000..0b7db05
--- /dev/null
+++ b/src/wireshark_compat.h
@@ -0,0 +1,39 @@
+/* wireshark_compat.h
+ * Copyright (C) 2020 by sysmocom - s.f.m.c. GmbH <info at sysmocom.de>
+ *
+ * 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 max(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 a21c22d..0215cc8 100644
--- a/tests/rlcmac/RLCMACTest.cpp
+++ b/tests/rlcmac/RLCMACTest.cpp
@@ -24,7 +24,6 @@
 #include <cstdlib>
 #include <cstring>
 #include <assert.h>
-#include "gsm_rlcmac.h"
 #include "gprs_rlcmac.h"
 #include "decoding.h"
 
@@ -38,6 +37,7 @@
 #include <osmocom/core/application.h>
 
 #include "csn1.h"
+#include "gsm_rlcmac.h"
 }
 using namespace std;
 
@@ -215,7 +215,9 @@
 	msgb_free(m);
 }
 
+extern "C" {
 int encode_gsm_ra_cap(struct bitvec *vector, MS_Radio_Access_capability_t * data);
+}
 
 void testRAcap(void *test_ctx)
 {

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/17627
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I818a8ae947f002d35142f9f5473454cfd80e1830
Gerrit-Change-Number: 17627
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200326/531c4c7e/attachment.htm>


More information about the gerrit-log mailing list