diff 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
line wrap: on
line diff
--- /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);
+}