[MERGED] osmo-mgw[master]: mgcp_rtp_end: Group statistics members into 'stats' sub-struct

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Dec 25 09:20:14 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: mgcp_rtp_end: Group statistics members into 'stats' sub-struct
......................................................................


mgcp_rtp_end: Group statistics members into 'stats' sub-struct

Change-Id: I4e0ecdcd9a75fe08abc55b730780c01617f3d4af
---
M include/osmocom/mgcp/mgcp_internal.h
M src/libosmo-mgcp/mgcp_conn.c
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_osmux.c
M src/libosmo-mgcp/mgcp_stat.c
M src/libosmo-mgcp/mgcp_vty.c
M tests/mgcp/mgcp_test.c
7 files changed, 26 insertions(+), 28 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/mgcp/mgcp_internal.h b/include/osmocom/mgcp/mgcp_internal.h
index 9e7246e..11bafe7 100644
--- a/include/osmocom/mgcp/mgcp_internal.h
+++ b/include/osmocom/mgcp/mgcp_internal.h
@@ -97,11 +97,14 @@
 
 struct mgcp_rtp_end {
 	/* statistics */
-	unsigned int packets_rx;
-	unsigned int octets_rx;
-	unsigned int packets_tx;
-	unsigned int octets_tx;
-	unsigned int dropped_packets;
+	struct {
+		unsigned int packets_rx;
+		unsigned int octets_rx;
+		unsigned int packets_tx;
+		unsigned int octets_tx;
+		unsigned int dropped_packets;
+	} stats;
+
 	struct in_addr addr;
 
 	/* in network byte order */
diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index 4090a9f..9063bec 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -93,12 +93,7 @@
 
 	end->rtp.fd = -1;
 	end->rtcp.fd = -1;
-	end->local_port = 0;
-	end->packets_rx = 0;
-	end->octets_rx = 0;
-	end->packets_tx = 0;
-	end->octets_tx = 0;
-	end->dropped_packets = 0;
+	memset(&end->stats, 0, sizeof(end->stats));
 	end->rtp_port = end->rtcp_port = 0;
 	talloc_free(end->fmtp_extra);
 	end->fmtp_extra = NULL;
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 2056a8e..dc5628a 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -693,7 +693,7 @@
 	dest_name = conn_dst->conn->name;
 
 	if (!rtp_end->output_enabled) {
-		rtp_end->dropped_packets += 1;
+		rtp_end->stats.dropped_packets += 1;
 		LOGP(DRTP, LOGL_DEBUG,
 		     "endpoint:0x%x output disabled, drop to %s %s "
 		     "rtp_port:%u rtcp_port:%u\n",
@@ -748,8 +748,8 @@
 			if (len <= 0)
 				return len;
 
-			conn_dst->end.packets_tx += 1;
-			conn_dst->end.octets_tx += len;
+			conn_dst->end.stats.packets_tx += 1;
+			conn_dst->end.stats.octets_tx += len;
 
 			nbytes += len;
 			buflen = cont;
@@ -768,8 +768,8 @@
 				    &rtp_end->addr,
 				    rtp_end->rtcp_port, buf, len);
 
-		conn_dst->end.packets_tx += 1;
-		conn_dst->end.octets_tx += len;
+		conn_dst->end.stats.packets_tx += 1;
+		conn_dst->end.stats.octets_tx += len;
 
 		return len;
 	}
@@ -929,8 +929,8 @@
 	}
 
 	/* Increment RX statistics */
-	conn->end.packets_rx += 1;
-	conn->end.octets_rx += rc;
+	conn->end.stats.packets_rx += 1;
+	conn->end.stats.octets_rx += rc;
 
 	/* Forward a copy of the RTP data to a debug ip/port */
 	forward_data(fd->fd, &conn->tap_in, buf, rc);
diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index 5030812..6e19611 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -255,8 +255,8 @@
 		.sin_port = conn_net->end.rtp_port,
 	};
 
-	conn_bts->end.octets_tx += msg->len;
-	conn_bts->end.packets_tx++;
+	conn_bts->end.stats.octets_tx += msg->len;
+	conn_bts->end.stats.packets_tx++;
 
 	/* Send RTP data to NET */
 	/* FIXME: Get rid of conn_bts and conn_net! */
@@ -282,8 +282,8 @@
 		.sin_port = conn_bts->end.rtp_port,
 	};
 
-	conn_net->end.octets_tx += msg->len;
-	conn_net->end.packets_tx++;
+	conn_net->end.stats.octets_tx += msg->len;
+	conn_net->end.stats.packets_tx++;
 
 	/* Send RTP data to BTS */
 	/* FIXME: Get rid of conn_bts and conn_net! */
diff --git a/src/libosmo-mgcp/mgcp_stat.c b/src/libosmo-mgcp/mgcp_stat.c
index 54c4b66..88a2d69 100644
--- a/src/libosmo-mgcp/mgcp_stat.c
+++ b/src/libosmo-mgcp/mgcp_stat.c
@@ -43,8 +43,8 @@
 	 * Make sure the sign is correct and use the biggest
 	 * positive/negative number that fits.
 	 */
-	*loss = *expected - end->packets_rx;
-	if (*expected < end->packets_rx) {
+	*loss = *expected - end->stats.packets_rx;
+	if (*expected < end->stats.packets_rx) {
 		if (*loss > 0)
 			*loss = INT_MIN;
 	} else {
@@ -74,8 +74,8 @@
 
 	nchars = snprintf(str, str_len,
 			  "\r\nP: PS=%u, OS=%u, PR=%u, OR=%u, PL=%d, JI=%u",
-			  conn->end.packets_tx, conn->end.octets_tx,
-			  conn->end.packets_rx, conn->end.octets_rx,
+			  conn->end.stats.packets_tx, conn->end.stats.octets_tx,
+			  conn->end.stats.packets_rx, conn->end.stats.octets_rx,
 			  ploss, jitter);
 	if (nchars < 0 || nchars >= str_len)
 		goto truncate;
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index e938391..7fa3949 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -167,7 +167,7 @@
 		"   Output-Enabled: %d Force-PTIME: %d%s",
 		state->in_stream.err_ts_counter,
 		state->out_stream.err_ts_counter, VTY_NEWLINE,
-		end->dropped_packets, VTY_NEWLINE,
+		end->stats.dropped_packets, VTY_NEWLINE,
 		codec->payload_type, codec->rate, codec->channels, VTY_NEWLINE,
 		codec->frame_duration_num, codec->frame_duration_den,
 		VTY_NEWLINE, end->frames_per_packet, end->packet_duration_ms,
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index 6f8e4ca..46fc1c1 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -921,7 +921,7 @@
 		state.stats.max_seq = pl_test_dat[i].max_seq;
 		state.stats.cycles = pl_test_dat[i].cycles;
 
-		rtp.packets_rx = pl_test_dat[i].packets;
+		rtp.stats.packets_rx = pl_test_dat[i].packets;
 		calc_loss(&state, &rtp, &expected, &loss);
 
 		if (loss != pl_test_dat[i].loss

-- 
To view, visit https://gerrit.osmocom.org/5583
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4e0ecdcd9a75fe08abc55b730780c01617f3d4af
Gerrit-PatchSet: 2
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list