diff rvinterf/asyncshell/tchcmd.c @ 1014:0511507bf6e7

fc-shell: tch-dl control command implemented
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sun, 20 Mar 2016 22:52:25 +0000
parents
children 9ced8e13cf91
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/asyncshell/tchcmd.c	Sun Mar 20 22:52:25 2016 +0000
@@ -0,0 +1,62 @@
+/*
+ * Commands for manipulating the experimental TCH rerouting feature
+ * of FreeCalypso GSM firmware
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#include "pktmux.h"
+#include "tch_feature.h"
+
+send_tch_config_req(config)
+{
+	u_char sendpkt[3];
+
+	sendpkt[0] = RVT_TCH_HEADER;
+	sendpkt[1] = TCH_CONFIG_REQ;
+	sendpkt[2] = config;
+	/* send it! */
+	send_pkt_to_target(sendpkt, 3);
+	return(0);
+}
+
+cmd_tchdl_common(argc, argv)
+	char **argv;
+{
+	int config;
+
+	if (!strcmp(argv[1], "enable") || !strcmp(argv[1], "on") ||
+	    !strcmp(argv[1], "1"))
+		config = 1;
+	else if (!strcmp(argv[1], "disable") || !strcmp(argv[1], "off") ||
+		 !strcmp(argv[1], "0"))
+		config = 0;
+	else {
+		printf("error: boolean argument required\n");
+		return(1);
+	}
+	return send_tch_config_req(config);
+}
+
+void
+cmd_tchdl_interactive(argstr)
+	char *argstr;
+{
+	char *argv[2];
+	int argc, rc;
+
+	rc = parse_interactive_command_into_argv(argstr, argv, 1, 1, &argc);
+	if (rc < 0)
+		return;
+	tch_rx_control(1);
+	cmd_tchdl_common(argc, argv);
+}
+
+cmd_tchdl_oneshot(argc, argv)
+	char **argv;
+{
+	return cmd_tchdl_common(argc - 1, argv + 1);
+}