diff sip-manual-out/user_cmd.c @ 195:a3d71489672f

sip-manual-out: implement tfo-req command
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 17 Mar 2023 17:22:42 -0800
parents 1f9a6cede2c5
children f3164f732b84
line wrap: on
line diff
--- a/sip-manual-out/user_cmd.c	Fri Mar 17 16:52:21 2023 -0800
+++ b/sip-manual-out/user_cmd.c	Fri Mar 17 17:22:42 2023 -0800
@@ -9,6 +9,44 @@
 #include <string.h>
 #include <strings.h>
 
+static void
+tfo_req_cmd(args)
+	char *args;
+{
+	char *cp;
+	unsigned sig, codec;
+
+	for (cp = args; isspace(*cp); cp++)
+		;
+	if (!isdigit(*cp)) {
+inv_syntax:	fprintf(stderr, "error: tfo-req command invalid syntax\n");
+		return;
+	}
+	sig = strtoul(cp, &cp, 0);
+	if (!isspace(*cp))
+		goto inv_syntax;
+	if (sig > 0xFF) {
+		fprintf(stderr, "error: Sig argument out of range\n");
+		return;
+	}
+	while (isspace(*cp))
+		cp++;
+	if (!isdigit(*cp))
+		goto inv_syntax;
+	codec = strtoul(cp, &cp, 0);
+	if (*cp && !isspace(*cp))
+		goto inv_syntax;
+	if (codec > 14) {
+		fprintf(stderr, "error: Codec_Type argument out of range\n");
+		return;
+	}
+	while (isspace(*cp))
+		cp++;
+	if (*cp)
+		goto inv_syntax;
+	send_tfo_req(sig, codec);
+}
+
 void
 select_stdin()
 {
@@ -29,6 +67,8 @@
 		send_bye_req();
 	else if (!strcmp(cp, "c") || !strcasecmp(cp, "cancel"))
 		send_cancel_req();
+	else if (!strncmp(cp, "tfo-req", 7) && isspace(cp[7]))
+		tfo_req_cmd(cp + 8);
 	else
 		fprintf(stderr, "error: non-understood stdin command\n");
 }