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.org
Review at https://gerrit.osmocom.org/4237
mgcp: move port/timeslot calculator to separate header
the functions rtp_calculate_port(), mgcp_timeslot_to_endpoint(),
mgcp_endpoint_to_timeslot() may be useful in an application that
uses the mgcp_client as well. Unfortunately it is not possible
to include mgcp.h when mgcp_client.h is already included.
Move the functions to a separate header file that can be included
without issues from both sides.
Change-Id: I8a553e863701d3bafa7b8dc17a503455c303546e
---
M include/Makefile.am
M include/osmocom/mgcp/mgcp.h
A include/osmocom/mgcp/mgcp_calc.h
3 files changed, 70 insertions(+), 39 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/37/4237/1
diff --git a/include/Makefile.am b/include/Makefile.am
index 3cc4b1d..dcf9fb0 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -9,6 +9,7 @@
osmocom/mgcp_client/mgcp_client.h \
osmocom/mgcp_client/mgcp_common.h \
osmocom/mgcp/mgcp.h \
+ osmocom/mgcp/mgcp_calc.h \
osmocom/mgcp/mgcp_internal.h \
osmocom/mgcp/osmux.h \
$(NULL)
diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index 67c499b..6437203 100644
--- a/include/osmocom/mgcp/mgcp.h
+++ b/include/osmocom/mgcp/mgcp.h
@@ -36,29 +36,6 @@
#define RTP_PORT_DEFAULT_RANGE_START 16002
#define RTP_PORT_DEFAULT_RANGE_END RTP_PORT_DEFAULT_RANGE_START + 64
-/**
- * Calculate the RTP audio port for the given multiplex
- * and the direction. This allows a semi static endpoint
- * to port calculation removing the need for the BSC
- * and the MediaGateway to communicate.
- *
- * Port usage explained:
- * base + (multiplex * 2) + 0 == local port to wait for network packets
- * base + (multiplex * 2) + 1 == local port for rtcp
- *
- * The above port will receive packets from the BTS that need
- * to be patched and forwarded to the network.
- * The above port will receive packets from the network that
- * need to be patched and forwarded to the BTS.
- *
- * We assume to have a static BTS IP address so we can differentiate
- * network and BTS.
- *
- */
-static inline int rtp_calculate_port(int multiplex, int base)
-{
- return base + (multiplex * 2);
-}
/*
@@ -250,22 +227,6 @@
*/
struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg);
-/* adc helper */
-static inline int mgcp_timeslot_to_endpoint(int multiplex, int timeslot)
-{
- if (timeslot == 0) {
- LOGP(DLMGCP, LOGL_ERROR, "Timeslot should not be 0\n");
- timeslot = 255;
- }
-
- return timeslot + (32 * multiplex);
-}
-
-static inline void mgcp_endpoint_to_timeslot(int endpoint, int *multiplex, int *timeslot)
-{
- *multiplex = endpoint / 32;
- *timeslot = endpoint % 32;
-}
int mgcp_send_reset_ep(struct mgcp_endpoint *endp, int endpoint);
int mgcp_send_reset_all(struct mgcp_config *cfg);
diff --git a/include/osmocom/mgcp/mgcp_calc.h b/include/osmocom/mgcp/mgcp_calc.h
new file mode 100644
index 0000000..1939176
--- /dev/null
+++ b/include/osmocom/mgcp/mgcp_calc.h
@@ -0,0 +1,69 @@
+/* Helpers to calculate ports and endpoints */
+
+/*
+ * (C) 2009-2012 by Holger Hans Peter Freyther <zecke at selfish.org>
+ * (C) 2009-2012 by On-Waves
+ * All Rights Reserved
+ *
+ * This program 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.
+ *
+ * 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+/**
+ * Calculate the RTP audio port for the given multiplex
+ * and the direction. This allows a semi static endpoint
+ * to port calculation removing the need for the BSC
+ * and the MediaGateway to communicate.
+ *
+ * Port usage explained:
+ * base + (multiplex * 2) + 0 == local port to wait for network packets
+ * base + (multiplex * 2) + 1 == local port for rtcp
+ *
+ * The above port will receive packets from the BTS that need
+ * to be patched and forwarded to the network.
+ * The above port will receive packets from the network that
+ * need to be patched and forwarded to the BTS.
+ *
+ * We assume to have a static BTS IP address so we can differentiate
+ * network and BTS.
+ *
+ */
+static inline int rtp_calculate_port(int multiplex, int base)
+{
+ return base + (multiplex * 2);
+}
+
+/**
+ * Calculate the MGCP endpoint from a given timeslot
+ */
+static inline int mgcp_timeslot_to_endpoint(int multiplex, int timeslot)
+{
+ if (timeslot == 0) {
+ LOGP(DLMGCP, LOGL_ERROR, "Timeslot should not be 0\n");
+ timeslot = 255;
+ }
+
+ return timeslot + (32 * multiplex);
+}
+
+/**
+ * Calculate the timeslot from a given mgcp endpoint
+ */
+static inline void mgcp_endpoint_to_timeslot(int endpoint, int *multiplex, int *timeslot)
+{
+ *multiplex = endpoint / 32;
+ *timeslot = endpoint % 32;
+}
--
To view, visit https://gerrit.osmocom.org/4237
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a553e863701d3bafa7b8dc17a503455c303546e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>