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/.
dexter gerrit-no-reply at lists.osmocom.orgHello Harald Welte,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/644
to look at the new patch set (#8).
V42BIS integration
The previously committed SPANDSP v42bis implementation has been minimaly
edited to fit our needs
Change-Id: I689413f2541b6def0625ce6bd96f1f488f05f99d
---
M openbsc/include/openbsc/Makefile.am
M openbsc/include/openbsc/debug.h
M openbsc/include/openbsc/v42bis.h
R openbsc/include/openbsc/v42bis_private.h
M openbsc/src/gprs/Makefile.am
M openbsc/src/gprs/v42bis.c
6 files changed, 116 insertions(+), 12 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/44/644/8
diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am
index e159db5..e404b17 100644
--- a/openbsc/include/openbsc/Makefile.am
+++ b/openbsc/include/openbsc/Makefile.am
@@ -19,7 +19,8 @@
gprs_gsup_client.h bsc_msg_filter.h \
oap.h oap_messages.h \
gtphub.h gprs_sndcp.h slhc.h gprs_llc_xid.h gprs_sndcp_xid.h \
- gprs_sndcp_comp_entity.h gprs_sndcp_hdrcomp.h
+ gprs_sndcp_comp_entity.h gprs_sndcp_hdrcomp.h v42bis.h \
+ v42bis_private.h
openbsc_HEADERS = gsm_04_08.h meas_rep.h bsc_api.h
openbscdir = $(includedir)/openbsc
diff --git a/openbsc/include/openbsc/debug.h b/openbsc/include/openbsc/debug.h
index 90ddca5..f98439f 100644
--- a/openbsc/include/openbsc/debug.h
+++ b/openbsc/include/openbsc/debug.h
@@ -28,7 +28,6 @@
DNS,
DBSSGP,
DLLC,
- DSNDCP,
DSLHC,
DNAT,
DCTRL,
@@ -37,6 +36,8 @@
DGTPHUB,
DRANAP,
DSUA,
+ DSNDCP,
+ DV42BIS,
Debug_LastEntry,
};
diff --git a/openbsc/include/openbsc/v42bis.h b/openbsc/include/openbsc/v42bis.h
index f13e5c5..e7592e8 100644
--- a/openbsc/include/openbsc/v42bis.h
+++ b/openbsc/include/openbsc/v42bis.h
@@ -36,6 +36,8 @@
#if !defined(_SPANDSP_V42BIS_H_)
#define _SPANDSP_V42BIS_H_
+#define SPAN_DECLARE(x) x
+
#define V42BIS_MAX_BITS 12
#define V42BIS_MAX_CODEWORDS 4096 /* 2^V42BIS_MAX_BITS */
#define V42BIS_TABLE_SIZE 5021 /* This should be a prime >(2^V42BIS_MAX_BITS) */
diff --git a/openbsc/include/openbsc/private_v42bis.h b/openbsc/include/openbsc/v42bis_private.h
similarity index 100%
rename from openbsc/include/openbsc/private_v42bis.h
rename to openbsc/include/openbsc/v42bis_private.h
diff --git a/openbsc/src/gprs/Makefile.am b/openbsc/src/gprs/Makefile.am
index 3d6c82a..2c03a45 100644
--- a/openbsc/src/gprs/Makefile.am
+++ b/openbsc/src/gprs/Makefile.am
@@ -22,7 +22,7 @@
osmo_sgsn_SOURCES = gprs_gmm.c gprs_sgsn.c gprs_sndcp.c gprs_sndcp_vty.c \
slhc.c gprs_sndcp_xid.c gprs_sndcp_comp_entity.c \
- gprs_sndcp_hdrcomp.c \
+ gprs_sndcp_hdrcomp.c v42bis.c \
sgsn_main.c sgsn_vty.c sgsn_libgtp.c \
gprs_llc.c gprs_llc_parse.c gprs_llc_vty.c \
gprs_llc_xid.c crc24.c \
diff --git a/openbsc/src/gprs/v42bis.c b/openbsc/src/gprs/v42bis.c
index d8d3f3f..fc42be4 100644
--- a/openbsc/src/gprs/v42bis.c
+++ b/openbsc/src/gprs/v42bis.c
@@ -31,9 +31,8 @@
/*! \file */
-#if defined(HAVE_CONFIG_H)
-#include "config.h"
-#endif
+#define FALSE 0
+#define TRUE 1
#include <stdio.h>
#include <stdlib.h>
@@ -44,13 +43,9 @@
#include <ctype.h>
#include <assert.h>
-#include "spandsp/telephony.h"
-#include "spandsp/logging.h"
-#include "spandsp/bit_operations.h"
-#include "spandsp/v42bis.h"
+#include <openbsc/v42bis.h>
+#include <openbsc/v42bis_private.h>
-#include "spandsp/private/logging.h"
-#include "spandsp/private/v42bis.h"
/* Fixed parameters from the spec. */
#define V42BIS_N3 8 /* Character size (bits) */
@@ -74,6 +69,111 @@
V42BIS_RESET = 2 /* Force reinitialisation */
};
+/*! \brief Find the bit position of the highest set bit in a word
+ \param bits The word to be searched
+ \return The bit number of the highest set bit, or -1 if the word is zero. */
+static __inline__ int top_bit(unsigned int bits)
+{
+/*
+ * Note: This function was taken from spandsp/bit_operations.h
+ * without modification
+ */
+
+#if defined(SPANDSP_USE_86_ASM)
+ int res;
+
+ __asm__ (" xorl %[res],%[res];\n"
+ " decl %[res];\n"
+ " bsrl %[bits],%[res]\n"
+ : [res] "=&r" (res)
+ : [bits] "rm" (bits));
+ return res;
+#elif defined(__ppc__) || defined(__powerpc__)
+ int res;
+
+ __asm__ ("cntlzw %[res],%[bits];\n"
+ : [res] "=&r" (res)
+ : [bits] "r" (bits));
+ return 31 - res;
+#elif defined(_M_IX86)
+ /* Visual Studio i386 */
+ __asm
+ {
+ xor eax, eax
+ dec eax
+ bsr eax, bits
+ }
+#elif defined(_M_X64)
+ /* Visual Studio x86_64 */
+ /* TODO: Need the appropriate x86_64 code */
+ int res;
+
+ if (bits == 0)
+ return -1;
+ res = 0;
+ if (bits & 0xFFFF0000)
+ {
+ bits &= 0xFFFF0000;
+ res += 16;
+ }
+ if (bits & 0xFF00FF00)
+ {
+ bits &= 0xFF00FF00;
+ res += 8;
+ }
+ if (bits & 0xF0F0F0F0)
+ {
+ bits &= 0xF0F0F0F0;
+ res += 4;
+ }
+ if (bits & 0xCCCCCCCC)
+ {
+ bits &= 0xCCCCCCCC;
+ res += 2;
+ }
+ if (bits & 0xAAAAAAAA)
+ {
+ bits &= 0xAAAAAAAA;
+ res += 1;
+ }
+ return res;
+#else
+ int res;
+
+ if (bits == 0)
+ return -1;
+ res = 0;
+ if (bits & 0xFFFF0000)
+ {
+ bits &= 0xFFFF0000;
+ res += 16;
+ }
+ if (bits & 0xFF00FF00)
+ {
+ bits &= 0xFF00FF00;
+ res += 8;
+ }
+ if (bits & 0xF0F0F0F0)
+ {
+ bits &= 0xF0F0F0F0;
+ res += 4;
+ }
+ if (bits & 0xCCCCCCCC)
+ {
+ bits &= 0xCCCCCCCC;
+ res += 2;
+ }
+ if (bits & 0xAAAAAAAA)
+ {
+ bits &= 0xAAAAAAAA;
+ res += 1;
+ }
+ return res;
+#endif
+}
+/*- End of function --------------------------------------------------------*/
+
+
static __inline__ void push_compressed_raw_octet(v42bis_compress_state_t *ss, int octet)
{
ss->output_buf[ss->output_octet_count++] = (uint8_t) octet;
--
To view, visit https://gerrit.osmocom.org/644
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I689413f2541b6def0625ce6bd96f1f488f05f99d
Gerrit-PatchSet: 8
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>