aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-05-25 17:35:54 +0200
committerHarald Welte <laforge@gnumonks.org>2018-05-25 18:58:16 +0000
commit584ab8e11fd9a4f3699a2167eb4d0eb8ad914190 (patch)
tree0cff791bb57abbb3e3229790efc063f7704eba91
parent3909d99faeda91befc05c50bf8b3d404bee1e68f (diff)
bsc: Add mgcp_port_to_cic() to determine CIC from RTP Port
Also: Move mgcp_timeslot_to_port() next to it, as they are more or less the inverse transformation of each other. Change-Id: Ica908e2bb8fc4e59e0d146b428c93a9efc385688
-rw-r--r--include/osmocom/bsc/bsc_msc_data.h22
-rw-r--r--src/osmo-bsc/osmo_bsc_bssap.c13
2 files changed, 22 insertions, 13 deletions
diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h
index c69a9ca55..2ace1786b 100644
--- a/include/osmocom/bsc/bsc_msc_data.h
+++ b/include/osmocom/bsc/bsc_msc_data.h
@@ -28,6 +28,7 @@
#define _OSMO_MSC_DATA_H
#include "bsc_msc.h"
+#include "debug.h"
#include <osmocom/core/timer.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
@@ -42,6 +43,7 @@
#include <osmocom/gsm/gsm23003.h>
#include <regex.h>
+#include <errno.h>
struct osmo_bsc_rf;
struct gsm_network;
@@ -164,5 +166,25 @@ int osmo_bsc_audio_init(struct gsm_network *network);
struct bsc_msc_data *osmo_msc_data_find(struct gsm_network *, int);
struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *, int);
+/* Helper function to calculate the port number for a given
+ * timeslot/multiplex. This functionality is needed to support
+ * the sccp-lite scenario where the MGW is handled externally */
+static inline int mgcp_timeslot_to_port(int multiplex, int timeslot, int base)
+{
+ if (timeslot == 0) {
+ LOGP(DLMGCP, LOGL_ERROR, "Timeslot should not be 0\n");
+ timeslot = 255;
+ }
+
+ return base + (timeslot + (32 * multiplex)) * 2;
+}
+
+static inline int mgcp_port_to_cic(uint16_t port, uint16_t base)
+{
+ if (port < base)
+ return -EINVAL;
+ return (port - base) / 2;
+}
+
#endif
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index 24dbc95a6..2adbb3f9b 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -634,19 +634,6 @@ reject:
return -1;
}
-/* Helper function to calculate the port number for a given
- * timeslot/multiplex. This functionality is needed to support
- * the sccp-lite scenario where the MGW is handled externally */
-static inline int mgcp_timeslot_to_port(int multiplex, int timeslot, int base)
-{
- if (timeslot == 0) {
- LOGP(DLMGCP, LOGL_ERROR, "Timeslot should not be 0\n");
- timeslot = 255;
- }
-
- return base + (timeslot + (32 * multiplex)) * 2;
-}
-
/*
* Handle the assignment request message.
*