pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-mgw/+/39213?usp=email )

Change subject: mgw: Split mgcp_rtp_end to its own file
......................................................................

mgw: Split mgcp_rtp_end to its own file

Preparation path to add an init function and start untangling related
code.

While at it, move definition of struct mgcp_rtp_codec to the mgcp_codec.h where 
it belongs.

Change-Id: Id1b6cab57e44ad4859bde8212d0ac9f7146d7198
---
M include/osmocom/mgcp/Makefile.am
M include/osmocom/mgcp/mgcp_codec.h
M include/osmocom/mgcp/mgcp_conn.h
M include/osmocom/mgcp/mgcp_network.h
A include/osmocom/mgcp/mgcp_rtp_end.h
M src/libosmo-mgcp/Makefile.am
M src/libosmo-mgcp/mgcp_network.c
A src/libosmo-mgcp/mgcp_rtp_end.c
8 files changed, 134 insertions(+), 85 deletions(-)

Approvals:
  daniel: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/include/osmocom/mgcp/Makefile.am b/include/osmocom/mgcp/Makefile.am
index 15ff01a..2ab1d0d 100644
--- a/include/osmocom/mgcp/Makefile.am
+++ b/include/osmocom/mgcp/Makefile.am
@@ -1,6 +1,7 @@
 noinst_HEADERS = \
        vty.h \
        mgcp_msg.h \
+       mgcp_codec.h \
        mgcp_conn.h \
        mgcp_stat.h \
        mgcp_endp.h \
@@ -13,4 +14,5 @@
        mgcp_network.h \
        mgcp_protocol.h \
        mgcp_iuup.h \
+       mgcp_rtp_end.h \
        $(NULL)
diff --git a/include/osmocom/mgcp/mgcp_codec.h 
b/include/osmocom/mgcp/mgcp_codec.h
index cfc8ecf..1df8055 100644
--- a/include/osmocom/mgcp/mgcp_codec.h
+++ b/include/osmocom/mgcp/mgcp_codec.h
@@ -1,5 +1,9 @@
 #pragma once

+#include <stdint.h>
+#include <stdbool.h>
+#include <osmocom/mgcp/mgcp_common.h>
+
 #define DEFAULT_RTP_AUDIO_FRAME_DUR_NUM 20
 #define DEFAULT_RTP_AUDIO_FRAME_DUR_DEN 1000
 #define DEFAULT_RTP_AUDIO_PACKET_DURATION_MS 20
@@ -8,6 +12,20 @@

 #define PTYPE_UNDEFINED (-1)

+struct mgcp_rtp_codec {
+       uint32_t rate;
+       int channels;
+       uint32_t frame_duration_num;
+       uint32_t frame_duration_den;
+
+       int payload_type;
+       char audio_name[64];
+       char subtype_name[64];
+
+       bool param_present;
+       struct mgcp_codec_param param;
+};
+
 struct mgcp_conn_rtp;

 void mgcp_codec_summary(struct mgcp_conn_rtp *conn);
diff --git a/include/osmocom/mgcp/mgcp_conn.h b/include/osmocom/mgcp/mgcp_conn.h
index 26cdffc..4325d46 100644
--- a/include/osmocom/mgcp/mgcp_conn.h
+++ b/include/osmocom/mgcp/mgcp_conn.h
@@ -31,6 +31,7 @@
 #include <osmocom/core/rate_ctr.h>
 #include <osmocom/core/utils.h>
 #include <osmocom/gsm/iuup.h>
+#include <osmocom/mgcp/mgcp_rtp_end.h>
 #include <inttypes.h>

 #define LOGPCONN(conn, cat, level, fmt, args...) \
diff --git a/include/osmocom/mgcp/mgcp_network.h 
b/include/osmocom/mgcp/mgcp_network.h
index db3dce7..fe35e78 100644
--- a/include/osmocom/mgcp/mgcp_network.h
+++ b/include/osmocom/mgcp/mgcp_network.h
@@ -74,66 +74,6 @@
        uint32_t alt_rtp_tx_ssrc;
 };

