From 1436ad11591777a7bb37ddf4444309f7f0cf957a Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Thu, 16 Sep 2010 17:36:30 -0400 Subject: [PATCH] ADded packetseer script for pl_drl to see all packets via libpcap --- Makefile | 5 ++++- fd_packetseer.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 fd_packetseer.c diff --git a/Makefile b/Makefile index bfea8db..cc699bc 100644 --- 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 index 0000000..f4b2899 --- /dev/null +++ b/fd_packetseer.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include +#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); +} -- 2.43.0