changeset 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 820d34f3f3d7
children 6eee1e547778
files rvinterf/asyncshell/Makefile rvinterf/asyncshell/oneshot.c rvinterf/asyncshell/sendarb.c
diffstat 3 files changed, 36 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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
 
--- 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 <string.h>
 #include <strings.h>
 #include <stdlib.h>
+#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}
--- /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 <sys/types.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+#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);
+}