changeset 14:44c1d4d787e9 default tip

themwi-test-mtc: add option to set bearer cap
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 28 Nov 2024 20:37:23 +0000
parents c71801aa0039
children
files mtctest/main.c mtctest/setup.c
diffstat 2 files changed, 70 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mtctest/main.c	Tue Oct 29 00:06:28 2024 +0000
+++ b/mtctest/main.c	Thu Nov 28 20:37:23 2024 +0000
@@ -25,17 +25,27 @@
 {
 	extern int optind;
 	extern char *optarg;
-	char *from;
+	char *from, *bc_extra;
+	int include_bc;
 	fd_set fds;
 	struct timeval next_rtp_out, timeout;
 	int c, max_fd, rtp_out_running;
 
 	from = 0;
-	while ((c = getopt(argc, argv, "f:")) != EOF) {
+	include_bc = 0;
+	bc_extra = 0;
+	while ((c = getopt(argc, argv, "f:sS:")) != EOF) {
 		switch (c) {
 		case 'f':
 			from = optarg;
 			continue;
+		case 's':
+			include_bc = 1;
+			continue;
+		case 'S':
+			include_bc = 1;
+			bc_extra = optarg;
+			continue;
 		default:
 		usage:
 			fprintf(stderr,
@@ -48,6 +58,8 @@
 		goto usage;
 	openlog("themwi-test-mtc", 0, LOG_LOCAL5);
 	init_setup_msg(from, argv[optind]);
+	if (include_bc)
+		set_bearer_cap(bc_extra);
 	obtain_rtp_endp();
 	connect_mtc_socket();
 	send_setup_msg();
--- a/mtctest/setup.c	Tue Oct 29 00:06:28 2024 +0000
+++ b/mtctest/setup.c	Thu Nov 28 20:37:23 2024 +0000
@@ -233,6 +233,62 @@
 	}
 }
 
+static void
+bearer_cap_extras(arg)
+	char *arg;
+{
+	int s = 0;
+
+	for (;;) {
+		while (*arg == ',')
+			arg++;
+		if (!*arg)
+			return;
+		if (*arg >= '0' && *arg <= '5') {
+			if (s >= 7) {
+				fprintf(stderr,
+				"error: too many speech versions listed\n");
+				exit(1);
+			}
+			setup_msg.bearer_cap.speech_ver[s++] = *arg - '0';
+			setup_msg.bearer_cap.speech_ver[s] = -1;
+			arg++;
+		} else if (!strncmp(arg, "dual-fr", 7)) {
+			arg += 7;
+			setup_msg.bearer_cap.radio = GSM48_BCAP_RRQ_DUAL_FR;
+		} else if (!strncmp(arg, "dual-hr", 7)) {
+			arg += 7;
+			setup_msg.bearer_cap.radio = GSM48_BCAP_RRQ_DUAL_HR;
+		} else if (!strncmp(arg, "ctm", 3)) {
+			arg += 3;
+			setup_msg.bearer_cap.speech_ctm = 1;
+		} else {
+inv_param:		fprintf(stderr,
+		"error: bearer cap argument contains invalid parameter\n");
+			exit(1);
+		}
+		if (!*arg)
+			return;
+		if (*arg != ',')
+			goto inv_param;
+	}
+}
+
+void
+set_bearer_cap(extra_arg)
+	char *extra_arg;
+{
+	setup_msg.fields |= MNCC_F_BEARER_CAP;
+	setup_msg.bearer_cap.transfer = GSM48_BCAP_ITCAP_SPEECH;
+	setup_msg.bearer_cap.mode = GSM48_BCAP_TMOD_CIRCUIT;
+	setup_msg.bearer_cap.coding = GSM48_BCAP_CODING_GSM_STD;
+	setup_msg.bearer_cap.radio = GSM48_BCAP_RRQ_FR_ONLY;
+	setup_msg.bearer_cap.speech_ctm = 0;
+	setup_msg.bearer_cap.speech_ver[0] = -1;
+	if (extra_arg)
+		bearer_cap_extras(extra_arg);
+}
+
 void
 send_setup_msg()
 {