-struct mgcp_rtp_codec {
-       uint32_t rate;
-       int channels;
-       uint32_t frame_duration_num;
-       uint32_t frame_duration_den;
-
-       int payload_type;
-       char audio_name[64];
-       char subtype_name[64];
-
-       bool param_present;
-       struct mgcp_codec_param param;
-};
-
-/* 'mgcp_rtp_end': basically a wrapper around the RTP+RTCP ports */
-struct mgcp_rtp_end {
-       /* remote IP address of the RTP socket */
-       struct osmo_sockaddr addr;
-
-       /* in network byte order */
-       uint16_t rtcp_port;
-
-       /* currently selected audio codec */
-       struct mgcp_rtp_codec *codec;
-
-       /* array with assigned audio codecs to choose from (SDP) */
-       struct mgcp_rtp_codec codecs[MGCP_MAX_CODECS];
-
-       /* number of assigned audio codecs (SDP) */
-       unsigned int codecs_assigned;
-
-       /* per endpoint data */
-       int  frames_per_packet;
-       uint32_t packet_duration_ms;
-       int maximum_packet_time; /* -1: not set */
-       /* are we transmitting packets (true) or dropping (false) outbound 
packets */
-       bool output_enabled;
-       /* FIXME: This parameter can be set + printed, but is nowhere used! */
-       int force_output_ptime;
-
-       /* RTP patching */
-       int force_constant_ssrc; /* -1: always, 0: don't, 1: once */
-       /* should we perform align_rtp_timestamp_offset() (1) or not (0) */
-       int force_aligned_timing;
-       bool rfc5993_hr_convert;
-
-       /* Each end has a separate socket for RTP and RTCP */
-       struct osmo_io_fd *rtp;
-       struct osmo_io_fd *rtcp;
-
-       /* local UDP port number of the RTP socket; RTCP is +1 */
-       int local_port;
-       /* where the endpoint RTP connection binds to, set during CRCX and
-        * possibly updated during MDCX */
-       char local_addr[INET6_ADDRSTRLEN];
-};
-
-bool mgcp_rtp_end_remote_addr_available(const struct mgcp_rtp_end *rtp_end);
-void mgcp_rtp_end_free_port(struct mgcp_rtp_end *end);
-
 struct mgcp_rtp_tap {
        /* is this tap active (1) or not (0) */
        int enabled;
diff --git a/include/osmocom/mgcp/mgcp_rtp_end.h 
b/include/osmocom/mgcp/mgcp_rtp_end.h
new file mode 100644
index 0000000..9c3bb4d
--- /dev/null
+++ b/include/osmocom/mgcp/mgcp_rtp_end.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include <inttypes.h>
+#include <stdbool.h>
+
+#include <osmocom/core/socket.h>
+#include <osmocom/core/osmo_io.h>
+
+#include <osmocom/mgcp/mgcp.h>
+#include <osmocom/mgcp/mgcp_codec.h>
+
+/* 'mgcp_rtp_end': basically a wrapper around the RTP+RTCP ports */
+struct mgcp_rtp_end {
+       /* remote IP address of the RTP socket */
+       struct osmo_sockaddr addr;
+
+       /* in network byte order */
+       uint16_t rtcp_port;
+
+       /* currently selected audio codec */
+       struct mgcp_rtp_codec *codec;
+
+       /* array with assigned audio codecs to choose from (SDP) */
+       struct mgcp_rtp_codec codecs[MGCP_MAX_CODECS];
+
+       /* number of assigned audio codecs (SDP) */
+       unsigned int codecs_assigned;
+
+       /* per endpoint data */
+       int  frames_per_packet;
+       uint32_t packet_duration_ms;
+       int maximum_packet_time; /* -1: not set */
+       /* are we transmitting packets (true) or dropping (false) outbound 
packets */
+       bool output_enabled;
+       /* FIXME: This parameter can be set + printed, but is nowhere used! */
+       int force_output_ptime;
+
+       /* RTP patching */
+       int force_constant_ssrc; /* -1: always, 0: don't, 1: once */
+       /* should we perform align_rtp_timestamp_offset() (1) or not (0) */
+       int force_aligned_timing;
+       bool rfc5993_hr_convert;
+
+       /* Each end has a separate socket for RTP and RTCP */
+       struct osmo_io_fd *rtp;
+       struct osmo_io_fd *rtcp;
+
+       /* local UDP port number of the RTP socket; RTCP is +1 */
+       int local_port;
+       /* where the endpoint RTP connection binds to, set during CRCX and
+        * possibly updated during MDCX */
+       char local_addr[INET6_ADDRSTRLEN];
+};
+
+bool mgcp_rtp_end_remote_addr_available(const struct mgcp_rtp_end *rtp_end);
+void mgcp_rtp_end_free_port(struct mgcp_rtp_end *end);
diff --git a/src/libosmo-mgcp/Makefile.am b/src/libosmo-mgcp/Makefile.am
index fa9a8eb..c5e4bf4 100644
--- a/src/libosmo-mgcp/Makefile.am
+++ b/src/libosmo-mgcp/Makefile.am
@@ -40,6 +40,7 @@
        mgcp_endp.c \
        mgcp_trunk.c \
        mgcp_ratectr.c \
+       mgcp_rtp_end.c \
        mgcp_e1.c \
        mgcp_iuup.c \
        $(NULL)
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 9a993a7..27cca09 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -1719,28 +1719,3 @@

        return bind_rtp(endp->trunk->cfg, conn->end.local_addr, end, endp);
 }
