annotate rvinterf/asyncshell/sendarb.c @ 1034:405b5469abc4 default tip

top README: repository change notice
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 12 Jun 2016 19:06:34 +0000
parents 6eee1e547778
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1012
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 * Command for sending arbitrary packets to the target
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 */
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <ctype.h>
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <strings.h>
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <stdlib.h>
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "limits.h"
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12
1013
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
13 cmd_send_common(argc, argv)
1012
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14 char **argv;
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 {
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16 u_char sendpkt[MAX_PKT_TO_TARGET];
1013
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
17 unsigned pktlen = argc, i;
1012
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 char *endp;
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
19
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20 for (i = 0; i < pktlen; i++) {
1013
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
21 sendpkt[i] = strtoul(argv[i], &endp, 16);
1012
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 if (*endp) {
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 printf(
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 "error: all arguments to send command must be hex bytes\n");
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 return(1);
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 }
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 }
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 /* send it! */
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 send_pkt_to_target(sendpkt, pktlen);
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30 return(0);
93f4fc26b204 fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 }
1013
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
32
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
33 void
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
34 cmd_send_interactive(argstr)
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
35 char *argstr;
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
36 {
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
37 char *argv[MAX_PKT_TO_TARGET+1];
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
38 int argc, rc;
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
39
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
40 rc = parse_interactive_command_into_argv(argstr, argv, 1,
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
41 MAX_PKT_TO_TARGET, &argc);
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
42 if (rc < 0)
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
43 return;
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
44 cmd_send_common(argc, argv);
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
45 }
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
46
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
47 cmd_send_oneshot(argc, argv)
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
48 char **argv;
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
49 {
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
50 return cmd_send_common(argc - 1, argv + 1);
6eee1e547778 fc-shell: arbitrary send command implemented in interactive mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1012
diff changeset
51 }