osmux: send osmux stats in MGCP DLCX responses

This allows us to know what number of messages and bytes has been
received per active osmux endpoint.

Note that an Osmux message is composed of several chunks. Each chunk
contains an osmux header plus several voice data frames.

 P: PS=385, OS=11188, PR=195, OR=5655, PL=0, JI=49
 X-Osmo-CP: EC TIS=0, TOS=0, TIR=0, TOR=0
 X-Osmux-ST: CR=51, BR=3129

The new 'X-Osmux-ST:' notifies the received chunks and bytes.
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index a728b67..79422fe 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -1745,12 +1745,24 @@
 	size -= nchars;
 
 	/* Error Counter */
-	snprintf(msg, size,
-		 "\r\nX-Osmo-CP: EC TIS=%u, TOS=%u, TIR=%u, TOR=%u",
-		 endp->net_state.in_stream.err_ts_counter,
-		 endp->net_state.out_stream.err_ts_counter,
-		 endp->bts_state.in_stream.err_ts_counter,
-		 endp->bts_state.out_stream.err_ts_counter);
+	nchars = snprintf(msg, size,
+			  "\r\nX-Osmo-CP: EC TIS=%u, TOS=%u, TIR=%u, TOR=%u",
+			  endp->net_state.in_stream.err_ts_counter,
+			  endp->net_state.out_stream.err_ts_counter,
+			  endp->bts_state.in_stream.err_ts_counter,
+			  endp->bts_state.out_stream.err_ts_counter);
+	if (nchars < 0 || nchars >= size)
+		goto truncate;
+
+	msg += nchars;
+	size -= nchars;
+
+	if (endp->osmux.state == OSMUX_STATE_ENABLED) {
+		snprintf(msg, size,
+			 "\r\nX-Osmux-ST: CR=%u, BR=%u",
+			 endp->osmux.stats.chunks,
+			 endp->osmux.stats.octets);
+	}
 truncate:
 	msg[size - 1] = '\0';
 }