-
-/***********************
- * mgcp_rtp_end
- **********************/
-
-bool mgcp_rtp_end_remote_addr_available(const struct mgcp_rtp_end *rtp_end)
-{
-       return (osmo_sockaddr_port(&rtp_end->addr.u.sa) != 0) &&
-              (osmo_sockaddr_is_any(&rtp_end->addr) == 0);
-}
-
-/*! free allocated RTP and RTCP ports.
- *  \param[in] end RTP end */
-void mgcp_rtp_end_free_port(struct mgcp_rtp_end *end)
-{
-       if (end->rtp) {
-               osmo_iofd_free(end->rtp);
-               end->rtp = NULL;
-       }
-
-       if (end->rtcp) {
-               osmo_iofd_free(end->rtcp);
-               end->rtcp = NULL;
-       }
-}
diff --git a/src/libosmo-mgcp/mgcp_rtp_end.c b/src/libosmo-mgcp/mgcp_rtp_end.c
new file mode 100644
index 0000000..ddc1533
--- /dev/null
+++ b/src/libosmo-mgcp/mgcp_rtp_end.c
@@ -0,0 +1,56 @@
+/* 'mgcp_rtp_end': basically a wrapper around the RTP+RTCP ports */
+/*
+ * (C) 2009-2012 by Holger Hans Peter Freyther <[email protected]>
+ * (C) 2009-2012 by On-Waves
+ * (C) 2013-2024 by sysmocom - s.f.m.c. GmbH
+ * 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/>.
+ *
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <unistd.h>
+
+#include <osmocom/core/select.h>
+#include <osmocom/core/socket.h>
+#include <osmocom/core/osmo_io.h>
+#include <osmocom/mgcp/mgcp_rtp_end.h>
+
+/***********************
+ * mgcp_rtp_end
+ **********************/
+
+bool mgcp_rtp_end_remote_addr_available(const struct mgcp_rtp_end *rtp_end)
+{
+       return (osmo_sockaddr_port(&rtp_end->addr.u.sa) != 0) &&
+              (osmo_sockaddr_is_any(&rtp_end->addr) == 0);
+}
+
+/*! free allocated RTP and RTCP ports.
+ *  \param[in] end RTP end */
+void mgcp_rtp_end_free_port(struct mgcp_rtp_end *end)
+{
+       if (end->rtp) {
+               osmo_iofd_free(end->rtp);
+               end->rtp = NULL;
+       }
+
+       if (end->rtcp) {
+               osmo_iofd_free(end->rtcp);
+               end->rtcp = NULL;
+       }
+}

--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39213?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Id1b6cab57e44ad4859bde8212d0ac9f7146d7198
Gerrit-Change-Number: 39213
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: neels <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to