# HG changeset patch # User Mychaela Falconia # Date 1458511571 0 # Node ID 93f4fc26b20431e1ff9508b3b7ec75c8099ca3f9 # Parent 820d34f3f3d7d361551244e8a445111d1bf40922 fc-shell: arbitrary send command implemented in one-shot mode diff -r 820d34f3f3d7 -r 93f4fc26b204 rvinterf/asyncshell/Makefile --- a/rvinterf/asyncshell/Makefile Sun Mar 20 21:10:21 2016 +0000 +++ b/rvinterf/asyncshell/Makefile Sun Mar 20 22:06:11 2016 +0000 @@ -1,8 +1,8 @@ CC= gcc CFLAGS= -O2 -I../include PROG= fc-shell -OBJS= at.o init.o main.o oneshot.o pktsort.o poweroff.o rxctl.o sendsp.o \ - usercmd.o +OBJS= at.o init.o main.o oneshot.o pktsort.o poweroff.o rxctl.o sendarb.o \ + sendsp.o usercmd.o LIBS= ../libasync/libasync.a ../libg23/libg23.a INSTBIN=/usr/local/bin diff -r 820d34f3f3d7 -r 93f4fc26b204 rvinterf/asyncshell/oneshot.c --- a/rvinterf/asyncshell/oneshot.c Sun Mar 20 21:10:21 2016 +0000 +++ b/rvinterf/asyncshell/oneshot.c Sun Mar 20 22:06:11 2016 +0000 @@ -6,8 +6,10 @@ #include #include #include +#include "limits.h" extern int cmd_poweroff(); +extern int cmd_send_oneshot(); extern int cmd_sp_oneshot(); extern int cmd_tgtreset(); @@ -18,6 +20,7 @@ int (*func)(); } cmdtab[] = { {"poweroff", 0, 0, cmd_poweroff}, + {"send", 1, MAX_PKT_TO_TARGET, cmd_send_oneshot}, {"sp", 2, 2, cmd_sp_oneshot}, {"tgtreset", 0, 0, cmd_tgtreset}, {0, 0, 0, 0} diff -r 820d34f3f3d7 -r 93f4fc26b204 rvinterf/asyncshell/sendarb.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/asyncshell/sendarb.c Sun Mar 20 22:06:11 2016 +0000 @@ -0,0 +1,31 @@ +/* + * Command for sending arbitrary packets to the target + */ + +#include +#include +#include +#include +#include +#include +#include "limits.h" + +cmd_send_oneshot(argc, argv) + char **argv; +{ + u_char sendpkt[MAX_PKT_TO_TARGET]; + unsigned pktlen = argc - 1, i; + char *endp; + + for (i = 0; i < pktlen; i++) { + sendpkt[i] = strtoul(argv[i+1], &endp, 16); + if (*endp) { + printf( + "error: all arguments to send command must be hex bytes\n"); + return(1); + } + } + /* send it! */ + send_pkt_to_target(sendpkt, pktlen); + return(0); +}