2 # Parent 6030a90ae3ac82273dbb9dff32752b8d3634271b
4 diff -r 6030a90ae3ac Makefile.target
5 --- a/Makefile.target Fri Aug 27 04:45:05 2010 -0400
6 +++ b/Makefile.target Mon Aug 30 13:03:18 2010 -0400
10 obj-y = vl.o async.o monitor.o pci.o pci_host.o pcie_host.o machine.o gdbstub.o
12 # virtio has to be here due to weird dependency between PCI and virtio-net.
13 # need to fix this properly
14 obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o virtio-pci.o
15 diff -r 6030a90ae3ac net/slirp.c
16 --- a/net/slirp.c Fri Aug 27 04:45:05 2010 -0400
17 +++ b/net/slirp.c Mon Aug 30 13:03:18 2010 -0400
19 #include "qemu_socket.h"
20 #include "slirp/libslirp.h"
24 static int get_str_sep(char *buf, int buf_size, const char **pp, int sep)
29 SlirpState *s = opaque;
31 + pcap_dump(pkt, pkt_len);
32 qemu_send_packet(&s->nc, pkt, pkt_len);
37 SlirpState *s = DO_UPCAST(SlirpState, nc, nc);
39 + pcap_dump(buf, size);
40 slirp_input(s->slirp, buf, size);
43 diff -r 6030a90ae3ac pcap.c
44 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45 +++ b/pcap.c Mon Aug 30 13:03:18 2010 -0400
49 +#include <sys/time.h>
54 +static int started = 0;
55 +static FILE *cap_file;
58 +pcap_write(const char *b, int l) {
59 + size_t c = fwrite(b, 1, l, cap_file);
65 +pcap_dump_init(const char *fname) {
66 + pcap_hdr_t pcap_hdr;
69 + fname = "slirp.cap";
71 + cap_file = fopen(fname, "wb");
73 + perror("pcap_dump_init:");
77 + pcap_hdr.magic_number = PCAP_MAGIC;
78 + pcap_hdr.version_major = PCAP_VMAJOR;
79 + pcap_hdr.version_minor = PCAP_VMINOR;
80 + pcap_hdr.thiszone = 0;
81 + pcap_hdr.sigfigs = 0;
82 + pcap_hdr.snaplen = 65535;
83 + pcap_hdr.network = 1; // Ethernet
85 + pcap_write((char *)&pcap_hdr, sizeof(pcap_hdr));
91 +pcap_dump(const uint8_t *pkt, int len) {
92 + pcaprec_hdr_t pkt_hdr;
98 + gettimeofday(&tv, 0);
100 + pkt_hdr.ts_sec = tv.tv_sec;
101 + pkt_hdr.ts_usec = tv.tv_usec;
102 + pkt_hdr.incl_len = len;
103 + pkt_hdr.orig_len = len;
105 + pcap_write((char *)&pkt_hdr, sizeof(pkt_hdr));
106 + pcap_write((char *)pkt, len);
108 diff -r 6030a90ae3ac pcap.h
109 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
110 +++ b/pcap.h Mon Aug 30 13:03:18 2010 -0400
115 +#include "qemu-common.h"
118 + * Used http://wiki.wireshark.org/Development/LibpcapFileFormat to get the pcap file format
121 +#define PCAP_MAGIC 0xa1b2c3d4
122 +#define PCAP_VMAJOR 2
123 +#define PCAP_VMINOR 4
125 +typedef struct pcap_hdr_s {
126 + uint32_t magic_number; /* magic number */
127 + uint16_t version_major; /* major version number */
128 + uint16_t version_minor; /* minor version number */
129 + int32_t thiszone; /* GMT to local correction */
130 + uint32_t sigfigs; /* accuracy of timestamps */
131 + uint32_t snaplen; /* max length of captured packets, in octets */
132 + uint32_t network; /* data link type */
135 +typedef struct pcaprec_hdr_s {
136 + uint32_t ts_sec; /* timestamp seconds */
137 + uint32_t ts_usec; /* timestamp microseconds */
138 + uint32_t incl_len; /* number of octets of packet saved in file */
139 + uint32_t orig_len; /* actual length of packet */
142 +void pcap_dump_init(const char *fname);
143 +void pcap_dump(const uint8_t *pkt, int len);
146 diff -r 6030a90ae3ac qemu-options.hx
147 --- a/qemu-options.hx Fri Aug 27 04:45:05 2010 -0400
148 +++ b/qemu-options.hx Mon Aug 30 13:03:18 2010 -0400
149 @@ -1394,6 +1394,16 @@
154 +DEF("pcap", HAS_ARG, QEMU_OPTION_pcap,
156 +" when -net user is enabled, dump packets to file\n")
159 +@item -pcap @var{file}
160 +When -net user is enabled, dump packets to @var{file}.
165 DEFHEADING(Linux/Multiboot boot specific:)
166 diff -r 6030a90ae3ac vl.c
167 --- a/vl.c Fri Aug 27 04:45:05 2010 -0400
168 +++ b/vl.c Mon Aug 30 13:03:18 2010 -0400
171 #include "qemu-queue.h"
178 //#define DEBUG_SLIRP
180 @@ -5192,6 +5196,11 @@
184 + case QEMU_OPTION_pcap:
185 + pcap_dump_init(optarg);
189 case QEMU_OPTION_tftp:
190 legacy_tftp_prefix = optarg;