changeset 15:96b37cef5020

rtp-gsmfr-dump: convert from old libgsm to libgsmfr2
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 19 Sep 2024 01:59:14 +0000
parents e7f43262efa1
children 1bc144545563
files pcap-study/Makefile pcap-study/rtp-gsmfr-dump.c
diffstat 2 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/pcap-study/Makefile	Sun Jul 28 01:53:41 2024 +0000
+++ b/pcap-study/Makefile	Thu Sep 19 01:59:14 2024 +0000
@@ -12,7 +12,7 @@
 	${CC} ${CFLAGS} -o $@ $@.c -lpcap
 
 rtp-gsmfr-dump:	rtp-gsmfr-dump.c
-	${CC} ${CFLAGS} -o $@ $@.c -lpcap -lgsmefr -lgsm
+	${CC} ${CFLAGS} -o $@ $@.c -lpcap -lgsmefr -lgsmfr2
 
 rtp-gsmfr-extr:	rtp-gsmfr-extr.c
 	${CC} ${CFLAGS} -o $@ $@.c -lpcap
--- a/pcap-study/rtp-gsmfr-dump.c	Sun Jul 28 01:53:41 2024 +0000
+++ b/pcap-study/rtp-gsmfr-dump.c	Thu Sep 19 01:59:14 2024 +0000
@@ -16,11 +16,12 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
 #include <pcap/pcap.h>
-#include <gsm.h>
+#include <tw_gsmfr.h>
 #include <gsm_efr.h>
 
 static pcap_t *pcap;
@@ -30,7 +31,6 @@
 static unsigned link_hdr_len, ethertype_offset;
 static int stream_init_flag;
 static unsigned last_seq, last_tstamp, stream_ssrc;
-static gsm dummy_state;
 
 static void
 check_dl_type()
@@ -96,7 +96,7 @@
 	u_char *payload;
 	unsigned payload_len;
 {
-	gsm_signal params[76];
+	int16_t params[76];
 	int i, j, n;
 
 	printf("seq 0x%04X ts 0x%08X: ", last_seq, last_tstamp);
@@ -144,7 +144,7 @@
 		if ((payload[0] & 0xF0) != 0xD0)
 			break;
 		fputs("std FR", stdout);
-		gsm_explode(dummy_state, payload, params);
+		gsmfr_unpack_to_array(payload, params);
 	print_fr:
 		n = 0;
 		for (i = 0; i < 8; i++)
@@ -163,7 +163,7 @@
 		if ((payload[1] & 0xF0) != 0xD0)
 			break;
 		printf("TEH 0x%02X FR", payload[0]);
-		gsm_explode(dummy_state, payload+1, params);
+		gsmfr_unpack_to_array(payload+1, params);
 		goto print_fr;
 	}
 	printf("unknown payload format, length=%u\n", payload_len);
@@ -257,11 +257,6 @@
 		exit(1);
 	}
 	match_udp_port = htons(strtoul(argv[4], 0, 0));
-	dummy_state = gsm_create();
-	if (!dummy_state) {
-		fprintf(stderr, "gsm_create() failed!\n");
-		exit(1);
-	}
 	for (pkt_idx = 0; ; pkt_idx++) {
 		pkt = pcap_next(pcap, &pkthdr);
 		if (!pkt)