FreeCalypso > hg > freecalypso-sw
annotate rvinterf/asyncshell/sendarb.c @ 1012:93f4fc26b204
fc-shell: arbitrary send command implemented in one-shot mode
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 20 Mar 2016 22:06:11 +0000 |
parents | |
children | 6eee1e547778 |
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 |
93f4fc26b204
fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 cmd_send_oneshot(argc, argv) |
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]; |
93f4fc26b204
fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 unsigned pktlen = argc - 1, i; |
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++) { |
93f4fc26b204
fc-shell: arbitrary send command implemented in one-shot mode
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 sendpkt[i] = strtoul(argv[i+1], &endp, 16); |
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 } |