changeset 96:f24bbfd23c9d

mgw p2g: outgoing seq numbers, forwarding control
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2022 19:32:27 -0800
parents f280328e7e2e
children 9aed16c30622
files mgw/pstn2gsm.c mgw/struct.h
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mgw/pstn2gsm.c	Sun Sep 25 19:17:44 2022 -0800
+++ b/mgw/pstn2gsm.c	Sun Sep 25 19:32:27 2022 -0800
@@ -106,14 +106,17 @@
 		m_out = 1;
 	ep->p2g_state = 1;
 	ep->p2g_ssrc = pkt.ssrc;
-	ep->p2g_last_ts = htonl(pkt.tstamp);
-	ep->p2g_last_seq = htons(pkt.seq);
+	ep->p2g_last_ts = ntohl(pkt.tstamp);
+	ep->p2g_last_seq = ntohs(pkt.seq);
 	/* actual transcoding and forwarding */
+	if (!(ep->fwd_mode & TMGW_FWD_ENABLE_PSTN2GSM))
+		return;
 	for (n = 0; n < SAMPLES_PER_FRAME; n++)
 		pcm_samples[n] = pcm_dec_table[pkt.payload[n]];
 	pkt.m_pt = ep->gsm_payload_type;
 	if (m_out)
 		pkt.m_pt |= 0x80;
+	pkt.seq = htons(++ep->p2g_out_seq);
 	switch (ep->gsm_payload_msg_type) {
 	case GSM_TCHF_FRAME:
 		gsm_encode(ep->gsm_encoder_state, pcm_samples, pkt.payload);
--- a/mgw/struct.h	Sun Sep 25 19:17:44 2022 -0800
+++ b/mgw/struct.h	Sun Sep 25 19:32:27 2022 -0800
@@ -32,6 +32,7 @@
 	uint32_t	p2g_ssrc;
 	uint32_t	p2g_last_ts;
 	uint16_t	p2g_last_seq;
+	uint16_t	p2g_out_seq;
 	int		p2g_err_flags;
 	/* linked list management */
 	unsigned	ep_id;