Skip to contentSkip to conversation

Support for dumping trafic in uml_switch

uml-devel Julien Iguchi-Cartigny 1 participant 1 message Jul 9, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello,

This is a simple patch for uml tools with a program (uml_dump) which can connect to instance of uml_switch and then dump packets in cap format. Very useful to see communications between uml instances in wireshark or tcpdump.

Cheers,

Julien, Benoit and Jean-paul.

Makefile +1 -1
diff -rupN tools-original/Makefile tools/Makefile
@@ -1,7 +1,7 @@
 TUNCTL = $(shell [ -e /usr/include/linux/if_tun.h ] && echo tunctl)
 
 SUBDIRS = jail jailtest humfsify mconsole moo port-helper $(TUNCTL) uml_net \
-	uml_router watchdog
+	uml_router watchdog uml_dump
 UMLVER = $(shell date +%Y%m%d)
 TARBALL = uml_utilities_$(UMLVER).tar
 BIN_DIR = /usr/bin
uml_dump/Makefile +17 -0
diff -rupN tools-original/uml_dump/Makefile tools/uml_dump/Makefile
@@ -0,0 +1,17 @@
+OBJS = uml_dump.o
+BIN = uml_dump
+CFLAGS = -g -Wall
+
+BIN_DIR ?= /usr/bin
+
+all : $(BIN)
+
+$(BIN) : $(OBJS)
+	$(CC) $(CFLAGS) -o $(BIN) $(OBJS)
+
+clean : 
+	rm -f $(BIN) $(OBJS) *~
+
+install : $(BIN)
+	install -d $(DESTDIR)$(BIN_DIR)
+	install -s $(BIN) $(DESTDIR)$(BIN_DIR)
uml_dump/uml_dump.c +276 -0

276 lines not on this page · raw message

uml_router/Makefile +1 -1
diff -rupN tools-original/uml_router/Makefile tools/uml_router/Makefile
@@ -1,6 +1,6 @@
 TUNTAP = $(shell [ -e /usr/include/linux/if_tun.h ] && echo -DTUNTAP)
 
-OBJS = hash.o port.o uml_switch.o 
+OBJS = hash.o port.o uml_switch.o
 BIN = uml_switch
 CFLAGS = -g -Wall $(TUNTAP)
 
uml_router/port.c +20 -27

92 lines not on this page · raw message

uml_router/port.h +22 -2
diff -rupN tools-original/uml_router/port.h tools/uml_router/port.h
@@ -8,12 +8,32 @@
 #include <sys/socket.h>
 #include <sys/un.h>
 
+struct packet {
+  struct {
+    unsigned char dest[ETH_ALEN];
+    unsigned char src[ETH_ALEN];
+    unsigned char proto[2];
+  } header;
+  unsigned char data[1500];
+};
+
+struct port {
+  struct port *next;
+  struct port *prev;
+  int control;
+  void *data;
+  int data_len;
+  unsigned char src[ETH_ALEN];
+  void (*sender)(int fd, void *packet, int len, void *data);
+  int dump;
+};
+
 extern int handle_port(int fd);
 extern void close_port(int fd);
-extern int setup_sock_port(int fd, struct sockaddr_un *name, int data_fd);
+extern int setup_sock_port(int fd, struct sockaddr_un *name, int data_fd, int dump);
 extern int setup_port(int fd, void (*sender)(int fd, void *packet, int len, 
 					     void *data), void *data, 
-		      int data_len);
+		      int data_len, int dump);
 extern void handle_tap_data(int fd, int hub);
 extern void handle_sock_data(int fd, int hub);
 
uml_router/tuntap.c +2 -1
diff -rupN tools-original/uml_router/tuntap.c tools/uml_router/tuntap.c
@@ -6,6 +6,7 @@
 #include <sys/ioctl.h>
 #include <net/if.h>
 #include <linux/if_tun.h>
+#include "switch.h"
 #include "port.h"
 
 static void send_tap(int fd, void *packet, int len, void *unused)
@@ -35,7 +36,7 @@ int open_tap(char *dev)
     close(fd);
     return(-1);
   }
-  err = setup_port(fd, send_tap, NULL, 0);
+  err = setup_port(fd, send_tap, NULL, 0, 0);
   if(err) return(err);
   return(fd);
 }
uml_router/uml_switch.c +25 -57

132 lines not on this page · raw message

uml_router/uml_switch.h +67 -0

67 lines not on this page · raw message

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge

_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel