ADded packetseer script for pl_drl to see all packets via libpcap
authorSapan Bhatia <gwsapan@gmail.com>
Thu, 16 Sep 2010 21:36:30 +0000 (17:36 -0400)
committerSapan Bhatia <gwsapan@gmail.com>
Thu, 16 Sep 2010 21:36:30 +0000 (17:36 -0400)
Makefile
fd_packetseer.c [new file with mode: 0644]

index bfea8db..cc699bc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 CC=gcc
 CFLAGS=-g -O2
 
-all: dcookie fd_bmsocket fd_udpsocket fd_fusemount fd_tuntap fd_tos
+all: dcookie fd_bmsocket fd_udpsocket fd_fusemount fd_tuntap fd_tos fd_packetseer
 
 fd_tuntap: fd_tuntap.c
        gcc fd_tuntap.c -o exec/fd_tuntap
@@ -24,5 +24,8 @@ fd_fusemount: fd_fusemount.c fdpass.o
 fd_tos: fd_tos.c fdpass.o
        gcc fd_tos.c fdpass.o -o exec/fd_tos
 
+fd_packetseer: fd_packetseer.c fdpass.o
+       gcc fd_packetseer.c fdpass.o -o exec/fd_packetseer
+
 clean: 
        rm -f exec/*
diff --git a/fd_packetseer.c b/fd_packetseer.c
new file mode 100644 (file)
index 0000000..f4b2899
--- /dev/null
@@ -0,0 +1,44 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <linux/if_ether.h>
+#include "fdpass.h"
+
+#define MAX_BUFSIZE (32*1024*1024)
+
+/*------------------------------------------------------------------*/
+void
+receive_argument(int control_fd, int *rcvbuf, int *sndbuf)
+{
+  if (recv(control_fd, rcvbuf, sizeof(int), 0) != sizeof(int)) {
+    fprintf(stderr, "receiving the first argument failed\n");
+    exit(-1);
+  }
+  if (recv(control_fd, sndbuf, sizeof(int), 0) != sizeof(int)) {
+    fprintf(stderr, "receiving the first argument failed\n");
+
+    exit(-1);
+  }
+}
+/*------------------------------------------------------------------*/
+int 
+main(int argc, char *argv[]) 
+{
+    int control_channel_fd, magic_socket;
+    int rcvbufsize = 0, sndbufsize = 0;
+    
+    if (argc < 3) {
+        printf("This script is called by vsys.\n");
+        exit(1);
+    }
+
+    magic_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
+    if (magic_socket == -1) {
+      fprintf(stderr, "Error creating socket: %d\n", errno);
+      exit(1);
+    }
+
+    send_fd(control_channel_fd, magic_socket);
+}