annotate rvinterf/asyncshell/tchcmd.c @ 1017:759b3cbf46aa

doc/TCH-special-feature: document written
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 21 Mar 2016 06:05:57 +0000
parents 9ced8e13cf91
children f511bbac0efa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1014
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 * Commands for manipulating the experimental TCH rerouting feature
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 * of FreeCalypso GSM firmware
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4 */
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/types.h>
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <strings.h>
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <stdlib.h>
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "pktmux.h"
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "tch_feature.h"
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14 send_tch_config_req(config)
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 {
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16 u_char sendpkt[3];
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 sendpkt[0] = RVT_TCH_HEADER;
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
19 sendpkt[1] = TCH_CONFIG_REQ;
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20 sendpkt[2] = config;
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 /* send it! */
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 send_pkt_to_target(sendpkt, 3);
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 return(0);
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 }
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 cmd_tchdl_common(argc, argv)
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 char **argv;
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 {
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 int config;
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30
1015
9ced8e13cf91 fc-shell tch-dl command implementation: brown paper bag
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1014
diff changeset
31 if (!strcmp(argv[0], "enable") || !strcmp(argv[0], "on") ||
9ced8e13cf91 fc-shell tch-dl command implementation: brown paper bag
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1014
diff changeset
32 !strcmp(argv[0], "1"))
1014
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 config = 1;
1015
9ced8e13cf91 fc-shell tch-dl command implementation: brown paper bag
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1014
diff changeset
34 else if (!strcmp(argv[0], "disable") || !strcmp(argv[0], "off") ||
9ced8e13cf91 fc-shell tch-dl command implementation: brown paper bag
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1014
diff changeset
35 !strcmp(argv[0], "0"))
1014
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 config = 0;
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 else {
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 printf("error: boolean argument required\n");
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 return(1);
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 }
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 return send_tch_config_req(config);
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 }
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 void
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 cmd_tchdl_interactive(argstr)
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 char *argstr;
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47 {
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 char *argv[2];
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 int argc, rc;
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 rc = parse_interactive_command_into_argv(argstr, argv, 1, 1, &argc);
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 if (rc < 0)
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 return;
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 tch_rx_control(1);
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 cmd_tchdl_common(argc, argv);
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 }
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 cmd_tchdl_oneshot(argc, argv)
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 char **argv;
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 {
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 return cmd_tchdl_common(argc - 1, argv + 1);
0511507bf6e7 fc-shell: tch-dl control command implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 }