FreeCalypso > hg > freecalypso-tools
comparison rvinterf/asyncshell/sendarb.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Jun 2016 00:13:35 +0000 |
parents | |
children | d43d82cbfb85 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e7502631a0f9 |
---|---|
1 /* | |
2 * Command for sending arbitrary packets to the target | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <ctype.h> | |
8 #include <string.h> | |
9 #include <strings.h> | |
10 #include <stdlib.h> | |
11 #include "limits.h" | |
12 | |
13 cmd_send_common(argc, argv) | |
14 char **argv; | |
15 { | |
16 u_char sendpkt[MAX_PKT_TO_TARGET]; | |
17 unsigned pktlen = argc, i; | |
18 char *endp; | |
19 | |
20 for (i = 0; i < pktlen; i++) { | |
21 sendpkt[i] = strtoul(argv[i], &endp, 16); | |
22 if (*endp) { | |
23 printf( | |
24 "error: all arguments to send command must be hex bytes\n"); | |
25 return(1); | |
26 } | |
27 } | |
28 /* send it! */ | |
29 send_pkt_to_target(sendpkt, pktlen); | |
30 return(0); | |
31 } | |
32 | |
33 void | |
34 cmd_send_interactive(argstr) | |
35 char *argstr; | |
36 { | |
37 char *argv[MAX_PKT_TO_TARGET+1]; | |
38 int argc, rc; | |
39 | |
40 rc = parse_interactive_command_into_argv(argstr, argv, 1, | |
41 MAX_PKT_TO_TARGET, &argc); | |
42 if (rc < 0) | |
43 return; | |
44 cmd_send_common(argc, argv); | |
45 } | |
46 | |
47 cmd_send_oneshot(argc, argv) | |
48 char **argv; | |
49 { | |
50 return cmd_send_common(argc - 1, argv + 1); | |
51 } |