[PATCH 2/9] mgcp/rtp: Add flag to disable RTP output

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/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Tue Jan 7 11:07:44 UTC 2014


This patch make it possible to have a valid endpoint that drops all
outgoing RTP packets. The number of dropped packets is shown by the
VTY 'show mgcp' command. By default, this feature is disabled. To
enable packet dropping, the corresponding output_enabled field must
be set to 0.

Ticket: OW#1044
Sponsored-by: On-Waves ehf
---
 openbsc/include/openbsc/mgcp_internal.h |    2 ++
 openbsc/src/libmgcp/mgcp_network.c      |    4 +++-
 openbsc/src/libmgcp/mgcp_protocol.c     |    2 ++
 openbsc/src/libmgcp/mgcp_vty.c          |    8 +++++++-
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h
index a9ae33c..b4899e4 100644
--- a/openbsc/include/openbsc/mgcp_internal.h
+++ b/openbsc/include/openbsc/mgcp_internal.h
@@ -71,6 +71,7 @@ struct mgcp_rtp_end {
 	/* statistics */
 	unsigned int packets;
 	unsigned int octets;
+	unsigned int dropped_packets;
 	struct in_addr addr;
 
 	/* in network byte order */
@@ -84,6 +85,7 @@ struct mgcp_rtp_end {
 	int  frames_per_packet;
 	uint32_t packet_duration_ms;
 	char *fmtp_extra;
+	int output_enabled;
 
 	/* RTP patching */
 	int force_constant_ssrc; /* -1: always, 0: don't, 1: once */
diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c
index 1c7c3da..21d52b5 100644
--- a/openbsc/src/libmgcp/mgcp_network.c
+++ b/openbsc/src/libmgcp/mgcp_network.c
@@ -559,7 +559,9 @@ static int mgcp_send(struct mgcp_endpoint *endp, int dest, int is_rtp,
 		tap_idx = MGCP_TAP_BTS_OUT;
 	}
 
-	if (is_rtp) {
+	if (!rtp_end->output_enabled)
+		rtp_end->dropped_packets += 1;
+	else if (is_rtp) {
 		mgcp_patch_and_count(endp, rtp_state, rtp_end, addr, buf, rc);
 		forward_data(rtp_end->rtp.fd, &endp->taps[tap_idx], buf, rc);
 		return mgcp_udp_send(rtp_end->rtp.fd,
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index ddec44d..95f3910 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -1178,6 +1178,7 @@ static void mgcp_rtp_end_reset(struct mgcp_rtp_end *end)
 
 	end->packets = 0;
 	end->octets = 0;
+	end->dropped_packets = 0;
 	memset(&end->addr, 0, sizeof(end->addr));
 	end->rtp_port = end->rtcp_port = 0;
 	end->payload_type = -1;
@@ -1191,6 +1192,7 @@ static void mgcp_rtp_end_reset(struct mgcp_rtp_end *end)
 	end->frames_per_packet  = 0; /* unknown */
 	end->packet_duration_ms = DEFAULT_RTP_AUDIO_PACKET_DURATION_MS;
 	end->rate               = DEFAULT_RTP_AUDIO_DEFAULT_RATE;
+	end->output_enabled	= 1;
 }
 
 static void mgcp_rtp_end_init(struct mgcp_rtp_end *end)
diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c
index 8411b4a..3f1ebeb 100644
--- a/openbsc/src/libmgcp/mgcp_vty.c
+++ b/openbsc/src/libmgcp/mgcp_vty.c
@@ -150,7 +150,7 @@ static void dump_trunk(struct vty *vty, struct mgcp_trunk_config *cfg, int verbo
 			endp->trans_net.packets, endp->trans_bts.packets,
 			VTY_NEWLINE);
 
-		if (verbose)
+		if (verbose) {
 			vty_out(vty,
 				"  Timestamp Errs: BTS %d->%d, Net %d->%d%s",
 				endp->bts_state.in_stream.err_ts_counter,
@@ -158,6 +158,12 @@ static void dump_trunk(struct vty *vty, struct mgcp_trunk_config *cfg, int verbo
 				endp->net_state.in_stream.err_ts_counter,
 				endp->net_state.out_stream.err_ts_counter,
 				VTY_NEWLINE);
+			vty_out(vty,
+				"  Dropped Packets: Net->BTS %d, BTS->Net %d%s",
+				endp->bts_end.dropped_packets,
+				endp->net_end.dropped_packets,
+				VTY_NEWLINE);
+		}
 	}
 }
 
-- 
1.7.9.5





More information about the OpenBSC mailing list